@liberfi.io/ui-predict 0.1.110 → 0.1.112
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1 -5
- package/dist/index.d.ts +1 -5
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMemo,useEffect,useCallback,useContext,Fragment as Fragment$1,startTransition,Component}from'react';import {PolymarketIcon,KalshiIcon,cn as cn$1,Skeleton,toast,StyledModal,ModalContent,useDisclosure,Tabs,Tab,StyledNumberInput,StyledSwitch,Select,SelectItem,ChevronDownIcon,Button,useScreen,ModalBody,ModalHeader,ModalFooter,TimerIcon,DropletIcon,ChartLineIcon,CalendarIcon,Linkable,Avatar,ChevronUpIcon,Spinner,OrderbookTableIcon,OrderbookDepthIcon,Dropdown,DropdownTrigger,DropdownMenu,DropdownItem,ChevronRightIcon,ChevronLeftIcon,TrashIcon,Chip,StyledInput,XCloseIcon,Kbd,SearchIcon,EmptyIcon}from'@liberfi.io/ui';import {AsyncModal,useAsyncModal}from'@liberfi.io/ui-scaffold';import {useTranslation}from'@liberfi.io/i18n';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useWallets,useAuth,useSwitchChain,useAuthCallback}from'@liberfi.io/wallet-connector';import {keepPreviousData,useQueryClient,useQueries}from'@tanstack/react-query';import jr from'canvas-confetti';import {ChartRange,useInfiniteMatchMarkets,useBalance,useDFlowKYC,usePolymarketSetup,usePredictClient,PolymarketContext,usePositions,useDFlowQuote,useDFlowSubmit,useOrder,buildCtfExchangeDomain,buildOrderMessage,CTF_ORDER_TYPES,buildSignedOrder,buildClobPayload,buildPolymarketL2Headers,resolveEventsParams,useInfiniteEvents,useInfiniteOrders,useCancelOrder,useInfiniteTrades,useOrderbook,useMarketHistory,useEvent,useSimilarEvents,candlesticksQueryKey,useSearchEvents}from'@liberfi.io/react-predict';export{PredictClient,PredictContext,PredictProvider,PredictWsClient,createPredictClient,createPredictWsClient,fetchMatchMarketsPage,fetchMatchesPage,matchMarketsQueryKey,matchQueryKey,matchesQueryKey,useBalance,useCancelOrder,useCandlesticks,useDFlowKYC,useDFlowQuote,useDFlowSubmit,useEvent,useEvents,useInfiniteEvents,useInfiniteMatchMarkets,useInfiniteMatches,useInfiniteOrders,useInfiniteTrades,useMarket,useMarketHistory,useMarketTrades,useMatch,useOrder,useOrderbook,useOrders,usePositions,usePredictClient,usePriceHistory,useSearchEvents,useSimilarEvents,useTrades}from'@liberfi.io/react-predict';import {ChainNamespace,Chain}from'@liberfi.io/types';import {SOLANA_TOKENS,debounce}from'@liberfi.io/utils';import {List}from'react-window';import {useInfiniteLoader}from'react-window-infinite-loader';import {useResizeObserver,useScrollCollapse,useCallbackRef}from'@liberfi.io/hooks';import {ResponsiveContainer,LineChart,CartesianGrid,XAxis,YAxis,Tooltip,Line,ReferenceDot}from'recharts';import {useAtom}from'jotai';import {atomWithStorage}from'jotai/utils';typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-predict"]="0.1.110");var li="0.1.110";var ci={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},Xn=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],zr=(()=>{let e=t=>{let r=Xn.indexOf(t);return r===-1?Xn.length:r};return Object.entries(ci).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 eo({categories:e,selectedCategory:t,selectedTag:r,activeTags:o,onCategorySelect:n,onTagSelect:s,trailing:i,pulsingTab:a="Trending",className:l}){let{t:c}=useTranslation(),p=useCallback(()=>{n(null);},[n]),u=c("predict.categories.trending");return jsxs("div",{className:cn$1("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:[jsxs("div",{className:"flex w-full items-center gap-2",children:[jsx("div",{className:"hideScrollbar min-w-0 flex-1 overflow-x-auto overflow-y-hidden",children:jsxs("div",{className:"flex min-h-8 items-stretch gap-x-2 lg:min-h-9",children:[jsx(Zn,{label:u,isSelected:t===null,onPress:p,showPulse:u===a}),jsx(mi,{}),e.map(m=>jsx(Zn,{label:m.category,isSelected:t===m.category,onPress:()=>n(m.category),badge:m.badge,showPulse:m.category===a},m.category))]})}),i&&jsx("div",{className:"flex-shrink-0",children:i})]}),t&&o.length>0&&jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxs("div",{className:"flex gap-x-1 pl-2 lg:w-full lg:gap-x-2",children:[jsx(Jn,{label:c("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>s(null)}),o.map(m=>jsx(Jn,{label:m.label,icon:m.icon,isSelected:r===m.label,onPress:()=>s(m.label)},m.label))]})})]})}function Zn({label:e,isSelected:t,onPress:r,badge:o,showPulse:n}){return jsxs("button",{type:"button",onClick:r,className:cn$1("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?jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsx("span",{children:e})]}):e,o&&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 mi(){return jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function Jn({label:e,icon:t,isSelected:r,onPress:o}){return jsxs("button",{type:"button",onClick:o,className:cn$1("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&&jsx("span",{className:cn$1("iconify size-4",t)}),e]})}function sf({count:e=6}){return jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-1 lg:px-2 lg:py-1",children:jsx("div",{className:"flex min-h-8 items-center gap-x-2 lg:min-h-9",children:Array.from({length:e}).map((t,r)=>jsx(Skeleton,{className:"h-6 w-16 shrink-0 rounded"},r))})})}function fi(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function gi(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function no({onSelect:e,trailing:t,className:r}){let[o,n]=useState(null),[s,i]=useState(null),a=useCallback(m=>{n(m),i(null),e?.({categorySlug:m,tagSlug:null});},[e]),l=useCallback(m=>{i(m),e?.({categorySlug:o,tagSlug:m});},[o,e]),c=fi(zr),p=zr.find(m=>m.slug===o),u=gi(p);return jsx(eo,{categories:c,selectedCategory:o,selectedTag:s,activeTags:u,onCategorySelect:a,onTagSelect:l,trailing:t,className:r})}function oo(e){return {title:e.title,imageUrl:e.image_url}}function so(e){let t=e.outcomes[0],r=e.outcomes[1];return {question:e.question,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"}}var Ot=48,Wr=4,ar={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},Ee={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},ir=Ee.ALL,gf={[Ee.ONE_DAY]:ar.ONE_MINUTE,[Ee.ONE_WEEK]:ar.ONE_HOUR,[Ee.ONE_MONTH]:ar.ONE_HOUR,[Ee.ALL]:ar.ONE_DAY},hf={[Ee.ONE_DAY]:300,[Ee.ONE_WEEK]:3600,[Ee.ONE_MONTH]:10800,[Ee.ALL]:1440*60},xf={[Ee.ONE_DAY]:1440*60,[Ee.ONE_WEEK]:10080*60,[Ee.ONE_MONTH]:720*60*60,[Ee.ALL]:null},Ur=1,vf=1,bf=1,yf=99,bt={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},kf=bt.ONE_WEEK,Sf={[bt.ONE_HOUR]:60,[bt.SIX_HOURS]:60,[bt.ONE_DAY]:300,[bt.ONE_WEEK]:1800,[bt.MAX]:1800};var lo=createContext(null);function Vr(){let e=useContext(lo);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var Si=1e4;function wi({pollingInterval:e=Si,enabled:t=true,children:r}){let o=useWallets(),n=useMemo(()=>o.find(v=>v.chainNamespace===ChainNamespace.SOLANA&&v.isConnected)?.address,[o]),s=useMemo(()=>o.find(v=>v.chainNamespace===ChainNamespace.EVM&&v.isConnected)?.address,[o]),{data:i,isLoading:a,isFetching:l,error:c}=useBalance({source:"kalshi",user:n??""},{enabled:t&&!!n,refetchInterval:e}),{data:p,isLoading:u}=useDFlowKYC(n,{enabled:t&&!!n,refetchInterval:3e4}),{data:m,isLoading:d}=usePolymarketSetup(s,{enabled:t&&!!s,refetchInterval:3e4}),f=m?.safe_address,g=m?.verified??false,{data:h,isLoading:x,isFetching:P,error:b}=useBalance({source:"polymarket",user:f??""},{enabled:t&&g&&!!f,refetchInterval:e}),R=useMemo(()=>({solanaAddress:n,evmAddress:s,polymarketSafeAddress:f,kalshiUsdcBalance:i?Number(i.balance):null,polymarketUsdcBalance:g&&h?Number(h.balance):null,kalshiKycVerified:p?.verified??false,kalshiKycUrl:p?.kyc_url??null,kalshiKycLoading:u,polymarketSetupVerified:g,polymarketSafeDeployed:m?.safe_deployed??false,polymarketTokenApproved:m?.token_approved??false,polymarketSetupLoading:d,isLoading:a||x,isFetching:l||P,error:c??b??null}),[n,s,f,i,h,g,p,u,m,d,a,x,l,P,c,b]);return jsx(lo.Provider,{value:R,children:r})}var Ki={minutes:60,hours:3600,days:86400};function Vi(e,t,r){let o=Math.floor(Date.now()/1e3);switch(e){case "5m":return o+300;case "1h":return o+3600;case "12h":return o+720*60;case "24h":return o+1440*60;case "eod":{let n=new Date;return n.setUTCHours(23,59,59,0),Math.floor(n.getTime()/1e3)}case "custom":return o+t*Ki[r]}}function Gr(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};jr({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{jr({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{jr({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function mo({market:e,initialOutcome:t="yes",initialSide:r="buy"}){let{t:o}=useTranslation(),{status:n}=useAuth(),s=useWallets(),i=useSwitchChain(),a=usePredictClient(),l=useContext(PolymarketContext),c=useQueryClient(),p=e.source,u=p==="polymarket",m=s.find(w=>w.chainNamespace===ChainNamespace.SOLANA&&w.isConnected),d=s.find(w=>w.chainNamespace===ChainNamespace.EVM&&w.isConnected&&"switchChain"in w),f=n==="authenticated",g=m?.address,h=d?.address,[x,P]=useState(t),[b,R]=useState(r),[v,L]=useState("market"),[y,X]=useState(NaN),[Y,K]=useState(NaN),[oe,D]=useState(false),[$,H]=useState(null),[me,fe]=useState(null),[C,_]=useState(false),[W,I]=useState(false),[se,ve]=useState("1h"),[ge,Ze]=useState(30),[it,Ir]=useState("minutes"),ze=null,Jt=false,er=null,xt;try{let w=Vr();ze={kalshiUsdcBalance:w.kalshiUsdcBalance,polymarketUsdcBalance:w.polymarketUsdcBalance,isLoading:w.isLoading},Jt=w.kalshiKycVerified,er=w.kalshiKycUrl,xt=w.polymarketSafeAddress;}catch{}let Se=useMemo(()=>{let w=x==="yes"?0:1,q=e.outcomes[w];return b==="buy"?q?.best_ask??q?.price??.5:q?.best_bid??q?.price??.5},[e.outcomes,x,b]),Or=useCallback(w=>{L(w);},[]),F=useCallback(w=>{P(w),K(NaN);},[]);useEffect(()=>{v==="limit"&&isNaN(Y)&&K(Math.round(Se*100)/100);},[v,Y,Se]);let Ie=useMemo(()=>isNaN(y)||y<=0?0:b==="buy"?Se>0?y/Se:0:y,[b,y,Se]),We=useMemo(()=>isNaN(y)||y<=0?"0":String(Math.round(y*1e6)),[y]),Ba=e.provider_meta?.["dflow.yesMint"]??"",$a=e.provider_meta?.["dflow.noMint"]??"",lt=SOLANA_TOKENS.stablecoins.USDC.address,za=e.provider_meta?.["dflow.collateralMint"]||"",Bn=x==="yes"?Ba:$a,$n=p==="kalshi"?g??"":h??"",{data:Oe,isLoading:Wa}=usePositions({source:p,user:$n},{enabled:!!$n}),zn=useMemo(()=>!Oe||b!=="sell"?null:Oe.positions.find(w=>w.side?.toLowerCase()===x&&w.market?.slug===e.slug)??null,[Oe,e.slug,x,b])?.market?.provider_meta,Ua=b==="sell"&&zn?.["dflow.outcomeMint"]||Bn,Lt=b==="sell"&&zn?.["dflow.collateralMint"]||za,_t=b==="buy"?lt:Ua,Rt=b==="buy"?Bn:Lt||lt,Ka=p==="kalshi"&&!!_t&&!!Rt&&!!g&&We!=="0",{refetch:Wn}=useDFlowQuote({inputMint:_t,outputMint:Rt,amount:We,userPublicKey:g??"",slippageBps:100},{enabled:Ka}),tr=useMemo(()=>ze?p==="kalshi"?ze.kalshiUsdcBalance:ze.polymarketUsdcBalance:Oe&&Oe.positions.reduce((q,Me)=>Me.side==="USDC"||Me.side==="collateral"?q+(Me.current_value??0):q,0)||null,[ze,Oe,p]),Va=ze?ze.isLoading:Wa,Ar=useMemo(()=>Oe?Oe.positions.find(q=>q.side?.toLowerCase()==="yes"&&q.market?.slug===e.slug)?.size??0:null,[Oe,e.slug]),Dr=useMemo(()=>Oe?Oe.positions.find(q=>q.side?.toLowerCase()==="no"&&q.market?.slug===e.slug)?.size??0:null,[Oe,e.slug]),Fr=useMemo(()=>v==="limit"&&u&&!isNaN(Y)?Y:Se,[v,u,Y,Se]),rr=useMemo(()=>{if(isNaN(y)||y<=0)return 0;if(b==="buy")return y;let w=x==="yes"?e.outcomes[0]?.best_bid??0:e.outcomes[1]?.best_bid??0;return y*w},[b,x,y,e.outcomes]),Un=useMemo(()=>isNaN(y)||y<=0?0:b==="buy"?Fr>0?y/Fr*1:0:rr,[b,y,Fr,rr]),ja=Un-rr,Ga=useCallback(w=>{R(w),X(NaN);},[]),Ya=useCallback(w=>{if(isNaN(w)){X(NaN);return}let q=Math.max(0,w),Me=b==="buy"?Math.round(q*100)/100:Math.round(q);X(Me);},[b]),qa=useCallback(w=>{if(isNaN(w)){K(NaN);return}let q=Math.max(.01,Math.min(.99,w));K(Math.round(q*100)/100);},[]),Hr=useMemo(()=>{let w=[];(isNaN(y)||y<Ur)&&w.push(`Minimum quantity is ${Ur}`),e.status!=="open"&&w.push("Market is not active"),b==="buy"&&tr!=null&&!isNaN(y)&&y>0&&y>tr&&w.push("Insufficient USDC balance");let q=x==="yes"?Ar:Dr;return b==="sell"&&q!=null&&!isNaN(y)&&y>0&&y>q&&w.push("Insufficient shares"),v==="limit"&&u&&(isNaN(Y)||Y<.01||Y>.99)&&w.push("Limit price must be between $0.01 and $0.99"),v==="limit"&&u&&W&&se==="custom"&&(isNaN(ge)||ge<=0)&&w.push(o("predict.trade.expiration.invalidDate")),{isValid:w.length===0,errors:w}},[y,e.status,b,tr,Ar,Dr,x,v,u,Y,W,se,ge,o]),{mutateAsync:nr}=useDFlowSubmit(),{data:Br}=useOrder({id:$??"",source:p},{enabled:!!$}),Kn=useCallback(async()=>{if(!me||!g||!m)return;let{cashAmount:w,collateral:q}=me;fe(null);try{let ct=(await a.createDFlowQuote({inputMint:q,outputMint:lt,amount:w,userPublicKey:g,slippageBps:100}))?.transaction;if(!ct)return;let Je=Uint8Array.from(atob(ct),It=>It.charCodeAt(0)),Ue=await m.signTransaction(Je);await nr({signedTransaction:btoa(String.fromCharCode(...Ue)),orderContext:{user_public_key:g,input_mint:q,output_mint:lt,amount:w,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[me,g,m,a,nr,lt]);useEffect(()=>{if(!Br||!$)return;let{status:w}=Br;w==="closed"?(H(null),me?Kn().finally(()=>{D(false),toast.success(o("predict.trade.submitSuccess")),Gr(),X(NaN);}):(D(false),toast.success(o("predict.trade.submitSuccess")),Gr(),X(NaN))):(w==="failed"||w==="expired")&&(D(false),H(null),fe(null),toast.error(o("predict.trade.submitError")));},[Br,$,me,Kn,o]);let Vn=useCallback(async()=>{if(!g||!m)return;if(!_t||!Rt){toast.error("Missing token mint addresses"),D(false);return}if(!Jt){_(true),D(false);return}let Me=(await Wn()).data,ct=Me?.transaction;if(!ct){toast.error(o("predict.trade.submitError")),D(false);return}if(b==="sell"&&Lt&&Lt!==lt){let et=String(Me?.outAmount??"");et&&et!=="0"&&fe({cashAmount:et,collateral:Lt});}let Je=Uint8Array.from(atob(ct),et=>et.charCodeAt(0)),Ue=await m.signTransaction(Je),It=await nr({signedTransaction:btoa(String.fromCharCode(...Ue)),orderContext:{user_public_key:g,input_mint:_t,output_mint:Rt,amount:We,price:String(Se),side:b==="buy"?"BUY":"SELL",outcome:x==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});H(It.signature);},[g,m,a,Wn,nr,_t,Rt,We,Se,b,x,e.slug,Lt,lt,o]),jn=useCallback(async()=>{if(!d||!l)return;let w=d.chain,q=w!==Chain.POLYGON;q&&await i(Chain.POLYGON);try{let Me=await d.getEip1193Provider();if(!Me){toast.error(o("predict.trade.submitError")),D(!1);return}let ct=!!xt,Je={address:d.address,signatureType:ct?2:0,signTypedData:async(dt,oi,si,ai)=>{let vt=[];"name"in dt&&vt.push({name:"name",type:"string"}),"version"in dt&&vt.push({name:"version",type:"string"}),"chainId"in dt&&vt.push({name:"chainId",type:"uint256"}),"verifyingContract"in dt&&vt.push({name:"verifyingContract",type:"address"}),"salt"in dt&&vt.push({name:"salt",type:"bytes32"});let ii={EIP712Domain:vt,...oi};return await Me.request({method:"eth_signTypedData_v4",params:[d.address,JSON.stringify({domain:dt,types:ii,primaryType:si,message:ai})]})}},Ue=l.credentials??await l.authenticate(Je),It=x==="yes"?0:1,et="",or=e.provider_meta?.["polymarket.clobTokenIds"];or&&(et=(typeof or=="string"?JSON.parse(or):or)[It]??"");let Gn=e.provider_meta?.["polymarket.negRisk"]??!1,$r=v==="limit"&&!isNaN(Y)?Y:Se,Xa=v==="limit"?W?"GTD":"GTC":"FOK",Za=b==="buy"&&$r>0?y/$r:y,Yn={tokenId:et,price:$r,size:Za,side:b==="buy"?"BUY":"SELL",orderType:Xa,tickSize:"0.01",negRisk:Gn,...xt&&{funderAddress:xt},...v==="limit"&&W&&{expiration:Vi(se,ge,it)}},Ja=buildCtfExchangeDomain(Gn),qn=buildOrderMessage({...Yn,signerAddress:Je.address,signatureType:Je.signatureType}),ei=await Je.signTypedData(Ja,CTF_ORDER_TYPES,"Order",qn),ti=buildSignedOrder(qn,ei,Yn.orderType),Qn=buildClobPayload(ti,Ue.apiKey),ri=JSON.stringify(Qn),ni=await buildPolymarketL2Headers(Ue.address,{apiKey:Ue.apiKey,secret:Ue.secret,passphrase:Ue.passphrase,method:"POST",requestPath:"/order",body:ri});await a.createPolymarketOrder(Qn,ni),c.invalidateQueries({queryKey:["predict","orders"]}),c.invalidateQueries({queryKey:["predict","positions"]}),toast.success(o("predict.trade.submitSuccess")),Gr(),X(NaN),D(!1);}finally{q&&w&&i(w).catch(()=>{});}},[d,l,i,x,e.provider_meta,v,Y,Se,y,b,a,c,W,se,ge,it,o]),Qa=useCallback(async()=>{if(!(!Hr.isValid||!f)){D(true),H(null),_(false);try{p==="kalshi"?await Vn():await jn();}catch(w){let q=w instanceof Error?w.message:void 0;toast.error(q||o("predict.trade.submitError")),D(false);}}},[Hr.isValid,f,p,Vn,jn,o]);return {outcome:x,side:b,orderType:v,quantity:y,limitPrice:Y,shares:Ie,estimatedCost:rr,potentialPayout:Un,potentialProfit:ja,usdcBalance:tr,yesTokenBalance:Ar,noTokenBalance:Dr,isBalanceLoading:Va,isSubmitting:oe,validation:Hr,supportsLimitOrder:u,kycRequired:C,kycUrl:er,expirationEnabled:W,expirationPreset:se,customDuration:ge,customDurationUnit:it,setOutcome:F,setSide:Ga,setOrderType:Or,setQuantity:Ya,setLimitPrice:qa,setExpirationEnabled:I,setExpirationPreset:ve,setCustomDuration:Ze,setCustomDurationUnit:Ir,submit:Qa}}function fo({isOpen:e,onClose:t,kycUrl:r}){let{t:o}=useTranslation();return jsx(StyledModal,{isOpen:e,onOpenChange:n=>{n||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:o("predict.trade.kycModalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5",children:[jsx("p",{className:"text-[13px] text-zinc-400 mb-4 text-left",children:o("predict.trade.kycModalDescription")}),jsx("div",{className:"flex flex-col gap-2 mb-4",children:["predict.trade.kycModalBullet1","predict.trade.kycModalBullet2","predict.trade.kycModalBullet3"].map(n=>jsxs("div",{className:"flex items-center gap-2.5 text-[13px] text-zinc-300",children:[jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e] shrink-0",children:jsx("polyline",{points:"20 6 9 17 4 12"})}),jsx("span",{children:o(n)})]},n))}),r&&jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[13px] text-[#c7ff2e]/70 hover:text-[#c7ff2e] transition-colors mb-3",children:[o("predict.trade.goToKYC")," \u2192"]}),jsx("p",{className:"text-[11px] text-zinc-500 mb-5",children:o("predict.trade.kycModalNote")}),jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:o("common.ok")})]})]})})})}var nl=`https://s1.chainstream.io/chains/sol/tokens/${SOLANA_TOKENS.stablecoins.USDC.address}/image.png`,ol=["5m","1h","12h","24h","eod","custom"],sl={"5m":"predict.trade.expiration.5m","1h":"predict.trade.expiration.1h","12h":"predict.trade.expiration.12h","24h":"predict.trade.expiration.24h",eod:"predict.trade.expiration.eod",custom:"predict.trade.expiration.custom"},al=["minutes","hours","days"],il={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"};function ko({event:e,market:t,variant:r="bordered",outcome:o,side:n,orderType:s,quantity:i,limitPrice:a,shares:l,potentialProfit:c,potentialPayout:p,estimatedCost:u,usdcBalance:m,yesTokenBalance:d,noTokenBalance:f,isBalanceLoading:g,isSubmitting:h,isValid:x,validationErrors:P,supportsLimitOrder:b,kycRequired:R,kycUrl:v,expirationEnabled:L,expirationPreset:y,customDuration:X,customDurationUnit:Y,onOutcomeChange:K,onSideChange:oe,onOrderTypeChange:D,onQuantityChange:$,onLimitPriceChange:H,onExpirationEnabledChange:me,onExpirationPresetChange:fe,onCustomDurationChange:C,onCustomDurationUnitChange:_,onSubmit:W}){let{t:I}=useTranslation(),[se,ve]=useState(false),ge=useDisclosure();useEffect(()=>{R&&!ge.isOpen&&ge.onOpen();},[R]);let Ze=useMemo(()=>{let F=n==="buy"?o==="yes"?t.yesAsk:t.noAsk:o==="yes"?t.yesBid:t.noBid;return F!=null?parseFloat((Number(F)*100).toFixed(2)):null},[n,o,t]),it=!isNaN(i)&&i>0,Ir=useMemo(()=>{if(h)return I("predict.trade.submitting");if(R)return I("predict.trade.kycRequired");if(!it)return I("predict.trade.enterAmount");let F=I(n==="buy"?"predict.trade.buy":"predict.trade.sell"),Ie=I(o==="yes"?"predict.trade.yes":"predict.trade.no"),We=n==="buy"&&c>0?` \u2192 Win $${c.toFixed(2)}`:"";return `${F} ${Ie}${We}`},[h,R,it,n,o,c,I]),ze=useMemo(()=>o==="yes"?"primary":"secondary",[o]),Jt=()=>{$(Math.floor((m??0)/2*100)/100);},er=()=>{$(m??0);},[xt,Se]=useState(false),Or=()=>{if(R){ge.onOpen();return}if(!x){Se(true);return}Se(false),W();};return jsxs(Fragment,{children:[jsxs("div",{className:cn$1("flex w-full flex-col gap-y-4 p-4",r==="bordered"&&"rounded-xl border border-default-200 bg-content1"),children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:o==="yes"?"text-bullish":"text-bearish",children:[I(n==="buy"?"predict.trade.buy":"predict.trade.sell")," ",I(o==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[b?jsxs(Tabs,{variant:"underlined",selectedKey:s,onSelectionChange:F=>D(F),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:I("predict.trade.market")},"market"),jsx(Tab,{title:I("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:I("predict.trade.market")}),s==="limit"&&b?jsx(StyledNumberInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",value:isNaN(a)?void 0:parseFloat((a*100).toFixed(2)),onValueChange:F=>H(F/100),minValue:1,maxValue:99,step:1,formatOptions:{maximumFractionDigits:2},endContent:jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):Ze!=null&&jsxs("span",{className:"text-xl font-bold tabular-nums",children:[Ze," \xA2"]})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(F=>{let Ie=F==="yes"?d:f;return jsxs("div",{className:"flex flex-1 flex-col gap-y-1",children:[jsxs("button",{type:"button",onClick:()=>K(F),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===F?F==="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:[jsx("span",{children:I(F==="yes"?"predict.trade.yes":"predict.trade.no")}),(()=>{let We=n==="buy"?F==="yes"?t.yesAsk:t.noAsk:F==="yes"?t.yesBid:t.noBid;return We!=null?jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(We)*100).toFixed(2)),"\xA2"]}):null})()]}),n==="sell"&&o===F&&jsx("span",{className:"text-center text-xs text-foreground",children:g?"\u2013":`${Ie??0} shares`})]},F)})}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:I(n==="buy"?"predict.trade.youArePaying":"predict.trade.contracts")}),n==="buy"&&jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("img",{src:nl,alt:"USDC",className:"h-3.5 w-3.5 rounded-full object-cover"}),jsx("span",{className:"font-medium text-foreground tabular-nums",children:m!=null?`${m.toFixed(2)} USDC`:"\u2013"}),jsx("button",{type:"button",onClick:Jt,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:I("predict.trade.half")}),jsx("button",{type:"button",onClick:er,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:I("predict.trade.max")})]})]}),jsx(StyledNumberInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",value:isNaN(i)?void 0:i,onValueChange:F=>{Se(false),$(F);},minValue:0,step:n==="buy"?.01:1,formatOptions:n==="buy"?{maximumFractionDigits:2}:{maximumFractionDigits:0},startContent:n==="buy"?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),n==="sell"&&jsxs("div",{className:"flex gap-x-2 justify-end",children:[[25,50].map(F=>jsxs("button",{type:"button",onClick:()=>{$(Math.floor((o==="yes"?d??0:f??0)*F/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:[F,"%"]},F)),jsx("button",{type:"button",onClick:()=>{$(o==="yes"?d??0:f??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:I("common.all")})]}),xt&&P.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:P.map(F=>jsx("span",{className:"text-xs text-danger",children:F},F))})]}),s==="limit"&&b&&jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium text-primary",children:I("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:L,onValueChange:me,"aria-label":I("predict.trade.setExpiration")})]}),L&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":I("predict.trade.setExpiration"),selectedKeys:[y],onSelectionChange:F=>{let Ie=Array.from(F)[0];Ie&&fe(Ie);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:ol.map(F=>jsx(SelectItem,{children:I(sl[F])},F))}),y==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(X)?void 0:X,onValueChange:C,minValue:1,step:1,formatOptions:{maximumFractionDigits:0},classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsx(Select,{"aria-label":"Duration unit",selectedKeys:[Y],onSelectionChange:F=>{let Ie=Array.from(F)[0];Ie&&_(Ie);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:al.map(F=>jsx(SelectItem,{children:I(il[F])},F))})]})]})]}),jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxs("button",{type:"button",onClick:()=>ve(F=>!F),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{children:I("predict.trade.odds")}),jsx(ChevronDownIcon,{className:cn$1("h-3.5 w-3.5 transition-transform",se&&"rotate-180")})]}),Ze!=null&&jsxs("span",{className:"text-foreground font-medium tabular-nums",children:[Ze,"% chance"]})]}),se&&jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:"Total Size"}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${u.toFixed(2)}`:"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:"No. of Contracts"}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(l)&&l>0?parseFloat(l.toFixed(2)):"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:"Payout"}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(i)&&i>0?`$${p.toFixed(2)}`:"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:"Est. Profit"}),jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(i)&&i>0&&c>0?`+$${c.toFixed(2)}`:"\u2013"})]})]})]}),jsx(Button,{color:ze,fullWidth:true,radius:"lg",size:"lg",isDisabled:!it||h,isLoading:h,onPress:Or,children:Ir})]}),jsx(fo,{isOpen:ge.isOpen,onClose:ge.onClose,kycUrl:v})]})}function lr({event:e,market:t,variant:r,initialSide:o,initialOutcome:n,chain:s}){let{outcome:i,side:a,orderType:l,quantity:c,limitPrice:p,shares:u,estimatedCost:m,potentialPayout:d,potentialProfit:f,usdcBalance:g,yesTokenBalance:h,noTokenBalance:x,isBalanceLoading:P,isSubmitting:b,validation:R,supportsLimitOrder:v,kycRequired:L,kycUrl:y,expirationEnabled:X,expirationPreset:Y,customDuration:K,customDurationUnit:oe,setOutcome:D,setSide:$,setOrderType:H,setQuantity:me,setLimitPrice:fe,setExpirationEnabled:C,setExpirationPreset:_,setCustomDuration:W,setCustomDurationUnit:I,submit:se}=mo({market:t,initialSide:o,initialOutcome:n}),ve=useAuthCallback(se),ge=useMemo(()=>e?oo(e):void 0,[e]),Ze=useMemo(()=>so(t),[t]);return jsx(ko,{event:ge,market:Ze,variant:r,outcome:i,side:a,orderType:l,quantity:c,limitPrice:p,shares:u,estimatedCost:m,potentialPayout:d,potentialProfit:f,usdcBalance:g,yesTokenBalance:h,noTokenBalance:x,isBalanceLoading:P,isSubmitting:b,isValid:R.isValid,validationErrors:R.errors,supportsLimitOrder:v,kycRequired:L,kycUrl:y,expirationEnabled:X,expirationPreset:Y,customDuration:K,customDurationUnit:oe,onOutcomeChange:D,onSideChange:$,onOrderTypeChange:H,onQuantityChange:me,onLimitPriceChange:fe,onExpirationEnabledChange:C,onExpirationPresetChange:_,onCustomDurationChange:W,onCustomDurationUnitChange:I,onSubmit:ve})}var At="predict-trade";function cr({id:e=At}){return jsx(AsyncModal,{id:e,children:t=>jsx(gl,{...t})})}function gl({params:e,isOpen:t,onOpenChange:r}){let{isMobile:o}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:o?"lg":"md",backdrop:"blur",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsx(ModalBody,{className:"p-2",children:jsx(lr,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,initialSide:e.initialSide??"buy",chain:e.chain,variant:"flat"})})})}):null}var Qr={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function Xr(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function wo({isOpen:e,onClose:t,value:r,onChange:o}){let{t:n}=useTranslation(),[s,i]=useState(r),a=useCallback(h=>{h?i(r):t();},[r,t]),l=useCallback(()=>{i(Qr);},[]),c=useCallback(()=>{o(s),t();},[s,o,t]),p=useCallback((h,x)=>{i(P=>({...P,[h]:x}));},[]),u=useMemo(()=>Xr(s),[s]),m=useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"polymarket",label:n("predict.platform.polymarket")},{value:"kalshi",label:n("predict.platform.kalshi")}],[n]),d=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]),f=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]),g=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 jsx(StyledModal,{isOpen:e,onOpenChange:a,size:"md",backdrop:"blur",scrollBehavior:"inside",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsxs(ModalContent,{children:[jsx(ModalHeader,{style:{padding:"12px 16px",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:jsx("span",{style:{fontSize:14,fontWeight:600,color:"#f4f4f5"},children:n("predict.filter.title")})}),jsxs(ModalBody,{style:{padding:"16px",display:"flex",flexDirection:"column",gap:20},children:[jsx(ur,{label:n("predict.filter.platform"),children:jsx(pr,{options:m,selected:s.source,onSelect:h=>p("source",h)})}),jsx(ur,{label:n("predict.filter.timeRemaining"),children:jsx(pr,{options:d,selected:s.timeRemaining,onSelect:h=>p("timeRemaining",h)})}),jsx(ur,{label:n("predict.filter.minVolume"),children:jsx(pr,{options:f,selected:s.minVolume,onSelect:h=>p("minVolume",h)})}),jsx(ur,{label:n("predict.filter.minLiquidity"),children:jsx(pr,{options:g,selected:s.minLiquidity,onSelect:h=>p("minLiquidity",h)})})]}),jsxs(ModalFooter,{style:{padding:"12px 16px",borderTop:"1px solid rgba(39,39,42,0.5)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[jsxs("button",{type:"button",style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 14px",borderRadius:8,border:"1px solid rgba(63,63,70,0.5)",background:"transparent",color:"#a1a1aa",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s"},onMouseEnter:h=>{h.currentTarget.style.background="rgba(39,39,42,0.5)",h.currentTarget.style.color="#fff";},onMouseLeave:h=>{h.currentTarget.style.background="transparent",h.currentTarget.style.color="#a1a1aa";},onClick:l,children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:14,height:14},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),jsx("path",{d:"M21 3v5h-5"}),jsx("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),jsx("path",{d:"M8 16H3v5"})]}),n("predict.filter.reset")]}),jsxs("button",{type:"button",style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 16px",borderRadius:8,border:"1px solid rgba(199,255,46,0.3)",background:"rgba(199,255,46,0.1)",color:"#c7ff2e",fontSize:13,fontWeight:600,cursor:"pointer",transition:"all 0.15s"},onMouseEnter:h=>{h.currentTarget.style.background="rgba(199,255,46,0.18)";},onMouseLeave:h=>{h.currentTarget.style.background="rgba(199,255,46,0.1)";},onClick:c,children:[n("predict.filter.showResults"),u>0&&jsxs("span",{style:{opacity:.8},children:["(",u,")"]})]})]})]})})}function ur({label:e,children:t}){return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[jsx("span",{style:{fontSize:11,fontWeight:500,color:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:e}),t]})}function pr({options:e,selected:t,onSelect:r,allowDeselect:o=true}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:e.map(n=>{let s=t===n.value;return jsx("button",{type:"button",onClick:()=>{r(s&&o?void 0:n.value);},style:{flexShrink:0,borderRadius:10,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s",border:s?"1px solid rgba(199,255,46,0.3)":"1px solid rgba(63,63,70,0.5)",background:s?"rgba(199,255,46,0.08)":"rgba(39,39,42,0.4)",color:s?"#c7ff2e":"#a1a1aa"},onMouseEnter:i=>{s||(i.currentTarget.style.background="rgba(39,39,42,0.8)",i.currentTarget.style.color="#fff");},onMouseLeave:i=>{s||(i.currentTarget.style.background="rgba(39,39,42,0.4)",i.currentTarget.style.color="#a1a1aa");},children:n.label},n.value??"__all")})})}var Eo={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},Po={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},_l=["start_time","volume","liquidity","ending_soon"],Co={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"6px 12px",fontSize:13,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},Rl={position:"absolute",left:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function To({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:o,onFilterPress:n,filterCount:s=0,className:i}){let{t:a}=useTranslation(),[l,c]=useState(false),p=useRef(null),u=useCallback(d=>{p.current&&!p.current.contains(d.target)&&c(false);},[]);useEffect(()=>(document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)),[u]),useEffect(()=>{if(!l)return;let d=f=>{f.key==="Escape"&&c(false);};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[l]);let m=Mo[e];return jsxs("div",{className:i,style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:p,style:{position:"relative"},children:[jsxs("button",{type:"button",style:Co,onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>c(d=>!d),children:[jsx(Il,{}),jsx(m,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a(Po[e])}),jsx(Al,{open:l})]}),l&&jsx("div",{style:{...Rl,width:200,padding:4},children:_l.map(d=>{let f=Mo[d],g=e===d;return jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:10,padding:"8px 12px",textAlign:"left",fontSize:13,border:"none",cursor:"pointer",transition:"all 0.15s",background:g?"rgba(199,255,46,0.08)":"transparent",color:g?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:h=>{g||(h.currentTarget.style.background="rgba(39,39,42,0.5)",h.currentTarget.style.color="#fff");},onMouseLeave:h=>{g||(h.currentTarget.style.background="transparent",h.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===d?o(!r):t(d),c(false);},children:[jsx(f,{className:"size-4 shrink-0",style:{color:g?"#c7ff2e":"#71717a"}}),jsx("span",{style:{flex:1,fontWeight:500},children:a(Po[d])}),g&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},d)})})]}),jsx("button",{type:"button",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:34,height:34,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:14},onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)",d.currentTarget.style.color="#fff";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)",d.currentTarget.style.color="#a1a1aa";},onClick:()=>o(!r),children:r?"\u2191":"\u2193"}),jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",style:Co,onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:n,children:[jsx(Ol,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:a("predict.filter.title")})]}),s>0&&jsx("span",{style:{position:"absolute",top:-4,right:-4,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,background:"#c7ff2e",color:"#000",fontSize:10,fontWeight:600,padding:"0 4px"},children:s})]})]})}var Mo={start_time:CalendarIcon,volume:ChartLineIcon,liquidity:DropletIcon,ending_soon:TimerIcon};function Il(){return jsxs("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"m21 16-4 4-4-4"}),jsx("path",{d:"M17 20V4"}),jsx("path",{d:"m3 8 4-4 4 4"}),jsx("path",{d:"M7 4v16"})]})}function Ol(){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})})}function Al({open:e}){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#71717a",transition:"transform 0.15s",transform:e?"rotate(180deg)":void 0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"m6 9 6 6 6-6"})})}function Ro(e={}){let t=useMemo(()=>resolveEventsParams(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets,e.minVolume,e.minLiquidity,e.timeRemaining]),{data:r,isLoading:o,isFetching:n,isFetchingNextPage:s,isError:i,error:a,hasNextPage:l,fetchNextPage:c,refetch:p}=useInfiniteEvents(t),u=useMemo(()=>r?.pages.flatMap(f=>f.items).filter(f=>f!=null)??[],[r]),m=useCallback(()=>{c();},[c]),d=useCallback(()=>{p();},[p]);return {data:u,isLoading:o,isFetching:n&&!s,isFetchingMore:s,isError:i,error:a??null,hasMore:l??false,fetchMore:m,refetch:d}}function Zr({count:e=6}){return jsx("div",{className:"grid w-full grid-cols-1 gap-0 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:Array.from({length:e}).map((t,r)=>jsx("div",{className:"p-2",children:jsxs("div",{className:"flex h-full min-h-52 flex-col rounded-xl border border-border/90 bg-background p-3 lg:min-h-72 lg:p-4",children:[jsxs("div",{className:"flex items-center gap-3",children:[jsx(Skeleton,{className:"size-10 shrink-0 rounded-lg"}),jsxs("div",{className:"flex flex-1 flex-col gap-1",children:[jsx(Skeleton,{className:"h-4 w-11/12 rounded"}),jsx(Skeleton,{className:"h-3 w-2/5 rounded"})]})]}),jsxs("div",{className:"mt-3 flex flex-1 flex-col gap-2 lg:gap-3",children:[jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsx(Skeleton,{className:"h-7 w-1/2 rounded"}),jsx(Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]}),jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsx(Skeleton,{className:"h-7 w-3/5 rounded"}),jsx(Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]}),jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsx(Skeleton,{className:"h-7 w-2/5 rounded"}),jsx(Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]})]}),jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[jsx(Skeleton,{className:"h-3 w-20 rounded"}),jsx(Skeleton,{className:"h-3 w-24 rounded"})]})]})},r))})}function Eg({count:e=48}){return jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsxs("div",{className:"flex min-h-8 items-center justify-between gap-3 lg:min-h-9",children:[jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[jsx(Skeleton,{className:"h-6 w-16 rounded"}),jsx(Skeleton,{className:"h-6 w-20 rounded"}),jsx(Skeleton,{className:"h-6 w-16 rounded"}),jsx(Skeleton,{className:"h-6 w-20 rounded"})]}),jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[jsx(Skeleton,{className:"h-7 w-28 rounded-full"}),jsx(Skeleton,{className:"h-7 w-24 rounded-full"})]})]}),jsx("div",{className:"min-h-0 flex-1",children:jsx(Zr,{count:e})})]})}var Io=3,en={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},Ho={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},Vl={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},Ft=[{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 Oo(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 jl(e){let t=e.outcomes?.map(i=>i.label?.toLowerCase().trim()??"")??[];if(t.some(i=>i==="up")&&t.some(i=>i==="down"))return [en,Vl];if(t.some(i=>i==="yes")&&t.some(i=>i==="no"))return [en,Ho];let r=t[0]??"",o=t[1]??"",n=Oo(r)%Ft.length,s=Oo(o)%Ft.length;return s===n&&(s=(s+1)%Ft.length),[Ft[n],Ft[s]]}function Gl(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function Bo(e){let t=Gl(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function $o(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function Ao(e){let t=e.outcomes?.[0],r=t?.best_ask??t?.price??0;return parseFloat((r*100).toFixed(2)).toString()}function Do(e){let t=e.outcomes?.[1];if(t){let n=t.best_ask??t.price??0;return parseFloat((n*100).toFixed(2)).toString()}let r=e.outcomes?.[0],o=r?.best_ask??r?.price??0;return parseFloat(((1-o)*100).toFixed(2)).toString()}function Yl(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 ql=`
|
|
1
|
+
import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMemo,useEffect,useCallback,useContext,Fragment as Fragment$1,startTransition,Component}from'react';import {PolymarketIcon,KalshiIcon,cn as cn$1,Skeleton,toast,StyledModal,ModalContent,useDisclosure,Tabs,Tab,StyledNumberInput,StyledSwitch,Select,SelectItem,ChevronDownIcon,Button,useScreen,TimerIcon,DropletIcon,ChartLineIcon,CalendarIcon,Linkable,Avatar,ChevronUpIcon,Spinner,OrderbookTableIcon,OrderbookDepthIcon,Dropdown,DropdownTrigger,DropdownMenu,DropdownItem,ChevronRightIcon,ChevronLeftIcon,TrashIcon,Chip,StyledInput,XCloseIcon,Kbd,SearchIcon,EmptyIcon,ModalHeader,ModalBody}from'@liberfi.io/ui';import {AsyncModal,useAsyncModal}from'@liberfi.io/ui-scaffold';import {useTranslation}from'@liberfi.io/i18n';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useWallets,useAuth,useSwitchChain,useAuthCallback}from'@liberfi.io/wallet-connector';import {keepPreviousData,useQueryClient,useQueries}from'@tanstack/react-query';import Vr from'canvas-confetti';import {ChartRange,useInfiniteMatchMarkets,useBalance,useDFlowKYC,usePolymarketSetup,usePredictClient,PolymarketContext,usePositions,useDFlowQuote,useDFlowSubmit,useOrder,buildCtfExchangeDomain,buildOrderMessage,CTF_ORDER_TYPES,buildSignedOrder,buildClobPayload,buildPolymarketL2Headers,resolveEventsParams,useInfiniteEvents,useInfiniteOrders,useCancelOrder,useInfiniteTrades,useOrderbook,useMarketHistory,useEvent,useSimilarEvents,candlesticksQueryKey,useSearchEvents}from'@liberfi.io/react-predict';export{PredictClient,PredictContext,PredictProvider,PredictWsClient,createPredictClient,createPredictWsClient,fetchMatchMarketsPage,fetchMatchesPage,matchMarketsQueryKey,matchQueryKey,matchesQueryKey,useBalance,useCancelOrder,useCandlesticks,useDFlowKYC,useDFlowQuote,useDFlowSubmit,useEvent,useEvents,useInfiniteEvents,useInfiniteMatchMarkets,useInfiniteMatches,useInfiniteOrders,useInfiniteTrades,useMarket,useMarketHistory,useMarketTrades,useMatch,useOrder,useOrderbook,useOrders,usePositions,usePredictClient,usePriceHistory,useSearchEvents,useSimilarEvents,useTrades}from'@liberfi.io/react-predict';import {ChainNamespace,Chain}from'@liberfi.io/types';import {SOLANA_TOKENS,debounce}from'@liberfi.io/utils';import {List}from'react-window';import {useInfiniteLoader}from'react-window-infinite-loader';import {useResizeObserver,useScrollCollapse,useCallbackRef}from'@liberfi.io/hooks';import {ResponsiveContainer,LineChart,CartesianGrid,XAxis,YAxis,Tooltip,Line,ReferenceDot}from'recharts';import {useAtom}from'jotai';import {atomWithStorage}from'jotai/utils';typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-predict"]="0.1.112");var ca="0.1.112";var da={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},Zn=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],$r=(()=>{let e=t=>{let r=Zn.indexOf(t);return r===-1?Zn.length:r};return Object.entries(da).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 to({categories:e,selectedCategory:t,selectedTag:r,activeTags:o,onCategorySelect:n,onTagSelect:s,trailing:a,pulsingTab:i="Trending",className:l}){let{t:c}=useTranslation(),p=useCallback(()=>{n(null);},[n]),u=c("predict.categories.trending");return jsxs("div",{className:cn$1("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:[jsxs("div",{className:"flex w-full items-center gap-2",children:[jsx("div",{className:"hideScrollbar min-w-0 flex-1 overflow-x-auto overflow-y-hidden",children:jsxs("div",{className:"flex min-h-8 items-stretch gap-x-2 lg:min-h-9",children:[jsx(Jn,{label:u,isSelected:t===null,onPress:p,showPulse:u===i}),jsx(fa,{}),e.map(m=>jsx(Jn,{label:m.category,isSelected:t===m.category,onPress:()=>n(m.category),badge:m.badge,showPulse:m.category===i},m.category))]})}),a&&jsx("div",{className:"flex-shrink-0",children:a})]}),t&&o.length>0&&jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxs("div",{className:"flex gap-x-1 pl-2 lg:w-full lg:gap-x-2",children:[jsx(eo,{label:c("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>s(null)}),o.map(m=>jsx(eo,{label:m.label,icon:m.icon,isSelected:r===m.label,onPress:()=>s(m.label)},m.label))]})})]})}function Jn({label:e,isSelected:t,onPress:r,badge:o,showPulse:n}){return jsxs("button",{type:"button",onClick:r,className:cn$1("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?jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsx("span",{children:e})]}):e,o&&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 fa(){return jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function eo({label:e,icon:t,isSelected:r,onPress:o}){return jsxs("button",{type:"button",onClick:o,className:cn$1("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&&jsx("span",{className:cn$1("iconify size-4",t)}),e]})}function df({count:e=6}){return jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-1 lg:px-2 lg:py-1",children:jsx("div",{className:"flex min-h-8 items-center gap-x-2 lg:min-h-9",children:Array.from({length:e}).map((t,r)=>jsx(Skeleton,{className:"h-6 w-16 shrink-0 rounded"},r))})})}function ga(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function ha(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function oo({onSelect:e,trailing:t,className:r}){let[o,n]=useState(null),[s,a]=useState(null),i=useCallback(m=>{n(m),a(null),e?.({categorySlug:m,tagSlug:null});},[e]),l=useCallback(m=>{a(m),e?.({categorySlug:o,tagSlug:m});},[o,e]),c=ga($r),p=$r.find(m=>m.slug===o),u=ha(p);return jsx(to,{categories:c,selectedCategory:o,selectedTag:s,activeTags:u,onCategorySelect:i,onTagSelect:l,trailing:t,className:r})}function so(e){return {title:e.title,imageUrl:e.image_url}}function io(e){let t=e.outcomes[0],r=e.outcomes[1];return {question:e.question,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"}}var It=48,zr=4,sr={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},Me={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},ir=Me.ALL,bf={[Me.ONE_DAY]:sr.ONE_MINUTE,[Me.ONE_WEEK]:sr.ONE_HOUR,[Me.ONE_MONTH]:sr.ONE_HOUR,[Me.ALL]:sr.ONE_DAY},yf={[Me.ONE_DAY]:300,[Me.ONE_WEEK]:3600,[Me.ONE_MONTH]:10800,[Me.ALL]:1440*60},kf={[Me.ONE_DAY]:1440*60,[Me.ONE_WEEK]:10080*60,[Me.ONE_MONTH]:720*60*60,[Me.ALL]:null},Wr=1,Sf=1,wf=1,Nf=99,bt={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Pf=bt.ONE_WEEK,Cf={[bt.ONE_HOUR]:60,[bt.SIX_HOURS]:60,[bt.ONE_DAY]:300,[bt.ONE_WEEK]:1800,[bt.MAX]:1800};var co=createContext(null);function Kr(){let e=useContext(co);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var wa=1e4;function Na({pollingInterval:e=wa,enabled:t=true,children:r}){let o=useWallets(),n=useMemo(()=>o.find(v=>v.chainNamespace===ChainNamespace.SOLANA&&v.isConnected)?.address,[o]),s=useMemo(()=>o.find(v=>v.chainNamespace===ChainNamespace.EVM&&v.isConnected)?.address,[o]),{data:a,isLoading:i,isFetching:l,error:c}=useBalance({source:"kalshi",user:n??""},{enabled:t&&!!n,refetchInterval:e}),{data:p,isLoading:u}=useDFlowKYC(n,{enabled:t&&!!n,refetchInterval:3e4}),{data:m,isLoading:d}=usePolymarketSetup(s,{enabled:t&&!!s,refetchInterval:3e4}),f=m?.safe_address,g=m?.verified??false,{data:h,isLoading:x,isFetching:w,error:b}=useBalance({source:"polymarket",user:f??""},{enabled:t&&g&&!!f,refetchInterval:e}),L=useMemo(()=>({solanaAddress:n,evmAddress:s,polymarketSafeAddress:f,kalshiUsdcBalance:a?Number(a.balance):null,polymarketUsdcBalance:g&&h?Number(h.balance):null,kalshiKycVerified:p?.verified??false,kalshiKycUrl:p?.kyc_url??null,kalshiKycLoading:u,polymarketSetupVerified:g,polymarketSafeDeployed:m?.safe_deployed??false,polymarketTokenApproved:m?.token_approved??false,polymarketSetupLoading:d,isLoading:i||x,isFetching:l||w,error:c??b??null}),[n,s,f,a,h,g,p,u,m,d,i,x,l,w,c,b]);return jsx(co.Provider,{value:L,children:r})}var Va={minutes:60,hours:3600,days:86400};function ja(e,t,r){let o=Math.floor(Date.now()/1e3);switch(e){case "5m":return o+300;case "1h":return o+3600;case "12h":return o+720*60;case "24h":return o+1440*60;case "eod":{let n=new Date;return n.setUTCHours(23,59,59,0),Math.floor(n.getTime()/1e3)}case "custom":return o+t*Va[r]}}function jr(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};Vr({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{Vr({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{Vr({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function fo({market:e,initialOutcome:t="yes",initialSide:r="buy"}){let{t:o}=useTranslation(),{status:n}=useAuth(),s=useWallets(),a=useSwitchChain(),i=usePredictClient(),l=useContext(PolymarketContext),c=useQueryClient(),p=e.source,u=p==="polymarket",m=s.find(N=>N.chainNamespace===ChainNamespace.SOLANA&&N.isConnected),d=s.find(N=>N.chainNamespace===ChainNamespace.EVM&&N.isConnected&&"switchChain"in N),f=n==="authenticated",g=m?.address,h=d?.address,[x,w]=useState(t),[b,L]=useState(r),[v,T]=useState("market"),[y,X]=useState(NaN),[Y,K]=useState(NaN),[oe,D]=useState(false),[$,H]=useState(null),[fe,ge]=useState(null),[C,R]=useState(false),[W,I]=useState(false),[se,ve]=useState("1h"),[he,Ze]=useState(30),[at,Rr]=useState("minutes"),ze=null,Zt=false,Jt=null,xt;try{let N=Kr();ze={kalshiUsdcBalance:N.kalshiUsdcBalance,polymarketUsdcBalance:N.polymarketUsdcBalance,isLoading:N.isLoading},Zt=N.kalshiKycVerified,Jt=N.kalshiKycUrl,xt=N.polymarketSafeAddress;}catch{}let ke=useMemo(()=>{let N=x==="yes"?0:1,q=e.outcomes[N];return b==="buy"?q?.best_ask??q?.price??.5:q?.best_bid??q?.price??.5},[e.outcomes,x,b]),Ir=useCallback(N=>{T(N);},[]),F=useCallback(N=>{w(N),K(NaN);},[]);useEffect(()=>{v==="limit"&&isNaN(Y)&&K(Math.round(ke*100)/100);},[v,Y,ke]);let Re=useMemo(()=>isNaN(y)||y<=0?0:b==="buy"?ke>0?y/ke:0:y,[b,y,ke]),We=useMemo(()=>isNaN(y)||y<=0?"0":String(Math.round(y*1e6)),[y]),$i=e.provider_meta?.["dflow.yesMint"]??"",zi=e.provider_meta?.["dflow.noMint"]??"",lt=SOLANA_TOKENS.stablecoins.USDC.address,Wi=e.provider_meta?.["dflow.collateralMint"]||"",$n=x==="yes"?$i:zi,zn=p==="kalshi"?g??"":h??"",{data:Ie,isLoading:Ui}=usePositions({source:p,user:zn},{enabled:!!zn}),Wn=useMemo(()=>!Ie||b!=="sell"?null:Ie.positions.find(N=>N.side?.toLowerCase()===x&&N.market?.slug===e.slug)??null,[Ie,e.slug,x,b])?.market?.provider_meta,Ki=b==="sell"&&Wn?.["dflow.outcomeMint"]||$n,Tt=b==="sell"&&Wn?.["dflow.collateralMint"]||Wi,Lt=b==="buy"?lt:Ki,_t=b==="buy"?$n:Tt||lt,Vi=p==="kalshi"&&!!Lt&&!!_t&&!!g&&We!=="0",{refetch:Un}=useDFlowQuote({inputMint:Lt,outputMint:_t,amount:We,userPublicKey:g??"",slippageBps:100},{enabled:Vi}),er=useMemo(()=>ze?p==="kalshi"?ze.kalshiUsdcBalance:ze.polymarketUsdcBalance:Ie&&Ie.positions.reduce((q,Ce)=>Ce.side==="USDC"||Ce.side==="collateral"?q+(Ce.current_value??0):q,0)||null,[ze,Ie,p]),ji=ze?ze.isLoading:Ui,Or=useMemo(()=>Ie?Ie.positions.find(q=>q.side?.toLowerCase()==="yes"&&q.market?.slug===e.slug)?.size??0:null,[Ie,e.slug]),Ar=useMemo(()=>Ie?Ie.positions.find(q=>q.side?.toLowerCase()==="no"&&q.market?.slug===e.slug)?.size??0:null,[Ie,e.slug]),Dr=useMemo(()=>v==="limit"&&u&&!isNaN(Y)?Y:ke,[v,u,Y,ke]),tr=useMemo(()=>{if(isNaN(y)||y<=0)return 0;if(b==="buy")return y;let N=x==="yes"?e.outcomes[0]?.best_bid??0:e.outcomes[1]?.best_bid??0;return y*N},[b,x,y,e.outcomes]),Kn=useMemo(()=>isNaN(y)||y<=0?0:b==="buy"?Dr>0?y/Dr*1:0:tr,[b,y,Dr,tr]),Gi=Kn-tr,Yi=useCallback(N=>{L(N),X(NaN);},[]),qi=useCallback(N=>{if(isNaN(N)){X(NaN);return}let q=Math.max(0,N),Ce=b==="buy"?Math.round(q*100)/100:Math.round(q);X(Ce);},[b]),Qi=useCallback(N=>{if(isNaN(N)){K(NaN);return}let q=Math.max(.01,Math.min(.99,N));K(Math.round(q*100)/100);},[]),Fr=useMemo(()=>{let N=[];(isNaN(y)||y<Wr)&&N.push(`Minimum quantity is ${Wr}`),e.status!=="open"&&N.push("Market is not active"),b==="buy"&&er!=null&&!isNaN(y)&&y>0&&y>er&&N.push("Insufficient USDC balance");let q=x==="yes"?Or:Ar;return b==="sell"&&q!=null&&!isNaN(y)&&y>0&&y>q&&N.push("Insufficient shares"),v==="limit"&&u&&(isNaN(Y)||Y<.01||Y>.99)&&N.push("Limit price must be between $0.01 and $0.99"),v==="limit"&&u&&W&&se==="custom"&&(isNaN(he)||he<=0)&&N.push(o("predict.trade.expiration.invalidDate")),{isValid:N.length===0,errors:N}},[y,e.status,b,er,Or,Ar,x,v,u,Y,W,se,he,o]),{mutateAsync:rr}=useDFlowSubmit(),{data:Hr}=useOrder({id:$??"",source:p},{enabled:!!$}),Vn=useCallback(async()=>{if(!fe||!g||!m)return;let{cashAmount:N,collateral:q}=fe;ge(null);try{let ct=(await i.createDFlowQuote({inputMint:q,outputMint:lt,amount:N,userPublicKey:g,slippageBps:100}))?.transaction;if(!ct)return;let Je=Uint8Array.from(atob(ct),Rt=>Rt.charCodeAt(0)),Ue=await m.signTransaction(Je);await rr({signedTransaction:btoa(String.fromCharCode(...Ue)),orderContext:{user_public_key:g,input_mint:q,output_mint:lt,amount:N,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[fe,g,m,i,rr,lt]);useEffect(()=>{if(!Hr||!$)return;let{status:N}=Hr;N==="closed"?(H(null),fe?Vn().finally(()=>{D(false),toast.success(o("predict.trade.submitSuccess")),jr(),X(NaN);}):(D(false),toast.success(o("predict.trade.submitSuccess")),jr(),X(NaN))):(N==="failed"||N==="expired")&&(D(false),H(null),ge(null),toast.error(o("predict.trade.submitError")));},[Hr,$,fe,Vn,o]);let jn=useCallback(async()=>{if(!g||!m)return;if(!Lt||!_t){toast.error("Missing token mint addresses"),D(false);return}if(!Zt){R(true),D(false);return}let Ce=(await Un()).data,ct=Ce?.transaction;if(!ct){toast.error(o("predict.trade.submitError")),D(false);return}if(b==="sell"&&Tt&&Tt!==lt){let et=String(Ce?.outAmount??"");et&&et!=="0"&&ge({cashAmount:et,collateral:Tt});}let Je=Uint8Array.from(atob(ct),et=>et.charCodeAt(0)),Ue=await m.signTransaction(Je),Rt=await rr({signedTransaction:btoa(String.fromCharCode(...Ue)),orderContext:{user_public_key:g,input_mint:Lt,output_mint:_t,amount:We,price:String(ke),side:b==="buy"?"BUY":"SELL",outcome:x==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});H(Rt.signature);},[g,m,i,Un,rr,Lt,_t,We,ke,b,x,e.slug,Tt,lt,o]),Gn=useCallback(async()=>{if(!d||!l)return;let N=d.chain,q=N!==Chain.POLYGON;q&&await a(Chain.POLYGON);try{let Ce=await d.getEip1193Provider();if(!Ce){toast.error(o("predict.trade.submitError")),D(!1);return}let ct=!!xt,Je={address:d.address,signatureType:ct?2:0,signTypedData:async(dt,sa,ia,aa)=>{let vt=[];"name"in dt&&vt.push({name:"name",type:"string"}),"version"in dt&&vt.push({name:"version",type:"string"}),"chainId"in dt&&vt.push({name:"chainId",type:"uint256"}),"verifyingContract"in dt&&vt.push({name:"verifyingContract",type:"address"}),"salt"in dt&&vt.push({name:"salt",type:"bytes32"});let la={EIP712Domain:vt,...sa};return await Ce.request({method:"eth_signTypedData_v4",params:[d.address,JSON.stringify({domain:dt,types:la,primaryType:ia,message:aa})]})}},Ue=l.credentials??await l.authenticate(Je),Rt=x==="yes"?0:1,et="",nr=e.provider_meta?.["polymarket.clobTokenIds"];nr&&(et=(typeof nr=="string"?JSON.parse(nr):nr)[Rt]??"");let Yn=e.provider_meta?.["polymarket.negRisk"]??!1,Br=v==="limit"&&!isNaN(Y)?Y:ke,Zi=v==="limit"?W?"GTD":"GTC":"FOK",Ji=b==="buy"&&Br>0?y/Br:y,qn={tokenId:et,price:Br,size:Ji,side:b==="buy"?"BUY":"SELL",orderType:Zi,tickSize:"0.01",negRisk:Yn,...xt&&{funderAddress:xt},...v==="limit"&&W&&{expiration:ja(se,he,at)}},ea=buildCtfExchangeDomain(Yn),Qn=buildOrderMessage({...qn,signerAddress:Je.address,signatureType:Je.signatureType}),ta=await Je.signTypedData(ea,CTF_ORDER_TYPES,"Order",Qn),ra=buildSignedOrder(Qn,ta,qn.orderType),Xn=buildClobPayload(ra,Ue.apiKey),na=JSON.stringify(Xn),oa=await buildPolymarketL2Headers(Ue.address,{apiKey:Ue.apiKey,secret:Ue.secret,passphrase:Ue.passphrase,method:"POST",requestPath:"/order",body:na});await i.createPolymarketOrder(Xn,oa),c.invalidateQueries({queryKey:["predict","orders"]}),c.invalidateQueries({queryKey:["predict","positions"]}),toast.success(o("predict.trade.submitSuccess")),jr(),X(NaN),D(!1);}finally{q&&N&&a(N).catch(()=>{});}},[d,l,a,x,e.provider_meta,v,Y,ke,y,b,i,c,W,se,he,at,o]),Xi=useCallback(async()=>{if(!(!Fr.isValid||!f)){D(true),H(null),R(false);try{p==="kalshi"?await jn():await Gn();}catch(N){let q=N instanceof Error?N.message:void 0;toast.error(q||o("predict.trade.submitError")),D(false);}}},[Fr.isValid,f,p,jn,Gn,o]);return {outcome:x,side:b,orderType:v,quantity:y,limitPrice:Y,shares:Re,estimatedCost:tr,potentialPayout:Kn,potentialProfit:Gi,usdcBalance:er,yesTokenBalance:Or,noTokenBalance:Ar,isBalanceLoading:ji,isSubmitting:oe,validation:Fr,supportsLimitOrder:u,kycRequired:C,kycUrl:Jt,expirationEnabled:W,expirationPreset:se,customDuration:he,customDurationUnit:at,setOutcome:F,setSide:Yi,setOrderType:Ir,setQuantity:qi,setLimitPrice:Qi,setExpirationEnabled:I,setExpirationPreset:ve,setCustomDuration:Ze,setCustomDurationUnit:Rr,submit:Xi}}function go({isOpen:e,onClose:t,kycUrl:r}){let{t:o}=useTranslation();return jsx(StyledModal,{isOpen:e,onOpenChange:n=>{n||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:o("predict.trade.kycModalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5",children:[jsx("p",{className:"text-[13px] text-zinc-400 mb-4 text-left",children:o("predict.trade.kycModalDescription")}),jsx("div",{className:"flex flex-col gap-2 mb-4",children:["predict.trade.kycModalBullet1","predict.trade.kycModalBullet2","predict.trade.kycModalBullet3"].map(n=>jsxs("div",{className:"flex items-center gap-2.5 text-[13px] text-zinc-300",children:[jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e] shrink-0",children:jsx("polyline",{points:"20 6 9 17 4 12"})}),jsx("span",{children:o(n)})]},n))}),r&&jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[13px] text-[#c7ff2e]/70 hover:text-[#c7ff2e] transition-colors mb-3",children:[o("predict.trade.goToKYC")," \u2192"]}),jsx("p",{className:"text-[11px] text-zinc-500 mb-5",children:o("predict.trade.kycModalNote")}),jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:o("common.ok")})]})]})})})}var ol=`https://s1.chainstream.io/chains/sol/tokens/${SOLANA_TOKENS.stablecoins.USDC.address}/image.png`,sl=["5m","1h","12h","24h","eod","custom"],il={"5m":"predict.trade.expiration.5m","1h":"predict.trade.expiration.1h","12h":"predict.trade.expiration.12h","24h":"predict.trade.expiration.24h",eod:"predict.trade.expiration.eod",custom:"predict.trade.expiration.custom"},al=["minutes","hours","days"],ll={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"};function So({event:e,market:t,variant:r="bordered",outcome:o,side:n,orderType:s,quantity:a,limitPrice:i,shares:l,potentialProfit:c,potentialPayout:p,estimatedCost:u,usdcBalance:m,yesTokenBalance:d,noTokenBalance:f,isBalanceLoading:g,isSubmitting:h,isValid:x,validationErrors:w,supportsLimitOrder:b,kycRequired:L,kycUrl:v,expirationEnabled:T,expirationPreset:y,customDuration:X,customDurationUnit:Y,onOutcomeChange:K,onSideChange:oe,onOrderTypeChange:D,onQuantityChange:$,onLimitPriceChange:H,onExpirationEnabledChange:fe,onExpirationPresetChange:ge,onCustomDurationChange:C,onCustomDurationUnitChange:R,onSubmit:W}){let{t:I}=useTranslation(),[se,ve]=useState(false),he=useDisclosure();useEffect(()=>{L&&!he.isOpen&&he.onOpen();},[L]);let Ze=useMemo(()=>{let F=n==="buy"?o==="yes"?t.yesAsk:t.noAsk:o==="yes"?t.yesBid:t.noBid;return F!=null?parseFloat((Number(F)*100).toFixed(2)):null},[n,o,t]),at=!isNaN(a)&&a>0,Rr=useMemo(()=>{if(h)return I("predict.trade.submitting");if(L)return I("predict.trade.kycRequired");if(!at)return I("predict.trade.enterAmount");let F=I(n==="buy"?"predict.trade.buy":"predict.trade.sell"),Re=I(o==="yes"?"predict.trade.yes":"predict.trade.no"),We=n==="buy"&&c>0?` \u2192 Win $${c.toFixed(2)}`:"";return `${F} ${Re}${We}`},[h,L,at,n,o,c,I]),ze=useMemo(()=>o==="yes"?"primary":"secondary",[o]),Zt=()=>{$(Math.floor((m??0)/2*100)/100);},Jt=()=>{$(m??0);},[xt,ke]=useState(false),Ir=()=>{if(L){he.onOpen();return}if(!x){ke(true);return}ke(false),W();};return jsxs(Fragment,{children:[jsxs("div",{className:cn$1("flex w-full flex-col gap-y-4 p-4",r==="bordered"&&"rounded-xl border border-default-200 bg-content1"),children:[e&&jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxs("span",{className:o==="yes"?"text-bullish":"text-bearish",children:[I(n==="buy"?"predict.trade.buy":"predict.trade.sell")," ",I(o==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxs("div",{className:"flex items-center justify-between",children:[b?jsxs(Tabs,{variant:"underlined",selectedKey:s,onSelectionChange:F=>D(F),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsx(Tab,{title:I("predict.trade.market")},"market"),jsx(Tab,{title:I("predict.trade.limit")},"limit")]}):jsx("span",{className:"text-sm font-medium text-foreground",children:I("predict.trade.market")}),s==="limit"&&b?jsx(StyledNumberInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",value:isNaN(i)?void 0:parseFloat((i*100).toFixed(2)),onValueChange:F=>H(F/100),minValue:1,maxValue:99,step:1,formatOptions:{maximumFractionDigits:2},endContent:jsx("span",{className:"text-xl font-bold tabular-nums text-foreground",children:"\xA2"}),classNames:{base:"w-28",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 rounded-lg px-2 h-9 min-h-9",input:"text-xl font-bold tabular-nums text-right"}}):Ze!=null&&jsxs("span",{className:"text-xl font-bold tabular-nums",children:[Ze," \xA2"]})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(F=>{let Re=F==="yes"?d:f;return jsxs("div",{className:"flex flex-1 flex-col gap-y-1",children:[jsxs("button",{type:"button",onClick:()=>K(F),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===F?F==="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:[jsx("span",{children:I(F==="yes"?"predict.trade.yes":"predict.trade.no")}),(()=>{let We=n==="buy"?F==="yes"?t.yesAsk:t.noAsk:F==="yes"?t.yesBid:t.noBid;return We!=null?jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(We)*100).toFixed(2)),"\xA2"]}):null})()]}),n==="sell"&&o===F&&jsx("span",{className:"text-center text-xs text-foreground",children:g?"\u2013":`${Re??0} shares`})]},F)})}),jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsx("span",{className:"text-sm font-medium text-foreground",children:I(n==="buy"?"predict.trade.youArePaying":"predict.trade.contracts")}),n==="buy"&&jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("img",{src:ol,alt:"USDC",className:"h-3.5 w-3.5 rounded-full object-cover"}),jsx("span",{className:"font-medium text-foreground tabular-nums",children:m!=null?`${m.toFixed(2)} USDC`:"\u2013"}),jsx("button",{type:"button",onClick:Zt,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:I("predict.trade.half")}),jsx("button",{type:"button",onClick:Jt,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:I("predict.trade.max")})]})]}),jsx(StyledNumberInput,{"aria-label":"Trade amount",fullWidth:true,placeholder:"0",radius:"lg",size:"lg",value:isNaN(a)?void 0:a,onValueChange:F=>{ke(false),$(F);},minValue:0,step:n==="buy"?.01:1,formatOptions:n==="buy"?{maximumFractionDigits:2}:{maximumFractionDigits:0},startContent:n==="buy"?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),n==="sell"&&jsxs("div",{className:"flex gap-x-2 justify-end",children:[[25,50].map(F=>jsxs("button",{type:"button",onClick:()=>{$(Math.floor((o==="yes"?d??0:f??0)*F/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:[F,"%"]},F)),jsx("button",{type:"button",onClick:()=>{$(o==="yes"?d??0:f??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:I("common.all")})]}),xt&&w.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:w.map(F=>jsx("span",{className:"text-xs text-danger",children:F},F))})]}),s==="limit"&&b&&jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium text-primary",children:I("predict.trade.setExpiration")}),jsx(StyledSwitch,{size:"sm",color:"primary",isSelected:T,onValueChange:fe,"aria-label":I("predict.trade.setExpiration")})]}),T&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":I("predict.trade.setExpiration"),selectedKeys:[y],onSelectionChange:F=>{let Re=Array.from(F)[0];Re&&ge(Re);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:sl.map(F=>jsx(SelectItem,{children:I(il[F])},F))}),y==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(X)?void 0:X,onValueChange:C,minValue:1,step:1,formatOptions:{maximumFractionDigits:0},classNames:{base:"flex-1",inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 min-h-10",input:"text-sm"}}),jsx(Select,{"aria-label":"Duration unit",selectedKeys:[Y],onSelectionChange:F=>{let Re=Array.from(F)[0];Re&&R(Re);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:al.map(F=>jsx(SelectItem,{children:I(ll[F])},F))})]})]})]}),jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxs("button",{type:"button",onClick:()=>ve(F=>!F),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{children:I("predict.trade.odds")}),jsx(ChevronDownIcon,{className:cn$1("h-3.5 w-3.5 transition-transform",se&&"rotate-180")})]}),Ze!=null&&jsxs("span",{className:"text-foreground font-medium tabular-nums",children:[Ze,"% chance"]})]}),se&&jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:"Total Size"}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?`$${u.toFixed(2)}`:"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:"No. of Contracts"}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(l)&&l>0?parseFloat(l.toFixed(2)):"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:"Payout"}),jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?`$${p.toFixed(2)}`:"\u2013"})]}),jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{children:"Est. Profit"}),jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(a)&&a>0&&c>0?`+$${c.toFixed(2)}`:"\u2013"})]})]})]}),jsx(Button,{color:ze,fullWidth:true,radius:"lg",size:"lg",isDisabled:!at||h,isLoading:h,onPress:Ir,children:Rr})]}),jsx(go,{isOpen:he.isOpen,onClose:he.onClose,kycUrl:v})]})}function ar({event:e,market:t,variant:r,initialSide:o,initialOutcome:n,chain:s}){let{outcome:a,side:i,orderType:l,quantity:c,limitPrice:p,shares:u,estimatedCost:m,potentialPayout:d,potentialProfit:f,usdcBalance:g,yesTokenBalance:h,noTokenBalance:x,isBalanceLoading:w,isSubmitting:b,validation:L,supportsLimitOrder:v,kycRequired:T,kycUrl:y,expirationEnabled:X,expirationPreset:Y,customDuration:K,customDurationUnit:oe,setOutcome:D,setSide:$,setOrderType:H,setQuantity:fe,setLimitPrice:ge,setExpirationEnabled:C,setExpirationPreset:R,setCustomDuration:W,setCustomDurationUnit:I,submit:se}=fo({market:t,initialSide:o,initialOutcome:n}),ve=useAuthCallback(se),he=useMemo(()=>e?so(e):void 0,[e]),Ze=useMemo(()=>io(t),[t]);return jsx(So,{event:he,market:Ze,variant:r,outcome:a,side:i,orderType:l,quantity:c,limitPrice:p,shares:u,estimatedCost:m,potentialPayout:d,potentialProfit:f,usdcBalance:g,yesTokenBalance:h,noTokenBalance:x,isBalanceLoading:w,isSubmitting:b,isValid:L.isValid,validationErrors:L.errors,supportsLimitOrder:v,kycRequired:T,kycUrl:y,expirationEnabled:X,expirationPreset:Y,customDuration:K,customDurationUnit:oe,onOutcomeChange:D,onSideChange:$,onOrderTypeChange:H,onQuantityChange:fe,onLimitPriceChange:ge,onExpirationEnabledChange:C,onExpirationPresetChange:R,onCustomDurationChange:W,onCustomDurationUnitChange:I,onSubmit:ve})}var Ot="predict-trade";function lr({id:e=Ot}){return jsx(AsyncModal,{id:e,children:t=>jsx(hl,{...t})})}function hl({params:e,isOpen:t,onOpenChange:r}){let{t:o}=useTranslation(),{isMobile:n}=useScreen();return e?jsx(StyledModal,{isOpen:t,onOpenChange:r,size:n?"lg":"md",backdrop:"blur",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:o("predict.trade.action")}),jsx("button",{type:"button",onClick:()=>r(false),className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsx("div",{className:"px-5 pb-5",children:jsx(ar,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,initialSide:e.initialSide??"buy",chain:e.chain,variant:"flat"})})]})})}):null}var Qr={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function Xr(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function No({isOpen:e,onClose:t,value:r,onChange:o}){let{t:n}=useTranslation(),[s,a]=useState(r),i=useCallback(h=>{h?a(r):t();},[r,t]),l=useCallback(()=>{a(Qr);},[]),c=useCallback(()=>{o(s),t();},[s,o,t]),p=useCallback((h,x)=>{a(w=>({...w,[h]:x}));},[]),u=useMemo(()=>Xr(s),[s]),m=useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"polymarket",label:n("predict.platform.polymarket")},{value:"kalshi",label:n("predict.platform.kalshi")}],[n]),d=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]),f=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]),g=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 jsx(StyledModal,{isOpen:e,onOpenChange:i,size:"md",backdrop:"blur",scrollBehavior:"inside",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:n("predict.filter.title")}),jsx(kl,{onClick:()=>i(false)})]}),jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[jsx(dr,{label:n("predict.filter.platform"),children:jsx(ur,{options:m,selected:s.source,onSelect:h=>p("source",h)})}),jsx(dr,{label:n("predict.filter.timeRemaining"),children:jsx(ur,{options:d,selected:s.timeRemaining,onSelect:h=>p("timeRemaining",h)})}),jsx(dr,{label:n("predict.filter.minVolume"),children:jsx(ur,{options:f,selected:s.minVolume,onSelect:h=>p("minVolume",h)})}),jsx(dr,{label:n("predict.filter.minLiquidity"),children:jsx(ur,{options:g,selected:s.minLiquidity,onSelect:h=>p("minLiquidity",h)})})]}),jsxs("div",{className:"flex items-center gap-3 px-5 py-4",style:{borderTop:"1px solid rgba(39,39,42,0.5)"},children:[jsx("button",{type:"button",className:"inline-flex items-center justify-center py-2.5 px-5 rounded-[10px] text-zinc-400 text-sm font-medium hover:text-white transition-colors cursor-pointer",onClick:l,children:n("predict.filter.reset")}),jsxs("button",{type:"button",className:"flex-1 inline-flex items-center justify-center gap-2 py-2.5 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer",onClick:c,children:[n("predict.filter.showResults"),u>0&&jsxs("span",{style:{opacity:.7},children:["(",u,")"]})]})]})]})})})}function dr({label:e,children:t}){return jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[jsx("span",{style:{fontSize:11,fontWeight:500,color:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:e}),t]})}function kl({onClick:e}){return jsx("button",{type:"button",onClick:e,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}function ur({options:e,selected:t,onSelect:r,allowDeselect:o=true}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:e.map(n=>{let s=t===n.value;return jsx("button",{type:"button",onClick:()=>{r(s&&o?void 0:n.value);},style:{flexShrink:0,borderRadius:10,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer",transition:"all 0.15s",border:s?"1px solid rgba(199,255,46,0.3)":"1px solid rgba(63,63,70,0.5)",background:s?"rgba(199,255,46,0.08)":"rgba(39,39,42,0.4)",color:s?"#c7ff2e":"#a1a1aa"},onMouseEnter:a=>{s||(a.currentTarget.style.background="rgba(39,39,42,0.8)",a.currentTarget.style.color="#fff");},onMouseLeave:a=>{s||(a.currentTarget.style.background="rgba(39,39,42,0.4)",a.currentTarget.style.color="#a1a1aa");},children:n.label},n.value??"__all")})})}var To={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},Co={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},Ll=["start_time","volume","liquidity","ending_soon"],Mo={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},_l={position:"absolute",left:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function Lo({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:o,onFilterPress:n,filterCount:s=0,className:a}){let{t:i}=useTranslation(),[l,c]=useState(false),p=useRef(null),u=useCallback(d=>{p.current&&!p.current.contains(d.target)&&c(false);},[]);useEffect(()=>(document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)),[u]),useEffect(()=>{if(!l)return;let d=f=>{f.key==="Escape"&&c(false);};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[l]);let m=Eo[e];return jsxs("div",{className:a,style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:p,style:{position:"relative"},children:[jsxs("button",{type:"button",style:Mo,onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>c(d=>!d),children:[jsx(Rl,{}),jsx(m,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:i(Co[e])}),jsx(Ol,{open:l})]}),l&&jsx("div",{style:{..._l,width:224,padding:4},children:Ll.map(d=>{let f=Eo[d],g=e===d;return jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:12,padding:"10px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",transition:"all 0.15s",background:g?"rgba(199,255,46,0.08)":"transparent",color:g?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:h=>{g||(h.currentTarget.style.background="rgba(39,39,42,0.5)",h.currentTarget.style.color="#fff");},onMouseLeave:h=>{g||(h.currentTarget.style.background="transparent",h.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===d?o(!r):t(d),c(false);},children:[jsx(f,{className:"size-4 shrink-0",style:{color:g?"#c7ff2e":"#71717a"}}),jsx("span",{style:{flex:1,fontWeight:500},children:i(Co[d])}),g&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},d)})})]}),jsx("button",{type:"button",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:14},onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)",d.currentTarget.style.color="#fff";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)",d.currentTarget.style.color="#a1a1aa";},onClick:()=>o(!r),children:r?"\u2191":"\u2193"}),jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",style:Mo,onMouseEnter:d=>{d.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:d=>{d.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:n,children:[jsx(Il,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:i("predict.filter.title")})]}),s>0&&jsx("span",{style:{position:"absolute",top:-4,right:-4,minWidth:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,background:"#c7ff2e",color:"#000",fontSize:10,fontWeight:600,padding:"0 4px"},children:s})]})]})}var Eo={start_time:CalendarIcon,volume:ChartLineIcon,liquidity:DropletIcon,ending_soon:TimerIcon};function Rl(){return jsxs("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"m21 16-4 4-4-4"}),jsx("path",{d:"M17 20V4"}),jsx("path",{d:"m3 8 4-4 4 4"}),jsx("path",{d:"M7 4v16"})]})}function Il(){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})})}function Ol({open:e}){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#71717a",transition:"transform 0.15s",transform:e?"rotate(180deg)":void 0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"m6 9 6 6 6-6"})})}function Io(e={}){let t=useMemo(()=>resolveEventsParams(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets,e.minVolume,e.minLiquidity,e.timeRemaining]),{data:r,isLoading:o,isFetching:n,isFetchingNextPage:s,isError:a,error:i,hasNextPage:l,fetchNextPage:c,refetch:p}=useInfiniteEvents(t),u=useMemo(()=>r?.pages.flatMap(f=>f.items).filter(f=>f!=null)??[],[r]),m=useCallback(()=>{c();},[c]),d=useCallback(()=>{p();},[p]);return {data:u,isLoading:o,isFetching:n&&!s,isFetchingMore:s,isError:a,error:i??null,hasMore:l??false,fetchMore:m,refetch:d}}var Oo="@keyframes evtShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}@media(max-width:1279px){.evt-skel-grid{grid-template-columns:repeat(3,1fr)!important}}@media(max-width:1023px){.evt-skel-grid{grid-template-columns:repeat(2,1fr)!important}}@media(max-width:767px){.evt-skel-grid{grid-template-columns:1fr!important}}";function Zr({count:e=6}){return jsxs(Fragment,{children:[jsx("style",{children:Oo}),jsx("div",{className:"evt-skel-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",width:"100%"},children:Array.from({length:e}).map((t,r)=>jsx(Fl,{index:r},r))})]})}function Fl({index:e}){let r={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:`evtShimmer 1.8s ease-in-out infinite ${e*120}ms`,borderRadius:6},o=e%3===0?"85%":e%3===1?"70%":"60%";return jsx("div",{style:{padding:8},children:jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 14px 8px"},children:[jsx("div",{style:{...r,width:36,height:36,borderRadius:10,flexShrink:0}}),jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[jsx("div",{style:{...r,height:12,width:o}}),jsx("div",{style:{...r,height:10,width:"40%"}})]})]}),jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"4px 14px 14px",flex:1},children:[0,1,2].map(n=>jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[jsx("div",{style:{...r,height:11,width:n===0?"55%":n===1?"45%":"35%"}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("div",{style:{...r,height:11,width:32}}),jsx("div",{style:{...r,height:28,width:80,borderRadius:8}})]})]},n))}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsx("div",{style:{...r,height:10,width:56}}),jsx("div",{style:{...r,height:10,width:72}})]})]})})}function Rg({count:e=48}){let t={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:"evtShimmer 1.8s ease-in-out infinite",borderRadius:6};return jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",maxWidth:1680,margin:"0 auto",gap:12},children:[jsx("style",{children:Oo}),jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:[48,64,48,56,72,56].map((r,o)=>jsx("div",{style:{...t,height:24,width:r}},o))}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,minHeight:36},children:[jsx("div",{style:{...t,height:32,width:120,borderRadius:10}}),jsx("div",{style:{...t,height:32,width:32,borderRadius:10}}),jsx("div",{style:{...t,height:32,width:80,borderRadius:10}})]}),jsx("div",{style:{flex:1,minHeight:0},children:jsx(Zr,{count:e})})]})}var Ao=3,jl={polymarket:{border:"rgba(80,162,255,0.4)",shadow:"0 2px 18px rgba(80,162,255,0.45)"},kalshi:{border:"rgba(0,212,146,0.4)",shadow:"0 2px 18px rgba(0,212,146,0.45)"}},Gl={border:"hsl(var(--heroui-primary) / 0.4)",shadow:"0 2px 18px hsl(var(--heroui-primary) / 0.45)"},en={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},$o={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},Yl={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},Dt=[{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 Do(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 ql(e){let t=e.outcomes?.map(a=>a.label?.toLowerCase().trim()??"")??[];if(t.some(a=>a==="up")&&t.some(a=>a==="down"))return [en,Yl];if(t.some(a=>a==="yes")&&t.some(a=>a==="no"))return [en,$o];let r=t[0]??"",o=t[1]??"",n=Do(r)%Dt.length,s=Do(o)%Dt.length;return s===n&&(s=(s+1)%Dt.length),[Dt[n],Dt[s]]}function Ql(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function zo(e){let t=Ql(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function Wo(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function Fo(e){let t=e.outcomes?.[0],r=t?.best_ask??t?.price??0;return parseFloat((r*100).toFixed(2)).toString()}function Ho(e){let t=e.outcomes?.[1];if(t){let n=t.best_ask??t.price??0;return parseFloat((n*100).toFixed(2)).toString()}let r=e.outcomes?.[0],o=r?.best_ask??r?.price??0;return parseFloat(((1-o)*100).toFixed(2)).toString()}function Xl(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 Zl=`
|
|
2
2
|
.badge-shine { position: relative; overflow: hidden; }
|
|
3
3
|
.badge-shine::after {
|
|
4
4
|
content: "";
|
|
@@ -16,13 +16,13 @@ import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMem
|
|
|
16
16
|
60% { transform: translate(200%); }
|
|
17
17
|
100% { transform: translate(200%); }
|
|
18
18
|
}
|
|
19
|
-
`;function zo({event:e,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n,onHover:s}){let[i,a]=useState(null),l=e.markets??[],p=useMemo(()=>l.length>2?[...l].sort((v,L)=>(L.outcomes?.[0]?.price??0)-(v.outcomes?.[0]?.price??0)):l,[l]).filter(v=>v.status==="open"),u=p.length===1,m=p.slice(0,Io),d=p.length-Io,f=useMemo(()=>`$${Math.round(e.volume??0).toLocaleString("en-US")}`,[e.volume]),g=i?p.find(v=>v.slug===i)??null:null,h=!!g||u,x=()=>{h||o?.(e);},P=v=>{v.stopPropagation(),g&&(v.preventDefault(),a(null));},b=v=>{v.stopPropagation(),t||(v.preventDefault(),o?.(e));},R=u?jsx(ic,{event:e,formattedVolume:f,href:t,LinkComponent:r,onSelect:o}):g?jsx(cc,{onCollapse:()=>a(null)}):jsx(nc,{moreCount:d,formattedVolume:f,source:e.source,href:t,LinkComponent:r,onShowMore:b});return jsxs("div",{className:"group",style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:h?void 0:"pointer"},onMouseEnter:v=>{let L=v.currentTarget;L.style.borderColor="rgba(63,63,70,0.6)",L.style.boxShadow="0 8px 24px -4px hsla(var(--heroui-primary) / 0.12)",s?.(e);},onMouseLeave:v=>{let L=v.currentTarget;L.style.borderColor="rgba(39,39,42,0.6)",L.style.boxShadow="none";},onClick:x,children:[jsx("style",{children:ql}),jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,padding:"14px 14px 12px",gap:8},children:[jsx(Ql,{event:e,href:t,LinkComponent:r,onClick:P,isExpanded:h}),jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:u?jsx(ac,{market:p[0],event:e,onSelectOutcome:n}):g?jsx(lc,{market:g,event:e,onCollapse:()=>a(null),onSelectOutcome:n}):jsx(rc,{displayedMarkets:m,onMarketClick:v=>a(v.slug)})})]}),jsx(oc,{children:R})]})}function Ql({event:e,href:t,LinkComponent:r,onClick:o,isExpanded:n}){let s=e.start_at?Yl(e.start_at):null;return jsxs(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:[jsx(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"}}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsx("p",{className:cn$1("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&&jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",s]})]}),jsx(Zl,{event:e})]})}function Xl(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,i=900*1e3;if(n>0&&n<=i){let a=n<=s?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:n<=s?"5m":"15m",color:a});}}return o&&t.push({kind:"live"}),t.slice(0,2)}function Zl({event:e}){let t=useMemo(()=>Xl(e),[e]);return t.length===0?null:jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:t.map((r,o)=>{switch(r.kind){case "live":return jsx(Jl,{},o);case "crypto-short":return jsx(ec,{label:r.label,color:r.color},o);case "closed":return jsx(tc,{},o)}})})}function Jl(){let{t:e}=useTranslation();return 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:[jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-current"}),e("predict.event.status.live")]})}function ec({label:e,color:t}){return 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:[jsx(TimerIcon,{className:"size-3 shrink-0"}),e]})}function tc(){let{t:e}=useTranslation();return 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 rc({displayedMarkets:e,onMarketClick:t}){return e.length>0?jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(r=>{let o=Bo(r);return 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:n=>{n.stopPropagation(),t(r);},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:r.outcomes?.[0]?.label??r.question}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:$o(o)}),jsx(sc,{})]})]},r.id??`${r.source}-${r.slug}`)})}):null}function nc({moreCount:e,formattedVolume:t,source:r,href:o,LinkComponent:n,onShowMore:s}){let{t:i}=useTranslation();return jsxs(Fragment,{children:[e>0?jsxs(Linkable,{href:o,LinkComponent:n,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:s,children:[i("predict.event.showMore"),jsx(Uo,{className:"h-3 w-3"})]}):jsx("div",{}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",i("predict.event.volume"),jsx(Ko,{source:r})]})]})}function oc({children:e}){return jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px",marginTop:"auto"},children:e})}function Fo({bgColor:e,textColor:t,shadowColor:r,onClick:o,children:n}){return 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:o,children:n})}function Wo({market:e,event:t,onSelectOutcome:r,dynamicColors:o=false,labelFormat:n="action"}){let{t:s}=useTranslation(),[i,a]=o?jl(e):[en,Ho],l=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",c=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",p=n==="label"&&l===c?"action":n,u=p==="label"?`${e.outcomes?.[0]?.label??"Yes"} ${Ao(e)}\xA2`:s("predict.market.action.yes",{price:Ao(e)}),m=p==="label"?`${e.outcomes?.[1]?.label??"No"} ${Do(e)}\xA2`:s("predict.market.action.no",{price:Do(e)});return jsxs("div",{className:"flex gap-2",children:[jsx(Fo,{bgColor:i.bg,textColor:i.text,shadowColor:i.shadow,onClick:d=>{d.stopPropagation(),r?.(t,e,"yes");},children:u}),jsx(Fo,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:d=>{d.stopPropagation(),r?.(t,e,"no");},children:m})]})}function sc(){let{t:e}=useTranslation();return 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:[jsx("span",{className:"text-primary",children:e("predict.market.yes")}),jsx("span",{className:"text-neutral-400",children:"/"}),jsx("span",{className:"text-secondary",children:e("predict.market.no")})]})}function ac({market:e,event:t,onSelectOutcome:r}){return jsx("div",{style:{flex:1},children:jsx(Wo,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label"})})}function ic({event:e,formattedVolume:t,href:r,LinkComponent:o,onSelect:n}){let{t:s}=useTranslation();return jsxs(Fragment,{children:[jsxs(Linkable,{href:r,LinkComponent:o,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:a=>{a.stopPropagation(),r||(a.preventDefault(),n?.(e));},children:[s("predict.event.viewEvent"),jsx(Uo,{className:"h-3 w-3"})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",s("predict.event.volume"),jsx(Ko,{source:e.source})]})]})}function lc({market:e,event:t,onCollapse:r,onSelectOutcome:o}){let n=Bo(e);return jsxs("div",{style:{flex:1},children:[jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:s=>{s.stopPropagation(),r();},children:[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}),jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:$o(n)}),jsx(ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsx("div",{style:{marginTop:12},children:jsx(Wo,{market:e,event:t,onSelectOutcome:o,labelFormat:"action"})})]})}function cc({onCollapse:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsxs("button",{type:"button",className:"flex items-center gap-x-1 text-[10px] font-normal transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",style:{color:"#71717a"},onClick:r=>{r.stopPropagation(),e();},children:[jsx(dc,{className:"h-3 w-3"}),t("predict.event.back")]}),jsx("div",{})]})}function Uo({className:e}){return jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsx("path",{d:"M4.5 2.5L8 6l-3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function dc({className:e}){return jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsx("path",{d:"M7.5 2.5L4 6l3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ko({source:e}){return jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsx(PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsx(KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var hc=768,jo=1024,xc=1280,vc=8,bc=224,yc=304,kc=114;function Sc(e){return e>=xc?4:e>=jo?3:e>=hc?2:1}function wc(e){return e>=jo?yc:bc}function Go({events:e,hasMore:t=false,onFetchMore:r,onSelect:o,onSelectOutcome:n,getEventHref:s,LinkComponent:i,onHover:a}){let l=useRef(null),c=useRef(null),{width:p=0,height:u=0}=useResizeObserver({ref:l}),m=Sc(p),d=wc(p),f=Math.ceil(e.length/m)||0,g=!t&&e.length>0,h=f+(t?1:0)+(g?1:0),x=useCallback(v=>v<f,[f]),P=useCallback(async()=>{r?.();},[r]),b=useInfiniteLoader({isRowLoaded:x,loadMoreRows:P,rowCount:h,threshold:3}),R=useCallback(()=>{c.current?.scrollToRow({index:0,behavior:"smooth"});},[]);return jsxs("div",{ref:l,className:"@container w-full h-full",children:[jsx("style",{children:"@keyframes eventCardEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}"}),u>0&&jsx(List,{listRef:c,className:"no-scrollbar",style:{height:u},onRowsRendered:b,rowComponent:Nc,rowCount:h,rowHeight:v=>g&&v===h-1?kc:(d),rowProps:{events:e,columnCount:m,dataRowCount:f,showEndOfList:g,totalRowCount:h,onSelect:o,onSelectOutcome:n,getEventHref:s,LinkComponent:i,onHover:a,onScrollToTop:R}})]})}function Nc({index:e,style:t,events:r,columnCount:o,dataRowCount:n,showEndOfList:s,totalRowCount:i,onSelect:a,onSelectOutcome:l,getEventHref:c,LinkComponent:p,onHover:u,onScrollToTop:m}){if(s&&e===i-1)return jsx("div",{style:t,children:jsx(Pc,{onScrollToTop:m})});if(e>=n)return jsx("div",{style:t,className:"flex justify-center items-start pt-4",children:jsx(Spinner,{size:"sm"})});let d=e*o,f=r.slice(d,d+o),g=o-f.length;return jsx("div",{style:t,children:jsxs("div",{className:"flex w-full h-full",children:[f.map((h,x)=>h==null?null:jsx("div",{className:"flex-1 min-w-0 flex",style:{padding:vc,animation:`eventCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${(d+x)*35}ms both`},children:jsx(zo,{event:h,href:c?.(h),LinkComponent:p,onSelect:a,onSelectOutcome:l,onHover:u})},`${d+x}-${h.source}-${h.slug}`)),g>0&&Array.from({length:g}).map((h,x)=>jsx("div",{style:{flex:1,minWidth:0}},`spacer-${x}`))]})})}function Pc({onScrollToTop:e}){let{t}=useTranslation();return jsxs("div",{className:"flex w-full flex-col items-center justify-center gap-y-4 py-6",children:[jsxs("div",{className:"flex w-full items-center justify-center gap-x-4",children:[jsx("div",{className:"h-px w-16 bg-neutral-700"}),jsx("span",{className:"text-xs font-medium text-neutral-500",children:t("predict.event.endOfList")}),jsx("div",{className:"h-px w-16 bg-neutral-700"})]}),jsxs("button",{type:"button",className:"flex cursor-pointer items-center gap-x-1 text-xs font-medium text-neutral-400",onClick:e,children:[jsx("span",{className:"iconify size-4 ph--arrow-up-bold"}),jsx("span",{children:t("predict.event.backToTop")})]})]})}function qo({tagSlugSelection:e,limit:t=48,status:r,sort_by:o,sort_asc:n,source:s,with_markets:i,timeRemaining:a,minVolume:l,minLiquidity:c,onSelect:p,onSelectOutcome:u,getEventHref:m,LinkComponent:d,onHover:f}){let{data:g,hasMore:h,fetchMore:x,isFetching:P}=Ro({tagSlugSelection:e,limit:t,status:r,sort_by:o,sort_asc:n,source:s,with_markets:i,timeRemaining:a,minVolume:l,minLiquidity:c});return P?jsx(Zr,{count:48}):jsx(Go,{events:g,hasMore:h,onFetchMore:x,onSelect:p,onSelectOutcome:u,getEventHref:m,LinkComponent:d,onHover:f})}function s0({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:o,onHover:n}){let[s,i]=useState({categorySlug:null,tagSlug:null}),[a,l]=useState(Qr),{isOpen:c,onOpen:p,onClose:u}=useDisclosure(),{onOpen:m}=useAsyncModal(At),d=useCallback((v,L,y)=>{t?.(v,L,y),m({params:{event:v,market:L,initialOutcome:y}});},[t,m]),f=useCallback(v=>{i(v);},[]),g=useCallback(v=>{l(L=>({...L,sortPreset:v}));},[]),h=useCallback(v=>{l(L=>({...L,sortAsc:v}));},[]),x=useCallback(v=>{l(v);},[]),P=useMemo(()=>Eo[a.sortPreset].sort_by,[a.sortPreset]),b=useMemo(()=>Xr(a),[a]),R=useMemo(()=>jsx(To,{sortPreset:a.sortPreset,onSortChange:g,sortAsc:a.sortAsc,onSortAscChange:h,onFilterPress:p,filterCount:b}),[a.sortPreset,a.sortAsc,b,g,h,p]);return jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsx(no,{onSelect:f,trailing:R}),jsx(wo,{isOpen:c,onClose:u,value:a,onChange:x}),jsx("div",{className:"min-h-0 flex-1",children:jsx(qo,{tagSlugSelection:s,sort_by:P,sort_asc:a.sortAsc,source:a.source,timeRemaining:a.timeRemaining,minVolume:a.minVolume,minLiquidity:a.minLiquidity,onSelect:e,onSelectOutcome:d,getEventHref:r,LinkComponent:o,onHover:n})}),jsx(cr,{})]})}var ln=40,gr=36,Wt=480,cn=Wt-gr;function Jo({event:e,walletAddress:t,onCancelOrder:r}){let{t:o}=useTranslation(),[n,s]=useState("positions"),i=useMemo(()=>e.markets?.map(u=>u.slug)??[],[e.markets]),{data:a}=usePositions({source:e.source,user:t??""}),l=useMemo(()=>!a?.positions||!t?0:i.length===0?a.positions.length:a.positions.filter(u=>u.market&&i.includes(u.market.slug)).length,[a?.positions,i,t]),p=[{key:"positions",label:l>0?`${o("predict.positions.title")} (${l})`:o("predict.positions.title")},{key:"orders",label:o("predict.openOrders.title")},{key:"trades",label:o("predict.tradeHistory.title")}];return jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:p.map(u=>jsx("button",{type:"button",onClick:()=>s(u.key),className:cn$1("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?jsxs("div",{style:{height:Wt},children:[n==="positions"&&jsx(Oc,{source:e.source,walletAddress:t,marketSlugs:i}),n==="orders"&&jsx(Dc,{source:e.source,walletAddress:t,marketSlugs:i,onCancelOrder:r}),n==="trades"&&jsx(Bc,{source:e.source,walletAddress:t})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:Wt},children:o("predict.trade.connectWallet")})]})}function Oc({source:e,walletAddress:t,marketSlugs:r}){let{t:o}=useTranslation(),{data:n,isLoading:s}=usePositions({source:e,user:t}),i=useMemo(()=>n?.positions?r.length===0?n.positions:n.positions.filter(a=>a.market&&r.includes(a.market.slug)):[],[n?.positions,r]);return s?jsx(un,{}):i.length===0?jsx(dn,{message:o("predict.positions.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:gr},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2 whitespace-nowrap",children:o("predict.positions.event")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.value")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.markPrice")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.estSettlement")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:cn},rowComponent:Ac,rowCount:i.length,rowHeight:ln,rowProps:{positions:i,closeLabel:o("predict.positions.close")}})]})}function Ac({index:e,style:t,positions:r,closeLabel:o}){let n=r[e];if(!n)return null;let s=n.pnl??0,i=n.pnl_percent??0,a=n.avg_price??0,l=n.current_price??0,c=s>0?"text-success":s<0?"text-danger":"text-foreground",p=s>0?"+":"",u=n.market?.outcomes?.[0]?.label??n.market?.question??"\u2014",m=n.side,d=n.size,f=n.size*l,g=n.market?.end_at?Wc(n.market.end_at):"\u2014";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-xs lg:text-sm",children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("div",{className:"flex flex-col gap-y-0.5",children:[jsx("span",{className:"text-foreground truncate font-medium",children:u}),jsx("span",{className:cn$1("text-[10px] font-medium",m.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:m})]})}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:n.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",f.toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:mr(a)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:mr(l)}),jsxs("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",c),children:[p,"$",Math.abs(s).toFixed(2),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",p,i.toFixed(1),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",d.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:g}),jsx("div",{className:"w-16 shrink-0 text-right",children: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:o})})]})}function Dc({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:o}){let{t:n}=useTranslation(),{data:s,isLoading:i,fetchNextPage:a,hasNextPage:l}=useInfiniteOrders({source:e,wallet_address:t}),c=useCancelOrder(),p=useMemo(()=>{let x=s?.pages?.flatMap(R=>R.items)??[],P=new Set(["live","open","submitted","pending"]),b=x.filter(R=>P.has(R.status));return r.length>0&&(b=b.filter(R=>R.market_id&&r.includes(R.market_id))),b},[s?.pages,r]),u=useCallback(x=>{o?o(x.id):c.mutate({source:x.source,id:x.id});},[o,c]),m=p.length,d=m+(l?1:0),f=useCallback(x=>x<m,[m]),g=useCallback(async()=>{await a();},[a]),h=useInfiniteLoader({isRowLoaded:f,loadMoreRows:g,rowCount:d,threshold:5});return i?jsx(un,{}):p.length===0&&!l?jsx(dn,{message:n("predict.openOrders.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:gr},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:n("predict.openOrders.side")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.openOrders.outcome")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.openOrders.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.openOrders.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.openOrders.filled")}),jsx("div",{className:"w-20 shrink-0 pr-2",children:n("predict.openOrders.status")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:cn},onRowsRendered:h,rowComponent:Fc,rowCount:d,rowHeight:ln,rowProps:{orders:p,itemCount:m,onCancel:u,isCancelling:c.isPending,cancelLabel:n("predict.openOrders.cancel")}})]})}function Fc({index:e,style:t,orders:r,itemCount:o,onCancel:n,isCancelling:s,cancelLabel:i}){if(e>=o)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let a=r[e];if(!a)return null;let l=a.side==="BUY";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn$1("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",l?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:a.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:a.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:a.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:a.price?mr(parseFloat(a.price)):"\u2014"}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[a.size_matched??"0","/",a.original_size??"\u2014"]}),jsx("div",{className:"w-20 shrink-0 pr-2",children:jsx(Hc,{status:a.status})}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",onClick:()=>n(a),disabled:s,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:s?jsx(Spinner,{size:"sm"}):i})})]})}function Hc({status:e}){return jsx("span",{className:cn$1("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 Bc({source:e,walletAddress:t}){let{t:r}=useTranslation(),{data:o,isLoading:n,fetchNextPage:s,hasNextPage:i}=useInfiniteTrades({source:e,wallet:t,limit:50}),a=useMemo(()=>o?.pages?.flatMap(d=>d.items)??[],[o?.pages]),l=a.length,c=l+(i?1:0),p=useCallback(d=>d<l,[l]),u=useCallback(async()=>{await s();},[s]),m=useInfiniteLoader({isRowLoaded:p,loadMoreRows:u,rowCount:c,threshold:5});return n?jsx(un,{}):a.length===0&&!i?jsx(dn,{message:r("predict.tradeHistory.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:gr},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:r("predict.tradeHistory.side")}),jsx("div",{className:"flex-1 pr-2",children:r("predict.tradeHistory.outcome")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.qty")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.total")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:r("predict.tradeHistory.time")})]}),jsx(List,{style:{height:cn},onRowsRendered:m,rowComponent:$c,rowCount:c,rowHeight:ln,rowProps:{trades:a,itemCount:l}})]})}function $c({index:e,style:t,trades:r,itemCount:o}){if(e>=o)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let n=r[e];if(!n)return null;let s=n.side?.toUpperCase()==="BUY",i=zc(n.timestamp),a=n.price??0,l=n.usd_size??0;return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn$1("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:n.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:n.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:mr(a)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:n.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",l.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:i})]})}function dn({message:e}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:Wt},children:e})}function un(){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:Wt},children:Array.from({length:6}).map((e,t)=>jsx(Skeleton,{className:"h-8 w-full rounded-md"},t))})}function mr(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function zc(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 Wc(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}function Ut({marketCount:e=4,showBack:t}){return jsxs("div",{className:"flex w-full flex-col gap-4 animate-pulse lg:gap-6",children:[t&&jsx("div",{className:"h-5"}),jsxs("div",{className:"flex items-center gap-x-2 h-16 lg:h-20 lg:gap-x-4",children:[jsx(Skeleton,{className:"size-16 shrink-0 rounded-lg lg:size-20"}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(Skeleton,{className:"h-3.5 w-12 rounded"}),jsx(Skeleton,{className:"h-3.5 w-10 rounded"}),jsx(Skeleton,{className:"h-3.5 w-10 rounded"})]}),jsx(Skeleton,{className:"h-5 w-full max-w-sm rounded lg:h-6"})]})]}),jsx(Skeleton,{className:"h-4 w-48 rounded"}),jsxs("div",{className:"flex flex-col gap-3",children:[jsxs("div",{className:"flex items-center gap-4",children:[jsx(Skeleton,{className:"h-4 w-24 rounded"}),jsx(Skeleton,{className:"h-4 w-20 rounded"})]}),jsx(Skeleton,{className:"h-[300px] w-full rounded-xl"}),jsxs("div",{className:"flex items-center justify-between",children:[jsx(Skeleton,{className:"h-4 w-20 rounded"}),jsxs("div",{className:"flex items-center gap-2",children:[jsx(Skeleton,{className:"h-7 w-[200px] rounded-lg"}),jsx(Skeleton,{className:"h-7 w-28 rounded-lg"})]})]})]}),jsxs("div",{className:"flex flex-col",children:[jsxs("div",{className:"flex items-center py-2",children:[jsx("div",{className:"flex-1"}),jsx(Skeleton,{className:"h-3.5 w-14 rounded"}),jsx("div",{className:"flex-1"})]}),Array.from({length:e}).map((r,o)=>jsxs("div",{className:"flex items-center gap-x-2 border-b border-border py-2.5 lg:gap-x-3",children:[jsx(Skeleton,{className:"size-5 shrink-0 rounded-lg lg:size-8"}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[jsx(Skeleton,{className:"h-3.5 w-32 rounded lg:h-4 lg:w-48"}),jsx(Skeleton,{className:"h-2.5 w-16 rounded"})]}),jsx(Skeleton,{className:"h-4 w-10 rounded"}),jsxs("div",{className:"flex items-center gap-2",children:[jsx(Skeleton,{className:"h-8 w-16 rounded-lg lg:w-24"}),jsx(Skeleton,{className:"h-8 w-16 rounded-lg lg:w-24"})]})]},o))]}),jsxs("div",{className:"flex flex-col gap-2",children:[jsx(Skeleton,{className:"h-4 w-16 rounded"}),jsx(Skeleton,{className:"h-3.5 w-full rounded"}),jsx(Skeleton,{className:"h-3.5 w-4/5 rounded"}),jsx(Skeleton,{className:"h-3.5 w-3/5 rounded"})]})]})}function es(){return jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-border p-4 animate-pulse",children:[jsx(Skeleton,{className:"h-10 w-full rounded-lg"}),jsx(Skeleton,{className:"h-24 w-full rounded-lg"}),jsx(Skeleton,{className:"h-10 w-full rounded-lg"})]})}var os="var(--color-bullish)",ss="var(--color-bearish)";function Kt(e){let t=Math.abs(e);return t>=1e9?`${parseFloat((e/1e9).toFixed(2))}B`:t>=1e6?`${parseFloat((e/1e6).toFixed(2))}M`:t>=1e3?`${parseFloat((e/1e3).toFixed(2))}K`:e.toLocaleString()}function Vc(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function jc(e,t){let r=new Float64Array(101),o=new Float64Array(101);for(let d of e){let f=Math.round(d.price*100);f>=0&&f<=100&&(r[f]+=d.quantity);}for(let d of t){let f=Math.round(d.price*100);f>=0&&f<=100&&(o[f]+=d.quantity);}let n=0,s=0,i=new Float64Array(101),a=new Float64Array(101);for(let d=100;d>=0;d--)n+=r[d],s+=r[d]*d/100,i[d]=n,a[d]=s;let l=0,c=0,p=new Float64Array(101),u=new Float64Array(101);for(let d=0;d<=100;d++)l+=o[d],c+=o[d]*d/100,p[d]=l,u[d]=c;let m=Math.max(i[0]??0,p[100]??0);return Array.from({length:101},(d,f)=>{let g=i[f]>0,h=p[f]>0,x=i[f]||p[f],P=r[f]>0||o[f]>0;return {priceCents:f,displayHeight:Vc(x,m),opacity:x>0?P?1:.5:0,isBid:g,isAsk:h,bidCumTotal:i[f],askCumTotal:p[f],bidCumCost:a[f],askCumCost:u[f]}})}function Gc({info:e}){let{t}=useTranslation(),r=e.isBid?os:ss,o=e.leftPct>65?void 0:`${e.leftPct}%`,n=e.leftPct>65?`${100-e.leftPct}%`:void 0;return jsxs("div",{style:{position:"absolute",top:8,left:o,right:n,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:[jsx("div",{style:{marginBottom:4,fontWeight:600},children:t("predict.orderBook.depthToPrice",{price:e.priceCents})}),jsx("div",{style:{color:r},children:t("predict.orderBook.depthContracts",{amount:Kt(Math.round(e.cumTotal))})}),jsxs("div",{style:{color:r},children:["$",Kt(Math.round(e.cumCost))]})]})}var Yc=memo(function({slot:t,onEnter:r,onLeave:o}){let n=useRef(null),s=t.isBid||t.isAsk,i=t.isBid?os:t.isAsk?ss:void 0;return 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&&jsx("div",{ref:n,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:i,opacity:t.opacity}})})}),qc=[0,10,20,30,40,50,60,70,80,90,100];function Qc(){return 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:qc.map(e=>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 as({bids:e,asks:t}){let{t:r}=useTranslation(),o=useMemo(()=>jc(e,t),[e,t]),n=useMemo(()=>{let u=e.length>0?Math.max(...e.map(d=>d.price)):0,m=t.length>0?Math.min(...t.map(d=>d.price)):1;return Math.round((u+m)/2*100)},[e,t]),s=useMemo(()=>o.some(u=>u.isBid||u.isAsk),[o]),[i,a]=useState(null),l=useRef(null),c=useCallback((u,m)=>{l.current&&(l.current.style.filter=""),m?(m.style.filter="brightness(1.5)",l.current=m):l.current=null,u.isBid||u.isAsk?a({priceCents:u.priceCents,isBid:u.isBid,cumTotal:u.isBid?u.bidCumTotal:u.askCumTotal,cumCost:u.isBid?u.bidCumCost:u.askCumCost,leftPct:u.priceCents}):a(null);},[]),p=useCallback(()=>{l.current&&(l.current.style.filter="",l.current=null),a(null);},[]);return s?jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[n>0&&jsx("div",{style:{position:"absolute",left:`${n}%`,top:0,bottom:0,width:1,backgroundImage:"repeating-linear-gradient(to bottom, #6b7280 0, #6b7280 4px, transparent 4px, transparent 8px)",zIndex:1,pointerEvents:"none"}}),i&&jsx(Gc,{info:i}),o.map(u=>jsx(Yc,{slot:u,onEnter:c,onLeave:p},u.priceCents))]}),jsx(Qc,{})]}):jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:r("predict.orderBook.noData")})}function mn(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function is(){let{t:e}=useTranslation();return jsxs("div",{className:"flex items-center justify-center gap-x-2 h-full text-neutral text-xs",children:[jsx(Spinner,{size:"sm"}),jsx("span",{children:e("predict.orderBook.loading")})]})}function us({market:e,outcome:t="yes",onTradeAction:r}){let{t:o}=useTranslation(),[n,s]=useState("depth"),i=t==="no",a=e.source,{data:l,isLoading:c}=useOrderbook({slug:e.slug,source:a}),p=useMemo(()=>((i?l?.asks:l?.bids)??[]).map(h=>({price:i?1-h.price:h.price,quantity:h.size})),[l?.bids,l?.asks,i]),u=useMemo(()=>((i?l?.bids:l?.asks)??[]).map(h=>({price:i?1-h.price:h.price,quantity:h.size})),[l?.bids,l?.asks,i]),m=useMemo(()=>p.length>0?Math.max(...p.map(g=>g.price)):null,[p]),d=useMemo(()=>u.length>0?Math.min(...u.map(g=>g.price)):null,[u]),f=useMemo(()=>{if(m==null||d==null)return null;let g=(d-m)*100;return Math.round(g*10)/10},[m,d]);return jsxs("div",{className:"flex flex-col h-[262px]",children:[jsxs("div",{className:"flex h-9 items-center border-b border-border px-1 text-xs",children:[jsx("span",{className:"flex-1 text-left text-neutral",children:f!=null?`${o("predict.orderBook.spread")}: ${Number.isInteger(f)?`${f}\xA2`:`${f.toFixed(1)}\xA2`}`:null}),jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[m!=null&&jsxs("span",{style:{color:"var(--color-bullish)"},children:[o("predict.trade.bestBid"),": ",mn(m)]}),m!=null&&d!=null&&jsx("span",{className:"text-neutral",children:"|"}),d!=null&&jsxs("span",{style:{color:"var(--color-bearish)"},children:[o("predict.trade.bestAsk"),": ",mn(d)]})]}),jsx("div",{className:"flex flex-1 justify-end",children:jsx("button",{type:"button",title:n==="depth"?"Orderbook":"Depth chart",onClick:()=>s(g=>g==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:n==="depth"?jsx(OrderbookTableIcon,{className:"h-4 w-4"}):jsx(OrderbookDepthIcon,{className:"h-4 w-4"})})})]}),jsxs("div",{className:"flex-1 min-h-0 overflow-hidden",children:[n==="depth"&&jsx(Fragment,{children:c?jsx(is,{}):jsx(as,{bids:p,asks:u})}),n==="table"&&jsx(Fragment,{children:c?jsx(is,{}):jsx(rd,{bids:p,asks:u,bestBid:m??void 0,bestAsk:d??void 0,spread:f??void 0})})]})]})}var ls=8;function rd({bids:e,asks:t,spread:r}){let{t:o}=useTranslation(),n=useMemo(()=>[...t].sort((l,c)=>l.price-c.price).slice(0,ls).reverse(),[t]),s=useMemo(()=>[...e].sort((l,c)=>c.price-l.price).slice(0,ls),[e]),i=useMemo(()=>{let l=[...n,...s].map(c=>c.quantity);return Math.max(...l,1)},[n,s]);return n.length===0&&s.length===0?jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:o("predict.orderBook.empty")}):jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[n.map(l=>jsx(cs,{price:l.price,quantity:l.quantity,side:"ask",maxQty:i},`ask-${l.price}`)),jsx("div",{className:"flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:r!=null&&jsxs("span",{children:[o("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]})}),s.map(l=>jsx(cs,{price:l.price,quantity:l.quantity,side:"bid",maxQty:i},`bid-${l.price}`)),jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-neutral border-t border-border",children:[jsx("span",{children:o("predict.orderBook.price")}),jsx("span",{className:"text-center",children:o("predict.orderBook.contracts")}),jsx("span",{className:"text-right",children:o("predict.orderBook.total")})]})]})}function cs({price:e,quantity:t,side:r,maxQty:o}){let n=r==="ask",s=Math.min(t/o*100,100),i=n?"bg-bearish/10":"bg-bullish/10",a=n?"text-bearish":"text-bullish",l=Kt(Math.round(t)),c=Math.round(t*e),p=`$${Kt(c)}`;return jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsx("div",{className:`absolute inset-y-0 left-0 ${i} transition-[width] duration-200`,style:{width:`${s}%`}}),jsx("span",{className:`relative z-10 ${a}`,children:mn(e)}),jsx("span",{className:"relative z-10 text-foreground text-center",children:l}),jsx("span",{className:"relative z-10 text-foreground text-right",children:p})]})}var hn=class extends Component{state={error:null};static getDerivedStateFromError(t){return {error:t}}componentDidCatch(t,r){}render(){return this.state.error?jsxs("div",{style:{height:this.props.fallbackHeight??320,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:"#6b7280",fontSize:13},children:[jsx("span",{children:"Chart unavailable"}),jsx("span",{style:{fontSize:11,opacity:.7},children:this.state.error.message})]}):this.props.children}},vr=4,ps=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function fd(e,t){let r=new Date(e);return t===ChartRange.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function gd(e,t){let r=new Date(e);return t===ChartRange.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===ChartRange.ONE_WEEK?r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function ms(e){return `${(e*100).toFixed(2)}%`}var hd=[{range:ChartRange.ONE_DAY,label:"1D"},{range:ChartRange.ONE_WEEK,label:"1W"},{range:ChartRange.ONE_MONTH,label:"1M"},{range:ChartRange.ALL,label:"ALL"}];function xd({value:e,onChange:t}){return jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:hd.map(({range:r,label:o})=>{let n=r===e;return 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 vd(){let e=useRef(null),t=useRef(null),r=useCallback(n=>{let s=e.current,i=t.current;if(!s||!i)return;let a=s.getBoundingClientRect(),l=(n.clientX-a.left)/a.width*100;i.style.background=`linear-gradient(to right, transparent ${l}%, rgba(0,0,0,0.55) ${l}%)`,i.style.opacity="1";},[]),o=useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:o}}function bd({active:e,payload:t,label:r,labelMap:o,allSeries:n,range:s}){if(!e||!n?.length)return null;let i=new Map;t?.forEach(l=>i.set(l.dataKey,l));let a=n.map(l=>i.get(l.slug)??{dataKey:l.slug,value:void 0,stroke:l.color,color:l.color});return 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:[jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof r=="number"?gd(r,s):r}),a.map(l=>jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:l.stroke??l.color,flexShrink:0}}),jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:o.get(l.dataKey)??l.dataKey}),jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:l.value!=null?ms(l.value):"--"})]},l.dataKey))]})}function yd({markets:e,selectedSlugs:t,colorMap:r,onToggle:o}){let[n,s]=useState(false),i=useRef(null);useEffect(()=>{if(!n)return;function c(p){i.current&&!i.current.contains(p.target)&&s(false);}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[n]);let a=t.length>=vr,l=jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(c=>jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(c)??"#6b7280",display:"inline-block"}},c))}),jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let c=e.find(p=>p.slug===t[0]);return c?.outcomes?.[0]?.label??c?.question??"1 market"})():`${t.length} / ${e.length} markets`})]});return jsxs("div",{ref:i,style:{position:"relative",display:"inline-block",width:200},children:[jsxs("button",{onClick:()=>s(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",width:"100%",userSelect:"none"},children:[l,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:jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),n&&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:[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 ",vr," markets"]}),e.map((c,p)=>{let u=t.includes(c.slug),m=!u&&a,d=u&&t.length===1,f=r.get(c.slug)??"#6b7280",g=c.outcomes.find(x=>x.label.toLowerCase()==="yes")??c.outcomes[0],h=g?.price!=null?`${Math.round(g.price*100)}%`:null;return jsxs("button",{onClick:()=>{d||m||o(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:m||d?"not-allowed":"pointer",opacity:m?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:x=>{!m&&!d&&(x.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:x=>{x.currentTarget.style.background=u?"rgba(255,255,255,0.05)":"transparent";},children:[jsx("span",{style:{width:16,height:16,borderRadius:4,border:u?`2px solid ${f}`:"2px solid rgba(255,255,255,0.2)",background:u?`${f}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:u&&jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:f,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:f,flexShrink:0}}),jsx("span",{style:{color:u?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.outcomes?.[0]?.label??c.question}),h&&jsx("span",{style:{color:f,fontWeight:700,fontSize:12,flexShrink:0},children:h})]},c.id??`${p}-${c.slug}`)})]})]})}function kd({series:e,colorMap:t,displayValues:r}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 24px",padding:"0 2px"},children:e.map(o=>{let n=t.get(o.marketSlug)??"#6b7280",s=r.get(o.marketSlug);return jsxs("div",{style:{display:"inline-flex",alignItems:"flex-start",gap:6},children:[jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:n,flexShrink:0,marginTop:3}}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1},children:[jsx("span",{style:{color:"#9ca3af",fontSize:12,lineHeight:"17px",whiteSpace:"nowrap"},children:o.label}),jsx("span",{style:{color:"#f9fafb",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:s!=null?ms(s):"--"})]})]},o.marketSlug)})})}function Sd(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function wd(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),i=Math.min(Math.floor((n+1)*o),e.length),a=e.slice(s,i),l=a.map(c=>c.price).sort((c,p)=>c-p);r.push({timestamp:a[a.length-1].timestamp,price:Sd(l)});}return r}function Nd(e,t=200){if(e.length===0)return [];let r=e.map(a=>({...a,data:wd(a.data,t)})),o=new Set;r.forEach(a=>a.data.forEach(l=>o.add(l.timestamp)));let n=Array.from(o).sort((a,l)=>a-l),s=r.map(a=>{let l=new Map;return a.data.forEach(c=>l.set(c.timestamp,c.price)),{slug:a.marketSlug,map:l}}),i=new Map;return n.map(a=>{let l={timestamp:a};return s.forEach(({slug:c,map:p})=>{let u=p.get(a);if(u!==void 0)i.set(c,u),l[c]=u;else {let m=i.get(c);m!==void 0&&(l[c]=m);}}),l})}function fs(e){return jsx(hn,{children:jsx(Pd,{...e})})}function Pd({event:e,isLoading:t,className:r,volume:o}){let n=useMemo(()=>{let C=new Set;return (e.markets??[]).filter(_=>_.status!=="open"||C.has(_.slug)?false:(C.add(_.slug),true))},[e.markets]),s=useMemo(()=>[...n].sort((C,_)=>{let W=I=>(I.outcomes.find(se=>se.label.toLowerCase()==="yes")??I.outcomes[0])?.price??0;return W(_)-W(C)}),[n]),[i,a]=useState(()=>s.slice(0,vr).map(C=>C.slug)),[l,c]=useState(ir),p=useMemo(()=>{let C=new Map;return i.forEach((_,W)=>{C.set(_,ps[W%ps.length]);}),C},[i]),u=useMemo(()=>n.filter(C=>i.includes(C.slug)),[n,i]),{series:m,isLoading:d}=useMarketHistory(u,l),f=t||d,g=useMemo(()=>{if(m.length>0&&m.some(W=>W.data.length>0))return m;let C=Date.now(),_=864e5;return u.map(W=>{let se=(W.outcomes?.find(ve=>ve.label.toLowerCase()==="yes")??W.outcomes?.[0])?.price??.5;return {marketSlug:W.slug,label:W.outcomes?.[0]?.label??W.question,data:[{timestamp:C-7*_,price:se},{timestamp:C,price:se}]}})},[m,u]),h=useMemo(()=>l===ChartRange.ONE_DAY?96:l===ChartRange.ONE_WEEK?168:l===ChartRange.ONE_MONTH?180:300,[l]),x=useMemo(()=>Nd(g,h),[g,h]),P=useMemo(()=>{if(x.length===0)return [0,1];let C=1/0,_=-1/0;if(i.forEach(I=>{x.forEach(se=>{let ve=se[I];ve!=null&&(ve<C&&(C=ve),ve>_&&(_=ve));});}),!isFinite(C))return [0,1];let W=Math.max((_-C)*.15,.05);return [Math.max(0,C-W),Math.min(1,_+W)]},[x,i]),b=useMemo(()=>{let C=new Map;return g.forEach(_=>{_.data.length>0&&C.set(_.marketSlug,_.data[_.data.length-1].price);}),C},[g]),R=useMemo(()=>{let C=new Map;return g.forEach(_=>C.set(_.marketSlug,_.label)),C},[g]),v=useMemo(()=>g.map(C=>({slug:C.marketSlug,color:p.get(C.marketSlug)??"#6b7280"})),[g,p]),{wrapperRef:L,overlayRef:y,onMouseMove:X,onMouseLeave:Y}=vd(),K=useCallback(C=>{a(_=>_.includes(C)?_.length<=1?_:_.filter(W=>W!==C):_.length>=vr?_:[..._,C]);},[]),[oe,D]=useState(null),$=useRef(null),H=useRef(""),me=useRef(0),fe=!f&&x.length>0;return jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12},children:[jsx(kd,{series:g,colorMap:p,displayValues:oe??b}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0},children:[jsx("div",{ref:L,style:{height:300,width:"100%",userSelect:"none",position:"relative"},onMouseMove:fe?C=>{X(C),cancelAnimationFrame(me.current),me.current=requestAnimationFrame(()=>{D($.current);});}:void 0,onMouseLeave:fe?()=>{Y(),cancelAnimationFrame(me.current),H.current="",$.current=null,D(null);}:void 0,children:f?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):x.length===0?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No price history data"}):jsxs(Fragment,{children:[jsx("div",{ref:y,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsxs(LineChart,{data:x,margin:{top:8,right:16,left:0,bottom:0},children:[jsx(CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsx(XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:["dataMin","dataMax"],tickFormatter:C=>fd(C,l),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsx(YAxis,{domain:P,tickFormatter:C=>`${Math.round(C*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsx(Tooltip,{content:C=>{let _=C;if(_.active&&_.payload?.length){let W=_.payload.map(I=>`${I.dataKey}:${I.value}`).join(",");if(W!==H.current){H.current=W;let I=new Map;_.payload.forEach(se=>{se.value!=null&&I.set(se.dataKey,se.value);}),$.current=I;}}return jsx(bd,{..._,labelMap:R,allSeries:v,range:l})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),g.map(C=>{let _=p.get(C.marketSlug)??"#6b7280";return jsx(Line,{type:"linear",dataKey:C.marketSlug,stroke:_,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:_},connectNulls:true,isAnimationActive:false},C.marketSlug)}),oe==null&&x.length>0&&g.map(C=>{let _=x[x.length-1],W=_[C.marketSlug];if(W==null)return null;let I=p.get(C.marketSlug)??"#6b7280";return jsx(ReferenceDot,{x:_.timestamp,y:W,ifOverflow:"extendDomain",shape:se=>{let{cx:ve,cy:ge}=se;return ve==null||ge==null?jsx("g",{}):jsxs("g",{children:[jsxs("circle",{cx:ve,cy:ge,r:6,fill:I,opacity:.3,children:[jsx("animate",{attributeName:"r",values:"4;9;4",dur:"2s",repeatCount:"indefinite"}),jsx("animate",{attributeName:"opacity",values:"0.4;0.05;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsx("circle",{cx:ve,cy:ge,r:3.5,fill:I})]})}},`pulse-${C.marketSlug}`)})]})})]})}),jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"6px 8px",marginTop:6},children:[o!=null&&o>0&&jsxs("span",{style:{color:"#6b7280",fontSize:12},children:["$",Math.round(o).toLocaleString()," vol"]}),jsx("div",{style:{flex:1,minWidth:0}}),jsx(xd,{value:l,onChange:c}),s.length>1&&jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsx(yd,{markets:s,selectedSlugs:i,colorMap:p,onToggle:K})})]})]})]})}function jt(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Hd(e){return `${parseFloat((e*100).toFixed(2))}%`}function gs(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function br(e){return e.outcomes?.[0]?.label??e.question}function Bd(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function Vt(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"),i=t.getMinutes().toString().padStart(2,"0");return `${r} ${o}, ${n} ${s}:${i}`}function hs(e){let[t,r]=useState(0);if(useEffect(()=>{if(!e)return;r(Date.now());let p=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(p)},[e]),!e||t===0)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),i=Math.floor(n%864e5/36e5),a=Math.floor(n%36e5/6e4),l=Math.floor(n%6e4/1e3),c=[];return s>0&&c.push(`${s}d`),c.push(`${String(i).padStart(2,"0")}h`),c.push(`${String(a).padStart(2,"0")}m`),c.push(`${String(l).padStart(2,"0")}s`),c.join(" ")}function xs(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"),i=t.getFullYear(),a=-t.getTimezoneOffset(),l=a>=0?"+":"-",c=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${s}/${i} (${l}${c})`}function ks({event:e,onTradeAction:t}){let{t:r}=useTranslation(),{ref:o,isCollapsed:n}=useScrollCollapse(),s=useMemo(()=>{let u=[...e.markets||[]],m=u.filter(f=>f.status==="open").sort((f,g)=>jt(g)-jt(f)),d=u.filter(f=>f.status!=="open").sort((f,g)=>jt(g)-jt(f));return [...m,...d]},[e.markets]),i=e.status==="closed"||e.status==="voided",a=hs(i?void 0:e.start_at),l=hs(i?void 0:e.end_at),c=xs(e.start_at),p=xs(e.end_at);return jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxs("div",{ref:o,className:`sticky top-0 z-30 flex items-center backdrop-blur-md transition-all duration-300 ${n?"h-14 lg:h-16 gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"h-16 lg:h-20 gap-x-2 lg:gap-x-4"}`,children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",classNames:{base:"bg-transparent"},className:`flex-shrink-0 transition-all duration-300 ${n?"!h-10 !w-10 lg:!h-12 lg:!w-12":"!h-16 !w-16 lg:!h-20 lg:!w-20"}`}),jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[!n&&jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((u,m)=>jsxs(Fragment$1,{children:[m>0&&jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-sm text-neutral truncate",children:u.label})]},u.slug)),jsx(Ud,{source:e.source})]}),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||l||i)&&jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:i?p&&jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:p})}):a?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.beginsIn",{time:a})}),c&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:c})]})]}):l?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.endsIn",{time:l})}),p&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:p})]})]}):null}),jsx(fs,{event:e,volume:e.volume??void 0}),jsx($d,{markets:s,onTradeAction:t}),jsx(Wd,{markets:s,event:e})]})}var vs=5;function $d({markets:e,onTradeAction:t}){let{t:r}=useTranslation(),{isMobile:o}=useScreen(),[n,s]=useState(false),[i,a]=useState(null),l=useMemo(()=>{let h=new Set;return e.filter(x=>h.has(x.slug)?false:(h.add(x.slug),true))},[e]),c=l.find(h=>h.status==="open")?.slug,[p,u]=useState(c?`${c}:yes`:null);if(l.length===0)return null;let m=l.length>vs,d=n?l:l.slice(0,vs),f=h=>{a(x=>x===h?null:h);},g=(h,x,P)=>{u(`${h.slug}:${x}`),o||a(h.slug),t?.(h,x,P);};return jsxs("div",{className:"flex flex-col",children:[jsxs("table",{className:"w-full border-collapse",children:[jsx("thead",{children:jsxs("tr",{children:[jsx("th",{}),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")}),jsx("th",{})]})}),jsx("tbody",{children:d.map((h,x)=>{let P=jt(h),b=h.outcomes[1]?.best_ask??h.outcomes[1]?.price,R=i===h.slug;return jsx(zd,{market:h,yesPrice:P,noPrice:b??void 0,activeYes:p===`${h.slug}:yes`,activeNo:p===`${h.slug}:no`,isExpanded:R,onToggleExpand:()=>f(h.slug),onTradeAction:g},h.id??`${x}-${h.slug}`)})})]}),m&&jsxs("button",{type:"button",onClick:()=>s(h=>!h),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:[jsx("span",{children:r(n?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsx(ChevronDownIcon,{className:cn$1("h-4 w-4 transition-transform",n&&"rotate-180")})]})]})}function zd({market:e,yesPrice:t,noPrice:r,activeYes:o,activeNo:n,isExpanded:s,onToggleExpand:i,onTradeAction:a}){let{t:l}=useTranslation(),c=e.status==="open",p=e.volume?`$${Math.round(e.volume).toLocaleString("en-US")} vol`:void 0;return jsxs(Fragment,{children:[jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:i,role:"button",tabIndex:0,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),i());},children:[jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[e.image_url&&jsx(Avatar,{src:e.image_url,name:br(e)?.[0]||"?",radius:"lg",className:"size-5 shrink-0 lg:size-8",imgProps:{className:"object-cover"}}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-foreground truncate max-w-[200px] lg:max-w-[300px]",children:br(e)}),p&&jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:p})]})]})}),jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:Hd(t)}),jsx("td",{className:"py-2 pr-1 lg:pr-2",children:c?jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsx("button",{type:"button",className:cn$1("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all",o?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:u=>{u.stopPropagation(),a?.(e,"yes","buy");},children:l("predict.market.action.yes",{price:gs(t)})}),jsx("button",{type:"button",className:cn$1("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all",n?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:u=>{u.stopPropagation(),a?.(e,"no","buy");},children:r!=null?l("predict.market.action.no",{price:gs(r)}):l("predict.market.no")})]}):jsx("div",{className:"flex items-center justify-end",children:jsx("span",{className:cn$1("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",e.status==="closed"?"bg-neutral/10 text-neutral":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?l("predict.event.status.closed"):e.status==="voided"?l("predict.event.status.voided"):l("predict.event.status.pending")})})})]}),s&&jsx("tr",{children:jsx("td",{colSpan:3,className:"pb-3",children:jsx("div",{className:"max-h-100 overflow-y-auto",children:jsx(us,{market:e,outcome:n?"no":"yes",onTradeAction:a})})})})]})}function Wd({markets:e,event:t}){let{t:r}=useTranslation(),[o,n]=useState(false),[s,i]=useState(false),[a,l]=useState(0),c=e.filter(d=>d.rules&&d.rules.length>0||d.description);if(c.length===0)return null;let p=c[a]??c[0],u=p.rules&&p.rules.length>0?p.rules.join(`
|
|
19
|
+
`;function Uo({event:e,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n,onHover:s}){let[a,i]=useState(null),l=e.markets??[],p=useMemo(()=>l.length>2?[...l].sort((v,T)=>(T.outcomes?.[0]?.price??0)-(v.outcomes?.[0]?.price??0)):l,[l]).filter(v=>v.status==="open"),u=p.length===1,m=p.slice(0,Ao),d=p.length-Ao,f=useMemo(()=>`$${Math.round(e.volume??0).toLocaleString("en-US")}`,[e.volume]),g=a?p.find(v=>v.slug===a)??null:null,h=!!g||u,x=()=>{h||o?.(e);},w=v=>{v.stopPropagation(),g&&(v.preventDefault(),i(null));},b=v=>{v.stopPropagation(),t||(v.preventDefault(),o?.(e));},L=u?jsx(dc,{event:e,formattedVolume:f,href:t,LinkComponent:r,onSelect:o}):g?jsx(pc,{onCollapse:()=>i(null)}):jsx(ic,{moreCount:d,formattedVolume:f,source:e.source,href:t,LinkComponent:r,onShowMore:b});return jsxs("div",{className:"group",style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",cursor:h?void 0:"pointer"},onMouseEnter:v=>{let T=v.currentTarget,y=jl[e.source]??Gl;T.style.borderColor=y.border,T.style.boxShadow=y.shadow,s?.(e);},onMouseLeave:v=>{let T=v.currentTarget;T.style.borderColor="rgba(39,39,42,0.6)",T.style.boxShadow="none";},onClick:x,children:[jsx("style",{children:Zl}),jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,padding:"14px 14px 12px",gap:8},children:[jsx(Jl,{event:e,href:t,LinkComponent:r,onClick:w,isExpanded:h}),jsx("div",{style:{display:"flex",flexDirection:"column",flex:1},children:u?jsx(cc,{market:p[0],event:e,onSelectOutcome:n}):g?jsx(uc,{market:g,event:e,onCollapse:()=>i(null),onSelectOutcome:n}):jsx(sc,{displayedMarkets:m,onMarketClick:v=>i(v.slug)})})]}),jsx(ac,{children:L})]})}function Jl({event:e,href:t,LinkComponent:r,onClick:o,isExpanded:n}){let s=e.start_at?Xl(e.start_at):null;return jsxs(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:[jsx(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"}}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsx("p",{className:cn$1("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&&jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",s]})]}),jsx(tc,{event:e})]})}function ec(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 tc({event:e}){let t=useMemo(()=>ec(e),[e]);return t.length===0?null:jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:t.map((r,o)=>{switch(r.kind){case "live":return jsx(rc,{},o);case "crypto-short":return jsx(nc,{label:r.label,color:r.color},o);case "closed":return jsx(oc,{},o)}})})}function rc(){let{t:e}=useTranslation();return 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:[jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-current"}),e("predict.event.status.live")]})}function nc({label:e,color:t}){return 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:[jsx(TimerIcon,{className:"size-3 shrink-0"}),e]})}function oc(){let{t:e}=useTranslation();return 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 sc({displayedMarkets:e,onMarketClick:t}){return e.length>0?jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(r=>{let o=zo(r);return 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:n=>{n.stopPropagation(),t(r);},children:[jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:r.outcomes?.[0]?.label??r.question}),jsxs("div",{className:"flex items-center gap-x-2",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:Wo(o)}),jsx(lc,{})]})]},r.id??`${r.source}-${r.slug}`)})}):null}function ic({moreCount:e,formattedVolume:t,source:r,href:o,LinkComponent:n,onShowMore:s}){let{t:a}=useTranslation();return jsxs(Fragment,{children:[e>0?jsxs(Linkable,{href:o,LinkComponent:n,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:s,children:[a("predict.event.showMore"),jsx(Vo,{className:"h-3 w-3"})]}):jsx("div",{}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",a("predict.event.volume"),jsx(jo,{source:r})]})]})}function ac({children:e}){return jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px",marginTop:"auto"},children:e})}function Bo({bgColor:e,textColor:t,shadowColor:r,onClick:o,children:n}){return 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 l=i.currentTarget;l.style.setProperty("--shadow-offset","2px"),l.style.transform="translateY(2px)";},onMouseLeave:i=>{let l=i.currentTarget;l.style.setProperty("--shadow-offset","4px"),l.style.transform="translateY(0px)";},onClick:o,children:n})}function Ko({market:e,event:t,onSelectOutcome:r,dynamicColors:o=false,labelFormat:n="action"}){let{t:s}=useTranslation(),[a,i]=o?ql(e):[en,$o],l=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",c=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",p=n==="label"&&l===c?"action":n,u=p==="label"?`${e.outcomes?.[0]?.label??"Yes"} ${Fo(e)}\xA2`:s("predict.market.action.yes",{price:Fo(e)}),m=p==="label"?`${e.outcomes?.[1]?.label??"No"} ${Ho(e)}\xA2`:s("predict.market.action.no",{price:Ho(e)});return jsxs("div",{className:"flex gap-2",children:[jsx(Bo,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:d=>{d.stopPropagation(),r?.(t,e,"yes");},children:u}),jsx(Bo,{bgColor:i.bg,textColor:i.text,shadowColor:i.shadow,onClick:d=>{d.stopPropagation(),r?.(t,e,"no");},children:m})]})}function lc(){let{t:e}=useTranslation();return 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:[jsx("span",{className:"text-primary",children:e("predict.market.yes")}),jsx("span",{className:"text-neutral-400",children:"/"}),jsx("span",{className:"text-secondary",children:e("predict.market.no")})]})}function cc({market:e,event:t,onSelectOutcome:r}){return jsx("div",{style:{flex:1},children:jsx(Ko,{market:e,event:t,onSelectOutcome:r,dynamicColors:true,labelFormat:"label"})})}function dc({event:e,formattedVolume:t,href:r,LinkComponent:o,onSelect:n}){let{t:s}=useTranslation();return jsxs(Fragment,{children:[jsxs(Linkable,{href:r,LinkComponent:o,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-zinc-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:i=>{i.stopPropagation(),r||(i.preventDefault(),n?.(e));},children:[s("predict.event.viewEvent"),jsx(Vo,{className:"h-3 w-3"})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,color:"#71717a"},children:[t," ",s("predict.event.volume"),jsx(jo,{source:e.source})]})]})}function uc({market:e,event:t,onCollapse:r,onSelectOutcome:o}){let n=zo(e);return jsxs("div",{style:{flex:1},children:[jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:s=>{s.stopPropagation(),r();},children:[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}),jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:Wo(n)}),jsx(ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsx("div",{style:{marginTop:12},children:jsx(Ko,{market:e,event:t,onSelectOutcome:o,labelFormat:"action"})})]})}function pc({onCollapse:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsxs("button",{type:"button",className:"flex items-center gap-x-1 text-[10px] font-normal transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",style:{color:"#71717a"},onClick:r=>{r.stopPropagation(),e();},children:[jsx(mc,{className:"h-3 w-3"}),t("predict.event.back")]}),jsx("div",{})]})}function Vo({className:e}){return jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsx("path",{d:"M4.5 2.5L8 6l-3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function mc({className:e}){return jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsx("path",{d:"M7.5 2.5L4 6l3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function jo({source:e}){return jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsx(PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsx(KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var bc=768,Yo=1024,yc=1280,kc=8,Sc=224,wc=304,Nc=114;function Pc(e){return e>=yc?4:e>=Yo?3:e>=bc?2:1}function Cc(e){return e>=Yo?wc:Sc}function qo({events:e,hasMore:t=false,onFetchMore:r,onSelect:o,onSelectOutcome:n,getEventHref:s,LinkComponent:a,onHover:i}){let l=useRef(null),c=useRef(null),{width:p=0,height:u=0}=useResizeObserver({ref:l}),m=Pc(p),d=Cc(p),f=Math.ceil(e.length/m)||0,g=!t&&e.length>0,h=f+(t?1:0)+(g?1:0),x=useCallback(v=>v<f,[f]),w=useCallback(async()=>{r?.();},[r]),b=useInfiniteLoader({isRowLoaded:x,loadMoreRows:w,rowCount:h,threshold:3}),L=useCallback(()=>{c.current?.scrollToRow({index:0,behavior:"smooth"});},[]);return jsxs("div",{ref:l,className:"@container w-full h-full",children:[jsx("style",{children:"@keyframes eventCardEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}"}),u>0&&jsx(List,{listRef:c,className:"no-scrollbar",style:{height:u},onRowsRendered:b,rowComponent:Mc,rowCount:h,rowHeight:v=>g&&v===h-1?Nc:(d),rowProps:{events:e,columnCount:m,dataRowCount:f,showEndOfList:g,totalRowCount:h,onSelect:o,onSelectOutcome:n,getEventHref:s,LinkComponent:a,onHover:i,onScrollToTop:L}})]})}function Mc({index:e,style:t,events:r,columnCount:o,dataRowCount:n,showEndOfList:s,totalRowCount:a,onSelect:i,onSelectOutcome:l,getEventHref:c,LinkComponent:p,onHover:u,onScrollToTop:m}){if(s&&e===a-1)return jsx("div",{style:t,children:jsx(Ec,{onScrollToTop:m})});if(e>=n)return jsx("div",{style:t,className:"flex justify-center items-start pt-4",children:jsx(Spinner,{size:"sm"})});let d=e*o,f=r.slice(d,d+o),g=o-f.length;return jsx("div",{style:t,children:jsxs("div",{className:"flex w-full h-full",children:[f.map((h,x)=>h==null?null:jsx("div",{className:"flex-1 min-w-0 flex",style:{padding:kc,animation:`eventCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${x*35}ms both`},children:jsx(Uo,{event:h,href:c?.(h),LinkComponent:p,onSelect:i,onSelectOutcome:l,onHover:u})},`${d+x}-${h.source}-${h.slug}`)),g>0&&Array.from({length:g}).map((h,x)=>jsx("div",{style:{flex:1,minWidth:0}},`spacer-${x}`))]})})}function Ec({onScrollToTop:e}){let{t}=useTranslation();return jsxs("div",{className:"flex w-full flex-col items-center justify-center gap-y-4 py-6",children:[jsxs("div",{className:"flex w-full items-center justify-center gap-x-4",children:[jsx("div",{className:"h-px w-16 bg-neutral-700"}),jsx("span",{className:"text-xs font-medium text-neutral-500",children:t("predict.event.endOfList")}),jsx("div",{className:"h-px w-16 bg-neutral-700"})]}),jsxs("button",{type:"button",className:"flex cursor-pointer items-center gap-x-1 text-xs font-medium text-neutral-400",onClick:e,children:[jsx("span",{className:"iconify size-4 ph--arrow-up-bold"}),jsx("span",{children:t("predict.event.backToTop")})]})]})}function Xo({tagSlugSelection:e,limit:t=48,status:r,sort_by:o,sort_asc:n,source:s,with_markets:a,timeRemaining:i,minVolume:l,minLiquidity:c,onSelect:p,onSelectOutcome:u,getEventHref:m,LinkComponent:d,onHover:f}){let{data:g,hasMore:h,fetchMore:x,isFetching:w}=Io({tagSlugSelection:e,limit:t,status:r,sort_by:o,sort_asc:n,source:s,with_markets:a,timeRemaining:i,minVolume:l,minLiquidity:c});return w?jsx(Zr,{count:48}):jsx(qo,{events:g,hasMore:h,onFetchMore:x,onSelect:p,onSelectOutcome:u,getEventHref:m,LinkComponent:d,onHover:f})}function c0({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:o,onHover:n}){let[s,a]=useState({categorySlug:null,tagSlug:null}),[i,l]=useState(Qr),{isOpen:c,onOpen:p,onClose:u}=useDisclosure(),{onOpen:m}=useAsyncModal(Ot),d=useCallback((v,T,y)=>{t?.(v,T,y),m({params:{event:v,market:T,initialOutcome:y}});},[t,m]),f=useCallback(v=>{a(v);},[]),g=useCallback(v=>{l(T=>({...T,sortPreset:v}));},[]),h=useCallback(v=>{l(T=>({...T,sortAsc:v}));},[]),x=useCallback(v=>{l(v);},[]),w=useMemo(()=>To[i.sortPreset].sort_by,[i.sortPreset]),b=useMemo(()=>Xr(i),[i]),L=useMemo(()=>jsx(Lo,{sortPreset:i.sortPreset,onSortChange:g,sortAsc:i.sortAsc,onSortAscChange:h,onFilterPress:p,filterCount:b}),[i.sortPreset,i.sortAsc,b,g,h,p]);return jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsx(oo,{onSelect:f,trailing:L}),jsx(No,{isOpen:c,onClose:u,value:i,onChange:x}),jsx("div",{className:"min-h-0 flex-1",children:jsx(Xo,{tagSlugSelection:s,sort_by:w,sort_asc:i.sortAsc,source:i.source,timeRemaining:i.timeRemaining,minVolume:i.minVolume,minLiquidity:i.minLiquidity,onSelect:e,onSelectOutcome:d,getEventHref:r,LinkComponent:o,onHover:n})}),jsx(lr,{})]})}var ln=40,fr=36,zt=480,cn=zt-fr;function ts({event:e,walletAddress:t,onCancelOrder:r}){let{t:o}=useTranslation(),[n,s]=useState("positions"),a=useMemo(()=>e.markets?.map(u=>u.slug)??[],[e.markets]),{data:i}=usePositions({source:e.source,user:t??""}),l=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]),p=[{key:"positions",label:l>0?`${o("predict.positions.title")} (${l})`:o("predict.positions.title")},{key:"orders",label:o("predict.openOrders.title")},{key:"trades",label:o("predict.tradeHistory.title")}];return jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:p.map(u=>jsx("button",{type:"button",onClick:()=>s(u.key),className:cn$1("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?jsxs("div",{style:{height:zt},children:[n==="positions"&&jsx(Fc,{source:e.source,walletAddress:t,marketSlugs:a}),n==="orders"&&jsx(Bc,{source:e.source,walletAddress:t,marketSlugs:a,onCancelOrder:r}),n==="trades"&&jsx(Wc,{source:e.source,walletAddress:t})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:zt},children:o("predict.trade.connectWallet")})]})}function Fc({source:e,walletAddress:t,marketSlugs:r}){let{t:o}=useTranslation(),{data:n,isLoading:s}=usePositions({source:e,user:t}),a=useMemo(()=>n?.positions?r.length===0?n.positions:n.positions.filter(i=>i.market&&r.includes(i.market.slug)):[],[n?.positions,r]);return s?jsx(un,{}):a.length===0?jsx(dn,{message:o("predict.positions.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:fr},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2 whitespace-nowrap",children:o("predict.positions.event")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.value")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.markPrice")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.estSettlement")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:cn},rowComponent:Hc,rowCount:a.length,rowHeight:ln,rowProps:{positions:a,closeLabel:o("predict.positions.close")}})]})}function Hc({index:e,style:t,positions:r,closeLabel:o}){let n=r[e];if(!n)return null;let s=n.pnl??0,a=n.pnl_percent??0,i=n.avg_price??0,l=n.current_price??0,c=s>0?"text-success":s<0?"text-danger":"text-foreground",p=s>0?"+":"",u=n.market?.outcomes?.[0]?.label??n.market?.question??"\u2014",m=n.side,d=n.size,f=n.size*l,g=n.market?.end_at?Vc(n.market.end_at):"\u2014";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-xs lg:text-sm",children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("div",{className:"flex flex-col gap-y-0.5",children:[jsx("span",{className:"text-foreground truncate font-medium",children:u}),jsx("span",{className:cn$1("text-[10px] font-medium",m.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:m})]})}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:n.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",f.toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:pr(i)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:pr(l)}),jsxs("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",c),children:[p,"$",Math.abs(s).toFixed(2),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",p,a.toFixed(1),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",d.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:g}),jsx("div",{className:"w-16 shrink-0 text-right",children: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:o})})]})}function Bc({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:o}){let{t:n}=useTranslation(),{data:s,isLoading:a,fetchNextPage:i,hasNextPage:l}=useInfiniteOrders({source:e,wallet_address:t}),c=useCancelOrder(),p=useMemo(()=>{let x=s?.pages?.flatMap(L=>L.items)??[],w=new Set(["live","open","submitted","pending"]),b=x.filter(L=>w.has(L.status));return r.length>0&&(b=b.filter(L=>L.market_id&&r.includes(L.market_id))),b},[s?.pages,r]),u=useCallback(x=>{o?o(x.id):c.mutate({source:x.source,id:x.id});},[o,c]),m=p.length,d=m+(l?1:0),f=useCallback(x=>x<m,[m]),g=useCallback(async()=>{await i();},[i]),h=useInfiniteLoader({isRowLoaded:f,loadMoreRows:g,rowCount:d,threshold:5});return a?jsx(un,{}):p.length===0&&!l?jsx(dn,{message:n("predict.openOrders.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:fr},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:n("predict.openOrders.side")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.openOrders.outcome")}),jsx("div",{className:"flex-1 pr-2",children:n("predict.openOrders.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.openOrders.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.openOrders.filled")}),jsx("div",{className:"w-20 shrink-0 pr-2",children:n("predict.openOrders.status")}),jsx("div",{className:"w-16 shrink-0"})]}),jsx(List,{style:{height:cn},onRowsRendered:h,rowComponent:$c,rowCount:d,rowHeight:ln,rowProps:{orders:p,itemCount:m,onCancel:u,isCancelling:c.isPending,cancelLabel:n("predict.openOrders.cancel")}})]})}function $c({index:e,style:t,orders:r,itemCount:o,onCancel:n,isCancelling:s,cancelLabel:a}){if(e>=o)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let i=r[e];if(!i)return null;let l=i.side==="BUY";return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn$1("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",l?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:i.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:i.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:i.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:i.price?pr(parseFloat(i.price)):"\u2014"}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[i.size_matched??"0","/",i.original_size??"\u2014"]}),jsx("div",{className:"w-20 shrink-0 pr-2",children:jsx(zc,{status:i.status})}),jsx("div",{className:"w-16 shrink-0 text-right",children:jsx("button",{type:"button",onClick:()=>n(i),disabled:s,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:s?jsx(Spinner,{size:"sm"}):a})})]})}function zc({status:e}){return jsx("span",{className:cn$1("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 Wc({source:e,walletAddress:t}){let{t:r}=useTranslation(),{data:o,isLoading:n,fetchNextPage:s,hasNextPage:a}=useInfiniteTrades({source:e,wallet:t,limit:50}),i=useMemo(()=>o?.pages?.flatMap(d=>d.items)??[],[o?.pages]),l=i.length,c=l+(a?1:0),p=useCallback(d=>d<l,[l]),u=useCallback(async()=>{await s();},[s]),m=useInfiniteLoader({isRowLoaded:p,loadMoreRows:u,rowCount:c,threshold:5});return n?jsx(un,{}):i.length===0&&!a?jsx(dn,{message:r("predict.tradeHistory.empty")}):jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:fr},children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:r("predict.tradeHistory.side")}),jsx("div",{className:"flex-1 pr-2",children:r("predict.tradeHistory.outcome")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.price")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.qty")}),jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.tradeHistory.total")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:r("predict.tradeHistory.time")})]}),jsx(List,{style:{height:cn},onRowsRendered:m,rowComponent:Uc,rowCount:c,rowHeight:ln,rowProps:{trades:i,itemCount:l}})]})}function Uc({index:e,style:t,trades:r,itemCount:o}){if(e>=o)return jsx("div",{style:t,className:"flex justify-center items-center",children:jsx(Spinner,{size:"sm"})});let n=r[e];if(!n)return null;let s=n.side?.toUpperCase()==="BUY",a=Kc(n.timestamp),i=n.price??0,l=n.usd_size??0;return jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsx("div",{className:"w-16 shrink-0 pr-2",children:jsx("span",{className:cn$1("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:n.side})}),jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:n.outcome??"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:pr(i)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:n.size}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",l.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:a})]})}function dn({message:e}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:zt},children:e})}function un(){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:zt},children:Array.from({length:6}).map((e,t)=>jsx(Skeleton,{className:"h-8 w-full rounded-md"},t))})}function pr(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function Kc(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 Vc(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}function Wt({marketCount:e=4,showBack:t}){return jsxs("div",{className:"flex w-full flex-col gap-4 animate-pulse lg:gap-6",children:[t&&jsx("div",{className:"h-5"}),jsxs("div",{className:"flex items-center gap-x-2 h-16 lg:h-20 lg:gap-x-4",children:[jsx(Skeleton,{className:"size-16 shrink-0 rounded-lg lg:size-20"}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[jsxs("div",{className:"flex items-center gap-1.5",children:[jsx(Skeleton,{className:"h-3.5 w-12 rounded"}),jsx(Skeleton,{className:"h-3.5 w-10 rounded"}),jsx(Skeleton,{className:"h-3.5 w-10 rounded"})]}),jsx(Skeleton,{className:"h-5 w-full max-w-sm rounded lg:h-6"})]})]}),jsx(Skeleton,{className:"h-4 w-48 rounded"}),jsxs("div",{className:"flex flex-col gap-3",children:[jsxs("div",{className:"flex items-center gap-4",children:[jsx(Skeleton,{className:"h-4 w-24 rounded"}),jsx(Skeleton,{className:"h-4 w-20 rounded"})]}),jsx(Skeleton,{className:"h-[300px] w-full rounded-xl"}),jsxs("div",{className:"flex items-center justify-between",children:[jsx(Skeleton,{className:"h-4 w-20 rounded"}),jsxs("div",{className:"flex items-center gap-2",children:[jsx(Skeleton,{className:"h-7 w-[200px] rounded-lg"}),jsx(Skeleton,{className:"h-7 w-28 rounded-lg"})]})]})]}),jsxs("div",{className:"flex flex-col",children:[jsxs("div",{className:"flex items-center py-2",children:[jsx("div",{className:"flex-1"}),jsx(Skeleton,{className:"h-3.5 w-14 rounded"}),jsx("div",{className:"flex-1"})]}),Array.from({length:e}).map((r,o)=>jsxs("div",{className:"flex items-center gap-x-2 border-b border-border py-2.5 lg:gap-x-3",children:[jsx(Skeleton,{className:"size-5 shrink-0 rounded-lg lg:size-8"}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[jsx(Skeleton,{className:"h-3.5 w-32 rounded lg:h-4 lg:w-48"}),jsx(Skeleton,{className:"h-2.5 w-16 rounded"})]}),jsx(Skeleton,{className:"h-4 w-10 rounded"}),jsxs("div",{className:"flex items-center gap-2",children:[jsx(Skeleton,{className:"h-8 w-16 rounded-lg lg:w-24"}),jsx(Skeleton,{className:"h-8 w-16 rounded-lg lg:w-24"})]})]},o))]}),jsxs("div",{className:"flex flex-col gap-2",children:[jsx(Skeleton,{className:"h-4 w-16 rounded"}),jsx(Skeleton,{className:"h-3.5 w-full rounded"}),jsx(Skeleton,{className:"h-3.5 w-4/5 rounded"}),jsx(Skeleton,{className:"h-3.5 w-3/5 rounded"})]})]})}function rs(){return jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-border p-4 animate-pulse",children:[jsx(Skeleton,{className:"h-10 w-full rounded-lg"}),jsx(Skeleton,{className:"h-24 w-full rounded-lg"}),jsx(Skeleton,{className:"h-10 w-full rounded-lg"})]})}var is="var(--color-bullish)",as="var(--color-bearish)";function Ut(e){let t=Math.abs(e);return t>=1e9?`${parseFloat((e/1e9).toFixed(2))}B`:t>=1e6?`${parseFloat((e/1e6).toFixed(2))}M`:t>=1e3?`${parseFloat((e/1e3).toFixed(2))}K`:e.toLocaleString()}function Yc(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function qc(e,t){let r=new Float64Array(101),o=new Float64Array(101);for(let d of e){let f=Math.round(d.price*100);f>=0&&f<=100&&(r[f]+=d.quantity);}for(let d of t){let f=Math.round(d.price*100);f>=0&&f<=100&&(o[f]+=d.quantity);}let n=0,s=0,a=new Float64Array(101),i=new Float64Array(101);for(let d=100;d>=0;d--)n+=r[d],s+=r[d]*d/100,a[d]=n,i[d]=s;let l=0,c=0,p=new Float64Array(101),u=new Float64Array(101);for(let d=0;d<=100;d++)l+=o[d],c+=o[d]*d/100,p[d]=l,u[d]=c;let m=Math.max(a[0]??0,p[100]??0);return Array.from({length:101},(d,f)=>{let g=a[f]>0,h=p[f]>0,x=a[f]||p[f],w=r[f]>0||o[f]>0;return {priceCents:f,displayHeight:Yc(x,m),opacity:x>0?w?1:.5:0,isBid:g,isAsk:h,bidCumTotal:a[f],askCumTotal:p[f],bidCumCost:i[f],askCumCost:u[f]}})}function Qc({info:e}){let{t}=useTranslation(),r=e.isBid?is:as,o=e.leftPct>65?void 0:`${e.leftPct}%`,n=e.leftPct>65?`${100-e.leftPct}%`:void 0;return jsxs("div",{style:{position:"absolute",top:8,left:o,right:n,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:[jsx("div",{style:{marginBottom:4,fontWeight:600},children:t("predict.orderBook.depthToPrice",{price:e.priceCents})}),jsx("div",{style:{color:r},children:t("predict.orderBook.depthContracts",{amount:Ut(Math.round(e.cumTotal))})}),jsxs("div",{style:{color:r},children:["$",Ut(Math.round(e.cumCost))]})]})}var Xc=memo(function({slot:t,onEnter:r,onLeave:o}){let n=useRef(null),s=t.isBid||t.isAsk,a=t.isBid?is:t.isAsk?as:void 0;return 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&&jsx("div",{ref:n,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:a,opacity:t.opacity}})})}),Zc=[0,10,20,30,40,50,60,70,80,90,100];function Jc(){return 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:Zc.map(e=>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 ls({bids:e,asks:t}){let{t:r}=useTranslation(),o=useMemo(()=>qc(e,t),[e,t]),n=useMemo(()=>{let u=e.length>0?Math.max(...e.map(d=>d.price)):0,m=t.length>0?Math.min(...t.map(d=>d.price)):1;return Math.round((u+m)/2*100)},[e,t]),s=useMemo(()=>o.some(u=>u.isBid||u.isAsk),[o]),[a,i]=useState(null),l=useRef(null),c=useCallback((u,m)=>{l.current&&(l.current.style.filter=""),m?(m.style.filter="brightness(1.5)",l.current=m):l.current=null,u.isBid||u.isAsk?i({priceCents:u.priceCents,isBid:u.isBid,cumTotal:u.isBid?u.bidCumTotal:u.askCumTotal,cumCost:u.isBid?u.bidCumCost:u.askCumCost,leftPct:u.priceCents}):i(null);},[]),p=useCallback(()=>{l.current&&(l.current.style.filter="",l.current=null),i(null);},[]);return s?jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[n>0&&jsx("div",{style:{position:"absolute",left:`${n}%`,top:0,bottom:0,width:1,backgroundImage:"repeating-linear-gradient(to bottom, #6b7280 0, #6b7280 4px, transparent 4px, transparent 8px)",zIndex:1,pointerEvents:"none"}}),a&&jsx(Qc,{info:a}),o.map(u=>jsx(Xc,{slot:u,onEnter:c,onLeave:p},u.priceCents))]}),jsx(Jc,{})]}):jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:r("predict.orderBook.noData")})}function mn(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function cs(){let{t:e}=useTranslation();return jsxs("div",{className:"flex items-center justify-center gap-x-2 h-full text-neutral text-xs",children:[jsx(Spinner,{size:"sm"}),jsx("span",{children:e("predict.orderBook.loading")})]})}function ms({market:e,outcome:t="yes",onTradeAction:r}){let{t:o}=useTranslation(),[n,s]=useState("depth"),a=t==="no",i=e.source,{data:l,isLoading:c}=useOrderbook({slug:e.slug,source:i}),p=useMemo(()=>((a?l?.asks:l?.bids)??[]).map(h=>({price:a?1-h.price:h.price,quantity:h.size})),[l?.bids,l?.asks,a]),u=useMemo(()=>((a?l?.bids:l?.asks)??[]).map(h=>({price:a?1-h.price:h.price,quantity:h.size})),[l?.bids,l?.asks,a]),m=useMemo(()=>p.length>0?Math.max(...p.map(g=>g.price)):null,[p]),d=useMemo(()=>u.length>0?Math.min(...u.map(g=>g.price)):null,[u]),f=useMemo(()=>{if(m==null||d==null)return null;let g=(d-m)*100;return Math.round(g*10)/10},[m,d]);return jsxs("div",{className:"flex flex-col h-[262px]",children:[jsxs("div",{className:"flex h-9 items-center border-b border-border px-1 text-xs",children:[jsx("span",{className:"flex-1 text-left text-neutral",children:f!=null?`${o("predict.orderBook.spread")}: ${Number.isInteger(f)?`${f}\xA2`:`${f.toFixed(1)}\xA2`}`:null}),jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[m!=null&&jsxs("span",{style:{color:"var(--color-bullish)"},children:[o("predict.trade.bestBid"),": ",mn(m)]}),m!=null&&d!=null&&jsx("span",{className:"text-neutral",children:"|"}),d!=null&&jsxs("span",{style:{color:"var(--color-bearish)"},children:[o("predict.trade.bestAsk"),": ",mn(d)]})]}),jsx("div",{className:"flex flex-1 justify-end",children:jsx("button",{type:"button",title:n==="depth"?"Orderbook":"Depth chart",onClick:()=>s(g=>g==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:n==="depth"?jsx(OrderbookTableIcon,{className:"h-4 w-4"}):jsx(OrderbookDepthIcon,{className:"h-4 w-4"})})})]}),jsxs("div",{className:"flex-1 min-h-0 overflow-hidden",children:[n==="depth"&&jsx(Fragment,{children:c?jsx(cs,{}):jsx(ls,{bids:p,asks:u})}),n==="table"&&jsx(Fragment,{children:c?jsx(cs,{}):jsx(sd,{bids:p,asks:u,bestBid:m??void 0,bestAsk:d??void 0,spread:f??void 0})})]})]})}var ds=8;function sd({bids:e,asks:t,spread:r}){let{t:o}=useTranslation(),n=useMemo(()=>[...t].sort((l,c)=>l.price-c.price).slice(0,ds).reverse(),[t]),s=useMemo(()=>[...e].sort((l,c)=>c.price-l.price).slice(0,ds),[e]),a=useMemo(()=>{let l=[...n,...s].map(c=>c.quantity);return Math.max(...l,1)},[n,s]);return n.length===0&&s.length===0?jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:o("predict.orderBook.empty")}):jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[n.map(l=>jsx(us,{price:l.price,quantity:l.quantity,side:"ask",maxQty:a},`ask-${l.price}`)),jsx("div",{className:"flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:r!=null&&jsxs("span",{children:[o("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]})}),s.map(l=>jsx(us,{price:l.price,quantity:l.quantity,side:"bid",maxQty:a},`bid-${l.price}`)),jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-neutral border-t border-border",children:[jsx("span",{children:o("predict.orderBook.price")}),jsx("span",{className:"text-center",children:o("predict.orderBook.contracts")}),jsx("span",{className:"text-right",children:o("predict.orderBook.total")})]})]})}function us({price:e,quantity:t,side:r,maxQty:o}){let n=r==="ask",s=Math.min(t/o*100,100),a=n?"bg-bearish/10":"bg-bullish/10",i=n?"text-bearish":"text-bullish",l=Ut(Math.round(t)),c=Math.round(t*e),p=`$${Ut(c)}`;return jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsx("div",{className:`absolute inset-y-0 left-0 ${a} transition-[width] duration-200`,style:{width:`${s}%`}}),jsx("span",{className:`relative z-10 ${i}`,children:mn(e)}),jsx("span",{className:"relative z-10 text-foreground text-center",children:l}),jsx("span",{className:"relative z-10 text-foreground text-right",children:p})]})}var hn=class extends Component{state={error:null};static getDerivedStateFromError(t){return {error:t}}componentDidCatch(t,r){}render(){return this.state.error?jsxs("div",{style:{height:this.props.fallbackHeight??320,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:"#6b7280",fontSize:13},children:[jsx("span",{children:"Chart unavailable"}),jsx("span",{style:{fontSize:11,opacity:.7},children:this.state.error.message})]}):this.props.children}},xr=4,fs=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function xd(e,t){let r=new Date(e);return t===ChartRange.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function vd(e,t){let r=new Date(e);return t===ChartRange.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===ChartRange.ONE_WEEK?r.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function gs(e){return `${(e*100).toFixed(2)}%`}var bd=[{range:ChartRange.ONE_DAY,label:"1D"},{range:ChartRange.ONE_WEEK,label:"1W"},{range:ChartRange.ONE_MONTH,label:"1M"},{range:ChartRange.ALL,label:"ALL"}];function yd({value:e,onChange:t}){return jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:bd.map(({range:r,label:o})=>{let n=r===e;return 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 kd(){let e=useRef(null),t=useRef(null),r=useCallback(n=>{let s=e.current,a=t.current;if(!s||!a)return;let i=s.getBoundingClientRect(),l=(n.clientX-i.left)/i.width*100;a.style.background=`linear-gradient(to right, transparent ${l}%, rgba(0,0,0,0.55) ${l}%)`,a.style.opacity="1";},[]),o=useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:o}}function Sd({active:e,payload:t,label:r,labelMap:o,allSeries:n,range:s}){if(!e||!n?.length)return null;let a=new Map;t?.forEach(l=>a.set(l.dataKey,l));let i=n.map(l=>a.get(l.slug)??{dataKey:l.slug,value:void 0,stroke:l.color,color:l.color});return 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:[jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof r=="number"?vd(r,s):r}),i.map(l=>jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:l.stroke??l.color,flexShrink:0}}),jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:o.get(l.dataKey)??l.dataKey}),jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:l.value!=null?gs(l.value):"--"})]},l.dataKey))]})}function wd({markets:e,selectedSlugs:t,colorMap:r,onToggle:o}){let[n,s]=useState(false),a=useRef(null);useEffect(()=>{if(!n)return;function c(p){a.current&&!a.current.contains(p.target)&&s(false);}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[n]);let i=t.length>=xr,l=jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(c=>jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(c)??"#6b7280",display:"inline-block"}},c))}),jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let c=e.find(p=>p.slug===t[0]);return c?.outcomes?.[0]?.label??c?.question??"1 market"})():`${t.length} / ${e.length} markets`})]});return jsxs("div",{ref:a,style:{position:"relative",display:"inline-block",width:200},children:[jsxs("button",{onClick:()=>s(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",width:"100%",userSelect:"none"},children:[l,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:jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),n&&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:[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 ",xr," markets"]}),e.map((c,p)=>{let u=t.includes(c.slug),m=!u&&i,d=u&&t.length===1,f=r.get(c.slug)??"#6b7280",g=c.outcomes.find(x=>x.label.toLowerCase()==="yes")??c.outcomes[0],h=g?.price!=null?`${Math.round(g.price*100)}%`:null;return jsxs("button",{onClick:()=>{d||m||o(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:m||d?"not-allowed":"pointer",opacity:m?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:x=>{!m&&!d&&(x.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:x=>{x.currentTarget.style.background=u?"rgba(255,255,255,0.05)":"transparent";},children:[jsx("span",{style:{width:16,height:16,borderRadius:4,border:u?`2px solid ${f}`:"2px solid rgba(255,255,255,0.2)",background:u?`${f}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:u&&jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:f,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:f,flexShrink:0}}),jsx("span",{style:{color:u?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.outcomes?.[0]?.label??c.question}),h&&jsx("span",{style:{color:f,fontWeight:700,fontSize:12,flexShrink:0},children:h})]},c.id??`${p}-${c.slug}`)})]})]})}function Nd({series:e,colorMap:t,displayValues:r}){return jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 24px",padding:"0 2px"},children:e.map(o=>{let n=t.get(o.marketSlug)??"#6b7280",s=r.get(o.marketSlug);return jsxs("div",{style:{display:"inline-flex",alignItems:"flex-start",gap:6},children:[jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:n,flexShrink:0,marginTop:3}}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1},children:[jsx("span",{style:{color:"#9ca3af",fontSize:12,lineHeight:"17px",whiteSpace:"nowrap"},children:o.label}),jsx("span",{style:{color:"#f9fafb",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:s!=null?gs(s):"--"})]})]},o.marketSlug)})})}function Pd(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function Cd(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),l=i.map(c=>c.price).sort((c,p)=>c-p);r.push({timestamp:i[i.length-1].timestamp,price:Pd(l)});}return r}function Md(e,t=200){if(e.length===0)return [];let r=e.map(i=>({...i,data:Cd(i.data,t)})),o=new Set;r.forEach(i=>i.data.forEach(l=>o.add(l.timestamp)));let n=Array.from(o).sort((i,l)=>i-l),s=r.map(i=>{let l=new Map;return i.data.forEach(c=>l.set(c.timestamp,c.price)),{slug:i.marketSlug,map:l}}),a=new Map;return n.map(i=>{let l={timestamp:i};return s.forEach(({slug:c,map:p})=>{let u=p.get(i);if(u!==void 0)a.set(c,u),l[c]=u;else {let m=a.get(c);m!==void 0&&(l[c]=m);}}),l})}function hs(e){return jsx(hn,{children:jsx(Ed,{...e})})}function Ed({event:e,isLoading:t,className:r,volume:o}){let n=useMemo(()=>{let C=new Set;return (e.markets??[]).filter(R=>R.status!=="open"||C.has(R.slug)?false:(C.add(R.slug),true))},[e.markets]),s=useMemo(()=>[...n].sort((C,R)=>{let W=I=>(I.outcomes.find(se=>se.label.toLowerCase()==="yes")??I.outcomes[0])?.price??0;return W(R)-W(C)}),[n]),[a,i]=useState(()=>s.slice(0,xr).map(C=>C.slug)),[l,c]=useState(ir),p=useMemo(()=>{let C=new Map;return a.forEach((R,W)=>{C.set(R,fs[W%fs.length]);}),C},[a]),u=useMemo(()=>n.filter(C=>a.includes(C.slug)),[n,a]),{series:m,isLoading:d}=useMarketHistory(u,l),f=t||d,g=useMemo(()=>{if(m.length>0&&m.some(W=>W.data.length>0))return m;let C=Date.now(),R=864e5;return u.map(W=>{let se=(W.outcomes?.find(ve=>ve.label.toLowerCase()==="yes")??W.outcomes?.[0])?.price??.5;return {marketSlug:W.slug,label:W.outcomes?.[0]?.label??W.question,data:[{timestamp:C-7*R,price:se},{timestamp:C,price:se}]}})},[m,u]),h=useMemo(()=>l===ChartRange.ONE_DAY?96:l===ChartRange.ONE_WEEK?168:l===ChartRange.ONE_MONTH?180:300,[l]),x=useMemo(()=>Md(g,h),[g,h]),w=useMemo(()=>{if(x.length===0)return [0,1];let C=1/0,R=-1/0;if(a.forEach(I=>{x.forEach(se=>{let ve=se[I];ve!=null&&(ve<C&&(C=ve),ve>R&&(R=ve));});}),!isFinite(C))return [0,1];let W=Math.max((R-C)*.15,.05);return [Math.max(0,C-W),Math.min(1,R+W)]},[x,a]),b=useMemo(()=>{let C=new Map;return g.forEach(R=>{R.data.length>0&&C.set(R.marketSlug,R.data[R.data.length-1].price);}),C},[g]),L=useMemo(()=>{let C=new Map;return g.forEach(R=>C.set(R.marketSlug,R.label)),C},[g]),v=useMemo(()=>g.map(C=>({slug:C.marketSlug,color:p.get(C.marketSlug)??"#6b7280"})),[g,p]),{wrapperRef:T,overlayRef:y,onMouseMove:X,onMouseLeave:Y}=kd(),K=useCallback(C=>{i(R=>R.includes(C)?R.length<=1?R:R.filter(W=>W!==C):R.length>=xr?R:[...R,C]);},[]),[oe,D]=useState(null),$=useRef(null),H=useRef(""),fe=useRef(0),ge=!f&&x.length>0;return jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12},children:[jsx(Nd,{series:g,colorMap:p,displayValues:oe??b}),jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0},children:[jsx("div",{ref:T,style:{height:300,width:"100%",userSelect:"none",position:"relative"},onMouseMove:ge?C=>{X(C),cancelAnimationFrame(fe.current),fe.current=requestAnimationFrame(()=>{D($.current);});}:void 0,onMouseLeave:ge?()=>{Y(),cancelAnimationFrame(fe.current),H.current="",$.current=null,D(null);}:void 0,children:f?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):x.length===0?jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No price history data"}):jsxs(Fragment,{children:[jsx("div",{ref:y,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsxs(LineChart,{data:x,margin:{top:8,right:16,left:0,bottom:0},children:[jsx(CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsx(XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:["dataMin","dataMax"],tickFormatter:C=>xd(C,l),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsx(YAxis,{domain:w,tickFormatter:C=>`${Math.round(C*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsx(Tooltip,{content:C=>{let R=C;if(R.active&&R.payload?.length){let W=R.payload.map(I=>`${I.dataKey}:${I.value}`).join(",");if(W!==H.current){H.current=W;let I=new Map;R.payload.forEach(se=>{se.value!=null&&I.set(se.dataKey,se.value);}),$.current=I;}}return jsx(Sd,{...R,labelMap:L,allSeries:v,range:l})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),g.map(C=>{let R=p.get(C.marketSlug)??"#6b7280";return jsx(Line,{type:"linear",dataKey:C.marketSlug,stroke:R,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:R},connectNulls:true,isAnimationActive:false},C.marketSlug)}),oe==null&&x.length>0&&g.map(C=>{let R=x[x.length-1],W=R[C.marketSlug];if(W==null)return null;let I=p.get(C.marketSlug)??"#6b7280";return jsx(ReferenceDot,{x:R.timestamp,y:W,ifOverflow:"extendDomain",shape:se=>{let{cx:ve,cy:he}=se;return ve==null||he==null?jsx("g",{}):jsxs("g",{children:[jsxs("circle",{cx:ve,cy:he,r:6,fill:I,opacity:.3,children:[jsx("animate",{attributeName:"r",values:"4;9;4",dur:"2s",repeatCount:"indefinite"}),jsx("animate",{attributeName:"opacity",values:"0.4;0.05;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsx("circle",{cx:ve,cy:he,r:3.5,fill:I})]})}},`pulse-${C.marketSlug}`)})]})})]})}),jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"6px 8px",marginTop:6},children:[o!=null&&o>0&&jsxs("span",{style:{color:"#6b7280",fontSize:12},children:["$",Math.round(o).toLocaleString()," vol"]}),jsx("div",{style:{flex:1,minWidth:0}}),jsx(yd,{value:l,onChange:c}),s.length>1&&jsx("div",{style:{width:"100%",display:"flex",alignItems:"center"},children:jsx(wd,{markets:s,selectedSlugs:a,colorMap:p,onToggle:K})})]})]})]})}function Vt(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function zd(e){return `${parseFloat((e*100).toFixed(2))}%`}function xs(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function vr(e){return e.outcomes?.[0]?.label??e.question}function Wd(e){switch(e){case "polymarket":return "Polymarket";case "kalshi":return "Kalshi";default:return e}}function Kt(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 vs(e){let[t,r]=useState(0);if(useEffect(()=>{if(!e)return;r(Date.now());let p=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(p)},[e]),!e||t===0)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),l=Math.floor(n%6e4/1e3),c=[];return s>0&&c.push(`${s}d`),c.push(`${String(a).padStart(2,"0")}h`),c.push(`${String(i).padStart(2,"0")}m`),c.push(`${String(l).padStart(2,"0")}s`),c.join(" ")}function bs(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(),l=i>=0?"+":"-",c=String(Math.abs(Math.floor(i/60))).padStart(2,"0");return `${r}:${o} ${n}/${s}/${a} (${l}${c})`}function ws({event:e,onTradeAction:t}){let{t:r}=useTranslation(),{ref:o,isCollapsed:n}=useScrollCollapse(),s=useMemo(()=>{let u=[...e.markets||[]],m=u.filter(f=>f.status==="open").sort((f,g)=>Vt(g)-Vt(f)),d=u.filter(f=>f.status!=="open").sort((f,g)=>Vt(g)-Vt(f));return [...m,...d]},[e.markets]),a=e.status==="closed"||e.status==="voided",i=vs(a?void 0:e.start_at),l=vs(a?void 0:e.end_at),c=bs(e.start_at),p=bs(e.end_at);return jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxs("div",{ref:o,className:`sticky top-0 z-30 flex items-center backdrop-blur-md transition-all duration-300 ${n?"h-14 lg:h-16 gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"h-16 lg:h-20 gap-x-2 lg:gap-x-4"}`,children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",classNames:{base:"bg-transparent"},className:`flex-shrink-0 transition-all duration-300 ${n?"!h-10 !w-10 lg:!h-12 lg:!w-12":"!h-16 !w-16 lg:!h-20 lg:!w-20"}`}),jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[!n&&jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((u,m)=>jsxs(Fragment$1,{children:[m>0&&jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-sm text-neutral truncate",children:u.label})]},u.slug)),jsx(jd,{source:e.source})]}),jsx("span",{className:`font-semibold truncate transition-all duration-300 ${n?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),(i||l||a)&&jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:a?p&&jsx("span",{className:"text-neutral",children:r("predict.event.endedAt",{time:p})}):i?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.beginsIn",{time:i})}),c&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:c})]})]}):l?jsxs(Fragment,{children:[jsx("span",{className:"text-foreground",children:r("predict.event.endsIn",{time:l})}),p&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsx("span",{className:"text-neutral",children:p})]})]}):null}),jsx(hs,{event:e,volume:e.volume??void 0}),jsx(Ud,{markets:s,onTradeAction:t}),jsx(Vd,{markets:s,event:e})]})}var ys=5;function Ud({markets:e,onTradeAction:t}){let{t:r}=useTranslation(),{isMobile:o}=useScreen(),[n,s]=useState(false),[a,i]=useState(null),l=useMemo(()=>{let h=new Set;return e.filter(x=>h.has(x.slug)?false:(h.add(x.slug),true))},[e]),c=l.find(h=>h.status==="open")?.slug,[p,u]=useState(c?`${c}:yes`:null);if(l.length===0)return null;let m=l.length>ys,d=n?l:l.slice(0,ys),f=h=>{i(x=>x===h?null:h);},g=(h,x,w)=>{u(`${h.slug}:${x}`),o||i(h.slug),t?.(h,x,w);};return jsxs("div",{className:"flex flex-col",children:[jsxs("table",{className:"w-full border-collapse",children:[jsx("thead",{children:jsxs("tr",{children:[jsx("th",{}),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")}),jsx("th",{})]})}),jsx("tbody",{children:d.map((h,x)=>{let w=Vt(h),b=h.outcomes[1]?.best_ask??h.outcomes[1]?.price,L=a===h.slug;return jsx(Kd,{market:h,yesPrice:w,noPrice:b??void 0,activeYes:p===`${h.slug}:yes`,activeNo:p===`${h.slug}:no`,isExpanded:L,onToggleExpand:()=>f(h.slug),onTradeAction:g},h.id??`${x}-${h.slug}`)})})]}),m&&jsxs("button",{type:"button",onClick:()=>s(h=>!h),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:[jsx("span",{children:r(n?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsx(ChevronDownIcon,{className:cn$1("h-4 w-4 transition-transform",n&&"rotate-180")})]})]})}function Kd({market:e,yesPrice:t,noPrice:r,activeYes:o,activeNo:n,isExpanded:s,onToggleExpand:a,onTradeAction:i}){let{t:l}=useTranslation(),c=e.status==="open",p=e.volume?`$${Math.round(e.volume).toLocaleString("en-US")} vol`:void 0;return jsxs(Fragment,{children:[jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:a,role:"button",tabIndex:0,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),a());},children:[jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[e.image_url&&jsx(Avatar,{src:e.image_url,name:vr(e)?.[0]||"?",radius:"lg",className:"size-5 shrink-0 lg:size-8",imgProps:{className:"object-cover"}}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-foreground truncate max-w-[200px] lg:max-w-[300px]",children:vr(e)}),p&&jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:p})]})]})}),jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:zd(t)}),jsx("td",{className:"py-2 pr-1 lg:pr-2",children:c?jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsx("button",{type:"button",className:cn$1("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all",o?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:u=>{u.stopPropagation(),i?.(e,"yes","buy");},children:l("predict.market.action.yes",{price:xs(t)})}),jsx("button",{type:"button",className:cn$1("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all",n?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:u=>{u.stopPropagation(),i?.(e,"no","buy");},children:r!=null?l("predict.market.action.no",{price:xs(r)}):l("predict.market.no")})]}):jsx("div",{className:"flex items-center justify-end",children:jsx("span",{className:cn$1("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",e.status==="closed"?"bg-neutral/10 text-neutral":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?l("predict.event.status.closed"):e.status==="voided"?l("predict.event.status.voided"):l("predict.event.status.pending")})})})]}),s&&jsx("tr",{children:jsx("td",{colSpan:3,className:"pb-3",children:jsx("div",{className:"max-h-100 overflow-y-auto",children:jsx(ms,{market:e,outcome:n?"no":"yes",onTradeAction:i})})})})]})}function Vd({markets:e,event:t}){let{t:r}=useTranslation(),[o,n]=useState(false),[s,a]=useState(false),[i,l]=useState(0),c=e.filter(d=>d.rules&&d.rules.length>0||d.description);if(c.length===0)return null;let p=c[i]??c[0],u=p.rules&&p.rules.length>0?p.rules.join(`
|
|
20
20
|
|
|
21
|
-
`):p.description??"";if(!u)return null;let m=u.length>200&&!o?u.slice(0,200)+"...":u;return jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:r("predict.event.rules")}),c.length>1&&jsxs(Dropdown,{placement:"bottom-end",classNames:{content:"min-w-36 bg-content1 border border-border"},children:[jsx(DropdownTrigger,{children:jsx(Button,{size:"sm",variant:"bordered",radius:"lg",endContent:jsx(ChevronDownIcon,{className:"h-3.5 w-3.5"}),className:"text-xs text-foreground",children:br(p)})}),jsx(DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(a)],onAction:d=>{l(Number(d)),n(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:c.map((d,f)=>jsx(DropdownItem,{className:cn$1(f===a?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:br(d)},String(f)))})]})]}),jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:m}),u.length>200&&jsx("button",{type:"button",onClick:()=>n(d=>!d),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(o?"predict.event.rules.collapse":"predict.event.showMore")}),jsxs("button",{type:"button",onClick:()=>i(d=>!d),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:[jsx("span",{children:r("predict.event.timelineAndPayout")}),jsx(ChevronDownIcon,{className:cn$1("h-4 w-4 transition-transform",s&&"rotate-180")})]}),s&&jsxs(Fragment,{children:[jsx("div",{className:"flex flex-col",children:(()=>{let d=p.status,f=[];return p.created_at&&f.push({label:r("predict.event.timeline.created"),value:Vt(p.created_at),isActive:true}),f.push({label:r("predict.event.timeline.open"),value:Vt(p.start_at),isActive:d!=="pending"}),d==="voided"?f.push({label:r("predict.event.timeline.voided"),value:Vt(p.closed_at??p.end_at),isActive:true}):d==="closed"?f.push({label:r("predict.event.timeline.closed"),value:Vt(p.closed_at??p.end_at),isActive:true}):f.push({label:r("predict.event.timeline.close"),value:Vt(p.end_at),isActive:false}),f})().map((d,f,g)=>jsxs("div",{className:"flex items-stretch gap-x-3",children:[jsxs("div",{className:"flex flex-col items-center w-3",children:[jsx("div",{className:`h-3 w-3 shrink-0 rounded-full border-2 mt-0.5 ${d.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),f<g.length-1&&jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxs("div",{className:`flex flex-col ${f<g.length-1?"pb-4":""}`,children:[jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:d.label}),jsx("span",{className:"text-xs text-neutral lg:text-sm",children:d.value})]})]},d.label))}),jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.event"),":"]})," ",jsx("span",{className:"text-foreground",children:t.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.market"),":"]})," ",jsx("span",{className:"text-foreground",children:p.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsx("span",{className:"text-foreground",children:Bd(p.source)})]})]})]})]})}function Ud({source:e}){return jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsx(PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsx(KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}function Ss({eventSlug:e,source:t,onTradeAction:r}){let{data:o,isLoading:n,error:s}=useEvent({slug:e,source:t});return n?jsx(Ut,{}):s||!o?jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:s?.message||"Event not found"}):jsx(ks,{event:o,onTradeAction:r})}function ws({eventSlug:e,source:t,limit:r=4,onEventClick:o}){let{t:n}=useTranslation(),{data:s,isLoading:i}=useSimilarEvents({slug:e,source:t,limit:r});return i||!s||s.length===0?null:jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:n("predict.similar.title")}),jsx("div",{className:"grid grid-cols-1 gap-3",children:s.map(a=>jsx(qd,{event:a,onClick:o},`${a.source}-${a.slug}`))})]})}function qd({event:e,onClick:t}){let r=e.volume;return 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:[jsx(Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"lg",className:"size-8 shrink-0 bg-transparent",imgProps:{className:"object-cover"}}),jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[jsx("span",{className:"text-sm font-medium text-foreground truncate",children:e.title}),r!=null&&r>0&&jsxs("span",{className:"text-xs text-neutral",children:["$",Math.round(r).toLocaleString()," vol"]})]}),jsx(ChevronRightIcon,{className:"h-4 w-4 text-neutral shrink-0"})]})}function Ns(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function kh({eventSlug:e,source:t,chain:r,walletAddress:o,onSimilarEventClick:n,onBack:s}){let{t:i}=useTranslation(),{isMobile:a}=useScreen(),{onOpen:l}=useAsyncModal(At),{data:c,isLoading:p}=useEvent({slug:e,source:t}),u=useMemo(()=>[...c?.markets||[]].sort((x,P)=>Ns(P)-Ns(x)),[c?.markets]),[m,d]=useState(null),f=useCallback((x,P,b)=>{d(R=>({market:x,outcome:P,side:b,version:(R?.version??0)+1})),a&&c&&l({params:{event:c,market:x,initialOutcome:P,chain:r}});},[a,c,r,l]),g=m?.market??u[0];if(p){let x=!!s;return a?jsx(Ut,{showBack:x}):jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsx(Ut,{showBack:x})}),jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsx("div",{className:"sticky top-4 max-h-[calc(100dvh-2rem)] overflow-y-auto scrollbar-thin",children:jsx(es,{})})})]})}let h=m?`${m.market.slug}-${m.version}`:g?.slug??"default";return jsxs("div",{className:"flex w-full flex-col gap-y-4 pb-12 lg:max-w-7xl lg:gap-y-8 lg:pb-16 mx-auto",children:[jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[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&&jsx("div",{className:"flex items-center justify-between",children:jsx(Button,{as:"a",onPress:s,startContent:jsx(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:i("common.back")})}),jsx(Ss,{eventSlug:e,source:t,onTradeAction:f})]}),jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[g&&jsx(lr,{event:c,market:g,initialSide:m?.side,initialOutcome:m?.outcome,chain:r},h),c&&jsx(ws,{eventSlug:e,source:c.source,onEventClick:n})]})]}),c&&jsx("div",{className:"flex w-full flex-col",children:jsx(Jo,{event:c,walletAddress:o})}),jsx(cr,{})]})}function Ps(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function cu(e){switch(e){case ChartRange.ONE_DAY:return {interval:"15m",limit:96};case ChartRange.ONE_WEEK:return {interval:"1h",limit:168};case ChartRange.ONE_MONTH:return {interval:"4h",limit:180};case ChartRange.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var Eh=e=>{let{candlestickMarketSlugs:t,chartRange:r=ir,source:o}=e,n=usePredictClient(),s=useMemo(()=>cu(r),[r]),{data:i,isLoading:a,error:l}=useEvent({slug:e.eventSlug,source:o}),c=useMemo(()=>{if(!i?.markets)return [];let f=new Set,g=i.markets.filter(x=>f.has(x.slug)?false:(f.add(x.slug),true));return (t&&t.length>0?t.slice(0,4).map(x=>g.find(P=>P.slug===x)).filter(x=>x!==void 0):[...g].sort((x,P)=>Ps(P)-Ps(x)).slice(0,4)).map(x=>x.slug)},[t,i?.markets]),p=useQueries({queries:c.map(f=>({queryKey:candlesticksQueryKey(f,s),queryFn:()=>n.listCandlesticks(f,s),enabled:c.length>0}))}),u=p.some(f=>f.isLoading),m=useMemo(()=>{let f=new Map;return c.forEach((g,h)=>{let x=p[h]?.error;x&&f.set(g,x);}),f},[c,p]),d=useMemo(()=>{let f=new Map;return c.forEach((g,h)=>{let x=p[h]?.data;x&&f.set(g,x);}),f},[c,p]);return {event:i,isEventLoading:a,eventError:l,candlestickParams:s,candlesticks:d,isCandlesticksLoading:u,candlestickErrors:m}};var pu=10,mu=atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function Nr(){let[e,t]=useAtom(mu),r=useCallback(n=>{let s=n.trim();s&&t(i=>{let a=i.filter(l=>l!==s);return [s,...a].slice(0,pu)});},[t]),o=useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:o}}function Ts({histories:e,onSelect:t,onClear:r,className:o}){let{t:n}=useTranslation();return e.length===0?null:jsxs("div",{className:cn$1("px-4 pb-4",o),children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium",children:n("predict.search.history")}),jsx(Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(TrashIcon,{width:20,height:20})})]}),jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(s=>jsx(Chip,{size:"sm",variant:"bordered",className:cn$1("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(s),children:s},s))})]})}function Ls({onSelect:e,className:t}){let{histories:r,clearHistories:o}=Nr();return jsx(Ts,{className:cn$1(t),histories:r,onSelect:e,onClear:o})}function _s({value:e,onValueChange:t,onClear:r,onEscape:o,className:n}){let{t:s}=useTranslation();return jsx("div",{className:n,children:jsx(StyledInput,{autoFocus:true,variant:"bordered",radius:"lg",value:e,onValueChange:t,placeholder:s("predict.search.placeholder"),classNames:{inputWrapper:["!bg-[rgba(39,39,42,0.6)]","!border-[rgba(63,63,70,0.5)]","data-[hover=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!border-[rgba(63,63,70,0.8)]"].join(" ")},startContent:jsx(SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsx(Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(XCloseIcon,{width:20,height:20})}):jsx(Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-[rgba(63,63,70,0.5)] rounded-lg cursor-pointer select-none",onMouseDown:i=>{i.preventDefault(),o?.();},children:"Esc"})})})}var Tu={kalshi:{label:"KALSHI",color:"#00d492",bgColor:"rgba(0, 212, 146, 0.12)",icon:jsx(KalshiIcon,{className:"w-3.5 h-3.5 shrink-0"})},polymarket:{label:"POLYMARKET",color:"#50a2ff",bgColor:"rgba(43, 127, 255, 0.12)",icon:jsx(PolymarketIcon,{className:"w-3.5 h-3.5 shrink-0"})},dflow:{label:"DFLOW",color:"rgb(16, 185, 129)",bgColor:"rgba(16, 185, 129, 0.12)",icon:null}},Lu={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function ot(e){return Tu[e]??Lu}function fx({source:e,className:t}){let r=ot(e);return jsxs("span",{className:cn$1("inline-flex items-center gap-x-1 rounded-md px-1.5 py-0.5 text-xs font-medium",t),style:{backgroundColor:r.bgColor,color:r.color},children:[r.icon,r.label]})}function Hu(e){return e==null?"-":e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${e.toFixed(0)}`}function Is({event:e,href:t,LinkComponent:r,onSelect:o,onHover:n,className:s}){let{t:i}=useTranslation(),a=e.tags?.[0],l=ot(e.source),c=useMemo(()=>Hu(e.volume),[e.volume]);return jsxs(Linkable,{href:t,LinkComponent:r,className:cn$1("group 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:p=>{t&&o&&p.preventDefault(),o?.(e);},onMouseEnter:()=>n?.(e),children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-y-0.5",children:[jsx("span",{className:"min-w-0 text-sm font-medium line-clamp-2 group-hover:text-primary transition-colors",children:e.title}),jsxs("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[jsxs("span",{className:"inline-flex items-center gap-x-1 shrink-0",style:{color:l.color},children:[l.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:l.label})]}),jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsxs("span",{className:"text-neutral-400",children:[c," ",i("predict.event.volume")]}),a&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsx("span",{className:"text-neutral-500",children:a.label})]})]})]}),jsx(ChevronRightIcon,{width:16,height:16,className:"shrink-0 text-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function Os({keyword:e="",limit:t,source:r}){let{data:o,isLoading:n,isFetchingNextPage:s,hasNextPage:i,fetchNextPage:a}=useSearchEvents({keyword:e,limit:t,source:r,sort_by:e?void 0:"volume",sort_asc:e?void 0:false},{enabled:true});return {events:useMemo(()=>o?.pages.flatMap(c=>c.items).filter(c=>c!=null)??[],[o]),isLoading:n,isFetchingNextPage:s,hasNextPage:i??false,fetchNextPage:a}}var Yu=64;function Hs({onSelect:e,getEventHref:t,LinkComponent:r,onHover:o,className:n,...s}){let{events:i,isLoading:a,isFetchingNextPage:l,hasNextPage:c,fetchNextPage:p}=Os(s),u=useRef(null),{height:m}=useResizeObserver({ref:u}),d=useCallback(x=>x<i.length,[i]),f=useCallback(async()=>{c&&!l&&await p();},[c,l,p]),g=useMemo(()=>c?i.length+1:i.length,[i,c]),h=useInfiniteLoader({isRowLoaded:d,loadMoreRows:f,rowCount:g,threshold:5});return a?jsx(Qu,{className:n}):i.length===0?jsx(Xu,{className:n}):jsx("div",{className:cn$1("w-full h-full flex flex-col",n),children:jsx("div",{className:"flex-auto min-h-0",ref:u,children:jsx(List,{className:"no-scrollbar",style:{height:m},onRowsRendered:h,rowComponent:qu,rowCount:g,rowHeight:Yu,rowProps:{events:i,onSelect:e,getEventHref:t,LinkComponent:r,onHover:o},overscanCount:5})})})}function qu({index:e,style:t,events:r,onSelect:o,getEventHref:n,LinkComponent:s,onHover:i}){let a=r[e];return a?jsx("div",{style:t,children:jsx(Is,{event:a,href:n?.(a),LinkComponent:s,onSelect:o,onHover:i})}):jsx("div",{style:t,className:"flex items-center justify-center",children:jsx(Spinner,{size:"sm"})})}function Qu({className:e}){let{t}=useTranslation();return jsxs("div",{className:cn$1("flex items-center justify-center gap-2 py-16",e),children:[jsx(Spinner,{size:"sm"}),jsx("span",{className:"text-sm text-neutral",children:t("predict.search.loading")})]})}function Xu({className:e}){let{t}=useTranslation();return jsxs("div",{className:cn$1("flex flex-col items-center justify-center py-16",e),children:[jsx(EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsx("p",{className:"mt-2 text-sm text-neutral",children:t("predict.search.noResults")})]})}function Ws({onKeywordChange:e}){let[t,r]=useState(""),[o,n]=useState(""),{addHistory:s}=Nr(),i=useCallbackRef(e),a=useCallbackRef(s),l=useMemo(()=>debounce(m=>{n(m),i(m),m&&a(m);},500),[i,a]),c=useCallback(m=>{r(m),l(m);},[l]),p=useCallback(m=>{l.cancel(),r(m),n(m),i(m),m&&a(m);},[l,i,a]),u=useCallback(()=>p(""),[p]);return {text:t,keyword:o,setText:c,setKeyword:p,clearKeyword:u}}function Us({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:o,onHover:n,onEscape:s,source:i}){let{text:a,keyword:l,setText:c,setKeyword:p,clearKeyword:u}=Ws({onKeywordChange:e});return jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsx(_s,{value:a,onValueChange:c,onClear:u,onEscape:s}),!l&&jsx(Ls,{onSelect:p}),jsx(Hs,{className:"flex-auto min-h-0",keyword:l,onSelect:t,getEventHref:r,LinkComponent:o,onHover:n,source:i})]})}var Sn="predict-search";function Jx({id:e=Sn}){return jsx(AsyncModal,{id:e,children:t=>jsx(dp,{...t})})}function dp({params:e,isOpen:t,onOpenChange:r,onResult:o}){let{t:n}=useTranslation(),{isMobile:s}=useScreen(),i=useCallback(l=>{o(l);},[o]),a=useCallback(()=>{r(false);},[r]);return jsx(StyledModal,{isOpen:t,onOpenChange:r,size:s?"full":"lg",hideCloseButton:true,backdrop:"blur",radius:"lg",children:jsxs(ModalContent,{className:"w-full h-full",style:{borderRadius:s?void 0:14,border:s?void 0:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:s?void 0:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"},children:[jsxs(ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsx("span",{className:"text-base font-semibold",children:n("predict.search.title")}),jsx(Button,{isIconOnly:true,onPress:()=>r(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsx(XCloseIcon,{width:20,height:20})})]}),jsx(ModalBody,{className:"p-4",children:jsx(Us,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:i,onEscape:a})})]})})}function lv({onSelectEvent:e,modalParams:t,className:r}){let{t:o}=useTranslation(),{isDesktop:n,isMobile:s}=useScreen(),{onOpen:i,onClose:a}=useAsyncModal(Sn),l=useCallbackRef(e),c=useCallbackRef(async()=>{let u=await i({params:t});u&&l(u);}),p=useCallbackRef(()=>{a();});return useEffect(()=>{let u=m=>{let d=document.activeElement,f=!!d&&(d.tagName==="INPUT"||d.tagName==="TEXTAREA"||d.getAttribute("contenteditable")==="true");m.key==="/"&&!f&&(m.preventDefault(),c()),m.key==="Escape"&&(m.preventDefault(),p());};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u);}},[c,p]),jsx(Button,{size:"sm",radius:"full",isIconOnly:!n,onPress:c,variant:s?"flat":"bordered",startContent:n?jsx(SearchIcon,{className:"text-neutral"}):void 0,endContent:n?jsx(Kbd,{className:"ml-auto min-w-6 justify-center text-xs bg-transparent border border-border rounded-full",children:"/"}):void 0,className:cn$1(n&&"min-w-56 justify-start pl-3 pr-1.5 text-neutral",r),children:n?o("predict.search.placeholder"):jsx(SearchIcon,{className:"text-neutral"})})}var Nn=[{value:"spread",labelKey:"predict.matches.sort.spread",descKey:"predict.matches.sort.spreadDesc",icon:"trending-up"},{value:"volume",labelKey:"predict.matches.sort.volume",descKey:"predict.matches.sort.volumeDesc",icon:"chart-column"},{value:"confidence",labelKey:"predict.matches.sort.confidence",descKey:"predict.matches.sort.confidenceDesc",icon:"flame"}],Zs=[{labelKey:"predict.matches.filter.noMinimum",label:"$0",value:0},{labelKey:null,label:"$100+",value:100},{labelKey:null,label:"$500+",value:500},{labelKey:null,label:"$1K+",value:1e3},{labelKey:null,label:"$5K+",value:5e3},{labelKey:null,label:"$10K+",value:1e4},{labelKey:null,label:"$50K+",value:5e4},{labelKey:null,label:"$100K+",value:1e5}],qs={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},Qs={position:"absolute",right:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function yp(e,t){if(!e)return "$5K+";let r=Zs.find(o=>o.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function Js({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:o,minVolume:n,onMinVolumeChange:s,onRefresh:i}){let{t:a}=useTranslation(),[l,c]=useState(false),[p,u]=useState(false),[m,d]=useState(false),[f,g]=useState(false),h=useRef(null),x=useRef(null),P=Nn.find(v=>v.value===e)??Nn[0],b=useCallback(v=>{h.current&&!h.current.contains(v.target)&&c(false),x.current&&!x.current.contains(v.target)&&u(false);},[]);useEffect(()=>(document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)),[b]);let R=useCallback(()=>{i?.(),g(true),setTimeout(()=>g(false),700);},[i]);return jsxs(Fragment,{children:[jsx("style",{children:`
|
|
21
|
+
`):p.description??"";if(!u)return null;let m=u.length>200&&!o?u.slice(0,200)+"...":u;return jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:r("predict.event.rules")}),c.length>1&&jsxs(Dropdown,{placement:"bottom-end",classNames:{content:"min-w-36 bg-content1 border border-border"},children:[jsx(DropdownTrigger,{children:jsx(Button,{size:"sm",variant:"bordered",radius:"lg",endContent:jsx(ChevronDownIcon,{className:"h-3.5 w-3.5"}),className:"text-xs text-foreground",children:vr(p)})}),jsx(DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(i)],onAction:d=>{l(Number(d)),n(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:c.map((d,f)=>jsx(DropdownItem,{className:cn$1(f===i?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:vr(d)},String(f)))})]})]}),jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:m}),u.length>200&&jsx("button",{type:"button",onClick:()=>n(d=>!d),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(o?"predict.event.rules.collapse":"predict.event.showMore")}),jsxs("button",{type:"button",onClick:()=>a(d=>!d),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:[jsx("span",{children:r("predict.event.timelineAndPayout")}),jsx(ChevronDownIcon,{className:cn$1("h-4 w-4 transition-transform",s&&"rotate-180")})]}),s&&jsxs(Fragment,{children:[jsx("div",{className:"flex flex-col",children:(()=>{let d=p.status,f=[];return p.created_at&&f.push({label:r("predict.event.timeline.created"),value:Kt(p.created_at),isActive:true}),f.push({label:r("predict.event.timeline.open"),value:Kt(p.start_at),isActive:d!=="pending"}),d==="voided"?f.push({label:r("predict.event.timeline.voided"),value:Kt(p.closed_at??p.end_at),isActive:true}):d==="closed"?f.push({label:r("predict.event.timeline.closed"),value:Kt(p.closed_at??p.end_at),isActive:true}):f.push({label:r("predict.event.timeline.close"),value:Kt(p.end_at),isActive:false}),f})().map((d,f,g)=>jsxs("div",{className:"flex items-stretch gap-x-3",children:[jsxs("div",{className:"flex flex-col items-center w-3",children:[jsx("div",{className:`h-3 w-3 shrink-0 rounded-full border-2 mt-0.5 ${d.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),f<g.length-1&&jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxs("div",{className:`flex flex-col ${f<g.length-1?"pb-4":""}`,children:[jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:d.label}),jsx("span",{className:"text-xs text-neutral lg:text-sm",children:d.value})]})]},d.label))}),jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.event"),":"]})," ",jsx("span",{className:"text-foreground",children:t.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.market"),":"]})," ",jsx("span",{className:"text-foreground",children:p.slug})]}),jsxs("span",{children:[jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsx("span",{className:"text-foreground",children:Wd(p.source)})]})]})]})]})}function jd({source:e}){return jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsx(PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsx(KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}function Ns({eventSlug:e,source:t,onTradeAction:r}){let{data:o,isLoading:n,error:s}=useEvent({slug:e,source:t});return n?jsx(Wt,{}):s||!o?jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:s?.message||"Event not found"}):jsx(ws,{event:o,onTradeAction:r})}function Ps({eventSlug:e,source:t,limit:r=4,onEventClick:o}){let{t:n}=useTranslation(),{data:s,isLoading:a}=useSimilarEvents({slug:e,source:t,limit:r});return a||!s||s.length===0?null:jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:n("predict.similar.title")}),jsx("div",{className:"grid grid-cols-1 gap-3",children:s.map(i=>jsx(Zd,{event:i,onClick:o},`${i.source}-${i.slug}`))})]})}function Zd({event:e,onClick:t}){let r=e.volume;return 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:[jsx(Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"lg",className:"size-8 shrink-0 bg-transparent",imgProps:{className:"object-cover"}}),jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[jsx("span",{className:"text-sm font-medium text-foreground truncate",children:e.title}),r!=null&&r>0&&jsxs("span",{className:"text-xs text-neutral",children:["$",Math.round(r).toLocaleString()," vol"]})]}),jsx(ChevronRightIcon,{className:"h-4 w-4 text-neutral shrink-0"})]})}function Cs(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Ph({eventSlug:e,source:t,chain:r,walletAddress:o,onSimilarEventClick:n,onBack:s}){let{t:a}=useTranslation(),{isMobile:i}=useScreen(),{onOpen:l}=useAsyncModal(Ot),{data:c,isLoading:p}=useEvent({slug:e,source:t}),u=useMemo(()=>[...c?.markets||[]].sort((x,w)=>Cs(w)-Cs(x)),[c?.markets]),[m,d]=useState(null),f=useCallback((x,w,b)=>{d(L=>({market:x,outcome:w,side:b,version:(L?.version??0)+1})),i&&c&&l({params:{event:c,market:x,initialOutcome:w,chain:r}});},[i,c,r,l]),g=m?.market??u[0];if(p){let x=!!s;return i?jsx(Wt,{showBack:x}):jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsx(Wt,{showBack:x})}),jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsx("div",{className:"sticky top-4 max-h-[calc(100dvh-2rem)] overflow-y-auto scrollbar-thin",children:jsx(rs,{})})})]})}let h=m?`${m.market.slug}-${m.version}`:g?.slug??"default";return jsxs("div",{className:"flex w-full flex-col gap-y-4 pb-12 lg:max-w-7xl lg:gap-y-8 lg:pb-16 mx-auto",children:[jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[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&&jsx("div",{className:"flex items-center justify-between",children:jsx(Button,{as:"a",onPress:s,startContent:jsx(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")})}),jsx(Ns,{eventSlug:e,source:t,onTradeAction:f})]}),jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[g&&jsx(ar,{event:c,market:g,initialSide:m?.side,initialOutcome:m?.outcome,chain:r},h),c&&jsx(Ps,{eventSlug:e,source:c.source,onEventClick:n})]})]}),c&&jsx("div",{className:"flex w-full flex-col",children:jsx(ts,{event:c,walletAddress:o})}),jsx(lr,{})]})}function Ms(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function pu(e){switch(e){case ChartRange.ONE_DAY:return {interval:"15m",limit:96};case ChartRange.ONE_WEEK:return {interval:"1h",limit:168};case ChartRange.ONE_MONTH:return {interval:"4h",limit:180};case ChartRange.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var Rh=e=>{let{candlestickMarketSlugs:t,chartRange:r=ir,source:o}=e,n=usePredictClient(),s=useMemo(()=>pu(r),[r]),{data:a,isLoading:i,error:l}=useEvent({slug:e.eventSlug,source:o}),c=useMemo(()=>{if(!a?.markets)return [];let f=new Set,g=a.markets.filter(x=>f.has(x.slug)?false:(f.add(x.slug),true));return (t&&t.length>0?t.slice(0,4).map(x=>g.find(w=>w.slug===x)).filter(x=>x!==void 0):[...g].sort((x,w)=>Ms(w)-Ms(x)).slice(0,4)).map(x=>x.slug)},[t,a?.markets]),p=useQueries({queries:c.map(f=>({queryKey:candlesticksQueryKey(f,s),queryFn:()=>n.listCandlesticks(f,s),enabled:c.length>0}))}),u=p.some(f=>f.isLoading),m=useMemo(()=>{let f=new Map;return c.forEach((g,h)=>{let x=p[h]?.error;x&&f.set(g,x);}),f},[c,p]),d=useMemo(()=>{let f=new Map;return c.forEach((g,h)=>{let x=p[h]?.data;x&&f.set(g,x);}),f},[c,p]);return {event:a,isEventLoading:i,eventError:l,candlestickParams:s,candlesticks:d,isCandlesticksLoading:u,candlestickErrors:m}};var gu=10,hu=atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function wr(){let[e,t]=useAtom(hu),r=useCallback(n=>{let s=n.trim();s&&t(a=>{let i=a.filter(l=>l!==s);return [s,...i].slice(0,gu)});},[t]),o=useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:o}}function _s({histories:e,onSelect:t,onClear:r,className:o}){let{t:n}=useTranslation();return e.length===0?null:jsxs("div",{className:cn$1("px-4 pb-4",o),children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("span",{className:"text-sm font-medium",children:n("predict.search.history")}),jsx(Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(TrashIcon,{width:20,height:20})})]}),jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(s=>jsx(Chip,{size:"sm",variant:"bordered",className:cn$1("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(s),children:s},s))})]})}function Rs({onSelect:e,className:t}){let{histories:r,clearHistories:o}=wr();return jsx(_s,{className:cn$1(t),histories:r,onSelect:e,onClear:o})}function Is({value:e,onValueChange:t,onClear:r,onEscape:o,className:n}){let{t:s}=useTranslation();return jsx("div",{className:n,children:jsx(StyledInput,{autoFocus:true,variant:"bordered",radius:"lg",value:e,onValueChange:t,placeholder:s("predict.search.placeholder"),classNames:{inputWrapper:["!bg-[rgba(39,39,42,0.6)]","!border-[rgba(63,63,70,0.5)]","data-[hover=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!bg-[rgba(39,39,42,1)]","group-data-[focus=true]:!border-[rgba(63,63,70,0.8)]"].join(" ")},startContent:jsx(SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsx(Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsx(XCloseIcon,{width:20,height:20})}):jsx(Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-[rgba(63,63,70,0.5)] rounded-lg cursor-pointer select-none",onMouseDown:a=>{a.preventDefault(),o?.();},children:"Esc"})})})}var Ru={kalshi:{label:"KALSHI",color:"#00d492",bgColor:"rgba(0, 212, 146, 0.12)",icon:jsx(KalshiIcon,{className:"w-3.5 h-3.5 shrink-0"})},polymarket:{label:"POLYMARKET",color:"#50a2ff",bgColor:"rgba(43, 127, 255, 0.12)",icon:jsx(PolymarketIcon,{className:"w-3.5 h-3.5 shrink-0"})},dflow:{label:"DFLOW",color:"rgb(16, 185, 129)",bgColor:"rgba(16, 185, 129, 0.12)",icon:null}},Iu={label:"Unknown",color:"rgb(156, 163, 175)",bgColor:"rgba(156, 163, 175, 0.12)",icon:null};function ot(e){return Ru[e]??Iu}function vx({source:e,className:t}){let r=ot(e);return jsxs("span",{className:cn$1("inline-flex items-center gap-x-1 rounded-md px-1.5 py-0.5 text-xs font-medium",t),style:{backgroundColor:r.bgColor,color:r.color},children:[r.icon,r.label]})}function zu(e){return e==null?"-":e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${e.toFixed(0)}`}function As({event:e,href:t,LinkComponent:r,onSelect:o,onHover:n,className:s}){let{t:a}=useTranslation(),i=e.tags?.[0],l=ot(e.source),c=useMemo(()=>zu(e.volume),[e.volume]);return jsxs(Linkable,{href:t,LinkComponent:r,className:cn$1("group 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:p=>{t&&o&&p.preventDefault(),o?.(e);},onMouseEnter:()=>n?.(e),children:[jsx(Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-y-0.5",children:[jsx("span",{className:"min-w-0 text-sm font-medium line-clamp-2 group-hover:text-primary transition-colors",children:e.title}),jsxs("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[jsxs("span",{className:"inline-flex items-center gap-x-1 shrink-0",style:{color:l.color},children:[l.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:l.label})]}),jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsxs("span",{className:"text-neutral-400",children:[c," ",a("predict.event.volume")]}),i&&jsxs(Fragment,{children:[jsx("span",{className:"text-neutral-600",children:"\xB7"}),jsx("span",{className:"text-neutral-500",children:i.label})]})]})]}),jsx(ChevronRightIcon,{width:16,height:16,className:"shrink-0 text-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function Ds({keyword:e="",limit:t,source:r}){let{data:o,isLoading:n,isFetchingNextPage:s,hasNextPage:a,fetchNextPage:i}=useSearchEvents({keyword:e,limit:t,source:r,sort_by:e?void 0:"volume",sort_asc:e?void 0:false},{enabled:true});return {events:useMemo(()=>o?.pages.flatMap(c=>c.items).filter(c=>c!=null)??[],[o]),isLoading:n,isFetchingNextPage:s,hasNextPage:a??false,fetchNextPage:i}}var Xu=64;function $s({onSelect:e,getEventHref:t,LinkComponent:r,onHover:o,className:n,...s}){let{events:a,isLoading:i,isFetchingNextPage:l,hasNextPage:c,fetchNextPage:p}=Ds(s),u=useRef(null),{height:m}=useResizeObserver({ref:u}),d=useCallback(x=>x<a.length,[a]),f=useCallback(async()=>{c&&!l&&await p();},[c,l,p]),g=useMemo(()=>c?a.length+1:a.length,[a,c]),h=useInfiniteLoader({isRowLoaded:d,loadMoreRows:f,rowCount:g,threshold:5});return i?jsx(Ju,{className:n}):a.length===0?jsx(ep,{className:n}):jsx("div",{className:cn$1("w-full h-full flex flex-col",n),children:jsx("div",{className:"flex-auto min-h-0",ref:u,children:jsx(List,{className:"no-scrollbar",style:{height:m},onRowsRendered:h,rowComponent:Zu,rowCount:g,rowHeight:Xu,rowProps:{events:a,onSelect:e,getEventHref:t,LinkComponent:r,onHover:o},overscanCount:5})})})}function Zu({index:e,style:t,events:r,onSelect:o,getEventHref:n,LinkComponent:s,onHover:a}){let i=r[e];return i?jsx("div",{style:t,children:jsx(As,{event:i,href:n?.(i),LinkComponent:s,onSelect:o,onHover:a})}):jsx("div",{style:t,className:"flex items-center justify-center",children:jsx(Spinner,{size:"sm"})})}function Ju({className:e}){let{t}=useTranslation();return jsxs("div",{className:cn$1("flex items-center justify-center gap-2 py-16",e),children:[jsx(Spinner,{size:"sm"}),jsx("span",{className:"text-sm text-neutral",children:t("predict.search.loading")})]})}function ep({className:e}){let{t}=useTranslation();return jsxs("div",{className:cn$1("flex flex-col items-center justify-center py-16",e),children:[jsx(EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsx("p",{className:"mt-2 text-sm text-neutral",children:t("predict.search.noResults")})]})}function Ks({onKeywordChange:e}){let[t,r]=useState(""),[o,n]=useState(""),{addHistory:s}=wr(),a=useCallbackRef(e),i=useCallbackRef(s),l=useMemo(()=>debounce(m=>{n(m),a(m),m&&i(m);},500),[a,i]),c=useCallback(m=>{r(m),l(m);},[l]),p=useCallback(m=>{l.cancel(),r(m),n(m),a(m),m&&i(m);},[l,a,i]),u=useCallback(()=>p(""),[p]);return {text:t,keyword:o,setText:c,setKeyword:p,clearKeyword:u}}function Vs({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:o,onHover:n,onEscape:s,source:a}){let{text:i,keyword:l,setText:c,setKeyword:p,clearKeyword:u}=Ks({onKeywordChange:e});return jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsx(Is,{value:i,onValueChange:c,onClear:u,onEscape:s}),!l&&jsx(Rs,{onSelect:p}),jsx($s,{className:"flex-auto min-h-0",keyword:l,onSelect:t,getEventHref:r,LinkComponent:o,onHover:n,source:a})]})}var Sn="predict-search";function nv({id:e=Sn}){return jsx(AsyncModal,{id:e,children:t=>jsx(mp,{...t})})}function mp({params:e,isOpen:t,onOpenChange:r,onResult:o}){let{t:n}=useTranslation(),{isMobile:s}=useScreen(),a=useCallback(l=>{o(l);},[o]),i=useCallback(()=>{r(false);},[r]);return jsx(StyledModal,{isOpen:t,onOpenChange:r,size:s?"full":"lg",hideCloseButton:true,backdrop:"blur",radius:"lg",children:jsxs(ModalContent,{className:"w-full h-full",style:{borderRadius:s?void 0:14,border:s?void 0:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:s?void 0:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"},children:[jsxs(ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsx("span",{className:"text-base font-semibold",children:n("predict.search.title")}),jsx(Button,{isIconOnly:true,onPress:()=>r(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsx(XCloseIcon,{width:20,height:20})})]}),jsx(ModalBody,{className:"p-4",children:jsx(Vs,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:a,onEscape:i})})]})})}function pv({onSelectEvent:e,modalParams:t,className:r}){let{t:o}=useTranslation(),{isDesktop:n,isMobile:s}=useScreen(),{onOpen:a,onClose:i}=useAsyncModal(Sn),l=useCallbackRef(e),c=useCallbackRef(async()=>{let u=await a({params:t});u&&l(u);}),p=useCallbackRef(()=>{i();});return useEffect(()=>{let u=m=>{let d=document.activeElement,f=!!d&&(d.tagName==="INPUT"||d.tagName==="TEXTAREA"||d.getAttribute("contenteditable")==="true");m.key==="/"&&!f&&(m.preventDefault(),c()),m.key==="Escape"&&(m.preventDefault(),p());};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u);}},[c,p]),jsx(Button,{size:"sm",radius:"full",isIconOnly:!n,onPress:c,variant:s?"flat":"bordered",startContent:n?jsx(SearchIcon,{className:"text-neutral"}):void 0,endContent:n?jsx(Kbd,{className:"ml-auto min-w-6 justify-center text-xs bg-transparent border border-border rounded-full",children:"/"}):void 0,className:cn$1(n&&"min-w-56 justify-start pl-3 pr-1.5 text-neutral",r),children:n?o("predict.search.placeholder"):jsx(SearchIcon,{className:"text-neutral"})})}var Nn=[{value:"spread",labelKey:"predict.matches.sort.spread",descKey:"predict.matches.sort.spreadDesc",icon:"trending-up"},{value:"volume",labelKey:"predict.matches.sort.volume",descKey:"predict.matches.sort.volumeDesc",icon:"chart-column"},{value:"confidence",labelKey:"predict.matches.sort.confidence",descKey:"predict.matches.sort.confidenceDesc",icon:"flame"}],ei=[{labelKey:"predict.matches.filter.noMinimum",label:"$0",value:0},{labelKey:null,label:"$100+",value:100},{labelKey:null,label:"$500+",value:500},{labelKey:null,label:"$1K+",value:1e3},{labelKey:null,label:"$5K+",value:5e3},{labelKey:null,label:"$10K+",value:1e4},{labelKey:null,label:"$50K+",value:5e4},{labelKey:null,label:"$100K+",value:1e5}],Xs={display:"inline-flex",alignItems:"center",gap:8,borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"8px 12px",fontSize:14,color:"#d4d4d8",cursor:"pointer",transition:"all 0.15s"},Zs={position:"absolute",right:0,top:"100%",zIndex:20,marginTop:8,borderRadius:14,border:"1px solid rgba(39,39,42,1)",background:"rgba(24,24,27,1)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",overflow:"hidden"};function wp(e,t){if(!e)return "$5K+";let r=ei.find(o=>o.value===e);return r?r.labelKey?t(r.labelKey):r.label:`$${e}`}function ti({sortBy:e,onSortChange:t,sortAsc:r,onSortAscChange:o,minVolume:n,onMinVolumeChange:s,onRefresh:a}){let{t:i}=useTranslation(),[l,c]=useState(false),[p,u]=useState(false),[m,d]=useState(false),[f,g]=useState(false),h=useRef(null),x=useRef(null),w=Nn.find(v=>v.value===e)??Nn[0],b=useCallback(v=>{h.current&&!h.current.contains(v.target)&&c(false),x.current&&!x.current.contains(v.target)&&u(false);},[]);useEffect(()=>(document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)),[b]);let L=useCallback(()=>{a?.(),g(true),setTimeout(()=>g(false),700);},[a]);return jsxs(Fragment,{children:[jsx("style",{children:`
|
|
22
22
|
@keyframes matchRefreshSpin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}
|
|
23
23
|
.match-refresh-spin{animation:matchRefreshSpin .6s ease-in-out}
|
|
24
24
|
.match-btn:focus-visible{outline:2px solid #c7ff2e;outline-offset:2px;z-index:10}
|
|
25
|
-
`}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:h,style:{position:"relative"},children:[jsxs("button",{type:"button",className:"match-btn",style:
|
|
25
|
+
`}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[jsxs("div",{ref:h,style:{position:"relative"},children:[jsxs("button",{type:"button",className:"match-btn",style:Xs,onMouseEnter:v=>{v.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:v=>{v.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{c(v=>!v),u(false);},children:[jsx(Np,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:i(w.labelKey)}),jsx(Js,{open:l})]}),l&&jsx("div",{style:{...Zs,width:224,padding:4},children:Nn.map(v=>{let T=e===v.value;return jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",gap:12,padding:"10px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",transition:"all 0.15s",background:T?"rgba(199,255,46,0.08)":"transparent",color:T?"#c7ff2e":"#a1a1aa",borderRadius:10},onMouseEnter:y=>{T||(y.currentTarget.style.background="rgba(39,39,42,0.5)",y.currentTarget.style.color="#fff");},onMouseLeave:y=>{T||(y.currentTarget.style.background="transparent",y.currentTarget.style.color="#a1a1aa");},onClick:()=>{e===v.value?o(!r):t(v.value),c(false);},children:[jsx("div",{style:{color:T?"#c7ff2e":"#71717a"},children:jsx(Pp,{type:v.icon})}),jsxs("div",{style:{flex:1,textAlign:"left"},children:[jsx("div",{style:{fontWeight:500},children:i(v.labelKey)}),jsx("div",{style:{fontSize:11,color:"#71717a",marginTop:1},children:i(v.descKey)})]}),T&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},v.value)})})]}),s&&jsxs("div",{ref:x,style:{position:"relative"},children:[jsxs("div",{style:{position:"relative",display:"inline-flex"},children:[jsxs("button",{type:"button",className:"match-btn",style:Xs,onMouseEnter:v=>{v.currentTarget.style.background="rgba(39,39,42,1)";},onMouseLeave:v=>{v.currentTarget.style.background="rgba(39,39,42,0.6)";},onClick:()=>{u(v=>!v),c(false);},children:[jsx(Cp,{}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:wp(n,i)}),jsx(Mp,{onMouseEnter:()=>d(true),onMouseLeave:()=>d(false)}),jsx(Js,{open:p})]}),m&&jsxs("div",{style:{position:"absolute",zIndex:100,top:"100%",marginTop:8,left:"50%",transform:"translateX(-50%)",width:256,padding:12,borderRadius:14,background:"rgba(24,24,27,1)",border:"1px solid rgba(63,63,70,0.5)",boxShadow:"0 25px 50px -12px rgba(0,0,0,0.5)",pointerEvents:"none"},children:[jsx("div",{style:{position:"absolute",top:-6,left:"50%",transform:"translateX(-50%) rotate(45deg)",width:12,height:12,background:"rgba(24,24,27,1)",borderLeft:"1px solid rgba(63,63,70,0.5)",borderTop:"1px solid rgba(63,63,70,0.5)"}}),jsxs("div",{style:{position:"relative",fontSize:12,color:"#d4d4d8",lineHeight:1.625},children:[jsxs("div",{style:{fontWeight:600,color:"#fff",display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#c7ff2e",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})}),i("predict.matches.filter.liquidityFilter")]}),jsx("p",{style:{color:"#a1a1aa",margin:"0 0 4px"},children:i("predict.matches.filter.tooltipDesc")}),jsx("p",{style:{color:"#71717a",fontSize:11,margin:0},children:i("predict.matches.filter.tooltipNote")})]})]})]}),p&&jsxs("div",{style:{...Zs,right:0,width:176},children:[jsx("div",{style:{padding:"8px 12px",borderBottom:"1px solid rgba(39,39,42,1)"},children:jsx("span",{style:{fontSize:11,fontWeight:500,color:"#71717a",textTransform:"uppercase",letterSpacing:"0.05em"},children:i("predict.matches.filter.minVolumeEach")})}),jsx("div",{style:{padding:4},children:ei.map(v=>{let T=v.value===0?!n:n===v.value;return jsxs("button",{type:"button",style:{display:"flex",width:"100%",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",textAlign:"left",fontSize:14,border:"none",cursor:"pointer",background:T?"rgba(199,255,46,0.08)":"transparent",color:T?"#c7ff2e":"#a1a1aa",borderRadius:10,transition:"all 0.15s"},onMouseEnter:y=>{T||(y.currentTarget.style.background="rgba(39,39,42,0.5)",y.currentTarget.style.color="#fff");},onMouseLeave:y=>{T||(y.currentTarget.style.background="transparent",y.currentTarget.style.color="#a1a1aa");},onClick:()=>{s?.(v.value===0?void 0:v.value),u(false);},children:[jsx("span",{children:v.labelKey?i(v.labelKey):v.label}),T&&jsx("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 6 9 17l-5-5"})})]},v.value)})})]})]}),a&&jsx("button",{type:"button",className:"match-btn",style:{borderRadius:10,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",width:36,height:36,color:"#a1a1aa",cursor:"pointer",transition:"all 0.15s",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:v=>{v.currentTarget.style.background="rgba(39,39,42,1)",v.currentTarget.style.color="#fff";},onMouseLeave:v=>{v.currentTarget.style.background="rgba(39,39,42,0.6)",v.currentTarget.style.color="#a1a1aa";},onClick:L,children:jsxs("svg",{className:f?"match-refresh-spin":void 0,viewBox:"0 0 24 24",style:{width:16,height:16},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),jsx("path",{d:"M21 3v5h-5"}),jsx("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),jsx("path",{d:"M8 16H3v5"})]})})]})]})}function Np(){return jsxs("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"m21 16-4 4-4-4"}),jsx("path",{d:"M17 20V4"}),jsx("path",{d:"m3 8 4-4 4 4"}),jsx("path",{d:"M7 4v16"})]})}function Pp({type:e}){let t={width:16,height:16},r={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};return e==="trending-up"?jsxs("svg",{...r,style:t,children:[jsx("path",{d:"M16 7h6v6"}),jsx("path",{d:"m22 7-8.5 8.5-5-5L2 17"})]}):e==="chart-column"?jsxs("svg",{...r,style:t,children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}):jsx("svg",{...r,style:t,children:jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})})}function Cp(){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#a1a1aa"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z"})})}function Mp({onMouseEnter:e,onMouseLeave:t}){return jsxs("svg",{viewBox:"0 0 24 24",className:"hidden sm:block",style:{width:12,height:12,color:"#52525b",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",onMouseEnter:e,onMouseLeave:t,children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M12 16v-4"}),jsx("path",{d:"M12 8h.01"})]})}function Js({open:e}){return jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#71717a",transition:"transform 0.15s",transform:e?"rotate(180deg)":void 0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"m6 9 6 6 6-6"})})}function Lp(e){return e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${(e/1e3).toFixed(0)}K`:`$${e.toFixed(0)}`}var _p=[{key:"activePairs",labelKey:"predict.matches.stats.activePairs",format:e=>e.toLocaleString(),valueColor:"#c7ff2e",gradientFrom:"rgba(199,255,46,0.18)",gradientTo:"rgba(199,255,46,0.04)",borderColor:"rgba(199,255,46,0.18)"},{key:"maxSpread",labelKey:"predict.matches.stats.maxSpread",format:e=>`${(e*100).toFixed(1)}%`,valueColor:"#f76816",gradientFrom:"rgba(247,104,22,0.18)",gradientTo:"rgba(247,104,22,0.04)",borderColor:"rgba(247,104,22,0.18)"},{key:"highSpreadCount",labelKey:"predict.matches.stats.highSpreadCount",format:e=>e.toLocaleString(),valueColor:"#17c964",gradientFrom:"rgba(23,201,100,0.18)",gradientTo:"rgba(23,201,100,0.04)",borderColor:"rgba(23,201,100,0.18)"},{key:"totalVolume",labelKey:"predict.matches.stats.totalVolume",format:Lp,valueColor:"#f5a524",gradientFrom:"rgba(245,165,36,0.18)",gradientTo:"rgba(245,165,36,0.04)",borderColor:"rgba(245,165,36,0.18)"}];function ri({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:`
|
|
26
26
|
@keyframes match-live-ping{75%,100%{transform:scale(2.2);opacity:0}}
|
|
27
27
|
@keyframes match-live-breathe{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.55;transform:scale(.85)}}
|
|
28
28
|
@keyframes matchStatsEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
|
|
@@ -60,14 +60,14 @@ import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMem
|
|
|
60
60
|
.matches-stat-label{font-size:11px;line-height:16px;min-height:16px}
|
|
61
61
|
@media(min-width:640px){.matches-stat-label{font-size:12px;line-height:18px;min-height:18px}}
|
|
62
62
|
`}),jsxs("div",{className:"matches-hero-outer",style:{display:"flex",marginBottom:0},children:[jsxs("div",{className:"matches-hero-left",style:{display:"flex",flexDirection:"column",minWidth:0,flex:1,animation:"matchHeroTitleEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both"},children:[jsx("div",{className:"matches-hero-live",style:{display:"flex",marginBottom:16},children:jsxs("div",{className:"inline-flex items-center",style:{gap:8,borderRadius:9999,border:"1px solid rgba(63,63,70,0.5)",background:"rgba(39,39,42,0.6)",padding:"6px 12px",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},children:[jsxs("span",{style:{position:"relative",display:"flex",width:8,height:8},children:[jsx("span",{style:{position:"absolute",display:"inline-flex",width:"100%",height:"100%",borderRadius:9999,background:"#00d492",opacity:.75,animation:"match-live-ping 1.2s cubic-bezier(0,0,0.2,1) infinite"}}),jsx("span",{style:{position:"relative",display:"inline-flex",width:8,height:8,borderRadius:9999,background:"#00bc7d",animation:"match-live-breathe 2.4s ease-in-out infinite"}})]}),jsx("span",{style:{fontSize:12,fontWeight:500,color:"#d4d4d8",letterSpacing:"0.025em"},children:t("predict.matches.liveBadge")}),jsx("span",{style:{borderRadius:4,background:"rgba(199,255,46,0.12)",padding:"2px 6px",fontSize:10,fontWeight:600,color:"#c7ff2e",textTransform:"uppercase",border:"1px solid rgba(199,255,46,0.22)"},children:t("predict.matches.betaTag")})]})}),jsxs("h1",{className:"matches-hero-title",style:{fontFamily:"var(--font-dm-sans, 'DM Sans', sans-serif)",fontSize:46,fontWeight:700,letterSpacing:"-1.2px",lineHeight:1.2,color:"#fff",margin:"0 0 14px"},children:[jsxs("span",{style:{color:"#fff"},children:[t("predict.matches.titlePrefix")," "]}),jsx("span",{style:{backgroundImage:"linear-gradient(to right, #c7ff2e, #a0e515, #17c964)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text"},children:t("predict.matches.titleHighlight")})]}),jsx("p",{className:"matches-hero-subtitle matches-hero-subtitle-text",style:{lineHeight:1.6,color:"#71717a",maxWidth:460},children:String(t("predict.matches.heroSubtitle")).split(`
|
|
63
|
-
`).map((r,o)=>jsxs("span",{children:[o>0&&jsx("br",{className:"hidden sm:block"}),r,o===0?" ":""]},o))})]}),jsx("div",{className:"matches-stat-grid",style:{display:"grid",borderRadius:16,border:"1px solid rgba(39,39,42,0.5)",overflow:"hidden",flexShrink:0,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",...e?{animation:"matchStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{}},children:Ep.map((r,o)=>jsxs("div",{style:{padding:"16px 20px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"rgba(255,255,255,0.02)",borderRight:o%2===0?"1px solid rgba(39,39,42,0.4)":"none",borderBottom:o<2?"1px solid rgba(39,39,42,0.4)":"none",...e?{animation:"matchStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+o*60}ms`}:{}},children:[jsx("div",{className:"matches-stat-val",style:{fontWeight:700,fontVariantNumeric:"tabular-nums",color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]):jsx("div",{style:{height:16,width:56,borderRadius:4,background:"rgba(255,255,255,0.06)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${o*80}ms`}})}),jsx("div",{className:"matches-stat-label",style:{fontWeight:500,color:e?"#71717a":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsx("div",{style:{height:10,width:64,borderRadius:4,background:"rgba(255,255,255,0.04)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${50+o*80}ms`}})})]},r.key))})]})]})}function Pn(e){return e==null?"-":e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${e.toFixed(0)}`}function Cn(e){let t=e.outcomes?.[0];return t?.best_ask??t?.price??null}function Lp(e){return e.outcomes?.[0]?.label||null}function _p(e){return e==null?"low":e>=3?"high":e>=2?"medium":"low"}var oa={high:{color:"#f76816",bandFrom:"rgba(247,104,22,0.14)",bandTo:"rgba(247,104,22,0.03)",gaugeActive:"#f76816",gaugeInactive:"rgba(247,104,22,0.15)"},medium:{color:"#c7ff2e",bandFrom:"rgba(199,255,46,0.12)",bandTo:"rgba(199,255,46,0.02)",gaugeActive:"#c7ff2e",gaugeInactive:"rgba(199,255,46,0.15)"},low:{color:"#71717a",bandFrom:"rgba(113,113,122,0.08)",bandTo:"transparent",gaugeActive:"#71717a",gaugeInactive:"rgba(113,113,122,0.12)"}},ta={high:{dot:"#17c964",label:"predict.matches.confidenceHigh"},medium:{dot:"#f5a524",label:"predict.matches.confidenceMed"},low:{dot:"#71717a",label:"predict.matches.confidenceLow"}};function Rp(e,t){return e||(t==null?"low":t>=.9?"high":t>=.7?"medium":"low")}function Ip({tier:e}){let t=oa[e],r=e==="high"?5:e==="medium"?3:1;return jsx("div",{style:{display:"flex",gap:2,alignItems:"center"},children:Array.from({length:5},(o,n)=>jsx("div",{style:{width:6,height:10,borderRadius:1.5,background:n<r?t.gaugeActive:t.gaugeInactive,transition:"background 0.2s"}},n))})}var Op={polymarket:{text:"#50a2ff",icon:"#50a2ff"},kalshi:{text:"#00d492",icon:"#00d492"}},Ap={text:"#9ca3af",icon:"#9ca3af"};function Dp(e){return Op[e]??Ap}function sa({match:e,onSelect:t,onHover:r,getMarketHref:o,LinkComponent:n}){let{t:s}=useTranslation(),i=Cn(e.market_a),a=Cn(e.market_b),l=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,c=_p(l),p=oa[c],u=i!=null&&a!=null?i<=a?e.source_a:e.source_b:null,m=e.event_a_title||e.event_b_title,d=Rp(e.confidence_tier,e.similarity_score),f=ta[d]??ta.low,g=c==="high"?"orange":"lime";return jsxs("div",{className:"group",style:{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s"},onMouseEnter:h=>{let x=h.currentTarget;x.style.borderColor="rgba(63,63,70,0.6)",x.style.boxShadow=`0 8px 24px -4px ${c==="high"?"rgba(247,104,22,0.10)":"rgba(199,255,46,0.08)"}`,r?.(e);},onMouseLeave:h=>{let x=h.currentTarget;x.style.borderColor="rgba(39,39,42,0.6)",x.style.boxShadow="none";},children:[l!=null&&jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:`linear-gradient(90deg, ${p.bandFrom}, ${p.bandTo})`,borderBottom:"1px solid rgba(39,39,42,0.3)"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:p.color},fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsxs("span",{style:{fontSize:15,fontWeight:700,fontVariantNumeric:"tabular-nums",color:p.color},children:[l.toFixed(1),"%"]}),jsx("span",{style:{fontSize:10,fontWeight:500,color:"rgba(161,161,170,0.7)",textTransform:"uppercase",letterSpacing:"0.06em"},children:"SPREAD"})]}),jsx(Ip,{tier:c})]}),jsxs("div",{style:{padding:"14px 14px 12px"},children:[jsx("h3",{style:{fontSize:13,fontWeight:600,lineHeight:1.4,letterSpacing:"-0.2px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",margin:"0 0 12px"},children:m}),jsxs("div",{style:{borderRadius:10,border:"1px solid rgba(39,39,42,0.4)",overflow:"hidden"},children:[jsx(ra,{source:e.source_a,market:e.market_a,isCheaper:u===e.source_a,onClick:()=>t?.(e,e.source_a),href:o?.(e,e.source_a),LinkComponent:n}),jsx("div",{style:{height:1,background:"rgba(39,39,42,0.3)"}}),jsx(ra,{source:e.source_b,market:e.market_b,isCheaper:u===e.source_b,onClick:()=>t?.(e,e.source_b),href:o?.(e,e.source_b),LinkComponent:n})]}),u&&l!=null&&jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:10},children:jsxs("button",{type:"button",style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 12px",borderRadius:8,border:`1px solid ${g==="orange"?"rgba(247,104,22,0.2)":"rgba(199,255,46,0.15)"}`,background:g==="orange"?"rgba(247,104,22,0.08)":"rgba(199,255,46,0.06)",cursor:"pointer",transition:"all 0.15s",fontSize:11,fontWeight:500,color:g==="orange"?"rgba(247,104,22,0.9)":"rgba(199,255,46,0.85)"},onMouseEnter:h=>{let x=h.currentTarget;x.style.background=g==="orange"?"rgba(247,104,22,0.14)":"rgba(199,255,46,0.10)";},onMouseLeave:h=>{let x=h.currentTarget;x.style.background=g==="orange"?"rgba(247,104,22,0.08)":"rgba(199,255,46,0.06)";},onClick:()=>t?.(e,u),children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,flexShrink:0,color:g==="orange"?"#f76816":"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),s("predict.matches.buyEdge",{platform:u.charAt(0).toUpperCase()+u.slice(1),spread:l.toFixed(1)}),jsxs("svg",{viewBox:"0 0 24 24",style:{width:10,height:10,color:g==="orange"?"rgba(247,104,22,0.5)":"rgba(199,255,46,0.4)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M5 12h14"}),jsx("path",{d:"m12 5 7 7-7 7"})]})]})})]}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),Pn(e.combined_volume)]}),e.combined_volume_24h!=null&&e.combined_volume_24h>0&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})}),Pn(e.combined_volume_24h)," ",s("predict.matches.vol24h")]})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:f.dot,flexShrink:0}}),s(f.label)]})]})]})}function ra({source:e,market:t,isCheaper:r,onClick:o,href:n,LinkComponent:s}){let{t:i}=useTranslation(),a=ot(e),l=Dp(e),c=Cn(t),p=Lp(t),u=t.volume,m=jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px",cursor:n||o?"pointer":void 0,transition:"background 0.15s",background:r?"rgba(199,255,46,0.03)":"transparent"},onMouseEnter:d=>{d.currentTarget.style.background=r?"rgba(199,255,46,0.06)":"rgba(255,255,255,0.02)";},onMouseLeave:d=>{d.currentTarget.style.background=r?"rgba(199,255,46,0.03)":"transparent";},onClick:o,children:[r?jsx("span",{style:{fontSize:10,color:"#c7ff2e",flexShrink:0},children:"\u2605"}):jsx("span",{style:{width:10,flexShrink:0}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,width:90,flexShrink:0},children:[a.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",color:l.text,textTransform:"uppercase"},children:a.label})]}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[p&&jsx("span",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p}),jsxs("span",{style:{fontSize:9,color:"#52525b"},children:[Pn(u)," ",i("predict.matches.volume")]})]}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:3,flexShrink:0},children:[jsx("span",{style:{fontSize:18,fontWeight:700,fontVariantNumeric:"tabular-nums",color:r?"#c7ff2e":"#f4f4f5"},children:c!=null?(c*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:9,color:"#71717a"},children:i("predict.matches.centsYes")})]}),jsxs("svg",{viewBox:"0 0 24 24",className:"opacity-0 group-hover:opacity-100 transition-opacity",style:{width:10,height:10,color:"#52525b",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})]});return n&&s?jsx(s,{href:n,className:"block",children:m}):m}var la=forwardRef(function({sortBy:t,sortAsc:r,minVolume:o,onSelect:n,onHover:s,getMarketHref:i,LinkComponent:a,onStatsChange:l},c){let{t:p}=useTranslation(),{data:u,hasNextPage:m,fetchNextPage:d,isFetchingNextPage:f,isLoading:g,isPlaceholderData:h,refetch:x}=useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:o,status:"active",limit:20},{placeholderData:keepPreviousData}),[P,b]=useState(0),[R,v]=useState(false);R&&!h?(v(false),b(K=>K+1)):h&&!R&&v(true),useImperativeHandle(c,()=>({refetch:()=>{x();}}),[x]);let L=useMemo(()=>u?.pages.flatMap(K=>K.items??[])??[],[u]),y=u?.pages[0]?.total,X=useMemo(()=>{let K=0,oe=0,D=0;for(let $ of L){let H=$.spread??0;H>K&&(K=H),H>=.03&&D++,$.combined_volume!=null&&(oe+=$.combined_volume);}return {activePairs:y??L.length,maxSpread:K,highSpreadCount:D,totalVolume:oe}},[L,y]);useEffect(()=>{X.activePairs>0&&l?.(X);},[X,l]);let Y=useRef(null);return useEffect(()=>{let K=Y.current;if(!K)return;let oe=new IntersectionObserver(D=>{D[0]?.isIntersecting&&m&&!f&&d();},{rootMargin:"200px"});return oe.observe(K),()=>oe.disconnect()},[m,f,d]),useEffect(()=>{if(m)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[m]),g?jsx(Up,{}):L.length===0?jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 0",color:"rgba(255,255,255,0.35)"},children:jsx("p",{style:{fontSize:18},children:p("predict.matches.empty")})}):jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsx("style",{children:`
|
|
63
|
+
`).map((r,o)=>jsxs("span",{children:[o>0&&jsx("br",{className:"hidden sm:block"}),r,o===0?" ":""]},o))})]}),jsx("div",{className:"matches-stat-grid",style:{display:"grid",borderRadius:16,border:"1px solid rgba(39,39,42,0.5)",overflow:"hidden",flexShrink:0,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",...e?{animation:"matchStatsEnter 0.5s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:"0.1s"}:{}},children:_p.map((r,o)=>jsxs("div",{style:{padding:"16px 20px",background:e?`linear-gradient(to bottom, ${r.gradientFrom}, ${r.gradientTo})`:"rgba(255,255,255,0.02)",borderRight:o%2===0?"1px solid rgba(39,39,42,0.4)":"none",borderBottom:o<2?"1px solid rgba(39,39,42,0.4)":"none",...e?{animation:"matchStatCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) both",animationDelay:`${150+o*60}ms`}:{}},children:[jsx("div",{className:"matches-stat-val",style:{fontWeight:700,fontVariantNumeric:"tabular-nums",color:e?r.valueColor:"transparent",display:"flex",alignItems:"center"},children:e?r.format(e[r.key]):jsx("div",{style:{height:16,width:56,borderRadius:4,background:"rgba(255,255,255,0.06)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${o*80}ms`}})}),jsx("div",{className:"matches-stat-label",style:{fontWeight:500,color:e?"#71717a":"transparent",marginTop:2,display:"flex",alignItems:"center"},children:e?t(r.labelKey):jsx("div",{style:{height:10,width:64,borderRadius:4,background:"rgba(255,255,255,0.04)",animation:"matchStatCardEnter 0.6s ease-out both",animationDelay:`${50+o*80}ms`}})})]},r.key))})]})]})}function Pn(e){return e==null?"-":e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${e.toFixed(0)}`}function Cn(e){let t=e.outcomes?.[0];return t?.best_ask??t?.price??null}function Ip(e){return e.outcomes?.[0]?.label||null}function Op(e){return e==null?"low":e>=3?"high":e>=2?"medium":"low"}var ii={high:{color:"#f76816",bandFrom:"rgba(247,104,22,0.14)",bandTo:"rgba(247,104,22,0.03)",gaugeActive:"#f76816",gaugeInactive:"rgba(247,104,22,0.15)"},medium:{color:"#c7ff2e",bandFrom:"rgba(199,255,46,0.12)",bandTo:"rgba(199,255,46,0.02)",gaugeActive:"#c7ff2e",gaugeInactive:"rgba(199,255,46,0.15)"},low:{color:"#71717a",bandFrom:"rgba(113,113,122,0.08)",bandTo:"transparent",gaugeActive:"#71717a",gaugeInactive:"rgba(113,113,122,0.12)"}},Ap={high:{border:"rgba(247,104,22,0.4)",shadow:"0 2px 18px rgba(247,104,22,0.35)"},medium:{border:"rgba(199,255,46,0.5)",shadow:"0 2px 20px rgba(199,255,46,0.45)"},low:{border:"rgba(113,113,122,0.5)",shadow:"0 2px 20px rgba(113,113,122,0.35)"}},ni={high:{dot:"#17c964",label:"predict.matches.confidenceHigh"},medium:{dot:"#f5a524",label:"predict.matches.confidenceMed"},low:{dot:"#71717a",label:"predict.matches.confidenceLow"}};function Dp(e,t){return e||(t==null?"low":t>=.9?"high":t>=.7?"medium":"low")}function Fp({tier:e}){let t=ii[e],r=e==="high"?5:e==="medium"?3:1;return jsx("div",{style:{display:"flex",gap:2,alignItems:"center"},children:Array.from({length:5},(o,n)=>jsx("div",{style:{width:6,height:10,borderRadius:1.5,background:n<r?t.gaugeActive:t.gaugeInactive,transition:"background 0.2s"}},n))})}var Hp={polymarket:{text:"#50a2ff",icon:"#50a2ff"},kalshi:{text:"#00d492",icon:"#00d492"}},Bp={text:"#9ca3af",icon:"#9ca3af"};function $p(e){return Hp[e]??Bp}function ai({match:e,onSelect:t,onHover:r,getMarketHref:o,LinkComponent:n}){let{t:s}=useTranslation(),a=Cn(e.market_a),i=Cn(e.market_b),l=e.spread_percent!=null?e.spread_percent:e.spread!=null?e.spread*100:null,c=Op(l),p=ii[c],u=a!=null&&i!=null?a<=i?e.source_a:e.source_b:null,m=e.event_a_title||e.event_b_title,d=Dp(e.confidence_tier,e.similarity_score),f=ni[d]??ni.low,g=c==="high"?"orange":"lime";return jsxs("div",{className:"group",style:{borderRadius:14,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s"},onMouseEnter:h=>{let x=h.currentTarget,w=Ap[c];x.style.borderColor=w.border,x.style.boxShadow=w.shadow,r?.(e);},onMouseLeave:h=>{let x=h.currentTarget;x.style.borderColor="rgba(39,39,42,0.6)",x.style.boxShadow="none";},children:[l!=null&&jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:`linear-gradient(90deg, ${p.bandFrom}, ${p.bandTo})`,borderBottom:"1px solid rgba(39,39,42,0.3)"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:p.color},fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsxs("span",{style:{fontSize:15,fontWeight:700,fontVariantNumeric:"tabular-nums",color:p.color},children:[l.toFixed(1),"%"]}),jsx("span",{style:{fontSize:10,fontWeight:500,color:"rgba(161,161,170,0.7)",textTransform:"uppercase",letterSpacing:"0.06em"},children:"SPREAD"})]}),jsx(Fp,{tier:c})]}),jsxs("div",{style:{padding:"14px 14px 12px"},children:[jsx("h3",{style:{fontSize:13,fontWeight:600,lineHeight:1.4,letterSpacing:"-0.2px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",margin:"0 0 12px"},children:m}),jsxs("div",{style:{borderRadius:10,border:"1px solid rgba(39,39,42,0.4)",overflow:"hidden"},children:[jsx(oi,{source:e.source_a,market:e.market_a,isCheaper:u===e.source_a,onClick:()=>t?.(e,e.source_a),href:o?.(e,e.source_a),LinkComponent:n}),jsx("div",{style:{height:1,background:"rgba(39,39,42,0.3)"}}),jsx(oi,{source:e.source_b,market:e.market_b,isCheaper:u===e.source_b,onClick:()=>t?.(e,e.source_b),href:o?.(e,e.source_b),LinkComponent:n})]}),u&&l!=null&&jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:10},children:jsxs("button",{type:"button",style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 12px",borderRadius:8,border:`1px solid ${g==="orange"?"rgba(247,104,22,0.2)":"rgba(199,255,46,0.15)"}`,background:g==="orange"?"rgba(247,104,22,0.08)":"rgba(199,255,46,0.06)",cursor:"pointer",transition:"all 0.15s",fontSize:11,fontWeight:500,color:g==="orange"?"rgba(247,104,22,0.9)":"rgba(199,255,46,0.85)"},onMouseEnter:h=>{let x=h.currentTarget;x.style.background=g==="orange"?"rgba(247,104,22,0.14)":"rgba(199,255,46,0.10)";},onMouseLeave:h=>{let x=h.currentTarget;x.style.background=g==="orange"?"rgba(247,104,22,0.08)":"rgba(199,255,46,0.06)";},onClick:()=>t?.(e,u),children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,flexShrink:0,color:g==="orange"?"#f76816":"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),s("predict.matches.buyEdge",{platform:u.charAt(0).toUpperCase()+u.slice(1),spread:l.toFixed(1)}),jsxs("svg",{viewBox:"0 0 24 24",style:{width:10,height:10,color:g==="orange"?"rgba(247,104,22,0.5)":"rgba(199,255,46,0.4)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M5 12h14"}),jsx("path",{d:"m12 5 7 7-7 7"})]})]})})]}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.15)",padding:"8px 14px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),Pn(e.combined_volume)]}),e.combined_volume_24h!=null&&e.combined_volume_24h>0&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:11,height:11},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})}),Pn(e.combined_volume_24h)," ",s("predict.matches.vol24h")]})]}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:f.dot,flexShrink:0}}),s(f.label)]})]})]})}function oi({source:e,market:t,isCheaper:r,onClick:o,href:n,LinkComponent:s}){let{t:a}=useTranslation(),i=ot(e),l=$p(e),c=Cn(t),p=Ip(t),u=t.volume,m=jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px",cursor:n||o?"pointer":void 0,transition:"background 0.15s",background:r?"rgba(199,255,46,0.03)":"transparent"},onMouseEnter:d=>{d.currentTarget.style.background=r?"rgba(199,255,46,0.06)":"rgba(255,255,255,0.02)";},onMouseLeave:d=>{d.currentTarget.style.background=r?"rgba(199,255,46,0.03)":"transparent";},onClick:o,children:[r?jsx("span",{style:{fontSize:10,color:"#c7ff2e",flexShrink:0},children:"\u2605"}):jsx("span",{style:{width:10,flexShrink:0}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,width:90,flexShrink:0},children:[i.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.04em",color:l.text,textTransform:"uppercase"},children:i.label})]}),jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[p&&jsx("span",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p}),jsxs("span",{style:{fontSize:9,color:"#52525b"},children:[Pn(u)," ",a("predict.matches.volume")]})]}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:3,flexShrink:0},children:[jsx("span",{style:{fontSize:18,fontWeight:700,fontVariantNumeric:"tabular-nums",color:r?"#c7ff2e":"#f4f4f5"},children:c!=null?(c*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:9,color:"#71717a"},children:a("predict.matches.centsYes")})]}),jsxs("svg",{viewBox:"0 0 24 24",className:"opacity-0 group-hover:opacity-100 transition-opacity",style:{width:10,height:10,color:"#52525b",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})]});return n&&s?jsx(s,{href:n,className:"block",children:m}):m}var di=forwardRef(function({sortBy:t,sortAsc:r,minVolume:o,onSelect:n,onHover:s,getMarketHref:a,LinkComponent:i,onStatsChange:l},c){let{t:p}=useTranslation(),{data:u,hasNextPage:m,fetchNextPage:d,isFetchingNextPage:f,isLoading:g,isPlaceholderData:h,refetch:x}=useInfiniteMatchMarkets({sort_by:t,sort_asc:r,min_volume:o,status:"active",limit:20},{placeholderData:keepPreviousData}),[w,b]=useState(0),[L,v]=useState(false);L&&!h?(v(false),b(K=>K+1)):h&&!L&&v(true),useImperativeHandle(c,()=>({refetch:()=>{x();}}),[x]);let T=useMemo(()=>u?.pages.flatMap(K=>K.items??[])??[],[u]),y=u?.pages[0]?.total,X=useMemo(()=>{let K=0,oe=0,D=0;for(let $ of T){let H=$.spread??0;H>K&&(K=H),H>=.03&&D++,$.combined_volume!=null&&(oe+=$.combined_volume);}return {activePairs:y??T.length,maxSpread:K,highSpreadCount:D,totalVolume:oe}},[T,y]);useEffect(()=>{X.activePairs>0&&l?.(X);},[X,l]);let Y=useRef(null);return useEffect(()=>{let K=Y.current;if(!K)return;let oe=new IntersectionObserver(D=>{D[0]?.isIntersecting&&m&&!f&&d();},{rootMargin:"200px"});return oe.observe(K),()=>oe.disconnect()},[m,f,d]),useEffect(()=>{if(m)return document.documentElement.style.overscrollBehaviorY="none",()=>{document.documentElement.style.overscrollBehaviorY="";}},[m]),g?jsx(Gp,{}):T.length===0?jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 0",color:"rgba(255,255,255,0.35)"},children:jsx("p",{style:{fontSize:18},children:p("predict.matches.empty")})}):jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[jsx("style",{children:`
|
|
64
64
|
@media(max-width:1023px){.matches-card-grid{grid-template-columns:1fr!important}}
|
|
65
65
|
@keyframes matchCardEnter{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
|
|
66
|
-
`}),jsx("div",{className:"matches-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:16},children:u?.pages.map(K=>K.items?.map((oe,D)=>jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${D*35}ms both`},children:jsx(sa,{match:oe,onSelect:n,onHover:s,getMarketHref:i,LinkComponent:a})},`${P}-${oe.match_id}-${oe.source_a}-${oe.market_a?.slug??D}`)))}),jsxs("div",{ref:Y,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 0",minHeight:1},children:[jsx("style",{children:"@keyframes match-load-spin{to{transform:rotate(360deg)}}"}),f&&jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#71717a",fontSize:13},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"match-load-spin 1s linear infinite"},children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),p("predict.matches.loadMore")]})]})]})});function Up(){return jsxs(Fragment,{children:[jsx("style",{children:"@keyframes shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}@media(max-width:1023px){.matches-skeleton-grid{grid-template-columns:1fr!important}}"}),jsx("div",{className:"matches-skeleton-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:16},children:Array.from({length:6}).map((e,t)=>jsx(Kp,{index:t},t))})]})}function Kp({index:e}){let r={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:`shimmer 1.8s ease-in-out infinite ${e*150}ms`,borderRadius:6};return jsxs("div",{style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden"},children:[jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:"16px 16px 12px"},children:[jsx("div",{style:{...r,height:14,width:e%2===0?"75%":"60%"}}),jsx("div",{style:{...r,height:24,width:64,borderRadius:10,flexShrink:0,marginLeft:12}})]}),jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,padding:"0 16px"},children:[0,1].map(o=>jsxs("div",{style:{borderRadius:12,border:"1px solid rgba(255,255,255,0.04)",background:"rgba(255,255,255,0.02)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...r,height:10,width:72}}),jsx("div",{style:{...r,height:10,width:48}}),jsx("div",{style:{...r,height:20,width:56}}),jsx("div",{style:{...r,height:10,width:60,marginTop:4}})]},o))}),jsx("div",{style:{padding:"12px 16px"},children:jsx("div",{style:{...r,height:36,borderRadius:10,width:"100%"}})}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",padding:"10px 16px"},children:[jsxs("div",{style:{display:"flex",gap:12},children:[jsx("div",{style:{...r,height:10,width:40}}),jsx("div",{style:{...r,height:10,width:50}})]}),jsx("div",{style:{...r,height:10,width:56}})]})]})}var qp={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function Qp(){let[e,t]=useState("");return useEffect(()=>{let r=()=>{let n=new Date;return `${String(n.getHours()).padStart(2,"0")}:${String(n.getMinutes()).padStart(2,"0")}`};t(r());let o=setInterval(()=>t(r()),1e4);return ()=>clearInterval(o)},[]),jsx("span",{children:e})}function Xp({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:"@media(max-width:768px){.matches-status-bar{display:none!important}}"}),jsxs("div",{className:"matches-status-bar",style:{position:"fixed",bottom:0,left:0,right:0,height:28,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 12px",background:"rgba(12,12,13,0.8)",borderTop:"1px solid rgba(39,39,42,0.6)",fontSize:11,color:"rgba(255,255,255,0.4)",zIndex:50,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",flexShrink:0},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,color:"#00bc7d"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 20h.01"}),jsx("path",{d:"M2 8.82a15 15 0 0 1 20 0"}),jsx("path",{d:"M5 12.859a10 10 0 0 1 14 0"}),jsx("path",{d:"M8.5 16.429a5 5 0 0 1 7 0"})]}),jsx("span",{style:{color:"#00bc7d",fontWeight:500},children:t("predict.matches.status.live")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)"}}),e&&jsxs("div",{className:"hidden sm:flex",style:{alignItems:"center",gap:12},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.markets")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:e.activePairs.toLocaleString()})]}),jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.vol24h")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:e.totalVolume>=1e6?`$${(e.totalVolume/1e6).toFixed(1)}M`:e.totalVolume>=1e3?`$${Math.round(e.totalVolume/1e3)}K`:`$${e.totalVolume}`})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),jsx("path",{d:"M10 9H8"}),jsx("path",{d:"M16 13H8"}),jsx("path",{d:"M16 17H8"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.docs")})]}),jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"currentColor",children:jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),jsx("span",{className:"hidden lg:inline",children:"X"})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.watchlist")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.portfolio")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),jsx("path",{d:"M12 17h.01"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.help")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),jsx(Qp,{})]})]})]})]})}function Gv({onSelect:e,onHover:t,getMarketHref:r,LinkComponent:o,bgImageSrc:n}){let{t:s}=useTranslation(),[i,a]=useState("spread"),[l,c]=useState(false),[p,u]=useState(5e3),[m,d]=useState(),f=useRef(null),g=useCallback(b=>{a(b);},[]),h=useCallback(b=>{c(b);},[]),x=useCallback(b=>{startTransition(()=>{d(b);});},[]),P=useCallback(()=>{f.current?.refetch();},[]);return jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[jsx("style",{children:`
|
|
66
|
+
`}),jsx("div",{className:"matches-card-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:16},children:u?.pages.map(K=>K.items?.map((oe,D)=>jsx("div",{style:{animation:`matchCardEnter 0.45s cubic-bezier(0.34,1.56,0.64,1) ${D*35}ms both`},children:jsx(ai,{match:oe,onSelect:n,onHover:s,getMarketHref:a,LinkComponent:i})},`${w}-${oe.match_id}-${oe.source_a}-${oe.market_a?.slug??D}`)))}),jsxs("div",{ref:Y,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"16px 0",minHeight:1},children:[jsx("style",{children:"@keyframes match-load-spin{to{transform:rotate(360deg)}}"}),f&&jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#71717a",fontSize:13},children:[jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{animation:"match-load-spin 1s linear infinite"},children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),p("predict.matches.loadMore")]})]})]})});function Gp(){return jsxs(Fragment,{children:[jsx("style",{children:"@keyframes shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}@media(max-width:1023px){.matches-skeleton-grid{grid-template-columns:1fr!important}}"}),jsx("div",{className:"matches-skeleton-grid",style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:16},children:Array.from({length:6}).map((e,t)=>jsx(Yp,{index:t},t))})]})}function Yp({index:e}){let r={background:"linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%)",backgroundSize:"200% 100%",animation:`shimmer 1.8s ease-in-out infinite ${e*150}ms`,borderRadius:6};return jsxs("div",{style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden"},children:[jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:"16px 16px 12px"},children:[jsx("div",{style:{...r,height:14,width:e%2===0?"75%":"60%"}}),jsx("div",{style:{...r,height:24,width:64,borderRadius:10,flexShrink:0,marginLeft:12}})]}),jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,padding:"0 16px"},children:[0,1].map(o=>jsxs("div",{style:{borderRadius:12,border:"1px solid rgba(255,255,255,0.04)",background:"rgba(255,255,255,0.02)",padding:12,display:"flex",flexDirection:"column",gap:8},children:[jsx("div",{style:{...r,height:10,width:72}}),jsx("div",{style:{...r,height:10,width:48}}),jsx("div",{style:{...r,height:20,width:56}}),jsx("div",{style:{...r,height:10,width:60,marginTop:4}})]},o))}),jsx("div",{style:{padding:"12px 16px"},children:jsx("div",{style:{...r,height:36,borderRadius:10,width:"100%"}})}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",padding:"10px 16px"},children:[jsxs("div",{style:{display:"flex",gap:12},children:[jsx("div",{style:{...r,height:10,width:40}}),jsx("div",{style:{...r,height:10,width:50}})]}),jsx("div",{style:{...r,height:10,width:56}})]})]})}var Jp={spread:"predict.matches.topOpportunities",volume:"predict.matches.highestVolume",confidence:"predict.matches.trendingToday"};function em(){let[e,t]=useState("");return useEffect(()=>{let r=()=>{let n=new Date;return `${String(n.getHours()).padStart(2,"0")}:${String(n.getMinutes()).padStart(2,"0")}`};t(r());let o=setInterval(()=>t(r()),1e4);return ()=>clearInterval(o)},[]),jsx("span",{children:e})}function tm({stats:e}){let{t}=useTranslation();return jsxs(Fragment,{children:[jsx("style",{children:"@media(max-width:768px){.matches-status-bar{display:none!important}}"}),jsxs("div",{className:"matches-status-bar",style:{position:"fixed",bottom:0,left:0,right:0,height:28,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 12px",background:"rgba(12,12,13,0.8)",borderTop:"1px solid rgba(39,39,42,0.6)",fontSize:11,color:"rgba(255,255,255,0.4)",zIndex:50,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",flexShrink:0},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,color:"#00bc7d"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 20h.01"}),jsx("path",{d:"M2 8.82a15 15 0 0 1 20 0"}),jsx("path",{d:"M5 12.859a10 10 0 0 1 14 0"}),jsx("path",{d:"M8.5 16.429a5 5 0 0 1 7 0"})]}),jsx("span",{style:{color:"#00bc7d",fontWeight:500},children:t("predict.matches.status.live")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)"}}),e&&jsxs("div",{className:"hidden sm:flex",style:{alignItems:"center",gap:12},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.markets")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:e.activePairs.toLocaleString()})]}),jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),jsx("span",{style:{color:"#52525b"},children:t("predict.matches.status.vol24h")}),jsx("span",{style:{color:"#d4d4d8",fontWeight:500,fontVariantNumeric:"tabular-nums"},children:e.totalVolume>=1e6?`$${(e.totalVolume/1e6).toFixed(1)}M`:e.totalVolume>=1e3?`$${Math.round(e.totalVolume/1e3)}K`:`$${e.totalVolume}`})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),jsx("path",{d:"M10 9H8"}),jsx("path",{d:"M16 13H8"}),jsx("path",{d:"M16 17H8"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.docs")})]}),jsxs("a",{href:"#",target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",textDecoration:"none",transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"currentColor",children:jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),jsx("span",{className:"hidden lg:inline",children:"X"})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.watchlist")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2.5"}),jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.portfolio")})]}),jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:4,color:"#71717a",background:"transparent",border:"none",cursor:"pointer",fontSize:11,transition:"color 0.15s, background 0.15s"},onMouseEnter:r=>{r.currentTarget.style.color="#d4d4d8",r.currentTarget.style.background="rgba(39,39,42,0.5)";},onMouseLeave:r=>{r.currentTarget.style.color="#71717a",r.currentTarget.style.background="transparent";},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),jsx("path",{d:"M12 17h.01"})]}),jsx("span",{className:"hidden lg:inline",children:t("predict.matches.status.help")})]}),jsx("div",{style:{width:1,height:14,background:"rgba(39,39,42,0.8)",margin:"0 4px"}}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"#71717a"},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]}),jsx(em,{})]})]})]})]})}function Xv({onSelect:e,onHover:t,getMarketHref:r,LinkComponent:o,bgImageSrc:n}){let{t:s}=useTranslation(),[a,i]=useState("spread"),[l,c]=useState(false),[p,u]=useState(5e3),[m,d]=useState(),f=useRef(null),g=useCallback(b=>{i(b);},[]),h=useCallback(b=>{c(b);},[]),x=useCallback(b=>{startTransition(()=>{d(b);});},[]),w=useCallback(()=>{f.current?.refetch();},[]);return jsxs("div",{style:{minHeight:"100vh",position:"relative"},children:[jsx("style",{children:`
|
|
67
67
|
@keyframes matchFadeIn{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}
|
|
68
68
|
.match-fade-in{animation:matchFadeIn .5s ease-out both}
|
|
69
69
|
.match-fade-in-d1{animation:matchFadeIn .5s ease-out .1s both}
|
|
70
70
|
.match-fade-in-d2{animation:matchFadeIn .5s ease-out .2s both}
|
|
71
|
-
`}),jsxs("div",{style:{position:"relative",overflow:"hidden",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:0,overflow:"hidden"},children:[n&&jsx("img",{src:n,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",objectPosition:"center center",opacity:.3,mixBlendMode:"lighten",maskImage:"linear-gradient(to bottom, black 50%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 50%, transparent 100%)"}}),jsx("div",{style:{position:"absolute",inset:0,opacity:.025,backgroundImage:"radial-gradient(circle at 1px 1px, rgb(255 255 255) 1px, transparent 0)",backgroundSize:"20px 20px"}})]}),jsx("style",{children:".matches-hero-wrap{padding:40px 16px 32px}@media(min-width:640px){.matches-hero-wrap{padding:48px 24px 40px}}@media(min-width:1024px){.matches-hero-wrap{padding:52px 32px 44px}}"}),jsx("div",{className:"match-fade-in matches-hero-wrap",style:{position:"relative",zIndex:2,maxWidth:1152,margin:"0 auto"},children:jsx(ea,{stats:m})})]}),jsxs("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsx("style",{children:".matches-toolbar-inner{padding:12px 16px}@media(min-width:640px){.matches-toolbar-inner{padding:12px 24px}}@media(min-width:1024px){.matches-toolbar-inner{padding:12px 32px}}"}),jsxs("div",{className:"matches-toolbar-inner",style:{maxWidth:1152,margin:"0 auto",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,minWidth:0},children:[jsx("div",{className:"hidden sm:flex",style:{alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:10,background:"linear-gradient(to bottom right, rgba(199,255,46,0.15), rgba(23,201,100,0.15))",border:"1px solid rgba(199,255,46,0.15)",flexShrink:0},children:jsxs("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"}),jsx("path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"}),jsx("path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"})]})}),jsxs("div",{style:{minWidth:0},children:[jsx("h2",{style:{fontSize:14,fontWeight:600,color:"#fff",margin:0,letterSpacing:"-0.28px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s(qp[i])}),m&&m.activePairs>0&&jsx("p",{className:"hidden sm:block",style:{fontSize:11,color:"#71717a",margin:0},children:s("predict.matches.pairsFound",{count:m.activePairs})})]})]}),jsx(Js,{sortBy:i,onSortChange:g,sortAsc:l,onSortAscChange:h,minVolume:p,onMinVolumeChange:u,onRefresh:P})]})]}),jsx("style",{children:".matches-content-wrap{padding:24px 16px 80px}@media(min-width:640px){.matches-content-wrap{padding:32px 24px 80px}}@media(min-width:1024px){.matches-content-wrap{padding:24px 32px 80px}}"}),jsxs("div",{className:"match-fade-in-d2 matches-content-wrap",style:{position:"relative",maxWidth:1152,margin:"0 auto"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:16,padding:"8px 12px",borderRadius:8,border:"1px solid rgba(39,39,42,0.4)",background:"rgba(24,24,27,0.25)"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#52525b",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),jsxs("p",{style:{fontSize:11,color:"#52525b",lineHeight:1.5,margin:0},children:[jsx("span",{style:{color:"#71717a",fontWeight:500},children:s("predict.matches.experimentalFeature")})," \u2014 ",s("predict.matches.disclaimer")]})]}),jsx(la,{ref:f,sortBy:i,sortAsc:l,minVolume:p,onSelect:e,onHover:t,getMarketHref:r,LinkComponent:o,onStatsChange:x})]}),jsx(Xp,{stats:m})]})}function En(e){return e==null?"-":e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${e.toFixed(0)}`}var Jp={polymarket:{text:"#50a2ff",border:"rgba(43,127,255,0.15)",hoverBorder:"rgba(43,127,255,0.3)",bg:"rgba(43,127,255,0.05)",priceColor:"rgba(244,244,245,1)",priceActiveColor:"rgba(244,244,245,1)"},kalshi:{text:"#00d492",border:"rgba(0,212,146,0.15)",hoverBorder:"rgba(0,212,146,0.3)",bg:"rgba(0,212,146,0.05)",priceColor:"#00d492",priceActiveColor:"#00d492"}},em={text:"#9ca3af",border:"rgba(156,163,175,0.15)",hoverBorder:"rgba(156,163,175,0.3)",bg:"rgba(156,163,175,0.05)",priceColor:"rgba(244,244,245,1)",priceActiveColor:"rgba(244,244,245,1)"};function tm(e){return Jp[e]??em}function rm(e){if(!e.matched_markets?.length)return null;let t=null,r=-1;for(let o of e.matched_markets){let n=o.spread??0;n>r&&(r=n,t=o);}return t}function nm(e,t){let r=e.entries.find(a=>a.source===(t?.source_a??e.entries[0]?.source)),o=e.entries.find(a=>a.source===(t?.source_b??e.entries[1]?.source)),n=a=>{if(!a?.outcomes?.[0])return {name:null,price:null};let l=a.outcomes[0];return {name:l.label||null,price:l.best_ask??l.price??null}},s=n(t?.market_a),i=n(t?.market_b);return [{source:t?.source_a??r?.source??"unknown",outcomeName:s.name,yesPrice:s.price,volume:r?.event?.volume??null,event:r?.event},{source:t?.source_b??o?.source??"unknown",outcomeName:i.name,yesPrice:i.price,volume:o?.event?.volume??null,event:o?.event}]}function Jv({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:o}){let {t:n}=useTranslation(),s=useMemo(()=>rm(e),[e]),i=e.max_spread!=null?e.max_spread*100:null,[a,l]=useMemo(()=>nm(e,s),[e,s]),c=i!=null&&i>=3;a.yesPrice!=null&&l.yesPrice!=null?a.source==="kalshi"?a.yesPrice>l.yesPrice:l.yesPrice>a.yesPrice:false;let u=a.yesPrice!=null&&l.yesPrice!=null?a.yesPrice<=l.yesPrice?a:l:null,m=u?ot(u.source):null,d=c?"amber":"violet";return jsxs("div",{className:"group",style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",position:"relative"},onMouseEnter:f=>{let g=f.currentTarget;g.style.borderColor="rgba(63,63,70,0.6)",g.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:f=>{let g=f.currentTarget;g.style.borderColor="rgba(39,39,42,0.6)",g.style.boxShadow="none";},children:[i!=null&&jsxs("span",{style:{position:"absolute",top:12,right:12,zIndex:10,display:"inline-flex",alignItems:"center",gap:4,borderRadius:10,padding:"4px 10px",fontSize:12,fontWeight:600,border:`1px solid ${c?"rgba(255,185,0,0.3)":i>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:c?"rgba(255,185,0,0.15)":i>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:c?"#ffb900":i>=2?"#a684ff":"#9ca3af"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),i.toFixed(1),"%"]}),jsxs("div",{style:{padding:16},children:[jsx("h3",{style:{fontSize:14,fontWeight:600,lineHeight:1.375,letterSpacing:"-0.28px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",paddingRight:80,margin:"0 0 16px"},children:e.title}),jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[jsx(ua,{data:a,isCheaper:u===a,onSelect:t,getEventHref:r,LinkComponent:o}),jsx(ua,{data:l,isCheaper:u===l,onSelect:t,getEventHref:r,LinkComponent:o})]}),u&&m&&i!=null&&jsxs("div",{style:{marginTop:12,padding:"8px 12px",borderRadius:10,display:"flex",alignItems:"center",gap:8,cursor:"pointer",transition:"all 0.15s",border:`1px solid ${d==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:d==="amber"?"rgba(255,185,0,0.05)":"rgba(166,132,255,0.05)"},onClick:()=>u.event&&t?.(u.event),children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:d==="amber"?"#ffb900":"#a684ff"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsx("span",{style:{fontSize:11,fontWeight:500,color:d==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:n("predict.matches.buyEdge",{platform:u.source.charAt(0).toUpperCase()+u.source.slice(1),spread:i.toFixed(1)})}),jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,marginLeft:"auto",color:d==="amber"?"rgba(255,185,0,0.5)":"rgba(166,132,255,0.5)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M5 12h14"}),jsx("path",{d:"m12 5 7 7-7 7"})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.2)",padding:"10px 16px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),En(e.combined_volume)]}),e.combined_volume_24h!=null&&e.combined_volume_24h>0&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})}),En(e.combined_volume_24h)," ",n("predict.matches.vol24h")]})]}),e.confidence!=null&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),Math.round(e.confidence*100),"%"," ",n("predict.matches.match")]})]})]})}function ua({data:e,isCheaper:t,onSelect:r,getEventHref:o,LinkComponent:n}){let{t:s}=useTranslation(),i=ot(e.source),a=tm(e.source),l=e.event?o?.(e.event):void 0,c=jsxs("div",{style:{borderRadius:14,border:`1px solid ${a.border}`,background:a.bg,padding:12,cursor:l||r?"pointer":void 0,transition:"border-color 0.15s"},onMouseEnter:p=>{p.currentTarget.style.borderColor=a.hoverBorder;},onMouseLeave:p=>{p.currentTarget.style.borderColor=a.border;},onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[i.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.05em",color:a.text,textTransform:"uppercase"},children:i.label}),jsxs("svg",{viewBox:"0 0 24 24",className:"opacity-0 group-hover:opacity-100 transition-opacity",style:{width:10,height:10,color:"#52525b",marginLeft:"auto"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})]}),e.outcomeName&&jsx("div",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginBottom:8},children:e.outcomeName}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[jsx("span",{style:{fontSize:20,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?a.priceActiveColor:a.priceColor},children:e.yesPrice!=null?(e.yesPrice*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:10,color:"#71717a"},children:s("predict.matches.centsYes")})]}),jsxs("div",{style:{fontSize:10,color:"#52525b",marginTop:6},children:[En(e.volume)," ",s("predict.matches.volume")]})]});return l&&n?jsx(n,{href:l,className:"block",children:c}):c}function am(e){return e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${(e/1e3).toFixed(1)}K`:`$${e.toFixed(0)}`}function ob({matches:e,total:t}){let{t:r}=useTranslation(),o=useMemo(()=>{let n=0,s=0,i=new Set;for(let a of e){a.max_spread!=null&&a.max_spread>n&&(n=a.max_spread),a.combined_volume!=null&&(s+=a.combined_volume);for(let l of a.entries)i.add(typeof l.source=="string"?l.source:"");}return {count:t??e.length,maxSpread:n,totalVolume:s,platformCount:i.size}},[e,t]);return jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 rounded-xl border border-border/60 bg-background/50 px-4 py-3 text-sm",children:[jsx(Er,{label:r("predict.matches.stats.matchedMarkets"),value:o.count.toLocaleString()}),jsx(Tn,{}),jsx(Er,{label:r("predict.matches.stats.totalVolume"),value:am(o.totalVolume)}),jsx(Tn,{}),jsx(Er,{label:r("predict.matches.stats.highestSpread"),value:`${(o.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-green-400"}),jsx(Tn,{}),jsx(Er,{label:r("predict.matches.stats.platforms"),value:String(o.platformCount)})]})}function Er({label:e,value:t,valueClassName:r="text-slate-200"}){return jsxs("div",{className:"flex items-center gap-x-1.5",children:[jsxs("span",{className:"text-neutral-500",children:[e,":"]}),jsx("span",{className:`font-semibold ${r}`,children:t})]})}function Tn(){return jsx("span",{className:"hidden text-neutral-700 sm:inline",children:"|"})}function fa(e){return `${(e*100).toFixed(1)}\xA2`}function im(e){return e>=.05?"text-green-400":e>=.02?"text-yellow-400":"text-neutral-400"}function lb({spread:e,arbProfit:t,className:r}){if(e==null)return null;let o=t!=null&&t>0;return jsxs("div",{className:cn$1("flex items-center gap-x-2",r),children:[jsx("span",{className:cn$1("text-sm font-semibold",im(e)),children:fa(e)}),o&&jsxs("span",{className:"text-xs text-green-500/80",children:["+",fa(t)]})]})}var Qt=10,mm=64,va=40,Tr=48;function ba({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=useTranslation(),[n,s]=useState(1),{data:i,isLoading:a,fetchNextPage:l,hasNextPage:c,isFetchingNextPage:p}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:u,isLoading:m,fetchNextPage:d,hasNextPage:f,isFetchingNextPage:g}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),h=a||m,x=p||g,P=c||f,b=useMemo(()=>{let D=[];return i?.pages&&D.push(...i.pages.flatMap($=>$.items)),u?.pages&&D.push(...u.pages.flatMap($=>$.items)),D.sort(($,H)=>(H.timestamp??0)-($.timestamp??0)),D},[i,u]),R=Math.max(1,Math.ceil(b.length/Qt)+(P?1:0)),v=(n-1)*Qt,L=b.slice(v,v+Qt),y=useCallback(()=>{s(D=>Math.max(1,D-1));},[]),X=useCallback(async()=>{n*Qt>=b.length&&P&&(c&&await l(),f&&await d()),s($=>$+1);},[n,b.length,P,c,f,l,d]),Y=n>1,K=n*Qt<b.length||P;if(h)return jsx(bm,{height:r});if(b.length===0&&!P)return jsx(vm,{message:o("predict.profile.noHistory"),height:r});let oe=r-va-Tr;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:va},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:o("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.status")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.price")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:o("predict.profile.depositWithdraw")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.fee")}),jsx("div",{className:"w-10 shrink-0"})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:oe},children:[L.map((D,$)=>jsx(fm,{trade:D},D.id??`${v+$}`)),x&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:Tr},children:[jsxs("button",{type:"button",disabled:!Y,onClick:y,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",Y?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",o("predict.profile.previous")]}),Array.from({length:Math.min(R,5)},(D,$)=>{let H=$+1;return jsx("button",{type:"button",onClick:()=>s(H),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",H===n?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:H},H)}),jsxs("button",{type:"button",disabled:!K,onClick:X,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",K?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[o("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-Tr},children:L.map((D,$)=>jsx(gm,{trade:D},D.id??`m-${v+$}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:Tr},children:[jsx("button",{type:"button",disabled:!Y,onClick:y,className:cn$1("text-sm cursor-pointer",Y?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:n}),jsx("button",{type:"button",disabled:!K,onClick:X,className:cn$1("text-sm cursor-pointer",K?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function fm({trade:e}){let{t}=useTranslation(),r=e.side?.toUpperCase()==="BUY",o=e.price??0,n=e.usd_size??0,s=ya(e.type,t),i=r,a=i?"+":"-",l=i?"text-success":"text-foreground",c=e.event?.title??e.market?.question??"\u2014",p=e.event?.image_url,u=e.outcome??"",m=Na(e.timestamp),d=ka(e),f=hm(e),g=xm(e);return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:mm},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[p&&jsx("img",{src:p,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsx("span",{className:"text-foreground truncate font-medium text-sm",children:c}),jsxs("span",{className:"text-[11px] text-neutral",children:[u&&jsx("span",{className:"mr-1",children:u}),jsx("span",{children:m})]})]})]})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn$1("text-sm font-medium",r?"text-success":"text-danger"),children:t(r?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-sm text-foreground",children:s}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:wa(o)}),jsx("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono",l),children:n>0?jsxs(Fragment,{children:[a,"$",n.toFixed(2)]}):"\u2014"}),jsx("div",{className:cn$1("flex-1 pr-2 text-right font-mono",f!==null?f>=0?"text-success":"text-danger":"text-neutral"),children:f!==null?`${f>=0?"+":"-"}$${Math.abs(f).toFixed(2)}`:"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-neutral",children:g!==null?`$${g.toFixed(2)}`:"\u2014"}),jsx("div",{className:"w-10 shrink-0 text-right",children:d&&jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"text-neutral hover:text-foreground transition-colors","aria-label":"View transaction",children:jsx(Sa,{})})})]})}function gm({trade:e}){let{t}=useTranslation(),r=e.side?.toUpperCase()==="BUY",o=e.price??0,n=e.usd_size??0,s=ya(e.type,t),i=e.event?.title??e.market?.question??"\u2014",a=Na(e.timestamp),l=ka(e);return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsx("img",{src:e.event.image_url,alt:"",className:"w-6 h-6 rounded-full object-cover shrink-0"}),jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:i})]}),jsx("span",{className:"text-[11px] text-neutral whitespace-nowrap",children:a})]}),jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.action")}),jsx("span",{className:cn$1("font-medium",r?"text-success":"text-danger"),children:t(r?"predict.profile.buy":"predict.profile.sell")})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.status")}),jsx("span",{className:"text-foreground",children:s})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.price")}),jsx("span",{className:"font-mono text-foreground",children:wa(o)})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.depositWithdraw")}),jsx("span",{className:"font-mono text-foreground",children:n>0?`$${n.toFixed(2)}`:"\u2014"})]}),l&&jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:"ml-auto text-neutral hover:text-foreground transition-colors",children:jsx(Sa,{})})]})]})}function ya(e,t){switch(e){case "TRADE":return t("predict.profile.filled");case "REDEEM":return t("predict.profile.claimed");case "SPLIT":case "MERGE":case "CONVERSION":return t("predict.profile.created");default:return e}}function ka(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function hm(e){let t=e.provider_meta;if(t){let r=t.pnl??t.profit??t.realized_pnl??t["dflow.pnl"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let o=parseFloat(r);if(!Number.isNaN(o))return o}}return e.type==="REDEEM"&&e.usd_size!=null?e.usd_size:null}function xm(e){let t=e.provider_meta;if(t){let r=t.fee??t.fees??t.trading_fee??t["dflow.fee"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let o=parseFloat(r);if(!Number.isNaN(o))return o}}return null}function Sa(){return jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),jsx("polyline",{points:"15 3 21 3 21 9"}),jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}function vm({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function bm({height:e}){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsx(Skeleton,{className:"h-12 w-full rounded-md"},r))})}function wa(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function Na(e){let t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getFullYear(),a=t.getTimezoneOffset(),l=a<=0?"+":"-",c=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${s}/${i} (${l}${c})`}var Xt=10,Cm=64,Ca=40,Lr=48;function Ea({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=useTranslation(),n=useCancelOrder(),[s,i]=useState(1),{data:a,isLoading:l,fetchNextPage:c,hasNextPage:p,isFetchingNextPage:u}=useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:m,isLoading:d,fetchNextPage:f,hasNextPage:g,isFetchingNextPage:h}=useInfiniteOrders({source:"polymarket",wallet_address:t??""}),x=l||d,P=u||h,b=p||g,R=useMemo(()=>{let H=[],me=new Set(["live","open","submitted","pending"]);return a?.pages&&H.push(...a.pages.flatMap(fe=>fe.items).filter(fe=>me.has(fe.status))),m?.pages&&H.push(...m.pages.flatMap(fe=>fe.items).filter(fe=>me.has(fe.status))),H},[a,m]),v=useCallback(H=>{n.mutate({source:H.source,id:H.id});},[n]),L=Math.max(1,Math.ceil(R.length/Xt)+(b?1:0)),y=(s-1)*Xt,X=R.slice(y,y+Xt),Y=useCallback(()=>{i(H=>Math.max(1,H-1));},[]),K=useCallback(async()=>{s*Xt>=R.length&&b&&(p&&await c(),g&&await f()),i(me=>me+1);},[s,R.length,b,p,g,c,f]),oe=s>1,D=s*Xt<R.length||b;if(x)return jsx(Lm,{height:r});if(R.length===0&&!b)return jsx(Tm,{message:o("predict.profile.noOrders"),height:r});let $=r-Ca-Lr;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:Ca},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:o("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.fillPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.cost")})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:$},children:[X.map(H=>jsx(Mm,{order:H,onCancel:v},H.id)),P&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsx(Ma,{className:"hidden lg:flex",currentPage:s,totalPages:L,canGoPrev:oe,canGoNext:D,onPrev:Y,onNext:K,onPage:i,t:o}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-Lr},children:X.map(H=>jsx(Em,{order:H,onCancel:v},H.id))}),jsx(Ma,{className:"lg:hidden",currentPage:s,totalPages:L,canGoPrev:oe,canGoNext:D,onPrev:Y,onNext:K,onPage:i,t:o,compact:true})]})}function Mm({order:e,onCancel:t}){let{t:r}=useTranslation(),o=e.side==="BUY",n=e.price?parseFloat(e.price):0,s=e.in_amount?parseFloat(e.in_amount):n*parseFloat(e.original_size??"0");return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:Cm},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsx("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:jsx("span",{className:"text-foreground truncate font-medium",children:e.outcome??e.market_id??"\u2014"})})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn$1("text-sm font-medium",o?"text-success":"text-danger"),children:r(o?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize text-sm",children:e.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:n>0?Ta(n):"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:s>0?`$${s.toFixed(2)}`:"\u2014"})]})}function Em({order:e,onCancel:t}){let{t:r}=useTranslation(),o=e.side==="BUY",n=e.price?parseFloat(e.price):0;return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:cn$1("text-xs font-medium px-1.5 py-0.5 rounded",o?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side}),jsx("span",{className:"text-sm text-foreground capitalize",children:e.outcome??"\u2014"})]}),jsx("span",{className:"text-xs text-neutral capitalize",children:e.order_type??"limit"})]}),jsxs("div",{className:"flex items-center gap-4 text-xs",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:r("predict.profile.fillPrice")}),jsx("span",{className:"font-mono text-foreground",children:n>0?Ta(n):"\u2014"})]}),jsx("div",{className:"flex-1"}),jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer border border-border rounded px-2 py-1",children:r("predict.orders.cancel")})]})]})}function Ma({className:e,currentPage:t,totalPages:r,canGoPrev:o,canGoNext:n,onPrev:s,onNext:i,onPage:a,t:l,compact:c}){return c?jsxs("div",{className:cn$1("flex items-center justify-center gap-3 shrink-0",e),style:{height:Lr},children:[jsx("button",{type:"button",disabled:!o,onClick:s,className:cn$1("text-sm cursor-pointer",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:t}),jsx("button",{type:"button",disabled:!n,onClick:i,className:cn$1("text-sm cursor-pointer",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]}):jsxs("div",{className:cn$1("flex items-center justify-center gap-2 shrink-0",e),style:{height:Lr},children:[jsxs("button",{type:"button",disabled:!o,onClick:s,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",l("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(p,u)=>{let m=u+1;return jsx("button",{type:"button",onClick:()=>a(m),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",m===t?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:m},m)}),jsxs("button",{type:"button",disabled:!n,onClick:i,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[l("predict.profile.next")," \u2192"]})]})}function Tm({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Lm({height:e}){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsx(Skeleton,{className:"h-12 w-full rounded-md"},r))})}function Ta(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var On=10,Om=64,La=40,_r=48;function _a({positions:e,isLoading:t,listHeight:r,onClosePosition:o,onEventClick:n}){let{t:s}=useTranslation(),[i,a]=useState(1),l=useCallback(()=>{for(let g of e)o?.(g);},[e,o]);if(t)return jsx(Hm,{height:r});if(e.length===0)return jsx(Fm,{message:s("predict.profile.noPositions"),height:r});let c=Math.max(1,Math.ceil(e.length/On)),p=(i-1)*On,u=e.slice(p,p+On),m=i>1,d=i<c,f=r-La-_r;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:La},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:s("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2 text-right",children:s("predict.profile.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right",children:s("predict.profile.value")}),jsx("div",{className:"flex-1 pr-2 text-right",children:s("predict.profile.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:s("predict.profile.markPrice")}),jsxs("div",{className:"flex-[1.5] pr-2 text-right",children:[jsx("span",{children:s("predict.profile.pnl")}),jsxs("span",{className:"text-[10px] ml-1 opacity-60",children:["(",s("predict.profile.pnlExcludeFees"),")"]})]}),jsx("div",{className:"flex-1 pr-2 text-right",children:s("predict.profile.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:s("predict.profile.estSettlement")}),jsx("div",{className:"w-20 shrink-0 text-right",children:o&&e.length>0&&jsx("button",{type:"button",onClick:l,className:"text-xs text-primary hover:text-primary/80 cursor-pointer transition-colors",children:s("predict.profile.closeAll")})})]}),jsx("div",{className:"hidden lg:block overflow-y-auto",style:{height:f},children:u.map((g,h)=>jsx(Am,{position:g,onClosePosition:o,onEventClick:n},`${g.source}-${g.market?.slug??p+h}`))}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:_r},children:[jsxs("button",{type:"button",disabled:!m,onClick:()=>a(g=>Math.max(1,g-1)),className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",m?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",s("predict.profile.previous")]}),Array.from({length:Math.min(c,5)},(g,h)=>{let x=h+1;return jsx("button",{type:"button",onClick:()=>a(x),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",x===i?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:x},x)}),jsxs("button",{type:"button",disabled:!d,onClick:()=>a(g=>g+1),className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",d?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[s("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-_r},children:u.map((g,h)=>jsx(Dm,{position:g,onClose:o,onEventClick:n},`${g.source}-${g.market?.slug??`m-${p+h}`}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:_r},children:[jsx("button",{type:"button",disabled:!m,onClick:()=>a(g=>Math.max(1,g-1)),className:cn$1("text-sm cursor-pointer",m?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:i}),jsx("button",{type:"button",disabled:!d,onClick:()=>a(g=>g+1),className:cn$1("text-sm cursor-pointer",d?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function Am({position:e,onClosePosition:t,onEventClick:r}){let{t:o}=useTranslation(),n=e.pnl??0,s=e.pnl_percent??0,i=e.avg_price??0,a=e.current_price??0,l=e.current_value??e.size*a,c=e.size,p=n>0?"text-success":n<0?"text-danger":"text-foreground",u=n>0?"+":"",m=e.event?.title??e.market?.question??"\u2014",d=e.event?.image_url,f=e.side,g=e.market?.outcomes?.[0]?.label??"",h=e.market?.end_at?Bm(e.market.end_at):"\u2014";return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:Om},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("button",{type:"button",className:"flex items-center gap-2.5 min-w-0 cursor-pointer text-left",onClick:()=>e.event&&r?.(e.event),children:[d&&jsx("img",{src:d,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsx("span",{className:"text-foreground truncate font-medium text-sm",children:m}),jsxs("span",{className:"text-[11px] text-neutral",children:[jsx("span",{className:cn$1("font-medium",f.toLowerCase()==="yes"?"text-success":"text-danger"),children:f}),g&&jsxs(Fragment,{children:[jsx("span",{className:"mx-1",children:"\xB7"}),jsx("span",{children:g})]})]})]})]})}),jsx("div",{className:"flex-1 pr-2 text-right",children:jsxs("div",{className:"flex flex-col items-end",children:[jsxs("span",{className:"font-mono text-foreground",children:["$",l.toFixed(2)]}),jsx("span",{className:"text-[10px] text-neutral",children:o("predict.profile.contracts",{count:e.size})})]})}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",(e.size*i).toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:An(i)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:An(a)}),jsxs("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono",p),children:[jsxs("span",{children:[u,"$",Math.abs(n).toFixed(2)]}),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",u,s.toFixed(2),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",c.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap text-xs",children:h}),jsx("div",{className:"w-20 shrink-0 text-right",children:t&&jsxs("button",{type:"button",onClick:()=>t(e),className:"inline-flex items-center gap-1 text-xs text-neutral hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{className:"text-danger",children:"\u2715"}),o("predict.profile.close")]})})]})}function Dm({position:e,onClose:t,onEventClick:r}){let{t:o}=useTranslation(),n=e.pnl??0,s=e.pnl_percent??0,i=e.current_price??0,a=n>0?"text-success":n<0?"text-danger":"text-foreground",l=n>0?"+":"",c=e.event?.title??e.market?.question??"\u2014";return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("button",{type:"button",className:"flex items-start justify-between gap-2 text-left cursor-pointer",onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsx("img",{src:e.event.image_url,alt:"",className:"w-7 h-7 rounded-full object-cover shrink-0"}),jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:c})]}),jsx("span",{className:cn$1("shrink-0 text-xs font-medium px-1.5 py-0.5 rounded",e.side.toLowerCase()==="yes"?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side})]}),jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsx(Rr,{label:o("predict.profile.totalSize"),value:`${e.size}`}),jsx(Rr,{label:o("predict.profile.markPrice"),value:An(i)}),jsx(Rr,{label:o("predict.profile.pnl"),value:`${l}$${Math.abs(n).toFixed(2)} (${l}${s.toFixed(1)}%)`,className:a}),jsx(Rr,{label:o("predict.profile.payoutIfRight"),value:`$${e.size.toFixed(2)}`})]}),t&&jsx("div",{className:"flex justify-end",children:jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer transition-colors border border-border rounded px-2 py-1",children:o("predict.profile.close")})})]})}function Rr({label:e,value:t,className:r}){return jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:e}),jsx("span",{className:cn$1("font-mono text-foreground",r),children:t})]})}function Fm({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Hm({height:e}){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsx(Skeleton,{className:"h-12 w-full rounded-md"},r))})}function An(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function Bm(e){try{let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getFullYear(),a=t.getTimezoneOffset(),l=a<=0?"+":"-",c=String(Math.abs(Math.floor(a/60))).padStart(2,"0");return `${r}:${o} ${n}/${s}/${i} (${l}${c})`}catch{return "\u2014"}}function Ia({positions:e,trades:t,isLoading:r}){let{t:o}=useTranslation(),n=useMemo(()=>{let a=0,l=0;for(let d of e)a+=d.realized_pnl??0,l+=d.current_value??d.size*(d.current_price??0);let c=0,p=0,u=0;for(let d of t)c+=d.usd_size??0,d.type==="REDEEM"&&(u++,(d.usd_size??0)>0&&p++);let m=u>0?`${p} / ${u}`:"0 / 0";return {realizedPnl:a,positionsValue:l,volume:c,winRateStr:m}},[e,t]),s=n.realizedPnl>0?"text-success":n.realizedPnl<0?"text-danger":"text-foreground",i=n.realizedPnl>0?"+":"";return jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 py-8",children:[jsxs("div",{className:"flex flex-col gap-1",children:[jsx("span",{className:"text-xl text-neutral",children:o("predict.profile.realizedPnl")}),r?jsx(Skeleton,{className:"h-14 w-48 rounded-md"}):jsxs("span",{className:cn$1("text-5xl font-bold tabular-nums",s),children:[i,"$",Math.abs(n.realizedPnl).toFixed(2)]})]}),jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsx(Fn,{label:o("predict.profile.winRate"),value:n.winRateStr,isLoading:r}),jsx(Fn,{label:o("predict.profile.positions"),value:`$${n.positionsValue.toFixed(2)}`,isLoading:r}),jsx(Fn,{label:o("predict.profile.volume"),value:`$${n.volume.toFixed(2)}`,isLoading:r})]})]})}function Fn({label:e,value:t,isLoading:r}){return jsxs("div",{className:"flex flex-col items-end gap-0.5",children:[jsx("span",{className:"text-sm text-neutral whitespace-nowrap",children:e}),r?jsx(Skeleton,{className:"h-6 w-14 rounded-md"}):jsx("span",{className:"text-base font-semibold tabular-nums text-foreground",children:t})]})}var Hn=600;function Gm({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:o}){let{t:n}=useTranslation(),[s,i]=useState("positions"),a=!!(e||t),{data:l,isLoading:c}=usePositions({source:"kalshi",user:e??""}),{data:p,isLoading:u}=usePositions({source:"polymarket",user:t??""}),m=useMemo(()=>{let y=[];return l?.positions&&y.push(...l.positions),p?.positions&&y.push(...p.positions),y},[l,p]),d=c||u,{data:f,isLoading:g}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:h,isLoading:x}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),P=useMemo(()=>[...f?.pages?.flatMap(X=>X.items)??[],...h?.pages?.flatMap(X=>X.items)??[]],[f,h]),b=d||g||x,R=m.length,L=[{key:"positions",label:R>0?`${n("predict.profile.positionsTab")} (${R})`:n("predict.profile.positionsTab")},{key:"orders",label:n("predict.profile.openOrdersTab")},{key:"history",label:n("predict.profile.historyTab")}];return a?jsxs("div",{className:"flex flex-col max-w-[1280px] mx-auto w-full px-4 max-sm:px-2",children:[jsx(Ia,{positions:m,trades:P,isLoading:b}),jsx("div",{className:"flex items-center gap-1 border-b border-border",children:L.map(y=>jsx("button",{type:"button",onClick:()=>i(y.key),className:cn$1("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",s===y.key?"text-foreground border-b-2 border-foreground":"text-neutral hover:text-foreground"),children:y.label},y.key))}),jsxs("div",{className:"py-2",children:[s==="positions"&&jsx(_a,{positions:m,isLoading:d,listHeight:Hn,onClosePosition:r,onEventClick:o}),s==="orders"&&jsx(Ea,{solanaAddress:e,evmAddress:t,listHeight:Hn}),s==="history"&&jsx(ba,{solanaAddress:e,evmAddress:t,listHeight:Hn})]})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral py-24 px-4",children:n("predict.profile.connectWallet")})}function o1({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:o,onDeployAndApprove:n}){let{t:s}=useTranslation(),[i,a]=useState(false),[l,c]=useState(null),p=r?"done":i?"running":"pending",u=o?"done":r&&i?"running":"pending",m=r&&o,d=useCallback(async()=>{c(null),a(true);try{await n();}catch(x){c(x instanceof Error?x.message:String(x));}finally{a(false);}},[n]),f=[{key:"step1",label:s("predict.setup.step1"),status:p},{key:"step2",label:s("predict.setup.step2"),status:u}],g=()=>{m?t():d();},h=s(m?"predict.setup.done":"predict.setup.setupButton");return jsx(StyledModal,{isOpen:e,onOpenChange:x=>{x||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:s("predict.setup.modalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5 space-y-4",children:[jsx("p",{className:"text-[13px] text-zinc-400 text-center",children:s("predict.setup.modalDescription")}),jsx("div",{className:"space-y-2.5",children:f.map((x,P)=>jsxs("div",{className:"flex items-center gap-3 rounded-[10px] border border-zinc-700/50 bg-zinc-800/50 px-3 py-3",children:[jsx(Zm,{index:P+1,status:x.status}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("p",{className:"text-sm font-medium text-zinc-200",children:x.label}),jsx("p",{className:"text-xs text-zinc-500",children:x.status==="done"?s("predict.setup.stepComplete"):x.status==="running"?s("predict.setup.stepRunning"):s("predict.setup.stepPending")})]})]},x.key))}),l&&jsx("div",{className:"rounded-[10px] bg-red-500/10 border border-red-500/20 px-3 py-2",children:jsx("p",{className:"text-xs text-red-400",children:l})}),jsx("button",{type:"button",onClick:g,disabled:i,className:m?"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus":"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:i?jsxs("span",{className:"inline-flex items-center gap-2",children:[jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]}),s("predict.setup.stepRunning")]}):h}),!m&&jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] text-sm text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:s("common.cancel")})]})]})})})}function Zm({index:e,status:t}){return t==="done"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/15 shrink-0",children:jsx("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e]",children:jsx("polyline",{points:"20 6 9 17 4 12"})})}):t==="running"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/10 shrink-0",children:jsxs("svg",{className:"animate-spin h-4 w-4 text-[#c7ff2e]",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]})}):jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-zinc-700/50 text-xs font-bold text-zinc-400 shrink-0",children:e})}
|
|
72
|
-
export{
|
|
71
|
+
`}),jsxs("div",{style:{position:"relative",overflow:"hidden",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:0,overflow:"hidden"},children:[n&&jsx("img",{src:n,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",objectPosition:"center center",opacity:.3,mixBlendMode:"lighten",maskImage:"linear-gradient(to bottom, black 50%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 50%, transparent 100%)"}}),jsx("div",{style:{position:"absolute",inset:0,opacity:.025,backgroundImage:"radial-gradient(circle at 1px 1px, rgb(255 255 255) 1px, transparent 0)",backgroundSize:"20px 20px"}})]}),jsx("style",{children:".matches-hero-wrap{padding:40px 16px 32px}@media(min-width:640px){.matches-hero-wrap{padding:48px 24px 40px}}@media(min-width:1024px){.matches-hero-wrap{padding:52px 32px 44px}}"}),jsx("div",{className:"match-fade-in matches-hero-wrap",style:{position:"relative",zIndex:2,maxWidth:1152,margin:"0 auto"},children:jsx(ri,{stats:m})})]}),jsxs("div",{style:{position:"sticky",top:0,zIndex:40,background:"rgba(10,10,11,0.8)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderBottom:"1px solid rgba(39,39,42,0.5)"},children:[jsx("style",{children:".matches-toolbar-inner{padding:12px 16px}@media(min-width:640px){.matches-toolbar-inner{padding:12px 24px}}@media(min-width:1024px){.matches-toolbar-inner{padding:12px 32px}}"}),jsxs("div",{className:"matches-toolbar-inner",style:{maxWidth:1152,margin:"0 auto",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,minWidth:0},children:[jsx("div",{className:"hidden sm:flex",style:{alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:10,background:"linear-gradient(to bottom right, rgba(199,255,46,0.15), rgba(23,201,100,0.15))",border:"1px solid rgba(199,255,46,0.15)",flexShrink:0},children:jsxs("svg",{viewBox:"0 0 24 24",style:{width:16,height:16,color:"#c7ff2e"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"}),jsx("path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"}),jsx("path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"})]})}),jsxs("div",{style:{minWidth:0},children:[jsx("h2",{style:{fontSize:14,fontWeight:600,color:"#fff",margin:0,letterSpacing:"-0.28px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s(Jp[a])}),m&&m.activePairs>0&&jsx("p",{className:"hidden sm:block",style:{fontSize:11,color:"#71717a",margin:0},children:s("predict.matches.pairsFound",{count:m.activePairs})})]})]}),jsx(ti,{sortBy:a,onSortChange:g,sortAsc:l,onSortAscChange:h,minVolume:p,onMinVolumeChange:u,onRefresh:w})]})]}),jsx("style",{children:".matches-content-wrap{padding:24px 16px 80px}@media(min-width:640px){.matches-content-wrap{padding:32px 24px 80px}}@media(min-width:1024px){.matches-content-wrap{padding:24px 32px 80px}}"}),jsxs("div",{className:"match-fade-in-d2 matches-content-wrap",style:{position:"relative",maxWidth:1152,margin:"0 auto"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:16,padding:"8px 12px",borderRadius:8,border:"1px solid rgba(39,39,42,0.4)",background:"rgba(24,24,27,0.25)"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,color:"#52525b",flexShrink:0},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),jsxs("p",{style:{fontSize:11,color:"#52525b",lineHeight:1.5,margin:0},children:[jsx("span",{style:{color:"#71717a",fontWeight:500},children:s("predict.matches.experimentalFeature")})," \u2014 ",s("predict.matches.disclaimer")]})]}),jsx(di,{ref:f,sortBy:a,sortAsc:l,minVolume:p,onSelect:e,onHover:t,getMarketHref:r,LinkComponent:o,onStatsChange:x})]}),jsx(tm,{stats:m})]})}function En(e){return e==null?"-":e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${e.toFixed(0)}`}var nm={polymarket:{text:"#50a2ff",border:"rgba(43,127,255,0.15)",hoverBorder:"rgba(43,127,255,0.3)",bg:"rgba(43,127,255,0.05)",priceColor:"rgba(244,244,245,1)",priceActiveColor:"rgba(244,244,245,1)"},kalshi:{text:"#00d492",border:"rgba(0,212,146,0.15)",hoverBorder:"rgba(0,212,146,0.3)",bg:"rgba(0,212,146,0.05)",priceColor:"#00d492",priceActiveColor:"#00d492"}},om={text:"#9ca3af",border:"rgba(156,163,175,0.15)",hoverBorder:"rgba(156,163,175,0.3)",bg:"rgba(156,163,175,0.05)",priceColor:"rgba(244,244,245,1)",priceActiveColor:"rgba(244,244,245,1)"};function sm(e){return nm[e]??om}function im(e){if(!e.matched_markets?.length)return null;let t=null,r=-1;for(let o of e.matched_markets){let n=o.spread??0;n>r&&(r=n,t=o);}return t}function am(e,t){let r=e.entries.find(i=>i.source===(t?.source_a??e.entries[0]?.source)),o=e.entries.find(i=>i.source===(t?.source_b??e.entries[1]?.source)),n=i=>{if(!i?.outcomes?.[0])return {name:null,price:null};let l=i.outcomes[0];return {name:l.label||null,price:l.best_ask??l.price??null}},s=n(t?.market_a),a=n(t?.market_b);return [{source:t?.source_a??r?.source??"unknown",outcomeName:s.name,yesPrice:s.price,volume:r?.event?.volume??null,event:r?.event},{source:t?.source_b??o?.source??"unknown",outcomeName:a.name,yesPrice:a.price,volume:o?.event?.volume??null,event:o?.event}]}function nb({group:e,onSelectEntry:t,getEventHref:r,LinkComponent:o}){let {t:n}=useTranslation(),s=useMemo(()=>im(e),[e]),a=e.max_spread!=null?e.max_spread*100:null,[i,l]=useMemo(()=>am(e,s),[e,s]),c=a!=null&&a>=3;i.yesPrice!=null&&l.yesPrice!=null?i.source==="kalshi"?i.yesPrice>l.yesPrice:l.yesPrice>i.yesPrice:false;let u=i.yesPrice!=null&&l.yesPrice!=null?i.yesPrice<=l.yesPrice?i:l:null,m=u?ot(u.source):null,d=c?"amber":"violet";return jsxs("div",{className:"group",style:{borderRadius:16,border:"1px solid rgba(39,39,42,0.6)",background:"rgba(24,24,27,0.4)",overflow:"hidden",transition:"all 0.2s",position:"relative"},onMouseEnter:f=>{let g=f.currentTarget;g.style.borderColor="rgba(63,63,70,0.6)",g.style.boxShadow="0 10px 15px -3px rgba(0,0,0,0.2)";},onMouseLeave:f=>{let g=f.currentTarget;g.style.borderColor="rgba(39,39,42,0.6)",g.style.boxShadow="none";},children:[a!=null&&jsxs("span",{style:{position:"absolute",top:12,right:12,zIndex:10,display:"inline-flex",alignItems:"center",gap:4,borderRadius:10,padding:"4px 10px",fontSize:12,fontWeight:600,border:`1px solid ${c?"rgba(255,185,0,0.3)":a>=2?"rgba(166,132,255,0.3)":"rgba(156,163,175,0.3)"}`,background:c?"rgba(255,185,0,0.15)":a>=2?"rgba(166,132,255,0.15)":"rgba(156,163,175,0.12)",color:c?"#ffb900":a>=2?"#a684ff":"#9ca3af"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),a.toFixed(1),"%"]}),jsxs("div",{style:{padding:16},children:[jsx("h3",{style:{fontSize:14,fontWeight:600,lineHeight:1.375,letterSpacing:"-0.28px",color:"#f4f4f5",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",paddingRight:80,margin:"0 0 16px"},children:e.title}),jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[jsx(mi,{data:i,isCheaper:u===i,onSelect:t,getEventHref:r,LinkComponent:o}),jsx(mi,{data:l,isCheaper:u===l,onSelect:t,getEventHref:r,LinkComponent:o})]}),u&&m&&a!=null&&jsxs("div",{style:{marginTop:12,padding:"8px 12px",borderRadius:10,display:"flex",alignItems:"center",gap:8,cursor:"pointer",transition:"all 0.15s",border:`1px solid ${d==="amber"?"rgba(255,185,0,0.15)":"rgba(166,132,255,0.15)"}`,background:d==="amber"?"rgba(255,185,0,0.05)":"rgba(166,132,255,0.05)"},onClick:()=>u.event&&t?.(u.event),children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:14,height:14,flexShrink:0,color:d==="amber"?"#ffb900":"#a684ff"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"})}),jsx("span",{style:{fontSize:11,fontWeight:500,color:d==="amber"?"rgba(255,185,0,0.9)":"rgba(166,132,255,0.9)"},children:n("predict.matches.buyEdge",{platform:u.source.charAt(0).toUpperCase()+u.source.slice(1),spread:a.toFixed(1)})}),jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12,marginLeft:"auto",color:d==="amber"?"rgba(255,185,0,0.5)":"rgba(166,132,255,0.5)"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M5 12h14"}),jsx("path",{d:"m12 5 7 7-7 7"})]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid rgba(39,39,42,0.5)",background:"rgba(39,39,42,0.2)",padding:"10px 16px"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,fontSize:10,color:"#71717a"},children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsxs("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),jsx("path",{d:"M18 17V9"}),jsx("path",{d:"M13 17V5"}),jsx("path",{d:"M8 17v-3"})]}),En(e.combined_volume)]}),e.combined_volume_24h!=null&&e.combined_volume_24h>0&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})}),En(e.combined_volume_24h)," ",n("predict.matches.vol24h")]})]}),e.confidence!=null&&jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:10,color:"#52525b"},children:[jsx("svg",{viewBox:"0 0 24 24",style:{width:12,height:12},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"})}),Math.round(e.confidence*100),"%"," ",n("predict.matches.match")]})]})]})}function mi({data:e,isCheaper:t,onSelect:r,getEventHref:o,LinkComponent:n}){let{t:s}=useTranslation(),a=ot(e.source),i=sm(e.source),l=e.event?o?.(e.event):void 0,c=jsxs("div",{style:{borderRadius:14,border:`1px solid ${i.border}`,background:i.bg,padding:12,cursor:l||r?"pointer":void 0,transition:"border-color 0.15s"},onMouseEnter:p=>{p.currentTarget.style.borderColor=i.hoverBorder;},onMouseLeave:p=>{p.currentTarget.style.borderColor=i.border;},onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[a.icon,jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.05em",color:i.text,textTransform:"uppercase"},children:a.label}),jsxs("svg",{viewBox:"0 0 24 24",className:"opacity-0 group-hover:opacity-100 transition-opacity",style:{width:10,height:10,color:"#52525b",marginLeft:"auto"},fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 7h10v10"}),jsx("path",{d:"M7 17 17 7"})]})]}),e.outcomeName&&jsx("div",{style:{fontSize:10,color:"#71717a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginBottom:8},children:e.outcomeName}),jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[jsx("span",{style:{fontSize:20,fontWeight:700,fontVariantNumeric:"tabular-nums",color:t?i.priceActiveColor:i.priceColor},children:e.yesPrice!=null?(e.yesPrice*100).toFixed(1):"-"}),jsx("span",{style:{fontSize:10,color:"#71717a"},children:s("predict.matches.centsYes")})]}),jsxs("div",{style:{fontSize:10,color:"#52525b",marginTop:6},children:[En(e.volume)," ",s("predict.matches.volume")]})]});return l&&n?jsx(n,{href:l,className:"block",children:c}):c}function dm(e){return e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${(e/1e3).toFixed(1)}K`:`$${e.toFixed(0)}`}function lb({matches:e,total:t}){let{t:r}=useTranslation(),o=useMemo(()=>{let n=0,s=0,a=new Set;for(let i of e){i.max_spread!=null&&i.max_spread>n&&(n=i.max_spread),i.combined_volume!=null&&(s+=i.combined_volume);for(let l of i.entries)a.add(typeof l.source=="string"?l.source:"");}return {count:t??e.length,maxSpread:n,totalVolume:s,platformCount:a.size}},[e,t]);return jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 rounded-xl border border-border/60 bg-background/50 px-4 py-3 text-sm",children:[jsx(Mr,{label:r("predict.matches.stats.matchedMarkets"),value:o.count.toLocaleString()}),jsx(Tn,{}),jsx(Mr,{label:r("predict.matches.stats.totalVolume"),value:dm(o.totalVolume)}),jsx(Tn,{}),jsx(Mr,{label:r("predict.matches.stats.highestSpread"),value:`${(o.maxSpread*100).toFixed(1)}\xA2`,valueClassName:"text-green-400"}),jsx(Tn,{}),jsx(Mr,{label:r("predict.matches.stats.platforms"),value:String(o.platformCount)})]})}function Mr({label:e,value:t,valueClassName:r="text-slate-200"}){return jsxs("div",{className:"flex items-center gap-x-1.5",children:[jsxs("span",{className:"text-neutral-500",children:[e,":"]}),jsx("span",{className:`font-semibold ${r}`,children:t})]})}function Tn(){return jsx("span",{className:"hidden text-neutral-700 sm:inline",children:"|"})}function hi(e){return `${(e*100).toFixed(1)}\xA2`}function um(e){return e>=.05?"text-green-400":e>=.02?"text-yellow-400":"text-neutral-400"}function pb({spread:e,arbProfit:t,className:r}){if(e==null)return null;let o=t!=null&&t>0;return jsxs("div",{className:cn$1("flex items-center gap-x-2",r),children:[jsx("span",{className:cn$1("text-sm font-semibold",um(e)),children:hi(e)}),o&&jsxs("span",{className:"text-xs text-green-500/80",children:["+",hi(t)]})]})}var qt=10,xm=64,yi=40,Er=48;function ki({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=useTranslation(),[n,s]=useState(1),{data:a,isLoading:i,fetchNextPage:l,hasNextPage:c,isFetchingNextPage:p}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:50}),{data:u,isLoading:m,fetchNextPage:d,hasNextPage:f,isFetchingNextPage:g}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:50}),h=i||m,x=p||g,w=c||f,b=useMemo(()=>{let D=[];return a?.pages&&D.push(...a.pages.flatMap($=>$.items)),u?.pages&&D.push(...u.pages.flatMap($=>$.items)),D.sort(($,H)=>(H.timestamp??0)-($.timestamp??0)),D},[a,u]),L=Math.max(1,Math.ceil(b.length/qt)+(w?1:0)),v=(n-1)*qt,T=b.slice(v,v+qt),y=useCallback(()=>{s(D=>Math.max(1,D-1));},[]),X=useCallback(async()=>{n*qt>=b.length&&w&&(c&&await l(),f&&await d()),s($=>$+1);},[n,b.length,w,c,f,l,d]),Y=n>1,K=n*qt<b.length||w;if(h)return jsx(wm,{height:r});if(b.length===0&&!w)return jsx(Sm,{message:o("predict.profile.noHistory"),height:r});let oe=r-yi-Er;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:yi},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:o("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.status")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.price")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:o("predict.profile.depositWithdraw")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.pnl")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.fee")}),jsx("div",{className:"w-10 shrink-0"})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:oe},children:[T.map((D,$)=>jsx(vm,{trade:D},D.id??`${v+$}`)),x&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:Er},children:[jsxs("button",{type:"button",disabled:!Y,onClick:y,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",Y?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",o("predict.profile.previous")]}),Array.from({length:Math.min(L,5)},(D,$)=>{let H=$+1;return jsx("button",{type:"button",onClick:()=>s(H),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",H===n?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:H},H)}),jsxs("button",{type:"button",disabled:!K,onClick:X,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",K?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[o("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-Er},children:T.map((D,$)=>jsx(bm,{trade:D},D.id??`m-${v+$}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:Er},children:[jsx("button",{type:"button",disabled:!Y,onClick:y,className:cn$1("text-sm cursor-pointer",Y?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:n}),jsx("button",{type:"button",disabled:!K,onClick:X,className:cn$1("text-sm cursor-pointer",K?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function vm({trade:e}){let{t}=useTranslation(),r=e.side?.toUpperCase()==="BUY",o=e.price??0,n=e.usd_size??0,s=Si(e.type,t),a=r,i=a?"+":"-",l=a?"text-success":"text-foreground",c=e.event?.title??e.market?.question??"\u2014",p=e.event?.image_url,u=e.outcome??"",m=Ci(e.timestamp),d=wi(e),f=ym(e),g=km(e);return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:xm},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[p&&jsx("img",{src:p,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsx("span",{className:"text-foreground truncate font-medium text-sm",children:c}),jsxs("span",{className:"text-[11px] text-neutral",children:[u&&jsx("span",{className:"mr-1",children:u}),jsx("span",{children:m})]})]})]})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn$1("text-sm font-medium",r?"text-success":"text-danger"),children:t(r?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-sm text-foreground",children:s}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:Pi(o)}),jsx("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono",l),children:n>0?jsxs(Fragment,{children:[i,"$",n.toFixed(2)]}):"\u2014"}),jsx("div",{className:cn$1("flex-1 pr-2 text-right font-mono",f!==null?f>=0?"text-success":"text-danger":"text-neutral"),children:f!==null?`${f>=0?"+":"-"}$${Math.abs(f).toFixed(2)}`:"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-neutral",children:g!==null?`$${g.toFixed(2)}`:"\u2014"}),jsx("div",{className:"w-10 shrink-0 text-right",children:d&&jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"text-neutral hover:text-foreground transition-colors","aria-label":"View transaction",children:jsx(Ni,{})})})]})}function bm({trade:e}){let{t}=useTranslation(),r=e.side?.toUpperCase()==="BUY",o=e.price??0,n=e.usd_size??0,s=Si(e.type,t),a=e.event?.title??e.market?.question??"\u2014",i=Ci(e.timestamp),l=wi(e);return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsx("img",{src:e.event.image_url,alt:"",className:"w-6 h-6 rounded-full object-cover shrink-0"}),jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:a})]}),jsx("span",{className:"text-[11px] text-neutral whitespace-nowrap",children:i})]}),jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.action")}),jsx("span",{className:cn$1("font-medium",r?"text-success":"text-danger"),children:t(r?"predict.profile.buy":"predict.profile.sell")})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.status")}),jsx("span",{className:"text-foreground",children:s})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.price")}),jsx("span",{className:"font-mono text-foreground",children:Pi(o)})]}),jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:t("predict.profile.depositWithdraw")}),jsx("span",{className:"font-mono text-foreground",children:n>0?`$${n.toFixed(2)}`:"\u2014"})]}),l&&jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:"ml-auto text-neutral hover:text-foreground transition-colors",children:jsx(Ni,{})})]})]})}function Si(e,t){switch(e){case "TRADE":return t("predict.profile.filled");case "REDEEM":return t("predict.profile.claimed");case "SPLIT":case "MERGE":case "CONVERSION":return t("predict.profile.created");default:return e}}function wi(e){if(e.tx_hash)return e.source==="polymarket"?`https://polygonscan.com/tx/${e.tx_hash}`:`https://solscan.io/tx/${e.tx_hash}`}function ym(e){let t=e.provider_meta;if(t){let r=t.pnl??t.profit??t.realized_pnl??t["dflow.pnl"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let o=parseFloat(r);if(!Number.isNaN(o))return o}}return e.type==="REDEEM"&&e.usd_size!=null?e.usd_size:null}function km(e){let t=e.provider_meta;if(t){let r=t.fee??t.fees??t.trading_fee??t["dflow.fee"];if(typeof r=="number")return r;if(typeof r=="string"&&r!==""){let o=parseFloat(r);if(!Number.isNaN(o))return o}}return null}function Ni(){return jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),jsx("polyline",{points:"15 3 21 3 21 9"}),jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}function Sm({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function wm({height:e}){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsx(Skeleton,{className:"h-12 w-full rounded-md"},r))})}function Pi(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function Ci(e){let t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear(),i=t.getTimezoneOffset(),l=i<=0?"+":"-",c=String(Math.abs(Math.floor(i/60))).padStart(2,"0");return `${r}:${o} ${n}/${s}/${a} (${l}${c})`}var Qt=10,Lm=64,Ei=40,Tr=48;function Li({solanaAddress:e,evmAddress:t,listHeight:r}){let{t:o}=useTranslation(),n=useCancelOrder(),[s,a]=useState(1),{data:i,isLoading:l,fetchNextPage:c,hasNextPage:p,isFetchingNextPage:u}=useInfiniteOrders({source:"kalshi",wallet_address:e??""}),{data:m,isLoading:d,fetchNextPage:f,hasNextPage:g,isFetchingNextPage:h}=useInfiniteOrders({source:"polymarket",wallet_address:t??""}),x=l||d,w=u||h,b=p||g,L=useMemo(()=>{let H=[],fe=new Set(["live","open","submitted","pending"]);return i?.pages&&H.push(...i.pages.flatMap(ge=>ge.items).filter(ge=>fe.has(ge.status))),m?.pages&&H.push(...m.pages.flatMap(ge=>ge.items).filter(ge=>fe.has(ge.status))),H},[i,m]),v=useCallback(H=>{n.mutate({source:H.source,id:H.id});},[n]),T=Math.max(1,Math.ceil(L.length/Qt)+(b?1:0)),y=(s-1)*Qt,X=L.slice(y,y+Qt),Y=useCallback(()=>{a(H=>Math.max(1,H-1));},[]),K=useCallback(async()=>{s*Qt>=L.length&&b&&(p&&await c(),g&&await f()),a(fe=>fe+1);},[s,L.length,b,p,g,c,f]),oe=s>1,D=s*Qt<L.length||b;if(x)return jsx(Om,{height:r});if(L.length===0&&!b)return jsx(Im,{message:o("predict.profile.noOrders"),height:r});let $=r-Ei-Tr;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:Ei},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:o("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.action")}),jsx("div",{className:"flex-1 pr-2",children:o("predict.profile.type")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.fillPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:o("predict.profile.cost")})]}),jsxs("div",{className:"hidden lg:block overflow-y-auto",style:{height:$},children:[X.map(H=>jsx(_m,{order:H,onCancel:v},H.id)),w&&jsx("div",{className:"flex justify-center items-center py-4",children:jsx(Spinner,{size:"sm"})})]}),jsx(Ti,{className:"hidden lg:flex",currentPage:s,totalPages:T,canGoPrev:oe,canGoNext:D,onPrev:Y,onNext:K,onPage:a,t:o}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-Tr},children:X.map(H=>jsx(Rm,{order:H,onCancel:v},H.id))}),jsx(Ti,{className:"lg:hidden",currentPage:s,totalPages:T,canGoPrev:oe,canGoNext:D,onPrev:Y,onNext:K,onPage:a,t:o,compact:true})]})}function _m({order:e,onCancel:t}){let{t:r}=useTranslation(),o=e.side==="BUY",n=e.price?parseFloat(e.price):0,s=e.in_amount?parseFloat(e.in_amount):n*parseFloat(e.original_size??"0");return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:Lm},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsx("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:jsx("span",{className:"text-foreground truncate font-medium",children:e.outcome??e.market_id??"\u2014"})})}),jsx("div",{className:"flex-1 pr-2",children:jsx("span",{className:cn$1("text-sm font-medium",o?"text-success":"text-danger"),children:r(o?"predict.profile.buy":"predict.profile.sell")})}),jsx("div",{className:"flex-1 pr-2 text-neutral capitalize text-sm",children:e.order_type??"limit"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:n>0?_i(n):"\u2014"}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:s>0?`$${s.toFixed(2)}`:"\u2014"})]})}function Rm({order:e,onCancel:t}){let{t:r}=useTranslation(),o=e.side==="BUY",n=e.price?parseFloat(e.price):0;return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:cn$1("text-xs font-medium px-1.5 py-0.5 rounded",o?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side}),jsx("span",{className:"text-sm text-foreground capitalize",children:e.outcome??"\u2014"})]}),jsx("span",{className:"text-xs text-neutral capitalize",children:e.order_type??"limit"})]}),jsxs("div",{className:"flex items-center gap-4 text-xs",children:[jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:r("predict.profile.fillPrice")}),jsx("span",{className:"font-mono text-foreground",children:n>0?_i(n):"\u2014"})]}),jsx("div",{className:"flex-1"}),jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer border border-border rounded px-2 py-1",children:r("predict.orders.cancel")})]})]})}function Ti({className:e,currentPage:t,totalPages:r,canGoPrev:o,canGoNext:n,onPrev:s,onNext:a,onPage:i,t:l,compact:c}){return c?jsxs("div",{className:cn$1("flex items-center justify-center gap-3 shrink-0",e),style:{height:Tr},children:[jsx("button",{type:"button",disabled:!o,onClick:s,className:cn$1("text-sm cursor-pointer",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:t}),jsx("button",{type:"button",disabled:!n,onClick:a,className:cn$1("text-sm cursor-pointer",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]}):jsxs("div",{className:cn$1("flex items-center justify-center gap-2 shrink-0",e),style:{height:Tr},children:[jsxs("button",{type:"button",disabled:!o,onClick:s,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",o?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",l("predict.profile.previous")]}),Array.from({length:Math.min(r,5)},(p,u)=>{let m=u+1;return jsx("button",{type:"button",onClick:()=>i(m),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",m===t?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:m},m)}),jsxs("button",{type:"button",disabled:!n,onClick:a,className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",n?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[l("predict.profile.next")," \u2192"]})]})}function Im({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Om({height:e}){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsx(Skeleton,{className:"h-12 w-full rounded-md"},r))})}function _i(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}var On=10,Hm=64,Ri=40,Lr=48;function Ii({positions:e,isLoading:t,listHeight:r,onClosePosition:o,onEventClick:n}){let{t:s}=useTranslation(),[a,i]=useState(1),l=useCallback(()=>{for(let g of e)o?.(g);},[e,o]);if(t)return jsx(Wm,{height:r});if(e.length===0)return jsx(zm,{message:s("predict.profile.noPositions"),height:r});let c=Math.max(1,Math.ceil(e.length/On)),p=(a-1)*On,u=e.slice(p,p+On),m=a>1,d=a<c,f=r-Ri-Lr;return jsxs("div",{className:"flex flex-col",style:{height:r},children:[jsxs("div",{className:"hidden lg:flex items-center text-neutral text-xs font-normal shrink-0 border-b border-border/50",style:{height:Ri},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:s("predict.profile.event")}),jsx("div",{className:"flex-1 pr-2 text-right",children:s("predict.profile.totalSize")}),jsx("div",{className:"flex-1 pr-2 text-right",children:s("predict.profile.value")}),jsx("div",{className:"flex-1 pr-2 text-right",children:s("predict.profile.avgPrice")}),jsx("div",{className:"flex-1 pr-2 text-right",children:s("predict.profile.markPrice")}),jsxs("div",{className:"flex-[1.5] pr-2 text-right",children:[jsx("span",{children:s("predict.profile.pnl")}),jsxs("span",{className:"text-[10px] ml-1 opacity-60",children:["(",s("predict.profile.pnlExcludeFees"),")"]})]}),jsx("div",{className:"flex-1 pr-2 text-right",children:s("predict.profile.payoutIfRight")}),jsx("div",{className:"flex-[1.5] pr-2 text-right",children:s("predict.profile.estSettlement")}),jsx("div",{className:"w-20 shrink-0 text-right",children:o&&e.length>0&&jsx("button",{type:"button",onClick:l,className:"text-xs text-primary hover:text-primary/80 cursor-pointer transition-colors",children:s("predict.profile.closeAll")})})]}),jsx("div",{className:"hidden lg:block overflow-y-auto",style:{height:f},children:u.map((g,h)=>jsx(Bm,{position:g,onClosePosition:o,onEventClick:n},`${g.source}-${g.market?.slug??p+h}`))}),jsxs("div",{className:"hidden lg:flex items-center justify-center gap-2 shrink-0",style:{height:Lr},children:[jsxs("button",{type:"button",disabled:!m,onClick:()=>i(g=>Math.max(1,g-1)),className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",m?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:["\u2190 ",s("predict.profile.previous")]}),Array.from({length:Math.min(c,5)},(g,h)=>{let x=h+1;return jsx("button",{type:"button",onClick:()=>i(x),className:cn$1("w-8 h-8 rounded text-sm transition-colors cursor-pointer",x===a?"bg-foreground/10 text-foreground font-medium":"text-neutral hover:text-foreground"),children:x},x)}),jsxs("button",{type:"button",disabled:!d,onClick:()=>i(g=>g+1),className:cn$1("text-sm transition-colors cursor-pointer flex items-center gap-1",d?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:[s("predict.profile.next")," \u2192"]})]}),jsx("div",{className:"lg:hidden flex flex-col gap-2 overflow-y-auto py-2",style:{height:r-Lr},children:u.map((g,h)=>jsx($m,{position:g,onClose:o,onEventClick:n},`${g.source}-${g.market?.slug??`m-${p+h}`}`))}),jsxs("div",{className:"lg:hidden flex items-center justify-center gap-3 shrink-0",style:{height:Lr},children:[jsx("button",{type:"button",disabled:!m,onClick:()=>i(g=>Math.max(1,g-1)),className:cn$1("text-sm cursor-pointer",m?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2190"}),jsx("span",{className:"text-sm text-foreground tabular-nums",children:a}),jsx("button",{type:"button",disabled:!d,onClick:()=>i(g=>g+1),className:cn$1("text-sm cursor-pointer",d?"text-neutral hover:text-foreground":"text-neutral/40 cursor-not-allowed"),children:"\u2192"})]})]})}function Bm({position:e,onClosePosition:t,onEventClick:r}){let{t:o}=useTranslation(),n=e.pnl??0,s=e.pnl_percent??0,a=e.avg_price??0,i=e.current_price??0,l=e.current_value??e.size*i,c=e.size,p=n>0?"text-success":n<0?"text-danger":"text-foreground",u=n>0?"+":"",m=e.event?.title??e.market?.question??"\u2014",d=e.event?.image_url,f=e.side,g=e.market?.outcomes?.[0]?.label??"",h=e.market?.end_at?Um(e.market.end_at):"\u2014";return jsxs("div",{className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-sm",style:{height:Hm},children:[jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxs("button",{type:"button",className:"flex items-center gap-2.5 min-w-0 cursor-pointer text-left",onClick:()=>e.event&&r?.(e.event),children:[d&&jsx("img",{src:d,alt:"",className:"w-8 h-8 rounded-full object-cover shrink-0"}),jsxs("div",{className:"flex flex-col gap-y-0.5 min-w-0",children:[jsx("span",{className:"text-foreground truncate font-medium text-sm",children:m}),jsxs("span",{className:"text-[11px] text-neutral",children:[jsx("span",{className:cn$1("font-medium",f.toLowerCase()==="yes"?"text-success":"text-danger"),children:f}),g&&jsxs(Fragment,{children:[jsx("span",{className:"mx-1",children:"\xB7"}),jsx("span",{children:g})]})]})]})]})}),jsx("div",{className:"flex-1 pr-2 text-right",children:jsxs("div",{className:"flex flex-col items-end",children:[jsxs("span",{className:"font-mono text-foreground",children:["$",l.toFixed(2)]}),jsx("span",{className:"text-[10px] text-neutral",children:o("predict.profile.contracts",{count:e.size})})]})}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",(e.size*a).toFixed(2)]}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:An(a)}),jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:An(i)}),jsxs("div",{className:cn$1("flex-[1.5] pr-2 text-right font-mono",p),children:[jsxs("span",{children:[u,"$",Math.abs(n).toFixed(2)]}),jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",u,s.toFixed(2),"%)"]})]}),jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",c.toFixed(2)]}),jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap text-xs",children:h}),jsx("div",{className:"w-20 shrink-0 text-right",children:t&&jsxs("button",{type:"button",onClick:()=>t(e),className:"inline-flex items-center gap-1 text-xs text-neutral hover:text-foreground cursor-pointer transition-colors",children:[jsx("span",{className:"text-danger",children:"\u2715"}),o("predict.profile.close")]})})]})}function $m({position:e,onClose:t,onEventClick:r}){let{t:o}=useTranslation(),n=e.pnl??0,s=e.pnl_percent??0,a=e.current_price??0,i=n>0?"text-success":n<0?"text-danger":"text-foreground",l=n>0?"+":"",c=e.event?.title??e.market?.question??"\u2014";return jsxs("div",{className:"rounded-lg border border-border bg-content1 p-3 flex flex-col gap-2",children:[jsxs("button",{type:"button",className:"flex items-start justify-between gap-2 text-left cursor-pointer",onClick:()=>e.event&&r?.(e.event),children:[jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.event?.image_url&&jsx("img",{src:e.event.image_url,alt:"",className:"w-7 h-7 rounded-full object-cover shrink-0"}),jsx("span",{className:"text-sm font-medium text-foreground line-clamp-2",children:c})]}),jsx("span",{className:cn$1("shrink-0 text-xs font-medium px-1.5 py-0.5 rounded",e.side.toLowerCase()==="yes"?"bg-success/10 text-success":"bg-danger/10 text-danger"),children:e.side})]}),jsxs("div",{className:"flex items-center gap-4 text-xs flex-wrap",children:[jsx(_r,{label:o("predict.profile.totalSize"),value:`${e.size}`}),jsx(_r,{label:o("predict.profile.markPrice"),value:An(a)}),jsx(_r,{label:o("predict.profile.pnl"),value:`${l}$${Math.abs(n).toFixed(2)} (${l}${s.toFixed(1)}%)`,className:i}),jsx(_r,{label:o("predict.profile.payoutIfRight"),value:`$${e.size.toFixed(2)}`})]}),t&&jsx("div",{className:"flex justify-end",children:jsx("button",{type:"button",onClick:()=>t(e),className:"text-xs text-danger hover:text-danger/80 cursor-pointer transition-colors border border-border rounded px-2 py-1",children:o("predict.profile.close")})})]})}function _r({label:e,value:t,className:r}){return jsxs("div",{className:"flex flex-col",children:[jsx("span",{className:"text-neutral",children:e}),jsx("span",{className:cn$1("font-mono text-foreground",r),children:t})]})}function zm({message:e,height:t}){return jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:t},children:e})}function Wm({height:e}){return jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:e},children:Array.from({length:6}).map((t,r)=>jsx(Skeleton,{className:"h-12 w-full rounded-md"},r))})}function An(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(t%1===0?0:1)}\xA2`}function Um(e){try{let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear(),i=t.getTimezoneOffset(),l=i<=0?"+":"-",c=String(Math.abs(Math.floor(i/60))).padStart(2,"0");return `${r}:${o} ${n}/${s}/${a} (${l}${c})`}catch{return "\u2014"}}function Ai({positions:e,trades:t,isLoading:r}){let{t:o}=useTranslation(),n=useMemo(()=>{let i=0,l=0;for(let d of e)i+=d.realized_pnl??0,l+=d.current_value??d.size*(d.current_price??0);let c=0,p=0,u=0;for(let d of t)c+=d.usd_size??0,d.type==="REDEEM"&&(u++,(d.usd_size??0)>0&&p++);let m=u>0?`${p} / ${u}`:"0 / 0";return {realizedPnl:i,positionsValue:l,volume:c,winRateStr:m}},[e,t]),s=n.realizedPnl>0?"text-success":n.realizedPnl<0?"text-danger":"text-foreground",a=n.realizedPnl>0?"+":"";return jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 py-8",children:[jsxs("div",{className:"flex flex-col gap-1",children:[jsx("span",{className:"text-xl text-neutral",children:o("predict.profile.realizedPnl")}),r?jsx(Skeleton,{className:"h-14 w-48 rounded-md"}):jsxs("span",{className:cn$1("text-5xl font-bold tabular-nums",s),children:[a,"$",Math.abs(n.realizedPnl).toFixed(2)]})]}),jsxs("div",{className:"flex items-end gap-8 sm:gap-10",children:[jsx(Fn,{label:o("predict.profile.winRate"),value:n.winRateStr,isLoading:r}),jsx(Fn,{label:o("predict.profile.positions"),value:`$${n.positionsValue.toFixed(2)}`,isLoading:r}),jsx(Fn,{label:o("predict.profile.volume"),value:`$${n.volume.toFixed(2)}`,isLoading:r})]})]})}function Fn({label:e,value:t,isLoading:r}){return jsxs("div",{className:"flex flex-col items-end gap-0.5",children:[jsx("span",{className:"text-sm text-neutral whitespace-nowrap",children:e}),r?jsx(Skeleton,{className:"h-6 w-14 rounded-md"}):jsx("span",{className:"text-base font-semibold tabular-nums text-foreground",children:t})]})}var Hn=600;function Xm({solanaAddress:e,evmAddress:t,onClosePosition:r,onEventClick:o}){let{t:n}=useTranslation(),[s,a]=useState("positions"),i=!!(e||t),{data:l,isLoading:c}=usePositions({source:"kalshi",user:e??""}),{data:p,isLoading:u}=usePositions({source:"polymarket",user:t??""}),m=useMemo(()=>{let y=[];return l?.positions&&y.push(...l.positions),p?.positions&&y.push(...p.positions),y},[l,p]),d=c||u,{data:f,isLoading:g}=useInfiniteTrades({source:"kalshi",wallet:e??"",limit:100}),{data:h,isLoading:x}=useInfiniteTrades({source:"polymarket",wallet:t??"",limit:100}),w=useMemo(()=>[...f?.pages?.flatMap(X=>X.items)??[],...h?.pages?.flatMap(X=>X.items)??[]],[f,h]),b=d||g||x,L=m.length,T=[{key:"positions",label:L>0?`${n("predict.profile.positionsTab")} (${L})`:n("predict.profile.positionsTab")},{key:"orders",label:n("predict.profile.openOrdersTab")},{key:"history",label:n("predict.profile.historyTab")}];return i?jsxs("div",{className:"flex flex-col max-w-[1280px] mx-auto w-full px-4 max-sm:px-2",children:[jsx(Ai,{positions:m,trades:w,isLoading:b}),jsx("div",{className:"flex items-center gap-1 border-b border-border",children:T.map(y=>jsx("button",{type:"button",onClick:()=>a(y.key),className:cn$1("px-3 py-3 text-base font-normal transition-colors cursor-pointer whitespace-nowrap",s===y.key?"text-foreground border-b-2 border-foreground":"text-neutral hover:text-foreground"),children:y.label},y.key))}),jsxs("div",{className:"py-2",children:[s==="positions"&&jsx(Ii,{positions:m,isLoading:d,listHeight:Hn,onClosePosition:r,onEventClick:o}),s==="orders"&&jsx(Li,{solanaAddress:e,evmAddress:t,listHeight:Hn}),s==="history"&&jsx(ki,{solanaAddress:e,evmAddress:t,listHeight:Hn})]})]}):jsx("div",{className:"flex items-center justify-center text-sm text-neutral py-24 px-4",children:n("predict.profile.connectWallet")})}function l1({isOpen:e,onClose:t,safeDeployed:r,tokenApproved:o,onDeployAndApprove:n}){let{t:s}=useTranslation(),[a,i]=useState(false),[l,c]=useState(null),[p,u]=useState(false),m=r||p,d=o||p,f=m?"done":a?"running":"pending",g=d?"done":m&&a?"running":"pending",h=m&&d,x=useCallback(async()=>{c(null),u(false),i(true);try{await n(),u(!0);}catch(v){c(v instanceof Error?v.message:String(v));}finally{i(false);}},[n]),w=[{key:"step1",label:s("predict.setup.step1"),desc:s("predict.setup.step1Desc"),status:f},{key:"step2",label:s("predict.setup.step2"),desc:s("predict.setup.step2Desc"),status:g}],b=()=>{h?t():x();},L=s(h?"predict.setup.done":"predict.setup.setupButton");return jsx(StyledModal,{isOpen:e,onOpenChange:v=>{v||t();},size:"md",classNames:{base:"!bg-[#18181b] !rounded-[14px] !border !border-[rgba(39,39,42,1)] !shadow-[0_25px_50px_-12px_rgba(0,0,0,0.5)]",body:"!p-0"},children:jsx(ModalContent,{children:jsxs("div",{children:[jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4",children:[jsx("h3",{className:"text-base font-semibold text-white",children:s("predict.setup.modalTitle")}),jsx("button",{type:"button",onClick:t,className:"p-1 rounded-[10px] hover:bg-[rgba(39,39,42,0.5)] text-zinc-400 hover:text-white transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),jsxs("div",{className:"px-5 pb-5 space-y-4",children:[jsx("p",{className:"text-[13px] text-zinc-400 text-left",children:s("predict.setup.modalDescription")}),jsx("div",{className:"space-y-2.5",children:w.map((v,T)=>jsxs("div",{className:"flex gap-3 rounded-[10px] border border-zinc-700/50 bg-zinc-800/50 px-3 py-3",children:[jsx(rf,{index:T+1,status:v.status}),jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("p",{className:"text-sm font-medium text-zinc-200",children:v.label}),jsx("span",{className:`text-[11px] leading-none ${v.status==="done"?"text-[#c7ff2e]":v.status==="running"?"text-[#c7ff2e]/70":"text-zinc-500"}`,children:v.status==="done"?s("predict.setup.stepComplete"):v.status==="running"?s("predict.setup.stepRunning"):s("predict.setup.stepPending")})]}),jsx("p",{className:"text-xs text-zinc-500 mt-1",children:v.desc})]})]},v.key))}),l&&jsx("div",{className:"rounded-[10px] bg-red-500/10 border border-red-500/20 px-3 py-2",children:jsx("p",{className:"text-xs text-red-400",children:l})}),jsx("button",{type:"button",onClick:b,disabled:a,className:h?"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus":"w-full py-3 rounded-[10px] bg-[#c7ff2e] text-zinc-900 text-sm font-semibold hover:bg-[#c7ff2e]/90 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:a?jsxs("span",{className:"inline-flex items-center gap-2",children:[jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]}),s("predict.setup.stepRunning")]}):L}),!h&&jsx("button",{type:"button",onClick:t,className:"w-full py-2.5 rounded-[10px] text-sm text-zinc-400 hover:text-white hover:bg-[rgba(39,39,42,0.5)] transition-colors cursor-pointer focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",children:s("common.cancel")})]})]})})})}function rf({index:e,status:t}){return t==="done"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/15 shrink-0",children:jsx("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#c7ff2e]",children:jsx("polyline",{points:"20 6 9 17 4 12"})})}):t==="running"?jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#c7ff2e]/10 shrink-0",children:jsxs("svg",{className:"animate-spin h-4 w-4 text-[#c7ff2e]",viewBox:"0 0 24 24",fill:"none",children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",className:"opacity-25"}),jsx("path",{d:"M4 12a8 8 0 018-8",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",className:"opacity-75"})]})}):jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-zinc-700/50 text-xs font-bold text-zinc-400 shrink-0",children:e})}
|
|
72
|
+
export{kf as CHART_RANGE_DURATION,bf as CHART_RANGE_PERIOD,yf as CHART_RANGE_SAMPLE_INTERVAL,sr as CandlestickPeriod,df as CategoriesSkeleton,to as CategoriesUI,oo as CategoriesWidget,Me as ChartRange,ir as DEFAULT_CHART_RANGE,Qr as DEFAULT_FILTER_STATE,It as DEFAULT_PAGE_SIZE,Pf as DEFAULT_PRICE_HISTORY_INTERVAL,Ph as EventDetailPage,Wt as EventDetailSkeleton,ws as EventDetailUI,Ns as EventDetailWidget,Uo as EventItem,ls as EventMarketDepthChartUI,ms as EventMarketDetailWidget,hs as EventPriceChart,No as EventsFilterUI,c0 as EventsPage,Rg as EventsPageSkeleton,Zr as EventsSkeleton,Lo as EventsToolbarUI,qo as EventsUI,Xo as EventsWidget,go as KycModal,zr as MAX_PRICE_HISTORY_MARKETS,nb as MatchGroupCard,ai as MatchMarketCard,ti as MatchesFilterBar,ri as MatchesHero,Xv as MatchesPage,lb as MatchesStatsBar,di as MatchesWidget,Nf as ORDER_MAX_PRICE,wf as ORDER_MIN_PRICE,Wr as ORDER_MIN_QUANTITY,Sf as ORDER_PRICE_STEP,Sn as PREDICT_SEARCH_MODAL_ID,Ot as PREDICT_TRADE_MODAL_ID,Cf as PRICE_HISTORY_SAMPLE_INTERVAL,nv as PredictSearchModal,lr as PredictTradeModal,Na as PredictWalletProvider,bt as PriceHistoryInterval,Xm as ProfilePage,To as SORT_PRESETS,$r as STATIC_CATEGORIES,pv as SearchEventsButton,_s as SearchHistoryUI,Rs as SearchHistoryWidget,Is as SearchInputUI,As as SearchResultItemUI,$s as SearchResultListWidget,Vs as SearchWidget,l1 as SetupModal,Zd as SimilarEventCard,Ps as SimilarEventsSection,vx as SourceBadge,pb as SpreadIndicator,rs as TradeFormSkeleton,So as TradeFormUI,ar as TradeFormWidget,ts as UserActivitySection,Xr as countActiveFilters,Ut as formatKMB,ot as getSourceMeta,Rh as useEventDetail,Io as useEventsInfinite,wr as usePredictSearchHistory,Kr as usePredictWallet,Ds as useSearchResultListScript,Ks as useSearchScript,fo as useTradeForm,ca as version};//# sourceMappingURL=index.mjs.map
|
|
73
73
|
//# sourceMappingURL=index.mjs.map
|