PageSourceSearch

https://raptorx.trade/_next/static/chunks/8432-9b229eceae257e4f.js?dpl=dpl_2Fo8V8gNRU2aGjd3HHyy1Ug4PNEF

js raptorx.trade collected 2026-10-08 12:40:26 UTC 243,475 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8432],{1968:(e,t,r)=>{"use strict";r.d(t,{d:()=>i});var s=r(16610),a=r(55003);function i(){let{user:e,isAuthenticated:t}=(0,a.F)(),{authenticated:r,ready:i,user:n}=(0,s.u)(),l=t&&e?.solanaWallet?e.solanaWallet:null,o=(n?.linkedAccounts??[]).find(e=>"wallet"===e.type&&"solana"===e.chainType&&"string"==typeof e.address),c=r&&o?.address?o.address:null;return{solanaAddress:l||c||null,source:l?"phantom":c?"privy":null,isLoading:r&&!i}}},4095:(e,t,r)=>{"use strict";r.d(t,{$6:()=>h,Nm:()=>u,v7:()=>x});var s=r(84291),a=r(50343),i=r(93200),n=r(5809);function l(e){if(null==e)return null;let t=String(e).trim();if(!t)return null;t.startsWith("0x")||(t=`0x${t}`);let r=t.slice(2);return/^[0-9a-fA-F]+$/.test(r)?(r.length>64?t=`0x${r.slice(-64)}`:r.length<64&&(t=`0x${r.padStart(64,"0")}`),t):null}function o(e){let t=e.trim().toLowerCase();return["yes","up","y"].includes(t)?1:["no","down","n"].includes(t)?2:null}function c(e){let t=e?.outcome;for(let r of[e?.indexSet,e?.index_set,t?.indexSet,t?.index_set]){let e=Number(r);if(1===e||2===e)return e}return o(String(t?.name??("string"==typeof e?.outcome?e.outcome:"")??"").trim())}function d(e){if(!e||"object"!=typeof e)return null;let t=Number(e?.winningIndexSet??e?.winning_index_set??e?.resolvedIndexSet??e?.resolved_index_set);if(1===t||2===t)return t;let r=o(String(e?.winningOutcome??e?.winning_outcome??e?.resolvedOutcome??e?.resolved_outcome??"").trim());if(r)return r;let s=Array.isArray(e?.outcomes)?e.outcomes:[];for(let e of s){if(e?.won===!0||e?.isWinner===!0){let t=c({outcome:e,indexSet:e?.indexSet});if(t)return t}if(1===Number(e?.payout??e?.payoutNumerator??e?.payout_numerator)){let t=c({outcome:e,indexSet:e?.indexSet});if(t)return t}}for(let e of s){let t=Number(e?.bestBid?.price),r=Number(e?.bestAsk?.price);if((Number.isFinite(t)&&Number.isFinite(r)?(t+r)/2:Number.isFinite(r)?r:Number.isFinite(t)?t:0)>=.99){let t=c({outcome:e,indexSet:e?.indexSet});if(t)return t}}return null}let m=BigInt(0);function u(e,t){if(function(e,t){let r=e?.outcome;if(e?.isWinner===!1||e?.won===!1||r?.isWinner===!1||r?.won===!1||["LOST","LOSER","LOSS","NOT_WON"].includes(String(r?.status??e?.outcomeStatus??"").toUpperCase()))return!0;if(e?.redeemable===!1||r?.redeemable===!1){let r=e?.market??e?.category??t??{};if((0,i.Z)(r))return!0}let s=e?.market??e?.category??t;if(s&&(0,i.Z)(s)){let t=d(s),r=c(e);if(t&&r&&t!==r)return!0}return!1}(e,t))return!1;if(e?.redeemable===!0||e?.canRedeem===!0||e?.winningsToClaim===!0||e?.voidedWinningsToClaim===!0||e?.outcome?.redeemable===!0||e?.outcome?.canRedeem===!0||e?.outcome?.winningsToClaim===!0||e?.outcome?.voidedWinningsToClaim===!0||e?.isWinner===!0||e?.won===!0||e?.outcome?.isWinner===!0||e?.outcome?.won===!0)return null!=h(e);let r=e?.market??e?.category??t??e;if(!(0,i.Z)(r)||0>=(0,n.k7)(e))return!1;let s=d(r),a=c(e);return!!s&&!!a&&s===a&&null!=h(e)}function x(e,t){if(0>=(0,n.k7)(e))return!1;let r=t??e?.market??e?.category??e;return!(0,i.Z)(r)||u(e,r)}function h(e){let t,r=e?.market??e?.category??{},i=l(e?.conditionId)??l(e?.condition_id)??l(r?.conditionId)??l(r?.condition_id),n=c(e);if(!i||!n)return null;let o=(t=e?.market??e?.category??{},{isNegRisk:!!(e?.isNegRisk??t?.isNegRisk),isYieldBearing:!!(e?.isYieldBearing??t?.isYieldBearing)}),d=function(e){for(let t of[e?.balance,e?.amount,e?.sharesWei,e?.shareAmount,e?.tokenAmount,e?.outcome?.balance,e?.outcome?.amount])if(null!=t)try{if("bigint"==typeof t)return t>m?t:m;let e=String(t).trim();if(!e)continue;if(/^\d+$/.test(e)){let t=BigInt(e);return t>m?t:m}if("number"==typeof t&&Number.isFinite(t)&&t>0)return s.gH.from(a.XS(String(t),18)).toBigInt()}catch{continue}return m}(e);return o.isNegRisk&&d<=m?null:{conditionId:i,indexSet:n,amountWei:d,...o}}},4206:(e,t,r)=>{"use strict";r.d(t,{J:()=>a});var s=r(74080);function a(e,t,r){let a=function(e,t,r){let a=e.trim(),i=r?.trim();if(i&&/^0x[a-fA-F0-9]{40}$/.test(i))return i;let n=(0,s.Vn)(t,a);return n&&/^0x[a-fA-F0-9]{40}$/.test(n)?n:a}(e,t,r),i=new Set,n=[];for(let t of[a,e.trim(),r?.trim()]){if(!t||!/^0x[a-fA-F0-9]{40}$/.test(t))continue;let e=t.toLowerCase();i.has(e)||(i.add(e),n.push(t))}let l=(0,s.Vn)(t,e);if(l&&/^0x[a-fA-F0-9]{40}$/.test(l)){let e=l.toLowerCase();i.has(e)||(i.add(e),n.push(l))}return n}},5677:(e,t,r)=>{"use strict";r.d(t,{S:()=>l});var s=r(66577),a=r(56693),i=r(65294),n=r(71348);function l({checked:e,onChange:t,label:r,disabled:l=!1,className:o="",id:c,size:d="default"}){let m=(0,a.useRef)(0),u=(0,a.useCallback)(()=>
1{if(l)return;let r=Date.now();r-m.current<350||(m.current=r,t(!e))},[l,e,t]),x="sm"===d;return(0,s.jsxs)("div",{className:(0,n.A)("flex items-center gap-2",o),children:[(0,s.jsx)("span",{className:(0,n.A)("inline-flex items-center justify-center shrink-0 touch-manipulation",x&&"p-[14px] -m-[14px]"),children:(0,s.jsx)("button",{type:"button",role:"checkbox","aria-checked":e,onClick:u,onTouchEnd:e=>{e.preventDefault(),u()},disabled:l,id:c,style:{WebkitTapHighlightColor:"transparent"},className:(0,n.A)("flex items-center justify-center rounded border-2 transition-all shrink-0 touch-manipulation",x?"w-4 h-4":"w-5 h-5",e?"bg-[#ffc000] border-[#ffc000]":"bg-transparent border-white/30 active:border-white/50",l&&"opacity-50 cursor-not-allowed",!l&&"cursor-pointer"),children:e&&(0,s.jsx)(i.A,{className:(0,n.A)("text-black stroke-3",x?"w-2.5 h-2.5":"w-3.5 h-3.5")})})}),r&&(0,s.jsx)("label",{htmlFor:c,className:(0,n.A)("text-sm text-gray-300 cursor-pointer select-none",l&&"opacity-50 cursor-not-allowed"),onClick:u,children:r})]})}},5809:(e,t,r)=>{"use strict";r.d(t,{Ac:()=>l,k7:()=>n,oD:()=>i});var s=r(50343),a=r(16164);function i(e){if(Array.isArray(e))return e;if(!e||"object"!=typeof e)return[];let t=(0,a.W2)(e);if(t.length>0)return t;let r=e.data;if(Array.isArray(r))return r;if(r&&"object"==typeof r){if(Array.isArray(r.data))return r.data;if(Array.isArray(r.positions))return r.positions;if(Array.isArray(r.items))return r.items;if(Array.isArray(r.results))return r.results}return[]}function n(e){for(let t of[e?.balance,e?.amount,e?.size,e?.shares,e?.quantity,e?.sharesWei,e?.shareAmount,e?.tokenAmount,e?.outcome?.balance,e?.outcome?.amount]){if(null==t)continue;if("number"==typeof t){if(Number.isFinite(t)&&t>0)return t;continue}let e=String(t).trim();if(e)try{if(/^\d+$/.test(e)){let t=Number(s.Js(e,18));if(t>0)return t;continue}let t=Number(e);if(Number.isFinite(t)&&t>0)return t}catch{}}return 0}function l(e){if(!e||"object"!=typeof e)return null;let t=e.data,r=String(t?.address??t?.predictAccount??t?.depositAddress??"").trim();return/^0x[a-fA-F0-9]{40}$/i.test(r)?r:null}},8959:(e,t,r)=>{"use strict";r.d(t,{m:()=>o});var s=r(56693);let a="limitless_auth";function i(){try{let e=localStorage.getItem(a);if(!e)return null;let t=JSON.parse(e);if(t?.id!=null&&t?.account)return t}catch{}return null}function n(e){if(e){let t={...e};t.sessionCookie&&(t.sessionCookie=t.sessionCookie),localStorage.setItem(a,JSON.stringify(t))}else localStorage.removeItem(a)}function l(e){return(e||"").toLowerCase().trim()}function o(e){let[t,r]=(0,s.useState)(()=>{let e=i();return e?.id!=null?String(e.id):null}),[a,o]=(0,s.useState)(i),[c,d]=(0,s.useState)(!1),[m,u]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!e){o(null),r(null);return}let t=!1;return e.getAddress().then(e=>{if(t)return;let s=l(e),a=i();a&&(l(a.account)!==s?(o(null),r(null),n(null)):(o(a),r(null!=a.id?String(a.id):null)))}),()=>{t=!0}},[e]);let x=(0,s.useCallback)(async()=>{if(!e)return u(Error("Wallet not connected")),null;d(!0),u(null);try{let t=await fetch("/api/limitless/auth/signing-message",{method:"GET",cache:"no-store"});if(!t.ok)throw Error("Failed to get signing message");let s=await t.text(),a="0x"+Array.from(new TextEncoder().encode(s)).map(e=>e.toString(16).padStart(2,"0")).join(""),i=await e.getAddress(),l=await e.signMessage(s),c=await fetch("/api/limitless/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({address:i,signingMessageHex:a,signature:l})});if(!c.ok){let e=await c.json().catch(()=>({}));throw Error(e?.error||`Login failed ${c.status}`)}let d=await c.json();if(!d?.id||!d?.account)throw Error("Invalid login response");o(d);let m=String(d.id);return r(m),n(d),d}catch(e){return u(e instanceof Error?e:Error("Limitless login failed")),o(null),r(null),n(null),null}finally{d(!1)}},[e]),h=(0,s.useCallback)(()=>{o(null),r(null),n(null),u(null)},[]),p=i(),f=a??p;return{ownerId:f?.id!=null?String(f.id):t,user:f,login:x,logout:h,isLoading:c,error:m}}},9630:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});var s=r(76180);function a(e,t,r=50){return(0,s.I)({queryKey:["trades",t,r],queryFn:async()=>
1{if(!e||!t)return[];try{return(await e.getTrades()||[]).filter(e=>{let r=(e.maker_address||e.maker||e.makerAddress||"").toLowerCase(),s=(e.taker_address||e.taker||e.takerAddress||"").toLowerCase(),a=t.toLowerCase();return r===a||s===a})}catch(e){return console.error("Error fetching trades:",e),[]}},enabled:!!e&&!!t,staleTime:5e3,refetchInterval:1e4,refetchIntervalInBackground:!0,refetchOnWindowFocus:!0})}},10773:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});var s=r(76180);function a(e){return(0,s.I)({queryKey:["polymarket-positions",e],queryFn:async()=>{if(!e)return[];let t=await fetch(`/api/polymarket/positions?user=${e}`);if(!t.ok)throw Error("Failed to fetch positions");return t.json()},enabled:!!e,staleTime:2e3,refetchInterval:3e3,refetchIntervalInBackground:!0,refetchOnWindowFocus:!0})}},12222:(e,t,r)=>{"use strict";r.d(t,{A:()=>tn});var s=r(66577),a=r(56693),i=r(87562),n=r(16610),l=r(55003),o=r(59339),c=r(69623),d=r(7998),m=r(90175),u=r(82981),x=r(48769),h=r(70486),p=r(97770),f=r(8579),g=r(55936),y=r(58670),b=r(41326),w=r(26882),N=r(19635),j=r(53325),v=r(52698);let k=new(r(1284)).A({headingStyle:"atx",bulletListMarker:"-",codeBlockStyle:"fenced"});function S(e){return e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"")}function C(e){let t,r=(e||"").trim();if(!r)return"<p></p>";if(t=r.trim(),/^<(p|div|h[1-6]|ul|ol|blockquote|span|strong|em|b|i)\b/i.test(t))return S(r);let s=v.xI.parse(r,{async:!1});return s.trim()?s:"<p></p>"}function A(e){let t=(e||"").trim()||"<p></p>";return k.turndown(S(t)).trim()}v.xI.use({breaks:!0,gfm:!0});var E=r(29604);function I({markdown:e,onMarkdownChange:t,placeholder:r,disabled:i}){let n=(0,c.hG)({immediatelyRender:!1,extensions:[d.A.configure({heading:{levels:[2,3]}}),u.A,m.A.configure({placeholder:r||"Write an update for token holders…"})],content:C(e),editable:!i,editorProps:{attributes:{class:"golden-team-updates-prose min-h-[200px] px-3 py-2 text-base sm:text-sm text-white focus:outline-none max-w-none"}},onUpdate:({editor:e})=>{let r=A(e.getHTML()),s=(0,E.c3)(r);s!==r&&e.commands.setContent(C(s),!1),t(s)}}),l=(0,a.useMemo)(()=>(0,E.ze)(e),[e]);if((0,a.useEffect)(()=>{n&&n.setEditable(!i)},[n,i]),!n)return(0,s.jsx)("div",{className:"min-h-[220px] rounded-md border border-white/15 bg-black/40"});let o=e=>`rounded p-1.5 transition ${e?"bg-[#ffc000] text-black":"text-white/80 hover:bg-white/10 hover:text-white"} ${i?"pointer-events-none opacity-50":""}`;return(0,s.jsxs)("div",{className:"rounded-md border border-[#ffc000]/35 bg-black/40 overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex flex-wrap gap-0.5 border-b border-white/10 bg-black/30 px-1.5 py-1.5",children:[(0,s.jsx)("button",{type:"button",className:o(n.isActive("bold")),onClick:()=>n.chain().focus().toggleBold().run(),title:"Bold","aria-label":"Bold",children:(0,s.jsx)(x.A,{className:"h-4 w-4"})}),(0,s.jsx)("button",{type:"button",className:o(n.isActive("italic")),onClick:()=>n.chain().focus().toggleItalic().run(),title:"Italic","aria-label":"Italic",children:(0,s.jsx)(h.A,{className:"h-4 w-4"})}),(0,s.jsx)("button",{type:"button",className:o(n.isActive("underline")),onClick:()=>n.chain().focus().toggleUnderline().run(),title:"Underline","aria-label":"Underline",children:(0,s.jsx)(p.A,{className:"h-4 w-4"})}),(0,s.jsx)("span",{className:"mx-0.5 w-px self-stretch bg-white/15","aria-hidden":!0}),(0,s.jsx)("button",{type:"button",className:o(n.isActive("heading",{level:2})),onClick:()=>n.chain().focus().toggleHeading({level:2}).run(),title:"Heading 2","aria-label":"Heading 2",children:(0,s.jsx)(f.A,{className:"h-4 w-4"})}),(0,s.jsx)("button",{type:"button",className:o(n.isActive("heading",{level:3})),onClick:()=>n.chain().focus().toggleHeading({level:3}).run(),title:"Heading 3","aria-label":"Heading 3",children:(0,s.jsx)(g.A,{className:"h-4 w-4"})}),(0,s.jsx)("span",{className:"mx-0.5 w-px self-stretch bg-white/15","aria-hidden":!0}),(0,s.jsx)("button",{type:"button",className:o(n.isActive("bulletList")),onClick:()=>n.chain().focus().toggleBulletList().run(),title:"Bullet list","aria-label":"Bullet list",children:(0,s.jsx)(y.A,{className:"h-4 w-4"})}),(0,s.jsx)("button",{type:"button",className:o(n.isActive("orderedList")),onClick:()=>n.chain().focus().toggleOrderedList().run(),title:"Numbered list","aria-label":"Numbered list",children:(0,s.jsx)(b.A,{className:"h-4 w-4"})}),(0,s.jsx)("button",{type:"button",className:o(n.isActive("blockquote")),onClick:()=>n.chain().focus().toggleBlockquote().run(),title:"Quote","aria-label":"Quote",children:(0,s.jsx)(w.A,{className:"h-4 w-4"})}),(0,s.jsx)("span",{className:"mx-0.5 w-px self-stretch bg-white/15","aria-hidden":!0}),(0,s.jsx)("button",{type:"button",className:`rounded p-1.5 text-white/80 transition hover:bg-white/10 hover:text-white ${i||
1!n.can().undo()?"cursor-not-allowed opacity-35":""}`,onClick:()=>n.chain().focus().undo().run(),disabled:i||!n.can().undo(),title:"Undo","aria-label":"Undo",children:(0,s.jsx)(N.A,{className:"h-4 w-4"})}),(0,s.jsx)("button",{type:"button",className:`rounded p-1.5 text-white/80 transition hover:bg-white/10 hover:text-white ${i||!n.can().redo()?"cursor-not-allowed opacity-35":""}`,onClick:()=>n.chain().focus().redo().run(),disabled:i||!n.can().redo(),title:"Redo","aria-label":"Redo",children:(0,s.jsx)(j.A,{className:"h-4 w-4"})})]}),(0,s.jsx)(c.$Z,{editor:n}),(0,s.jsxs)("div",{className:"border-t border-white/10 bg-black/30 px-3 py-1.5 text-right text-xs text-white/65",children:[l,"/",E.OP," words"]})]})}function T({documentKey:e,...t}){return(0,s.jsx)(I,{...t},e)}var F=r(61111),L=r(65294);function D({userId:e,referralCode:t}){let[r,n]=(0,a.useState)(!1),[l,o]=(0,a.useState)(null),c=async()=>{if(t)try{let e=`https://www.raptorx.trade?referralcode=${t}`;await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),2e3)}catch(e){console.error("Failed to copy:",e)}},d=(0,a.useCallback)(async()=>{if(e)try{let t=await fetch("/api/referral",{headers:{"x-user-id":e}});if(t.ok){let e=await t.json();o(e.referralStats)}}catch(e){console.error("Failed to fetch referral stats:",e)}},[e]);return((0,a.useEffect)(()=>{e&&d()},[e,d]),t)?(0,s.jsxs)("div",{className:"w-full bg-white/5 border border-white/10 rounded-2xl p-6",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-6",children:[(0,s.jsx)("div",{className:"rounded-lg",children:(0,s.jsx)(i.default,{src:"/images/referral.png",width:80,height:80,alt:"referral"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-xl font-bold text-white",children:"Your Referral Link"}),(0,s.jsx)("p",{className:"text-gray-400 text-sm",children:"Share with friends to earn points"})]})]}),(0,s.jsxs)("div",{className:"flex gap-3 items-center justify-center mb-6",children:[(0,s.jsx)("div",{className:"bg-[#262626] rounded-lg h-10 flex items-center justify-center w-full",children:(0,s.jsx)("div",{className:"flex items-center justify-between",children:(0,s.jsx)("div",{children:(0,s.jsxs)("p",{className:"text-white font-mono text-[14px] font-bold",children:["https://raptorx.trade?referralcode=",t]})})})}),(0,s.jsx)("button",{onClick:c,className:"flex items-center justify-center gap-1 text-[#F9B80C] border border-[#6D4F03] w-20.25 h-10 rounded-lg transition-colors text-[14px]",children:r?(0,s.jsx)(L.A,{className:"w-4 h-4"}):(0,s.jsx)(F.A,{className:"w-4 h-4"})})]}),l&&(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4 mb-6",children:[(0,s.jsxs)("div",{className:"bg-white/5 border border-white/10 rounded-lg p-4",children:[(0,s.jsx)("p",{className:"text-gray-400 text-sm",children:"Total Referrals"}),(0,s.jsx)("p",{className:"text-white text-2xl font-bold",children:l.totalReferrals})]}),(0,s.jsxs)("div",{className:"bg-white/5 border border-white/10 rounded-lg p-4",children:[(0,s.jsx)("p",{className:"text-gray-400 text-sm",children:"Points Earned"}),(0,s.jsxs)("p",{className:"text-green-400 text-2xl font-bold",children:["+",l.totalPointsEarned]})]})]}),l&&l.recentReferrals.length>0&&(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-white font-semibold mb-3",children:"Recent Referrals"}),(0,s.jsx)("div",{className:"space-y-2",children:l.recentReferrals.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between bg-white/5 border border-white/10 rounded-lg p-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-white font-medium",children:e.username}),(0,s.jsx)("p",{className:"text-gray-400 text-sm",children:new Date(e.createdAt).toLocaleDateString()})]}),(0,s.jsx)("span",{className:"text-green-400 font-bold",children:"+150"})]},e.id))})]}),(0,s.jsxs)("div",{className:"mt-6 pt-6 border-t border-gray-700",children:[(0,s.jsx)("h4",{className:"text-white font-medium mb-2",children:"Referral Rewards"}),(0,s.jsxs)("ul",{className:"text-sm text-gray-400 space-y-1",children:[(0,s.jsx)("li",{children:"• You earn 150 points for each successful referral"}),(0,s.jsx)("li",{children:"• New users get 100 points (instead of 50) when using your link"}),(0,s.jsx)("li",{children:"• Share your link on social media, Discord, or with friends!"})]})]})]}):null}var B=r(16329),R=r.n(B),P=r(25514),$=r(75486),O=r(44985),_=r(48663),U=r(78427);function M(e){return`raptorx_golden_editor_v1:${e}`}
1function K(e,t,r=Date.now()){if(e)try{localStorage.setItem(M(e),JSON.stringify({v:1,fetchedAt:r,projects:t}))}catch{}}function z(e,t=864e5){return Date.now()-e.fetchedAt<t}let W=e=>!e||e.length<=10?e:`${e.slice(0,6)}...${e.slice(-4)}`;function q(e,t,r){let s=0;if(t&&e.length>0){let a=e.findIndex(e=>e.contractAddress===t&&e.chain===r);a>=0&&(s=a)}return s}function G({isOpen:e,onClose:t,currentUser:r,isLoadingUser:i,isLoggingOut:n,onLogout:l}){let o,[c,d]=(0,a.useState)("profile"),[m,u]=(0,a.useState)(null),x=(0,a.useRef)(null),h=(0,a.useRef)(null),[p,f]=(0,a.useState)([]),[g,y]=(0,a.useState)(!1),[b,w]=(0,a.useState)(0),[N,j]=(0,a.useState)(""),[v,k]=(0,a.useState)(!1),[S,E]=(0,a.useState)(!1),I=(0,a.useRef)(p),B=(0,a.useRef)(b);I.current=p,B.current=b;let{eoaAddress:G}=(0,$.v)(),{derivedSafeAddressFromEoa:J}=(0,_.A)(G),{data:X,isLoading:H,error:V}=(0,O.i)({walletAddress:J||null,enabled:e&&!!J}),Y=(e,t)=>{e&&(R()(e),u(t),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{u(null)},2e3))};(0,a.useEffect)(()=>()=>{h.current&&clearTimeout(h.current)},[]);let Q=(0,a.useCallback)(async(e,t)=>{let r=t?.showLoading!==!1,s=I.current,a=B.current,i=s[a]?.contractAddress,n=s[a]?.chain;r&&y(!0);try{let t=await fetch("/api/golden-reports/editor",{headers:{"x-user-id":e},cache:"no-store"}),r=await t.json().catch(()=>({})),s=Array.isArray(r?.projects)?r.projects:[],a=q(s,i,n);return K(e,s,Date.now()),f(s),w(a),j(s[a]?.teamUpdatesContent??""),!0}catch{return r&&(f([]),j("")),!1}finally{r&&y(!1)}},[]),Z=async()=>{if(r?.id&&!S&&(!et||window.confirm("You have unsaved Team Updates changes. Refreshing will replace the editor with the latest published content. Continue?"))){E(!0);try{if(!await Q(r.id,{showLoading:!1}))return void(0,U.showErrorNotification)("Could not refresh","Failed to fetch the latest Team Updates. Please try again.",{position:"top-right"});(0,U.showSuccessNotification)("Team updates refreshed","Loaded the latest Team Updates from the database.",{position:"top-right"})}finally{E(!1)}}};(0,a.useEffect)(()=>{if(!e||"goldenReport"!==c||!r?.id)return;let t=r.id,s=function(e){if(!e)return null;try{let t=localStorage.getItem(M(e));if(!t)return null;let r=JSON.parse(t);if(r?.v!==1||!Array.isArray(r.projects)||"number"!=typeof r.fetchedAt)return null;return{v:1,fetchedAt:r.fetchedAt,projects:r.projects.map(e=>({contractAddress:String(e.contractAddress??""),chain:String(e.chain??"solana"),teamUpdatesContent:String(e.teamUpdatesContent??""),teamUpdatesPublishedAt:null===e.teamUpdatesPublishedAt||void 0===e.teamUpdatesPublishedAt?null:String(e.teamUpdatesPublishedAt)}))}}catch{return null}}(t);if(s&&z(s)){let e=s.projects;if(0===e.length)return void Q(t,{showLoading:!0});let r=q(e,I.current[B.current]?.contractAddress,I.current[B.current]?.chain);return f(e),w(r),void j(e[r]?.teamUpdatesContent??"")}if(s&&!z(s)){let e=s.projects,r=q(e,I.current[B.current]?.contractAddress,I.current[B.current]?.chain);f(e),w(r),j(e[r]?.teamUpdatesContent??""),Q(t,{showLoading:!1});return}Q(t,{showLoading:!0})},[e,c,r?.id,Q]),(0,a.useEffect)(()=>{let e=p[b];e&&j(e.teamUpdatesContent??"")},[b,p]);let ee=p[b]?.teamUpdatesContent??"",et=(0,a.useMemo)(()=>A(C(N??""))!==A(C(ee??"")),[N,ee]),er=async()=>{let e=p[b];if(r?.id&&e&&et){k(!0);try{let t=await fetch("/api/golden-reports/editor",{method:"PUT",headers:{"Content-Type":"application/json","x-user-id":r.id},body:JSON.stringify({contractAddress:e.contractAddress,chain:e.chain,content:N})}),s=await t.json().catch(()=>({}));if(!t.ok||s?.ok===!1){let e="string"==typeof s?.error?s.error:"Publish failed.";(0,U.showErrorNotification)("Could not publish",e,{position:"top-right"});return}(0,U.showSuccessNotification)("Team updates published","RexScreener reports will show the latest under Team Updates.",{position:"top-right"});let a=s?.project;a&&r?.id&&(f(e=>{let t=e.map(e=>e.contractAddress===a.contractAddress&&e.chain===a.chain?{...e,teamUpdatesContent:a.teamUpdatesContent??e.teamUpdatesContent,teamUpdatesPublishedAt:null!=a.teamUpdatesPublishedAt?String(a.teamUpdatesPublishedAt):e.teamUpdatesPublishedAt}:e);return K(r.id,t,Date.now()),t}),j("string"==typeof a.teamUpdatesContent?a.teamUpdatesContent:""))}catch{(0,U.showErrorNotification)("Could not publish","Publish failed.",{position:"top-right"})}finally{k(!1)}}};return((0,a.useEffect)(()=>{let r=e=>{x.current&&!x.current.contains(e.target)&&t()};if(e)return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[e,t]),(0,a.useEffect)(()=>{let r=r=>{"Escape"===r.key&&e&&t()};if(e)return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[e,t]),e)?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/50 z-40",onClick:t}),(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center z-50 pointer-events-none",children:(0,s.jsxs)("div",{ref:x,className:"w-125 max-w-[90%] bg-[#0D0D0D] rounded-xl shadow-2xl border border-white/10 pointer-events-auto max-h-[80vh] overflow-y-auto custom-sidebar-scrollbar",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-white/10",children:[(0,s.jsx)("h2",{className:"text-xl font-bold text-white",children:"Account & Referrals"}),(0,s.jsx)("button",{onClick:t,className:"p-2 hover:bg-gray-800 rounded-lg transition text-gray-400 hover:text-white","aria-label":"Close modal",children:(0,s.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}
1),(0,s.jsxs)("div",{className:"flex gap-1 mx-4 mt-4 bg-[#141414] p-1 rounded-lg",children:[(0,s.jsx)("button",{type:"button",onClick:()=>d("profile"),className:`min-w-0 flex-1 py-2 px-2 sm:px-3 rounded-md text-xs sm:text-sm font-medium transition-colors ${"profile"===c?"bg-[#ffc000] text-black":"text-gray-400 hover:text-white"}`,children:"Profile"}),(0,s.jsx)("button",{type:"button",onClick:()=>d("goldenReport"),className:`min-w-0 flex-1 py-2 px-2 sm:px-3 rounded-md text-xs sm:text-sm font-medium transition-colors ${"goldenReport"===c?"bg-[#ffc000] text-black":"text-gray-400 hover:text-white"}`,children:"Golden Report"}),(0,s.jsx)("button",{type:"button",onClick:()=>d("referral"),className:`min-w-0 flex-1 py-2 px-2 sm:px-3 rounded-md text-xs sm:text-sm font-medium transition-colors ${"referral"===c?"bg-[#ffc000] text-black":"text-gray-400 hover:text-white"}`,children:"Referrals"})]}),(0,s.jsx)("div",{className:"p-4",children:i?(0,s.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,s.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-[#ffc000]"})}):r?(0,s.jsxs)(s.Fragment,{children:["profile"===c&&(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"flex flex-col items-center mb-6",children:[(0,s.jsx)("div",{className:"w-20 h-20 rounded-full bg-[#ffc000] text-black flex items-center justify-center text-2xl font-bold mb-4",children:(o=r.username.replace(/[0-9]/g,"")).length<2?o.toUpperCase():(o[0]+o[o.length-1]).toUpperCase()}),(0,s.jsx)("h3",{className:"font-bold text-white text-2xl",children:r.username}),(0,s.jsxs)("p",{className:"text-white text-lg mt-2",children:[(0,s.jsx)("span",{className:"text-[#00B050] text-xl font-bold",children:r.points.toLocaleString()})," ","points"]})]}),(0,s.jsxs)("div",{className:"bg-white/5 rounded-lg p-4",children:[(0,s.jsx)("h4",{className:"text-white font-semibold mb-3",children:"Account Information"}),(0,s.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{className:"text-gray-400",children:"Username:"}),(0,s.jsx)("span",{className:"text-white",children:r.username})]}),(0,s.jsxs)("div",{className:"flex justify-between items-center gap-2",children:[(0,s.jsx)("span",{className:"text-gray-400",children:"Solana Wallet:"}),(0,s.jsxs)("div",{className:"flex items-center gap-2 max-w-55",children:[(0,s.jsx)("span",{className:"text-white text-right",children:r.solanaWallet?W(r.solanaWallet):"Not connected"}),r.solanaWallet&&(0,s.jsx)("button",{onClick:()=>Y(r.solanaWallet,"solana"),className:"p-1 hover:bg-white/10 rounded transition-colors shrink-0",title:"Copy address","aria-label":"Copy Solana wallet address",children:"solana"===m?(0,s.jsx)(L.A,{className:"w-4 h-4 text-green-400"}):(0,s.jsx)(F.A,{className:"w-4 h-4 text-gray-400 hover:text-white"})})]})]}),(0,s.jsxs)("div",{className:"flex justify-between items-center gap-2",children:[(0,s.jsx)("span",{className:"text-gray-400",children:"BNB Wallet:"}),(0,s.jsxs)("div",{className:"flex items-center gap-2 max-w-55",children:[(0,s.jsx)("span",{className:"text-white text-right",children:r.ethereumWallet?W(r.ethereumWallet):"Not connected"}),r.ethereumWallet&&(0,s.jsx)("button",{onClick:()=>Y(r.ethereumWallet,"ethereum"),className:"p-1 hover:bg-white/10 rounded transition-colors shrink-0",title:"Copy address","aria-label":"Copy Ethereum wallet address",children:"ethereum"===m?(0,s.jsx)(L.A,{className:"w-4 h-4 text-green-400"}):(0,s.jsx)(F.A,{className:"w-4 h-4 text-gray-400 hover:text-white"})})]})]}),(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{className:"text-gray-400",children:"Email:"}),(0,s.jsx)("span",{className:"text-white",children:r.email||"Not provided"})]}),(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{className:"text-gray-400",children:"Member Since:"}),(0,s.jsx)("span",{className:"text-white",children:new Date(r.createdAt).toLocaleDateString()})]})]})]})]}),"goldenReport"===c&&(0,s.jsx)("div",{className:"space-y-4",children:g?(0,s.jsx)("div",{className:"flex justify-center py-12",children:(0,s.jsx)("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-[#ffc000] border-t-transparent"})}):p.length>0?(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"mb-1 flex items-center justify-between gap-2",children:[(0,s.jsxs)("h6",{className:"text-[14px]! font-medium!",children:[(0,s.jsx)("span",{className:"text-[#ffc000] font-medium!",children:"Golden Report"})," (Team updates)"]}),(0,s.jsx)("button",{type:"button",onClick:()=>void Z(),disabled:S||v,className:"inline-flex items-center justify-center p-1 text-white/90 transition hover:text-white disabled:cursor-not-allowed disabled:opacity-50",title:"Refresh latest team updates from database","aria-label":"Refresh Team Updates",children:(0,s.jsx)(P.A,{className:`h-4 w-4 ${S?"animate-spin":""}`})})]}),p.length>1?(0,s.jsxs)("label",{className:"mb-2 block text-xs text-gray-400",children:["Project",(0,s.jsx)("select",{value:b,onChange:e=>{let t=Number(e.target.value),r=p[t];w(t),j(r?.teamUpdatesContent??"")},className:"mt-1 w-full rounded-md border border-white/15 bg-black/40 px-2 py-2 text-sm text-white",children:p.map((e,t)=>(0,s.jsxs)("option",{value:t,children:[e.contractAddress.slice(0,6),"…",e.contractAddress.slice(-4)," (",e.chain,")"]},`${e.chain}:${e.contractAddress}`))})]}):null,(0,s.jsx)("div",{className:"mb-3",children:(0,s.jsx)(T,{documentKey:`${p[b]?.contractAddress??""}-${p[b]?.chain??""}-${p[b]?.teamUpdatesPublishedAt??""}`,markdown:N,onMarkdownChange:j,placeholder:"Share the latest official update for token holders…",disabled:v})}),(0,s.jsx)("div",{className:"flex flex-wrap items-center justify-end gap-2",children:(0,s.jsx)("button",{type:"button",onClick:()=>void er(),disabled:v||!et,className:"rounded-lg bg-[#ffc000] px-4 py-2 text-sm font-semibold text-black transition hover:bg-[#ffd000] disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:bg-[#ffc000]",children:v?"Publishing…":"Publish"})})]}):(0,s.jsx)("p",{className:"rounded-lg border border-white/10 bg-white/5 p-4 text-center text-sm text-gray-400",children:"No Golden Report projects are linked to your account email. If you should have access, ask the RaptorX team to add your email for your project's contract."})}),"referral"===c&&(0,s.jsx)("div",{className:"space-y-4",children:(0,s.jsx)(D,{userId:r.id,referralCode:r.referralCode||""})})]}):(0,s.jsx)("div",{className:"text-center py-8",children:(0,s.jsx)("p",{className:"text-gray-400",children:"User data not available"})})}),(0,s.jsx)("div",{className:"p-4 border-t border-gray-700",children:(0,s.jsx)("button",{onClick:()=>{r?.id&&function(e){if(e)try{localStorage.removeItem(M(e))}catch{}}(r.id),l()},disabled:n,className:`w-full flex items-center justify-center gap-2 px-4 py-3 rounded-lg transition ${n?"bg-gray-700 text-gray-400 cursor-not-allowed":"bg-[#ffc000] text-black hover:bg-[#ffc000]/80 font-semibold"}`,children:n?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),(0,s.jsx)("span",{children:"Logging out..."})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3v1"})}),(0,s.jsx)("span",{children:"Sign Out"})]})})})]})})]}):null}var J=r(92723),X=r(21557),H=r(38382),V=r(24211),Y=r(84444),Q=r(63992),Z=r(81258),ee=r(85672),et=r(9630),er=r(76180);let es=new Map;var ea=r(10773),ei=r(16105),en=r(12491),el=r(88435);let eo=[{inputs:[{name:"collateralToken",type:"address"},{name:"parentCollectionId",type:"bytes32"},{name:"conditionId",type:"bytes32"},{name:"indexSets",type:"uint256[]"}],name:"redeemPositions",outputs:[],stateMutability:"nonpayable",type:"function"}],ec=[{inputs:[{name:"conditionId",type:"bytes32"},{name:"amounts",type:"uint256[]"}],name:"redeemPositions",outputs:[],stateMutability:"nonpayable",type:"function"}];var ed=r(24449),em=r(1968),eu=r(45293),ex=r(87211),eh=r(8959),ep=r(95208),ef=r(14243),eg=r(24057);let ey=[{inputs:[{name:"collateralToken",type:"address"},{name:"parentCollectionId",type:"bytes32"},{name:"conditionId",type:"bytes32"},{name:"indexSets",type:"uint256[]"}],name:"redeemPositions",outputs:[],stateMutability:"nonpayable",type:"function"}],eb="0x"+"0".repeat(64),ew=[BigInt(1),BigInt(2)];var eN=r(64551),ej=r(20089);let ev=BigInt(10)**BigInt(18);function ek(e){return"string"==typeof e&&/^\d+$/.test(e)?e:"number"==typeof e&&Number.isFinite(e)&&e>=0?String(Math.trunc(e)):"0"}function eS(e){return"number"==typeof e&&Number.isFinite(e)?Math.trunc(e):"string"==typeof e&&/^\d+$/.test(e.trim())?parseInt(e.trim(),10):NaN}function eC(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e&&""!==e.trim()){let t=parseFloat(e);return Number.isFinite(t)?t:0}return 0}function eA(e){return"number"==typeof e&&Number.isFinite(e)?Math.trunc(e):"string"==typeof e&&/^\d+$/.test(e.trim())?parseInt(e.trim(),10):0}function eE(e){if(!e||"object"!=typeof e)return[];let t=Array.isArray(e.data)?e.data:Array.isArray(e.markets)?e.markets:Array.isArray(e.items)?e.items:[],r=new Map,s=(e,t,s,a,i,n,l)=>{if(!Number.isFinite(e)||e<=0)return;let o=r.get(e),c=t||o?.slug||"",d=s||o?.title||c||`Market #${e}`,m=a||o?.state||"";r.set(e,{slug:c,title:d,state:m,yes:(o?.yes??0)+i,no:(o?.no??0)+n,redeemEligible:!!(o?.redeemEligible||l)})},a=(e,t,r,s)=>{let a=e.outcomeId??e.outcome_id??e.outcomeIndex,i=eC(e.shares??e.balance??e.amount);if(1===a||"1"===a)r.v+=i;else if(0===a||"0"===a)t.v+=i;else if(i>0){let s=String(e.outcomeTitle??e.outcome_title??"").toLowerCase();"no"===s||s.startsWith("no ")?r.v+=i:t.v+=i}(!0===e.winningsToClaim||!0===e.voidedWinningsToClaim)&&(s.v=!0)};for(let e of t){if(!e||"object"!=typeof e)continue;let t=e.market&&"object"==typeof e.market?e.market:e,r=eS(t.chainMarketId??t.marketId??t.id??e.marketId??e.chainMarketId),i=String(t.slug??e.slug??e.marketSlug??e.market_slug??"").trim(),n=String(t.title??t.question??e.title??e.marketTitle??e.market_title??"").trim(),l=String(t.state??t.status??e.state??"").toLowerCase(),o=eC(e.yesShares??e.yes_shares??e.yesBalance??t.yesShares),c=eC(e.noShares??e.no_shares??e.noBalance??t.noShares),d=e.portfolio&&"object"==typeof e.portfolio?e.portfolio:null,m=d&&Array.isArray(d.positions)?d.positions:[],u=Array.isArray(e.positions)?e.positions:[],x=Array.isArray(e.outcomes)?e.outcomes:[],h=m.length>0?m:[...u,...x],p={v:o},f={v:c},g={v:!1};for(let e of h){if(!e||"object"!=typeof e)continue;let t=eS(e.marketId??e.market_id);Number.isFinite(t)&&t>0&&(!Number.isFinite(r)||r<=0)&&(r=t),a(e,p,f,g)}o=p.v,c=f.v;let y=eC(e.shares??e.balance);if(0===h.length&&y>0&&(null!=e.outcomeId||null!=e.outcome_id)&&Number.isFinite(eS(e.marketId??e.market_id))){let t=e.outcomeId??e.outcome_id;1===t||"1"===t?c=y:o=y,(!Number.isFinite(r)||r<=0)&&(r=eS(e.marketId??e.market_id)),(!0===e.winningsToClaim||!0===e.voidedWinningsToClaim)&&(g.v=!0)}let b=g.v||!0===e.redeemable||!0===t.redeemable||!0===e.canRedeem||"resolved"===l||"closed"===l||"finalized"===l;s(r,i,n,l,o,c,b)}let i=[];for(let[e,t]of r)t.yes<=0&&t.no<=0||i.push({marketId:e,slug:t.slug||String(e),title:t.title,state:t.state,yesShares:t.yes,noShares:t.no,redeemEligible:t.redeemEligible});return i.sort((e,t)=>
1t.marketId-e.marketId),i}var eI=r(58311),eT=r(81426),eF=r(88618),eL=r(75115);let eD=(e,t,r)=>{let s=setInterval(e,t);return setTimeout(()=>clearInterval(s),r),s};var eB=r(5677),eR=r(10621),eP=r(16164),e$=r(65343);async function eO(e,t){let r=t.search.toString(),s=r?`${e}?${r}`:e,a={};t.jwt&&(a.Authorization=`Bearer ${t.jwt}`);let i=await fetch(s,{cache:"no-store",headers:a});if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error||e.detail||"Predict.fun request failed")}return i.json()}var e_=r(98773),eU=r(14226),eM=r(5809);async function eK(e){let t=await fetch(`/api/predictfun/market-details?id=${encodeURIComponent(e)}`,{cache:"no-store"});if(!t.ok)return null;let r=await t.json(),s=r?.rawEventData??r?.data;return s&&"object"==typeof s&&!Array.isArray(s)?s:null}var ez=r(41250),eW=r(13060),eq=r(4206),eG=r(21832);let eJ="#A855F7";function eX({isOpen:e,onClose:t,activeTab:r,setActiveTab:i,eoaAddress:l,signer:c}){var d,m;let u,x,h,p,f=(0,o.useRouter)(),g=(0,V.jE)(),[y,b]=(0,a.useState)(!1),[w,N]=(0,a.useState)(null),[j,v]=(0,a.useState)(new Set),{redeem:k,isRedeeming:S}=(0,eW.u)(),C=e&&!!l,{authenticated:A,user:E}=(0,n.u)(),{wallets:I,ready:T}=(0,Y.u)(),[F,L]=(0,a.useState)(null),D=A&&E?.wallet?.address?E.wallet.address:void 0,B=(D?I.find(e=>(e.address??"").toLowerCase()===D.toLowerCase()):null)??(T&&I.length>0?I[0]:null);(0,a.useEffect)(()=>{let e=!1;return async function(){if(!C||!B||!A||!T||c){e||L(null);return}try{let t=await B.getEthereumProvider(),r=new eR.j(t,"any").getSigner();await r.getAddress(),e||L(r)}catch{e||L(null)}}(),()=>{e=!0}},[C,B,A,T,c]);let R=c??F,{jwt:P,tradingAddress:$,chainId:O,isLoading:_,refresh:M}=(0,ez.d)(R,l,C),K=$??l??null,z=(0,a.useCallback)(e=>e.redeemParams?(0,eG.bJ)(e.redeemParams):e.key,[]),W=(0,a.useMemo)(()=>l?`predictfun_redeem_locks:${l.toLowerCase()}:${O}`:null,[l,O]),q=(0,a.useCallback)(()=>{if(!W)return new Set;try{let e=localStorage.getItem(W);if(!e)return new Set;let t=JSON.parse(e),r=Date.now(),s=Object.entries(t).filter(([,e])=>Number.isFinite(e)&&e>r).map(([e])=>e);return new Set(s)}catch{return new Set}},[W]),G=(0,a.useCallback)(e=>{if(!W)return;let t=Date.now(),r={};e.forEach(e=>{r[e]=t+3e5}),localStorage.setItem(W,JSON.stringify(r))},[W]),J=(0,a.useCallback)(async()=>{if(!l||!R)return void(0,U.showErrorNotification)("Connect wallet","Connect your EVM wallet to sign in.");b(!0),N(null);try{await M(),(0,U.showSuccessNotification)("Signed in","Predict.fun session ready."),g.invalidateQueries({queryKey:["predictfun-orders-history"]}),g.invalidateQueries({queryKey:["predictfun-order-matches"]}),g.invalidateQueries({queryKey:["predictfun-positions"]})}catch(t){let e=t instanceof Error?t.message:String(t);N(e),(0,U.showErrorNotification)("Predict.fun sign-in failed",e)}finally{b(!1)}},[l,R,M,g]),{data:X,isLoading:H,error:Q,refetch:Z}=(d=C&&!!P,u=(0,e$.y)(K),(0,er.I)({queryKey:["predictfun-orders-history",u,P],enabled:d&&!!P&&!!u,queryFn:async()=>{let e=new URLSearchParams;return e.set("first","50"),e.set("signer",u),eO("/api/predictfun/orders",{jwt:P,search:e})},staleTime:1e4})),{data:ee,isLoading:et,error:es,refetch:ea}=(x=(0,e$.y)(K),(0,er.I)({queryKey:["predictfun-order-matches",x,P],enabled:C&&!!x,queryFn:async()=>{let e=new URLSearchParams;return e.set("first","50"),e.set("signerAddress",x),eO("/api/predictfun/orders/matches",{jwt:P,search:e})},staleTime:1e4})),ei=(0,a.useMemo)(()=>l?(0,eq.J)(l,O,$):[],[l,O,$]),en=ei[0]??null,el=ei.slice(1),{positions:eo,isLoading:ec,error:ed,refetch:em}=(0,e_.c)(en,C,P,el,{walletAddress:l,chainId:O,tradingAddress:$}),{marketById:eu,isLoading:ex}=(m=C&&!!eo,h=(0,a.useMemo)(()=>{let e=(0,eM.oD)(eo),t=new Set;for(let r of e){let e=String(r?.market?.id??r?.marketId??r?.market_id??"").trim();/^\d+$/.test(e)&&t.add(e)}return[...t].slice(0,25)},[eo]),p=(0,eU.E)({queries:h.map(e=>({queryKey:["predictfun-position-market-meta",e],enabled:m&&!!e,queryFn:()=>eK(e),staleTime:6e4}))}),{marketById:(0,a.useMemo)(()=>{let e=new Map;return h.forEach((t,r)=>{let s=p[r]?.data;s&&e.set(t,s)}),e},[h,p]),isLoading:p.some(e=>e.isLoading||e.isFetching),marketIds:h});(0,a.useEffect)(()=>{C&&(ea(),em(),P&&Z())},[C,P,r,Z,ea,em]);let eh=(0,a.useMemo)(()=>l?(0,eG.xq)((0,eG.ZU)(l,O)):[],[l,O,j.size]),ep=(0,a.useMemo)(()=>K?(0,eP.c7)(X,ee,K,eh):eh,[X,ee,K,eh]),ef=(0,a.useMemo)(()=>l&&eo?(0,eP.NT)(eo,l,eo?.data?.usdtBalanceWei??null,ei,{skipOwnerFilter:!0,hideRedeemKeys:j,marketMetaById:eu}):[],[eo,l,ei,j,eu]);(0,a.useEffect)(()=>{v(q())},[q]),(0,a.useEffect)(()=>
1{if(0===j.size)return;let e=new Set(ef.filter(e=>!!e.redeemParams&&e.redeemEligible).map(e=>z(e)));v(t=>{let r=!1,s=new Set;for(let a of t)e.has(a)?s.add(a):r=!0;return r&&G(s),r?s:t})},[ef,j.size,z,G]);let eg=et||!!P&&H,ey=es??(P?Q:null),eb=(0,a.useCallback)(async e=>{if(e.redeemParams&&l){if(!R)return void(0,U.showErrorNotification)("Connect wallet","Connect your EVM wallet to redeem.");try{let t=await k({rowKey:e.key,signer:R,walletAddress:l,chainId:O,params:e.redeemParams,wallet:B??void 0});(0,U.showSuccessNotification)("Redeemed",t?`Position redeemed. Tx: ${t.slice(0,10)}…`:"Position redeemed successfully.");let r=z(e);(0,eG.rh)(l,O,{key:r,marketId:e.marketId,marketTitle:e.marketTitle,slugForLink:e.slugForLink,outcome:e.outcome,shares:e.shares,txHash:t,redeemedAt:Date.now()}),v(e=>{let t=new Set(e);return t.add(r),G(t),t}),i("trades"),g.invalidateQueries({queryKey:["predictfun-positions"]}),g.invalidateQueries({queryKey:["predictfun-orders-history"]}),g.invalidateQueries({queryKey:["predictfun-order-matches"]}),em(),Z(),ea()}catch(r){let e=r instanceof Error?r.message:String(r),t=/result.*not received|not resolved/i.test(e)?"Market is not resolved on-chain yet. Try again after settlement.":e;(0,U.showErrorNotification)("Redeem failed",t)}}},[l,R,O,k,B,g,em,Z,ea,z]),ew=(0,s.jsxs)("div",{className:"text-center py-12 space-y-4",children:[(0,s.jsx)("p",{className:"text-gray-400",children:"Sign in to Predict.fun to view orders and trade history (BNB Chain)."}),l?R?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",onClick:()=>void J(),disabled:y,className:"px-6 py-3 rounded-lg font-semibold text-white disabled:opacity-50",style:{backgroundColor:eJ},children:y?"Signing in…":"Sign in to Predict.fun"}),w&&(0,s.jsx)("p",{className:"text-sm text-red-400",children:w})]}):(0,s.jsx)("p",{className:"text-sm text-amber-400",children:"Wallet signer loading…"}):(0,s.jsx)("p",{className:"text-sm text-amber-400",children:"Connect your wallet first."})]});return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex border-b border-white/10 sticky top-[73px] bg-[#0D0D0D] z-10 -mx-4 sm:-mx-6 px-4 sm:px-6 mb-0",children:[(0,s.jsx)("button",{type:"button",onClick:()=>i("trades"),className:`flex-1 px-4 py-3 text-sm font-medium transition-colors border-b-2 ${"trades"===r?"border-[#A855F7] text-[#A855F7]":"border-transparent text-gray-400 hover:text-white"}`,children:"Trades"}),(0,s.jsx)("button",{type:"button",onClick:()=>i("positions"),className:`flex-1 px-4 py-3 text-sm font-medium transition-colors border-b-2 ${"positions"===r?"border-[#A855F7] text-[#A855F7]":"border-transparent text-gray-400 hover:text-white"}`,children:"Positions"})]}),"trades"===r&&(0,s.jsx)(s.Fragment,{children:l?eg?(0,s.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,s.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2",style:{borderColor:eJ}})}):ey?(0,s.jsx)("div",{className:"text-center py-8",children:(0,s.jsx)("p",{className:"text-red-400",children:ey instanceof Error?ey.message:"Failed to load Predict.fun trades."})}):0===ep.length?(0,s.jsxs)("div",{className:"text-center py-12 space-y-4",children:[(0,s.jsx)("p",{className:"text-gray-400 text-lg",children:"No trades found."}),!P&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"text-gray-500 text-sm max-w-md mx-auto",children:["Sign in to also load your open orders from"," ",(0,s.jsx)("span",{className:"text-white/70",children:"GET /orders"}),"."]}),ew]})]}):(0,s.jsxs)(s.Fragment,{children:[!P&&(0,s.jsx)("p",{className:"text-gray-500 text-xs text-center mb-3 px-4",children:"Showing fills for your wallet. Sign in to include open orders."}),(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full border-collapse min-w-[720px]",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"border-b border-white/10",children:[(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Market"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Side"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Price"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Size"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Role"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Status"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Time"})]})}),(0,s.jsx)("tbody",{children:ep.map(e=>{let r="buy"===e.sideTone?"bg-green-500/20 text-green-400":"sell"===e.sideTone?"bg-red-500/20 text-red-400":"bg-white/10 text-white/90",a="confirmed"===e.statusStyle?"bg-green-500/20 text-green-400":"open"===e.statusStyle?"bg-blue-500/20 text-blue-300":"cancelled"===e.statusStyle?"bg-red-500/20 text-red-400":"bg-gray-500/20 text-gray-400";return(0,s.jsxs)("tr",{className:"border-b border-white/5 hover:bg-white/5",children:[(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:e.slugForLink?(0,s.jsx)("a",{href:`/rexmarkets/predict-fun/${encodeURIComponent(e.slugForLink)}`,onClick:r=>{r.preventDefault(),t(),f.push(`/rexmarkets/predict-fun/${encodeURIComponent(e.slugForLink)}`)},className:"max-w-[200px] truncate block hover:text-[#A855F7] underline decoration-dotted",title:e.marketTitle,children:e.marketTitle}):e.marketTitle}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:(0,s.jsx)("span",{className:`inline-block px-2 py-1 rounded text-xs font-medium ${r}`,children:e.sideLabel})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm tabular-nums",children:e.priceDisplay}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm tabular-nums",children:e.sizeDisplay}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:"—"===e.role?(0,s.jsx)("span",{className:"text-gray-500 text-xs",children:"—"}):(0,s.jsx)("span",{className:"inline-block px-2 py-1 rounded text-xs font-medium bg-blue-500/20 text-blue-400",children:e.role})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:(0,s.jsx)("span",{className:`inline-block px-2 py-1 rounded text-xs font-medium ${a}`,children:e.statusLabel})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-gray-400 text-xs whitespace-nowrap",children:e.timeStr})]},e.key)})})]})})]}):(0,s.jsx)("div",{className:"text-center py-12",children:(0,s.jsx)("p",{className:"text-gray-400",children:"Connect your wallet to view Predict.fun activity."})})}),"positions"===r&&(0,s.jsx)(s.Fragment,{children:l?_||ec||ex?(0,s.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,s.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2",style:{borderColor:eJ}})}):ed?(0,s.jsx)("div",{className:"text-center py-8",children:(0,s.jsx)("p",{className:"text-red-400",children:ed instanceof Error?ed.message:"Failed to load positions."})}):0===ef.length?(0,s.jsx)("div",{className:"text-center py-12",children:(0,s.jsx)("p",{className:"text-gray-400 text-lg",children:"No positions foun
1d."})}):(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full border-collapse",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"border-b border-white/10",children:[(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Market"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Outcome"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Size"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Action"})]})}),(0,s.jsx)("tbody",{children:ef.map(e=>(0,s.jsxs)("tr",{className:"border-b border-white/5 hover:bg-white/5",children:[(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:e.slugForLink?(0,s.jsx)("a",{href:`/rexmarkets/predict-fun/${encodeURIComponent(e.slugForLink)}`,onClick:r=>{r.preventDefault(),t(),f.push(`/rexmarkets/predict-fun/${encodeURIComponent(e.slugForLink)}`)},className:"max-w-[200px] truncate block hover:text-[#A855F7] underline decoration-dotted",title:e.marketTitle,children:e.marketTitle}):e.marketTitle}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:e.outcome}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm tabular-nums",children:"usdt-collateral"===e.key?`${e.sharesDisplay} USDT`:e.sharesDisplay}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:"usdt-collateral"!==e.key&&e.redeemParams?(0,s.jsx)("button",{type:"button",onClick:()=>void eb(e),"data-redeem-state":S(e.key)?"redeeming":j.has(z(e))?"redeemed":"idle",disabled:S(e.key)||j.has(z(e))||!e.redeemEligible||!R,title:R?j.has(z(e))?"Redeem submitted. Waiting for positions to sync.":e.redeemEligible?"Redeem winning shares for USDT (on-chain via Predict.fun SDK)":"Redeem is available after the market resolves":"Connect wallet to redeem",className:`min-w-[72px] px-3 py-1.5 rounded text-xs font-medium transition-colors ${S(e.key)?"bg-[#A855F7]/70 cursor-wait text-white":e.redeemEligible&&R?"bg-[#A855F7] hover:bg-[#9333EA] text-white":"bg-white/10 text-gray-500 cursor-not-allowed"}`,children:S(e.key)?(0,s.jsx)("span",{className:"flex items-center justify-center",children:(0,s.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-white/30 border-t-white rounded-full animate-spin"})}):j.has(z(e))?"Redeemed":"Redeem"}):(0,s.jsx)("span",{className:"text-gray-500 text-xs",children:"—"})})]},e.key))})]})}):(0,s.jsx)("div",{className:"text-center py-12",children:(0,s.jsx)("p",{className:"text-gray-400",children:"Connect your wallet to view Predict.fun positions."})})})]})}var eH=r(42501),eV=r(6143),eY=r(49031),eQ=r(31363),eZ=r(21245),e0=r(1839);let e1=e=>null==e||0===e?"—":new Date(1e3*e).toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"});function e4({isOpen:e,onClose:t}){let r=(0,a.useRef)(null),i=(0,o.useRouter)(),c=(0,a.useContext)(ee.v),{eoaAddress:d,ethersSigner:m}=(0,$.v)(),{derivedSafeAddressFromEoa:u}=(0,_.A)(d),{user:x,login:h,isLoading:p,error:f}=(0,eh.m)(m),g=c?.clobClient||null,y=c?.relayClient||null,b=c?.isTradingSessionComplete,w=c?.currentStep||"idle",N=c?.sessionError,j=c?.initializeTradingSession,{solanaAddress:v,source:k}=(0,em.d)(),{authenticated:S,user:C}=(0,n.u)(),{wallets:A}=(0,Y.u)(),{isAuthenticated:E}=(0,l.F)(),{signAndSendTransaction:I}=(0,Q.y2)(),{wallets:T,ready:F}=(0,Z.u)(),L="privy"===k&&v&&F?T.find(e=>{let t=e.address??e.accounts?.[0]?.address;return t?.toLowerCase()===v.toLowerCase()})??null:null,[D,B]=(0,a.useState)(!1),[R,P]=(0,a.useState)(null),[O,M]=(0,a.useState)("polymarket"),[K,z]=(0,a.useState)("trades"),[W,q]=(0,a.useState)(!0),[G,J]=(0,a.useState)(null),[X,eR]=(0,a.useState)(null),[eP,e$]=(0,a.useState)(null),[eO,e_]=(0,a.useState)(null),[eU,eM]=(0,a.useState)(null),[eK,ez]=(0,a.useState)(null),[eW,eq]=(0,a.useState)(null),[eG,eJ]=(0,a.useState)(null),[e4,e2]=(0,a.useState)(new Map),e3=(0,V.jE)(),e5=(0,a.useCallback)(async e=>{if("privy"===k&&L){let t=atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);let s=(await I({transaction:r,wallet:L,chain:"solana:mainnet",options:{uiOptions:{showWalletUIs:!0}}})).signature;
1if(!s||0===s.length)throw Error("No signature from Privy");return eH.A.encode(s)}let t=window.phantom?.solana;if(!t||"function"!=typeof t.signAndSendTransaction)throw Error("Phantom wallet not found. Please install Phantom or use Privy.");let r=atob(e),s=new Uint8Array(r.length);for(let e=0;e<r.length;e++)s[e]=r.charCodeAt(e);let a=eV.Kt.deserialize(s),i=await t.signAndSendTransaction(a,{skipPreflight:!1,maxRetries:3});return"object"==typeof i&&null!==i&&"signature"in i?i.signature:String(i)},[k,L,I]),e6=(0,a.useCallback)(async e=>{for(let t=0;t<30;t++){let t=await fetch(`/api/kalshi/dflow-order-status?signature=${encodeURIComponent(e)}`);if(!t.ok){await new Promise(e=>setTimeout(e,2e3));continue}let r=await t.json();if("closed"===r.status||"failed"===r.status||"expired"===r.status)return r;await new Promise(e=>setTimeout(e,2e3))}return{status:"pending"}},[]),e8=(0,a.useCallback)(e=>{let t=e.market?.status,r=e.redemptionStatus,s=e.market?.result??"";return("determined"===t||"finalized"===t)&&"open"===r&&("yes"===s&&"YES"===e.position||"no"===s&&"NO"===e.position||""===s&&null!=e.scalarOutcomePct&&void 0!==e.scalarOutcomePct&&("YES"===e.position||"NO"===e.position))},[]),e7=(0,a.useCallback)(async e=>{if(!v)return void(0,U.showErrorNotification)("Redeem","Connect your Solana wallet.");let t=parseInt(e.rawBalance,10);if(isNaN(t)||t<=0)return void(0,U.showErrorNotification)("Redeem","No balance to redeem.");eM(e.mint);try{let r=new URLSearchParams({userPublicKey:v,inputMint:e.mint,outputMint:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",amount:t.toString(),slippageBps:"100",predictionMarketSlippageBps:"100"}),s=await fetch(`/api/kalshi/dflow-order?${r.toString()}`),a=await s.json();if(!s.ok||a.code){let e=a.msg??a.error??"Failed to get redeem order";throw Error(e)}if(!a.transaction)throw Error("No transaction in order response.");let i=await e5(a.transaction),n=await e6(i);"closed"===n.status?((0,U.showSuccessNotification)("Redeem",`Redeemed successfully. Tx: ${i.slice(0,8)}...`),e3.invalidateQueries({queryKey:["dflow-positions",v]})):("failed"===n.status||"expired"===n.status)&&(0,U.showErrorNotification)("Redeem",`Order ${n.status}. Try again.`)}catch(t){let e=t instanceof Error?t.message:"Redeem failed.";(0,U.showErrorNotification)("Redeem",e)}finally{eM(null)}},[v,e3,e5,e6]),e9=(0,a.useCallback)(async e=>{if(!v)return void(0,U.showErrorNotification)("Reclaim rent","Connect your Solana wallet.");ez(e.tokenAccountAddress);try{let t=new eV.Ng("https://mainnet.helius-rpc.com/?api-key=67d144bc-41ee-47c4-b5c7-a260a6a87712","confirmed"),r=new eV.J3(e.tokenAccountAddress),s=new eV.J3(e.mint),a=new eV.J3(v),i=await (0,eY.sU)(t,r,"confirmed",eQ.sy),n=[];i.amount>BigInt(0)&&n.push((0,eZ.CE)(r,s,a,i.amount,[],eQ.sy)),n.push((0,e0.wy)(r,a,a,[],eQ.sy));let{blockhash:l,lastValidBlockHeight:o}=await t.getLatestBlockhash("confirmed"),c=new eV.wu({payerKey:a,recentBlockhash:l,instructions:n}).compileToV0Message(),d=new eV.Kt(c).serialize(),m="";for(let e=0;e<d.length;e++)m+=String.fromCharCode(d[e]);let u=btoa(m),x=await e5(u);(0,U.showSuccessNotification)("Reclaim rent",`Closed account. Rent reclaimed. Tx: ${x.slice(0,8)}...`),e3.invalidateQueries({queryKey:["dflow-positions",v]})}catch(t){let e=t instanceof Error?t.message:"Failed to close account.";(0,U.showErrorNotification)("Reclaim rent",e)}finally{ez(null)}},[v,e3,e5]),te=async(e,r)=>{if(e){P(e);try{let r=await fetch("/api/polymarket/markets?limit=100&active=true&closed=false&archived=false");if(r.ok){let s=(await r.json()).markets||[],a=null;for(let t of s){if(t.markets&&Array.isArray(t.markets)){for(let r of t.markets)if((r.conditionId||r.condition_id||r.ticker||r.id)===e){a=t;break}}if(a)break}if(a){let r=a.slug||a.ticker||a.event_ticker||e;t(),i.push(`/rexmarkets/polymarket/${r}`),setTimeout(()=>P(null),500);return}}if(g)try{let r=await g.getMarket(e);if(r?.eventId||r?.event_id){let s=r.slug||r.ticker||r.eventTicker||e;t(),i.push(`/rexmarkets/polymarket/${s}`),setTimeout(()=>P(null),500);return}}catch(e){console.warn("getMarket failed:",e)}console.warn("Could not find event for condition ID, using as fallback:",e),t(),i.push(`/rexmarkets/polymarket/${e}`),setTimeout(()=>P(null),500)}catch(r){console.error("Error searching for event:",r),t(),i.push(`/rexmarkets/polymarket/${e}`),setTimeout(()=>P(null),500)}}},{data:tt=[],isLoading:tr,error:ts,refetch:ta}=(0,et.A)(g,u,50),{data:ti,isLoading:tn,error:tl,refetch:to}=function({ticker:e,limit:t=50,cursor:r,enabled:s=!0}={}){return(0,er.I)({queryKey:["kalshi-fills",e,t,r],queryFn:async()=>{let s=new URLSearchParams;e&&s.set("ticker",e),s.set("limit",String(t)),r&&s.set("cursor",r);let a=await fetch(`/api/kalshi/fills?${s.toString()}`,{method:"GET",headers:{"Content-Type":"application/json"},cache:"no-store"});if(!a.ok){let e=await a.text();throw console.error("Kalshi fills fetch error:",e),Error(`Failed to fetch fills: ${a.status} ${e}`)}let i=await a.json();return{fills:i.fills??[],cursor:i.cursor}},enabled:s,staleTime:5e3,refetchInterval:1e4,refetchIntervalInBackgroun
1d:!0,refetchOnWindowFocus:!0})}({limit:50,enabled:e&&"kalshi"===O}),tc=ti?.fills??[],{data:td,isLoading:tm,error:tu}=(0,ex.x)({limit:50,enabled:e&&"limitless"===O}),tx=td?.trades??[],{data:th=[],isLoading:tp,error:tf}=(0,ex.g)({enabled:e&&"limitless"===O}),tg=e&&"myriad"===O,{data:ty=[],isLoading:tb,error:tw,refetch:tN}=(0,er.I)({queryKey:["myriad-orders-history",d,eN.KV],enabled:!!(tg&&d),queryFn:async()=>{let e=new URLSearchParams({trader:d,network_id:String(eN.KV),limit:"100",offset:"0"}),t=await fetch(`/api/myriad/orders?${e.toString()}`,{cache:"no-store"}),r=await t.json().catch(()=>({}));if(!t.ok)throw Error("string"==typeof r?.error?r.error:`HTTP ${t.status}`);return function(e){if(!e||"object"!=typeof e)return[];let t=Array.isArray(e.data)?e.data:Array.isArray(e)?e:[],r=[];for(let e of t){if(!e||"object"!=typeof e)continue;let t=e.order&&"object"==typeof e.order?e.order:e,s="string"==typeof e.orderHash?e.orderHash:"string"==typeof e.hash?e.hash:"";if(!s.startsWith("0x"))continue;let a=eS(t.marketId);if(!Number.isFinite(a))continue;let i="number"==typeof t.outcomeId?t.outcomeId:Number(t.outcomeId),n=+(1===t.side||"1"===t.side);r.push({orderHash:s,marketId:a,outcomeId:Number.isFinite(i)?Math.trunc(i):0,side:n,priceWei:ek(t.price),amountWei:ek(t.amount),filledAmountWei:ek(e.filledAmount),status:"string"==typeof e.status?e.status:"unknown",createdAt:"string"==typeof e.createdAt?e.createdAt:void 0,filledAt:null===e.filledAt?null:"string"==typeof e.filledAt?e.filledAt:void 0,timeInForce:"string"==typeof e.timeInForce?e.timeInForce:void 0})}return r}(r)},staleTime:15e3,refetchInterval:3e4}),{data:tj=[],isLoading:tv,error:tk,refetch:tS}=(0,er.I)({queryKey:["myriad-user-events",d,eN.KV],enabled:!!(tg&&d),queryFn:async()=>{let e=new URLSearchParams({address:d.toLowerCase(),network_id:String(eN.KV),limit:"100",page:"1"}),t=await fetch(`/api/myriad/user-events?${e.toString()}`,{cache:"no-store"}),r=await t.json().catch(()=>({}));if(!t.ok)throw Error("string"==typeof r?.error?r.error:`HTTP ${t.status}`);return function(e){if(!e||"object"!=typeof e)return[];let t=Array.isArray(e.data)?e.data:[],r=[];for(let e of t){if(!e||"object"!=typeof e)continue;let t="string"==typeof e.action?e.action:"";if(!t)continue;let s=eS(e.marketId??e.market_id);if(!Number.isFinite(s))continue;let a=eS(e.networkId??e.network_id),i=Number.isFinite(a)?a:0,n=e.outcomeId??e.outcome_id,l="number"==typeof n&&Number.isFinite(n)?Math.trunc(n):"string"==typeof n?parseInt(n,10):0;r.push({action:t,marketTitle:String(e.marketTitle??e.market_title??"").trim(),marketSlug:String(e.marketSlug??e.market_slug??"").trim(),marketId:s,networkId:i,outcomeTitle:String(e.outcomeTitle??e.outcome_title??"").trim(),outcomeId:Number.isFinite(l)?l:0,shares:eC(e.shares),value:eC(e.value),timestamp:eA(e.timestamp),blockNumber:eA(e.blockNumber??e.block_number)})}return r}(r)},staleTime:15e3,refetchInterval:3e4}),{data:tC=[],isLoading:tA,error:tE,refetch:tI}=(0,er.I)({queryKey:["myriad-user-markets-modal",d,eN.KV],enabled:!!(tg&&d),queryFn:async()=>{let e=new URLSearchParams({address:d,network_id:String(eN.KV),trading_model:"all",limit:"100",page:"1"}),t=await fetch(`/api/myriad/user-markets?${e.toString()}`,{cache:"no-store"}),r=await t.json().catch(()=>({}));if(!t.ok)throw Error("string"==typeof r?.error?r.error:`HTTP ${t.status}`);let s=eE(r);if(0===s.length){let e=new URLSearchParams({address:d,network_id:String(eN.KV),limit:"100",page:"1"}),t=await fetch(`/api/myriad/user-portfolio?${e.toString()}`,{cache:"no-store"}),r=await t.json().catch(()=>({}));t.ok&&(s=eE(r))}return s},staleTime:15e3,refetchInterval:35e3}),tT=(0,a.useMemo)(()=>{let e=new Map;for(let t of tC)e.set(t.marketId,{slug:t.slug,title:t.title});return e},[tC]),tF=(0,a.useMemo)(()=>tC.filter(e=>e.yesShares>.01||e.noShares>.01),[tC]),tL=(0,a.useMemo)(()=>[...ty].sort((e,t)=>{let r=e.createdAt?Date.parse(e.createdAt):0;return(t.createdAt?Date.parse(t.createdAt):0)-r}),[ty]),tD=(0,a.useMemo)(()=>[...tj].sort((e,t)=>t.timestamp-e.timestamp),[tj]),tB=(0,a.useMemo)(()=>{let e=e=>1===e?"No":"Yes";return[...tD.map((t,r)=>{let s,a=t.marketSlug?.trim()||String(t.marketId),i=t.action.toLowerCase(),n="neutral";"buy"===i?(n="buy",s=`BUY ${e(t.outcomeId)}`):"sell"===i?(n="sell",s=`SELL ${e(t.outcomeId)}`):i.includes("claim")?(n="claim",s="CLAIM"):s=t.action.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ").toUpperCase();let l="—";("buy"===i||"sell"===i)&&t.shares>0&&t.value>0&&(l=(t.value/t.shares).toFixed(4));let o=t.shares>0?(0,eT.Ym)(t.shares):"—",c=t.timestamp>
10?new Date(1e3*t.timestamp).toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"}):"—";return{kind:"event",key:`e-${t.marketId}-${t.timestamp}-${t.blockNumber}-${r}`,marketTitle:t.marketTitle||`Market #${t.marketId}`,slugForLink:a,sideLabel:s,sideTone:n,priceDisplay:l,sizeDisplay:o,role:"TAKER",statusLabel:"CONFIRMED",statusStyle:"confirmed",timeStr:c,sortMs:t.timestamp>0?1e3*t.timestamp:0}}),...tL.map(t=>{let r,s=tT.get(t.marketId),a=s?.slug?.trim()||String(t.marketId),i=s?.title?.trim()||`Market #${t.marketId}`,n=`${0===t.side?"BUY":"SELL"} ${e(t.outcomeId)}`,l=(function(e){try{let t=BigInt(e);if(t<=BigInt(0))return 0;return Number(t)/Number(ev)}catch{return 0}})(t.priceWei).toFixed(4),o=t.status.toLowerCase(),c=(function(e,t=18){try{return Number((0,ej.J)(BigInt(e),t))}catch{return 0}})("filled"===o?t.filledAmountWei:t.amountWei).toFixed(2),d="TAKER";"open"===o?d="MAKER":("cancelled"===o||"canceled"===o||"expired"===o)&&(d="—");let m=t.status.toUpperCase(),u="muted";"filled"===o?(m="FILLED",u="confirmed"):"open"===o?(m="OPEN",u="open"):"cancelled"===o||"canceled"===o?u="cancelled":"expired"===o&&(u="expired");let x=t.createdAt?Number.isNaN((r=new Date(t.createdAt)).getTime())?t.createdAt:r.toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"}):"—",h=t.createdAt?Date.parse(t.createdAt):0;return{kind:"order",key:`o-${t.orderHash}`,marketTitle:i,slugForLink:a,sideLabel:n,isBuySide:0===t.side,priceDisplay:l,sizeDisplay:c,role:d,statusLabel:m,statusStyle:u,timeStr:x,sortMs:h}})].sort((e,t)=>t.sortMs-e.sortMs)},[tD,tL,tT]),{data:tR=[],isLoading:tP,error:t$}=(0,ea.A)(u),{data:tO,isLoading:t_,error:tU}=(0,eu.I)(v),tM=tO?.positions??[],tK=tO?.emptyOutcomeAccounts??[],{redeemPosition:tz,isRedeeming:tW}=function(){let[e,t]=(0,a.useState)(!1),[r,s]=(0,a.useState)(null);return{isRedeeming:e,error:r,redeemPosition:(0,a.useCallback)(async(e,r)=>{t(!0),s(null);try{let t=(e=>{let{conditionId:t,outcomeIndex:r,negativeRisk:s=!1,size:a=0}=e;if(s){let e=BigInt(Math.floor(1e6*a)),s=[BigInt(0),BigInt(0)];s[r]=e;let i=(0,en.p)({abi:ec,functionName:"redeemPositions",args:[t,s]});return{to:el.g8,operation:ei.OperationType.Call,data:i,value:"0"}}let i="0x"+"0".repeat(64),n=BigInt(1<<r),l=(0,en.p)({abi:eo,functionName:"redeemPositions",args:[el.Gi,i,t,[n]]});
1return{to:el.OG,operation:ei.OperationType.Call,data:l,value:"0"}})(r),s=await e.execute([t],`Redeem position for condition ${r.conditionId}`);return await s.wait(),!0}catch(t){let e=t instanceof Error?t:Error("Failed to redeem position");throw s(e),console.error("Redeem error:",e),e}finally{t(!1)}},[])}}(),{submitOrder:tq,isSubmitting:tG}=(0,ed.A)(g,d),{redeem:tJ,isRedeeming:tX}=function(){let{wallets:e}=(0,Y.u)(),[t,r]=(0,a.useState)(!1);return{redeem:(0,a.useCallback)(async(t,s)=>{var a;let i;if(!s?.trim())throw Error("Market slug is required to claim winnings.");let n=await fetch(`/api/limitless/market-details?slug=${encodeURIComponent(s.trim())}`,{cache:"no-store"});if(!n.ok){let e=(await n.json()).error??n.statusText;throw Error(`Failed to load market: ${e}`)}let l=(await n.json()).conditionId;if(null==l||""===String(l).trim())throw Error("This market does not expose a condition ID for redemption. Please try again later or contact support.");let o=el.qI,c=(i=(a=String(l).trim()).startsWith("0x")?a.slice(2):a).length>64?`0x${i.slice(-64)}`:i.length<64?`0x${i.padStart(64,"0")}`:`0x${i}`,d=t.toLowerCase(),m=e?.find(e=>e.address.toLowerCase()===d);if(!m)throw Error("Wallet not found. Please connect your wallet.");let u=await m.getEthereumProvider?.();if(!u)throw Error("Could not get wallet provider.");let x=m.chainId;x!==eg.E.id&&x!==`eip155:${eg.E.id}`&&x!==String(eg.E.id)&&"function"==typeof m.switchChain&&await m.switchChain(eg.E.id);let h=(0,ep.F)({account:t,chain:eg.E,transport:(0,ef.I)(u)});r(!0);try{return{hash:await h.sendTransaction({to:o,data:(0,en.p)({abi:ey,functionName:"redeemPositions",args:[el.JF,eb,c,[...ew]]})})}}catch(t){let e=t instanceof Error?t.message:String(t);if(/result for condition not received yet|result not received/i.test(e))throw Error("The market result has not been reported on-chain yet. Claim will be available shortly after the market resolves. Please try again in a few minutes.");throw t}finally{r(!1)}},[e]),isRedeeming:t}}(),tH=(0,a.useCallback)(async e=>{if(!d)return void(0,U.showErrorNotification)("Claim","Connect your EVM wallet.");if(!m)return void(0,U.showErrorNotification)("Claim","Wallet signer not ready.");eJ(e);try{let t,r=A.find(e=>e.address===C?.wallet?.address);if(r){let e=r.chainId;e!==`eip155:${eN.KV}`&&e!==String(eN.KV)&&(await r.switchChain(eN.KV),await new Promise(e=>setTimeout(e,400)))}let s=eI.T,a=BigInt(0),i=await fetch("/api/myriad/markets/claim",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({market_id:e,network_id:eN.KV})}),n=await i.json();if(i.ok&&"string"==typeof n.calldata&&n.calldata.startsWith("0x"))t=n.calldata,"string"==typeof n.to&&n.to.startsWith("0x")&&(s=n.to);else{let r=await fetch("/api/myriad/positions/redeem",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({market_id:e,network_id:eN.KV})}),i=await r.json();if(!r.ok)throw Error(n.error||i.error||"Claim failed (resolved markets use POST /markets/claim)");if(!i.to||!i.calldata||!i.to.startsWith("0x"))throw Error("Invalid redeem calldata from API");s=i.to,t=i.calldata,a=void 0!==i.value&&null!==i.value&&""!==i.value?BigInt(String(i.value)):BigInt(0)}if(!t?.startsWith("0x"))throw Error("No calldata returned for claim");let l=await m.sendTransaction({to:s,data:t,value:a});(0,U.showSuccessNotification)("Myriad claim","Transaction submitted"),await l.wait(1).catch(()=>{}),e3.invalidateQueries({queryKey:["myriad-user-markets-modal"]}),e3.invalidateQueries({queryKey:["myriad-orders-history"]}),e3.invalidateQueries({queryKey:["myriad-user-events"]}),e3.invalidateQueries({queryKey:["myriad-user-portfolio"]}),e3.invalidateQueries({queryKey:["myriad-erc20-balance"]})}catch(t){let e=t instanceof Error?t.message:"Claim failed";(0,U.showErrorNotification)("Myriad claim",e)}finally{eJ(null)}},[d,m,A,C?.wallet?.address,e3]),tV=(0,a.useMemo)(()=>[...new Set(tt.map(e=>e.market).filter(Boolean))],[tt]),{data:tY=new Map}=(0,er.I)({queryKey:["market-titles",tV.sort().join(",")],queryFn:async()=>{if(!g||0===tV.length)return new Map;let e=new Map;return await Promise.allSettled(tV.map(async t=>{if(es.has(t)){let r=es.get(t);r&&e.set(t,r);return}try{let r=await g.getMarket(t),s=r?.question||r?.groupItemTitle||r?.subtitle||r?.title||null;s&&(es.set(t,s),e.set(t,s))}catch(e){console.warn(`Failed to fetch market title for ${t}:`,e)}})),e},enabled:!!g&&tV.length>0,staleTime:3e5}),tQ=(0,a.useMemo)(()=>tt.map(e=>({...e,marketTitle:tY.get(e.market)||e.market||"Unknown Market"})),[tt,tY]),tZ=(0,a.useMemo)(()=>
1{if(!tR)return[];let e=tR.filter(e=>e.size>=eF.zB);return W&&(e=e.filter(e=>e.currentValue>=eF.zB)),e},[tR,W]);(0,a.useEffect)(()=>{if(!tR||0===e4.size)return;let e=new Map;e4.forEach((t,r)=>{let s=tR.find(e=>e.asset===r);(s?.size||0)<t||e.set(r,t)}),e.size!==e4.size&&e2(e)},[tR,e4]);let t0=e=>{var t;let r,s="An unexpected error occurred";return e instanceof Error?s=e.message:"string"==typeof e?s=e:e&&"object"==typeof e&&(e.message?s=e.message:e.error?s="string"==typeof e.error?e.error:JSON.stringify(e.error):e.response?.data?.error?s="string"==typeof e.response.data.error?e.response.data.error:JSON.stringify(e.response.data.error):e.response?.data?.message&&(s=e.response.data.message)),(r=(r=(r=(r=(t=s).charAt(0).toUpperCase()+t.slice(1)).replace(/not enough balance \/ allowance/gi,"Not enough balance or allowance")).replace(/not enough balance\/allowance/gi,"Not enough balance or allowance")).replace(/not enough balance or allowance/gi,"Not enough balance or allowance"))&&!r.match(/[.!?]$/)&&(r+="."),r},t1=async e=>{eR(e.asset),e$(null);try{await tq({tokenId:e.asset,size:e.size,side:"SELL",negRisk:e.negativeRisk,isMarketOrder:!0}),e$(e.asset),eR(null),(0,U.showSuccessNotification)("Sell Order","Transaction Success"),e2(t=>new Map(t).set(e.asset,e.size)),e3.invalidateQueries({queryKey:["polymarket-positions"]}),eD(()=>{e3.invalidateQueries({queryKey:["polymarket-positions"]})},eL.es,eL.nB),setTimeout(()=>{e2(t=>{let r=new Map(t);return r.delete(e.asset),r})},eL.nB),setTimeout(()=>{e$(null)},3e3)}catch(t){console.error("Failed to sell position:",t);let e=t0(t);(0,U.showErrorNotification)("Sell Order",e),eR(null),e$(null)}},t4=(0,a.useCallback)(async e=>{if(!d)return void(0,U.showErrorNotification)("Claim","Connect your wallet to claim winnings.");if(e&&"—"!==e){eq(e);try{let{hash:t}=await tJ(d,e);(0,U.showSuccessNotification)("Claim winnings",`Success. Tx: ${t.slice(0,10)}...`),e3.invalidateQueries({queryKey:["limitless-portfolio-positions"]}),e3.invalidateQueries({queryKey:["baseBalance",d]})}catch(r){let e=r instanceof Error?r.message:"Failed to claim winnings.",t=/rejected the request|user denied|user rejected|request was rejected/i.test(e)?"User rejected the request.":e;(0,U.showErrorNotification)("Claim",t)}finally{eq(null)}}},[d,tJ,e3]),t2=async e=>{if(!y)return void(0,U.showErrorNotification)("Redeem Failed","Relay client not initialized");J(e.asset),e_(null);try{await tz(y,{conditionId:e.conditionId,outcomeIndex:e.outcomeIndex,negativeRisk:e.negativeRisk,size:e.size}),e_(e.asset),J(null),(0,U.showSuccessNotification)("Redeem Position","Transaction Success"),e3.invalidateQueries({queryKey:["polymarket-positions"]}),e3.invalidateQueries({queryKey:["polygon-balances"]}),eD(()=>{e3.invalidateQueries({queryKey:["polymarket-positions"]}),e3.invalidateQueries({queryKey:["polygon-balances"]})},eL.es,eL.nB),setTimeout(()=>{e_(null)},3e3)}catch(t){console.error("Failed to redeem position:",t);let e=t0(t);(0,U.showErrorNotification)("Redeem Position Failed",e),J(null),e_(null)}};return((0,a.useEffect)(()=>{e&&"polymarket"===O&&g&&u&&"trades"===K&&ta(),e&&"kalshi"===O&&"trades"===K&&to(),e&&"myriad"===O&&(tN(),tS(),tI())},[e,O,g,u,ta,to,tN,tS,tI,K]),(0,a.useEffect)(()=>{let s=e=>{r.current&&!r.current.contains(e.target)&&t()};if(e)return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[e,t]),(0,a.useEffect)(()=>{let r=r=>{"Escape"===r.key&&e&&t()};if(e)return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[e,t]),e)?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/50 z-40",onClick:t}),(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center z-50 pointer-events-none",children:(0,s.jsxs)("div",{ref:r,className:"w-[90%] max-w-4xl bg-[#0D0D0D] rounded-xl shadow-2xl border border-white/10 pointer-events-auto max-h-[85vh] overflow-y-auto custom-sidebar-scrollbar",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between p-4 sm:p-6 border-b border-white/10 sticky top-0 bg-[#0D0D0D] z-10",children:[(0,s.jsx)("h2",{className:"text-xl sm:text-2xl font-bold text-white",children:"Open Orders"}),(0,s.jsx)("button",{onClick:t,className:"p-2 hover:bg-gray-800 rounded-lg transition text-gray-400 hover:text-white","aria-label":"Close modal",children:(0,s.jsx)(H.A,{className:"w-5 h-5 sm:w-6 sm:h-6"})})]}),(0,s.jsxs)("div",{className:"grid grid-cols-5 border-b border-white/10 sticky top-[73px] bg-[#0D0D0D] z-10 px-4 sm:px-6",children:[(0,s.jsx)("button",{type:"button",onClick:()=>M("polymarket"),className:`px-1 sm:px-2 py-3 text-[10px] sm:text-sm font-medium transition-colors border-b-2 text-center ${"polymarket"===O?"border-[#2C59F7] text-[#2C59F7]":"border-transparent text-gray-400 hover:text-white"}`,children:"Polymarket"}),(0,s.jsx)("button",{type:"button",onClick:()=>{M("kalshi"),z("trades")},className:`px-1 sm:px-2 py-3 text-[10px] sm:text-sm font-medium transition-colors border-b-2 text-center ${"kalshi"===O?"border-[#17cb91] text-[#17cb91]":"border-transparent text-gray-400 hover:text-white"}`,children:"Kalshi"}),(0,s.jsx)("button",{type:"button",onClick:()=>{M("limitless"),z("trades")},className:`px-1 sm:px-2 py-3 text-[10px] sm:text-sm font-medium transition-colors border-b-2 text-center ${"limitless"===O?"border-white text-white":"border-transparent text-gray-400 hover:text-white"}`,children:"Limitless"}),(0,s.jsx)("button",{type:"button",onClick:()=>{M("myriad"),z("trades")},className:`px-1 sm:px-2 py-3 text-[10px] sm:text-sm font-medium transition-colors border-b-2 text-center ${"myriad"===O?"border-[#ffc000] text-[#ffc000]":"border-transparent text-gray-400 hover:text-white"}`,children:"Myriad"}),(0,s.jsxs)("button",{type:"button",onClick:()=>{M("predictfun"),z("trades")},className:`px-1 sm:px-2 py-3 text-[10px] sm:text-sm font-medium transition-colors border-b-2 text-center leading-tight ${"predictfun"===O?"border-[#A855F7] text-[#A855F7]":"border-transparent text-gray-400 hover:text-white"}`,children:[(0,s.jsx)("span",{className:"sm:hidden",children:"Predict"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"Predict.fun"})]})]}),(0,s.jsx)("div",{className:"p-4 sm:p-6",children:"kalshi"===O?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex border-b border-white/10 sticky top-[73px] bg-[#0D0D0D] z-10 -mx-4 sm:-mx-6 px-4 sm:px-6 mb-0",children:[(0,s.jsx)("button",{onClick:()=>z("trades"),className:`flex-1 px-4 py-3 text-sm font-medium transition-colors border-b-2 ${"trades"===K?"border-[#17cb91] text-[#17cb91]":"border-transparent text-gray-400 hover:text-white"}`,children:"Trades"}),(0,s.jsx)("button",{onClick:()=>z("positions"),className:`flex-1 px-4 py-3 text-sm font-medium transition-colors border-b-2 ${"positions"===K?"border-[#17cb91] text-[#17cb91]":"border-transparent text-gray-400 hover:text-white"}`,children:"Positions"})]}),"kalshi"===O&&"trades"===K&&(0,s.jsx)(s.Fragment,{children:tn?(0,s.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,s.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-[#17cb91]"})}):tl?(0,s.jsx)("div",{className:"text-center py-8",children:(0,s.jsx)("p",{className:"text-red-400",children:"Failed to load trade history. Please try again later."})}):0===tc.length?(0,s.jsx)("div",{className:"text-center py-12",children:(0,s.jsx)("p",{className:"text-gray-400 text-lg",children:"No trades found."})}):(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full border-collapse",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"border-b border-white/10",children:[(0,s.jsxs)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:["Market"," ",(0,s.jsx)("span",{className:"text-gray-500 text-xs font-normal",children:"(Click to view)"})]}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Side"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Price"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Size"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Role"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Time"})]})}),(0,s.jsx)("tbody",{children:tc.map(e=>{var r;let a="buy"===e.action?`BUY ${(e.side??"").toUpperCase()}`:`SELL ${(e.side??"").toUpperCase()}`,n=e.is_taker?"TAKER":"MAKER",l=e.ticker??"—";return(0,s.jsxs)("tr",{className:"border-b border-white/5 hover:bg-white/5 transition-colors",children:[(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:"—"!==l?(0,s.jsx)("a",{href:`/rexmarkets/kalshi/${encodeURIComponent(l)}`,onClick:e=>{e.preventDefault(),t(),i.push(`/rexmarkets/kalshi/${encodeURIComponent(l)}`)},className:"max-w-[200px] truncate block text-left hover:text-[#17cb91] transition-colors cursor-pointer underline decoration-dotted underline-offset-2 hover:
1decoration-solid",title:`View ${l} on RexMarkets`,children:l}):l}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:(0,s.jsx)("span",{className:`inline-block px-2 py-1 rounded text-xs font-medium ${"buy"===e.action?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:a})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:null==(r=e.price)||"number"!=typeof r?"—":(r>1?r/100:r).toFixed(4)}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:(e.count??0).toLocaleString(void 0,{maximumFractionDigits:4})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:(0,s.jsx)("span",{className:"inline-block px-2 py-1 rounded text-xs font-medium bg-blue-500/20 text-blue-400",children:n})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-gray-400 text-xs",children:(e=>{if(!e)return"—";let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"})})(e.created_time)})]},e.fill_id??e.order_id??String(Math.random()))})})]})})}),"kalshi"===O&&"positions"===K&&(0,s.jsxs)(s.Fragment,{children:[v?t_?(0,s.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,s.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-[#17cb91]"})}):tU?(0,s.jsx)("div",{className:"text-center py-8",children:(0,s.jsx)("p",{className:"text-red-400",children:"Failed to load Kalshi positions. Please try again later."})}):0===tM.length?(0,s.jsx)("div",{className:"text-center py-12",children:(0,s.jsx)("p",{className:"text-gray-400 text-lg",children:"No Kalshi positions found."})}):(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full border-collapse",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"border-b border-white/10",children:[(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Market"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Outcome"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Balance"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Redemption"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Open"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Close"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Status"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Redeem"})]})}),(0,s.jsx)("tbody",{children:tM.map(e=>{let t=e.market?.eventTicker,r=e.market?.title??e.market?.question??t??"—",a=t?`/rexmarkets/kalshi/${encodeURIComponent(t)}`:null,i=e8(e),n=eU===e.mint;return(0,s.jsxs)("tr",{className:"border-b border-white/5 hover:bg-white/5 transition-colors",children:[(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:a?(0,s.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"max-w-[220px] block truncate hover:text-[#17cb91] transition-colors underline decoration-dotted underline-offset-2",title:`Open ${r} in new tab`,children:r}):r}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:(0,s.jsx)("span",{className:`inline-block px-2 py-1 rounded text-xs font-medium ${"YES"===e.position?"bg-green-500/20 text-green-400":"NO"===e.position?"bg-red-500/20 text-red-400":"bg-gray-500/20 text-gray-400"}`,children:e.position})}),(0,s.jsxs)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:[e.balance.toLocaleString(void 0,{maximumFractionDigits:4})," ","shares"]}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-gray-300 text-xs sm:text-sm",children:e.redemptionStatus??"—"}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-gray-300 text-xs sm:text-sm whitespace-nowrap",children:e1(e.market?.openTime)}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-gray-300 text-xs sm:text-sm whitespace-nowrap",children:e1(e.market?.closeTime)}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:(0,s.jsx)("span",{className:"inline-block px-2 py-1 rounded text-xs font-medium bg-white/10 text-gray-300",children:e.market?.status??"—"})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:i?(0,s.jsx)("button",{type:"button",onClick:()=>e7(e),disabled:n,className:`min-w-[80px] px-3 py-1.5 rounded text-xs font-medium transition-colors ${n?"bg-yellow-600/70 cursor-wait text-white":"bg-[#17cb91] hover:bg-[#14b87d] text-black disabled:opacity-50 disabled:cursor-not-allowed"}`,children:n?(0,s.jsxs)("span",{className:"flex items-center gap-1.5 justify-center",children:[(0,s.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-black/30 border-t-black rounded-full animate-spin"}),"Redeeming..."]}):"Redeem"}):(0,s.jsx)("span",{className:"text-gray-500 text-xs",children:"Not Yet"})})]},e.mint)})})]})}):(0,s.jsx)("div",{className:"text-center py-12",children:(0,s.jsx)("p",{className:"text-gray-400",children:"Connect your Solana wallet to view Kalshi positions."})}),tK.length>0&&v&&!t_&&!tU&&(0,s.jsxs)("div",{className:"mt-6 pt-6 border-t border-white/10",children:[(0,s.jsx)("h3",{className:"text-sm font-medium text-gray-300 mb-2",children:"Reclaim rent from closed positions"}),(0,s.jsx)("p",{className:"text-xs text-gray-500 mb-3",children:"Empty outcome token accounts can be closed to reclaim SOL rent."}),(0,s.jsx)("div",{className:"space-y-2",children:tK.map(e=>{let t=eK===e.tokenAccountAddress;return(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3 py-2 px-3 rounded-lg bg-white/5",children:[(0,s.jsxs)("span",{className:"text-gray-400 text-xs font-mono truncate max-w-[200px] sm:max-w-[320px]",title:e.tokenAccountAddress,children:[e.tokenAccountAddress.slice(0,8),"...",e.tokenAccountAddress.slice(-6)]}),(0,s.jsx)("button",{type:"button",onClick:()=>e9(e),disabled:t,className:"shrink-0 px-3 py-1.5 rounded text-xs font-medium bg-[#17cb91] hover:bg-[#14b87d] text-black disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:t?(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-black/30 border-t-black rounded-full animate-spin"}),"Closing..."]}):"Reclaim rent"})]},e.tokenAccountAddress)})})]})]})]}):"limitless"===O?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex border-b border-white/10 sticky top-[73px] bg-[#0D0D0D] z-10 -mx-4 sm:-mx-6 px-4 sm:px-6 mb-0",children:[(0,s.jsx)("button",{onClick:()=>z("trades"),className:`flex-1 px-4 py-3 text-sm font-medium transition-colors border-b-2 ${"trades"===K?"border-[#ffc000] text-[#ffc000]":"border-transparent text-gray-400 hover:text-white"}`,children:"Trades"}),(0,s.jsx)("button",{onClick:()=>z("positions"),className:`flex-1 px-4 py-3 text-sm font-medium transition-colors border-b-2 ${"positions"===K?"border-[#ffc000] text-[#ffc000]":"border-transparent text-gray-400 hover:text-white"}`,children:"Positions"})]}),"limitless"===O&&"trades"===K&&(0,s.jsx)(s.Fragment,{children:x?.sessionCookie?tm?(0,s.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,s.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-[#ffc000]"})}):tu?(0,s.jsx)("div",{className:"text-center py-8",children:(0,s.jsx)("p",{className:"text-red-400",children:"Failed to load Limitless trades. Please try again."})}):0===tx.length?(0,s.jsx)("div",{className:"text-center py-12",children:(0,s.jsx)("p",{className:"text-gray-400 text-lg",children:"No trades found."})}):(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full border-collapse",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"border-b border-white/10",children:[(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Market"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Side"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Action"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Price"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Size"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Amount"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Time"})]})}),(0,s.jsx)("tbody",{children:tx.map((e,r)=>{let a,n=e.marketSlug??e.market??"—",l=e.market??e.marketSlug??"—",o=(e.side??e.outcome??"—").toString(),c=e.action??e.strategy??"—",d=c.toLowerCase(),m=null!=e.price?String(e.price):"—",u=e.size??"—",x=e.amount,h=null!=x&&""!==x?Number.isFinite(a="string"==typeof x?parseFloat(x):Number(x))?`$${a.toFixed(2)}`:String(x):"—",p=e.timestamp??e.createdAt,f=null!=p?(()=>{let e=("string"==typeof p&&/^\d+$/.test(p),Number(p));
1if(Number.isFinite(e))return new Date(1e3*e).toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"});let t=new Date("string"==typeof p?p:1e3*Number(p));return Number.isNaN(t.getTime())?"—":t.toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"})})():"—";return(0,s.jsxs)("tr",{className:"border-b border-white/5 hover:bg-white/5",children:[(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:"—"!==n?(0,s.jsx)("a",{href:`/rexmarkets/limitless/${encodeURIComponent(n)}`,onClick:e=>{e.preventDefault(),t(),i.push(`/rexmarkets/limitless/${encodeURIComponent(n)}`)},className:"max-w-[200px] truncate block hover:text-[#ffc000] transition-colors underline decoration-dotted",title:l,children:l}):l}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:(0,s.jsx)("span",{className:"inline-block px-2 py-1 rounded text-xs font-medium bg-white/10 text-white",children:o})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:(0,s.jsx)("span",{className:`inline-block px-2 py-1 rounded text-xs font-medium ${"won"===d?"bg-green-500/20 text-green-300":"lose"===d||"lost"===d?"bg-red-500/20 text-red-300":"bg-white/10 text-white/90"}`,children:c})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:m}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",title:"Outcome tokens (shares) bought or sold",children:String(u)}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",title:"USDC spent or received (after fees)",children:h}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-gray-400 text-xs",children:f})]},e.id??`limitless-trade-${r}`)})})]})}):(0,s.jsxs)("div",{className:"text-center py-12 space-y-4",children:[(0,s.jsx)("p",{className:"text-gray-400",children:"Sign in to Limitless to view your trade history."}),d?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",onClick:async()=>{await h()&&(e3.invalidateQueries({queryKey:["limitless-portfolio-trades"]}),e3.invalidateQueries({queryKey:["limitless-portfolio-positions"]}))},disabled:p||!m,className:"px-6 py-3 rounded-lg font-semibold text-black bg-[#ffc000] hover:bg-[#ffd000] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:p?(0,s.jsxs)("span",{className:"flex items-center justify-center gap-2",children:[(0,s.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-black/30 border-t-black rounded-full animate-spin"}),"Signing in..."]}):"Sign in to Limitless"}),f&&(0,s.jsx)("p",{className:"text-sm text-red-400",children:f.message})]}):(0,s.jsx)("p",{className:"text-sm text-amber-400",children:"Connect your wallet first to sign in to Limitless."})]})}),"limitless"===O&&"positions"===K&&(0,s.jsx)(s.Fragment,{children:x?.sessionCookie?tp?(0,s.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,s.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-[#ffc000]"})}):tf?(0,s.jsx)("div",{className:"text-center py-8",children:(0,s.jsx)("p",{className:"text-red-400",children:"Failed to load Limitless positions. Please try again."})}):0===th.length?(0,s.jsx)("div",{className:"text-center py-12",children:(0,s.jsx)("p",{className:"text-gray-400 text-lg",children:"No positions found."})}):(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full border-collapse",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"border-b border-white/10",children:[(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Market"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Outcome"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Size"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Closed"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Expiration"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Claim"})]})}),(0,s.jsx)("tbody",{children:th.map((e,r)=>{let a,n=e.marketSlug??e.market??"—",l=e.market??e.marketSlug??"—",o=(e.outcome??"—").toString(),c=e.size??e.balance??"—",m=!0===e.marketClosed?"Yes":!1===e.marketClosed?"No":"—",u=e.expirationDate,x=null!=u&&""!==u?(a="string"==typeof u?new Date(u):null)&&!Number.isNaN(a.getTime())?a.toLocaleStr
1ing(void 0,{dateStyle:"short",timeStyle:"short"}):String(u):"—",h="Yes"===m&&"—"!==n&&!!d,p=eW===n||tX;return(0,s.jsxs)("tr",{className:"border-b border-white/5 hover:bg-white/5",children:[(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:"—"!==n?(0,s.jsx)("a",{href:`/rexmarkets/limitless/${encodeURIComponent(n)}`,onClick:e=>{e.preventDefault(),t(),i.push(`/rexmarkets/limitless/${encodeURIComponent(n)}`)},className:"max-w-[200px] truncate block hover:text-[#ffc000] transition-colors underline decoration-dotted",title:l,children:l}):l}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:(0,s.jsx)("span",{className:"inline-block px-2 py-1 rounded text-xs font-medium bg-white/10 text-white",children:o})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:String(c)}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white/80 text-xs sm:text-sm",children:m}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white/80 text-xs sm:text-sm",children:x}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:h?(0,s.jsx)("button",{type:"button",onClick:()=>t4(n),disabled:p,className:`min-w-[80px] px-3 py-1.5 rounded text-xs font-medium transition-colors ${p?"bg-amber-600/70 cursor-wait text-white":"bg-[#ffc000] hover:bg-[#ffd000] text-black disabled:opacity-50 disabled:cursor-not-allowed"}`,children:p?(0,s.jsxs)("span",{className:"flex items-center gap-1.5 justify-center",children:[(0,s.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-black/30 border-t-black rounded-full animate-spin"}),"Claiming..."]}):"Claim"}):(0,s.jsx)("span",{className:"text-gray-500 text-xs",children:"—"})})]},e.id??e.tokenId??`limitless-pos-${r}`)})})]})}):(0,s.jsxs)("div",{className:"text-center py-12 space-y-4",children:[(0,s.jsx)("p",{className:"text-gray-400",children:"Sign in to Limitless to view your positions."}),d?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",onClick:async()=>{await h()&&(e3.invalidateQueries({queryKey:["limitless-portfolio-trades"]}),e3.invalidateQueries({queryKey:["limitless-portfolio-positions"]}))},disabled:p||!m,className:"px-6 py-3 rounded-lg font-semibold text-black bg-[#ffc000] hover:bg-[#ffd000] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:p?(0,s.jsxs)("span",{className:"flex items-center justify-center gap-2",children:[(0,s.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-black/30 border-t-black rounded-full animate-spin"}),"Signing in..."]}):"Sign in to Limitless"}),f&&(0,s.jsx)("p",{className:"text-sm text-red-400",children:f.message})]}):(0,s.jsx)("p",{className:"text-sm text-amber-400",children:"Connect your wallet first to sign in to Limitless."})]})})]}):"myriad"===O?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex border-b border-white/10 sticky top-[73px] bg-[#0D0D0D] z-10 -mx-4 sm:-mx-6 px-4 sm:px-6 mb-0",children:[(0,s.jsx)("button",{type:"button",onClick:()=>z("trades"),className:`flex-1 px-4 py-3 text-sm font-medium transition-colors border-b-2 ${"trades"===K?"border-[#ffc000] text-[#ffc000]":"border-transparent text-gray-400 hover:text-white"}`,children:"Trades"}),(0,s.jsx)("button",{type:"button",onClick:()=>z("positions"),className:`flex-1 px-4 py-3 text-sm font-medium transition-colors border-b-2 ${"positions"===K?"border-[#ffc000] text-[#ffc000]":"border-transparent text-gray-400 hover:text-white"}`,children:"Positions"})]}),"trades"===K&&(0,s.jsx)(s.Fragment,{children:d?tb&&tv?(0,s.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,s.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-[#ffc000]"})}):tw&&tk?(0,s.jsx)("div",{className:"text-center py-8",children:(0,s.jsx)("p",{className:"text-red-400",children:tk instanceof Error?tk.message:tw instanceof Error?tw.message:"Failed to load Myriad data."})}):0===tD.length&&0===tL.length?(0,s.jsxs)("div",{className:"text-center py-12",children:[(0,s.jsx)("p",{className:"text-gray-400 text-lg",children:"No trades or activity yet."}),(0,s.jsxs)("p",{className:"text-gray-500 text-sm mt-2 max-w-md mx-auto",children:[(0,s.jsx)("span",{className:"text-white/70",children:"GET /users/…/events"})," lists AMM and other on-chain actions. ",(0,s.jsx)("span",{className:"text-white/70",children:"GET /orders"})," lists signed order-book orders (resting and filled)."]})]}):(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full border-collapse min-w-[720px]",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"border-b border-white/10",children:[(0,s.jsxs)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:["Market"," ",(0,s.jsx)("span",{className:"text-gray-500 text-xs font-normal",children:"(Click to view)"})]}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Side"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Price"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Size"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Role"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Status"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Time"})]})}),(0,s.jsx)("tbody",{children:tB.map(e=>{let r="order"===e.kind?e.isBuySide?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400":"buy"===e.sideTone?"bg-green-500/20 text-green-400":"sell"===e.sideTone?"bg-red-500/20 text-red-400":"claim"===e.sideTone?"bg-amber-500/20 text-amber-300":"bg-gray-500/20 text-gray-400",a="confirmed"===e.statusStyle?"bg-green-500/20 text-green-400":"open"===e.statusStyle?"bg-blue-500/20 text-blue-300":"pending"===e.statusStyle?"bg-yellow-500/20 text-yellow-400":"cancelled"===e.statusStyle?"bg-red-500/20 text-red-400":"expired"===e.statusStyle?"bg-amber-500/15 text-amber-300":"bg-gray-500/20 text-gray-400";return(0,s.jsxs)("tr",{className:"border-b border-white/5 hover:bg-white/5 transition-colors",children:[(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:(0,s.jsx)("a",{href:`/rexmarkets/myriad/${encodeURIComponent(e.slugForLink)}`,onClick:r=>{r.preventDefault(),t(),i.push(`/rexmarkets/myriad/${encodeURIComponent(e.slugForLink)}`)},className:"max-w-[200px] truncate block text-left hover:text-[#ffc000] transition-colors cursor-pointer underline decoration-dotted underline-offset-2 hover:
1decoration-solid",title:e.marketTitle,children:e.marketTitle})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:(0,s.jsx)("span",{className:`inline-block px-2 py-1 rounded text-xs font-medium ${r}`,children:e.sideLabel})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm tabular-nums font-medium",children:e.priceDisplay}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm tabular-nums font-semibold",children:e.sizeDisplay}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:"—"===e.role?(0,s.jsx)("span",{className:"text-gray-500 text-xs",children:"—"}):(0,s.jsx)("span",{className:"inline-block px-2 py-1 rounded text-xs font-medium bg-blue-500/20 text-blue-400",children:e.role})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:(0,s.jsx)("span",{className:`inline-block px-2 py-1 rounded text-xs font-medium ${a}`,children:e.statusLabel})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-gray-400 text-xs whitespace-nowrap",children:e.timeStr})]},e.key)})})]})}):(0,s.jsx)("div",{className:"text-center py-12",children:(0,s.jsx)("p",{className:"text-gray-400",children:"Connect your wallet to view Myriad activity and order-book orders (BNB Chain)."})})}),"positions"===K&&(0,s.jsx)(s.Fragment,{children:d?tA?(0,s.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,s.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-[#ffc000]"})}):tE?(0,s.jsx)("div",{className:"text-center py-8",children:(0,s.jsx)("p",{className:"text-red-400",children:tE instanceof Error?tE.message:"Failed to load Myriad positions."})}):0===tF.length?(0,s.jsx)("div",{className:"text-center py-12",children:(0,s.jsx)("p",{className:"text-gray-400 text-lg",children:"No positions found."})}):(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full border-collapse",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"border-b border-white/10",children:[(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Market"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Yes (shares)"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"No (shares)"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"State"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Claim"})]})}),(0,s.jsx)("tbody",{children:tF.map(e=>{let r=e.slug?.trim()||String(e.marketId),a=eG===e.marketId;return(0,s.jsxs)("tr",{className:"border-b border-white/5 hover:bg-white/5 transition-colors",children:[(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:(0,s.jsx)("a",{href:`/rexmarkets/myriad/${encodeURIComponent(r)}`,onClick:e=>{e.preventDefault(),t(),i.push(`/rexmarkets/myriad/${encodeURIComponent(r)}`)},className:"max-w-[200px] truncate block hover:text-[#ffc000] transition-colors underline decoration-dotted",title:e.title,children:e.title})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm tabular-nums",children:e.yesShares.toLocaleString(void 0,{maximumFractionDigits:4})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm tabular-nums",children:e.noShares.toLocaleString(void 0,{maximumFractionDigits:4})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-gray-300 text-xs sm:text-sm capitalize",children:e.state||"—"}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:(0,s.jsx)("button",{type:"button",onClick:()=>void tH(e.marketId),disabled:a||!e.redeemEligible,title:e.redeemEligible?"POST /markets/claim — submit calldata on BNB Smart Chain (fallback: order-book redeem).":"Claim is only available when the market is resolved and you have winnings or voided proceeds to claim (per API).",className:`min-w-[88px] px-3 py-1.5 rounded text-xs font-medium transition-colors ${a?"bg-amber-600/70 cursor-wait text-white":e.redeemEligible?"bg-[#ffc000] hover:bg-[#ffd000] text-black":"bg-white/10 text-gray-500 cursor-not-allowed"}`,children:a?(0,s.jsxs)("span",{className:"flex items-center gap-1.5 justify-center",children:[(0,s.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-black/30 border-t-black rounded-full animate-spin"}),"…"]}):"Claim"})})]},e.marketId)})})]})}):(0,s.jsx)("div",{className:"text-center py-12",children:(0,s.jsx)("p",{className:"text-gray-400",children:"Connect your wallet to view Myriad positions and claim on BNB Chain."})})})]}):"predictfun"===O?(0,s.jsx)(eX,{isOpen:e,onClose:t,activeTab:K,setActiveTab:z,eoaAddress:d,signer:m}):c?g&&u&&b?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex border-b border-white/10 sticky top-[73px] bg-[#0D0D0D] z-10 -mx-4 sm:-mx-6 px-4 sm:px-6",children:[(0,s.jsx)("button",{onClick:()=>z("trades"),className:`flex-1 px-4 py-3 text-sm font-medium transition-colors border-b-2 ${"trades"===K?"border-[#ffc000] text-[#ffc000]":"border-transparent text-gray-400 hover:text-white"}`,children:"Trades"}),(0,s.jsx)("button",{onClick:()=>z("positions"),className:`flex-1 px-4 py-3 text-sm font-medium transition-colors border-b-2 ${"positions"===K?"border-[#ffc000] text-[#ffc000]":"border-transparent text-gray-400 hover:text-white"}`,children:"Positions"})]}),"trades"===K&&(0,s.jsx)(s.Fragment,{children:tr?(0,s.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,s.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-[#ffc000]"})}):ts?(0,s.jsx)("div",{className:"text-center py-8",children:(0,s.jsx)("p",{className:"text-red-400",children:"Failed to load trades. Please try again later."})}):0===tt.length?(0,s.jsx)("div",{className:"text-center py-12",children:(0,s.jsx)("p",{className:"text-gray-400 text-lg",children:"No trades found."})}):(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full border-collapse",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"border-b border-white/10",children:[(0,s.jsxs)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:["Market"," ",(0,s.jsx)("span",{className:"text-gray-500 text-xs font-normal",children:"(Click to view)"})]}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Side"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Price"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Size"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Role"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Status"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Time"})]})}),(0,s.jsx)("tbody",{children:tQ.map(e=>{var t;let r,a=(e.maker_address||"").toLowerCase()===(u||"").toLowerCase(),i=e.trader_side||(a?"MAKER":"TAKER");return(0,s.jsxs)("tr",{className:"border-b border-white/5 hover:bg-white/5 transition-colors",children:[(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:(0,s.jsx)("button",{onClick:()=>te(e.market||e.asset_id||"",e.marketTitle||e.market||e.asset_id||"N/A"),disabled:R===(e.market||e.asset_id||""),className:"max-w-[200px] truncate text-left hover:text-[#ffc000] transition-colors cursor-pointer underline decoration-dotted underline-offset-2 hover:
1decoration-solid disabled:opacity-50 disabled:cursor-wait flex items-center gap-2",title:`Click to view ${e.marketTitle||e.market||e.asset_id||"N/A"}`,children:R===(e.market||e.asset_id||"")?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-[#ffc000] flex-shrink-0"}),(0,s.jsx)("span",{className:"truncate",children:e.marketTitle||e.market||e.asset_id||"N/A"})]}):e.marketTitle||e.market||e.asset_id||"N/A"})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:(0,s.jsx)("span",{className:`inline-block px-2 py-1 rounded text-xs font-medium ${"BUY"===e.side?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:e.side})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:parseFloat(e.price).toFixed(4)}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:parseFloat(e.size).toFixed(2)}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:(0,s.jsx)("span",{className:"inline-block px-2 py-1 rounded text-xs font-medium bg-blue-500/20 text-blue-400",children:i})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:(0,s.jsx)("span",{className:`inline-block px-2 py-1 rounded text-xs font-medium ${"CONFIRMED"===e.status?"bg-green-500/20 text-green-400":"PENDING"===e.status?"bg-yellow-500/20 text-yellow-400":"bg-gray-500/20 text-gray-400"}`,children:e.status||"N/A"})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-gray-400 text-xs",children:isNaN(r="string"==typeof(t=e.match_time)?parseInt(t,10):t)||0===r?"N/A":new Date(1e3*r).toLocaleString()})]},e.id)})})]})})}),"positions"===K&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3 mb-4 mt-4",children:[W&&tR&&tR.length>tZ.length&&(0,s.jsxs)("span",{className:"text-yellow-300 text-sm",children:["Hiding ",tR.length-tZ.length," ","dust position(s) (value < $",eF.zB.toFixed(2),")"]}),(0,s.jsx)("div",{className:"ml-auto",children:(0,s.jsx)(eB.S,{checked:!W,onChange:e=>q(!e),label:"Show All"})})]}),tP?(0,s.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,s.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-[#ffc000]"})}):t$?(0,s.jsx)("div",{className:"text-center py-8",children:(0,s.jsx)("p",{className:"text-red-400",children:"Failed to load positions. Please try again later."})}):0===tZ.length?(0,s.jsx)("div",{className:"text-center py-12",children:(0,s.jsx)("p",{className:"text-gray-400 text-lg",children:"No open positions found."})}):(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full border-collapse",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"border-b border-white/10",children:[(0,s.jsxs)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:["Market"," ",(0,s.jsx)("span",{className:"text-gray-500 text-xs font-normal",children:"(Click to view)"})]}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Outcome"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Size"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Avg Price"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Current Price"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Current Value"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"P&L"}),(0,s.jsx)("th",{className:"text-left py-3 px-2 sm:px-4 text-gray-400 text-xs sm:text-sm font-medium",children:"Action"})]})}),(0,s.jsx)("tbody",{children:tZ.map(e=>{let t=e4.has(e.asset),r=X===e.asset,a=G===e.asset,i=eP===e.asset,n=eO===e.asset;return(0,s.jsxs)("tr",{className:"border-b border-white/5 hover:bg-white/5 transition-colors",children:[(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:(0,s.jsx)("button",{onClick:()=>te(e.conditionId,e.title),disabled:R===e.conditionId,className:"max-w-[200px] truncate text-left hover:text-[#ffc000] transition-colors cursor-pointer underline decoration-dotted underline-offset-2 hover:
1decoration-solid disabled:opacity-50 disabled:cursor-wait flex items-center gap-2",title:`Click to view ${e.title}`,children:R===e.conditionId?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-[#ffc000] flex-shrink-0"}),(0,s.jsx)("span",{className:"truncate",children:e.title})]}):e.title})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:e.outcome}),(0,s.jsxs)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:[(0,eT.Ym)(e.size)," shares"]}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:(0,eT.vv)(e.avgPrice,3)}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:(0,eT.vv)(e.curPrice,3)}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4 text-white text-xs sm:text-sm",children:(0,eT.vv)(e.currentValue)}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:(0,s.jsxs)("span",{className:`text-xs sm:text-sm font-medium ${e.cashPnl>=0?"text-green-400":"text-red-400"}`,children:[(0,eT.vv)(e.cashPnl)," (",(0,eT.Ee)(e.percentPnl),")"]})}),(0,s.jsx)("td",{className:"py-3 px-2 sm:px-4",children:e.redeemable?(0,s.jsxs)("div",{className:"flex flex-col items-end gap-1",children:[(0,s.jsx)("button",{onClick:()=>t2(e),disabled:a||!y||n,className:`min-w-[80px] px-3 py-1.5 rounded text-xs font-medium transition-colors ${n?"bg-green-600/70 cursor-default text-white":a?"bg-yellow-600/70 cursor-wait text-white":"bg-green-600 hover:bg-green-700 disabled:bg-gray-600 disabled:cursor-not-allowed text-white"}`,children:n?(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Success"]}):a?(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-white"}),"Signing..."]}):"Redeem"}),n&&(0,s.jsx)("span",{className:"text-green-400 text-xs font-medium animate-pulse",children:"Transaction Success"})]}):(0,s.jsxs)("div",{className:"flex flex-col items-end gap-1",children:[(0,s.jsx)("button",{onClick:()=>t1(e),disabled:r||tG||!g||t||i,className:`min-w-[80px] px-3 py-1.5 rounded text-xs font-medium transition-colors ${i?"bg-green-600/70 cursor-default text-white":r||t?"bg-yellow-600/70 cursor-wait text-white":"bg-red-600 hover:bg-red-700 disabled:bg-gray-600 disabled:cursor-not-allowed text-white"}`,children:i?(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Success"]}):r?(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("div",{className:"animate-spin rounded-full h-3 w-3 border-b-2 border-white"}),"Signing..."]}):t?"Processing...":"Sell"}),i&&(0,s.jsx)("span",{className:"text-green-400 text-xs font-medium animate-pulse",children:"Transaction Success"})]})})]},`${e.conditionId}-${e.outcomeIndex}`)})})]})})]})]}):(0,s.jsxs)("div",{className:"text-center py-8 space-y-4",children:[(0,s.jsx)("p",{className:"text-gray-400",children:d?"Please initialize trading session to view data.":"Please connect your wallet to view trading data."}),d&&j&&(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("button",{onClick:async()=>{if(j){B(!0);try{await j()}catch(e){console.error("Failed to initialize trading:",e)}finally{B(!1)}}},disabled:D||"idle"!==w||b,className:"px-6 py-3 bg-[#ffc000] text-black font-semibold rounded-lg hover:bg-[#ffd633] transition-colors disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-[#ffc000]",children:D||"idle"!==w?(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-black"}),"checking"===w?"Checking...":"deploying"===w?"Deploying Safe...":"credentials"===w?"Setting up credentials...":"approvals"===w?"Setting approvals...":"Initializing..."]}):"Initialize Trading"}),N&&(0,s.jsx)("p",{className:"text-red-400 text-sm mt-2",children:N.message||"Failed to initialize trading session"})]})]}):(0,s.jsx)("div",{className:"text-center py-8",children:(0,s.jsx)("p",{className:"text-gray-400",children:"Trading provider not available. Please navigate to the trading page to view data."})})})]})})]}):null}var e2=r(82929),e3=r(28527),e5=r(49487),e6=r(38043),e8=r(49846),e7=r(49843),e9=r(84239),te=r(50747),tt=r(13429),tr=r(71348);let ts={all:{hex:"#ffc000",desktopActive:"sm:bg-[#ffc000] sm:!text-black sm:!border-transparent"},predictfun:{hex:"#A855F7",desktopActive:"sm:bg-[#A855F7] sm:!text-white sm:!border-transparent"},kalshi:{hex:"#17cb91",desktopActive:"sm:bg-[#17cb91] sm:!text-black sm:!border-transparent"},polymarket:{hex:"#2C59F7",desktopActive:"sm:bg-[#2C59F7] sm:!text-white sm:!border-transparent"},limitless:{hex:"#c3ff01",desktopActive:"sm:bg-[#c3ff01] sm:!text-black sm:!border-transparent"},myriad:{hex:"#ffffff",desktopActive:"sm:bg-black sm:!text-white sm:!border-transparent"}};function ta({source:e,label:t,isActive:r,onClick:a,icon:i}){let n=ts[e];return(0,s.jsxs)("button",{type:"button",onClick:a,className:(0,tr.A)("flex items-center justify-center gap-1 shrink-0 px-2.5 sm:px-4 h-10 text-[11px] sm:text-xs font-medium whitespace-nowrap transition-colors duration-200 border-b-2 sm:border-b-0 sm:rounded-[10px]",r?(0,tr.A)("font-semibold",n.desktopActive):"text-white/70 border-transparent hover:text-white/90"),style:r?{color:n.hex,borderBottomColor:n.hex}:void 0,children:[i,(0,s.jsx)("span",{children:t})]})}function ti({dataSource:e,setDataSource:t}){return(0,s.jsx)("div",{className:"w-full min-w-0 max-w-full overflow-x-auto scrollbar-none border-b border-white/10 sm:w-auto 
1sm:overflow-visible sm:border-b-0",children:(0,s.jsxs)("div",{className:"inline-flex min-w-max items-center sm:bg-white/12 sm:p-0.5 sm:rounded-xl",children:[(0,s.jsx)(ta,{source:"all",label:"All",isActive:"all"===e,onClick:()=>t("all")}),(0,s.jsx)(ta,{source:"predictfun",label:"Predict.fun",isActive:"predictfun"===e,onClick:()=>t("predictfun"),icon:(0,s.jsx)("span",{className:"flex size-4 sm:size-5 shrink-0 items-center justify-center",children:(0,s.jsx)(i.default,{src:"predictfun"===e?te.j:te.H,alt:"",width:20,height:20,className:"max-h-4 max-w-4 sm:max-h-5 sm:max-w-5 object-contain"})})}),(0,s.jsx)(ta,{source:"kalshi",label:"Kalshi",isActive:"kalshi"===e,onClick:()=>t("kalshi"),icon:(0,s.jsx)("span",{className:"flex size-4 sm:size-5 shrink-0 items-center justify-center font-bold leading-none text-[15px] sm:text-[18px] text-inherit",children:"K"})}),(0,s.jsx)(ta,{source:"polymarket",label:"Polymarket",isActive:"polymarket"===e,onClick:()=>t("polymarket"),icon:(0,s.jsx)("span",{className:"flex size-4 sm:size-5 shrink-0 items-center justify-center",children:(0,s.jsx)(i.default,{src:"/images/polymarket.png",alt:"",width:20,height:20,className:"max-h-4 max-w-4 sm:max-h-5 sm:max-w-5 object-contain"})})}),(0,s.jsx)(ta,{source:"limitless",label:"Limitless",isActive:"limitless"===e,onClick:()=>t("limitless"),icon:(0,s.jsx)("span",{className:"flex size-4 sm:size-5 shrink-0 items-center justify-center",children:(0,s.jsx)(i.default,{src:"/images/limitless-logo-new-white.webp",alt:"",width:20,height:20,className:"max-h-4 max-w-4 sm:max-h-5 sm:max-w-5 object-contain"})})}),(0,s.jsx)(ta,{source:"myriad",label:"Myriad",isActive:"myriad"===e,onClick:()=>t("myriad"),icon:(0,s.jsx)("span",{className:"flex size-4 sm:size-5 shrink-0 items-center justify-center",children:(0,s.jsx)(i.default,{src:"/images/myriad.webp",alt:"",width:20,height:20,className:"max-h-4 max-w-4 sm:max-h-5 sm:max-w-5 object-contain"})})})]})})}function tn({onHistoryClick:e,onExchangeClick:t,showExchangeButton:r=!1,onLogout:c,title:d,description:m,mobileMenuButton:u,clawV5MainNavShiftPx:x}){let{authenticated:h,ready:p,user:f,login:g,logout:y}=(0,n.u)(),{isAuthenticated:b,user:w,disconnect:N}=(0,l.F)(),j=(0,o.useRouter)(),v=(0,o.usePathname)(),k="/rexmarkets"===v||v.startsWith("/rexmarkets/"),S=k&&v.split("/").filter(Boolean).length>=3,C="/claw-v5"===v||v.startsWith("/claw-v5/"),A=(0,e9.FP)(v),{dataSource:E,setDataSource:I}=(0,e8.x)(),{solanaAddress:T}=(0,em.d)(),{ethereumAddress:F}=(0,e7.y)(),L=h||b,D=d||(C?"Claw AI 5.0":k?"Rex Predictions":"Market Overview"),B=m||(C?"AI-powered chat assistant.":k?"Prediction Intelligence by your side.":"Real time insights powered by Claw AI 5.0."),[R,P]=(0,a.useState)(null),[$,O]=(0,a.useState)(!1),[_,U]=(0,a.useState)(!1),[M,K]=(0,a.useState)(!1),[z,W]=(0,a.useState)(!1),[q,V]=(0,a.useState)(!1),[Y,Q]=(0,a.useState)(!1),[Z,ee]=(0,a.useState)(!1),{isTopbarVisible:et,setTopbarVisible:er}=(0,e6.O)(),[es,ea]=(0,a.useState)(!1),[ei,en]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=()=>{ea(window.innerWidth<640)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),(0,a.useEffect)(()=>{let e=window.matchMedia("(min-width: 768px)"),t=()=>en(e.matches);return t(),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]);let el=C&&ei&&"number"==typeof x?x:0,eo=C&&ei&&"number"==typeof x?0!==x?x+20:16:0,ec=()=>{W(!0)},ed=(0,a.useCallback)(async()=>{if(!L)return void P(null);let e=f?.id,t=w?.id;if(!(e||t))return void P(null);O(!0);try{let r;w?.email?r=w.email:f&&(r="object"==typeof f.email&&f.email?.address||"string"==typeof f.email&&f.email||void 0);let s=await fetch("/api/user",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e?{privyId:e}:{phantomId:t},email:r,...T?{solanaWallet:T}:{},...F?{ethereumWallet:F}:{}}),cache:"no-store"});if(s.ok){let e=await s.json();P(e.user)}else P(null)}catch{P(null)}finally{O(!1)}},[L,f?.id,w?.id,w?.email,f,T,F]);(0,a.useEffect)(()=>{ed()},[ed]);let eu=(0,a.useRef)(null),ex=(0,a.useRef)(null);(0,a.useEffect)(()=>{let e=L&&T&&T!==eu.current,t=L&&F&&F!==ex.current;e&&(eu.current=T),t&&(ex.current=F),(e||t)&&ed()},[L,T,F,ed]),(0,a.useEffect)(()=>{M&&ed()}
1,[M,ed]),(0,a.useEffect)(()=>{k&&"true"===new URLSearchParams(window.location.search).get("openPolymarketModal")&&(Q(!0),j.replace("/rexmarkets",{scroll:!1}))},[k,j]);let eh=async()=>{if(!_){U(!0);try{localStorage.clear(),h&&await y(),b&&await N(),P(null),K(!1),c&&c(),j.push("/")}finally{U(!1)}}},ep=(0,s.jsx)("button",{className:"shrink-0 cursor-pointer transition hover:scale-[1.05]",onClick:()=>{e?e():L||ec()},children:(0,s.jsx)(i.default,{src:"/images/btn_claw-ai.png",alt:"Claw AI — report history",width:120,height:50,className:"w-22 h-10.25 sm:w-20 sm:h-8.25 md:w-25 md:h-10"})});return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"w-full flex flex-col z-20",children:[et&&(0,s.jsxs)("div",{className:"w-full flex items-center px-3 sm:px-5 py-2 bg-linear-to-b from-[#002008] to-[#00761E] relative",children:[(0,s.jsx)("div",{className:"mx-auto flex min-w-0 max-w-[calc(100%-2.75rem)] items-center gap-2 px-1 transition-transform duration-300 ease-in-out",style:0!==eo?{transform:`translateX(${eo}px)`}:void 0,children:(0,s.jsx)("span",{className:"text-center text-[13px] sm:text-sm font-normal text-white [overflow-wrap:anywhere]",children:"The Intelligent Terminal for Prediction Markets & Crypto."})}),(0,s.jsx)("button",{onClick:()=>er(!1),className:"absolute right-3 sm:right-5 p-1 hover:bg-white/10 rounded transition","aria-label":"Close topbar",children:(0,s.jsx)(H.A,{className:"w-4 h-4 text-white"})})]}),(0,s.jsxs)("div",{className:"w-full flex justify-between items-center px-3 sm:px-5 py-2.5 bg-[#141414] border-b-[0.5px] border-[#B58405]",children:[(0,s.jsx)("div",{className:"flex items-end shrink-0",children:(0,s.jsx)(i.default,{src:"/images/raptorx.png",alt:"RaptorX Logo",width:100,height:100,className:"w-13 h-11 sm:w-17.75 sm:h-15 md:w-18.25 md:h-15.5"})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0 px-2 sm:px-4",children:[(0,s.jsx)("div",{className:"sm:hidden w-full",children:(0,s.jsxs)("div",{className:"w-full max-w-65 mx-auto bg-white/12 p-1 rounded-xl flex items-center gap-1",children:[(0,s.jsx)("button",{onClick:()=>{A||j.push(e9.As)},className:`flex-1 min-w-0 h-9 rounded-[10px] text-[11px] font-semibold transition-colors truncate ${A?"bg-[#ffc000] text-black border border-[#B58405]":"bg-transparent text-white/80"}`,children:"RexScreener"}),(0,s.jsx)("button",{onClick:()=>{C||((0,tt.W)(),j.push("/claw-v5"))},className:`flex-1 min-w-0 h-9 rounded-[10px] text-[11px] font-semibold transition-colors truncate ${C?"bg-[#ffc000] text-black border border-[#B58405]":"bg-transparent text-white/80"}`,children:"Claw AI 5.0"}),(0,s.jsx)("button",{onClick:()=>{k||j.push("/rexmarkets")},className:`flex-1 min-w-0 h-9 rounded-[10px] text-[11px] font-semibold transition-colors truncate ${k&&!C?"bg-[#ffc000] text-black border border-[#B58405]":"bg-transparent text-white/80"}`,children:"Rex Predictions"})]})}),(0,s.jsx)("div",{className:"hidden sm:flex justify-center transition-transform duration-300 ease-in-out",style:0!==el?{transform:`translateX(${el}px)`}:void 0,children:(0,s.jsx)("div",{className:"relative inline-flex items-center",children:(0,s.jsxs)("div",{className:"relative flex items-center bg-white/12 p-0.5",style:{width:"360px",borderRadius:"12px"},children:[(0,s.jsx)("div",{className:"absolute top-1 bottom-1 bg-[#ffc000] shadow-md",style:{left:A?"3px":C?"126px":"237px",width:A?"121px":C?"110px":"118px",height:"40px",borderRadius:"12px",border:"0.5px solid #B58405",transition:"all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",willChange:"left, width",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.2)"}}),(0,s.jsxs)("div",{className:"relative flex items-center justify-center w-full h-full py-0.5 px-0.5",children:[(0,s.jsx)("button",{onClick:()=>{A||j.push(e9.As)},className:`relative z-10 font-medium text-xs whitespace-nowrap transition-colors duration-200 flex items-center justify-center ${A?"text-black font-semibold":"text-white/70 hover:text-white/90"}`,style:{width:"121px",height:"40px",borderRadius:"12px"},children:"RexScreener"}),(0,s.jsx)("button",{onClick:()=>{C||((0,tt.W)(),j.push("/claw-v5"))},className:`relative z-10 font-medium text-xs whitespace-nowrap transition-colors duration-200 flex items-center justify-center ${C?"text-black font-semibold":"text-white/70 hover:text-white/90"}`,style:{width:"110px",height:"40px",borderRadius:"12px"},children:"Claw AI 5.0"}),(0,s.jsx)("button",{onClick:()=>{k||j.push("/rexmarkets")},className:`relative z-10 font-medium text-xs whitespace-nowrap transition-colors duration-200 flex items-center justify-center ${k&&!C?"text-black font-semibold":"text-white/70 hover:text-white/90"}`,style:{width:"118px",height:"40px",borderRadius:"12px"},children:"Rex Predictions"})]})]})})})]}),(0,s.jsxs)("div",{className:"relative z-30 flex shrink-0 items-center gap-2 sm:gap-4",children:[L&&k&&(0,s.jsx)("button",{onClick:()=>V(!0),className:"hidden sm:inline-flex px-4 py-2 rounded-lg bg-[#ffc000] hover:bg-[#ffd000] text-black font-semibold text-sm transition","aria-label":"Deposit",title:"Deposit & Withdraw",children:"Deposit"}),L?(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("button",{onClick:()=>ee(e=>!e),className:"rounded-full border border-[#ffc000] p-1",children:(0,s.jsx)(e2.A,{color:"#ffc000"})}),Z&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"fixed inset-0 z-30",onClick:()=>ee(!1)}),(0,s.jsxs)("div",{className:"absolute right-0 top-full mt-2 w-48 bg-[#0D0D0D] border border-white/10 rounded-lg shadow-xl z-40 overflow-hidden py-1",children:[(0,s.jsxs)("button",{onClick:()=>{ee(!1),K(!0),ed()},className:"w-full px-4 py-3 text-left text-white hover:bg-white/10 transition-colors text-sm font-medium flex items-center gap-3",children:[(0,s.jsx)(e2.A,{className:"w-4 h-4 shrink-0 text-white/70"}),"Profile"]}),k&&(0,s.jsxs)("button",{onClick:()=>{ee(!1),V(!0)},className:"w-full px-4 py-3 text-left text-white hover:bg-white/10 transition-colors text-sm font-medium flex items-center gap-3 sm:hidden",children:[(0,s.jsx)(e3.A,{className:"w-4 h-4 shrink-0 text-white/70"}),"Deposit"]}),(0,s.jsxs)("button",{onClick:()=>{ee(!1),k?Q(!0):j.push("/rexmarkets?openPolymarketModal=true")},className:"w-full px-4 py-3 text-left text-white hover:bg-white/10 transition-colors text-sm font-medium flex items-center gap-3",children:[(0,s.jsx)(e5.A,{className:"w-4 h-4 shrink-0 text-white/70"}),"My Orders"]})]})]})]}):(0,s.jsx)("button",{onClick:ec,className:"w-14 sm:w-15 h-10 rounded-xl flex items-center justify-center bg-[#ffc000] text-black font-bold text-[14px] curs
1or-pointer transition hover:bg-[#ffd000]",children:"Login"})]})]}),!C&&(0,s.jsx)("div",{className:`w-full pt-6 px-3 sm:px-5 ${k?"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4":"flex flex-row justify-between items-center gap-1 sm:gap-4"}`,children:k?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex w-full items-center justify-between gap-2 sm:w-auto sm:shrink-0 sm:justify-start",children:[(0,s.jsxs)("div",{className:"flex min-w-0 flex-col items-start text-left",children:[(0,s.jsx)("h1",{className:"text-[14px]! sm:text-[18px]! font-semibold! text-[#ffc000]",children:D}),(0,s.jsx)("p",{className:"block max-w-full text-[12px]! sm:text-[14px]! font-normal! text-[#7A7A7A]",children:B})]}),(0,s.jsx)("div",{className:"sm:hidden",children:ep})]}),(0,s.jsxs)("div",{className:"flex w-full flex-row items-center justify-center gap-2 sm:w-auto sm:min-w-0 sm:justify-end sm:gap-3",children:[!S&&(0,s.jsx)(ti,{dataSource:E,setDataSource:I}),r&&(0,s.jsx)("button",{className:"cursor-pointer transition hover:scale-[1.05]",onClick:t,children:(0,s.jsx)(i.default,{src:"/images/exchange.png",alt:"Enter The Exchange.",width:140,height:80,className:"w-25 h-[39.5px] sm:w-20 sm:h-8 md:w-25 md:h-[38.5px]"})}),(0,s.jsx)("div",{className:"hidden sm:block",children:ep})]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex min-w-0 flex-col",children:[(0,s.jsx)("h1",{className:"text-[14px]! sm:text-[18px]! font-semibold! text-[#ffc000]",children:D}),(0,s.jsx)("p",{className:"block max-w-40 text-[12px]! sm:max-w-full sm:text-[14px]! font-normal! text-[#7A7A7A]",children:B})]}),(0,s.jsxs)("div",{className:"flex flex-row items-center gap-1 sm:gap-3",children:[r&&(0,s.jsx)("button",{className:"cursor-pointer transition hover:scale-[1.05]",onClick:t,children:(0,s.jsx)(i.default,{src:"/images/exchange.png",alt:"Enter The Exchange.",width:140,height:80,className:"w-25 h-[39.5px] sm:w-20 sm:h-8 md:w-25 md:h-[38.5px]"})}),ep]})]})})]}),(0,s.jsx)(G,{isOpen:M,onClose:()=>K(!1),currentUser:R,isLoadingUser:$,isLoggingOut:_,onLogout:eh}),(0,s.jsx)(J.A,{isOpen:z,onClose:()=>W(!1)}),(0,s.jsx)(X.A,{isOpen:q,onClose:()=>V(!1),defaultPlatform:v.startsWith("/rexmarkets/kalshi")?"kalshi":v.startsWith("/rexmarkets/limitless")?"limitless":v.startsWith("/rexmarkets/myriad")?"myriad":v.startsWith("/rexmarkets/predict-fun")?"predictfun":"polymarket"}),(0,s.jsx)(e4,{isOpen:Y,onClose:()=>Q(!1)})]})}},13060:(e,t,r)=>{"use strict";r.d(t,{u:()=>y});var s=r(56693),a=r(98243),i=r(84291),n=r(2531),l=r(96855),o=r(87162);let c=`0x${"0".repeat(64)}`,d={56:{KERNEL:"0xBAC849bB641841b44E965fB01A4Bf5F074f84b4D",NEG_RISK_ADAPTER:"0xc3Cf7c252f65E0d8D88537dF96569AE94a7F1A6E",YIELD_BEARING_NEG_RISK_ADAPTER:"0x41dCe1A4B8FB5e6327701750aF6231B7CD0B2A40"},97:{KERNEL:"0xBAC849bB641841b44E965fB01A4Bf5F074f84b4D",NEG_RISK_ADAPTER:"0x285c1B939380B130D7EBd09467b93faD4BA623Ed",YIELD_BEARING_NEG_RISK_ADAPTER:"0xb74aea04bdeBE912Aa425bC9173F9668e6f11F99"}},m=["function redeemPositions(address collateralToken, bytes32 parentCollectionId, bytes32 conditionId, uint256[] indexSets)"],u=["function redeemPositions(bytes32 conditionId, uint256[] amounts)"],x=["function execute(bytes32 execMode, bytes executionCalldata) payable"];function h(e,t,r=0){return a.qn([a.bj(e,32),a.bj(i.gH.from(r).toHexString(),32),t])}async function p(e,t,r,s){let a=o.D9[t],p=d[t],{isNegRisk:f,isYieldBearing:g,conditionId:y,indexSet:b,amountWei:w}=r;if(f){let t,r=g?p.YIELD_BEARING_NEG_RISK_ADAPTER:p.NEG_RISK_ADAPTER,a=new n.KA(u),o=(t=i.gH.from(w.toString()),1===b?[t,i.gH.from(0)]:[i.gH.from(0),t]),d=a.encodeFunctionData("redeemPositions",[y,o]);if(s){let t=new l.NZ(s,x,e),a=h(r,d),i=await t.execute(c,a),n=await i.wait(1);if(n?.status!==1)throw Error("Redeem transaction failed");return n.transactionHash}let m=new l.NZ(r,u,e),f=await m.redeemPositions(y,o),N=await f.wait(1);if(N?.status!==1)throw Error("Redeem transaction failed");return N.transactionHash}let N=(0,o.t0)(t,{isNegRisk:!1,isYieldBearing:g}),j=[i.gH.from(b)],v=new n.KA(m).encodeFunctionData("redeemPositions",[a.USDT,c,y,j]);if(s){let t=new l.NZ(s,x,e),r=h(N,v),a=await t.execute(c,r),i=await a.wait(1);if(i?.status!==1)throw Error("Redeem transaction failed");return i.transactionHash}let k=new l.NZ(N,m,e),S=await k.redeemPositions(a.USDT,c,y,j),C=await S.wait(1);if(C?.status!==1)throw Error("Redeem transaction failed");return C.transactionHash}var f=r(74080);async function g(e,t){if(!e?.switchChain)return;let r=e.chainId;r!==t&&r!==`eip155:${t}`&&r!==String(t)&&(await e.switchChain(t),await new Promise(e=>setTimeout(e,400)))}
1function y(){let[e,t]=(0,s.useState)(null);return{redeem:(0,s.useCallback)(async e=>{let{rowKey:r,signer:s,walletAddress:a,chainId:i,params:n,wallet:l}=e;t(r);try{await g(l,i);let e=(0,f.Vn)(i,a);return await p(s,i,n,e)}finally{t(null)}},[]),redeemingKey:e,isRedeeming:t=>e===t}}},13429:(e,t,r)=>{"use strict";r.d(t,{W:()=>a,Z:()=>i});let s="claw-v5:scroll-to-input";function a(){try{sessionStorage.setItem(s,"1")}catch{}}function i(){try{let e=sessionStorage.getItem(s);return null!==e&&sessionStorage.removeItem(s),"1"===e}catch{return!1}}},16164:(e,t,r)=>{"use strict";r.d(t,{A1:()=>h,NT:()=>f,W2:()=>l,c7:()=>p});var s=r(50343),a=r(65343),i=r(5809),n=r(4095);function l(e){if(Array.isArray(e))return e;if(!e||"object"!=typeof e)return[];if(Array.isArray(e.data))return e.data;let t=e.data;return t&&Array.isArray(t.data)?t.data:t&&Array.isArray(t.positions)?t.positions:t&&Array.isArray(t.items)?t.items:t&&Array.isArray(t.results)?t.results:Array.isArray(e.items)?e.items:Array.isArray(e.results)?e.results:Array.isArray(e.orders)?e.orders:Array.isArray(e.matches)?e.matches:Array.isArray(e.positions)?e.positions:[]}function o(e,t=18){if(null==e)return 0;try{if("number"==typeof e)return Number.isFinite(e)?e:0;let r=String(e).trim();if(!r)return 0;if(/^\d+$/.test(r))return Number(s.Js(r,t));let a=Number(r);return Number.isFinite(a)?a:0}catch{return 0}}function c(e){if(null==e)return{sortTime:0,timeStr:"—"};if("number"==typeof e){let t=new Date(e>1e12?e:1e3*e);return{sortTime:t.getTime(),timeStr:Number.isNaN(t.getTime())?"—":t.toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"})}}let t=String(e).trim();if(!t)return{sortTime:0,timeStr:"—"};if(/^\d+$/.test(t)){let e=Number(t),r=new Date(e>1e12?e:1e3*e);return{sortTime:r.getTime(),timeStr:r.toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"})}}let r=new Date(t);return{sortTime:r.getTime(),timeStr:Number.isNaN(r.getTime())?t:r.toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"})}}function d(e){let t=e?.market??e?.category??{},r=String(e?.marketId??e?.market_id??t?.id??t?.marketId??"").trim(),s=String(e?.marketTitle??e?.market_title??t?.title??t?.question??e?.title??(r?`Market #${r}`:"Market")).trim(),a=String(t?.categorySlug??t?.slug??r).trim()||r;return{marketId:r,marketTitle:s,slugForLink:a}}function m(e,t){let r=String(e??"").trim().toLowerCase(),s=t.trim();return"bid"===r?{sideLabel:s?`BID ${s.toUpperCase()}`:"BID",sideTone:"buy"}:"ask"===r?{sideLabel:s?`ASK ${s.toUpperCase()}`:"ASK",sideTone:"sell"}:{sideLabel:"—",sideTone:"neutral"}}function u(e){if(null==e)return"—";if("number"==typeof e)return e>0&&e<=1?`${(100*e).toFixed(2)}\xa2`:String(e);let t=o(e,18);return t>0&&t<=1?`${(100*t).toFixed(2)}\xa2`:t>1&&t<=100?`${t.toFixed(2)}\xa2`:t>0?String(t):"—"}function x(e){let t="number"==typeof e?e:o(e,18);return!Number.isFinite(t)||t<=0?"—":t<1e6?t.toLocaleString(void 0,{maximumFractionDigits:4}):t.toLocaleString(void 0,{maximumFractionDigits:2})}function h(e,t){let{marketTitle:r}=d(e),{sortTime:s,timeStr:a}=c(e?.executedAt),i=e?.taker;if(!i)return[];let n=String(i?.outcome?.name??"Yes").trim(),{sideLabel:l,sideTone:o}=m(i?.quoteType,n),h=i?.price??e?.priceExecuted??e?.price_executed??null;return[{key:String(e?.transactionHash??`match-${t}`),sideLabel:l,sideTone:o,outcome:n||"—",priceDisplay:u(h),sizeDisplay:x(i?.amount??e?.amountFilled??e?.amount_filled),timeStr:a,sortTime:s,marketTitle:r}]}function p(e,t,r,s=[]){let i=(0,a.y)(r);if(!i)return[...s].sort((e,t)=>t.sortTime-e.sortTime);let n=l(e).map((e,t)=>(function(e,t,r){let s,i;if(s=e?.order??e,!((0,a.L)(s?.maker,r)||(0,a.L)(s?.signer,r)||(0,a.L)(e?.maker,r)||(0,a.L)(e?.signer,r)))return null;let n=e?.order??e,{marketId:l,marketTitle:o,slugForLink:m}=d(e),{sideLabel:h,sideTone:p}=function(e){let t=e?.order??e,r=t?.side??e?.side,s=String(e?.sideName??e?.side_label??"").toLowerCase();if(0===r||"0"===r||"buy"===s||"bid"===s)return{sideLabel:"BUY",sideTone:"buy"};if(1===r||"1"===r||"sell"===s||"ask"===s)return{sideLabel:"SELL",sideTone:"sell"};let a=String(e?.outcome?.name??e?.outcomeName??("string"==typeof e?.outcome?e.outcome:"")??"").trim();return a?{sideLabel:a.toUpperCase(),sideTone:"neutral"}:{sideLabel:"—",sideTone:"neutral"}}(n),{statusLabel:f,statusStyle:g}=(i=String(e?.status??e?.orderStatus??e?.state??e?.fillStatus??"—").trim().toUpperCase())&&"—"!==i?i.includes("OPEN")||i.includes("LIVE")||i.includes("ACTIVE")?{statusLabel:i,statusStyle:"open"}:i.includes("FILL")||i.includes("MATCH")||i.includes("EXEC")||"CONFIRMED"===i?{statusLabel:i,statusStyle:"confirmed"}:i.includes("CANCEL")?{statusLabel:i,statusStyle:"cancelled"}:i.includes("PEND")?{statusLabel:i,statusStyle:"pending"}:{statusLabel:i,statusStyle:"other"}:{statusLabel:"—",statusStyle:"other"},{sortTime:y,timeStr:b}=c(e?.createdAt??e?.created_at??n?.createdAt??e?.updatedAt??n?.updatedAt);return{key:String(e?.id??n?.hash??n?.id??e?.hash??`order-${t}`),marketId:l,marketTitle:o,slugForLink:m,sideLabel:h,sideTone:p,priceDisplay:u(e?.pricePerShare??e?.price_per_share??n?.pricePerShare),sizeDisplay:x(n?.takerAmount??n?.makerAmount??e?.takerAmount??e?.makerAmount),role:"—",statusLabel:f,statusStyle:g,timeStr:b,sortTime:y}})(e,t,i)).filter(e=>null!=e),o=l(t).flatMap((e,t)=>(function(e,t,r){let{marketId:s,marketTitle:i,slugForLink:n}=d(e),{sortTime:l,timeStr:o}=c(e?.executedAt),h=[],p=(c,d,p)=>{if(!c||!(0,a.L)(c?.signer,r))return;let f=String(c?.outcome?.name??"").trim(),{sideLabel:g,sideTone:y}=m(c?.quoteType,f);h.push({key:`${e?.transactionHash??t}-${d}-${p}`,marketId:s,marketTitle:i,slugForLink:n,sideLabel:g,sideTone:y,priceDisplay:u(c?.price??e?.priceExecuted),sizeDisplay:x(c?.amount??e?.amountFilled),role:d,statusLabel:"MATCHED",statusStyle:"confirmed",timeStr:o,sortTime:l})};return p(e?.taker,"TAKER",0),(Array.isArray(e?.makers)?e.makers:[]).forEac
1h((e,t)=>p(e,"MAKER",t)),h})(e,t,i)),h=new Map;for(let e of[...s,...o,...n])h.has(e.key)||h.set(e.key,e);return[...h.values()].sort((e,t)=>t.sortTime-e.sortTime)}function f(e,t,r,s,l){let c=(0,a.y)(t);if(!c)return[];let m=l?.skipOwnerFilter?null:[c,...(s??[]).map(e=>(0,a.y)(e)).filter(e=>!!e)],u=(0,i.oD)(e).filter(e=>{let t=String(e?.market?.id??e?.marketId??e?.market_id??"").trim(),r=(t&&l?.marketMetaById?.get(t))??e?.market??e?.category;return(0,n.v7)(e,r)}).map((e,t)=>{let r=String(e?.market?.id??e?.marketId??e?.market_id??"").trim(),s=(r&&l?.marketMetaById?.get(r))??e?.market;return function(e,t,r){let s=Array.isArray(r)?r:r?[r]:[];if(s.length>0){let t=e?.owner??e?.holder??e?.account;if(t&&!s.some(e=>(0,a.L)(t,e)))return null}let{marketId:l,marketTitle:o,slugForLink:c}=d(e),m=String(e?.outcome?.name??e?.outcome??e?.outcomeName??e?.name??"—").trim(),u=(0,i.k7)(e);if(u<=0)return null;let x=(0,n.$6)(e);return{key:String(e?.tokenId??e?.id??`pos-${t}`),marketId:l,marketTitle:o,slugForLink:c,outcome:m||"—",shares:u,sharesDisplay:u.toLocaleString(void 0,{maximumFractionDigits:4}),redeemEligible:!!x&&(0,n.Nm)(e,e?.market),redeemParams:x}}(s?{...e,market:{...e?.market??{},...s}}:e,t,m)}).filter(e=>null!=e).filter(e=>{if(!l?.hideRedeemKeys?.size||!e.redeemParams)return!0;let t=`${e.redeemParams.conditionId}:${e.redeemParams.indexSet}:${+!!e.redeemParams.isNegRisk}:${+!!e.redeemParams.isYieldBearing}`;return!l.hideRedeemKeys.has(t)});if(r){let e=o(r,18);e>0&&u.unshift({key:"usdt-collateral",marketId:"",marketTitle:"USDT collateral (wallet)",slugForLink:"",outcome:"USDT",shares:e,sharesDisplay:e.toLocaleString(void 0,{maximumFractionDigits:2}),usdtBalanceDisplay:e.toFixed(2)})}return u}},21557:(e,t,r)=>{"use strict";r.d(t,{A:()=>G});var s=r(66577),a=r(56693),i=r(24211),n=r(94225),l=r(67964),o=r(65294),c=r(61111),d=r(25514),m=r(26021),u=r(16329),x=r.n(u),h=r(75486),p=r(48663),f=r(44985),g=r(85672),y=r(16105),b=r(12491),w=r(82385),N=r(88435),j=r(50316),v=r(1968),k=r(85607),S=r(86112),C=r(31204),A=r(78427),E=r(87089),I=r(19741),T=r(95208),F=r(14243),L=r(82248),D=r(24057),B=r(24084),R=r(84444),P=r(16610),$=r(63992),O=r(81258),_=r(6143),U=r(41056),M=r(84218),K=r(20840),z=r(54588),W=r(81426);let q="https://mainnet.helius-rpc.com/?api-key=67d144bc-41ee-47c4-b5c7-a260a6a87712";function G({isOpen:e,onClose:t,defaultPlatform:r="polymarket"}){let[u,G]=(0,a.useState)(r),[J,X]=(0,a.useState)("deposit"),[H,V]=(0,a.useState)(null),[Y,Q]=(0,a.useState)(""),[Z,ee]=(0,a.useState)(""),[et,er]=(0,a.useState)(!1),[es,ea]=(0,a.useState)(null),[ei,en]=(0,a.useState)(!1),[el,eo]=(0,a.useState)(!1),[ec,ed]=(0,a.useState)(!1),[em,eu]=(0,a.useState)(!1),[ex,eh]=(0,a.useState)("USDC"),[ep,ef]=(0,a.useState)(null),[eg,ey]=(0,a.useState)(!1),[eb,ew]=(0,a.useState)(null),[eN,ej]=(0,a.useState)(null),[ev,ek]=(0,a.useState)(!1),[eS,eC]=(0,a.useState)(null),[eA,eE]=(0,a.useState)(!1),[eI,eT]=(0,a.useState)("USD1"),[eF,eL]=(0,a.useState)(null),[eD,eB]=(0,a.useState)(!1),[eR,eP]=(0,a.useState)(!1),e$=(0,a.useRef)(null),eO=(0,a.useRef)(null),e_=(0,a.useRef)(null),{eoaAddress:eU}=(0,h.v)(),{derivedSafeAddressFromEoa:eM}=(0,p.A)(eU),{wallets:eK,ready:ez}=(0,R.u)(),{ready:eW,user:eq}=(0,P.u)(),eG=(0,a.useContext)(g.v),eJ=eG?.relayClient||null,eX=eG?.safeAddress||eM,eH=eG?.isTradingSessionComplete,eV=eG?.initializeTradingSession,eY=eG?.currentStep||"idle",eQ=eG?.sessionError,eZ=eG?.isGeoblocked||!1,e0=eG?.geoblockStatus,{solanaAddress:e1,source:e4,isLoading:e2}=(0,v.d)(),{signAndSendTransaction:e3}=(0,$.y2)(),{wallets:e5,ready:e6}=(0,O.u)(),e8="privy"===e4&&e1&&e6?e5.find(e=>{let t=e.address??e.accounts?.[0]?.address;return t?.toLowerCase()===e1.toLowerCase()})??null:null,e7=(0,i.jE)(),e9="privy"===e4?eq?.id??null:null,{data:te,isLoading:tt,refetch:tr}=(0,k.s)(e&&"kalshi"===u?e1:null,e4,e9),{data:ts,isLoading:ta,refetch:ti}=(0,S.d)(e&&"kalshi"===u?e1:null),{usdcBalance:tn,usdcBalanceFormatted:tl,ethBalanceFormatted:to,isLoading:tc,refetch:td}=(0,C.F)(e&&"limitless"===u?eU:void 0),{data:tm,isLoading:tu,refetch:tx}=(0,z.Rr)(eU,e&&("myriad"===u||"predictfun"===u)),{data:th,isLoading:tp,error:tf}=(0,f.i)({walletAddress:eX||null,enabled:e&&"polymarket"===u&&"deposit"===J&&!!eX}),{isTransferring:tg,error:ty,transferUsdc:tb}=function(){let[e,t]=(0,a.useState)(!1),[r,s]=(0,a.useState)(null);return{isTransferring:e,error:r,transferUsdc:(0,a.useCallback)(async(e,r)=>{t(!0),s(null);try{let t=(e=>{let{recipient:t,amount:r}=e,s=(0,b.p)({abi:w.xw,functionName:"transfer",args:[t,r]});return{to:N.Gi,operation:y.OperationType.Call,data:s,value:"0"}})(r),s=await e.execute([t],`Transfer USDC.e to ${r.recipient}`);return await s.wait(),!0}catch(t){let e=t instanceof Error?t:Error("Failed to transfer USDC.e");throw s(e),console.error("Transfer error:",e),e}finally{t(!1)}},[])}}(),{formattedUsdcBalance:tw,rawUsdcBalance:tN}=(0,j.A)(eX);(0,a.useEffect)(()=>{e&&(G(r),Q(""),ee(""),er(!1),V(null),ea(null),ef(null),eC(null),eL(null),eT("predictfun"===r?"USDT":"USD1"),eh("USDC"),ew(null),ej(null))},[e,r]),(0,a.useEffect)(()=>{"predictfun"===u&&"USD1"===eI&&eT("USDT")},[u,eI]),(0,a.useEffect)(()=>((ty||es)&&(en(!0),e_.current&&clearTimeout(e_.current),e_.current=setTimeout(()=>{ea(null),en(!1)},3e3)),()=>{e_.current&&clearTimeout(e_.current)}),[ty,es]),(0,a.useEffect)(()=>(eO.current&&clearTimeout(eO.current),()=>{eO.current&&clearTimeout(eO.current)}),[]),(0,a.useEffect)(()=>{let r=e=>{e$.current&&!e$.current.contains(e.target)&&t()};if(e)return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[e,t]),(0,a.useEffect)(()=>{let r=r=>{"Escape"===r.key&&e&&t()};if(e)return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[e,t]),(0,a.useEffect)(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="unset",()=>{document.body.style.overflow="unset"}),[e]);let tj=(e,t)=>{e&&(x()(e),V(t),eO.current&&clearTimeout(eO.current),eO.current=setTimeout(()=>{V(null)},2e3))},tv=(0,a.useCallback)(async()=>
1{if(!eg){ey(!0);try{await Promise.all([tr(),ti()])}finally{ey(!1)}}},[tr,ti,eg]),tk=(0,a.useCallback)(async()=>{if(!eA&&td){eE(!0);try{await td()}finally{eE(!1)}}},[td,eA]),tS=(0,a.useCallback)(async()=>{if(!eR){eP(!0);try{await tx()}finally{eP(!1)}}},[tx,eR]),tC=async()=>{if(!eJ||!Y||!Z)return;let e=Y.trim();if(!(0,E.P)(e)){ea("Invalid Address"),en(!0),e_.current&&clearTimeout(e_.current),e_.current=setTimeout(()=>{ea(null),en(!1)},3e3);return}ea(null),en(!1);try{let r=(0,I.X)(Z,N.$X);await tb(eJ,{recipient:e,amount:r}),er(!0),(0,A.showSuccessNotification)("Withdrawal successful",`${Z} USDC.e withdrawn successfully.`),setTimeout(()=>{t(),er(!1)},2e3)}catch(e){console.error("Transfer failed:",e)}},tA=(0,a.useCallback)(e=>{try{return new _.J3(e),!0}catch{return!1}},[]),tE=(0,a.useCallback)(async()=>{let e=Y.trim(),t=parseFloat(Z);if(!e1||!e||!Z)return void ef("Please enter recipient and amount.");if(!tA(e))return void ef("Invalid Solana address.");if(isNaN(t)||t<=0)return void ef("Please enter a valid SOL amount.");let r=Math.floor(t*_.Sr);if(r+5e3>(te?.lamports??0))return void ef("Insufficient SOL balance.");ef(null),ed(!0);try{let t=new _.Ng(q,"confirmed"),{blockhash:s,lastValidBlockHeight:a}=await t.getLatestBlockhash("confirmed"),i=new _.J3(e1),n=new _.J3(e),l=_.yq.transfer({fromPubkey:i,toPubkey:n,lamports:r}),o=new _.wu({payerKey:i,recentBlockhash:s,instructions:[l]}).compileToV0Message(),c=new _.Kt(o).serialize();if("privy"===e4){if(!e8)throw Error("Privy Solana wallet not found. Please reconnect.");let e=new Uint8Array(c),t=(await e3({transaction:e,wallet:e8,chain:"solana:mainnet",options:{uiOptions:{showWalletUIs:!0}}})).signature;if(!t?.length)throw Error("No signature from Privy")}else if("phantom"===e4){let e=window.phantom?.solana;if(!e||"function"!=typeof e.signAndSendTransaction)throw Error("Phantom wallet not found. Please install or unlock Phantom.");let t=_.Kt.deserialize(c);await e.signAndSendTransaction(t,{skipPreflight:!1,maxRetries:3})}else throw Error("Connect your Phantom or Privy Solana wallet to withdraw.");ew(Z),ej("SOL"),er(!0),Q(""),ee(""),(0,A.showSuccessNotification)("Withdrawal successful",`${Z} SOL withdrawn successfully.`),e1&&(e7.invalidateQueries({queryKey:["solana-balance",e1]}),e7.invalidateQueries({queryKey:["usdc-balance",e1]})),setTimeout(()=>{er(!1),ew(null),ej(null)},3e3)}catch(e){ef(e instanceof Error?e.message:"Withdraw failed.")}finally{ed(!1)}},[Y,Z,e1,e4,te?.lamports,tA,e8,e3,e7]),tI=(0,a.useCallback)(async()=>{let e=Y.trim(),t=parseFloat(Z);if(!e1||!e||!Z)return void ef("Please enter recipient and amount.");if(!tA(e))return void ef("Invalid Solana address.");if(isNaN(t)||t<=0)return void ef("Please enter a valid USDC amount.");let r=BigInt(Math.floor(1e6*t));if(r>BigInt(ts?.rawAmount??"0"))return void ef("Insufficient USDC balance.");ef(null),eu(!0);try{let t=new _.Ng(q,"confirmed"),s=new _.J3("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),a=new _.J3(e1),i=new _.J3(e),n=(0,U.Xt)(s,a),l=(0,U.Xt)(s,i),o=[];await t.getAccountInfo(l)||o.push((0,M.JA)(a,l,i,s)),o.push((0,K.fl)(n,s,l,a,r,6));let{blockhash:c,lastValidBlockHeight:d}=await t.getLatestBlockhash("confirmed"),m=new _.wu({payerKey:a,recentBlockhash:c,instructions:o}).compileToV0Message(),u=new _.Kt(m).serialize();if("privy"===e4){if(!e8)throw Error("Privy Solana wallet not found. Please reconnect.");let e=new Uint8Array(u);await e3({transaction:e,wallet:e8,chain:"solana:mainnet",options:{uiOptions:{showWalletUIs:!0}}})}else if("phantom"===e4){let e=window.phantom?.solana;if(!e||"function"!=typeof e.signAndSendTransaction)throw Error("Phantom wallet not found. Please install or unlock Phantom.");let t=_.Kt.deserialize(u);await e.signAndSendTransaction(t,{skipPreflight:!1,maxRetries:3})}else throw Error("Connect your Phantom or Privy Solana wallet to withdraw.");ew(Z),ej("USDC"),er(!0),Q(""),ee(""),(0,A.showSuccessNotification)("Withdrawal successful",`${Z} USDC withdrawn successfully.`),e1&&(e7.invalidateQueries({queryKey:["usdc-balance",e1]}),e7.invalidateQueries({queryKey:["solana-balance",e1]})),setTimeout(()=>{er(!1),ew(null),ej(null)},3e3)}catch(e){ef(e instanceof Error?e.message:"USDC withdraw failed.")}finally{eu(!1)}},[Y,Z,e1,e4,ts?.rawAmount,tA,e8,e3,e7]),tT=(0,a.useCallback)(async()=>{let e=Y.trim(),t=parseFloat(Z);if(!eU||!e||!Z)return void eC("Please enter recipient and amount.");if(!(0,E.P)(e))return void eC("Invalid EVM address.");
1if(isNaN(t)||t<=0)return void eC("Please enter a valid USDC amount.");if(t>tn)return void eC("Insufficient USDC balance on Base.");eC(null),ek(!0);try{let t=eK?.find(e=>e.address?.toLowerCase()===eU?.toLowerCase());if(!t)throw Error("Wallet not found. Please connect your wallet.");let r="function"==typeof t.getEthereumProvider?await t.getEthereumProvider():null;if(!r)throw Error("Wallet provider not available. Please connect your wallet.");let s=t.chainId;if(s!==D.E.id&&s!==`eip155:${D.E.id}`&&s!==String(D.E.id)){if("function"!=typeof t.switchChain)throw Error("Cannot switch chain. Please switch your wallet to Base (Chain ID 8453) manually and try again.");await t.switchChain(D.E.id)}let a=(0,T.F)({account:eU,chain:D.E,transport:(0,F.I)(r)}),i=(0,I.X)(Z,N.Xp);await a.writeContract({address:N.JF,abi:w.xw,functionName:"transfer",args:[e,i]}),er(!0),Q(""),ee(""),(0,A.showSuccessNotification)("Withdrawal successful",`${Z} USDC sent on Base.`),td?.(),e7.invalidateQueries({queryKey:["baseBalance",eU]}),setTimeout(()=>er(!1),3e3)}catch(e){eC(e instanceof Error?e.message:"Withdraw failed.")}finally{ek(!1)}},[Y,Z,eU,tn,eK,td,e7]),tF=(0,a.useCallback)(async()=>{let e=Y.trim(),t=parseFloat(Z),r=tm?.usd1??0,s=BigInt(tm?.bnbMaxSendAfterReserveWei??"0");if(!eU||!e||!Z)return void eL("Please enter recipient and amount.");if(!(0,E.P)(e))return void eL("Invalid EVM address.");if(isNaN(t)||t<=0)return void eL("Please enter a valid amount.");if("USD1"===eI){if(t>r)return void eL("Insufficient USD1 balance on BNB Chain.")}else if("USDT"===eI){if(t>(tm?.usdt??0))return void eL("Insufficient USDT balance on BNB Chain.")}else{let e;try{e=(0,L.g)(Z.trim())}catch{eL("Invalid BNB amount.");return}if(e<=BigInt(0))return void eL("Please enter a valid amount.");if(e>s)return void eL(`Exceeds sendable BNB (wallet keeps ~${z.bl} BNB for gas).`)}eL(null),eB(!0);try{let t=eK?.find(e=>e.address?.toLowerCase()===eU?.toLowerCase());if(!t)throw Error("Wallet not found. Please connect your wallet.");let r="function"==typeof t.getEthereumProvider?await t.getEthereumProvider():null;if(!r)throw Error("Wallet provider not available. Please connect your wallet.");let s=t.chainId;if(s!==B.N.id&&s!==`eip155:${B.N.id}`&&s!==String(B.N.id)){if("function"!=typeof t.switchChain)throw Error("Cannot switch chain. Switch your wallet to BNB Smart Chain (56) and try again.");await t.switchChain(B.N.id)}let a=(0,T.F)({account:eU,chain:B.N,transport:(0,F.I)(r)});if("USD1"===eI){let t=(0,I.X)(Z,z.ns);await a.writeContract({address:z.gG,abi:w.xw,functionName:"transfer",args:[e,t]})}else if("USDT"===eI){let t=(0,I.X)(Z,z.ns);await a.writeContract({address:z.Ng,abi:w.xw,functionName:"transfer",args:[e,t]})}else{let t=(0,L.g)(Z);await a.sendTransaction({to:e,value:t})}er(!0),Q(""),ee(""),(0,A.showSuccessNotification)("Withdrawal successful",`${Z} ${eI} sent on BNB Smart Chain.`),tx(),e7.invalidateQueries({queryKey:["myriad-bsc-balances"]}),e7.invalidateQueries({queryKey:["myriad-erc20-balance"]}),e7.invalidateQueries({queryKey:["predictfun-positions"]}),setTimeout(()=>er(!1),3e3)}catch(e){eL(e instanceof Error?e.message:"Withdraw failed.")}finally{eB(!1)}},[Y,Z,eU,eI,tm?.bnbMaxSendAfterReserveWei,tm?.usd1,tm?.usdt,eK,tx,e7]),tL="predictfun"===u,tD="bg-[#ffc000] text-black",tB="focus:border-[#ffc000]",tR="text-[#ffc000]";return e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm z-40"}),(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center z-50 pointer-events-none",children:(0,s.jsxs)("div",{ref:e$,className:"w-125 max-w-[90%] bg-[#0D0D0D] rounded-xl shadow-2xl border border-white/10 pointer-events-auto max-h-[80vh] overflow-y-auto custom-sidebar-scrollbar",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-white/10",children:[(0,s.jsx)("h2",{className:"text-xl font-bold text-white",children:"Deposit & Withdraw"}),(0,s.jsx)("button",{onClick:t,className:"p-2 hover:bg-gray-800 rounded-lg transition text-gray-400 hover:text-white","aria-label":"Close modal",children:(0,s.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,s.jsxs)("div",{className:"mx-4 mt-4 bg-[#141414] p-1 rounded-lg grid grid-cols-5 ga
1p-1",children:[(0,s.jsx)("button",{type:"button",onClick:()=>G("kalshi"),className:`py-2 px-1 rounded-md text-[10px] sm:text-xs font-medium transition-colors text-center leading-tight ${"kalshi"===u?"bg-[#17cb91] text-black":"text-gray-400 hover:text-white"}`,children:"Kalshi"}),(0,s.jsx)("button",{type:"button",onClick:()=>G("polymarket"),className:`py-2 px-1 rounded-md text-[10px] sm:text-xs font-medium transition-colors text-center leading-tight ${"polymarket"===u?"bg-[#2C59F7] text-white":"text-gray-400 hover:text-white"}`,children:"Polymarket"}),(0,s.jsx)("button",{type:"button",onClick:()=>G("limitless"),className:`py-2 px-1 rounded-md text-[10px] sm:text-xs font-medium transition-colors text-center leading-tight ${"limitless"===u?"bg-black text-white border border-white/20":"text-gray-400 hover:text-white"}`,children:"Limitless"}),(0,s.jsx)("button",{type:"button",onClick:()=>G("myriad"),className:`py-2 px-1 rounded-md text-[10px] sm:text-xs font-medium transition-colors text-center leading-tight ${"myriad"===u?"bg-[#ffc000] text-black":"text-gray-400 hover:text-white"}`,children:"Myriad"}),(0,s.jsxs)("button",{type:"button",onClick:()=>{G("predictfun"),eT("USDT")},className:`py-2 px-1 rounded-md text-[10px] sm:text-xs font-medium transition-colors text-center leading-tight ${"predictfun"===u?"bg-[#A855F7] text-white":"text-gray-400 hover:text-white"}`,children:[(0,s.jsx)("span",{className:"sm:hidden",children:"Predict"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"Predict.fun"})]})]}),("polymarket"===u||"kalshi"===u||"limitless"===u||"myriad"===u||"predictfun"===u)&&(0,s.jsxs)("div",{className:"mx-4 mt-2 bg-[#141414] p-1 rounded-lg grid grid-cols-2 gap-1",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>X("deposit"),className:`py-2 px-4 rounded-md text-sm font-medium transition-colors flex items-center justify-center gap-2 ${"deposit"===J?"bg-[#ffc000] text-black":"text-gray-400 hover:text-white"}`,children:[(0,s.jsx)(n.A,{className:"w-4 h-4"}),"Deposit"]}),(0,s.jsxs)("button",{type:"button",onClick:()=>X("withdraw"),className:`py-2 px-4 rounded-md text-sm font-medium transition-colors flex items-center justify-center gap-2 ${"withdraw"===J?"bg-[#ffc000] text-black":"text-gray-400 hover:text-white"}`,children:[(0,s.jsx)(l.A,{className:"w-4 h-4"}),"Withdraw"]})]}),(0,s.jsx)("div",{className:"p-4",children:"kalshi"===u?"deposit"===J?(0,s.jsx)("div",{className:"space-y-4",children:(0,s.jsxs)("div",{className:"bg-white/5 rounded-lg p-4",children:[(0,s.jsx)("h4",{className:"text-white font-semibold mb-3",children:"Solana Wallet (Kalshi)"}),(0,s.jsx)("p",{className:"text-xs text-gray-400 mb-3",children:"Send SOL or USDC to this address to fund your Kalshi trading account."}),e2?(0,s.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,s.jsx)("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-[#17cb91]"})}):e1?(0,s.jsxs)("div",{className:"space-y-3",children:[e4&&(0,s.jsxs)("span",{className:"text-xs text-gray-500",children:["Connected via"," ","phantom"===e4?"Phantom":"Privy"]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("span",{className:"text-gray-400 text-xs",children:"Solana (SVM) Address:"}),(0,s.jsxs)("div",{className:"flex items-center gap-2 bg-black/30 rounded px-2 py-1.5",children:[(0,s.jsx)("span",{className:"text-white text-xs font-mono break-all flex-1 min-w-0",children:e1}),(0,s.jsx)("button",{onClick:()=>tj(e1,"svm"),className:"p-1 hover:bg-white/10 rounded transition-colors shrink-0",title:"Copy Solana address",children:"svm"===H?(0,s.jsx)(o.A,{className:"w-4 h-4 text-green-400"}):(0,s.jsx)(c.A,{className:"w-4 h-4 text-gray-400 hover:text-white"})})]})]}),(0,s.jsxs)("div",{className:"bg-black/30 rounded-lg p-3 mt-2 space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,s.jsx)("p",{className:"text-xs text-gray-400",children:"Wallet Balance"}),(0,s.jsx)("button",{type:"button",onClick:tv,disabled:eg||tt||ta,className:"p-1.5 rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Refresh balance",children:(0,s.jsx)(d.A,{className:`w-4 h-4 text-gray-400 hover:text-[#ffc000] ${eg?"animate-spin":""}`})})]}),(0,s.jsx)("div",{className:"flex flex-col gap-1 text-[14px]",children:ta||tt||eg?(0,s.jsx)("span",{className:"inline-block animate-pulse h-5 w-16 bg-white/10 rounded align-middle"}):(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("span",{className:"text-white/90 font-semibold text-[12px]",children:[ts?.formatted??"0.00"," ","USDC (",(0,s.jsxs)("span",{className:"text-white/90 font-semibold",children:[te?.formatted??"0"," SOL"]}),")"]})})})]})]}):(0,s.jsx)("p",{className:"text-gray-400 text-sm py-2",children:"Connect your Phantom or Privy wallet to see your Solana address."})]})}):(0,s.jsxs)("div",{className:"space-y-4",children:[ep&&(0,s.jsx)("div",{className:"bg-red-500/20 border border-red-500/40 rounded-lg p-3",children:(0,s.jsx)("p",{className:"text-red-300 text-sm",children:ep})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs text-gray-400 mb-2",children:"Withdraw as"}),(0,s.jsxs)("div",{className:"flex rounded-lg overflow-hidden border border-white/10",children:[(0,s.jsx)("button",{type:"button",onClick:()=>{eh("USDC"),ee("")},className:`flex-1 py-2 px-3 text-sm font-medium ${"USDC"===ex?"bg-[#17cb91] text-black":"bg-white/5 text-gray-400 hover:text-white"}`,children:"USDC"}),(0,s.jsx)("button",{type:"button",onClick:()=>{eh("SOL"),ee("")},className:`flex-1 py-2 px-3 text-sm font-medium ${"SOL"===ex?"bg-[#17cb91] text-black":"bg-white/5 text-gray-400 hover:text-white"}`,children:"SOL"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm text-gray-400 mb-2",children:"Recipient (Solana address)"}),(0,s.jsx)("input",{type:"text",value:Y,onChange:e=>Q(e.target.value),placeholder:"e.g. 9NvE68JVWHHHGLp5NNELtM5fiBw6SXHrzqQJjUqaykC1",className:"w-full px-4 py-2 bg-white/5 border border-white/10 rounded-lg focus:outline-none focus:border-[#17cb91] text-white font-mono text-sm",disabled:ec||em})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{className:"block text-sm text-gray-400 mb-2",children:["Available Balance (","USDC"===ex?(ts?.formatted??"0.00 USDC")+" USDC":(te?.formatted??"0")+" SOL",")"]}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{type:"text",value:Z,onChange:e=>ee(e.target.value),placeholder:"USDC"===ex?"0.00":"0.0000",className:"w-full px-4 py-2 pr-16 bg-white/5 border border-white/10 rounded-lg focus:outline-none focus:border-[#17cb91] text-white",disabled:ec||em}),(0,s.jsx)("button",{type:"button",onClick:()=>{"USDC"===ex?ee(ts?.formatted??"0"):ee(te?String(Math.max(0,te.sol-1e-4).toFixed(4)):"0")},className:"absolute right-2 top-1/2 -translate-y-1/2 px-2 py-1 text-xs bg-[#17cb91] hover:bg-[#1ee0a0] rounded text-black font-semibold",children:"MAX"})]})]}),(0,s.jsx)("button",{onClick:"USDC"===ex?tI:tE,disabled:ec||em||!Y.trim()||!Z||!e1||"privy"===e4&&!e8,className:"w-full py-3 bg-[#17cb91] hover:bg-[#1ee0a0] disabled:bg-gray-600 disabled:cursor-not-allowed text-black font-bold rounded-lg transition-colors",children:em||ec?"Sending...":"USDC"===ex?"Send USDC":"Send SOL"}),!e1&&(0,s.jsx)("p",{className:"text-xs text-yellow-400 text-center",children:"Connect your Phantom or Privy Solana wallet to withdraw."})]}):"limitless"===u?"deposit"===J?(0,s.jsx)("div",{className:"space-y-4",children:(0,s.jsxs)("div",{className:"bg-white/5 rounded-lg p-4",children:[(0,s.jsx)("h4",{className:"text-white font-semibold mb-3",children:"Base Wallet (Limitless)"}),(0,s.jsx)("p",{className:"text-xs text-gray-400 mb-3",children:"Send USDC or ETH on Base to this address to fund your Limitless trading."}),eU?(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("span",{className:"text-gray-400 text-xs",children:"Base (EVM) Address:"}),(0,s.jsxs)("div",{className:"flex items-center gap-2 bg-black/30 rounded px-2 py-1.5",children:[(0,s.jsx)("span",{className:"text-white text-xs font-mono break-all flex-1 min-w-0",children:eU}),(0,s.jsx)("button",{onClick:()=>tj(eU,"evm"),className:"p-1 hover:bg-white/10 rounded transition-colors shrink-0",title:"Copy Base address",children:"evm"===
1H?(0,s.jsx)(o.A,{className:"w-4 h-4 text-green-400"}):(0,s.jsx)(c.A,{className:"w-4 h-4 text-gray-400 hover:text-white"})})]})]}),(0,s.jsxs)("div",{className:"bg-black/30 rounded-lg p-3 mt-2 space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,s.jsx)("p",{className:"text-xs text-gray-400",children:"Wallet Balance (Base)"}),(0,s.jsx)("button",{type:"button",onClick:tk,disabled:eA||tc,className:"p-1.5 rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Refresh balance",children:(0,s.jsx)(d.A,{className:`w-4 h-4 text-gray-400 hover:text-[#ffc000] ${eA?"animate-spin":""}`})})]}),(0,s.jsx)("div",{className:"flex flex-col gap-1 text-[14px]",children:tc||eA?(0,s.jsx)("span",{className:"inline-block animate-pulse h-5 w-24 bg-white/10 rounded align-middle"}):(0,s.jsxs)("span",{className:"text-white/90 font-semibold text-[12px]",children:[tl," USDC (",to," ETH)"]})})]})]}):(0,s.jsx)("p",{className:"text-gray-400 text-sm py-2",children:"Connect your wallet to see your Base address."})]})}):(0,s.jsxs)("div",{className:"space-y-4",children:[eS&&(0,s.jsx)("div",{className:"bg-red-500/20 border border-red-500/40 rounded-lg p-3",children:(0,s.jsx)("p",{className:"text-red-300 text-sm",children:eS})}),et&&(0,s.jsx)("div",{className:"bg-green-500/20 border border-green-500/40 rounded-lg p-3",children:(0,s.jsx)("p",{className:"text-green-300 font-medium text-sm",children:"Transfer successful!"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm text-gray-400 mb-2",children:"Recipient (EVM address)"}),(0,s.jsx)("input",{type:"text",value:Y,onChange:e=>Q(e.target.value),placeholder:"0x...",className:"w-full px-4 py-2 bg-white/5 border border-white/10 rounded-lg focus:outline-none focus:border-[#ffc000] text-white font-mono text-sm",disabled:ev})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{className:"block text-sm text-gray-400 mb-2",children:["Available: ",tl," USDC (Base)"]}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{type:"text",value:Z,onChange:e=>ee(e.target.value.replace(/[^0-9.]/g,"")),placeholder:"0.00",className:"w-full px-4 py-2 pr-16 bg-white/5 border border-white/10 rounded-lg focus:outline-none focus:border-[#ffc000] text-white",disabled:ev}),(0,s.jsx)("button",{type:"button",onClick:()=>ee(tl),className:"absolute right-2 top-1/2 -translate-y-1/2 px-2 py-1 text-xs bg-[#ffc000] hover:bg-[#ffd000] rounded text-black font-semibold",children:"MAX"})]})]}),(0,s.jsx)("button",{onClick:tT,disabled:ev||!Y.trim()||!Z||!eU||tn<=0,className:"w-full py-3 bg-[#ffc000] hover:bg-[#ffd000] disabled:bg-gray-600 disabled:cursor-not-allowed text-black font-bold rounded-lg transition-colors",children:ev?"Sending...":"Send USDC (Base)"}),!eU&&(0,s.jsx)("p",{className:"text-xs text-yellow-400 text-center",children:"Connect your wallet to withdraw."})]}):"myriad"===u||"predictfun"===u?"deposit"===J?(0,s.jsx)("div",{className:"space-y-4",children:(0,s.jsxs)("div",{className:"bg-white/5 rounded-lg p-4",children:[(0,s.jsxs)("h4",{className:"text-white font-semibold mb-3",children:["BNB Smart Chain (","predictfun"===u?"Predict.fun":"Myriad",")"]}),(0,s.jsxs)("div",{className:"flex gap-3 rounded-lg border border-amber-500/35 bg-amber-950/35 px-3 py-2.5 mb-3",role:"note",children:[(0,s.jsx)("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full",children:(0,s.jsx)(m.A,{className:"h-4 w-4 text-amber-300","aria-hidden":!0})}),(0,s.jsx)("p",{className:"text-[13px] leading-snug text-amber-200/95",children:"predictfun"===u?(0,s.jsxs)(s.Fragment,{children:["Only send"," ",(0,s.jsx)("strong",{className:"font-semibold text-amber-100",children:"USDT"})," ","(BEP-20) on"," ",(0,s.jsx)("strong",{className:"font-semibold text-amber-100",children:"BNB Smart Chain"})," ","to this address to trade on Predict.fun."]}):(0,s.jsxs)(s.Fragment,{children:["Only send"," ",(0,s.jsx)("strong",{className:"font-semibold text-amber-100",children:"USD1"})," ","or"," ",(0,s.jsx)("strong",{className:"font-semibold text-amber-100",children:"USDT"})," ","(BEP-20) on"," ",(0,s.jsx)("strong",{className:"font-semibold text-amber-100",children:"BNB Smart Chain"})," ","to this address to trade on Myriad."]})})]}),eU?(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("span",{className:"text-gray-400 text-xs",children:"BNB Chain (EVM) address"}),(0,s.jsxs)("div",{className:"flex items-center gap-2 bg-black/30 rounded px-2 py-1.5",children:[(0,s.jsx)("span",{className:"text-white text-xs font-mono break-all flex-1 min-w-0",children:eU}),(0,s.jsx)("button",{type:"button",onClick:()=>tj(eU,"evm"),className:"p-1 hover:bg-white/10 rounded transition-colors shrink-0",title:"Copy address",children:"evm"===
1H?(0,s.jsx)(o.A,{className:"w-4 h-4 text-green-400"}):(0,s.jsx)(c.A,{className:"w-4 h-4 text-gray-400 hover:text-white"})})]})]}),(0,s.jsxs)("div",{className:"bg-black/30 rounded-lg p-3 mt-2 space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,s.jsx)("p",{className:"text-xs text-gray-400",children:"Wallet balance (BNB Chain)"}),(0,s.jsx)("button",{type:"button",onClick:()=>void tS(),disabled:eR||tu,className:"p-1.5 rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Refresh",children:(0,s.jsx)(d.A,{className:`w-4 h-4 text-gray-400 hover:text-[#ffc000] ${eR?"animate-spin":""}`})})]}),tu||eR?(0,s.jsx)("span",{className:"inline-block animate-pulse h-5 w-32 bg-white/10 rounded"}):(0,s.jsxs)("div",{className:"flex flex-col gap-1 text-[14px]",children:[tL?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{className:`text-white/90 font-semibold text-lg tabular-nums ${tR}`,children:[tm?.usdtFormatted??"0"," USDT"]}),(0,s.jsxs)("span",{className:"text-white/90 font-semibold text-[12px] break-words",children:[tm?.bnbFormatted??"0"," BNB (gas)"]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:`text-white/90 font-semibold text-lg tabular-nums ${tR}`,children:(0,W.vv)(tm?.totalUsdApprox??0)}),(0,s.jsxs)("span",{className:"text-white/90 font-semibold text-[12px] break-words",children:[tm?.bnbFormatted??"0"," BNB \xb7"," ",tm?.usd1Formatted??"0"," USD1 \xb7"," ",tm?.usdtFormatted??"0"," USDT"]}),(tm?.usdc??0)>0&&(0,s.jsx)("span",{className:"text-[11px] text-gray-500",children:"USDC included in total above"})]}),(0,s.jsxs)("p",{className:"text-[11px] text-gray-500 leading-snug pt-1 border-t border-white/10 mt-1",children:["Keep native BNB on this chain for gas (trades, transfers). As a rule of thumb, leave at least"," ",(0,s.jsxs)("span",{className:"text-gray-400 font-medium",children:[z.bl," BNB"]})," ","or more if you trade often."]})]})]})]}):(0,s.jsx)("p",{className:"text-gray-400 text-sm py-2",children:"Connect your wallet to see your BNB Chain address."})]})}):(0,s.jsxs)("div",{className:"space-y-4",children:[eF&&(0,s.jsx)("div",{className:"bg-red-500/20 border border-red-500/40 rounded-lg p-3",children:(0,s.jsx)("p",{className:"text-red-300 text-sm",children:eF})}),et&&(0,s.jsx)("div",{className:"bg-green-500/20 border border-green-500/40 rounded-lg p-3",children:(0,s.jsx)("p",{className:"text-green-300 font-medium text-sm",children:"Transfer successful!"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs text-gray-400 mb-2",children:"Withdraw asset"}),(0,s.jsxs)("div",{className:`grid ${tL?"grid-cols-2":"grid-cols-3"} rounded-lg overflow-hidden border border-white/10`,children:[(0,s.jsx)("button",{type:"button",onClick:()=>{eT("BNB"),ee("")},className:`py-2 px-2 text-xs sm:text-sm font-medium ${"BNB"===eI?tD:"bg-white/5 text-gray-400 hover:text-white"}`,children:"BNB"}),!tL&&(0,s.jsx)("button",{type:"button",onClick:()=>{eT("USD1"),ee("")},className:`py-2 px-2 text-xs sm:text-sm font-medium border-l border-white/10 ${"USD1"===eI?tD:"bg-white/5 text-gray-400 hover:text-white"}`,children:"USD1"}),(0,s.jsx)("button",{type:"button",onClick:()=>{eT("USDT"),ee("")},className:`py-2 px-2 text-xs sm:text-sm font-medium border-l border-white/10 ${"USDT"===eI?tD:"bg-white/5 text-gray-400 hover:text-white"}`,children:"USDT"})]}),(0,s.jsx)("p",{className:"text-[11px] text-gray-500 mt-1.5",children:tL?"Native BNB or BEP-20 USDT on BNB Smart Chain. Switch network if prompted.":"Native BNB or BEP-20 USD1 / USDT on BNB Smart Chain. Switch network if prompted."}),"BNB"===eI?(0,s.jsxs)("div",{className:"flex gap-2.5 rounded-lg border border-amber-500/35 bg-amber-950/35 px-3 py-2.5 mt-2",role:"note",children:[(0,s.jsx)(m.A,{className:"h-4 w-4 shrink-0 text-amber-300 mt-0.5","aria-hidden":!0}),(0,s.jsxs)("p",{className:"text-[12px] leading-snug text-amber-100/95",children:[(0,s.jsx)("span",{className:"font-semibold text-amber-50",children:"BNB gas reserve: "}),"Max withdraw leaves about"," ",(0,s.jsxs)("strong",{className:"font-semibold text-amber-50",children:[z.bl," BNB"]})," ","in your wallet so you can still pay network fees on BNB Smart Chain."," ",(0,s.jsxs)("span",{className:"text-amber-200/90",children:["The ",(0,s.jsx)("strong",{className:"text-amber-100",children:"MAX"})," button only fills the amount above that reserve."]})]})]}):(0,s.jsxs)("p",{className:"text-[11px] text-gray-500 mt-2 leading-snug",children:["Sending ",tL?"USDT":"USD1 or USDT"," still uses a small amount of ",(0,s.jsx)("span",{className:"text-gray-400",children:"BNB"})," for gas—keep native BNB in this wallet (e.g. at least ~",z.bl," BNB)."]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm text-gray-400 mb-2",children:"Recipient (EVM address)"}),(0,s.jsx)("input",{type:"text",value:Y,onChange:e=>Q(e.target.value),placeholder:"0x...",className:`w-full px-4 py-2 bg-white/5 border border-white/10 rounded-lg focus:outline-none ${tB} text-white font-mono text-sm`,disabled:eD})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{className:"block text-sm text-gray-400 mb-2",children:[!tL&&(0,s.jsxs)(s.Fragment,{children:["Total balance (est.):"," ",(0,W.vv)(tm?.totalUsdApprox??0)," \xb7"," "]}),"Available to send:"," ","USD1"===eI?`${tm?.usd1Formatted??"0"} USD1`:"USDT"===eI?`${tm?.usdtFormatted??"0"} USDT`:`${tm?.bnbMaxSendAfterReserveFormatted??"0"} BNB`," ","BNB"===eI?`\xb7 Wallet: ${tm?.bnbFormatted??"0"} BNB (BNB Chain)`:"(BNB Chain)"]}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{type:"text",value:Z,onChange:e=>ee(e.target.value.replace(/[^0-9.]/g,"")),placeholder:"BNB"===eI?"0.0000":"0.00",className:`w-full px-4 py-2 pr-16 bg-white/5 border border-white/10 rounded-lg focus:outline-none ${tB} text-white`,disabled:eD}),(0,s.jsx)("button",{type:"button",onClick:()=>{"USD1"===eI?ee(tm?.usd1Formatted??"0"):"USDT"===eI?ee(tm?.usdtFormatted??"0"):ee(tm?.bnbMaxSendAfterReserveFormatted??"0")},className:"absolute right-2 top-1/2 -translate-y-1/2 px-2 py-1 text-xs rounded font-semibold bg-[#ffc000] hover:bg-[#ffd000] text-black",children:"MAX"})]})]}),(0,s.jsx)("button",{type:"button",onClick:()=>void tF(),disabled:eD||!Y.trim()||!Z||!eU||("USD1"===eI?(tm?.usd1??0)<=0:"USDT"===eI?(tm?.usdt??0)<=0:BigInt(tm?.bnbMaxSendAfterReserveWei??"0")===BigInt(0)),className:"w-full py-3 disabled:cursor-not-allowed font-bold rounded-lg transition-colors bg-[#ffc000] hover:bg-[#ffd000] disabled:bg-gray-600 disabled:cursor-not-allowed text-black",children:eD?"Sending...":"BNB"===eI?"Send BNB":"USD1"===eI?"Send USD1":"Send USDT"}),!eU&&(0,s.jsx)("p",{className:"text-xs text-yellow-400 text-center",children:"Connect your wallet to withdraw."})]}):"deposit"===J?(0,s.jsx)("div",{className:"space-y-4",children:eX?(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("div",{className:"bg-white/5 rounded-lg p-4",children:[(0,s.jsx)("h4",{className:"text-white font-semibold mb-3",children:"Deposit Addresses"}),(0,s.jsx)("p",{className:"text-xs text-gray-400 mb-3",children:"Send assets to these addresses to bridge and swap to USDC.e on Polygon for trading."}),tp?(0,s.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,s.jsx)("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-[#ffc000]"})}):tf?(0,s.jsx)("div",{className:"text-red-400 text-sm py-2",children:"Failed to load deposit addresses. Please try again later."}):th?.address?(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("span",{className:"text-gray-400 text-xs",children:"Polygon (USDC.e):"}),(0,s.jsxs)("div",{className:"flex items-center gap-2 bg-black/30 rounded px-2 py-1.5",children:[(0,s.jsx)("span",{className:"text-white text-xs font-mono break-all flex-1 min-w-0",children:th.address.evm}),(0,s.jsx)("button",{onClick:()=>tj(th.address.evm,"evm"),className:"p-1 hover:bg-white/10 rounded transition-colors shrink-0",title:"Copy Polygon address",children:"evm"===
1H?(0,s.jsx)(o.A,{className:"w-4 h-4 text-green-400"}):(0,s.jsx)(c.A,{className:"w-4 h-4 text-gray-400 hover:text-white"})})]})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("span",{className:"text-gray-400 text-xs",children:"Solana (SVM):"}),(0,s.jsxs)("div",{className:"flex items-center gap-2 bg-black/30 rounded px-2 py-1.5",children:[(0,s.jsx)("span",{className:"text-white text-xs font-mono break-all flex-1 min-w-0",children:th.address.svm}),(0,s.jsx)("button",{onClick:()=>tj(th.address.svm,"svm"),className:"p-1 hover:bg-white/10 rounded transition-colors shrink-0",title:"Copy Solana address",children:"svm"===H?(0,s.jsx)(o.A,{className:"w-4 h-4 text-green-400"}):(0,s.jsx)(c.A,{className:"w-4 h-4 text-gray-400 hover:text-white"})})]})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("span",{className:"text-gray-400 text-xs",children:"Bitcoin:"}),(0,s.jsxs)("div",{className:"flex items-center gap-2 bg-black/30 rounded px-2 py-1.5",children:[(0,s.jsx)("span",{className:"text-white text-xs font-mono break-all flex-1 min-w-0",children:th.address.btc}),(0,s.jsx)("button",{onClick:()=>tj(th.address.btc,"btc"),className:"p-1 hover:bg-white/10 rounded transition-colors shrink-0",title:"Copy Bitcoin address",children:"btc"===H?(0,s.jsx)(o.A,{className:"w-4 h-4 text-green-400"}):(0,s.jsx)(c.A,{className:"w-4 h-4 text-gray-400 hover:text-white"})})]})]}),th.note&&(0,s.jsx)("p",{className:"text-xs text-gray-500 mt-2 italic",children:th.note})]}):(0,s.jsx)("div",{className:"text-gray-400 text-sm py-2",children:"No deposit addresses available."})]})}):(0,s.jsx)("div",{className:"text-center py-8 space-y-3",children:eW&&ez?(0,s.jsx)("p",{className:"text-gray-400",children:"Please connect your wallet to view deposit addresses. If you just logged in, your wallet may still be initializing."}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"flex items-center justify-center",children:(0,s.jsx)("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-[#ffc000]"})}),(0,s.jsx)("p",{className:"text-gray-400",children:"Setting up your wallet..."})]})})}):(0,s.jsxs)("div",{className:"space-y-4",children:[et&&(0,s.jsx)("div",{className:"bg-green-500/20 border border-green-500/40 rounded-lg p-3",children:(0,s.jsx)("p",{className:"text-green-300 font-medium text-sm",children:"Transfer successful!"})}),ty&&ei&&(0,s.jsx)("div",{className:"bg-red-500/20 border border-red-500/40 rounded-lg p-3",children:(0,s.jsx)("p",{className:"text-red-300 text-sm",children:(()=>{if(!ty)return null;let e=ty.message?.toLowerCase()||"",t=ty.toString().toLowerCase();return e.includes("invalid address")||e.includes("invalid recipient")||e.includes("checksum")||e.includes("address format")||t.includes("invalid address")||t.includes("invalid recipient")?"Invalid Address":ty.message||"An error occurred"})()})}),es&&ei&&(0,s.jsx)("div",{className:"bg-red-500/20 border border-red-500/40 rounded-lg p-3",children:(0,s.jsx)("p",{className:"text-red-300 text-sm",children:es})}),(0,s.jsxs)("div",{className:"bg-white/5 rounded-lg p-3",children:[(0,s.jsx)("p",{className:"text-xs text-gray-400 mb-1",children:"Available Balance"}),(0,s.jsxs)("p",{className:"text-lg font-bold",children:["$",tw," USDC.e"]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm text-gray-400 mb-2",children:"Recipient Address"}),(0,s.jsx)("input",{type:"text",value:Y,onChange:e=>Q(e.target.value),placeholder:"0x...",className:"w-full px-4 py-2 bg-white/5 border border-white/10 rounded-lg focus:outline-none focus:border-[#ffc000] text-white font-mono text-sm",disabled:tg})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm text-gray-400 mb-2",children:"Amount (USDC.e)"}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("input",{type:"text",value:Z,onChange:e=>ee(e.target.value),placeholder:"0.00",className:"w-full px-4 py-2 pr-16 bg-white/5 border border-white/10 rounded-lg focus:outline-none focus:border-[#ffc000] text-white",disabled:tg}),(0,s.jsx)("button",{type:"button",onClick:()=>{tN&&ee((Number(tN)/10**N.$X).toString())},className:"absolute right-2 top-1/2 -translate-y-1/2 px-2 py-1 text-xs bg-[#ffc000] hover:bg-[#ffd000] rounded text-black font-semibold",children:"MAX"})]})]}),(0,s.jsx)("button",{onClick:tC,disabled:tg||!Y||!Z||!eJ||!eX,className:"w-full py-3 bg-[#ffc000] hover:bg-[#ffd000] disabled:bg-gray-600 disabled:cursor-not-allowed text-black font-bold rounded-lg transition-colors",children:tg?"Sending...":"Send USDC.e"}),!eJ&&eU&&eV&&(0,s.jsxs)("div",{className:"space-y-3 mt-2",children:[(0,s.jsx)("button",{onClick:async()=>
1{if(eV){eo(!0);try{await eV()}catch(e){console.error("Failed to initialize trading:",e)}finally{eo(!1)}}},disabled:el||"idle"!==eY||eH||eZ,className:"w-full px-6 py-3 bg-[#ffc000] text-black font-semibold rounded-lg hover:bg-[#ffd633] transition-colors disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-[#ffc000]",children:el||"idle"!==eY?(0,s.jsxs)("span",{className:"flex items-center justify-center gap-2",children:[(0,s.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-black"}),"checking"===eY?"Checking...":"deploying"===eY?"Deploying Safe...":"credentials"===eY?"Setting up credentials...":"approvals"===eY?"Setting approvals...":"Initializing..."]}):eZ?"Trading not available in your region":"Initialize Trading"}),eZ&&!el&&"idle"===eY&&(0,s.jsx)("p",{className:"text-yellow-400 text-sm text-center",children:e0?.country||e0?.region?`Trading is not available in your region (${e0.country}${e0.region?`, ${e0.region}`:""}). Polymarket is geoblocked in your location.`:"Trading is not available in your region. Polymarket is geoblocked in your location."}),eQ&&(0,s.jsx)("p",{className:"text-red-400 text-sm text-center",children:eQ.message||"Failed to initialize trading session"})]}),!eJ&&!eU&&(0,s.jsx)("p",{className:"text-xs text-yellow-400 mt-2 text-center",children:"Please connect your wallet first"}),!eJ&&eU&&!eV&&(0,s.jsx)("p",{className:"text-xs text-yellow-400 mt-2 text-center",children:"Start a trading session first"})]})})]})})]}):null}},21832:(e,t,r)=>{"use strict";r.d(t,{BQ:()=>i,ZU:()=>o,bJ:()=>a,rh:()=>c,rz:()=>n,xq:()=>d});let s="predictfun_redeem_locks:";function a(e){return`${e.conditionId}:${e.indexSet}:${+!!e.isNegRisk}:${+!!e.isYieldBearing}`}function i(e,t){if(!e)return new Set;try{let r=localStorage.getItem(`${s}${e.toLowerCase()}:${t}`);if(!r)return new Set;let a=JSON.parse(r),i=Date.now();return new Set(Object.entries(a).filter(([,e])=>Number.isFinite(e)&&e>i).map(([e])=>e))}catch{return new Set}}function n(e,t,r){let a=Date.now(),i={};r.forEach(e=>{i[e]=a+3e5}),localStorage.setItem(`${s}${e.toLowerCase()}:${t}`,JSON.stringify(i))}function l(e,t){return`predictfun_redeem_history:${e.toLowerCase()}:${t}`}function o(e,t){if(!e)return[];try{let r=localStorage.getItem(l(e,t));if(!r)return[];let s=JSON.parse(r);return Array.isArray(s)?s:[]}catch{return[]}}function c(e,t,r){let s=[r,...o(e,t).filter(e=>e.key!==r.key)].slice(0,100);localStorage.setItem(l(e,t),JSON.stringify(s))}function d(e){return e.map(e=>({key:`redeem-${e.key}`,marketId:e.marketId,marketTitle:e.marketTitle,slugForLink:e.slugForLink,sideLabel:`REDEEM ${e.outcome}`.trim(),sideTone:"neutral",priceDisplay:"—",sizeDisplay:e.shares.toLocaleString(void 0,{maximumFractionDigits:4}),role:"—",statusLabel:"REDEEMED",statusStyle:"confirmed",timeStr:new Date(e.redeemedAt).toLocaleString(),sortTime:e.redeemedAt}))}},24449:(e,t,r)=>{"use strict";r.d(t,{A:()=>n});var s=r(56693),a=r(24211),i=r(10877);
1function n(e,t){let[r,n]=(0,s.useState)(!1),[l,o]=(0,s.useState)(null),[c,d]=(0,s.useState)(null),m=(0,a.jE)();return{submitOrder:(0,s.useCallback)(async r=>{if(!t)throw Error("Wallet not connected");if(!e)throw Error("CLOB client not initialized");n(!0),o(null),d(null);try{let t,s="BUY"===r.side?i.mn.BUY:i.mn.SELL;if(r.isMarketOrder){let a;try{let t=await e.getPrice(r.tokenId,s),i=parseFloat(t.price);if(isNaN(i)||i<=0||i>=1)throw Error("Invalid price from orderbook");a="BUY"===r.side?Math.min(.99,1.05*i):Math.max(.01,.95*i)}catch(e){a="BUY"===r.side?.99:.01}let n={tokenID:r.tokenId,price:a,size:r.size,side:s,feeRateBps:0,expiration:0,taker:"0x0000000000000000000000000000000000000000"};t=await e.createAndPostOrder(n,{negRisk:r.negRisk},i.ZN.GTC)}else{if(!r.price)throw Error("Price required for limit orders");let a={tokenID:r.tokenId,price:r.price,size:r.size,side:s,feeRateBps:0,expiration:0,taker:"0x0000000000000000000000000000000000000000"};t=await e.createAndPostOrder(a,{negRisk:r.negRisk},i.ZN.GTC)}if(t?.error){let e;throw e="string"==typeof t.error?t.error:t.error?.error?"string"==typeof t.error.error?t.error.error:JSON.stringify(t.error.error):"object"==typeof t.error?t.error.message||JSON.stringify(t.error):String(t.error),Error(e)}if(t&&"object"==typeof t&&!t.orderID&&"error"in t){let e;throw e="string"==typeof t.error?t.error:t.error?.error?"string"==typeof t.error.error?t.error.error:JSON.stringify(t.error.error):JSON.stringify(t.error),Error(e)}if(t?.orderID)return d(t.orderID),m.invalidateQueries({queryKey:["active-orders"]}),m.invalidateQueries({queryKey:["polymarket-positions"]}),{success:!0,orderId:t.orderID};throw Error("Order submission failed - unexpected response format")}catch(r){let e="Failed to submit order";if(r instanceof Error)e=r.message;else if(r?.response?.data?.error)e="string"==typeof r.response.data.error?r.response.data.error:JSON.stringify(r.response.data.error);else if(r?.response?.data&&"object"==typeof r.response.data)e=r.response.data.error?"string"==typeof r.response.data.error?r.response.data.error:JSON.stringify(r.response.data.error):r.response.data.message||JSON.stringify(r.response.data);else if(r?.response?.data&&"string"==typeof r.response.data)try{let t=JSON.parse(r.response.data);e=t.error||t.message||e}catch{e=r.response.data}else r?.data?.error?e="string"==typeof r.data.error?r.data.error:JSON.stringify(r.data.error):r?.error?e="string"==typeof r.error?r.error:JSON.stringify(r.error):r?.message?e=r.message:"string"==typeof r&&(e=r);let t=Error(e);throw o(t),t}finally{n(!1)}},[e,t,m]),cancelOrder:(0,s.useCallback)(async t=>{if(!e)throw Error("CLOB client not initialized");n(!0),o(null);try{return await e.cancelOrder({orderID:t}),m.invalidateQueries({queryKey:["active-orders"]}),{success:!0}}catch(r){let e="Failed to cancel order";if(r?.response?.data?.error)e=r.response.data.error;else if(r?.response?.data&&"object"==typeof r.response.data)e=r.response.data.error||r.response.data.message||JSON.stringify(r.response.data);else if(r?.response?.data&&"string"==typeof r.response.data)try{let t=JSON.parse(r.response.data);e=t.error||t.message||e}catch{e=r.response.data}else r?.data?.error?e=r.data.error:r?.error?e="string"==typeof r.error?r.error:JSON.stringify(r.error):r?.message?e=r.message:"string"==typeof r&&(e=r);let t=Error(e);throw o(t),t}finally{n(!1)}},[e,m]),isSubmitting:r,error:l,orderId:c}}},28507:(e,t,r)=>{"use strict";r.d(t,{$u:()=>s.$u,Fy:()=>s.Fy,Ni:()=>a,tD:()=>s.tD,ww:()=>s.ww});var s=r(99183);let a=137},29604:(e,t,r)=>{"use strict";r.d(t,{OP:()=>s,Rp:()=>n,c3:()=>a,ze:()=>i});let s=100;function a(e){let t="string"==typeof e?e:"";return(t=function(e,t=s){if(!e||t<=0)return"";let r=Array.from(e.matchAll(/\S+/g));if(r.length<=t)return e;let a=r[t-1],i=(a.index??0)+a[0].length;return e.slice(0,i)}(t=t.replace(/\u0000/g,""),s)).length>8e3&&(t=t.slice(0,8e3)),t.trimEnd()}function i(e){let t=(e||"").trim().match(/\S+/g);return t?t.length:0}function n(e,t,r){let s=(a(t)||"There are no updates from the team.").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").split("\n"),i=function(e){if(!e)return null;let t=function(e){let t=(e||"").trim();if(!t)return null;let r=new Date(/(?:z|[+-]\d{2}:\d{2})$/i.test(t)?t:`${t}Z`);return Number.isNaN(r.getTime())?null:r}(e);
1return t?t.toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):null}(r),n=i&&`Last published: ${i}`,l={title:"Team Updates",body:n?[n,"",...s]:s,id:"rex-report-section-golden-team-updates"},o=e.findIndex(e=>e.title.toLowerCase().includes("what it is"));return -1===o?[l,...e]:[...e.slice(0,o),l,...e.slice(o)]}},31204:(e,t,r)=>{"use strict";r.d(t,{F:()=>x});var s=r(4183),a=r(70636),i=r(82385),n=r(20089),l=r(24057),o=r(76180),c=r(99183),d=r(88435),m=r(75115);let u=(0,s.l)({chain:l.E,transport:(0,a.L)(c.QI)});function x(e){let{data:t,isLoading:r,error:s,refetch:a}=(0,o.I)({queryKey:["baseBalance",e],queryFn:async()=>{if(!e)return null;let[t,r]=await Promise.all([u.getBalance({address:e}),u.readContract({address:d.JF,abi:i.xw,functionName:"balanceOf",args:[e]})]),s=parseFloat((0,n.J)(r,d.Xp)),a=(0,n.J)(t,18);return{ethBalance:t,usdcBalance:s,usdcBalanceFormatted:s.toFixed(2),ethBalanceFormatted:a}},enabled:!!e,staleTime:m.Q1.BALANCE,refetchInterval:m.el.BALANCE,refetchOnWindowFocus:!0});return{usdcBalance:t?.usdcBalance??0,usdcBalanceFormatted:t?.usdcBalanceFormatted??"0.00",ethBalanceFormatted:t?.ethBalanceFormatted??"0",isLoading:r,isError:!!s,refetch:a}}},38043:(e,t,r)=>{"use strict";r.d(t,{O:()=>l,TopbarProvider:()=>n});var s=r(66577),a=r(56693);let i=(0,a.createContext)(void 0);function n({children:e}){let[t,r]=(0,a.useState)(!0);return(0,s.jsx)(i.Provider,{value:{isTopbarVisible:t,setTopbarVisible:r},children:e})}function l(){let e=(0,a.useContext)(i);if(void 0===e)throw Error("useTopbar must be used within a TopbarProvider");return e}},38365:(e,t,r)=>{"use strict";r.d(t,{a:()=>u});var s=r(49747),a=r(79916),i=r(74080),n=r(81001);async function l(){let e=await fetch("/api/predictfun/config",{cache:"no-store"});if(!e.ok)throw Error("Predict.fun config unavailable");let t=await e.json();return{chainId:97===t.chainId?97:56,apiBase:String(t.base??"mainnet")}}async function o(){let e=await fetch("/api/predictfun/auth-message",{cache:"no-store"});if(!e.ok)throw Error("Failed to get Predict.fun auth message");let t=await e.json(),r=String(t?.data?.message??"").trim();if(!r)throw Error("Predict.fun auth message missing");return r}async function c(e){let t=await fetch("/api/predictfun/auth",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error((await t.json().catch(()=>({error:t.statusText}))).error||"Predict.fun auth failed");let r=await t.json(),s=String(r?.data?.token??"").trim();if(!s)throw Error("Predict.fun JWT missing from response");return s}async function d(e){let t=await fetch("/api/predictfun/account",{cache:"no-store",headers:{Authorization:`Bearer ${e}`}});if(!t.ok)return null;let r=await t.json(),a=String(r?.data?.address??"").trim();return/^0x[a-fA-F0-9]{40}$/.test(a)?s.bv(a):null}async function m(e){let t=await o(),r=e.usePredictAccountSignature?await (0,n.wo)(e.signer,e.authSigner,e.chainId,t):await e.signer.signMessage(t),s=await c({signer:e.authSigner,message:t,signature:r});return(0,a.$A)(e.chainId,e.authSigner,s,e.apiBase),s}async function u(e,t){let r=s.bv(await e.getAddress()),{chainId:o,apiBase:c}=await l(),u=(0,i.Vn)(o,r),x=u?s.bv(u):null,h=x??r,p=!!(x&&(0,n.vS)(r,x));if(t?.forceRefresh)(0,a.XL)(o,h,c),(0,a.XL)(o,r,c);else{let e=(0,a.CK)(o,h,c);if(e)return{jwt:e,walletAddress:r,authSigner:h,predictAccount:x,tradingAddress:x??r,chainId:o,apiBase:c}}let f=await m({signer:e,chainId:o,apiBase:c,authSigner:h,predictAccount:x,usePredictAccountSignature:p}),g=await d(f);return g&&(0,n.vS)(r,g)?((0,i.S9)(o,r,g),x=g,h.toLowerCase()!==g.toLowerCase()&&((0,a.XL)(o,h,c),h=g,f=await m({signer:e,chainId:o,apiBase:c,authSigner:g,predictAccount:g,usePredictAccountSignature:!0}))):x&&((0,i.ic)(o,r),x=null,h=r),{jwt:f,walletAddress:r,authSigner:h,predictAccount:x,tradingAddress:x??r,chainId:o,apiBase:c}}},41250:(e,t,r)=>{"use strict";r.d(t,{d:()=>l});var s=r(56693),a=r(38365),i=r(79916),n=r(74080);
1function l(e,t,r){let[l,o]=(0,s.useState)(null),[c,d]=(0,s.useState)(null),[m,u]=(0,s.useState)(56),[x,h]=(0,s.useState)("mainnet"),[p,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{if(!r||!t){o(null),d(null);return}let s=!1;return(async()=>{try{let r=await fetch("/api/predictfun/config",{cache:"no-store"}),l=r.ok?await r.json():{},c=97===l.chainId?97:56,m=String(l.base??"mainnet");if(s)return;u(c),h(m);let x=(0,n.Vn)(c,t),p=x??t,g=(0,i.CK)(c,p,m);if(g&&!s){o(g);let e=x??t;if(!x)try{let r=await fetch("/api/predictfun/account",{cache:"no-store",headers:{Authorization:`Bearer ${g}`}});if(r.ok){let s=await r.json(),a=String(s?.data?.address??"").trim();/^0x[a-fA-F0-9]{40}$/.test(a)&&((0,n.S9)(c,t,a),e=a)}}catch{}d(e)}if(!e)return;f(!0);let y=await (0,a.a)(e);s||(o(y.jwt),d(y.tradingAddress),u(y.chainId),h(y.apiBase))}catch{s||o(null)}finally{s||f(!1)}})(),()=>{s=!0}},[r,t,e]),{jwt:l,tradingAddress:c,chainId:m,apiBase:x,isLoading:p,refresh:async()=>{if(!e)return null;let t=await (0,a.a)(e,{forceRefresh:!0});return o(t.jwt),d(t.tradingAddress),t}}}},43948:(e,t,r)=>{"use strict";r.d(t,{P:()=>o});
1var s=r(4183),a=r(70636),i=r(24084),n=r(55036);let l=void 0!==n&&n.env.NEXT_PUBLIC_BSC_RPC_URL?.trim()?n.env.NEXT_PUBLIC_BSC_RPC_URL.trim():"https://bsc-dataseed.binance.org",o=(0,s.l)({chain:i.N,transport:(0,a.L)(l)})},44985:(e,t,r)=>{"use strict";r.d(t,{i:()=>a});var s=r(76180);function a({walletAddress:e,enabled:t=!0}){return(0,s.I)({queryKey:["polymarket-deposit-addresses",e],queryFn:async()=>{if(!e)return null;let t=await fetch("/api/polymarket/deposit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({address:e}),cache:"no-store"});if(!t.ok){let e=await t.text();throw console.error("Deposit addresses fetch error:",e),Error(`Failed to fetch deposit addresses: ${t.status} ${e}`)}return await t.json()},enabled:t&&!!e,staleTime:3e5,refetchOnWindowFocus:!1})}},45293:(e,t,r)=>{"use strict";r.d(t,{I:()=>l});var s=r(76180),a=r(6143);let i=new a.J3("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");async function n(e){let t=new a.Ng("https://mainnet.helius-rpc.com/?api-key=67d144bc-41ee-47c4-b5c7-a260a6a87712","confirmed"),r=new a.J3(e),s=(await t.getParsedTokenAccountsByOwner(r,{programId:i})).value.map(({pubkey:e,account:t})=>{let r=t.data.parsed.info,s=r.tokenAmount??{};return{tokenAccountAddress:e.toBase58(),mint:r.mint,rawBalance:s.amount??"0",balance:s.uiAmount??0,decimals:s.decimals??6}}),n=[...new Set(s.map(e=>e.mint))];if(0===n.length)return{positions:[],emptyOutcomeAccounts:[]};let l=await fetch("/api/kalshi/dflow-filter-outcome-mints",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({addresses:n})});if(!l.ok)throw Error((await l.json().catch(()=>({}))).error??"Failed to filter outcome mints");let o=(await l.json()).outcomeMints??[],c=s.filter(e=>o.includes(e.mint)),d=c.filter(e=>e.balance>0),m=c.filter(e=>0===e.balance).map(e=>({tokenAccountAddress:e.tokenAccountAddress,mint:e.mint}));if(0===d.length)return{positions:[],emptyOutcomeAccounts:m};let u=await fetch("/api/kalshi/dflow-markets-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mints:[...new Set(d.map(e=>e.mint))]})});if(!u.ok)throw Error((await u.json().catch(()=>({}))).error??"Failed to fetch markets batch");let x=(await u.json()).markets??[],h=new Map;return x.forEach(e=>{Object.values(e.accounts??{}).forEach(t=>{t.yesMint&&h.set(t.yesMint,e),t.noMint&&h.set(t.noMint,e)})}),{positions:d.map(e=>{let t=h.get(e.mint)??null;if(!t)return{mint:e.mint,balance:e.balance,rawBalance:e.rawBalance,decimals:e.decimals,position:"UNKNOWN",market:null,redemptionStatus:null,scalarOutcomePct:null};let r=Object.values(t.accounts??{}),s=r.find(t=>t.yesMint===e.mint||t.noMint===e.mint),a=r.some(t=>t.yesMint===e.mint),i=r.some(t=>t.noMint===e.mint);return{mint:e.mint,balance:e.balance,rawBalance:e.rawBalance,decimals:e.decimals,position:a?"YES":i?"NO":"UNKNOWN",market:t,redemptionStatus:s?.redemptionStatus??null,scalarOutcomePct:s?.scalarOutcomePct??null}}),emptyOutcomeAccounts:m}}function l(e){return(0,s.I)({queryKey:["dflow-positions",e],queryFn:()=>n(e),enabled:!!e,staleTime:6e4})}},45627:(e,t,r)=>{"use strict";r.d(t,{$T:()=>l,Qk:()=>c,dF:()=>d,fO:()=>o,mn:()=>n});let s="phantom_return_to",a="phantom_resume_swap";function i(e){return e.startsWith("/")&&!e.startsWith("//")&&!e.includes("://")}function n(e){let t=e?.path??`${window.location.pathname}${window.location.search}${window.location.hash}`;try{i(t)&&localStorage.setItem(s,t),e?.resumeSwap&&localStorage.setItem(a,String(Date.now()))}catch{}}function l(e="/"){let t=null;try{t=localStorage.getItem(s),localStorage.removeItem(s)}catch{return e}return!t||!i(t)||t.startsWith("/auth/callback")?e:t}function o(){try{let e=localStorage.getItem(a);if(!e)return!1;let t=Number(e);return Number.isFinite(t)&&Date.now()-t<9e5}catch{return!1}}function c(){let e=null;try{e=localStorage.getItem(a),localStorage.removeItem(a)}catch{return!1}if(!e)return!1;let t=Number(e);return Number.isFinite(t)&&Date.now()-t<9e5}function d(){try{localStorage.setItem("walletName",JSON.stringify("Phantom"))}catch{}}},48663:(e,t,r)=>{"use strict";r.d(t,{A:()=>c});
1var s=r(56693),a=r(16105),i=r(75486),n=r(76624),l=r(45826),o=r(28507);function c(e){let{publicClient:t}=(0,i.v)(),r=(0,s.useMemo)(()=>{if(e&&t&&o.Ni)try{let t=(0,l.getContractConfig)(o.Ni);return(0,n.deriveSafe)(e,t.SafeContracts.SafeFactory)}catch(e){console.error("Error deriving Safe address:",e);return}},[e,t,o.Ni]);return{derivedSafeAddressFromEoa:r,isSafeDeployed:(0,s.useCallback)(async(e,r)=>{try{return await e.getDeployed(r)}catch(s){console.warn("API check failed, falling back to RPC",s);let e=await t?.getCode({address:r});return!!e&&"0x"!==e}},[t]),deploySafe:(0,s.useCallback)(async e=>{try{let t=await e.deploy(),r=await e.pollUntilState(t.transactionID,[a.RelayerTransactionState.STATE_MINED,a.RelayerTransactionState.STATE_CONFIRMED,a.RelayerTransactionState.STATE_FAILED],"60",3e3);if(!r)throw Error("Safe deployment failed");return r.proxyAddress}catch(e){throw e instanceof Error?e:Error("Failed to deploy Safe")}},[])}}},49843:(e,t,r)=>{"use strict";r.d(t,{y:()=>i});var s=r(16610),a=r(55003);function i(){let{user:e,isAuthenticated:t}=(0,a.F)(),{authenticated:r,ready:i,user:n}=(0,s.u)(),l=t&&e?.ethereumWallet?e.ethereumWallet:null,o=(n?.linkedAccounts??[]).find(e=>"wallet"===e.type&&"ethereum"===e.chainType&&"string"==typeof e.address),c=r&&o?.address?o.address:null;return{ethereumAddress:l||c||null,source:l?"phantom":c?"privy":null,isLoading:r&&!i}}},49846:(e,t,r)=>{"use strict";r.d(t,{DataSourceProvider:()=>n,x:()=>l});var s=r(66577),a=r(56693);let i=(0,a.createContext)(void 0);function n({children:e}){let[t,r]=(0,a.useState)("kalshi");return(0,a.useLayoutEffect)(()=>{{let e=localStorage.getItem("dataSource");r("polymarket"===e||"kalshi"===e||"limitless"===e||"myriad"===e||"predictfun"===e||"all"===e?e:"kalshi")}},[]),(0,a.useEffect)(()=>{let e=()=>{{let e=localStorage.getItem("dataSource");("polymarket"===e||"kalshi"===e||"limitless"===e||"myriad"===e||"predictfun"===e||"all"===e)&&r(e)}};return window.addEventListener("dataSourceChange",e),window.addEventListener("storage",e),()=>{window.removeEventListener("dataSourceChange",e),window.removeEventListener("storage",e)}},[]),(0,s.jsx)(i.Provider,{value:{dataSource:t,setDataSource:e=>{r(e),localStorage.setItem("dataSource",e),window.dispatchEvent(new Event("dataSourceChange"))}},children:e})}function l(){let e=(0,a.useContext)(i);if(void 0===e)throw Error("useDataSource must be used within a DataSourceProvider");return e}},50316:(e,t,r)=>{"use strict";r.d(t,{A:()=>c});var s=r(82385),a=r(20089),i=r(76180),n=r(75486),l=r(88435),o=r(75115);function c(e){let{publicClient:t}=(0,n.v)(),{data:r,isLoading:c,error:d}=(0,i.I)({queryKey:["usdcBalance",e],queryFn:async()=>e&&t?await t.readContract({address:l.Gi,abi:s.xw,functionName:"balanceOf",args:[e]}):null,enabled:!!e,staleTime:o.Q1.BALANCE,refetchInterval:o.el.BALANCE,refetchIntervalInBackground:!0,refetchOnWindowFocus:!0}),m=r?parseFloat((0,a.J)(r,l.$X)):0;return{usdcBalance:m,formattedUsdcBalance:m.toFixed(2),rawUsdcBalance:r,isLoading:c,isError:!!d}}},50747:(e,t,r)=>{"use strict";r.d(t,{H:()=>s,j:()=>a});let s="/images/predict-fun.webp",a="/images/predict-fun-logo-white.webp"},52631:(e,t,r)=>{"use strict";r.d(t,{A:()=>c});var s=r(66577),a=r(56693),i=r(59339),n=r(87562),l=r(70072);function o({isOpen:e,onClose:t}){let r=(0,a.useRef)(null);if((0,a.useEffect)(()=>{if(!e)return;let r=e=>{"Escape"===e.key&&t()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[e,t]),(0,a.useEffect)(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=t}},[e]),!e||"undefined"==typeof document)return null;let i=(0,s.jsxs)("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/70 px-4",role:"dialog","aria-modal":"true",children:[(0,s.jsx)("div",{className:"absolute inset-0","aria-hidden":"true",onClick:e=>{r.current&&!r.current.contains(e.target)&&t()}}),(0,s.jsxs)("div",{ref:r,className:"relative bg-[#0D0D0D] border border-[#303030] max-w-3xl w-full max-h-[90vh] rounded-2xl shadow-2xl flex flex-col",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-b border-[#303030]",children:[(0,s.jsx)("h2",{className:"text-[#ffc000] text-lg! sm:text-2xl! font-semibold",children:"RaptorX Terms of Service"}),(0,s.jsx)("button",{type:"button",onClick:t,className:"text-gray-300 hover:text-[#ffc000] transition-colors text-2xl leading-none","aria-label":"Close terms of service",children:"\xd7"})]}),(0,s.jsx)("div",{className:"px-5 py-4 overflow-y-auto text-[13px] sm:text-sm leading-relaxed text-gray-100 space-y-6 custom-sidebar-scrollbar",children:[{id:"acceptance",title:"1. ACCEPTANCE OF TERMS",paragraphs:['By accessing or using the RaptorX platform, API, or the Claw reasoning model (collectively, the "Services"), you agree to be bound by these Terms of Service ("Terms"). If you do not agree to these Terms, you may 
1not access or use the Services. RaptorX reserves the right to modify these Terms at any time, and continued use constitutes acceptance of those changes.']},{id:"nature-of-services",title:"2. NATURE OF THE SERVICES",paragraphs:["RaptorX provides an intelligence and execution engine designed to ingest real-time on-chain and off-chain signals and facilitate automated or manual execution within third-party prediction markets and decentralized finance (DeFi) protocols.",'The Services utilize proprietary artificial intelligence and reasoning models ("Claw"), which are inherently probabilistic; we do not guarantee absolute accuracy, reliability, or inference speed under all market conditions. RaptorX acts solely as an execution layer and does not host, operate, or control the underlying markets, blockchains, or smart contracts where your trades are executed.']},{id:"no-advice",title:"3. NO FINANCIAL OR INVESTMENT ADVICE",paragraphs:["RAPTORX IS NOT A BROKER, FINANCIAL ADVISOR, OR INVESTMENT FUND.","The signals, data infrastructure, and AI-driven reasoning provided by RaptorX are for informational and execution purposes only and do not constitute financial, legal, tax, or investment advice. You remain solely responsible for deciding whether to execute any transaction based on RaptorX's intelligence."]},{id:"risk",title:"4. ASSUMPTION OF RISK",paragraphs:["By using the Services, you expressly acknowledge and assume risks including, but not limited to, market volatility (you can lose your entire principal), execution and latency risk arising from network congestion or third-party APIs, and smart contract risk on underlying decentralized protocols.","RaptorX is not liable for slippage, missed opportunities, or funds lost due to exploits, hacks, or vulnerabilities in third-party smart contracts or blockchain networks."]},{id:"compliance",title:"5. REGULATORY COMPLIANCE & GEOGRAPHIC RESTRICTIONS",paragraphs:["You are solely responsible for ensuring that your use of the Services, including participation in prediction markets, complies with the laws and regulations of your jurisdiction.","You represent and warrant that you are not accessing the Services from any jurisdiction where interaction with prediction markets or digital assets is prohibited by law. We may geoblock, restrict, or terminate access to the Services at any time to comply with sanctions, regulatory directives, or legal risk."]},{id:"ip",title:"6. INTELLECTUAL PROPERTY",paragraphs:["All rights, title, and interest in and to the Services, including the Claw reasoning model, data ingestion pipelines, code, and the RaptorX brand, are the exclusive property of RaptorX and its licensors.","You are granted a limited, non-exclusive, non-transferable license to use the Services for their intended purpose only. You may not reverse-engineer, decompile, or attempt to extract the source code or model weights of Claw."]},{id:"liability",title:"7. LIMITATION OF LIABILITY",paragraphs:["To the maximum extent permitted by law, RAPTORX, its founders, directors, or affiliates shall not be liable in any event for any indirect, incidental, special, consequential, or punitive damages (including but not limited to loss of profits, loss of data, or loss of digital assets) arising in connection with your use of the Service, even if RAPTORX was notified in advance of the possibility of such damages."]},{id:"indemnification",title:"8. INDEMNIFICATION",paragraphs:["You agree to indemnify, defend, and hold harmless RaptorX from and against any claims, disputes, demands, liabilities, damages, losses, and costs and expenses (including reasonable legal and accounting fees) arising out of or in any way connected with your access to or use of the Services or your violation of these Terms."]},{id:"governing-law",title:"9. GOVERNING LAW AND DISPUTE RESOLUTION",paragraphs:["These Terms shall be governed by and construed in accordance with the laws of the governing jurisdiction selected by RaptorX.","Any dispute arising out of or relating to these Terms or the breach thereof shall be finally resolved by binding arbitration administered by the applicable arbitration body under its commercial arbitration rules."]}].map(e=>(0,s.jsxs)("section",{className:"space-y-2",children:[(0,s.jsx)("h4",{className:"font-semibold text-[16px]! sm:text-base! text-white",children:e.title}),e.paragraphs.map((t,r)=>(0,s.jsx)("p",{className:"no-advice"===e.id&&0===r?"uppercase text-[11px] font-semibold! sm:text-xs text-[#A0A0A0]":"text-[#A0A0A0] font-normal!",children:t},r))]},e.id))})]})]});return(0,l.createPortal)(i,document.body)}function c(){let e="/rexmarkets"===(0,i.usePathname)(),[t,r]=(0,a.useState)([]),[l,c]=(0,a.useState)([]),[d,m]=(0,a.useState)(!1);(0,a.useEffect)(()=>
1{if(!e){let e=async()=>{try{let e=await fetch("/api/crypto/top",{cache:"no-store"});if(e.ok){let t=await e.json();r(t.tokens||[])}}catch(e){console.error("Failed to fetch crypto tokens:",e)}};e();let t=setInterval(e,3e4);return()=>clearInterval(t)}},[e]),(0,a.useEffect)(()=>{if(e){let e=async()=>{try{let e=await fetch("/api/kalshi/markets?limit=15&status=open",{cache:"no-store"});if(e.ok){let t=((await e.json()).markets||[]).slice(0,15).map(e=>({ticker:e.ticker||"",title:e.title||"",yes_price:e.yes_price||0,no_price:e.no_price||0}));c(t)}}catch(e){console.error("Failed to fetch prediction markets:",e)}};e();let t=setInterval(e,3e4);return()=>clearInterval(t)}},[e]);let u=e?l:t,x=u.length>0?[...u,...u]:[];return(0,s.jsxs)("footer",{className:"relative w-full shrink-0 bg-[#141414] border-t-[0.5px] border-[#B58405] pb-[env(safe-area-inset-bottom,0px)]",children:[(0,s.jsxs)("div",{className:"w-full flex flex-col gap-2 sm:gap-0 sm:flex-row justify-center sm:justify-between items-center px-3 sm:px-5 py-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2 sm:gap-4 sm:flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,s.jsx)("div",{className:"w-2 h-2 bg-[#00B050] rounded-full live-dot-pulse"}),(0,s.jsx)("span",{className:"text-white text-[12px] font-normal",children:"Live"})]}),(0,s.jsx)("div",{className:"flex-1 flex items-center min-w-0 overflow-hidden relative h-10",children:x.length>0?(0,s.jsx)("div",{className:"flex items-center gap-3 sm:gap-4 animate-scroll-infinite whitespace-nowrap",children:x.map((t,r)=>(0,s.jsx)("div",{className:"shrink-0 flex items-center gap-2 sm:gap-3 min-w-0",children:e?(0,s.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,s.jsx)("span",{className:"text-white text-sm font-normal truncate max-w-37.5 sm:max-w-50",children:t.title}),(0,s.jsxs)("div",{className:"flex gap-2 text-sm",children:[(0,s.jsxs)("span",{className:"text-[#00B050]",children:["Yes:"," ",(100*t.yes_price).toFixed(1),"%"]}),(0,s.jsxs)("span",{className:"text-[#FF4444]",children:["No:"," ",(100*t.no_price).toFixed(1),"%"]})]})]}):(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[t.image&&(0,s.jsx)(n.default,{src:t.image,alt:t.symbol,width:20,height:20,className:"rounded-full",unoptimized:!0}),(0,s.jsxs)("span",{className:"text-white text-sm font-normal",children:["$",t.symbol,":"]}),(0,s.jsxs)("span",{className:"text-white text-sm font-normal",children:["$",t.current_price.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),(0,s.jsx)("div",{className:"flex items-center gap-1",children:t.price_change_percentage_24h<0?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-red-500",children:(0,s.jsx)("path",{d:"M6 9L2 5H4V1H8V5H10L6 9Z",fill:"currentColor"})}),(0,s.jsxs)("span",{className:"text-red-500 text-sm font-normal",children:[Math.abs(t.price_change_percentage_24h).toFixed(2),"%"]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-green-500",children:(0,s.jsx)("path",{d:"M6 3L10 7H8V11H4V7H2L6 3Z",fill:"currentColor"})}),(0,s.jsxs)("span",{className:"text-green-500 text-sm font-normal",children:[t.price_change_percentage_24h.toFixed(2),"%"]})]})})]})},`${e?t.ticker:t.id}-${r}`))}):(0,s.jsx)("div",{className:"flex items-center justify-center w-full"})})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between w-full sm:w-auto sm:justify-start gap-2 sm:gap-4 flex-wrap",children:[(0,s.jsxs)("div",{className:" flex items-center gap-2",children:[(0,s.jsx)("a",{href:"https://x.com/huntonraptor",target:"_blank",rel:"noopener noreferrer",className:"text-white hover:text-[#ffc000] transition-colors","aria-label":"Follow us on X (Twitter)",children:(0,s.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"transition-colors",children:(0,s.jsx)("path",{d:"M2.66675 13.3332L7.17875 8.82117M8.81875 7.18117L13.3334 2.6665M2.66675 2.6665L10.4887 13.3332H13.3334L5.51141 2.6665H2.66675Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})})}),(0,s.jsx)("a",{href:"https://t.me/huntonraptor",target:"_blank",rel:"noopener noreferrer",className:"text-white hover:text-[#ffc000] transition-colors","aria-label":"Join us on Telegram",children:(0,s.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"transition-colors",children:(0,s.jsx)("path",{d:"M10 6.6665L7.33333 9.33317L11.3333 13.3332L14 2.6665L2 7.33317L4.66667 8.6665L6 12.6665L8 9.99984",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),(0,s.jsx)("div",{className:"flex items-center gap-2 ml-0 sm:ml-2",children:(0,s.jsx)("a",{href:"/docs/TermsofService-RaptorX.pdf",target:"_blank",rel:"noopener noreferrer",className:"text-white text-xs sm:text-sm hover:text-[#ffc000] transition-colors whitespace-nowrap",children:"Terms of Service"})}),(0,s.jsxs)("span",{className:"text-white text-xs sm:text-sm font-normal whitespace-nowrap",children:["\xa9 ",new Date().getFullYear()," Raptorx. All Rights Reserved"]})]})]}),(0,s.jsx)(o,{isOpen:d,onClose:()=>m(!1)})]})}},54588:(e,t,r)=>{"use strict";r.d(t,{Ng:()=>x,Rr:()=>f,bl:()=>c,gG:()=>u,ns:()=>h});var s=r(76180),a=r(82248),i=r(82385),n=r(79610),l=r(20089),o=r(43948);let c="0.002";function d(e,t=8){if(!e.includes("."))return e||"0";let[r,s=""]=e.split("."),a=s.slice(0,t).replace(/0+$/,"");return a?`${r}.${a}`:r||"0"}let m=(0,a.g)(c),u="0x8d0D000Ee44948FC98c9B98A4FA4921476f08B0d",x="0x55d398326f99059fF775485246999027B3197955",h=18;async function p(){try{let e=await fetch("https://api.coingecko.com/api/v3/simple/price?ids=binancecoin&vs_currencies=usd",{cache:"no-store"});if(!e.ok)return null;let t=await e.json(),r=t.binancecoin?.usd;return"number"==typeof r&&r>0?r:null}catch{return null}}function f(e,t){return(0,s.I)({queryKey:["myriad-bsc-balances",e],enabled:!!(t&&e),queryFn:async()=>{let[t,r,s,a,c]=await Promise.all([o.P.getBalance({address:e}),o.P.readContract({address:u,abi:i.xw,functionName:"balanceOf",args:[e]}),o.P.readContract({address:x,abi:i.xw,functionName:"balanceOf",args:[e]}),o.P.readContract({address:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",abi:i.xw,functionName:"balanceOf",args:[e]}),p()]),f=(0,n.c)(t),g=parseFloat(f),y=t>m?t-m:BigInt(0),b=Number((0,l.J)(r,h)),w=Number((0,l.J)(s,h)),N=Number((0,l.J)(a,h)),j=null!=c&&Number.isFinite(g)?g*c:0;return{bnbWei:t.toString(),bnbMaxSendAfterReserveWei:y.toString(),bnbMaxSendAfterReserveFormatted:d((0,n.c)(y),18),bnb:g,bnbFormatted:d(f,18),usd1:b,usd1Formatted:(0,l.J)(r,h),usdt:w,usdc:N,usdtFormatted:(0,l.J)(s,h),usdcFormatted:(0,l.J)(a,h),bnbUsdPrice:c,totalUsdApprox:b+w+N+j}},staleTime:1e4,refetchInterval:25e3})}},55003:(e,t,r)=>{"use strict";r.d(t,{F:()=>o,PhantomConnectProvider:()=>l});var s=r(66577),a=r(96030),i=r(51283),n=r(45627);function l({children:e,appId:t}){let r=t||"065d764e-9c04-47e1-88b1-b090538d0faa";
1return(0,s.jsxs)(a.p1,{config:{providers:["google","apple","injected","deeplink"],appId:r||"00000000-0000-0000-0000-000000000000",addressTypes:[i.RX.solana,i.RX.ethereum],authOptions:{redirectUrl:`${window.location.origin}/auth/callback`}},theme:a.a5,appIcon:"/images/home-logo.png",appName:"RaptorXchange",children:[!r&&!1,e]})}function o(){let{isConnected:e,isLoading:t,user:r,clearError:s}=(0,a.TH)(),l=(0,a.oV)(),{open:o,close:c,isOpened:d}=(0,a.hS)(),{connect:m,isConnecting:u,error:x}=(0,a.eF)(),{disconnect:h,isDisconnecting:p}=(0,a.uP)(),f=l?.find(e=>e.addressType===i.RX.solana)?.address||null,g=l?.find(e=>e.addressType===i.RX.ethereum)?.address||null,y=f||l?.[0]?.address||null,b=r?.email||r?.profile?.email||r?.user?.email||null;return{isAuthenticated:e,isLoading:t||u||p,user:e&&y?{id:y,email:b||void 0,solanaWallet:f||void 0,ethereumWallet:g||void 0}:null,openModal:()=>{s("connect"),(0,n.mn)(),o()},closeModal:c,isModalOpen:d,connect:async e=>{((0,n.mn)(),s("connect"),e)?"string"==typeof e?"injected"===e?o():await m({provider:e}):await m(e):o()},disconnect:async()=>{await h()},clearError:s,error:x}}},58311:(e,t,r)=>{"use strict";r.d(t,{T:()=>i});var s=r(55036);let a=void 0!==s?s.env.NEXT_PUBLIC_MYRIAD_PREDICTION_MARKET?.trim():void 0,i=a&&a.startsWith("0x")?a:"0x39E66eE6b2ddaf4DEfDEd3038E0162180dbeF340"},63514:()=>{},64551:(e,t,r)=>{"use strict";r.d(t,{$n:()=>c,KV:()=>a,YJ:()=>l,_K:()=>d,d4:()=>n,iy:()=>s,js:()=>o,sO:()=>m});let s="0xa0b6f8ef8EdB64f395018D1933f2273Ce9f0f16A",a=56,i=BigInt(10)**BigInt(18);function n(e,t){if(!Number.isFinite(t)||t<=0||!/^\d+$/.test(e))return"0";let r=BigInt(e);if(r<=BigInt(0))return"0";let s=BigInt(Math.round(1e6*t));return s<=BigInt(0)?"0":(s*BigInt(10)**BigInt(30)/r).toString()}function l(){return{Order:[{name:"trader",type:"address"},{name:"marketId",type:"uint256"},{name:"outcomeId",type:"uint8"},{name:"side",type:"uint8"},{name:"amount",type:"uint256"},{name:"price",type:"uint256"},{name:"minFillAmount",type:"uint256"},{name:"nonce",type:"uint256"},{name:"expiration",type:"uint256"}]}}function o(e=s){return{name:"MyriadCTFExchange",version:"1",chainId:a,verifyingContract:e}}function c(e){if(!Number.isFinite(e)||e<=0||e>1)return"0";let t=BigInt(Math.round(1e8*e))*BigInt(10)**BigInt(10);return t<BigInt(1)&&(t=BigInt(1)),t>i&&(t=i),t.toString()}function d(e){if(!Number.isFinite(e)||e<=0)return"0";let t=BigInt(Math.round(1e8*e))*BigInt(10)**BigInt(10);return t<BigInt(1)?"0":t.toString()}function m(){let e=BigInt(Math.floor(1e9*Math.random()));return((BigInt(Date.now())<<BigInt(20))+e).toString()}},65343:(e,t,r)=>{"use strict";function s(e){if(!e)return null;let t=e.trim();return/^0x[a-fA-F0-9]{40}$/.test(t)?t.toLowerCase():null}function a(e,t){let r=s(e),a=s(t);return!!r&&!!a&&r===a}r.d(t,{L:()=>a,y:()=>s})},74080:(e,t,r)=>{"use strict";function s(e,t){return`predictfun_predict_account_v1:${e}:${t.toLowerCase()}`}function a(e,t){let r=localStorage.getItem(s(e,t));return r&&/^0x[a-fA-F0-9]{40}$/.test(r.trim())?r.trim():null}function i(e,t,r){localStorage.setItem(s(e,t),r.trim())}function n(e,t){localStorage.removeItem(s(e,t))}r.d(t,{S9:()=>i,Vn:()=>a,ic:()=>n})},75115:(e,t,r)=>{"use strict";r.d(t,{Q1:()=>s,el:()=>a,es:()=>n,nB:()=>i});let s={BALANCE:2e3,POSITIONS:5e3,MARKETS:3e5,ORDERS:5e3},a={BALANCE:3e3,POSITIONS:5e3,ORDERS:3e3},i=3e4,n=2e3},75486:(e,t,r)=>{"use strict";r.d(t,{b:()=>a,v:()=>i});var s=r(56693);let a=(0,s.createContext)({eoaAddress:void 0,walletClient:null,publicClient:null,ethersSigner:null,isReady:!1,authenticated:!1});function i(){return(0,s.useContext)(a)}},78427:(e,t,r)=>{"use strict";r.d(t,{NotificationToaster:()=>m,showErrorNotification:()=>x,b:()=>h,showSuccessNotification:()=>u});var s=r(93396),a=r(66577),i=r(92103),n=r(78683),l=r(93029),o=r(99322),c=r(15044);let d="shrink-0";function m(){return(0,a.jsx)(s.l$,{position:"top-center",theme:"dark",icons:{success:(0,a.jsx)(i.A,{size:18,className:`${d} text-emerald-500`,"aria-hidden":!0}),error:(0,a.jsx)(n.A,{size:18,className:`${d} text-red-500`,"aria-hidden":!0}),warning:(0,a.jsx)(l.A,{size:18,className:`${d} text-amber-500`,"aria-hidden":!0}),info:(0,a.jsx)(o.A,{size:18,className:`${d} text-blue-500`,"aria-hidden":!0}),loading:(0,a.jsx)(c.A,{size:18,className:`${d} text-blue-500 animate-spin`,"aria-hidden":!0})}})}function u(e,t,r){s.oR.success(e,{description:t,duration:r?.duration??5e3,...r?.position?{position:r.position}:{}})}function x(e,t,r){s.oR.error(e,{description:t,duration:r?.duration??5e3,...r?.position?{position:r.position}:{}})}function h(e,t,r){s.oR.info(e,{description:t,duration:r?.duration??5e3,...r?.position?{position:r.position}:{}})}},79916:(e,t,r)=>{"use strict";function s(e,t,r){let s=(r??"mainnet").replace(/[^a-z0-9]/gi,"_").toLowerCase();return`predictfun_jwt_v2:${s}:${e}:${t.toLowerCase()}`}function a(e,t,r){let a=localStorage.getItem(s(e,t,r));return!a||a.trim().length<10?null:a.trim()}function i(e,t,r,a){localStorage.setItem(s(e,t,a),r.trim())}function n(e,t,r){localStorage.removeItem(s(e,t,r))}r.d(t,{$A:()=>i,CK:()=>a,XL:()=>n})},81001:(e,t,r)=>{"use strict";r.d(t,{hD:()=>h,vS:()=>p,wo:()=>x});var s=r(9546),a=r(18576),i=r(98243),n=r(98284),l=r(33787),o=r(8887),c=r(49747);let d="0x845ADb2C711129d4f3966735eD98a9F09fC4cE57",m={56:{name:"Kernel",version:"0.3.1",chainId:56},97:{name:"Kernel",version:"0.3.1",chainId:97}};function u(e,t){let r,o,c=l.z.hashDomain(t),d=(r=new s.y,o=a.S(i.c$(n.YW("Kernel(bytes32 hash)"))),a.S(r.encode(["bytes32","bytes32"],[o,e])));return a.S(i.xW(["0x1901",c,d]))}async function x(e,t,r,s){let a=m[r],n=u(o.A(s),{...a,verifyingContract:c.bv(t)}),l=i.k9(n),x=await e.signMessage(l);return i.qn(["0x01",d,x])}async function h(e,t,r,s){let a=u(s,{...m[r],verifyingContract:c.bv(t)}),n=i.k9(a),l=await e.signMessage(n);return i.qn(["0x01",d,l])}function p(e,t){if(!t)return!1;try{return c.bv(e).toLowerCase()!==c.bv(t).toLowerCase()}catch{return!1}}},81426:(e,t,r)=>{"use strict";r.d(t,{Ee:()=>a,Ro:()=>n,UK:()=>l,Ym:()=>i,vv:()=>s});let s=(e,t=2)=>`$${e.toFixed(t)}`,a=(e,t=1)=>`${e.toFixed(t)}%`,i=(e,t=2)=>e.toFixed(t);function n(e){if(null==e)return null;let t="string"==typeof e?Number(e):e;return Number.isFinite(t)?t:null}function l(e){let t=n(e);return null==t?"—":Math.abs(t)>=1e9?`$${(t/1e9).toFixed(2)}B`:Math.abs(t)>=1e6?`$${(t/1e6).toFixed(2)}M`:Math.abs(t)>=1e3?`$${(t/1e3).toFixed(2)}
1K`:`$${t.toLocaleString(void 0,{maximumFractionDigits:6})}`}},84239:(e,t,r)=>{"use strict";r.d(t,{$4:()=>d,$t:()=>c,Af:()=>i,As:()=>n,FP:()=>j,GK:()=>a,OW:()=>w,PY:()=>N,R8:()=>f,Yt:()=>v,ZW:()=>o,dB:()=>m,kQ:()=>u,lP:()=>p,li:()=>h,pC:()=>b,tw:()=>g});let s=["monad","base","solana","robinhood","bnb","ethereum"];function a(e){return s.includes(e.toLowerCase())}function i(e){let t=e.toLowerCase();return a(t)?"bnb"===t?"bsc":t:null}let n="/base";function l(e){return"all"===e?null:"bsc"===e?"bnb":"ethereum"===e?"ethereum":e}function o(e){let t=l(e);return t?`/${t}`:n}function c(e,t){let r=String(e||"solana").toLowerCase(),s="bnb"===r||"bsc"===r||"56"===r?"bsc":"eth"===r||"ethereum"===r||"1"===r?"ethereum":"base"===r||"8453"===r?"base":"monad"===r||"10143"===r?"monad":"robinhood"===r||"4663"===r?"robinhood":"all"===r?"all":"solana",a=(t||"").trim(),i=l(s);return i&&a?`/${i}/${a}`:o(s)}function d(e){return l(e)}function m(e){let t=String(e.chainId??"").toLowerCase();return"bsc"===t||"56"===t?"bsc":"base"===t||"8453"===t?"base":"monad"===t||"10143"===t?"monad":"ethereum"===t||"eth"===t||"1"===t?"ethereum":"robinhood"===t?"robinhood":"solana"}function u(e){return l(m(e))}function x(e){return y((e.symbol??e.name??"token").trim())}function h(e){return/^0x[a-fA-F0-9]{40}$/.test(e.trim())}function p(e){return/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e.trim())}function f(e){let t=(e.tokenAddress??"").trim();return t?"solana"===m(e)?p(t)?t:x(e):h(t)?t.toLowerCase():x(e):x(e)}function g(e,t,r){let s=t.trim();return h(s)&&"solana"!==m(e)?(e.tokenAddress||"").toLowerCase()===s.toLowerCase():p(s)?(e.tokenAddress||"")===s:function(e,t){if(!t)return!1;for(let r of function(e){let t=new Set;for(let r of[e.symbol,e.name,e.uniqueName])"string"==typeof r&&r.trim()&&t.add(y(r));return t}(e))if(r===t)return!0;return!1}(e,r)}function y(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/_/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")||"token"}function b(e){return e.trim().toLowerCase().replace(/_/g,"-")}function w(e,t){if("all"===t)return!0;let r=String(e.chainId??"").toLowerCase();return"solana"===t?"solana"===r||""===r||"101"===r:"bsc"===t?"bsc"===r||"56"===r:"base"===t?"base"===r||"8453"===r:"monad"===t?"monad"===r||"10143"===r:"ethereum"===t?"ethereum"===r||"eth"===r||"1"===r:"robinhood"!==t||"robinhood"===r}function N(e){let t=e.split("/").filter(Boolean);if(0===t.length)return{routeChain:"all",routeTokenSlug:null};let r=t[0].toLowerCase();if("rexscreener"===r&&1===t.length)return{routeChain:"base",routeTokenSlug:null};if(!a(r))return{routeChain:"all",routeTokenSlug:null};let s=i(r);if(t.length>=2)try{return{routeChain:s,routeTokenSlug:decodeURIComponent(t[1])}}catch{return{routeChain:s,routeTokenSlug:t[1]}}return{routeChain:s,routeTokenSlug:null}}function j(e){if(!e)return!1;let t=e.split("?")[0]??e;if("/rexscreener"===t||t.startsWith("/rexscreener/")||t===n)return!0;let r=t.split("/").filter(Boolean);return 0!==r.length&&!(r.length>2)&&a(r[0].toLowerCase())}function v(e,t){try{window.history.pushState(null,"",t)}catch{}e.push(t)}},85607:(e,t,r)=>{"use strict";r.d(t,{s:()=>i});var s=r(76180),a=r(6143);function i(e,t,r){let i=!!e;return(0,s.I)({queryKey:["solana-balance",e],queryFn:async()=>{if(!e)return null;let t=new a.Ng("https://mainnet.helius-rpc.com/?api-key=67d144bc-41ee-47c4-b5c7-a260a6a87712","confirmed"),r=new a.J3(e),s=await t.getBalance(r),i=s/a.Sr;return{lamports:s,sol:i,formatted:i.toFixed(4)}},enabled:i,staleTime:3e4})}},85672:(e,t,r)=>{"use strict";r.d(t,{v:()=>C,default:()=>E,f:()=>A});var s=r(66577),a=r(56693),i=r(75486),n=r(71185),l=r(48663),o=r(78271),c=r(28507),d=r(16105),m=r(4183),u=r(70636),x=r(82385),h=r(12491),p=r(72878),f=r(88435);let g=[{inputs:[{name:"operator",type:"address"},{name:"approved",type:"bool"}],name:"setApprovalForAll",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"account",type:"address"},{name:"operator",type:"address"}],name:"isApprovedForAll",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"}],y=(0,m.l)({chain:p.n,transport:(0,u.L)(c.tD)}),b=[{address:f.OG,name:"CTF Contract"},{address:f.g8,name:"Neg Risk Adapter"}
1,{address:f.xH,name:"CTF Exchange"},{address:f.ao,name:"Neg Risk CTF Exchange"}],w=[{address:f.xH,name:"CTF Exchange"},{address:f.ao,name:"Neg Risk Exchange"},{address:f.g8,name:"Neg Risk Adapter"}],N=async(e,t)=>{try{let r=await y.readContract({address:f.Gi,abi:x.xw,functionName:"allowance",args:[e,t]}),s=BigInt("1000000000000");return r>=s}catch(e){return console.warn(`Failed to check USDC approval for ${t}:`,e),!1}},j=async(e,t)=>{try{return await y.readContract({address:f.OG,abi:g,functionName:"isApprovedForAll",args:[e,t]})}catch(e){return console.warn(`Failed to check ERC1155 approval for ${t}:`,e),!1}},v=async e=>{let t={},r={};return await Promise.all(b.map(async({address:r,name:s})=>{t[s]=await N(e,r)})),await Promise.all(w.map(async({address:t,name:s})=>{r[s]=await j(e,t)})),{allApproved:Object.values(t).every(e=>e)&&Object.values(r).every(e=>e),usdcApprovals:t,outcomeTokenApprovals:r}},k=e=>{localStorage.removeItem(`polymarket_trading_session_${e.toLowerCase()}`)};var S=r(99183);let C=(0,a.createContext)(null);function A(){let e=(0,a.useContext)(C);if(!e)throw Error("useTrading must be used within TradingProvider");return e}function E({children:e}){let{eoaAddress:t}=(0,i.v)(),{derivedSafeAddressFromEoa:r}=(0,l.A)(t),{isBlocked:m,isLoading:u,geoblockStatus:p}=function(){let[e,t]=(0,a.useState)(!1),[r,s]=(0,a.useState)(!0),[i,n]=(0,a.useState)(null),[l,o]=(0,a.useState)(null),c=(0,a.useCallback)(async()=>{s(!0),n(null);try{let e=await fetch(S.W3,{method:"GET",headers:{Accept:"application/json"}});if(!e.ok)throw Error(`Geoblock API error: ${e.status}`);let r=await e.json();o(r),t(r.blocked)}catch(r){let e=r instanceof Error?r:Error("Failed to check geoblock");n(e),console.error("Geoblock check failed:",e),t(!1)}finally{s(!1)}},[]);return(0,a.useEffect)(()=>{c()},[c]),{isBlocked:e,isLoading:r,error:i,geoblockStatus:l,recheckGeoblock:c}}(),{tradingSession:y,currentStep:N,sessionError:j,isTradingSessionComplete:A,initializeTradingSession:E,endTradingSession:I,relayClient:T}=function(){let[e,t]=(0,a.useState)("idle"),[r,s]=(0,a.useState)(null),[m,u]=(0,a.useState)(null),{eoaAddress:p,walletClient:y}=(0,i.v)(),{createOrDeriveUserApiCredentials:N}=function(){let{eoaAddress:e,ethersSigner:t}=(0,i.v)();return{createOrDeriveUserApiCredentials:(0,a.useCallback)(async()=>{let r;if(!e||!t)throw Error("Wallet not connected");try{if((r=await t.getAddress()).toLowerCase()!==e.toLowerCase())throw Error(`Signer address mismatch: ${r} !== ${e}`)}catch(e){throw Error("Signer is not properly configured")}if("function"!=typeof t._signTypedData)throw Error("Signer does not support EIP-712 signing (_signTypedData). This is required for L1 authentication. Please ensure you're using a compatible wallet.");let s=new n.Q(c.ww,c.Ni,t,void 0,void 0,void 0,void 0,!0);try{let e=await s.deriveApiKey().catch(e=>null);if(e?.key&&e?.secret&&e?.passphrase)return e;return await s.createApiKey()}catch(e){if(e?.message?.includes("Invalid L1 Request headers"))throw Error(`L1 authentication failed. The ClobClient could not generate valid L1 auth headers. Please ensure your wallet is connected and can sign EIP-712 messages. Error: ${e.message}`);if(e?.message?.includes("Signer is needed"))throw Error("L1 authentication failed. Signer is not available. Please ensure your wallet is connected.");throw e}},[e,t])}}(),{checkAllTokenApprovals:j,setAllTokenApprovals:S}={checkAllTokenApprovals:(0,a.useCallback)(async e=>{try{return await v(e)}catch(e){throw e instanceof Error?e:Error("Failed to check approvals")}},[]),setAllTokenApprovals:(0,a.useCallback)(async e=>{try{let t=(()=>{let e=[];for(let{address:t}of b)e.push({to:f.Gi,operation:d.OperationType.Call,data:(0,h.p)({abi:x.xw,functionName:"approve",args:[t,BigInt("115792089237316195423570985008687907853269984665640564039457584007913129639935")]}),value:"0"});for(let{address:t}of w)e.push({to:f.OG,operation:d.OperationType.Call,data:(0,h.p)({abi:g,functionName:"setApprovalForAll",args:[t,!0]}),value:"0"});return e})(),r=await e.execute(t,"Set all token approvals for trading");return await r.wait(),!0}catch(e){return console.error("Failed to set all token approvals:",e),!1}},[])},{derivedSafeAddressFromEoa:C,isSafeDeployed:A,deploySafe:E}=(0,l.A)(p),{relayClient:I,initializeRelayClient:T,clearRelayClient:F}=function(){let[e,t]=(0,a.useState)(null),{eoaAddress:r,ethersSigner:s}=(0,i.v)();return{relayClient:e,initializeRelayClient:(0,a.useCallback)(async()=>
1{if(!r||!s)throw Error("Wallet not connected");let e=new o.BuilderConfig({remoteBuilderConfig:{url:(0,c.Fy)()}}),a=new d.RelayClient(c.$u,c.Ni,s,e);return t(a),a},[r,s]),clearRelayClient:(0,a.useCallback)(()=>{t(null)},[])}}();(0,a.useEffect)(()=>{if(!p){u(null),t("idle"),s(null);return}let e=(e=>{let t=localStorage.getItem(`polymarket_trading_session_${e.toLowerCase()}`);if(!t)return null;try{let r=JSON.parse(t);if(r.eoaAddress.toLowerCase()!==e.toLowerCase())return console.warn("Session address mismatch, clearing invalid session"),k(e),null;return r}catch(e){return console.error("Failed to parse session:",e),null}})(p);if(u(e),!e){t("idle"),s(null);return}},[p]),(0,a.useEffect)(()=>{m&&!I&&p&&y&&T().catch(e=>{console.error("Failed to restore relay client:",e)})},[m,I,p,y,T]);let L=(0,a.useCallback)(async()=>{if(!p)throw Error("Wallet not connected");t("checking"),s(null);try{let e=await T();if(!C)throw Error("Failed to derive Safe address");await A(e,C)||(t("deploying"),await E(e));let r=m?.apiCredentials;m?.hasApiCredentials&&r&&r.key&&r.secret&&r.passphrase||(t("credentials"),r=await N()),t("approvals");let s=await j(C),a=!1;a=!!s.allApproved||await S(e);let i={eoaAddress:p,safeAddress:C,isSafeDeployed:!0,hasApiCredentials:!0,hasApprovals:a,apiCredentials:r,lastChecked:Date.now()};u(i),localStorage.setItem(`polymarket_trading_session_${p.toLowerCase()}`,JSON.stringify(i)),t("complete")}catch(e){console.error("Session initialization error:",e),s(e instanceof Error?e:Error("Unknown error")),t("idle")}},[p,y,I,T,C,A,E,N,j,S,m]),D=(0,a.useCallback)(()=>{p&&(k(p),u(null),F(),t("idle"),s(null))},[p,F]);return{tradingSession:m,currentStep:e,sessionError:r,isTradingSessionComplete:m?.isSafeDeployed&&m?.hasApiCredentials&&m?.hasApprovals,initializeTradingSession:L,endTradingSession:D,relayClient:I}}(),{clobClient:F}=function(e,t){let{eoaAddress:r,ethersSigner:s}=(0,i.v)(),{derivedSafeAddressFromEoa:d}=(0,l.A)(r);return{clobClient:(0,a.useMemo)(()=>{if(!s||!r||!d||!t||!e?.apiCredentials)return null;let a=new o.BuilderConfig({remoteBuilderConfig:{url:(0,c.Fy)()}});return new n.Q(c.ww,c.Ni,s,e.apiCredentials,2,d,void 0,!0,a)},[r,s,d,t,e?.apiCredentials])}}(y,A),L=(0,a.useCallback)(async()=>{if(m)throw Error("Trading is not available in your region. Polymarket is geoblocked in your location.");return E()},[m,E]);return(0,s.jsx)(C.Provider,{value:{tradingSession:y,currentStep:N,sessionError:j,isTradingSessionComplete:A,initializeTradingSession:L,endTradingSession:I,clobClient:F,relayClient:T,eoaAddress:t,safeAddress:r,isGeoblocked:m,isGeoblockLoading:u,geoblockStatus:p},children:e})}},86112:(e,t,r)=>{"use strict";r.d(t,{d:()=>i});var s=r(76180),a=r(6143);function i(e){return(0,s.I)({queryKey:["usdc-balance",e],queryFn:async()=>{if(!e)return null;let t=new a.Ng("https://mainnet.helius-rpc.com/?api-key=67d144bc-41ee-47c4-b5c7-a260a6a87712","confirmed"),r=new a.J3(e),s=await t.getParsedTokenAccountsByOwner(r,{mint:new a.J3("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v")});if(0===s.value.length)return{amount:0,rawAmount:"0",formatted:"0.00"};let i=s.value[0].account.data.parsed?.info,n=i?.tokenAmount,l=n?.uiAmount??0;return{amount:l,rawAmount:n?.amount??"0",formatted:l.toFixed(2)}},enabled:!!e,staleTime:3e4})}},87162:(e,t,r)=>{"use strict";r.d(t,{D9:()=>o,Uq:()=>m,X4:()=>h,b3:()=>u,dw:()=>p,gI:()=>c,gz:()=>x,t0:()=>d});var s=r(84291),a=r(49747),i=r(33787);let n=[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],l=[{name:"salt",type:"uint256"},{name:"maker",type:"address"},{name:"signer",type:"address"},{name:"taker",type:"address"},{name:"tokenId",type:"uint256"},{name:"makerAmount",type:"uint256"},{name:"takerAmount",type:"uint256"},{name:"expiration",type:"uint256"},{name:"nonce",type:"uint256"},{name:"feeRateBps",type:"uint256"},{name:"side",type:"uint8"},{name:"signatureType",type:"uint8"}],o={56:{YIELD_BEARING_CTF_EXCHANGE:"0x6bEb5a40C032AFc305961162d8204CDA16DECFa5",YIELD_BEARING_NEG_RISK_CTF_EXCHANGE:"0x8A289d458f5a134bA40015085A8F50Ffb681B41d",CTF_EXCHANGE:"0x8BC070BEdAB741406F4B1Eb65A72bee27894B689",NEG_RISK_CTF_EXCHANGE:"0x365fb81bd4A24D6303cd2F19c349dE6894D8d58A",YIELD_BEARING_CONDITIONAL_TOKENS:"0x9400F8Ad57e9e0F352345935d6D3175975eb1d9F",YIELD_BEARING_NEG_RISK_CONDITIONAL_TOKENS:"0xF64b0b318AAf83BD9071110af24D24445719A07F",CONDITIONAL_TOKENS:"0x22DA1810B194ca018378464a58f6Ac2B10C9d244",NEG_RISK_CONDITIONAL_TOKENS:"0x22DA1810B194ca018378464a58f6Ac2B10C9d244",USDT:"0x55d398326f99059fF775485246999027B3197955"},97:{YIELD_BEARING_CTF_EXCHANGE:"0x8a6B4Fa700A1e310b106E7a48bAFa29111f66e89",YIELD_BEARING_NEG_RISK_CTF_EXCHANGE:"0x95D5113bc50eD201e319101bbca3e0E250662fCC",CTF_EXCHANGE:"0x2A6413639BD3d73a20ed8C95F634Ce198ABbd2d7",NEG_RISK_CTF_EXCHANGE:"0xd690b2bd441bE36431F6F6639D7Ad351e7B29680",YIELD_BEARING_CONDITIONAL_TOKENS:"0x38BF1cbD66d174bb5F3037d7068E708861D68D7f",YIELD_BEARING_NEG_RISK_CONDITIONAL_TOKENS:"0x26e865CbaAe99b62fbF9D18B55c25B5E079A93D5",CONDITIONAL_TOKENS:"0x2827AAef52D71910E8FBad2FfeBC1B6C2DA37743",NEG_RISK_CONDITIONAL_TOKENS:"0x2827AAef52D71910E8FBad2FfeBC1B6C2DA37743",USDT:"0xB32171ecD878607FFc4F8FC0bCcE6852BB3149E0"}};function c(e,t){let r=o[e];return t.isNegRisk?t.isYieldBearing?r.YIELD_BEARING_NEG_RISK_CTF_EXCHANGE:r.NEG_RISK_CTF_EXCHANGE:t.isYieldBearing?r.YIELD_BEARING_CTF_EXCHANGE:r.CTF_EXCHANGE}function d(e,t){let r=o[e];return t.isYieldBearing?t.isNegRisk?r.YIELD_BEARING_NEG_RISK_CONDITIONAL_TOKENS:r.YIELD_BEARING_CONDITIONAL_TOKENS:t.isNegRisk?r.NEG_RISK_CONDITIONAL_TOKENS:r.CONDITIONAL_TOKENS}function m(e){let t,r=Math.max(1,Math.min(99,Math.round((!Number.isFinite(t=Number(e))||t<=0?0:Math.round(100*t)/100)*100)));return{priceNum:r,priceDenom:100,priceRounded:r/100}}function u(e){return s.gH.from(e).mul(s.gH.from(10).pow(16)).toString()}function x(e){let t=Math.floor(Date.now()/1e3),r="number"==typeof e.expirationSec&&e.expirationSec>t?e.expirationSec:Math.floor(new Date("2100-01-01T00:00:00Z").getTime()/1e3),s=a.bv(e.maker),i=a.bv(e.signer??e.maker);return{salt:e.salt??String(Math.floor(0x80000000*Math.random())),maker:s,signer:i,taker:a.bv("0x0000000000000000000000000000000000000000"),tokenId:String(e.tokenId),makerAmount:String(e.makerAmount),takerAmount:String(e.takerAmount),expiration:String(r),nonce:String(e.nonce??"0"),feeRateBps:String(e.feeRateBps??0),side:e.side,signatureType:e.signatureType??0}}function h(e){return{primaryType:"Order",types:{EIP712Domain:n,Order:l},domain:{name:"predict.fun CTF Exchange",version:"1",chainId:e.chainId,verifyingContract:e.verifyingContract},message:{...e.order}}}function p(e){let{EIP712Domain:t,...r}=e.types;return i.z.hash(e.domain,r,e.message)}},87211:(e,t,r)=>{"use strict";r.d(t,{g:()=>l,x:()=>n});var s=r(76180),a=r(8959),i=r(75486);function n({limit:e=50,cursor:t,enabled:r=!0}={}){let{ethersSigner:l}=(0,i.v)(),{user:o}=(0,a.m)(l),c=o?.sessionCookie;return(0,s.I)({queryKey:["limitless-portfolio-trades",c?"ok":"none",e,t],queryFn:async()=>{let r;if(!c)return{trades:[]};let s=new URLSearchParams;s.set("limit",String(e)),t&&s.set("cursor",t);let a=`/api/limitless/portfolio/trades?${s.toString()}`,i=await fetch(a,{method:"GET",headers:{"X-Limitless-Session":c},cache:"no-store"});if(!i.ok){let e=await i.text();throw Error((()=>{try{return JSON.parse(e)}catch{return{error:e}}})().error??`Trades ${i.status}`)}let n=await i.json(),l=[];return Array.isArray(n)?l=n:Array.isArray(n.trades)?(l=n.trades,r=n.cursor):Array.isArray(n.data)&&(l=n.data.map(e=>{let t=e.market??{},r=e.outcomeIndex,s=0===r?"Yes":1===r?"No":e.outcome??"",a=e.outcomeTokenPrice??e.price,i=e.outcomeTokenAmount??(Array.isArray(e.outcomeTokenAmounts)&&null!=r?e.outcomeTokenAmounts[r]:e.size),n=e.collateralAmount??e.amount,l=e.blockTimestamp??e.timestamp,o=e.action??e.strategy;return{id:e.transactionHash??String(l??""),marketSlug:t.slug,market:t.title??t.slug,outcome:s,action:o,price:a,size:i,amount:n,timestamp:l}}),r=void 0),{trades:l,cursor:r}},enabled:r&&!!c,staleTime:0,refetchOnWindowFocus:!0})}function l({enabled:e=!0}={}){let{ethersSigner:t}=(0,i.v)(),{user:r}=(0,a.m)(t),n=r?.sessionCookie;return(0,s.I)({queryKey:["limitless-portfolio-positions",n?"ok":"none"],queryFn:async()=>
1{if(!n)return[];let e=await fetch("/api/limitless/portfolio/positions",{method:"GET",headers:{"X-Limitless-Session":n},cache:"no-store"});if(!e.ok){let t=await e.text();throw Error((()=>{try{return JSON.parse(t)}catch{return{error:t}}})().error??`Positions ${e.status}`)}let t=await e.json();if(Array.isArray(t))return t;if(t.positions&&Array.isArray(t.positions))return t.positions;let r=t.clob;return r&&Array.isArray(r)?function(e){let t=[];for(let r of e){let e=r.market??{},s=e.slug??"",a=e.title??s,i=e.status??"",n=!0===e.closed,l=e.deadline??null,o=function(e){if(null!=e){if("string"==typeof e)return e;if("number"==typeof e)return String(e);if("object"==typeof e&&"userRewards"in e){let t=Number(e.userRewards);if(Number.isFinite(t))return(t/1e6).toFixed(2)}}}(r.rewards),c=r.positions??{};if(c.yes){let e=c.yes.cost??c.yes.marketValue;e&&Number(Number(e))>0&&t.push({marketSlug:s,market:a,outcome:"Yes",size:e,balance:e,status:i||void 0,marketClosed:n,closed:n?c.yes.realisedPnl??c.yes.marketValue??e:void 0,expirationDate:l??void 0,rewards:o??r.rewards??void 0})}if(c.no){let e=c.no.cost??c.no.marketValue;e&&Number(Number(e))>0&&t.push({marketSlug:s,market:a,outcome:"No",size:e,balance:e,status:i||void 0,marketClosed:n,closed:n?c.no.realisedPnl??c.no.marketValue??e:void 0,expirationDate:l??void 0,rewards:o??r.rewards??void 0})}}return t}(r):[]},enabled:e&&!!n,staleTime:0,refetchOnWindowFocus:!0})}},88435:(e,t,r)=>{"use strict";r.d(t,{$X:()=>i,Gi:()=>a,JF:()=>d,OG:()=>n,Xp:()=>m,ao:()=>o,g8:()=>c,qI:()=>u,xH:()=>l});var s=r(55036);let a="0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",i=6,n="0x4d97dcd97ec945f40cf65f87097ace5ea0476045",l="0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E",o="0xC5d563A36AE78145C45a50134d48A1215220f80a",c="0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296",d="0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",m=6;s.env.NEXT_PUBLIC_CTF_BASE_ADDRESS;let u="0xC9c98965297Bc527861c898329Ee280632B76e18"},88618:(e,t,r)=>{"use strict";r.d(t,{M5:()=>s,MG:()=>a,Mh:()=>n,fR:()=>l,qA:()=>o,wz:()=>c,zB:()=>i});let s=.01,a=3,i=.01,n=e=>e>s,l=e=>!isNaN(e)&&e>=1&&e<=99,o=e=>""===e||/^\d*\.?\d*$/.test(e),c=e=>""===e||/^\d{0,2}$/.test(e)},92723:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});var s=r(66577),a=r(56693),i=r(16610),n=r(55003),l=r(87562);function o({isOpen:e,onClose:t,onSuccess:r}){let{login:o,ready:c}=(0,i.u)(),{connect:d,isLoading:m,openModal:u}=(0,n.F)(),[x,h]=(0,a.useState)(!1),p=(0,a.useRef)(null);if((0,a.useEffect)(()=>{let r=e=>{p.current&&!p.current.contains(e.target)&&t()};if(e)return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[e,t]),(0,a.useEffect)(()=>{let r=r=>{"Escape"===r.key&&e&&t()};if(e)return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[e,t]),!e)return null;let f=async()=>{if(c){h(!0);try{await o(),r?.(),t()}catch(e){console.error("Privy login error:",e)}finally{h(!1)}}},g=async e=>{h(!0);try{e?await d(e):u()}catch(e){console.error("Phantom Connect error:",e)}finally{h(!1)}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/50 z-40",onClick:t}),(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center z-50 pointer-events-none",children:(0,s.jsxs)("div",{ref:p,className:"w-[340px] max-w-[90%] bg-[#0D0D0D] rounded-xl shadow-2xl border border-white/10 pointer-events-auto relative",children:[(0,s.jsx)("button",{onClick:t,className:"absolute top-4 right-4 p-2 hover:bg-white/10 rounded-lg transition text-gray-400 hover:text-white z-10","aria-label":"Close modal",children:(0,s.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),(0,s.jsx)("div",{className:"flex justify-center pt-8 pb-12",children:(0,s.jsx)(l.default,{src:"/images/raptorx.png",alt:"RaptorX Logo",width:80,height:80,className:"w-[52px] h-[44px] sm:w-[71px] sm:h-[60px] md:w-[73px] md:h-[62px]"})}),(0,s.jsxs)("div",{className:"px-6 pb-6 space-y-3 pt-4",children:[(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("button",{onClick:f,disabled:!c||x,className:`w-full flex items-center justify-center gap-3 px-4 py-3 rounded-lg transition-all duration-300 border ${!c||x?"border-white/10 text-gray-400 cursor-not-allowed":"border-white/20 hover:border-[#ffc000] text-white hover:text-[#ffc000]"}`,children:[(0,s.jsx)(l.default,{src:"/images/privy.png",alt:"Privy",width:24,height:24,className:"w-6 h-6"}),(0,s.jsx)("span",{className:`font-semibold text-sm ${!c||x?"text-gray-400":""}`,children:"Privy Login"}),x&&(0,s.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"})]}),(0,s.jsxs)("button",{onClick:()=>g("google"),disabled:m||x,className:`w-full flex items-center justify-center gap-3 px-4 py-3 rounded-lg transition-all duration-300 border ${m||x?"border-white/10 text-gray-400 cursor-not-allowed":"border-white/20 hover:border-[#ffc000] text-white hover:text-[#ffc000]"}`,children:[(0,s.jsx)(l.default,{src:"/images/phantom.png",alt:"Phantom",width:24,height:24,className:"w-6 h-6"}),(0,s.jsx)("span",{className:`font-semibold text-sm ${m||x?"text-gray-400":""}`,children:"Phantom Connect"}),m&&(0,s.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"})]})]}),(0,s.jsx)("div",{className:"pt-2 border-t-1 border-white/10",children:(0,s.jsx)("button",{onClick:()=>g(),disabled:m||x,className:`w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg transition-all duration-300 ${m||x?"text-gray-400 cursor-not-allowed":"hover:border-[#ffc000]/50 text-white/80 hover:text-white"}`,children:(0,s.jsx)("span",{className:"text-xs font-medium",children:"Or choose from all options"})})})]})]})})]})}},93200:(e,t,r)=>{"use strict";r.d(t,{C:()=>l,Z:()=>n});let s=new Set(["CLOSED","RESOLVED","SETTLED","ENDED","EXPIRED","CANCELLED","CANCELED","REMOVED"]),a=new Set(["CLOSED","RESOLVED","SETTLED","EXPIRED","CANCELLED","CANCELED","REMOVED","ARCHIVED","FINALIZED"]);function i(e){let t=e?.market??e?.category??e??{};return{trading:String(t.tradingStatus??t.trading_status??e?.tradingStatus??"").toUpperCase(),status:String(t.status??e?.status??"").toUpperCase()}}function n(e){if(!e||"object"!=typeof e)return!1;let{trading:t,status:r}=i(e);if(t&&s.has(t)||r&&a.has(r))return!0;let n=function(e){let t=e?.market??e?.category??e??{},r=t.endsAt??t.ends_at??e?.endsAt??e?.ends_at;if(null==r)return null;let s="number"==typeof r?r:new Date(String(r)).getTime();return Number.isFinite(s)?s:null}(e);return!!(null!=n&&n<Date.now())||e?.resolved===!0||e?.isResolved===!0||e?.market?.resolved===!0||e?.market?.isResolved===!0}function l(e){if(!e||"object"!=typeof e||n(e))return!1;let{trading:t,status:r}=i(e);return!(t&&s.has(t)||r&&a.has(r))&&("OPEN"===t||"ACTIVE"===t||"REGISTERED"===r||"OPEN"===r||"ACTIVE"===r||!n(e))}},98308:()=>{},98773:(e,t,r)=>{"use strict";r.d(t,{c:()=>c});var s=r(76180),a=r(5809),i=r(4206),n=r(74080);async function l(e){let t=await fetch("/api/predictfun/account",{cache:"no-store",headers:{Authorization:`Bearer ${e}`}});if(!t.ok)return null;let r=await t.json();return(0,a.Ac)(r)}async function o(e,t){let r=new URLSearchParams;r.set("address",e),r.set("first","100");let s={};t&&(s.Authorization=`Bearer ${t}`);let a=await fetch(`/api/predictfun/positions?${r}`,{cache:"no-store",headers:s});if(!a.ok)throw Error((await a.json().catch(()=>({error:a.statusText}))).error||"Positions fetch failed");return await a.json()}function c(e,t=!0,r=null,d=[],m){let u=m?.walletAddress??e,x=m?.chainId??56,h=m?.tradingAddress??null,p=(0,s.I)({queryKey:["predictfun-positions",e,d,r,u,x,h],enabled:t&&!!(e||u),queryFn:async()=>{let t=(0,i.J)(u,x,h??e);if(r){let e=await l(r);if(e){(0,n.S9)(x,u,e);let r=e.toLowerCase();t=t.some(e=>e.toLowerCase()===r)?[e,...t.filter(e=>e.toLowerCase()!==r)]:[e,...t]}}for(let e of d){let r=e?.trim();r&&/^0x[a-fA-F0-9]{40}$/i.test(r)&&(t.some(e=>
1e.toLowerCase()===r.toLowerCase())||t.push(r))}0===t.length&&e&&(t=[e]);let s=await Promise.all(t.map(e=>o(e,r)));return 1===s.length?s[0]:function(e){let t=[],r=new Map;for(let s of e)for(let e of(0,a.oD)(s)){let s=String(e?.tokenId??e?.id??JSON.stringify(e?.marketId??e?.market?.id??t.length));r.has(s)||(r.set(s,e),t.push(e))}let s=e[0];return{success:!0,data:{..."object"==typeof s?.data&&s?.data&&!Array.isArray(s.data)?s.data:{},positions:t}}}(s)},staleTime:1e4,refetchInterval:15e3});return{positions:p.data??null,isLoading:p.isLoading,isError:p.isError,error:p.error,refetch:p.refetch}}},99183:(e,t,r)=>{"use strict";r.d(t,{$u:()=>a,Fy:()=>c,QI:()=>o,W3:()=>n,tD:()=>l,ww:()=>i});var s=r(55036);let a="https://relayer-v2.polymarket.com/",i="https://clob.polymarket.com",n="https://polymarket.com/api/geoblock",l="https://polygon-rpc.com",o=s.env.NEXT_PUBLIC_BASE_RPC_URL||"https://mainnet.base.org",c=()=>`${window.location.origin}/api/polymarket/sign`}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.