@liberfi.io/ui-predict 0.1.88 → 0.1.89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var react=require('react'),ui=require('@liberfi.io/ui'),uiScaffold=require('@liberfi.io/ui-scaffold'),i18n=require('@liberfi.io/i18n'),jsxRuntime=require('react/jsx-runtime'),walletConnector=require('@liberfi.io/wallet-connector'),reactQuery=require('@tanstack/react-query'),zt=require('canvas-confetti'),reactPredict=require('@liberfi.io/react-predict'),types=require('@liberfi.io/types'),utils=require('@liberfi.io/utils'),reactWindow=require('react-window'),reactWindowInfiniteLoader=require('react-window-infinite-loader'),hooks=require('@liberfi.io/hooks'),recharts=require('recharts'),jotai=require('jotai'),utils$1=require('jotai/utils');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var zt__default=/*#__PURE__*/_interopDefault(zt);typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-predict"]="0.1.88");var zo="0.1.88";var Ko={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},Mr=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Bt=(()=>{let e=t=>{let n=Mr.indexOf(t);return n===-1?Mr.length:n};return Object.entries(Ko).map(([t,n])=>({slug:t,label:t,tags:(n??[]).map(o=>({slug:o,label:o}))})).sort((t,n)=>e(t.slug)-e(n.slug))})();function Or({categories:e,selectedCategory:t,selectedTag:n,activeTags:o,onCategorySelect:r,onTagSelect:i,trailing:s,pulsingTab:l="Trending",className:a}){let{t:c}=i18n.useTranslation(),d=react.useCallback(()=>{r(null);},[r]),u=c("predict.categories.trending");return jsxRuntime.jsxs("div",{className:ui.cn("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-1 lg:px-2 lg:py-1",a),children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center gap-2",children:[jsxRuntime.jsx("div",{className:"hideScrollbar min-w-0 flex-1 overflow-x-auto overflow-y-hidden",children:jsxRuntime.jsxs("div",{className:"flex min-h-8 items-stretch gap-x-2 lg:min-h-9",children:[jsxRuntime.jsx(Rr,{label:u,isSelected:t===null,onPress:d,showPulse:u===l}),jsxRuntime.jsx(jo,{}),e.map(m=>jsxRuntime.jsx(Rr,{label:m.category,isSelected:t===m.category,onPress:()=>r(m.category),badge:m.badge,showPulse:m.category===l},m.category))]})}),s&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:s})]}),t&&o.length>0&&jsxRuntime.jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxRuntime.jsxs("div",{className:"flex gap-x-1 pl-2 lg:w-full lg:gap-x-2",children:[jsxRuntime.jsx(Lr,{label:c("predict.categories.allMarkets"),isSelected:n===null,onPress:()=>i(null)}),o.map(m=>jsxRuntime.jsx(Lr,{label:m.label,icon:m.icon,isSelected:n===m.label,onPress:()=>i(m.label)},m.label))]})})]})}function Rr({label:e,isSelected:t,onPress:n,badge:o,showPulse:r}){return jsxRuntime.jsxs("button",{type:"button",onClick:n,className:ui.cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b p-1 text-base font-normal capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[r?jsxRuntime.jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsxRuntime.jsx("span",{children:e})]}):e,o&&jsxRuntime.jsx("span",{className:"absolute -right-1 top-0 rounded bg-primary px-0.5 py-px text-[0.625rem] font-semibold leading-none text-neutral-950",children:o})]})}function jo(){return jsxRuntime.jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function Lr({label:e,icon:t,isSelected:n,onPress:o}){return jsxRuntime.jsxs("button",{type:"button",onClick:o,className:ui.cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-2 py-1 text-sm font-medium uppercase transition-colors cursor-pointer",n?"border-transparent bg-primary text-black":"border-border/80 text-neutral-200 hover:bg-primary/10 hover:text-primary"),children:[t&&jsxRuntime.jsx("span",{className:ui.cn("iconify size-4",t)}),e]})}function Bc({count:e=6}){return jsxRuntime.jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-1 lg:px-2 lg:py-1",children:jsxRuntime.jsx("div",{className:"flex min-h-8 items-center gap-x-2 lg:min-h-9",children:Array.from({length:e}).map((t,n)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 shrink-0 rounded"},n))})})}function Go(e){return e.map(t=>({category:t.label,tags:t.tags.map(n=>n.label)}))}function Xo(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function Ar({onSelect:e,trailing:t,className:n}){let[o,r]=react.useState(null),[i,s]=react.useState(null),l=react.useCallback(m=>{r(m),s(null),e?.({categorySlug:m,tagSlug:null});},[e]),a=react.useCallback(m=>{s(m),e?.({categorySlug:o,tagSlug:m});},[o,e]),c=Go(Bt),d=Bt.find(m=>m.slug===o),u=Xo(d);return jsxRuntime.jsx(Or,{categories:c,selectedCategory:o,selectedTag:i,activeTags:u,onCategorySelect:l,onTagSelect:a,trailing:t,className:n})}function Dr(e){return {title:e.title,imageUrl:e.image_url}}function Fr(e){let t=e.outcomes[0],n=e.outcomes[1];return {question:e.question,yesAsk:t?.best_ask??t?.price,noAsk:n?.best_ask??n?.price,yesBid:t?.best_bid,noBid:n?.best_bid,yesSubTitle:t?.label??"Yes",noSubTitle:n?.label??"No"}}var Ye=48,Ht=4,ut={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},ne={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},pt=ne.ALL,qc={[ne.ONE_DAY]:ut.ONE_MINUTE,[ne.ONE_WEEK]:ut.ONE_HOUR,[ne.ONE_MONTH]:ut.ONE_HOUR,[ne.ALL]:ut.ONE_DAY},jc={[ne.ONE_DAY]:300,[ne.ONE_WEEK]:3600,[ne.ONE_MONTH]:10800,[ne.ALL]:1440*60},Gc={[ne.ONE_DAY]:1440*60,[ne.ONE_WEEK]:10080*60,[ne.ONE_MONTH]:720*60*60,[ne.ALL]:null},Ut=1,Xc=1,Qc=1,Jc=99,_e={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Zc=_e.ONE_WEEK,ed={[_e.ONE_HOUR]:60,[_e.SIX_HOURS]:60,[_e.ONE_DAY]:300,[_e.ONE_WEEK]:1800,[_e.MAX]:1800};var Ur=react.createContext(null);function Wt(){let e=react.useContext(Ur);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var ts=3e4;function rs({pollingInterval:e=ts,enabled:t=true,children:n}){let o=walletConnector.useWallets(),r=react.useMemo(()=>o.find(f=>f.chainNamespace===types.ChainNamespace.SOLANA&&f.isConnected)?.address,[o]),i=react.useMemo(()=>o.find(f=>f.chainNamespace===types.ChainNamespace.EVM&&f.isConnected)?.address,[o]),{data:s,isLoading:l,error:a}=reactPredict.useBalance({source:"dflow",user:r??""},{enabled:t&&!!r,refetchInterval:e}),{data:c,isLoading:d,error:u}=reactPredict.useBalance({source:"polymarket",user:i??""},{enabled:t&&!!i,refetchInterval:e}),m=react.useMemo(()=>({solanaAddress:r,evmAddress:i,dflowUsdcBalance:s?Number(s.balance):0,polymarketUsdcBalance:c?Number(c.balance):0,isLoading:l||d,error:a??u??null}),[r,i,s,c,l,d,a,u]);return jsxRuntime.jsx(Ur.Provider,{value:m,children:n})}function Kr(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};zt__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{zt__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{zt__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function Vr({market:e,initialOutcome:t="yes",initialSide:n="buy"}){let{t:o}=i18n.useTranslation(),{status:r}=walletConnector.useAuth(),i=walletConnector.useWallets(),s=walletConnector.useSwitchChain(),l=reactPredict.usePredictClient(),a=react.useContext(reactPredict.PolymarketContext),c=reactQuery.useQueryClient(),d=e.source,u=d==="polymarket",m=i.find(w=>w.chainNamespace===types.ChainNamespace.SOLANA&&w.isConnected),f=i.find(w=>w.chainNamespace===types.ChainNamespace.EVM&&w.isConnected&&"switchChain"in w),p=r==="authenticated",g=m?.address,v=f?.address,[h,U]=react.useState(t),[P,C]=react.useState(n),[R,j]=react.useState("market"),[M,le]=react.useState(NaN),[W,pe]=react.useState(NaN),[Se,N]=react.useState(false),[re,se]=react.useState(null),[Q,ae]=react.useState(false),[y,T]=react.useState(null),I=null;try{let w=Wt();I={dflowUsdcBalance:w.dflowUsdcBalance,polymarketUsdcBalance:w.polymarketUsdcBalance,isLoading:w.isLoading};}catch{}let D=react.useMemo(()=>{let w=h==="yes"?0:1,B=e.outcomes[w];return P==="buy"?B?.best_ask??B?.price??.5:B?.best_bid??B?.price??.5},[e.outcomes,h,P]),G=react.useCallback(w=>{j(w);},[]),J=react.useCallback(w=>{U(w),pe(NaN);},[]);react.useEffect(()=>{R==="limit"&&isNaN(W)&&pe(Math.round(D*100)/100);},[R,W,D]);let ve=react.useMemo(()=>isNaN(M)||M<=0?0:P==="buy"?D>0?M/D:0:M,[P,M,D]),Oe=react.useMemo(()=>isNaN(M)||M<=0?"0":String(Math.round(M*1e6)),[M]),_=e.provider_meta?.["dflow.yesMint"]??"",Ie=e.provider_meta?.["dflow.noMint"]??"",Ee=e.provider_meta?.["dflow.collateralMint"]||utils.SOLANA_TOKENS.stablecoins.USDC.address,yr=h==="yes"?_:Ie,Ke=P==="buy"?Ee:yr,Ve=P==="buy"?yr:Ee,Eo=d==="dflow"&&!!Ke&&!!Ve&&!!g&&Oe!=="0",{refetch:wr}=reactPredict.useDFlowQuote({inputMint:Ke,outputMint:Ve,amount:Oe,userPublicKey:g??"",slippageBps:100},{enabled:Eo}),Sr=d==="dflow"?g??"":v??"",{data:xe,isLoading:Co}=reactPredict.usePositions({source:d,user:Sr},{enabled:!!Sr}),it=react.useMemo(()=>I?d==="dflow"?I.dflowUsdcBalance:I.polymarketUsdcBalance:xe&&xe.positions.reduce((B,he)=>he.side==="USDC"||he.side==="collateral"?B+(he.current_value??0):B,0)||null,[I,xe,d]),To=I?I.isLoading:Co,Lt=react.useMemo(()=>xe?xe.positions.find(B=>B.side?.toLowerCase()==="yes"&&B.market?.slug===e.slug)?.size??0:null,[xe,e.slug]),Ot=react.useMemo(()=>xe?xe.positions.find(B=>B.side?.toLowerCase()==="no"&&B.market?.slug===e.slug)?.size??0:null,[xe,e.slug]),It=react.useMemo(()=>R==="limit"&&u&&!isNaN(W)?W:D,[R,u,W,D]),lt=react.useMemo(()=>{if(isNaN(M)||M<=0)return 0;if(P==="buy")return M;let w=h==="yes"?e.outcomes[0]?.best_bid??0:e.outcomes[1]?.best_bid??0;return M*w},[P,h,M,e.outcomes]),Nr=react.useMemo(()=>isNaN(M)||M<=0?0:P==="buy"?It>0?M/It*1:0:lt,[P,M,It,lt]),Mo=Nr-lt,Ro=react.useCallback(w=>{C(w),le(NaN);},[]),Lo=react.useCallback(w=>{if(isNaN(w)){le(NaN);return}let B=Math.max(0,w),he=P==="buy"?Math.round(B*100)/100:Math.round(B);le(he);},[P]),Oo=react.useCallback(w=>{if(isNaN(w)){pe(NaN);return}let B=Math.max(.01,Math.min(.99,w));pe(Math.round(B*100)/100);},[]),_t=react.useMemo(()=>{let w=[];(isNaN(M)||M<Ut)&&w.push(`Minimum quantity is ${Ut}`),e.status!=="open"&&w.push("Market is not active"),P==="buy"&&it!=null&&!isNaN(M)&&M>0&&M>it&&w.push("Insufficient USDC balance");let B=h==="yes"?Lt:Ot;return P==="sell"&&B!=null&&!isNaN(M)&&M>0&&M>B&&w.push("Insufficient shares"),R==="limit"&&u&&(isNaN(W)||W<.01||W>.99)&&w.push("Limit price must be between $0.01 and $0.99"),{isValid:w.length===0,errors:w}},[M,e.status,P,it,Lt,Ot,h,R,u,W]),{mutateAsync:kr}=reactPredict.useDFlowSubmit(),{data:At}=reactPredict.useOrder({id:re??"",source:d},{enabled:!!re});react.useEffect(()=>{if(!At||!re)return;let{status:w}=At;w==="closed"?(N(false),se(null),ui.toast.success(o("predict.trade.submitSuccess")),Kr(),le(NaN)):(w==="failed"||w==="expired")&&(N(false),se(null),ui.toast.error(o("predict.trade.submitError")));},[At,re,o]);let Pr=react.useCallback(async()=>{if(!g||!m)return;if(!Ke||!Ve){ui.toast.error("Missing token mint addresses"),N(false);return}let w=await l.checkDFlowKYC(g);if(!w.verified){ae(true),T(w.kyc_url||null),N(false);return}let be=(await wr()).data?.transaction;if(!be){ui.toast.error(o("predict.trade.submitError")),N(false);return}let ye=Uint8Array.from(atob(be),ct=>ct.charCodeAt(0)),Dt=await m.signTransaction(ye),Ft=await kr({signedTransaction:btoa(String.fromCharCode(...Dt)),orderContext:{user_public_key:g,input_mint:Ke,output_mint:Ve,amount:Oe,price:String(D),side:P==="buy"?"BUY":"SELL",outcome:h==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});se(Ft.signature);},[g,m,l,wr,kr,Ke,Ve,Oe,D,P,h,e.slug,o]),Er=react.useCallback(async()=>{if(!f||!a)return;let w=f.chain,B=w!==types.Chain.POLYGON;B&&await s(types.Chain.POLYGON);try{let he=await f.getEip1193Provider();if(!he){ui.toast.error(o("predict.trade.submitError")),N(!1);return}let be={address:f.address,signatureType:0,signTypedData:async(Uo,$o,Wo)=>await he.request({method:"eth_signTypedData_v4",params:[f.address,JSON.stringify({domain:Uo,types:$o,message:Wo})]})},ye=a.credentials;if(!ye&&(await a.authenticate(be),ye=a.credentials,!ye))throw new Error("Polymarket authentication failed");let Dt=h==="yes"?0:1,Ft=e.provider_meta?.[`polymarket.tokenId${Dt}`]??e.provider_meta?.["polymarket.conditionId"]??"",ct=e.provider_meta?.["polymarket.negRisk"]??!1,_o=R==="limit"&&!isNaN(W)?W:D,Cr={tokenId:Ft,price:_o,size:M,side:P==="buy"?"BUY":"SELL",orderType:R==="limit"?"GTC":"FOK",tickSize:"0.01",negRisk:ct},Ao=reactPredict.buildCtfExchangeDomain(ct),Do=reactPredict.buildOrderMessage({...Cr,signerAddress:be.address,signatureType:be.signatureType}),Fo=await be.signTypedData(Ao,reactPredict.CTF_ORDER_TYPES,Do),Tr=reactPredict.buildSignedOrder({...Cr,signerAddress:be.address,signatureType:be.signatureType,signature:Fo}),Bo=JSON.stringify(Tr),Ho=await reactPredict.buildPolymarketL2Headers(ye.address,{apiKey:ye.apiKey,secret:ye.secret,passphrase:ye.passphrase,method:"POST",requestPath:"/api/v1/orders/polymarket",body:Bo});await l.createPolymarketOrder(Tr,Ho),c.invalidateQueries({queryKey:["predict","orders"]}),c.invalidateQueries({queryKey:["predict","positions"]}),ui.toast.success(o("predict.trade.submitSuccess")),Kr(),le(NaN),N(!1);}finally{B&&w&&s(w).catch(()=>{});}},[f,a,s,h,e.provider_meta,R,W,D,M,P,l,c,o]),Io=react.useCallback(async()=>{if(!(!_t.isValid||!p)){N(true),se(null),ae(false);try{d==="dflow"?await Pr():await Er();}catch{ui.toast.error(o("predict.trade.submitError")),N(false);}}},[_t.isValid,p,d,Pr,Er,o]);return {outcome:h,side:P,orderType:R,quantity:M,limitPrice:W,shares:ve,estimatedCost:lt,potentialPayout:Nr,potentialProfit:Mo,usdcBalance:it,yesTokenBalance:Lt,noTokenBalance:Ot,isBalanceLoading:To,isSubmitting:Se,validation:_t,supportsLimitOrder:u,kycRequired:Q,kycUrl:y,setOutcome:J,setSide:Ro,setOrderType:G,setQuantity:Lo,setLimitPrice:Oo,submit:Io}}var Is=`https://s1.chainstream.io/chains/sol/tokens/${utils.SOLANA_TOKENS.stablecoins.USDC.address}/image.png`;function Xr({event:e,market:t,variant:n="bordered",outcome:o,side:r,orderType:i,quantity:s,limitPrice:l,shares:a,potentialProfit:c,potentialPayout:d,estimatedCost:u,usdcBalance:m,yesTokenBalance:f,noTokenBalance:p,isBalanceLoading:g,isSubmitting:v,isValid:h,validationErrors:U,supportsLimitOrder:P,kycRequired:C,kycUrl:R,onOutcomeChange:j,onSideChange:M,onOrderTypeChange:le,onQuantityChange:W,onLimitPriceChange:pe,onSubmit:Se}){let{t:N}=i18n.useTranslation(),[re,se]=react.useState(false),Q=ui.useDisclosure();react.useEffect(()=>{C&&!Q.isOpen&&Q.onOpen();},[C]);let ae=react.useMemo(()=>{let _=r==="buy"?o==="yes"?t.yesAsk:t.noAsk:o==="yes"?t.yesBid:t.noBid;return _!=null?parseFloat((Number(_)*100).toFixed(2)):null},[r,o,t]),y=!isNaN(s)&&s>0,T=react.useMemo(()=>{if(v)return N("predict.trade.submitting");if(C)return N("predict.trade.kycRequired");if(!y)return N("predict.trade.enterAmount");let _=N(r==="buy"?"predict.trade.buy":"predict.trade.sell"),Ie=N(o==="yes"?"predict.trade.yes":"predict.trade.no"),Ee=r==="buy"&&c>0?` \u2192 Win $${c.toFixed(2)}`:"";return `${_} ${Ie}${Ee}`},[v,C,y,r,o,c,N]),I=react.useMemo(()=>o==="yes"?"primary":"secondary",[o]),D=()=>{W(Math.floor((m??0)/2*100)/100);},G=()=>{W(m??0);},[J,ve]=react.useState(false),Oe=()=>{if(C){Q.onOpen();return}if(!h){ve(true);return}ve(false),Se();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:ui.cn("flex w-full flex-col gap-y-4 p-4",n==="bordered"&&"rounded-xl border border-default-200 bg-content1"),children:[e&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsxRuntime.jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxRuntime.jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxRuntime.jsxs("span",{className:o==="yes"?"text-bullish":"text-bearish",children:[N(r==="buy"?"predict.trade.buy":"predict.trade.sell")," ",N(o==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxRuntime.jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[P?jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:i,onSelectionChange:_=>le(_),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:N("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:N("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:N("predict.trade.market")}),i==="limit"&&P?jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",value:isNaN(l)?void 0:parseFloat((l*100).toFixed(2)),onValueChange:_=>pe(_/100),minValue:1,maxValue:99,step:1,formatOptions:{maximumFractionDigits:2},endContent:jsxRuntime.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"}}):ae!=null&&jsxRuntime.jsxs("span",{className:"text-xl font-bold tabular-nums",children:[ae," \xA2"]})]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(_=>{let Ie=_==="yes"?f:p;return jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-y-1",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>j(_),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===_?_==="yes"?"border-primary bg-primary-50 text-primary":"border-secondary bg-secondary-50 text-secondary":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:N(_==="yes"?"predict.trade.yes":"predict.trade.no")}),(()=>{let Ee=r==="buy"?_==="yes"?t.yesAsk:t.noAsk:_==="yes"?t.yesBid:t.noBid;return Ee!=null?jsxRuntime.jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(Ee)*100).toFixed(2)),"\xA2"]}):null})()]}),r==="sell"&&o===_&&jsxRuntime.jsx("span",{className:"text-center text-xs text-foreground",children:g?"\u2013":`${Ie??0} shares`})]},_)})}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:N(r==="buy"?"predict.trade.youArePaying":"predict.trade.contracts")}),r==="buy"&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("img",{src:Is,alt:"USDC",className:"h-3.5 w-3.5 rounded-full object-cover"}),jsxRuntime.jsx("span",{className:"font-medium text-foreground tabular-nums",children:m!=null?`${m.toFixed(2)} USDC`:"\u2013"}),jsxRuntime.jsx("button",{type:"button",onClick:D,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:N("predict.trade.half")}),jsxRuntime.jsx("button",{type:"button",onClick:G,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:N("predict.trade.max")})]})]}),jsxRuntime.jsx(ui.StyledNumberInput,{fullWidth:true,placeholder:"0",radius:"lg",size:"lg",value:isNaN(s)?void 0:s,onValueChange:_=>{ve(false),W(_);},minValue:0,step:r==="buy"?.01:1,formatOptions:r==="buy"?{maximumFractionDigits:2}:{maximumFractionDigits:0},startContent:r==="buy"?jsxRuntime.jsx("span",{className:"text-default-600 text-xl",children:"$"}):void 0,classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}},r),r==="sell"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2 justify-end",children:[[25,50].map(_=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{W(Math.floor((o==="yes"?f??0:p??0)*_/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:[_,"%"]},_)),jsxRuntime.jsx("button",{type:"button",onClick:()=>{W(o==="yes"?f??0:p??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:N("common.all")})]}),J&&U.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:U.map(_=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:_},_))})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>se(_=>!_),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:N("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",re&&"rotate-180")})]}),ae!=null&&jsxRuntime.jsxs("span",{className:"text-foreground font-medium tabular-nums",children:[ae,"% chance"]})]}),re&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:"Total Size"}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(s)&&s>0?`$${u.toFixed(2)}`:"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:"No. of Contracts"}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?parseFloat(a.toFixed(2)):"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:"Payout"}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(s)&&s>0?`$${d.toFixed(2)}`:"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:"Est. Profit"}),jsxRuntime.jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(s)&&s>0&&c>0?`+$${c.toFixed(2)}`:"\u2013"})]})]})]}),jsxRuntime.jsx(ui.Button,{color:I,fullWidth:true,radius:"lg",size:"lg",isDisabled:!y||v,isLoading:v,onPress:Oe,children:T})]}),jsxRuntime.jsx(ui.Modal,{isOpen:Q.isOpen,onClose:Q.onClose,size:"md",children:jsxRuntime.jsxs(ui.ModalContent,{children:[jsxRuntime.jsx(ui.ModalHeader,{className:"flex flex-col gap-1",children:jsxRuntime.jsxs("span",{className:"text-lg",children:["\u{1F6E1}\uFE0F ",N("predict.trade.kycModalTitle")]})}),jsxRuntime.jsxs(ui.ModalBody,{className:"gap-y-4",children:[jsxRuntime.jsx("p",{className:"text-sm text-default-600",children:N("predict.trade.kycModalDescription")}),jsxRuntime.jsxs("ul",{className:"flex flex-col gap-y-2 text-sm text-foreground",children:[jsxRuntime.jsxs("li",{className:"flex items-start gap-x-2",children:[jsxRuntime.jsx("span",{className:"mt-0.5 text-primary",children:"\u2713"}),jsxRuntime.jsx("span",{children:N("predict.trade.kycModalBullet1")})]}),jsxRuntime.jsxs("li",{className:"flex items-start gap-x-2",children:[jsxRuntime.jsx("span",{className:"mt-0.5 text-primary",children:"\u2713"}),jsxRuntime.jsx("span",{children:N("predict.trade.kycModalBullet2")})]}),jsxRuntime.jsxs("li",{className:"flex items-start gap-x-2",children:[jsxRuntime.jsx("span",{className:"mt-0.5 text-primary",children:"\u2713"}),jsxRuntime.jsx("span",{children:N("predict.trade.kycModalBullet3")})]})]}),jsxRuntime.jsx("p",{className:"text-xs text-default-400",children:N("predict.trade.kycModalNote")})]}),jsxRuntime.jsxs(ui.ModalFooter,{children:[jsxRuntime.jsx(ui.Button,{variant:"light",onPress:Q.onClose,children:N("common.cancel")}),R&&jsxRuntime.jsx(ui.Button,{color:"primary",onPress:()=>{window.open(R,"_blank","noopener,noreferrer"),Q.onClose();},children:N("predict.trade.goToKYC")})]})]})})]})}function mt({event:e,market:t,variant:n,initialSide:o,initialOutcome:r,chain:i}){let{outcome:s,side:l,orderType:a,quantity:c,limitPrice:d,shares:u,estimatedCost:m,potentialPayout:f,potentialProfit:p,usdcBalance:g,yesTokenBalance:v,noTokenBalance:h,isBalanceLoading:U,isSubmitting:P,validation:C,supportsLimitOrder:R,kycRequired:j,kycUrl:M,setOutcome:le,setSide:W,setOrderType:pe,setQuantity:Se,setLimitPrice:N,submit:re}=Vr({market:t,initialSide:o,initialOutcome:r}),se=walletConnector.useAuthCallback(re),Q=react.useMemo(()=>e?Dr(e):void 0,[e]),ae=react.useMemo(()=>Fr(t),[t]);return jsxRuntime.jsx(Xr,{event:Q,market:ae,variant:n,outcome:s,side:l,orderType:a,quantity:c,limitPrice:d,shares:u,estimatedCost:m,potentialPayout:f,potentialProfit:p,usdcBalance:g,yesTokenBalance:v,noTokenBalance:h,isBalanceLoading:U,isSubmitting:P,isValid:C.isValid,validationErrors:C.errors,supportsLimitOrder:R,kycRequired:j,kycUrl:M,onOutcomeChange:le,onSideChange:W,onOrderTypeChange:pe,onQuantityChange:Se,onLimitPriceChange:N,onSubmit:se})}var Yt="predict-trade";function Jr({id:e=Yt}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(Ws,{...t})})}function Ws({params:e,isOpen:t,onOpenChange:n}){let{isMobile:o}=ui.useScreen();return e?jsxRuntime.jsx(ui.StyledModal,{isOpen:t,onOpenChange:n,size:o?"full":"md",backdrop:"blur",radius:"lg",children:jsxRuntime.jsx(ui.ModalContent,{children:jsxRuntime.jsx(ui.ModalBody,{className:"p-4",children:jsxRuntime.jsx(mt,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,initialSide:"buy",chain:e.chain,variant:"flat"})})})}):null}var qt={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function jt(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function en({isOpen:e,onClose:t,value:n,onChange:o}){let{t:r}=i18n.useTranslation(),[i,s]=react.useState(n),l=react.useCallback(v=>{v?s(n):t();},[n,t]),a=react.useCallback(()=>{s(qt);},[]),c=react.useCallback(()=>{o(i),t();},[i,o,t]),d=react.useCallback((v,h)=>{s(U=>({...U,[v]:h}));},[]),u=react.useMemo(()=>jt(i),[i]),m=react.useMemo(()=>[{value:void 0,label:r("predict.filter.all")},{value:"polymarket",label:r("predict.platform.polymarket")},{value:"dflow",label:r("predict.platform.dflow")}],[r]),f=react.useMemo(()=>[{value:void 0,label:r("predict.filter.all")},{value:"1d",label:r("predict.filter.lessThanDay")},{value:"7d",label:r("predict.filter.lessThanWeek")},{value:"30d",label:r("predict.filter.lessThanMonth")}],[r]),p=react.useMemo(()=>[{value:void 0,label:r("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[r]),g=react.useMemo(()=>[{value:void 0,label:r("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[r]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:l,size:"md",scrollBehavior:"inside",children:jsxRuntime.jsxs(ui.ModalContent,{children:[jsxRuntime.jsx(ui.ModalHeader,{className:"px-4 py-2",children:jsxRuntime.jsx("span",{className:"text-base font-semibold",children:r("predict.filter.title")})}),jsxRuntime.jsxs(ui.ModalBody,{className:"flex flex-col gap-5",children:[jsxRuntime.jsx(gt,{label:r("predict.filter.platform"),children:jsxRuntime.jsx(vt,{options:m,selected:i.source,onSelect:v=>d("source",v)})}),jsxRuntime.jsx(gt,{label:r("predict.filter.timeRemaining"),children:jsxRuntime.jsx(vt,{options:f,selected:i.timeRemaining,onSelect:v=>d("timeRemaining",v)})}),jsxRuntime.jsx(gt,{label:r("predict.filter.minVolume"),children:jsxRuntime.jsx(vt,{options:p,selected:i.minVolume,onSelect:v=>d("minVolume",v)})}),jsxRuntime.jsx(gt,{label:r("predict.filter.minLiquidity"),children:jsxRuntime.jsx(vt,{options:g,selected:i.minLiquidity,onSelect:v=>d("minLiquidity",v)})})]}),jsxRuntime.jsx(ui.ModalFooter,{className:"px-4",children:jsxRuntime.jsxs("div",{className:"w-full flex justify-between items-center",children:[jsxRuntime.jsx(ui.Button,{variant:"light",color:"default",size:"sm",radius:"full",startContent:jsxRuntime.jsx(ui.RefreshIcon,{width:16,height:16}),onPress:a,children:r("predict.filter.reset")}),jsxRuntime.jsxs(ui.Button,{color:"primary",size:"sm",radius:"full",onPress:c,children:[r("predict.filter.showResults"),u>0&&jsxRuntime.jsxs("span",{className:"ml-1 text-xs opacity-80",children:["(",u,")"]})]})]})})]})})}function gt({label:e,children:t}){return jsxRuntime.jsxs("div",{className:"flex flex-col gap-2.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground",children:e}),t]})}function vt({options:e,selected:t,onSelect:n,allowDeselect:o=true}){return jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(r=>{let i=t===r.value;return jsxRuntime.jsx("button",{type:"button",onClick:()=>{n(i&&o?void 0:r.value);},className:ui.cn("shrink-0 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors duration-150 cursor-pointer border",i?"bg-primary/15 text-primary border-primary/40":"bg-content2 text-foreground/60 border-default-100 hover:bg-default-100 hover:text-foreground"),children:r.label},r.value??"__all")})})}var on={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},rn={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},la=["start_time","volume","liquidity","ending_soon"];function sn({sortPreset:e,onSortChange:t,sortAsc:n,onSortAscChange:o,onFilterPress:r,filterCount:i=0,className:s}){let{t:l}=i18n.useTranslation(),[a,c]=react.useState(false),d=react.useRef(null);react.useEffect(()=>{if(!a)return;let m=p=>{d.current&&!d.current.contains(p.target)&&c(false);},f=p=>{p.key==="Escape"&&c(false);};return document.addEventListener("mousedown",m),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",f);}},[a]);let u=nn[e];return jsxRuntime.jsxs("div",{className:ui.cn("flex items-center gap-2",s),children:[jsxRuntime.jsxs("div",{ref:d,className:"relative flex shrink-0 items-center rounded-full border border-border",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>c(m=>!m),className:"flex shrink-0 items-center gap-2 px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsxRuntime.jsx(u,{className:"size-[18px] shrink-0"}),jsxRuntime.jsx("span",{className:"whitespace-nowrap",children:l(rn[e])})]}),jsxRuntime.jsx("div",{className:"h-6 w-px bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o(!n),className:"px-2.5 py-1.5 text-xs text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:n?"\u2191":"\u2193"}),a&&jsxRuntime.jsx("div",{className:"absolute left-0 top-full z-20 mt-1 flex min-w-max flex-col gap-0.5 rounded-lg border border-border bg-content1 p-1 shadow-lg",children:la.map(m=>{let f=nn[m];return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{t(m),c(false);},className:ui.cn("flex w-full items-center gap-2 rounded px-2.5 py-1.5 text-xs font-medium transition-colors cursor-pointer",m===e?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsxRuntime.jsx(f,{className:"size-4 shrink-0"}),jsxRuntime.jsx("span",{children:l(rn[m])})]},m)})})]}),jsxRuntime.jsx(ui.StyledBadge,{content:i>0?i:void 0,color:"primary",size:"sm",isInvisible:i===0,children:jsxRuntime.jsxs("button",{type:"button",onClick:r,className:"flex shrink-0 items-center gap-2 rounded-full border border-border px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsxRuntime.jsx(ui.FilterIcon,{className:"size-[18px]"}),jsxRuntime.jsx("span",{className:"whitespace-nowrap",children:l("predict.filter.title")})]})})]})}var nn={start_time:ui.CalendarIcon,volume:ui.ChartLineIcon,liquidity:ui.DropletIcon,ending_soon:ui.TimerIcon};function cn(e={}){let t=react.useMemo(()=>reactPredict.resolveEventsParams(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets,e.minVolume,e.minLiquidity,e.timeRemaining]),{data:n,isLoading:o,isFetching:r,isFetchingNextPage:i,isError:s,error:l,hasNextPage:a,fetchNextPage:c,refetch:d}=reactPredict.useInfiniteEvents(t),u=react.useMemo(()=>n?.pages.flatMap(p=>p.items).filter(p=>p!=null)??[],[n]),m=react.useCallback(()=>{c();},[c]),f=react.useCallback(()=>{d();},[d]);return {data:u,isLoading:o,isFetching:r&&!i,isFetchingMore:i,isError:s,error:l??null,hasMore:a??false,fetchMore:m,refetch:f}}function Gt({count:e=6}){return jsxRuntime.jsx("div",{className:"grid w-full grid-cols-1 gap-0 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:Array.from({length:e}).map((t,n)=>jsxRuntime.jsx("div",{className:"p-2",children:jsxRuntime.jsxs("div",{className:"flex h-full min-h-52 flex-col rounded-xl border border-border/90 bg-background p-3 lg:min-h-72 lg:p-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"size-10 shrink-0 rounded-lg"}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-1",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-11/12 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-2/5 rounded"})]})]}),jsxRuntime.jsxs("div",{className:"mt-3 flex flex-1 flex-col gap-2 lg:gap-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-1/2 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-3/5 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-2/5 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]})]}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-20 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-24 rounded"})]})]})},n))})}function Zd({count:e=48}){return jsxRuntime.jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsxRuntime.jsxs("div",{className:"flex min-h-8 items-center justify-between gap-3 lg:min-h-9",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-20 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-20 rounded"})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-28 rounded-full"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-24 rounded-full"})]})]}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(Gt,{count:e})})]})}var dn=3,Qt={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},vn={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},xa={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},Ge=[{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 un(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function ha(e){let t=e.outcomes?.map(s=>s.label?.toLowerCase().trim()??"")??[];if(t.some(s=>s==="up")&&t.some(s=>s==="down"))return [Qt,xa];if(t.some(s=>s==="yes")&&t.some(s=>s==="no"))return [Qt,vn];let n=t[0]??"",o=t[1]??"",r=un(n)%Ge.length,i=un(o)%Ge.length;return i===r&&(i=(i+1)%Ge.length),[Ge[r],Ge[i]]}function ba(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function xn(e){let t=ba(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function hn(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function pn(e){let t=e.outcomes?.[0],n=t?.best_ask??t?.price??0;return parseFloat((n*100).toFixed(2)).toString()}function mn(e){let t=e.outcomes?.[1];if(t){let r=t.best_ask??t.price??0;return parseFloat((r*100).toFixed(2)).toString()}let n=e.outcomes?.[0],o=n?.best_ask??n?.price??0;return parseFloat(((1-o)*100).toFixed(2)).toString()}function ya(e){let t=new Date(e).getTime()-Date.now();if(t<=0)return null;let n=Math.floor(t/864e5),o=Math.floor(t%864e5/36e5),r=Math.floor(t%36e5/6e4),i=[];return n>0&&i.push(`${n}d`),o>0&&i.push(`${o}h`),i.push(`${r}m`),i.join(" ")}var wa=`
1
+ 'use strict';var react=require('react'),ui=require('@liberfi.io/ui'),uiScaffold=require('@liberfi.io/ui-scaffold'),i18n=require('@liberfi.io/i18n'),jsxRuntime=require('react/jsx-runtime'),walletConnector=require('@liberfi.io/wallet-connector'),reactQuery=require('@tanstack/react-query'),Qt=require('canvas-confetti'),reactPredict=require('@liberfi.io/react-predict'),types=require('@liberfi.io/types'),utils=require('@liberfi.io/utils'),reactWindow=require('react-window'),reactWindowInfiniteLoader=require('react-window-infinite-loader'),hooks=require('@liberfi.io/hooks'),recharts=require('recharts'),jotai=require('jotai'),utils$1=require('jotai/utils');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Qt__default=/*#__PURE__*/_interopDefault(Qt);typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-predict"]="0.1.89");var es="0.1.89";var ts={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},Br=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],Yt=(()=>{let e=t=>{let n=Br.indexOf(t);return n===-1?Br.length:n};return Object.entries(ts).map(([t,n])=>({slug:t,label:t,tags:(n??[]).map(o=>({slug:o,label:o}))})).sort((t,n)=>e(t.slug)-e(n.slug))})();function $r({categories:e,selectedCategory:t,selectedTag:n,activeTags:o,onCategorySelect:r,onTagSelect:i,trailing:s,pulsingTab:l="Trending",className:a}){let{t:c}=i18n.useTranslation(),d=react.useCallback(()=>{r(null);},[r]),u=c("predict.categories.trending");return jsxRuntime.jsxs("div",{className:ui.cn("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-1 lg:px-2 lg:py-1",a),children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center gap-2",children:[jsxRuntime.jsx("div",{className:"hideScrollbar min-w-0 flex-1 overflow-x-auto overflow-y-hidden",children:jsxRuntime.jsxs("div",{className:"flex min-h-8 items-stretch gap-x-2 lg:min-h-9",children:[jsxRuntime.jsx(Hr,{label:u,isSelected:t===null,onPress:d,showPulse:u===l}),jsxRuntime.jsx(ss,{}),e.map(m=>jsxRuntime.jsx(Hr,{label:m.category,isSelected:t===m.category,onPress:()=>r(m.category),badge:m.badge,showPulse:m.category===l},m.category))]})}),s&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:s})]}),t&&o.length>0&&jsxRuntime.jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxRuntime.jsxs("div",{className:"flex gap-x-1 pl-2 lg:w-full lg:gap-x-2",children:[jsxRuntime.jsx(Ur,{label:c("predict.categories.allMarkets"),isSelected:n===null,onPress:()=>i(null)}),o.map(m=>jsxRuntime.jsx(Ur,{label:m.label,icon:m.icon,isSelected:n===m.label,onPress:()=>i(m.label)},m.label))]})})]})}function Hr({label:e,isSelected:t,onPress:n,badge:o,showPulse:r}){return jsxRuntime.jsxs("button",{type:"button",onClick:n,className:ui.cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b p-1 text-base font-normal capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[r?jsxRuntime.jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsxRuntime.jsx("span",{children:e})]}):e,o&&jsxRuntime.jsx("span",{className:"absolute -right-1 top-0 rounded bg-primary px-0.5 py-px text-[0.625rem] font-semibold leading-none text-neutral-950",children:o})]})}function ss(){return jsxRuntime.jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function Ur({label:e,icon:t,isSelected:n,onPress:o}){return jsxRuntime.jsxs("button",{type:"button",onClick:o,className:ui.cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-2 py-1 text-sm font-medium uppercase transition-colors cursor-pointer",n?"border-transparent bg-primary text-black":"border-border/80 text-neutral-200 hover:bg-primary/10 hover:text-primary"),children:[t&&jsxRuntime.jsx("span",{className:ui.cn("iconify size-4",t)}),e]})}function td({count:e=6}){return jsxRuntime.jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-1 lg:px-2 lg:py-1",children:jsxRuntime.jsx("div",{className:"flex min-h-8 items-center gap-x-2 lg:min-h-9",children:Array.from({length:e}).map((t,n)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 shrink-0 rounded"},n))})})}function as(e){return e.map(t=>({category:t.label,tags:t.tags.map(n=>n.label)}))}function is(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function Kr({onSelect:e,trailing:t,className:n}){let[o,r]=react.useState(null),[i,s]=react.useState(null),l=react.useCallback(m=>{r(m),s(null),e?.({categorySlug:m,tagSlug:null});},[e]),a=react.useCallback(m=>{s(m),e?.({categorySlug:o,tagSlug:m});},[o,e]),c=as(Yt),d=Yt.find(m=>m.slug===o),u=is(d);return jsxRuntime.jsx($r,{categories:c,selectedCategory:o,selectedTag:i,activeTags:u,onCategorySelect:l,onTagSelect:a,trailing:t,className:n})}function Vr(e){return {title:e.title,imageUrl:e.image_url}}function Yr(e){let t=e.outcomes[0],n=e.outcomes[1];return {question:e.question,yesAsk:t?.best_ask??t?.price,noAsk:n?.best_ask??n?.price,yesBid:t?.best_bid,noBid:n?.best_bid,yesSubTitle:t?.label??"Yes",noSubTitle:n?.label??"No"}}var Qe=48,qt=4,vt={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},oe={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},xt=oe.ALL,dd={[oe.ONE_DAY]:vt.ONE_MINUTE,[oe.ONE_WEEK]:vt.ONE_HOUR,[oe.ONE_MONTH]:vt.ONE_HOUR,[oe.ALL]:vt.ONE_DAY},ud={[oe.ONE_DAY]:300,[oe.ONE_WEEK]:3600,[oe.ONE_MONTH]:10800,[oe.ALL]:1440*60},pd={[oe.ONE_DAY]:1440*60,[oe.ONE_WEEK]:10080*60,[oe.ONE_MONTH]:720*60*60,[oe.ALL]:null},jt=1,md=1,fd=1,gd=99,Be={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},vd=Be.ONE_WEEK,xd={[Be.ONE_HOUR]:60,[Be.SIX_HOURS]:60,[Be.ONE_DAY]:300,[Be.ONE_WEEK]:1800,[Be.MAX]:1800};var Gr=react.createContext(null);function Xt(){let e=react.useContext(Gr);if(!e)throw new Error("usePredictWallet must be used within a PredictWalletProvider");return e}var ps=3e4;function ms({pollingInterval:e=ps,enabled:t=true,children:n}){let o=walletConnector.useWallets(),r=react.useMemo(()=>o.find(f=>f.chainNamespace===types.ChainNamespace.SOLANA&&f.isConnected)?.address,[o]),i=react.useMemo(()=>o.find(f=>f.chainNamespace===types.ChainNamespace.EVM&&f.isConnected)?.address,[o]),{data:s,isLoading:l,error:a}=reactPredict.useBalance({source:"dflow",user:r??""},{enabled:t&&!!r,refetchInterval:e}),{data:c,isLoading:d,error:u}=reactPredict.useBalance({source:"polymarket",user:i??""},{enabled:t&&!!i,refetchInterval:e}),m=react.useMemo(()=>({solanaAddress:r,evmAddress:i,dflowUsdcBalance:s?Number(s.balance):0,polymarketUsdcBalance:c?Number(c.balance):0,isLoading:l||d,error:a??u??null}),[r,i,s,c,l,d,a,u]);return jsxRuntime.jsx(Gr.Provider,{value:m,children:n})}var Is={minutes:60,hours:3600,days:86400};function _s(e,t,n){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 r=new Date;return r.setUTCHours(23,59,59,0),Math.floor(r.getTime()/1e3)}case "custom":return o+t*Is[n]}}function Zr(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};Qt__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{Qt__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{Qt__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function en({market:e,initialOutcome:t="yes",initialSide:n="buy"}){let{t:o}=i18n.useTranslation(),{status:r}=walletConnector.useAuth(),i=walletConnector.useWallets(),s=walletConnector.useSwitchChain(),l=reactPredict.usePredictClient(),a=react.useContext(reactPredict.PolymarketContext),c=reactQuery.useQueryClient(),d=e.source,u=d==="polymarket",m=i.find(N=>N.chainNamespace===types.ChainNamespace.SOLANA&&N.isConnected),f=i.find(N=>N.chainNamespace===types.ChainNamespace.EVM&&N.isConnected&&"switchChain"in N),p=r==="authenticated",g=m?.address,v=f?.address,[h,H]=react.useState(t),[P,M]=react.useState(n),[L,q]=react.useState("market"),[R,ie]=react.useState(NaN),[V,fe]=react.useState(NaN),[Me,Q]=react.useState(false),[J,le]=react.useState(null),[he,be]=react.useState(false),[S,C]=react.useState(null),[I,y]=react.useState(false),[$,j]=react.useState("1h"),[z,Pe]=react.useState(30),[Re,At]=react.useState("minutes"),ye=null;try{let N=Xt();ye={dflowUsdcBalance:N.dflowUsdcBalance,polymarketUsdcBalance:N.polymarketUsdcBalance,isLoading:N.isLoading};}catch{}let ne=react.useMemo(()=>{let N=h==="yes"?0:1,F=e.outcomes[N];return P==="buy"?F?.best_ask??F?.price??.5:F?.best_bid??F?.price??.5},[e.outcomes,h,P]),Ft=react.useCallback(N=>{q(N);},[]),Bt=react.useCallback(N=>{H(N),fe(NaN);},[]);react.useEffect(()=>{L==="limit"&&isNaN(V)&&fe(Math.round(ne*100)/100);},[L,V,ne]);let je=react.useMemo(()=>isNaN(R)||R<=0?0:P==="buy"?ne>0?R/ne:0:R,[P,R,ne]),Fe=react.useMemo(()=>isNaN(R)||R<=0?"0":String(Math.round(R*1e6)),[R]),T=e.provider_meta?.["dflow.yesMint"]??"",ce=e.provider_meta?.["dflow.noMint"]??"",Le=e.provider_meta?.["dflow.collateralMint"]||utils.SOLANA_TOKENS.stablecoins.USDC.address,Mr=h==="yes"?T:ce,Ge=P==="buy"?Le:Mr,Xe=P==="buy"?Mr:Le,Fo=d==="dflow"&&!!Ge&&!!Xe&&!!g&&Fe!=="0",{refetch:Rr}=reactPredict.useDFlowQuote({inputMint:Ge,outputMint:Xe,amount:Fe,userPublicKey:g??"",slippageBps:100},{enabled:Fo}),Lr=d==="dflow"?g??"":v??"",{data:Se,isLoading:Bo}=reactPredict.usePositions({source:d,user:Lr},{enabled:!!Lr}),pt=react.useMemo(()=>ye?d==="dflow"?ye.dflowUsdcBalance:ye.polymarketUsdcBalance:Se&&Se.positions.reduce((F,Ne)=>Ne.side==="USDC"||Ne.side==="collateral"?F+(Ne.current_value??0):F,0)||null,[ye,Se,d]),Ho=ye?ye.isLoading:Bo,Ht=react.useMemo(()=>Se?Se.positions.find(F=>F.side?.toLowerCase()==="yes"&&F.market?.slug===e.slug)?.size??0:null,[Se,e.slug]),Ut=react.useMemo(()=>Se?Se.positions.find(F=>F.side?.toLowerCase()==="no"&&F.market?.slug===e.slug)?.size??0:null,[Se,e.slug]),$t=react.useMemo(()=>L==="limit"&&u&&!isNaN(V)?V:ne,[L,u,V,ne]),mt=react.useMemo(()=>{if(isNaN(R)||R<=0)return 0;if(P==="buy")return R;let N=h==="yes"?e.outcomes[0]?.best_bid??0:e.outcomes[1]?.best_bid??0;return R*N},[P,h,R,e.outcomes]),Or=react.useMemo(()=>isNaN(R)||R<=0?0:P==="buy"?$t>0?R/$t*1:0:mt,[P,R,$t,mt]),Uo=Or-mt,$o=react.useCallback(N=>{M(N),ie(NaN);},[]),Wo=react.useCallback(N=>{if(isNaN(N)){ie(NaN);return}let F=Math.max(0,N),Ne=P==="buy"?Math.round(F*100)/100:Math.round(F);ie(Ne);},[P]),zo=react.useCallback(N=>{if(isNaN(N)){fe(NaN);return}let F=Math.max(.01,Math.min(.99,N));fe(Math.round(F*100)/100);},[]),Wt=react.useMemo(()=>{let N=[];(isNaN(R)||R<jt)&&N.push(`Minimum quantity is ${jt}`),e.status!=="open"&&N.push("Market is not active"),P==="buy"&&pt!=null&&!isNaN(R)&&R>0&&R>pt&&N.push("Insufficient USDC balance");let F=h==="yes"?Ht:Ut;return P==="sell"&&F!=null&&!isNaN(R)&&R>0&&R>F&&N.push("Insufficient shares"),L==="limit"&&u&&(isNaN(V)||V<.01||V>.99)&&N.push("Limit price must be between $0.01 and $0.99"),L==="limit"&&u&&I&&$==="custom"&&(isNaN(z)||z<=0)&&N.push(o("predict.trade.expiration.invalidDate")),{isValid:N.length===0,errors:N}},[R,e.status,P,pt,Ht,Ut,h,L,u,V,I,$,z,o]),{mutateAsync:Ir}=reactPredict.useDFlowSubmit(),{data:zt}=reactPredict.useOrder({id:J??"",source:d},{enabled:!!J});react.useEffect(()=>{if(!zt||!J)return;let{status:N}=zt;N==="closed"?(Q(false),le(null),ui.toast.success(o("predict.trade.submitSuccess")),Zr(),ie(NaN)):(N==="failed"||N==="expired")&&(Q(false),le(null),ui.toast.error(o("predict.trade.submitError")));},[zt,J,o]);let _r=react.useCallback(async()=>{if(!g||!m)return;if(!Ge||!Xe){ui.toast.error("Missing token mint addresses"),Q(false);return}let N=await l.checkDFlowKYC(g);if(!N.verified){be(true),C(N.kyc_url||null),Q(false);return}let we=(await Rr()).data?.transaction;if(!we){ui.toast.error(o("predict.trade.submitError")),Q(false);return}let ke=Uint8Array.from(atob(we),ft=>ft.charCodeAt(0)),Kt=await m.signTransaction(ke),Vt=await Ir({signedTransaction:btoa(String.fromCharCode(...Kt)),orderContext:{user_public_key:g,input_mint:Ge,output_mint:Xe,amount:Fe,price:String(ne),side:P==="buy"?"BUY":"SELL",outcome:h==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}});le(Vt.signature);},[g,m,l,Rr,Ir,Ge,Xe,Fe,ne,P,h,e.slug,o]),Dr=react.useCallback(async()=>{if(!f||!a)return;let N=f.chain,F=N!==types.Chain.POLYGON;F&&await s(types.Chain.POLYGON);try{let Ne=await f.getEip1193Provider();if(!Ne){ui.toast.error(o("predict.trade.submitError")),Q(!1);return}let we={address:f.address,signatureType:0,signTypedData:async(Qo,Jo,Zo)=>await Ne.request({method:"eth_signTypedData_v4",params:[f.address,JSON.stringify({domain:Qo,types:Jo,message:Zo})]})},ke=a.credentials;if(!ke&&(await a.authenticate(we),ke=a.credentials,!ke))throw new Error("Polymarket authentication failed");let Kt=h==="yes"?0:1,Vt=e.provider_meta?.[`polymarket.tokenId${Kt}`]??e.provider_meta?.["polymarket.conditionId"]??"",ft=e.provider_meta?.["polymarket.negRisk"]??!1,Vo=L==="limit"&&!isNaN(V)?V:ne,Ar={tokenId:Vt,price:Vo,size:R,side:P==="buy"?"BUY":"SELL",orderType:L==="limit"?I?"GTD":"GTC":"FOK",tickSize:"0.01",negRisk:ft,...L==="limit"&&I&&{expiration:_s($,z,Re)}},Yo=reactPredict.buildCtfExchangeDomain(ft),qo=reactPredict.buildOrderMessage({...Ar,signerAddress:we.address,signatureType:we.signatureType}),jo=await we.signTypedData(Yo,reactPredict.CTF_ORDER_TYPES,qo),Fr=reactPredict.buildSignedOrder({...Ar,signerAddress:we.address,signatureType:we.signatureType,signature:jo}),Go=JSON.stringify(Fr),Xo=await reactPredict.buildPolymarketL2Headers(ke.address,{apiKey:ke.apiKey,secret:ke.secret,passphrase:ke.passphrase,method:"POST",requestPath:"/api/v1/orders/polymarket",body:Go});await l.createPolymarketOrder(Fr,Xo),c.invalidateQueries({queryKey:["predict","orders"]}),c.invalidateQueries({queryKey:["predict","positions"]}),ui.toast.success(o("predict.trade.submitSuccess")),Zr(),ie(NaN),Q(!1);}finally{F&&N&&s(N).catch(()=>{});}},[f,a,s,h,e.provider_meta,L,V,ne,R,P,l,c,I,$,z,Re,o]),Ko=react.useCallback(async()=>{if(!(!Wt.isValid||!p)){Q(true),le(null),be(false);try{d==="dflow"?await _r():await Dr();}catch{ui.toast.error(o("predict.trade.submitError")),Q(false);}}},[Wt.isValid,p,d,_r,Dr,o]);return {outcome:h,side:P,orderType:L,quantity:R,limitPrice:V,shares:je,estimatedCost:mt,potentialPayout:Or,potentialProfit:Uo,usdcBalance:pt,yesTokenBalance:Ht,noTokenBalance:Ut,isBalanceLoading:Ho,isSubmitting:Me,validation:Wt,supportsLimitOrder:u,kycRequired:he,kycUrl:S,expirationEnabled:I,expirationPreset:$,customDuration:z,customDurationUnit:Re,setOutcome:Bt,setSide:$o,setOrderType:Ft,setQuantity:Wo,setLimitPrice:zo,setExpirationEnabled:y,setExpirationPreset:j,setCustomDuration:Pe,setCustomDurationUnit:At,submit:Ko}}var qs=`https://s1.chainstream.io/chains/sol/tokens/${utils.SOLANA_TOKENS.stablecoins.USDC.address}/image.png`,js=["5m","1h","12h","24h","eod","custom"],Gs={"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"},Xs=["minutes","hours","days"],Qs={minutes:"predict.trade.expiration.minutes",hours:"predict.trade.expiration.hours",days:"predict.trade.expiration.days"};function ln({event:e,market:t,variant:n="bordered",outcome:o,side:r,orderType:i,quantity:s,limitPrice:l,shares:a,potentialProfit:c,potentialPayout:d,estimatedCost:u,usdcBalance:m,yesTokenBalance:f,noTokenBalance:p,isBalanceLoading:g,isSubmitting:v,isValid:h,validationErrors:H,supportsLimitOrder:P,kycRequired:M,kycUrl:L,expirationEnabled:q,expirationPreset:R,customDuration:ie,customDurationUnit:V,onOutcomeChange:fe,onSideChange:Me,onOrderTypeChange:Q,onQuantityChange:J,onLimitPriceChange:le,onExpirationEnabledChange:he,onExpirationPresetChange:be,onCustomDurationChange:S,onCustomDurationUnitChange:C,onSubmit:I}){let{t:y}=i18n.useTranslation(),[$,j]=react.useState(false),z=ui.useDisclosure();react.useEffect(()=>{M&&!z.isOpen&&z.onOpen();},[M]);let Pe=react.useMemo(()=>{let T=r==="buy"?o==="yes"?t.yesAsk:t.noAsk:o==="yes"?t.yesBid:t.noBid;return T!=null?parseFloat((Number(T)*100).toFixed(2)):null},[r,o,t]),Re=!isNaN(s)&&s>0,At=react.useMemo(()=>{if(v)return y("predict.trade.submitting");if(M)return y("predict.trade.kycRequired");if(!Re)return y("predict.trade.enterAmount");let T=y(r==="buy"?"predict.trade.buy":"predict.trade.sell"),ce=y(o==="yes"?"predict.trade.yes":"predict.trade.no"),Le=r==="buy"&&c>0?` \u2192 Win $${c.toFixed(2)}`:"";return `${T} ${ce}${Le}`},[v,M,Re,r,o,c,y]),ye=react.useMemo(()=>o==="yes"?"primary":"secondary",[o]),ne=()=>{J(Math.floor((m??0)/2*100)/100);},Ft=()=>{J(m??0);},[Bt,je]=react.useState(false),Fe=()=>{if(M){z.onOpen();return}if(!h){je(true);return}je(false),I();};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:ui.cn("flex w-full flex-col gap-y-4 p-4",n==="bordered"&&"rounded-xl border border-default-200 bg-content1"),children:[e&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsxRuntime.jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxRuntime.jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxRuntime.jsxs("span",{className:o==="yes"?"text-bullish":"text-bearish",children:[y(r==="buy"?"predict.trade.buy":"predict.trade.sell")," ",y(o==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxRuntime.jsxs("span",{className:"text-foreground",children:[" \xB7 ",t.yesSubTitle]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[P?jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:i,onSelectionChange:T=>Q(T),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:y("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:y("predict.trade.limit")},"limit")]}):jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:y("predict.trade.market")}),i==="limit"&&P?jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Limit price",placeholder:"50",size:"sm",radius:"none",value:isNaN(l)?void 0:parseFloat((l*100).toFixed(2)),onValueChange:T=>le(T/100),minValue:1,maxValue:99,step:1,formatOptions:{maximumFractionDigits:2},endContent:jsxRuntime.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"}}):Pe!=null&&jsxRuntime.jsxs("span",{className:"text-xl font-bold tabular-nums",children:[Pe," \xA2"]})]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(T=>{let ce=T==="yes"?f:p;return jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-y-1",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>fe(T),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${o===T?T==="yes"?"border-primary bg-primary-50 text-primary":"border-secondary bg-secondary-50 text-secondary":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:y(T==="yes"?"predict.trade.yes":"predict.trade.no")}),(()=>{let Le=r==="buy"?T==="yes"?t.yesAsk:t.noAsk:T==="yes"?t.yesBid:t.noBid;return Le!=null?jsxRuntime.jsxs("span",{className:"ml-1 opacity-70",children:[parseFloat((Number(Le)*100).toFixed(2)),"\xA2"]}):null})()]}),r==="sell"&&o===T&&jsxRuntime.jsx("span",{className:"text-center text-xs text-foreground",children:g?"\u2013":`${ce??0} shares`})]},T)})}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:y(r==="buy"?"predict.trade.youArePaying":"predict.trade.contracts")}),r==="buy"&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("img",{src:qs,alt:"USDC",className:"h-3.5 w-3.5 rounded-full object-cover"}),jsxRuntime.jsx("span",{className:"font-medium text-foreground tabular-nums",children:m!=null?`${m.toFixed(2)} USDC`:"\u2013"}),jsxRuntime.jsx("button",{type:"button",onClick:ne,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:y("predict.trade.half")}),jsxRuntime.jsx("button",{type:"button",onClick:Ft,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:y("predict.trade.max")})]})]}),jsxRuntime.jsx(ui.StyledNumberInput,{fullWidth:true,placeholder:"0",radius:"lg",size:"lg",value:isNaN(s)?void 0:s,onValueChange:T=>{je(false),J(T);},minValue:0,step:r==="buy"?.01:1,formatOptions:r==="buy"?{maximumFractionDigits:2}:{maximumFractionDigits:0},startContent:r==="buy"?jsxRuntime.jsx("span",{className:"text-default-600 text-xl",children:"$"}):void 0,classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}},r),r==="sell"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2 justify-end",children:[[25,50].map(T=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{J(Math.floor((o==="yes"?f??0:p??0)*T/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:[T,"%"]},T)),jsxRuntime.jsx("button",{type:"button",onClick:()=>{J(o==="yes"?f??0:p??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:y("common.all")})]}),Bt&&H.length>0&&jsxRuntime.jsx("div",{className:"flex flex-col gap-y-0.5",children:H.map(T=>jsxRuntime.jsx("span",{className:"text-xs text-danger",children:T},T))})]}),i==="limit"&&P&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-primary",children:y("predict.trade.setExpiration")}),jsxRuntime.jsx(ui.StyledSwitch,{size:"sm",color:"primary",isSelected:q,onValueChange:he,"aria-label":y("predict.trade.setExpiration")})]}),q&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Select,{"aria-label":y("predict.trade.setExpiration"),selectedKeys:[R],onSelectionChange:T=>{let ce=Array.from(T)[0];ce&&be(ce);},size:"sm",radius:"lg",classNames:{trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:js.map(T=>jsxRuntime.jsx(ui.SelectItem,{children:y(Gs[T])},T))}),R==="custom"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2",children:[jsxRuntime.jsx(ui.StyledNumberInput,{"aria-label":"Duration amount",size:"sm",radius:"lg",value:isNaN(ie)?void 0:ie,onValueChange:S,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"}}),jsxRuntime.jsx(ui.Select,{"aria-label":"Duration unit",selectedKeys:[V],onSelectionChange:T=>{let ce=Array.from(T)[0];ce&&C(ce);},size:"sm",radius:"lg",classNames:{base:"w-32",trigger:"bg-content2 data-[hover=true]:bg-content2 min-h-10",value:"text-sm"},children:Xs.map(T=>jsxRuntime.jsx(ui.SelectItem,{children:y(Qs[T])},T))})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>j(T=>!T),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:y("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",$&&"rotate-180")})]}),Pe!=null&&jsxRuntime.jsxs("span",{className:"text-foreground font-medium tabular-nums",children:[Pe,"% chance"]})]}),$&&jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5 border-l-2 border-default-300 pl-3 text-sm text-neutral-500",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:"Total Size"}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(s)&&s>0?`$${u.toFixed(2)}`:"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:"No. of Contracts"}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(a)&&a>0?parseFloat(a.toFixed(2)):"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:"Payout"}),jsxRuntime.jsx("span",{className:"tabular-nums text-foreground",children:!isNaN(s)&&s>0?`$${d.toFixed(2)}`:"\u2013"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{children:"Est. Profit"}),jsxRuntime.jsx("span",{className:"tabular-nums text-bullish",children:!isNaN(s)&&s>0&&c>0?`+$${c.toFixed(2)}`:"\u2013"})]})]})]}),jsxRuntime.jsx(ui.Button,{color:ye,fullWidth:true,radius:"lg",size:"lg",isDisabled:!Re||v,isLoading:v,onPress:Fe,children:At})]}),jsxRuntime.jsx(ui.Modal,{isOpen:z.isOpen,onClose:z.onClose,size:"md",children:jsxRuntime.jsxs(ui.ModalContent,{children:[jsxRuntime.jsx(ui.ModalHeader,{className:"flex flex-col gap-1",children:jsxRuntime.jsxs("span",{className:"text-lg",children:["\u{1F6E1}\uFE0F ",y("predict.trade.kycModalTitle")]})}),jsxRuntime.jsxs(ui.ModalBody,{className:"gap-y-4",children:[jsxRuntime.jsx("p",{className:"text-sm text-default-600",children:y("predict.trade.kycModalDescription")}),jsxRuntime.jsxs("ul",{className:"flex flex-col gap-y-2 text-sm text-foreground",children:[jsxRuntime.jsxs("li",{className:"flex items-start gap-x-2",children:[jsxRuntime.jsx("span",{className:"mt-0.5 text-primary",children:"\u2713"}),jsxRuntime.jsx("span",{children:y("predict.trade.kycModalBullet1")})]}),jsxRuntime.jsxs("li",{className:"flex items-start gap-x-2",children:[jsxRuntime.jsx("span",{className:"mt-0.5 text-primary",children:"\u2713"}),jsxRuntime.jsx("span",{children:y("predict.trade.kycModalBullet2")})]}),jsxRuntime.jsxs("li",{className:"flex items-start gap-x-2",children:[jsxRuntime.jsx("span",{className:"mt-0.5 text-primary",children:"\u2713"}),jsxRuntime.jsx("span",{children:y("predict.trade.kycModalBullet3")})]})]}),jsxRuntime.jsx("p",{className:"text-xs text-default-400",children:y("predict.trade.kycModalNote")})]}),jsxRuntime.jsxs(ui.ModalFooter,{children:[jsxRuntime.jsx(ui.Button,{variant:"light",onPress:z.onClose,children:y("common.cancel")}),L&&jsxRuntime.jsx(ui.Button,{color:"primary",onPress:()=>{window.open(L,"_blank","noopener,noreferrer"),z.onClose();},children:y("predict.trade.goToKYC")})]})]})})]})}function ht({event:e,market:t,variant:n,initialSide:o,initialOutcome:r,chain:i}){let{outcome:s,side:l,orderType:a,quantity:c,limitPrice:d,shares:u,estimatedCost:m,potentialPayout:f,potentialProfit:p,usdcBalance:g,yesTokenBalance:v,noTokenBalance:h,isBalanceLoading:H,isSubmitting:P,validation:M,supportsLimitOrder:L,kycRequired:q,kycUrl:R,expirationEnabled:ie,expirationPreset:V,customDuration:fe,customDurationUnit:Me,setOutcome:Q,setSide:J,setOrderType:le,setQuantity:he,setLimitPrice:be,setExpirationEnabled:S,setExpirationPreset:C,setCustomDuration:I,setCustomDurationUnit:y,submit:$}=en({market:t,initialSide:o,initialOutcome:r}),j=walletConnector.useAuthCallback($),z=react.useMemo(()=>e?Vr(e):void 0,[e]),Pe=react.useMemo(()=>Yr(t),[t]);return jsxRuntime.jsx(ln,{event:z,market:Pe,variant:n,outcome:s,side:l,orderType:a,quantity:c,limitPrice:d,shares:u,estimatedCost:m,potentialPayout:f,potentialProfit:p,usdcBalance:g,yesTokenBalance:v,noTokenBalance:h,isBalanceLoading:H,isSubmitting:P,isValid:M.isValid,validationErrors:M.errors,supportsLimitOrder:L,kycRequired:q,kycUrl:R,expirationEnabled:ie,expirationPreset:V,customDuration:fe,customDurationUnit:Me,onOutcomeChange:Q,onSideChange:J,onOrderTypeChange:le,onQuantityChange:he,onLimitPriceChange:be,onExpirationEnabledChange:S,onExpirationPresetChange:C,onCustomDurationChange:I,onCustomDurationUnitChange:y,onSubmit:j})}var tr="predict-trade";function dn({id:e=tr}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(sa,{...t})})}function sa({params:e,isOpen:t,onOpenChange:n}){let{isMobile:o}=ui.useScreen();return e?jsxRuntime.jsx(ui.StyledModal,{isOpen:t,onOpenChange:n,size:o?"full":"md",backdrop:"blur",radius:"lg",children:jsxRuntime.jsx(ui.ModalContent,{children:jsxRuntime.jsx(ui.ModalBody,{className:"p-4",children:jsxRuntime.jsx(ht,{event:e.event,market:e.market,initialOutcome:e.initialOutcome,initialSide:"buy",chain:e.chain,variant:"flat"})})})}):null}var rr={sortPreset:"volume",sortAsc:false,source:void 0,timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function nr(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function pn({isOpen:e,onClose:t,value:n,onChange:o}){let{t:r}=i18n.useTranslation(),[i,s]=react.useState(n),l=react.useCallback(v=>{v?s(n):t();},[n,t]),a=react.useCallback(()=>{s(rr);},[]),c=react.useCallback(()=>{o(i),t();},[i,o,t]),d=react.useCallback((v,h)=>{s(H=>({...H,[v]:h}));},[]),u=react.useMemo(()=>nr(i),[i]),m=react.useMemo(()=>[{value:void 0,label:r("predict.filter.all")},{value:"polymarket",label:r("predict.platform.polymarket")},{value:"dflow",label:r("predict.platform.dflow")}],[r]),f=react.useMemo(()=>[{value:void 0,label:r("predict.filter.all")},{value:"1d",label:r("predict.filter.lessThanDay")},{value:"7d",label:r("predict.filter.lessThanWeek")},{value:"30d",label:r("predict.filter.lessThanMonth")}],[r]),p=react.useMemo(()=>[{value:void 0,label:r("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[r]),g=react.useMemo(()=>[{value:void 0,label:r("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[r]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:l,size:"md",scrollBehavior:"inside",children:jsxRuntime.jsxs(ui.ModalContent,{children:[jsxRuntime.jsx(ui.ModalHeader,{className:"px-4 py-2",children:jsxRuntime.jsx("span",{className:"text-base font-semibold",children:r("predict.filter.title")})}),jsxRuntime.jsxs(ui.ModalBody,{className:"flex flex-col gap-5",children:[jsxRuntime.jsx(yt,{label:r("predict.filter.platform"),children:jsxRuntime.jsx(St,{options:m,selected:i.source,onSelect:v=>d("source",v)})}),jsxRuntime.jsx(yt,{label:r("predict.filter.timeRemaining"),children:jsxRuntime.jsx(St,{options:f,selected:i.timeRemaining,onSelect:v=>d("timeRemaining",v)})}),jsxRuntime.jsx(yt,{label:r("predict.filter.minVolume"),children:jsxRuntime.jsx(St,{options:p,selected:i.minVolume,onSelect:v=>d("minVolume",v)})}),jsxRuntime.jsx(yt,{label:r("predict.filter.minLiquidity"),children:jsxRuntime.jsx(St,{options:g,selected:i.minLiquidity,onSelect:v=>d("minLiquidity",v)})})]}),jsxRuntime.jsx(ui.ModalFooter,{className:"px-4",children:jsxRuntime.jsxs("div",{className:"w-full flex justify-between items-center",children:[jsxRuntime.jsx(ui.Button,{variant:"light",color:"default",size:"sm",radius:"full",startContent:jsxRuntime.jsx(ui.RefreshIcon,{width:16,height:16}),onPress:a,children:r("predict.filter.reset")}),jsxRuntime.jsxs(ui.Button,{color:"primary",size:"sm",radius:"full",onPress:c,children:[r("predict.filter.showResults"),u>0&&jsxRuntime.jsxs("span",{className:"ml-1 text-xs opacity-80",children:["(",u,")"]})]})]})})]})})}function yt({label:e,children:t}){return jsxRuntime.jsxs("div",{className:"flex flex-col gap-2.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground",children:e}),t]})}function St({options:e,selected:t,onSelect:n,allowDeselect:o=true}){return jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(r=>{let i=t===r.value;return jsxRuntime.jsx("button",{type:"button",onClick:()=>{n(i&&o?void 0:r.value);},className:ui.cn("shrink-0 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors duration-150 cursor-pointer border",i?"bg-primary/15 text-primary border-primary/40":"bg-content2 text-foreground/60 border-default-100 hover:bg-default-100 hover:text-foreground"),children:r.label},r.value??"__all")})})}var vn={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},fn={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},Pa=["start_time","volume","liquidity","ending_soon"];function xn({sortPreset:e,onSortChange:t,sortAsc:n,onSortAscChange:o,onFilterPress:r,filterCount:i=0,className:s}){let{t:l}=i18n.useTranslation(),[a,c]=react.useState(false),d=react.useRef(null);react.useEffect(()=>{if(!a)return;let m=p=>{d.current&&!d.current.contains(p.target)&&c(false);},f=p=>{p.key==="Escape"&&c(false);};return document.addEventListener("mousedown",m),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",f);}},[a]);let u=gn[e];return jsxRuntime.jsxs("div",{className:ui.cn("flex items-center gap-2",s),children:[jsxRuntime.jsxs("div",{ref:d,className:"relative flex shrink-0 items-center rounded-full border border-border",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>c(m=>!m),className:"flex shrink-0 items-center gap-2 px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsxRuntime.jsx(u,{className:"size-[18px] shrink-0"}),jsxRuntime.jsx("span",{className:"whitespace-nowrap",children:l(fn[e])})]}),jsxRuntime.jsx("div",{className:"h-6 w-px bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o(!n),className:"px-2.5 py-1.5 text-xs text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:n?"\u2191":"\u2193"}),a&&jsxRuntime.jsx("div",{className:"absolute left-0 top-full z-20 mt-1 flex min-w-max flex-col gap-0.5 rounded-lg border border-border bg-content1 p-1 shadow-lg",children:Pa.map(m=>{let f=gn[m];return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{t(m),c(false);},className:ui.cn("flex w-full items-center gap-2 rounded px-2.5 py-1.5 text-xs font-medium transition-colors cursor-pointer",m===e?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsxRuntime.jsx(f,{className:"size-4 shrink-0"}),jsxRuntime.jsx("span",{children:l(fn[m])})]},m)})})]}),jsxRuntime.jsx(ui.StyledBadge,{content:i>0?i:void 0,color:"primary",size:"sm",isInvisible:i===0,children:jsxRuntime.jsxs("button",{type:"button",onClick:r,className:"flex shrink-0 items-center gap-2 rounded-full border border-border px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsxRuntime.jsx(ui.FilterIcon,{className:"size-[18px]"}),jsxRuntime.jsx("span",{className:"whitespace-nowrap",children:l("predict.filter.title")})]})})]})}var gn={start_time:ui.CalendarIcon,volume:ui.ChartLineIcon,liquidity:ui.DropletIcon,ending_soon:ui.TimerIcon};function yn(e={}){let t=react.useMemo(()=>reactPredict.resolveEventsParams(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets,e.minVolume,e.minLiquidity,e.timeRemaining]),{data:n,isLoading:o,isFetching:r,isFetchingNextPage:i,isError:s,error:l,hasNextPage:a,fetchNextPage:c,refetch:d}=reactPredict.useInfiniteEvents(t),u=react.useMemo(()=>n?.pages.flatMap(p=>p.items).filter(p=>p!=null)??[],[n]),m=react.useCallback(()=>{c();},[c]),f=react.useCallback(()=>{d();},[d]);return {data:u,isLoading:o,isFetching:r&&!i,isFetchingMore:i,isError:s,error:l??null,hasMore:a??false,fetchMore:m,refetch:f}}function or({count:e=6}){return jsxRuntime.jsx("div",{className:"grid w-full grid-cols-1 gap-0 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:Array.from({length:e}).map((t,n)=>jsxRuntime.jsx("div",{className:"p-2",children:jsxRuntime.jsxs("div",{className:"flex h-full min-h-52 flex-col rounded-xl border border-border/90 bg-background p-3 lg:min-h-72 lg:p-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"size-10 shrink-0 rounded-lg"}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-1",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-11/12 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-2/5 rounded"})]})]}),jsxRuntime.jsxs("div",{className:"mt-3 flex flex-1 flex-col gap-2 lg:gap-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-1/2 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-3/5 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-2/5 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-[85px] rounded-lg lg:h-9 lg:w-24"})]})]}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-20 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-24 rounded"})]})]})},n))})}function vu({count:e=48}){return jsxRuntime.jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsxRuntime.jsxs("div",{className:"flex min-h-8 items-center justify-between gap-3 lg:min-h-9",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-20 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-20 rounded"})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-28 rounded-full"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-24 rounded-full"})]})]}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(or,{count:e})})]})}var Sn=3,ar={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},Cn={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},_a={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},et=[{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 Nn(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function Da(e){let t=e.outcomes?.map(s=>s.label?.toLowerCase().trim()??"")??[];if(t.some(s=>s==="up")&&t.some(s=>s==="down"))return [ar,_a];if(t.some(s=>s==="yes")&&t.some(s=>s==="no"))return [ar,Cn];let n=t[0]??"",o=t[1]??"",r=Nn(n)%et.length,i=Nn(o)%et.length;return i===r&&(i=(i+1)%et.length),[et[r],et[i]]}function Aa(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function Tn(e){let t=Aa(e);return t!=null?parseFloat((t*100).toFixed(2)):0}function Mn(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function wn(e){let t=e.outcomes?.[0],n=t?.best_ask??t?.price??0;return parseFloat((n*100).toFixed(2)).toString()}function kn(e){let t=e.outcomes?.[1];if(t){let r=t.best_ask??t.price??0;return parseFloat((r*100).toFixed(2)).toString()}let n=e.outcomes?.[0],o=n?.best_ask??n?.price??0;return parseFloat(((1-o)*100).toFixed(2)).toString()}function Fa(e){let t=new Date(e).getTime()-Date.now();if(t<=0)return null;let n=Math.floor(t/864e5),o=Math.floor(t%864e5/36e5),r=Math.floor(t%36e5/6e4),i=[];return n>0&&i.push(`${n}d`),o>0&&i.push(`${o}h`),i.push(`${r}m`),i.join(" ")}var Ba=`
2
2
  .badge-shine { position: relative; overflow: hidden; }
3
3
  .badge-shine::after {
4
4
  content: "";
@@ -16,7 +16,7 @@
16
16
  60% { transform: translate(200%); }
17
17
  100% { transform: translate(200%); }
18
18
  }
19
- `;function bn({event:e,href:t,LinkComponent:n,onSelect:o,onSelectOutcome:r,onHover:i}){let[s,l]=react.useState(null),a=e.markets??[],c=react.useMemo(()=>a.length>2?[...a].sort((C,R)=>(R.outcomes?.[0]?.price??0)-(C.outcomes?.[0]?.price??0)):a,[a]),d=c.filter(C=>C.status==="open"),u=c.length===1,m=d.slice(0,dn),f=d.length-dn,p=react.useMemo(()=>`$${Math.round(e.volume??0).toLocaleString("en-US")}`,[e.volume]),g=s?d.find(C=>C.slug===s)??null:null,v=!!g||u,h=()=>{v||o?.(e);},U=C=>{C.stopPropagation(),g&&(C.preventDefault(),l(null));},P=C=>{C.stopPropagation(),t||(C.preventDefault(),o?.(e));};return jsxRuntime.jsxs("div",{className:ui.cn("group flex h-full w-full flex-col rounded-xl","min-h-52 border border-border/90 bg-background p-3","lg:min-h-72 lg:max-w-md lg:p-4","gap-y-1.5 lg:gap-y-4","transition duration-300","hover:border-primary/40 hover:shadow-card-glow","focus-within:border-primary/40 focus-within:shadow-card-glow",!v&&"cursor-pointer"),onMouseEnter:()=>i?.(e),onClick:h,children:[jsxRuntime.jsx("style",{children:wa}),jsxRuntime.jsx(Sa,{event:e,href:t,LinkComponent:n,onClick:U,isExpanded:v}),jsxRuntime.jsx("div",{className:"flex flex-1 flex-col",children:u?jsxRuntime.jsx(Ra,{market:d[0],event:e,formattedVolume:p,href:t,LinkComponent:n,onSelect:o,onSelectOutcome:r}):g?jsxRuntime.jsx(La,{market:g,event:e,onCollapse:()=>l(null),onSelectOutcome:r}):jsxRuntime.jsx(Ta,{displayedMarkets:m,moreCount:f,formattedVolume:p,source:e.source,href:t,LinkComponent:n,onMarketClick:C=>l(C.slug),onShowMore:P})})]})}function Sa({event:e,href:t,LinkComponent:n,onClick:o,isExpanded:r}){let i=e.start_at?ya(e.start_at):null;return jsxRuntime.jsxs(ui.Linkable,{href:t,LinkComponent:n,as:"button",className:"group/header flex items-center gap-x-2 lg:gap-x-4 w-full text-left cursor-pointer",onClick:o,children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsxRuntime.jsx("p",{className:ui.cn("min-w-0 text-sm font-semibold leading-snug text-slate-200 line-clamp-2 lg:text-base",r&&"group-hover/header:text-neutral-400"),children:e.title}),i&&jsxRuntime.jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",i]})]}),jsxRuntime.jsx(ka,{event:e})]})}function Na(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let n=e.tags?.some(r=>r.label?.toLowerCase()==="crypto"),o=e.tags?.some(r=>r.label?.toLowerCase()==="live");if(n&&e.end_at){let r=new Date(e.end_at).getTime()-Date.now(),i=300*1e3,s=900*1e3;if(r>0&&r<=s){let l=r<=i?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:r<=i?"5m":"15m",color:l});}}return o&&t.push({kind:"live"}),t.slice(0,2)}function ka({event:e}){let t=react.useMemo(()=>Na(e),[e]);return t.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:t.map((n,o)=>{switch(n.kind){case "live":return jsxRuntime.jsx(Pa,{},o);case "crypto-short":return jsxRuntime.jsx(Ea,{label:n.label,color:n.color},o);case "closed":return jsxRuntime.jsx(Ca,{},o)}})})}function Pa(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md bg-[rgb(240,68,56)]/10 px-1.5 py-0.5 text-xs font-semibold text-[rgb(240,68,56)]",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-current"}),e("predict.event.status.live")]})}function Ea({label:e,color:t}){return jsxRuntime.jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{backgroundColor:`${t}26`,color:t},children:[jsxRuntime.jsx(ui.TimerIcon,{className:"size-3 shrink-0"}),e]})}function Ca(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsx("span",{className:"inline-flex items-center rounded-md bg-neutral-800/80 px-1.5 py-0.5 text-xs font-semibold text-neutral-400",children:e("predict.event.status.closed")})}function Ta({displayedMarkets:e,moreCount:t,formattedVolume:n,source:o,href:r,LinkComponent:i,onMarketClick:s,onShowMore:l}){let{t:a}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e.length>0&&jsxRuntime.jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(c=>{let d=xn(c);return jsxRuntime.jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:u=>{u.stopPropagation(),s(c);},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:c.outcomes?.[0]?.label??c.question}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:hn(d)}),jsxRuntime.jsx(Ma,{})]})]},c.slug)})}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[t>0?jsxRuntime.jsxs(ui.Linkable,{href:r,LinkComponent:i,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:l,children:[a("predict.event.showMore"),jsxRuntime.jsx(wn,{className:"h-3 w-3"})]}):jsxRuntime.jsx("div",{}),jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1.5 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[n," ",a("predict.event.volume"),jsxRuntime.jsx(Sn,{source:o})]})]})]})}function fn({bgColor:e,textColor:t,shadowColor:n,onClick:o,children:r}){return jsxRuntime.jsx("button",{type:"button",className:"flex h-12 flex-1 w-full items-center justify-center gap-x-1 overflow-hidden rounded-lg p-3 text-base font-normal hover:cursor-pointer will-change-transform [-webkit-tap-highlight-color:transparent]",style:{backgroundColor:e,color:t,"--shadow-color":n,"--shadow-offset":"4px",boxShadow:"inset 0 -1px 0 rgba(255,255,255,0.08), 0 var(--shadow-offset, 4px) 0 var(--shadow-color, rgba(0,0,0,0.22))",transition:"transform .12s, box-shadow .12s, opacity .14s"},onMouseEnter:l=>{let a=l.currentTarget;a.style.setProperty("--shadow-offset","2px"),a.style.transform="translateY(2px)";},onMouseLeave:l=>{let a=l.currentTarget;a.style.setProperty("--shadow-offset","4px"),a.style.transform="translateY(0px)";},onClick:o,children:r})}function yn({market:e,event:t,onSelectOutcome:n,dynamicColors:o=false,labelFormat:r="action"}){let{t:i}=i18n.useTranslation(),[s,l]=o?ha(e):[Qt,vn],a=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",c=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",d=r==="label"&&a===c?"action":r,u=d==="label"?`${e.outcomes?.[0]?.label??"Yes"} ${pn(e)}\xA2`:i("predict.market.action.yes",{price:pn(e)}),m=d==="label"?`${e.outcomes?.[1]?.label??"No"} ${mn(e)}\xA2`:i("predict.market.action.no",{price:mn(e)});return jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx(fn,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:f=>{f.stopPropagation(),n?.(t,e,"yes");},children:u}),jsxRuntime.jsx(fn,{bgColor:l.bg,textColor:l.text,shadowColor:l.shadow,onClick:f=>{f.stopPropagation(),n?.(t,e,"no");},children:m})]})}function Ma(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("span",{className:"inline-flex h-7 w-[85px] items-center justify-center gap-x-3 rounded-lg p-1.5 text-xs font-semibold flex-shrink-0 bg-gradient-to-r from-primary/15 to-secondary/15 lg:h-9 lg:w-24 lg:gap-x-4 lg:p-2 lg:text-sm",children:[jsxRuntime.jsx("span",{className:"text-primary",children:e("predict.market.yes")}),jsxRuntime.jsx("span",{className:"text-neutral-400",children:"/"}),jsxRuntime.jsx("span",{className:"text-secondary",children:e("predict.market.no")})]})}function Ra({market:e,event:t,formattedVolume:n,href:o,LinkComponent:r,onSelect:i,onSelectOutcome:s}){let{t:l}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex-1",children:jsxRuntime.jsx(yn,{market:e,event:t,onSelectOutcome:s,dynamicColors:true,labelFormat:"label"})}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[jsxRuntime.jsxs(ui.Linkable,{href:o,LinkComponent:r,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:c=>{c.stopPropagation(),o||(c.preventDefault(),i?.(t));},children:[l("predict.event.viewEvent"),jsxRuntime.jsx(wn,{className:"h-3 w-3"})]}),jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1.5 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[n," ",l("predict.event.volume"),jsxRuntime.jsx(Sn,{source:t.source})]})]})]})}function La({market:e,event:t,onCollapse:n,onSelectOutcome:o}){let{t:r}=i18n.useTranslation(),i=xn(e);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:s=>{s.stopPropagation(),n();},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 lg:text-sm",children:e.outcomes?.[0]?.label??e.question}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:hn(i)}),jsxRuntime.jsx(ui.ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsxRuntime.jsx("div",{className:"mt-3",children:jsxRuntime.jsx(yn,{market:e,event:t,onSelectOutcome:o,labelFormat:"action"})})]}),jsxRuntime.jsxs("button",{type:"button",className:"mt-auto flex items-center gap-x-1 pt-4 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:s=>{s.stopPropagation(),n();},children:[jsxRuntime.jsx(Oa,{className:"h-3 w-3"}),r("predict.event.back")]})]})}function wn({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsxRuntime.jsx("path",{d:"M4.5 2.5L8 6l-3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Oa({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsxRuntime.jsx("path",{d:"M7.5 2.5L4 6l3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Sn({source:e}){return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsxRuntime.jsx(ui.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var Ba=768,kn=1024,Ha=1280,Ua=8,$a=224,Wa=304,za=114;function Ka(e){return e>=Ha?4:e>=kn?3:e>=Ba?2:1}function Va(e){return e>=kn?Wa:$a}function Pn({events:e,hasMore:t=false,onFetchMore:n,onSelect:o,onSelectOutcome:r,getEventHref:i,LinkComponent:s,onHover:l}){let a=react.useRef(null),c=react.useRef(null),{width:d=0,height:u=0}=hooks.useResizeObserver({ref:a}),m=Ka(d),f=Va(d),p=Math.ceil(e.length/m)||0,g=!t&&e.length>0,v=p+(t?1:0)+(g?1:0),h=react.useCallback(R=>R<p,[p]),U=react.useCallback(async()=>{n?.();},[n]),P=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:h,loadMoreRows:U,rowCount:v,threshold:3}),C=react.useCallback(()=>{c.current?.scrollToRow({index:0,behavior:"smooth"});},[]);return jsxRuntime.jsx("div",{ref:a,className:"@container w-full h-full",children:u>0&&jsxRuntime.jsx(reactWindow.List,{listRef:c,className:"no-scrollbar",style:{height:u},onRowsRendered:P,rowComponent:Ya,rowCount:v,rowHeight:R=>g&&R===v-1?za:(f),rowProps:{events:e,columnCount:m,dataRowCount:p,showEndOfList:g,totalRowCount:v,onSelect:o,onSelectOutcome:r,getEventHref:i,LinkComponent:s,onHover:l,onScrollToTop:C}})})}function Ya({index:e,style:t,events:n,columnCount:o,dataRowCount:r,showEndOfList:i,totalRowCount:s,onSelect:l,onSelectOutcome:a,getEventHref:c,LinkComponent:d,onHover:u,onScrollToTop:m}){if(i&&e===s-1)return jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(qa,{onScrollToTop:m})});if(e>=r)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-start pt-4",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})});let f=e*o,p=n.slice(f,f+o),g=o-p.length;return jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsxs("div",{className:"flex w-full h-full",children:[p.map(v=>v==null?null:jsxRuntime.jsx("div",{className:"flex-1 min-w-0 flex",style:{padding:Ua},children:jsxRuntime.jsx(bn,{event:v,href:c?.(v),LinkComponent:d,onSelect:l,onSelectOutcome:a,onHover:u})},v.slug)),g>0&&Array.from({length:g}).map((v,h)=>jsxRuntime.jsx("div",{style:{flex:1,minWidth:0}},`spacer-${h}`))]})})}function qa({onScrollToTop:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"flex w-full flex-col items-center justify-center gap-y-4 py-6",children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center justify-center gap-x-4",children:[jsxRuntime.jsx("div",{className:"h-px w-16 bg-neutral-700"}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-neutral-500",children:t("predict.event.endOfList")}),jsxRuntime.jsx("div",{className:"h-px w-16 bg-neutral-700"})]}),jsxRuntime.jsxs("button",{type:"button",className:"flex cursor-pointer items-center gap-x-1 text-xs font-medium text-neutral-400",onClick:e,children:[jsxRuntime.jsx("span",{className:"iconify size-4 ph--arrow-up-bold"}),jsxRuntime.jsx("span",{children:t("predict.event.backToTop")})]})]})}function Cn({tagSlugSelection:e,limit:t=48,status:n,sort_by:o,sort_asc:r,source:i,with_markets:s,timeRemaining:l,minVolume:a,minLiquidity:c,onSelect:d,onSelectOutcome:u,getEventHref:m,LinkComponent:f,onHover:p}){let{data:g,hasMore:v,fetchMore:h,isFetching:U}=cn({tagSlugSelection:e,limit:t,status:n,sort_by:o,sort_asc:r,source:i,with_markets:s,timeRemaining:l,minVolume:a,minLiquidity:c});return U?jsxRuntime.jsx(Gt,{count:48}):jsxRuntime.jsx(Pn,{events:g,hasMore:v,onFetchMore:h,onSelect:d,onSelectOutcome:u,getEventHref:m,LinkComponent:f,onHover:p})}function Ru({onSelect:e,onSelectOutcome:t,getEventHref:n,LinkComponent:o,onHover:r}){let[i,s]=react.useState({categorySlug:null,tagSlug:null}),[l,a]=react.useState(qt),{isOpen:c,onOpen:d,onClose:u}=ui.useDisclosure(),{onOpen:m}=uiScaffold.useAsyncModal(Yt),f=react.useCallback((R,j,M)=>{t?.(R,j,M),m({params:{event:R,market:j,initialOutcome:M}});},[t,m]),p=react.useCallback(R=>{s(R);},[]),g=react.useCallback(R=>{a(j=>({...j,sortPreset:R}));},[]),v=react.useCallback(R=>{a(j=>({...j,sortAsc:R}));},[]),h=react.useCallback(R=>{a(R);},[]),U=react.useMemo(()=>on[l.sortPreset].sort_by,[l.sortPreset]),P=react.useMemo(()=>jt(l),[l]),C=react.useMemo(()=>jsxRuntime.jsx(sn,{sortPreset:l.sortPreset,onSortChange:g,sortAsc:l.sortAsc,onSortAscChange:v,onFilterPress:d,filterCount:P}),[l.sortPreset,l.sortAsc,P,g,v,d]);return jsxRuntime.jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsxRuntime.jsx(Ar,{onSelect:p,trailing:C}),jsxRuntime.jsx(en,{isOpen:c,onClose:u,value:l,onChange:h}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(Cn,{tagSlugSelection:i,sort_by:U,sort_asc:l.sortAsc,source:l.source,timeRemaining:l.timeRemaining,minVolume:l.minVolume,minLiquidity:l.minLiquidity,onSelect:e,onSelectOutcome:f,getEventHref:n,LinkComponent:o,onHover:r})}),jsxRuntime.jsx(Jr,{})]})}var or=40,yt=36,Ze=480,sr=Ze-yt;function Ln({event:e,walletAddress:t,onCancelOrder:n}){let{t:o}=i18n.useTranslation(),[r,i]=react.useState("positions"),s=react.useMemo(()=>e.markets?.map(u=>u.slug)??[],[e.markets]),{data:l}=reactPredict.usePositions({source:e.source,user:t??""}),a=react.useMemo(()=>!l?.positions||!t?0:s.length===0?l.positions.length:l.positions.filter(u=>u.market&&s.includes(u.market.slug)).length,[l?.positions,s,t]),d=[{key:"positions",label:a>0?`${o("predict.positions.title")} (${a})`:o("predict.positions.title")},{key:"orders",label:o("predict.openOrders.title")},{key:"trades",label:o("predict.tradeHistory.title")}];return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:d.map(u=>jsxRuntime.jsx("button",{type:"button",onClick:()=>i(u.key),className:ui.cn("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",r===u.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:u.label},u.key))}),t?jsxRuntime.jsxs("div",{style:{height:Ze},children:[r==="positions"&&jsxRuntime.jsx(ri,{source:e.source,walletAddress:t,marketSlugs:s}),r==="orders"&&jsxRuntime.jsx(oi,{source:e.source,walletAddress:t,marketSlugs:s,onCancelOrder:n}),r==="trades"&&jsxRuntime.jsx(ii,{source:e.source,walletAddress:t})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:Ze},children:o("predict.trade.connectWallet")})]})}function ri({source:e,walletAddress:t,marketSlugs:n}){let{t:o}=i18n.useTranslation(),{data:r,isLoading:i}=reactPredict.usePositions({source:e,user:t}),s=react.useMemo(()=>r?.positions?n.length===0?r.positions:r.positions.filter(l=>l.market&&n.includes(l.market.slug)):[],[r?.positions,n]);return i?jsxRuntime.jsx(ir,{}):s.length===0?jsxRuntime.jsx(ar,{message:o("predict.positions.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:yt},children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2 whitespace-nowrap",children:o("predict.positions.event")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.totalSize")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.value")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.avgPrice")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.markPrice")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.pnl")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.payoutIfRight")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.estSettlement")}),jsxRuntime.jsx("div",{className:"w-16 shrink-0"})]}),jsxRuntime.jsx(reactWindow.List,{style:{height:sr},rowComponent:ni,rowCount:s.length,rowHeight:or,rowProps:{positions:s,closeLabel:o("predict.positions.close")}})]})}function ni({index:e,style:t,positions:n,closeLabel:o}){let r=n[e];if(!r)return null;let i=r.pnl??0,s=r.pnl_percent??0,l=r.avg_price??0,a=r.current_price??0,c=i>0?"text-success":i<0?"text-danger":"text-foreground",d=i>0?"+":"",u=r.market?.outcomes?.[0]?.label??r.market?.question??"\u2014",m=r.side,f=r.size,p=r.size*a,g=r.market?.end_at?di(r.market.end_at):"\u2014";return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate font-medium",children:u}),jsxRuntime.jsx("span",{className:ui.cn("text-[10px] font-medium",m.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:m})]})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:r.size}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",p.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:ht(l)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:ht(a)}),jsxRuntime.jsxs("div",{className:ui.cn("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",c),children:[d,"$",Math.abs(i).toFixed(2),jsxRuntime.jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",d,s.toFixed(1),"%)"]})]}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",f.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:g}),jsxRuntime.jsx("div",{className:"w-16 shrink-0 text-right",children:jsxRuntime.jsx("button",{type:"button",className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors rounded px-2 py-0.5 border border-border hover:border-foreground/40",children:o})})]})}function oi({source:e,walletAddress:t,marketSlugs:n,onCancelOrder:o}){let{t:r}=i18n.useTranslation(),{data:i,isLoading:s,fetchNextPage:l,hasNextPage:a}=reactPredict.useInfiniteOrders({source:e,wallet_address:t}),c=reactPredict.useCancelOrder(),d=react.useMemo(()=>{let h=i?.pages?.flatMap(C=>C.items)??[],U=new Set(["live","open","submitted","pending"]),P=h.filter(C=>U.has(C.status));return n.length>0&&(P=P.filter(C=>C.market_id&&n.includes(C.market_id))),P},[i?.pages,n]),u=react.useCallback(h=>{o?o(h.id):c.mutate({source:h.source,id:h.id});},[o,c]),m=d.length,f=m+(a?1:0),p=react.useCallback(h=>h<m,[m]),g=react.useCallback(async()=>{await l();},[l]),v=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:p,loadMoreRows:g,rowCount:f,threshold:5});return s?jsxRuntime.jsx(ir,{}):d.length===0&&!a?jsxRuntime.jsx(ar,{message:r("predict.openOrders.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:yt},children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:r("predict.openOrders.side")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:r("predict.openOrders.outcome")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:r("predict.openOrders.type")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.openOrders.price")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.openOrders.filled")}),jsxRuntime.jsx("div",{className:"w-20 shrink-0 pr-2",children:r("predict.openOrders.status")}),jsxRuntime.jsx("div",{className:"w-16 shrink-0"})]}),jsxRuntime.jsx(reactWindow.List,{style:{height:sr},onRowsRendered:v,rowComponent:si,rowCount:f,rowHeight:or,rowProps:{orders:d,itemCount:m,onCancel:u,isCancelling:c.isPending,cancelLabel:r("predict.openOrders.cancel")}})]})}function si({index:e,style:t,orders:n,itemCount:o,onCancel:r,isCancelling:i,cancelLabel:s}){if(e>=o)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})});let l=n[e];if(!l)return null;let a=l.side==="BUY";return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",a?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:l.side})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:l.outcome??"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:l.order_type??"limit"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:l.price?ht(parseFloat(l.price)):"\u2014"}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[l.size_matched??"0","/",l.original_size??"\u2014"]}),jsxRuntime.jsx("div",{className:"w-20 shrink-0 pr-2",children:jsxRuntime.jsx(ai,{status:l.status})}),jsxRuntime.jsx("div",{className:"w-16 shrink-0 text-right",children:jsxRuntime.jsx("button",{type:"button",onClick:()=>r(l),disabled:i,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:i?jsxRuntime.jsx(ui.Spinner,{size:"sm"}):s})})]})}function ai({status:e}){return jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium capitalize",{live:"bg-success/10 text-success",open:"bg-success/10 text-success",submitted:"bg-warning/10 text-warning",pending:"bg-warning/10 text-warning",matched:"bg-primary/10 text-primary",cancelled:"bg-neutral/10 text-neutral",failed:"bg-danger/10 text-danger",expired:"bg-neutral/10 text-neutral"}[e]??"bg-neutral/10 text-neutral"),children:e})}function ii({source:e,walletAddress:t}){let{t:n}=i18n.useTranslation(),{data:o,isLoading:r,fetchNextPage:i,hasNextPage:s}=reactPredict.useInfiniteTrades({source:e,wallet:t,limit:50}),l=react.useMemo(()=>o?.pages?.flatMap(f=>f.items)??[],[o?.pages]),a=l.length,c=a+(s?1:0),d=react.useCallback(f=>f<a,[a]),u=react.useCallback(async()=>{await i();},[i]),m=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:d,loadMoreRows:u,rowCount:c,threshold:5});return r?jsxRuntime.jsx(ir,{}):l.length===0&&!s?jsxRuntime.jsx(ar,{message:n("predict.tradeHistory.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:yt},children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:n("predict.tradeHistory.side")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:n("predict.tradeHistory.outcome")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.tradeHistory.price")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.tradeHistory.qty")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.tradeHistory.total")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right",children:n("predict.tradeHistory.time")})]}),jsxRuntime.jsx(reactWindow.List,{style:{height:sr},onRowsRendered:m,rowComponent:li,rowCount:c,rowHeight:or,rowProps:{trades:l,itemCount:a}})]})}function li({index:e,style:t,trades:n,itemCount:o}){if(e>=o)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})});let r=n[e];if(!r)return null;let i=r.side?.toUpperCase()==="BUY",s=ci(r.timestamp),l=r.price??0,a=r.usd_size??0;return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",i?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:r.side})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:r.outcome??"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:ht(l)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:r.size}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",a.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:s})]})}function ar({message:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:Ze},children:e})}function ir(){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:Ze},children:Array.from({length:6}).map((e,t)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-full rounded-md"},t))})}function ht(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function ci(e){let t=new Date(e*1e3),n=(t.getMonth()+1).toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),r=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${n}/${o} ${r}:${i}`}function di(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}function et({marketCount:e=4,showBack:t}){return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-4 animate-pulse lg:gap-6",children:[t&&jsxRuntime.jsx("div",{className:"h-5"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 h-16 lg:h-20 lg:gap-x-4",children:[jsxRuntime.jsx(ui.Skeleton,{className:"size-16 shrink-0 rounded-lg lg:size-20"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-12 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-10 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-10 rounded"})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-5 w-full max-w-sm rounded lg:h-6"})]})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-48 rounded"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-24 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-20 rounded"})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-[300px] w-full rounded-xl"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-20 rounded"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-[200px] rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-28 rounded-lg"})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"flex items-center py-2",children:[jsxRuntime.jsx("div",{className:"flex-1"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-14 rounded"}),jsxRuntime.jsx("div",{className:"flex-1"})]}),Array.from({length:e}).map((n,o)=>jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 border-b border-border py-2.5 lg:gap-x-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"size-5 shrink-0 rounded-lg lg:size-8"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-32 rounded lg:h-4 lg:w-48"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-2.5 w-16 rounded"})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-10 rounded"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-16 rounded-lg lg:w-24"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-16 rounded-lg lg:w-24"})]})]},o))]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-16 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-full rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-4/5 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-3/5 rounded"})]})]})}function On(){return jsxRuntime.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-border p-4 animate-pulse",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-10 w-full rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-24 w-full rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-10 w-full rounded-lg"})]})}var Dn="var(--color-bullish)",Fn="var(--color-bearish)";function tt(e){let t=Math.abs(e);return t>=1e9?`${parseFloat((e/1e9).toFixed(2))}B`:t>=1e6?`${parseFloat((e/1e6).toFixed(2))}M`:t>=1e3?`${parseFloat((e/1e3).toFixed(2))}K`:e.toLocaleString()}function mi(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function fi(e,t){let n=new Float64Array(101),o=new Float64Array(101);for(let f of e){let p=Math.round(f.price*100);p>=0&&p<=100&&(n[p]+=f.quantity);}for(let f of t){let p=Math.round(f.price*100);p>=0&&p<=100&&(o[p]+=f.quantity);}let r=0,i=0,s=new Float64Array(101),l=new Float64Array(101);for(let f=100;f>=0;f--)r+=n[f],i+=n[f]*f/100,s[f]=r,l[f]=i;let a=0,c=0,d=new Float64Array(101),u=new Float64Array(101);for(let f=0;f<=100;f++)a+=o[f],c+=o[f]*f/100,d[f]=a,u[f]=c;let m=Math.max(s[0]??0,d[100]??0);return Array.from({length:101},(f,p)=>{let g=s[p]>0,v=d[p]>0,h=s[p]||d[p],U=n[p]>0||o[p]>0;return {priceCents:p,displayHeight:mi(h,m),opacity:h>0?U?1:.5:0,isBid:g,isAsk:v,bidCumTotal:s[p],askCumTotal:d[p],bidCumCost:l[p],askCumCost:u[p]}})}function gi({info:e}){let{t}=i18n.useTranslation(),n=e.isBid?Dn:Fn,o=e.leftPct>65?void 0:`${e.leftPct}%`,r=e.leftPct>65?`${100-e.leftPct}%`:void 0;return jsxRuntime.jsxs("div",{style:{position:"absolute",top:8,left:o,right:r,zIndex:10,background:"rgba(17,24,39,0.95)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:8,padding:"8px 12px",fontSize:12,color:"#f9fafb",minWidth:140,pointerEvents:"none"},children:[jsxRuntime.jsx("div",{style:{marginBottom:4,fontWeight:600},children:t("predict.orderBook.depthToPrice",{price:e.priceCents})}),jsxRuntime.jsx("div",{style:{color:n},children:t("predict.orderBook.depthContracts",{amount:tt(Math.round(e.cumTotal))})}),jsxRuntime.jsxs("div",{style:{color:n},children:["$",tt(Math.round(e.cumCost))]})]})}var vi=react.memo(function({slot:t,onEnter:n,onLeave:o}){let r=react.useRef(null),i=t.isBid||t.isAsk,s=t.isBid?Dn:t.isAsk?Fn:void 0;return jsxRuntime.jsx("div",{style:{position:"absolute",left:`${t.priceCents}%`,width:"1%",height:"100%",boxSizing:"border-box",borderRight:t.priceCents<100?"1px solid transparent":"none",cursor:i?"crosshair":"default"},onMouseEnter:()=>n(t,r.current),onMouseLeave:o,children:i&&jsxRuntime.jsx("div",{ref:r,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:s,opacity:t.opacity}})})}),xi=[0,10,20,30,40,50,60,70,80,90,100];function hi(){return jsxRuntime.jsx("div",{className:"relative flex h-6 items-center border-b border-t border-border px-1",style:{background:"rgba(0,0,0,0.15)"},children:xi.map(e=>jsxRuntime.jsx("span",{className:"absolute text-neutral font-normal",style:{fontSize:10,left:`${e}%`,transform:e===0?"translateX(0px)":e===100?"translateX(-100%)":"translateX(-50%)"},children:e},e))})}function Bn({bids:e,asks:t}){let{t:n}=i18n.useTranslation(),o=react.useMemo(()=>fi(e,t),[e,t]),r=react.useMemo(()=>{let u=e.length>0?Math.max(...e.map(f=>f.price)):0,m=t.length>0?Math.min(...t.map(f=>f.price)):1;return Math.round((u+m)/2*100)},[e,t]),i=react.useMemo(()=>o.some(u=>u.isBid||u.isAsk),[o]),[s,l]=react.useState(null),a=react.useRef(null),c=react.useCallback((u,m)=>{a.current&&(a.current.style.filter=""),m?(m.style.filter="brightness(1.5)",a.current=m):a.current=null,u.isBid||u.isAsk?l({priceCents:u.priceCents,isBid:u.isBid,cumTotal:u.isBid?u.bidCumTotal:u.askCumTotal,cumCost:u.isBid?u.bidCumCost:u.askCumCost,leftPct:u.priceCents}):l(null);},[]),d=react.useCallback(()=>{a.current&&(a.current.style.filter="",a.current=null),l(null);},[]);return i?jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxRuntime.jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[r>0&&jsxRuntime.jsx("div",{style:{position:"absolute",left:`${r}%`,top:0,bottom:0,width:1,backgroundImage:"repeating-linear-gradient(to bottom, #6b7280 0, #6b7280 4px, transparent 4px, transparent 8px)",zIndex:1,pointerEvents:"none"}}),s&&jsxRuntime.jsx(gi,{info:s}),o.map(u=>jsxRuntime.jsx(vi,{slot:u,onEnter:c,onLeave:d},u.priceCents))]}),jsxRuntime.jsx(hi,{})]}):jsxRuntime.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:n("predict.orderBook.noData")})}function cr(e){let t=e*100,n=Math.round(t*10)/10;return Number.isInteger(n)?`${n}\xA2`:`${n.toFixed(1)}\xA2`}function Hn(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"flex items-center justify-center gap-x-2 h-full text-neutral text-xs",children:[jsxRuntime.jsx(ui.Spinner,{size:"sm"}),jsxRuntime.jsx("span",{children:e("predict.orderBook.loading")})]})}function zn({market:e,outcome:t="yes",onTradeAction:n}){let{t:o}=i18n.useTranslation(),[r,i]=react.useState("depth"),s=t==="no",l=e.source,{data:a,isLoading:c}=reactPredict.useOrderbook({slug:e.slug,source:l}),d=react.useMemo(()=>((s?a?.asks:a?.bids)??[]).map(v=>({price:s?1-v.price:v.price,quantity:v.size})),[a?.bids,a?.asks,s]),u=react.useMemo(()=>((s?a?.bids:a?.asks)??[]).map(v=>({price:s?1-v.price:v.price,quantity:v.size})),[a?.bids,a?.asks,s]),m=react.useMemo(()=>d.length>0?Math.max(...d.map(g=>g.price)):null,[d]),f=react.useMemo(()=>u.length>0?Math.min(...u.map(g=>g.price)):null,[u]),p=react.useMemo(()=>{if(m==null||f==null)return null;let g=(f-m)*100;return Math.round(g*10)/10},[m,f]);return jsxRuntime.jsxs("div",{className:"flex flex-col h-[262px]",children:[jsxRuntime.jsxs("div",{className:"flex h-9 items-center border-b border-border px-1 text-xs",children:[jsxRuntime.jsx("span",{className:"flex-1 text-left text-neutral",children:p!=null?`${o("predict.orderBook.spread")}: ${Number.isInteger(p)?`${p}\xA2`:`${p.toFixed(1)}\xA2`}`:null}),jsxRuntime.jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[m!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bullish)"},children:[o("predict.trade.bestBid"),": ",cr(m)]}),m!=null&&f!=null&&jsxRuntime.jsx("span",{className:"text-neutral",children:"|"}),f!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bearish)"},children:[o("predict.trade.bestAsk"),": ",cr(f)]})]}),jsxRuntime.jsx("div",{className:"flex flex-1 justify-end",children:jsxRuntime.jsx("button",{type:"button",title:r==="depth"?"Orderbook":"Depth chart",onClick:()=>i(g=>g==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:r==="depth"?jsxRuntime.jsx(ui.OrderbookTableIcon,{className:"h-4 w-4"}):jsxRuntime.jsx(ui.OrderbookDepthIcon,{className:"h-4 w-4"})})})]}),jsxRuntime.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden",children:[r==="depth"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:c?jsxRuntime.jsx(Hn,{}):jsxRuntime.jsx(Bn,{bids:d,asks:u})}),r==="table"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:c?jsxRuntime.jsx(Hn,{}):jsxRuntime.jsx(ki,{bids:d,asks:u,bestBid:m??void 0,bestAsk:f??void 0,spread:p??void 0})})]})]})}var Un=8;function ki({bids:e,asks:t,spread:n}){let{t:o}=i18n.useTranslation(),r=react.useMemo(()=>[...t].sort((a,c)=>a.price-c.price).slice(0,Un).reverse(),[t]),i=react.useMemo(()=>[...e].sort((a,c)=>c.price-a.price).slice(0,Un),[e]),s=react.useMemo(()=>{let a=[...r,...i].map(c=>c.quantity);return Math.max(...a,1)},[r,i]);return r.length===0&&i.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:o("predict.orderBook.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[r.map(a=>jsxRuntime.jsx($n,{price:a.price,quantity:a.quantity,side:"ask",maxQty:s},`ask-${a.price}`)),jsxRuntime.jsx("div",{className:"flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:n!=null&&jsxRuntime.jsxs("span",{children:[o("predict.orderBook.spread"),":"," ",Number.isInteger(n)?`${n}\xA2`:`${n.toFixed(1)}\xA2`]})}),i.map(a=>jsxRuntime.jsx($n,{price:a.price,quantity:a.quantity,side:"bid",maxQty:s},`bid-${a.price}`)),jsxRuntime.jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-neutral border-t border-border",children:[jsxRuntime.jsx("span",{children:o("predict.orderBook.price")}),jsxRuntime.jsx("span",{className:"text-center",children:o("predict.orderBook.contracts")}),jsxRuntime.jsx("span",{className:"text-right",children:o("predict.orderBook.total")})]})]})}function $n({price:e,quantity:t,side:n,maxQty:o}){let r=n==="ask",i=Math.min(t/o*100,100),s=r?"bg-bearish/10":"bg-bullish/10",l=r?"text-bearish":"text-bullish",a=tt(Math.round(t)),c=Math.round(t*e),d=`$${tt(c)}`;return jsxRuntime.jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsxRuntime.jsx("div",{className:`absolute inset-y-0 left-0 ${s} transition-[width] duration-200`,style:{width:`${i}%`}}),jsxRuntime.jsx("span",{className:`relative z-10 ${l}`,children:cr(e)}),jsxRuntime.jsx("span",{className:"relative z-10 text-foreground text-center",children:a}),jsxRuntime.jsx("span",{className:"relative z-10 text-foreground text-right",children:d})]})}var pr=class extends react.Component{state={error:null};static getDerivedStateFromError(t){return {error:t}}componentDidCatch(t,n){}render(){return this.state.error?jsxRuntime.jsxs("div",{style:{height:this.props.fallbackHeight??320,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:"#6b7280",fontSize:13},children:[jsxRuntime.jsx("span",{children:"Chart unavailable"}),jsxRuntime.jsx("span",{style:{fontSize:11,opacity:.7},children:this.state.error.message})]}):this.props.children}},Nt=4,Kn=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function Di(e,t){let n=new Date(e);return t===reactPredict.ChartRange.ONE_DAY?n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):n.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Fi(e,t){let n=new Date(e);return t===reactPredict.ChartRange.ONE_DAY?n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===reactPredict.ChartRange.ONE_WEEK?n.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false}):n.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Yn(e){return `${(e*100).toFixed(2)}%`}var Bi=[{range:reactPredict.ChartRange.ONE_DAY,label:"1D"},{range:reactPredict.ChartRange.ONE_WEEK,label:"1W"},{range:reactPredict.ChartRange.ONE_MONTH,label:"1M"},{range:reactPredict.ChartRange.ALL,label:"ALL"}];function Hi({value:e,onChange:t}){return jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:Bi.map(({range:n,label:o})=>{let r=n===e;return jsxRuntime.jsx("button",{onClick:()=>t(n),style:{padding:"2px 8px",border:"none",background:"transparent",color:r?"#f9fafb":"#6b7280",fontWeight:r?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:o},n)})})}function Ui(){let e=react.useRef(null),t=react.useRef(null),n=react.useCallback(r=>{let i=e.current,s=t.current;if(!i||!s)return;let l=i.getBoundingClientRect(),a=(r.clientX-l.left)/l.width*100;s.style.background=`linear-gradient(to right, transparent ${a}%, rgba(0,0,0,0.55) ${a}%)`,s.style.opacity="1";},[]),o=react.useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:n,onMouseLeave:o}}function $i({active:e,payload:t,label:n,labelMap:o,allSeries:r,range:i}){if(!e||!r?.length)return null;let s=new Map;t?.forEach(a=>s.set(a.dataKey,a));let l=r.map(a=>s.get(a.slug)??{dataKey:a.slug,value:void 0,stroke:a.color,color:a.color});return jsxRuntime.jsxs("div",{style:{background:"rgba(10,10,10,0.92)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 12px",minWidth:180,backdropFilter:"blur(8px)",fontSize:12},children:[jsxRuntime.jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof n=="number"?Fi(n,i):n}),l.map(a=>jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsxRuntime.jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:a.stroke??a.color,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:o.get(a.dataKey)??a.dataKey}),jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:a.value!=null?Yn(a.value):"--"})]},a.dataKey))]})}function Wi({markets:e,selectedSlugs:t,colorMap:n,onToggle:o}){let[r,i]=react.useState(false),s=react.useRef(null);react.useEffect(()=>{if(!r)return;function c(d){s.current&&!s.current.contains(d.target)&&i(false);}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[r]);let l=t.length>=Nt,a=jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(c=>jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:n.get(c)??"#6b7280",display:"inline-block"}},c))}),jsxRuntime.jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let c=e.find(d=>d.slug===t[0]);return c?.outcomes?.[0]?.label??c?.question??"1 market"})():`${t.length} / ${e.length} markets`})]});return jsxRuntime.jsxs("div",{ref:s,style:{position:"relative",display:"inline-block",width:200},children:[jsxRuntime.jsxs("button",{onClick:()=>i(c=>!c),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.05)",cursor:"pointer",width:"100%",userSelect:"none"},children:[a,jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:r?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s",color:"#6b7280"},children:jsxRuntime.jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),r&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"#111827",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",minWidth:260,maxWidth:360,maxHeight:320,overflowY:"auto",padding:"6px 0"},children:[jsxRuntime.jsxs("div",{style:{padding:"4px 12px 8px",fontSize:11,color:"#6b7280",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:["Select up to ",Nt," markets"]}),e.map(c=>{let d=t.includes(c.slug),u=!d&&l,m=d&&t.length===1,f=n.get(c.slug)??"#6b7280",p=c.outcomes.find(v=>v.label.toLowerCase()==="yes")??c.outcomes[0],g=p?.price!=null?`${Math.round(p.price*100)}%`:null;return jsxRuntime.jsxs("button",{onClick:()=>{m||u||o(c.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:d?"rgba(255,255,255,0.05)":"transparent",cursor:u||m?"not-allowed":"pointer",opacity:u?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:v=>{!u&&!m&&(v.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:v=>{v.currentTarget.style.background=d?"rgba(255,255,255,0.05)":"transparent";},children:[jsxRuntime.jsx("span",{style:{width:16,height:16,borderRadius:4,border:d?`2px solid ${f}`:"2px solid rgba(255,255,255,0.2)",background:d?`${f}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:d&&jsxRuntime.jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:f,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:f,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:d?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.outcomes?.[0]?.label??c.question}),g&&jsxRuntime.jsx("span",{style:{color:f,fontWeight:700,fontSize:12,flexShrink:0},children:g})]},c.slug)})]})]})}function zi({series:e,colorMap:t,displayValues:n}){return jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 24px",padding:"0 2px"},children:e.map(o=>{let r=t.get(o.marketSlug)??"#6b7280",i=n.get(o.marketSlug);return jsxRuntime.jsxs("div",{style:{display:"inline-flex",alignItems:"flex-start",gap:6},children:[jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r,flexShrink:0,marginTop:3}}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1},children:[jsxRuntime.jsx("span",{style:{color:"#9ca3af",fontSize:12,lineHeight:"17px",whiteSpace:"nowrap"},children:o.label}),jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:i!=null?Yn(i):"--"})]})]},o.marketSlug)})})}function Ki(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function Vi(e,t){if(e.length<=t)return e;let n=[],o=e.length/t;for(let r=0;r<t;r++){let i=Math.floor(r*o),s=Math.min(Math.floor((r+1)*o),e.length),l=e.slice(i,s),a=l.map(c=>c.price).sort((c,d)=>c-d);n.push({timestamp:l[l.length-1].timestamp,price:Ki(a)});}return n}function Yi(e,t=200){if(e.length===0)return [];let n=e.map(l=>({...l,data:Vi(l.data,t)})),o=new Set;n.forEach(l=>l.data.forEach(a=>o.add(a.timestamp)));let r=Array.from(o).sort((l,a)=>l-a),i=n.map(l=>{let a=new Map;return l.data.forEach(c=>a.set(c.timestamp,c.price)),{slug:l.marketSlug,map:a}}),s=new Map;return r.map(l=>{let a={timestamp:l};return i.forEach(({slug:c,map:d})=>{let u=d.get(l);if(u!==void 0)s.set(c,u),a[c]=u;else {let m=s.get(c);m!==void 0&&(a[c]=m);}}),a})}function qn(e){return jsxRuntime.jsx(pr,{children:jsxRuntime.jsx(qi,{...e})})}function qi({event:e,isLoading:t,className:n,volume:o}){let r=react.useMemo(()=>(e.markets??[]).filter(y=>y.status==="open"),[e.markets]),i=react.useMemo(()=>[...r].sort((y,T)=>{let I=D=>(D.outcomes.find(G=>G.label.toLowerCase()==="yes")??D.outcomes[0])?.price??0;return I(T)-I(y)}),[r]),[s,l]=react.useState(()=>i.slice(0,Nt).map(y=>y.slug)),[a,c]=react.useState(pt),d=react.useMemo(()=>{let y=new Map;return s.forEach((T,I)=>{y.set(T,Kn[I%Kn.length]);}),y},[s]),u=react.useMemo(()=>r.filter(y=>s.includes(y.slug)),[r,s]),{series:m,isLoading:f}=reactPredict.useMarketHistory(u,a),p=t||f,g=react.useMemo(()=>{if(m.length>0&&m.some(I=>I.data.length>0))return m;let y=Date.now(),T=864e5;return u.map(I=>{let G=(I.outcomes?.find(J=>J.label.toLowerCase()==="yes")??I.outcomes?.[0])?.price??.5;return {marketSlug:I.slug,label:I.outcomes?.[0]?.label??I.question,data:[{timestamp:y-7*T,price:G},{timestamp:y,price:G}]}})},[m,u]),v=react.useMemo(()=>a===reactPredict.ChartRange.ONE_DAY?96:a===reactPredict.ChartRange.ONE_WEEK?168:a===reactPredict.ChartRange.ONE_MONTH?180:300,[a]),h=react.useMemo(()=>Yi(g,v),[g,v]),U=react.useMemo(()=>{if(h.length===0)return [0,1];let y=1/0,T=-1/0;if(s.forEach(D=>{h.forEach(G=>{let J=G[D];J!=null&&(J<y&&(y=J),J>T&&(T=J));});}),!isFinite(y))return [0,1];let I=Math.max((T-y)*.15,.05);return [Math.max(0,y-I),Math.min(1,T+I)]},[h,s]),P=react.useMemo(()=>{let y=new Map;return g.forEach(T=>{T.data.length>0&&y.set(T.marketSlug,T.data[T.data.length-1].price);}),y},[g]),C=react.useMemo(()=>{let y=new Map;return g.forEach(T=>y.set(T.marketSlug,T.label)),y},[g]),R=react.useMemo(()=>g.map(y=>({slug:y.marketSlug,color:d.get(y.marketSlug)??"#6b7280"})),[g,d]),{wrapperRef:j,overlayRef:M,onMouseMove:le,onMouseLeave:W}=Ui(),pe=react.useCallback(y=>{l(T=>T.includes(y)?T.length<=1?T:T.filter(I=>I!==y):T.length>=Nt?T:[...T,y]);},[]),[Se,N]=react.useState(null),re=react.useRef(null),se=react.useRef(""),Q=react.useRef(0),ae=!p&&h.length>0;return jsxRuntime.jsxs("div",{className:n,style:{display:"flex",flexDirection:"column",gap:12},children:[jsxRuntime.jsx(zi,{series:g,colorMap:d,displayValues:Se??P}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0},children:[jsxRuntime.jsx("div",{ref:j,style:{height:300,width:"100%",userSelect:"none",position:"relative"},onMouseMove:ae?y=>{le(y),cancelAnimationFrame(Q.current),Q.current=requestAnimationFrame(()=>{N(re.current);});}:void 0,onMouseLeave:ae?()=>{W(),cancelAnimationFrame(Q.current),se.current="",re.current=null,N(null);}:void 0,children:p?jsxRuntime.jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):h.length===0?jsxRuntime.jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No price history data"}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:M,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.LineChart,{data:h,margin:{top:8,right:16,left:0,bottom:0},children:[jsxRuntime.jsx(recharts.CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:["dataMin","dataMax"],tickFormatter:y=>Di(y,a),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsxRuntime.jsx(recharts.YAxis,{domain:U,tickFormatter:y=>`${Math.round(y*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsxRuntime.jsx(recharts.Tooltip,{content:y=>{let T=y;if(T.active&&T.payload?.length){let I=T.payload.map(D=>`${D.dataKey}:${D.value}`).join(",");if(I!==se.current){se.current=I;let D=new Map;T.payload.forEach(G=>{G.value!=null&&D.set(G.dataKey,G.value);}),re.current=D;}}return jsxRuntime.jsx($i,{...T,labelMap:C,allSeries:R,range:a})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),g.map(y=>{let T=d.get(y.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.Line,{type:"linear",dataKey:y.marketSlug,stroke:T,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:T},connectNulls:true,isAnimationActive:false},y.marketSlug)}),Se==null&&h.length>0&&g.map(y=>{let T=h[h.length-1],I=T[y.marketSlug];if(I==null)return null;let D=d.get(y.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.ReferenceDot,{x:T.timestamp,y:I,ifOverflow:"extendDomain",shape:G=>{let{cx:J,cy:ve}=G;return J==null||ve==null?jsxRuntime.jsx("g",{}):jsxRuntime.jsxs("g",{children:[jsxRuntime.jsxs("circle",{cx:J,cy:ve,r:6,fill:D,opacity:.3,children:[jsxRuntime.jsx("animate",{attributeName:"r",values:"4;9;4",dur:"2s",repeatCount:"indefinite"}),jsxRuntime.jsx("animate",{attributeName:"opacity",values:"0.4;0.05;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsxRuntime.jsx("circle",{cx:J,cy:ve,r:3.5,fill:D})]})}},`pulse-${y.marketSlug}`)})]})})]})}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:6},children:[o!=null&&o>0&&jsxRuntime.jsxs("span",{style:{color:"#6b7280",fontSize:12},children:["$",Math.round(o).toLocaleString()," vol"]}),jsxRuntime.jsx("div",{style:{flex:1}}),i.length>1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Wi,{markets:i,selectedSlugs:s,colorMap:d,onToggle:pe}),jsxRuntime.jsx("span",{style:{width:1,height:14,background:"#374151",flexShrink:0}})]}),jsxRuntime.jsx(Hi,{value:a,onChange:c})]})]})]})}function nt(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function sl(e){return `${parseFloat((e*100).toFixed(2))}%`}function jn(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function kt(e){return e.outcomes?.[0]?.label??e.question}function al(e){switch(e){case "polymarket":return "Polymarket";case "dflow":return "Kalshi";default:return e}}function rt(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let n=t.toLocaleString("default",{month:"short"}),o=t.getDate(),r=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0");return `${n} ${o}, ${r} ${i}:${s}`}function Gn(e){let[t,n]=react.useState(Date.now());if(react.useEffect(()=>{if(!e)return;let d=setInterval(()=>n(Date.now()),1e3);return ()=>clearInterval(d)},[e]),!e)return null;let o=new Date(e).getTime();if(isNaN(o))return null;let r=o-t;if(r<=0)return null;let i=Math.floor(r/864e5),s=Math.floor(r%864e5/36e5),l=Math.floor(r%36e5/6e4),a=Math.floor(r%6e4/1e3),c=[];return i>0&&c.push(`${i}d`),c.push(`${String(s).padStart(2,"0")}h`),c.push(`${String(l).padStart(2,"0")}m`),c.push(`${String(a).padStart(2,"0")}s`),c.join(" ")}function Xn(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let n=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),r=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getDate().toString().padStart(2,"0"),s=t.getFullYear(),l=-t.getTimezoneOffset(),a=l>=0?"+":"-",c=String(Math.abs(Math.floor(l/60))).padStart(2,"0");return `${n}:${o} ${r}/${i}/${s} (${a}${c})`}function Zn({event:e,onTradeAction:t}){let{t:n}=i18n.useTranslation(),{ref:o,isCollapsed:r}=hooks.useScrollCollapse(),i=react.useMemo(()=>{let u=[...e.markets||[]],m=u.filter(p=>p.status==="open").sort((p,g)=>nt(g)-nt(p)),f=u.filter(p=>p.status!=="open").sort((p,g)=>nt(g)-nt(p));return [...m,...f]},[e.markets]),s=e.status==="closed"||e.status==="voided",l=Gn(s?void 0:e.start_at),a=Gn(s?void 0:e.end_at),c=Xn(e.start_at),d=Xn(e.end_at);return jsxRuntime.jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxRuntime.jsxs("div",{ref:o,className:`sticky top-0 z-30 flex items-center backdrop-blur-md transition-all duration-300 ${r?"h-14 lg:h-16 gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"h-16 lg:h-20 gap-x-2 lg:gap-x-4"}`,children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",classNames:{base:"bg-transparent"},className:`flex-shrink-0 transition-all duration-300 ${r?"!h-10 !w-10 lg:!h-12 lg:!w-12":"!h-16 !w-16 lg:!h-20 lg:!w-20"}`}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[!r&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((u,m)=>jsxRuntime.jsxs(react.Fragment,{children:[m>0&&jsxRuntime.jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-sm text-neutral truncate",children:u.label})]},u.slug)),jsxRuntime.jsx(dl,{source:e.source})]}),jsxRuntime.jsx("span",{className:`font-semibold truncate transition-all duration-300 ${r?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),(l||a||s)&&jsxRuntime.jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:s?d&&jsxRuntime.jsx("span",{className:"text-neutral",children:n("predict.event.endedAt",{time:d})}):l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-foreground",children:n("predict.event.beginsIn",{time:l})}),c&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-neutral",children:c})]})]}):a?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-foreground",children:n("predict.event.endsIn",{time:a})}),d&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-neutral",children:d})]})]}):null}),jsxRuntime.jsx(qn,{event:e,volume:e.volume??void 0}),jsxRuntime.jsx(il,{markets:i,onTradeAction:t}),jsxRuntime.jsx(cl,{markets:i,event:e})]})}var Qn=5;function il({markets:e,onTradeAction:t}){let{t:n}=i18n.useTranslation(),[o,r]=react.useState(false),[i,s]=react.useState(null),l=e.find(p=>p.status==="open")?.slug,[a,c]=react.useState(l?`${l}:yes`:null);if(e.length===0)return null;let d=e.length>Qn,u=o?e:e.slice(0,Qn),m=p=>{s(g=>g===p?null:p);},f=(p,g,v)=>{c(`${p.slug}:${g}`),s(p.slug),t?.(p,g,v);};return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("table",{className:"w-full border-collapse",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{children:[jsxRuntime.jsx("th",{}),jsxRuntime.jsx("th",{className:"py-2 text-left text-xs text-neutral font-normal lg:text-center lg:text-sm",children:n("predict.market.table.chance")}),jsxRuntime.jsx("th",{})]})}),jsxRuntime.jsx("tbody",{children:u.map(p=>{let g=nt(p),v=p.outcomes[1]?.best_ask??p.outcomes[1]?.price,h=i===p.slug;return jsxRuntime.jsx(ll,{market:p,yesPrice:g,noPrice:v??void 0,activeYes:a===`${p.slug}:yes`,activeNo:a===`${p.slug}:no`,isExpanded:h,onToggleExpand:()=>m(p.slug),onTradeAction:f},p.slug)})})]}),d&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>r(p=>!p),className:"flex w-full items-center justify-start gap-x-2 py-2 pl-1 text-xs text-neutral lg:pl-2 lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:n(o?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-4 w-4 transition-transform",o&&"rotate-180")})]})]})}function ll({market:e,yesPrice:t,noPrice:n,activeYes:o,activeNo:r,isExpanded:i,onToggleExpand:s,onTradeAction:l}){let{t:a}=i18n.useTranslation(),c=e.status==="open",d=e.volume?`$${Math.round(e.volume).toLocaleString("en-US")} vol`:void 0;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:s,role:"button",tabIndex:0,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),s());},children:[jsxRuntime.jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[e.image_url&&jsxRuntime.jsx(ui.Avatar,{src:e.image_url,name:kt(e)?.[0]||"?",radius:"lg",className:"size-5 shrink-0 lg:size-8",imgProps:{className:"object-cover"}}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate max-w-[200px] lg:max-w-[300px]",children:kt(e)}),d&&jsxRuntime.jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:d})]})]})}),jsxRuntime.jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:sl(t)}),jsxRuntime.jsx("td",{className:"py-2 pr-1 lg:pr-2",children:c?jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsxRuntime.jsx("button",{type:"button",className:ui.cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all",o?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:u=>{u.stopPropagation(),l?.(e,"yes","buy");},children:a("predict.market.action.yes",{price:jn(t)})}),jsxRuntime.jsx("button",{type:"button",className:ui.cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all",r?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:u=>{u.stopPropagation(),l?.(e,"no","buy");},children:n!=null?a("predict.market.action.no",{price:jn(n)}):a("predict.market.no")})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-end",children:jsxRuntime.jsx("span",{className:ui.cn("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",e.status==="closed"?"bg-neutral/10 text-neutral":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?a("predict.event.status.closed"):e.status==="voided"?a("predict.event.status.voided"):a("predict.event.status.pending")})})})]}),i&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:3,className:"pb-3",children:jsxRuntime.jsx("div",{className:"max-h-100 overflow-y-auto",children:jsxRuntime.jsx(zn,{market:e,outcome:r?"no":"yes",onTradeAction:l})})})})]})}function cl({markets:e,event:t}){let{t:n}=i18n.useTranslation(),[o,r]=react.useState(false),[i,s]=react.useState(false),[l,a]=react.useState(0),c=e.filter(f=>f.rules&&f.rules.length>0||f.description);if(c.length===0)return null;let d=c[l]??c[0],u=d.rules&&d.rules.length>0?d.rules.join(`
19
+ `;function Rn({event:e,href:t,LinkComponent:n,onSelect:o,onSelectOutcome:r,onHover:i}){let[s,l]=react.useState(null),a=e.markets??[],c=react.useMemo(()=>a.length>2?[...a].sort((M,L)=>(L.outcomes?.[0]?.price??0)-(M.outcomes?.[0]?.price??0)):a,[a]),d=c.filter(M=>M.status==="open"),u=c.length===1,m=d.slice(0,Sn),f=d.length-Sn,p=react.useMemo(()=>`$${Math.round(e.volume??0).toLocaleString("en-US")}`,[e.volume]),g=s?d.find(M=>M.slug===s)??null:null,v=!!g||u,h=()=>{v||o?.(e);},H=M=>{M.stopPropagation(),g&&(M.preventDefault(),l(null));},P=M=>{M.stopPropagation(),t||(M.preventDefault(),o?.(e));};return jsxRuntime.jsxs("div",{className:ui.cn("group flex h-full w-full flex-col rounded-xl","min-h-52 border border-border/90 bg-background p-3","lg:min-h-72 lg:max-w-md lg:p-4","gap-y-1.5 lg:gap-y-4","transition duration-300","hover:border-primary/40 hover:shadow-card-glow","focus-within:border-primary/40 focus-within:shadow-card-glow",!v&&"cursor-pointer"),onMouseEnter:()=>i?.(e),onClick:h,children:[jsxRuntime.jsx("style",{children:Ba}),jsxRuntime.jsx(Ha,{event:e,href:t,LinkComponent:n,onClick:H,isExpanded:v}),jsxRuntime.jsx("div",{className:"flex flex-1 flex-col",children:u?jsxRuntime.jsx(qa,{market:d[0],event:e,formattedVolume:p,href:t,LinkComponent:n,onSelect:o,onSelectOutcome:r}):g?jsxRuntime.jsx(ja,{market:g,event:e,onCollapse:()=>l(null),onSelectOutcome:r}):jsxRuntime.jsx(Va,{displayedMarkets:m,moreCount:f,formattedVolume:p,source:e.source,href:t,LinkComponent:n,onMarketClick:M=>l(M.slug),onShowMore:P})})]})}function Ha({event:e,href:t,LinkComponent:n,onClick:o,isExpanded:r}){let i=e.start_at?Fa(e.start_at):null;return jsxRuntime.jsxs(ui.Linkable,{href:t,LinkComponent:n,as:"button",className:"group/header flex items-center gap-x-2 lg:gap-x-4 w-full text-left cursor-pointer",onClick:o,children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsxRuntime.jsx("p",{className:ui.cn("min-w-0 text-sm font-semibold leading-snug text-slate-200 line-clamp-2 lg:text-base",r&&"group-hover/header:text-neutral-400"),children:e.title}),i&&jsxRuntime.jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",i]})]}),jsxRuntime.jsx($a,{event:e})]})}function Ua(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let n=e.tags?.some(r=>r.label?.toLowerCase()==="crypto"),o=e.tags?.some(r=>r.label?.toLowerCase()==="live");if(n&&e.end_at){let r=new Date(e.end_at).getTime()-Date.now(),i=300*1e3,s=900*1e3;if(r>0&&r<=s){let l=r<=i?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:r<=i?"5m":"15m",color:l});}}return o&&t.push({kind:"live"}),t.slice(0,2)}function $a({event:e}){let t=react.useMemo(()=>Ua(e),[e]);return t.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:t.map((n,o)=>{switch(n.kind){case "live":return jsxRuntime.jsx(Wa,{},o);case "crypto-short":return jsxRuntime.jsx(za,{label:n.label,color:n.color},o);case "closed":return jsxRuntime.jsx(Ka,{},o)}})})}function Wa(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md bg-[rgb(240,68,56)]/10 px-1.5 py-0.5 text-xs font-semibold text-[rgb(240,68,56)]",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-current"}),e("predict.event.status.live")]})}function za({label:e,color:t}){return jsxRuntime.jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{backgroundColor:`${t}26`,color:t},children:[jsxRuntime.jsx(ui.TimerIcon,{className:"size-3 shrink-0"}),e]})}function Ka(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsx("span",{className:"inline-flex items-center rounded-md bg-neutral-800/80 px-1.5 py-0.5 text-xs font-semibold text-neutral-400",children:e("predict.event.status.closed")})}function Va({displayedMarkets:e,moreCount:t,formattedVolume:n,source:o,href:r,LinkComponent:i,onMarketClick:s,onShowMore:l}){let{t:a}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e.length>0&&jsxRuntime.jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(c=>{let d=Tn(c);return jsxRuntime.jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:u=>{u.stopPropagation(),s(c);},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:c.outcomes?.[0]?.label??c.question}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:Mn(d)}),jsxRuntime.jsx(Ya,{})]})]},c.slug)})}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[t>0?jsxRuntime.jsxs(ui.Linkable,{href:r,LinkComponent:i,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:l,children:[a("predict.event.showMore"),jsxRuntime.jsx(On,{className:"h-3 w-3"})]}):jsxRuntime.jsx("div",{}),jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1.5 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[n," ",a("predict.event.volume"),jsxRuntime.jsx(In,{source:o})]})]})]})}function Pn({bgColor:e,textColor:t,shadowColor:n,onClick:o,children:r}){return jsxRuntime.jsx("button",{type:"button",className:"flex h-12 flex-1 w-full items-center justify-center gap-x-1 overflow-hidden rounded-lg p-3 text-base font-normal hover:cursor-pointer will-change-transform [-webkit-tap-highlight-color:transparent]",style:{backgroundColor:e,color:t,"--shadow-color":n,"--shadow-offset":"4px",boxShadow:"inset 0 -1px 0 rgba(255,255,255,0.08), 0 var(--shadow-offset, 4px) 0 var(--shadow-color, rgba(0,0,0,0.22))",transition:"transform .12s, box-shadow .12s, opacity .14s"},onMouseEnter:l=>{let a=l.currentTarget;a.style.setProperty("--shadow-offset","2px"),a.style.transform="translateY(2px)";},onMouseLeave:l=>{let a=l.currentTarget;a.style.setProperty("--shadow-offset","4px"),a.style.transform="translateY(0px)";},onClick:o,children:r})}function Ln({market:e,event:t,onSelectOutcome:n,dynamicColors:o=false,labelFormat:r="action"}){let{t:i}=i18n.useTranslation(),[s,l]=o?Da(e):[ar,Cn],a=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",c=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",d=r==="label"&&a===c?"action":r,u=d==="label"?`${e.outcomes?.[0]?.label??"Yes"} ${wn(e)}\xA2`:i("predict.market.action.yes",{price:wn(e)}),m=d==="label"?`${e.outcomes?.[1]?.label??"No"} ${kn(e)}\xA2`:i("predict.market.action.no",{price:kn(e)});return jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx(Pn,{bgColor:s.bg,textColor:s.text,shadowColor:s.shadow,onClick:f=>{f.stopPropagation(),n?.(t,e,"yes");},children:u}),jsxRuntime.jsx(Pn,{bgColor:l.bg,textColor:l.text,shadowColor:l.shadow,onClick:f=>{f.stopPropagation(),n?.(t,e,"no");},children:m})]})}function Ya(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("span",{className:"inline-flex h-7 w-[85px] items-center justify-center gap-x-3 rounded-lg p-1.5 text-xs font-semibold flex-shrink-0 bg-gradient-to-r from-primary/15 to-secondary/15 lg:h-9 lg:w-24 lg:gap-x-4 lg:p-2 lg:text-sm",children:[jsxRuntime.jsx("span",{className:"text-primary",children:e("predict.market.yes")}),jsxRuntime.jsx("span",{className:"text-neutral-400",children:"/"}),jsxRuntime.jsx("span",{className:"text-secondary",children:e("predict.market.no")})]})}function qa({market:e,event:t,formattedVolume:n,href:o,LinkComponent:r,onSelect:i,onSelectOutcome:s}){let{t:l}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex-1",children:jsxRuntime.jsx(Ln,{market:e,event:t,onSelectOutcome:s,dynamicColors:true,labelFormat:"label"})}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[jsxRuntime.jsxs(ui.Linkable,{href:o,LinkComponent:r,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:c=>{c.stopPropagation(),o||(c.preventDefault(),i?.(t));},children:[l("predict.event.viewEvent"),jsxRuntime.jsx(On,{className:"h-3 w-3"})]}),jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1.5 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[n," ",l("predict.event.volume"),jsxRuntime.jsx(In,{source:t.source})]})]})]})}function ja({market:e,event:t,onCollapse:n,onSelectOutcome:o}){let{t:r}=i18n.useTranslation(),i=Tn(e);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:s=>{s.stopPropagation(),n();},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 lg:text-sm",children:e.outcomes?.[0]?.label??e.question}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:Mn(i)}),jsxRuntime.jsx(ui.ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsxRuntime.jsx("div",{className:"mt-3",children:jsxRuntime.jsx(Ln,{market:e,event:t,onSelectOutcome:o,labelFormat:"action"})})]}),jsxRuntime.jsxs("button",{type:"button",className:"mt-auto flex items-center gap-x-1 pt-4 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:s=>{s.stopPropagation(),n();},children:[jsxRuntime.jsx(Ga,{className:"h-3 w-3"}),r("predict.event.back")]})]})}function On({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsxRuntime.jsx("path",{d:"M4.5 2.5L8 6l-3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ga({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsxRuntime.jsx("path",{d:"M7.5 2.5L4 6l3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function In({source:e}){return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsxRuntime.jsx(ui.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var ti=768,Dn=1024,ri=1280,ni=8,oi=224,si=304,ai=114;function ii(e){return e>=ri?4:e>=Dn?3:e>=ti?2:1}function li(e){return e>=Dn?si:oi}function An({events:e,hasMore:t=false,onFetchMore:n,onSelect:o,onSelectOutcome:r,getEventHref:i,LinkComponent:s,onHover:l}){let a=react.useRef(null),c=react.useRef(null),{width:d=0,height:u=0}=hooks.useResizeObserver({ref:a}),m=ii(d),f=li(d),p=Math.ceil(e.length/m)||0,g=!t&&e.length>0,v=p+(t?1:0)+(g?1:0),h=react.useCallback(L=>L<p,[p]),H=react.useCallback(async()=>{n?.();},[n]),P=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:h,loadMoreRows:H,rowCount:v,threshold:3}),M=react.useCallback(()=>{c.current?.scrollToRow({index:0,behavior:"smooth"});},[]);return jsxRuntime.jsx("div",{ref:a,className:"@container w-full h-full",children:u>0&&jsxRuntime.jsx(reactWindow.List,{listRef:c,className:"no-scrollbar",style:{height:u},onRowsRendered:P,rowComponent:ci,rowCount:v,rowHeight:L=>g&&L===v-1?ai:(f),rowProps:{events:e,columnCount:m,dataRowCount:p,showEndOfList:g,totalRowCount:v,onSelect:o,onSelectOutcome:r,getEventHref:i,LinkComponent:s,onHover:l,onScrollToTop:M}})})}function ci({index:e,style:t,events:n,columnCount:o,dataRowCount:r,showEndOfList:i,totalRowCount:s,onSelect:l,onSelectOutcome:a,getEventHref:c,LinkComponent:d,onHover:u,onScrollToTop:m}){if(i&&e===s-1)return jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(di,{onScrollToTop:m})});if(e>=r)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-start pt-4",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})});let f=e*o,p=n.slice(f,f+o),g=o-p.length;return jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsxs("div",{className:"flex w-full h-full",children:[p.map(v=>v==null?null:jsxRuntime.jsx("div",{className:"flex-1 min-w-0 flex",style:{padding:ni},children:jsxRuntime.jsx(Rn,{event:v,href:c?.(v),LinkComponent:d,onSelect:l,onSelectOutcome:a,onHover:u})},v.slug)),g>0&&Array.from({length:g}).map((v,h)=>jsxRuntime.jsx("div",{style:{flex:1,minWidth:0}},`spacer-${h}`))]})})}function di({onScrollToTop:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"flex w-full flex-col items-center justify-center gap-y-4 py-6",children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center justify-center gap-x-4",children:[jsxRuntime.jsx("div",{className:"h-px w-16 bg-neutral-700"}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-neutral-500",children:t("predict.event.endOfList")}),jsxRuntime.jsx("div",{className:"h-px w-16 bg-neutral-700"})]}),jsxRuntime.jsxs("button",{type:"button",className:"flex cursor-pointer items-center gap-x-1 text-xs font-medium text-neutral-400",onClick:e,children:[jsxRuntime.jsx("span",{className:"iconify size-4 ph--arrow-up-bold"}),jsxRuntime.jsx("span",{children:t("predict.event.backToTop")})]})]})}function Bn({tagSlugSelection:e,limit:t=48,status:n,sort_by:o,sort_asc:r,source:i,with_markets:s,timeRemaining:l,minVolume:a,minLiquidity:c,onSelect:d,onSelectOutcome:u,getEventHref:m,LinkComponent:f,onHover:p}){let{data:g,hasMore:v,fetchMore:h,isFetching:H}=yn({tagSlugSelection:e,limit:t,status:n,sort_by:o,sort_asc:r,source:i,with_markets:s,timeRemaining:l,minVolume:a,minLiquidity:c});return H?jsxRuntime.jsx(or,{count:48}):jsxRuntime.jsx(An,{events:g,hasMore:v,onFetchMore:h,onSelect:d,onSelectOutcome:u,getEventHref:m,LinkComponent:f,onHover:p})}function qu({onSelect:e,onSelectOutcome:t,getEventHref:n,LinkComponent:o,onHover:r}){let[i,s]=react.useState({categorySlug:null,tagSlug:null}),[l,a]=react.useState(rr),{isOpen:c,onOpen:d,onClose:u}=ui.useDisclosure(),{onOpen:m}=uiScaffold.useAsyncModal(tr),f=react.useCallback((L,q,R)=>{t?.(L,q,R),m({params:{event:L,market:q,initialOutcome:R}});},[t,m]),p=react.useCallback(L=>{s(L);},[]),g=react.useCallback(L=>{a(q=>({...q,sortPreset:L}));},[]),v=react.useCallback(L=>{a(q=>({...q,sortAsc:L}));},[]),h=react.useCallback(L=>{a(L);},[]),H=react.useMemo(()=>vn[l.sortPreset].sort_by,[l.sortPreset]),P=react.useMemo(()=>nr(l),[l]),M=react.useMemo(()=>jsxRuntime.jsx(xn,{sortPreset:l.sortPreset,onSortChange:g,sortAsc:l.sortAsc,onSortAscChange:v,onFilterPress:d,filterCount:P}),[l.sortPreset,l.sortAsc,P,g,v,d]);return jsxRuntime.jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsxRuntime.jsx(Kr,{onSelect:p,trailing:M}),jsxRuntime.jsx(pn,{isOpen:c,onClose:u,value:l,onChange:h}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(Bn,{tagSlugSelection:i,sort_by:H,sort_asc:l.sortAsc,source:l.source,timeRemaining:l.timeRemaining,minVolume:l.minVolume,minLiquidity:l.minLiquidity,onSelect:e,onSelectOutcome:f,getEventHref:n,LinkComponent:o,onHover:r})}),jsxRuntime.jsx(dn,{})]})}var mr=40,Pt=36,ot=480,fr=ot-Pt;function Wn({event:e,walletAddress:t,onCancelOrder:n}){let{t:o}=i18n.useTranslation(),[r,i]=react.useState("positions"),s=react.useMemo(()=>e.markets?.map(u=>u.slug)??[],[e.markets]),{data:l}=reactPredict.usePositions({source:e.source,user:t??""}),a=react.useMemo(()=>!l?.positions||!t?0:s.length===0?l.positions.length:l.positions.filter(u=>u.market&&s.includes(u.market.slug)).length,[l?.positions,s,t]),d=[{key:"positions",label:a>0?`${o("predict.positions.title")} (${a})`:o("predict.positions.title")},{key:"orders",label:o("predict.openOrders.title")},{key:"trades",label:o("predict.tradeHistory.title")}];return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:d.map(u=>jsxRuntime.jsx("button",{type:"button",onClick:()=>i(u.key),className:ui.cn("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",r===u.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:u.label},u.key))}),t?jsxRuntime.jsxs("div",{style:{height:ot},children:[r==="positions"&&jsxRuntime.jsx(bi,{source:e.source,walletAddress:t,marketSlugs:s}),r==="orders"&&jsxRuntime.jsx(Si,{source:e.source,walletAddress:t,marketSlugs:s,onCancelOrder:n}),r==="trades"&&jsxRuntime.jsx(ki,{source:e.source,walletAddress:t})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:ot},children:o("predict.trade.connectWallet")})]})}function bi({source:e,walletAddress:t,marketSlugs:n}){let{t:o}=i18n.useTranslation(),{data:r,isLoading:i}=reactPredict.usePositions({source:e,user:t}),s=react.useMemo(()=>r?.positions?n.length===0?r.positions:r.positions.filter(l=>l.market&&n.includes(l.market.slug)):[],[r?.positions,n]);return i?jsxRuntime.jsx(vr,{}):s.length===0?jsxRuntime.jsx(gr,{message:o("predict.positions.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:Pt},children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2 whitespace-nowrap",children:o("predict.positions.event")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.totalSize")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.value")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.avgPrice")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.markPrice")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.pnl")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right whitespace-nowrap",children:o("predict.positions.payoutIfRight")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right whitespace-nowrap",children:o("predict.positions.estSettlement")}),jsxRuntime.jsx("div",{className:"w-16 shrink-0"})]}),jsxRuntime.jsx(reactWindow.List,{style:{height:fr},rowComponent:yi,rowCount:s.length,rowHeight:mr,rowProps:{positions:s,closeLabel:o("predict.positions.close")}})]})}function yi({index:e,style:t,positions:n,closeLabel:o}){let r=n[e];if(!r)return null;let i=r.pnl??0,s=r.pnl_percent??0,l=r.avg_price??0,a=r.current_price??0,c=i>0?"text-success":i<0?"text-danger":"text-foreground",d=i>0?"+":"",u=r.market?.outcomes?.[0]?.label??r.market?.question??"\u2014",m=r.side,f=r.size,p=r.size*a,g=r.market?.end_at?Ci(r.market.end_at):"\u2014";return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 hover:bg-content2/40 transition-colors text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"flex-[3] min-w-0 pr-2",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate font-medium",children:u}),jsxRuntime.jsx("span",{className:ui.cn("text-[10px] font-medium",m.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:m})]})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:r.size}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",p.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:wt(l)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:wt(a)}),jsxRuntime.jsxs("div",{className:ui.cn("flex-[1.5] pr-2 text-right font-mono whitespace-nowrap",c),children:[d,"$",Math.abs(i).toFixed(2),jsxRuntime.jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",d,s.toFixed(1),"%)"]})]}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground whitespace-nowrap",children:["$",f.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:g}),jsxRuntime.jsx("div",{className:"w-16 shrink-0 text-right",children:jsxRuntime.jsx("button",{type:"button",className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors rounded px-2 py-0.5 border border-border hover:border-foreground/40",children:o})})]})}function Si({source:e,walletAddress:t,marketSlugs:n,onCancelOrder:o}){let{t:r}=i18n.useTranslation(),{data:i,isLoading:s,fetchNextPage:l,hasNextPage:a}=reactPredict.useInfiniteOrders({source:e,wallet_address:t}),c=reactPredict.useCancelOrder(),d=react.useMemo(()=>{let h=i?.pages?.flatMap(M=>M.items)??[],H=new Set(["live","open","submitted","pending"]),P=h.filter(M=>H.has(M.status));return n.length>0&&(P=P.filter(M=>M.market_id&&n.includes(M.market_id))),P},[i?.pages,n]),u=react.useCallback(h=>{o?o(h.id):c.mutate({source:h.source,id:h.id});},[o,c]),m=d.length,f=m+(a?1:0),p=react.useCallback(h=>h<m,[m]),g=react.useCallback(async()=>{await l();},[l]),v=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:p,loadMoreRows:g,rowCount:f,threshold:5});return s?jsxRuntime.jsx(vr,{}):d.length===0&&!a?jsxRuntime.jsx(gr,{message:r("predict.openOrders.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:Pt},children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:r("predict.openOrders.side")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:r("predict.openOrders.outcome")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:r("predict.openOrders.type")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.openOrders.price")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:r("predict.openOrders.filled")}),jsxRuntime.jsx("div",{className:"w-20 shrink-0 pr-2",children:r("predict.openOrders.status")}),jsxRuntime.jsx("div",{className:"w-16 shrink-0"})]}),jsxRuntime.jsx(reactWindow.List,{style:{height:fr},onRowsRendered:v,rowComponent:Ni,rowCount:f,rowHeight:mr,rowProps:{orders:d,itemCount:m,onCancel:u,isCancelling:c.isPending,cancelLabel:r("predict.openOrders.cancel")}})]})}function Ni({index:e,style:t,orders:n,itemCount:o,onCancel:r,isCancelling:i,cancelLabel:s}){if(e>=o)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})});let l=n[e];if(!l)return null;let a=l.side==="BUY";return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",a?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:l.side})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:l.outcome??"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-neutral capitalize",children:l.order_type??"limit"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:l.price?wt(parseFloat(l.price)):"\u2014"}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:[l.size_matched??"0","/",l.original_size??"\u2014"]}),jsxRuntime.jsx("div",{className:"w-20 shrink-0 pr-2",children:jsxRuntime.jsx(wi,{status:l.status})}),jsxRuntime.jsx("div",{className:"w-16 shrink-0 text-right",children:jsxRuntime.jsx("button",{type:"button",onClick:()=>r(l),disabled:i,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:i?jsxRuntime.jsx(ui.Spinner,{size:"sm"}):s})})]})}function wi({status:e}){return jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium capitalize",{live:"bg-success/10 text-success",open:"bg-success/10 text-success",submitted:"bg-warning/10 text-warning",pending:"bg-warning/10 text-warning",matched:"bg-primary/10 text-primary",cancelled:"bg-neutral/10 text-neutral",failed:"bg-danger/10 text-danger",expired:"bg-neutral/10 text-neutral"}[e]??"bg-neutral/10 text-neutral"),children:e})}function ki({source:e,walletAddress:t}){let{t:n}=i18n.useTranslation(),{data:o,isLoading:r,fetchNextPage:i,hasNextPage:s}=reactPredict.useInfiniteTrades({source:e,wallet:t,limit:50}),l=react.useMemo(()=>o?.pages?.flatMap(f=>f.items)??[],[o?.pages]),a=l.length,c=a+(s?1:0),d=react.useCallback(f=>f<a,[a]),u=react.useCallback(async()=>{await i();},[i]),m=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:d,loadMoreRows:u,rowCount:c,threshold:5});return r?jsxRuntime.jsx(vr,{}):l.length===0&&!s?jsxRuntime.jsx(gr,{message:n("predict.tradeHistory.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center text-neutral text-xs lg:text-sm font-normal shrink-0",style:{height:Pt},children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:n("predict.tradeHistory.side")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2",children:n("predict.tradeHistory.outcome")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.tradeHistory.price")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.tradeHistory.qty")}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right",children:n("predict.tradeHistory.total")}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right",children:n("predict.tradeHistory.time")})]}),jsxRuntime.jsx(reactWindow.List,{style:{height:fr},onRowsRendered:m,rowComponent:Pi,rowCount:c,rowHeight:mr,rowProps:{trades:l,itemCount:a}})]})}function Pi({index:e,style:t,trades:n,itemCount:o}){if(e>=o)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})});let r=n[e];if(!r)return null;let i=r.side?.toUpperCase()==="BUY",s=Ei(r.timestamp),l=r.price??0,a=r.usd_size??0;return jsxRuntime.jsxs("div",{style:t,className:"flex items-center border-b border-border/50 text-xs lg:text-sm",children:[jsxRuntime.jsx("div",{className:"w-16 shrink-0 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",i?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:r.side})}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-foreground capitalize",children:r.outcome??"\u2014"}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:wt(l)}),jsxRuntime.jsx("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:r.size}),jsxRuntime.jsxs("div",{className:"flex-1 pr-2 text-right font-mono text-foreground",children:["$",a.toFixed(2)]}),jsxRuntime.jsx("div",{className:"flex-[1.5] pr-2 text-right text-neutral whitespace-nowrap",children:s})]})}function gr({message:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-sm text-neutral",style:{height:ot},children:e})}function vr(){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",style:{height:ot},children:Array.from({length:6}).map((e,t)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-full rounded-md"},t))})}function wt(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function Ei(e){let t=new Date(e*1e3),n=(t.getMonth()+1).toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),r=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return `${n}/${o} ${r}:${i}`}function Ci(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}function st({marketCount:e=4,showBack:t}){return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-4 animate-pulse lg:gap-6",children:[t&&jsxRuntime.jsx("div",{className:"h-5"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 h-16 lg:h-20 lg:gap-x-4",children:[jsxRuntime.jsx(ui.Skeleton,{className:"size-16 shrink-0 rounded-lg lg:size-20"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-12 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-10 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-10 rounded"})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-5 w-full max-w-sm rounded lg:h-6"})]})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-48 rounded"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-24 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-20 rounded"})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-[300px] w-full rounded-xl"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-20 rounded"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-[200px] rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-7 w-28 rounded-lg"})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("div",{className:"flex items-center py-2",children:[jsxRuntime.jsx("div",{className:"flex-1"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-14 rounded"}),jsxRuntime.jsx("div",{className:"flex-1"})]}),Array.from({length:e}).map((n,o)=>jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 border-b border-border py-2.5 lg:gap-x-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"size-5 shrink-0 rounded-lg lg:size-8"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-32 rounded lg:h-4 lg:w-48"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-2.5 w-16 rounded"})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-10 rounded"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-16 rounded-lg lg:w-24"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-16 rounded-lg lg:w-24"})]})]},o))]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-16 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-full rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-4/5 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3.5 w-3/5 rounded"})]})]})}function zn(){return jsxRuntime.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-border p-4 animate-pulse",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-10 w-full rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-24 w-full rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-10 w-full rounded-lg"})]})}var qn="var(--color-bullish)",jn="var(--color-bearish)";function at(e){let t=Math.abs(e);return t>=1e9?`${parseFloat((e/1e9).toFixed(2))}B`:t>=1e6?`${parseFloat((e/1e6).toFixed(2))}M`:t>=1e3?`${parseFloat((e/1e3).toFixed(2))}K`:e.toLocaleString()}function Ri(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function Li(e,t){let n=new Float64Array(101),o=new Float64Array(101);for(let f of e){let p=Math.round(f.price*100);p>=0&&p<=100&&(n[p]+=f.quantity);}for(let f of t){let p=Math.round(f.price*100);p>=0&&p<=100&&(o[p]+=f.quantity);}let r=0,i=0,s=new Float64Array(101),l=new Float64Array(101);for(let f=100;f>=0;f--)r+=n[f],i+=n[f]*f/100,s[f]=r,l[f]=i;let a=0,c=0,d=new Float64Array(101),u=new Float64Array(101);for(let f=0;f<=100;f++)a+=o[f],c+=o[f]*f/100,d[f]=a,u[f]=c;let m=Math.max(s[0]??0,d[100]??0);return Array.from({length:101},(f,p)=>{let g=s[p]>0,v=d[p]>0,h=s[p]||d[p],H=n[p]>0||o[p]>0;return {priceCents:p,displayHeight:Ri(h,m),opacity:h>0?H?1:.5:0,isBid:g,isAsk:v,bidCumTotal:s[p],askCumTotal:d[p],bidCumCost:l[p],askCumCost:u[p]}})}function Oi({info:e}){let{t}=i18n.useTranslation(),n=e.isBid?qn:jn,o=e.leftPct>65?void 0:`${e.leftPct}%`,r=e.leftPct>65?`${100-e.leftPct}%`:void 0;return jsxRuntime.jsxs("div",{style:{position:"absolute",top:8,left:o,right:r,zIndex:10,background:"rgba(17,24,39,0.95)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:8,padding:"8px 12px",fontSize:12,color:"#f9fafb",minWidth:140,pointerEvents:"none"},children:[jsxRuntime.jsx("div",{style:{marginBottom:4,fontWeight:600},children:t("predict.orderBook.depthToPrice",{price:e.priceCents})}),jsxRuntime.jsx("div",{style:{color:n},children:t("predict.orderBook.depthContracts",{amount:at(Math.round(e.cumTotal))})}),jsxRuntime.jsxs("div",{style:{color:n},children:["$",at(Math.round(e.cumCost))]})]})}var Ii=react.memo(function({slot:t,onEnter:n,onLeave:o}){let r=react.useRef(null),i=t.isBid||t.isAsk,s=t.isBid?qn:t.isAsk?jn:void 0;return jsxRuntime.jsx("div",{style:{position:"absolute",left:`${t.priceCents}%`,width:"1%",height:"100%",boxSizing:"border-box",borderRight:t.priceCents<100?"1px solid transparent":"none",cursor:i?"crosshair":"default"},onMouseEnter:()=>n(t,r.current),onMouseLeave:o,children:i&&jsxRuntime.jsx("div",{ref:r,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:s,opacity:t.opacity}})})}),_i=[0,10,20,30,40,50,60,70,80,90,100];function Di(){return jsxRuntime.jsx("div",{className:"relative flex h-6 items-center border-b border-t border-border px-1",style:{background:"rgba(0,0,0,0.15)"},children:_i.map(e=>jsxRuntime.jsx("span",{className:"absolute text-neutral font-normal",style:{fontSize:10,left:`${e}%`,transform:e===0?"translateX(0px)":e===100?"translateX(-100%)":"translateX(-50%)"},children:e},e))})}function Gn({bids:e,asks:t}){let{t:n}=i18n.useTranslation(),o=react.useMemo(()=>Li(e,t),[e,t]),r=react.useMemo(()=>{let u=e.length>0?Math.max(...e.map(f=>f.price)):0,m=t.length>0?Math.min(...t.map(f=>f.price)):1;return Math.round((u+m)/2*100)},[e,t]),i=react.useMemo(()=>o.some(u=>u.isBid||u.isAsk),[o]),[s,l]=react.useState(null),a=react.useRef(null),c=react.useCallback((u,m)=>{a.current&&(a.current.style.filter=""),m?(m.style.filter="brightness(1.5)",a.current=m):a.current=null,u.isBid||u.isAsk?l({priceCents:u.priceCents,isBid:u.isBid,cumTotal:u.isBid?u.bidCumTotal:u.askCumTotal,cumCost:u.isBid?u.bidCumCost:u.askCumCost,leftPct:u.priceCents}):l(null);},[]),d=react.useCallback(()=>{a.current&&(a.current.style.filter="",a.current=null),l(null);},[]);return i?jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxRuntime.jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[r>0&&jsxRuntime.jsx("div",{style:{position:"absolute",left:`${r}%`,top:0,bottom:0,width:1,backgroundImage:"repeating-linear-gradient(to bottom, #6b7280 0, #6b7280 4px, transparent 4px, transparent 8px)",zIndex:1,pointerEvents:"none"}}),s&&jsxRuntime.jsx(Oi,{info:s}),o.map(u=>jsxRuntime.jsx(Ii,{slot:u,onEnter:c,onLeave:d},u.priceCents))]}),jsxRuntime.jsx(Di,{})]}):jsxRuntime.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:n("predict.orderBook.noData")})}function hr(e){let t=e*100,n=Math.round(t*10)/10;return Number.isInteger(n)?`${n}\xA2`:`${n.toFixed(1)}\xA2`}function Xn(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"flex items-center justify-center gap-x-2 h-full text-neutral text-xs",children:[jsxRuntime.jsx(ui.Spinner,{size:"sm"}),jsxRuntime.jsx("span",{children:e("predict.orderBook.loading")})]})}function eo({market:e,outcome:t="yes",onTradeAction:n}){let{t:o}=i18n.useTranslation(),[r,i]=react.useState("depth"),s=t==="no",l=e.source,{data:a,isLoading:c}=reactPredict.useOrderbook({slug:e.slug,source:l}),d=react.useMemo(()=>((s?a?.asks:a?.bids)??[]).map(v=>({price:s?1-v.price:v.price,quantity:v.size})),[a?.bids,a?.asks,s]),u=react.useMemo(()=>((s?a?.bids:a?.asks)??[]).map(v=>({price:s?1-v.price:v.price,quantity:v.size})),[a?.bids,a?.asks,s]),m=react.useMemo(()=>d.length>0?Math.max(...d.map(g=>g.price)):null,[d]),f=react.useMemo(()=>u.length>0?Math.min(...u.map(g=>g.price)):null,[u]),p=react.useMemo(()=>{if(m==null||f==null)return null;let g=(f-m)*100;return Math.round(g*10)/10},[m,f]);return jsxRuntime.jsxs("div",{className:"flex flex-col h-[262px]",children:[jsxRuntime.jsxs("div",{className:"flex h-9 items-center border-b border-border px-1 text-xs",children:[jsxRuntime.jsx("span",{className:"flex-1 text-left text-neutral",children:p!=null?`${o("predict.orderBook.spread")}: ${Number.isInteger(p)?`${p}\xA2`:`${p.toFixed(1)}\xA2`}`:null}),jsxRuntime.jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[m!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bullish)"},children:[o("predict.trade.bestBid"),": ",hr(m)]}),m!=null&&f!=null&&jsxRuntime.jsx("span",{className:"text-neutral",children:"|"}),f!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bearish)"},children:[o("predict.trade.bestAsk"),": ",hr(f)]})]}),jsxRuntime.jsx("div",{className:"flex flex-1 justify-end",children:jsxRuntime.jsx("button",{type:"button",title:r==="depth"?"Orderbook":"Depth chart",onClick:()=>i(g=>g==="depth"?"table":"depth"),className:"flex items-center text-neutral transition-colors cursor-pointer hover:text-foreground",children:r==="depth"?jsxRuntime.jsx(ui.OrderbookTableIcon,{className:"h-4 w-4"}):jsxRuntime.jsx(ui.OrderbookDepthIcon,{className:"h-4 w-4"})})})]}),jsxRuntime.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden",children:[r==="depth"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:c?jsxRuntime.jsx(Xn,{}):jsxRuntime.jsx(Gn,{bids:d,asks:u})}),r==="table"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:c?jsxRuntime.jsx(Xn,{}):jsxRuntime.jsx($i,{bids:d,asks:u,bestBid:m??void 0,bestAsk:f??void 0,spread:p??void 0})})]})]})}var Qn=8;function $i({bids:e,asks:t,spread:n}){let{t:o}=i18n.useTranslation(),r=react.useMemo(()=>[...t].sort((a,c)=>a.price-c.price).slice(0,Qn).reverse(),[t]),i=react.useMemo(()=>[...e].sort((a,c)=>c.price-a.price).slice(0,Qn),[e]),s=react.useMemo(()=>{let a=[...r,...i].map(c=>c.quantity);return Math.max(...a,1)},[r,i]);return r.length===0&&i.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:o("predict.orderBook.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[r.map(a=>jsxRuntime.jsx(Jn,{price:a.price,quantity:a.quantity,side:"ask",maxQty:s},`ask-${a.price}`)),jsxRuntime.jsx("div",{className:"flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:n!=null&&jsxRuntime.jsxs("span",{children:[o("predict.orderBook.spread"),":"," ",Number.isInteger(n)?`${n}\xA2`:`${n.toFixed(1)}\xA2`]})}),i.map(a=>jsxRuntime.jsx(Jn,{price:a.price,quantity:a.quantity,side:"bid",maxQty:s},`bid-${a.price}`)),jsxRuntime.jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-neutral border-t border-border",children:[jsxRuntime.jsx("span",{children:o("predict.orderBook.price")}),jsxRuntime.jsx("span",{className:"text-center",children:o("predict.orderBook.contracts")}),jsxRuntime.jsx("span",{className:"text-right",children:o("predict.orderBook.total")})]})]})}function Jn({price:e,quantity:t,side:n,maxQty:o}){let r=n==="ask",i=Math.min(t/o*100,100),s=r?"bg-bearish/10":"bg-bullish/10",l=r?"text-bearish":"text-bullish",a=at(Math.round(t)),c=Math.round(t*e),d=`$${at(c)}`;return jsxRuntime.jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsxRuntime.jsx("div",{className:`absolute inset-y-0 left-0 ${s} transition-[width] duration-200`,style:{width:`${i}%`}}),jsxRuntime.jsx("span",{className:`relative z-10 ${l}`,children:hr(e)}),jsxRuntime.jsx("span",{className:"relative z-10 text-foreground text-center",children:a}),jsxRuntime.jsx("span",{className:"relative z-10 text-foreground text-right",children:d})]})}var Sr=class extends react.Component{state={error:null};static getDerivedStateFromError(t){return {error:t}}componentDidCatch(t,n){}render(){return this.state.error?jsxRuntime.jsxs("div",{style:{height:this.props.fallbackHeight??320,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:"#6b7280",fontSize:13},children:[jsxRuntime.jsx("span",{children:"Chart unavailable"}),jsxRuntime.jsx("span",{style:{fontSize:11,opacity:.7},children:this.state.error.message})]}):this.props.children}},Tt=4,to=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function Zi(e,t){let n=new Date(e);return t===reactPredict.ChartRange.ONE_DAY?n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):n.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function el(e,t){let n=new Date(e);return t===reactPredict.ChartRange.ONE_DAY?n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):t===reactPredict.ChartRange.ONE_WEEK?n.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:false}):n.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function no(e){return `${(e*100).toFixed(2)}%`}var tl=[{range:reactPredict.ChartRange.ONE_DAY,label:"1D"},{range:reactPredict.ChartRange.ONE_WEEK,label:"1W"},{range:reactPredict.ChartRange.ONE_MONTH,label:"1M"},{range:reactPredict.ChartRange.ALL,label:"ALL"}];function rl({value:e,onChange:t}){return jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:tl.map(({range:n,label:o})=>{let r=n===e;return jsxRuntime.jsx("button",{onClick:()=>t(n),style:{padding:"2px 8px",border:"none",background:"transparent",color:r?"#f9fafb":"#6b7280",fontWeight:r?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:o},n)})})}function nl(){let e=react.useRef(null),t=react.useRef(null),n=react.useCallback(r=>{let i=e.current,s=t.current;if(!i||!s)return;let l=i.getBoundingClientRect(),a=(r.clientX-l.left)/l.width*100;s.style.background=`linear-gradient(to right, transparent ${a}%, rgba(0,0,0,0.55) ${a}%)`,s.style.opacity="1";},[]),o=react.useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:n,onMouseLeave:o}}function ol({active:e,payload:t,label:n,labelMap:o,allSeries:r,range:i}){if(!e||!r?.length)return null;let s=new Map;t?.forEach(a=>s.set(a.dataKey,a));let l=r.map(a=>s.get(a.slug)??{dataKey:a.slug,value:void 0,stroke:a.color,color:a.color});return jsxRuntime.jsxs("div",{style:{background:"rgba(10,10,10,0.92)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 12px",minWidth:180,backdropFilter:"blur(8px)",fontSize:12},children:[jsxRuntime.jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof n=="number"?el(n,i):n}),l.map(a=>jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsxRuntime.jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:a.stroke??a.color,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:"#9ca3af",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:o.get(a.dataKey)??a.dataKey}),jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:a.value!=null?no(a.value):"--"})]},a.dataKey))]})}function sl({markets:e,selectedSlugs:t,colorMap:n,onToggle:o}){let[r,i]=react.useState(false),s=react.useRef(null);react.useEffect(()=>{if(!r)return;function c(d){s.current&&!s.current.contains(d.target)&&i(false);}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[r]);let l=t.length>=Tt,a=jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(c=>jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:n.get(c)??"#6b7280",display:"inline-block"}},c))}),jsxRuntime.jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?(()=>{let c=e.find(d=>d.slug===t[0]);return c?.outcomes?.[0]?.label??c?.question??"1 market"})():`${t.length} / ${e.length} markets`})]});return jsxRuntime.jsxs("div",{ref:s,style:{position:"relative",display:"inline-block",width:200},children:[jsxRuntime.jsxs("button",{onClick:()=>i(c=>!c),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.05)",cursor:"pointer",width:"100%",userSelect:"none"},children:[a,jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:r?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s",color:"#6b7280"},children:jsxRuntime.jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),r&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"#111827",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",minWidth:260,maxWidth:360,maxHeight:320,overflowY:"auto",padding:"6px 0"},children:[jsxRuntime.jsxs("div",{style:{padding:"4px 12px 8px",fontSize:11,color:"#6b7280",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:["Select up to ",Tt," markets"]}),e.map(c=>{let d=t.includes(c.slug),u=!d&&l,m=d&&t.length===1,f=n.get(c.slug)??"#6b7280",p=c.outcomes.find(v=>v.label.toLowerCase()==="yes")??c.outcomes[0],g=p?.price!=null?`${Math.round(p.price*100)}%`:null;return jsxRuntime.jsxs("button",{onClick:()=>{m||u||o(c.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:d?"rgba(255,255,255,0.05)":"transparent",cursor:u||m?"not-allowed":"pointer",opacity:u?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:v=>{!u&&!m&&(v.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:v=>{v.currentTarget.style.background=d?"rgba(255,255,255,0.05)":"transparent";},children:[jsxRuntime.jsx("span",{style:{width:16,height:16,borderRadius:4,border:d?`2px solid ${f}`:"2px solid rgba(255,255,255,0.2)",background:d?`${f}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:d&&jsxRuntime.jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:f,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:f,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:d?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.outcomes?.[0]?.label??c.question}),g&&jsxRuntime.jsx("span",{style:{color:f,fontWeight:700,fontSize:12,flexShrink:0},children:g})]},c.slug)})]})]})}function al({series:e,colorMap:t,displayValues:n}){return jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 24px",padding:"0 2px"},children:e.map(o=>{let r=t.get(o.marketSlug)??"#6b7280",i=n.get(o.marketSlug);return jsxRuntime.jsxs("div",{style:{display:"inline-flex",alignItems:"flex-start",gap:6},children:[jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r,flexShrink:0,marginTop:3}}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1},children:[jsxRuntime.jsx("span",{style:{color:"#9ca3af",fontSize:12,lineHeight:"17px",whiteSpace:"nowrap"},children:o.label}),jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:i!=null?no(i):"--"})]})]},o.marketSlug)})})}function il(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function ll(e,t){if(e.length<=t)return e;let n=[],o=e.length/t;for(let r=0;r<t;r++){let i=Math.floor(r*o),s=Math.min(Math.floor((r+1)*o),e.length),l=e.slice(i,s),a=l.map(c=>c.price).sort((c,d)=>c-d);n.push({timestamp:l[l.length-1].timestamp,price:il(a)});}return n}function cl(e,t=200){if(e.length===0)return [];let n=e.map(l=>({...l,data:ll(l.data,t)})),o=new Set;n.forEach(l=>l.data.forEach(a=>o.add(a.timestamp)));let r=Array.from(o).sort((l,a)=>l-a),i=n.map(l=>{let a=new Map;return l.data.forEach(c=>a.set(c.timestamp,c.price)),{slug:l.marketSlug,map:a}}),s=new Map;return r.map(l=>{let a={timestamp:l};return i.forEach(({slug:c,map:d})=>{let u=d.get(l);if(u!==void 0)s.set(c,u),a[c]=u;else {let m=s.get(c);m!==void 0&&(a[c]=m);}}),a})}function oo(e){return jsxRuntime.jsx(Sr,{children:jsxRuntime.jsx(dl,{...e})})}function dl({event:e,isLoading:t,className:n,volume:o}){let r=react.useMemo(()=>(e.markets??[]).filter(S=>S.status==="open"),[e.markets]),i=react.useMemo(()=>[...r].sort((S,C)=>{let I=y=>(y.outcomes.find($=>$.label.toLowerCase()==="yes")??y.outcomes[0])?.price??0;return I(C)-I(S)}),[r]),[s,l]=react.useState(()=>i.slice(0,Tt).map(S=>S.slug)),[a,c]=react.useState(xt),d=react.useMemo(()=>{let S=new Map;return s.forEach((C,I)=>{S.set(C,to[I%to.length]);}),S},[s]),u=react.useMemo(()=>r.filter(S=>s.includes(S.slug)),[r,s]),{series:m,isLoading:f}=reactPredict.useMarketHistory(u,a),p=t||f,g=react.useMemo(()=>{if(m.length>0&&m.some(I=>I.data.length>0))return m;let S=Date.now(),C=864e5;return u.map(I=>{let $=(I.outcomes?.find(j=>j.label.toLowerCase()==="yes")??I.outcomes?.[0])?.price??.5;return {marketSlug:I.slug,label:I.outcomes?.[0]?.label??I.question,data:[{timestamp:S-7*C,price:$},{timestamp:S,price:$}]}})},[m,u]),v=react.useMemo(()=>a===reactPredict.ChartRange.ONE_DAY?96:a===reactPredict.ChartRange.ONE_WEEK?168:a===reactPredict.ChartRange.ONE_MONTH?180:300,[a]),h=react.useMemo(()=>cl(g,v),[g,v]),H=react.useMemo(()=>{if(h.length===0)return [0,1];let S=1/0,C=-1/0;if(s.forEach(y=>{h.forEach($=>{let j=$[y];j!=null&&(j<S&&(S=j),j>C&&(C=j));});}),!isFinite(S))return [0,1];let I=Math.max((C-S)*.15,.05);return [Math.max(0,S-I),Math.min(1,C+I)]},[h,s]),P=react.useMemo(()=>{let S=new Map;return g.forEach(C=>{C.data.length>0&&S.set(C.marketSlug,C.data[C.data.length-1].price);}),S},[g]),M=react.useMemo(()=>{let S=new Map;return g.forEach(C=>S.set(C.marketSlug,C.label)),S},[g]),L=react.useMemo(()=>g.map(S=>({slug:S.marketSlug,color:d.get(S.marketSlug)??"#6b7280"})),[g,d]),{wrapperRef:q,overlayRef:R,onMouseMove:ie,onMouseLeave:V}=nl(),fe=react.useCallback(S=>{l(C=>C.includes(S)?C.length<=1?C:C.filter(I=>I!==S):C.length>=Tt?C:[...C,S]);},[]),[Me,Q]=react.useState(null),J=react.useRef(null),le=react.useRef(""),he=react.useRef(0),be=!p&&h.length>0;return jsxRuntime.jsxs("div",{className:n,style:{display:"flex",flexDirection:"column",gap:12},children:[jsxRuntime.jsx(al,{series:g,colorMap:d,displayValues:Me??P}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0},children:[jsxRuntime.jsx("div",{ref:q,style:{height:300,width:"100%",userSelect:"none",position:"relative"},onMouseMove:be?S=>{ie(S),cancelAnimationFrame(he.current),he.current=requestAnimationFrame(()=>{Q(J.current);});}:void 0,onMouseLeave:be?()=>{V(),cancelAnimationFrame(he.current),le.current="",J.current=null,Q(null);}:void 0,children:p?jsxRuntime.jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):h.length===0?jsxRuntime.jsx("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No price history data"}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:R,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.LineChart,{data:h,margin:{top:8,right:16,left:0,bottom:0},children:[jsxRuntime.jsx(recharts.CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:["dataMin","dataMax"],tickFormatter:S=>Zi(S,a),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsxRuntime.jsx(recharts.YAxis,{domain:H,tickFormatter:S=>`${Math.round(S*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsxRuntime.jsx(recharts.Tooltip,{content:S=>{let C=S;if(C.active&&C.payload?.length){let I=C.payload.map(y=>`${y.dataKey}:${y.value}`).join(",");if(I!==le.current){le.current=I;let y=new Map;C.payload.forEach($=>{$.value!=null&&y.set($.dataKey,$.value);}),J.current=y;}}return jsxRuntime.jsx(ol,{...C,labelMap:M,allSeries:L,range:a})},cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},wrapperStyle:{zIndex:2},isAnimationActive:false}),g.map(S=>{let C=d.get(S.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.Line,{type:"linear",dataKey:S.marketSlug,stroke:C,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:C},connectNulls:true,isAnimationActive:false},S.marketSlug)}),Me==null&&h.length>0&&g.map(S=>{let C=h[h.length-1],I=C[S.marketSlug];if(I==null)return null;let y=d.get(S.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.ReferenceDot,{x:C.timestamp,y:I,ifOverflow:"extendDomain",shape:$=>{let{cx:j,cy:z}=$;return j==null||z==null?jsxRuntime.jsx("g",{}):jsxRuntime.jsxs("g",{children:[jsxRuntime.jsxs("circle",{cx:j,cy:z,r:6,fill:y,opacity:.3,children:[jsxRuntime.jsx("animate",{attributeName:"r",values:"4;9;4",dur:"2s",repeatCount:"indefinite"}),jsxRuntime.jsx("animate",{attributeName:"opacity",values:"0.4;0.05;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsxRuntime.jsx("circle",{cx:j,cy:z,r:3.5,fill:y})]})}},`pulse-${S.marketSlug}`)})]})})]})}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:6},children:[o!=null&&o>0&&jsxRuntime.jsxs("span",{style:{color:"#6b7280",fontSize:12},children:["$",Math.round(o).toLocaleString()," vol"]}),jsxRuntime.jsx("div",{style:{flex:1}}),i.length>1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(sl,{markets:i,selectedSlugs:s,colorMap:d,onToggle:fe}),jsxRuntime.jsx("span",{style:{width:1,height:14,background:"#374151",flexShrink:0}})]}),jsxRuntime.jsx(rl,{value:a,onChange:c})]})]})]})}function lt(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Nl(e){return `${parseFloat((e*100).toFixed(2))}%`}function so(e){let t=e*100;return t<1&&t>0?"< 1":parseFloat(t.toFixed(2)).toString()}function Mt(e){return e.outcomes?.[0]?.label??e.question}function wl(e){switch(e){case "polymarket":return "Polymarket";case "dflow":return "Kalshi";default:return e}}function it(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let n=t.toLocaleString("default",{month:"short"}),o=t.getDate(),r=t.getFullYear(),i=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0");return `${n} ${o}, ${r} ${i}:${s}`}function ao(e){let[t,n]=react.useState(Date.now());if(react.useEffect(()=>{if(!e)return;let d=setInterval(()=>n(Date.now()),1e3);return ()=>clearInterval(d)},[e]),!e)return null;let o=new Date(e).getTime();if(isNaN(o))return null;let r=o-t;if(r<=0)return null;let i=Math.floor(r/864e5),s=Math.floor(r%864e5/36e5),l=Math.floor(r%36e5/6e4),a=Math.floor(r%6e4/1e3),c=[];return i>0&&c.push(`${i}d`),c.push(`${String(s).padStart(2,"0")}h`),c.push(`${String(l).padStart(2,"0")}m`),c.push(`${String(a).padStart(2,"0")}s`),c.join(" ")}function io(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let n=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),r=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getDate().toString().padStart(2,"0"),s=t.getFullYear(),l=-t.getTimezoneOffset(),a=l>=0?"+":"-",c=String(Math.abs(Math.floor(l/60))).padStart(2,"0");return `${n}:${o} ${r}/${i}/${s} (${a}${c})`}function uo({event:e,onTradeAction:t}){let{t:n}=i18n.useTranslation(),{ref:o,isCollapsed:r}=hooks.useScrollCollapse(),i=react.useMemo(()=>{let u=[...e.markets||[]],m=u.filter(p=>p.status==="open").sort((p,g)=>lt(g)-lt(p)),f=u.filter(p=>p.status!=="open").sort((p,g)=>lt(g)-lt(p));return [...m,...f]},[e.markets]),s=e.status==="closed"||e.status==="voided",l=ao(s?void 0:e.start_at),a=ao(s?void 0:e.end_at),c=io(e.start_at),d=io(e.end_at);return jsxRuntime.jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxRuntime.jsxs("div",{ref:o,className:`sticky top-0 z-30 flex items-center backdrop-blur-md transition-all duration-300 ${r?"h-14 lg:h-16 gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"h-16 lg:h-20 gap-x-2 lg:gap-x-4"}`,children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",classNames:{base:"bg-transparent"},className:`flex-shrink-0 transition-all duration-300 ${r?"!h-10 !w-10 lg:!h-12 lg:!w-12":"!h-16 !w-16 lg:!h-20 lg:!w-20"}`}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[!r&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[e.tags?.slice(0,3).map((u,m)=>jsxRuntime.jsxs(react.Fragment,{children:[m>0&&jsxRuntime.jsx("span",{className:"text-sm text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-sm text-neutral truncate",children:u.label})]},u.slug)),jsxRuntime.jsx(Cl,{source:e.source})]}),jsxRuntime.jsx("span",{className:`font-semibold truncate transition-all duration-300 ${r?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),(l||a||s)&&jsxRuntime.jsx("div",{className:"flex items-center gap-x-2 text-xs lg:text-sm font-mono",children:s?d&&jsxRuntime.jsx("span",{className:"text-neutral",children:n("predict.event.endedAt",{time:d})}):l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-foreground",children:n("predict.event.beginsIn",{time:l})}),c&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-neutral",children:c})]})]}):a?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-foreground",children:n("predict.event.endsIn",{time:a})}),d&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{className:"text-neutral",children:d})]})]}):null}),jsxRuntime.jsx(oo,{event:e,volume:e.volume??void 0}),jsxRuntime.jsx(kl,{markets:i,onTradeAction:t}),jsxRuntime.jsx(El,{markets:i,event:e})]})}var lo=5;function kl({markets:e,onTradeAction:t}){let{t:n}=i18n.useTranslation(),[o,r]=react.useState(false),[i,s]=react.useState(null),l=e.find(p=>p.status==="open")?.slug,[a,c]=react.useState(l?`${l}:yes`:null);if(e.length===0)return null;let d=e.length>lo,u=o?e:e.slice(0,lo),m=p=>{s(g=>g===p?null:p);},f=(p,g,v)=>{c(`${p.slug}:${g}`),s(p.slug),t?.(p,g,v);};return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("table",{className:"w-full border-collapse",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{children:[jsxRuntime.jsx("th",{}),jsxRuntime.jsx("th",{className:"py-2 text-left text-xs text-neutral font-normal lg:text-center lg:text-sm",children:n("predict.market.table.chance")}),jsxRuntime.jsx("th",{})]})}),jsxRuntime.jsx("tbody",{children:u.map(p=>{let g=lt(p),v=p.outcomes[1]?.best_ask??p.outcomes[1]?.price,h=i===p.slug;return jsxRuntime.jsx(Pl,{market:p,yesPrice:g,noPrice:v??void 0,activeYes:a===`${p.slug}:yes`,activeNo:a===`${p.slug}:no`,isExpanded:h,onToggleExpand:()=>m(p.slug),onTradeAction:f},p.slug)})})]}),d&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>r(p=>!p),className:"flex w-full items-center justify-start gap-x-2 py-2 pl-1 text-xs text-neutral lg:pl-2 lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:n(o?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-4 w-4 transition-transform",o&&"rotate-180")})]})]})}function Pl({market:e,yesPrice:t,noPrice:n,activeYes:o,activeNo:r,isExpanded:i,onToggleExpand:s,onTradeAction:l}){let{t:a}=i18n.useTranslation(),c=e.status==="open",d=e.volume?`$${Math.round(e.volume).toLocaleString("en-US")} vol`:void 0;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:s,role:"button",tabIndex:0,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),s());},children:[jsxRuntime.jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[e.image_url&&jsxRuntime.jsx(ui.Avatar,{src:e.image_url,name:Mt(e)?.[0]||"?",radius:"lg",className:"size-5 shrink-0 lg:size-8",imgProps:{className:"object-cover"}}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate max-w-[200px] lg:max-w-[300px]",children:Mt(e)}),d&&jsxRuntime.jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:d})]})]})}),jsxRuntime.jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:Nl(t)}),jsxRuntime.jsx("td",{className:"py-2 pr-1 lg:pr-2",children:c?jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsxRuntime.jsx("button",{type:"button",className:ui.cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all",o?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:u=>{u.stopPropagation(),l?.(e,"yes","buy");},children:a("predict.market.action.yes",{price:so(t)})}),jsxRuntime.jsx("button",{type:"button",className:ui.cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-all",r?"bg-secondary text-secondary-foreground":"bg-secondary/10 text-secondary"),onClick:u=>{u.stopPropagation(),l?.(e,"no","buy");},children:n!=null?a("predict.market.action.no",{price:so(n)}):a("predict.market.no")})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-end",children:jsxRuntime.jsx("span",{className:ui.cn("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",e.status==="closed"?"bg-neutral/10 text-neutral":e.status==="voided"?"bg-warning/10 text-warning":"bg-primary/10 text-primary"),children:e.status==="closed"?a("predict.event.status.closed"):e.status==="voided"?a("predict.event.status.voided"):a("predict.event.status.pending")})})})]}),i&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:3,className:"pb-3",children:jsxRuntime.jsx("div",{className:"max-h-100 overflow-y-auto",children:jsxRuntime.jsx(eo,{market:e,outcome:r?"no":"yes",onTradeAction:l})})})})]})}function El({markets:e,event:t}){let{t:n}=i18n.useTranslation(),[o,r]=react.useState(false),[i,s]=react.useState(false),[l,a]=react.useState(0),c=e.filter(f=>f.rules&&f.rules.length>0||f.description);if(c.length===0)return null;let d=c[l]??c[0],u=d.rules&&d.rules.length>0?d.rules.join(`
20
20
 
21
- `):d.description??"";if(!u)return null;let m=u.length>200&&!o?u.slice(0,200)+"...":u;return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:n("predict.event.rules")}),c.length>1&&jsxRuntime.jsxs(ui.Dropdown,{placement:"bottom-end",classNames:{content:"min-w-36 bg-content1 border border-border"},children:[jsxRuntime.jsx(ui.DropdownTrigger,{children:jsxRuntime.jsx(ui.Button,{size:"sm",variant:"bordered",radius:"lg",endContent:jsxRuntime.jsx(ui.ChevronDownIcon,{className:"h-3.5 w-3.5"}),className:"text-xs text-foreground",children:kt(d)})}),jsxRuntime.jsx(ui.DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(l)],onAction:f=>{a(Number(f)),r(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:c.map((f,p)=>jsxRuntime.jsx(ui.DropdownItem,{className:ui.cn(p===l?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:kt(f)},String(p)))})]})]}),jsxRuntime.jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:m}),u.length>200&&jsxRuntime.jsx("button",{type:"button",onClick:()=>r(f=>!f),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:n(o?"predict.event.rules.collapse":"predict.event.showMore")}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(f=>!f),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-neutral lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:n("predict.event.timelineAndPayout")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-4 w-4 transition-transform",i&&"rotate-180")})]}),i&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex flex-col",children:(()=>{let f=d.status,p=[];return d.created_at&&p.push({label:n("predict.event.timeline.created"),value:rt(d.created_at),isActive:true}),p.push({label:n("predict.event.timeline.open"),value:rt(d.start_at),isActive:f!=="pending"}),f==="voided"?p.push({label:n("predict.event.timeline.voided"),value:rt(d.closed_at??d.end_at),isActive:true}):f==="closed"?p.push({label:n("predict.event.timeline.closed"),value:rt(d.closed_at??d.end_at),isActive:true}):p.push({label:n("predict.event.timeline.close"),value:rt(d.end_at),isActive:false}),p})().map((f,p,g)=>jsxRuntime.jsxs("div",{className:"flex items-stretch gap-x-3",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-center w-3",children:[jsxRuntime.jsx("div",{className:`h-3 w-3 shrink-0 rounded-full border-2 mt-0.5 ${f.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),p<g.length-1&&jsxRuntime.jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxRuntime.jsxs("div",{className:`flex flex-col ${p<g.length-1?"pb-4":""}`,children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:f.label}),jsxRuntime.jsx("span",{className:"text-xs text-neutral lg:text-sm",children:f.value})]})]},f.label))}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[n("predict.event.id.event"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:t.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[n("predict.event.id.market"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:d.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[n("predict.event.id.source"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:al(d.source)})]})]})]})]})}function dl({source:e}){return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsxRuntime.jsx(ui.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}function eo({eventSlug:e,source:t,onTradeAction:n}){let{data:o,isLoading:r,error:i}=reactPredict.useEvent({slug:e,source:t});return r?jsxRuntime.jsx(et,{}):i||!o?jsxRuntime.jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:i?.message||"Event not found"}):jsxRuntime.jsx(Zn,{event:o,onTradeAction:n})}function to({eventSlug:e,source:t,limit:n=4,onEventClick:o}){let{t:r}=i18n.useTranslation(),{data:i,isLoading:s}=reactPredict.useSimilarEvents({slug:e,source:t,limit:n});return s||!i||i.length===0?null:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:r("predict.similar.title")}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 gap-3",children:i.map(l=>jsxRuntime.jsx(vl,{event:l,onClick:o},l.slug))})]})}function vl({event:e,onClick:t}){let n=e.volume;return jsxRuntime.jsxs("button",{type:"button",onClick:()=>t?.(e),className:"flex items-center gap-x-3 rounded-xl border border-border p-3 hover:bg-content2 transition-colors cursor-pointer text-left w-full",children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"lg",className:"size-8 shrink-0 bg-transparent",imgProps:{className:"object-cover"}}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:e.title}),n!=null&&n>0&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral",children:["$",Math.round(n).toLocaleString()," vol"]})]}),jsxRuntime.jsx(ui.ChevronRightIcon,{className:"h-4 w-4 text-neutral shrink-0"})]})}function ro(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Kp({eventSlug:e,source:t,chain:n,walletAddress:o,onSimilarEventClick:r,onBack:i}){let{t:s}=i18n.useTranslation(),{isMobile:l}=ui.useScreen(),{isOpen:a,onOpen:c,onClose:d}=ui.useDisclosure(),{data:u,isLoading:m}=reactPredict.useEvent({slug:e,source:t}),f=react.useMemo(()=>[...u?.markets||[]].sort((P,C)=>ro(C)-ro(P)),[u?.markets]),[p,g]=react.useState(null),v=react.useCallback((P,C,R)=>{g(j=>({market:P,outcome:C,side:R,version:(j?.version??0)+1})),l&&c();},[l,c]),h=p?.market??f[0];if(m){let P=!!i;return l?jsxRuntime.jsx(et,{showBack:P}):jsxRuntime.jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsxRuntime.jsx(et,{showBack:P})}),jsxRuntime.jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsxRuntime.jsx("div",{className:"sticky top-4 max-h-[calc(100dvh-2rem)] overflow-y-auto scrollbar-thin",children:jsxRuntime.jsx(On,{})})})]})}let U=p?`${p.market.slug}-${p.version}`:h?.slug??"default";return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 pb-12 lg:max-w-7xl lg:gap-y-8 lg:pb-16 mx-auto",children:[jsxRuntime.jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-y-4 px-4 lg:gap-y-6 lg:px-0",children:[i&&jsxRuntime.jsx("div",{className:"flex items-center justify-between",children:jsxRuntime.jsx(ui.Button,{as:"a",onPress:i,startContent:jsxRuntime.jsx(ui.ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-neutral bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:s("common.back")})}),jsxRuntime.jsx(eo,{eventSlug:e,source:t,onTradeAction:v})]}),jsxRuntime.jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[h&&jsxRuntime.jsx(mt,{event:u,market:h,initialSide:p?.side,initialOutcome:p?.outcome,chain:n},U),u&&jsxRuntime.jsx(to,{eventSlug:e,source:u.source,onEventClick:r})]})]}),u&&jsxRuntime.jsx("div",{className:"flex w-full flex-col",children:jsxRuntime.jsx(Ln,{event:u,walletAddress:o})})]})}function no(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Rl(e){switch(e){case reactPredict.ChartRange.ONE_DAY:return {interval:"15m",limit:96};case reactPredict.ChartRange.ONE_WEEK:return {interval:"1h",limit:168};case reactPredict.ChartRange.ONE_MONTH:return {interval:"4h",limit:180};case reactPredict.ChartRange.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var Qp=e=>{let{candlestickMarketSlugs:t,chartRange:n=pt,source:o}=e,r=reactPredict.usePredictClient(),i=react.useMemo(()=>Rl(n),[n]),{data:s,isLoading:l,error:a}=reactPredict.useEvent({slug:e.eventSlug,source:o}),c=react.useMemo(()=>s?.markets?(t&&t.length>0?t.slice(0,4).map(g=>s.markets.find(v=>v.slug===g)).filter(g=>g!==void 0):[...s.markets].sort((g,v)=>no(v)-no(g)).slice(0,4)).map(g=>g.slug):[],[t,s?.markets]),d=reactQuery.useQueries({queries:c.map(p=>({queryKey:reactPredict.candlesticksQueryKey(p,i),queryFn:()=>r.listCandlesticks(p,i),enabled:c.length>0}))}),u=d.some(p=>p.isLoading),m=react.useMemo(()=>{let p=new Map;return c.forEach((g,v)=>{let h=d[v]?.error;h&&p.set(g,h);}),p},[c,d]),f=react.useMemo(()=>{let p=new Map;return c.forEach((g,v)=>{let h=d[v]?.data;h&&p.set(g,h);}),p},[c,d]);return {event:s,isEventLoading:l,eventError:a,candlestickParams:i,candlesticks:f,isCandlesticksLoading:u,candlestickErrors:m}};var Il=10,_l=utils$1.atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function Mt(){let[e,t]=jotai.useAtom(_l),n=react.useCallback(r=>{let i=r.trim();i&&t(s=>{let l=s.filter(a=>a!==i);return [i,...l].slice(0,Il)});},[t]),o=react.useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:n,clearHistories:o}}function io({histories:e,onSelect:t,onClear:n,className:o}){let{t:r}=i18n.useTranslation();return e.length===0?null:jsxRuntime.jsxs("div",{className:ui.cn("px-4 pb-4",o),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:r("predict.search.history")}),jsxRuntime.jsx(ui.Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:n,children:jsxRuntime.jsx(ui.TrashIcon,{width:20,height:20})})]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(i=>jsxRuntime.jsx(ui.Chip,{size:"sm",variant:"bordered",className:ui.cn("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(i),children:i},i))})]})}function lo({onSelect:e,className:t}){let{histories:n,clearHistories:o}=Mt();return jsxRuntime.jsx(io,{className:ui.cn(t),histories:n,onSelect:e,onClear:o})}function co({value:e,onValueChange:t,onClear:n,onEscape:o,className:r}){let{t:i}=i18n.useTranslation();return jsxRuntime.jsx("div",{className:r,children:jsxRuntime.jsx(ui.StyledInput,{autoFocus:true,variant:"flat",radius:"full",value:e,onValueChange:t,placeholder:i("predict.search.placeholder"),startContent:jsxRuntime.jsx(ui.SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsxRuntime.jsx(ui.Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:n,children:jsxRuntime.jsx(ui.XCloseIcon,{width:20,height:20})}):jsxRuntime.jsx(ui.Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-border rounded-full cursor-pointer select-none",onMouseDown:s=>{s.preventDefault(),o?.();},children:"Esc"})})})}function po({event:e,href:t,LinkComponent:n,onSelect:o,onHover:r,className:i}){let{t:s}=i18n.useTranslation(),l=e.tags?.[0],a=react.useMemo(()=>`$${Math.round(e.volume??0).toLocaleString("en-US")}`,[e.volume]);return jsxRuntime.jsxs(ui.Linkable,{href:t,LinkComponent:n,className:ui.cn("w-full h-full px-3 flex items-center gap-3","hover:cursor-pointer hover:bg-content2 rounded-lg","transition-colors duration-150",i),onClick:c=>{t&&o&&c.preventDefault(),o?.(e);},onMouseEnter:()=>r?.(e),children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"min-w-0 text-sm font-medium truncate",children:e.title}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[l&&jsxRuntime.jsx("span",{className:ui.cn("inline-flex items-center","rounded-full px-1.5 py-0.5","text-[10px] font-semibold leading-none uppercase","bg-primary/15 text-primary"),children:l.label}),jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1.5",children:[a," ",s("predict.event.volume"),jsxRuntime.jsx(Zl,{source:e.source})]})]})]})]})}function Zl({source:e}){return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsxRuntime.jsx(ui.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}function mo({keyword:e="",limit:t,source:n}){let{data:o,isLoading:r,isFetchingNextPage:i,hasNextPage:s,fetchNextPage:l}=reactPredict.useSearchEvents({keyword:e,limit:t,source:n},{enabled:true});return {events:react.useMemo(()=>o?.pages.flatMap(c=>c.items).filter(c=>c!=null)??[],[o]),isLoading:r,isFetchingNextPage:i,hasNextPage:s??false,fetchNextPage:l}}var lc=56;function xo({onSelect:e,getEventHref:t,LinkComponent:n,onHover:o,className:r,...i}){let{events:s,isLoading:l,isFetchingNextPage:a,hasNextPage:c,fetchNextPage:d}=mo(i),u=react.useRef(null),{height:m}=hooks.useResizeObserver({ref:u}),f=react.useCallback(h=>h<s.length,[s]),p=react.useCallback(async()=>{c&&!a&&await d();},[c,a,d]),g=react.useMemo(()=>c?s.length+1:s.length,[s,c]),v=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:f,loadMoreRows:p,rowCount:g,threshold:5});return l?jsxRuntime.jsx(dc,{className:r}):s.length===0?jsxRuntime.jsx(uc,{className:r}):jsxRuntime.jsx("div",{className:ui.cn("w-full h-full flex flex-col",r),children:jsxRuntime.jsx("div",{className:"flex-auto min-h-0",ref:u,children:jsxRuntime.jsx(reactWindow.List,{style:{height:m},onRowsRendered:v,rowComponent:cc,rowCount:g,rowHeight:lc,rowProps:{events:s,onSelect:e,getEventHref:t,LinkComponent:n,onHover:o},overscanCount:5})})})}function cc({index:e,style:t,events:n,onSelect:o,getEventHref:r,LinkComponent:i,onHover:s}){let l=n[e];return l?jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(po,{event:l,href:r?.(l),LinkComponent:i,onSelect:o,onHover:s})}):jsxRuntime.jsx("div",{style:t,className:"flex items-center justify-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})})}function dc({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui.cn("flex items-center justify-center gap-2 py-16",e),children:[jsxRuntime.jsx(ui.Spinner,{size:"sm"}),jsxRuntime.jsx("span",{className:"text-sm text-neutral",children:t("predict.search.loading")})]})}function uc({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui.cn("flex flex-col items-center justify-center py-16",e),children:[jsxRuntime.jsx(ui.EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsxRuntime.jsx("p",{className:"mt-2 text-sm text-neutral",children:t("predict.search.noResults")})]})}function wo({onKeywordChange:e}){let[t,n]=react.useState(""),[o,r]=react.useState(""),{addHistory:i}=Mt(),s=hooks.useCallbackRef(e),l=hooks.useCallbackRef(i),a=react.useMemo(()=>utils.debounce(m=>{r(m),s(m),m&&l(m);},500),[s,l]),c=react.useCallback(m=>{n(m),a(m);},[a]),d=react.useCallback(m=>{a.cancel(),n(m),r(m),s(m),m&&l(m);},[a,s,l]),u=react.useCallback(()=>d(""),[d]);return {text:t,keyword:o,setText:c,setKeyword:d,clearKeyword:u}}function So({onKeywordChange:e,onSelectEvent:t,getEventHref:n,LinkComponent:o,onHover:r,onEscape:i,source:s}){let{text:l,keyword:a,setText:c,setKeyword:d,clearKeyword:u}=wo({onKeywordChange:e});return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsxRuntime.jsx(co,{value:l,onValueChange:c,onClear:u,onEscape:i}),!a&&jsxRuntime.jsx(lo,{onSelect:d}),jsxRuntime.jsx(xo,{className:"flex-auto min-h-0",keyword:a,onSelect:t,getEventHref:n,LinkComponent:o,onHover:r,source:s})]})}var hr="predict-search";function hf({id:e=hr}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(kc,{...t})})}function kc({params:e,isOpen:t,onOpenChange:n,onResult:o}){let{t:r}=i18n.useTranslation(),{isMobile:i}=ui.useScreen(),s=react.useCallback(a=>{o(a);},[o]),l=react.useCallback(()=>{n(false);},[n]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:t,onOpenChange:n,size:i?"full":"lg",hideCloseButton:true,backdrop:"blur",radius:"lg",children:jsxRuntime.jsxs(ui.ModalContent,{className:"w-full h-full",children:[jsxRuntime.jsxs(ui.ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsxRuntime.jsx("span",{className:"text-base font-semibold",children:r("predict.search.title")}),jsxRuntime.jsx(ui.Button,{isIconOnly:true,onPress:()=>n(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsxRuntime.jsx(ui.XCloseIcon,{width:20,height:20})})]}),jsxRuntime.jsx(ui.ModalBody,{className:"p-4",children:jsxRuntime.jsx(So,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:s,onEscape:l})})]})})}function Cf({onSelectEvent:e,modalParams:t,className:n}){let{t:o}=i18n.useTranslation(),{isDesktop:r,isMobile:i}=ui.useScreen(),{onOpen:s,onClose:l}=uiScaffold.useAsyncModal(hr),a=hooks.useCallbackRef(e),c=hooks.useCallbackRef(async()=>{let u=await s({params:t});u&&a(u);}),d=hooks.useCallbackRef(()=>{l();});return react.useEffect(()=>{let u=m=>{let f=document.activeElement,p=!!f&&(f.tagName==="INPUT"||f.tagName==="TEXTAREA"||f.getAttribute("contenteditable")==="true");m.key==="/"&&!p&&(m.preventDefault(),c()),m.key==="Escape"&&(m.preventDefault(),d());};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u);}},[c,d]),jsxRuntime.jsx(ui.Button,{size:"sm",radius:"full",isIconOnly:!r,onPress:c,variant:i?"flat":"bordered",startContent:r?jsxRuntime.jsx(ui.SearchIcon,{className:"text-neutral"}):void 0,endContent:r?jsxRuntime.jsx(ui.Kbd,{className:"ml-auto min-w-6 justify-center text-xs bg-transparent border border-border rounded-full",children:"/"}):void 0,className:ui.cn(r&&"min-w-56 justify-start pl-3 pr-1.5 text-neutral",n),children:r?o("predict.search.placeholder"):jsxRuntime.jsx(ui.SearchIcon,{className:"text-neutral"})})}Object.defineProperty(exports,"PredictClient",{enumerable:true,get:function(){return reactPredict.PredictClient}});Object.defineProperty(exports,"PredictContext",{enumerable:true,get:function(){return reactPredict.PredictContext}});Object.defineProperty(exports,"PredictProvider",{enumerable:true,get:function(){return reactPredict.PredictProvider}});Object.defineProperty(exports,"PredictWsClient",{enumerable:true,get:function(){return reactPredict.PredictWsClient}});Object.defineProperty(exports,"createPredictClient",{enumerable:true,get:function(){return reactPredict.createPredictClient}});Object.defineProperty(exports,"createPredictWsClient",{enumerable:true,get:function(){return reactPredict.createPredictWsClient}});Object.defineProperty(exports,"useBalance",{enumerable:true,get:function(){return reactPredict.useBalance}});Object.defineProperty(exports,"useCancelOrder",{enumerable:true,get:function(){return reactPredict.useCancelOrder}});Object.defineProperty(exports,"useCandlesticks",{enumerable:true,get:function(){return reactPredict.useCandlesticks}});Object.defineProperty(exports,"useDFlowKYC",{enumerable:true,get:function(){return reactPredict.useDFlowKYC}});Object.defineProperty(exports,"useDFlowQuote",{enumerable:true,get:function(){return reactPredict.useDFlowQuote}});Object.defineProperty(exports,"useDFlowSubmit",{enumerable:true,get:function(){return reactPredict.useDFlowSubmit}});Object.defineProperty(exports,"useEvent",{enumerable:true,get:function(){return reactPredict.useEvent}});Object.defineProperty(exports,"useEvents",{enumerable:true,get:function(){return reactPredict.useEvents}});Object.defineProperty(exports,"useInfiniteEvents",{enumerable:true,get:function(){return reactPredict.useInfiniteEvents}});Object.defineProperty(exports,"useMarket",{enumerable:true,get:function(){return reactPredict.useMarket}});Object.defineProperty(exports,"useMarketHistory",{enumerable:true,get:function(){return reactPredict.useMarketHistory}});Object.defineProperty(exports,"useMarketTrades",{enumerable:true,get:function(){return reactPredict.useMarketTrades}});Object.defineProperty(exports,"useOrder",{enumerable:true,get:function(){return reactPredict.useOrder}});Object.defineProperty(exports,"useOrderbook",{enumerable:true,get:function(){return reactPredict.useOrderbook}});Object.defineProperty(exports,"useOrders",{enumerable:true,get:function(){return reactPredict.useOrders}});Object.defineProperty(exports,"usePositions",{enumerable:true,get:function(){return reactPredict.usePositions}});Object.defineProperty(exports,"usePredictClient",{enumerable:true,get:function(){return reactPredict.usePredictClient}});Object.defineProperty(exports,"usePriceHistory",{enumerable:true,get:function(){return reactPredict.usePriceHistory}});Object.defineProperty(exports,"useSearchEvents",{enumerable:true,get:function(){return reactPredict.useSearchEvents}});Object.defineProperty(exports,"useSimilarEvents",{enumerable:true,get:function(){return reactPredict.useSimilarEvents}});Object.defineProperty(exports,"useTrades",{enumerable:true,get:function(){return reactPredict.useTrades}});exports.CHART_RANGE_DURATION=Gc;exports.CHART_RANGE_PERIOD=qc;exports.CHART_RANGE_SAMPLE_INTERVAL=jc;exports.CandlestickPeriod=ut;exports.CategoriesSkeleton=Bc;exports.CategoriesUI=Or;exports.CategoriesWidget=Ar;exports.ChartRange=ne;exports.DEFAULT_CHART_RANGE=pt;exports.DEFAULT_FILTER_STATE=qt;exports.DEFAULT_PAGE_SIZE=Ye;exports.DEFAULT_PRICE_HISTORY_INTERVAL=Zc;exports.EventDetailPage=Kp;exports.EventDetailSkeleton=et;exports.EventDetailUI=Zn;exports.EventDetailWidget=eo;exports.EventItem=bn;exports.EventMarketDepthChartUI=Bn;exports.EventMarketDetailWidget=zn;exports.EventPriceChart=qn;exports.EventsFilterUI=en;exports.EventsPage=Ru;exports.EventsPageSkeleton=Zd;exports.EventsSkeleton=Gt;exports.EventsToolbarUI=sn;exports.EventsUI=Pn;exports.EventsWidget=Cn;exports.MAX_PRICE_HISTORY_MARKETS=Ht;exports.ORDER_MAX_PRICE=Jc;exports.ORDER_MIN_PRICE=Qc;exports.ORDER_MIN_QUANTITY=Ut;exports.ORDER_PRICE_STEP=Xc;exports.PREDICT_SEARCH_MODAL_ID=hr;exports.PREDICT_TRADE_MODAL_ID=Yt;exports.PRICE_HISTORY_SAMPLE_INTERVAL=ed;exports.PredictSearchModal=hf;exports.PredictTradeModal=Jr;exports.PredictWalletProvider=rs;exports.PriceHistoryInterval=_e;exports.SORT_PRESETS=on;exports.STATIC_CATEGORIES=Bt;exports.SearchEventsButton=Cf;exports.SearchHistoryUI=io;exports.SearchHistoryWidget=lo;exports.SearchInputUI=co;exports.SearchResultItemUI=po;exports.SearchResultListWidget=xo;exports.SearchWidget=So;exports.SimilarEventCard=vl;exports.SimilarEventsSection=to;exports.TradeFormSkeleton=On;exports.TradeFormUI=Xr;exports.TradeFormWidget=mt;exports.UserActivitySection=Ln;exports.countActiveFilters=jt;exports.formatKMB=tt;exports.useEventDetail=Qp;exports.useEventsInfinite=cn;exports.usePredictSearchHistory=Mt;exports.usePredictWallet=Wt;exports.useSearchResultListScript=mo;exports.useSearchScript=wo;exports.useTradeForm=Vr;exports.version=zo;//# sourceMappingURL=index.js.map
21
+ `):d.description??"";if(!u)return null;let m=u.length>200&&!o?u.slice(0,200)+"...":u;return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:n("predict.event.rules")}),c.length>1&&jsxRuntime.jsxs(ui.Dropdown,{placement:"bottom-end",classNames:{content:"min-w-36 bg-content1 border border-border"},children:[jsxRuntime.jsx(ui.DropdownTrigger,{children:jsxRuntime.jsx(ui.Button,{size:"sm",variant:"bordered",radius:"lg",endContent:jsxRuntime.jsx(ui.ChevronDownIcon,{className:"h-3.5 w-3.5"}),className:"text-xs text-foreground",children:Mt(d)})}),jsxRuntime.jsx(ui.DropdownMenu,{"aria-label":"Select market rules",selectionMode:"single",selectedKeys:[String(l)],onAction:f=>{a(Number(f)),r(false);},classNames:{list:"gap-1"},itemClasses:{base:"rounded-md px-3 h-8"},children:c.map((f,p)=>jsxRuntime.jsx(ui.DropdownItem,{className:ui.cn(p===l?"bg-content2 text-foreground":"text-neutral","data-[hover=true]:bg-content2 data-[hover=true]:text-foreground"),children:Mt(f)},String(p)))})]})]}),jsxRuntime.jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:m}),u.length>200&&jsxRuntime.jsx("button",{type:"button",onClick:()=>r(f=>!f),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:n(o?"predict.event.rules.collapse":"predict.event.showMore")}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>s(f=>!f),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-neutral lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:n("predict.event.timelineAndPayout")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-4 w-4 transition-transform",i&&"rotate-180")})]}),i&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex flex-col",children:(()=>{let f=d.status,p=[];return d.created_at&&p.push({label:n("predict.event.timeline.created"),value:it(d.created_at),isActive:true}),p.push({label:n("predict.event.timeline.open"),value:it(d.start_at),isActive:f!=="pending"}),f==="voided"?p.push({label:n("predict.event.timeline.voided"),value:it(d.closed_at??d.end_at),isActive:true}):f==="closed"?p.push({label:n("predict.event.timeline.closed"),value:it(d.closed_at??d.end_at),isActive:true}):p.push({label:n("predict.event.timeline.close"),value:it(d.end_at),isActive:false}),p})().map((f,p,g)=>jsxRuntime.jsxs("div",{className:"flex items-stretch gap-x-3",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-center w-3",children:[jsxRuntime.jsx("div",{className:`h-3 w-3 shrink-0 rounded-full border-2 mt-0.5 ${f.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),p<g.length-1&&jsxRuntime.jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxRuntime.jsxs("div",{className:`flex flex-col ${p<g.length-1?"pb-4":""}`,children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:f.label}),jsxRuntime.jsx("span",{className:"text-xs text-neutral lg:text-sm",children:f.value})]})]},f.label))}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[n("predict.event.id.event"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:t.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[n("predict.event.id.market"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:d.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[n("predict.event.id.source"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:wl(d.source)})]})]})]})]})}function Cl({source:e}){return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsxRuntime.jsx(ui.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}function po({eventSlug:e,source:t,onTradeAction:n}){let{data:o,isLoading:r,error:i}=reactPredict.useEvent({slug:e,source:t});return r?jsxRuntime.jsx(st,{}):i||!o?jsxRuntime.jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:i?.message||"Event not found"}):jsxRuntime.jsx(uo,{event:o,onTradeAction:n})}function mo({eventSlug:e,source:t,limit:n=4,onEventClick:o}){let{t:r}=i18n.useTranslation(),{data:i,isLoading:s}=reactPredict.useSimilarEvents({slug:e,source:t,limit:n});return s||!i||i.length===0?null:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:r("predict.similar.title")}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 gap-3",children:i.map(l=>jsxRuntime.jsx(Il,{event:l,onClick:o},l.slug))})]})}function Il({event:e,onClick:t}){let n=e.volume;return jsxRuntime.jsxs("button",{type:"button",onClick:()=>t?.(e),className:"flex items-center gap-x-3 rounded-xl border border-border p-3 hover:bg-content2 transition-colors cursor-pointer text-left w-full",children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"lg",className:"size-8 shrink-0 bg-transparent",imgProps:{className:"object-cover"}}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:e.title}),n!=null&&n>0&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral",children:["$",Math.round(n).toLocaleString()," vol"]})]}),jsxRuntime.jsx(ui.ChevronRightIcon,{className:"h-4 w-4 text-neutral shrink-0"})]})}function fo(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function im({eventSlug:e,source:t,chain:n,walletAddress:o,onSimilarEventClick:r,onBack:i}){let{t:s}=i18n.useTranslation(),{isMobile:l}=ui.useScreen(),{isOpen:a,onOpen:c,onClose:d}=ui.useDisclosure(),{data:u,isLoading:m}=reactPredict.useEvent({slug:e,source:t}),f=react.useMemo(()=>[...u?.markets||[]].sort((P,M)=>fo(M)-fo(P)),[u?.markets]),[p,g]=react.useState(null),v=react.useCallback((P,M,L)=>{g(q=>({market:P,outcome:M,side:L,version:(q?.version??0)+1})),l&&c();},[l,c]),h=p?.market??f[0];if(m){let P=!!i;return l?jsxRuntime.jsx(st,{showBack:P}):jsxRuntime.jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsxRuntime.jsx(st,{showBack:P})}),jsxRuntime.jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsxRuntime.jsx("div",{className:"sticky top-4 max-h-[calc(100dvh-2rem)] overflow-y-auto scrollbar-thin",children:jsxRuntime.jsx(zn,{})})})]})}let H=p?`${p.market.slug}-${p.version}`:h?.slug??"default";return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 pb-12 lg:max-w-7xl lg:gap-y-8 lg:pb-16 mx-auto",children:[jsxRuntime.jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-y-4 px-4 lg:gap-y-6 lg:px-0",children:[i&&jsxRuntime.jsx("div",{className:"flex items-center justify-between",children:jsxRuntime.jsx(ui.Button,{as:"a",onPress:i,startContent:jsxRuntime.jsx(ui.ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-neutral bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:s("common.back")})}),jsxRuntime.jsx(po,{eventSlug:e,source:t,onTradeAction:v})]}),jsxRuntime.jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[h&&jsxRuntime.jsx(ht,{event:u,market:h,initialSide:p?.side,initialOutcome:p?.outcome,chain:n},H),u&&jsxRuntime.jsx(mo,{eventSlug:e,source:u.source,onEventClick:r})]})]}),u&&jsxRuntime.jsx("div",{className:"flex w-full flex-col",children:jsxRuntime.jsx(Wn,{event:u,walletAddress:o})})]})}function go(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function ql(e){switch(e){case reactPredict.ChartRange.ONE_DAY:return {interval:"15m",limit:96};case reactPredict.ChartRange.ONE_WEEK:return {interval:"1h",limit:168};case reactPredict.ChartRange.ONE_MONTH:return {interval:"4h",limit:180};case reactPredict.ChartRange.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var fm=e=>{let{candlestickMarketSlugs:t,chartRange:n=xt,source:o}=e,r=reactPredict.usePredictClient(),i=react.useMemo(()=>ql(n),[n]),{data:s,isLoading:l,error:a}=reactPredict.useEvent({slug:e.eventSlug,source:o}),c=react.useMemo(()=>s?.markets?(t&&t.length>0?t.slice(0,4).map(g=>s.markets.find(v=>v.slug===g)).filter(g=>g!==void 0):[...s.markets].sort((g,v)=>go(v)-go(g)).slice(0,4)).map(g=>g.slug):[],[t,s?.markets]),d=reactQuery.useQueries({queries:c.map(p=>({queryKey:reactPredict.candlesticksQueryKey(p,i),queryFn:()=>r.listCandlesticks(p,i),enabled:c.length>0}))}),u=d.some(p=>p.isLoading),m=react.useMemo(()=>{let p=new Map;return c.forEach((g,v)=>{let h=d[v]?.error;h&&p.set(g,h);}),p},[c,d]),f=react.useMemo(()=>{let p=new Map;return c.forEach((g,v)=>{let h=d[v]?.data;h&&p.set(g,h);}),p},[c,d]);return {event:s,isEventLoading:l,eventError:a,candlestickParams:i,candlesticks:f,isCandlesticksLoading:u,candlestickErrors:m}};var Xl=10,Ql=utils$1.atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function _t(){let[e,t]=jotai.useAtom(Ql),n=react.useCallback(r=>{let i=r.trim();i&&t(s=>{let l=s.filter(a=>a!==i);return [i,...l].slice(0,Xl)});},[t]),o=react.useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:n,clearHistories:o}}function bo({histories:e,onSelect:t,onClear:n,className:o}){let{t:r}=i18n.useTranslation();return e.length===0?null:jsxRuntime.jsxs("div",{className:ui.cn("px-4 pb-4",o),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:r("predict.search.history")}),jsxRuntime.jsx(ui.Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:n,children:jsxRuntime.jsx(ui.TrashIcon,{width:20,height:20})})]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(i=>jsxRuntime.jsx(ui.Chip,{size:"sm",variant:"bordered",className:ui.cn("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(i),children:i},i))})]})}function yo({onSelect:e,className:t}){let{histories:n,clearHistories:o}=_t();return jsxRuntime.jsx(bo,{className:ui.cn(t),histories:n,onSelect:e,onClear:o})}function So({value:e,onValueChange:t,onClear:n,onEscape:o,className:r}){let{t:i}=i18n.useTranslation();return jsxRuntime.jsx("div",{className:r,children:jsxRuntime.jsx(ui.StyledInput,{autoFocus:true,variant:"flat",radius:"full",value:e,onValueChange:t,placeholder:i("predict.search.placeholder"),startContent:jsxRuntime.jsx(ui.SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsxRuntime.jsx(ui.Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:n,children:jsxRuntime.jsx(ui.XCloseIcon,{width:20,height:20})}):jsxRuntime.jsx(ui.Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-border rounded-full cursor-pointer select-none",onMouseDown:s=>{s.preventDefault(),o?.();},children:"Esc"})})})}function wo({event:e,href:t,LinkComponent:n,onSelect:o,onHover:r,className:i}){let{t:s}=i18n.useTranslation(),l=e.tags?.[0],a=react.useMemo(()=>`$${Math.round(e.volume??0).toLocaleString("en-US")}`,[e.volume]);return jsxRuntime.jsxs(ui.Linkable,{href:t,LinkComponent:n,className:ui.cn("w-full h-full px-3 flex items-center gap-3","hover:cursor-pointer hover:bg-content2 rounded-lg","transition-colors duration-150",i),onClick:c=>{t&&o&&c.preventDefault(),o?.(e);},onMouseEnter:()=>r?.(e),children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 flex flex-col justify-center gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"min-w-0 text-sm font-medium truncate",children:e.title}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[l&&jsxRuntime.jsx("span",{className:ui.cn("inline-flex items-center","rounded-full px-1.5 py-0.5","text-[10px] font-semibold leading-none uppercase","bg-primary/15 text-primary"),children:l.label}),jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1.5",children:[a," ",s("predict.event.volume"),jsxRuntime.jsx(vc,{source:e.source})]})]})]})]})}function vc({source:e}){return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsxRuntime.jsx(ui.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}function ko({keyword:e="",limit:t,source:n}){let{data:o,isLoading:r,isFetchingNextPage:i,hasNextPage:s,fetchNextPage:l}=reactPredict.useSearchEvents({keyword:e,limit:t,source:n},{enabled:true});return {events:react.useMemo(()=>o?.pages.flatMap(c=>c.items).filter(c=>c!=null)??[],[o]),isLoading:r,isFetchingNextPage:i,hasNextPage:s??false,fetchNextPage:l}}var Pc=56;function To({onSelect:e,getEventHref:t,LinkComponent:n,onHover:o,className:r,...i}){let{events:s,isLoading:l,isFetchingNextPage:a,hasNextPage:c,fetchNextPage:d}=ko(i),u=react.useRef(null),{height:m}=hooks.useResizeObserver({ref:u}),f=react.useCallback(h=>h<s.length,[s]),p=react.useCallback(async()=>{c&&!a&&await d();},[c,a,d]),g=react.useMemo(()=>c?s.length+1:s.length,[s,c]),v=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:f,loadMoreRows:p,rowCount:g,threshold:5});return l?jsxRuntime.jsx(Cc,{className:r}):s.length===0?jsxRuntime.jsx(Tc,{className:r}):jsxRuntime.jsx("div",{className:ui.cn("w-full h-full flex flex-col",r),children:jsxRuntime.jsx("div",{className:"flex-auto min-h-0",ref:u,children:jsxRuntime.jsx(reactWindow.List,{style:{height:m},onRowsRendered:v,rowComponent:Ec,rowCount:g,rowHeight:Pc,rowProps:{events:s,onSelect:e,getEventHref:t,LinkComponent:n,onHover:o},overscanCount:5})})})}function Ec({index:e,style:t,events:n,onSelect:o,getEventHref:r,LinkComponent:i,onHover:s}){let l=n[e];return l?jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(wo,{event:l,href:r?.(l),LinkComponent:i,onSelect:o,onHover:s})}):jsxRuntime.jsx("div",{style:t,className:"flex items-center justify-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})})}function Cc({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui.cn("flex items-center justify-center gap-2 py-16",e),children:[jsxRuntime.jsx(ui.Spinner,{size:"sm"}),jsxRuntime.jsx("span",{className:"text-sm text-neutral",children:t("predict.search.loading")})]})}function Tc({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui.cn("flex flex-col items-center justify-center py-16",e),children:[jsxRuntime.jsx(ui.EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsxRuntime.jsx("p",{className:"mt-2 text-sm text-neutral",children:t("predict.search.noResults")})]})}function Oo({onKeywordChange:e}){let[t,n]=react.useState(""),[o,r]=react.useState(""),{addHistory:i}=_t(),s=hooks.useCallbackRef(e),l=hooks.useCallbackRef(i),a=react.useMemo(()=>utils.debounce(m=>{r(m),s(m),m&&l(m);},500),[s,l]),c=react.useCallback(m=>{n(m),a(m);},[a]),d=react.useCallback(m=>{a.cancel(),n(m),r(m),s(m),m&&l(m);},[a,s,l]),u=react.useCallback(()=>d(""),[d]);return {text:t,keyword:o,setText:c,setKeyword:d,clearKeyword:u}}function Io({onKeywordChange:e,onSelectEvent:t,getEventHref:n,LinkComponent:o,onHover:r,onEscape:i,source:s}){let{text:l,keyword:a,setText:c,setKeyword:d,clearKeyword:u}=Oo({onKeywordChange:e});return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsxRuntime.jsx(So,{value:l,onValueChange:c,onClear:u,onEscape:i}),!a&&jsxRuntime.jsx(yo,{onSelect:d}),jsxRuntime.jsx(To,{className:"flex-auto min-h-0",keyword:a,onSelect:t,getEventHref:n,LinkComponent:o,onHover:r,source:s})]})}var Cr="predict-search";function Df({id:e=Cr}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx($c,{...t})})}function $c({params:e,isOpen:t,onOpenChange:n,onResult:o}){let{t:r}=i18n.useTranslation(),{isMobile:i}=ui.useScreen(),s=react.useCallback(a=>{o(a);},[o]),l=react.useCallback(()=>{n(false);},[n]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:t,onOpenChange:n,size:i?"full":"lg",hideCloseButton:true,backdrop:"blur",radius:"lg",children:jsxRuntime.jsxs(ui.ModalContent,{className:"w-full h-full",children:[jsxRuntime.jsxs(ui.ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsxRuntime.jsx("span",{className:"text-base font-semibold",children:r("predict.search.title")}),jsxRuntime.jsx(ui.Button,{isIconOnly:true,onPress:()=>n(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsxRuntime.jsx(ui.XCloseIcon,{width:20,height:20})})]}),jsxRuntime.jsx(ui.ModalBody,{className:"p-4",children:jsxRuntime.jsx(Io,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:s,onEscape:l})})]})})}function Kf({onSelectEvent:e,modalParams:t,className:n}){let{t:o}=i18n.useTranslation(),{isDesktop:r,isMobile:i}=ui.useScreen(),{onOpen:s,onClose:l}=uiScaffold.useAsyncModal(Cr),a=hooks.useCallbackRef(e),c=hooks.useCallbackRef(async()=>{let u=await s({params:t});u&&a(u);}),d=hooks.useCallbackRef(()=>{l();});return react.useEffect(()=>{let u=m=>{let f=document.activeElement,p=!!f&&(f.tagName==="INPUT"||f.tagName==="TEXTAREA"||f.getAttribute("contenteditable")==="true");m.key==="/"&&!p&&(m.preventDefault(),c()),m.key==="Escape"&&(m.preventDefault(),d());};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u);}},[c,d]),jsxRuntime.jsx(ui.Button,{size:"sm",radius:"full",isIconOnly:!r,onPress:c,variant:i?"flat":"bordered",startContent:r?jsxRuntime.jsx(ui.SearchIcon,{className:"text-neutral"}):void 0,endContent:r?jsxRuntime.jsx(ui.Kbd,{className:"ml-auto min-w-6 justify-center text-xs bg-transparent border border-border rounded-full",children:"/"}):void 0,className:ui.cn(r&&"min-w-56 justify-start pl-3 pr-1.5 text-neutral",n),children:r?o("predict.search.placeholder"):jsxRuntime.jsx(ui.SearchIcon,{className:"text-neutral"})})}Object.defineProperty(exports,"PredictClient",{enumerable:true,get:function(){return reactPredict.PredictClient}});Object.defineProperty(exports,"PredictContext",{enumerable:true,get:function(){return reactPredict.PredictContext}});Object.defineProperty(exports,"PredictProvider",{enumerable:true,get:function(){return reactPredict.PredictProvider}});Object.defineProperty(exports,"PredictWsClient",{enumerable:true,get:function(){return reactPredict.PredictWsClient}});Object.defineProperty(exports,"createPredictClient",{enumerable:true,get:function(){return reactPredict.createPredictClient}});Object.defineProperty(exports,"createPredictWsClient",{enumerable:true,get:function(){return reactPredict.createPredictWsClient}});Object.defineProperty(exports,"useBalance",{enumerable:true,get:function(){return reactPredict.useBalance}});Object.defineProperty(exports,"useCancelOrder",{enumerable:true,get:function(){return reactPredict.useCancelOrder}});Object.defineProperty(exports,"useCandlesticks",{enumerable:true,get:function(){return reactPredict.useCandlesticks}});Object.defineProperty(exports,"useDFlowKYC",{enumerable:true,get:function(){return reactPredict.useDFlowKYC}});Object.defineProperty(exports,"useDFlowQuote",{enumerable:true,get:function(){return reactPredict.useDFlowQuote}});Object.defineProperty(exports,"useDFlowSubmit",{enumerable:true,get:function(){return reactPredict.useDFlowSubmit}});Object.defineProperty(exports,"useEvent",{enumerable:true,get:function(){return reactPredict.useEvent}});Object.defineProperty(exports,"useEvents",{enumerable:true,get:function(){return reactPredict.useEvents}});Object.defineProperty(exports,"useInfiniteEvents",{enumerable:true,get:function(){return reactPredict.useInfiniteEvents}});Object.defineProperty(exports,"useMarket",{enumerable:true,get:function(){return reactPredict.useMarket}});Object.defineProperty(exports,"useMarketHistory",{enumerable:true,get:function(){return reactPredict.useMarketHistory}});Object.defineProperty(exports,"useMarketTrades",{enumerable:true,get:function(){return reactPredict.useMarketTrades}});Object.defineProperty(exports,"useOrder",{enumerable:true,get:function(){return reactPredict.useOrder}});Object.defineProperty(exports,"useOrderbook",{enumerable:true,get:function(){return reactPredict.useOrderbook}});Object.defineProperty(exports,"useOrders",{enumerable:true,get:function(){return reactPredict.useOrders}});Object.defineProperty(exports,"usePositions",{enumerable:true,get:function(){return reactPredict.usePositions}});Object.defineProperty(exports,"usePredictClient",{enumerable:true,get:function(){return reactPredict.usePredictClient}});Object.defineProperty(exports,"usePriceHistory",{enumerable:true,get:function(){return reactPredict.usePriceHistory}});Object.defineProperty(exports,"useSearchEvents",{enumerable:true,get:function(){return reactPredict.useSearchEvents}});Object.defineProperty(exports,"useSimilarEvents",{enumerable:true,get:function(){return reactPredict.useSimilarEvents}});Object.defineProperty(exports,"useTrades",{enumerable:true,get:function(){return reactPredict.useTrades}});exports.CHART_RANGE_DURATION=pd;exports.CHART_RANGE_PERIOD=dd;exports.CHART_RANGE_SAMPLE_INTERVAL=ud;exports.CandlestickPeriod=vt;exports.CategoriesSkeleton=td;exports.CategoriesUI=$r;exports.CategoriesWidget=Kr;exports.ChartRange=oe;exports.DEFAULT_CHART_RANGE=xt;exports.DEFAULT_FILTER_STATE=rr;exports.DEFAULT_PAGE_SIZE=Qe;exports.DEFAULT_PRICE_HISTORY_INTERVAL=vd;exports.EventDetailPage=im;exports.EventDetailSkeleton=st;exports.EventDetailUI=uo;exports.EventDetailWidget=po;exports.EventItem=Rn;exports.EventMarketDepthChartUI=Gn;exports.EventMarketDetailWidget=eo;exports.EventPriceChart=oo;exports.EventsFilterUI=pn;exports.EventsPage=qu;exports.EventsPageSkeleton=vu;exports.EventsSkeleton=or;exports.EventsToolbarUI=xn;exports.EventsUI=An;exports.EventsWidget=Bn;exports.MAX_PRICE_HISTORY_MARKETS=qt;exports.ORDER_MAX_PRICE=gd;exports.ORDER_MIN_PRICE=fd;exports.ORDER_MIN_QUANTITY=jt;exports.ORDER_PRICE_STEP=md;exports.PREDICT_SEARCH_MODAL_ID=Cr;exports.PREDICT_TRADE_MODAL_ID=tr;exports.PRICE_HISTORY_SAMPLE_INTERVAL=xd;exports.PredictSearchModal=Df;exports.PredictTradeModal=dn;exports.PredictWalletProvider=ms;exports.PriceHistoryInterval=Be;exports.SORT_PRESETS=vn;exports.STATIC_CATEGORIES=Yt;exports.SearchEventsButton=Kf;exports.SearchHistoryUI=bo;exports.SearchHistoryWidget=yo;exports.SearchInputUI=So;exports.SearchResultItemUI=wo;exports.SearchResultListWidget=To;exports.SearchWidget=Io;exports.SimilarEventCard=Il;exports.SimilarEventsSection=mo;exports.TradeFormSkeleton=zn;exports.TradeFormUI=ln;exports.TradeFormWidget=ht;exports.UserActivitySection=Wn;exports.countActiveFilters=nr;exports.formatKMB=at;exports.useEventDetail=fm;exports.useEventsInfinite=yn;exports.usePredictSearchHistory=_t;exports.usePredictWallet=Xt;exports.useSearchResultListScript=ko;exports.useSearchScript=Oo;exports.useTradeForm=en;exports.version=es;//# sourceMappingURL=index.js.map
22
22
  //# sourceMappingURL=index.js.map