1import{o as U}from"./rolldown-runtime-ChpBd9eV.js";import{Ar as N,En as W,F as f,Ft as G,Ka as X,On as K,P as J,Pa as Q,Rt as Z,Tr as ee,Va as te,Vi as C,Wi as u,ba as x,gt as ae,ji as P,ln as F,pn as re,tt as se,wa as R}from"./chat-page-C-flp553.js";import{Et as $}from"./education-page-Buqr-MLV.js";import{t as ie}from"./OnboardingBrokerStep-B3jBJy5l.js";var n=U(X(),1),e=Q(),oe=[{id:"day",label:"Day Trader",desc:"Open and close within the same session"},{id:"swing",label:"Swing Trader",desc:"Hold positions 1â5 days"},{id:"scalper",label:"Scalper",desc:"Multiple quick intraday trades"},{id:"options",label:"Options",desc:"Derivatives and spreads"},{id:"futures",label:"Futures",desc:"Index, commodity, or crypto futures"},{id:"other",label:"Mixed / Other",desc:"Combination or still figuring it out"}],ne=[{pct:1,label:"1%",desc:"Conservative â protect capital above all"},{pct:2,label:"2%",desc:"Standard â recommended for most traders"},{pct:3,label:"3%",desc:"Aggressive â high risk, high reward"},{pct:null,label:"Custom",desc:"Set your own percentage"}],de=[{value:3,label:"3 trades",desc:"High-conviction only"},{value:5,label:"5 trades",desc:"Focused and selective"},{value:10,label:"10 trades",desc:"Active but disciplined"},{value:-1,label:"Unlimited",desc:"No daily cap (advanced)"}];function le({value:r,onChange:o}){return(0,e.jsx)("div",{className:"grid grid-cols-2 gap-3",children:oe.map(i=>(0,e.jsxs)("button",{onClick:()=>o(i.id),className:` 2 relative text-left p-4 rounded-2xl border transition-all 3 ${r===i.id?"border-[#da0b3f] bg-[#da0b3f]/10 ring-1 ring-[#da0b3f]/40":"border-gray-200 dark:border-white/[0.08] bg-gray-50 dark:bg-white/[0.03] hover:border-gray-300 dark:hover:border-white/[0.15] hover:bg-gray-100 dark:hover:bg-white/[0.06]"} 4 `,children:[r===i.id&&(0,e.jsx)("div",{className:"absolute top-3 right-3 w-5 h-5 bg-[#da0b3f] rounded-full flex items-center justify-center",children:(0,e.jsx)(F,{className:"w-3 h-3 text-white"})}),(0,e.jsx)("p",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:i.label}),(0,e.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/50 mt-1 leading-snug",children:i.desc})]},i.id))})}function ce({value:r,customPct:o,onSelect:i,onCustomChange:b}){return(0,e.jsxs)("div",{className:"space-y-3",children:[ne.map(t=>(0,e.jsxs)("button",{onClick:()=>i(t.pct),className:` 5 w-full text-left px-5 py-4 rounded-2xl border flex items-center justify-between transition-all 6 ${r===t.pct?"border-[#da0b3f] bg-[#da0b3f]/10 ring-1 ring-[#da0b3f]/40":"border-gray-200 dark:border-white/[0.08] bg-gray-50 dark:bg-white/[0.03] hover:border-gray-300 dark:hover:border-white/[0.15] hover:bg-gray-100 dark:hover:bg-white/[0.06]"} 7 `,children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:t.label}),(0,e.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/50 mt-0.5",children:t.desc})]}),r===t.pct&&(0,e.jsx)("div",{className:"w-5 h-5 bg-[#da0b3f] rounded-full flex items-center justify-center flex-shrink-0",children:(0,e.jsx)(F,{className:"w-3 h-3 text-white"})})]},t.label)),r===null&&(0,e.jsx)(x.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},className:"overflow-hidden",children:(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)(J,{min:"0.5",max:"20",step:"0.5",value:o,onChange:t=>b(t.target.value),placeholder:"e.g. 2.5",className:"w-full px-5 py-4 rounded-2xl bg-gray-50 dark:bg-white/[0.05] border border-gray-200 dark:border-white/[0.15] text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-white/30 text-sm focus:outline-none focus:border-[#da0b3f]/60 focus:ring-1 focus:ring-[#da0b3f]/40"}),(0,e.jsx)("span",{className:"absolute right-5 top-1/2 -translate-y-1/2 text-white/40 text-sm",children:"%"})]})}),(0,e.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/40 text-center pt-1",children:"Redline will alert you and lock trading when this limit is hit."})]})}function ue({value:r,onChange:o}){return(0,e.jsxs)("div",{className:"space-y-3",children:[de.map(i=>(0,e.jsxs)("button",{onClick:()=>
7o(i.value),className:` 8 w-full text-left px-5 py-4 rounded-2xl border flex items-center justify-between transition-all 9 ${r===i.value?"border-[#da0b3f] bg-[#da0b3f]/10 ring-1 ring-[#da0b3f]/40":"border-gray-200 dark:border-white/[0.08] bg-gray-50 dark:bg-white/[0.03] hover:border-gray-300 dark:hover:border-white/[0.15] hover:bg-gray-100 dark:hover:bg-white/[0.06]"} 10 `,children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:i.label}),(0,e.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/50 mt-0.5",children:i.desc})]}),r===i.value&&(0,e.jsx)("div",{className:"w-5 h-5 bg-[#da0b3f] rounded-full flex items-center justify-center flex-shrink-0",children:(0,e.jsx)(F,{className:"w-3 h-3 text-white"})})]},i.value)),(0,e.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/40 text-center pt-1",children:"Over-trading is the #1 discipline violation. A limit keeps you accountable."})]})}function be(){return(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"grid grid-cols-1 gap-3",children:[{icon:"ð",stat:"23%",desc:"Average P/L improvement after 30 days"},{icon:"ð¯",stat:"41%",desc:"Reduction in rule violations in week 1"},{icon:"ð§ ",stat:"87%",desc:"Traders who track say they feel more in control"}].map(r=>(0,e.jsxs)("div",{className:"flex items-center gap-4 px-5 py-4 rounded-2xl border border-gray-200 dark:border-white/[0.06] bg-gray-50 dark:bg-white/[0.02]",children:[(0,e.jsx)("span",{className:"text-2xl",children:r.icon}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-lg font-bold text-[#da0b3f]",children:r.stat}),(0,e.jsx)("p",{className:"text-xs text-gray-500 dark:text-white/50 leading-snug",children:r.desc})]})]},r.stat))}),(0,e.jsx)("p",{className:"text-xs text-gray-400 dark:text-white/30 text-center pt-1",children:"Your discipline score starts at 100. Every session you'll earn or lose points based on rule adherence. Your first trade starts the journey."})]})}var w=[{id:"style",icon:re,iconColor:"text-blue-400",iconBg:"bg-blue-500/10",title:"What's your trading style?",subtitle:"We personalize violation rules and insights around how you trade."},{id:"loss",icon:ae,iconColor:"text-red-400",iconBg:"bg-red-500/10",title:"Set your max daily loss",subtitle:"Redline can track this limit and show alerts. Any broker action depends on account support and authorization."},{id:"trades",icon:Z,iconColor:"text-amber-400",iconBg:"bg-amber-500/10",title:"Max trades per day",subtitle:"Over-trading is the most common discipline violation. Limit it now."},{id:"broker",icon:G,iconColor:"text-emerald-400",iconBg:"bg-emerald-500/10",title:"Connect your broker",subtitle:"Connect a supported account to sync the history and activity it makes available."},{id:"done",icon:$,iconColor:"text-amber-400",iconBg:"bg-amber-500/10",title:"You're set up for success",subtitle:"Your profile and guardrails are ready. Ten closed trades provide an initial sample for a discipline score."}];function pe({onComplete:r}){const{user:o,patchUser:i}
10=ee(),b=te(),[t,h]=(0,n.useState)(0),[k,T]=(0,n.useState)(!1),[d,I]=(0,n.useState)(null),[g,L]=(0,n.useState)(2),[y,O]=(0,n.useState)(""),[l,D]=(0,n.useState)(5),[_,B]=(0,n.useState)(!1),[A,E]=(0,n.useState)([]),v=(0,n.useRef)(null),c=w.length,m=w[t],M=m.icon,p=g!==null?g:parseFloat(y)||2,j=(0,n.useCallback)(()=>t===0?!!d:t===1?g!==null?!0:parseFloat(y)>0:t===2?l!==null:!0,[t,d,g,y,l]),z=s=>{if(!s||!s.brokerId){h(a=>a+1);return}B(s.brokerId),E(a=>[...a,{brokerId:s.brokerId,accountId:s.accountId||null,lookbackDays:s.lookbackDays??null,importedCount:Number.isFinite(s.imported)?s.imported:0,deferred:!!s.deferred,connectedAt:new Date().toISOString()}]),f.onboardingStepComplete?.(3,"broker",s.brokerId),h(a=>a+1)},Y=async()=>{if(!j())return;if(f.onboardingStepComplete(t,w[t].id,t===0?d:t===1?p:t===2?l:void 0),t<c-1){h(a=>a+1),f.onboardingStepViewed(t+1,w[t+1].id);return}if(!o?.uid){r?.(),b("/dashboard");return}T(!0);const s={onboarding:{completedAt:u(),tradingStyle:d,dailyLossLimitPct:p,maxTradesPerDay:l,brokerConnected:_||!1,brokerConnections:A||[]},guardrails:{dailyLossLimitPct:p,maxTradesPerDay:l,updatedAt:u()},onboardingCompleted:!0,defaultRulesPromptPending:!0,updatedAt:u()};try{await P(C(N,"users",o.uid),s,{merge:!0})}catch(a){console.warn("[OnboardingFlow] users write failed (non-blocking):",a.message)}try{const a={onboardingCompleted:!0,updatedAt:u(),guardrails:{dailyLossLimitPct:p,maxTradesPerDay:l,updatedAt:u()}};d&&(a.tradingStyle=d),await P(C(N,"userProfiles",o.uid),a,{merge:!0})}catch(a){console.warn("[OnboardingFlow] userProfiles write failed (non-blocking):",a.message)}f.onboardingCompleted({tradingStyle:d,dailyLossLimitPct:p,maxTradesPerDay:l,brokerConnected:_||!1});try{localStorage.setItem(`rdl_ob_${o.uid}`,"1")}catch{}i({onboardingCompleted:!0,defaultRulesPromptPending:!0}),r?.(),A.some(a=>a.deferred)?b("/settings/accounts"):b("/dashboard")},V=async()=>{if(!o?.uid){r?.(),b("/dashboard");return}T(!0);const s=Number(o.onboardingSkipCount||0)+1,a=!0;try{await P(C(N,"users",o.uid),{onboardingCompleted:a,onboardingSkipCount:s,onboarding:{skippedAt:u(),completedAt:u(),skipCapReached:!1,brokerOptional:!0},updatedAt:u()},{merge:!0})}catch(S){console.warn("[OnboardingFlow] Skip write failed (non-blocking):",S.message)}f.onboardingSkipped(t);try{localStorage.setItem(`rdl_ob_${o.uid}`,"1")}catch{}try{sessionStorage.removeItem(`rdl_ob_skip_${o.uid}`)}catch{}i({onboardingCompleted:a,onboardingSkipCount:s,defaultRulesPromptPending:!0}),r?.(),b("/dashboard")},q=()=>{if(t===3&&v.current?.brokerView!=="picker"){v.current.goBackToPicker();return}t>0&&h(s=>s-1)},H=(t+1)/c*100;return(0,e.jsx)("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/70 dark:bg-black/90 backdrop-blur-sm px-4",style:{paddingTop:"max(env(safe-area-inset-top, 0px), var(--cap-safe-top, 59px))",paddingBottom:"max(env(safe-area-inset-bottom, 0px), 34px)"},children:(0,e.jsxs)(x.div,{initial:{opacity:0,scale:.96,y:16},animate:{opacity:1,scale:1,y:0},transition:{duration:.3,ease:"easeOut"},className:"relative w-full max-w-md bg-white dark:bg-[#0d0d12] border border-gray-200 dark:border-white/[0.08] rounded-3xl overflow-hidden shadow-2xl flex flex-col",style:{maxHeight:"calc(100dvh - 2rem)"},children:[(0,e.jsx)("div",{className:"h-0.5 w-full bg-gray-100 dark:bg-white/[0.06]",children:(0,e.jsx)(x.div,{className:"h-full bg-[#da0b3f]",animate:{width:`${H}%`},transition:{duration:.4,ease:"easeOut"}})}),t>0&&t<c-1&&(0,e.jsx)("button",{onClick:q,className:"absolute top-5 left-5 text-gray-400 dark:text-white/30 hover:text-gray-700 dark:hover:text-white/60 transition-colors z-10","aria-label":"Go back",children:(0,e.jsx)(K,{className:"w-5 h-5"})}),t<c-1&&(0,e.jsx)("button",{onClick:V,className:"absolute top-5 right-5 text-gray-300 dark:text-white/30 hover:text-gray-600 dark:hover:text-white/60 transition-colors z-10","aria-label":"Skip onboarding",children:(0,e.jsx)(se,{className:"w-5 h-5"})}),(0,e.jsxs)("div",{className:"absolute top-5 text-xs text-gray-400 dark:text-white/30 font-medium z-10 tabular-nums",style:{left:t>0&&t<c-1?"50%":"1.25rem",transform:t>0&&t<c-1?"translateX(-50%)":"none"},children:[t+1," / ",c]}),(0,e.jsxs)("div",{className:"px-6 pb-6 pt-14 overflow-y-auto flex-1",children:[(0,e.jsx)("div",{className:`w-14 h-14 roun
10ded-2xl ${m.iconBg} flex items-center justify-center mb-5`,children:(0,e.jsx)(M,{className:`w-7 h-7 ${m.iconColor}`})}),(0,e.jsx)(R,{mode:"wait",children:(0,e.jsxs)(x.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.25},className:"mb-6",children:[(0,e.jsx)("h2",{className:"text-xl font-bold text-gray-900 dark:text-white leading-snug mb-1.5",children:m.title}),(0,e.jsx)("p",{className:"text-sm text-gray-500 dark:text-white/50 leading-relaxed",children:m.subtitle})]},`heading-${t}`)}),(0,e.jsx)(R,{mode:"wait",children:(0,e.jsxs)(x.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.25},children:[t===0&&(0,e.jsx)(le,{value:d,onChange:I}),t===1&&(0,e.jsx)(ce,{value:g,customPct:y,onSelect:L,onCustomChange:O}),t===2&&(0,e.jsx)(ue,{value:l,onChange:D}),t===3&&(0,e.jsx)(ie,{ref:v,userId:o?.uid,onComplete:z,onSkip:()=>h(s=>s+1)}),t===4&&(0,e.jsx)(be,{})]},`content-${t}`)}),t!==3&&(0,e.jsx)(x.button,{layout:!0,onClick:Y,disabled:!j()||k,className:` 11 mt-6 w-full flex items-center justify-center gap-2 py-4 rounded-2xl font-semibold text-sm transition-all 12 ${j()&&!k?"bg-[#da0b3f] hover:bg-[#c0082f] text-white":"bg-white/[0.06] text-white/30 curs
12or-not-allowed"} 13 `,children:k?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Savingâ¦"]}):t===c-1?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)($,{className:"w-4 h-4"}),"Start Trading"]}):(0,e.jsxs)(e.Fragment,{children:["Continue",(0,e.jsx)(W,{className:"w-4 h-4"})]})})]})]})})}export{pe 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.