1/*! For license information please see 9900.24bf08c9.chunk.js.LICENSE.txt */ 2"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[9900],{5077(e,t,s){s.d(t,{A:()=>a});const a=(0,s(77784).A)("flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]])},7365(e,t,s){s.d(t,{A:()=>a});const a=(0,s(77784).A)("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]])},14960(e,t,s){s.d(t,{A:()=>a});const a=(0,s(77784).A)("bitcoin",[["path",{d:"M11.767 19.089c4.924.868 6.14-6.025 1.216-6.894m-1.216 6.894L5.86 18.047m5.908 1.042-.347 1.97m1.563-8.864c4.924.869 6.14-6.025 1.215-6.893m-1.215 6.893-3.94-.694m5.155-6.2L8.29 4.26m5.908 1.042.348-1.97M7.48 20.364l3.126-17.727",key:"yr8idg"}]])},27899(e,t,s){s.d(t,{A:()=>a});const a=(0,s(77784).A)("arrow-down-right",[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]])},29900(e,t,s){s.r(t),s.d(t,{default:()=>ie});var a=s(53986),l=s(89379),r=s(65043),n=s(45685),i=s(79722),c=s(13390),d=s(92264),o=s(95258),x=s(14960),m=s(53639),h=s(55731),p=s(22024),u=s(68236),b=s(82054),g=s(20073);const v=(0,s(77784).A)("power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]);var j=s(84991),f=s(64830),N=s(37719),y=s(27033),w=s(7365),A=s(34537),_=s(50516),k=s(39292),S=s(76245),C=s(44919),D=s(73782),P=s(56099),L=s(67010),U=s(27899),T=s(23165),F=s(87147),R=s(42489),E=s(88693),M=s(56328),$=s(69284),I=s(41180),B=s(877),O=s(87734),z=s(52185),G=s(6026),q=s(80379),H=s(35963),V=s(16992),K=s(56102),W=s(17869),Y=s(5077),Q=s(63507),X=s(85347),Z=s(75088),J=s(70579);function ee(e){let{label:t,value:s,subtitle:a,icon:l,color:r="text-white",bgColor:n="bg-slate-800"}=e;return(0,J.jsxs)("div",{className:"".concat(n," backdrop-blur-xl border border-white/10 rounded-xl p-4"),"data-testid":"stat-".concat(t.toLowerCase().replace(/\s/g,"-")),children:[(0,J.jsxs)("div",{className:"flex items-start justify-between mb-2",children:[(0,J.jsx)("span",{className:"text-xs text-slate-400 uppercase tracking-wider",children:t}),l&&(0,J.jsx)(l,{className:"w-4 h-4 ".concat(r)})]}),(0,J.jsx)("div",{className:"text-2xl font-bold ".concat(r),children:s}),a&&(0,J.jsx)("div",{className:"text-xs text-slate-500 mt-1",children:a})]})}function te(e){var t,s;let{auth:a}=e;const[l,n]=(0,r.useState)(null),[d,o]=(0,r.useState)(!0),x={Authorization:"Bearer ".concat(null===a||void 0===a?void 0:a.token)},m=(0,r.useCallback)(async()=>{try{const e=await i.A.get("".concat("https://api.bittradehq.com/api","/power-bot/dashboard/analytics"),{headers:x});n(e.data)}catch(t){var e;403!==(null===(e=t.response)||void 0===e?void 0:e.status)&&M.oR.error("Failed to load dashboard data")}finally{o(!1)}},[null===a||void 0===a?void 0:a.token]);if((0,r.useEffect)(()=>{m();const e=setInterval(m,6e4);return()=>clearInterval(e)},[m]),d)return(0,J.jsx)("div",{className:"flex items-center justify-center h-96",children:(0,J.jsx)(p.A,{className:"w-8 h-8 animate-spin text-emerald-400"})});const h=(null===l||void 0===l?void 0:l.summary)||{},u=(null===l||void 0===l?void 0:l.pnl_timeline)||[],b=(null===l||void 0===l?void 0:l.asset_performance)||[],v=(null===l||void 0===l?void 0:l.recent_trades)||[],j=(null===l||void 0===l?void 0:l.trade_distribution)||{},f=(null===l||void 0===l?void 0:l.auto_pilot)||{},N=[{name:"Wins",value:h.winning_trades||0},{name:"Losses",value:h.losing_trades||0}].filter(e=>e.value>0),w=["#10b981","#ef4444"],k=[{name:"Long",value:j.long||0},{name:"Short",value:j.short||0}].filter(e=>e.value>0),S=["#3b82f6","#f97316"],P=0===h.total_trades;return(0,J.jsxs)("div",{className:"space-y-6","data-testid":"power-bot-dashboard",children:[(0,J.jsxs)("div",{className:"flex items-center justify-between",children:[(0,J.jsxs)("div",{children:[(0,J.jsxs)("h2",{className:"text-xl font-bold flex items-center gap-2",children:[(0,J.jsx)(y.A,{className:"w-5 h-5 text-emerald-400"}),"Performance Dashboard"]}),(0,J.jsx)("p",{className:"text-sm text-slate-400 mt-0.5",children:f.enabled?f.live_mode?(0,J.jsxs)("span",{className:"text-red-400 flex items-center gap-1",children:[(0,J.jsx)(g.A,{className:"w-3 h-3"})," Auto-Pilot LIVE on ",null===(t=f.live_exchange)||void 0===t?void 0:t.toUpperCase()]}):(0,J.jsxs)("span",{className:"text-emerald-400 flex items-center gap-1",children:[(0,J.jsx)(g.A,{className:"w-3 h-3"})," Auto-Pilot Active (Paper)"]}):"Real-time trading performance analytics"})]}),(0,J.jsxs)(c.$,{variant:"outline",size:"sm",onClick:()=>{o(!0),m()},className:"border-white/10","data-testid":"refresh-dashboard-btn",children:[(0,J.jsx)(_.A,{className:"w-4 h-4 mr-1"})," Refresh"]})]}),P?(0,J.jsxs)("div",{className:"bg-slate-900/60 border border-white/10 rounded-xl p-12 text-center",children:[(0,J.jsx)(y.A,{className:"w-12 h-12 text-slate-600 mx-auto mb-4"}),(0,J.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"No Trading Data Yet"}),(0,J.jsx)("p",{className:"text-sm text-slate-400 max-w-md mx-auto",children:"Start trading with the Power Bot to see your performance here. Use Quick Scan to find opportunities or enable Auto-Pilot for 24/7 hands-off trading."})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-3",children:[(0,J.jsx)(ee,{label:"Total P&L",value:"$".concat(null===(s=h.total_pnl)||void 0===s?void 0:s.toLocaleStr
2ing()),subtitle:"".concat(h.closed_trades," closed trades"),icon:h.total_pnl>=0?C.A:D.A,color:h.total_pnl>=0?"text-emerald-400":"text-red-400"}),(0,J.jsx)(ee,{label:"Win Rate",value:"".concat(h.win_rate,"%"),subtitle:"".concat(h.winning_trades,"W / ").concat(h.losing_trades,"L"),icon:T.A,color:h.win_rate>=60?"text-emerald-400":h.win_rate>=40?"text-amber-400":"text-red-400"}),(0,J.jsx)(ee,{label:"Open Trades",value:h.open_trades,subtitle:"Active positions",icon:A.A,color:"text-blue-400"}),(0,J.jsx)(ee,{label:"Avg Confidence",value:"".concat(h.avg_confidence,"%"),subtitle:"Signal quality",icon:R.A,color:"text-cyan-400"}),(0,J.jsx)(ee,{label:"Win Streak",value:h.current_win_streak,subtitle:"Best: ".concat(h.max_win_streak),icon:Y.A,color:"text-amber-400"}),(0,J.jsx)(ee,{label:"Avg Hold Time",value:h.avg_hold_hours?"".concat(h.avg_hold_hours,"h"):"N/A",subtitle:"Per trade",icon:Q.A,color:"text-purple-400"})]}),(0,J.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[(0,J.jsxs)("div",{className:"lg:col-span-2 bg-slate-900/60 border border-white/10 rounded-xl p-5","data-testid":"pnl-chart",children:[(0,J.jsxs)("h3",{className:"text-sm font-semibold mb-4 flex items-center gap-2",children:[(0,J.jsx)(C.A,{className:"w-4 h-4 text-emerald-400"}),"Cumulative P&L"]}),u.length>0?(0,J.jsx)(I.u,{width:"100%",height:250,children:(0,J.jsxs)(B.Q,{data:u,children:[(0,J.jsx)("defs",{children:(0,J.jsxs)("linearGradient",{id:"pnlGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,J.jsx)("stop",{offset:"5%",stopColor:"#10b981",stopOpacity:.3}),(0,J.jsx)("stop",{offset:"95%",stopColor:"#10b981",stopOpacity:0})]})}),(0,J.jsx)(O.d,{strokeDasharray:"3 3",stroke:"#1e293b"}),(0,J.jsx)(z.W,{dataKey:"date",tick:{fontSize:10,fill:"#64748b"},tickFormatter:e=>new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}),(0,J.jsx)(G.h,{tick:{fontSize:10,fill:"#64748b"},tickFormatter:e=>"$".concat(e)}),(0,J.jsx)(q.m,{contentStyle:{backgroundColor:"#0f172a",border:"1px solid #1e293b",borderRadius:8},labelFormatter:e=>new Date(e).toLocaleString(),formatter:(e,t)=>["$".concat(e),"cumulative"===t?"Cumulative P&L":"Trade P&L"]}),(0,J.jsx)(H.Gk,{type:"monotone",dataKey:"cumulative",stroke:"#10b981",fill:"url(#pnlGradient)",strokeWidth:2})]})}):(0,J.jsx)("div",{className:"h-[250px] flex items-center justify-center text-slate-500 text-sm",children:"Complete trades to see P&L chart"})]}),(0,J.jsxs)("div",{className:"space-y-4",children:[(0,J.jsxs)("div",{className:"bg-slate-900/60 border border-white/10 rounded-xl p-5","data-testid":"win-loss-chart",children:[(0,J.jsx)("h3",{className:"text-sm font-semibold mb-3",children:"Win / Loss Ratio"}),N.length>0?(0,J.jsx)(I.u,{width:"100%",height:110,children:(0,J.jsxs)(V.r,{children:[(0,J.jsx)(K.Fq,{data:N,cx:"50%",cy:"50%",innerRadius:30,outerRadius:50,dataKey:"value",paddingAngle:4,children:N.map((e,t)=>(0,J.jsx)(W.f,{fill:w[t]},t))}),(0,J.jsx)(q.m,{contentStyle:{backgroundColor:"#0f172a",border:"1px solid #1e293b",borderRadius:8}})]})}):(0,J.jsx)("div",{className:"h-[110px] flex items-center justify-center text-slate-500 text-sm",children:"No data"}),(0,J.jsxs)("div",{className:"flex justify-center gap-4 text-xs mt-1",children:[(0,J.jsxs)("span",{className:"flex items-center gap-1",children:[(0,J.jsx)("span",{className:"w-2 h-2 rounded-full bg-emerald-500"})," Wins"]}),(0,J.jsxs)("span",{className:"flex items-center gap-1",children:[(0,J.jsx)("span",{className:"w-2 h-2 rounded-full bg-red-500"})," Losses"]})]})]}),(0,J.jsxs)("div",{className:"bg-slate-900/60 border border-white/10 rounded-xl p-5",children:[(0,J.jsx)("h3",{className:"text-sm font-semibold mb-3",children:"Trade Direction"}),k.length>0?(0,J.jsx)(I.u,{width:"100%",height:110,children:(0,J.jsxs)(V.r,{children:[(0,J.jsx)(K.Fq,{data:k,cx:"50%",cy:"50%",innerRadius:30,outerRadius:50,dataKey:"value",paddingAngle:4,children:k.map((e,t)=>(0,J.jsx)(W.f,{fill:S[t]},t))}),(0,J.jsx)(q.m,{contentStyle:{backgroundColor:"#0f172a",border:"1px solid #1e293b",borderRadius:8}})]})}):(0,J.jsx)("div",{className:"h-[110px] flex items-center justify-center text-slate-500 text-sm",children:"No data"}),(0,J.jsxs)("div",{className:"flex justify-center gap-4 text-xs mt-1",children:[(0,J.jsxs)("span",{className:"flex items-center gap-1",children:[(0,J.jsx)("span",{className:"w-2 h-2 rounded-full bg-blue-500"})," Long"]}),(0,J.jsxs)("span",{className:"flex items-center gap-1",children:[(0,J.jsx)("span",{className:"w-2 h-2 rounded-full bg-orange-500"})," Short"]})]})]})]})]}),(0,J.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,J.jsxs)("div",{className:"bg-slate-900/60 border border-white/10 rounded-xl p-5","data-testid":"asset-performance",children:[(0,J.jsxs)("h3",{className:"text-sm font-semibold mb-4 flex items-center gap-2",children:[(0,J.jsx)(X.A,{className:"w-4 h-4 text-amber-400"}),"Asset Performance"]}),b.length>0?(0,J.jsx)("div",{className:"space-y-2 max-h-72 overflow-y-auto pr-1",children:b.map((e,t)=>(0,J.jsxs)("div",{className:"flex items-center justify-between p-2.5 bg-slate-800/40 rounded-lg",children:[(0,J.jsxs)("div",{className:"flex items-center gap-3",children:[(0,J.jsx)("span",{className:"text-xs font-bold w-5 h-5 rounded flex items-center justify-center ".concat(0===t?"bg-amber-500/20 text-amber-400":1===t?"bg-slate-500/20 text-slate-300":2===t?"bg-orange-500/20 text-orange-400":"bg-slate-700/40 text-slate-500"),children:t+1}),(0,J.jsxs)("div",{children:[(0,J.jsx)("span",{className:"text-sm font-medium",children:e.symbol}),(0,J.jsxs)("span",{className:"text-xs text-slate-500 ml-2",children:[e.trades," trades"]})]})]}),(0,J.jsxs)("div",{className:"text-right",children:[(0,J.jsxs)("div",{className:"text-sm font-semibold ".concat(e.total_pnl>=0?"text-emerald-400":"text-red-400"),children:[e.total_pnl>=0?"+":"","$",e.total_pnl]}),(0,J.jsxs)("div",{className:"text-xs text-slate-500",children:[e.win_rate,"% win"]})]})]},e.symbol))}):(0,J.jsx)("p",{className:"text-sm text-slate-500 text-center py-6",children:"No asset data yet"})]}),(0,J.jsxs)("div",{className:"bg-slate-900/60 border border-white/10 rounded-xl p-5","data-testid":"recent-trades",children:[(0,J.jsxs)("h3",{className:"text-sm font-semibold mb-4 flex items-center gap-2",children:[(0,J.jsx)(Z.A,{className:"w-4 h-4 text-blue-400"}),"Recent Trades"]}),v.length>0?(0,J.jsx)("div",{className:"space-y-1.5 max-h-72 overflow-y-auto pr-1",children:v.map((e,t)=>(0,J.jsxs)("div",{className:"flex items-center justify-between p-2.5 bg-slate-800/40 rounded-lg",children:[(0,J.jsxs)("div",{className:"flex items-center gap-2",children:[(0,J.jsx)("div",{className:"w-6 h-6 rounded flex items-center justify-center ".concat("LONG"===e.direction||"BUY"===e.direction?"bg-emerald-500/20":"bg-red-500/20"),children:"LONG"===e.direction||"BUY"===e.direction?(0,J.jsx)(L.A,{className:"w-3.5 h-3.5 text-emerald-400"}):(0,J.jsx)(U.A,{className:"w-3.5 h-3.5 text-red-400"})}),(0,J.jsxs)("div",{children:[(0,J.jsx)("div",{className:"text-sm font-medium",children:e.symbol}),(0,J.jsxs)("div",{className:"text-xs text-slate-500",children:[e.created_at?new Date(e.created_at).toLocaleDateString():"","auto_pilot"===e.source&&(0,J.jsx)("span",{className:"ml-1 text-cyan-400",children:"AP"})]})]})]}),(0,J.jsxs)("div",{className:"flex items-center gap-3",children:[(0,J.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded ".concat("open"===e.status?"bg-blue-500/20 text-blue-400":"bg-slate-700 text-slate-400"),children:e.status}),(0,J.jsxs)("div",{className:"text-right",children:[(0,J.jsxs)("div",{className:"text-sm font-semibold ".concat(e.pnl>=0?"text-emerald-400":"text-red-400"),children:[e.pnl>=0?"+":"",e.pnl_pct,"%"]}),(0,J.jsxs)("div",{className:"text-xs text-slate-500",children:["$",e.investment]}
2)]})]})]},t))}):(0,J.jsx)("p",{className:"text-sm text-slate-500 text-center py-6",children:"No trades yet"})]})]}),f.enabled&&(0,J.jsxs)("div",{className:"bg-emerald-500/5 border border-emerald-500/20 rounded-xl p-5","data-testid":"auto-pilot-stats",children:[(0,J.jsxs)("h3",{className:"text-sm font-semibold mb-3 flex items-center gap-2",children:[(0,J.jsx)(g.A,{className:"w-4 h-4 text-emerald-400"}),"Auto-Pilot Performance"]}),(0,J.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-center",children:[(0,J.jsxs)("div",{children:[(0,J.jsx)("div",{className:"text-2xl font-bold text-emerald-400",children:f.scans_completed}),(0,J.jsx)("div",{className:"text-xs text-slate-500",children:"Total Scans"})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("div",{className:"text-2xl font-bold text-blue-400",children:f.trades_executed}),(0,J.jsx)("div",{className:"text-xs text-slate-500",children:"Trades Executed"})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("div",{className:"text-2xl font-bold text-amber-400",children:f.started_at?Math.round((Date.now()-new Date(f.started_at).getTime())/36e5)+"h":"N/A"}),(0,J.jsx)("div",{className:"text-xs text-slate-500",children:"Uptime"})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("div",{className:"text-2xl font-bold text-purple-400",children:f.last_scan?new Date(f.last_scan).toLocaleTimeString():"N/A"}),(0,J.jsx)("div",{className:"text-xs text-slate-500",children:"Last Scan"})]})]})]})]})]})}const se=["user_id","updated_at","created_at","_id"],ae=["user_id","updated_at","created_at","_id"],le=["user_id","updated_at","created_at","_id"],re=[{id:"all",label:"All Assets",icon:o.A,color:"bg-purple-500"},{id:"crypto",label:"Crypto",icon:x.A,color:"bg-amber-500"},{id:"stocks",label:"Stocks",icon:m.A,color:"bg-blue-500"},{id:"forex",label:"Forex",icon:h.A,color:"bg-emerald-500"}],ne={crypto:[{value:"BTCUSD",label:"BTC/USD",name:"Bitcoin"},{value:"ETHUSD",label:"ETH/USD",name:"Ethereum"},{value:"SOLUSD",label:"SOL/USD",name:"Solana"},{value:"XRPUSD",label:"XRP/USD",name:"Ripple"},{value:"ADAUSD",label:"ADA/USD",name:"Cardano"},{value:"DOGEUSD",label:"DOGE/USD",name:"Dogecoin"},{value:"AVAXUSD",label:"AVAX/USD",name:"Avalanche"},{value:"LINKUSD",label:"LINK/USD",name:"Chainlink"}],stocks:[{value:"AAPL",label:"AAPL",name:"Apple Inc."},{value:"MSFT",label:"MSFT",name:"Microsoft"},{value:"GOOGL",label:"GOOGL",name:"Alphabet"},{value:"AMZN",label:"AMZN",name:"Amazon"},{value:"NVDA",label:"NVDA",name:"NVIDIA"},{value:"TSLA",label:"TSLA",name:"Tesla"},{value:"META",label:"META",name:"Meta Platforms"},{value:"SPY",label:"SPY",name:"S&P 500 ETF"}],forex:[{value:"EURUSD",label:"EUR/USD",name:"Euro / US Dollar"},{value:"GBPUSD",label:"GBP/USD",name:"British Pound / US Dollar"},{value:"USDJPY",label:"USD/JPY",name:"US Dollar / Japanese Yen"},{value:"USDCHF",label:"USD/CHF",name:"US Dollar / Swiss Franc"},{value:"AUDUSD",label:"AUD/USD",name:"Australian Dollar / US Dollar"},{value:"USDCAD",label:"USD/CAD",name:"US Dollar / Canadian Dollar"}]};ne.crypto.map(e=>(0,l.A)((0,l.A)({},e),{},{type:"crypto"})),ne.stocks.map(e=>(0,l.A)((0,l.A)({},e),{},{type:"stocks"})),ne.forex.map(e=>(0,l.A)((0,l.A)({},e),{},{type:"forex"}));function ie(e){var t,s,I,B;let{auth:O}=e;const z=(0,n.Zp)(),[G,q]=(0,r.useState)(!0),[H,V]=(0,r.useState)(!1),[K,W]=(0,r.useState)(!1),[Y,Q]=(0,r.useState)("scanner"),[X,Z]=(0,r.useState)(""),[ee,ne]=(0,r.useState)([]),[ie,ce]=(0,r.useState)([]),[de,oe]=(0,r.useState)([]),[xe,me]=(0,r.useState)(null),[he,pe]=(0,r.useState)(null),[ue,be]=(0,r.useState)(null),[ge,ve]=(0,r.useState)(100),[je,fe]=(0,r.useState)(!1),[Ne,ye]=(0,r.useState)(!1),[we,Ae]=(0,r.useState)(!1),[_e,ke]=(0,r.useState)(!1),[Se,Ce]=(0,r.useState)(null),[De,Pe]=(0,r.useState)(!1),[Le,Ue]=(0,r.useState)({scan_interval_minutes:5,min_confidence:75,max_positions:5,investment_per_trade:100,scan_type:"quick",live_mode:!1,live_exchange:""}),[Te,Fe]=(0,r.useState)(null),[Re,Ee]=(0,r.useState)("all"),[Me,$e]=(0,r.useState)(""),[Ie,Be]=(0,r.useState)(!1),[Oe,ze]=(0,r.useState)([]),Ge=(0,r.useRef)(null),qe=(0,r.useRef)(null),[He,Ve]=(0,r.useState)([]),[Ke,We]=(0,r.useState)("all"),[Ye,Qe]=(0,r.useState)({min_profit_percent:2,max_profit_percent:20,trailing_activation:2,trailing_distance:1,stop_loss_percent:2,smart_trailing_enabled:!0,auto_manage_positions:!0,risk_per_trade:2}),Xe=localStorage.getItem("token"),Ze=Xe?{Authorization:"Bearer ".concat(Xe)}:{};(0,r.useEffect)(()=>{Je()},[]),(0,r.useEffect)(()=>{let e=[...ee];if("all"!==Re&&(e=e.filter(e=>{var t;return(null===(t=e.asset_type)||void 0===t?void 0:t.toLowerCase())===Re.toLowerCase()})),Me.trim()){const t=Me.toLowerCase();e=e.filter(e=>{var s;return null===(s=e.symbol)||void 0===s?void 0:s.toLowerCase().includes(t)})}"all"!==Ke&&(e=e.filter(e=>{var t,s;return(null===(t=e.exchange)||void 0===t?void 0:t.toLowerCase())===Ke.toLowerCase()||(null===(s=e.platform)||void 0===s?void 0:s.toLowerCase())===Ke.toLowerCase()})),ce(e)},[ee,Re,Me,Ke]),(0,r.useEffect)(()=>{const e=setTimeout(async()=>{try{const e=new URLSearchParams;Re&&"all"!==Re&&e.set("asset_type","stocks"===Re?"stock":Re),Me.trim()&&e.set("search",Me.trim());const{data:t}=await i.A.get("".concat($.nC,"/market/pairs?").concat(e),{headers:Ze}),s=(t.pairs||[]).slice(0,30).map(e=>
2({value:e.symbol.replace("/",""),label:e.symbol,name:e.name,type:"USD"!==e.quote||e.symbol.includes("/")?e.symbol.includes("/")&&["EUR","GBP","USD","JPY","CHF","AUD","CAD","NZD","SGD","HKD","TRY","MXN","ZAR","SEK","NOK","XAU","XAG"].includes(e.base)?"forex":"crypto":"stocks"}));0===s.length&&Me.trim()?ze([{value:Me.toUpperCase(),label:Me.toUpperCase(),name:"Custom Symbol",type:"custom",isCustom:!0}]):ze(s)}catch(e){Me.trim()&&ze([{value:Me.toUpperCase(),label:Me.toUpperCase(),name:"Custom Symbol",type:"custom",isCustom:!0}])}},Me?250:0);return()=>clearTimeout(e)},[Me,Re]),(0,r.useEffect)(()=>{const e=e=>{qe.current&&!qe.current.contains(e.target)&&Ge.current&&!Ge.current.contains(e.target)&&Be(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,r.useEffect)(()=>{(async()=>{try{const e=(await i.A.get("".concat($.nC,"/exchanges/connected"),{headers:Ze})).data.exchanges||[];Ve(e)}catch(e){Ve([{id:"binance",name:"Binance",type:"crypto"},{id:"alpaca",name:"Alpaca",type:"stocks"},{id:"oanda",name:"OANDA",type:"forex"}])}})()},[]);const Je=async()=>{try{const e=await i.A.get("".concat($.nC,"/power-bot/access"),{headers:Ze});W(e.data.has_access),Z(e.data.reason),e.data.has_access&&await Promise.all([at(),lt(),rt(),et(),tt(),st()])}catch(t){var e;console.error("Access check error:",t),401===(null===(e=t.response)||void 0===e?void 0:e.status)&&z("/login")}finally{q(!1)}},et=async()=>{try{const e=await i.A.get("".concat($.nC,"/power-bot/settings"),{headers:Ze});if(e.data.settings){const t=e.data.settings,{user_id:s,updated_at:r,created_at:n,_id:i}=t,c=(0,a.A)(t,se);Qe(e=>(0,l.A)((0,l.A)({},e),c))}}catch(e){console.error("Error loading settings:",e)}},tt=async()=>{try{const e=await i.A.get("".concat($.nC,"/power-bot/auto-pilot/status"),{headers:Ze});Ce(e.data),e.data.scan_interval_minutes&&Ue({scan_interval_minutes:e.data.scan_interval_minutes||5,min_confidence:e.data.min_confidence||75,max_positions:e.data.max_positions||5,investment_per_trade:e.data.investment_per_trade||100,scan_type:e.data.scan_type||"quick",live_mode:e.data.live_mode||!1,live_exchange:e.data.live_exchange||""}),e.data.current_regimes&&Fe(e.data.current_regimes)}catch(e){console.error("Auto-pilot status error:",e)}},st=async()=>{try{const e=await i.A.get("".concat($.nC,"/power-bot/market-regime?market_type=all"),{headers:Ze});e.data.regimes&&Fe(Object.fromEntries(Object.entries(e.data.regimes).map(e=>{let[t,s]=e;return[t,s.regime]})))}catch(e){console.error("Market regime error:",e)}};(0,r.useEffect)(()=>{if(null===Se||void 0===Se||!Se.enabled||!K)return;const e=setInterval(()=>{tt(),at(),lt(),rt()},3e4);return()=>clearInterval(e)},[null===Se||void 0===Se?void 0:Se.enabled,K]);const at=async()=>{try{const e=await i.A.get("".concat($.nC,"/power-bot/opportunities"),{headers:Ze});ne(e.data.opportunities||[]),pe(e.data.last_scan)}catch(e){console.error("Error loading opportunities:",e)}},lt=async()=>{try{const e=await i.A.get("".concat($.nC,"/power-bot/positions"),{headers:Ze});oe(e.data.positions||[])}catch(e){console.error("Error loading positions:",e)}},rt=async()=>{try{const e=await i.A.get("".concat($.nC,"/power-bot/performance"),{headers:Ze});me(e.data.stats)}catch(e){console.error("Error loading stats:",e)}},[nt,it]=(0,r.useState)("quick"),[ct,dt]=(0,r.useState)(""),[ot,xt]=(0,r.useState)(!1),mt=async()=>{xt(!0);try{const e=await i.A.post("".concat($.nC,"/stripe/create-checkout"),{plan_key:"power_bot_monthly",origin_url:window.location.origin},{headers:Ze});e.data.checkout_url?window.location.href=e.data.checkout_url:M.oR.error("Failed to create checkout session")}catch(e){M.oR.error("Failed to initiate purchase")}finally{xt(!1)}};return G?(0,J.jsx)("div",{className:"min-h-screen bg-slate-950 flex items-center justify-center",children:(0,J.jsx)(p.A,{className:"w-8 h-8 animate-spin text-cyan-400"})}):K?(0,J.jsx)("div",{className:"min-h-screen bg-slate-950 p-6",children:(0,J.jsxs)("div",{className:"max-w-7xl mx-auto space-y-6",children:[(0,J.jsx)("div",{className:"backdrop-blur-xl bg-gradient-to-r from-amber-500/10 to-orange-500/10 border border-amber-500/20 rounded-xl p-5",children:(0,J.jsxs)("div",{className:"flex items-start gap-4",children:[(0,J.jsx)("div",{className:"w-12 h-12 bg-amber-500/20 rounded-xl flex items-center justify-center flex-shrink-0",children:(0,J.jsx)(u.A,{className:"w-6 h-6 text-amber-400"})}),(0,J.jsxs)("div",{children:[(0,J.jsx)("h3",{className:"font-semibold text-white text-lg mb-2",children:"What is the Power Bot?"}),(0,J.jsxs)("p",{className:"text-slate-300 text-sm mb-3",children:[(0,J.jsx)("strong",{children:"The Power Bot is your AI-powered market assistant."})," It scans hundreds of stocks and cryptocurrencies, analyzes patterns and trends, then shows you the best trading opportunities. Think of it as having a professional analyst working for you around the clock, finding profitable trades while you focus on other things."]}),(0,J.jsxs)("div",{className:"grid sm:grid-cols-3 gap-3 mt-3",children:[(0,J.jsxs)("div",{className:"p-2 bg-slate-800/50 rounded-lg text-center",children:[(0,J.jsx)("p",{className:"text-amber-400 font-semibold text-sm",children:"Best For"}),(0,J.jsx)("p",{className:"text-xs text-slate-400",children:"Finding opportunities fast"})]}),(0,J.jsxs)("div",{className:"p-2 bg-slate-800/50 rounded-lg text-center",children:[(0,J.jsx)("p",{className:"text-amber-400 font-semibold text-sm",children:"Key Feature"}),(0,J.jsx)("p",{className:"text-xs text-slate-400",children:"AI-powered market scanning"})]}),(0,J.jsxs)("div",{className:"p-2 bg-slate-800/50 rounded-lg text-center",children:[(0,J.jsx)("p",{className:"text-amber-400 font-semibold text-sm",children:"Risk Level"}),(0,J.jsx)("p",{className:"text-xs text-slate-400",children:"Configurable with trailing stops"})]})]})]})]})}),(0,J.jsxs)("div",{className:"backdrop-blur-xl border rounded-xl p-5 transition-all ".concat(null!==Se&&void 0!==Se&&Se.enabled?"bg-emerald-500/5 border-emerald-500/30":"bg-slate-900/60 border-white/10"),"data-testid":"auto-pilot-panel",children:[(0,J.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[(0,J.jsxs)("div",{className:"flex items-center gap-4",children:[(0,J.jsx)("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center ".concat(null!==Se&&void 0!==Se&&Se.enabled?"bg-emerald-500/20":"bg-slate-800"),children:(0,J.jsx)(v,{className:"w-6 h-6 ".concat(null!==Se&&void 0!==Se&&Se.enabled?"text-emerald-400":"text-slate-500")})}),(0,J.jsxs)("div",{children:[(0,J.jsxs)("div",{className:"flex items-center gap-2",children:[(0,J.jsx)("h3",{className:"font-semibold text-lg",children:"Auto-Pilot Mode"}),(null===Se||void 0===Se?void 0:Se.enabled)&&(0,J.jsx)("span",{className:"px-2 py-0.5 text-xs font-medium rounded-full animate-pulse ".concat(Se.live_mode?"bg-red-500/20 text-red-400":"bg-emerald-500/20 text-emerald-400"),children:Se.live_mode?"LIVE 24/7":"PAPER 24/7"})]}),(0,J.jsx)("p",{className:"text-sm text-slate-400",children:null!==Se&&void 0!==Se&&Se.enabled?(0,J.jsxs)(J.Fragment,{children:["Scanning every ",Se.scan_interval_minutes,"min | Min confidence: ",Se.min_confidence,"% | Max positions: ",Se.max_positions,Se.live_mode&&(0,J.jsxs)("span",{className:"ml-1 text-red-400 font-semibold",children:[" | LIVE on ",null===(t=Se.live_exchange)||void 0===t?void 0:t.toUpperCase()]}),!Se.live_mode&&(0,J.jsx)("span",{className:"ml-1 text-sky-400",children:" | Paper"})]}):"Enable hands-off trading \u2014 AI scans, finds, and executes trades automatically"})]})]}),(0,J.jsxs)("div",{className:"flex items-center gap-3",children:[(null===Se||void 0===Se?void 0:Se.enabled)&&(0,J.jsxs)("div",{className:"flex items-center gap-4 text-xs text-slate-400 mr-2",children:[(0,J.jsxs)("div",{children:[(0,J.jsx)("span",{className:"block text-slate-500",children:"Scans"}),(0,J.jsx)("span",{className:"font-semibold text-white",children:Se.scans_completed||0})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("span",{className:"block text-slate-500",children:"Trades"}),(0,J.jsx)("span",{className:"font-semibold text-emerald-400",children:Se.trades_executed||0})]}
2),Se.last_auto_scan&&(0,J.jsxs)("div",{children:[(0,J.jsx)("span",{className:"block text-slate-500",children:"Last Scan"}),(0,J.jsx)("span",{className:"font-semibold text-white",children:new Date(Se.last_auto_scan).toLocaleTimeString()})]})]}),(0,J.jsxs)(c.$,{onClick:async()=>{Pe(!0);try{if(null!==Se&&void 0!==Se&&Se.enabled)await i.A.post("".concat($.nC,"/power-bot/auto-pilot/stop"),{},{headers:Ze}),M.oR.success("Auto-pilot disabled"),Ce(e=>(0,l.A)((0,l.A)({},e),{},{enabled:!1}));else{await i.A.post("".concat($.nC,"/power-bot/auto-pilot/start"),Le,{headers:Ze});M.oR.success("Auto-pilot enabled! Power Bot is now trading 24/7"),await tt()}}catch(s){var e,t;M.oR.error("Failed to toggle auto-pilot: "+((null===(e=s.response)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.detail)||"Unknown error"))}finally{Pe(!1)}},disabled:De,className:null!==Se&&void 0!==Se&&Se.enabled?"bg-red-500/20 text-red-400 hover:bg-red-500/30 border border-red-500/30":"bg-gradient-to-r from-emerald-500 to-teal-600 hover:from-emerald-600 hover:to-teal-700","data-testid":"auto-pilot-toggle-btn",children:[De?(0,J.jsx)(p.A,{className:"w-4 h-4 mr-2 animate-spin"}):null!==Se&&void 0!==Se&&Se.enabled?(0,J.jsx)(j.A,{className:"w-4 h-4 mr-2"}):(0,J.jsx)(f.A,{className:"w-4 h-4 mr-2"}),null!==Se&&void 0!==Se&&Se.enabled?"Stop Auto-Pilot":"Start Auto-Pilot"]})]})]}),!(null!==Se&&void 0!==Se&&Se.enabled)&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3 mt-4 pt-4 border-t border-white/5",children:[(0,J.jsxs)("div",{children:[(0,J.jsx)("label",{className:"text-xs text-slate-500 block mb-1",children:"Scan Interval"}),(0,J.jsxs)("select",{value:Le.scan_interval_minutes,onChange:e=>Ue(t=>(0,l.A)((0,l.A)({},t),{},{scan_interval_minutes:parseInt(e.target.value)})),className:"w-full bg-slate-800/50 border border-white/10 rounded-lg px-3 py-2 text-sm","data-testid":"ap-scan-interval",children:[(0,J.jsx)("option",{value:"5",children:"Every 5 min"}),(0,J.jsx)("option",{value:"10",children:"Every 10 min"}),(0,J.jsx)("option",{value:"15",children:"Every 15 min"}),(0,J.jsx)("option",{value:"30",children:"Every 30 min"})]})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("label",{className:"text-xs text-slate-500 block mb-1",children:"Min Confidence"}),(0,J.jsxs)("select",{value:Le.min_confidence,onChange:e=>Ue(t=>(0,l.A)((0,l.A)({},t),{},{min_confidence:parseFloat(e.target.value)})),className:"w-full bg-slate-800/50 border border-white/10 rounded-lg px-3 py-2 text-sm","data-testid":"ap-min-confidence",children:[(0,J.jsx)("option",{value:"60",children:"60%+"}),(0,J.jsx)("option",{value:"70",children:"70%+"}),(0,J.jsx)("option",{value:"75",children:"75%+"}),(0,J.jsx)("option",{value:"80",children:"80%+"}),(0,J.jsx)("option",{value:"85",children:"85%+"}),(0,J.jsx)("option",{value:"90",children:"90%+"})]})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("label",{className:"text-xs text-slate-500 block mb-1",children:"Max Positions"}),(0,J.jsxs)("select",{value:Le.max_positions,onChange:e=>Ue(t=>(0,l.A)((0,l.A)({},t),{},{max_positions:parseInt(e.target.value)})),className:"w-full bg-slate-800/50 border border-white/10 rounded-lg px-3 py-2 text-sm","data-testid":"ap-max-positions",children:[(0,J.jsx)("option",{value:"3",children:"3 max"}),(0,J.jsx)("option",{value:"5",children:"5 max"}),(0,J.jsx)("option",{value:"10",children:"10 max"}),(0,J.jsx)("option",{value:"15",children:"15 max"}),(0,J.jsx)("option",{value:"20",children:"20 max"})]})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("label",{className:"text-xs text-slate-500 block mb-1",children:"$ Per Trade"}),(0,J.jsx)("input",{type:"number",value:Le.investment_per_trade,onChange:e=>Ue(t=>(0,l.A)((0,l.A)({},t),{},{investment_per_trade:parseFloat(e.target.value)||100})),className:"w-full bg-slate-800/50 border border-white/10 rounded-lg px-3 py-2 text-sm",min:"10","data-testid":"ap-investment"})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("label",{className:"text-xs text-slate-500 block mb-1",children:"Scan Type"}
2),(0,J.jsxs)("select",{value:Le.scan_type,onChange:e=>Ue(t=>(0,l.A)((0,l.A)({},t),{},{scan_type:e.target.value})),className:"w-full bg-slate-800/50 border border-white/10 rounded-lg px-3 py-2 text-sm","data-testid":"ap-scan-type",children:[(0,J.jsx)("option",{value:"quick",children:"Quick (70 assets)"}),(0,J.jsx)("option",{value:"full",children:"Full (178 assets)"})]})]})]}),(0,J.jsx)("div",{className:"mt-4 pt-4 border-t border-white/5","data-testid":"ap-live-mode-section",children:(0,J.jsxs)("div",{className:"flex items-center gap-4 flex-wrap",children:[(0,J.jsxs)("div",{className:"flex items-center gap-2",children:[(0,J.jsx)("label",{className:"text-xs text-slate-500",children:"Execution Mode:"}),(0,J.jsxs)("div",{className:"flex gap-1 bg-slate-800/50 rounded-lg p-0.5",children:[(0,J.jsx)("button",{onClick:()=>Ue(e=>(0,l.A)((0,l.A)({},e),{},{live_mode:!1,live_exchange:""})),"data-testid":"ap-mode-paper",className:"px-3 py-1.5 rounded-md text-xs font-medium transition-all ".concat(Le.live_mode?"text-slate-400 hover:text-white":"bg-sky-500/20 text-sky-400 border border-sky-500/30"),children:"Paper Trading"}),(0,J.jsx)("button",{onClick:()=>Ue(e=>(0,l.A)((0,l.A)({},e),{},{live_mode:!0})),"data-testid":"ap-mode-live",className:"px-3 py-1.5 rounded-md text-xs font-medium transition-all ".concat(Le.live_mode?"bg-red-500/20 text-red-400 border border-red-500/30":"text-slate-400 hover:text-white"),children:"Live Trading"})]})]}),Le.live_mode&&(0,J.jsxs)("div",{className:"flex items-center gap-2",children:[(0,J.jsx)("label",{className:"text-xs text-slate-500",children:"Exchange:"}),(0,J.jsxs)("select",{value:Le.live_exchange,onChange:e=>Ue(t=>(0,l.A)((0,l.A)({},t),{},{live_exchange:e.target.value})),className:"bg-slate-800/50 border border-red-500/20 rounded-lg px-3 py-1.5 text-xs text-white","data-testid":"ap-live-exchange-select",children:[(0,J.jsx)("option",{value:"",children:"Select exchange..."}),He.filter(e=>["binance","okx","bybit","kraken","coinbase","kucoin","cryptocom","gemini","phemex"].includes(e.exchange)).map(e=>(0,J.jsx)("option",{value:e.exchange,children:e.exchange.charAt(0).toUpperCase()+e.exchange.slice(1)},e.exchange))]}),0===He.length&&(0,J.jsx)("span",{className:"text-xs text-amber-400",children:"No exchanges connected. Go to Settings."})]}),Le.live_mode&&(0,J.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-red-400",children:[(0,J.jsx)(N.A,{className:"w-3.5 h-3.5"}),(0,J.jsx)("span",{children:"Real money will be used"})]})]})})]})]}),Te&&(0,J.jsx)("div",{className:"grid grid-cols-3 gap-3","data-testid":"market-regime-bar",children:[{key:"crypto",label:"Crypto",icon:"\u20bf"},{key:"stocks",label:"Stocks",icon:"\ud83d\udcc8"},{key:"forex",label:"Forex",icon:"\ud83d\udcb1"}].map(e=>{let{key:t,label:s,icon:a}=e;const l=Te[t]||"NEUTRAL",r="BULL"===l,n="BEAR"===l;return(0,J.jsxs)("div",{className:"flex items-center justify-between p-3 rounded-xl border ".concat(r?"bg-emerald-500/5 border-emerald-500/20":n?"bg-red-500/5 border-red-500/20":"bg-slate-900/60 border-white/10"),"data-testid":"regime-".concat(t),children:[(0,J.jsxs)("div",{className:"flex items-center gap-2",children:[(0,J.jsx)("span",{className:"text-lg",children:a}),(0,J.jsx)("span",{className:"text-sm font-medium",children:s})]}),(0,J.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,J.jsx)("div",{className:"w-2 h-2 rounded-full ".concat(r?"bg-emerald-400":n?"bg-red-400":"bg-slate-400")}),(0,J.jsx)("span",{className:"text-xs font-bold ".concat(r?"text-emerald-400":n?"text-red-400":"text-slate-400"),children:l}),(0,J.jsx)("span",{className:"text-xs text-slate-500 ml-1",children:r?"LONG bias":n?"SHORT bias":"Mixed"})]})]},t)})}),(0,J.jsxs)("div",{className:"flex gap-1 bg-slate-900/60 p-1 rounded-xl border border-white/10","data-testid":"power-bot-tabs",children:[(0,J.jsxs)("button",{onClick:()=>Q("scanner"),className:"flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg text-sm font-medium transition-all ".concat("scanner"===Y?"bg-gradient-to-r from-amber-500/20 to-orange-500/20 text-amber-400 border border-amber-500/30":"text-slate-400 hover:text-white hover:bg-slate-800/50"),"data-testid":"tab-scanner",children:[(0,J.jsx)(g.A,{className:"w-4 h-4"})," Scanner"]}),(0,J.jsxs)("button",{onClick:()=>
2Q("dashboard"),className:"flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg text-sm font-medium transition-all ".concat("dashboard"===Y?"bg-gradient-to-r from-emerald-500/20 to-teal-500/20 text-emerald-400 border border-emerald-500/30":"text-slate-400 hover:text-white hover:bg-slate-800/50"),"data-testid":"tab-dashboard",children:[(0,J.jsx)(y.A,{className:"w-4 h-4"})," Performance Dashboard"]})]}),"dashboard"===Y&&(0,J.jsx)(te,{auth:O}),"scanner"===Y&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[(0,J.jsxs)("div",{className:"flex items-center gap-4",children:[(0,J.jsx)("div",{className:"w-12 h-12 bg-gradient-to-r from-amber-500 to-orange-600 rounded-xl flex items-center justify-center",children:(0,J.jsx)(g.A,{className:"w-6 h-6 text-white"})}),(0,J.jsxs)("div",{children:[(0,J.jsx)("h1",{className:"text-2xl font-bold",children:"AI Power Scanner V2"}),(0,J.jsx)("p",{className:"text-sm text-slate-400",children:he?"Last scan: ".concat(new Date(he).toLocaleTimeString()):"Run a scan to find opportunities"})]})]}),(0,J.jsxs)("div",{className:"flex items-center gap-3",children:[(0,J.jsxs)(c.$,{variant:"outline",onClick:()=>ye(!0),className:"border-white/10","data-testid":"settings-btn",children:[(0,J.jsx)(w.A,{className:"w-4 h-4 mr-2"}),"Settings"]}),de.length>0&&(0,J.jsxs)(c.$,{variant:"outline",onClick:async()=>{ke(!0);try{const e=(await i.A.post("".concat($.nC,"/power-bot/manage"),{},{headers:Ze})).data.actions_taken||[];e.length>0?(M.oR.success("".concat(e.length," position(s) updated")),await lt()):M.oR.info("All positions checked - no actions needed")}catch(e){M.oR.error("Position management failed")}finally{ke(!1)}},disabled:_e,className:"border-white/10","data-testid":"manage-positions-btn",children:[_e?(0,J.jsx)(p.A,{className:"w-4 h-4 mr-2 animate-spin"}):(0,J.jsx)(A.A,{className:"w-4 h-4 mr-2"}),_e?"Managing...":"Manage Positions"]}),(0,J.jsxs)("div",{className:"flex items-center gap-1 bg-slate-800/50 rounded-lg p-1",children:[(0,J.jsx)("button",{onClick:()=>it("quick"),className:"px-3 py-1.5 rounded-md text-sm font-medium transition-all ".concat("quick"===nt?"bg-cyan-500/20 text-cyan-400":"text-slate-400 hover:text-white"),children:"Quick (70)"}),(0,J.jsx)("button",{onClick:()=>it("full"),className:"px-3 py-1.5 rounded-md text-sm font-medium transition-all ".concat("full"===nt?"bg-amber-500/20 text-amber-400":"text-slate-400 hover:text-white"),children:"Full (178)"})]}),(0,J.jsx)(c.$,{onClick:()=>async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:nt;V(!0);const t="quick"===e;dt(t?"Scanning 70 top assets...":"Scanning 178 assets (3-5 min)...");try{const e=await i.A.post("".concat($.nC,"/power-bot/scan?quick_scan=").concat(t),{},{headers:Ze,timeout:t?6e4:3e5});ne(e.data.opportunities||[]),pe(e.data.scan_time);const s=t?"Quick scan":"Full scan";M.oR.success("".concat(s,": Found ").concat(e.data.opportunities_found," opportunities!"))}catch(l){var s,a;"ECONNABORTED"===l.code?M.oR.error("Scan timed out. Try Quick Scan for faster results."):M.oR.error("Scan failed: "+((null===(s=l.response)||void 0===s||null===(a=s.data)||void 0===a?void 0:a.detail)||"Unknown error"))}finally{V(!1),dt("")}}(nt),disabled:H,className:"quick"===nt?"bg-gradient-to-r from-cyan-500 to-blue-600 hover:from-cyan-600 hover:to-blue-700":"bg-gradient-to-r from-amber-500 to-orange-600 hover:from-amber-600 hover:to-orange-700","data-testid":"scan-markets-btn",children:H?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(p.A,{className:"w-4 h-4 mr-2 animate-spin"}),ct||"Scanning..."]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(_.A,{className:"w-4 h-4 mr-2"}),"quick"===nt?"Quick Scan (~30s)":"Full Scan (~2-3 min)"]})})]})]}),xe&&(0,J.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[(0,J.jsxs)("div",{className:"backdrop-blur-xl bg-slate-900/60 border border-white/10 rounded-xl p-4",children:[(0,J.jsx)("div",{className:"text-sm text-slate-400",children:"Total Trades"}),(0,J.jsx)("div",{className:"text-2xl font-bold",children:xe.total_trades})]}),(0,J.jsxs)("div",{className:"backdrop-blur-xl bg-slate-900/60 border border-white/10 rounded-xl p-4",children:[(0,J.jsx)("div",{className:"text-sm text-slate-400",children:"Win Rate"}),(0,J.jsxs)("div",{className:"text-2xl font-bold text-emerald-400",children:[xe.win_rate,"%"]})]}),(0,J.jsxs)("div",{className:"backdrop-blur-xl bg-slate-900/60 border border-white/10 rounded-xl p-4",children:[(0,J.jsx)("div",{className:"text-sm text-slate-400",children:"Total P&L"}),(0,J.jsxs)("div",{className:"text-2xl font-bold ".concat(xe.total_pnl>=0?"text-emerald-400":"text-red-400"),children:[xe.total_pnl>=0?"+":"","$",xe.total_pnl.toFixed(2)]})]}),(0,J.jsxs)("div",{className:"backdrop-blur-xl bg-slate-900/60 border border-white/10 rounded-xl p-4",children:[(0,J.jsx)("div",{className:"text-sm text-slate-400",children:"Active Positions"}),(0,J.jsx)("div",{className:"text-2xl font-bold",children:de.length})]}),(0,J.jsxs)("div",{className:"backdrop-blur-xl bg-slate-900/60 border border-white/10 rounded-xl p-4",children:[(0,J.jsx)("div",{className:"text-sm text-slate-400",children:"Avg Hold Time"}),(0,J.jsx)("div",{className:"text-2xl font-bold",children:xe.avg_hold_time_hours?"".concat(xe.avg_hold_time_hours,"h"):"N/A"})]})]}),(0,J.jsx)("div",{className:"backdrop-blur-xl bg-slate-900/60 border border-white/10 rounded-xl p-4",children:(0,J.jsxs)("div",{className:"flex items-center justify-between",children:[(0,J.jsxs)("div",{className:"flex items-center gap-6 text-sm",children:[(0,J.jsxs)("div",{children:[(0,J.jsx)("span",{className:"text-slate-400",children:"Min Profit: "}),(0,J.jsxs)("span",{className:"font-semibold text-emerald-400",children:[Ye.min_profit_percent,"%"]})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("span",{className:"text-slate-400",children:"Max Profit: "}),(0,J.jsxs)("span",{className:"font-semibold text-amber-400",children:[Ye.max_profit_percent,"%"]})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("span",{className:"text-slate-400",children:"Trailing: "}),(0,J.jsx)("span",{className:"font-semibold ".concat(Ye.smart_trailing_enabled?"text-cyan-400":"text-slate-500"),children:Ye.smart_trailing_enabled?"".concat(Ye.trailing_distance,"% from peak"):"Disabled"})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("span",{className:"text-slate-400",children:"Stop Loss: "}),(0,J.jsxs)("span",{className:"font-semibold text-red-400",children:[Ye.stop_loss_percent,"%"]})]})]}),(0,J.jsxs)(c.$,{variant:"ghost",size:"sm",onClick:()=>ye(!0),className:"text-slate-400 hover:text-white",children:[(0,J.jsx)(w.A,{className:"w-4 h-4 mr-1"}),"Edit"]})]})}),(0,J.jsxs)("div",{className:"backdrop-blur-xl bg-slate-900/60 border border-white/10 rounded-xl p-4",children:[(0,J.jsxs)("div",{className:"flex flex-col lg:flex-row items-start lg:items-center gap-4",children:[(0,J.jsxs)("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-3",children:[(0,J.jsxs)("div",{className:"flex items-center gap-2",children:[(0,J.jsx)(o.A,{className:"w-5 h-5 text-slate-400"}),(0,J.jsx)("span",{className:"text-slate-400 text-sm font-medium",children:"Filter:"})]}),(0,J.jsx)("div",{className:"flex flex-wrap gap-2",children:re.map(e=>{const t=e.icon,s=Re===e.id;return(0,J.jsxs)("button",{onClick:()=>Ee(e.id),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg font-medium text-sm transition-all ".concat(s?"".concat(e.color," text-white shadow-lg"):"bg-slate-800/50 text-slate-400 hover:text-white hover:bg-slate-700/50"),"data-testid":"powerbot-filter-".concat(e.id),children:[(0,J.jsx)(t,{className:"w-4 h-4"}),e.label]},e.id)})})]}),(0,J.jsxs)("div",{className:"flex items-center gap-2",children:[(0,J.jsx)("span",{className:"text-slate-400 text-sm",children:"Platform:"}),(0,J.jsxs)("select",{value:Ke,onChange:e=>We(e.target.value),className:"bg-slate-800/50 border border-white/10 text-white text-sm rounded-lg px-3 py-1.5 focus:outline-none focus:border-amber-500","data-testid":"exchange-selector",children:[(0,J.jsx)("option",{value:"all",children:"All Platforms"}),He.map(e=>(0,J.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),(0,J.jsxs)("div",{className:"relative flex-1 min-w-[200px]",children:[(0,J.jsx)("form",{onSubmit:e=>{e.preventDefault(),Be(!1)},children:(0,J.jsxs)("div",{className:"relative",children:[(0,J.jsx)(k.A,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-500"}),(0,J.jsx)(d.p,{ref:Ge,value:Me,onChange:e=>$e(e.target.value),onFocus:()=>Be(!0),placeholder:"Search symbol...",className:"pl-10 pr-8 bg-slate-800/50 border-white/10 text-white placeholder:text-slate-500 h-9","data-testid":"powerbot-symbol-search"}),Me&&(0,J.jsx)("button",{type:"button",onClick:()=>{$e(""),Be(!1)},className:"absolute right-2 top-1/2 -translate-y-1/2 text-slate-400 hover:text-white",children:(0,J.jsx)(S.A,{className:"w-4 h-4"})})]})}),Ie&&(0,J.jsxs)("div",{ref:qe,className:"absolute top-full left-0 right-0 mt-2 bg-slate-900 border border-white/10 rounded-xl shadow-2xl overflow-hidden z-50 max-h-64 overflow-y-auto",children:[(0,J.jsx)("div",{className:"p-2 border-b border-white/10 bg-slate-800/50",children:(0,J.jsx)("p",{className:"text-xs text-slate-500",children:Me?'Filtering "'.concat(Me,'"'):"Popular symbols"})}),Oe.map((e,t)=>{const s={crypto:{icon:x.A,color:"text-amber-400",bg:"bg-amber-500/20"},stocks:{icon:m.A,color:"text-blue-400",bg:"bg-blue-500/20"},forex:{icon:h.A,color:"text-emerald-400",bg:"bg-emerald-500/20"},custom:{icon:k.A,color:"text-purple-400",bg:"bg-purple-500/20"}},a=s[e.type]||s.custom,l=a.icon;return(0,J.jsxs)("button",{onClick:()=>{$e(e.value),Be(!1),M.oR.success("Filtering for ".concat(e.value))},className:"w-full flex items-center gap-3 px-4 py-2 hover:bg-white/5 transition-colors text-left border-b border-white/5 last:border-0",children:[(0,J.jsx)("div",{className:"w-7 h-7 rounded-lg ".concat(a.bg," flex items-center justify-center"),children:(0,J.jsx)(l,{className:"w-3.5 h-3.5 ".concat(a.color)})}),(0,J.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,J.jsxs)("div",{className:"flex items-center gap-2",children:[(0,J.jsx)("span",{className:"text-white font-medium text-sm",children:e.label}),e.isCustom&&(0,J.jsx)("span",{className:"text-xs px-1.5 py-0.5 bg-purple-500/20 text-purple-400 rounded",children:"CUSTOM"})]}),(0,J.jsx)("p",{className:"text-slate-500 text-xs truncate",children:e.name})]})]},"".concat(e.value,"-").concat(t))})]})]})]}),("all"!==Re||Me||"all"!==Ke)&&(0,J.jsxs)("div",{className:"mt-3 pt-3 border-t border-white/5 flex items-center gap-2 flex-wrap",children:[(0,J.jsx)("span",{className:"text-xs text-slate-500",children:"Active filters:"}),"all"!==Re&&(0,J.jsx)("span",{className:"text-xs px-2 py-0.5 bg-purple-500/20 text-purple-400 rounded-full",children:Re.charAt(0).toUpperCase()+Re.slice(1)}),Me&&(0,J.jsxs)("span",{className:"text-xs px-2 py-0.5 bg-amber-500/20 text-amber-400 rounded-full",children:["Symbol: ",Me]}),"all"!==Ke&&(0,J.jsx)("span",{className:"text-xs px-2 py-0.5 bg-cyan-500/20 text-cyan-400 rounded-full",children:(null===(s=He.find(e=>e.id===Ke))||void 0===s?void 0:s.name)||Ke}),(0,J.jsx)("button",{onClick:()=>{Ee("all"),$e(""),We("all")},className:"text-xs text-slate-400 hover:text-white ml-2",children:"Clear all"})]})]}),de.length>0&&(0,J.jsxs)("div",{className:"backdrop-blur-xl bg-slate-900/60 border border-white/10 rounded-xl p-6",children:[(0,J.jsxs)("h2",{className:"text-lg font-semibold mb-4 flex items-center gap-2",children:[(0,J.jsx)(y.A,{className:"w-5 h-5"}),"Active Positions (",de.length,")"]}),(0,J.jsx)("div",{className:"space-y-3",children:de.map((e,t)=>{var s,a,l,r,n,d,o,x,m;return(0,J.jsxs)("div",{className:"p-4 bg-slate-800/30 rounded-lg",children:[(0,J.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,J.jsxs)("div",{className:"flex items-center gap-4",children:[(0,J.jsx)("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center ".concat("LONG"===e.direction?"bg-emerald-500/20":"bg-red-500/20"),children:"LONG"===e.direction?(0,J.jsx)(C.A,{className:"w-5 h-5 text-emerald-400"}):(0,J.jsx)(D.A,{className:"w-5 h-5 text-red-400"})}),(0,J.jsxs)("div",{children:[(0,J.jsx)("div",{className:"font-semibold",children:e.symbol}),(0,J.jsxs)("div",{className:"text-sm text-slate-400",children:[e.direction," @ $",null===(s=e.entry_price)||void 0===s?void 0:s.toFixed(2)]})]})]}),(0,J.jsxs)("div",{className:"text-right",children:[(0,J.jsxs)("div",{className:"font-bold ".concat(e.unrealized_pnl_pct>=0?"text-emerald-400":"text-red-400"),children:[e.unrealized_pnl_pct>=0?"+":"",e.unrealized_pnl_pct,"%"]}),(0,J.jsxs)("div",{className:"text-sm text-slate-400",children:["$",null===(a=e.unrealized_pnl)||void 0===a?void 0:a.toFixed(2)]})]}),(0,J.jsx)(c.$,{variant:"outline",size:"sm",onClick:()=>(async e=>{try{const t=await i.A.post("".concat($.nC,"/power-bot/close"),{symbol:e},{headers:Ze});M.oR.success("Position closed: ".concat(t.data.pnl_pct>=0?"+":"").concat(t.data.pnl_pct,"%")),await Promise.all([lt(),rt()])}catch(t){M.oR.error("Failed to close position")}})(e.symbol),"data-testid":"close-position-".concat(e.symbol),children:"Close"})]}),(0,J.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-5 ga
2p-3 pt-3 border-t border-white/5 text-sm",children:[(0,J.jsxs)("div",{children:[(0,J.jsx)("div",{className:"text-slate-500",children:"Current"}),(0,J.jsxs)("div",{className:"font-medium",children:["$",null===(l=e.current_price)||void 0===l?void 0:l.toFixed(2)]})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("div",{className:"text-slate-500",children:"Take Profit"}),(0,J.jsxs)("div",{className:"font-medium text-emerald-400",children:["$",null===(r=e.take_profit)||void 0===r?void 0:r.toFixed(2)]})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("div",{className:"text-slate-500",children:"Stop Loss"}),(0,J.jsxs)("div",{className:"font-medium text-red-400",children:["$",null===(n=e.stop_loss)||void 0===n?void 0:n.toFixed(2)]})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("div",{className:"text-slate-500",children:"Trailing Stop"}),(0,J.jsx)("div",{className:"font-medium",children:e.trailing_stop?"$".concat(e.trailing_stop.toFixed(2)):"Inactive"})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("div",{className:"text-slate-500",children:"Trend"}),(0,J.jsxs)("div",{className:"font-medium ".concat("BULLISH"===(null===(d=e.current_trend)||void 0===d?void 0:d.direction)?"text-emerald-400":"BEARISH"===(null===(o=e.current_trend)||void 0===o?void 0:o.direction)?"text-red-400":"text-slate-400"),children:[(null===(x=e.current_trend)||void 0===x?void 0:x.direction)||"N/A"," (",(null===(m=e.current_trend)||void 0===m?void 0:m.strength)||0,"%)"]})]})]}),e.smart_trailing_enabled&&(0,J.jsxs)("div",{className:"mt-2 flex items-center gap-2 text-xs",children:[(0,J.jsx)("span",{className:"px-2 py-0.5 rounded bg-amber-500/20 text-amber-400",children:"Smart Trailing Active"}),e.trailing_stop&&(0,J.jsxs)("span",{className:"text-slate-400",children:["Trailing at ",e.trailing_distance_pct,"% from peak"]})]})]},t)})})]}),(0,J.jsxs)("div",{className:"backdrop-blur-xl bg-slate-900/60 border border-white/10 rounded-xl p-6",children:[(0,J.jsxs)("h2",{className:"text-lg font-semibold mb-4 flex items-center gap-2",children:[(0,J.jsx)(P.A,{className:"w-5 h-5 text-amber-400"}),"Top Opportunities (",ie.length,ie.length!==ee.length?" of ".concat(ee.length):"",")"]}),0===ie.length?(0,J.jsxs)("div",{className:"text-center py-12 text-slate-400",children:[(0,J.jsx)(_.A,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),0===ee.length?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)("p",{children:"No opportunities found yet."}),(0,J.jsx)("p",{className:"text-sm",children:'Click "Scan All Markets" to find trading opportunities.'})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)("p",{children:"No opportunities match your filters."}),(0,J.jsx)("p",{className:"text-sm",children:"Try adjusting your asset class or symbol search."})]})]}):(0,J.jsx)("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-4",children:ie.map((e,t)=>{var s,a;return(0,J.jsxs)("div",{className:"p-4 rounded-xl border-2 transition-all cursor-pointer ".concat((null===ue||void 0===ue?void 0:ue.symbol)===e.symbol?"border-amber-500 bg-amber-500/10":"border-white/10 hover:border-amber-500/50"),onClick:()=>be(e),"data-testid":"opportunity-".concat(e.symbol),children:[(0,J.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,J.jsxs)("div",{className:"flex items-center gap-2",children:[(0,J.jsx)("span",{className:"px-2 py-0.5 rounded text-xs font-medium ".concat("crypto"===e.asset_type?"bg-amber-500/20 text-amber-400":"stocks"===e.asset_type?"bg-cyan-500/20 text-cyan-400":"bg-purple-500/20 text-purple-400"),children:e.asset_type.toUpperCase()}),(0,J.jsx)("span",{className:"font-bold",children:e.symbol})]}),(0,J.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 rounded-lg ".concat("LONG"===e.direction?"bg-emerald-500/20 text-emerald-400":"bg-red-500/20 text-red-400"),children:["LONG"===e.direction?(0,J.jsx)(L.A,{className:"w-4 h-4"}):(0,J.jsx)(U.A,{className:"w-4 h-4"}),(0,J.jsx)("span",{className:"text-sm font-medium",children:e.direction})]})]}),(0,J.jsxs)("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[(0,J.jsxs)("div",{children:[(0,J.jsx)("div",{className:"text-slate-400",children:"Profit Potential"}),(0,J.jsxs)("div",{className:"text-emerald-400 font-bold text-lg",children:["+",e.potential_profit,"%"]})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("div",{className:"text-slate-400",children:"Confidence"}),(0,J.jsxs)("div",{className:"font-bold text-lg",children:[e.confidence,"%"]})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("div",{className:"text-slate-400",children:"Entry"}),(0,J.jsxs)("div",{className:"font-medium",children:["$",null===(s=e.current_price)||void 0===s?void 0:s.toLocaleStr
2ing()]})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("div",{className:"text-slate-400",children:"Target"}),(0,J.jsxs)("div",{className:"font-medium",children:["$",null===(a=e.target_price)||void 0===a?void 0:a.toLocaleString()]})]})]}),e.trend&&(0,J.jsxs)("div",{className:"mt-3 pt-3 border-t border-white/5 flex items-center justify-between text-xs",children:[(0,J.jsxs)("div",{className:"flex items-center gap-2",children:[(0,J.jsx)(A.A,{className:"w-3 h-3 text-slate-400"}),(0,J.jsx)("span",{className:"font-medium ".concat("BULLISH"===e.trend.direction?"text-emerald-400":"BEARISH"===e.trend.direction?"text-red-400":"text-slate-400"),children:e.trend.direction}),(0,J.jsxs)("span",{className:"text-slate-500",children:["(",e.trend.strength,"% strength)"]})]}),e.trend.continue_trend&&(0,J.jsx)("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 rounded",children:"Strong Trend"})]})]},t)})})]}),ue&&(0,J.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:(0,J.jsxs)("div",{className:"backdrop-blur-xl bg-slate-900/60 border border-white/10 rounded-xl p-6 max-w-md w-full",children:[(0,J.jsx)("h3",{className:"text-xl font-bold mb-4",children:"Execute Trade"}),(0,J.jsxs)("div",{className:"space-y-4 mb-6",children:[(0,J.jsxs)("div",{className:"flex items-center justify-between p-3 bg-slate-800/30 rounded-lg",children:[(0,J.jsx)("span",{children:"Symbol"}),(0,J.jsx)("span",{className:"font-bold",children:ue.symbol})]}),(0,J.jsxs)("div",{className:"flex items-center justify-between p-3 bg-slate-800/30 rounded-lg",children:[(0,J.jsx)("span",{children:"Direction"}),(0,J.jsx)("span",{className:"font-bold ".concat("LONG"===ue.direction?"text-emerald-400":"text-red-400"),children:ue.direction})]}),(0,J.jsxs)("div",{className:"flex items-center justify-between p-3 bg-slate-800/30 rounded-lg",children:[(0,J.jsx)("span",{children:"Entry Price"}),(0,J.jsxs)("span",{className:"font-bold",children:["$",null===(I=ue.current_price)||void 0===I?void 0:I.toLocaleString()]})]}),(0,J.jsxs)("div",{className:"flex items-center justify-between p-3 bg-slate-800/30 rounded-lg",children:[(0,J.jsx)("span",{children:"Target"}),(0,J.jsxs)("span",{className:"font-bold text-emerald-400",children:["$",null===(B=ue.target_price)||void 0===B?void 0:B.toLocaleString()]})]}),(0,J.jsxs)("div",{className:"flex items-center justify-between p-3 bg-slate-800/30 rounded-lg",children:[(0,J.jsx)("span",{children:"Potential Profit"}),(0,J.jsxs)("span",{className:"font-bold text-emerald-400",children:["+",ue.potential_profit,"%"]})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("label",{className:"text-sm text-slate-400 mb-2 block",children:"Investment Amount ($)"}),(0,J.jsx)("input",{type:"number",value:ge,onChange:e=>ve(Number(e.target.value)),className:"w-full p-3 bg-slate-800/50 rounded-lg border border-white/10",min:"10",step:"10"})]})]}),(0,J.jsxs)("div",{className:"flex gap-3",children:[(0,J.jsx)(c.$,{variant:"outline",className:"flex-1",onClick:()=>be(null),children:"Cancel"}),(0,J.jsx)(c.$,{className:"flex-1 bg-gradient-to-r from-amber-500 to-orange-600",onClick:()=>(async e=>{fe(!0);try{await i.A.post("".concat($.nC,"/power-bot/execute"),{symbol:e.symbol,investment_amount:ge},{headers:Ze}),M.oR.success("Trade executed: ".concat(e.direction," ").concat(e.symbol)),be(null),await lt()}catch(a){var t,s;M.oR.error("Trade failed: "+((null===(t=a.response)||void 0===t||null===(s=t.data)||void 0===s?void 0:s.detail)||"Unknown error"))}finally{fe(!1)}})(ue),disabled:je,"data-testid":"confirm-trade-btn",children:je?(0,J.jsx)(p.A,{className:"w-4 h-4 animate-spin"}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(f.A,{className:"w-4 h-4 mr-2"}),"Execute Trade"]})})]})]})}),Ne&&(0,J.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4 overflow-y-auto",children:(0,J.jsxs)("div",{className:"backdrop-blur-xl bg-slate-900/60 border border-white/10 rounded-xl p-6 max-w-lg w-full my-8",children:[(0,J.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,J.jsxs)("h3",{className:"text-xl font-bold flex items-center gap-2",children:[(0,J.jsx)(w.A,{className:"w-5 h-5"}),"Power Bot Settings"]}),(0,J.jsx)("button",{onClick:()=>ye(!1),className:"text-slate-400 hover:text-white",children:(0,J.jsx)(S.A,{className:"w-5 h-5"})})]}),(0,J.jsxs)("div",{className:"space-y-6",children:[(0,J.jsxs)("div",{children:[(0,J.jsxs)("h4",{className:"text-sm font-semibold text-amber-400 mb-3 flex items-center gap-2",children:[(0,J.jsx)(T.A,{className:"w-4 h-4"}),"Profit Targets"]}),(0,J.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,J.jsxs)("div",{children:[(0,J.jsx)("label",{className:"text-sm text-slate-400 mb-1 block",children:"Min Profit %"}),(0,J.jsxs)("div",{className:"relative",children:[(0,J.jsx)("input",{type:"number",value:Ye.min_profit_percent,onChange:e=>Qe((0,l.A)((0,l.A)({},Ye),{},{min_profit_percent:parseFloat(e.target.value)})),className:"w-full p-3 pr-8 bg-slate-800/50 rounded-lg border border-white/10",min:"0.5",max:"10",step:"0.1","data-testid":"min-profit-input"}),(0,J.jsx)(F.A,{className:"w-4 h-4 text-slate-400 absolute right-3 top-1/2 -translate-y-1/2"})]}),(0,J.jsx)("p",{className:"text-xs text-slate-500 mt-1",children:"Minimum profit to trigger take-profit"})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("label",{className:"text-sm text-slate-400 mb-1 block",children:"Max Profit %"}),(0,J.jsxs)("div",{className:"relative",children:[(0,J.jsx)("input",{type:"number",value:Ye.max_profit_percent,onChange:e=>Qe((0,l.A)((0,l.A)({},Ye),{},{max_profit_percent:parseFloat(e.target.value)})),className:"w-full p-3 pr-8 bg-slate-800/50 rounded-lg border border-white/10",min:"5",max:"100",step:"0.1","data-testid":"max-profit-input"}),(0,J.jsx)(F.A,{className:"w-4 h-4 text-slate-400 absolute right-3 top-1/2 -translate-y-1/2"})]}),(0,J.jsx)("p",{className:"text-xs text-slate-500 mt-1",children:"Force close at this profit level"})]})]})]}),(0,J.jsxs)("div",{children:[(0,J.jsxs)("h4",{className:"text-sm font-semibold text-cyan-400 mb-3 flex items-center gap-2",children:[(0,J.jsx)(A.A,{className:"w-4 h-4"}),"Smart Trailing"]}),(0,J.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,J.jsxs)("div",{children:[(0,J.jsx)("label",{className:"text-sm text-slate-400 mb-1 block",children:"Activation %"}),(0,J.jsxs)("div",{className:"relative",children:[(0,J.jsx)("input",{type:"number",value:Ye.trailing_activation,onChange:e=>Qe((0,l.A)((0,l.A)({},Ye),{},{trailing_activation:parseFloat(e.target.value)})),className:"w-full p-3 pr-8 bg-slate-800/50 rounded-lg border border-white/10",min:"0.5",max:"10",step:"0.1","data-testid":"trailing-activation-input"}),(0,J.jsx)(F.A,{className:"w-4 h-4 text-slate-400 absolute right-3 top-1/2 -translate-y-1/2"})]}),(0,J.jsx)("p",{className:"text-xs text-slate-500 mt-1",children:"Activate trailing after this profit"})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("label",{className:"text-sm text-slate-400 mb-1 block",children:"Trailing Distance %"}),(0,J.jsxs)("div",{className:"relative",children:[(0,J.jsx)("input",{type:"number",value:Ye.trailing_distance,onChange:e=>Qe((0,l.A)((0,l.A)({},Ye),{},{trailing_distance:parseFloat(e.target.value)})),className:"w-full p-3 pr-8 bg-slate-800/50 rounded-lg border border-white/10",min:"0.25",max:"5",step:"0.1","data-testid":"trailing-distance-input"}),(0,J.jsx)(F.A,{className:"w-4 h-4 text-slate-400 absolute right-3 top-1/2 -translate-y-1/2"})]}),(0,J.jsx)("p",{className:"text-xs text-slate-500 mt-1",children:"Distance from peak before exit"})]})]})]}),(0,J.jsxs)("div",{children:[(0,J.jsxs)("h4",{className:"text-sm font-semibold text-red-400 mb-3 flex items-center gap-2",children:[(0,J.jsx)(R.A,{className:"w-4 h-4"}),"Risk Management"]}),(0,J.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,J.jsxs)("div",{children:[(0,J.jsx)("label",{className:"text-sm text-slate-400 mb-1 block",children:"Stop Loss %"}),(0,J.jsxs)("div",{className:"relative",children:[(0,J.jsx)("input",{type:"number",value:Ye.stop_loss_percent,onChange:e=>Qe((0,l.A)((0,l.A)({},Ye),{},{stop_loss_percent:parseFloat(e.target.value)})),className:"w-full p-3 pr-8 bg-slate-800/50 rounded-lg border border-white/10",min:"0.5",max:"10",step:"0.1","data-testid":"stop-loss-in
2put"}),(0,J.jsx)(F.A,{className:"w-4 h-4 text-slate-400 absolute right-3 top-1/2 -translate-y-1/2"})]}),(0,J.jsx)("p",{className:"text-xs text-slate-500 mt-1",children:"Maximum loss before exit"})]}),(0,J.jsxs)("div",{children:[(0,J.jsx)("label",{className:"text-sm text-slate-400 mb-1 block",children:"Risk Per Trade %"}),(0,J.jsxs)("div",{className:"relative",children:[(0,J.jsx)("input",{type:"number",value:Ye.risk_per_trade,onChange:e=>Qe((0,l.A)((0,l.A)({},Ye),{},{risk_per_trade:parseFloat(e.target.value)})),className:"w-full p-3 pr-8 bg-slate-800/50 rounded-lg border border-white/10",min:"0.5",max:"10",step:"0.1","data-testid":"risk-per-trade-input"}),(0,J.jsx)(F.A,{className:"w-4 h-4 text-slate-400 absolute right-3 top-1/2 -translate-y-1/2"})]}),(0,J.jsx)("p",{className:"text-xs text-slate-500 mt-1",children:"Portfolio % per trade"})]})]})]}),(0,J.jsxs)("div",{className:"space-y-3",children:[(0,J.jsxs)("label",{className:"flex items-center justify-between p-3 bg-slate-800/30 rounded-lg cursor-pointer",children:[(0,J.jsxs)("div",{children:[(0,J.jsx)("div",{className:"font-medium",children:"Smart Trailing"}),(0,J.jsx)("div",{className:"text-sm text-slate-400",children:"Ride trends instead of fixed exits"})]}),(0,J.jsx)("input",{type:"checkbox",checked:Ye.smart_trailing_enabled,onChange:e=>Qe((0,l.A)((0,l.A)({},Ye),{},{smart_trailing_enabled:e.target.checked})),className:"w-5 h-5 accent-amber-500","data-testid":"smart-trailing-toggle"})]}),(0,J.jsxs)("label",{className:"flex items-center justify-between p-3 bg-slate-800/30 rounded-lg cursor-pointer",children:[(0,J.jsxs)("div",{children:[(0,J.jsx)("div",{className:"font-medium",children:"Auto Manage Positions"}),(0,J.jsx)("div",{className:"text-sm text-slate-400",children:"Automatically adjust stops based on trend"})]}),(0,J.jsx)("input",{type:"checkbox",checked:Ye.auto_manage_positions,onChange:e=>Qe((0,l.A)((0,l.A)({},Ye),{},{auto_manage_positions:e.target.checked})),className:"w-5 h-5 accent-amber-500","data-testid":"auto-manage-toggle"})]})]})]}),(0,J.jsxs)("div",{className:"flex gap-3 mt-6",children:[(0,J.jsx)(c.$,{variant:"outline",className:"flex-1",onClick:()=>ye(!1),children:"Cancel"}),(0,J.jsx)(c.$,{className:"flex-1 bg-gradient-to-r from-amber-500 to-orange-600",onClick:async()=>{Ae(!0);try{const{user_id:e,updated_at:t,created_at:s,_id:r}=Ye,n=(0,a.A)(Ye,ae),c=await i.A.post("".concat($.nC,"/power-bot/settings"),n,{headers:Ze});if(c.data.settings){const e=c.data.settings,{user_id:t,updated_at:s,created_at:r,_id:n}=e,i=(0,a.A)(e,le);Qe(e=>(0,l.A)((0,l.A)({},e),i))}M.oR.success("Settings saved successfully"),ye(!1)}catch(e){M.oR.error("Failed to save settings")}finally{Ae(!1)}},disabled:we,"data-testid":"save-settings-btn",children:we?(0,J.jsx)(p.A,{className:"w-4 h-4 animate-spin"}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(E.A,{className:"w-4 h-4 mr-2"}),"Save Settings"]})})]})]})})]})]})}):(0,J.jsx)("div",{className:"min-h-screen bg-slate-950 p-6",children:(0,J.jsx)("div",{className:"max-w-2xl mx-auto",children:(0,J.jsxs)("div",{className:"backdrop-blur-xl bg-slate-900/60 border border-white/10 rounded-xl p-8 text-center",children:[(0,J.jsx)("div",{className:"w-20 h-20 bg-gradient-to-r from-amber-500 to-orange-600 rounded-2xl flex items-center justify-center mx-auto mb-6",children:(0,J.jsx)(u.A,{className:"w-10 h-10 text-white"})}),(0,J.jsx)("h1",{className:"text-3xl font-bold mb-2",children:"AI Power Scanner Bot"}),(0,J.jsx)("p",{className:"text-slate-400 mb-6",children:"Unlock the ultimate trading advantage with our AI-powered market scanner"}),(0,J.jsx)("div",{className:"grid gap-4 text-left mb-8",children:["Scans 60+ trading pairs across crypto, stocks & forex","Finds opportunities with minimum 2% profit potential","AI-powered analysis with 70%+ confidence threshold","Automatic long & short position detection","Real-time alerts and trade execution","Performance tracking and analytics"].map((e,t)=>(0,J.jsxs)("div",{className:"flex items-center gap-3",children:[(0,J.jsx)(b.A,{className:"w-5 h-5 text-emerald-400 flex-shrink-0"}),(0,J.jsx)("span",{children:e})]},t))}),(0,J.jsxs)("div",{className:"p-6 bg-gradient-to-r from-amber-500/10 to-orange-600/10 rounded-xl border border-amber-500/30 mb-6",children:[(0,J.jsx)("div",{className:"text-4xl font-bold text-amber-400 mb-1",children:"$19.95"}),(0,J.jsx)("div",{className:"text-slate-400",children:"per month"})]}),(0,J.jsxs)(c.$,{className:"w-full h-12 bg-gradient-to-r from-amber-500 to-orange-600 hover:from-amber-600 hover:to-orange-700",onClick:mt,disabled:ot,"data-testid":"upgrade-power-bot-btn",children:[ot?(0,J.jsx)(p.A,{className:"w-5 h-5 mr-2 animate-spin"}):(0,J.jsx)(g.A,{className:"w-5 h-5 mr-2"}),ot?"Processing...":"Upgrade to Power Bot"]}),(0,J.jsx)("p",{className:"text-xs text-slate-400 mt-4",children:"Cancel anytime. 7-day money-back guarantee."})]})})})}},39292(e,t,s){s.d(t,{A:()=>a});const a=(0,s(77784).A)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]])},67010(e,t,s){s.d(t,{A:()=>a});const a=(0,s(77784).A)("arrow-up-right",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]])},76245(e,t,s){s.d(t,{A:()=>a});const a=(0,s(77784).A)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},84991(e,t,s){s.d(t,{A:()=>a});const a=(0,s(77784).A)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]])},85347(e,t,s){s.d(t,{A:()=>a});const a=(0,s(77784).A)("award",[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]])},87147(e,t,s){s.d(t,{A:()=>a});const a=(0,s(77784).A)("percent",[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]])},88693(e,t,s){s.d(t,{A:()=>a});const a=(0,s(77784).A)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]])}}]); 3//# sourceMappingURL=9900.24bf08c9.chunk.js.map
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.