1import{o as we,r as Ce}from"./rolldown-runtime-ChpBd9eV.js";import{Dn as Se,Ga as Re,It as _e,Ka as We,Mt as ke,P as oe,Pa as Ve,Tr as ze,Vt as Be,ba as z,bn as He,cn as ce,mn as Ye,pn as G,qn as ae,rn as Te,tt as Ee,ut as de,wa as q}from"./chat-page-C-flp553.js";import{Lc as Ge,Yc as Ke,au as qe,cl as Le,gc as Xe,mc as $e,ou as F,po as Ze,qc as xe,su as ee,vc as Qe,zc as Je}from"./market-core-B8Bfud51.js";import{$n as et,C as tt,er as me,f as Y,w as ue,y as st}from"./community-page-dub7UFXa.js";import{Rt as pe,ct as at}from"./education-page-Buqr-MLV.js";import{Q as lt,d as rt,i as he}from"./icons-vendor-DpKLKbbD.js";import{a as le,c as nt,d as it,g as ot,h as ct,i as dt,l as xt,m as mt,n as ut,o as pt,p as ht,s as bt,u as ft}from"./chartjs-vendor-CJ58C3gX.js";var c=we(We(),1),e=Ve(),Qt=({selectedAccountId:t,onSelect:a,showCreateOption:s=!0,className:o=""})=>{const{user:x}=ze(),{allMemberships:r,fetchAllMemberships:d}=qe(),[m,w]=(0,c.useState)([]),[j,S]=(0,c.useState)(!1),[k,T]=(0,c.useState)(!0),[I,y]=(0,c.useState)(!1),$=(0,c.useCallback)(async()=>{if(!x?.uid){w([]),T(!1);return}T(!0);try{let h=await ee.getUserAccounts(x.uid);const C=new Map;if(h.forEach(i=>{C.has(i.id)||C.set(i.id,i)}),h=Array.from(C.values()),h.length===0){const i=await ee.ensurePersonalAccount(x.uid,x.displayName||"My");i&&(h=[i])}const D=await d(x.uid),A=new Set(h.filter(i=>i.type===F.ORG_LINKED).map(i=>i.organizationId));for(const{org:i}of D)if(!(!i||i.isActive===!1)&&!A.has(i.id)){console.log(`Creating missing org-linked account for ${i.name}`);try{const N=await ee.createOrgLinkedAccount(x.uid,i.id,i.name);N&&(h.push(N),A.add(i.id))}catch(N){console.error(`Failed to create org account for ${i.name}:`,N)}}const M=new Set(D.filter(({org:i})=>i&&i.isActive!==!1).map(({org:i})=>i.id)),n=new Map,g=new Set;h.forEach(i=>{if(i.type===F.ORG_LINKED){if(i.organizationId&&!M.has(i.organizationId))return;g.has(i.organizationId)||(g.add(i.organizationId),n.set(i.id,i))}else n.has(i.id)||n.set(i.id,i)});const b=Array.from(n.values());if(w(b),!t&&b.length>0){const i=h.find(N=>N.isDefault)||h[0];i&&a(i.id)}}catch(h){console.error("Error loading accounts:",h)}T(!1)},[x?.uid,x?.displayName,t,a,d]);(0,c.useEffect)(()=>{$()},[$]);const L=m.find(h=>h.id===t),p=h=>{a(h),S(!1)},f=h=>h.type===F.ORG_LINKED?(0,e.jsx)($e,{className:"w-4 h-4 text-blue-400","aria-hidden":"true"}):(0,e.jsx)(Le,{className:"w-4 h-4 text-slate-400","aria-hidden":"true"});return k?(0,e.jsx)("div",{className:`px-4 py-2 bg-slate-800 rounded-lg border border-slate-700 ${o}`,children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"w-4 h-4 border-2 border-slate-400 border-t-white rounded-full animate-spin"}),(0,e.jsx)("span",{className:"text-sm text-slate-400","aria-live":"polite",children:"Loading accountsâ¦"})]})}):(0,e.jsxs)("div",{className:`relative ${o}`,children:[(0,e.jsxs)("button",{type:"button","aria-expanded":j,"aria-haspopup":"listbox",onClick:()=>S(!j),className:"flex min-h-11 w-full touch-manipulation items-center gap-3 rounded-lg border border-slate-700 bg-slate-800 px-4 py-2.5 transition-colors hover:bg-slate-700 focus-visible:ring-2 focus-visible:ring-blue-400",children:[L?(0,e.jsxs)(e.Fragment,{children:[f(L),(0,e.jsxs)("div",{className:"flex-1 text-left min-w-0",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-white truncate",children:L.name}),L.type===F.ORG_LINKED&&(0,e.jsxs)("p",{className:"text-xs text-blue-400 truncate flex items-center gap-1",children:[(0,e.jsx)(Ge,{className:"w-3 h-3","aria-hidden":"true"}),L.organizationName]}),L.type===F.PERSONAL&&(0,e.jsxs)("p",{className:"text-xs text-slate-500 flex items-center gap-1",children:[(0,e.jsx)(Je,{className:"w-3 h-3","aria-hidden":"true"}),"Personal (Private)"]})]})]}):(0,e.jsx)("span",{className:"text-sm text-slate-400",children:"Select account"}),(0,e.jsx)(Qe,{"aria-hidden":"true",className:`w-4 h-4 text-slate-400 transition-transform ${j?"rotate-180":""}`})]}),(0,e.jsx)(q,{children:j&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button","aria-label":"Close account menu",className:"fixed inset-0 z-40 cursor-default",onClick:()=>S(!1)}),(0,e.jsxs)(z.div,{role:"listbox","aria-label":"Trading accounts",initial:{opacity:0,y:-10,scale:.95}
1,animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:.95},transition:{duration:.15},className:"absolute top-full left-0 right-0 mt-2 bg-slate-800 border border-slate-700 rounded-xl shadow-xl z-50 overflow-hidden",children:[(0,e.jsx)("div",{className:"px-4 py-2.5 border-b border-slate-700 bg-slate-800/50",children:(0,e.jsx)("p",{className:"text-xs font-medium text-slate-400 uppercase tracking-wider",children:"Trading Accounts"})}),(0,e.jsxs)("div",{className:"py-1",children:[(0,e.jsx)("div",{className:"px-4 py-1.5 text-xs font-medium text-slate-500",children:"Personal"}),m.filter(h=>h.type===F.PERSONAL).map(h=>(0,e.jsx)(be,{account:h,isSelected:t===h.id,onSelect:()=>p(h.id)},h.id)),m.filter(h=>h.type===F.PERSONAL).length===0&&(0,e.jsx)("div",{className:"px-4 py-2 text-sm text-slate-500",children:"No personal accounts"})]}),m.filter(h=>h.type===F.ORG_LINKED).length>0?(0,e.jsxs)("div",{className:"py-1 border-t border-slate-700",children:[(0,e.jsx)("div",{className:"px-4 py-1.5 text-xs font-medium text-slate-500",children:"Organization Linked"}),m.filter(h=>h.type===F.ORG_LINKED).map(h=>(0,e.jsx)(be,{account:h,isSelected:t===h.id,onSelect:()=>p(h.id)},h.id))]}):r&&r.length>0?(0,e.jsxs)("div",{className:"py-1 border-t border-slate-700",children:[(0,e.jsx)("div",{className:"px-4 py-1.5 text-xs font-medium text-slate-500",children:"Organization Linked"}),(0,e.jsxs)("div",{className:"px-4 py-2 text-sm text-slate-400",children:[(0,e.jsxs)("p",{className:"mb-2",children:["You have ",r.length," org membership(s) but no linked accounts."]}),(0,e.jsx)("button",{type:"button",onClick:async()=>{y(!0),await $(),y(!1)},disabled:I,className:"text-blue-400 hover:text-blue-300 text-sm flex items-center gap-2",children:I?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Ke,{className:"w-3 h-3 animate-spin","aria-hidden":"true"}),"Creatingâ¦"]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(xe,{className:"w-3 h-3","aria-hidden":"true"}),"Create org accounts"]})})]})]}):null,s&&(0,e.jsx)("div",{className:"border-t border-slate-700",children:(0,e.jsxs)("button",{type:"button",onClick:()=>{S(!1)},className:"w-full px-4 py-3 flex items-center gap-3 text-blue-400 hover:bg-blue-500/10 transition-colors",children:[(0,e.jsx)(xe,{className:"w-4 h-4","aria-hidden":"true"}),(0,e.jsx)("span",{className:"text-sm font-medium",children:"Add New Account"})]})})]})]})})]})},be=({account:t,isSelected:a,onSelect:s})=>{const o=()=>t.type===F.ORG_LINKED?(0,e.jsx)($e,{className:"w-5 h-5 text-blue-400","aria-hidden":"true"}):(0,e.jsx)(Le,{className:"w-5 h-5 text-slate-400","aria-hidden":"true"});return(0,e.jsxs)("button",{type:"button",onClick:s,role:"option","aria-selected":a,className:`w-full px-4 py-3 flex items-center gap-3 hover:bg-slate-700/50 transition-colors focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-blue-400 ${a?"bg-blue-500/10 border-l-2 border-blue-500":""}`,children:[o(),(0,e.jsxs)("div",{className:"flex-1 text-left min-w-0",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-white truncate",children:t.name}),t.type===F.ORG_LINKED&&(0,e.jsx)("p",{className:"text-xs text-blue-400 truncate",children:t.organizationName}),t.type===F.PERSONAL&&(0,e.jsx)("p",{className:"text-xs text-slate-500",children:"Private"})]}),t.isDefault&&(0,e.jsx)("span",{className:"px-2 py-0.5 text-xs font-medium rounded bg-slate-700 text-slate-300",children:"Default"}),a&&(0,e.jsx)(Xe,{className:"w-4 h-4 text-blue-400 flex-shrink-0","aria-hidden":"true"})]})},gt=we(Re(),1),te=[{value:"America/New_York",label:"New York (ET)",abbr:"ET"},{value:"America/Chicago",label:"Chicago (CT)",abbr:"CT"},{value:"America/Denver",label:"Denver (MT)",abbr:"MT"},{value:"America/Los_Angeles",label:"Los Angeles (PT)",abbr:"PT"},{value:"America/Toronto",label:"Toronto (ET)",abbr:"ET"},{value:"America/Sao_Paulo",label:"São Paulo (BRT)",abbr:"BRT"},{value:"Europe/London",label:"London (GMT/BST)",abbr:"GMT"},{value:"Europe/Paris",label:"Paris / Frankfurt (CET)",abbr:"CET"},{value:"Asia/Dubai",label:"Dubai (GST)",abbr:"GST"},{value:"Asia/Singapore",label:"Singapore (SGT)",abbr:"SGT"},{value:"Asia/Tokyo",label:"Tokyo (JST)",abbr:"JST"},{value:"Asia/Shanghai",label:"Shanghai (CST)",abbr:"CST"},{value:"Australia/Sydney",label:"Sydney (AEDT)",abbr:"AET"},{value:"UTC",label:"UTC",abbr:"UTC"}],Me=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],jt=[{id:"pre",label:"Pre-market",start:240,end:570,color:"#f59e0b",startLabel:"04:00",endLabel:"09:30"},{id:"regular",label:"Regular",start:570,end:960,color:"#10b981",startLabel:"09:30",endLabel:"16:00"},{id:"after",label:"After-hours",start:960,end:1200,color:"#8b5cf6",startLabel:"16:00",endLabel:"20:00"}],X=[{id:"sydney",label:"Sydney",flag:"ð¦ðº",startUTC:1320,endUTC:420,color:"#2dd4bf",wraps:!0,totalMins:540},{id:"tokyo",label:"Tokyo",flag:"ð¯ðµ",startUTC:0,endUTC:540,color:"#fb923c",wraps:!1,totalMins:540},{id:"london",label:"London",flag:"ð¬ð§",startUTC:480,endUTC:1020,color:"#60a5fa",wraps:!1,totalMins:540},{id:"new_york",label:"New York",flag:"ðºð¸",startUTC:720,endUTC:1260,color:"#a78bfa",wraps:!1,totalMins:540}],fe="marketClock_timezone";function W(t){return String(t).padStart(2,"0")}function re(t){const a=Math.max(0,Math.floor(t)),s=Math.floor(a/3600),o=Math.floor(a%3600/60),x=a%60;return s>0?`${W(s)}:${W(o)}:${W(x)}`:`${W(o)}:${W(x)}`}function Nt(t){const a=Math.max(0,Math.floor(t));return{h:W(Math.floor(a/3600)),m:W(Math.floor(a%3600/60)),sec:W(a%60)}}function yt(t,a){const s=new Intl.DateTimeFormat("en-US",{timeZone:a,hour:"numeric",minute:"numeric",hour12:!1}).formatToParts(t),o=parseInt(s.find(r=>r.type==="hour")?.value??"0",10),x=parseInt(s.find(r=>r.type==="minute")?.value??"0",10);return o*60+x}function vt(t,a){const s=new Intl.DateTimeFormat("en-US",{timeZone:a,weekday:"short"}).formatToParts(t).find(o=>o.type==="weekday")?.value??"Sun";return Me.indexOf(s.slice(0,3))}function wt(t,a){return new Intl.DateTimeFormat("en-US",{timeZone:a,hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(t)}function Ct(t,a){return new Intl.DateTimeFormat("en-US",{timeZone:a,weekday:"long",month:"short",day:"numeric"}).format(t)}
1function ge(t){const a=vt(t,"America/New_York"),s=yt(t,"America/New_York"),o=t.getSeconds(),x=t.getUTCDay(),r=t.getUTCHours()*60+t.getUTCMinutes(),d=t.getUTCSeconds(),m=et(t),w=!!m?.fullClose,j=!!m?.earlyClose13ET,S=j?[{id:"pre",label:"Pre-market",start:240,end:570,color:"#f59e0b",startLabel:"04:00",endLabel:"09:30"},{id:"regular",label:"Regular",start:570,end:780,color:"#10b981",startLabel:"09:30",endLabel:"13:00"},{id:"after",label:"After-hours",start:780,end:1020,color:"#8b5cf6",startLabel:"13:00",endLabel:"17:00"}]:jt,k=a===0||a===6,T=k||w;let I=null,y=0,$="",L=0;if(T){let n=1440-s+240,g=new Date(t.getTime()+(1440-s)*60*1e3);for(;me(g);)n+=1440,g=new Date(g.getTime()+1440*60*1e3);y=(n-1)*60+(60-o),$="Pre-market opens in"}else{for(const n of S)if(s>=n.start&&s<n.end){I=n,y=(n.end-s-1)*60+(60-o),$="Closes in",L=Math.min(1,Math.max(0,(s-n.start)/(n.end-n.start)));break}if(!I){const n=S.find(g=>g.start>s);if(n)y=(n.start-s-1)*60+(60-o),$=`${n.label} opens in`;else{let g=1440-s+240,b=new Date(t.getTime()+(1440-s)*60*1e3);for(;me(b);)g+=1440,b=new Date(b.getTime()+1440*60*1e3);y=(g-1)*60+(60-o),$="Pre-market opens in"}}}const p=x===6||x===5&&r>=1260||x===0&&r<1320,f=[],h=[];if(!p){for(const n of X)if(n.wraps?r>=n.startUTC||r<n.endUTC:r>=n.startUTC&&r<n.endUTC){f.push(n);let g,b;n.wraps?r>=n.startUTC?(g=n.endUTC+1440-r,b=r-n.startUTC):(g=n.endUTC-r,b=r+(1440-n.startUTC)):(g=n.endUTC-r,b=r-n.startUTC);const i=Math.max(0,(g-1)*60+(60-d)),N=Math.min(1,Math.max(0,b/n.totalMins));h.push({...n,countdownSec:i,progress:N,remMins:g})}}const C=p?[]:X.filter(n=>!f.some(g=>g.id===n.id)).map(n=>{const g=(n.startUTC>r?n.startUTC:n.startUTC+1440)-r;return{...n,opensInMins:g,opensInSec:Math.max(0,(g-1)*60+(60-d))}}).sort((n,g)=>n.opensInMins-g.opensInMins),D=f.some(n=>n.id==="london")&&f.some(n=>n.id==="new_york");let A=0,M="";if(p){let n;x===0&&r<1320?n=1320-r:x===6?n=1440-r+1320:n=(7-x)*1440+1320-r,A=Math.max(0,(n-1)*60+(60-d)),M="Forex opens in"}else if(h.length>0){const n=h.reduce((g,b)=>g.countdownSec<b.countdownSec?g:b);A=n.countdownSec,M=`${n.label} closes in`}else C.length>0&&(A=C[0].opensInSec,M=`${C[0].label} opens in`);return{us:{session:I,isWeekend:k,isHoliday:w,isEarlyClose:j,holidayName:m?.name||null,etMins:s,etDay:a,countdownSec:y,countdownLabel:$,progress:L,sessions:S},forex:{activeSessions:f,sessionData:h,upcomingSessions:C,isWeekend:p,isOverlap:D,utcMins:r,utcDay:x,countdownSec:A,countdownLabel:M},etDay:a}}function K({color:t="#10b981",size:a="sm"}){const s=a==="lg"?"h-2.5 w-2.5":"h-2 w-2";return(0,e.jsxs)("span",{className:`relative flex ${s} flex-shrink-0`,children:[(0,e.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-50",style:{backgroundColor:t}}),(0,e.jsx)("span",{className:`relative inline-flex rounded-full ${s}`,style:{backgroundColor:t}})]})}function je({label:t,countdownSec:a,color:s,sublabel:o}){const{h:x,m:r,sec:d}=Nt(a);return(0,e.jsxs)("div",{className:"rounded-2xl p-4 mb-4",style:{background:s+"10",border:`1px solid ${s}25`},children:[o&&(0,e.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-1.5",style:{color:s+"aa"},children:o}),(0,e.jsx)("div",{className:"text-[11px] text-slate-400 mb-2",children:t}),(0,e.jsxs)("div",{className:"flex items-end gap-2",children:[(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("div",{className:"font-mono text-[28px] font-bold tabular-nums leading-none",style:{color:s},children:x}),(0,e.jsx)("div",{className:"text-[9px] text-slate-600 uppercase tracking-widest mt-1",children:"hr"})]}),(0,e.jsx)("div",{className:"text-slate-700 text-2xl font-bold leading-none mb-1",children:":"}),(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("div",{className:"font-mono text-[28px] font-bold tabular-nums leading-none",style:{color:s},children:r}),(0,e.jsx)("div",{className:"text-[9px] text-slate-600 uppercase tracking-widest mt-1",children:"min"})]}),(0,e.jsx)("div",{className:"text-slate-700 text-2xl font-bold leading-none mb-1",children:":"}),(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("div",{className:"font-mono text-[28px] font-bold tabular-nums leading-none",style:{color:s},children:d}),(0,e.jsx)("div",{className:"text-[9px] text-slate-600 uppercase tracking-widest mt-1",children:"sec"})]})]})]})}function Ie({progress:t,color:a,startLabel:s,endLabel:o}){return(0,e.jsxs)("div",{className:"mb-1",children:[(0,e.jsx)("div",{className:"h-1.5 bg-white/[0.06] rounded-full overflow-hidden",children:(0,e.jsx)(z.div,{className:"h-full rounded-full",style:{backgroundColor:a},initial:!1,animate:{width:`${Math.max(0,Math.min(1,t))*100}%`},transition:{duration:1,ease:"linear"}})}),s&&(0,e.jsxs)("div",{className:"flex justify-between text-[9px] text-slate-600 mt-1",children:[(0,e.jsx)("span",{children:s}),(0,e.jsx)("span",{children:o})]})]})}function St({data:t,isOverlap:a}){const s=W(Math.floor((t.wraps,t.endUTC/60)));return(0,e.jsxs)("div",{className:"rounded-xl p-3 mb-2.5 last:mb-0",style:{background:t.color+"0d",border:`1px solid ${t.color}28`},children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-2.5",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,e.jsx)(K,{color:t.color}),(0,e.jsxs)("span",{className:"text-sm font-semibold text-white truncate",children:[t.flag," ",t.label]}),a&&(0,e.jsx)("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-emerald-500/15 text-emerald-400 border border-emerald-500/20 font-semibold flex-shrink-0",children:"Overlap"})]}),(0,e.jsxs)("div",{className:"text-right flex-shrink-0 ml-2",children:[(0,e.jsx)("div",{className:"font-mono text-[14px] font-bold tabular-nums",style:{color:t.color},children:re(t.countdownSec)}),(0,e.jsx)("div",{className:"text-[9px] text-slate-600",children:"closes in"})]})]}),(0,e.jsx)(Ie,{progress:t.progress,color:t.color,startLabel:`${W(Math.floor(t.startUTC/60))}:00 UTC`,endLabel:`${s}:00 UTC${t.wraps?"+1":""}`})]})}function kt({data:t}){return(0,e.jsxs)("div",{className:"flex items-center justify-between py-2 border-b border-white/[0.04] last:border-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-slate-700"}),(0,e.jsxs)("span",{className:"text-[12px] text-slate-500",children:[t.flag," ",t.label]})]}),(0,e.jsxs)("div",{className:"text-right",children:[(0,e.jsx)("div",{className:"text-[11px] font-mono text-slate-400",children:re(t.opensInSec)}),(0,e.jsx)("div",{className:"text-[9px] text-slate-600",children:"opens in"})]})]})}function Tt({utcMins:t,activeSessions:a}){return(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"relative h-7 rounded-lg overflow-hidden bg-white/[0.04]",children:[X.map(s=>{const o=a.some(x=>x.id===s.id);return s.wraps?(0,e.jsxs)(c.Fragment,{children:[(0,e.jsx)("div",{className:"absolute top-0 h-full rounded-none",style:{left:`${s.startUTC/1440*100}%`,width:`${(1440-s.startUTC)/1440*100}%`,backgroundColor:s.color,opacity:o?.4:.12}}),(0,e.jsx)("div",{className:"absolute top-0 h-full",style:{left:0,width:`${s.endUTC/1440*100}%`,backgroundColor:s.color,opacity:o?.4:.12}})]},s.id):(0,e.jsx)("div",{className:"absolute top-0 h-full",style:{left:`${s.startUTC/1440*100}%`,width:`${(s.endUTC-s.startUTC)/1440*100}%`,backgroundColor:s.color,opacity:o?.4:.12}},s.id)}),[6,12,18].map(s=>(0,e.jsx)("div",{className:"absolute top-0 bottom-0 w-px bg-white/[0.07]",style:{left:`${s/24*100}%`}},s)),(0,e.jsx)("div",{className:"absolute top-0 bottom-0 w-0.5 bg-white/80 rounded-full shadow-[0_0_4px_rgba(255,255,255,0.5)]",style:{left:`${t/1440*100}%`}})]}),(0,e.jsxs)("div",{className:"flex justify-between text-[9px] text-slate-700 mt-1 px-0.5",children:[(0,e.jsx)("span",{children:"00"}),(0,e.jsx)("span",{children:"06"}),(0,e.jsx)("span",{children:"12"}),(0,e.jsx)("span",{children:"18"}),(0,e.jsx)("span",{children:"24"})]}),(0,e.jsx)("div",{className:"flex flex-wrap gap-x-3 gap-y-0.5 mt-1.5",children:X.map(s=>{const o=a.some(x=>x.id===s.id);return(0,e.jsxs)("div",{className:"flex items-center gap-1 text-[9px]",style:{color:o?s.color:"#475569"},children:[(0,e.jsx)("span",{className:"w-2 h-1.5 rounded-sm inline-block",style:{backgroundColor:s.color,opacity:o?1:.35}}),s.flag," ",s.label]},s.id)})})]})}function Et({day:t,dayIdx:a,etDay:s,todayIsHoliday:o,todayIsEarlyClose:x,holidayName:r}){const d=a===s;return(0,e.jsxs)("div",{className:`flex items-center justify-between py-1.5 border-b border-white/[0.04] last:border-0 ${d?"bg-white/[0.04] -mx-3 px-3 rounded-lg":""}`,children:[(0,e.jsx)("span",{className:`text-[12px] font-medium w-10 ${d?"text-white":"text-slate-400"}`,children:t}),a===0||a===6?(0,e.jsx)("span",{className:"text-[11px] text-red-400/60",children:"Closed"}):d&&o?(0,e.jsxs)("span",{className:"text-[11px] text-red-400/80 font-semibold",children:["Closed · ",r]}):d&&x?(0,e.jsxs)("div",{className:"flex flex-col items-end gap-px",children:[(0,e.jsx)("span",{className:"text-[10px] text-amber-400/80",children:"04:00 â 09:29 ET"}),(0,e.jsxs)("span",{className:"text-[10px] text-emerald-400/90",children:["09:30 â 13:00 ET ",(0,e.jsx)("span",{className:"text-amber-300",children:"(early close)"})]}),(0,e.jsx)("span",{className:"text-[10px] text-purple-400/80",children:"13:00 â 17:00 ET"})]}):(0,e.jsxs)("div",{className:"flex flex-col items-end gap-px",children:[(0,e.jsx)("span",{className:"text-[10px] text-amber-400/80",children:"04:00 â 09:29 ET"}),(0,e.jsx)("span",{className:"text-[10px] text-emerald-400/90",children:"09:30 â 16:00 ET"}),(0,e.jsx)("span",{className:"text-[10px] text-purple-400/80",children:"16:00 â 20:00 ET"})]})]})}function Lt({compact:t=!1}){const[a,s]=(0,c.useState)(()=>ge(new Date)),[o,x]=(0,c.useState)(()=>new Date),[r,d]=(0,c.useState)(!1),[m,w]=(0,c.useState)("us"),[j,S]=(0,c.useState)(()=>
1{try{return localStorage.getItem(fe)||"America/New_York"}catch{return"America/New_York"}}),[k,T]=(0,c.useState)(""),[I,y]=(0,c.useState)(!1),$=(0,c.useRef)(null);(0,c.useEffect)(()=>{const l=setInterval(()=>{const v=new Date;x(v),s(ge(v))},1e3);return()=>clearInterval(l)},[]);const L=(0,c.useCallback)(l=>{S(l);try{localStorage.setItem(fe,l)}catch{}y(!1),T("")},[]),{us:p,forex:f}=a,h=te.find(l=>l.value===j)||te[0],C=wt(o,j),D=Ct(o,j),A=p.session?.color??"#64748b",M=p.session?p.session.label:p.isHoliday?`Closed · ${p.holidayName}`:p.isWeekend?"Weekend":"Closed",n=f.isWeekend?"#64748b":f.isOverlap?"#10b981":f.activeSessions[0]?.color??"#64748b",g=te.filter(l=>l.label.toLowerCase().includes(k.toLowerCase())||l.abbr.toLowerCase().includes(k.toLowerCase())),b=()=>{const l=typeof window<"u"?window.innerWidth:400,v=typeof window<"u"?window.innerHeight:800,U=8,P=Math.min(400,l-U*2),_=$.current?.getBoundingClientRect();if(!_)return{top:68,left:U,width:P};const H=Math.max(U,Math.min(_.bottom+8,v-200)),V=_.right-P;return{top:H,left:Math.max(U,Math.min(V,l-P-U)),width:P}},i=(0,e.jsxs)("button",{ref:$,onClick:()=>d(l=>!l),className:`inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-full text-[11px] font-semibold border transition-all hover:opacity-90 focus:outline-none focus:ring-2 focus:ring-white/20 ${p.session?.id==="regular"?"bg-emerald-500/10 border-emerald-500/25 text-emerald-400":p.session?.id==="pre"?"bg-amber-500/10 border-amber-500/25 text-amber-400":p.session?.id==="after"?"bg-purple-500/10 border-purple-500/25 text-purple-400":"bg-slate-500/10 border-slate-500/25 text-slate-400"}`,"aria-label":"Market clock",children:[(0,e.jsx)(K,{color:A}),(0,e.jsx)("span",{className:"hidden xs:inline",children:M}),p.session&&(0,e.jsx)("span",{className:"hidden sm:inline font-mono text-[10px] opacity-70",children:re(Math.max(0,p.countdownSec))}),(0,e.jsx)(ce,{className:`w-3 h-3 opacity-60 transition-transform ${r?"rotate-180":""}`})]});if(t)return i;const N=(0,e.jsx)(q,{children:r&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(z.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},transition:{duration:.12},className:"fixed inset-0 z-[8998]",onClick:()=>{d(!1),y(!1)}},"mcw-bd"),(0,e.jsxs)(z.div,{initial:{opacity:0,scale:.95,y:-6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:-6},transition:{type:"spring",damping:26,stiffness:360,mass:.65},className:"fixed z-[8999] bg-[#0e1117] border border-white/[0.09] rounded-2xl shadow-2xl flex flex-col",style:{...b(),maxHeight:"calc(100vh - 80px)"},children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-5 pt-4 pb-3 border-b border-white/[0.07] flex-shrink-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(Te,{className:"w-4 h-4 text-blue-400"}),(0,e.jsx)("span",{className:"text-[13px] font-semibold text-white",children:"Market Clock"})]}),(0,e.jsxs)("div",{className:"relative flex items-center gap-1",children:[(0,e.jsxs)("button",{onClick:l=>{l.stopPropagation(),y(v=>!v)},className:"flex items-center gap-1 text-[11px] text-slate-400 hover:text-white px-2 py-1 rounded-lg hover:bg-white/[0.05] transition",children:[(0,e.jsx)(Be,{className:"w-3.5 h-3.5"}),(0,e.jsx)("span",{children:h.abbr}),(0,e.jsx)(ce,{className:`w-3 h-3 transition-transform ${I?"rotate-180":""}`})]}),(0,e.jsx)(q,{children:I&&(0,e.jsxs)(z.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.1},className:"absolute right-0 top-full mt-1 w-60 bg-[#1a1f2e] border border-white/[0.09] rounded-xl shadow-xl z-20 overflow-hidden",onClick:l=>l.stopPropagation(),children:[(0,e.jsx)("div",{className:"px-2 pt-2 pb-1",children:(0,e.jsx)("input",{autoFocus:!0,value:k,onChange:l=>T(l.target.value),placeholder:"Search timezoneâ¦",className:"w-full px-2.5 py-1.5 bg-white/[0.05] border border-white/[0.08] rounded-lg text-[11px] text-white placeholder-slate-600 focus:outline-none focus:ring-1 focus:ring-blue-500/50"})}),(0,e.jsx)("div",{className:"max-h-44 overflow-y-auto py-1",children:g.map(l=>(0,e.jsxs)("button",{onClick:()=>L(l.value),className:`w-full text-left px-3 py-1.5 text-[11px] hover:bg-white/[0.05] flex items-center justify-between transition ${j===l.value?"text-blue-400 bg-blue-500/[0.07]":"text-slate-300"}`,children:[(0,e.jsx)("span",{children:l.label}),j===l.value&&(0,e.jsx)("span",{className:"text-[9px]",children:"â"})]},l.value))})]},"tz")}),(0,e.jsx)("button",{onClick:()=>d(!1),className:"p-1.5 rounded-lg hover:bg-white/[0.06] text-slate-500 hover:text-white transition",children:(0,e.jsx)(Ee,{className:"w-4 h-4"})})]})]}),(0,e.jsxs)("div",{className:"px-5 pt-4 pb-3 text-center border-b border-white/[0.05] flex-shrink-0",children:[(0,e.jsx)("div",{className:"font-mono text-[32px] font-bold text-white tabular-nums tracking-tight leading-none",children:C}),(0,e.jsxs)("div",{className:"text-[11px] text-slate-500 mt-1",children:[D," · ",h.label]})]}),(0,e.jsx)("div",{className:"flex mx-5 mt-4 mb-3 bg-white/[0.04] rounded-xl p-0.5 flex-shrink-0",children:[{id:"us",label:"ðºð¸ US Equities"},{id:"forex",label:"ð± Forex"}].map(l=>(0,e.jsx)("button",{onClick:()=>w(l.id),className:`flex-1 py-1.5 rounded-[10px] text-[11px] font-semibold transition-all ${m===l.id?"bg-white/[0.09] text-white shadow":"text-slate-500 hover:text-slate-300"}`,children:l.label},l.id))}),(0,e.jsxs)("div",{className:"overflow-y-auto flex-1 px-5 pb-5",children:[m==="us"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,e.jsx)(K,{color:A,size:"lg"}),(0,e.jsx)("span",{className:"text-sm font-semibold text-white",children:M}),!p.isWeekend&&!p.isHoliday&&(0,e.jsx)("span",{className:"ml-auto text-[11px] text-slate-500",children:p.countdownLabel})]}),(p.isHoliday||p.isEarlyClose)&&(0,e.jsxs)("div",{className:"rounded-xl p-3 mb-4 flex items-start gap-2",style:{background:p.isHoliday?"#ef444412":"#f59e0b12",border:`1px solid ${p.isHoliday?"#ef4444":"#f59e0b"}30`},children:[(0,e.jsx)("span",{className:"text-base leading-none mt-0.5",children:p.isHoliday?"ð":"â°"}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:`text-[12px] font-semibold ${p.isHoliday?"text-red-300":"text-amber-300"}`,children:p.isHoliday?`Markets closed today â ${p.holidayName}`:`Early close 13:00 ET â ${p.holidayName}`}),(0,e.jsx)("div",{className:"text-[11px] text-slate-400 mt-0.5",children:p.isHoliday?"Regular trading resumes the next business day at 09:30 ET.":"Regular session ends at 13:00 ET; after-hours runs 13:00â17:00 ET."})]})]}),(0,e.jsx)(je,{label:p.countdownLabel,countdownSec:p.countdownSec,color:A,sublabel:p.session?`${p.session.label} session`:p.isHoliday?p.holidayName:p.isWeekend?"Weekend":"US Markets"}),p.session&&(0,e.jsx)(Ie,{progress:p.progress,color:p.session.color,startLabel:`${p.session.startLabel} ET`,endLabel:`${p.session.endLabel} ET`}),(0,e.jsx)("div",{className:"flex gap-2 mt-4 mb-5",children:p.sessions.map(l=>(0,e.jsxs)("div",{className:`flex items-center gap-1.5 text-[10px] font-medium px-2 py-1 rounded-lg flex-1 justify-center ${p.session?.id===l.id?"bg-white/[0.07]":""}`,children:[(0,e.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:l.color}}),(0,e.jsx)("span",{style:{color:p.session?.id===l.id?l.color:"#475569"},children:l.label})]},l.id))}),(0,e.jsxs)("div",{className:"border-t border-white/[0.06] pt-4",children:[(0,e.jsx)("div",{className:"text-[10px] text-slate-500 uppercase tracking-wider mb-2 font-semibold",children:"Weekly Schedule (ET)"}),Me.map((l,v)=>(0,e.jsx)(Et,{day:l,dayIdx:v,etDay:a.etDay,todayIsHoliday:v===a.etDay&&p.isHoliday,todayIsEarlyClose:v===a.etDay&&p.isEarlyClose,holidayName:p.holidayName},l))]})]}),m==="forex"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,e.jsx)(K,{color:n,size:"lg"}),(0,e.jsx)("span",{className:"text-sm font-semibold text-white",children:f.isWeekend?"Forex Closed":f.isOverlap?"London/NY Overlap":f.activeSessions.length===0?"Off-peak":f.activeSessions.map(l=>l.label).join(" · ")}),f.isOverlap&&(0,e.jsx)("span",{className:"ml-auto text-[9px] px-2 py-0.5 rounded-full bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 font-semibold",children:"Peak liquidity"})]}),(0,e.jsx)(je,{label:f.countdownLabel,countdownSec:f.countdownSec,color:n,sublabel:f.isWeekend?"Forex Weekend":f.isOverlap?"London/NY Overlap":f.activeSessions.length===0?"Off-peak":"Active Session"}),(0,e.jsxs)("div",{className:"mb-5",children:[(0,e.jsx)("div",{className:"text-[10px] text-slate-500 uppercase tracking-wider mb-2 font-semibold",children:"24h UTC timeline"}),(0,e.jsx)(Tt,{utcMins:f.utcMins,activeSessions:f.activeSessions})]}),!f.isWeekend&&f.sessionData.length>0&&(0,e.jsxs)("div",{className:"mb-4",children:[(0,e.jsx)("div",{className:"text-[10px] text-slate-500 uppercase tracking-wider mb-2 font-semibold",children:"Open now"}),f.sessionData.map(l=>(0,e.jsx)(St,{data:l,isOverlap:f.isOverlap&&(l.id==="london"||l.id==="new_york")}
1,l.id))]}),!f.isWeekend&&f.sessionData.length===0&&(0,e.jsxs)("div",{className:"rounded-xl p-3 mb-4 bg-slate-800/50 border border-white/[0.05] text-center",children:[(0,e.jsx)("div",{className:"text-[12px] text-slate-400",children:"No major session active"}),(0,e.jsx)("div",{className:"text-[11px] text-slate-600 mt-0.5",children:"Off-peak hours â lower liquidity"})]}),!f.isWeekend&&f.upcomingSessions.length>0&&(0,e.jsxs)("div",{className:"mb-4",children:[(0,e.jsx)("div",{className:"text-[10px] text-slate-500 uppercase tracking-wider mb-1 font-semibold",children:"Opening next"}),f.upcomingSessions.map(l=>(0,e.jsx)(kt,{data:l},l.id))]}),(0,e.jsxs)("div",{className:"rounded-xl p-3 mb-4",style:{background:"#10b98110",border:"1px solid #10b98125"},children:[(0,e.jsx)("div",{className:"text-[11px] text-emerald-400 font-semibold mb-1",children:f.isOverlap?"â¡ London/NY Overlap â Active now":"ð¡ London/NY Overlap · 13:00â17:00 UTC"}),(0,e.jsx)("div",{className:"text-[10px] text-slate-400 leading-relaxed",children:"Peak liquidity window. EUR/USD, GBP/USD and USD/JPY see tightest spreads and largest moves."})]}),(0,e.jsxs)("div",{className:"border-t border-white/[0.06] pt-4",children:[(0,e.jsx)("div",{className:"text-[10px] text-slate-500 uppercase tracking-wider mb-2 font-semibold",children:"Weekly Open / Close"}),(0,e.jsx)("div",{className:"space-y-1.5",children:[{label:"Opens",value:"Sun 22:00 UTC (5 PM ET)",color:"text-emerald-400"},{label:"Closes",value:"Fri 22:00 UTC (5 PM ET)",color:"text-red-400"},{label:"Weekend",value:"Sat all day + Sun until 22:00 UTC",color:"text-slate-500"}].map(l=>(0,e.jsxs)("div",{className:"flex justify-between text-[11px]",children:[(0,e.jsx)("span",{className:"text-slate-400",children:l.label}),(0,e.jsx)("span",{className:l.color,children:l.value})]},l.label))})]})]})]})]},"mcw-panel")]})});return(0,e.jsxs)(e.Fragment,{children:[i,typeof document<"u"&&(0,gt.createPortal)(N,document.body)]})}var Ae="label";function Ne(t,a){typeof t=="function"?t(a):t&&(t.current=a)}function $t(t,a){const s=t.options;s&&a&&Object.assign(s,a)}function Oe(t,a){t.labels=a}function De(t,a){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ae;const o=[];t.datasets=a.map(x=>{const r=t.datasets.find(d=>d[s]===x[s]);return!r||!x.data||o.includes(r)?{...x}:(o.push(r),Object.assign(r,x),r)})}function Mt(t){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ae;const s={labels:[],datasets:[]};return Oe(s,t.labels),De(s,t.datasets,a),s}function It(t,a){const{height:s=150,width:o=300,redraw:x=!1,datasetIdKey:r,type:d,data:m,options:w,plugins:j=[],fallbackContent:S,updateMode:k,...T}=t,I=(0,c.useRef)(null),y=(0,c.useRef)(null),$=()=>{I.current&&(y.current=new le(I.current,{type:d,data:Mt(m,r),options:w&&{...w},plugins:j}),Ne(a,y.current))},L=()=>{Ne(a,null),y.current&&(y.current.destroy(),y.current=null)};return(0,c.useEffect)(()=>{!x&&y.current&&w&&$t(y.current,w)},[x,w]),(0,c.useEffect)(()=>{!x&&y.current&&Oe(y.current.config.data,m.labels)},[x,m.labels]),(0,c.useEffect)(()=>{!x&&y.current&&m.datasets&&De(y.current.config.data,m.datasets,r)},[x,m.datasets]),(0,c.useEffect)(()=>{y.current&&(x?(L(),setTimeout($)):y.current.update(k))},[x,w,m.labels,m.datasets,k]),(0,c.useEffect)(()=>{y.current&&(L(),setTimeout($))},[d]),(0,c.useEffect)(()=>($(),()=>L()),[]),c.createElement("canvas",{ref:I,role:"img",height:s,width:o,...T},S)}var At=(0,c.forwardRef)(It);function Q(t,a){return le.register(a),(0,c.forwardRef)((s,o)=>c.createElement(At,{...s,ref:o,type:t}))}var Ot=Q("line",bt),Jt=Q("bar",ut),es=Q("radar",it),ts=Q("doughnut",pt),ss=Ce({default:()=>Dt});le.register(dt,xt,ft,nt,ct,ot,mt,ht);var Dt=({trades:t,startingBalance:a})=>{const s=Ze(),o=a||s,{labels:x,values:r}=(0,c.useMemo)(()=>{const d=[...t].sort((j,S)=>new Date(j.entryTime)-new Date(S.entryTime));let m=o;const w=d.map(j=>(m+=Number(j.pl)||0,m));return{labels:d.map((j,S)=>`Trade ${S+1}`),values:w}},[t,o]);return(0,e.jsx)(Ot,{data:(0,c.useMemo)(()=>({labels:x,datasets:[{label:"Cumulative P/L",data:r,fill:!0,backgroundColor:d=>{const m=d.chart.ctx.createLinearGradient(0,0,0,d.chart.chartArea?.bottom||200);
1return m.addColorStop(0,"rgba(148, 163, 184, 0.18)"),m.addColorStop(1,"rgba(148, 163, 184, 0)"),m},borderColor:"rgba(148, 163, 184, 0.9)",segment:{borderColor:d=>{const m=d.p0?.parsed?.y,w=d.p1?.parsed?.y;return m==null||w==null?"rgba(148, 163, 184, 0.9)":w>=m?"#10B981":"#EF4444"},borderWidth:d=>2},tension:.4,pointRadius:0,pointHoverRadius:3,pointBackgroundColor:d=>{const m=d.dataIndex,w=m>0?r[m-1]:0;return r[m]>=w?"#10B981":"#EF4444"}}]}),[x,r]),options:(0,c.useMemo)(()=>({responsive:!0,maintainAspectRatio:!1,scales:{y:{ticks:{color:"#9CA3AF",callback:function(d){return"$"+d}},grid:{color:d=>d.tick?.value===0?"#6B7280":"#374151",lineWidth:d=>d.tick?.value===0?1.5:1}},x:{ticks:{color:"#9CA3AF",maxTicksLimit:10},grid:{color:"#374151"}}},plugins:{legend:{display:!1},tooltip:{mode:"index",intersect:!1,callbacks:{label:function(d){let m=d.dataset.label||"";return m&&(m+=": "),d.parsed.y!==null&&(m+=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(d.parsed.y)),m}}}}}),[])})};tt();var Ut=t=>!t&&t!==0?"-":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(t),R=(t,a=2)=>!t&&t!==0?"-":new Intl.NumberFormat("en-US",{minimumFractionDigits:a,maximumFractionDigits:a}).format(t),Z=t=>t?t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString():"-",Pt=({strike:t,call:a,put:s,underlyingPrice:o,onSelectOption:x})=>{const r=a&&o>t,d=s&&o<t,m=Math.abs(o-t)<o*.01;return(0,e.jsxs)("tr",{className:`border-b border-gray-800 hover:bg-gray-800/50 ${m?"bg-yellow-500/5":""}`,children:[(0,e.jsx)("td",{className:`py-2 px-2 text-right text-xs ${r?"bg-green-500/10":""}`,children:(0,e.jsx)("span",{className:"text-gray-500",children:Z(a?.volume)})}),(0,e.jsx)("td",{className:`py-2 px-2 text-right text-xs ${r?"bg-green-500/10":""}`,children:(0,e.jsx)("span",{className:"text-gray-500",children:R(a?.openInterest,0)})}),(0,e.jsx)("td",{className:`py-2 px-2 text-right text-xs ${r?"bg-green-500/10":""}`,children:(0,e.jsx)("span",{className:"text-gray-400",children:R(a?.bid)})}),(0,e.jsx)("td",{className:`py-2 px-2 text-right text-xs ${r?"bg-green-500/10":""}`,children:(0,e.jsx)("span",{className:"text-gray-400",children:R(a?.ask)})}),(0,e.jsx)("td",{className:`py-2 px-2 text-right text-xs font-medium ${r?"bg-green-500/10":""}`,children:(0,e.jsx)("span",{className:a?.change>=0?"text-green-400":"text-red-400",children:R(a?.lastPrice)})}),(0,e.jsx)("td",{className:`py-2 px-2 text-right text-xs ${r?"bg-green-500/10":""}`,children:(0,e.jsxs)("span",{className:"text-gray-500",children:[R(a?.impliedVolatility*100,0),"%"]})}),(0,e.jsxs)("td",{className:`py-2 px-3 text-center font-bold text-sm ${m?"bg-yellow-500/20 text-yellow-400":"bg-gray-900 text-white"}`,children:[R(t,2),m&&(0,e.jsx)("span",{className:"ml-1 text-xs",children:"ATM"})]}),(0,e.jsx)("td",{className:`py-2 px-2 text-left text-xs ${d?"bg-red-500/10":""}`,children:(0,e.jsxs)("span",{className:"text-gray-500",children:[R(s?.impliedVolatility*100,0),"%"]})}),(0,e.jsx)("td",{className:`py-2 px-2 text-left text-xs font-medium ${d?"bg-red-500/10":""}`,children:(0,e.jsx)("span",{className:s?.change>=0?"text-green-400":"text-red-400",children:R(s?.lastPrice)})}),(0,e.jsx)("td",{className:`py-2 px-2 text-left text-xs ${d?"bg-red-500/10":""}`,children:(0,e.jsx)("span",{className:"text-gray-400",children:R(s?.bid)})}),(0,e.jsx)("td",{className:`py-2 px-2 text-left text-xs ${d?"bg-red-500/10":""}`,children:(0,e.jsx)("span",{className:"text-gray-400",children:R(s?.ask)})}),(0,e.jsx)("td",{className:`py-2 px-2 text-left text-xs ${d?"bg-red-500/10":""}`,children:(0,e.jsx)("span",{className:"text-gray-500",children:R(s?.openInterest,0)})}),(0,e.jsx)("td",{className:`py-2 px-2 text-left text-xs ${d?"bg-red-500/10":""}`,children:(0,e.jsx)("span",{className:"text-gray-500",children:Z(s?.volume)})})]})};function Ft({symbol:t="AAPL",onSymbolChange:a,onSelectOption:s,compact:o=!1}){const[x,r]=(0,c.useState)(!1),[d,m]=(0,c.useState)(null),[w,j]=(0,c.useState)(null),[S,k]=(0,c.useState)(null),[T,I]=(0,c.useState)(null),[y,$]=(0,c.useState)([]),[L,p]=(0,c.useState)(t),[f,h]=(0,c.useState)(!1),[C,D]=(0,c.useState)({strikeRange:10,minVolume:0,minOpenInterest:0}
1),A=(0,c.useCallback)(async(b,i=null)=>{if(b){r(!0),m(null);try{const N=await ue.getQuote(b),l=b.toUpperCase(),v=N?.[l]||(N&&typeof N=="object"?Object.values(N)[0]:null);if(v){const E=st(v);k(E.lastPrice||E.price||0)}const U=await ue.getOptionChain(b);if(!U||U.error){m(U?.error||"No options data available");return}const P=U.callExpDateMap||{},_=U.putExpDateMap||{},H=[...new Set([...Object.keys(P),...Object.keys(_)])].sort(),V=[];H.forEach(E=>{const ie=E.split(":")[0],Pe=P[E]||{},Fe=_[E]||{};Object.entries(Pe).forEach(([J,B])=>{const O=Array.isArray(B)?B[0]:B;O&&V.push({expirationDate:ie,strikePrice:Number(J),contractType:"call",lastPrice:O.last??0,bid:O.bid??0,ask:O.ask??0,change:O.netChange??0,impliedVolatility:O.volatility??0,delta:O.delta??0,volume:O.totalVolume??0,openInterest:O.openInterest??0})}),Object.entries(Fe).forEach(([J,B])=>{const O=Array.isArray(B)?B[0]:B;O&&V.push({expirationDate:ie,strikePrice:Number(J),contractType:"put",lastPrice:O.last??0,bid:O.bid??0,ask:O.ask??0,change:O.netChange??0,impliedVolatility:O.volatility??0,delta:O.delta??0,volume:O.totalVolume??0,openInterest:O.openInterest??0})})}),j({options:V});const u=[...new Set(V.map(E=>E.expirationDate))].sort();$(u),!T&&u.length>0&&I(u[0])}catch(N){console.error("Error fetching options chain:",N),m(N.message)}finally{r(!1)}}},[T]);(0,c.useEffect)(()=>{A(t)},[t]),(0,c.useEffect)(()=>{T&&t&&A(t,T)},[T]);const M=(0,c.useMemo)(()=>{if(!w?.options||!S)return[];const b=T?w.options.filter(l=>l.expirationDate===T):w.options,i={};b.forEach(l=>{const v=l.strikePrice;i[v]||(i[v]={strike:v,call:null,put:null}),l.contractType==="call"?i[v].call=l:i[v].put=l});let N=Object.values(i).sort((l,v)=>l.strike-v.strike);if(C.strikeRange>0){const l=N.findIndex(P=>P.strike>=S),v=Math.max(0,l-C.strikeRange),U=Math.min(N.length,l+C.strikeRange+1);N=N.slice(v,U)}return(C.minVolume>0||C.minOpenInterest>0)&&(N=N.filter(l=>{const v=l.call?.volume||0,U=l.put?.volume||0,P=l.call?.openInterest||0,_=l.put?.openInterest||0;return(v>=C.minVolume||U>=C.minVolume)&&(P>=C.minOpenInterest||_>=C.minOpenInterest)})),N},[w,S,T,C]),n=b=>{b.preventDefault(),L&&L!==t&&(a?.(L.toUpperCase()),A(L.toUpperCase()))},g=(0,c.useMemo)(()=>{if(!M.length)return null;let b=0,i=0,N=0,l=0;return M.forEach(v=>{b+=v.call?.volume||0,i+=v.put?.volume||0,N+=v.call?.openInterest||0,l+=v.put?.openInterest||0}),{totalCallVolume:b,totalPutVolume:i,totalCallOI:N,totalPutOI:l,putCallRatio:b>0?(i/b).toFixed(2):"N/A",oiPutCallRatio:N>0?(l/N).toFixed(2):"N/A"}},[M]);return(0,e.jsxs)("div",{className:`bg-gray-900 rounded-xl border border-gray-800 ${o?"":"p-4"}`,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-4 px-4 pt-4",children:[(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(G,{className:"w-5 h-5 text-blue-400"}),(0,e.jsx)("h2",{className:"text-lg font-bold text-white",children:"Options Chain"})]}),(0,e.jsx)("form",{onSubmit:n,className:"flex items-center gap-2",children:(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)(ke,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),(0,e.jsx)("input",{type:"text",value:L,onChange:b=>p(b.target.value.toUpperCase()),placeholder:"Symbol",className:"pl-9 pr-3 py-1.5 bg-gray-800 border border-gray-700 rounded-lg text-white text-sm w-24 focus:outline-none focus:ring-2 focus:ring-blue-500"})]})}),S&&(0,e.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,e.jsx)("span",{className:"text-gray-400",children:"Last:"}),(0,e.jsx)("span",{className:"font-bold text-white",children:Ut(S)})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:()=>h(!f),className:`p-2 rounded-lg transition ${f?"bg-blue-500/20 text-blue-400":"bg-gray-800 text-gray-400 hover:text-white"}`,children:(0,e.jsx)(lt,{className:"w-5 h-5"})}),(0,e.jsx)("button",{onClick:()=>A(t,T),disabled:x,className:"p-2 bg-gray-800 text-gray-400 hover:text-white rounded-lg transition disabled:opacity-50",children:(0,e.jsx)(Se,{className:`w-5 h-5 ${x?"animate-spin":""}`})})]})]}),y.length>0&&(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-4 px-4 overflow-x-auto",children:[(0,e.jsx)(Ye,{className:"w-4 h-4 text-gray-500 flex-shrink-0"}),(0,e.jsx)("div",{className:"flex gap-1",children:y.slice(0,8).map(b=>(0,e.jsx)("button",{onClick:()=>I(b),className:`px-3 py-1 rounded-lg text-xs font-medium whitespace-nowrap transition ${T===b?"bg-blue-500 text-white":"bg-gray-800 text-gray-400 hover:bg-gray-700"}`,children:new Date(b).toLocaleDateString("en-US",{month:"short",day:"numeric"})},b))})]}),(0,e.jsx)(q,{children:f&&(0,e.jsx)(z.div,{initial:{height:0,opacity:0}
1,animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"mb-4 px-4 overflow-hidden",children:(0,e.jsxs)("div",{className:"bg-gray-800 rounded-lg p-3 flex items-center gap-4",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("label",{className:"text-xs text-gray-400",children:"Strikes:"}),(0,e.jsxs)("select",{value:C.strikeRange,onChange:b=>D(i=>({...i,strikeRange:parseInt(b.target.value)})),className:"bg-gray-700 border-none rounded px-2 py-1 text-sm text-white",children:[(0,e.jsx)("option",{value:5,children:"±5"}),(0,e.jsx)("option",{value:10,children:"±10"}),(0,e.jsx)("option",{value:20,children:"±20"}),(0,e.jsx)("option",{value:0,children:"All"})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("label",{className:"text-xs text-gray-400",children:"Min Vol:"}),(0,e.jsx)(oe,{value:C.minVolume,onChange:b=>D(i=>({...i,minVolume:parseInt(b.target.value)||0})),className:"bg-gray-700 border-none rounded px-2 py-1 text-sm text-white w-20"})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("label",{className:"text-xs text-gray-400",children:"Min OI:"}),(0,e.jsx)(oe,{value:C.minOpenInterest,onChange:b=>D(i=>({...i,minOpenInterest:parseInt(b.target.value)||0})),className:"bg-gray-700 border-none rounded px-2 py-1 text-sm text-white w-20"})]})]})})}),g&&(0,e.jsxs)("div",{className:"grid grid-cols-4 gap-2 mb-4 px-4",children:[(0,e.jsxs)("div",{className:"bg-gray-800 rounded-lg p-2 text-center",children:[(0,e.jsx)("div",{className:"text-xs text-gray-500",children:"Call Volume"}),(0,e.jsx)("div",{className:"text-sm font-bold text-green-400",children:Z(g.totalCallVolume)})]}),(0,e.jsxs)("div",{className:"bg-gray-800 rounded-lg p-2 text-center",children:[(0,e.jsx)("div",{className:"text-xs text-gray-500",children:"Put Volume"}),(0,e.jsx)("div",{className:"text-sm font-bold text-red-400",children:Z(g.totalPutVolume)})]}),(0,e.jsxs)("div",{className:"bg-gray-800 rounded-lg p-2 text-center",children:[(0,e.jsx)("div",{className:"text-xs text-gray-500",children:"P/C Ratio"}),(0,e.jsx)("div",{className:"text-sm font-bold text-white",children:g.putCallRatio})]}),(0,e.jsxs)("div",{className:"bg-gray-800 rounded-lg p-2 text-center",children:[(0,e.jsx)("div",{className:"text-xs text-gray-500",children:"OI P/C"}),(0,e.jsx)("div",{className:"text-sm font-bold text-white",children:g.oiPutCallRatio})]})]}),d&&(0,e.jsx)("div",{className:"mx-4 mb-4 p-3 bg-red-500/10 border border-red-500/30 rounded-lg text-red-400 text-sm",children:d}),x&&!w&&(0,e.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,e.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"})}),M.length>0&&(0,e.jsx)("div",{className:"overflow-x-auto",children:(0,e.jsxs)("table",{className:"w-full text-xs",children:[(0,e.jsxs)("thead",{className:"bg-gray-800",children:[(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{colSpan:6,className:"py-2 px-4 text-center text-green-400 font-bold border-b border-gray-700",children:"CALLS"}),(0,e.jsx)("th",{className:"py-2 px-4 text-center text-gray-400 font-bold border-b border-gray-700 bg-gray-900",children:"STRIKE"}),(0,e.jsx)("th",{colSpan:6,className:"py-2 px-4 text-center text-red-400 font-bold border-b border-gray-700",children:"PUTS"})]}),(0,e.jsxs)("tr",{className:"text-gray-500",children:[(0,e.jsx)("th",{className:"py-1 px-2 text-right font-normal",children:"Vol"}),(0,e.jsx)("th",{className:"py-1 px-2 text-right font-normal",children:"OI"}),(0,e.jsx)("th",{className:"py-1 px-2 text-right font-normal",children:"Bid"}),(0,e.jsx)("th",{className:"py-1 px-2 text-right font-normal",children:"Ask"}),(0,e.jsx)("th",{className:"py-1 px-2 text-right font-normal",children:"Last"}),(0,e.jsx)("th",{className:"py-1 px-2 text-right font-normal",children:"IV"}),(0,e.jsx)("th",{className:"py-1 px-2 text-center font-normal bg-gray-900"}),(0,e.jsx)("th",{className:"py-1 px-2 text-left font-normal",children:"IV"}),(0,e.jsx)("th",{className:"py-1 px-2 text-left font-normal",children:"Last"}),(0,e.jsx)("th",{className:"py-1 px-2 text-left font-normal",children:"Bid"}),(0,e.jsx)("th",{className:"py-1 px-2 text-left font-normal",children:"Ask"}),(0,e.jsx)("th",{className:"py-1 px-2 text-left font-normal",children:"OI"}),(0,e.jsx)("th",{className:"py-1 px-2 text-left font-normal",children:"Vol"})]})]}),(0,e.jsx)("tbody",{children:M.map(b=>(0,e.jsx)(Pt,{strike:b.strike,call:b.call,put:b.put,underlyingPrice:S,onSelectOption:s},b.strike))})]})}),!x&&M.length===0&&!d&&(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[(0,e.jsx)(_e,{className:"w-12 h-12 mb-3"}),(0,e.jsxs)("p",{children:["No options data available for ",t]}),(0,e.jsx)("p",{className:"text-xs mt-1",children:"Try a different symbol or expiration"})]})]})}var as=Ce({default:()=>Bt}),se=["SPY","QQQ","DIA","IWM"],ye=[{symbol:"XLK",name:"Technology",color:"#3b82f6"},{symbol:"XLV",name:"Healthcare",color:"#22c55e"},{symbol:"XLF",name:"Financials",color:"#8b5cf6"},{symbol:"XLE",name:"Energy",color:"#f97316"},{symbol:"XLY",name:"Consumer Disc",color:"#ec4899"},{symbol:"XLI",name:"Industrials",color:"#14b8a6"},{symbol:"XLB",name:"Materials",color:"#eab308"},{symbol:"XLC",name:"Communication",color:"#06b6d4"},{symbol:"XLU",name:"Utilities",color:"#64748b"}
1,{symbol:"XLRE",name:"Real Estate",color:"#a855f7"},{symbol:"XLP",name:"Consumer Staples",color:"#84cc16"}],Rt=["AAPL","MSFT","GOOGL","AMZN","TSLA","NVDA","META","AMD","NFLX","JPM"],ve=[{value:"1",label:"1m"},{value:"5",label:"5m"},{value:"15",label:"15m"},{value:"60",label:"1H"},{value:"D",label:"1D"},{value:"W",label:"1W"}],Ue=t=>!t&&t!==0?"-":t.toLocaleString("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}),ne=t=>!t&&t!==0?"-":`${t>=0?"+":""}${t.toFixed(2)}%`,_t=t=>t?t>=1e9?`${(t/1e9).toFixed(1)}B`:t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString():"-",Wt=({quote:t,isLoading:a})=>{if(a||!t)return(0,e.jsxs)("div",{className:"p-3 rounded-lg bg-slate-800/50 border border-slate-700/50 animate-pulse min-w-[100px]",children:[(0,e.jsx)("div",{className:"h-3 bg-slate-700 rounded w-12 mb-2"}),(0,e.jsx)("div",{className:"h-5 bg-slate-700 rounded w-16 mb-1"}),(0,e.jsx)("div",{className:"h-3 bg-slate-700 rounded w-10"})]});const s=(t.changePercent||0)>=0;return(0,e.jsxs)("div",{className:"p-3 rounded-lg border backdrop-blur-sm min-w-[100px] flex-shrink-0 transition-all hover:scale-[1.02]",style:{background:s?"rgba(34, 197, 94, 0.08)":"rgba(239, 68, 68, 0.08)",borderColor:s?"rgba(34, 197, 94, 0.25)":"rgba(239, 68, 68, 0.25)"},children:[(0,e.jsx)("div",{className:"text-xs text-slate-400 font-medium mb-1",children:t.symbol}),(0,e.jsx)("div",{className:"text-sm font-bold text-white",children:Ue(t.price)}),(0,e.jsx)("div",{className:`text-xs font-semibold ${s?"text-green-400":"text-red-400"}`,children:ne(t.changePercent)})]})},Vt=({sectors:t,isLoading:a})=>a?(0,e.jsx)("div",{className:"flex gap-1 overflow-x-auto pb-2",children:[...Array(6)].map((s,o)=>(0,e.jsx)("div",{className:"h-8 w-16 bg-slate-800/50 rounded animate-pulse flex-shrink-0"},o))}):(0,e.jsx)("div",{className:"flex gap-1 overflow-x-auto pb-2",style:{scrollbarWidth:"none"},children:[...t].sort((s,o)=>(o.change||0)-(s.change||0)).map(s=>{const o=(s.change||0)>=0;return(0,e.jsxs)("div",{className:"px-2 py-1.5 rounded flex-shrink-0 flex items-center gap-1.5 cursor-pointer hover:opacity-80 transition-opacity",style:{background:o?"rgba(34, 197, 94, 0.15)":"rgba(239, 68, 68, 0.15)",borderLeft:`3px solid ${s.color}`},title:s.name,children:[(0,e.jsx)("span",{className:"text-[10px] font-medium text-white",children:s.symbol.replace("XL","")}),(0,e.jsx)("span",{className:`text-[10px] font-bold ${o?"text-green-400":"text-red-400"}`,children:ne(s.change)})]},s.symbol)})}),zt=({symbols:t,activeSymbol:a,onSelect:s,watchlist:o,onToggleWatchlist:x})=>(0,e.jsx)("div",{className:"flex gap-1 overflow-x-auto pb-1",style:{scrollbarWidth:"none"},children:t.map(r=>{const d=a===r,m=o.includes(r);return(0,e.jsxs)("button",{onClick:()=>s(r),className:`group relative px-3 py-1.5 rounded-lg text-xs font-medium transition-all flex-shrink-0 ${d?"bg-gradient-to-r from-blue-600 to-purple-600 text-white shadow-lg":"bg-slate-800/80 text-slate-400 hover:text-white hover:bg-slate-700/80"}`,children:[r,m&&(0,e.jsx)(ae,{className:"w-2.5 h-2.5 text-amber-400 absolute -top-1 -right-1"})]},r)})});function Bt({showChart:t=!0}={}){const[a,s]=(0,c.useState)("AAPL"),[o,x]=(0,c.useState)(""),[r,d]=(0,c.useState)("15"),[m,w]=(0,c.useState)(!1),[j,S]=(0,c.useState)(["AAPL","SPY","TSLA","NVDA"]),[k,T]=(0,c.useState)({chart:t,options:!1}),[I,y]=(0,c.useState)(!0),[$,L]=(0,c.useState)(null),[p,f]=(0,c.useState)(!1),h=Y(u=>u.subscribe),C=Y(u=>u.unsubscribe),D=Y(u=>u.quotes),A=Y(u=>u.quotesLoading),M=Y(u=>u.quotesLastUpdated),n=(0,c.useMemo)(()=>[...new Set([...se,...ye.map(u=>u.symbol),a,...j])],[a,j]);(0,c.useEffect)(()=>(h("MarketAnalysisTab",n),()=>C("MarketAnalysisTab")),[h,C,n.join(",")]);const g=(0,c.useMemo)(()=>{const u={};return se.forEach(E=>{D[E]&&(u[E]=D[E])}),u},[D]),b=(0,c.useMemo)(()=>ye.map(u=>({...u,price:D[u.symbol]?.price||0,change:D[u.symbol]?.changePercent||0})),[D]),i=D[a]||null;(0,c.useEffect)(()=>{y(A)},[A]),(0,c.useEffect)(()=>{M&&L(new Date(M))},[M]);const N=(0,c.useCallback)(async()=>{f(!0),h("MarketAnalysisTab",n),setTimeout(()=>f(!1),1e3)},[h,n]),l=(0,c.useCallback)(u=>{const E=u.toUpperCase().trim();E&&E.length>=1&&E.length<=5&&s(E)},[]),v=u=>{u.preventDefault(),o.trim()&&(l(o.trim()),x(""))},U=u=>{T(E=>({...E,[u]:!E[u]}))},P=u=>{j.includes(u)?S(j.filter(E=>E!==u)):S([...j,u])},_=()=>
1{const u=Object.values(k).filter(Boolean).length;return u===3?"grid-cols-1":u===2?"grid-cols-1 lg:grid-cols-12":"grid-cols-1"},H=()=>k.chart&&k.options?"col-span-12 lg:col-span-7":"col-span-1",V=()=>k.options&&k.chart?"col-span-12 lg:col-span-5":"col-span-1";return(0,e.jsxs)("div",{className:`min-h-screen flex flex-col transition-all duration-300 ${m?"fixed inset-0 z-50":""}`,style:{background:"linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%)"},children:[(0,e.jsx)("div",{className:"border-b border-slate-700/50 bg-slate-900/80 backdrop-blur-xl",children:(0,e.jsxs)("div",{className:"px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)("div",{className:"p-2 rounded-xl bg-gradient-to-br from-blue-500/20 to-purple-500/20 border border-blue-500/30",children:(0,e.jsx)(rt,{className:"w-5 h-5 text-blue-400"})}),(0,e.jsx)("div",{children:(0,e.jsxs)("h1",{className:"text-lg font-bold text-white flex items-center gap-2",children:["Market Analysis",(0,e.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium rounded-full bg-blue-500/20 text-blue-400 border border-blue-500/30",children:"PRO"})]})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(Lt,{}),(0,e.jsx)("button",{onClick:N,disabled:p,className:"p-2 rounded-lg bg-slate-800/80 hover:bg-slate-700/80 transition-all disabled:opacity-50",children:(0,e.jsx)(Se,{className:`w-4 h-4 text-slate-400 ${p?"animate-spin":""}`})}),(0,e.jsx)("button",{onClick:()=>w(!m),className:"p-2 rounded-lg bg-slate-800/80 hover:bg-slate-700/80 transition-all",children:m?(0,e.jsx)(pe,{className:"w-4 h-4 text-slate-400"}):(0,e.jsx)(He,{className:"w-4 h-4 text-slate-400"})})]})]}),(0,e.jsxs)("div",{className:"flex gap-2 overflow-x-auto pb-2 mb-3",style:{scrollbarWidth:"none"},children:[se.map(u=>(0,e.jsx)(Wt,{quote:g[u],isLoading:I},u)),(0,e.jsx)("div",{className:"flex items-center px-2",children:(0,e.jsx)("div",{className:"w-px h-10 bg-slate-600"})}),i&&(0,e.jsxs)("div",{className:"p-3 rounded-lg border backdrop-blur-sm min-w-[140px] flex-shrink-0",style:{background:"rgba(139, 92, 246, 0.1)",borderColor:"rgba(139, 92, 246, 0.3)"},children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,e.jsx)(de,{className:"w-3 h-3 text-purple-400"}),(0,e.jsx)("span",{className:"text-xs text-purple-300 font-medium",children:a})]}),(0,e.jsx)("div",{className:"text-sm font-bold text-white",children:Ue(i.price)}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:`text-xs font-semibold ${(i.changePercent||0)>=0?"text-green-400":"text-red-400"}`,children:ne(i.changePercent)}),(0,e.jsxs)("span",{className:"text-[10px] text-slate-500",children:["Vol: ",_t(i.volume)]})]})]})]}),(0,e.jsx)(Vt,{sectors:b,isLoading:I})]})}),(0,e.jsx)("div",{className:"border-b border-slate-700/50 bg-slate-800/50 backdrop-blur-xl px-4 py-2",children:(0,e.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("form",{onSubmit:v,className:"relative",children:[(0,e.jsx)(ke,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-500"}),(0,e.jsx)("input",{type:"text",value:o,onChange:u=>x(u.target.value.toUpperCase()),placeholder:"Symbol...",className:"pl-9 pr-3 py-2 bg-slate-900/80 border border-slate-700/50 rounded-lg text-white text-sm w-28 focus:outline-none focus:ring-2 focus:ring-blue-500/50",maxLength:5})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xl font-bold text-white",children:a}),(0,e.jsx)("button",{onClick:()=>P(a),className:`p-1.5 rounded-lg transition-all ${j.includes(a)?"bg-amber-500/20 text-amber-400":"bg-slate-800/80 text-slate-500 hover:text-amber-400"}`,children:j.includes(a)?(0,e.jsx)(ae,{className:"w-4 h-4"}):(0,e.jsx)(de,{className:"w-4 h-4"})})]}),(0,e.jsx)("div",{className:"hidden md:block",children:(0,e.jsx)(zt,{symbols:Rt.slice(0,8),activeSymbol:a,onSelect:l,watchlist:j,onToggleWatchlist:P})})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-1 bg-slate-900/50 p-1 rounded-lg",children:[t&&(0,e.jsx)("button",{onClick:()=>U("chart"),className:`p-2 rounded-lg transition-all ${k.chart?"bg-blue-500/20 text-blue-400 shadow-lg shadow-blue-500/20":"text-slate-500 hover:text-white"}`,title:"Toggle Chart",children:(0,e.jsx)(G,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:()=>U("options"),className:`p-2 rounded-lg transition-all ${k.options?"bg-purple-500/20 text-purple-400 shadow-lg shadow-purple-500/20":"text-slate-500 hover:text-white"}`,title:"Toggle Options Chain",children:(0,e.jsx)(he,{className:"w-4 h-4"})})]}),t&&(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-1 bg-slate-900/50 p-1 rounded-lg",children:ve.map(u=>(0,e.jsx)("button",{onClick:()=>d(u.value),className:`px-2 py-1.5 rounded text-xs font-medium transition-all ${r===u.value?"bg-slate-700/80 text-white":"text-slate-500 hover:text-white"}`,children:u.label},u.value))})]})]})}),j.length>0&&(0,e.jsx)("div",{className:"border-b border-slate-700/30 bg-slate-800/30 px-4 py-2",children:(0,e.jsxs)("div",{className:"flex items-center gap-2 overflow-x-auto",style:{scrollbarWidth:"none"},children:[(0,e.jsx)("span",{className:"text-xs text-slate-500 flex-shrink-0",children:"Watchlist:"}),j.map(u=>(0,e.jsxs)("button",{onClick:()=>l(u),className:`group flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-all flex-shrink-0 ${a===u?"bg-gradient-to-r from-amber-600/30 to-orange-600/30 text-amber-400 border border-amber-500/30":"bg-slate-800/80 text-slate-400 hover:bg-slate-700/80 hover:text-white"}`,children:[(0,e.jsx)(ae,{className:"w-3 h-3 text-amber-400"}),u,(0,e.jsx)(Ee,{onClick:E=>{E.stopPropagation(),P(u)},className:"w-3 h-3 text-slate-600 hover:text-red-400 transition-colors"})]},u))]})}),(0,e.jsxs)("div",{className:"flex-1 overflow-auto p-4",children:[(0,e.jsxs)("div",{className:`h-full grid gap-4 ${_()}`,children:[k.chart&&(0,e.jsx)(z.div,{initial:{opacity:0,scale:.98}
1,animate:{opacity:1,scale:1},className:`${H()} rounded-xl overflow-hidden border border-slate-700/50 bg-slate-900/80 backdrop-blur-xl`,children:(0,e.jsxs)("div",{className:"h-full flex flex-col",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-slate-700/50 bg-gradient-to-r from-slate-800/50 to-slate-900/50",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)("div",{className:"p-1.5 rounded-lg bg-blue-500/20",children:(0,e.jsx)(G,{className:"w-4 h-4 text-blue-400"})}),(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"text-sm font-semibold text-white",children:"Chart"}),(0,e.jsx)("span",{className:"ml-2 text-xs text-slate-500",children:a})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"flex items-center gap-1 px-2 py-1 rounded-md bg-slate-800/80",children:ve.map(u=>(0,e.jsx)("button",{onClick:()=>d(u.value),className:`px-2 py-0.5 rounded text-xs font-medium transition-all ${r===u.value?"bg-blue-500/30 text-blue-400":"text-slate-500 hover:text-white"}`,children:u.label},u.value))}),(0,e.jsxs)("span",{className:"text-xs text-green-400 bg-green-500/10 px-2 py-1 rounded-md flex items-center gap-1",children:[(0,e.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 animate-pulse"}),"LIVE"]})]})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0",children:(0,e.jsx)(at,{symbol:a,theme:"dark",interval:r,height:m?600:500})})]})}),k.options&&(0,e.jsxs)(z.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`${V()} rounded-xl overflow-hidden border border-slate-700/50 bg-slate-900/80 backdrop-blur-xl flex flex-col`,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-slate-700/50 bg-gradient-to-r from-slate-800/50 to-slate-900/50",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)("div",{className:"p-1.5 rounded-lg bg-purple-500/20",children:(0,e.jsx)(he,{className:"w-4 h-4 text-purple-400"})}),(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"text-sm font-semibold text-white",children:"Options Chain"}),(0,e.jsx)("span",{className:"ml-2 text-xs text-slate-500",children:a})]})]}),(0,e.jsx)("span",{className:"text-xs text-amber-400 bg-amber-500/10 px-2 py-1 rounded-md",children:"DELAYED"})]}),(0,e.jsx)("div",{className:"flex-1 min-h-0 overflow-auto",children:(0,e.jsx)(Ft,{symbol:a,onSymbolChange:l,compact:!1})})]})]}),!k.chart&&!k.options&&(0,e.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("div",{className:"w-20 h-20 mx-auto mb-4 rounded-2xl bg-slate-800/50 border border-slate-700/50 flex items-center justify-center",children:(0,e.jsx)(G,{className:"w-10 h-10 text-slate-600"})}),(0,e.jsx)("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Tools Selected"}),(0,e.jsxs)("p",{className:"text-sm text-slate-400 mb-4 max-w-md",children:["Enable Chart or Options Chain from the toolbar to start analyzing ",a]}),(0,e.jsxs)("div",{className:"flex gap-2 justify-center",children:[(0,e.jsx)("button",{onClick:()=>T({chart:!0,options:!1}),className:"px-4 py-2.5 bg-gradient-to-r from-blue-600 to-purple-600 text-white rounded-lg text-sm font-medium hover:shadow-lg hover:shadow-blue-500/25 transition-all",children:"Enable Chart"}),(0,e.jsx)("button",{onClick:()=>T({chart:!0,options:!0}),className:"px-4 py-2.5 bg-slate-800/80 text-white rounded-lg text-sm font-medium hover:bg-slate-700/80 transition-all border border-slate-700/50",children:"Enable Chart + Options"})]})]})})]}),(0,e.jsx)("div",{className:"border-t border-slate-700/50 bg-slate-900/80 px-4 py-2",children:(0,e.jsxs)("div",{className:"flex items-center justify-between text-xs text-slate-500",children:[(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,e.jsx)("span",{children:"Data: Polygon.io / Finnhub"}),$&&(0,e.jsxs)("span",{className:"flex items-center gap-1",children:[(0,e.jsx)(Te,{className:"w-3 h-3"}),"Last update: ",$.toLocaleTimeString()]})]}),(0,e.jsx)("div",{className:"text-slate-600",children:"For educational purposes only. Not financial advice."})]})}),m&&(0,e.jsx)("button",{onClick:()=>w(!1),className:"fixed top-4 right-4 z-50 p-3 bg-slate-800/90 text-white rounded-xl hover:bg-slate-700 transition-all shadow-xl border border-slate-600/50",children:(0,e.jsx)(pe,{className:"w-6 h-6"})})]})}export{Ot as a,Qt as c,ts as i,ss as n,es as o,Jt as r,Lt as s,as as t};
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.