1import{o as z}from"./rolldown-runtime-ChpBd9eV.js";import{In as H,La as q,P as E,Ta as F,_r as k}from"./chat-page-evUfHQgD.js";import{Bo as U,Go as _,Ho as Y,Jo as X,Ko as W,Uo as O,Vo as V,Wo as G,Xo as J,Yo as Z,qo as K}from"./market-core-DitXLvJ-.js";import{yr as B}from"./community-page-CrngAMw5.js";var c=z(q(),1),e=F(),w={active:{label:"LIVE",color:"text-green-400",bg:"bg-green-400",blink:!0},registration:{label:"REG",color:"text-amber-400",bg:"bg-amber-400",blink:!1},draft:{label:"DRAFT",color:"text-slate-500",bg:"bg-slate-500",blink:!1},completed:{label:"DONE",color:"text-slate-500",bg:"bg-slate-500",blink:!1},cancelled:{label:"CNCL",color:"text-red-500",bg:"bg-red-500",blink:!1}},M={Beginner:"text-green-400",Intermediate:"text-amber-400",Advanced:"text-orange-400",Expert:"text-red-400"},Q=[{id:"all",label:"ALL"},{id:"pnl",label:"P&L"},{id:"discipline",label:"DISC"}],R=({color:s="bg-green-400"})=>(0,e.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,e.jsx)("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full ${s} opacity-75`}),(0,e.jsx)("span",{className:`relative inline-flex rounded-full h-2 w-2 ${s}`})]}),$=({title:s,subtitle:x,right:p})=>(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-[#0a0e17] border-b border-amber-500/20",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-amber-500 font-mono text-[11px] font-bold tracking-wider",children:s}),x&&(0,e.jsx)("span",{className:"text-slate-500 font-mono text-[10px]",children:x})]}),p&&(0,e.jsx)("span",{className:"text-slate-600 font-mono text-[10px]",children:p})]}),n=({label:s,children:x})=>(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-slate-500 text-[9px] tracking-wider mb-1",children:s}),x]}),m="w-full px-2.5 py-1.5 bg-[#0d1220] border border-slate-700 rounded text-white text-[11px] font-mono focus:border-amber-500/50 focus:outline-none",S=m,ee=({isOpen:s,onClose:x,onSaved:p,editChallenge:d})=>{const j=!!d,[D,o]=(0,c.useState)(!1),{user:v}=k(),[a,f]=(0,c.useState)({title:"",description:"",type:"pnl",difficulty:"Intermediate",prize:"",startDate:"",endDate:"",maxParticipants:"",tags:"",startingBalance:1e5,maxDailyLoss:5,maxTotalDrawdown:10,minTrades:10,scoringMetric:"total_pnl",allowedInstruments:"all",maxPositionSize:5,requiredStopLoss:!0,maxTradesPerDay:10,journalRequired:!0});(0,c.useEffect)(()=>{if(d){const t=d.rules||{};f({title:d.title||"",description:d.description||"",type:d.type||"pnl",difficulty:d.difficulty||"Intermediate",prize:d.prize||"",startDate:d.startDate?.toDate?.()?.toISOString().slice(0,10)||"",endDate:d.endDate?.toDate?.()?.toISOString().slice(0,10)||"",maxParticipants:d.maxParticipants||"",tags:(d.tags||[]).join(", "),startingBalance:t.startingBalance||1e5,maxDailyLoss:t.maxDailyLoss||5,maxTotalDrawdown:t.maxTotalDrawdown||10,minTrades:t.minTrades||10,scoringMetric:t.scoringMetric||"total_pnl",allowedInstruments:t.allowedInstruments||"all",maxPositionSize:t.maxPositionSize||5,requiredStopLoss:t.requiredStopLoss!==!1,maxTradesPerDay:t.maxTradesPerDay||10,journalRequired:t.journalRequired!==!1})}},[d]);const i=(t,g)=>f(h=>({...h,[t]:g})),L=async()=>{if(!(!a.title||!a.startDate||!a.endDate)){o(!0);try{const t=a.type==="discipline"?{maxDailyLossLimit:a.maxDailyLoss,maxPositionSize:a.maxPositionSize,requiredStopLoss:a.requiredStopLoss,maxTradesPerDay:a.maxTradesPerDay,journalRequired:a.journalRequired,startingBalance:a.startingBalance}:{startingBalance:a.startingBalance,maxDailyLoss:a.maxDailyLoss,maxTotalDrawdown:a.maxTotalDrawdown,minTrades:a.minTrades,scoringMetric:a.scoringMetric,allowedInstruments:a.allowedInstruments};j?await J(d.id,{title:a.title,description:a.description,type:a.type,difficulty:a.difficulty,prize:a.prize,rules:t,startDate:a.startDate,endDate:a.endDate,maxParticipants:a.maxParticipants?Number(a.maxParticipants):null,tags:a.tags.split(",").map(g=>g.trim()).filter(Boolean)}):await U({title:a.title,description:a.description,type:a.type,difficulty:a.difficulty,prize:a.prize,rules:t,startDate:a.startDate,endD
1ate:a.endDate,maxParticipants:a.maxParticipants?Number(a.maxParticipants):null,tags:a.tags.split(",").map(g=>g.trim()).filter(Boolean),createdBy:v?.uid}),p(),x()}catch(t){console.error("Error saving challenge:",t)}finally{o(!1)}}};return s?(0,e.jsx)("div",{className:"fixed inset-0 bg-black/80 backdrop-blur-sm z-50 flex items-center justify-center p-4",onClick:x,children:(0,e.jsxs)("div",{className:"bg-[#0a0e17] border border-amber-500/30 rounded-lg w-full max-w-2xl max-h-[85vh] overflow-y-auto font-mono text-[11px]",onClick:t=>t.stopPropagation(),children:[(0,e.jsx)($,{title:j?"EDIT CHALLENGE":"CREATE CHALLENGE",subtitle:"// Admin",right:(0,e.jsx)("button",{onClick:x,className:"text-slate-500 hover:text-white",children:"â"})}),(0,e.jsxs)("div",{className:"p-4 space-y-3",children:[(0,e.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,e.jsx)(n,{label:"TITLE *",children:(0,e.jsx)("input",{className:m,value:a.title,onChange:t=>i("title",t.target.value),placeholder:"e.g. Weekly P&L Sprint"})}),(0,e.jsx)(n,{label:"TYPE *",children:(0,e.jsxs)("select",{className:S,value:a.type,onChange:t=>i("type",t.target.value),children:[(0,e.jsx)("option",{value:"pnl",children:"P&L Challenge â Highest profit wins"}),(0,e.jsx)("option",{value:"discipline",children:"Discipline Challenge â Best risk mgmt wins"})]})})]}),(0,e.jsx)(n,{label:"DESCRIPTION",children:(0,e.jsx)("textarea",{className:"w-full px-2.5 py-1.5 bg-[#0d1220] border border-slate-700 rounded text-white text-[11px] font-mono focus:border-amber-500/50 focus:outline-none h-16 resize-none",value:a.description,onChange:t=>i("description",t.target.value),placeholder:"Describe the challenge rules and goals..."})}),(0,e.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[(0,e.jsx)(n,{label:"START DATE *",children:(0,e.jsx)("input",{type:"date",className:m,value:a.startDate,onChange:t=>i("startDate",t.target.value)})}),(0,e.jsx)(n,{label:"END DATE *",children:(0,e.jsx)("input",{type:"date",className:m,value:a.endDate,onChange:t=>i("endDate",t.target.value)})}),(0,e.jsx)(n,{label:"DIFFICULTY",children:(0,e.jsx)("select",{className:S,value:a.difficulty,onChange:t=>i("difficulty",t.target.value),children:["Beginner","Intermediate","Advanced","Expert"].map(t=>(0,e.jsx)("option",{value:t,children:t},t))})}),(0,e.jsx)(n,{label:"PRIZE",children:(0,e.jsx)("input",{className:m,value:a.prize,onChange:t=>i("prize",t.target.value),placeholder:"e.g. $500 Cash"})})]}),(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,e.jsx)(n,{label:"MAX PARTICIPANTS (0 = unlimited)",children:(0,e.jsx)(E,{className:m,value:a.maxParticipants,onChange:t=>i("maxParticipants",t.target.value)})}),(0,e.jsx)(n,{label:"TAGS (comma separated)",children:(0,e.jsx)("input",{className:m,value:a.tags,onChange:t=>i("tags",t.target.value),placeholder:"e.g. Stocks, Day Trading"})})]}),(0,e.jsxs)("div",{className:"border-t border-slate-800 pt-3",children:[(0,e.jsx)("div",{className:"text-amber-400 text-[10px] font-bold tracking-wider mb-2",children:a.type==="pnl"?"⸠P&L CHALLENGE RULES":"⸠DISCIPLINE CHALLENGE RULES"}),a.type==="pnl"?(0,e.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:[(0,e.jsx)(n,{label:"STARTING BALANCE ($)",children:(0,e.jsx)(E,{className:m,value:a.startingBalance,onChange:t=>i("startingBalance",Number(t.target.value))})}),(0,e.jsx)(n,{label:"MAX DAILY LOSS (%)",children:(0,e.jsx)(E,{className:m,value:a.maxDailyLoss,onChange:t=>i("maxDailyLoss",Number(t.target.value))})}),(0,e.jsx)(n,{label:"MAX TOTAL DRAWDOWN (%)",children:(0,e.jsx)(E,{className:m,value:a.maxTotalDrawdown,onChange:t=>i("maxTotalDrawdown",Number(t.target.value))})}),(0,e.jsx)(n,{label:"MIN TRADES",children:(0,e.jsx)(E,{className:m,value:a.minTrades,onChange:t=>i("minTrades",Number(t.target.value))})}),(0,e.jsx)(n,{label:"SCORING METRIC",children:(0,e.jsxs)("select",{className:S,value:a.scoringMetric,onChange:t=>i("scoringMetric",t.target.value),children:[(0,e.jsx)("option",{value:"total_pnl",children:"Total P&L ($)"}),(0,e.jsx)("option",{value:"percentage_return",children:"% Return"}),(0,e.jsx)("option",{value:"risk_adjusted",children:"Risk-Adjusted (Sharpe)"})]})}),(0,e.jsx)(n,{label:"INSTRUMENTS",children:(0,e.jsxs)("select",{className:S,value:a.allowedInstruments,onChange:t=>i("allowedInstruments",t.target.value),children:[(0,e.jsx)("option",{value:"all",children:"All"}),(0,e.jsx)("option",{value:"stocks",children:"Stocks Only"}),(0,e.jsx)("option",{value:"options",children:"Options Only"}),(0,e.jsx)("option",{value:"crypto",children:"Crypto Only"}),(0,e.jsx)("option",{value:"forex",children:"Forex Only"})]})})]}):(0,e.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:[(0,e.jsx)(n,{label:"STARTING BALANCE ($)",children:(0,e.jsx)(E,{className:m,value:a.startingBalance,onChange:t=>i("startingBalance",Number(t.target.value))})}),(0,e.jsx)(n,{label:"MAX DAILY LOSS (%)",children:(0,e.jsx)(E,{className:m,value:a.maxDailyLoss,onChange:t=>i("maxDailyLoss",Number(t.target.value))})}),(0,e.jsx)(n,{label:"MAX POSITION SIZE (%)",children:(0,e.jsx)(E,{className:m,value:a.maxPositionSize,onChange:t=>i("maxPositionSize",Number(t.target.value))})}),(0,e.jsx)(n,{label:"MAX TRADES/DAY",children:(0,e.jsx)(E,{className:m,value:a.maxTradesPerDay,onChange:t=>i("maxTradesPerDay",Number(t.target.value))})}),(0,e.jsx)(n,{label:"REQUIRE STOP LOSS",children:(0,e.jsxs)("select",{className:S,value:a.requiredStopLoss?"yes":"no",onChange:t=>i("requiredStopLoss",t.target.value==="yes"),children:[(0,e.jsx)("option",{value:"yes",children:"Yes"}),(0,e.jsx)("option",{value:"no",children:"No"})]})}),(0,e.jsx)(n,{label:"REQUIRE JOURNAL",children:(0,e.jsxs)("select",{className:S,value:a.journalRequired?"yes":"no",onChange:t=>i("journalRequired",t.target.value==="yes"),children:[(0,e.jsx)("option",{value:"yes",children:"Yes"}),(0,e.jsx)("option",{value:"no",children:"No"})]})})]})]}),(0,e.jsxs)("div",{className:"flex gap-2 pt-2 border-t border-slate-800",children:[(0,e.jsx)("button",{onClick:L,disabled:D,className:"flex-1 py-2 bg-amber-500/15 border border-amber-500/50 text-amber-400 font-bold rounded hover:bg-amber-500/25 transition-colors disabled:opacity-50",children:D?"SAVING...":j?"UPDATE CHALLENGE":"CREATE CHALLENGE"}),(0,e.jsx)("button",{onClick:x,className:"px-6 py-2 bg-slate-800 border border-slate-700 text-slate-400 font-bold rounded hover:bg-slate-700 transition-colors",children:"CANCEL"})]})]})]})}):null},te=({challenge:s,onClose:x,isAdmin:p,onEdit:d,onDelete:j,onRefresh:D})=>{const{user:o}=k(),[v,a]=(0,c.useState)(null),[f,i]=(0,c.useState)([]),[L,t]=(0,c.useState)(!1),[g,h]=(0,c.useState)(!1),[A,T]=(0,c.useState)(!0),y=w[s.status]||w.active,I=s.rules||{};(0,c.useEffect)(()=>{(async()=>{T(!0);try{const[b,P]=await Promise.all([O(s.id,20),o?.uid?W(s.id,o.uid):null]);i(b),a(P)}catch(b){console.error("Error loading challenge detail:",b)}finally{T(!1)}})()},[s.id,o?.uid]);const l=async()=>
1{if(o){t(!0);try{await K(s.id,o),a({userId:o.uid,score:0}),D()}catch{}finally{t(!1)}}},N=async()=>{if(o)try{await X(s.id,o.uid),a(null),D()}catch{}},C=async()=>{if(o){h(!0);try{const r=await Z(s.id,o.uid);a(b=>({...b,...r})),i(await O(s.id,20))}catch{}finally{h(!1)}}},u=s.type==="pnl";return(0,e.jsxs)("div",{className:"bg-[#0a0e17] border border-amber-500/20 rounded font-mono text-[11px]",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-amber-500/20 bg-[#0d1220]",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-amber-400 font-bold text-sm",children:s.title}),(0,e.jsx)("span",{className:`px-1.5 py-0.5 rounded text-[9px] font-bold ${u?"bg-green-500/15 text-green-400":"bg-blue-500/15 text-blue-400"}`,children:u?"P&L":"DISCIPLINE"}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[y.blink&&(0,e.jsx)(R,{color:y.bg}),(0,e.jsx)("span",{className:`${y.color} text-[10px] font-bold`,children:y.label})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:()=>d(s),className:"text-blue-400 hover:text-blue-300 text-[10px] font-bold",children:"EDIT"}),(0,e.jsx)("button",{onClick:()=>{window.confirm("Delete this challenge?")&&j(s.id)},className:"text-red-400 hover:text-red-300 text-[10px] font-bold",children:"DEL"})]}),(0,e.jsx)("button",{onClick:x,className:"text-slate-500 hover:text-white px-1",children:"â"})]})]}),(0,e.jsxs)("div",{className:"p-3 space-y-3",children:[(0,e.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-px bg-slate-800/50",children:[{label:"PRIZE",value:s.prize||"â",color:"text-green-400"},{label:"TRADERS",value:s.participantCount||0,color:"text-cyan-400"},{label:"DIFFICULTY",value:s.difficulty,color:M[s.difficulty]||"text-white"},{label:"DATES",value:`${_(s.startDate)} â ${_(s.endDate)}`,color:"text-blue-400"},{label:"COUNTDOWN",value:G(s.endDate),color:"text-amber-400"}].map((r,b)=>(0,e.jsxs)("div",{className:"bg-[#0d1220] p-2",children:[(0,e.jsx)("div",{className:"text-slate-600 text-[9px] tracking-wider",children:r.label}),(0,e.jsx)("div",{className:`${r.color} font-bold`,children:r.value})]},b))}),s.description&&(0,e.jsx)("p",{className:"text-slate-400 text-[11px] leading-relaxed",children:s.description}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-slate-600 text-[9px] tracking-wider mb-1",children:"RULES"}),(0,e.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-px bg-slate-800/30",children:Object.entries(I).filter(([r])=>r!=="scoringWeights").map(([r,b])=>(0,e.jsxs)("div",{className:"bg-[#0d1220] px-2 py-1",children:[(0,e.jsxs)("span",{className:"text-slate-600 text-[9px]",children:[r.replace(/([A-Z])/g," $1").toUpperCase(),": "]}),(0,e.jsx)("span",{className:"text-white font-bold",children:typeof b=="boolean"?b?"YES":"NO":b})]},r))})]}),(0,e.jsx)("div",{className:"flex gap-2",children:v?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"flex-1 flex items-center gap-3 px-3 py-2 bg-green-500/10 border border-green-500/30 rounded",children:[(0,e.jsx)("span",{className:"text-green-400 font-bold",children:"â ENROLLED"}),(0,e.jsxs)("span",{className:"text-slate-400",children:["Score: ",(0,e.jsx)("span",{className:"text-white font-bold",children:v.score||0})]}),(0,e.jsxs)("span",{className:"text-slate-400",children:["P&L: ",(0,e.jsxs)("span",{className:`font-bold ${(v.pnl||0)>=0?"text-green-400":"text-red-400"}`,children:["$",(v.pnl||0).toLocaleString()]})]})]}),(0,e.jsx)("button",{onClick:C,disabled:g,className:"px-3 py-2 bg-blue-500/10 border border-blue-500/30 text-blue-400 font-bold rounded hover:bg-blue-500/20 disabled:opacity-50",children:g?"...":"â» SYNC"}),(0,e.jsx)("button",{onClick:N,className:"px-3 py-2 bg-red-500/10 border border-red-500/30 text-red-400 font-bold rounded hover:bg-red-500/20",children:"LEAVE"})]}):(0,e.jsx)("button",{onClick:l,disabled:L||s.status==="completed",className:"flex-1 py-2 bg-amber-500/10 border border-amber-500/40 text-amber-400 font-bold rounded hover:bg-amber-500/20 disabled:opacity-30",children:L?"JOINING...":s.status==="completed"?"CHALLENGE ENDED":"â¶ JOIN CHALLENGE"})}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"text-slate-600 text-[9px] tracking-wider mb-1",children:["LEADERBOARD â ",u?"RANKED BY P&L":"RANKED BY DISCIPLINE SCORE"]}),A?(0,e.jsx)("div",{className:"text-center py-4 text-amber-500 animate-pulse",children:"Loading leaderboard..."}):f.length===0?(0,e.jsx)("div",{className:"text-center py-4 text-slate-700 border border-dashed border-slate-800 rounded",children:"No participants yet. Be the first to join!"}):(0,e.jsxs)("div",{className:"border border-slate-800 rounded overflow-hidden",children:[(0,e.jsxs)("div",{className:"grid grid-cols-[32px_1fr_70px_60px_60px_60px] gap-px bg-slate-800/40 text-[9px] tracking-wider text-slate-600 font-bold",children:[(0,e.jsx)("div",{className:"bg-[#0d1220] px-2 py-1",children:"#"}),(0,e.jsx)("div",{className:"bg-[#0d1220] px-2 py-1",children:"TRADER"}),(0,e.jsx)("div",{className:"bg-[#0d1220] px-2 py-1 text-right",children:"SCORE"}),(0,e.jsx)("div",{className:"bg-[#0d1220] px-2 py-1 text-right",children:"P&L"}),(0,e.jsx)("div",{className:"bg-[#0d1220] px-2 py-1 text-right",children:"W/R"}),(0,e.jsx)("div",{className:"bg-[#0d1220] px-2 py-1 text-right",children:"TRADES"})]}),(0,e.jsx)("div",{className:"divide-y divide-slate-800/60 max-h-[200px] overflow-y-auto",children:f.map(r=>{const b=r.id===o?.uid,P=r.rank===1?"text-amber-400":r.rank===2?"text-slate-300":r.rank===3?"text-orange-400":"text-slate-500";return(0,e.jsxs)("div",{className:`grid grid-cols-[32px_1fr_70px_60px_60px_60px] gap-px ${b?"bg-amber-500/5":"hover:bg-slate-800/30"}`,children:[(0,e.jsx)("div",{className:`px-2 py-1.5 font-bold text-center ${P}`,children:r.rank}),(0,e.jsxs)("div",{className:"px-2 py-1.5 text-white truncate",children:[r.displayName||"Trader",b&&(0,e.jsx)("span",{className:"text-amber-400 ml-1",children:"(you)"})]}),(0,e.jsx)("div",{className:"px-2 py-1.5 text-right text-amber-400 font-bold",children:r.score||0}),(0,e.jsxs)("div",{className:`px-2 py-1.5 text-right font-bold ${B(r)>=0?"text-green-400":"text-red-400"}
1`,children:["$",B(r).toLocaleString()]}),(0,e.jsxs)("div",{className:"px-2 py-1.5 text-right text-emerald-400",children:[r.winRate||0,"%"]}),(0,e.jsx)("div",{className:"px-2 py-1.5 text-right text-slate-400",children:r.tradeCount||0})]},r.id)})})]})]})]})]})},ie=()=>{const{user:s}=k(),{isAdmin:x}=H(),[p,d]=(0,c.useState)([]),[j,D]=(0,c.useState)("all"),[o,v]=(0,c.useState)(null),[a,f]=(0,c.useState)(!1),[i,L]=(0,c.useState)(null),[t,g]=(0,c.useState)(!0),h=(0,c.useCallback)(async()=>{g(!0);try{d(await Y({typeFilter:j!=="all"?j:void 0}))}catch(l){console.error("Error loading challenges:",l)}finally{g(!1)}},[j]);(0,c.useEffect)(()=>{h()},[h]);const A=async l=>{try{await V(l),v(null),h()}catch{}},T=l=>{L(l),f(!0)},y=(0,c.useMemo)(()=>{const l=p.filter(u=>u.status==="active").length,N=p.filter(u=>u.status==="registration").length,C=p.reduce((u,r)=>u+(r.participantCount||0),0);return{active:l,reg:N,total:p.length,totalParticipants:C}},[p]),I=new Date().toISOString().replace("T"," ").slice(0,19)+" UTC";return t&&p.length===0?(0,e.jsx)("div",{className:"bg-[#070b14] min-h-[400px] flex items-center justify-center font-mono",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("div",{className:"text-amber-500 text-sm animate-pulse mb-2",children:"LOADING CHALLENGE DATA..."}),(0,e.jsx)("div",{className:"text-slate-600 text-[10px]",children:"Connecting to TradeIntelX Terminal"})]})}):(0,e.jsxs)("div",{className:"bg-[#070b14] min-h-[500px] font-mono text-[11px] select-none",children:[(0,e.jsx)("div",{className:"border-b border-amber-500/30 bg-[#0a0e17]",children:(0,e.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)("span",{className:"text-amber-500 font-bold text-sm tracking-widest",children:"TIX"}),(0,e.jsx)("span",{className:"text-slate-600 text-[10px]",children:"CHALLENGES"}),(0,e.jsx)("div",{className:"h-3 w-px bg-slate-700"}),(0,e.jsx)(R,{color:"bg-green-400"}),(0,e.jsx)("span",{className:"text-green-400 text-[10px] font-bold",children:"CONNECTED"})]}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[x&&(0,e.jsx)("button",{onClick:()=>{L(null),f(!0)},className:"px-3 py-1 bg-amber-500/15 border border-amber-500/50 text-amber-400 font-bold text-[10px] rounded hover:bg-amber-500/25 transition-colors",children:"+ NEW CHALLENGE"}),(0,e.jsx)("button",{onClick:h,className:"text-slate-500 hover:text-white text-[10px]",children:"â» REFRESH"}),(0,e.jsx)("span",{className:"text-slate-700 text-[10px]",children:I})]})]})}),(0,e.jsx)("div",{className:"border-b border-slate-800 bg-[#0a0e17]/80 overflow-x-auto",children:(0,e.jsx)("div",{className:"flex items-center min-w-max",children:[{label:"LIVE",value:y.active,color:"text-green-400"},{label:"REG OPEN",value:y.reg,color:"text-amber-400"},{label:"TOTAL",value:y.total,color:"text-blue-400"},{label:"TRADERS",value:y.totalParticipants,color:"text-cyan-400"}].map((l,N)=>(0,e.jsxs)("div",{className:"flex items-center gap-2 px-4 py-1.5 border-r border-slate-800/80 last:border-r-0",children:[(0,e.jsx)("span",{className:"text-slate-600 text-[9px] tracking-wider",children:l.label}),(0,e.jsx)("span",{className:`${l.color} font-bold text-xs`,children:l.value})]},N))})}),(0,e.jsxs)("div",{className:"p-2 sm:p-3 space-y-2 sm:space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 flex-wrap",children:[(0,e.jsx)("span",{className:"text-slate-600 text-[9px] tracking-wider mr-1",children:"TYPE:"}),Q.map(l=>(0,e.jsx)("button",{onClick:()=>D(l.id),className:`px-2.5 py-1 text-[10px] font-bold tracking-wider border transition-colors rounded-sm ${j===l.id?"bg-amber-500/15 border-amber-500/50 text-amber-400":"bg-transparent border-slate-800 text-slate-600 hover:text-slate-400 hover:border-slate-600"}`,children:l.label},l.id)),(0,e.jsxs)("span",{className:"text-slate-700 text-[9px] ml-auto",children:[p.length," CHALLENGES"]})]}),(0,e.jsxs)("div",{className:"border border-slate-800 rounded bg-[#0a0e17]",children:[(0,e.jsx)($,{title:"CHALLENGE BOARD",subtitle:"// Click a row for details",right:`${p.length} items`}),(0,e.jsxs)("div",{className:"grid grid-cols-[50px_1fr_55px_70px_65px_70px_65px] sm:grid-cols-[55px_1fr_65px_80px_75px_80px_75px] gap-px bg-slate-800/40 text-[9px] tracking-wider text-slate-600 font-bold",children:[(0,e.jsx)("div",{className:"bg-[#0d1220] px-2 py-1.5",children:"STATUS"}),(0,e.jsx)("div",{className:"bg-[#0d1220] px-2 py-1.5",children:"CHALLENGE"}),(0,e.jsx)("div",{className:"bg-[#0d1220] px-2 py-1.5",children:"TYPE"}),(0,e.jsx)("div",{className:"bg-[#0d1220] px-2 py-1.5 text-right",children:"PRIZE"}),(0,e.jsx)("div",{className:"bg-[#0d1220] px-2 py-1.5 text-right",children:"TRADERS"}),(0,e.jsx)("div",{className:"bg-[#0d1220] px-2 py-1.5",children:"LEVEL"}),(0,e.jsx)("div",{className:"bg-[#0d1220] px-2 py-1.5 text-right",children:"ENDS IN"})]}),(0,e.jsx)("div",{className:"divide-y divide-slate-800/60",children:p.length===0?(0,e.jsxs)("div",{className:"text-center py-8 text-slate-600",children:[(0,e.jsx)("div",{className:"text-sm mb-1",children:x?"NO CHALLENGES YET":"NO CHALLENGES AVAILABLE"}),(0,e.jsx)("div",{className:"text-[10px]",children:x?'Click "+ NEW CHALLENGE" to create one':"Check back soon for new challenges"})]}):p.map(l=>{const N=w[l.status]||w.active,C=o?.id===l.id,u=l.type==="pnl";return(0,e.jsxs)("button",{onClick:()=>v(C?null:l),className:`w-full grid grid-cols-[50px_1fr_55px_70px_65px_70px_65px] sm:grid-cols-[55px_1fr_65px_80px_75px_80px_75px] gap-px text-left transition-colors ${C?"bg-amber-500/5":"hover:bg-slate-800/30"}`,children:[(0,e.jsxs)("div",{className:"px-2 py-2 flex items-center gap-1",children:[N.blink&&(0,e.jsx)(R,{color:N.bg}),(0,e.jsx)("span",{className:`${N.color} font-bold text-[10px]`,children:N.label})]}),(0,e.jsx)("div",{className:"px-2 py-2 text-white truncate font-medium",children:l.title}),(0,e.jsx)("div",{className:`px-2 py-2 font-bold ${u?"text-green-400":"text-blue-400"}`,children:u?"P&L":"DISC"}),(0,e.jsx)("div",{className:"px-2 py-2 text-right text-green-400 font-bold",children:l.prize||"â"}),(0,e.jsx)("div",{className:"px-2 py-2 text-right text-cyan-400",children:l.participantCount||0}),(0,e.jsx)("div",{className:`px-2 py-2 ${M[l.difficulty]||"text-white"} font-bold`,children:l.difficulty?.slice(0,6).toUpperCase()}),(0,e.jsx)("div",{className:"px-2 py-2 text-right text-amber-400 font-bold",children:G(l.endDate)})]},l.id)})})]}),o&&(0,e.jsx)(te,{challenge:o,onClose:()=>v(null),isAdmin:x,onEdit:T,onDelete:A,onRefresh:h}),(0,e.jsxs)("div",{className:"flex items-center justify-between px-2 py-1 text-[9px] text-slate-700 border-t border-slate-800/50",children:[(0,e.jsx)("span",{children:"TradeIntelX Terminal ⢠Challenges v2"}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[x&&(0,e.jsx)("span",{className:"text-amber-500",children:"ADMIN MODE"}),(0,e.jsx)("span",{children:"Click row â Details + Leaderboard"})]})]})]}),(0,e.jsx)(ee,{isOpen:a,onClose:()=>{f(!1),L(null)},onSaved:h,editChallenge:i})]})};export{ie as default};
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.