1import{o as ne}from"./rolldown-runtime-ChpBd9eV.js";import{Gt as H,Ka as oe,Lt as K,Pa as de,Ua as ce,Va as Y,Yt as O,_t as M,ba as S,mt as A,pn as me,q as W,rn as z,un as xe,wa as he}from"./chat-page-C-flp553.js";import{_a as w,oa as ue,sa as V}from"./market-core-B8Bfud51.js";import{Ar as pe,Fn as ge,Gn as J,In as X,Mr as be,Nr as fe,fr as P,kr as Q,qn as ve}from"./community-page-dub7UFXa.js";import{C as ye,v as B,w as C}from"./dashboard-page-BSnUBMUY.js";var j=ne(oe(),1),e=de(),R=n=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(n||0),q=n=>n?n instanceof Date?n:typeof n?.toDate=="function"?n.toDate():new Date(n):new Date,G={critical:4,high:3,medium:2,low:1},je={NO_STOP_LOSS:"Stop-loss discipline",OVERTRADING:"Overtrading",REVENGE_TRADE:"Revenge trading",PLAN_DEVIATION:"Plan deviation",MAX_DAILY_LOSS:"Daily loss limit",RISK_LIMIT:"Risk limit"};function we(n=[]){const s=new Map;return n.forEach(i=>{const a=String(i?.code||i?.type||"RULE_VIOLATION").toUpperCase(),o=s.get(a)||{code:a,count:0,messages:[]};o.count+=1,i?.message&&o.messages.push(i.message),s.set(a,o)}),Array.from(s.values()).sort((i,a)=>a.count-i.count)}var Ne={"revenge-cluster":"revenge-clusters","overtrading-after-third":"overtrade-days","no-stop-pattern":"missing-stops","plan-drift":"rule-follow-through"},$e=new Set(["psychology","rule_adherence","risk"]);function ke(n=[]){return n.filter(s=>s&&!s.dismissed&&!s.acted&&$e.has(s.category)).map(s=>{const i=Number(s?.evidence?.pnlImpact),a=s.severity==="high"?Number.isFinite(i)&&i<-200?"critical":"high":"medium",o=(s.actions||[]).find(u=>u?.payload?.rule)?.payload?.rule;return{id:`insight-${s.detectorId||s.id}`,suppresses:Ne[s.detectorId]||null,priority:a,title:s.title,evidence:s.evidence?.stat||`${s.evidence?.sampleSize??"â"} trades in evidence`,impact:Number.isFinite(i)?`${R(i)} measured impact`:(s.body||"").slice(0,140),rule:o||(s.body||"").split(". ")[0]||s.title,route:`/trade-analytics?tab=lab&insightId=${encodeURIComponent(s.id)}`}})}function Re({activeViolations:n,revengeIncidents:s,overtrading:i,discipline:a,sorted:o,insights:u=[]}){const g=ke(u),m=new Set(g.map(c=>c.suppresses).filter(Boolean)),d=[...g],N=c=>{m.has(c.id)||d.push(c)};if(we(n).forEach(c=>{d.push({id:`violation-${c.code}`,priority:c.count>=3?"critical":"high",title:je[c.code]||c.code.replace(/_/g," "),evidence:`${c.count} active violation${c.count===1?"":"s"}`,impact:c.messages[0]||"Current enforcement state is already flagging this pattern.",rule:c.code==="NO_STOP_LOSS"?"No entry without a server-visible stop or invalidation.":c.code==="OVERTRADING"?"Stop when your daily trade cap is hit.":"Treat the active violation as blocking until reviewed.",route:`/education?source=violation&violation=${encodeURIComponent(c.code)}§ion=courses`})}),s.length>0){const c=s.reduce((b,$)=>b+Math.min(0,$.totalLoss||0),0);N({id:"revenge-clusters",priority:c<-200?"critical":"high",title:"Post-loss impulse control",evidence:`${s.length} loss streak${s.length===1?"":"s"} of ${w.consecutiveLossLimit+1}+`,impact:`${R(c)} tied to clustered losing sequences`,rule:`After ${w.consecutiveLossLimit} consecutive losses, force a cooldown before any new trade.`,route:"/trade-analytics?tab=lab&insightId=revenge-cluster::windowKey=last30days"})}if(i.length>0){const c=w.dailyTradeCap,b=i.reduce(($,T)=>$+(T.pl||0),0);N({id:"overtrade-days",priority:b<-200?"critical":"high",title:"Daily trade cap",evidence:`${i.length} day${i.length===1?"":"s"} above ${c} trades`,impact:`${R(b)} on excessive days`,rule:`Cap the day before quality drops. Make trade #${c+1} require an A+ setup.`,route:"/trade-analytics?tab=lab&insightId=overtrading-after-third::windowKey=last30days"})}if(Number(a.stopPct)<80){const c=o.filter(b=>!Q(b)&&C(b)).reduce((b,$)=>b+Math.min(0,P($)||0),0);N({id:"missing-stops",priority:Number(a.stopPct)<60?"critical":"high",title:"Mandatory stop process",evidence:`${a.noStop} trade${a.noStop===1?"":"s"} missing stops`,impact:`${R(c)} realized losses among closed trades without a recorded stop; this is correlation, not a causal estimate.`,rule:"Before entry: stop price, invalidation, and risk amount must be present.",route:"/trade-analytics?tab=lab&insightId=no-stop-pattern::windowKey=last30days"})}return a.rulesPct!=null&&Number(a.rulesPct)<80&&N({id:"rule-follow-through",priority:"medium",title:"Rule follow-through",evidence:`${a.noRules} rule break${a.noRules===1?"":"s"} among ${a.trackedRules} trades with recorded adherence`,impact:"Rule drift weakens the discipline score and makes automation less enforceable.",rule:"Name the exact playbook rule before every entry.",route:"/trade-analytics?tab=playbook"}),d.sort((c,b)=>(G[b.priority]||0)-(G[c.priority]||0))}var Z=({value:n,max:s=100,size:i=96,strokeWidth:a=8,color:o="#6366f1"})=>{const u=(i-a)/2,g=2*Math.PI*u,m=g*(n/s);return(0,e.jsxs)("svg",{role:"img","aria-label":`Discipline score ${n} out of ${s}`,width:i,height:i,style:{transform:"rotate(-90deg)"}
1,children:[(0,e.jsx)("circle",{cx:i/2,cy:i/2,r:u,fill:"none",stroke:"#1e293b",strokeWidth:a}),(0,e.jsx)("circle",{cx:i/2,cy:i/2,r:u,fill:"none",stroke:o,strokeWidth:a,strokeDasharray:`${m} ${g}`,strokeLinecap:"round",style:{transition:"stroke-dasharray 0.8s ease"}})]})},E=({label:n,value:s,sub:i,color:a="indigo"})=>(0,e.jsxs)("div",{className:`rounded-xl border p-4 ${{indigo:"bg-indigo-500/10 border-indigo-500/30 text-indigo-300",emerald:"bg-emerald-500/10 border-emerald-500/30 text-emerald-300",amber:"bg-amber-500/10 border-amber-500/30 text-amber-300",red:"bg-red-500/10 border-red-500/30 text-red-300",slate:"bg-slate-500/10 border-slate-500/30 text-slate-300"}[a]}`,children:[(0,e.jsx)("div",{className:"text-xs font-medium opacity-70 mb-1",children:n}),(0,e.jsx)("div",{className:"text-2xl font-bold text-white",children:s}),i&&(0,e.jsx)("div",{className:"text-xs mt-1 opacity-60",children:i})]}),L=({title:n,icon:s,severity:i="info",badge:a,children:o,defaultOpen:u=!0,id:g})=>{const[m,d]=(0,j.useState)(u),N={critical:"border-red-500/30 bg-red-500/5",warning:"border-amber-500/30 bg-amber-500/5",success:"border-emerald-500/30 bg-emerald-500/5",info:"border-indigo-500/30 bg-indigo-500/5"}[i];return(0,e.jsxs)("div",{id:g,className:`rounded-2xl border ${N} overflow-hidden`,children:[(0,e.jsxs)("button",{onClick:()=>d(!m),className:"w-full flex items-center justify-between p-5 hover:bg-white/5 transition",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[s&&(0,e.jsx)(s,{className:"w-5 h-5 text-slate-300 flex-shrink-0"}),(0,e.jsx)("span",{className:"font-semibold text-white",children:n}),a&&(0,e.jsx)("span",{className:"px-2 py-0.5 rounded-full text-xs bg-white/10 text-slate-300",children:a})]}),(0,e.jsx)(me,{className:`w-4 h-4 text-slate-500 transition-transform ${m?"rotate-90":""}`})]}),(0,e.jsx)(he,{initial:!1,children:m&&(0,e.jsx)(S.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:(0,e.jsx)("div",{className:"px-5 pb-5 border-t border-white/5",children:o})},"content")})]})},U={critical:"border-red-500/40 bg-red-500/10 text-red-300",high:"border-orange-500/40 bg-orange-500/10 text-orange-300",medium:"border-amber-500/40 bg-amber-500/10 text-amber-300",low:"border-slate-600 bg-slate-800/70 text-slate-300"};function Se({drivers:n,fallbackActions:s,focusedInsight:i,completedActions:a,onToggle:o,navigate:u}){const g=n.length?n:s.map(d=>({id:d.id,priority:d.priority==="high"?"high":"medium",title:d.title,evidence:d.desc,impact:"Derived from current behavior metrics.",rule:d.desc,route:null})),m=g[0];return m?(0,e.jsxs)("section",{className:"rounded-2xl border border-slate-700 bg-slate-950/40 overflow-hidden",children:[(0,e.jsxs)("div",{className:"p-5 border-b border-slate-800 flex flex-wrap items-start justify-between gap-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,e.jsx)(J,{className:"w-5 h-5 text-indigo-300"}),(0,e.jsx)("span",{className:"text-xs uppercase tracking-[0.2em] text-slate-400 font-semibold",children:"Behavior operating plan"})]}),(0,e.jsx)("h3",{className:"text-xl font-bold text-white",children:m.title}),(0,e.jsx)("p",{className:"text-sm text-slate-400 mt-1 max-w-3xl",children:i?`Working from Decisions: ${i.title}`:"Prioritized from active violations, discipline score movement, and recent trade behavior."})]}),(0,e.jsx)("span",{className:`text-xs px-2.5 py-1 rounded-full border font-semibold ${U[m.priority]||U.low}`,children:m.priority})]}),(0,e.jsxs)("div",{className:"grid gap-4 lg:grid-cols-[1.2fr_0.8fr] p-5",children:[(0,e.jsxs)("div",{className:"rounded-xl border border-slate-800 bg-slate-900/50 p-4",children:[(0,e.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs uppercase tracking-wide text-slate-500 mb-1",children:"Evidence"}),(0,e.jsx)("div",{className:"text-sm font-semibold text-white",children:m.evidence})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs uppercase tracking-wide text-slate-500 mb-1",children:"Impact"}),(0,e.jsx)("div",{className:"text-sm font-semibold text-slate-200",children:m.impact})]})]}),(0,e.jsxs)("div",{className:"mt-4 rounded-xl border border-indigo-500/25 bg-indigo-500/8 p-3",children:[(0,e.jsx)("div",{className:"text-xs uppercase tracking-wide text-indigo-300 mb-1",children:"Rule to enforce next"}),(0,e.jsx)("div",{className:"text-sm text-white font-medium",children:m.rule})]}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-2 mt-4",children:[(0,e.jsx)("button",{type:"button",onClick:()=>o(m.id),className:`text-xs px-3 py-1.5 rounded-lg font-semibold border transition ${a[m.id]?"border-emerald-500/40 bg-emerald-500/10 text-emerald-300":"border-slate-700 bg-slate-900 text-slate-200 hover:bg-slate-800"}`,children:a[m.id]?"Marked for today":"Mark as todayâs correction"}),m.route&&(0,e.jsx)("button",{type:"button",onClick:()=>u(m.route),className:"text-xs px-3 py-1.5 rounded-lg bg-blue-600 hover:bg-blue-500 text-white font-semibold transition",children:"Review evidence"}),(0,e.jsx)("button",{type:"button",onClick:()=>u("/education?section=courses"),className:"text-xs px-3 py-1.5 rounded-lg bg-emerald-900/40 border border-emerald-700/50 text-emerald-300 hover:bg-emerald-800/50 transition",children:"Train this skill"})]})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("div",{className:"text-xs uppercase tracking-wide text-slate-500 font-semibold",children:"Next corrections"}),g.slice(0,5).map(d=>(0,e.jsx)("button",{type:"button",onClick:()=>o(d.id),className:`w-full text-left rounded-xl border p-3 transition ${a[d.id]?"border-emerald-500/40 bg-emerald-500/8":"border-slate-800 bg-slate-900/50 hover:bg-slate-900"}`,children:(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,e.jsx)("div",{className:`w-4 h-4 rounded-full border-2 flex-shrink-0 mt-0.5 flex items-center justify-center ${a[d.id]?"bg-emerald-500 border-emerald-400":"border-slate-500"}`,children:a[d.id]&&(0,e.jsx)(xe,{className:"w-3 h-3 text-white"})}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:`text-sm font-semibold ${a[d.id]?"text-emerald-300 line-through opacity-70":"text-white"}`,children:d.title}),(0,e.jsx)("div",{className:"text-xs text-slate-400 mt-0.5",children:d.evidence})]})]})},d.id))]})]})]}):(0,e.jsx)("section",{className:"rounded-2xl border border-emerald-500/30 bg-emerald-500/5 p-5",children:(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,e.jsx)(M,{className:"w-5 h-5 text-emerald-300 mt-0.5"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-white font-semibold",children:"No flagged patterns in this sample"}),(0,e.jsx)("p",{className:"text-sm text-slate-400 mt-1",children:"This does not mean every behavior is verified as healthy. Review sample size and data coverage below; current enforcement flags are shown separately."})]})]})})}var Te=()=>{const n=Y(),{score:s,band:i}=X(),a=W(),o=[{icon:H,label:"Revenge trading detection",color:"text-red-400"},{icon:O,label:"FOMO & chasing patterns",color:"text-amber-400"},{icon:z,label:"Overtrading by session",color:"text-orange-400"},{icon:M,label:"Execution grade breakdown",color:"text-indigo-400"},{icon:J,label:"Personalised action plan",color:"text-blue-400"},{icon:K,label:"Emotional state by outcome",color:"text-pink-400"}];return(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center min-h-[520px] px-6 py-16 text-center max-w-2xl mx-auto",children:[(0,e.jsxs)(S.div,{className:"relative mb-8",initial:{scale:.7,opacity:0}
1,animate:{scale:1,opacity:1},transition:{type:"spring",stiffness:200,damping:18},children:[(0,e.jsx)(Z,{value:s??0,size:120,strokeWidth:10,color:s==null?"#64748b":s>=80?"#10b981":s>=60?"#f59e0b":"#ef4444"}),(0,e.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[(0,e.jsx)("span",{className:"text-3xl font-bold text-white",children:s??"â"}),s!=null&&(0,e.jsx)("span",{className:"text-xs text-slate-400",children:"/ 100"})]})]}),(0,e.jsxs)(S.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.15},children:[(0,e.jsxs)("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full bg-indigo-500/10 border border-indigo-500/30 text-indigo-300 text-xs font-medium mb-4",children:[(0,e.jsx)(A,{className:"w-3.5 h-3.5"}),s!=null?`Discipline: ${i?.label??""}`:"Building your behavioral baseline"]}),(0,e.jsx)("h2",{className:"text-2xl font-bold text-white mb-3",children:"Your Behavior Hub"}),(0,e.jsx)("p",{className:"text-slate-400 text-sm leading-relaxed mb-2",children:"Redline already has the profile and guardrails you shared. Add closed-trade history to build evidence; after 10 closed trades, it can start identifying repeatable patterns with the sample size and supporting trades shown."}),a.length>0&&(0,e.jsxs)("p",{className:"text-amber-400 text-xs font-medium mb-6",children:["â You have ",a.length," active violation",a.length!==1?"s":""," â log more trades to see full pattern analysis."]})]}),(0,e.jsx)(S.div,{className:"grid grid-cols-2 gap-3 w-full mb-8",initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.25},children:o.map(({icon:u,label:g,color:m})=>(0,e.jsxs)("div",{className:"flex items-center gap-3 rounded-xl bg-slate-800/60 border border-slate-700/50 px-4 py-3 text-left",children:[(0,e.jsx)(u,{className:`w-4 h-4 flex-shrink-0 ${m}`}),(0,e.jsx)("span",{className:"text-xs text-slate-300 font-medium",children:g})]},g))}),(0,e.jsxs)(S.div,{className:"flex flex-col sm:flex-row gap-3 w-full justify-center",initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.35},children:[(0,e.jsxs)("button",{onClick:()=>n("/trade-logger"),className:"flex items-center justify-center gap-2 px-6 py-3 bg-indigo-600 hover:bg-indigo-500 text-white font-semibold rounded-xl transition text-sm",children:[(0,e.jsx)(ve,{className:"w-4 h-4"}),"Log Your First Trade"]}),(0,e.jsxs)("button",{onClick:()=>n("/education"),className:"flex items-center justify-center gap-2 px-6 py-3 bg-slate-700/60 hover:bg-slate-700 text-slate-200 font-medium rounded-xl transition text-sm border border-slate-600/50",children:[(0,e.jsx)(A,{className:"w-4 h-4"}),"Visit Coach Me"]})]})]})},Oe=({trades:n=[],user:s})=>{const i=Y(),[a]=ce(),{score:o,band:u}=X(),{movements:g,fixes:m}=ge(),d=W(),N=a.get("insightId")||"",c=V(t=>N&&t.insights.find(r=>r.id===N)||null),b=V(t=>t.insights),$=`redline:behavior-actions:${s?.uid||"anon"}:${new Date().toISOString().slice(0,10)}
1`,[T,ee]=(0,j.useState)(()=>{if(typeof window>"u")return{};try{return JSON.parse(window.localStorage.getItem($)||"{}")}catch{return{}}});(0,j.useEffect)(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem($,JSON.stringify(T))}catch{}},[$,T]);const te=t=>ee(r=>({...r,[t]:!r[t]})),h=(0,j.useMemo)(()=>[...n].sort((t,r)=>q(t.entryTime)-q(r.entryTime)),[n]),D=(0,j.useMemo)(()=>h.filter(C),[h]),se=h.length-D.length,y=(0,j.useMemo)(()=>pe(D,{minLen:w.consecutiveLossLimit+1,plOf:t=>P(t)||0,timeOf:t=>t.entryTime}),[D]),v=(0,j.useMemo)(()=>{const t=new Map;return h.forEach(r=>{const l=be(r.entryTime);l&&(t.has(l)||t.set(l,[]),t.get(l).push(r))}),Array.from(t.entries()).filter(([,r])=>r.length>w.dailyTradeCap).map(([r,l])=>({day:r,count:l.length,pl:l.filter(C).reduce((x,k)=>x+P(k),0)})).sort((r,l)=>l.count-r.count)},[h]),p=(0,j.useMemo)(()=>{const t=h.length||1,r=h.filter(f=>Q(f)).length,l=h.filter(ye),x=l.filter(f=>B(f)===!0).length,k=l.filter(f=>B(f)===!1).length,F=h.filter(f=>f.setup&&f.setup.trim()&&f.setup!=="Unknown").length,I=h.filter(f=>f.notes&&f.notes.trim().length>20).length;return{stopPct:(r/t*100).toFixed(0),rulesPct:l.length?(x/l.length*100).toFixed(0):null,setupPct:(F/t*100).toFixed(0),notesPct:(I/t*100).toFixed(0),noStop:t-r,trackedRules:l.length,unknownRules:t-l.length,noRules:k}},[h]),_=(0,j.useMemo)(()=>{const t={premarket:[],regular:[],aftermarket:[]};h.forEach(l=>{const x=fe(l.entryTime);t[x==="premarket"?"premarket":x==="rth"?"regular":"aftermarket"].push(l)});const r=l=>{const x=l.filter(C),k=x.filter(I=>P(I)>0).length,F=x.reduce((I,f)=>I+P(f),0);return{count:x.length,openCount:l.length-x.length,wins:k,pl:F,wr:x.length?(k/x.length*100).toFixed(0):"â"}};return{premarket:r(t.premarket),regular:r(t.regular),aftermarket:r(t.aftermarket)}},[h]),re=(0,j.useMemo)(()=>{const t=[],r=w.consecutiveLossLimit,l=w.dailyTradeCap;return y.length>0&&t.push({id:"revenge",priority:"high",title:`Stop after ${r} consecutive losses`,desc:`${y.length} revenge incident${y.length>1?"s":""} detected. Walk away after ${r} losses.`}),v.length>0&&t.push({id:"overtrade",priority:"high",title:`Set a ${l}-trade daily limit`,desc:`${v.length} day${v.length>1?"s":""} with >${l} trades. Cap at ${l} per day.`}),parseInt(p.stopPct)<80&&t.push({id:"stops",priority:"high",title:"Make stop-loss mandatory",desc:`${p.noStop} trade${p.noStop!==1?"s":""} entered without a stop. Never enter without one.`}),p.rulesPct!=null&&parseInt(p.rulesPct)<80&&t.push({id:"rules",priority:"medium",title:"Re-read your rules before each trade",desc:`${p.noRules} rule breaks among ${p.trackedRules} trades with adherence recorded. ${p.unknownRules} trades have no adherence data.`}),m?.length&&m.slice(0,2).forEach((x,k)=>t.push({id:`fix_${k}`,priority:"medium",title:x.label||x.action,desc:x.description||x.impact||""})),t},[y,v,p,m]),ae=(0,j.useMemo)(()=>Re({activeViolations:d,revengeIncidents:y,overtrading:v,discipline:p,sorted:h,insights:b}),[d,y,v,p,h,b]);if(ue(h.length>0),h.length===0)return(0,e.jsx)(Te,{});const ie=o==null?"#64748b":o>=80?"#10b981":o>
1=60?"#f59e0b":"#ef4444",le=o==null?"slate":o>=80?"emerald":o>=60?"amber":"red";return(0,e.jsxs)(S.div,{className:"space-y-5 pb-8",initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3},children:[(0,e.jsx)("div",{className:"rounded-2xl bg-gradient-to-br from-indigo-600/15 to-purple-600/10 border border-indigo-500/25 p-6",children:(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-6",children:[(0,e.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,e.jsx)(Z,{value:o??0,size:100,strokeWidth:9,color:ie}),(0,e.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[(0,e.jsx)("span",{className:"text-2xl font-bold text-white",children:o??"â"}),o!=null&&(0,e.jsx)("span",{className:"text-[10px] text-slate-400",children:"/ 100"})]})]}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("h2",{className:"text-lg font-bold text-white mb-0.5 flex items-center gap-2",children:[(0,e.jsx)(K,{className:"w-5 h-5 text-indigo-400"}),"Behavioral Health"]}),(0,e.jsxs)("p",{className:"text-sm text-slate-400 mb-3",children:[o!=null?`${u?.label??""} · `:"Score needs 10 closed trades · ",h.length," logged · ",D.length," closed · ",se," open"]}),g?.length>0&&(0,e.jsx)("div",{className:"flex flex-wrap gap-2",children:g.slice(0,3).map((t,r)=>{const l=typeof t=="string"?t:t?.label??t?.reason??t?.message??t?.code??"";return l?(0,e.jsx)("span",{className:`text-xs px-2 py-0.5 rounded-full border ${t?.direction==="down"||typeof t?.impact=="number"&&t.impact<0?"bg-red-500/15 text-red-300 border-red-500/30":"bg-slate-700/60 text-slate-300 border-slate-600/40"}`,children:l},r):null})})]}),(0,e.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 w-full sm:w-auto",children:[(0,e.jsx)(E,{label:"Discipline",value:o,sub:u?.label,color:le}),(0,e.jsx)(E,{label:"Revenge",value:y.length,sub:"closed-trade loss streaks",color:y.length===0?"emerald":"red"}),(0,e.jsx)(E,{label:"Overtrade Days",value:v.length,sub:v.length===0?"In range â":`days >${w.dailyTradeCap} trades`,color:v.length===0?"emerald":"amber"}),(0,e.jsx)(E,{label:"Active Flags",value:d.length,sub:d.length===0?"None â":"open violations",color:d.length===0?"emerald":"amber"})]})]})}),(0,e.jsx)(Se,{drivers:ae,fallbackActions:re,focusedInsight:c,completedActions:T,onToggle:te,navigate:i}),y.length>0&&(0,e.jsx)(L,{id:"focus-revenge",title:"Revenge Trading",icon:H,badge:`${y.length} incidents`,severity:"critical",children:(0,e.jsxs)("div",{className:"space-y-3 mt-4",children:[(0,e.jsxs)("p",{className:"text-sm text-slate-400",children:["Streaks of ",w.consecutiveLossLimit+1,"+ consecutive realized losses in one ET trading day. This is a pattern consistent with revenge trading, not proof of intent. Each closed trade is counted once."]}),y.map((t,r)=>(0,e.jsxs)("div",{className:"flex items-center justify-between rounded-xl bg-red-900/20 border border-red-500/25 px-4 py-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"text-sm font-semibold text-red-300",children:[t.day," · ",t.count," losses"]}
1),(0,e.jsx)("div",{className:"text-xs text-slate-400",children:t.symbols}),(0,e.jsxs)("div",{className:"text-xs text-slate-500",children:["Gaps: ",t.timeGaps,t.rapidFire?" · â¡ rapid-fire":""]})]}),(0,e.jsx)("div",{className:"text-lg font-bold text-red-400",children:R(t.totalLoss)})]},r)),(0,e.jsxs)("div",{className:"rounded-xl bg-amber-500/8 border border-amber-500/25 p-3 text-sm text-amber-200",children:[(0,e.jsx)("span",{className:"font-semibold",children:"Rule: "}),w.consecutiveLossLimit," losses â step away. No exceptions."]})]})}),v.length>0&&(0,e.jsx)(L,{id:"focus-overtrading",title:"Overtrading Days",icon:O,badge:`${v.length} days`,severity:"warning",children:(0,e.jsx)("div",{className:"space-y-2 mt-4",children:v.map(t=>(0,e.jsxs)("div",{className:"flex items-center justify-between rounded-xl bg-amber-900/10 border border-amber-500/20 px-4 py-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-sm font-semibold text-white",children:t.day}),(0,e.jsxs)("div",{className:"text-xs text-slate-400",children:[t.count," logged trades; P&L below includes closed trades only"]})]}),(0,e.jsx)("div",{className:`text-base font-bold ${t.pl>=0?"text-emerald-400":"text-red-400"}`,children:R(t.pl)})]},t.day))})}),(0,e.jsxs)(L,{id:"focus-discipline",title:"Discipline Breakdown",icon:M,severity:"success",children:[(0,e.jsx)("p",{className:"text-xs text-slate-400 mt-4 mb-3",children:"These are logging/coverage rates, not a judgment of trade profitability. Missing fields are unknownânot counted as successful behavior."}),(0,e.jsx)("div",{className:"grid grid-cols-2 gap-3 mt-4",children:[{label:"Stop-loss set",pct:p.stopPct},{label:"Rules followed",pct:p.rulesPct},{label:"Setup named",pct:p.setupPct},{label:"Notes added",pct:p.notesPct}].map(({label:t,pct:r})=>{const l=r==null?null:parseInt(r),x=l>=80?"bg-emerald-500":l>=60?"bg-amber-500":"bg-red-500";return(0,e.jsxs)("div",{className:"rounded-xl bg-slate-800/60 border border-slate-700/40 p-4",children:[(0,e.jsxs)("div",{className:"flex justify-between text-xs text-slate-400 mb-2",children:[(0,e.jsx)("span",{children:t}),(0,e.jsx)("span",{className:"font-bold text-white",children:r==null?"Not recorded":`${r}%`})]}),(0,e.jsx)("div",{className:"h-1.5 rounded-full bg-slate-700 overflow-hidden",children:r!=null&&(0,e.jsx)("div",{className:`h-full rounded-full ${x} transition-all`,style:{width:`${r}%`}})}),(0,e.jsx)("div",{className:"text-[11px] text-slate-500 mt-1",children:t==="Rules followed"?`${p.trackedRules} recorded · ${p.unknownRules} unknown`:`${h.length} trades in sample`})]},t)})})]}),(0,e.jsxs)(L,{id:"focus-sessions",title:"Performance by Session",icon:z,severity:"info",children:[(0,e.jsx)("p",{className:"text-xs text-slate-400 mt-4",children:"Sessions use Eastern Time (ET). Win rate and P&L include closed trades only; open positions are counted separately."}),(0,e.jsx)("div",{className:"grid grid-cols-3 gap-3 mt-4",children:[{label:"Pre-market",data:_.premarket},{label:"Regular",data:_.regular},{label:"After-hours",data:_.aftermarket}].map(({label:t,data:r})=>(0,e.jsxs)("div",{className:"rounded-xl bg-slate-800/60 border border-slate-700/40 p-4 text-center",children:[(0,e.jsx)("div",{className:"text-xs text-slate-400 mb-2",children:t}),(0,e.jsxs)("div",{className:`text-xl font-bold ${parseInt(r.wr)>=50?"text-emerald-400":r.wr==="â"?"text-slate-500":"text-red-400"}`,children:[r.wr,r.wr!=="â"?"%":""]}),(0,e.jsxs)("div",{className:"text-xs text-slate-500 mt-1",children:[r.count," closed · ",r.openCount," open"]}),(0,e.jsx)("div",{className:`text-xs font-medium mt-1 ${r.pl>=0?"text-emerald-400":"text-red-400"}`,children:r.count>0?R(r.pl):"â"})]},t))})]}),d.length>0&&(0,e.jsx)(L,{title:"Active Rule Violations",icon:O,badge:`${d.length}`,severity:"critical",defaultOpen:!1,children:(0,e.jsx)("div",{className:"space-y-2 mt-4",children:d.slice(0,8).map(t=>(0,e.jsxs)("div",{className:"flex items-start gap-3 rounded-xl bg-slate-800/60 border border-slate-700/40 px-4 py-3",children:[(0,e.jsx)(O,{className:"w-4 h-4 text-amber-400 flex-shrink-0 mt-0.5"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-sm font-medium text-white",children:t.code}),t.message&&(0,e.jsx)("div",{className:"text-xs text-slate-400 mt-0.5",children:t.message})]})]},t.id))})})]})};export{Oe 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.