@liberfi.io/ui-predict 0.1.76 → 0.1.77
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/README.md +11 -9
- package/dist/index.d.mts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var react=require('react'),ui=require('@liberfi.io/ui'),i18n=require('@liberfi.io/i18n'),jsxRuntime=require('react/jsx-runtime'),reactPredict=require('@liberfi.io/react-predict'),reactWindow=require('react-window'),reactWindowInfiniteLoader=require('react-window-infinite-loader'),hooks=require('@liberfi.io/hooks'),walletConnector=require('@liberfi.io/wallet-connector'),Pt=require('canvas-confetti'),types=require('@liberfi.io/types'),utils=require('@liberfi.io/utils'),recharts=require('recharts'),reactQuery=require('@tanstack/react-query'),uiScaffold=require('@liberfi.io/ui-scaffold'),jotai=require('jotai'),utils$1=require('jotai/utils');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Pt__default=/*#__PURE__*/_interopDefault(Pt);typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-predict"]="0.1.76");var Wn="0.1.76";var $n={Weather:["Daily temperature","Snow and rain","Climate change","Natural disasters","Hurricanes"],Companies:["IPOs","Product launches","KPIs","Elon Musk","CEOs","Layoffs"],Crypto:["BTC","15 min","Hourly","ETH","SOL","DOGE","Pre-Market","XRP","BNB","HYPE"],Economics:["Growth","Fed","Inflation","Oil and energy","Employment","Housing","Jobs & Economy","Bankruptcy & Defaults","GDP","Global Central Banks"],Elections:["Primaries","International elections"],Entertainment:["Music","Movies","Music charts","Television","Awards","Video games","Oscars","Rotten Tomatoes"],Financials:["S&P","Nasdaq","Daily","Metals","Treasuries","Oil","EUR/USD","USD/JPY","WTI"],Mentions:["Politicians","Earnings","Entertainment"],Politics:["Trump","Congress","International","SCOTUS & courts","Local","Recurring","Iran","House"],Science:["AI","Energy","Space"],Social:null,Sports:["Soccer","Basketball","Baseball","Football","Hockey","Golf","Tennis","Motorsport","Esports","Boxing","MMA","Rugby","Lacrosse","Mentions","Chess","Cricket","Aussie Rules","Darts"],World:null},Wt=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],dt=(()=>{let e=t=>{let r=Wt.indexOf(t);return r===-1?Wt.length:r};return Object.entries($n).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(o=>({slug:o,label:o}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function Kt({categories:e,selectedCategory:t,selectedTag:r,activeTags:o,onCategorySelect:n,onTagSelect:s,trailing:a,pulsingTab:i="Trending",className:c}){let{t:l}=i18n.useTranslation(),d=react.useCallback(()=>{n(null);},[n]),u=l("predict.categories.trending");return jsxRuntime.jsxs("div",{className:ui.cn("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-1 lg:px-2 lg:py-1",c),children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center gap-2",children:[jsxRuntime.jsx("div",{className:"hideScrollbar min-w-0 flex-1 overflow-x-auto overflow-y-hidden",children:jsxRuntime.jsxs("div",{className:"flex min-h-8 items-stretch gap-x-2 lg:min-h-9",children:[jsxRuntime.jsx($t,{label:u,isSelected:t===null,onPress:d,showPulse:u===i}),jsxRuntime.jsx(Yn,{}),e.map(p=>jsxRuntime.jsx($t,{label:p.category,isSelected:t===p.category,onPress:()=>n(p.category),badge:p.badge,showPulse:p.category===i},p.category))]})}),a&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:a})]}),t&&o.length>0&&jsxRuntime.jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxRuntime.jsxs("div",{className:"flex gap-x-1 pl-2 lg:w-full lg:gap-x-2",children:[jsxRuntime.jsx(zt,{label:l("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>s(null)}),o.map(p=>jsxRuntime.jsx(zt,{label:p.label,icon:p.icon,isSelected:r===p.label,onPress:()=>s(p.label)},p.label))]})})]})}function $t({label:e,isSelected:t,onPress:r,badge:o,showPulse:n}){return jsxRuntime.jsxs("button",{type:"button",onClick:r,className:ui.cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b p-1 text-base font-normal capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[n?jsxRuntime.jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsxRuntime.jsx("span",{children:e})]}):e,o&&jsxRuntime.jsx("span",{className:"absolute -right-1 top-0 rounded bg-primary px-0.5 py-px text-[0.625rem] font-semibold leading-none text-neutral-950",children:o})]})}function Yn(){return jsxRuntime.jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function zt({label:e,icon:t,isSelected:r,onPress:o}){return jsxRuntime.jsxs("button",{type:"button",onClick:o,className:ui.cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-2 py-1 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-transparent bg-primary text-black":"border-border/80 text-neutral-200 hover:bg-primary/10 hover:text-primary"),children:[t&&jsxRuntime.jsx("span",{className:ui.cn("iconify size-4",t)}),e]})}function fl({count:e=6}){return jsxRuntime.jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-1 lg:px-2 lg:py-1",children:jsxRuntime.jsx("div",{className:"flex min-h-8 items-center gap-x-2 lg:min-h-9",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 shrink-0 rounded"},r))})})}function qn(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function jn(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function qt({onSelect:e,trailing:t,className:r}){let[o,n]=react.useState(null),[s,a]=react.useState(null),i=react.useCallback(p=>{n(p),a(null),e?.({categorySlug:p,tagSlug:null});},[e]),c=react.useCallback(p=>{a(p),e?.({categorySlug:o,tagSlug:p});},[o,e]),l=qn(dt),d=dt.find(p=>p.slug===o),u=jn(d);return jsxRuntime.jsx(Kt,{categories:l,selectedCategory:o,selectedTag:s,activeTags:u,onCategorySelect:i,onTagSelect:c,trailing:t,className:r})}var ut={sortPreset:"volume",sortAsc:false,source:"dflow",timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function pt(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function Gt({isOpen:e,onClose:t,value:r,onChange:o}){let{t:n}=i18n.useTranslation(),[s,a]=react.useState(r),i=react.useCallback(h=>{h?a(r):t();},[r,t]),c=react.useCallback(()=>{a(ut);},[]),l=react.useCallback(()=>{o(s),t();},[s,o,t]),d=react.useCallback((h,v)=>{a(O=>({...O,[h]:v}));},[]),u=react.useMemo(()=>pt(s),[s]),p=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"polymarket",label:n("predict.platform.polymarket")},{value:"dflow",label:n("predict.platform.dflow")}],[n]),m=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1d",label:n("predict.filter.lessThanDay")},{value:"7d",label:n("predict.filter.lessThanWeek")},{value:"30d",label:n("predict.filter.lessThanMonth")}],[n]),g=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[n]),f=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[n]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:i,size:"md",scrollBehavior:"inside",children:jsxRuntime.jsxs(ui.ModalContent,{children:[jsxRuntime.jsx(ui.ModalHeader,{className:"px-4 py-2",children:jsxRuntime.jsx("span",{className:"text-base font-semibold",children:n("predict.filter.title")})}),jsxRuntime.jsxs(ui.ModalBody,{className:"flex flex-col gap-5",children:[jsxRuntime.jsx($e,{label:n("predict.filter.platform"),children:jsxRuntime.jsx(ze,{options:p,selected:s.source,onSelect:h=>d("source",h)})}),jsxRuntime.jsx($e,{label:n("predict.filter.timeRemaining"),children:jsxRuntime.jsx(ze,{options:m,selected:s.timeRemaining,onSelect:h=>d("timeRemaining",h)})}),jsxRuntime.jsx($e,{label:n("predict.filter.minVolume"),children:jsxRuntime.jsx(ze,{options:g,selected:s.minVolume,onSelect:h=>d("minVolume",h)})}),jsxRuntime.jsx($e,{label:n("predict.filter.minLiquidity"),children:jsxRuntime.jsx(ze,{options:f,selected:s.minLiquidity,onSelect:h=>d("minLiquidity",h)})})]}),jsxRuntime.jsx(ui.ModalFooter,{className:"px-4",children:jsxRuntime.jsxs("div",{className:"w-full flex justify-between items-center",children:[jsxRuntime.jsx(ui.Button,{variant:"light",color:"default",size:"sm",radius:"full",startContent:jsxRuntime.jsx(ui.RefreshIcon,{width:16,height:16}),onPress:c,children:n("predict.filter.reset")}),jsxRuntime.jsxs(ui.Button,{color:"primary",size:"sm",radius:"full",onPress:l,children:[n("predict.filter.showResults"),u>0&&jsxRuntime.jsxs("span",{className:"ml-1 text-xs opacity-80",children:["(",u,")"]})]})]})})]})})}function $e({label:e,children:t}){return jsxRuntime.jsxs("div",{className:"flex flex-col gap-2.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground",children:e}),t]})}function ze({options:e,selected:t,onSelect:r,allowDeselect:o=true}){return jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(n=>{let s=t===n.value;return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(s&&o?void 0:n.value);},className:ui.cn("shrink-0 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors duration-150 cursor-pointer border",s?"bg-primary/15 text-primary border-primary/40":"bg-content2 text-foreground/60 border-default-100 hover:bg-default-100 hover:text-foreground"),children:n.label},n.value??"__all")})})}var Jt={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},Qt={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},vo=["start_time","volume","liquidity","ending_soon"];function er({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:o,onFilterPress:n,filterCount:s=0,className:a}){let{t:i}=i18n.useTranslation(),[c,l]=react.useState(false),d=react.useRef(null);react.useEffect(()=>{if(!c)return;let p=g=>{d.current&&!d.current.contains(g.target)&&l(false);},m=g=>{g.key==="Escape"&&l(false);};return document.addEventListener("mousedown",p),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",m);}},[c]);let u=Zt[e];return jsxRuntime.jsxs("div",{className:ui.cn("flex items-center gap-2",a),children:[jsxRuntime.jsxs("div",{ref:d,className:"relative flex shrink-0 items-center rounded-full border border-border",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>l(p=>!p),className:"flex shrink-0 items-center gap-2 px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsxRuntime.jsx(u,{className:"size-[18px] shrink-0"}),jsxRuntime.jsx("span",{className:"whitespace-nowrap",children:i(Qt[e])})]}),jsxRuntime.jsx("div",{className:"h-6 w-px bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o(!r),className:"px-2.5 py-1.5 text-xs text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:r?"\u2191":"\u2193"}),c&&jsxRuntime.jsx("div",{className:"absolute left-0 top-full z-20 mt-1 flex min-w-max flex-col gap-0.5 rounded-lg border border-border bg-content1 p-1 shadow-lg",children:vo.map(p=>{let m=Zt[p];return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{t(p),l(false);},className:ui.cn("flex w-full items-center gap-2 rounded px-2.5 py-1.5 text-xs font-medium transition-colors cursor-pointer",p===e?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsxRuntime.jsx(m,{className:"size-4 shrink-0"}),jsxRuntime.jsx("span",{children:i(Qt[p])})]},p)})})]}),jsxRuntime.jsx(ui.StyledBadge,{content:s>0?s:void 0,color:"primary",size:"sm",isInvisible:s===0,children:jsxRuntime.jsxs("button",{type:"button",onClick:n,className:"flex shrink-0 items-center gap-2 rounded-full border border-border px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsxRuntime.jsx(ui.FilterIcon,{className:"size-[18px]"}),jsxRuntime.jsx("span",{className:"whitespace-nowrap",children:i("predict.filter.title")})]})})]})}var Zt={start_time:ui.CalendarIcon,volume:ui.ChartLineIcon,liquidity:ui.DropletIcon,ending_soon:ui.TimerIcon};var mt=48,ft=4,Ke={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},j={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},Ve=j.ALL,Ol={[j.ONE_DAY]:Ke.ONE_MINUTE,[j.ONE_WEEK]:Ke.ONE_HOUR,[j.ONE_MONTH]:Ke.ONE_HOUR,[j.ALL]:Ke.ONE_DAY},Il={[j.ONE_DAY]:300,[j.ONE_WEEK]:3600,[j.ONE_MONTH]:10800,[j.ALL]:1440*60},_l={[j.ONE_DAY]:1440*60,[j.ONE_WEEK]:10080*60,[j.ONE_MONTH]:720*60*60,[j.ALL]:null},gt=1,Al=1,Dl=1,Hl=99,ge={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Bl=ge.ONE_WEEK,Fl={[ge.ONE_HOUR]:60,[ge.SIX_HOURS]:60,[ge.ONE_DAY]:300,[ge.ONE_WEEK]:1800,[ge.MAX]:1800};function nr(e={}){let t=react.useMemo(()=>reactPredict.resolveEventsParams(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets]),{data:r,isLoading:o,isFetching:n,isFetchingNextPage:s,isError:a,error:i,hasNextPage:c,fetchNextPage:l,refetch:d}=reactPredict.useInfiniteEvents(t),u=react.useMemo(()=>r?.pages.flatMap(g=>g.items).filter(g=>g!=null)??[],[r]),p=react.useCallback(()=>{l();},[l]),m=react.useCallback(()=>{d();},[d]);return {data:u,isLoading:o,isFetching:n&&!s,isFetchingMore:s,isError:a,error:i??null,hasMore:c??false,fetchMore:p,refetch:m}}function or({count:e=6}){return jsxRuntime.jsx("div",{className:"grid w-full grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-border bg-content1 p-4 animate-pulse",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"size-10 shrink-0 rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-3/4 rounded"})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-full rounded"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-20 rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-20 rounded-lg"})]})]},r))})}var sr=3,ht={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},ur={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},No={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},Te=[{bg:"rgba(139,92,246,0.14)",text:"rgb(139,92,246)",shadow:"rgba(139,92,246,0.18)"},{bg:"rgba(34,197,94,0.14)",text:"rgb(34,197,94)",shadow:"rgba(34,197,94,0.18)"},{bg:"rgba(0,166,212,0.14)",text:"rgb(0,166,212)",shadow:"rgba(0,166,212,0.18)"},{bg:"rgba(194,120,32,0.14)",text:"rgb(194,120,32)",shadow:"rgba(194,120,32,0.18)"},{bg:"rgba(202,138,4,0.14)",text:"rgb(202,138,4)",shadow:"rgba(202,138,4,0.18)"},{bg:"rgba(236,72,153,0.14)",text:"rgb(236,72,153)",shadow:"rgba(236,72,153,0.18)"},{bg:"rgba(99,102,241,0.14)",text:"rgb(99,102,241)",shadow:"rgba(99,102,241,0.18)"},{bg:"rgba(244,114,82,0.14)",text:"rgb(244,114,82)",shadow:"rgba(244,114,82,0.18)"}];function ar(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function wo(e){let t=e.outcomes?.map(a=>a.label?.toLowerCase().trim()??"")??[];if(t.some(a=>a==="up")&&t.some(a=>a==="down"))return [ht,No];if(t.some(a=>a==="yes")&&t.some(a=>a==="no"))return [ht,ur];let r=t[0]??"",o=t[1]??"",n=ar(r)%Te.length,s=ar(o)%Te.length;return s===n&&(s=(s+1)%Te.length),[Te[n],Te[s]]}function Co(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function pr(e){let t=Co(e);return t!=null?Math.round(t*100):0}function mr(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function ir(e){let t=e.outcomes?.[0];return ((t?.best_ask??t?.price??0)*100).toFixed(1)}function lr(e){let t=e.outcomes?.[1];if(t){let n=t.best_ask??t.price??0;return Math.round(n*100).toString()}let r=e.outcomes?.[0],o=r?.best_ask??r?.price??0;return Math.round((1-o)*100).toString()}function Mo(e){let t=new Date(e).getTime()-Date.now();if(t<=0)return null;let r=Math.floor(t/864e5),o=Math.floor(t%864e5/36e5),n=Math.floor(t%36e5/6e4),s=[];return r>0&&s.push(`${r}d`),o>0&&s.push(`${o}h`),s.push(`${n}m`),s.join(" ")}var To=`
|
|
1
|
+
'use strict';var react=require('react'),ui=require('@liberfi.io/ui'),i18n=require('@liberfi.io/i18n'),jsxRuntime=require('react/jsx-runtime'),reactPredict=require('@liberfi.io/react-predict'),reactWindow=require('react-window'),reactWindowInfiniteLoader=require('react-window-infinite-loader'),hooks=require('@liberfi.io/hooks'),walletConnector=require('@liberfi.io/wallet-connector'),Et=require('canvas-confetti'),types=require('@liberfi.io/types'),utils=require('@liberfi.io/utils'),recharts=require('recharts'),reactQuery=require('@tanstack/react-query'),uiScaffold=require('@liberfi.io/ui-scaffold'),jotai=require('jotai'),utils$1=require('jotai/utils');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Et__default=/*#__PURE__*/_interopDefault(Et);typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-predict"]="0.1.77");var Wn="0.1.77";var $n={Weather:["Daily temperature","Snow and rain","Climate change","Natural disasters","Hurricanes"],Companies:["IPOs","Product launches","KPIs","Elon Musk","CEOs","Layoffs"],Crypto:["BTC","15 min","Hourly","ETH","SOL","DOGE","Pre-Market","XRP","BNB","HYPE"],Economics:["Growth","Fed","Inflation","Oil and energy","Employment","Housing","Jobs & Economy","Bankruptcy & Defaults","GDP","Global Central Banks"],Elections:["Primaries","International elections"],Entertainment:["Music","Movies","Music charts","Television","Awards","Video games","Oscars","Rotten Tomatoes"],Financials:["S&P","Nasdaq","Daily","Metals","Treasuries","Oil","EUR/USD","USD/JPY","WTI"],Mentions:["Politicians","Earnings","Entertainment"],Politics:["Trump","Congress","International","SCOTUS & courts","Local","Recurring","Iran","House"],Science:["AI","Energy","Space"],Social:null,Sports:["Soccer","Basketball","Baseball","Football","Hockey","Golf","Tennis","Motorsport","Esports","Boxing","MMA","Rugby","Lacrosse","Mentions","Chess","Cricket","Aussie Rules","Darts"],World:null},$t=["Politics","Sports","Crypto","Economics","Financials","Elections","Entertainment","Companies","Science and Technology","Climate and Weather","Mentions","Social","World"],ut=(()=>{let e=t=>{let r=$t.indexOf(t);return r===-1?$t.length:r};return Object.entries($n).map(([t,r])=>({slug:t,label:t,tags:(r??[]).map(o=>({slug:o,label:o}))})).sort((t,r)=>e(t.slug)-e(r.slug))})();function Vt({categories:e,selectedCategory:t,selectedTag:r,activeTags:o,onCategorySelect:n,onTagSelect:s,trailing:a,pulsingTab:i="Trending",className:c}){let{t:l}=i18n.useTranslation(),d=react.useCallback(()=>{n(null);},[n]),u=l("predict.categories.trending");return jsxRuntime.jsxs("div",{className:ui.cn("sticky top-0 z-30 flex w-full flex-col justify-between gap-2 px-4 py-1 lg:px-2 lg:py-1",c),children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center gap-2",children:[jsxRuntime.jsx("div",{className:"hideScrollbar min-w-0 flex-1 overflow-x-auto overflow-y-hidden",children:jsxRuntime.jsxs("div",{className:"flex min-h-8 items-stretch gap-x-2 lg:min-h-9",children:[jsxRuntime.jsx(zt,{label:u,isSelected:t===null,onPress:d,showPulse:u===i}),jsxRuntime.jsx(Yn,{}),e.map(p=>jsxRuntime.jsx(zt,{label:p.category,isSelected:t===p.category,onPress:()=>n(p.category),badge:p.badge,showPulse:p.category===i},p.category))]})}),a&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:a})]}),t&&o.length>0&&jsxRuntime.jsx("div",{className:"hideScrollbar overflow-x-auto overflow-y-hidden flex items-center",children:jsxRuntime.jsxs("div",{className:"flex gap-x-1 pl-2 lg:w-full lg:gap-x-2",children:[jsxRuntime.jsx(Kt,{label:l("predict.categories.allMarkets"),isSelected:r===null,onPress:()=>s(null)}),o.map(p=>jsxRuntime.jsx(Kt,{label:p.label,icon:p.icon,isSelected:r===p.label,onPress:()=>s(p.label)},p.label))]})})]})}function zt({label:e,isSelected:t,onPress:r,badge:o,showPulse:n}){return jsxRuntime.jsxs("button",{type:"button",onClick:r,className:ui.cn("relative shrink-0 cursor-pointer whitespace-nowrap border-b p-1 text-base font-normal capitalize transition-colors",t?"border-primary/50 text-primary":"border-transparent text-neutral-500 hover:text-neutral-300"),children:[n?jsxRuntime.jsxs("span",{className:"flex items-center gap-x-1.5",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[rgb(240,68,56)]"}),jsxRuntime.jsx("span",{children:e})]}):e,o&&jsxRuntime.jsx("span",{className:"absolute -right-1 top-0 rounded bg-primary px-0.5 py-px text-[0.625rem] font-semibold leading-none text-neutral-950",children:o})]})}function Yn(){return jsxRuntime.jsx("span",{className:"flex items-center text-neutral-600","aria-hidden":"true",children:"|"})}function Kt({label:e,icon:t,isSelected:r,onPress:o}){return jsxRuntime.jsxs("button",{type:"button",onClick:o,className:ui.cn("flex shrink-0 items-center justify-center gap-x-1 min-w-14 rounded-2xl border px-2 py-1 text-sm font-medium uppercase transition-colors cursor-pointer",r?"border-transparent bg-primary text-black":"border-border/80 text-neutral-200 hover:bg-primary/10 hover:text-primary"),children:[t&&jsxRuntime.jsx("span",{className:ui.cn("iconify size-4",t)}),e]})}function fl({count:e=6}){return jsxRuntime.jsx("div",{className:"flex w-full flex-col gap-2 px-4 py-1 lg:px-2 lg:py-1",children:jsxRuntime.jsx("div",{className:"flex min-h-8 items-center gap-x-2 lg:min-h-9",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-16 shrink-0 rounded"},r))})})}function qn(e){return e.map(t=>({category:t.label,tags:t.tags.map(r=>r.label)}))}function jn(e){return e?e.tags.map(t=>({label:t.label,icon:t.icon})):[]}function jt({onSelect:e,trailing:t,className:r}){let[o,n]=react.useState(null),[s,a]=react.useState(null),i=react.useCallback(p=>{n(p),a(null),e?.({categorySlug:p,tagSlug:null});},[e]),c=react.useCallback(p=>{a(p),e?.({categorySlug:o,tagSlug:p});},[o,e]),l=qn(ut),d=ut.find(p=>p.slug===o),u=jn(d);return jsxRuntime.jsx(Vt,{categories:l,selectedCategory:o,selectedTag:s,activeTags:u,onCategorySelect:i,onTagSelect:c,trailing:t,className:r})}var pt={sortPreset:"volume",sortAsc:false,source:"dflow",timeRemaining:void 0,minVolume:void 0,minLiquidity:void 0};function mt(e){let t=0;return e.source&&t++,e.timeRemaining&&t++,e.minVolume&&t++,e.minLiquidity&&t++,t}function Xt({isOpen:e,onClose:t,value:r,onChange:o}){let{t:n}=i18n.useTranslation(),[s,a]=react.useState(r),i=react.useCallback(h=>{h?a(r):t();},[r,t]),c=react.useCallback(()=>{a(pt);},[]),l=react.useCallback(()=>{o(s),t();},[s,o,t]),d=react.useCallback((h,v)=>{a(O=>({...O,[h]:v}));},[]),u=react.useMemo(()=>mt(s),[s]),p=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"polymarket",label:n("predict.platform.polymarket")},{value:"dflow",label:n("predict.platform.dflow")}],[n]),m=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1d",label:n("predict.filter.lessThanDay")},{value:"7d",label:n("predict.filter.lessThanWeek")},{value:"30d",label:n("predict.filter.lessThanMonth")}],[n]),g=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[n]),f=react.useMemo(()=>[{value:void 0,label:n("predict.filter.all")},{value:"1000",label:">$1K"},{value:"10000",label:">$10K"},{value:"100000",label:">$100K"},{value:"1000000",label:">$1M"}],[n]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:e,onOpenChange:i,size:"md",scrollBehavior:"inside",children:jsxRuntime.jsxs(ui.ModalContent,{children:[jsxRuntime.jsx(ui.ModalHeader,{className:"px-4 py-2",children:jsxRuntime.jsx("span",{className:"text-base font-semibold",children:n("predict.filter.title")})}),jsxRuntime.jsxs(ui.ModalBody,{className:"flex flex-col gap-5",children:[jsxRuntime.jsx(ze,{label:n("predict.filter.platform"),children:jsxRuntime.jsx(Ke,{options:p,selected:s.source,onSelect:h=>d("source",h)})}),jsxRuntime.jsx(ze,{label:n("predict.filter.timeRemaining"),children:jsxRuntime.jsx(Ke,{options:m,selected:s.timeRemaining,onSelect:h=>d("timeRemaining",h)})}),jsxRuntime.jsx(ze,{label:n("predict.filter.minVolume"),children:jsxRuntime.jsx(Ke,{options:g,selected:s.minVolume,onSelect:h=>d("minVolume",h)})}),jsxRuntime.jsx(ze,{label:n("predict.filter.minLiquidity"),children:jsxRuntime.jsx(Ke,{options:f,selected:s.minLiquidity,onSelect:h=>d("minLiquidity",h)})})]}),jsxRuntime.jsx(ui.ModalFooter,{className:"px-4",children:jsxRuntime.jsxs("div",{className:"w-full flex justify-between items-center",children:[jsxRuntime.jsx(ui.Button,{variant:"light",color:"default",size:"sm",radius:"full",startContent:jsxRuntime.jsx(ui.RefreshIcon,{width:16,height:16}),onPress:c,children:n("predict.filter.reset")}),jsxRuntime.jsxs(ui.Button,{color:"primary",size:"sm",radius:"full",onPress:l,children:[n("predict.filter.showResults"),u>0&&jsxRuntime.jsxs("span",{className:"ml-1 text-xs opacity-80",children:["(",u,")"]})]})]})})]})})}function ze({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 Ke({options:e,selected:t,onSelect:r,allowDeselect:o=true}){return jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(n=>{let s=t===n.value;return jsxRuntime.jsx("button",{type:"button",onClick:()=>{r(s&&o?void 0:n.value);},className:ui.cn("shrink-0 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors duration-150 cursor-pointer border",s?"bg-primary/15 text-primary border-primary/40":"bg-content2 text-foreground/60 border-default-100 hover:bg-default-100 hover:text-foreground"),children:n.label},n.value??"__all")})})}var er={start_time:{sort_by:"created_at"},volume:{sort_by:"volume"},liquidity:{sort_by:"liquidity"},ending_soon:{sort_by:"end_at"}},Zt={start_time:"predict.sort.startTime",volume:"predict.sort.volume",liquidity:"predict.sort.liquidity",ending_soon:"predict.sort.endingSoon"},vo=["start_time","volume","liquidity","ending_soon"];function tr({sortPreset:e,onSortChange:t,sortAsc:r,onSortAscChange:o,onFilterPress:n,filterCount:s=0,className:a}){let{t:i}=i18n.useTranslation(),[c,l]=react.useState(false),d=react.useRef(null);react.useEffect(()=>{if(!c)return;let p=g=>{d.current&&!d.current.contains(g.target)&&l(false);},m=g=>{g.key==="Escape"&&l(false);};return document.addEventListener("mousedown",p),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",m);}},[c]);let u=Jt[e];return jsxRuntime.jsxs("div",{className:ui.cn("flex items-center gap-2",a),children:[jsxRuntime.jsxs("div",{ref:d,className:"relative flex shrink-0 items-center rounded-full border border-border",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>l(p=>!p),className:"flex shrink-0 items-center gap-2 px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsxRuntime.jsx(u,{className:"size-[18px] shrink-0"}),jsxRuntime.jsx("span",{className:"whitespace-nowrap",children:i(Zt[e])})]}),jsxRuntime.jsx("div",{className:"h-6 w-px bg-border"}),jsxRuntime.jsx("button",{type:"button",onClick:()=>o(!r),className:"px-2.5 py-1.5 text-xs text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:r?"\u2191":"\u2193"}),c&&jsxRuntime.jsx("div",{className:"absolute left-0 top-full z-20 mt-1 flex min-w-max flex-col gap-0.5 rounded-lg border border-border bg-content1 p-1 shadow-lg",children:vo.map(p=>{let m=Jt[p];return jsxRuntime.jsxs("button",{type:"button",onClick:()=>{t(p),l(false);},className:ui.cn("flex w-full items-center gap-2 rounded px-2.5 py-1.5 text-xs font-medium transition-colors cursor-pointer",p===e?"bg-primary/10 text-primary":"text-neutral hover:bg-content2 hover:text-foreground"),children:[jsxRuntime.jsx(m,{className:"size-4 shrink-0"}),jsxRuntime.jsx("span",{children:i(Zt[p])})]},p)})})]}),jsxRuntime.jsx(ui.StyledBadge,{content:s>0?s:void 0,color:"primary",size:"sm",isInvisible:s===0,children:jsxRuntime.jsxs("button",{type:"button",onClick:n,className:"flex shrink-0 items-center gap-2 rounded-full border border-border px-3 py-1.5 text-xs font-medium text-neutral transition-colors hover:text-primary/80 cursor-pointer",children:[jsxRuntime.jsx(ui.FilterIcon,{className:"size-[18px]"}),jsxRuntime.jsx("span",{className:"whitespace-nowrap",children:i("predict.filter.title")})]})})]})}var Jt={start_time:ui.CalendarIcon,volume:ui.ChartLineIcon,liquidity:ui.DropletIcon,ending_soon:ui.TimerIcon};var ft=48,gt=4,Ve={ONE_MINUTE:1,ONE_HOUR:60,ONE_DAY:1440},G={ONE_DAY:"1d",ONE_WEEK:"1w",ONE_MONTH:"1m",ALL:"all"},Ye=G.ALL,Ol={[G.ONE_DAY]:Ve.ONE_MINUTE,[G.ONE_WEEK]:Ve.ONE_HOUR,[G.ONE_MONTH]:Ve.ONE_HOUR,[G.ALL]:Ve.ONE_DAY},Il={[G.ONE_DAY]:300,[G.ONE_WEEK]:3600,[G.ONE_MONTH]:10800,[G.ALL]:1440*60},_l={[G.ONE_DAY]:1440*60,[G.ONE_WEEK]:10080*60,[G.ONE_MONTH]:720*60*60,[G.ALL]:null},vt=1,Al=1,Dl=1,Hl=99,he={ONE_HOUR:"1h",SIX_HOURS:"6h",ONE_DAY:"1d",ONE_WEEK:"1w",MAX:"max"},Bl=he.ONE_WEEK,Fl={[he.ONE_HOUR]:60,[he.SIX_HOURS]:60,[he.ONE_DAY]:300,[he.ONE_WEEK]:1800,[he.MAX]:1800};function or(e={}){let t=react.useMemo(()=>reactPredict.resolveEventsParams(e),[e.tagSlugSelection,e.limit,e.status,e.sort_by,e.sort_asc,e.source,e.with_markets]),{data:r,isLoading:o,isFetching:n,isFetchingNextPage:s,isError:a,error:i,hasNextPage:c,fetchNextPage:l,refetch:d}=reactPredict.useInfiniteEvents(t),u=react.useMemo(()=>r?.pages.flatMap(g=>g.items).filter(g=>g!=null)??[],[r]),p=react.useCallback(()=>{l();},[l]),m=react.useCallback(()=>{d();},[d]);return {data:u,isLoading:o,isFetching:n&&!s,isFetchingMore:s,isError:a,error:i??null,hasMore:c??false,fetchMore:p,refetch:m}}function xt({count:e=6}){return jsxRuntime.jsx("div",{className:"grid w-full grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-border bg-content1 p-4 animate-pulse",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"size-10 shrink-0 rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-3/4 rounded"})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-3 w-full rounded"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-20 rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-20 rounded-lg"})]})]},r))})}function Vl({count:e=6}){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 items-center justify-between gap-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-20 rounded-full"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-24 rounded-full"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-20 rounded-full"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-24 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-28 rounded-full"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-24 rounded-full"})]})]}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(xt,{count:e})})]})}var sr=3,bt={bg:"hsl(var(--heroui-primary) / 0.14)",text:"hsl(var(--heroui-primary))",shadow:"hsl(var(--heroui-primary) / 0.18)"},ur={bg:"hsl(var(--heroui-secondary) / 0.14)",text:"hsl(var(--heroui-secondary))",shadow:"hsl(var(--heroui-secondary) / 0.18)"},No={bg:"rgba(239, 68, 68, 0.14)",text:"rgb(239, 68, 68)",shadow:"rgba(239, 68, 68, 0.18)"},Le=[{bg:"rgba(139,92,246,0.14)",text:"rgb(139,92,246)",shadow:"rgba(139,92,246,0.18)"},{bg:"rgba(34,197,94,0.14)",text:"rgb(34,197,94)",shadow:"rgba(34,197,94,0.18)"},{bg:"rgba(0,166,212,0.14)",text:"rgb(0,166,212)",shadow:"rgba(0,166,212,0.18)"},{bg:"rgba(194,120,32,0.14)",text:"rgb(194,120,32)",shadow:"rgba(194,120,32,0.18)"},{bg:"rgba(202,138,4,0.14)",text:"rgb(202,138,4)",shadow:"rgba(202,138,4,0.18)"},{bg:"rgba(236,72,153,0.14)",text:"rgb(236,72,153)",shadow:"rgba(236,72,153,0.18)"},{bg:"rgba(99,102,241,0.14)",text:"rgb(99,102,241)",shadow:"rgba(99,102,241,0.18)"},{bg:"rgba(244,114,82,0.14)",text:"rgb(244,114,82)",shadow:"rgba(244,114,82,0.18)"}];function ar(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function wo(e){let t=e.outcomes?.map(a=>a.label?.toLowerCase().trim()??"")??[];if(t.some(a=>a==="up")&&t.some(a=>a==="down"))return [bt,No];if(t.some(a=>a==="yes")&&t.some(a=>a==="no"))return [bt,ur];let r=t[0]??"",o=t[1]??"",n=ar(r)%Le.length,s=ar(o)%Le.length;return s===n&&(s=(s+1)%Le.length),[Le[n],Le[s]]}function Co(e){let t=e.outcomes?.[0];return t?t.best_ask??t.price??null:null}function pr(e){let t=Co(e);return t!=null?Math.round(t*100):0}function mr(e){return e<=1&&e>0?"< 1%":e>=99&&e<100?"> 99%":`${e}%`}function ir(e){let t=e.outcomes?.[0];return ((t?.best_ask??t?.price??0)*100).toFixed(1)}function lr(e){let t=e.outcomes?.[1];if(t){let n=t.best_ask??t.price??0;return Math.round(n*100).toString()}let r=e.outcomes?.[0],o=r?.best_ask??r?.price??0;return Math.round((1-o)*100).toString()}function Mo(e){let t=new Date(e).getTime()-Date.now();if(t<=0)return null;let r=Math.floor(t/864e5),o=Math.floor(t%864e5/36e5),n=Math.floor(t%36e5/6e4),s=[];return r>0&&s.push(`${r}d`),o>0&&s.push(`${o}h`),s.push(`${n}m`),s.join(" ")}var To=`
|
|
2
2
|
.badge-shine { position: relative; overflow: hidden; }
|
|
3
3
|
.badge-shine::after {
|
|
4
4
|
content: "";
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
60% { transform: translate(200%); }
|
|
17
17
|
100% { transform: translate(200%); }
|
|
18
18
|
}
|
|
19
|
-
`;function fr({event:e,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n,onHover:s}){let[a,i]=react.useState(null),c=e.markets??[],l=react.useMemo(()=>c.length>2?[...c].sort((N,A)=>(A.outcomes?.[0]?.price??0)-(N.outcomes?.[0]?.price??0)):c,[c]),d=l.filter(N=>N.status==="open"),u=l.length===1,p=d.slice(0,sr),m=d.length-sr,g=react.useMemo(()=>`$${Math.round(e.volume??0).toLocaleString("en-US")}`,[e.volume]),f=a?d.find(N=>N.slug===a)??null:null,h=!!f||u,v=()=>{h||o?.(e);},O=N=>{N.stopPropagation(),f&&(N.preventDefault(),i(null));},R=N=>{N.stopPropagation(),t||(N.preventDefault(),o?.(e));};return jsxRuntime.jsxs("div",{className:ui.cn("group flex h-full w-full flex-col rounded-xl","min-h-52 border border-border/90 bg-background p-3","lg:min-h-72 lg:max-w-md lg:p-4","gap-y-1.5 lg:gap-y-4","transition duration-300","hover:border-primary/40 hover:shadow-card-glow","focus-within:border-primary/40 focus-within:shadow-card-glow",!h&&"cursor-pointer"),onMouseEnter:()=>s?.(e),onClick:v,children:[jsxRuntime.jsx("style",{children:To}),jsxRuntime.jsx(Lo,{event:e,href:t,LinkComponent:r,onClick:O,isExpanded:h}),jsxRuntime.jsx("div",{className:"flex flex-1 flex-col",children:u?jsxRuntime.jsx(Bo,{market:d[0],event:e,formattedVolume:g,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n}):f?jsxRuntime.jsx(Fo,{market:f,event:e,onCollapse:()=>i(null),onSelectOutcome:n}):jsxRuntime.jsx(Do,{displayedMarkets:p,moreCount:m,formattedVolume:g,source:e.source,href:t,LinkComponent:r,onMarketClick:N=>i(N.slug),onShowMore:R})})]})}function Lo({event:e,href:t,LinkComponent:r,onClick:o,isExpanded:n}){let s=e.start_at?Mo(e.start_at):null;return jsxRuntime.jsxs(ui.Linkable,{href:t,LinkComponent:r,as:"button",className:"group/header flex items-center gap-x-2 lg:gap-x-4 w-full text-left cursor-pointer",onClick:o,children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsxRuntime.jsx("p",{className:ui.cn("min-w-0 text-sm font-semibold leading-snug text-slate-200 line-clamp-2 lg:text-base",n&&"group-hover/header:text-neutral-400"),children:e.title}),s&&jsxRuntime.jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",s]})]}),jsxRuntime.jsx(Oo,{event:e})]})}function Ro(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(n=>n.label?.toLowerCase()==="crypto"),o=e.tags?.some(n=>n.label?.toLowerCase()==="live");if(r&&e.end_at){let n=new Date(e.end_at).getTime()-Date.now(),s=300*1e3,a=900*1e3;if(n>0&&n<=a){let i=n<=s?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:n<=s?"5m":"15m",color:i});}}return o&&t.push({kind:"live"}),t.slice(0,2)}function Oo({event:e}){let t=react.useMemo(()=>Ro(e),[e]);return t.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:t.map((r,o)=>{switch(r.kind){case "live":return jsxRuntime.jsx(Io,{},o);case "crypto-short":return jsxRuntime.jsx(_o,{label:r.label,color:r.color},o);case "closed":return jsxRuntime.jsx(Ao,{},o)}})})}function Io(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md bg-[rgb(240,68,56)]/10 px-1.5 py-0.5 text-xs font-semibold text-[rgb(240,68,56)]",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-current"}),e("predict.event.status.live")]})}function _o({label:e,color:t}){return jsxRuntime.jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{backgroundColor:`${t}26`,color:t},children:[jsxRuntime.jsx(ui.TimerIcon,{className:"size-3 shrink-0"}),e]})}function Ao(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsx("span",{className:"inline-flex items-center rounded-md bg-neutral-800/80 px-1.5 py-0.5 text-xs font-semibold text-neutral-400",children:e("predict.event.status.closed")})}function Do({displayedMarkets:e,moreCount:t,formattedVolume:r,source:o,href:n,LinkComponent:s,onMarketClick:a,onShowMore:i}){let{t:c}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e.length>0&&jsxRuntime.jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(l=>{let d=pr(l);return jsxRuntime.jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:u=>{u.stopPropagation(),a(l);},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:l.outcomes?.[0]?.label??l.question}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:mr(d)}),jsxRuntime.jsx(Ho,{})]})]},l.slug)})}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[t>0?jsxRuntime.jsxs(ui.Linkable,{href:n,LinkComponent:s,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:i,children:[c("predict.event.showMore"),jsxRuntime.jsx(vr,{className:"h-3 w-3"})]}):jsxRuntime.jsx("div",{}),jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1.5 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[r," ",c("predict.event.volume"),jsxRuntime.jsx(xr,{source:o})]})]})]})}function cr({bgColor:e,textColor:t,shadowColor:r,onClick:o,children:n}){return jsxRuntime.jsx("button",{type:"button",className:"flex h-12 flex-1 w-full items-center justify-center gap-x-1 overflow-hidden rounded-lg p-3 text-base font-normal hover:cursor-pointer will-change-transform [-webkit-tap-highlight-color:transparent]",style:{backgroundColor:e,color:t,"--shadow-color":r,"--shadow-offset":"4px",boxShadow:"inset 0 -1px 0 rgba(255,255,255,0.08), 0 var(--shadow-offset, 4px) 0 var(--shadow-color, rgba(0,0,0,0.22))",transition:"transform .12s, box-shadow .12s, opacity .14s"},onMouseEnter:i=>{let c=i.currentTarget;c.style.setProperty("--shadow-offset","2px"),c.style.transform="translateY(2px)";},onMouseLeave:i=>{let c=i.currentTarget;c.style.setProperty("--shadow-offset","4px"),c.style.transform="translateY(0px)";},onClick:o,children:n})}function gr({market:e,event:t,onSelectOutcome:r,dynamicColors:o=false,labelFormat:n="action"}){let{t:s}=i18n.useTranslation(),[a,i]=o?wo(e):[ht,ur],c=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",l=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",d=n==="label"&&c===l?"action":n,u=d==="label"?`${e.outcomes?.[0]?.label??"Yes"} ${ir(e)}\xA2`:s("predict.market.action.yes",{price:ir(e)}),p=d==="label"?`${e.outcomes?.[1]?.label??"No"} ${lr(e)}\xA2`:s("predict.market.action.no",{price:lr(e)});return jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx(cr,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:m=>{m.stopPropagation(),r?.(t,e,"yes");},children:u}),jsxRuntime.jsx(cr,{bgColor:i.bg,textColor:i.text,shadowColor:i.shadow,onClick:m=>{m.stopPropagation(),r?.(t,e,"no");},children:p})]})}function Ho(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("span",{className:"inline-flex h-7 w-[85px] items-center justify-center gap-x-3 rounded-lg p-1.5 text-xs font-semibold flex-shrink-0 bg-gradient-to-r from-primary/15 to-secondary/15 lg:h-9 lg:w-24 lg:gap-x-4 lg:p-2 lg:text-sm",children:[jsxRuntime.jsx("span",{className:"text-primary",children:e("predict.market.yes")}),jsxRuntime.jsx("span",{className:"text-neutral-400",children:"/"}),jsxRuntime.jsx("span",{className:"text-secondary",children:e("predict.market.no")})]})}function Bo({market:e,event:t,formattedVolume:r,href:o,LinkComponent:n,onSelect:s,onSelectOutcome:a}){let{t:i}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex-1",children:jsxRuntime.jsx(gr,{market:e,event:t,onSelectOutcome:a,dynamicColors:true,labelFormat:"label"})}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[jsxRuntime.jsxs(ui.Linkable,{href:o,LinkComponent:n,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:l=>{l.stopPropagation(),o||(l.preventDefault(),s?.(t));},children:[i("predict.event.viewEvent"),jsxRuntime.jsx(vr,{className:"h-3 w-3"})]}),jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1.5 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[r," ",i("predict.event.volume"),jsxRuntime.jsx(xr,{source:t.source})]})]})]})}function Fo({market:e,event:t,onCollapse:r,onSelectOutcome:o}){let{t:n}=i18n.useTranslation(),s=pr(e);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:a=>{a.stopPropagation(),r();},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 lg:text-sm",children:e.outcomes?.[0]?.label??e.question}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:mr(s)}),jsxRuntime.jsx(ui.ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsxRuntime.jsx("div",{className:"mt-3",children:jsxRuntime.jsx(gr,{market:e,event:t,onSelectOutcome:o,labelFormat:"action"})})]}),jsxRuntime.jsxs("button",{type:"button",className:"mt-auto flex items-center gap-x-1 pt-4 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:a=>{a.stopPropagation(),r();},children:[jsxRuntime.jsx(Uo,{className:"h-3 w-3"}),n("predict.event.back")]})]})}function vr({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsxRuntime.jsx("path",{d:"M4.5 2.5L8 6l-3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Uo({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsxRuntime.jsx("path",{d:"M7.5 2.5L4 6l3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function xr({source:e}){return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsxRuntime.jsx(ui.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var Yo=768,br=1024,qo=1280,jo=8,Go=224,Xo=304,Qo=114;function Zo(e){return e>=qo?4:e>=br?3:e>=Yo?2:1}function Jo(e){return e>=br?Xo:Go}function yr({events:e,hasMore:t=false,onFetchMore:r,onSelect:o,onSelectOutcome:n,getEventHref:s,LinkComponent:a,onHover:i}){let c=react.useRef(null),l=react.useRef(null),{width:d=0,height:u=0}=hooks.useResizeObserver({ref:c}),p=Zo(d),m=Jo(d),g=Math.ceil(e.length/p)||0,f=!t&&e.length>0,h=g+(t?1:0)+(f?1:0),v=react.useCallback(A=>A<g,[g]),O=react.useCallback(async()=>{r?.();},[r]),R=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:v,loadMoreRows:O,rowCount:h,threshold:3}),N=react.useCallback(()=>{l.current?.scrollToRow({index:0,behavior:"smooth"});},[]);return jsxRuntime.jsx("div",{ref:c,className:"@container w-full h-full",children:u>0&&jsxRuntime.jsx(reactWindow.List,{listRef:l,className:"no-scrollbar",style:{height:u},onRowsRendered:R,rowComponent:es,rowCount:h,rowHeight:A=>f&&A===h-1?Qo:(m),rowProps:{events:e,columnCount:p,dataRowCount:g,showEndOfList:f,totalRowCount:h,onSelect:o,onSelectOutcome:n,getEventHref:s,LinkComponent:a,onHover:i,onScrollToTop:N}})})}function es({index:e,style:t,events:r,columnCount:o,dataRowCount:n,showEndOfList:s,totalRowCount:a,onSelect:i,onSelectOutcome:c,getEventHref:l,LinkComponent:d,onHover:u,onScrollToTop:p}){if(s&&e===a-1)return jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(ts,{onScrollToTop:p})});if(e>=n)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-start pt-4",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})});let m=e*o,g=r.slice(m,m+o),f=o-g.length;return jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsxs("div",{className:"flex w-full h-full",children:[g.map(h=>h==null?null:jsxRuntime.jsx("div",{className:"flex-1 min-w-0 flex",style:{padding:jo},children:jsxRuntime.jsx(fr,{event:h,href:l?.(h),LinkComponent:d,onSelect:i,onSelectOutcome:c,onHover:u})},h.slug)),f>0&&Array.from({length:f}).map((h,v)=>jsxRuntime.jsx("div",{style:{flex:1,minWidth:0}},`spacer-${v}`))]})})}function ts({onScrollToTop:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"flex w-full flex-col items-center justify-center gap-y-4 py-6",children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center justify-center gap-x-4",children:[jsxRuntime.jsx("div",{className:"h-px w-16 bg-neutral-700"}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-neutral-500",children:t("predict.event.endOfList")}),jsxRuntime.jsx("div",{className:"h-px w-16 bg-neutral-700"})]}),jsxRuntime.jsxs("button",{type:"button",className:"flex cursor-pointer items-center gap-x-1 text-xs font-medium text-neutral-400",onClick:e,children:[jsxRuntime.jsx("span",{className:"iconify size-4 ph--arrow-up-bold"}),jsxRuntime.jsx("span",{children:t("predict.event.backToTop")})]})]})}function kr({tagSlugSelection:e,limit:t=48,status:r,sort_by:o,sort_asc:n,source:s,with_markets:a,onSelect:i,onSelectOutcome:c,getEventHref:l,LinkComponent:d,onHover:u}){let{data:p,hasMore:m,fetchMore:g,isFetching:f}=nr({tagSlugSelection:e,limit:t,status:r,sort_by:o,sort_asc:n,source:s,with_markets:a});return f?jsxRuntime.jsx(or,{count:48}):jsxRuntime.jsx(yr,{events:p,hasMore:m,onFetchMore:g,onSelect:i,onSelectOutcome:c,getEventHref:l,LinkComponent:d,onHover:u})}function bc({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:o,onHover:n}){let[s,a]=react.useState({categorySlug:null,tagSlug:null}),[i,c]=react.useState(ut),{isOpen:l,onOpen:d,onClose:u}=ui.useDisclosure(),p=react.useCallback(R=>{a(R);},[]),m=react.useCallback(R=>{c(N=>({...N,sortPreset:R}));},[]),g=react.useCallback(R=>{c(N=>({...N,sortAsc:R}));},[]),f=react.useCallback(R=>{c(R);},[]),h=react.useMemo(()=>Jt[i.sortPreset].sort_by,[i.sortPreset]),v=react.useMemo(()=>pt(i),[i]),O=jsxRuntime.jsx(er,{sortPreset:i.sortPreset,onSortChange:m,sortAsc:i.sortAsc,onSortAscChange:g,onFilterPress:d,filterCount:v});return jsxRuntime.jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsxRuntime.jsx(qt,{onSelect:p,trailing:O}),jsxRuntime.jsx(Gt,{isOpen:l,onClose:u,value:i,onChange:f}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(kr,{tagSlugSelection:s,sort_by:h,sort_asc:i.sortAsc,source:i.source,onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:o,onHover:n})})]})}function Nr(e){return {title:e.title,imageUrl:e.image_url}}function wr(e){let t=e.outcomes[0],r=e.outcomes[1];return {yesAsk:t?.best_ask??t?.price,noAsk:r?.best_ask??r?.price,yesBid:t?.best_bid,noBid:r?.best_bid,yesSubTitle:t?.label??"Yes",noSubTitle:r?.label??"No"}}function ms(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};Pt__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{Pt__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{Pt__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function Cr({market:e,chain:t="solana",initialOutcome:r="yes",initialSide:o="buy"}){let{t:n}=i18n.useTranslation(),{status:s}=walletConnector.useAuth(),i=walletConnector.useWallets().find(T=>T.chainNamespace===types.ChainNamespace.SOLANA&&T.isConnected),c=s==="authenticated",l=i?.address,d=e.source,[u,p]=react.useState(r),[m,g]=react.useState(o),[f,h]=react.useState(NaN),[v,O]=react.useState(false),[R,N]=react.useState(null),A=react.useMemo(()=>{let T=u==="yes"?0:1,D=e.outcomes[T];return m==="buy"?D?.best_ask??D?.price??.5:D?.best_bid??D?.price??.5},[e.outcomes,u,m]),q=react.useMemo(()=>isNaN(f)||f<=0?0:m==="buy"?A>0?f/A:0:f,[m,f,A]),Q=react.useMemo(()=>isNaN(f)||f<=0?"0":String(Math.round(f*1e6)),[f]),Pe=e.provider_meta?.["dflow.yesMint"]??"",Ee=e.provider_meta?.["dflow.noMint"]??"",pe=e.provider_meta?.["dflow.collateralMint"]??"",w=u==="yes"?Pe:Ee,X=m==="buy"?pe:w,ee=m==="buy"?w:pe,y=!!X&&!!ee&&!!l&&Q!=="0",{refetch:P}=reactPredict.useDFlowQuote({inputMint:X,outputMint:ee,amount:Q,userPublicKey:l??"",slippageBps:100},{enabled:y}),{data:C,isLoading:z}=reactPredict.usePositions({source:d,user:l??""},{enabled:!!l}),K=react.useMemo(()=>C&&C.positions.reduce((D,oe)=>oe.side==="USDC"||oe.side==="collateral"?D+(oe.current_value??0):D,0)||null,[C]),V=react.useMemo(()=>C?C.positions.find(D=>D.side?.toLowerCase()==="yes"&&D.market?.slug===e.slug)?.size??0:null,[C,e.slug]),me=react.useMemo(()=>C?C.positions.find(D=>D.side?.toLowerCase()==="no"&&D.market?.slug===e.slug)?.size??0:null,[C,e.slug]),ce=react.useMemo(()=>{if(isNaN(f)||f<=0)return 0;if(m==="buy")return f;let T=u==="yes"?e.outcomes[0]?.best_bid??0:e.outcomes[1]?.best_bid??0;return f*T},[m,u,f,e.outcomes]),Ne=react.useMemo(()=>isNaN(f)||f<=0?0:m==="buy"?q*1:ce,[m,q,ce,f]),An=Ne-ce,Dn=react.useCallback(T=>{g(T),h(NaN);},[]),Hn=react.useCallback(T=>{if(isNaN(T)){h(NaN);return}let D=Math.max(0,T),oe=m==="buy"?Math.round(D*100)/100:Math.round(D);h(oe);},[m]),lt=react.useMemo(()=>{let T=[];(isNaN(f)||f<gt)&&T.push(`Minimum quantity is ${gt}`),e.status!=="open"&&T.push("Market is not active"),m==="buy"&&K!=null&&!isNaN(f)&&f>0&&f>K&&T.push("Insufficient USDC balance");let D=u==="yes"?V:me;return m==="sell"&&D!=null&&!isNaN(f)&&f>0&&f>D&&T.push("Insufficient shares"),{isValid:T.length===0,errors:T}},[f,e.status,m,K,V,me,u]),{mutateAsync:Ft}=reactPredict.useDFlowSubmit(),{data:ct}=reactPredict.useOrder({id:R??"",source:d},{enabled:!!R});react.useEffect(()=>{if(!ct||!R)return;let{status:T}=ct;T==="closed"?(O(false),N(null),ui.toast.success(n("predict.trade.submitSuccess")),ms(),h(NaN)):(T==="failed"||T==="expired")&&(O(false),N(null),ui.toast.error(n("predict.trade.submitError")));},[ct,R,n]);let Bn=react.useCallback(async()=>{if(!(!lt.isValid||!c||!l||!i)){O(true),N(null);try{let oe=(await P()).data?.transaction;if(!oe){ui.toast.error(n("predict.trade.submitError")),O(!1);return}let Ut=Uint8Array.from(atob(oe),Un=>Un.charCodeAt(0)),Fn=await i.sendTransaction(Ut);await Ft({signedTransaction:btoa(String.fromCharCode(...Ut)),orderContext:{user_public_key:l,input_mint:X,output_mint:ee,amount:Q,price:String(A),side:m==="buy"?"BUY":"SELL",outcome:u==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}}),N(Fn);}catch{ui.toast.error(n("predict.trade.submitError")),O(false);}}},[lt.isValid,c,l,i,P,Ft,X,ee,Q,A,m,u,e.slug,n]);return {outcome:u,side:m,quantity:f,estimatedCost:ce,potentialPayout:Ne,potentialProfit:An,usdcBalance:K,yesTokenBalance:V,noTokenBalance:me,isBalanceLoading:z,isSubmitting:v,validation:lt,setOutcome:p,setSide:Dn,setQuantity:Hn,submit:Bn}}var ys=`https://s1.chainstream.io/chains/sol/tokens/${utils.SOLANA_TOKENS.stablecoins.USDC.address}/image.png`;function Lr({event:e,market:t,outcome:r,side:o,quantity:n,potentialProfit:s,estimatedCost:a,usdcBalance:i,yesTokenBalance:c,noTokenBalance:l,isBalanceLoading:d,isSubmitting:u,isValid:p,onOutcomeChange:m,onSideChange:g,onQuantityChange:f,onSubmit:h}){let{t:v}=i18n.useTranslation(),[O,R]=react.useState("market"),[N,A]=react.useState(false),q=react.useMemo(()=>{let w=o==="buy"?r==="yes"?t.yesAsk:t.noAsk:r==="yes"?t.yesBid:t.noBid;return w!=null?Math.round(Number(w)*100):null},[o,r,t]),Q=react.useMemo(()=>{if(u)return v("predict.trade.submitting");if(!n||isNaN(n)||n<=0)return v("predict.trade.enterAmount");let w=v(o==="buy"?"predict.trade.buy":"predict.trade.sell"),X=v(r==="yes"?"predict.trade.yes":"predict.trade.no");return `${w} ${X}`},[u,n,o,r,v]),Pe=react.useMemo(()=>r==="yes"?"primary":"secondary",[r]),Ee=()=>{f(Math.floor((i??0)/2*100)/100);},pe=()=>{f(i??0);};return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 rounded-xl border border-default-200 bg-content1 p-4",children:[e&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsxRuntime.jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxRuntime.jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxRuntime.jsxs("span",{className:r==="yes"?"text-bullish":"text-bearish",children:[v(o==="buy"?"predict.trade.buy":"predict.trade.sell")," ",v(r==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxRuntime.jsxs("span",{className:"text-foreground",children:[" \xB7 ",r==="yes"?t.yesSubTitle:t.noSubTitle]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:O,onSelectionChange:w=>R(w),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:v("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:v("predict.trade.limit")},"limit")]}),q!=null&&jsxRuntime.jsxs("span",{className:"text-xl font-bold tabular-nums",children:[q," \xA2"]})]}),jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:w=>g(w),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:v("predict.trade.buy")},"buy"),jsxRuntime.jsx(ui.Tab,{title:v("predict.trade.sell")},"sell")]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(w=>{let X=w==="yes"?c:l;return jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-y-1",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>m(w),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${r===w?w==="yes"?"border-primary bg-primary-50 text-primary":"border-secondary bg-secondary-50 text-secondary":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:v(w==="yes"?"predict.trade.yes":"predict.trade.no")}),(()=>{let ee=o==="buy"?w==="yes"?t.yesAsk:t.noAsk:w==="yes"?t.yesBid:t.noBid;return ee!=null?jsxRuntime.jsxs("span",{className:"ml-1 opacity-70",children:[Math.round(Number(ee)*100),"\xA2"]}):null})()]}),o==="sell"&&r===w&&jsxRuntime.jsx("span",{className:"text-center text-xs text-foreground",children:d?"\u2013":`${X??0} shares`})]},w)})}),o==="buy"&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsxRuntime.jsx("span",{children:v("predict.trade.youArePaying")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("img",{src:ys,alt:"USDC",className:"h-3.5 w-3.5 rounded-full object-cover"}),jsxRuntime.jsx("span",{className:"font-medium text-foreground tabular-nums",children:i!=null?`${i.toFixed(6)} USDC`:"\u2013"}),jsxRuntime.jsx("button",{type:"button",onClick:Ee,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:v("predict.trade.half")}),jsxRuntime.jsx("button",{type:"button",onClick:pe,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:v("predict.trade.max")})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:v(o==="buy"?"predict.trade.amount":"predict.trade.contracts")}),jsxRuntime.jsx(ui.StyledNumberInput,{fullWidth:true,placeholder:"0",radius:"lg",size:"lg",value:isNaN(n)?void 0:n,onValueChange:w=>{f(w);},minValue:0,step:o==="buy"?.01:1,formatOptions:o==="buy"?{maximumFractionDigits:2}:{maximumFractionDigits:0},startContent:o==="buy"?jsxRuntime.jsx("span",{className:"text-default-600 text-xl",children:"$"}):void 0,classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}},o),o==="sell"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2 justify-end",children:[[25,50].map(w=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{f(Math.floor((r==="yes"?c??0:l??0)*w/100));},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:[w,"%"]},w)),jsxRuntime.jsx("button",{type:"button",onClick:()=>{f(r==="yes"?c??0:l??0);},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:v("common.all")})]})]}),!isNaN(n)&&n>0&&jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-foreground",children:v(o==="buy"?"predict.trade.potentialWin":"predict.trade.estimatedReceive")}),jsxRuntime.jsxs("span",{className:"text-xl font-semibold text-bullish",children:["$",(o==="buy"?s:a).toFixed(2)]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>A(w=>!w),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:v("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",N&&"rotate-180")})]}),q!=null&&jsxRuntime.jsxs("span",{className:"text-foreground font-medium tabular-nums",children:[q,"% chance"]})]}),N&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsxRuntime.jsxs("span",{children:[v("predict.trade.bestBid"),":"," ",Math.round((t.yesBid??0)*100),"\xA2"]}),jsxRuntime.jsxs("span",{children:[v("predict.trade.bestAsk"),":"," ",Math.round((t.yesAsk??0)*100),"\xA2"]})]})]}),jsxRuntime.jsx(ui.Button,{color:Pe,fullWidth:true,radius:"lg",size:"lg",isDisabled:!p||u||!n||isNaN(n)||n<=0,isLoading:u,onPress:h,children:Q})]})}function Or({event:e,market:t,initialSide:r,initialOutcome:o,chain:n}){let{outcome:s,side:a,quantity:i,estimatedCost:c,potentialPayout:l,potentialProfit:d,usdcBalance:u,yesTokenBalance:p,noTokenBalance:m,isBalanceLoading:g,isSubmitting:f,validation:h,setOutcome:v,setSide:O,setQuantity:R,submit:N}=Cr({market:t,initialSide:r,initialOutcome:o,chain:n}),A=walletConnector.useAuthCallback(N),q=react.useMemo(()=>e?Nr(e):void 0,[e]),Q=react.useMemo(()=>wr(t),[t]);return jsxRuntime.jsx(Lr,{event:q,market:Q,outcome:s,side:a,quantity:i,estimatedCost:c,potentialPayout:l,potentialProfit:d,usdcBalance:u,yesTokenBalance:p,noTokenBalance:m,isBalanceLoading:g,isSubmitting:f,isValid:h.isValid,validationErrors:h.errors,onOutcomeChange:v,onSideChange:O,onQuantityChange:R,onSubmit:A})}function _r({event:e,walletAddress:t,onCancelOrder:r}){let{t:o}=i18n.useTranslation(),[n,s]=react.useState("positions"),a=react.useMemo(()=>e.markets?.map(u=>u.slug)??[],[e.markets]),{data:i}=reactPredict.usePositions({source:e.source,user:t??""}),c=react.useMemo(()=>!i?.positions||!t?0:a.length===0?i.positions.length:i.positions.filter(u=>u.market&&a.includes(u.market.slug)).length,[i?.positions,a,t]),d=[{key:"positions",label:c>0?`${o("predict.positions.title")} (${c})`:o("predict.positions.title")},{key:"orders",label:o("predict.openOrders.title")},{key:"trades",label:o("predict.tradeHistory.title")}];return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:d.map(u=>jsxRuntime.jsx("button",{type:"button",onClick:()=>s(u.key),className:ui.cn("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",n===u.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:u.label},u.key))}),t?jsxRuntime.jsxs("div",{className:"min-h-[120px]",children:[n==="positions"&&jsxRuntime.jsx(Ts,{source:e.source,walletAddress:t,marketSlugs:a}),n==="orders"&&jsxRuntime.jsx(Rs,{source:e.source,walletAddress:t,marketSlugs:a,onCancelOrder:r}),n==="trades"&&jsxRuntime.jsx(_s,{source:e.source,walletAddress:t})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-center py-12 text-sm text-neutral",children:o("predict.trade.connectWallet")})]})}function Ts({source:e,walletAddress:t,marketSlugs:r}){let{t:o}=i18n.useTranslation(),{data:n,isLoading:s}=reactPredict.usePositions({source:e,user:t}),a=react.useMemo(()=>n?.positions?r.length===0?n.positions:n.positions.filter(i=>i.market&&r.includes(i.market.slug)):[],[n?.positions,r]);return s?jsxRuntime.jsx(wt,{rows:3}):a.length===0?jsxRuntime.jsx(Nt,{message:o("predict.positions.empty")}):jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-xs lg:text-sm",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-neutral text-left",children:[jsxRuntime.jsx("th",{className:"py-2 pr-4 font-normal whitespace-nowrap",children:o("predict.positions.event")}),jsxRuntime.jsx("th",{className:"py-2 pr-3 font-normal text-right whitespace-nowrap",children:o("predict.positions.totalSize")}),jsxRuntime.jsx("th",{className:"py-2 pr-3 font-normal text-right whitespace-nowrap",children:o("predict.positions.value")}),jsxRuntime.jsx("th",{className:"py-2 pr-3 font-normal text-right whitespace-nowrap",children:o("predict.positions.avgPrice")}),jsxRuntime.jsx("th",{className:"py-2 pr-3 font-normal text-right whitespace-nowrap",children:o("predict.positions.markPrice")}),jsxRuntime.jsx("th",{className:"py-2 pr-3 font-normal text-right whitespace-nowrap",children:o("predict.positions.pnl")}),jsxRuntime.jsx("th",{className:"py-2 pr-3 font-normal text-right whitespace-nowrap",children:o("predict.positions.payoutIfRight")}),jsxRuntime.jsx("th",{className:"py-2 pr-3 font-normal text-right whitespace-nowrap",children:o("predict.positions.estSettlement")}),jsxRuntime.jsx("th",{className:"py-2 font-normal text-right whitespace-nowrap"})]})}),jsxRuntime.jsx("tbody",{children:a.map((i,c)=>jsxRuntime.jsx(Ls,{position:i},`${i.market?.slug??c}-${i.side}`))})]})})}function Ls({position:e}){let{t}=i18n.useTranslation(),r=e.pnl??0,o=e.pnl_percent??0,n=e.avg_price??0,s=e.current_price??0,a=r>0?"text-success":r<0?"text-danger":"text-foreground",i=r>0?"+":"",c=e.market?.outcomes?.[0]?.label??e.market?.question??"\u2014",l=e.side,d=e.size,u=e.size*s,p=e.market?.end_at?Hs(e.market.end_at):"\u2014";return jsxRuntime.jsxs("tr",{className:"border-b border-border/50 last:border-b-0 hover:bg-content2/40 transition-colors",children:[jsxRuntime.jsx("td",{className:"py-2 pr-4 max-w-[200px]",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate font-medium",children:c}),jsxRuntime.jsx("span",{className:ui.cn("inline-block text-[10px] font-medium w-fit",l.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:l})]})}),jsxRuntime.jsx("td",{className:"py-2 pr-3 text-right font-mono text-foreground whitespace-nowrap",children:e.size}),jsxRuntime.jsxs("td",{className:"py-2 pr-3 text-right font-mono text-foreground whitespace-nowrap",children:["$",u.toFixed(2)]}),jsxRuntime.jsx("td",{className:"py-2 pr-3 text-right font-mono text-foreground whitespace-nowrap",children:Qe(n)}),jsxRuntime.jsx("td",{className:"py-2 pr-3 text-right font-mono text-foreground whitespace-nowrap",children:Qe(s)}),jsxRuntime.jsxs("td",{className:ui.cn("py-2 pr-3 text-right font-mono whitespace-nowrap",a),children:[i,"$",Math.abs(r).toFixed(2),jsxRuntime.jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",i,o.toFixed(1),"%)"]})]}),jsxRuntime.jsxs("td",{className:"py-2 pr-3 text-right font-mono text-foreground whitespace-nowrap",children:["$",d.toFixed(2)]}),jsxRuntime.jsx("td",{className:"py-2 pr-3 text-right text-neutral whitespace-nowrap",children:p}),jsxRuntime.jsx("td",{className:"py-2 text-right whitespace-nowrap",children:jsxRuntime.jsx("button",{type:"button",className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors rounded px-2 py-0.5 border border-border hover:border-foreground/40",children:t("predict.positions.close")})})]})}function Rs({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:o}){let{t:n}=i18n.useTranslation(),{data:s,isLoading:a}=reactPredict.useOrders({source:e,wallet_address:t}),i=reactPredict.useCancelOrder(),c=react.useMemo(()=>{if(!s?.items)return [];let d=new Set(["live","open","submitted","pending"]),u=s.items.filter(p=>d.has(p.status));return r.length>0&&(u=u.filter(p=>p.market_id&&r.includes(p.market_id))),u},[s?.items,r]),l=d=>{o?o(d.id):i.mutate({source:d.source,id:d.id});};return a?jsxRuntime.jsx(wt,{rows:3}):c.length===0?jsxRuntime.jsx(Nt,{message:n("predict.openOrders.empty")}):jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-xs lg:text-sm",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-neutral text-left",children:[jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:n("predict.openOrders.side")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:n("predict.openOrders.outcome")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:n("predict.openOrders.type")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:n("predict.openOrders.price")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:n("predict.openOrders.filled")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:n("predict.openOrders.status")}),jsxRuntime.jsx("th",{className:"py-2 font-normal"})]})}),jsxRuntime.jsx("tbody",{children:c.map(d=>jsxRuntime.jsx(Os,{order:d,onCancel:()=>l(d),isCancelling:i.isPending},d.id))})]})})}function Os({order:e,onCancel:t,isCancelling:r}){let{t:o}=i18n.useTranslation(),n=e.side==="BUY";return jsxRuntime.jsxs("tr",{className:"border-b border-border/50 last:border-b-0",children:[jsxRuntime.jsx("td",{className:"py-2 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",n?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:e.side})}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-foreground capitalize",children:e.outcome??"\u2014"}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-neutral capitalize",children:e.order_type??"limit"}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:e.price?Qe(parseFloat(e.price)):"\u2014"}),jsxRuntime.jsxs("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:[e.size_matched??"0","/",e.original_size??"\u2014"]}),jsxRuntime.jsx("td",{className:"py-2 pr-2",children:jsxRuntime.jsx(Is,{status:e.status})}),jsxRuntime.jsx("td",{className:"py-2 text-right",children:jsxRuntime.jsx("button",{type:"button",onClick:t,disabled:r,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:r?jsxRuntime.jsx(ui.Spinner,{size:"sm"}):o("predict.openOrders.cancel")})})]})}function Is({status:e}){return jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium capitalize",{live:"bg-success/10 text-success",open:"bg-success/10 text-success",submitted:"bg-warning/10 text-warning",pending:"bg-warning/10 text-warning",matched:"bg-primary/10 text-primary",cancelled:"bg-neutral/10 text-neutral",failed:"bg-danger/10 text-danger",expired:"bg-neutral/10 text-neutral"}[e]??"bg-neutral/10 text-neutral"),children:e})}function _s({source:e,walletAddress:t}){let{t:r}=i18n.useTranslation(),{data:o,isLoading:n}=reactPredict.useTrades({source:e,wallet:t,limit:50}),s=o?.items??[];return n?jsxRuntime.jsx(wt,{rows:3}):s.length===0?jsxRuntime.jsx(Nt,{message:r("predict.tradeHistory.empty")}):jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-xs lg:text-sm",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-neutral text-left",children:[jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:r("predict.tradeHistory.side")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:r("predict.tradeHistory.outcome")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:r("predict.tradeHistory.price")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:r("predict.tradeHistory.qty")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:r("predict.tradeHistory.total")}),jsxRuntime.jsx("th",{className:"py-2 font-normal text-right",children:r("predict.tradeHistory.time")})]})}),jsxRuntime.jsx("tbody",{children:s.map(a=>jsxRuntime.jsx(As,{trade:a},a.id))})]})})}function As({trade:e}){let t=e.side?.toUpperCase()==="BUY",r=Ds(e.timestamp),o=e.price??0,n=e.usd_size??0;return jsxRuntime.jsxs("tr",{className:"border-b border-border/50 last:border-b-0",children:[jsxRuntime.jsx("td",{className:"py-2 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",t?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:e.side})}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-foreground capitalize",children:e.outcome??"\u2014"}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:Qe(o)}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:e.size}),jsxRuntime.jsxs("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:["$",n.toFixed(2)]}),jsxRuntime.jsx("td",{className:"py-2 text-right text-neutral whitespace-nowrap",children:r})]})}function Nt({message:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center py-12 text-sm text-neutral",children:e})}function wt({rows:e}){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-full rounded-md"},r))})}function Qe(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function Ds(e){let t=new Date(e*1e3),r=(t.getMonth()+1).toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),n=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0");return `${r}/${o} ${n}:${s}`}function Hs(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}function Oe({marketCount:e=4}){return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-4 animate-pulse",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"size-14 shrink-0 rounded-lg"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-32 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-full max-w-md rounded"})]})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-48 w-full rounded-xl"}),Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-12 w-full rounded-md"},r))]})}function Ar(){return jsxRuntime.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-border p-4 animate-pulse",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-10 w-full rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-24 w-full rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-10 w-full rounded-lg"})]})}var Br="var(--color-bullish)",Fr="var(--color-bearish)";function Ie(e){if(Math.abs(e)>=1e4){let t=e/1e4;return `${parseFloat(t.toFixed(2))}\u4E07`}return e.toLocaleString()}function Us(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function Ws(e,t){let r=new Float64Array(101),o=new Float64Array(101);for(let m of e){let g=Math.round(m.price*100);g>=0&&g<=100&&(r[g]+=m.quantity);}for(let m of t){let g=Math.round(m.price*100);g>=0&&g<=100&&(o[g]+=m.quantity);}let n=0,s=0,a=new Float64Array(101),i=new Float64Array(101);for(let m=100;m>=0;m--)n+=r[m],s+=r[m]*m/100,a[m]=n,i[m]=s;let c=0,l=0,d=new Float64Array(101),u=new Float64Array(101);for(let m=0;m<=100;m++)c+=o[m],l+=o[m]*m/100,d[m]=c,u[m]=l;let p=Math.max(a[0]??0,d[100]??0);return Array.from({length:101},(m,g)=>{let f=a[g]>0,h=d[g]>0,v=a[g]||d[g],O=r[g]>0||o[g]>0;return {priceCents:g,displayHeight:Us(v,p),opacity:v>0?O?1:.5:0,isBid:f,isAsk:h,bidCumTotal:a[g],askCumTotal:d[g],bidCumCost:i[g],askCumCost:u[g]}})}function $s({info:e}){let t=e.isBid?Br:Fr,r=e.leftPct>65?void 0:`${e.leftPct}%`,o=e.leftPct>65?`${100-e.leftPct}%`:void 0;return jsxRuntime.jsxs("div",{style:{position:"absolute",top:8,left:r,right:o,zIndex:10,background:"rgba(17,24,39,0.95)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:8,padding:"8px 12px",fontSize:12,color:"#f9fafb",minWidth:140,pointerEvents:"none"},children:[jsxRuntime.jsxs("div",{style:{marginBottom:4,fontWeight:600},children:[e.priceCents,"\xA2"]}),jsxRuntime.jsxs("div",{style:{color:t},children:[Ie(Math.round(e.cumTotal))," contracts"]}),jsxRuntime.jsxs("div",{style:{color:t},children:["$",Ie(Math.round(e.cumCost))]})]})}var zs=react.memo(function({slot:t,onEnter:r,onLeave:o}){let n=react.useRef(null),s=t.isBid||t.isAsk,a=t.isBid?Br:t.isAsk?Fr:void 0;return jsxRuntime.jsx("div",{style:{position:"absolute",left:`${t.priceCents}%`,width:"1%",height:"100%",boxSizing:"border-box",borderRight:t.priceCents<100?"1px solid transparent":"none",cursor:s?"crosshair":"default"},onMouseEnter:()=>r(t,n.current),onMouseLeave:o,children:s&&jsxRuntime.jsx("div",{ref:n,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:a,opacity:t.opacity}})})}),Ks=[0,10,20,30,40,50,60,70,80,90,100];function Vs(){return jsxRuntime.jsx("div",{className:"relative flex h-6 items-center border-b border-t border-border px-1",style:{background:"rgba(0,0,0,0.15)"},children:Ks.map(e=>jsxRuntime.jsx("span",{className:"absolute text-neutral font-normal",style:{fontSize:10,left:`${e}%`,transform:e===0?"translateX(0px)":e===100?"translateX(-100%)":"translateX(-50%)"},children:e},e))})}function Ur({bids:e,asks:t}){let r=react.useMemo(()=>Ws(e,t),[e,t]),o=react.useMemo(()=>{let d=e.length>0?Math.max(...e.map(p=>p.price)):0,u=t.length>0?Math.min(...t.map(p=>p.price)):1;return Math.round((d+u)/2*100)},[e,t]),n=react.useMemo(()=>r.some(d=>d.isBid||d.isAsk),[r]),[s,a]=react.useState(null),i=react.useRef(null),c=react.useCallback((d,u)=>{i.current&&(i.current.style.filter=""),u?(u.style.filter="brightness(1.5)",i.current=u):i.current=null,d.isBid||d.isAsk?a({priceCents:d.priceCents,isBid:d.isBid,cumTotal:d.isBid?d.bidCumTotal:d.askCumTotal,cumCost:d.isBid?d.bidCumCost:d.askCumCost,leftPct:d.priceCents}):a(null);},[]),l=react.useCallback(()=>{i.current&&(i.current.style.filter="",i.current=null),a(null);},[]);return n?jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxRuntime.jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[o>0&&jsxRuntime.jsx("div",{style:{position:"absolute",left:`${o}%`,top:0,bottom:0,width:1,backgroundImage:"repeating-linear-gradient(to bottom, #6b7280 0, #6b7280 4px, transparent 4px, transparent 8px)",zIndex:1,pointerEvents:"none"}}),s&&jsxRuntime.jsx($s,{info:s}),r.map(d=>jsxRuntime.jsx(zs,{slot:d,onEnter:c,onLeave:l},d.priceCents))]}),jsxRuntime.jsx(Vs,{})]}):jsxRuntime.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No depth data"})}function $r(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function zr(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"flex items-center justify-center gap-x-2 h-full text-neutral text-xs",children:[jsxRuntime.jsx(ui.Spinner,{size:"sm"}),jsxRuntime.jsx("span",{children:e("predict.orderBook.loading")})]})}function jr({market:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),[o,n]=react.useState("depth"),[s,a]=react.useState(reactPredict.ChartRange.ONE_WEEK),i=e.source,{data:c,isLoading:l}=reactPredict.useOrderbook({slug:e.slug,source:i}),{series:d,isLoading:u}=reactPredict.useMarketHistory(o==="chart"?[e]:[],s),p=react.useMemo(()=>(c?.bids??[]).map(v=>({price:v.price,quantity:v.size})),[c?.bids]),m=react.useMemo(()=>(c?.asks??[]).map(v=>({price:v.price,quantity:v.size})),[c?.asks]),g=react.useMemo(()=>p.length>0?Math.max(...p.map(v=>v.price)):null,[p]),f=react.useMemo(()=>m.length>0?Math.min(...m.map(v=>v.price)):null,[m]),h=react.useMemo(()=>{if(g==null||f==null)return null;let v=(f-g)*100;return Math.round(v*10)/10},[g,f]);return jsxRuntime.jsxs("div",{className:"flex flex-col h-[262px]",children:[jsxRuntime.jsxs("div",{className:"flex items-center border-b border-border px-1 py-2 text-xs",children:[jsxRuntime.jsx("span",{className:"flex-1 text-left text-neutral",children:h!=null?`${r("predict.orderBook.spread")}: ${Number.isInteger(h)?`${h}\xA2`:`${h.toFixed(1)}\xA2`}`:null}),jsxRuntime.jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[g!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bullish)"},children:[r("predict.trade.bestBid"),": ",$r(g)]}),g!=null&&f!=null&&jsxRuntime.jsx("span",{className:"text-neutral",children:"|"}),f!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bearish)"},children:[r("predict.trade.bestAsk"),": ",$r(f)]})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 justify-end gap-x-0.5",children:[jsxRuntime.jsx("button",{type:"button",title:"Depth chart",onClick:()=>n("depth"),className:ui.cn("flex items-center transition-colors cursor-pointer",o==="depth"?"text-foreground":"text-neutral hover:text-foreground"),children:jsxRuntime.jsx(ui.OrderbookDepthIcon,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",title:"Orderbook",onClick:()=>n("table"),className:ui.cn("flex items-center transition-colors cursor-pointer",o==="table"?"text-foreground":"text-neutral hover:text-foreground"),children:jsxRuntime.jsx(ui.OrderbookTableIcon,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",title:"Price chart",onClick:()=>n("chart"),className:ui.cn("flex items-center transition-colors cursor-pointer",o==="chart"?"text-foreground":"text-neutral hover:text-foreground"),children:jsxRuntime.jsx(ui.OrderbookChartIcon,{className:"h-4 w-4"})})]})]}),jsxRuntime.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden",children:[o==="depth"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:l?jsxRuntime.jsx(zr,{}):jsxRuntime.jsx(Ur,{bids:p,asks:m})}),o==="table"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:l?jsxRuntime.jsx(zr,{}):jsxRuntime.jsx(oa,{bids:p,asks:m,bestBid:g??void 0,bestAsk:f??void 0,spread:h??void 0})}),o==="chart"&&jsxRuntime.jsx(aa,{series:d,isLoading:u,chartRange:s,onRangeChange:a})]})]})}var Kr=8;function oa({bids:e,asks:t,spread:r}){let{t:o}=i18n.useTranslation(),n=react.useMemo(()=>[...t].sort((c,l)=>l.price-c.price).slice(0,Kr),[t]),s=react.useMemo(()=>[...e].sort((c,l)=>l.price-c.price).slice(0,Kr),[e]),a=react.useMemo(()=>{let c=[...n,...s].map(l=>l.quantity);return Math.max(...c,1)},[n,s]);return n.length===0&&s.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:o("predict.orderBook.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[n.map(c=>jsxRuntime.jsx(Vr,{price:c.price,quantity:c.quantity,side:"ask",maxQty:a},`ask-${c.price}`)),jsxRuntime.jsx("div",{className:"flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:r!=null&&jsxRuntime.jsxs("span",{children:[o("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]})}),s.map(c=>jsxRuntime.jsx(Vr,{price:c.price,quantity:c.quantity,side:"bid",maxQty:a},`bid-${c.price}`)),jsxRuntime.jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-neutral border-t border-border",children:[jsxRuntime.jsx("span",{children:o("predict.orderBook.price")}),jsxRuntime.jsx("span",{className:"text-right",children:o("predict.orderBook.contracts")}),jsxRuntime.jsx("span",{className:"text-right",children:o("predict.orderBook.total")})]})]})}function Vr({price:e,quantity:t,side:r,maxQty:o}){let n=r==="ask",s=Math.min(t/o*100,100),a=n?"bg-bullish/10":"bg-bearish/10",i=n?"text-bullish":"text-bearish",c=Math.round(e*100),l=Ie(Math.round(t)),d=Math.round(t*e),u=`$${Ie(d)}`;return jsxRuntime.jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsxRuntime.jsx("div",{className:`absolute inset-y-0 left-0 ${a} transition-[width] duration-200`,style:{width:`${s}%`}}),jsxRuntime.jsxs("span",{className:`relative z-10 ${i}`,children:[c,"\xA2"]}),jsxRuntime.jsx("span",{className:"relative z-10 text-foreground text-right",children:l}),jsxRuntime.jsx("span",{className:"relative z-10 text-foreground text-right",children:u})]})}var sa=[{value:reactPredict.ChartRange.ONE_DAY,label:"1D"},{value:reactPredict.ChartRange.ONE_WEEK,label:"1W"},{value:reactPredict.ChartRange.ONE_MONTH,label:"1M"},{value:reactPredict.ChartRange.ALL,label:"ALL"}];function aa({series:e,isLoading:t,chartRange:r,onRangeChange:o}){let n=react.useMemo(()=>!e.length||!e[0].data.length?[]:e[0].data.map(s=>({ts:s.timestamp,price:Math.round(s.price*100)})),[e]);return t?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-[200px]",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})}):n.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-[200px] text-xs text-neutral",children:"No price history"}):jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:180,children:jsxRuntime.jsxs(recharts.LineChart,{data:n,margin:{top:4,right:4,left:0,bottom:0},children:[jsxRuntime.jsx(recharts.CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.4}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"ts",hide:true}),jsxRuntime.jsx(recharts.YAxis,{domain:["auto","auto"],tickFormatter:s=>`${s}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:10},width:32}),jsxRuntime.jsx(recharts.Tooltip,{formatter:s=>[`${s??0}\xA2`,"Price"],contentStyle:{background:"rgba(17,24,39,0.95)",border:"1px solid #374151",borderRadius:8,fontSize:12},isAnimationActive:false}),jsxRuntime.jsx(recharts.Line,{type:"monotone",dataKey:"price",stroke:"hsl(var(--heroui-primary))",strokeWidth:2,dot:false,isAnimationActive:false})]})}),jsxRuntime.jsx("div",{className:"flex items-center justify-end gap-x-1",children:sa.map(s=>jsxRuntime.jsx("button",{type:"button",onClick:()=>o(s.value),className:ui.cn("px-2 py-0.5 rounded text-xs font-medium transition-colors cursor-pointer",r===s.value?"bg-content2 text-foreground":"text-neutral hover:text-foreground"),children:s.label},s.value))})]})}var Lt=class extends react.Component{state={error:null};static getDerivedStateFromError(t){return {error:t}}componentDidCatch(t,r){}render(){return this.state.error?jsxRuntime.jsxs("div",{style:{height:this.props.fallbackHeight??320,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:"#6b7280",fontSize:13},children:[jsxRuntime.jsx("span",{children:"Chart unavailable"}),jsxRuntime.jsx("span",{style:{fontSize:11,opacity:.7},children:this.state.error.message})]}):this.props.children}},tt=4,Gr=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function Xr(e,t){let r=new Date(e);return t===reactPredict.ChartRange.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Qr(e){return `${(e*100).toFixed(2)}%`}var ha=[{range:reactPredict.ChartRange.ONE_DAY,label:"1D"},{range:reactPredict.ChartRange.ONE_WEEK,label:"1W"},{range:reactPredict.ChartRange.ONE_MONTH,label:"1M"},{range:reactPredict.ChartRange.ALL,label:"ALL"}];function ba({value:e,onChange:t}){return jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:ha.map(({range:r,label:o})=>{let n=r===e;return jsxRuntime.jsx("button",{onClick:()=>t(r),style:{padding:"2px 8px",border:"none",background:"transparent",color:n?"#f9fafb":"#6b7280",fontWeight:n?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:o},r)})})}function ya({dots:e}){return jsxRuntime.jsx(jsxRuntime.Fragment,{children:e.map(({cx:t,cy:r,color:o},n)=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsxs("circle",{cx:t,cy:r,r:6,fill:o,opacity:.3,children:[jsxRuntime.jsx("animate",{attributeName:"r",values:"4;9;4",dur:"2s",repeatCount:"indefinite"}),jsxRuntime.jsx("animate",{attributeName:"opacity",values:"0.4;0.05;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsxRuntime.jsx("circle",{cx:t,cy:r,r:3.5,fill:o})]},n))})}function Sa(){let e=react.useRef(null),t=react.useRef(null),r=react.useCallback(n=>{let s=e.current,a=t.current;if(!s||!a)return;let i=s.getBoundingClientRect(),c=(n.clientX-i.left)/i.width*100;a.style.background=`linear-gradient(to right, transparent ${c}%, rgba(0,0,0,0.38) ${c}%)`,a.style.opacity="1";},[]),o=react.useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:o}}function ka({active:e,payload:t,label:r,labelMap:o}){if(!e||!t?.length)return null;let n=[...t].filter(s=>s.value!=null).sort((s,a)=>(a.value??0)-(s.value??0));return jsxRuntime.jsxs("div",{style:{background:"rgba(10,10,10,0.92)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 12px",minWidth:180,backdropFilter:"blur(8px)",fontSize:12},children:[jsxRuntime.jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof r=="number"?Xr(r):r}),n.map(s=>jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsxRuntime.jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:s.stroke??s.color,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:"#e5e7eb",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:o.get(s.dataKey)??s.dataKey}),jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:s.value!=null?Qr(s.value):"-"})]},s.dataKey))]})}function Pa({markets:e,selectedSlugs:t,colorMap:r,onToggle:o}){let[n,s]=react.useState(false),a=react.useRef(null);react.useEffect(()=>{if(!n)return;function l(d){a.current&&!a.current.contains(d.target)&&s(false);}return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[n]);let i=t.length>=tt,c=jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(l=>jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(l)??"#6b7280",display:"inline-block"}},l))}),jsxRuntime.jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?e.find(l=>l.slug===t[0])?.question??"1 market":`${t.length} / ${e.length} markets`})]});return jsxRuntime.jsxs("div",{ref:a,style:{position:"relative",display:"inline-block",maxWidth:320},children:[jsxRuntime.jsxs("button",{onClick:()=>s(l=>!l),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.05)",cursor:"pointer",minWidth:160,maxWidth:320,userSelect:"none"},children:[c,jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:n?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s",color:"#6b7280"},children:jsxRuntime.jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),n&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"#111827",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",minWidth:260,maxWidth:360,maxHeight:320,overflowY:"auto",padding:"6px 0"},children:[jsxRuntime.jsxs("div",{style:{padding:"4px 12px 8px",fontSize:11,color:"#6b7280",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:["Select up to ",tt," markets"]}),e.map(l=>{let d=t.includes(l.slug),u=!d&&i,p=d&&t.length===1,m=r.get(l.slug)??"#6b7280",g=l.outcomes.find(h=>h.label.toLowerCase()==="yes")??l.outcomes[0],f=g?.price!=null?`${Math.round(g.price*100)}%`:null;return jsxRuntime.jsxs("button",{onClick:()=>{p||u||o(l.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:d?"rgba(255,255,255,0.05)":"transparent",cursor:u||p?"not-allowed":"pointer",opacity:u?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:h=>{!u&&!p&&(h.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:h=>{h.currentTarget.style.background=d?"rgba(255,255,255,0.05)":"transparent";},children:[jsxRuntime.jsx("span",{style:{width:16,height:16,borderRadius:4,border:d?`2px solid ${m}`:"2px solid rgba(255,255,255,0.2)",background:d?`${m}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:d&&jsxRuntime.jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:m,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:m,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:d?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l.outcomes?.[0]?.label??l.question}),f&&jsxRuntime.jsx("span",{style:{color:m,fontWeight:700,fontSize:12,flexShrink:0},children:f})]},l.slug)})]})]})}function Ea({series:e,colorMap:t,displayValues:r}){let o=[...e].sort((n,s)=>(r.get(s.marketSlug)??0)-(r.get(n.marketSlug)??0));return jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 24px",padding:"0 2px"},children:o.map(n=>{let s=t.get(n.marketSlug)??"#6b7280",a=r.get(n.marketSlug);return jsxRuntime.jsxs("div",{style:{display:"inline-flex",alignItems:"flex-start",gap:6},children:[jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:s,flexShrink:0,marginTop:3}}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1},children:[jsxRuntime.jsx("span",{style:{color:"#9ca3af",fontSize:12,lineHeight:"17px",whiteSpace:"nowrap"},children:n.label}),a!=null&&jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:Qr(a)})]})]},n.marketSlug)})})}function Na(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function wa(e,t){if(e.length<=t)return e;let r=[],o=e.length/t;for(let n=0;n<t;n++){let s=Math.floor(n*o),a=Math.min(Math.floor((n+1)*o),e.length),i=e.slice(s,a),c=i.map(l=>l.price).sort((l,d)=>l-d);r.push({timestamp:i[i.length-1].timestamp,price:Na(c)});}return r}function Ca(e,t=200){if(e.length===0)return [];let r=e.map(i=>({...i,data:wa(i.data,t)})),o=new Set;r.forEach(i=>i.data.forEach(c=>o.add(c.timestamp)));let n=Array.from(o).sort((i,c)=>i-c),s=r.map(i=>{let c=new Map;return i.data.forEach(l=>c.set(l.timestamp,l.price)),{slug:i.marketSlug,map:c}}),a=new Map;return n.map(i=>{let c={timestamp:i};return s.forEach(({slug:l,map:d})=>{let u=d.get(i);if(u!==void 0)a.set(l,u),c[l]=u;else {let p=a.get(l);p!==void 0&&(c[l]=p);}}),c})}function Zr(e){return jsxRuntime.jsx(Lt,{children:jsxRuntime.jsx(Ma,{...e})})}function Ma({event:e,isLoading:t,className:r,volume:o}){let n=react.useMemo(()=>e.markets??[],[e.markets]),s=react.useMemo(()=>[...n].sort((y,P)=>{let C=z=>(z.outcomes.find(K=>K.label.toLowerCase()==="yes")??z.outcomes[0])?.price??0;return C(P)-C(y)}),[n]),[a,i]=react.useState(()=>s.slice(0,tt).map(y=>y.slug)),[c,l]=react.useState(Ve),d=react.useMemo(()=>{let y=new Map;return s.forEach((P,C)=>{y.set(P.slug,Gr[C%Gr.length]);}),y},[n]),u=react.useMemo(()=>n.filter(y=>a.includes(y.slug)),[n,a]),{series:p,isLoading:m}=reactPredict.useMarketHistory(u,c),g=t||m,f=react.useMemo(()=>{if(p.length>0&&p.some(C=>C.data.length>0))return p;let y=Date.now(),P=864e5;return u.map(C=>{let K=(C.outcomes?.find(V=>V.label.toLowerCase()==="yes")??C.outcomes?.[0])?.price??.5;return {marketSlug:C.slug,label:C.outcomes?.[0]?.label??C.question,data:[{timestamp:y-7*P,price:K},{timestamp:y,price:K}]}})},[p,u]),h=react.useMemo(()=>c===reactPredict.ChartRange.ONE_DAY?96:c===reactPredict.ChartRange.ONE_WEEK?168:c===reactPredict.ChartRange.ONE_MONTH?180:300,[c]),v=react.useMemo(()=>Ca(f,h),[f,h]),O=react.useMemo(()=>{if(v.length===0)return [0,1];let y=1/0,P=-1/0;if(a.forEach(z=>{v.forEach(K=>{let V=K[z];V!=null&&(V<y&&(y=V),V>P&&(P=V));});}),!isFinite(y))return [0,1];let C=Math.max((P-y)*.15,.05);return [Math.max(0,y-C),Math.min(1,P+C)]},[v,a]),R=react.useMemo(()=>{let y=new Map;return f.forEach(P=>{P.data.length>0&&y.set(P.marketSlug,P.data[P.data.length-1].price);}),y},[f]),N=react.useMemo(()=>{let y=new Map;return f.forEach(P=>y.set(P.marketSlug,P.label)),y},[f]),{wrapperRef:A,overlayRef:q,onMouseMove:Q,onMouseLeave:Pe}=Sa(),Ee=react.useCallback(y=>{i(P=>P.includes(y)?P.length<=1?P:P.filter(C=>C!==y):P.length>=tt?P:[...P,y]);},[]),[pe,w]=react.useState(null),X=react.useCallback(y=>{let P=y?.activePayload;if(!P?.length){w(null);return}let C=new Map;P.forEach(z=>{z.value!=null&&C.set(z.dataKey,z.value);}),w(C);},[]),ee=react.useCallback(()=>{w(null);},[]);return g?jsxRuntime.jsx("div",{style:{height:320,display:"flex",alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):v.length===0?jsxRuntime.jsx("div",{style:{height:320,display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No price history data"}):jsxRuntime.jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12},children:[jsxRuntime.jsx(Ea,{series:f,colorMap:d,displayValues:pe??R}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0},children:[jsxRuntime.jsxs("div",{ref:A,style:{height:300,width:"100%",userSelect:"none",position:"relative"},onMouseMove:Q,onMouseLeave:Pe,children:[jsxRuntime.jsx("div",{ref:q,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.LineChart,{data:v,margin:{top:8,right:16,left:0,bottom:0},onMouseMove:X,onMouseLeave:ee,children:[jsxRuntime.jsx(recharts.CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:["dataMin","dataMax"],tickFormatter:y=>Xr(y,c),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsxRuntime.jsx(recharts.YAxis,{domain:O,tickFormatter:y=>`${Math.round(y*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsxRuntime.jsx(recharts.Tooltip,{content:y=>jsxRuntime.jsx(ka,{...y,labelMap:N}),cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},isAnimationActive:false}),f.map(y=>{let P=d.get(y.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.Line,{type:"linear",dataKey:y.marketSlug,stroke:P,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:P},connectNulls:true,isAnimationActive:false},y.marketSlug)}),jsxRuntime.jsx(recharts.Customized,{component:y=>{let P=y.xAxisMap?Object.values(y.xAxisMap)[0]?.scale:null,C=y.yAxisMap?Object.values(y.yAxisMap)[0]?.scale:null,z=[];if(P&&C&&v.length>0){let K=v[v.length-1];f.forEach(V=>{let me=K[V.marketSlug];if(me==null)return;let ce=P(K.timestamp),Ne=C(me);ce==null||Ne==null||z.push({cx:ce,cy:Ne,color:d.get(V.marketSlug)??"#6b7280"});});}return jsxRuntime.jsx(ya,{dots:z})}})]})})]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:6},children:[s.length>1&&jsxRuntime.jsx(Pa,{markets:s,selectedSlugs:a,colorMap:d,onToggle:Ee}),o!=null&&o>0&&jsxRuntime.jsxs("span",{style:{flex:1,color:"#6b7280",fontSize:12,textAlign:"center"},children:["$",Math.round(o).toLocaleString()," vol"]}),jsxRuntime.jsx(ba,{value:c,onChange:l})]})]})]})}function Rt(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function _a(e){return `${Math.round(e*100)}%`}function Jr(e){let t=e*100;return t<1&&t>0?"< 1":Number.isInteger(t)?`${t}`:t.toFixed(1)}function en(e){return e.outcomes?.[0]?.label??e.question}function an(e){switch(e){case "polymarket":return "Polymarket";case "dflow":return "Kalshi";default:return e}}function tn(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),o=t.getDate(),n=t.getFullYear(),s=t.getHours().toString().padStart(2,"0"),a=t.getMinutes().toString().padStart(2,"0");return `${r} ${o}, ${n} ${s}:${a}`}function rn(e){let[t,r]=react.useState(Date.now());if(react.useEffect(()=>{if(!e)return;let d=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(d)},[e]),!e)return null;let o=new Date(e).getTime();if(isNaN(o))return null;let n=o-t;if(n<=0)return null;let s=Math.floor(n/864e5),a=Math.floor(n%864e5/36e5),i=Math.floor(n%36e5/6e4),c=Math.floor(n%6e4/1e3),l=[];return s>0&&l.push(`${s}d`),l.push(`${String(a).padStart(2,"0")}h`),l.push(`${String(i).padStart(2,"0")}m`),l.push(`${String(c).padStart(2,"0")}s`),l.join(" ")}function nn(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getDate().toString().padStart(2,"0"),a=t.getFullYear(),i=-t.getTimezoneOffset(),c=i>=0?"+":"-",l=String(Math.abs(Math.floor(i/60))).padStart(2,"0");return `${r}:${o} ${n}/${s}/${a} (${c}${l})`}function ln({event:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),{ref:o,isCollapsed:n}=hooks.useScrollCollapse(),s=react.useMemo(()=>[...e.markets||[]].sort((d,u)=>Rt(u)-Rt(d)),[e.markets]),a=rn(e.start_at),i=rn(e.end_at),c=nn(e.start_at),l=nn(e.end_at);return jsxRuntime.jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxRuntime.jsxs("div",{ref:o,className:`sticky top-0 z-30 flex items-center h-12 backdrop-blur-md transition-all duration-300 ${n?"gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"gap-x-2 lg:gap-x-4"}`,children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",className:`flex-shrink-0 transition-all duration-300 ${n?"!h-8 !w-8 lg:!h-10 lg:!w-10":"!h-14 !w-14 lg:!h-18 lg:!w-18"}`}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[!n&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(Ba,{source:e.source}),e.tags?.slice(0,3).map(d=>jsxRuntime.jsx("span",{className:"text-xs text-neutral truncate",children:d.label},d.slug))]}),jsxRuntime.jsx("span",{className:`font-semibold truncate transition-all duration-300 ${n?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),(a||i)&&jsxRuntime.jsx("div",{className:"flex items-center gap-x-2 text-xs text-neutral lg:text-sm font-mono",children:a?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:r("predict.event.beginsIn",{time:a})}),c&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{children:c})]})]}):i?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:r("predict.event.endsIn",{time:i})}),l&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{children:l})]})]}):null}),jsxRuntime.jsx(Zr,{event:e,volume:e.volume??void 0}),jsxRuntime.jsx(Aa,{markets:s,onTradeAction:t}),jsxRuntime.jsx(Ha,{markets:s,event:e})]})}var on=5;function Aa({markets:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),[o,n]=react.useState(false),[s,a]=react.useState(null);if(e.length===0)return null;let i=e.length>on,c=o?e:e.slice(0,on),l=d=>{a(u=>u===d?null:d);};return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("table",{className:"w-full border-collapse",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{children:[jsxRuntime.jsx("th",{}),jsxRuntime.jsx("th",{className:"py-2 text-left text-xs text-neutral font-normal lg:text-center lg:text-sm",children:r("predict.market.table.chance")}),jsxRuntime.jsx("th",{})]})}),jsxRuntime.jsx("tbody",{children:c.map((d,u)=>{let p=Rt(d),m=d.outcomes[1]?.best_ask??d.outcomes[1]?.price,g=u===0,f=s===d.slug;return jsxRuntime.jsx(Da,{market:d,yesPrice:p,noPrice:m??void 0,isTopMarket:g,isExpanded:f,onToggleExpand:()=>l(d.slug),onTradeAction:t},d.slug)})})]}),i&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>n(d=>!d),className:"flex w-full items-center justify-start gap-x-2 py-2 pl-1 text-xs text-neutral lg:pl-2 lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:r(o?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsxRuntime.jsx("svg",{className:ui.cn("h-4 w-4 transition-transform",o&&"rotate-180"),viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M4 6l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})}function Da({market:e,yesPrice:t,noPrice:r,isTopMarket:o,isExpanded:n,onToggleExpand:s,onTradeAction:a}){let{t:i}=i18n.useTranslation(),c=e.volume?`$${Math.round(e.volume).toLocaleString("en-US")} vol`:void 0;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:s,role:"button",tabIndex:0,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),s());},children:[jsxRuntime.jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:en(e)?.[0]||"?",radius:"lg",className:"size-5 shrink-0 lg:size-8",imgProps:{className:"object-cover"}}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate max-w-[200px] lg:max-w-[300px]",children:en(e)}),c&&jsxRuntime.jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:c})]})]})}),jsxRuntime.jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:_a(t)}),jsxRuntime.jsx("td",{className:"py-2 pr-1 lg:pr-2",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsxRuntime.jsx("button",{type:"button",className:ui.cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-opacity",o?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:l=>{l.stopPropagation(),a?.(e,"yes","buy");},children:i("predict.market.action.yes",{price:Jr(t)})}),jsxRuntime.jsx("button",{type:"button",className:"flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 bg-secondary/10 text-secondary cursor-pointer hover:opacity-80 transition-opacity",onClick:l=>{l.stopPropagation(),a?.(e,"no","buy");},children:r!=null?i("predict.market.action.no",{price:Jr(r)}):i("predict.market.no")})]})})]}),n&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:3,className:"px-2 pb-3",children:jsxRuntime.jsx("div",{className:"max-h-100 overflow-y-auto",children:jsxRuntime.jsx(jr,{market:e,onTradeAction:a})})})})]})}function Ha({markets:e,event:t}){let{t:r}=i18n.useTranslation(),[o,n]=react.useState(false),[s,a]=react.useState(false),i=e.filter(u=>u.rules&&u.rules.length>0);if(i.length===0)return null;let c=i[0];if(!c?.rules?.length)return null;let l=c.rules.join(`
|
|
19
|
+
`;function fr({event:e,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n,onHover:s}){let[a,i]=react.useState(null),c=e.markets??[],l=react.useMemo(()=>c.length>2?[...c].sort((N,A)=>(A.outcomes?.[0]?.price??0)-(N.outcomes?.[0]?.price??0)):c,[c]),d=l.filter(N=>N.status==="open"),u=l.length===1,p=d.slice(0,sr),m=d.length-sr,g=react.useMemo(()=>`$${Math.round(e.volume??0).toLocaleString("en-US")}`,[e.volume]),f=a?d.find(N=>N.slug===a)??null:null,h=!!f||u,v=()=>{h||o?.(e);},O=N=>{N.stopPropagation(),f&&(N.preventDefault(),i(null));},R=N=>{N.stopPropagation(),t||(N.preventDefault(),o?.(e));};return jsxRuntime.jsxs("div",{className:ui.cn("group flex h-full w-full flex-col rounded-xl","min-h-52 border border-border/90 bg-background p-3","lg:min-h-72 lg:max-w-md lg:p-4","gap-y-1.5 lg:gap-y-4","transition duration-300","hover:border-primary/40 hover:shadow-card-glow","focus-within:border-primary/40 focus-within:shadow-card-glow",!h&&"cursor-pointer"),onMouseEnter:()=>s?.(e),onClick:v,children:[jsxRuntime.jsx("style",{children:To}),jsxRuntime.jsx(Lo,{event:e,href:t,LinkComponent:r,onClick:O,isExpanded:h}),jsxRuntime.jsx("div",{className:"flex flex-1 flex-col",children:u?jsxRuntime.jsx(Bo,{market:d[0],event:e,formattedVolume:g,href:t,LinkComponent:r,onSelect:o,onSelectOutcome:n}):f?jsxRuntime.jsx(Fo,{market:f,event:e,onCollapse:()=>i(null),onSelectOutcome:n}):jsxRuntime.jsx(Do,{displayedMarkets:p,moreCount:m,formattedVolume:g,source:e.source,href:t,LinkComponent:r,onMarketClick:N=>i(N.slug),onShowMore:R})})]})}function Lo({event:e,href:t,LinkComponent:r,onClick:o,isExpanded:n}){let s=e.start_at?Mo(e.start_at):null;return jsxRuntime.jsxs(ui.Linkable,{href:t,LinkComponent:r,as:"button",className:"group/header flex items-center gap-x-2 lg:gap-x-4 w-full text-left cursor-pointer",onClick:o,children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",className:"h-8 w-8 flex-shrink-0 transition-transform duration-300 group-hover/header:scale-110 lg:h-12 lg:w-12",classNames:{base:"bg-transparent"}}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-y-0.5",children:[jsxRuntime.jsx("p",{className:ui.cn("min-w-0 text-sm font-semibold leading-snug text-slate-200 line-clamp-2 lg:text-base",n&&"group-hover/header:text-neutral-400"),children:e.title}),s&&jsxRuntime.jsxs("span",{className:"text-[10px] leading-4 text-neutral-500",children:["Live in ",s]})]}),jsxRuntime.jsx(Oo,{event:e})]})}function Ro(e){let t=[];if(e.status==="closed")return t.push({kind:"closed"}),t.slice(0,2);let r=e.tags?.some(n=>n.label?.toLowerCase()==="crypto"),o=e.tags?.some(n=>n.label?.toLowerCase()==="live");if(r&&e.end_at){let n=new Date(e.end_at).getTime()-Date.now(),s=300*1e3,a=900*1e3;if(n>0&&n<=a){let i=n<=s?"#ef4444":"#f59e0b";t.push({kind:"crypto-short",label:n<=s?"5m":"15m",color:i});}}return o&&t.push({kind:"live"}),t.slice(0,2)}function Oo({event:e}){let t=react.useMemo(()=>Ro(e),[e]);return t.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:t.map((r,o)=>{switch(r.kind){case "live":return jsxRuntime.jsx(Io,{},o);case "crypto-short":return jsxRuntime.jsx(_o,{label:r.label,color:r.color},o);case "closed":return jsxRuntime.jsx(Ao,{},o)}})})}function Io(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md bg-[rgb(240,68,56)]/10 px-1.5 py-0.5 text-xs font-semibold text-[rgb(240,68,56)]",children:[jsxRuntime.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-current"}),e("predict.event.status.live")]})}function _o({label:e,color:t}){return jsxRuntime.jsxs("span",{className:"badge-shine relative inline-flex items-center gap-1 overflow-hidden rounded-md px-1.5 py-0.5 text-xs font-semibold",style:{backgroundColor:`${t}26`,color:t},children:[jsxRuntime.jsx(ui.TimerIcon,{className:"size-3 shrink-0"}),e]})}function Ao(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsx("span",{className:"inline-flex items-center rounded-md bg-neutral-800/80 px-1.5 py-0.5 text-xs font-semibold text-neutral-400",children:e("predict.event.status.closed")})}function Do({displayedMarkets:e,moreCount:t,formattedVolume:r,source:o,href:n,LinkComponent:s,onMarketClick:a,onShowMore:i}){let{t:c}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e.length>0&&jsxRuntime.jsx("div",{className:"flex w-full flex-1 flex-col gap-y-0.5 lg:gap-y-2",children:e.map(l=>{let d=pr(l);return jsxRuntime.jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between gap-x-2 transition-opacity hover:cursor-pointer hover:opacity-80",onClick:u=>{u.stopPropagation(),a(l);},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 line-clamp-1 lg:text-sm",children:l.outcomes?.[0]?.label??l.question}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:mr(d)}),jsxRuntime.jsx(Ho,{})]})]},l.slug)})}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[t>0?jsxRuntime.jsxs(ui.Linkable,{href:n,LinkComponent:s,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:i,children:[c("predict.event.showMore"),jsxRuntime.jsx(vr,{className:"h-3 w-3"})]}):jsxRuntime.jsx("div",{}),jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1.5 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[r," ",c("predict.event.volume"),jsxRuntime.jsx(xr,{source:o})]})]})]})}function cr({bgColor:e,textColor:t,shadowColor:r,onClick:o,children:n}){return jsxRuntime.jsx("button",{type:"button",className:"flex h-12 flex-1 w-full items-center justify-center gap-x-1 overflow-hidden rounded-lg p-3 text-base font-normal hover:cursor-pointer will-change-transform [-webkit-tap-highlight-color:transparent]",style:{backgroundColor:e,color:t,"--shadow-color":r,"--shadow-offset":"4px",boxShadow:"inset 0 -1px 0 rgba(255,255,255,0.08), 0 var(--shadow-offset, 4px) 0 var(--shadow-color, rgba(0,0,0,0.22))",transition:"transform .12s, box-shadow .12s, opacity .14s"},onMouseEnter:i=>{let c=i.currentTarget;c.style.setProperty("--shadow-offset","2px"),c.style.transform="translateY(2px)";},onMouseLeave:i=>{let c=i.currentTarget;c.style.setProperty("--shadow-offset","4px"),c.style.transform="translateY(0px)";},onClick:o,children:n})}function gr({market:e,event:t,onSelectOutcome:r,dynamicColors:o=false,labelFormat:n="action"}){let{t:s}=i18n.useTranslation(),[a,i]=o?wo(e):[bt,ur],c=e.outcomes?.[0]?.label?.toLowerCase().trim()??"",l=e.outcomes?.[1]?.label?.toLowerCase().trim()??"",d=n==="label"&&c===l?"action":n,u=d==="label"?`${e.outcomes?.[0]?.label??"Yes"} ${ir(e)}\xA2`:s("predict.market.action.yes",{price:ir(e)}),p=d==="label"?`${e.outcomes?.[1]?.label??"No"} ${lr(e)}\xA2`:s("predict.market.action.no",{price:lr(e)});return jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx(cr,{bgColor:a.bg,textColor:a.text,shadowColor:a.shadow,onClick:m=>{m.stopPropagation(),r?.(t,e,"yes");},children:u}),jsxRuntime.jsx(cr,{bgColor:i.bg,textColor:i.text,shadowColor:i.shadow,onClick:m=>{m.stopPropagation(),r?.(t,e,"no");},children:p})]})}function Ho(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("span",{className:"inline-flex h-7 w-[85px] items-center justify-center gap-x-3 rounded-lg p-1.5 text-xs font-semibold flex-shrink-0 bg-gradient-to-r from-primary/15 to-secondary/15 lg:h-9 lg:w-24 lg:gap-x-4 lg:p-2 lg:text-sm",children:[jsxRuntime.jsx("span",{className:"text-primary",children:e("predict.market.yes")}),jsxRuntime.jsx("span",{className:"text-neutral-400",children:"/"}),jsxRuntime.jsx("span",{className:"text-secondary",children:e("predict.market.no")})]})}function Bo({market:e,event:t,formattedVolume:r,href:o,LinkComponent:n,onSelect:s,onSelectOutcome:a}){let{t:i}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex-1",children:jsxRuntime.jsx(gr,{market:e,event:t,onSelectOutcome:a,dynamicColors:true,labelFormat:"label"})}),jsxRuntime.jsxs("div",{className:"mt-auto flex items-center justify-between pt-3",children:[jsxRuntime.jsxs(ui.Linkable,{href:o,LinkComponent:n,as:"button",className:"flex items-center gap-1 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:l=>{l.stopPropagation(),o||(l.preventDefault(),s?.(t));},children:[i("predict.event.viewEvent"),jsxRuntime.jsx(vr,{className:"h-3 w-3"})]}),jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1.5 text-[10px] font-normal text-neutral-500 lg:text-xs",children:[r," ",i("predict.event.volume"),jsxRuntime.jsx(xr,{source:t.source})]})]})]})}function Fo({market:e,event:t,onCollapse:r,onSelectOutcome:o}){let{t:n}=i18n.useTranslation(),s=pr(e);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("button",{type:"button",className:"flex h-9 w-full items-center justify-between cursor-pointer",onClick:a=>{a.stopPropagation(),r();},children:[jsxRuntime.jsx("span",{className:"min-w-0 flex-1 text-left text-xs text-slate-200 lg:text-sm",children:e.outcomes?.[0]?.label??e.question}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 flex-shrink-0",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-slate-200 lg:text-lg",children:mr(s)}),jsxRuntime.jsx(ui.ChevronUpIcon,{className:"h-4 w-4 text-neutral-400"})]})]}),jsxRuntime.jsx("div",{className:"mt-3",children:jsxRuntime.jsx(gr,{market:e,event:t,onSelectOutcome:o,labelFormat:"action"})})]}),jsxRuntime.jsxs("button",{type:"button",className:"mt-auto flex items-center gap-x-1 pt-4 text-[10px] font-normal text-neutral-500 transition-colors hover:text-slate-200 cursor-pointer lg:text-xs",onClick:a=>{a.stopPropagation(),r();},children:[jsxRuntime.jsx(Uo,{className:"h-3 w-3"}),n("predict.event.back")]})]})}function vr({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsxRuntime.jsx("path",{d:"M4.5 2.5L8 6l-3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Uo({className:e}){return jsxRuntime.jsx("svg",{viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,children:jsxRuntime.jsx("path",{d:"M7.5 2.5L4 6l3.5 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function xr({source:e}){return jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-x-1 text-neutral-400",title:e==="polymarket"?"Polymarket":"Kalshi",children:[jsxRuntime.jsx("span",{className:"text-neutral-600",children:"\xB7"}),e==="polymarket"?jsxRuntime.jsx(ui.PolymarketIcon,{className:"h-5 w-auto shrink-0"}):jsxRuntime.jsx(ui.KalshiIcon,{className:"h-3 w-auto shrink-0"})]})}var Yo=768,br=1024,qo=1280,jo=8,Go=224,Xo=304,Qo=114;function Zo(e){return e>=qo?4:e>=br?3:e>=Yo?2:1}function Jo(e){return e>=br?Xo:Go}function yr({events:e,hasMore:t=false,onFetchMore:r,onSelect:o,onSelectOutcome:n,getEventHref:s,LinkComponent:a,onHover:i}){let c=react.useRef(null),l=react.useRef(null),{width:d=0,height:u=0}=hooks.useResizeObserver({ref:c}),p=Zo(d),m=Jo(d),g=Math.ceil(e.length/p)||0,f=!t&&e.length>0,h=g+(t?1:0)+(f?1:0),v=react.useCallback(A=>A<g,[g]),O=react.useCallback(async()=>{r?.();},[r]),R=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:v,loadMoreRows:O,rowCount:h,threshold:3}),N=react.useCallback(()=>{l.current?.scrollToRow({index:0,behavior:"smooth"});},[]);return jsxRuntime.jsx("div",{ref:c,className:"@container w-full h-full",children:u>0&&jsxRuntime.jsx(reactWindow.List,{listRef:l,className:"no-scrollbar",style:{height:u},onRowsRendered:R,rowComponent:es,rowCount:h,rowHeight:A=>f&&A===h-1?Qo:(m),rowProps:{events:e,columnCount:p,dataRowCount:g,showEndOfList:f,totalRowCount:h,onSelect:o,onSelectOutcome:n,getEventHref:s,LinkComponent:a,onHover:i,onScrollToTop:N}})})}function es({index:e,style:t,events:r,columnCount:o,dataRowCount:n,showEndOfList:s,totalRowCount:a,onSelect:i,onSelectOutcome:c,getEventHref:l,LinkComponent:d,onHover:u,onScrollToTop:p}){if(s&&e===a-1)return jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(ts,{onScrollToTop:p})});if(e>=n)return jsxRuntime.jsx("div",{style:t,className:"flex justify-center items-start pt-4",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})});let m=e*o,g=r.slice(m,m+o),f=o-g.length;return jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsxs("div",{className:"flex w-full h-full",children:[g.map(h=>h==null?null:jsxRuntime.jsx("div",{className:"flex-1 min-w-0 flex",style:{padding:jo},children:jsxRuntime.jsx(fr,{event:h,href:l?.(h),LinkComponent:d,onSelect:i,onSelectOutcome:c,onHover:u})},h.slug)),f>0&&Array.from({length:f}).map((h,v)=>jsxRuntime.jsx("div",{style:{flex:1,minWidth:0}},`spacer-${v}`))]})})}function ts({onScrollToTop:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"flex w-full flex-col items-center justify-center gap-y-4 py-6",children:[jsxRuntime.jsxs("div",{className:"flex w-full items-center justify-center gap-x-4",children:[jsxRuntime.jsx("div",{className:"h-px w-16 bg-neutral-700"}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-neutral-500",children:t("predict.event.endOfList")}),jsxRuntime.jsx("div",{className:"h-px w-16 bg-neutral-700"})]}),jsxRuntime.jsxs("button",{type:"button",className:"flex cursor-pointer items-center gap-x-1 text-xs font-medium text-neutral-400",onClick:e,children:[jsxRuntime.jsx("span",{className:"iconify size-4 ph--arrow-up-bold"}),jsxRuntime.jsx("span",{children:t("predict.event.backToTop")})]})]})}function kr({tagSlugSelection:e,limit:t=48,status:r,sort_by:o,sort_asc:n,source:s,with_markets:a,onSelect:i,onSelectOutcome:c,getEventHref:l,LinkComponent:d,onHover:u}){let{data:p,hasMore:m,fetchMore:g,isFetching:f}=or({tagSlugSelection:e,limit:t,status:r,sort_by:o,sort_asc:n,source:s,with_markets:a});return f?jsxRuntime.jsx(xt,{count:48}):jsxRuntime.jsx(yr,{events:p,hasMore:m,onFetchMore:g,onSelect:i,onSelectOutcome:c,getEventHref:l,LinkComponent:d,onHover:u})}function yc({onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:o,onHover:n}){let[s,a]=react.useState({categorySlug:null,tagSlug:null}),[i,c]=react.useState(pt),{isOpen:l,onOpen:d,onClose:u}=ui.useDisclosure(),p=react.useCallback(R=>{a(R);},[]),m=react.useCallback(R=>{c(N=>({...N,sortPreset:R}));},[]),g=react.useCallback(R=>{c(N=>({...N,sortAsc:R}));},[]),f=react.useCallback(R=>{c(R);},[]),h=react.useMemo(()=>er[i.sortPreset].sort_by,[i.sortPreset]),v=react.useMemo(()=>mt(i),[i]),O=jsxRuntime.jsx(tr,{sortPreset:i.sortPreset,onSortChange:m,sortAsc:i.sortAsc,onSortAscChange:g,onFilterPress:d,filterCount:v});return jsxRuntime.jsxs("div",{className:"flex h-full w-full max-w-[1680px] mx-auto flex-col gap-y-3",children:[jsxRuntime.jsx(jt,{onSelect:p,trailing:O}),jsxRuntime.jsx(Xt,{isOpen:l,onClose:u,value:i,onChange:f}),jsxRuntime.jsx("div",{className:"min-h-0 flex-1",children:jsxRuntime.jsx(kr,{tagSlugSelection:s,sort_by:h,sort_asc:i.sortAsc,source:i.source,onSelect:e,onSelectOutcome:t,getEventHref:r,LinkComponent:o,onHover:n})})]})}function Nr(e){return {title:e.title,imageUrl:e.image_url}}function wr(e){let t=e.outcomes[0],r=e.outcomes[1];return {yesAsk:t?.best_ask??t?.price,noAsk:r?.best_ask??r?.price,yesBid:t?.best_bid,noBid:r?.best_bid,yesSubTitle:t?.label??"Yes",noSubTitle:r?.label??"No"}}function ms(){let e={startVelocity:30,spread:360,ticks:60,zIndex:9999};Et__default.default({...e,particleCount:80,origin:{x:.5,y:.4}}),setTimeout(()=>{Et__default.default({...e,particleCount:40,origin:{x:.3,y:.6}});},150),setTimeout(()=>{Et__default.default({...e,particleCount:40,origin:{x:.7,y:.6}});},300);}function Cr({market:e,chain:t="solana",initialOutcome:r="yes",initialSide:o="buy"}){let{t:n}=i18n.useTranslation(),{status:s}=walletConnector.useAuth(),i=walletConnector.useWallets().find(T=>T.chainNamespace===types.ChainNamespace.SOLANA&&T.isConnected),c=s==="authenticated",l=i?.address,d=e.source,[u,p]=react.useState(r),[m,g]=react.useState(o),[f,h]=react.useState(NaN),[v,O]=react.useState(false),[R,N]=react.useState(null),A=react.useMemo(()=>{let T=u==="yes"?0:1,D=e.outcomes[T];return m==="buy"?D?.best_ask??D?.price??.5:D?.best_bid??D?.price??.5},[e.outcomes,u,m]),j=react.useMemo(()=>isNaN(f)||f<=0?0:m==="buy"?A>0?f/A:0:f,[m,f,A]),J=react.useMemo(()=>isNaN(f)||f<=0?"0":String(Math.round(f*1e6)),[f]),Ne=e.provider_meta?.["dflow.yesMint"]??"",we=e.provider_meta?.["dflow.noMint"]??"",ge=e.provider_meta?.["dflow.collateralMint"]??"",w=u==="yes"?Ne:we,Q=m==="buy"?ge:w,re=m==="buy"?w:ge,y=!!Q&&!!re&&!!l&&J!=="0",{refetch:P}=reactPredict.useDFlowQuote({inputMint:Q,outputMint:re,amount:J,userPublicKey:l??"",slippageBps:100},{enabled:y}),{data:C,isLoading:z}=reactPredict.usePositions({source:d,user:l??""},{enabled:!!l}),K=react.useMemo(()=>C&&C.positions.reduce((D,ae)=>ae.side==="USDC"||ae.side==="collateral"?D+(ae.current_value??0):D,0)||null,[C]),V=react.useMemo(()=>C?C.positions.find(D=>D.side?.toLowerCase()==="yes"&&D.market?.slug===e.slug)?.size??0:null,[C,e.slug]),ve=react.useMemo(()=>C?C.positions.find(D=>D.side?.toLowerCase()==="no"&&D.market?.slug===e.slug)?.size??0:null,[C,e.slug]),ue=react.useMemo(()=>{if(isNaN(f)||f<=0)return 0;if(m==="buy")return f;let T=u==="yes"?e.outcomes[0]?.best_bid??0:e.outcomes[1]?.best_bid??0;return f*T},[m,u,f,e.outcomes]),Ce=react.useMemo(()=>isNaN(f)||f<=0?0:m==="buy"?j*1:ue,[m,j,ue,f]),An=Ce-ue,Dn=react.useCallback(T=>{g(T),h(NaN);},[]),Hn=react.useCallback(T=>{if(isNaN(T)){h(NaN);return}let D=Math.max(0,T),ae=m==="buy"?Math.round(D*100)/100:Math.round(D);h(ae);},[m]),ct=react.useMemo(()=>{let T=[];(isNaN(f)||f<vt)&&T.push(`Minimum quantity is ${vt}`),e.status!=="open"&&T.push("Market is not active"),m==="buy"&&K!=null&&!isNaN(f)&&f>0&&f>K&&T.push("Insufficient USDC balance");let D=u==="yes"?V:ve;return m==="sell"&&D!=null&&!isNaN(f)&&f>0&&f>D&&T.push("Insufficient shares"),{isValid:T.length===0,errors:T}},[f,e.status,m,K,V,ve,u]),{mutateAsync:Ut}=reactPredict.useDFlowSubmit(),{data:dt}=reactPredict.useOrder({id:R??"",source:d},{enabled:!!R});react.useEffect(()=>{if(!dt||!R)return;let{status:T}=dt;T==="closed"?(O(false),N(null),ui.toast.success(n("predict.trade.submitSuccess")),ms(),h(NaN)):(T==="failed"||T==="expired")&&(O(false),N(null),ui.toast.error(n("predict.trade.submitError")));},[dt,R,n]);let Bn=react.useCallback(async()=>{if(!(!ct.isValid||!c||!l||!i)){O(true),N(null);try{let ae=(await P()).data?.transaction;if(!ae){ui.toast.error(n("predict.trade.submitError")),O(!1);return}let Wt=Uint8Array.from(atob(ae),Un=>Un.charCodeAt(0)),Fn=await i.sendTransaction(Wt);await Ut({signedTransaction:btoa(String.fromCharCode(...Wt)),orderContext:{user_public_key:l,input_mint:Q,output_mint:re,amount:J,price:String(A),side:m==="buy"?"BUY":"SELL",outcome:u==="yes"?"YES":"NO",market_slug:e.slug,slippage_bps:100}}),N(Fn);}catch{ui.toast.error(n("predict.trade.submitError")),O(false);}}},[ct.isValid,c,l,i,P,Ut,Q,re,J,A,m,u,e.slug,n]);return {outcome:u,side:m,quantity:f,estimatedCost:ue,potentialPayout:Ce,potentialProfit:An,usdcBalance:K,yesTokenBalance:V,noTokenBalance:ve,isBalanceLoading:z,isSubmitting:v,validation:ct,setOutcome:p,setSide:Dn,setQuantity:Hn,submit:Bn}}var ys=`https://s1.chainstream.io/chains/sol/tokens/${utils.SOLANA_TOKENS.stablecoins.USDC.address}/image.png`;function Lr({event:e,market:t,outcome:r,side:o,quantity:n,potentialProfit:s,estimatedCost:a,usdcBalance:i,yesTokenBalance:c,noTokenBalance:l,isBalanceLoading:d,isSubmitting:u,isValid:p,onOutcomeChange:m,onSideChange:g,onQuantityChange:f,onSubmit:h}){let{t:v}=i18n.useTranslation(),[O,R]=react.useState("market"),[N,A]=react.useState(false),j=react.useMemo(()=>{let w=o==="buy"?r==="yes"?t.yesAsk:t.noAsk:r==="yes"?t.yesBid:t.noBid;return w!=null?Math.round(Number(w)*100):null},[o,r,t]),J=react.useMemo(()=>{if(u)return v("predict.trade.submitting");if(!n||isNaN(n)||n<=0)return v("predict.trade.enterAmount");let w=v(o==="buy"?"predict.trade.buy":"predict.trade.sell"),Q=v(r==="yes"?"predict.trade.yes":"predict.trade.no");return `${w} ${Q}`},[u,n,o,r,v]),Ne=react.useMemo(()=>r==="yes"?"primary":"secondary",[r]),we=()=>{f(Math.floor((i??0)/2*100)/100);},ge=()=>{f(i??0);};return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 rounded-xl border border-default-200 bg-content1 p-4",children:[e&&jsxRuntime.jsxs("div",{className:"flex items-center gap-x-3",children:[e.imageUrl&&jsxRuntime.jsx("img",{src:e.imageUrl,alt:e.title,className:"h-10 w-10 shrink-0 rounded-lg object-cover"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-neutral-500 leading-tight line-clamp-1",children:e.title}),jsxRuntime.jsxs("span",{className:"text-base font-semibold leading-tight line-clamp-1",children:[jsxRuntime.jsxs("span",{className:r==="yes"?"text-bullish":"text-bearish",children:[v(o==="buy"?"predict.trade.buy":"predict.trade.sell")," ",v(r==="yes"?"predict.trade.yes":"predict.trade.no")]}),jsxRuntime.jsxs("span",{className:"text-foreground",children:[" \xB7 ",r==="yes"?t.yesSubTitle:t.noSubTitle]})]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:O,onSelectionChange:w=>R(w),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:v("predict.trade.market")},"market"),jsxRuntime.jsx(ui.Tab,{title:v("predict.trade.limit")},"limit")]}),j!=null&&jsxRuntime.jsxs("span",{className:"text-xl font-bold tabular-nums",children:[j," \xA2"]})]}),jsxRuntime.jsxs(ui.Tabs,{variant:"underlined",selectedKey:o,onSelectionChange:w=>g(w),classNames:{tabList:"gap-x-4",tab:"px-0"},children:[jsxRuntime.jsx(ui.Tab,{title:v("predict.trade.buy")},"buy"),jsxRuntime.jsx(ui.Tab,{title:v("predict.trade.sell")},"sell")]}),jsxRuntime.jsx("div",{className:"flex gap-x-2",children:["yes","no"].map(w=>{let Q=w==="yes"?c:l;return jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-y-1",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>m(w),className:`w-full rounded-lg border py-2 text-sm font-medium transition-colors cursor-pointer ${r===w?w==="yes"?"border-primary bg-primary-50 text-primary":"border-secondary bg-secondary-50 text-secondary":"border-default-400 text-foreground hover:border-default-500"}`,children:[jsxRuntime.jsx("span",{children:v(w==="yes"?"predict.trade.yes":"predict.trade.no")}),(()=>{let re=o==="buy"?w==="yes"?t.yesAsk:t.noAsk:w==="yes"?t.yesBid:t.noBid;return re!=null?jsxRuntime.jsxs("span",{className:"ml-1 opacity-70",children:[Math.round(Number(re)*100),"\xA2"]}):null})()]}),o==="sell"&&r===w&&jsxRuntime.jsx("span",{className:"text-center text-xs text-foreground",children:d?"\u2013":`${Q??0} shares`})]},w)})}),o==="buy"&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsxRuntime.jsx("span",{children:v("predict.trade.youArePaying")}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[jsxRuntime.jsx("img",{src:ys,alt:"USDC",className:"h-3.5 w-3.5 rounded-full object-cover"}),jsxRuntime.jsx("span",{className:"font-medium text-foreground tabular-nums",children:i!=null?`${i.toFixed(6)} USDC`:"\u2013"}),jsxRuntime.jsx("button",{type:"button",onClick:we,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:v("predict.trade.half")}),jsxRuntime.jsx("button",{type:"button",onClick:ge,className:"rounded px-1.5 py-0.5 bg-content2 hover:bg-content3 transition-colors cursor-pointer text-foreground font-medium",children:v("predict.trade.max")})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-1.5",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground",children:v(o==="buy"?"predict.trade.amount":"predict.trade.contracts")}),jsxRuntime.jsx(ui.StyledNumberInput,{fullWidth:true,placeholder:"0",radius:"lg",size:"lg",value:isNaN(n)?void 0:n,onValueChange:w=>{f(w);},minValue:0,step:o==="buy"?.01:1,formatOptions:o==="buy"?{maximumFractionDigits:2}:{maximumFractionDigits:0},startContent:o==="buy"?jsxRuntime.jsx("span",{className:"text-default-600 text-xl",children:"$"}):void 0,classNames:{inputWrapper:"bg-content2 data-[hover=true]:bg-content2 group-data-[focus=true]:bg-content2 h-14 min-h-14",input:"text-lg"}},o),o==="sell"&&jsxRuntime.jsxs("div",{className:"flex gap-x-2 justify-end",children:[[25,50].map(w=>jsxRuntime.jsxs("button",{type:"button",onClick:()=>{f(Math.floor((r==="yes"?c??0:l??0)*w/100));},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:[w,"%"]},w)),jsxRuntime.jsx("button",{type:"button",onClick:()=>{f(r==="yes"?c??0:l??0);},className:"rounded-md bg-content2 px-2.5 py-1 text-xs font-medium text-default-600 transition-colors hover:bg-content3 cursor-pointer",children:v("common.all")})]})]}),!isNaN(n)&&n>0&&jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-sm text-foreground",children:v(o==="buy"?"predict.trade.potentialWin":"predict.trade.estimatedReceive")}),jsxRuntime.jsxs("span",{className:"text-xl font-semibold text-bullish",children:["$",(o==="buy"?s:a).toFixed(2)]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>A(w=>!w),className:"flex items-center gap-x-1 text-neutral-500 hover:text-foreground cursor-pointer transition-colors",children:[jsxRuntime.jsx("span",{children:v("predict.trade.odds")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-3.5 w-3.5 transition-transform",N&&"rotate-180")})]}),j!=null&&jsxRuntime.jsxs("span",{className:"text-foreground font-medium tabular-nums",children:[j,"% chance"]})]}),N&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[jsxRuntime.jsxs("span",{children:[v("predict.trade.bestBid"),":"," ",Math.round((t.yesBid??0)*100),"\xA2"]}),jsxRuntime.jsxs("span",{children:[v("predict.trade.bestAsk"),":"," ",Math.round((t.yesAsk??0)*100),"\xA2"]})]})]}),jsxRuntime.jsx(ui.Button,{color:Ne,fullWidth:true,radius:"lg",size:"lg",isDisabled:!p||u||!n||isNaN(n)||n<=0,isLoading:u,onPress:h,children:J})]})}function Or({event:e,market:t,initialSide:r,initialOutcome:o,chain:n}){let{outcome:s,side:a,quantity:i,estimatedCost:c,potentialPayout:l,potentialProfit:d,usdcBalance:u,yesTokenBalance:p,noTokenBalance:m,isBalanceLoading:g,isSubmitting:f,validation:h,setOutcome:v,setSide:O,setQuantity:R,submit:N}=Cr({market:t,initialSide:r,initialOutcome:o,chain:n}),A=walletConnector.useAuthCallback(N),j=react.useMemo(()=>e?Nr(e):void 0,[e]),J=react.useMemo(()=>wr(t),[t]);return jsxRuntime.jsx(Lr,{event:j,market:J,outcome:s,side:a,quantity:i,estimatedCost:c,potentialPayout:l,potentialProfit:d,usdcBalance:u,yesTokenBalance:p,noTokenBalance:m,isBalanceLoading:g,isSubmitting:f,isValid:h.isValid,validationErrors:h.errors,onOutcomeChange:v,onSideChange:O,onQuantityChange:R,onSubmit:A})}function _r({event:e,walletAddress:t,onCancelOrder:r}){let{t:o}=i18n.useTranslation(),[n,s]=react.useState("positions"),a=react.useMemo(()=>e.markets?.map(u=>u.slug)??[],[e.markets]),{data:i}=reactPredict.usePositions({source:e.source,user:t??""}),c=react.useMemo(()=>!i?.positions||!t?0:a.length===0?i.positions.length:i.positions.filter(u=>u.market&&a.includes(u.market.slug)).length,[i?.positions,a,t]),d=[{key:"positions",label:c>0?`${o("predict.positions.title")} (${c})`:o("predict.positions.title")},{key:"orders",label:o("predict.openOrders.title")},{key:"trades",label:o("predict.tradeHistory.title")}];return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2 mt-6 px-1 lg:px-4",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-x-1 border-b border-border",children:d.map(u=>jsxRuntime.jsx("button",{type:"button",onClick:()=>s(u.key),className:ui.cn("px-3 py-2 text-sm font-medium transition-colors cursor-pointer",n===u.key?"text-foreground border-b-2 border-primary":"text-neutral hover:text-foreground"),children:u.label},u.key))}),t?jsxRuntime.jsxs("div",{className:"min-h-[120px]",children:[n==="positions"&&jsxRuntime.jsx(Ts,{source:e.source,walletAddress:t,marketSlugs:a}),n==="orders"&&jsxRuntime.jsx(Rs,{source:e.source,walletAddress:t,marketSlugs:a,onCancelOrder:r}),n==="trades"&&jsxRuntime.jsx(_s,{source:e.source,walletAddress:t})]}):jsxRuntime.jsx("div",{className:"flex items-center justify-center py-12 text-sm text-neutral",children:o("predict.trade.connectWallet")})]})}function Ts({source:e,walletAddress:t,marketSlugs:r}){let{t:o}=i18n.useTranslation(),{data:n,isLoading:s}=reactPredict.usePositions({source:e,user:t}),a=react.useMemo(()=>n?.positions?r.length===0?n.positions:n.positions.filter(i=>i.market&&r.includes(i.market.slug)):[],[n?.positions,r]);return s?jsxRuntime.jsx(Ct,{rows:3}):a.length===0?jsxRuntime.jsx(wt,{message:o("predict.positions.empty")}):jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-xs lg:text-sm",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-neutral text-left",children:[jsxRuntime.jsx("th",{className:"py-2 pr-4 font-normal whitespace-nowrap",children:o("predict.positions.event")}),jsxRuntime.jsx("th",{className:"py-2 pr-3 font-normal text-right whitespace-nowrap",children:o("predict.positions.totalSize")}),jsxRuntime.jsx("th",{className:"py-2 pr-3 font-normal text-right whitespace-nowrap",children:o("predict.positions.value")}),jsxRuntime.jsx("th",{className:"py-2 pr-3 font-normal text-right whitespace-nowrap",children:o("predict.positions.avgPrice")}),jsxRuntime.jsx("th",{className:"py-2 pr-3 font-normal text-right whitespace-nowrap",children:o("predict.positions.markPrice")}),jsxRuntime.jsx("th",{className:"py-2 pr-3 font-normal text-right whitespace-nowrap",children:o("predict.positions.pnl")}),jsxRuntime.jsx("th",{className:"py-2 pr-3 font-normal text-right whitespace-nowrap",children:o("predict.positions.payoutIfRight")}),jsxRuntime.jsx("th",{className:"py-2 pr-3 font-normal text-right whitespace-nowrap",children:o("predict.positions.estSettlement")}),jsxRuntime.jsx("th",{className:"py-2 font-normal text-right whitespace-nowrap"})]})}),jsxRuntime.jsx("tbody",{children:a.map((i,c)=>jsxRuntime.jsx(Ls,{position:i},`${i.market?.slug??c}-${i.side}`))})]})})}function Ls({position:e}){let{t}=i18n.useTranslation(),r=e.pnl??0,o=e.pnl_percent??0,n=e.avg_price??0,s=e.current_price??0,a=r>0?"text-success":r<0?"text-danger":"text-foreground",i=r>0?"+":"",c=e.market?.outcomes?.[0]?.label??e.market?.question??"\u2014",l=e.side,d=e.size,u=e.size*s,p=e.market?.end_at?Hs(e.market.end_at):"\u2014";return jsxRuntime.jsxs("tr",{className:"border-b border-border/50 last:border-b-0 hover:bg-content2/40 transition-colors",children:[jsxRuntime.jsx("td",{className:"py-2 pr-4 max-w-[200px]",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-0.5",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate font-medium",children:c}),jsxRuntime.jsx("span",{className:ui.cn("inline-block text-[10px] font-medium w-fit",l.toLowerCase()==="yes"?"text-primary":"text-secondary"),children:l})]})}),jsxRuntime.jsx("td",{className:"py-2 pr-3 text-right font-mono text-foreground whitespace-nowrap",children:e.size}),jsxRuntime.jsxs("td",{className:"py-2 pr-3 text-right font-mono text-foreground whitespace-nowrap",children:["$",u.toFixed(2)]}),jsxRuntime.jsx("td",{className:"py-2 pr-3 text-right font-mono text-foreground whitespace-nowrap",children:Ze(n)}),jsxRuntime.jsx("td",{className:"py-2 pr-3 text-right font-mono text-foreground whitespace-nowrap",children:Ze(s)}),jsxRuntime.jsxs("td",{className:ui.cn("py-2 pr-3 text-right font-mono whitespace-nowrap",a),children:[i,"$",Math.abs(r).toFixed(2),jsxRuntime.jsxs("span",{className:"text-[10px] ml-0.5 opacity-70",children:["(",i,o.toFixed(1),"%)"]})]}),jsxRuntime.jsxs("td",{className:"py-2 pr-3 text-right font-mono text-foreground whitespace-nowrap",children:["$",d.toFixed(2)]}),jsxRuntime.jsx("td",{className:"py-2 pr-3 text-right text-neutral whitespace-nowrap",children:p}),jsxRuntime.jsx("td",{className:"py-2 text-right whitespace-nowrap",children:jsxRuntime.jsx("button",{type:"button",className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors rounded px-2 py-0.5 border border-border hover:border-foreground/40",children:t("predict.positions.close")})})]})}function Rs({source:e,walletAddress:t,marketSlugs:r,onCancelOrder:o}){let{t:n}=i18n.useTranslation(),{data:s,isLoading:a}=reactPredict.useOrders({source:e,wallet_address:t}),i=reactPredict.useCancelOrder(),c=react.useMemo(()=>{if(!s?.items)return [];let d=new Set(["live","open","submitted","pending"]),u=s.items.filter(p=>d.has(p.status));return r.length>0&&(u=u.filter(p=>p.market_id&&r.includes(p.market_id))),u},[s?.items,r]),l=d=>{o?o(d.id):i.mutate({source:d.source,id:d.id});};return a?jsxRuntime.jsx(Ct,{rows:3}):c.length===0?jsxRuntime.jsx(wt,{message:n("predict.openOrders.empty")}):jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-xs lg:text-sm",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-neutral text-left",children:[jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:n("predict.openOrders.side")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:n("predict.openOrders.outcome")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:n("predict.openOrders.type")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:n("predict.openOrders.price")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:n("predict.openOrders.filled")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:n("predict.openOrders.status")}),jsxRuntime.jsx("th",{className:"py-2 font-normal"})]})}),jsxRuntime.jsx("tbody",{children:c.map(d=>jsxRuntime.jsx(Os,{order:d,onCancel:()=>l(d),isCancelling:i.isPending},d.id))})]})})}function Os({order:e,onCancel:t,isCancelling:r}){let{t:o}=i18n.useTranslation(),n=e.side==="BUY";return jsxRuntime.jsxs("tr",{className:"border-b border-border/50 last:border-b-0",children:[jsxRuntime.jsx("td",{className:"py-2 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",n?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:e.side})}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-foreground capitalize",children:e.outcome??"\u2014"}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-neutral capitalize",children:e.order_type??"limit"}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:e.price?Ze(parseFloat(e.price)):"\u2014"}),jsxRuntime.jsxs("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:[e.size_matched??"0","/",e.original_size??"\u2014"]}),jsxRuntime.jsx("td",{className:"py-2 pr-2",children:jsxRuntime.jsx(Is,{status:e.status})}),jsxRuntime.jsx("td",{className:"py-2 text-right",children:jsxRuntime.jsx("button",{type:"button",onClick:t,disabled:r,className:"text-[10px] text-danger hover:text-danger/80 cursor-pointer disabled:opacity-50 transition-colors",children:r?jsxRuntime.jsx(ui.Spinner,{size:"sm"}):o("predict.openOrders.cancel")})})]})}function Is({status:e}){return jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium capitalize",{live:"bg-success/10 text-success",open:"bg-success/10 text-success",submitted:"bg-warning/10 text-warning",pending:"bg-warning/10 text-warning",matched:"bg-primary/10 text-primary",cancelled:"bg-neutral/10 text-neutral",failed:"bg-danger/10 text-danger",expired:"bg-neutral/10 text-neutral"}[e]??"bg-neutral/10 text-neutral"),children:e})}function _s({source:e,walletAddress:t}){let{t:r}=i18n.useTranslation(),{data:o,isLoading:n}=reactPredict.useTrades({source:e,wallet:t,limit:50}),s=o?.items??[];return n?jsxRuntime.jsx(Ct,{rows:3}):s.length===0?jsxRuntime.jsx(wt,{message:r("predict.tradeHistory.empty")}):jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:"w-full text-xs lg:text-sm",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{className:"text-neutral text-left",children:[jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:r("predict.tradeHistory.side")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal",children:r("predict.tradeHistory.outcome")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:r("predict.tradeHistory.price")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:r("predict.tradeHistory.qty")}),jsxRuntime.jsx("th",{className:"py-2 pr-2 font-normal text-right",children:r("predict.tradeHistory.total")}),jsxRuntime.jsx("th",{className:"py-2 font-normal text-right",children:r("predict.tradeHistory.time")})]})}),jsxRuntime.jsx("tbody",{children:s.map(a=>jsxRuntime.jsx(As,{trade:a},a.id))})]})})}function As({trade:e}){let t=e.side?.toUpperCase()==="BUY",r=Ds(e.timestamp),o=e.price??0,n=e.usd_size??0;return jsxRuntime.jsxs("tr",{className:"border-b border-border/50 last:border-b-0",children:[jsxRuntime.jsx("td",{className:"py-2 pr-2",children:jsxRuntime.jsx("span",{className:ui.cn("inline-block rounded px-1.5 py-0.5 text-[10px] font-medium",t?"bg-primary/10 text-primary":"bg-danger/10 text-danger"),children:e.side})}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-foreground capitalize",children:e.outcome??"\u2014"}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:Ze(o)}),jsxRuntime.jsx("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:e.size}),jsxRuntime.jsxs("td",{className:"py-2 pr-2 text-right font-mono text-foreground",children:["$",n.toFixed(2)]}),jsxRuntime.jsx("td",{className:"py-2 text-right text-neutral whitespace-nowrap",children:r})]})}function wt({message:e}){return jsxRuntime.jsx("div",{className:"flex items-center justify-center py-12 text-sm text-neutral",children:e})}function Ct({rows:e}){return jsxRuntime.jsx("div",{className:"flex flex-col gap-y-2 py-3 animate-pulse",children:Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-8 w-full rounded-md"},r))})}function Ze(e){let t=e*100;return t<1&&t>0?"< 1\xA2":`${t.toFixed(1)}\xA2`}function Ds(e){let t=new Date(e*1e3),r=(t.getMonth()+1).toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),n=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0");return `${r}/${o} ${n}:${s}`}function Hs(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return "\u2014"}}function Ie({marketCount:e=4}){return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-4 animate-pulse",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(ui.Skeleton,{className:"size-14 shrink-0 rounded-lg"}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-4 w-32 rounded"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-6 w-full max-w-md rounded"})]})]}),jsxRuntime.jsx(ui.Skeleton,{className:"h-48 w-full rounded-xl"}),Array.from({length:e}).map((t,r)=>jsxRuntime.jsx(ui.Skeleton,{className:"h-12 w-full rounded-md"},r))]})}function Ar(){return jsxRuntime.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-border p-4 animate-pulse",children:[jsxRuntime.jsx(ui.Skeleton,{className:"h-10 w-full rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-24 w-full rounded-lg"}),jsxRuntime.jsx(ui.Skeleton,{className:"h-10 w-full rounded-lg"})]})}var Br="var(--color-bullish)",Fr="var(--color-bearish)";function _e(e){if(Math.abs(e)>=1e4){let t=e/1e4;return `${parseFloat(t.toFixed(2))}\u4E07`}return e.toLocaleString()}function Us(e,t){return e<=0||t<=0?0:Math.pow(e/t,.3)}function Ws(e,t){let r=new Float64Array(101),o=new Float64Array(101);for(let m of e){let g=Math.round(m.price*100);g>=0&&g<=100&&(r[g]+=m.quantity);}for(let m of t){let g=Math.round(m.price*100);g>=0&&g<=100&&(o[g]+=m.quantity);}let n=0,s=0,a=new Float64Array(101),i=new Float64Array(101);for(let m=100;m>=0;m--)n+=r[m],s+=r[m]*m/100,a[m]=n,i[m]=s;let c=0,l=0,d=new Float64Array(101),u=new Float64Array(101);for(let m=0;m<=100;m++)c+=o[m],l+=o[m]*m/100,d[m]=c,u[m]=l;let p=Math.max(a[0]??0,d[100]??0);return Array.from({length:101},(m,g)=>{let f=a[g]>0,h=d[g]>0,v=a[g]||d[g],O=r[g]>0||o[g]>0;return {priceCents:g,displayHeight:Us(v,p),opacity:v>0?O?1:.5:0,isBid:f,isAsk:h,bidCumTotal:a[g],askCumTotal:d[g],bidCumCost:i[g],askCumCost:u[g]}})}function $s({info:e}){let t=e.isBid?Br:Fr,r=e.leftPct>65?void 0:`${e.leftPct}%`,o=e.leftPct>65?`${100-e.leftPct}%`:void 0;return jsxRuntime.jsxs("div",{style:{position:"absolute",top:8,left:r,right:o,zIndex:10,background:"rgba(17,24,39,0.95)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:8,padding:"8px 12px",fontSize:12,color:"#f9fafb",minWidth:140,pointerEvents:"none"},children:[jsxRuntime.jsxs("div",{style:{marginBottom:4,fontWeight:600},children:[e.priceCents,"\xA2"]}),jsxRuntime.jsxs("div",{style:{color:t},children:[_e(Math.round(e.cumTotal))," contracts"]}),jsxRuntime.jsxs("div",{style:{color:t},children:["$",_e(Math.round(e.cumCost))]})]})}var zs=react.memo(function({slot:t,onEnter:r,onLeave:o}){let n=react.useRef(null),s=t.isBid||t.isAsk,a=t.isBid?Br:t.isAsk?Fr:void 0;return jsxRuntime.jsx("div",{style:{position:"absolute",left:`${t.priceCents}%`,width:"1%",height:"100%",boxSizing:"border-box",borderRight:t.priceCents<100?"1px solid transparent":"none",cursor:s?"crosshair":"default"},onMouseEnter:()=>r(t,n.current),onMouseLeave:o,children:s&&jsxRuntime.jsx("div",{ref:n,style:{position:"absolute",bottom:0,left:0,width:"100%",height:`${t.displayHeight*100}%`,backgroundColor:a,opacity:t.opacity}})})}),Ks=[0,10,20,30,40,50,60,70,80,90,100];function Vs(){return jsxRuntime.jsx("div",{className:"relative flex h-6 items-center border-b border-t border-border px-1",style:{background:"rgba(0,0,0,0.15)"},children:Ks.map(e=>jsxRuntime.jsx("span",{className:"absolute text-neutral font-normal",style:{fontSize:10,left:`${e}%`,transform:e===0?"translateX(0px)":e===100?"translateX(-100%)":"translateX(-50%)"},children:e},e))})}function Ur({bids:e,asks:t}){let r=react.useMemo(()=>Ws(e,t),[e,t]),o=react.useMemo(()=>{let d=e.length>0?Math.max(...e.map(p=>p.price)):0,u=t.length>0?Math.min(...t.map(p=>p.price)):1;return Math.round((d+u)/2*100)},[e,t]),n=react.useMemo(()=>r.some(d=>d.isBid||d.isAsk),[r]),[s,a]=react.useState(null),i=react.useRef(null),c=react.useCallback((d,u)=>{i.current&&(i.current.style.filter=""),u?(u.style.filter="brightness(1.5)",i.current=u):i.current=null,d.isBid||d.isAsk?a({priceCents:d.priceCents,isBid:d.isBid,cumTotal:d.isBid?d.bidCumTotal:d.askCumTotal,cumCost:d.isBid?d.bidCumCost:d.askCumCost,leftPct:d.priceCents}):a(null);},[]),l=react.useCallback(()=>{i.current&&(i.current.style.filter="",i.current=null),a(null);},[]);return n?jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",userSelect:"none",overflow:"hidden"},children:[jsxRuntime.jsxs("div",{style:{flex:1,position:"relative",width:"100%",overflow:"hidden"},children:[o>0&&jsxRuntime.jsx("div",{style:{position:"absolute",left:`${o}%`,top:0,bottom:0,width:1,backgroundImage:"repeating-linear-gradient(to bottom, #6b7280 0, #6b7280 4px, transparent 4px, transparent 8px)",zIndex:1,pointerEvents:"none"}}),s&&jsxRuntime.jsx($s,{info:s}),r.map(d=>jsxRuntime.jsx(zs,{slot:d,onEnter:c,onLeave:l},d.priceCents))]}),jsxRuntime.jsx(Vs,{})]}):jsxRuntime.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No depth data"})}function $r(e){let t=e*100,r=Math.round(t*10)/10;return Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`}function zr(){let{t:e}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"flex items-center justify-center gap-x-2 h-full text-neutral text-xs",children:[jsxRuntime.jsx(ui.Spinner,{size:"sm"}),jsxRuntime.jsx("span",{children:e("predict.orderBook.loading")})]})}function jr({market:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),[o,n]=react.useState("depth"),[s,a]=react.useState(reactPredict.ChartRange.ONE_WEEK),i=e.source,{data:c,isLoading:l}=reactPredict.useOrderbook({slug:e.slug,source:i}),{series:d,isLoading:u}=reactPredict.useMarketHistory(o==="chart"?[e]:[],s),p=react.useMemo(()=>(c?.bids??[]).map(v=>({price:v.price,quantity:v.size})),[c?.bids]),m=react.useMemo(()=>(c?.asks??[]).map(v=>({price:v.price,quantity:v.size})),[c?.asks]),g=react.useMemo(()=>p.length>0?Math.max(...p.map(v=>v.price)):null,[p]),f=react.useMemo(()=>m.length>0?Math.min(...m.map(v=>v.price)):null,[m]),h=react.useMemo(()=>{if(g==null||f==null)return null;let v=(f-g)*100;return Math.round(v*10)/10},[g,f]);return jsxRuntime.jsxs("div",{className:"flex flex-col h-[262px]",children:[jsxRuntime.jsxs("div",{className:"flex items-center border-b border-border px-1 py-2 text-xs",children:[jsxRuntime.jsx("span",{className:"flex-1 text-left text-neutral",children:h!=null?`${r("predict.orderBook.spread")}: ${Number.isInteger(h)?`${h}\xA2`:`${h.toFixed(1)}\xA2`}`:null}),jsxRuntime.jsxs("span",{className:"flex flex-1 items-center justify-center gap-x-1 whitespace-nowrap",children:[g!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bullish)"},children:[r("predict.trade.bestBid"),": ",$r(g)]}),g!=null&&f!=null&&jsxRuntime.jsx("span",{className:"text-neutral",children:"|"}),f!=null&&jsxRuntime.jsxs("span",{style:{color:"var(--color-bearish)"},children:[r("predict.trade.bestAsk"),": ",$r(f)]})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 justify-end gap-x-0.5",children:[jsxRuntime.jsx("button",{type:"button",title:"Depth chart",onClick:()=>n("depth"),className:ui.cn("flex items-center transition-colors cursor-pointer",o==="depth"?"text-foreground":"text-neutral hover:text-foreground"),children:jsxRuntime.jsx(ui.OrderbookDepthIcon,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",title:"Orderbook",onClick:()=>n("table"),className:ui.cn("flex items-center transition-colors cursor-pointer",o==="table"?"text-foreground":"text-neutral hover:text-foreground"),children:jsxRuntime.jsx(ui.OrderbookTableIcon,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{type:"button",title:"Price chart",onClick:()=>n("chart"),className:ui.cn("flex items-center transition-colors cursor-pointer",o==="chart"?"text-foreground":"text-neutral hover:text-foreground"),children:jsxRuntime.jsx(ui.OrderbookChartIcon,{className:"h-4 w-4"})})]})]}),jsxRuntime.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden",children:[o==="depth"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:l?jsxRuntime.jsx(zr,{}):jsxRuntime.jsx(Ur,{bids:p,asks:m})}),o==="table"&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:l?jsxRuntime.jsx(zr,{}):jsxRuntime.jsx(oa,{bids:p,asks:m,bestBid:g??void 0,bestAsk:f??void 0,spread:h??void 0})}),o==="chart"&&jsxRuntime.jsx(aa,{series:d,isLoading:u,chartRange:s,onRangeChange:a})]})]})}var Kr=8;function oa({bids:e,asks:t,spread:r}){let{t:o}=i18n.useTranslation(),n=react.useMemo(()=>[...t].sort((c,l)=>l.price-c.price).slice(0,Kr),[t]),s=react.useMemo(()=>[...e].sort((c,l)=>l.price-c.price).slice(0,Kr),[e]),a=react.useMemo(()=>{let c=[...n,...s].map(l=>l.quantity);return Math.max(...c,1)},[n,s]);return n.length===0&&s.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full text-xs text-neutral",children:o("predict.orderBook.empty")}):jsxRuntime.jsxs("div",{className:"flex flex-col h-full overflow-y-auto text-xs font-mono select-none",children:[n.map(c=>jsxRuntime.jsx(Vr,{price:c.price,quantity:c.quantity,side:"ask",maxQty:a},`ask-${c.price}`)),jsxRuntime.jsx("div",{className:"flex items-center justify-center gap-x-2 py-1 border-y border-border text-neutral text-[10px]",children:r!=null&&jsxRuntime.jsxs("span",{children:[o("predict.orderBook.spread"),":"," ",Number.isInteger(r)?`${r}\xA2`:`${r.toFixed(1)}\xA2`]})}),s.map(c=>jsxRuntime.jsx(Vr,{price:c.price,quantity:c.quantity,side:"bid",maxQty:a},`bid-${c.price}`)),jsxRuntime.jsxs("div",{className:"grid grid-cols-3 px-2 pt-2 pb-0.5 text-[10px] text-neutral border-t border-border",children:[jsxRuntime.jsx("span",{children:o("predict.orderBook.price")}),jsxRuntime.jsx("span",{className:"text-right",children:o("predict.orderBook.contracts")}),jsxRuntime.jsx("span",{className:"text-right",children:o("predict.orderBook.total")})]})]})}function Vr({price:e,quantity:t,side:r,maxQty:o}){let n=r==="ask",s=Math.min(t/o*100,100),a=n?"bg-bullish/10":"bg-bearish/10",i=n?"text-bullish":"text-bearish",c=Math.round(e*100),l=_e(Math.round(t)),d=Math.round(t*e),u=`$${_e(d)}`;return jsxRuntime.jsxs("div",{className:"relative grid grid-cols-3 px-2 py-1 hover:bg-content2 transition-colors cursor-default",children:[jsxRuntime.jsx("div",{className:`absolute inset-y-0 left-0 ${a} transition-[width] duration-200`,style:{width:`${s}%`}}),jsxRuntime.jsxs("span",{className:`relative z-10 ${i}`,children:[c,"\xA2"]}),jsxRuntime.jsx("span",{className:"relative z-10 text-foreground text-right",children:l}),jsxRuntime.jsx("span",{className:"relative z-10 text-foreground text-right",children:u})]})}var sa=[{value:reactPredict.ChartRange.ONE_DAY,label:"1D"},{value:reactPredict.ChartRange.ONE_WEEK,label:"1W"},{value:reactPredict.ChartRange.ONE_MONTH,label:"1M"},{value:reactPredict.ChartRange.ALL,label:"ALL"}];function aa({series:e,isLoading:t,chartRange:r,onRangeChange:o}){let n=react.useMemo(()=>!e.length||!e[0].data.length?[]:e[0].data.map(s=>({ts:s.timestamp,price:Math.round(s.price*100)})),[e]);return t?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-[200px]",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})}):n.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-[200px] text-xs text-neutral",children:"No price history"}):jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-2",children:[jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:180,children:jsxRuntime.jsxs(recharts.LineChart,{data:n,margin:{top:4,right:4,left:0,bottom:0},children:[jsxRuntime.jsx(recharts.CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.4}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"ts",hide:true}),jsxRuntime.jsx(recharts.YAxis,{domain:["auto","auto"],tickFormatter:s=>`${s}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:10},width:32}),jsxRuntime.jsx(recharts.Tooltip,{formatter:s=>[`${s??0}\xA2`,"Price"],contentStyle:{background:"rgba(17,24,39,0.95)",border:"1px solid #374151",borderRadius:8,fontSize:12},isAnimationActive:false}),jsxRuntime.jsx(recharts.Line,{type:"monotone",dataKey:"price",stroke:"hsl(var(--heroui-primary))",strokeWidth:2,dot:false,isAnimationActive:false})]})}),jsxRuntime.jsx("div",{className:"flex items-center justify-end gap-x-1",children:sa.map(s=>jsxRuntime.jsx("button",{type:"button",onClick:()=>o(s.value),className:ui.cn("px-2 py-0.5 rounded text-xs font-medium transition-colors cursor-pointer",r===s.value?"bg-content2 text-foreground":"text-neutral hover:text-foreground"),children:s.label},s.value))})]})}var Rt=class extends react.Component{state={error:null};static getDerivedStateFromError(t){return {error:t}}componentDidCatch(t,r){}render(){return this.state.error?jsxRuntime.jsxs("div",{style:{height:this.props.fallbackHeight??320,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:"#6b7280",fontSize:13},children:[jsxRuntime.jsx("span",{children:"Chart unavailable"}),jsxRuntime.jsx("span",{style:{fontSize:11,opacity:.7},children:this.state.error.message})]}):this.props.children}},rt=4,Gr=["#22d3ee","#a3e635","#f97316","#f472b6","#a78bfa"];function Xr(e,t){let r=new Date(e);return t===reactPredict.ChartRange.ONE_DAY?r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:false}):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Qr(e){return `${(e*100).toFixed(2)}%`}var ha=[{range:reactPredict.ChartRange.ONE_DAY,label:"1D"},{range:reactPredict.ChartRange.ONE_WEEK,label:"1W"},{range:reactPredict.ChartRange.ONE_MONTH,label:"1M"},{range:reactPredict.ChartRange.ALL,label:"ALL"}];function ba({value:e,onChange:t}){return jsxRuntime.jsx("div",{style:{display:"flex",alignItems:"center",gap:2},children:ha.map(({range:r,label:o})=>{let n=r===e;return jsxRuntime.jsx("button",{onClick:()=>t(r),style:{padding:"2px 8px",border:"none",background:"transparent",color:n?"#f9fafb":"#6b7280",fontWeight:n?700:400,fontSize:12,cursor:"pointer",borderRadius:4,letterSpacing:"0.02em",transition:"color 0.15s",userSelect:"none"},children:o},r)})})}function ya({dots:e}){return jsxRuntime.jsx(jsxRuntime.Fragment,{children:e.map(({cx:t,cy:r,color:o},n)=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsxs("circle",{cx:t,cy:r,r:6,fill:o,opacity:.3,children:[jsxRuntime.jsx("animate",{attributeName:"r",values:"4;9;4",dur:"2s",repeatCount:"indefinite"}),jsxRuntime.jsx("animate",{attributeName:"opacity",values:"0.4;0.05;0.4",dur:"2s",repeatCount:"indefinite"})]}),jsxRuntime.jsx("circle",{cx:t,cy:r,r:3.5,fill:o})]},n))})}function Sa(){let e=react.useRef(null),t=react.useRef(null),r=react.useCallback(n=>{let s=e.current,a=t.current;if(!s||!a)return;let i=s.getBoundingClientRect(),c=(n.clientX-i.left)/i.width*100;a.style.background=`linear-gradient(to right, transparent ${c}%, rgba(0,0,0,0.38) ${c}%)`,a.style.opacity="1";},[]),o=react.useCallback(()=>{t.current&&(t.current.style.opacity="0");},[]);return {wrapperRef:e,overlayRef:t,onMouseMove:r,onMouseLeave:o}}function ka({active:e,payload:t,label:r,labelMap:o}){if(!e||!t?.length)return null;let n=[...t].filter(s=>s.value!=null).sort((s,a)=>(a.value??0)-(s.value??0));return jsxRuntime.jsxs("div",{style:{background:"rgba(10,10,10,0.92)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"8px 12px",minWidth:180,backdropFilter:"blur(8px)",fontSize:12},children:[jsxRuntime.jsx("div",{style:{color:"#9ca3af",marginBottom:6,fontWeight:500},children:typeof r=="number"?Xr(r):r}),n.map(s=>jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[jsxRuntime.jsx("span",{style:{display:"inline-block",width:3,height:14,borderRadius:2,background:s.stroke??s.color,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:"#e5e7eb",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},children:o.get(s.dataKey)??s.dataKey}),jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:s.value!=null?Qr(s.value):"-"})]},s.dataKey))]})}function Pa({markets:e,selectedSlugs:t,colorMap:r,onToggle:o}){let[n,s]=react.useState(false),a=react.useRef(null);react.useEffect(()=>{if(!n)return;function l(d){a.current&&!a.current.contains(d.target)&&s(false);}return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[n]);let i=t.length>=rt,c=jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{display:"flex",gap:3,flexShrink:0},children:t.map(l=>jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:r.get(l)??"#6b7280",display:"inline-block"}},l))}),jsxRuntime.jsx("span",{style:{color:"#e5e7eb",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.length===1?e.find(l=>l.slug===t[0])?.question??"1 market":`${t.length} / ${e.length} markets`})]});return jsxRuntime.jsxs("div",{ref:a,style:{position:"relative",display:"inline-block",maxWidth:320},children:[jsxRuntime.jsxs("button",{onClick:()=>s(l=>!l),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.05)",cursor:"pointer",minWidth:160,maxWidth:320,userSelect:"none"},children:[c,jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{flexShrink:0,transform:n?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s",color:"#6b7280"},children:jsxRuntime.jsx("path",{d:"M2 4l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),n&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,background:"#111827",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",minWidth:260,maxWidth:360,maxHeight:320,overflowY:"auto",padding:"6px 0"},children:[jsxRuntime.jsxs("div",{style:{padding:"4px 12px 8px",fontSize:11,color:"#6b7280",borderBottom:"1px solid rgba(255,255,255,0.06)",marginBottom:4},children:["Select up to ",rt," markets"]}),e.map(l=>{let d=t.includes(l.slug),u=!d&&i,p=d&&t.length===1,m=r.get(l.slug)??"#6b7280",g=l.outcomes.find(h=>h.label.toLowerCase()==="yes")??l.outcomes[0],f=g?.price!=null?`${Math.round(g.price*100)}%`:null;return jsxRuntime.jsxs("button",{onClick:()=>{p||u||o(l.slug);},style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"7px 12px",border:"none",background:d?"rgba(255,255,255,0.05)":"transparent",cursor:u||p?"not-allowed":"pointer",opacity:u?.35:1,textAlign:"left",transition:"background 0.1s"},onMouseEnter:h=>{!u&&!p&&(h.currentTarget.style.background="rgba(255,255,255,0.07)");},onMouseLeave:h=>{h.currentTarget.style.background=d?"rgba(255,255,255,0.05)":"transparent";},children:[jsxRuntime.jsx("span",{style:{width:16,height:16,borderRadius:4,border:d?`2px solid ${m}`:"2px solid rgba(255,255,255,0.2)",background:d?`${m}30`:"transparent",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:d&&jsxRuntime.jsx("svg",{width:"9",height:"7",viewBox:"0 0 9 7",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 3.5L3.5 6L8 1",stroke:m,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:m,flexShrink:0}}),jsxRuntime.jsx("span",{style:{color:d?"#f9fafb":"#9ca3af",fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l.outcomes?.[0]?.label??l.question}),f&&jsxRuntime.jsx("span",{style:{color:m,fontWeight:700,fontSize:12,flexShrink:0},children:f})]},l.slug)})]})]})}function Ea({series:e,colorMap:t,displayValues:r}){let o=[...e].sort((n,s)=>(r.get(s.marketSlug)??0)-(r.get(n.marketSlug)??0));return jsxRuntime.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 24px",padding:"0 2px"},children:o.map(n=>{let s=t.get(n.marketSlug)??"#6b7280",a=r.get(n.marketSlug);return jsxRuntime.jsxs("div",{style:{display:"inline-flex",alignItems:"flex-start",gap:6},children:[jsxRuntime.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:s,flexShrink:0,marginTop:3}}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1},children:[jsxRuntime.jsx("span",{style:{color:"#9ca3af",fontSize:12,lineHeight:"17px",whiteSpace:"nowrap"},children:n.label}),a!=null&&jsxRuntime.jsx("span",{style:{color:"#f9fafb",fontSize:14,fontWeight:700,lineHeight:"20px",fontVariantNumeric:"tabular-nums"},children:Qr(a)})]})]},n.marketSlug)})})}function Na(e){let t=Math.floor(e.length/2);return e.length%2===1?e[t]:(e[t-1]+e[t])/2}function wa(e,t){if(e.length<=t)return e;let r=[],o=e.length/t;for(let n=0;n<t;n++){let s=Math.floor(n*o),a=Math.min(Math.floor((n+1)*o),e.length),i=e.slice(s,a),c=i.map(l=>l.price).sort((l,d)=>l-d);r.push({timestamp:i[i.length-1].timestamp,price:Na(c)});}return r}function Ca(e,t=200){if(e.length===0)return [];let r=e.map(i=>({...i,data:wa(i.data,t)})),o=new Set;r.forEach(i=>i.data.forEach(c=>o.add(c.timestamp)));let n=Array.from(o).sort((i,c)=>i-c),s=r.map(i=>{let c=new Map;return i.data.forEach(l=>c.set(l.timestamp,l.price)),{slug:i.marketSlug,map:c}}),a=new Map;return n.map(i=>{let c={timestamp:i};return s.forEach(({slug:l,map:d})=>{let u=d.get(i);if(u!==void 0)a.set(l,u),c[l]=u;else {let p=a.get(l);p!==void 0&&(c[l]=p);}}),c})}function Zr(e){return jsxRuntime.jsx(Rt,{children:jsxRuntime.jsx(Ma,{...e})})}function Ma({event:e,isLoading:t,className:r,volume:o}){let n=react.useMemo(()=>e.markets??[],[e.markets]),s=react.useMemo(()=>[...n].sort((y,P)=>{let C=z=>(z.outcomes.find(K=>K.label.toLowerCase()==="yes")??z.outcomes[0])?.price??0;return C(P)-C(y)}),[n]),[a,i]=react.useState(()=>s.slice(0,rt).map(y=>y.slug)),[c,l]=react.useState(Ye),d=react.useMemo(()=>{let y=new Map;return s.forEach((P,C)=>{y.set(P.slug,Gr[C%Gr.length]);}),y},[n]),u=react.useMemo(()=>n.filter(y=>a.includes(y.slug)),[n,a]),{series:p,isLoading:m}=reactPredict.useMarketHistory(u,c),g=t||m,f=react.useMemo(()=>{if(p.length>0&&p.some(C=>C.data.length>0))return p;let y=Date.now(),P=864e5;return u.map(C=>{let K=(C.outcomes?.find(V=>V.label.toLowerCase()==="yes")??C.outcomes?.[0])?.price??.5;return {marketSlug:C.slug,label:C.outcomes?.[0]?.label??C.question,data:[{timestamp:y-7*P,price:K},{timestamp:y,price:K}]}})},[p,u]),h=react.useMemo(()=>c===reactPredict.ChartRange.ONE_DAY?96:c===reactPredict.ChartRange.ONE_WEEK?168:c===reactPredict.ChartRange.ONE_MONTH?180:300,[c]),v=react.useMemo(()=>Ca(f,h),[f,h]),O=react.useMemo(()=>{if(v.length===0)return [0,1];let y=1/0,P=-1/0;if(a.forEach(z=>{v.forEach(K=>{let V=K[z];V!=null&&(V<y&&(y=V),V>P&&(P=V));});}),!isFinite(y))return [0,1];let C=Math.max((P-y)*.15,.05);return [Math.max(0,y-C),Math.min(1,P+C)]},[v,a]),R=react.useMemo(()=>{let y=new Map;return f.forEach(P=>{P.data.length>0&&y.set(P.marketSlug,P.data[P.data.length-1].price);}),y},[f]),N=react.useMemo(()=>{let y=new Map;return f.forEach(P=>y.set(P.marketSlug,P.label)),y},[f]),{wrapperRef:A,overlayRef:j,onMouseMove:J,onMouseLeave:Ne}=Sa(),we=react.useCallback(y=>{i(P=>P.includes(y)?P.length<=1?P:P.filter(C=>C!==y):P.length>=rt?P:[...P,y]);},[]),[ge,w]=react.useState(null),Q=react.useCallback(y=>{let P=y?.activePayload;if(!P?.length){w(null);return}let C=new Map;P.forEach(z=>{z.value!=null&&C.set(z.dataKey,z.value);}),w(C);},[]),re=react.useCallback(()=>{w(null);},[]);return g?jsxRuntime.jsx("div",{style:{height:320,display:"flex",alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx("div",{style:{width:28,height:28,borderRadius:"50%",border:"2.5px solid #22d3ee",borderTopColor:"transparent",animation:"spin 0.7s linear infinite"}})}):v.length===0?jsxRuntime.jsx("div",{style:{height:320,display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280",fontSize:13},children:"No price history data"}):jsxRuntime.jsxs("div",{className:r,style:{display:"flex",flexDirection:"column",gap:12},children:[jsxRuntime.jsx(Ea,{series:f,colorMap:d,displayValues:ge??R}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:0},children:[jsxRuntime.jsxs("div",{ref:A,style:{height:300,width:"100%",userSelect:"none",position:"relative"},onMouseMove:J,onMouseLeave:Ne,children:[jsxRuntime.jsx("div",{ref:j,style:{position:"absolute",inset:0,opacity:0,pointerEvents:"none",zIndex:1}}),jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsxs(recharts.LineChart,{data:v,margin:{top:8,right:16,left:0,bottom:0},onMouseMove:Q,onMouseLeave:re,children:[jsxRuntime.jsx(recharts.CartesianGrid,{horizontal:true,vertical:false,strokeDasharray:"3 3",stroke:"#374151",opacity:.5}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"timestamp",type:"number",scale:"time",domain:["dataMin","dataMax"],tickFormatter:y=>Xr(y,c),axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},minTickGap:70}),jsxRuntime.jsx(recharts.YAxis,{domain:O,tickFormatter:y=>`${Math.round(y*100)}%`,axisLine:false,tickLine:false,tick:{fill:"#6b7280",fontSize:11},width:40,tickCount:6}),jsxRuntime.jsx(recharts.Tooltip,{content:y=>jsxRuntime.jsx(ka,{...y,labelMap:N}),cursor:{stroke:"#4b5563",strokeWidth:1,strokeDasharray:"4 4"},isAnimationActive:false}),f.map(y=>{let P=d.get(y.marketSlug)??"#6b7280";return jsxRuntime.jsx(recharts.Line,{type:"linear",dataKey:y.marketSlug,stroke:P,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",dot:false,activeDot:{r:4.5,strokeWidth:2,stroke:"rgba(10,10,10,0.8)",fill:P},connectNulls:true,isAnimationActive:false},y.marketSlug)}),jsxRuntime.jsx(recharts.Customized,{component:y=>{let P=y.xAxisMap?Object.values(y.xAxisMap)[0]?.scale:null,C=y.yAxisMap?Object.values(y.yAxisMap)[0]?.scale:null,z=[];if(P&&C&&v.length>0){let K=v[v.length-1];f.forEach(V=>{let ve=K[V.marketSlug];if(ve==null)return;let ue=P(K.timestamp),Ce=C(ve);ue==null||Ce==null||z.push({cx:ue,cy:Ce,color:d.get(V.marketSlug)??"#6b7280"});});}return jsxRuntime.jsx(ya,{dots:z})}})]})})]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:6},children:[s.length>1&&jsxRuntime.jsx(Pa,{markets:s,selectedSlugs:a,colorMap:d,onToggle:we}),o!=null&&o>0&&jsxRuntime.jsxs("span",{style:{flex:1,color:"#6b7280",fontSize:12,textAlign:"center"},children:["$",Math.round(o).toLocaleString()," vol"]}),jsxRuntime.jsx(ba,{value:c,onChange:l})]})]})]})}function Ot(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function _a(e){return `${Math.round(e*100)}%`}function Jr(e){let t=e*100;return t<1&&t>0?"< 1":Number.isInteger(t)?`${t}`:t.toFixed(1)}function en(e){return e.outcomes?.[0]?.label??e.question}function an(e){switch(e){case "polymarket":return "Polymarket";case "dflow":return "Kalshi";default:return e}}function tn(e){if(!e)return "\u2014";let t=new Date(e);if(isNaN(t.getTime()))return "\u2014";let r=t.toLocaleString("default",{month:"short"}),o=t.getDate(),n=t.getFullYear(),s=t.getHours().toString().padStart(2,"0"),a=t.getMinutes().toString().padStart(2,"0");return `${r} ${o}, ${n} ${s}:${a}`}function rn(e){let[t,r]=react.useState(Date.now());if(react.useEffect(()=>{if(!e)return;let d=setInterval(()=>r(Date.now()),1e3);return ()=>clearInterval(d)},[e]),!e)return null;let o=new Date(e).getTime();if(isNaN(o))return null;let n=o-t;if(n<=0)return null;let s=Math.floor(n/864e5),a=Math.floor(n%864e5/36e5),i=Math.floor(n%36e5/6e4),c=Math.floor(n%6e4/1e3),l=[];return s>0&&l.push(`${s}d`),l.push(`${String(a).padStart(2,"0")}h`),l.push(`${String(i).padStart(2,"0")}m`),l.push(`${String(c).padStart(2,"0")}s`),l.join(" ")}function nn(e){if(!e)return null;let t=new Date(e);if(isNaN(t.getTime()))return null;let r=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0"),n=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getDate().toString().padStart(2,"0"),a=t.getFullYear(),i=-t.getTimezoneOffset(),c=i>=0?"+":"-",l=String(Math.abs(Math.floor(i/60))).padStart(2,"0");return `${r}:${o} ${n}/${s}/${a} (${c}${l})`}function ln({event:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),{ref:o,isCollapsed:n}=hooks.useScrollCollapse(),s=react.useMemo(()=>[...e.markets||[]].sort((d,u)=>Ot(u)-Ot(d)),[e.markets]),a=rn(e.start_at),i=rn(e.end_at),c=nn(e.start_at),l=nn(e.end_at);return jsxRuntime.jsxs("div",{className:"w-full flex flex-col gap-y-4 lg:gap-y-6",children:[jsxRuntime.jsxs("div",{ref:o,className:`sticky top-0 z-30 flex items-center h-12 backdrop-blur-md transition-all duration-300 ${n?"gap-x-2 py-2 px-1 lg:px-4 -mx-1 lg:-mx-4 shadow-sm":"gap-x-2 lg:gap-x-4"}`,children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"lg",className:`flex-shrink-0 transition-all duration-300 ${n?"!h-8 !w-8 lg:!h-10 lg:!w-10":"!h-14 !w-14 lg:!h-18 lg:!w-18"}`}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[!n&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx(Ba,{source:e.source}),e.tags?.slice(0,3).map(d=>jsxRuntime.jsx("span",{className:"text-xs text-neutral truncate",children:d.label},d.slug))]}),jsxRuntime.jsx("span",{className:`font-semibold truncate transition-all duration-300 ${n?"text-sm lg:text-base":"text-lg lg:text-xl"}`,children:e.title})]})]}),(a||i)&&jsxRuntime.jsx("div",{className:"flex items-center gap-x-2 text-xs text-neutral lg:text-sm font-mono",children:a?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:r("predict.event.beginsIn",{time:a})}),c&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{children:c})]})]}):i?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:r("predict.event.endsIn",{time:i})}),l&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"text-neutral/50",children:"\xB7"}),jsxRuntime.jsx("span",{children:l})]})]}):null}),jsxRuntime.jsx(Zr,{event:e,volume:e.volume??void 0}),jsxRuntime.jsx(Aa,{markets:s,onTradeAction:t}),jsxRuntime.jsx(Ha,{markets:s,event:e})]})}var on=5;function Aa({markets:e,onTradeAction:t}){let{t:r}=i18n.useTranslation(),[o,n]=react.useState(false),[s,a]=react.useState(null);if(e.length===0)return null;let i=e.length>on,c=o?e:e.slice(0,on),l=d=>{a(u=>u===d?null:d);};return jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("table",{className:"w-full border-collapse",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsxs("tr",{children:[jsxRuntime.jsx("th",{}),jsxRuntime.jsx("th",{className:"py-2 text-left text-xs text-neutral font-normal lg:text-center lg:text-sm",children:r("predict.market.table.chance")}),jsxRuntime.jsx("th",{})]})}),jsxRuntime.jsx("tbody",{children:c.map((d,u)=>{let p=Ot(d),m=d.outcomes[1]?.best_ask??d.outcomes[1]?.price,g=u===0,f=s===d.slug;return jsxRuntime.jsx(Da,{market:d,yesPrice:p,noPrice:m??void 0,isTopMarket:g,isExpanded:f,onToggleExpand:()=>l(d.slug),onTradeAction:t},d.slug)})})]}),i&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>n(d=>!d),className:"flex w-full items-center justify-start gap-x-2 py-2 pl-1 text-xs text-neutral lg:pl-2 lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:r(o?"predict.event.rules.collapse":"predict.event.moreMarketsLabel")}),jsxRuntime.jsx("svg",{className:ui.cn("h-4 w-4 transition-transform",o&&"rotate-180"),viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M4 6l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})}function Da({market:e,yesPrice:t,noPrice:r,isTopMarket:o,isExpanded:n,onToggleExpand:s,onTradeAction:a}){let{t:i}=i18n.useTranslation(),c=e.volume?`$${Math.round(e.volume).toLocaleString("en-US")} vol`:void 0;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("tr",{className:"cursor-pointer border-b border-border text-xs hover:bg-content2 lg:text-base",onClick:s,role:"button",tabIndex:0,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),s());},children:[jsxRuntime.jsx("td",{className:"py-2 pl-1 lg:pl-2",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-x-1 lg:gap-x-2",children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:en(e)?.[0]||"?",radius:"lg",className:"size-5 shrink-0 lg:size-8",imgProps:{className:"object-cover"}}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"text-foreground truncate max-w-[200px] lg:max-w-[300px]",children:en(e)}),c&&jsxRuntime.jsx("span",{className:"text-[8px] text-neutral lg:text-xxs",children:c})]})]})}),jsxRuntime.jsx("td",{className:"py-2 text-left text-foreground lg:text-center",children:_a(t)}),jsxRuntime.jsx("td",{className:"py-2 pr-1 lg:pr-2",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-x-2",children:[jsxRuntime.jsx("button",{type:"button",className:ui.cn("flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 cursor-pointer hover:opacity-80 transition-opacity",o?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"),onClick:l=>{l.stopPropagation(),a?.(e,"yes","buy");},children:i("predict.market.action.yes",{price:Jr(t)})}),jsxRuntime.jsx("button",{type:"button",className:"flex min-w-16 items-center justify-center whitespace-nowrap rounded-lg p-2 lg:min-w-24 bg-secondary/10 text-secondary cursor-pointer hover:opacity-80 transition-opacity",onClick:l=>{l.stopPropagation(),a?.(e,"no","buy");},children:r!=null?i("predict.market.action.no",{price:Jr(r)}):i("predict.market.no")})]})})]}),n&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:3,className:"px-2 pb-3",children:jsxRuntime.jsx("div",{className:"max-h-100 overflow-y-auto",children:jsxRuntime.jsx(jr,{market:e,onTradeAction:a})})})})]})}function Ha({markets:e,event:t}){let{t:r}=i18n.useTranslation(),[o,n]=react.useState(false),[s,a]=react.useState(false),i=e.filter(u=>u.rules&&u.rules.length>0);if(i.length===0)return null;let c=i[0];if(!c?.rules?.length)return null;let l=c.rules.join(`
|
|
20
20
|
|
|
21
|
-
`),d=l.length>200&&!o?l.slice(0,200)+"...":l;return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:r("predict.event.rules")}),jsxRuntime.jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:d}),l.length>200&&jsxRuntime.jsx("button",{type:"button",onClick:()=>n(u=>!u),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(o?"predict.event.rules.collapse":"predict.event.showMore")}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(u=>!u),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-neutral lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:r("predict.event.timelineAndPayout")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-4 w-4 transition-transform",s&&"rotate-180")})]}),s&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex flex-col",children:[{label:r("predict.event.timeline.open"),value:tn(c.start_at),isActive:true},{label:r("predict.event.timeline.close"),value:tn(c.end_at),isActive:c.status==="closed"||c.status==="voided"}].map((u,p,m)=>jsxRuntime.jsxs("div",{className:"flex items-stretch gap-x-3",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-center w-3",children:[jsxRuntime.jsx("div",{className:`h-3 w-3 shrink-0 rounded-full border-2 mt-0.5 ${u.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),p<m.length-1&&jsxRuntime.jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxRuntime.jsxs("div",{className:`flex flex-col ${p<m.length-1?"pb-4":""}`,children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:u.label}),jsxRuntime.jsx("span",{className:"text-xs text-neutral lg:text-sm",children:u.value})]})]},u.label))}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.event"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:t.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.market"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:c.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:an(c.source)})]})]})]})]})}function Ba({source:e}){return jsxRuntime.jsxs("span",{className:ui.cn("inline-flex items-center gap-x-1 rounded px-1.5 py-0.5","text-[10px] font-medium leading-none",e==="polymarket"?"bg-blue-500/15 text-blue-400":"bg-primary-500/15 text-primary"),children:[jsxRuntime.jsx("span",{className:ui.cn("h-1.5 w-1.5 rounded-sm",e==="polymarket"?"bg-blue-400":"bg-primary")}),an(e)]})}function cn({eventSlug:e,source:t,onTradeAction:r}){let{data:o,isLoading:n,error:s}=reactPredict.useEvent({slug:e,source:t});return n?jsxRuntime.jsx(Oe,{}):s||!o?jsxRuntime.jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:s?.message||"Event not found"}):jsxRuntime.jsx(ln,{event:o,onTradeAction:r})}function dn({eventSlug:e,source:t,limit:r=4,onEventClick:o}){let{t:n}=i18n.useTranslation(),{data:s,isLoading:a}=reactPredict.useSimilarEvents({slug:e,source:t,limit:r});return a||!s||s.length===0?null:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:n("predict.similar.title")}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 gap-3",children:s.map(i=>jsxRuntime.jsx(Ka,{event:i,onClick:o},i.slug))})]})}function Ka({event:e,onClick:t}){let r=e.volume;return jsxRuntime.jsxs("button",{type:"button",onClick:()=>t?.(e),className:"flex items-center gap-x-3 rounded-xl border border-border p-3 hover:bg-content2 transition-colors cursor-pointer text-left w-full",children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"lg",className:"size-8 shrink-0",imgProps:{className:"object-cover"}}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:e.title}),r!=null&&r>0&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral",children:["$",Math.round(r).toLocaleString()," vol"]})]}),jsxRuntime.jsx(ui.ChevronRightIcon,{className:"h-4 w-4 text-neutral shrink-0"})]})}function un(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function Jd({eventSlug:e,source:t,chain:r,walletAddress:o,onSimilarEventClick:n,onBack:s}){let{t:a}=i18n.useTranslation(),{isMobile:i}=ui.useScreen(),{isOpen:c,onOpen:l,onClose:d}=ui.useDisclosure(),{data:u,isLoading:p}=reactPredict.useEvent({slug:e,source:t}),m=react.useMemo(()=>[...u?.markets||[]].sort((R,N)=>un(N)-un(R)),[u?.markets]),[g,f]=react.useState(null),h=react.useCallback((R,N,A)=>{f(q=>({market:R,outcome:N,side:A,version:(q?.version??0)+1})),i&&l();},[i,l]),v=g?.market??m[0];if(p)return i?jsxRuntime.jsx(Oe,{}):jsxRuntime.jsxs("div",{className:"flex w-full max-w-6xl mx-auto gap-x-4 lg:gap-x-6",children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-1 max-w-3xl",children:jsxRuntime.jsx(Oe,{})}),jsxRuntime.jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsxRuntime.jsx("div",{className:"sticky top-4 max-h-[calc(100dvh-2rem)] overflow-y-auto scrollbar-thin",children:jsxRuntime.jsx(Ar,{})})})]});let O=g?`${g.market.slug}-${g.version}`:v?.slug??"default";return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 lg:max-w-7xl lg:gap-y-8 mx-auto",children:[jsxRuntime.jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-y-4 px-4 lg:gap-y-6 lg:px-0",children:[s&&jsxRuntime.jsx("div",{className:"flex items-center justify-between",children:jsxRuntime.jsx(ui.Button,{as:"a",onPress:s,startContent:jsxRuntime.jsx(ui.ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-neutral bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:a("common.back")})}),jsxRuntime.jsx(cn,{eventSlug:e,source:t,onTradeAction:h})]}),jsxRuntime.jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[v&&jsxRuntime.jsx(Or,{event:u,market:v,initialSide:g?.side,initialOutcome:g?.outcome,chain:r},O),u&&jsxRuntime.jsx(dn,{eventSlug:e,source:u.source,onEventClick:n})]})]}),u&&jsxRuntime.jsx("div",{className:"flex w-full flex-col",children:jsxRuntime.jsx(_r,{event:u,walletAddress:o})})]})}function pn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function oi(e){switch(e){case reactPredict.ChartRange.ONE_DAY:return {interval:"15m",limit:96};case reactPredict.ChartRange.ONE_WEEK:return {interval:"1h",limit:168};case reactPredict.ChartRange.ONE_MONTH:return {interval:"4h",limit:180};case reactPredict.ChartRange.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var au=e=>{let{candlestickMarketSlugs:t,chartRange:r=Ve,source:o}=e,n=reactPredict.usePredictClient(),s=react.useMemo(()=>oi(r),[r]),{data:a,isLoading:i,error:c}=reactPredict.useEvent({slug:e.eventSlug,source:o}),l=react.useMemo(()=>a?.markets?(t&&t.length>0?t.slice(0,4).map(f=>a.markets.find(h=>h.slug===f)).filter(f=>f!==void 0):[...a.markets].sort((f,h)=>pn(h)-pn(f)).slice(0,4)).map(f=>f.slug):[],[t,a?.markets]),d=reactQuery.useQueries({queries:l.map(g=>({queryKey:reactPredict.candlesticksQueryKey(g,s),queryFn:()=>n.listCandlesticks(g,s),enabled:l.length>0}))}),u=d.some(g=>g.isLoading),p=react.useMemo(()=>{let g=new Map;return l.forEach((f,h)=>{let v=d[h]?.error;v&&g.set(f,v);}),g},[l,d]),m=react.useMemo(()=>{let g=new Map;return l.forEach((f,h)=>{let v=d[h]?.data;v&&g.set(f,v);}),g},[l,d]);return {event:a,isEventLoading:i,eventError:c,candlestickParams:s,candlesticks:m,isCandlesticksLoading:u,candlestickErrors:p}};var ii=10,li=utils$1.atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function at(){let[e,t]=jotai.useAtom(li),r=react.useCallback(n=>{let s=n.trim();s&&t(a=>{let i=a.filter(c=>c!==s);return [s,...i].slice(0,ii)});},[t]),o=react.useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:o}}function vn({histories:e,onSelect:t,onClear:r,className:o}){let{t:n}=i18n.useTranslation();return e.length===0?null:jsxRuntime.jsxs("div",{className:ui.cn("px-4 pb-4",o),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:n("predict.search.history")}),jsxRuntime.jsx(ui.Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsxRuntime.jsx(ui.TrashIcon,{width:20,height:20})})]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(s=>jsxRuntime.jsx(ui.Chip,{size:"sm",variant:"bordered",className:ui.cn("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(s),children:s},s))})]})}function xn({onSelect:e,className:t}){let{histories:r,clearHistories:o}=at();return jsxRuntime.jsx(vn,{className:ui.cn(t),histories:r,onSelect:e,onClear:o})}function hn({value:e,onValueChange:t,onClear:r,onEscape:o,className:n}){let{t:s}=i18n.useTranslation();return jsxRuntime.jsx("div",{className:n,children:jsxRuntime.jsx(ui.StyledInput,{autoFocus:true,variant:"flat",radius:"full",value:e,onValueChange:t,placeholder:s("predict.search.placeholder"),startContent:jsxRuntime.jsx(ui.SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsxRuntime.jsx(ui.Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsxRuntime.jsx(ui.XCloseIcon,{width:20,height:20})}):jsxRuntime.jsx(ui.Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-border rounded-full cursor-pointer select-none",onMouseDown:a=>{a.preventDefault(),o?.();},children:"Esc"})})})}function Sn({event:e,href:t,LinkComponent:r,onSelect:o,onHover:n,className:s}){let a=e.tags?.[0];return jsxRuntime.jsxs(ui.Linkable,{href:t,LinkComponent:r,className:ui.cn("w-full h-full px-3 flex items-center gap-3","hover:cursor-pointer hover:bg-content2 rounded-lg","transition-colors duration-150",s),onClick:i=>{t&&o&&i.preventDefault(),o?.(e);},onMouseEnter:()=>n?.(e),children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2.5",children:[jsxRuntime.jsx("span",{className:"min-w-0 text-sm font-medium truncate",children:e.title}),a&&jsxRuntime.jsx("span",{className:ui.cn("flex-shrink-0 inline-flex items-center","rounded-full px-2.5 py-1.5","text-[11px] font-semibold leading-none uppercase","bg-primary/15 text-primary"),children:a.label})]})]})}function kn({keyword:e="",limit:t,source:r}){let{data:o,isLoading:n,isFetchingNextPage:s,hasNextPage:a,fetchNextPage:i}=reactPredict.useSearchEvents({keyword:e,limit:t,source:r},{enabled:true});return {events:react.useMemo(()=>o?.pages.flatMap(l=>l.items).filter(l=>l!=null)??[],[o]),isLoading:n,isFetchingNextPage:s,hasNextPage:a??false,fetchNextPage:i}}var Ri=56;function wn({onSelect:e,getEventHref:t,LinkComponent:r,onHover:o,className:n,...s}){let{events:a,isLoading:i,isFetchingNextPage:c,hasNextPage:l,fetchNextPage:d}=kn(s),u=react.useRef(null),{height:p}=hooks.useResizeObserver({ref:u}),m=react.useCallback(v=>v<a.length,[a]),g=react.useCallback(async()=>{l&&!c&&await d();},[l,c,d]),f=react.useMemo(()=>l?a.length+1:a.length,[a,l]),h=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:m,loadMoreRows:g,rowCount:f,threshold:5});return i?jsxRuntime.jsx(Ii,{className:n}):a.length===0?jsxRuntime.jsx(_i,{className:n}):jsxRuntime.jsx("div",{className:ui.cn("w-full h-full flex flex-col",n),children:jsxRuntime.jsx("div",{className:"flex-auto min-h-0",ref:u,children:jsxRuntime.jsx(reactWindow.List,{style:{height:p},onRowsRendered:h,rowComponent:Oi,rowCount:f,rowHeight:Ri,rowProps:{events:a,onSelect:e,getEventHref:t,LinkComponent:r,onHover:o},overscanCount:5})})})}function Oi({index:e,style:t,events:r,onSelect:o,getEventHref:n,LinkComponent:s,onHover:a}){let i=r[e];return i?jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(Sn,{event:i,href:n?.(i),LinkComponent:s,onSelect:o,onHover:a})}):jsxRuntime.jsx("div",{style:t,className:"flex items-center justify-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})})}function Ii({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui.cn("flex items-center justify-center gap-2 py-16",e),children:[jsxRuntime.jsx(ui.Spinner,{size:"sm"}),jsxRuntime.jsx("span",{className:"text-sm text-neutral",children:t("predict.search.loading")})]})}function _i({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui.cn("flex flex-col items-center justify-center py-16",e),children:[jsxRuntime.jsx(ui.EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsxRuntime.jsx("p",{className:"mt-2 text-sm text-neutral",children:t("predict.search.noResults")})]})}function Ln({onKeywordChange:e}){let[t,r]=react.useState(""),[o,n]=react.useState(""),{addHistory:s}=at(),a=hooks.useCallbackRef(e),i=hooks.useCallbackRef(s),c=react.useMemo(()=>utils.debounce(p=>{n(p),a(p),p&&i(p);},500),[a,i]),l=react.useCallback(p=>{r(p),c(p);},[c]),d=react.useCallback(p=>{c.cancel(),r(p),n(p),a(p),p&&i(p);},[c,a,i]),u=react.useCallback(()=>d(""),[d]);return {text:t,keyword:o,setText:l,setKeyword:d,clearKeyword:u}}function Rn({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:o,onHover:n,onEscape:s,source:a}){let{text:i,keyword:c,setText:l,setKeyword:d,clearKeyword:u}=Ln({onKeywordChange:e});return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsxRuntime.jsx(hn,{value:i,onValueChange:l,onClear:u,onEscape:s}),!c&&jsxRuntime.jsx(xn,{onSelect:d}),jsxRuntime.jsx(wn,{className:"flex-auto min-h-0",keyword:c,onSelect:t,getEventHref:r,LinkComponent:o,onHover:n,source:a})]})}var Ht="predict-search";function Pp({id:e=Ht}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(qi,{...t})})}function qi({params:e,isOpen:t,onOpenChange:r,onResult:o}){let{t:n}=i18n.useTranslation(),{isMobile:s}=ui.useScreen(),a=react.useCallback(c=>{o(c);},[o]),i=react.useCallback(()=>{r(false);},[r]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:t,onOpenChange:r,size:s?"full":"lg",hideCloseButton:true,backdrop:"blur",radius:"lg",children:jsxRuntime.jsxs(ui.ModalContent,{className:"w-full h-full",children:[jsxRuntime.jsxs(ui.ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsxRuntime.jsx("span",{className:"text-base font-semibold",children:n("predict.search.title")}),jsxRuntime.jsx(ui.Button,{isIconOnly:true,onPress:()=>r(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsxRuntime.jsx(ui.XCloseIcon,{width:20,height:20})})]}),jsxRuntime.jsx(ui.ModalBody,{className:"p-4",children:jsxRuntime.jsx(Rn,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:a,onEscape:i})})]})})}function Op({onSelectEvent:e,modalParams:t,className:r}){let{t:o}=i18n.useTranslation(),{isDesktop:n,isMobile:s}=ui.useScreen(),{onOpen:a,onClose:i}=uiScaffold.useAsyncModal(Ht),c=hooks.useCallbackRef(e),l=hooks.useCallbackRef(async()=>{let u=await a({params:t});u&&c(u);}),d=hooks.useCallbackRef(()=>{i();});return react.useEffect(()=>{let u=p=>{let m=document.activeElement,g=!!m&&(m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.getAttribute("contenteditable")==="true");p.key==="/"&&!g&&(p.preventDefault(),l()),p.key==="Escape"&&(p.preventDefault(),d());};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u);}},[l,d]),jsxRuntime.jsx(ui.Button,{size:"sm",radius:"full",isIconOnly:!n,onPress:l,variant:s?"flat":"bordered",startContent:n?jsxRuntime.jsx(ui.SearchIcon,{className:"text-neutral"}):void 0,endContent:n?jsxRuntime.jsx(ui.Kbd,{className:"ml-auto min-w-6 justify-center text-xs bg-transparent border border-border rounded-full",children:"/"}):void 0,className:ui.cn(n&&"min-w-56 justify-start pl-3 pr-1.5 text-neutral",r),children:n?o("predict.search.placeholder"):jsxRuntime.jsx(ui.SearchIcon,{className:"text-neutral"})})}var sl=react.createContext(null);var al=3e4;function il({walletAddress:e,source:t,pollingInterval:r=al,enabled:o=true,children:n}){let s=o&&!!e,{data:a,isLoading:i,error:c,refetch:l}=reactPredict.usePositions({user:e,source:t},{enabled:s,refetchInterval:r}),{data:d,isLoading:u,error:p}=reactPredict.useBalance({user:e,source:t??"dflow"},{enabled:s,refetchInterval:r}),m=react.useMemo(()=>({positions:a?.positions??[],usdcBalance:d?Number(d.balance):0,isLoading:i||u,error:c??p??null,refetch:l}),[a?.positions,d,i,u,c,p,l]);return jsxRuntime.jsx(sl.Provider,{value:m,children:n})}Object.defineProperty(exports,"PredictClient",{enumerable:true,get:function(){return reactPredict.PredictClient}});Object.defineProperty(exports,"PredictContext",{enumerable:true,get:function(){return reactPredict.PredictContext}});Object.defineProperty(exports,"PredictProvider",{enumerable:true,get:function(){return reactPredict.PredictProvider}});Object.defineProperty(exports,"PredictWsClient",{enumerable:true,get:function(){return reactPredict.PredictWsClient}});Object.defineProperty(exports,"createPredictClient",{enumerable:true,get:function(){return reactPredict.createPredictClient}});Object.defineProperty(exports,"createPredictWsClient",{enumerable:true,get:function(){return reactPredict.createPredictWsClient}});Object.defineProperty(exports,"useBalance",{enumerable:true,get:function(){return reactPredict.useBalance}});Object.defineProperty(exports,"useCancelOrder",{enumerable:true,get:function(){return reactPredict.useCancelOrder}});Object.defineProperty(exports,"useCandlesticks",{enumerable:true,get:function(){return reactPredict.useCandlesticks}});Object.defineProperty(exports,"useDFlowQuote",{enumerable:true,get:function(){return reactPredict.useDFlowQuote}});Object.defineProperty(exports,"useDFlowSubmit",{enumerable:true,get:function(){return reactPredict.useDFlowSubmit}});Object.defineProperty(exports,"useEvent",{enumerable:true,get:function(){return reactPredict.useEvent}});Object.defineProperty(exports,"useEvents",{enumerable:true,get:function(){return reactPredict.useEvents}});Object.defineProperty(exports,"useInfiniteEvents",{enumerable:true,get:function(){return reactPredict.useInfiniteEvents}});Object.defineProperty(exports,"useMarket",{enumerable:true,get:function(){return reactPredict.useMarket}});Object.defineProperty(exports,"useMarketHistory",{enumerable:true,get:function(){return reactPredict.useMarketHistory}});Object.defineProperty(exports,"useMarketTrades",{enumerable:true,get:function(){return reactPredict.useMarketTrades}});Object.defineProperty(exports,"useOrder",{enumerable:true,get:function(){return reactPredict.useOrder}});Object.defineProperty(exports,"useOrderbook",{enumerable:true,get:function(){return reactPredict.useOrderbook}});Object.defineProperty(exports,"useOrders",{enumerable:true,get:function(){return reactPredict.useOrders}});Object.defineProperty(exports,"usePositions",{enumerable:true,get:function(){return reactPredict.usePositions}});Object.defineProperty(exports,"usePredictClient",{enumerable:true,get:function(){return reactPredict.usePredictClient}});Object.defineProperty(exports,"usePriceHistory",{enumerable:true,get:function(){return reactPredict.usePriceHistory}});Object.defineProperty(exports,"useSearchEvents",{enumerable:true,get:function(){return reactPredict.useSearchEvents}});Object.defineProperty(exports,"useSimilarEvents",{enumerable:true,get:function(){return reactPredict.useSimilarEvents}});Object.defineProperty(exports,"useTrades",{enumerable:true,get:function(){return reactPredict.useTrades}});exports.CHART_RANGE_DURATION=_l;exports.CHART_RANGE_PERIOD=Ol;exports.CHART_RANGE_SAMPLE_INTERVAL=Il;exports.CandlestickPeriod=Ke;exports.CategoriesSkeleton=fl;exports.CategoriesUI=Kt;exports.CategoriesWidget=qt;exports.ChartRange=j;exports.DEFAULT_CHART_RANGE=Ve;exports.DEFAULT_FILTER_STATE=ut;exports.DEFAULT_PAGE_SIZE=mt;exports.DEFAULT_PRICE_HISTORY_INTERVAL=Bl;exports.EventDetailPage=Jd;exports.EventDetailSkeleton=Oe;exports.EventDetailUI=ln;exports.EventDetailWidget=cn;exports.EventItem=fr;exports.EventMarketDepthChartUI=Ur;exports.EventMarketDetailWidget=jr;exports.EventPriceChart=Zr;exports.EventsFilterUI=Gt;exports.EventsPage=bc;exports.EventsSkeleton=or;exports.EventsToolbarUI=er;exports.EventsUI=yr;exports.EventsWidget=kr;exports.MAX_PRICE_HISTORY_MARKETS=ft;exports.ORDER_MAX_PRICE=Hl;exports.ORDER_MIN_PRICE=Dl;exports.ORDER_MIN_QUANTITY=gt;exports.ORDER_PRICE_STEP=Al;exports.PREDICT_SEARCH_MODAL_ID=Ht;exports.PRICE_HISTORY_SAMPLE_INTERVAL=Fl;exports.PredictSearchModal=Pp;exports.PriceHistoryInterval=ge;exports.SORT_PRESETS=Jt;exports.STATIC_CATEGORIES=dt;exports.SearchEventsButton=Op;exports.SearchHistoryUI=vn;exports.SearchHistoryWidget=xn;exports.SearchInputUI=hn;exports.SearchResultItemUI=Sn;exports.SearchResultListWidget=wn;exports.SearchWidget=Rn;exports.SimilarEventCard=Ka;exports.SimilarEventsSection=dn;exports.TradeFormSkeleton=Ar;exports.TradeFormUI=Lr;exports.TradeFormWidget=Or;exports.UserActivitySection=_r;exports.UserPredictProvider=il;exports.countActiveFilters=pt;exports.formatWan=Ie;exports.useEventDetail=au;exports.useEventsInfinite=nr;exports.usePredictSearchHistory=at;exports.useSearchResultListScript=kn;exports.useSearchScript=Ln;exports.useTradeForm=Cr;exports.version=Wn;//# sourceMappingURL=index.js.map
|
|
21
|
+
`),d=l.length>200&&!o?l.slice(0,200)+"...":l;return jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:r("predict.event.rules")}),jsxRuntime.jsx("div",{className:"text-xs text-foreground/80 lg:text-sm whitespace-pre-wrap",children:d}),l.length>200&&jsxRuntime.jsx("button",{type:"button",onClick:()=>n(u=>!u),className:"text-xs text-neutral hover:text-foreground cursor-pointer transition-colors self-start",children:r(o?"predict.event.rules.collapse":"predict.event.showMore")}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>a(u=>!u),className:"flex items-center justify-between w-full mt-2 text-xs font-medium text-neutral lg:text-sm cursor-pointer hover:text-foreground transition-colors",children:[jsxRuntime.jsx("span",{children:r("predict.event.timelineAndPayout")}),jsxRuntime.jsx(ui.ChevronDownIcon,{className:ui.cn("h-4 w-4 transition-transform",s&&"rotate-180")})]}),s&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"flex flex-col",children:[{label:r("predict.event.timeline.open"),value:tn(c.start_at),isActive:true},{label:r("predict.event.timeline.close"),value:tn(c.end_at),isActive:c.status==="closed"||c.status==="voided"}].map((u,p,m)=>jsxRuntime.jsxs("div",{className:"flex items-stretch gap-x-3",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-center w-3",children:[jsxRuntime.jsx("div",{className:`h-3 w-3 shrink-0 rounded-full border-2 mt-0.5 ${u.isActive?"border-primary bg-primary":"border-border bg-transparent"}`}),p<m.length-1&&jsxRuntime.jsx("div",{className:"w-px flex-1 bg-border"})]}),jsxRuntime.jsxs("div",{className:`flex flex-col ${p<m.length-1?"pb-4":""}`,children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-foreground lg:text-sm",children:u.label}),jsxRuntime.jsx("span",{className:"text-xs text-neutral lg:text-sm",children:u.value})]})]},u.label))}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 text-xxs text-neutral mt-2 lg:text-xs",children:[jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.event"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:t.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.market"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:c.slug})]}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsxs("span",{className:"text-neutral",children:[r("predict.event.id.source"),":"]})," ",jsxRuntime.jsx("span",{className:"text-foreground",children:an(c.source)})]})]})]})]})}function Ba({source:e}){return jsxRuntime.jsxs("span",{className:ui.cn("inline-flex items-center gap-x-1 rounded px-1.5 py-0.5","text-[10px] font-medium leading-none",e==="polymarket"?"bg-blue-500/15 text-blue-400":"bg-primary-500/15 text-primary"),children:[jsxRuntime.jsx("span",{className:ui.cn("h-1.5 w-1.5 rounded-sm",e==="polymarket"?"bg-blue-400":"bg-primary")}),an(e)]})}function cn({eventSlug:e,source:t,onTradeAction:r}){let{data:o,isLoading:n,error:s}=reactPredict.useEvent({slug:e,source:t});return n?jsxRuntime.jsx(Ie,{}):s||!o?jsxRuntime.jsx("div",{className:"flex w-full items-center justify-center py-20 text-danger",children:s?.message||"Event not found"}):jsxRuntime.jsx(ln,{event:o,onTradeAction:r})}function dn({eventSlug:e,source:t,limit:r=4,onEventClick:o}){let{t:n}=i18n.useTranslation(),{data:s,isLoading:a}=reactPredict.useSimilarEvents({slug:e,source:t,limit:r});return a||!s||s.length===0?null:jsxRuntime.jsxs("div",{className:"flex flex-col gap-y-3 mt-6 px-1 lg:px-0",children:[jsxRuntime.jsx("span",{className:"text-sm font-semibold text-foreground lg:text-base",children:n("predict.similar.title")}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 gap-3",children:s.map(i=>jsxRuntime.jsx(Ka,{event:i,onClick:o},i.slug))})]})}function Ka({event:e,onClick:t}){let r=e.volume;return jsxRuntime.jsxs("button",{type:"button",onClick:()=>t?.(e),className:"flex items-center gap-x-3 rounded-xl border border-border p-3 hover:bg-content2 transition-colors cursor-pointer text-left w-full",children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title?.[0]||"?",radius:"lg",className:"size-8 shrink-0",imgProps:{className:"object-cover"}}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:e.title}),r!=null&&r>0&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral",children:["$",Math.round(r).toLocaleString()," vol"]})]}),jsxRuntime.jsx(ui.ChevronRightIcon,{className:"h-4 w-4 text-neutral shrink-0"})]})}function un(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function eu({eventSlug:e,source:t,chain:r,walletAddress:o,onSimilarEventClick:n,onBack:s}){let{t:a}=i18n.useTranslation(),{isMobile:i}=ui.useScreen(),{isOpen:c,onOpen:l,onClose:d}=ui.useDisclosure(),{data:u,isLoading:p}=reactPredict.useEvent({slug:e,source:t}),m=react.useMemo(()=>[...u?.markets||[]].sort((R,N)=>un(N)-un(R)),[u?.markets]),[g,f]=react.useState(null),h=react.useCallback((R,N,A)=>{f(j=>({market:R,outcome:N,side:A,version:(j?.version??0)+1})),i&&l();},[i,l]),v=g?.market??m[0];if(p)return i?jsxRuntime.jsx(Ie,{}):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(Ie,{})}),jsxRuntime.jsx("aside",{className:"hidden lg:block w-[340px] xl:w-[380px] shrink-0",children:jsxRuntime.jsx("div",{className:"sticky top-4 max-h-[calc(100dvh-2rem)] overflow-y-auto scrollbar-thin",children:jsxRuntime.jsx(Ar,{})})})]});let O=g?`${g.market.slug}-${g.version}`:v?.slug??"default";return jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-y-4 lg:max-w-7xl lg:gap-y-8 mx-auto",children:[jsxRuntime.jsxs("div",{className:"flex w-full justify-center gap-4 pt-4 lg:gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-y-4 px-4 lg:gap-y-6 lg:px-0",children:[s&&jsxRuntime.jsx("div",{className:"flex items-center justify-between",children:jsxRuntime.jsx(ui.Button,{as:"a",onPress:s,startContent:jsxRuntime.jsx(ui.ChevronLeftIcon,{className:"h-4 w-4"}),className:"text-neutral bg-transparent h-5 min-h-5 gap-x-2 p-0 text-base w-auto min-w-auto",children:a("common.back")})}),jsxRuntime.jsx(cn,{eventSlug:e,source:t,onTradeAction:h})]}),jsxRuntime.jsxs("div",{className:"hidden flex-none w-md flex-col gap-y-4 lg:sticky lg:top-4 lg:flex lg:self-start",children:[v&&jsxRuntime.jsx(Or,{event:u,market:v,initialSide:g?.side,initialOutcome:g?.outcome,chain:r},O),u&&jsxRuntime.jsx(dn,{eventSlug:e,source:u.source,onEventClick:n})]})]}),u&&jsxRuntime.jsx("div",{className:"flex w-full flex-col",children:jsxRuntime.jsx(_r,{event:u,walletAddress:o})})]})}function pn(e){return e.outcomes[0]?.best_ask??e.outcomes[0]?.price??0}function oi(e){switch(e){case reactPredict.ChartRange.ONE_DAY:return {interval:"15m",limit:96};case reactPredict.ChartRange.ONE_WEEK:return {interval:"1h",limit:168};case reactPredict.ChartRange.ONE_MONTH:return {interval:"4h",limit:180};case reactPredict.ChartRange.ALL:return {interval:"1d",limit:300};default:return {interval:"1h",limit:100}}}var iu=e=>{let{candlestickMarketSlugs:t,chartRange:r=Ye,source:o}=e,n=reactPredict.usePredictClient(),s=react.useMemo(()=>oi(r),[r]),{data:a,isLoading:i,error:c}=reactPredict.useEvent({slug:e.eventSlug,source:o}),l=react.useMemo(()=>a?.markets?(t&&t.length>0?t.slice(0,4).map(f=>a.markets.find(h=>h.slug===f)).filter(f=>f!==void 0):[...a.markets].sort((f,h)=>pn(h)-pn(f)).slice(0,4)).map(f=>f.slug):[],[t,a?.markets]),d=reactQuery.useQueries({queries:l.map(g=>({queryKey:reactPredict.candlesticksQueryKey(g,s),queryFn:()=>n.listCandlesticks(g,s),enabled:l.length>0}))}),u=d.some(g=>g.isLoading),p=react.useMemo(()=>{let g=new Map;return l.forEach((f,h)=>{let v=d[h]?.error;v&&g.set(f,v);}),g},[l,d]),m=react.useMemo(()=>{let g=new Map;return l.forEach((f,h)=>{let v=d[h]?.data;v&&g.set(f,v);}),g},[l,d]);return {event:a,isEventLoading:i,eventError:c,candlestickParams:s,candlesticks:m,isCandlesticksLoading:u,candlestickErrors:p}};var ii=10,li=utils$1.atomWithStorage("liberfi:predict_search_histories",[],void 0,{getOnInit:true});function it(){let[e,t]=jotai.useAtom(li),r=react.useCallback(n=>{let s=n.trim();s&&t(a=>{let i=a.filter(c=>c!==s);return [s,...i].slice(0,ii)});},[t]),o=react.useCallback(()=>{t([]);},[t]);return {histories:e,addHistory:r,clearHistories:o}}function vn({histories:e,onSelect:t,onClear:r,className:o}){let{t:n}=i18n.useTranslation();return e.length===0?null:jsxRuntime.jsxs("div",{className:ui.cn("px-4 pb-4",o),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:n("predict.search.history")}),jsxRuntime.jsx(ui.Button,{isIconOnly:true,size:"sm",className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsxRuntime.jsx(ui.TrashIcon,{width:20,height:20})})]}),jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(s=>jsxRuntime.jsx(ui.Chip,{size:"sm",variant:"bordered",className:ui.cn("text-neutral","border-border border-1","cursor-pointer","hover:opacity-hover"),onClick:()=>t?.(s),children:s},s))})]})}function xn({onSelect:e,className:t}){let{histories:r,clearHistories:o}=it();return jsxRuntime.jsx(vn,{className:ui.cn(t),histories:r,onSelect:e,onClear:o})}function hn({value:e,onValueChange:t,onClear:r,onEscape:o,className:n}){let{t:s}=i18n.useTranslation();return jsxRuntime.jsx("div",{className:n,children:jsxRuntime.jsx(ui.StyledInput,{autoFocus:true,variant:"flat",radius:"full",value:e,onValueChange:t,placeholder:s("predict.search.placeholder"),startContent:jsxRuntime.jsx(ui.SearchIcon,{width:20,height:20,className:"text-neutral"}),endContent:e?jsxRuntime.jsx(ui.Button,{isIconOnly:true,className:"bg-transparent min-w-6 w-6 h-6 text-neutral",onPress:r,children:jsxRuntime.jsx(ui.XCloseIcon,{width:20,height:20})}):jsxRuntime.jsx(ui.Kbd,{className:"min-w-8 justify-center text-xs text-neutral bg-transparent border border-border rounded-full cursor-pointer select-none",onMouseDown:a=>{a.preventDefault(),o?.();},children:"Esc"})})})}function Sn({event:e,href:t,LinkComponent:r,onSelect:o,onHover:n,className:s}){let a=e.tags?.[0];return jsxRuntime.jsxs(ui.Linkable,{href:t,LinkComponent:r,className:ui.cn("w-full h-full px-3 flex items-center gap-3","hover:cursor-pointer hover:bg-content2 rounded-lg","transition-colors duration-150",s),onClick:i=>{t&&o&&i.preventDefault(),o?.(e);},onMouseEnter:()=>n?.(e),children:[jsxRuntime.jsx(ui.Avatar,{src:e.image_url||void 0,name:e.title||"Event",radius:"full",className:"h-10 w-10 flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2.5",children:[jsxRuntime.jsx("span",{className:"min-w-0 text-sm font-medium truncate",children:e.title}),a&&jsxRuntime.jsx("span",{className:ui.cn("flex-shrink-0 inline-flex items-center","rounded-full px-2.5 py-1.5","text-[11px] font-semibold leading-none uppercase","bg-primary/15 text-primary"),children:a.label})]})]})}function kn({keyword:e="",limit:t,source:r}){let{data:o,isLoading:n,isFetchingNextPage:s,hasNextPage:a,fetchNextPage:i}=reactPredict.useSearchEvents({keyword:e,limit:t,source:r},{enabled:true});return {events:react.useMemo(()=>o?.pages.flatMap(l=>l.items).filter(l=>l!=null)??[],[o]),isLoading:n,isFetchingNextPage:s,hasNextPage:a??false,fetchNextPage:i}}var Ri=56;function wn({onSelect:e,getEventHref:t,LinkComponent:r,onHover:o,className:n,...s}){let{events:a,isLoading:i,isFetchingNextPage:c,hasNextPage:l,fetchNextPage:d}=kn(s),u=react.useRef(null),{height:p}=hooks.useResizeObserver({ref:u}),m=react.useCallback(v=>v<a.length,[a]),g=react.useCallback(async()=>{l&&!c&&await d();},[l,c,d]),f=react.useMemo(()=>l?a.length+1:a.length,[a,l]),h=reactWindowInfiniteLoader.useInfiniteLoader({isRowLoaded:m,loadMoreRows:g,rowCount:f,threshold:5});return i?jsxRuntime.jsx(Ii,{className:n}):a.length===0?jsxRuntime.jsx(_i,{className:n}):jsxRuntime.jsx("div",{className:ui.cn("w-full h-full flex flex-col",n),children:jsxRuntime.jsx("div",{className:"flex-auto min-h-0",ref:u,children:jsxRuntime.jsx(reactWindow.List,{style:{height:p},onRowsRendered:h,rowComponent:Oi,rowCount:f,rowHeight:Ri,rowProps:{events:a,onSelect:e,getEventHref:t,LinkComponent:r,onHover:o},overscanCount:5})})})}function Oi({index:e,style:t,events:r,onSelect:o,getEventHref:n,LinkComponent:s,onHover:a}){let i=r[e];return i?jsxRuntime.jsx("div",{style:t,children:jsxRuntime.jsx(Sn,{event:i,href:n?.(i),LinkComponent:s,onSelect:o,onHover:a})}):jsxRuntime.jsx("div",{style:t,className:"flex items-center justify-center",children:jsxRuntime.jsx(ui.Spinner,{size:"sm"})})}function Ii({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui.cn("flex items-center justify-center gap-2 py-16",e),children:[jsxRuntime.jsx(ui.Spinner,{size:"sm"}),jsxRuntime.jsx("span",{className:"text-sm text-neutral",children:t("predict.search.loading")})]})}function _i({className:e}){let{t}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:ui.cn("flex flex-col items-center justify-center py-16",e),children:[jsxRuntime.jsx(ui.EmptyIcon,{width:28,height:28,className:"text-neutral"}),jsxRuntime.jsx("p",{className:"mt-2 text-sm text-neutral",children:t("predict.search.noResults")})]})}function Ln({onKeywordChange:e}){let[t,r]=react.useState(""),[o,n]=react.useState(""),{addHistory:s}=it(),a=hooks.useCallbackRef(e),i=hooks.useCallbackRef(s),c=react.useMemo(()=>utils.debounce(p=>{n(p),a(p),p&&i(p);},500),[a,i]),l=react.useCallback(p=>{r(p),c(p);},[c]),d=react.useCallback(p=>{c.cancel(),r(p),n(p),a(p),p&&i(p);},[c,a,i]),u=react.useCallback(()=>d(""),[d]);return {text:t,keyword:o,setText:l,setKeyword:d,clearKeyword:u}}function Rn({onKeywordChange:e,onSelectEvent:t,getEventHref:r,LinkComponent:o,onHover:n,onEscape:s,source:a}){let{text:i,keyword:c,setText:l,setKeyword:d,clearKeyword:u}=Ln({onKeywordChange:e});return jsxRuntime.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[jsxRuntime.jsx(hn,{value:i,onValueChange:l,onClear:u,onEscape:s}),!c&&jsxRuntime.jsx(xn,{onSelect:d}),jsxRuntime.jsx(wn,{className:"flex-auto min-h-0",keyword:c,onSelect:t,getEventHref:r,LinkComponent:o,onHover:n,source:a})]})}var Bt="predict-search";function Ep({id:e=Bt}){return jsxRuntime.jsx(uiScaffold.AsyncModal,{id:e,children:t=>jsxRuntime.jsx(qi,{...t})})}function qi({params:e,isOpen:t,onOpenChange:r,onResult:o}){let{t:n}=i18n.useTranslation(),{isMobile:s}=ui.useScreen(),a=react.useCallback(c=>{o(c);},[o]),i=react.useCallback(()=>{r(false);},[r]);return jsxRuntime.jsx(ui.StyledModal,{isOpen:t,onOpenChange:r,size:s?"full":"lg",hideCloseButton:true,backdrop:"blur",radius:"lg",children:jsxRuntime.jsxs(ui.ModalContent,{className:"w-full h-full",children:[jsxRuntime.jsxs(ui.ModalHeader,{className:"sm:hidden flex items-center justify-between pt-4 pb-2",children:[jsxRuntime.jsx("span",{className:"text-base font-semibold",children:n("predict.search.title")}),jsxRuntime.jsx(ui.Button,{isIconOnly:true,onPress:()=>r(false),size:"sm",className:"bg-transparent min-w-6 w-6 h-6",children:jsxRuntime.jsx(ui.XCloseIcon,{width:20,height:20})})]}),jsxRuntime.jsx(ui.ModalBody,{className:"p-4",children:jsxRuntime.jsx(Rn,{getEventHref:e?.getEventHref,LinkComponent:e?.LinkComponent,onHover:e?.onHover,source:e?.source,onSelectEvent:a,onEscape:i})})]})})}function Ip({onSelectEvent:e,modalParams:t,className:r}){let{t:o}=i18n.useTranslation(),{isDesktop:n,isMobile:s}=ui.useScreen(),{onOpen:a,onClose:i}=uiScaffold.useAsyncModal(Bt),c=hooks.useCallbackRef(e),l=hooks.useCallbackRef(async()=>{let u=await a({params:t});u&&c(u);}),d=hooks.useCallbackRef(()=>{i();});return react.useEffect(()=>{let u=p=>{let m=document.activeElement,g=!!m&&(m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.getAttribute("contenteditable")==="true");p.key==="/"&&!g&&(p.preventDefault(),l()),p.key==="Escape"&&(p.preventDefault(),d());};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u);}},[l,d]),jsxRuntime.jsx(ui.Button,{size:"sm",radius:"full",isIconOnly:!n,onPress:l,variant:s?"flat":"bordered",startContent:n?jsxRuntime.jsx(ui.SearchIcon,{className:"text-neutral"}):void 0,endContent:n?jsxRuntime.jsx(ui.Kbd,{className:"ml-auto min-w-6 justify-center text-xs bg-transparent border border-border rounded-full",children:"/"}):void 0,className:ui.cn(n&&"min-w-56 justify-start pl-3 pr-1.5 text-neutral",r),children:n?o("predict.search.placeholder"):jsxRuntime.jsx(ui.SearchIcon,{className:"text-neutral"})})}var sl=react.createContext(null);var al=3e4;function il({walletAddress:e,source:t,pollingInterval:r=al,enabled:o=true,children:n}){let s=o&&!!e,{data:a,isLoading:i,error:c,refetch:l}=reactPredict.usePositions({user:e,source:t},{enabled:s,refetchInterval:r}),{data:d,isLoading:u,error:p}=reactPredict.useBalance({user:e,source:t??"dflow"},{enabled:s,refetchInterval:r}),m=react.useMemo(()=>({positions:a?.positions??[],usdcBalance:d?Number(d.balance):0,isLoading:i||u,error:c??p??null,refetch:l}),[a?.positions,d,i,u,c,p,l]);return jsxRuntime.jsx(sl.Provider,{value:m,children:n})}Object.defineProperty(exports,"PredictClient",{enumerable:true,get:function(){return reactPredict.PredictClient}});Object.defineProperty(exports,"PredictContext",{enumerable:true,get:function(){return reactPredict.PredictContext}});Object.defineProperty(exports,"PredictProvider",{enumerable:true,get:function(){return reactPredict.PredictProvider}});Object.defineProperty(exports,"PredictWsClient",{enumerable:true,get:function(){return reactPredict.PredictWsClient}});Object.defineProperty(exports,"createPredictClient",{enumerable:true,get:function(){return reactPredict.createPredictClient}});Object.defineProperty(exports,"createPredictWsClient",{enumerable:true,get:function(){return reactPredict.createPredictWsClient}});Object.defineProperty(exports,"useBalance",{enumerable:true,get:function(){return reactPredict.useBalance}});Object.defineProperty(exports,"useCancelOrder",{enumerable:true,get:function(){return reactPredict.useCancelOrder}});Object.defineProperty(exports,"useCandlesticks",{enumerable:true,get:function(){return reactPredict.useCandlesticks}});Object.defineProperty(exports,"useDFlowQuote",{enumerable:true,get:function(){return reactPredict.useDFlowQuote}});Object.defineProperty(exports,"useDFlowSubmit",{enumerable:true,get:function(){return reactPredict.useDFlowSubmit}});Object.defineProperty(exports,"useEvent",{enumerable:true,get:function(){return reactPredict.useEvent}});Object.defineProperty(exports,"useEvents",{enumerable:true,get:function(){return reactPredict.useEvents}});Object.defineProperty(exports,"useInfiniteEvents",{enumerable:true,get:function(){return reactPredict.useInfiniteEvents}});Object.defineProperty(exports,"useMarket",{enumerable:true,get:function(){return reactPredict.useMarket}});Object.defineProperty(exports,"useMarketHistory",{enumerable:true,get:function(){return reactPredict.useMarketHistory}});Object.defineProperty(exports,"useMarketTrades",{enumerable:true,get:function(){return reactPredict.useMarketTrades}});Object.defineProperty(exports,"useOrder",{enumerable:true,get:function(){return reactPredict.useOrder}});Object.defineProperty(exports,"useOrderbook",{enumerable:true,get:function(){return reactPredict.useOrderbook}});Object.defineProperty(exports,"useOrders",{enumerable:true,get:function(){return reactPredict.useOrders}});Object.defineProperty(exports,"usePositions",{enumerable:true,get:function(){return reactPredict.usePositions}});Object.defineProperty(exports,"usePredictClient",{enumerable:true,get:function(){return reactPredict.usePredictClient}});Object.defineProperty(exports,"usePriceHistory",{enumerable:true,get:function(){return reactPredict.usePriceHistory}});Object.defineProperty(exports,"useSearchEvents",{enumerable:true,get:function(){return reactPredict.useSearchEvents}});Object.defineProperty(exports,"useSimilarEvents",{enumerable:true,get:function(){return reactPredict.useSimilarEvents}});Object.defineProperty(exports,"useTrades",{enumerable:true,get:function(){return reactPredict.useTrades}});exports.CHART_RANGE_DURATION=_l;exports.CHART_RANGE_PERIOD=Ol;exports.CHART_RANGE_SAMPLE_INTERVAL=Il;exports.CandlestickPeriod=Ve;exports.CategoriesSkeleton=fl;exports.CategoriesUI=Vt;exports.CategoriesWidget=jt;exports.ChartRange=G;exports.DEFAULT_CHART_RANGE=Ye;exports.DEFAULT_FILTER_STATE=pt;exports.DEFAULT_PAGE_SIZE=ft;exports.DEFAULT_PRICE_HISTORY_INTERVAL=Bl;exports.EventDetailPage=eu;exports.EventDetailSkeleton=Ie;exports.EventDetailUI=ln;exports.EventDetailWidget=cn;exports.EventItem=fr;exports.EventMarketDepthChartUI=Ur;exports.EventMarketDetailWidget=jr;exports.EventPriceChart=Zr;exports.EventsFilterUI=Xt;exports.EventsPage=yc;exports.EventsPageSkeleton=Vl;exports.EventsSkeleton=xt;exports.EventsToolbarUI=tr;exports.EventsUI=yr;exports.EventsWidget=kr;exports.MAX_PRICE_HISTORY_MARKETS=gt;exports.ORDER_MAX_PRICE=Hl;exports.ORDER_MIN_PRICE=Dl;exports.ORDER_MIN_QUANTITY=vt;exports.ORDER_PRICE_STEP=Al;exports.PREDICT_SEARCH_MODAL_ID=Bt;exports.PRICE_HISTORY_SAMPLE_INTERVAL=Fl;exports.PredictSearchModal=Ep;exports.PriceHistoryInterval=he;exports.SORT_PRESETS=er;exports.STATIC_CATEGORIES=ut;exports.SearchEventsButton=Ip;exports.SearchHistoryUI=vn;exports.SearchHistoryWidget=xn;exports.SearchInputUI=hn;exports.SearchResultItemUI=Sn;exports.SearchResultListWidget=wn;exports.SearchWidget=Rn;exports.SimilarEventCard=Ka;exports.SimilarEventsSection=dn;exports.TradeFormSkeleton=Ar;exports.TradeFormUI=Lr;exports.TradeFormWidget=Or;exports.UserActivitySection=_r;exports.UserPredictProvider=il;exports.countActiveFilters=mt;exports.formatWan=_e;exports.useEventDetail=iu;exports.useEventsInfinite=or;exports.usePredictSearchHistory=it;exports.useSearchResultListScript=kn;exports.useSearchScript=Ln;exports.useTradeForm=Cr;exports.version=Wn;//# sourceMappingURL=index.js.map
|
|
22
22
|
//# sourceMappingURL=index.js.map
|