@liberfi.io/ui-predict 0.1.113 → 0.1.114
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 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- 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,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 Gr from'canvas-confetti';import {ChartRange,useInfiniteMatchMarkets,useBalance,useDFlowKYC,usePolymarketSetup,usePredictClient,PolymarketContext,useTickSize,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.113");var ma="0.1.113";var fa={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},eo=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Wr=(()=>{let e=t=>{let r=eo.indexOf(t);return r===-1?eo.length:r};return Object.entries(fa).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 no({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("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(to,{label:u,isSelected:t===null,onPress:p,showPulse:u===i}),jsx(va,{}),e.map(m=>jsx(to,{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(ro,{label:c("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>s(null)}),o.map(m=>jsx(ro,{label:m.label,icon:m.icon,isSelected:r===m.label,onPress:()=>s(m.label)},m.label))]})})]})}function to({label:e,isSelected:t,onPress:r,badge:o,showPulse:n}){return jsxs("button",{type:"button",onClick:r,className:cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b p-1 text-base font-normal capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[n?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 va(){return jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function ro({label:e,icon:t,isSelected:r,onPress:o}){return jsxs("button",{type:"button",onClick:o,className:cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-2 py-1 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-transparent bg-primary text-black":"border-border/80 text-neutral-200 hover:bg-primary/10 hover:text-primary"),children:[t&&jsx("span",{className:cn("iconify size-4",t)}),e]})}function gf({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 ba(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function ya(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function io({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=ba(Wr),p=Wr.find(m=>m.slug===o),u=ya(p);return jsx(no,{categories:c,selectedCategory:o,selectedTag:s,activeTags:u,onCategorySelect:i,onTagSelect:l,trailing:t,className:r})}function ao(e){return {title:e.title,imageUrl:e.image_url}}function lo(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 At=48,Ur=4,cr={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},Me={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},dr=Me.ALL,Nf={[Me.ONE_DAY]:cr.ONE_MINUTE,[Me.ONE_WEEK]:cr.ONE_HOUR,[Me.ONE_MONTH]:cr.ONE_HOUR,[Me.ALL]:cr.ONE_DAY},Pf={[Me.ONE_DAY]:300,[Me.ONE_WEEK]:3600,[Me.ONE_MONTH]:10800,[Me.ALL]:1440*60},Cf={[Me.ONE_DAY]:1440*60,[Me.ONE_WEEK]:10080*60,[Me.ONE_MONTH]:720*60*60,[Me.ALL]:null},Kr=1,Mf=1,Ef=1,Tf=99,bt={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Lf=bt.ONE_WEEK,_f={[bt.ONE_HOUR]:60,[bt.SIX_HOURS]:60,[bt.ONE_DAY]:300,[bt.ONE_WEEK]:1800,[bt.MAX]:1800};var po=createContext(null);function jr(){let e=useContext(po);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var Ma=1e4;function Ea({pollingInterval:e=Ma,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:N,error:E}=useBalance({source:"polymarket",user:s??""},{enabled:t&&g&&!!s,refetchInterval:e}),S=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||N,error:c??E??null}),[n,s,f,a,h,g,p,u,m,d,i,x,l,N,c,E]);return jsx(po.Provider,{value:S,children:r})}var Qa={minutes:60,hours:3600,days:86400};function Xa(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*Qa[r]}}function Yr(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};Gr({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{Gr({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{Gr({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function ho({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(k=>k.chainNamespace===ChainNamespace.SOLANA&&k.isConnected),d=s.find(k=>k.chainNamespace===ChainNamespace.EVM&&k.isConnected&&"switchChain"in k),f=n==="authenticated",g=m?.address,h=d?.address,x=useMemo(()=>{if(p!=="polymarket")return;let k=e.provider_meta?.["polymarket.clobTokenIds"];return k?(typeof k=="string"?JSON.parse(k):k)[0]:void 0},[p,e.provider_meta]),{data:N}=useTickSize(x),E=N?.minimum_tick_size?String(N.minimum_tick_size):"0.01",[S,v]=useState(t),[b,H]=useState(r),[K,me]=useState("market"),[C,X]=useState(NaN),[D,$]=useState(NaN),[z,oe]=useState(false),[fe,M]=useState(null),[L,V]=useState(null),[I,ue]=useState(false),[ie,Ne]=useState(false),[Re,gt]=useState("1h"),[Xe,er]=useState(30),[Tt,tr]=useState("minutes"),We=null,ht=false,rr=null,F;try{let k=jr();We={kalshiUsdcBalance:k.kalshiUsdcBalance,polymarketUsdcBalance:k.polymarketUsdcBalance,isLoading:k.isLoading},ht=k.kalshiKycVerified,rr=k.kalshiKycUrl,F=k.polymarketSafeAddress;}catch{}let ae=useMemo(()=>{let k=S==="yes"?0:1,j=e.outcomes[k];return b==="buy"?j?.best_ask??j?.price??.5:j?.best_bid??j?.price??.5},[e.outcomes,S,b]),xt=useCallback(k=>{me(k);},[]),Wi=useCallback(k=>{v(k),$(NaN);},[]);useEffect(()=>{K==="limit"&&isNaN(D)&&$(Math.round(ae*100)/100);},[K,D,ae]);let Ui=useMemo(()=>isNaN(C)||C<=0?0:b==="buy"?ae>0?C/ae:0:C,[b,C,ae]),nr=useMemo(()=>isNaN(C)||C<=0?"0":String(Math.round(C*1e6)),[C]),Ki=e.provider_meta?.["dflow.yesMint"]??"",Vi=e.provider_meta?.["dflow.noMint"]??"",it=SOLANA_TOKENS.stablecoins.USDC.address,ji=e.provider_meta?.["dflow.collateralMint"]||"",Wn=S==="yes"?Ki:Vi,Un=p==="kalshi"?g??"":h??"",{data:Ie,isLoading:Gi}=usePositions({source:p,user:Un},{enabled:!!Un}),Kn=useMemo(()=>!Ie||b!=="sell"?null:Ie.positions.find(k=>k.side?.toLowerCase()===S&&k.market?.slug===e.slug)??null,[Ie,e.slug,S,b])?.market?.provider_meta,Yi=b==="sell"&&Kn?.["dflow.outcomeMint"]||Wn,Lt=b==="sell"&&Kn?.["dflow.collateralMint"]||ji,_t=b==="buy"?it:Yi,Rt=b==="buy"?Wn:Lt||it,qi=p==="kalshi"&&!!_t&&!!Rt&&!!g&&nr!=="0",{refetch:Vn}=useDFlowQuote({inputMint:_t,outputMint:Rt,amount:nr,userPublicKey:g??"",slippageBps:100},{enabled:qi}),or=useMemo(()=>We?p==="kalshi"?We.kalshiUsdcBalance:We.polymarketUsdcBalance:Ie&&Ie.positions.reduce((j,Ce)=>Ce.side==="USDC"||Ce.side==="collateral"?j+(Ce.current_value??0):j,0)||null,[We,Ie,p]),Qi=We?We.isLoading:Gi,Dr=useMemo(()=>Ie?Ie.positions.find(j=>j.side?.toLowerCase()==="yes"&&j.market?.slug===e.slug)?.size??0:null,[Ie,e.slug]),Fr=useMemo(()=>Ie?Ie.positions.find(j=>j.side?.toLowerCase()==="no"&&j.market?.slug===e.slug)?.size??0:null,[Ie,e.slug]),Hr=useMemo(()=>K==="limit"&&u&&!isNaN(D)?D:ae,[K,u,D,ae]),sr=useMemo(()=>{if(isNaN(C)||C<=0)return 0;if(b==="buy")return C;let k=S==="yes"?e.outcomes[0]?.best_bid??0:e.outcomes[1]?.best_bid??0;return C*k},[b,S,C,e.outcomes]),jn=useMemo(()=>isNaN(C)||C<=0?0:b==="buy"?Hr>0?C/Hr*1:0:sr,[b,C,Hr,sr]),Xi=jn-sr,Zi=useCallback(k=>{H(k),X(NaN);},[]),Ji=useCallback(k=>{if(isNaN(k)){X(NaN);return}let j=Math.max(0,k),Ce=b==="buy"?Math.round(j*100)/100:Math.round(j);X(Ce);},[b]),ea=useCallback(k=>{if(isNaN(k)){$(NaN);return}let j=Math.max(.01,Math.min(.99,k));$(Math.round(j*100)/100);},[]),It=useCallback(()=>{X(NaN),$(NaN),me("market"),Ne(false),gt("1h"),er(30),tr("minutes");},[]),Br=useMemo(()=>{let k=[];(isNaN(C)||C<Kr)&&k.push(`Minimum quantity is ${Kr}`),e.status!=="open"&&k.push("Market is not active"),b==="buy"&&or!=null&&!isNaN(C)&&C>0&&C>or&&k.push("Insufficient USDC balance");let j=S==="yes"?Dr:Fr;return b==="sell"&&j!=null&&!isNaN(C)&&C>0&&C>j&&k.push("Insufficient shares"),K==="limit"&&u&&(isNaN(D)||D<.01||D>.99)&&k.push("Limit price must be between $0.01 and $0.99"),K==="limit"&&u&&ie&&Re==="custom"&&(isNaN(Xe)||Xe<=0)&&k.push(o("predict.trade.expiration.invalidDate")),{isValid:k.length===0,errors:k}},[C,e.status,b,or,Dr,Fr,S,K,u,D,ie,Re,Xe,o]),{mutateAsync:ir}=useDFlowSubmit(),{data:$r}=useOrder({id:fe??"",source:p},{enabled:!!fe}),Gn=useCallback(async()=>{if(!L||!g||!m)return;let{cashAmount:k,collateral:j}=L;V(null);try{let at=(await i.createDFlowQuote({inputMint:j,outputMint:it,amount:k,userPublicKey:g,slippageBps:100}))?.transaction;if(!at)return;let Ze=Uint8Array.from(atob(at),Ot=>Ot.charCodeAt(0)),Ue=await m.signTransaction(Ze);await ir({signedTransaction:btoa(String.fromCharCode(...Ue)),orderContext:{user_public_key:g,input_mint:j,output_mint:it,amount:k,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[L,g,m,i,ir,it]);useEffect(()=>{if(!$r||!fe)return;let{status:k}=$r;k==="closed"?(M(null),L?Gn().finally(()=>{oe(false),toast.success(o("predict.trade.submitSuccess")),Yr(),It();}):(oe(false),toast.success(o("predict.trade.submitSuccess")),Yr(),It())):(k==="failed"||k==="expired")&&(oe(false),M(null),V(null),toast.error(o("predict.trade.submitError")));},[$r,fe,L,Gn,It,o]);let Yn=useCallback(async()=>{if(!g||!m)return;if(!_t||!Rt){toast.error("Missing token mint addresses"),oe(false);return}if(!ht){ue(true),oe(false);return}let Ce=(await Vn()).data,at=Ce?.transaction;if(!at){toast.error(o("predict.trade.submitError")),oe(false);return}if(b==="sell"&&Lt&&Lt!==it){let Je=String(Ce?.outAmount??"");Je&&Je!=="0"&&V({cashAmount:Je,collateral:Lt});}let Ze=Uint8Array.from(atob(at),Je=>Je.charCodeAt(0)),Ue=await m.signTransaction(Ze),Ot=await ir({signedTransaction:btoa(String.fromCharCode(...Ue)),orderContext:{user_public_key:g,input_mint:_t,output_mint:Rt,amount:nr,price:String(ae),side:b==="buy"?"BUY":"SELL",outcome:S==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});M(Ot.signature);},[g,m,i,Vn,ir,_t,Rt,nr,ae,b,S,e.slug,Lt,it,o]),qn=useCallback(async()=>{if(!d||!l)return;let k=d.chain,j=k!==Chain.POLYGON;j&&await a(Chain.POLYGON);try{let Ce=await d.getEip1193Provider();if(!Ce){toast.error(o("predict.trade.submitError")),oe(!1);return}let at=!!F,Ze={address:d.address,signatureType:at?2:0,signTypedData:async(lt,ca,da,ua)=>{let vt=[];"name"in lt&&vt.push({name:"name",type:"string"}),"version"in lt&&vt.push({name:"version",type:"string"}),"chainId"in lt&&vt.push({name:"chainId",type:"uint256"}),"verifyingContract"in lt&&vt.push({name:"verifyingContract",type:"address"}),"salt"in lt&&vt.push({name:"salt",type:"bytes32"});let pa={EIP712Domain:vt,...ca};return await Ce.request({method:"eth_signTypedData_v4",params:[d.address,JSON.stringify({domain:lt,types:pa,primaryType:da,message:ua})]})}},Ue=l.credentials??await l.authenticate(Ze),Ot=S==="yes"?0:1,Je="",ar=e.provider_meta?.["polymarket.clobTokenIds"];ar&&(Je=(typeof ar=="string"?JSON.parse(ar):ar)[Ot]??"");let Qn=e.provider_meta?.["polymarket.negRisk"]??!1,zr=K==="limit"&&!isNaN(D)?D:ae,ra=K==="limit"?ie?"GTD":"GTC":"FOK",na=b==="buy"&&zr>0?C/zr:C,Xn={tokenId:Je,price:zr,size:na,side:b==="buy"?"BUY":"SELL",orderType:ra,tickSize:E,negRisk:Qn,...F&&{funderAddress:F},...K==="limit"&&ie&&{expiration:Xa(Re,Xe,Tt)}},oa=buildCtfExchangeDomain(Qn),Zn=buildOrderMessage({...Xn,signerAddress:Ze.address,signatureType:Ze.signatureType}),sa=await Ze.signTypedData(oa,CTF_ORDER_TYPES,"Order",Zn),ia=buildSignedOrder(Zn,sa,Xn.orderType),Jn=buildClobPayload(ia,Ue.apiKey),aa=JSON.stringify(Jn),la=await buildPolymarketL2Headers(Ue.address,{apiKey:Ue.apiKey,secret:Ue.secret,passphrase:Ue.passphrase,method:"POST",requestPath:"/order",body:aa});await i.createPolymarketOrder(Jn,la),c.invalidateQueries({queryKey:["predict","orders"]}),c.invalidateQueries({queryKey:["predict","positions"]}),toast.success(o("predict.trade.submitSuccess")),Yr(),It(),oe(!1);}finally{j&&k&&a(k).catch(()=>{});}},[d,l,a,S,e.provider_meta,K,D,ae,C,b,i,c,ie,Re,Xe,Tt,It,o]),ta=useCallback(async()=>{if(!(!Br.isValid||!f)){oe(true),M(null),ue(false);try{p==="kalshi"?await Yn():await qn();}catch(k){let j=k instanceof Error?k.message:void 0;toast.error(j||o("predict.trade.submitError")),oe(false);}}},[Br.isValid,f,p,Yn,qn,o]);return {outcome:S,side:b,orderType:K,quantity:C,limitPrice:D,shares:Ui,estimatedCost:sr,potentialPayout:jn,potentialProfit:Xi,usdcBalance:or,yesTokenBalance:Dr,noTokenBalance:Fr,isBalanceLoading:Qi,isSubmitting:z,validation:Br,supportsLimitOrder:u,kycRequired:I,kycUrl:rr,expirationEnabled:ie,expirationPreset:Re,customDuration:Xe,customDurationUnit:Tt,setOutcome:Wi,setSide:Zi,setOrderType:xt,setQuantity:Ji,setLimitPrice:ea,setExpirationEnabled:Ne,setExpirationPreset:gt,setCustomDuration:er,setCustomDurationUnit:tr,submit:ta}}function xo({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 cl=`https://s1.chainstream.io/chains/sol/tokens/${SOLANA_TOKENS.stablecoins.USDC.address}/image.png`,dl=["5m","1h","12h","24h","eod","custom"],ul={"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"},pl=["minutes","hours","days"],ml={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"};function No({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:N,supportsLimitOrder:E,kycRequired:S,kycUrl:v,expirationEnabled:b,expirationPreset:H,customDuration:K,customDurationUnit:me,onOutcomeChange:C,onSideChange:X,onOrderTypeChange:D,onQuantityChange:$,onLimitPriceChange:z,onExpirationEnabledChange:oe,onExpirationPresetChange:fe,onCustomDurationChange:M,onCustomDurationUnitChange:L,onSubmit:V}){let{t:I}=useTranslation(),[ue,ie]=useState(false),Ne=useDisclosure();useEffect(()=>{S&&!Ne.isOpen&&Ne.onOpen();},[S]);let Re=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]),gt=!isNaN(a)&&a>0,Xe=useMemo(()=>{if(h)return I("predict.trade.submitting");if(S)return I("predict.trade.kycRequired");if(!gt)return I("predict.trade.enterAmount");let F=I(n==="buy"?"predict.trade.buy":"predict.trade.sell"),ae=I(o==="yes"?"predict.trade.yes":"predict.trade.no"),xt=n==="buy"&&c>0?` \u2192 Win $${c.toFixed(2)}`:"";return `${F} ${ae}${xt}`},[h,S,gt,n,o,c,I]),er=useMemo(()=>o==="yes"?"primary":"secondary",[o]),Tt=()=>{$(Math.floor((m??0)/2*100)/100);},tr=()=>{$(m??0);},[We,ht]=useState(false),rr=()=>{if(S){Ne.onOpen();return}if(!x){ht(true);return}ht(false),V();};return jsxs(Fragment,{children:[jsxs("div",{className:cn("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:[E?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"&&E?jsx(StyledNumberInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",value:isNaN(i)?void 0:parseFloat((i*100).toFixed(2)),onValueChange:F=>z(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"}}):Re!=null&&jsxs("span",{className:"text-xl font-bold tabular-nums",children:[Re," \xA2"]})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(F=>{let ae=F==="yes"?d:f;return jsxs("div",{className:"flex flex-1 flex-col gap-y-1",children:[jsxs("button",{type:"button",onClick:()=>C(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 xt=n==="buy"?F==="yes"?t.yesAsk:t.noAsk:F==="yes"?t.yesBid:t.noBid;return xt!=null?jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(xt)*100).toFixed(2)),"\xA2"]}):null})()]}),n==="sell"&&o===F&&jsx("span",{className:"text-center text-xs text-foreground",children:g?"\u2013":`${ae??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:cl,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:Tt,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:tr,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=>{ht(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")})]}),We&&N.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:N.map(F=>jsx("span",{className:"text-xs text-danger",children:F},F))})]}),s==="limit"&&E&&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:b,onValueChange:oe,"aria-label":I("predict.trade.setExpiration")})]}),b&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":I("predict.trade.setExpiration"),selectedKeys:[H],onSelectionChange:F=>{let ae=Array.from(F)[0];ae&&fe(ae);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:dl.map(F=>jsx(SelectItem,{children:I(ul[F])},F))}),H==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(K)?void 0:K,onValueChange:M,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:[me],onSelectionChange:F=>{let ae=Array.from(F)[0];ae&&L(ae);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:pl.map(F=>jsx(SelectItem,{children:I(ml[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:()=>ie(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("h-3.5 w-3.5 transition-transform",ue&&"rotate-180")})]}),Re!=null&&jsxs("span",{className:"text-foreground font-medium tabular-nums",children:[Re,"% chance"]})]}),ue&&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:er,fullWidth:true,radius:"lg",size:"lg",isDisabled:!gt||h,isLoading:h,onPress:rr,children:Xe})]}),jsx(xo,{isOpen:Ne.isOpen,onClose:Ne.onClose,kycUrl:v})]})}function ur({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:N,isSubmitting:E,validation:S,supportsLimitOrder:v,kycRequired:b,kycUrl:H,expirationEnabled:K,expirationPreset:me,customDuration:C,customDurationUnit:X,setOutcome:D,setSide:$,setOrderType:z,setQuantity:oe,setLimitPrice:fe,setExpirationEnabled:M,setExpirationPreset:L,setCustomDuration:V,setCustomDurationUnit:I,submit:ue}=ho({market:t,initialSide:o,initialOutcome:n}),ie=useAuthCallback(ue),Ne=useMemo(()=>e?ao(e):void 0,[e]),Re=useMemo(()=>lo(t),[t]);return jsx(No,{event:Ne,market:Re,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:N,isSubmitting:E,isValid:S.isValid,validationErrors:S.errors,supportsLimitOrder:v,kycRequired:b,kycUrl:H,expirationEnabled:K,expirationPreset:me,customDuration:C,customDurationUnit:X,onOutcomeChange:D,onSideChange:$,onOrderTypeChange:z,onQuantityChange:oe,onLimitPriceChange:fe,onExpirationEnabledChange:M,onExpirationPresetChange:L,onCustomDurationChange:V,onCustomDurationUnitChange:I,onSubmit:ie})}var Dt="predict-trade";function pr({id:e=Dt}){return jsx(AsyncModal,{id:e,children:t=>jsx(kl,{...t})})}function kl({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(ur,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,initialSide:e.initialSide??"buy",chain:e.chain,variant:"flat"})})]})})}):null}var Zr={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function Jr(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function Co({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(Zr);},[]),c=useCallback(()=>{o(s),t();},[s,o,t]),p=useCallback((h,x)=>{a(N=>({...N,[h]:x}));},[]),u=useMemo(()=>Jr(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(Cl,{onClick:()=>i(false)})]}),jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[jsx(fr,{label:n("predict.filter.platform"),children:jsx(gr,{options:m,selected:s.source,onSelect:h=>p("source",h)})}),jsx(fr,{label:n("predict.filter.timeRemaining"),children:jsx(gr,{options:d,selected:s.timeRemaining,onSelect:h=>p("timeRemaining",h)})}),jsx(fr,{label:n("predict.filter.minVolume"),children:jsx(gr,{options:f,selected:s.minVolume,onSelect:h=>p("minVolume",h)})}),jsx(fr,{label:n("predict.filter.minLiquidity"),children:jsx(gr,{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 fr({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 Cl({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 gr({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 _o={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},Eo={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},Al=["start_time","volume","liquidity","ending_soon"],To={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"},Dl={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 Ro({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=Lo[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:To,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(Fl,{}),jsx(m,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:i(Eo[e])}),jsx(Bl,{open:l})]}),l&&jsx("div",{style:{...Dl,width:224,padding:4},children:Al.map(d=>{let f=Lo[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(Eo[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:To,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(Hl,{}),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 Lo={start_time:CalendarIcon,volume:ChartLineIcon,liquidity:DropletIcon,ending_soon:TimerIcon};function Fl(){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 Hl(){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 Bl({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 Ao(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 Do="@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 en({count:e=6}){return jsxs(Fragment,{children:[jsx("style",{children:Do}),jsx("div",{className:"evt-skel-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",width:"100%"},children:Array.from({length:e}).map((t,r)=>jsx(Wl,{index:r},r))})]})}function Wl({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 Fg({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:Do}),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(en,{count:e})})]})}var Fo=3,Xl={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)"}},Zl={border:"hsl(var(--heroui-primary) / 0.4)",shadow:"0 2px 18px hsl(var(--heroui-primary) / 0.45)"},rn={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},Wo={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},Jl={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},Ht=[{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 Ho(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 ec(e){let t=e.outcomes?.map(a=>a.label?.toLowerCase().trim()??"")??[];if(t.some(a=>a==="up")&&t.some(a=>a==="down"))return [rn,Jl];if(t.some(a=>a==="yes")&&t.some(a=>a==="no"))return [rn,Wo];let r=t[0]??"",o=t[1]??"",n=Ho(r)%Ht.length,s=Ho(o)%Ht.length;return s===n&&(s=(s+1)%Ht.length),[Ht[n],Ht[s]]}function tc(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function Uo(e){let t=tc(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function Ko(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function Bo(e){let t=e.outcomes?.[0],r=t?.best_ask??t?.price??0;return parseFloat((r*100).toFixed(2)).toString()}function $o(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 rc(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 nc=`
|
|
1
|
+
import {createContext,memo,useRef,forwardRef,useState,useImperativeHandle,useMemo,useEffect,useCallback,useContext,Fragment as Fragment$1,startTransition,Component}from'react';import {PolymarketIcon,KalshiIcon,cn,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 Gr from'canvas-confetti';import {ChartRange,useInfiniteMatchMarkets,useBalance,useDFlowKYC,usePolymarketSetup,usePredictClient,PolymarketContext,useTickSize,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.114");var ma="0.1.114";var fa={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},eo=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Wr=(()=>{let e=t=>{let r=eo.indexOf(t);return r===-1?eo.length:r};return Object.entries(fa).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 no({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("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(to,{label:u,isSelected:t===null,onPress:p,showPulse:u===i}),jsx(va,{}),e.map(m=>jsx(to,{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(ro,{label:c("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>s(null)}),o.map(m=>jsx(ro,{label:m.label,icon:m.icon,isSelected:r===m.label,onPress:()=>s(m.label)},m.label))]})})]})}function to({label:e,isSelected:t,onPress:r,badge:o,showPulse:n}){return jsxs("button",{type:"button",onClick:r,className:cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b p-1 text-base font-normal capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[n?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 va(){return jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function ro({label:e,icon:t,isSelected:r,onPress:o}){return jsxs("button",{type:"button",onClick:o,className:cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-2 py-1 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-transparent bg-primary text-black":"border-border/80 text-neutral-200 hover:bg-primary/10 hover:text-primary"),children:[t&&jsx("span",{className:cn("iconify size-4",t)}),e]})}function gf({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 ba(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function ya(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function io({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=ba(Wr),p=Wr.find(m=>m.slug===o),u=ya(p);return jsx(no,{categories:c,selectedCategory:o,selectedTag:s,activeTags:u,onCategorySelect:i,onTagSelect:l,trailing:t,className:r})}function ao(e){return {title:e.title,imageUrl:e.image_url}}function lo(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 At=48,Ur=4,cr={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},Me={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},dr=Me.ALL,Nf={[Me.ONE_DAY]:cr.ONE_MINUTE,[Me.ONE_WEEK]:cr.ONE_HOUR,[Me.ONE_MONTH]:cr.ONE_HOUR,[Me.ALL]:cr.ONE_DAY},Pf={[Me.ONE_DAY]:300,[Me.ONE_WEEK]:3600,[Me.ONE_MONTH]:10800,[Me.ALL]:1440*60},Cf={[Me.ONE_DAY]:1440*60,[Me.ONE_WEEK]:10080*60,[Me.ONE_MONTH]:720*60*60,[Me.ALL]:null},Kr=1,Mf=1,Ef=1,Tf=99,bt={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Lf=bt.ONE_WEEK,_f={[bt.ONE_HOUR]:60,[bt.SIX_HOURS]:60,[bt.ONE_DAY]:300,[bt.ONE_WEEK]:1800,[bt.MAX]:1800};var po=createContext(null);function jr(){let e=useContext(po);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var Ma=1e4;function Ea({pollingInterval:e=Ma,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:N,error:E}=useBalance({source:"polymarket",user:s??""},{enabled:t&&g&&!!s,refetchInterval:e}),S=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||N,error:c??E??null}),[n,s,f,a,h,g,p,u,m,d,i,x,l,N,c,E]);return jsx(po.Provider,{value:S,children:r})}var Qa={minutes:60,hours:3600,days:86400};function Xa(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*Qa[r]}}function Yr(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};Gr({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{Gr({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{Gr({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function ho({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(k=>k.chainNamespace===ChainNamespace.SOLANA&&k.isConnected),d=s.find(k=>k.chainNamespace===ChainNamespace.EVM&&k.isConnected&&"switchChain"in k),f=n==="authenticated",g=m?.address,h=d?.address,x=useMemo(()=>{if(p!=="polymarket")return;let k=e.provider_meta?.["polymarket.clobTokenIds"];return k?(typeof k=="string"?JSON.parse(k):k)[0]:void 0},[p,e.provider_meta]),{data:N}=useTickSize(x),E=N?.minimum_tick_size?String(N.minimum_tick_size):"0.01",[S,v]=useState(t),[b,H]=useState(r),[K,me]=useState("market"),[C,X]=useState(NaN),[D,$]=useState(NaN),[z,oe]=useState(false),[fe,M]=useState(null),[L,V]=useState(null),[I,ue]=useState(false),[ie,Ne]=useState(false),[Re,gt]=useState("1h"),[Xe,er]=useState(30),[Tt,tr]=useState("minutes"),We=null,ht=false,rr=null,F;try{let k=jr();We={kalshiUsdcBalance:k.kalshiUsdcBalance,polymarketUsdcBalance:k.polymarketUsdcBalance,isLoading:k.isLoading},ht=k.kalshiKycVerified,rr=k.kalshiKycUrl,F=k.polymarketSafeAddress;}catch{}let ae=useMemo(()=>{let k=S==="yes"?0:1,j=e.outcomes[k];return b==="buy"?j?.best_ask??j?.price??.5:j?.best_bid??j?.price??.5},[e.outcomes,S,b]),xt=useCallback(k=>{me(k);},[]),Wi=useCallback(k=>{v(k),$(NaN);},[]);useEffect(()=>{K==="limit"&&isNaN(D)&&$(Math.round(ae*100)/100);},[K,D,ae]);let Ui=useMemo(()=>isNaN(C)||C<=0?0:b==="buy"?ae>0?C/ae:0:C,[b,C,ae]),nr=useMemo(()=>isNaN(C)||C<=0?"0":String(Math.round(C*1e6)),[C]),Ki=e.provider_meta?.["dflow.yesMint"]??"",Vi=e.provider_meta?.["dflow.noMint"]??"",it=SOLANA_TOKENS.stablecoins.USDC.address,ji=e.provider_meta?.["dflow.collateralMint"]||"",Wn=S==="yes"?Ki:Vi,Un=p==="kalshi"?g??"":h??"",{data:Ie,isLoading:Gi}=usePositions({source:p,user:Un},{enabled:!!Un}),Kn=useMemo(()=>!Ie||b!=="sell"?null:Ie.positions.find(k=>k.side?.toLowerCase()===S&&k.market?.slug===e.slug)??null,[Ie,e.slug,S,b])?.market?.provider_meta,Yi=b==="sell"&&Kn?.["dflow.outcomeMint"]||Wn,Lt=b==="sell"&&Kn?.["dflow.collateralMint"]||ji,_t=b==="buy"?it:Yi,Rt=b==="buy"?Wn:Lt||it,qi=p==="kalshi"&&!!_t&&!!Rt&&!!g&&nr!=="0",{refetch:Vn}=useDFlowQuote({inputMint:_t,outputMint:Rt,amount:nr,userPublicKey:g??"",slippageBps:100},{enabled:qi}),or=useMemo(()=>We?p==="kalshi"?We.kalshiUsdcBalance:We.polymarketUsdcBalance:Ie&&Ie.positions.reduce((j,Ce)=>Ce.side==="USDC"||Ce.side==="collateral"?j+(Ce.current_value??0):j,0)||null,[We,Ie,p]),Qi=We?We.isLoading:Gi,Dr=useMemo(()=>Ie?Ie.positions.find(j=>j.side?.toLowerCase()==="yes"&&j.market?.slug===e.slug)?.size??0:null,[Ie,e.slug]),Fr=useMemo(()=>Ie?Ie.positions.find(j=>j.side?.toLowerCase()==="no"&&j.market?.slug===e.slug)?.size??0:null,[Ie,e.slug]),Hr=useMemo(()=>K==="limit"&&u&&!isNaN(D)?D:ae,[K,u,D,ae]),sr=useMemo(()=>{if(isNaN(C)||C<=0)return 0;if(b==="buy")return C;let k=S==="yes"?e.outcomes[0]?.best_bid??0:e.outcomes[1]?.best_bid??0;return C*k},[b,S,C,e.outcomes]),jn=useMemo(()=>isNaN(C)||C<=0?0:b==="buy"?Hr>0?C/Hr*1:0:sr,[b,C,Hr,sr]),Xi=jn-sr,Zi=useCallback(k=>{H(k),X(NaN);},[]),Ji=useCallback(k=>{if(isNaN(k)){X(NaN);return}let j=Math.max(0,k),Ce=b==="buy"?Math.round(j*100)/100:Math.round(j);X(Ce);},[b]),ea=useCallback(k=>{if(isNaN(k)){$(NaN);return}let j=Math.max(.01,Math.min(.99,k));$(Math.round(j*100)/100);},[]),It=useCallback(()=>{X(NaN),$(NaN),me("market"),Ne(false),gt("1h"),er(30),tr("minutes");},[]),Br=useMemo(()=>{let k=[];(isNaN(C)||C<Kr)&&k.push(`Minimum quantity is ${Kr}`),e.status!=="open"&&k.push("Market is not active"),b==="buy"&&or!=null&&!isNaN(C)&&C>0&&C>or&&k.push("Insufficient USDC balance");let j=S==="yes"?Dr:Fr;return b==="sell"&&j!=null&&!isNaN(C)&&C>0&&C>j&&k.push("Insufficient shares"),K==="limit"&&u&&(isNaN(D)||D<.01||D>.99)&&k.push("Limit price must be between $0.01 and $0.99"),K==="limit"&&u&&ie&&Re==="custom"&&(isNaN(Xe)||Xe<=0)&&k.push(o("predict.trade.expiration.invalidDate")),{isValid:k.length===0,errors:k}},[C,e.status,b,or,Dr,Fr,S,K,u,D,ie,Re,Xe,o]),{mutateAsync:ir}=useDFlowSubmit(),{data:$r}=useOrder({id:fe??"",source:p},{enabled:!!fe}),Gn=useCallback(async()=>{if(!L||!g||!m)return;let{cashAmount:k,collateral:j}=L;V(null);try{let at=(await i.createDFlowQuote({inputMint:j,outputMint:it,amount:k,userPublicKey:g,slippageBps:100}))?.transaction;if(!at)return;let Ze=Uint8Array.from(atob(at),Ot=>Ot.charCodeAt(0)),Ue=await m.signTransaction(Ze);await ir({signedTransaction:btoa(String.fromCharCode(...Ue)),orderContext:{user_public_key:g,input_mint:j,output_mint:it,amount:k,price:"1",side:"SELL",outcome:"",market_slug:"",slippage_bps:100}});}catch{}},[L,g,m,i,ir,it]);useEffect(()=>{if(!$r||!fe)return;let{status:k}=$r;k==="closed"?(M(null),L?Gn().finally(()=>{oe(false),toast.success(o("predict.trade.submitSuccess")),Yr(),It();}):(oe(false),toast.success(o("predict.trade.submitSuccess")),Yr(),It())):(k==="failed"||k==="expired")&&(oe(false),M(null),V(null),toast.error(o("predict.trade.submitError")));},[$r,fe,L,Gn,It,o]);let Yn=useCallback(async()=>{if(!g||!m)return;if(!_t||!Rt){toast.error("Missing token mint addresses"),oe(false);return}if(!ht){ue(true),oe(false);return}let Ce=(await Vn()).data,at=Ce?.transaction;if(!at){toast.error(o("predict.trade.submitError")),oe(false);return}if(b==="sell"&&Lt&&Lt!==it){let Je=String(Ce?.outAmount??"");Je&&Je!=="0"&&V({cashAmount:Je,collateral:Lt});}let Ze=Uint8Array.from(atob(at),Je=>Je.charCodeAt(0)),Ue=await m.signTransaction(Ze),Ot=await ir({signedTransaction:btoa(String.fromCharCode(...Ue)),orderContext:{user_public_key:g,input_mint:_t,output_mint:Rt,amount:nr,price:String(ae),side:b==="buy"?"BUY":"SELL",outcome:S==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});M(Ot.signature);},[g,m,i,Vn,ir,_t,Rt,nr,ae,b,S,e.slug,Lt,it,o]),qn=useCallback(async()=>{if(!d||!l)return;let k=d.chain,j=k!==Chain.POLYGON;j&&await a(Chain.POLYGON);try{let Ce=await d.getEip1193Provider();if(!Ce){toast.error(o("predict.trade.submitError")),oe(!1);return}let at=!!F,Ze={address:d.address,signatureType:at?2:0,signTypedData:async(lt,ca,da,ua)=>{let vt=[];"name"in lt&&vt.push({name:"name",type:"string"}),"version"in lt&&vt.push({name:"version",type:"string"}),"chainId"in lt&&vt.push({name:"chainId",type:"uint256"}),"verifyingContract"in lt&&vt.push({name:"verifyingContract",type:"address"}),"salt"in lt&&vt.push({name:"salt",type:"bytes32"});let pa={EIP712Domain:vt,...ca};return await Ce.request({method:"eth_signTypedData_v4",params:[d.address,JSON.stringify({domain:lt,types:pa,primaryType:da,message:ua})]})}},Ue=l.credentials??await l.authenticate(Ze),Ot=S==="yes"?0:1,Je="",ar=e.provider_meta?.["polymarket.clobTokenIds"];ar&&(Je=(typeof ar=="string"?JSON.parse(ar):ar)[Ot]??"");let Qn=e.provider_meta?.["polymarket.negRisk"]??!1,zr=K==="limit"&&!isNaN(D)?D:ae,ra=K==="limit"?ie?"GTD":"GTC":"FOK",na=b==="buy"&&zr>0?C/zr:C,Xn={tokenId:Je,price:zr,size:na,side:b==="buy"?"BUY":"SELL",orderType:ra,tickSize:E,negRisk:Qn,...F&&{funderAddress:F},...K==="limit"&&ie&&{expiration:Xa(Re,Xe,Tt)}},oa=buildCtfExchangeDomain(Qn),Zn=buildOrderMessage({...Xn,signerAddress:Ze.address,signatureType:Ze.signatureType}),sa=await Ze.signTypedData(oa,CTF_ORDER_TYPES,"Order",Zn),ia=buildSignedOrder(Zn,sa,Xn.orderType),Jn=buildClobPayload(ia,Ue.apiKey),aa=JSON.stringify(Jn),la=await buildPolymarketL2Headers(Ue.address,{apiKey:Ue.apiKey,secret:Ue.secret,passphrase:Ue.passphrase,method:"POST",requestPath:"/order",body:aa});await i.createPolymarketOrder(Jn,la),c.invalidateQueries({queryKey:["predict","orders"]}),c.invalidateQueries({queryKey:["predict","positions"]}),toast.success(o("predict.trade.submitSuccess")),Yr(),It(),oe(!1);}finally{j&&k&&a(k).catch(()=>{});}},[d,l,a,S,e.provider_meta,K,D,ae,C,b,i,c,ie,Re,Xe,Tt,It,o]),ta=useCallback(async()=>{if(!(!Br.isValid||!f)){oe(true),M(null),ue(false);try{p==="kalshi"?await Yn():await qn();}catch(k){let j=k instanceof Error?k.message:void 0;toast.error(j||o("predict.trade.submitError")),oe(false);}}},[Br.isValid,f,p,Yn,qn,o]);return {outcome:S,side:b,orderType:K,quantity:C,limitPrice:D,shares:Ui,estimatedCost:sr,potentialPayout:jn,potentialProfit:Xi,usdcBalance:or,yesTokenBalance:Dr,noTokenBalance:Fr,isBalanceLoading:Qi,isSubmitting:z,validation:Br,supportsLimitOrder:u,kycRequired:I,kycUrl:rr,expirationEnabled:ie,expirationPreset:Re,customDuration:Xe,customDurationUnit:Tt,setOutcome:Wi,setSide:Zi,setOrderType:xt,setQuantity:Ji,setLimitPrice:ea,setExpirationEnabled:Ne,setExpirationPreset:gt,setCustomDuration:er,setCustomDurationUnit:tr,submit:ta}}function xo({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 cl=`https://s1.chainstream.io/chains/sol/tokens/${SOLANA_TOKENS.stablecoins.USDC.address}/image.png`,dl=["5m","1h","12h","24h","eod","custom"],ul={"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"},pl=["minutes","hours","days"],ml={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"};function No({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:N,supportsLimitOrder:E,kycRequired:S,kycUrl:v,expirationEnabled:b,expirationPreset:H,customDuration:K,customDurationUnit:me,onOutcomeChange:C,onSideChange:X,onOrderTypeChange:D,onQuantityChange:$,onLimitPriceChange:z,onExpirationEnabledChange:oe,onExpirationPresetChange:fe,onCustomDurationChange:M,onCustomDurationUnitChange:L,onSubmit:V}){let{t:I}=useTranslation(),[ue,ie]=useState(false),Ne=useDisclosure();useEffect(()=>{S&&!Ne.isOpen&&Ne.onOpen();},[S]);let Re=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]),gt=!isNaN(a)&&a>0,Xe=useMemo(()=>{if(h)return I("predict.trade.submitting");if(S)return I("predict.trade.kycRequired");if(!gt)return I("predict.trade.enterAmount");let F=I(n==="buy"?"predict.trade.buy":"predict.trade.sell"),ae=I(o==="yes"?"predict.trade.yes":"predict.trade.no"),xt=n==="buy"&&c>0?` \u2192 Win $${c.toFixed(2)}`:"";return `${F} ${ae}${xt}`},[h,S,gt,n,o,c,I]),er=useMemo(()=>o==="yes"?"primary":"secondary",[o]),Tt=()=>{$(Math.floor((m??0)/2*100)/100);},tr=()=>{$(m??0);},[We,ht]=useState(false),rr=()=>{if(S){Ne.onOpen();return}if(!x){ht(true);return}ht(false),V();};return jsxs(Fragment,{children:[jsxs("div",{className:cn("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:[E?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"&&E?jsx(StyledNumberInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",value:isNaN(i)?void 0:parseFloat((i*100).toFixed(2)),onValueChange:F=>z(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"}}):Re!=null&&jsxs("span",{className:"text-xl font-bold tabular-nums",children:[Re," \xA2"]})]}),jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(F=>{let ae=F==="yes"?d:f;return jsxs("div",{className:"flex flex-1 flex-col gap-y-1",children:[jsxs("button",{type:"button",onClick:()=>C(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 xt=n==="buy"?F==="yes"?t.yesAsk:t.noAsk:F==="yes"?t.yesBid:t.noBid;return xt!=null?jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(xt)*100).toFixed(2)),"\xA2"]}):null})()]}),n==="sell"&&o===F&&jsx("span",{className:"text-center text-xs text-foreground",children:g?"\u2013":`${ae??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:cl,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:Tt,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:tr,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=>{ht(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")})]}),We&&N.length>0&&jsx("div",{className:"flex flex-col gap-y-0.5",children:N.map(F=>jsx("span",{className:"text-xs text-danger",children:F},F))})]}),s==="limit"&&E&&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:b,onValueChange:oe,"aria-label":I("predict.trade.setExpiration")})]}),b&&jsxs(Fragment,{children:[jsx(Select,{"aria-label":I("predict.trade.setExpiration"),selectedKeys:[H],onSelectionChange:F=>{let ae=Array.from(F)[0];ae&&fe(ae);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:dl.map(F=>jsx(SelectItem,{children:I(ul[F])},F))}),H==="custom"&&jsxs("div",{className:"flex gap-x-2",children:[jsx(StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(K)?void 0:K,onValueChange:M,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:[me],onSelectionChange:F=>{let ae=Array.from(F)[0];ae&&L(ae);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:pl.map(F=>jsx(SelectItem,{children:I(ml[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:()=>ie(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("h-3.5 w-3.5 transition-transform",ue&&"rotate-180")})]}),Re!=null&&jsxs("span",{className:"text-foreground font-medium tabular-nums",children:[Re,"% chance"]})]}),ue&&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:er,fullWidth:true,radius:"lg",size:"lg",isDisabled:!gt||h,isLoading:h,onPress:rr,children:Xe})]}),jsx(xo,{isOpen:Ne.isOpen,onClose:Ne.onClose,kycUrl:v})]})}function ur({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:N,isSubmitting:E,validation:S,supportsLimitOrder:v,kycRequired:b,kycUrl:H,expirationEnabled:K,expirationPreset:me,customDuration:C,customDurationUnit:X,setOutcome:D,setSide:$,setOrderType:z,setQuantity:oe,setLimitPrice:fe,setExpirationEnabled:M,setExpirationPreset:L,setCustomDuration:V,setCustomDurationUnit:I,submit:ue}=ho({market:t,initialSide:o,initialOutcome:n}),ie=useAuthCallback(ue),Ne=useMemo(()=>e?ao(e):void 0,[e]),Re=useMemo(()=>lo(t),[t]);return jsx(No,{event:Ne,market:Re,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:N,isSubmitting:E,isValid:S.isValid,validationErrors:S.errors,supportsLimitOrder:v,kycRequired:b,kycUrl:H,expirationEnabled:K,expirationPreset:me,customDuration:C,customDurationUnit:X,onOutcomeChange:D,onSideChange:$,onOrderTypeChange:z,onQuantityChange:oe,onLimitPriceChange:fe,onExpirationEnabledChange:M,onExpirationPresetChange:L,onCustomDurationChange:V,onCustomDurationUnitChange:I,onSubmit:ie})}var Dt="predict-trade";function pr({id:e=Dt}){return jsx(AsyncModal,{id:e,children:t=>jsx(kl,{...t})})}function kl({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(ur,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,initialSide:e.initialSide??"buy",chain:e.chain,variant:"flat"})})]})})}):null}var Zr={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function Jr(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function Co({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(Zr);},[]),c=useCallback(()=>{o(s),t();},[s,o,t]),p=useCallback((h,x)=>{a(N=>({...N,[h]:x}));},[]),u=useMemo(()=>Jr(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(Cl,{onClick:()=>i(false)})]}),jsxs("div",{style:{padding:"0 20px 16px",display:"flex",flexDirection:"column",gap:20},children:[jsx(fr,{label:n("predict.filter.platform"),children:jsx(gr,{options:m,selected:s.source,onSelect:h=>p("source",h)})}),jsx(fr,{label:n("predict.filter.timeRemaining"),children:jsx(gr,{options:d,selected:s.timeRemaining,onSelect:h=>p("timeRemaining",h)})}),jsx(fr,{label:n("predict.filter.minVolume"),children:jsx(gr,{options:f,selected:s.minVolume,onSelect:h=>p("minVolume",h)})}),jsx(fr,{label:n("predict.filter.minLiquidity"),children:jsx(gr,{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 fr({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 Cl({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 gr({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 _o={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},Eo={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},Al=["start_time","volume","liquidity","ending_soon"],To={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"},Dl={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 Ro({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=Lo[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:To,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(Fl,{}),jsx(m,{className:"size-4 shrink-0",style:{color:"#a1a1aa"}}),jsx("span",{className:"hidden sm:block",style:{color:"#d4d4d8"},children:i(Eo[e])}),jsx(Bl,{open:l})]}),l&&jsx("div",{style:{...Dl,width:224,padding:4},children:Al.map(d=>{let f=Lo[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(Eo[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:To,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(Hl,{}),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 Lo={start_time:CalendarIcon,volume:ChartLineIcon,liquidity:DropletIcon,ending_soon:TimerIcon};function Fl(){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 Hl(){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 Bl({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 Ao(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 Do="@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 en({count:e=6}){return jsxs(Fragment,{children:[jsx("style",{children:Do}),jsx("div",{className:"evt-skel-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",width:"100%"},children:Array.from({length:e}).map((t,r)=>jsx(Wl,{index:r},r))})]})}function Wl({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 Fg({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:Do}),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(en,{count:e})})]})}var Fo=3,Xl={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)"}},Zl={border:"hsl(var(--heroui-primary) / 0.4)",shadow:"0 2px 18px hsl(var(--heroui-primary) / 0.45)"},rn={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},Wo={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},Jl={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},Ht=[{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 Ho(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 ec(e){let t=e.outcomes?.map(a=>a.label?.toLowerCase().trim()??"")??[];if(t.some(a=>a==="up")&&t.some(a=>a==="down"))return [rn,Jl];if(t.some(a=>a==="yes")&&t.some(a=>a==="no"))return [rn,Wo];let r=t[0]??"",o=t[1]??"",n=Ho(r)%Ht.length,s=Ho(o)%Ht.length;return s===n&&(s=(s+1)%Ht.length),[Ht[n],Ht[s]]}function tc(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function Uo(e){let t=tc(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function Ko(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function Bo(e){let t=e.outcomes?.[0],r=t?.best_ask??t?.price??0;return parseFloat((r*100).toFixed(2)).toString()}function $o(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 rc(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 nc=`
|
|
2
2
|
.badge-shine { position: relative; overflow: hidden; }
|
|
3
3
|
.badge-shine::after {
|
|
4
4
|
content: "";
|