PageSourceSearch

https://tradeintelx.com/assets/OrgSettings-ymNob6ZU.js

js tradeintelx.com collected 2026-09-24 14:56:59 UTC 78,235 bytes, 2 lines download raw bytes

1import{o as Te}from"./rolldown-runtime-ChpBd9eV.js";import{La as Re,Ma as Pe,P as N,Pa as De,Ta as Ae,da as M,ha as oe}from"./chat-page-evUfHQgD.js";import{Dc as Me,Ec as Le,Ht as Fe,Ic as ee,Jc as Z,Mc as _e,Qc as $e,Sc as G,Tc as Ie,Uc as Ee,Xc as qe,Zc as L,_c as de,_n as Be,bc as Oe,dl as We,fl as re,fn as ze,hl as J,hn as Ue,kc as Ge,lc as D,ll as Xe,lu as He,ml as Ve,mn as Ye,nl as X,ol as se,pl as Je,pn as Qe,tl as ce,vc as U,wc as P,yc as Ze}from"./market-core-DitXLvJ-.js";import{t as Ke}from"./date-vendor-BjneNXXN.js";var l=Te(Re(),1),e=Ae(),K={org_created:{icon:U,color:"green",label:"Organization Created"},org_updated:{icon:Le,color:"blue",label:"Settings Updated"},org_deleted:{icon:se,color:"red",label:"Organization Deleted"},member_invited:{icon:re,color:"blue",label:"Member Invited"},member_joined:{icon:re,color:"green",label:"Member Joined"},member_removed:{icon:We,color:"red",label:"Member Removed"},member_suspended:{icon:J,color:"yellow",label:"Member Suspended"},member_activated:{icon:U,color:"green",label:"Member Activated"},role_changed:{icon:X,color:"purple",label:"Role Changed"},account_request_submitted:{icon:Xe,color:"blue",label:"Account Request"},account_request_approved:{icon:U,color:"green",label:"Request Approved"},account_request_rejected:{icon:J,color:"red",label:"Request Rejected"},phase_started:{icon:G,color:"blue",label:"Phase Started"},phase_completed:{icon:U,color:"green",label:"Phase Completed"},phase_failed:{icon:J,color:"red",label:"Phase Failed"},trader_funded:{icon:P,color:"green",label:"Trader Funded"},violation_detected:{icon:D,color:"red",label:"Violation Detected"},violation_acknowledged:{icon:Ge,color:"yellow",label:"Violation Acknowledged"},daily_loss_breach:{icon:D,color:"red",label:"Daily Loss Breach"},drawdown_breach:{icon:D,color:"red",label:"Drawdown Breach"},payout_requested:{icon:P,color:"blue",label:"Payout Requested"},payout_approved:{icon:P,color:"green",label:"Payout Approved"},payout_rejected:{icon:P,color:"red",label:"Payout Rejected"},risk_rules_updated:{icon:ce,color:"purple",label:"Risk Rules Updated"},subscription_changed:{icon:P,color:"blue",label:"Subscription Changed"},unknown:{icon:G,color:"gray",label:"Event"}},es=t=>K[t]||K.unknown,xe={green:"bg-green-500/20 text-green-400 border-green-500/30",blue:"bg-blue-500/20 text-blue-400 border-blue-500/30",red:"bg-red-500/20 text-red-400 border-red-500/30",yellow:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",purple:"bg-purple-500/20 text-purple-400 border-purple-500/30",gray:"bg-slate-500/20 text-slate-400 border-slate-500/30"},ss=({log:t,isExpanded:d,onToggle:c})=>{const a=es(t.action),n=a.icon,x=t.timestamp?.toDate?.()||new Date(t.timestamp),h=Ke(x,{addSuffix:!0});return(0,e.jsxs)(M.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},className:"bg-slate-800/50 rounded-lg border border-slate-700 overflow-hidden",children:[(0,e.jsxs)("button",{onClick:c,className:"w-full p-4 flex items-center gap-4 text-left hover:bg-slate-800/80 transition-colors",children:[(0,e.jsx)("div",{className:`p-2 rounded-lg ${xe[a.color]}`,children:(0,e.jsx)(n,{className:"w-4 h-4"})}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("p",{className:"font-medium text-white truncate",children:a.label}),(0,e.jsx)("p",{className:"text-sm text-slate-400 truncate",children:t.metadata?.description||`Action by ${t.actorId?.slice(0,8)}...`})]}),(0,e.jsxs)("div",{className:"text-right flex-shrink-0",children:[(0,e.jsx)("p",{className:"text-sm text-slate-400",children:h}),(0,e.jsx)("p",{className:"text-xs text-slate-500",children:x.toLocaleTimeString()})]}),(0,e.jsx)(Ze,{className:`w-4 h-4 text-slate-400 transition-transform ${d?"rotate-180":""}`})]}),(0,e.jsx)(oe,{children:d&&(0,e.jsx)(M.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"border-t border-slate-700",children:(0,e.jsxs)("div",{className:"p-4 space-y-3 bg-slate-900/50",children:[(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-slate-500",children:"Actor ID"}),(0,e.jsx)("p",{className:"text-white font-mono text-xs",children:t.actorId||"System"})]}),t.targetId&&(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-slate-500",children:"Target ID"}),(0,e.jsx)("p",{className:"text-white font-mono text-xs",children:t.targetId})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-slate-500",children:"Event ID"}),(0,e.jsx)("p",{className:"text-white font-mono text-xs",children:t.id})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-slate-500",children:"Timestamp"}),(0,e.jsx)("p",{className:"text-white text-xs",children:x.toISOString()})]})]}),t.metadata&&Object.keys(t.metadata).length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-slate-500 text-sm mb-2",children:"Metadata"}),(0,e.jsx)("pre",{className:"bg-slate-900 rounded-lg p-3 text-xs text-slate-300 overflow-x-auto",children:JSON.stringify(t.metadata,null,2)})]})]})})})]})},ts=({selectedTypes:t,onToggleType:d,onClearAll:c})=>{const[a,n]=(0,l.useState)(!1),x=Object.entries(K).filter(([h])=>h!=="unknown");return(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsxs)("button",{onClick:()=>n(!a),className:"px-4 py-2 bg-slate-800 border border-slate-600 rounded-lg text-slate-300 flex items-center gap-2 hover:border-slate-500 transition-colors",children:[(0,e.jsx)(_e,{className:"w-4 h-4"}),"Filter",t.length>0&&(0,e.jsx)("span",{className:"px-1.5 py-0.5 text-xs bg-blue-500 text-white rounded-full",children:t.length})]}),(0,e.jsx)(oe,{children:a&&(0,e.jsxs)(M.div,{initial:{opacity:0,y:-10}
1,animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"absolute right-0 mt-2 w-64 max-h-80 overflow-y-auto bg-slate-800 border border-slate-700 rounded-xl shadow-xl z-50",children:[(0,e.jsxs)("div",{className:"p-2 border-b border-slate-700 flex justify-between items-center",children:[(0,e.jsx)("span",{className:"text-sm text-slate-400",children:"Event Types"}),(0,e.jsx)("button",{onClick:c,className:"text-xs text-blue-400 hover:text-blue-300",children:"Clear All"})]}),(0,e.jsx)("div",{className:"p-2 space-y-1",children:x.map(([h,g])=>(0,e.jsxs)("label",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-slate-700 cursor-pointer",children:[(0,e.jsx)("input",{type:"checkbox",checked:t.includes(h),onChange:()=>d(h),className:"rounded border-slate-500"}),(0,e.jsx)(g.icon,{className:`w-4 h-4 ${xe[g.color].split(" ")[1]}`}),(0,e.jsx)("span",{className:"text-sm text-slate-300",children:g.label})]},h))})]})})]})},as=({orgId:t,maxLogs:d=100})=>{const{logs:c,loading:a,error:n}=Fe(t,d),[x,h]=(0,l.useState)(""),[g,i]=(0,l.useState)([]),[u,w]=(0,l.useState)(null),r=(0,l.useMemo)(()=>{let m=c||[];if(g.length>0&&(m=m.filter(f=>g.includes(f.action))),x){const f=x.toLowerCase();m=m.filter(v=>v.action?.toLowerCase().includes(f)||v.actorId?.toLowerCase().includes(f)||v.targetId?.toLowerCase().includes(f)||JSON.stringify(v.metadata||{}).toLowerCase().includes(f))}return m},[c,g,x]),p=m=>{i(f=>f.includes(m)?f.filter(v=>v!==m):[...f,m])},j=()=>
1{const m=[["Timestamp","Action","Actor ID","Target ID","Metadata"].join(","),...r.map(o=>[o.timestamp?.toDate?.()?.toISOString()||"",o.action,o.actorId||"",o.targetId||"",JSON.stringify(o.metadata||{}).replace(/,/g,";")].join(","))].join(`
2`),f=new Blob([m],{type:"text/csv"}),v=URL.createObjectURL(f),s=document.createElement("a");s.href=v,s.download=`audit-logs-${new Date().toISOString().split("T")[0]}.csv`,s.click(),URL.revokeObjectURL(v)};return a?(0,e.jsx)("div",{className:"space-y-4",children:[...Array(5)].map((m,f)=>(0,e.jsx)("div",{className:"h-20 bg-slate-800 rounded-lg animate-pulse"},f))}):n?(0,e.jsxs)("div",{className:"text-center py-12",children:[(0,e.jsx)(D,{className:"w-12 h-12 text-red-400 mx-auto mb-4"}),(0,e.jsx)("p",{className:"text-slate-400",children:"Failed to load audit logs"})]}):(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"flex flex-col sm:flex-row gap-3",children:[(0,e.jsxs)("div",{className:"relative flex-1",children:[(0,e.jsx)($e,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),(0,e.jsx)("input",{type:"text",value:x,onChange:m=>h(m.target.value),placeholder:"Search audit logs...",className:"w-full pl-10 pr-4 py-2 bg-slate-800 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)(ts,{selectedTypes:g,onToggleType:p,onClearAll:()=>i([])}),(0,e.jsxs)("button",{onClick:j,className:"px-4 py-2 bg-slate-800 border border-slate-600 rounded-lg text-slate-300 flex items-center gap-2 hover:border-slate-500 transition-colors",children:[(0,e.jsx)(Ie,{className:"w-4 h-4"}),"Export"]})]})]}),(0,e.jsx)("div",{className:"flex gap-4 text-sm",children:(0,e.jsxs)("span",{className:"text-slate-400",children:["Showing ",(0,e.jsx)("span",{className:"text-white font-medium",children:r.length})," of ",c?.length||0," events"]})}),(0,e.jsx)("div",{className:"space-y-2",children:r.length===0?(0,e.jsxs)("div",{className:"text-center py-12 bg-slate-800/50 rounded-xl border border-slate-700",children:[(0,e.jsx)(G,{className:"w-12 h-12 text-slate-600 mx-auto mb-4"}),(0,e.jsx)("p",{className:"text-slate-400",children:"No audit logs found"})]}):r.map(m=>(0,e.jsx)(ss,{log:m,isExpanded:u===m.id,onToggle:()=>w(u===m.id?null:m.id)},m.id))})]})},ls=({org:t,onSave:d,isSaving:c})=>{const[a,n]=(0,l.useState)(t?.name||""),[x,h]=(0,l.useState)(t?.website||""),[g,i]=(0,l.useState)(t?.description||""),[u,w]=(0,l.useState)(t?.settings?.allowSelfSignup??!1),[r,p]=(0,l.useState)(t?.settings?.requireApproval??!0),[j,m]=(0,l.useState)(t?.settings?.maxTraders||10),[f,v]=(0,l.useState)(t?.tradeLockerServer||""),s=()=>{d({name:a,website:x,description:g,tradeLockerServer:f.trim(),settings:{...t?.settings,allowSelfSignup:u,requireApproval:r,maxTraders:j}})};return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-lg font-semibold text-white mb-4",children:"Basic Information"}),(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Organization Name"}),(0,e.jsx)("input",{type:"text",value:a,onChange:o=>n(o.target.value),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Website"}),(0,e.jsx)("input",{type:"url",value:x,onChange:o=>h(o.target.value),placeholder:"https://example.com",className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Description"}),(0,e.jsx)("textarea",{value:g,onChange:o=>i(o.target.value),rows:3,className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-blue-500 resize-none"})]})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-lg font-semibold text-white mb-4",children:"Member Settings"}),(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between p-4 bg-slate-900 rounded-xl border border-slate-700",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"font-medium text-white",children:"Allow Self-Signup"}),(0,e.jsx)("p",{className:"text-sm text-slate-400",children:"Traders can join using your organization code"})]}),(0,e.jsx)("button",{type:"button",onClick:()=>w(!u),className:`relative w-14 h-7 rounded-full transition-all duration-200 ${u?"bg-gradient-to-r from-blue-500 to-blue-600 shadow-lg shadow-blue-500/30":"bg-slate-600"}`,children:(0,e.jsx)("span",{className:`absolute top-0.5 left-0.5 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-200 ${u?"translate-x-7":"translate-x-0"}`})})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between p-4 bg-slate-900 rounded-xl border border-slate-700",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"font-medium text-white",children:"Require Approval"}),(0,e.jsx)("p",{className:"text-sm text-slate-400",children:"New members must be approved by an admin"})]}),(0,e.jsx)("button",{type:"button",onClick:()=>p(!r),className:`relative w-14 h-7 rounded-full transition-all duration-200 ${r?"bg-gradient-to-r from-blue-500 to-blue-600 shadow-lg shadow-blue-500/30":"bg-slate-600"}`,children:(0,e.jsx)("span",{className:`absolute top-0.5 left-0.5 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-200 ${r?"translate-x-7":"translate-x-0"}`})})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Maximum Traders"}),(0,e.jsx)(N,{min:1,value:j,onChange:o=>m(parseInt(o.target.value)||10),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,e.jsx)("p",{className:"mt-1 text-sm text-slate-500",children:"Maximum number of traders allowed in your organization (no limit)"})]})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-lg font-semibold text-white mb-1",children:"Broker Integration"}),(0,e.jsx)("p",{className:"text-sm text-slate-400 mb-4",children:"Configure the TradeLocker server so traders only need their credentials when accepting invites."}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"TradeLocker Server"}),(0,e.jsx)("input",{type:"text",value:f,onChange:o=>v(o.target.value),placeholder:"e.g. ALPHA (prop firm) or ICMarkets-Live01 (broker)",className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,e.jsx)("p",{className:"mt-1 text-sm text-slate-500",children:"Traders will not need to type this — it is pre-filled for them on invite acceptance."})]})]}),u&&(0,e.jsx)("div",{className:"p-4 bg-blue-500/10 border border-blue-500/30 rounded-xl",children:(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,e.jsx)(ee,{className:"w-5 h-5 text-blue-400 flex-shrink-0 mt-0.5"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"font-medium text-blue-300",children:"Organization Code"}
2),(0,e.jsx)("p",{className:"text-sm text-blue-200/70 mb-2",children:"Share this code with traders to join your organization:"}),(0,e.jsx)("code",{className:"px-3 py-1.5 bg-slate-900 rounded text-white font-mono text-sm",children:t?.id?.slice(0,8).toUpperCase()||"XXXXXXXX"})]})]})}),(0,e.jsxs)("button",{onClick:s,disabled:c,className:"px-6 py-3 bg-blue-600 hover:bg-blue-500 text-white rounded-lg font-medium flex items-center gap-2 disabled:opacity-50",children:[c?(0,e.jsx)("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):(0,e.jsx)(L,{className:"w-4 h-4"}),"Save Changes"]})]})},Q=[{value:"currency",label:"Currency ($)",placeholder:"e.g., 1000",icon:"$",color:"green"},{value:"percentage",label:"Percentage (%)",placeholder:"e.g., 10",icon:"%",color:"purple"},{value:"number",label:"Number",placeholder:"e.g., 5",icon:"#",color:"blue"},{value:"boolean",label:"Yes/No Toggle",placeholder:"",icon:"⚡",color:"amber"},{value:"text",label:"Text",placeholder:"e.g., Must hold for 1 hour",icon:"T",color:"slate"}],ne=({value:t,onChange:d,min:c=0,max:a,step:n=1,prefix:x="",suffix:h="",placeholder:g,color:i="blue"})=>{const u=p=>{const j=p.target.value;if(j==="")d("");else{const m=parseFloat(j);isNaN(m)||d(m)}},w=()=>{const p=parseFloat(t)||0;d(a!==void 0?Math.min(p+n,a):p+n)},r=()=>{d(Math.max((parseFloat(t)||0)-n,c))};return(0,e.jsxs)("div",{className:"flex items-center",children:[(0,e.jsx)("button",{type:"button",onClick:r,className:"px-3 py-2 bg-slate-700 hover:bg-slate-600 text-white rounded-l-lg border border-r-0 border-slate-600 transition-colors",children:(0,e.jsx)(Ee,{className:"w-4 h-4"})}),(0,e.jsxs)("div",{className:"relative flex-1",children:[x&&(0,e.jsx)("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-400 text-sm font-medium",children:x}),(0,e.jsx)(N,{value:t,onChange:u,min:c,max:a,step:n,placeholder:g,className:`w-full py-2 bg-slate-900 border-y border-slate-600 text-white text-center focus:outline-none focus:ring-2 ${{blue:"focus:ring-blue-500 focus:border-blue-500",green:"focus:ring-green-500 focus:border-green-500",purple:"focus:ring-purple-500 focus:border-purple-500"}[i]} ${x?"pl-7":"px-3"} ${h?"pr-8":"px-3"}`}),h&&(0,e.jsx)("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 text-sm font-medium",children:h})]}),(0,e.jsx)("button",{type:"button",onClick:w,className:"px-3 py-2 bg-slate-700 hover:bg-slate-600 text-white rounded-r-lg border border-l-0 border-slate-600 transition-colors",children:(0,e.jsx)(Z,{className:"w-4 h-4"})})]})},rs=({value:t,onChange:d,min:c=0,max:a=100,step:n=1})=>{const x=parseFloat(t)||0;return(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,e.jsx)("input",{type:"range",min:c,max:a,step:n,value:x,onChange:h=>d(parseFloat(h.target.value)),className:"flex-1 h-2 bg-slate-700 rounded-lg appearance-none cursor-pointer accent-purple-500",style:{background:`linear-gradient(to right, rgb(168, 85, 247) ${x}%, rgb(51, 65, 85) ${x}%)`}}),(0,e.jsxs)("div",{className:"w-20 flex items-center",children:[(0,e.jsx)(N,{value:t,onChange:h=>{d(h.target.value===""?"":Math.min(a,Math.max(c,parseFloat(h.target.value)||0)))},min:c,max:a,step:n,className:"w-14 px-2 py-1 bg-slate-900 border border-slate-600 rounded-l-lg text-white text-center text-sm focus:outline-none focus:ring-2 focus:ring-purple-500"}),(0,e.jsx)("span",{className:"px-2 py-1 bg-slate-700 border border-l-0 border-slate-600 rounded-r-lg text-slate-400 text-sm",children:"%"})]})]}),(0,e.jsxs)("div",{className:"flex justify-between text-xs text-slate-500",children:[(0,e.jsxs)("span",{children:[c,"%"]}),(0,e.jsxs)("span",{className:"text-purple-400 font-medium",children:[x,"%"]}),(0,e.jsxs)("span",{children:[a,"%"]})]})]})},H=({customRules:t=[],onChange:d})=>{const[c,a]=(0,l.useState)(t),[n,x]=(0,l.useState)(!1),[h,g]=(0,l.useState)(null),[i,u]=(0,l.useState)({name:"",description:"",type:"currency",value:"",enabled:!0}),w=()=>
2{if(!i.name.trim())return;const s={...i,id:`rule_${Date.now()}`,value:i.type==="boolean"?!0:i.value},o=[...c,s];a(o),d(o),u({name:"",description:"",type:"currency",value:"",enabled:!0}),x(!1)},r=s=>{const o=[...c];o[s]=i,a(o),d(o),g(null),u({name:"",description:"",type:"currency",value:"",enabled:!0})},p=s=>{const o=c.filter((k,T)=>T!==s);a(o),d(o)},j=s=>{const o=[...c];o[s].type==="boolean"?o[s].value=!o[s].value:o[s].enabled=!o[s].enabled,a(o),d(o)},m=s=>{u(c[s]),g(s),x(!1)},f=s=>s.type==="currency"?`$${parseFloat(s.value||0).toLocaleString()}`:s.type==="percentage"?`${s.value}%`:s.type==="boolean"?s.value?"Enabled":"Disabled":s.value,v=s=>Q.find(o=>o.value===s)||Q[0];return(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-lg font-semibold text-white",children:"Custom Rules"}),(0,e.jsx)("p",{className:"text-sm text-slate-400",children:"Define your own trading rules and limits"})]}),!n&&h===null&&(0,e.jsxs)("button",{onClick:()=>x(!0),className:"px-4 py-2 bg-gradient-to-r from-blue-600 to-blue-500 hover:from-blue-500 hover:to-blue-400 text-white rounded-lg text-sm font-medium flex items-center gap-2 shadow-lg shadow-blue-500/20 transition-all",children:[(0,e.jsx)(Z,{className:"w-4 h-4"}),"Add Rule"]})]}),(n||h!==null)&&(0,e.jsxs)("div",{className:"p-5 bg-gradient-to-br from-slate-800 to-slate-800/50 border border-slate-600 rounded-xl space-y-5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)("h4",{className:"text-base font-semibold text-white",children:h!==null?"✏️ Edit Rule":"✨ Create New Rule"}),(0,e.jsx)("button",{onClick:()=>{x(!1),g(null),u({name:"",description:"",type:"currency",value:"",enabled:!0})},className:"p-1 text-slate-400 hover:text-white transition-colors",children:(0,e.jsx)(Ve,{className:"w-5 h-5"})})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Rule Type"}),(0,e.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-2",children:Q.map(s=>{const o=i.type===s.value;return(0,e.jsxs)("button",{type:"button",onClick:()=>u({...i,type:s.value,value:""}),className:`p-3 rounded-lg border-2 transition-all ${{green:o?"border-green-500 bg-green-500/10":"border-slate-700 hover:border-green-500/50",purple:o?"border-purple-500 bg-purple-500/10":"border-slate-700 hover:border-purple-500/50",blue:o?"border-blue-500 bg-blue-500/10":"border-slate-700 hover:border-blue-500/50",amber:o?"border-amber-500 bg-amber-500/10":"border-slate-700 hover:border-amber-500/50",slate:o?"border-slate-500 bg-slate-500/10":"border-slate-700 hover:border-slate-500/50"}[s.color]} bg-slate-900`,children:[(0,e.jsx)("div",{className:"text-lg mb-1",children:s.icon}),(0,e.jsx)("div",{className:"text-xs font-medium text-white",children:s.label})]},s.value)})})]}),(0,e.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Rule Name *"}),(0,e.jsx)("input",{type:"text",value:i.name,onChange:s=>u({...i,name:s.target.value}),placeholder:"e.g., Max Daily Loss Limit",className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Description"}),(0,e.jsx)("input",{type:"text",value:i.description,onChange:s=>u({...i,description:s.target.value}),placeholder:"Brief description of this rule",className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-blue-500"})]})]}),i.type!=="boolean"&&(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:i.type==="currency"?"Amount ($)":i.type==="percentage"?"Percentage":i.type==="number"?"Value":"Text Value"}),i.type==="currency"&&(0,e.jsx)(ne,{value:i.value,onChange:s=>u({...i,value:s}),min:0,step:100,prefix:"$",placeholder:"Enter amount",color:"green"}),i.type==="percentage"&&(0,e.jsx)(rs,{value:i.value,onChange:s=>u({...i,value:s}),min:0,max:100,step:.5}),i.type==="number"&&(0,e.jsx)(ne,{value:i.value,onChange:s=>u({...i,value:s}),min:0,step:1,placeholder:"Enter number",color:"blue"}),i.type==="text"&&(0,e.jsx)("textarea",{value:i.value,onChange:s=>u({...i,value:s.target.value}),placeholder:"Enter rule text or description...",rows:2,className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-blue-500 resize-none"})]}),i.name&&(0,e.jsxs)("div",{className:"p-3 bg-slate-900/50 border border-slate-700 rounded-lg",children:[(0,e.jsx)("p",{className:"text-xs text-slate-500 mb-1",children:"Preview"}),(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)("span",{className:"text-white font-medium",children:i.name}),(0,e.jsx)("span",{className:`font-semibold ${i.type==="currency"?"text-green-400":i.type==="percentage"?"text-purple-400":"text-blue-400"}`,children:f(i)})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-3 pt-2",children:[(0,e.jsxs)("button",{onClick:h!==null?()=>r(h):w,disabled:!i.name.trim(),className:"px-5 py-2.5 bg-gradient-to-r from-green-600 to-green-500 hover:from-green-500 hover:to-green-400 text-white rounded-lg font-medium disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2 shadow-lg shadow-green-500/20 transition-all",children:[(0,e.jsx)(de,{className:"w-4 h-4"}),h!==null?"Update Rule":"Create Rule"]}),(0,e.jsx)("button",{onClick:()=>{x(!1),g(null),u({name:"",description:"",type:"currency",value:"",enabled:!0})},className:"px-5 py-2.5 bg-slate-700 hover:bg-slate-600 text-white rounded-lg font-medium transition-colors",children:"Cancel"})]})]}),c.length>0?(0,e.jsx)("div",{className:"space-y-3",children:c.map((s,o)=>{const k=v(s.type);return(0,e.jsx)("div",{className:`p-4 rounded-xl border transition-all ${s.enabled!==!1?"bg-slate-800/50 border-slate-700 hover:border-slate-600":"bg-slate-900/30 border-slate-800 opacity-60"}`,children:(0,e.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,e.jsx)("p",{className:`font-semibold ${s.enabled!==!1?"text-white":"text-slate-500"}`,children:s.name}),(0,e.jsxs)("span",{className:`text-xs px-2 py-0.5 rounded-full border ${{green:"bg-green-500/20 text-green-400 border-green-500/30",purple:"bg-purple-500/20 text-purple-400 border-purple-500/30",blue:"bg-blue-500/20 text-blue-400 border-blue-500/30",amber:"bg-amber-500/20 text-amber-400 border-amber-500/30",slate:"bg-slate-500/20 text-slate-400 border-slate-500/30"}[k.color]}`,children:[k.icon," ",k.label]})]}),s.description&&(0,e.jsx)("p",{className:"text-sm text-slate-500 mt-1",children:s.description})]}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[s.type!=="boolean"&&(0,e.jsx)("div",{className:`text-right ${s.enabled!==!1?"":"opacity-50"}`,children:(0,e.jsx)("p",{className:`text-lg font-bold ${s.type==="currency"?"text-green-400":s.type==="percentage"?"text-purple-400":"text-blue-400"}`,children:f(s)})}),s.type==="boolean"?(0,e.jsx)("button",{onClick:()=>j(o),className:`relative w-14 h-7 rounded-full transition-all duration-200 ${s.value?"bg-gradient-to-r from-green-500 to-green-600 shadow-lg shadow-green-500/30":"bg-slate-600"}`,children:(0,e.jsx)("span",{className:`absolute top-0.5 left-0.5 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-200 ${s.value?"translate-x-7":"translate-x-0"}`})}):(0,e.jsx)("button",{onClick:()=>j(o),className:`px-3 py-1.5 text-xs font-medium rounded-lg transition-colors ${s.enabled!==!1?"bg-green-500/20 text-green-400 hover:bg-green-500/30":"bg-red-500/20 text-red-400 hover:bg-red-500/30"}`,children:s.enabled!==!1?"Active":"Disabled"}),(0,e.jsxs)("div",{className:"flex items-center gap-1 border-l border-slate-700 pl-3",children:[(0,e.jsx)("button",{onClick:()=>m(o),className:"p-2 text-slate-400 hover:text-blue-400 hover:bg-blue-500/10 rounded-lg transition-all",title:"Edit rule",children:(0,e.jsx)(Me,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:()=>p(o),className:"p-2 text-slate-400 hover:text-red-400 hover:bg-red-500/10 rounded-lg transition-all",title:"Delete rule",children:(0,e.jsx)(se,{className:"w-4 h-4"})})]})]})]})},s.id||o)})}):!n&&(0,e.jsxs)("div",{className:"text-center py-12 bg-slate-800/30 rounded-xl border border-dashed border-slate-700",children:[(0,e.jsx)("div",{className:"w-16 h-16 bg-slate-800 rounded-full flex items-center justify-center mx-auto mb-4",children:(0,e.jsx)(X,{className:"w-8 h-8 text-slate-600"})}),(0,e.jsx)("p",{className:"text-slate-400 font-medium",children:"No custom rules yet"}),(0,e.jsx)("p",{className:"text-slate-500 text-sm mt-1 mb-4",children:"Define limits, thresholds, and guidelines for your traders"}),(0,e.jsxs)("button",{onClick:()=>x(!0),className:"px-4 py-2 bg-blue-600 hover:bg-blue-500 text-white rounded-lg text-sm font-medium inline-flex items-center gap-2",children:[(0,e.jsx)(Z,{className:"w-4 h-4"}),"Create Your First Rule"]})]})]})},ns=({org:t,onSave:d,isSaving:c})=>{const a=t?.teamRules||{},[n,x]=(0,l.useState)(a.monthlyProfitGoal||5e3),[h,g]=(0,l.useState)(a.minTradesPerWeek||5),[i,u]=(0,l.useState)(a.suggestedDailyLoss||500),[w,r]=(0,l.useState)(a.maxRiskPerTrade||2),[p,j]=(0,l.useState)(a.sharedWatchlist??!0),[m,f]=(0,l.useState)(a.tradeSharing??!0),[v,s]=(0,l.useState)(a.weeklyLeaderboard??!0),[o,k]=(0,l.useState)(a.teamChat??!0),[T,R]=(0,l.useState)(a.customRules||[]),C=()=>{d({teamRules:{monthlyProfitGoal:n,minTradesPerWeek:h,suggestedDailyLoss:i,maxRiskPerTrade:w,sharedWatchlist:p,tradeSharing:m,weeklyLeaderboard:v,teamChat:o,customRules:T}})};return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"p-4 bg-green-500/10 border border-green-500/30 rounded-xl flex items-start gap-3",children:[(0,e.jsx)(Je,{className:"w-5 h-5 text-green-400 flex-shrink-0 mt-0.5"}),(0,e.jsx)("p",{className:"text-sm text-green-200",children:"Configure team goals and trading guidelines for your group. These help keep members accountable and aligned with group objectives."})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-lg font-semibold text-white mb-4",children:"Team Performance Goals"}),(0,e.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Monthly Profit Goal ($)"}),(0,e.jsx)(N,{min:0,step:500,value:n,onChange:S=>x(parseFloat(S.target.value)||5e3),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-green-500"}),(0,e.jsx)("p",{className:"mt-1 text-xs text-slate-500",children:"Team's collective monthly profit target"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Min Trades Per Week"}),(0,e.jsx)(N,{min:0,max:100,value:h,onChange:S=>g(parseInt(S.target.value)||5),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-green-500"}),(0,e.jsx)("p",{className:"mt-1 text-xs text-slate-500",children:"Minimum trades expected per member weekly"})]})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-lg font-semibold text-white mb-4",children:"Risk Guidelines"}),(0,e.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Suggested Daily Loss Limit ($)"}),(0,e.jsx)(N,{min:0,step:100,value:i,onChange:S=>u(parseFloat(S.target.value)||500),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-green-500"}),(0,e.jsx)("p",{className:"mt-1 text-xs text-slate-500",children:"Recommended max daily loss for members"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Max Risk Per Trade (%)"}),(0,e.jsx)(N,{min:.5,max:10,step:.5,value:w,onChange:S=>r(parseFloat(S.target.value)||2),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-green-500"}),(0,e.jsx)("p",{className:"mt-1 text-xs text-slate-500",children:"Suggested % of account to risk per trade"})]})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-lg font-semibold text-white mb-4",children:"Team Features"}),(0,e.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[{key:"sharedWatchlist",value:p,setter:j,label:"Shared Watchlist",desc:"Allow members to contribute to team watchlist"},{key:"tradeSharing",value:m,setter:f,label:"Trade Sharing",desc:"Members can share trades with the group"},{key:"weeklyLeaderboard",value:v,setter:s,label:"Weekly Leaderboard",desc:"Show performance rankings each week"},{key:"teamChat",value:o,setter:k,label:"Team Chat",desc:"Enable group chat for members"}].map(S=>(0,e.jsxs)("div",{className:"flex items-center justify-between p-4 bg-slate-900 rounded-xl border border-slate-700",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"font-medium text-white",children:S.label}),(0,e.jsx)("p",{className:"text-sm text-slate-400",children:S.desc})]}),(0,e.jsx)("button",{type:"button",onClick:()=>
2S.setter(!S.value),className:`relative w-14 h-7 rounded-full transition-all duration-200 ${S.value?"bg-gradient-to-r from-green-500 to-green-600 shadow-lg shadow-green-500/30":"bg-slate-600"}`,children:(0,e.jsx)("span",{className:`absolute top-0.5 left-0.5 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-200 ${S.value?"translate-x-7":"translate-x-0"}`})})]},S.key))})]}),(0,e.jsxs)("div",{className:"p-4 bg-slate-900 rounded-xl border border-slate-700",children:[(0,e.jsx)("h4",{className:"text-sm font-medium text-slate-300 mb-3",children:"Rules Summary"}),(0,e.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[(0,e.jsxs)("div",{className:"flex flex-col",children:[(0,e.jsx)("span",{className:"text-slate-500",children:"Monthly Goal"}),(0,e.jsxs)("span",{className:"text-green-400 font-semibold",children:["$",n.toLocaleString()]})]}),(0,e.jsxs)("div",{className:"flex flex-col",children:[(0,e.jsx)("span",{className:"text-slate-500",children:"Min Trades"}),(0,e.jsxs)("span",{className:"text-green-400 font-semibold",children:[h,"/week"]})]}),(0,e.jsxs)("div",{className:"flex flex-col",children:[(0,e.jsx)("span",{className:"text-slate-500",children:"Daily Limit"}),(0,e.jsxs)("span",{className:"text-yellow-400 font-semibold",children:["$",i]})]}),(0,e.jsxs)("div",{className:"flex flex-col",children:[(0,e.jsx)("span",{className:"text-slate-500",children:"Risk/Trade"}),(0,e.jsxs)("span",{className:"text-yellow-400 font-semibold",children:[w,"%"]})]})]})]}),(0,e.jsx)("div",{className:"pt-4 border-t border-slate-700",children:(0,e.jsx)(H,{customRules:T,onChange:R})}),(0,e.jsxs)("button",{onClick:C,disabled:c,className:"px-6 py-3 bg-green-600 hover:bg-green-500 text-white rounded-lg font-medium flex items-center gap-2 disabled:opacity-50",children:[c?(0,e.jsx)("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):(0,e.jsx)(L,{className:"w-4 h-4"}),"Save Team Rules"]})]})},is=({org:t,onSave:d,isSaving:c})=>{const[a,n]=(0,l.useState)((t?.brokerageRules||{}).customRules||[]),x=()=>{d({brokerageRules:{customRules:a}})};return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"p-4 bg-slate-500/10 border border-slate-500/30 rounded-xl flex items-start gap-3",children:[(0,e.jsx)(X,{className:"w-5 h-5 text-slate-400 flex-shrink-0 mt-0.5"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm text-slate-200",children:"Brokerage accounts use standard industry compliance rules by default."}),(0,e.jsx)("p",{className:"text-xs text-slate-400 mt-1",children:"You can add custom rules below to supplement standard compliance requirements."})]})]}),(0,e.jsx)(H,{customRules:a,onChange:n}),(0,e.jsxs)("button",{onClick:x,disabled:c,className:"px-6 py-3 bg-slate-600 hover:bg-slate-500 text-white rounded-lg font-medium flex items-center gap-2 disabled:opacity-50",children:[c?(0,e.jsx)("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):(0,e.jsx)(L,{className:"w-4 h-4"}),"Save Rules"]})]})},os=({org:t,onSave:d,isSaving:c})=>{const a=t?.complianceRules||{},[n,x]=(0,l.useState)(a.minAccountSize||25e3),[h,g]=(0,l.useState)(a.maxClientsPerAdvisor||100),[i,u]=(0,l.useState)(a.managementFee||1),[w,r]=(0,l.useState)(a.performanceFee||0),[p,j]=(0,l.useState)(a.maxSinglePosition||10),[m,f]=(0,l.useState)(a.maxSectorConcentration||25),[v,s]=(0,l.useState)(a.suitabilityRequired??!0),[o,k]=(0,l.useState)(a.quarterlyReporting??!0),[T,R]=(0,l.useState)(a.adv2Disclosure??!0),[C,S]=(0,l.useState)(a.custodyCompliance??!1),[E,A]=(0,l.useState)(a.customRules||[]),V=()=>{d({complianceRules:{minAccountSize:n,maxClientsPerAdvisor:h,managementFee:i,performanceFee:w,maxSinglePosition:p,maxSectorConcentration:m,suitabilityRequired:v,quarterlyReporting:o,adv2Disclosure:T,custodyCompliance:C,customRules:E}})};return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"p-4 bg-purple-500/10 border border-purple-500/30 rounded-xl flex items-start gap-3",children:[(0,e.jsx)(ee,{className:"w-5 h-5 text-purple-400 flex-shrink-0 mt-0.5"}),(0,e.jsx)("p",{className:"text-sm text-purple-200",children:"Configure compliance and advisory rules for your RIA. These settings help ensure SEC/state regulatory compliance and protect your clients."})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-lg font-semibold text-white mb-4",children:"Client & Asset Thresholds"}),(0,e.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Minimum Account Size ($)"}),(0,e.jsx)(N,{min:0,step:5e3,value:n,onChange:y=>x(parseFloat(y.target.value)||25e3),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-purple-500"}),(0,e.jsx)("p",{className:"mt-1 text-xs text-slate-500",children:"Minimum AUM required to open advisory account"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Maximum Clients Per Advisor"}),(0,e.jsx)(N,{min:1,max:1e3,value:h,onChange:y=>g(parseInt(y.target.value)||100),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-purple-500"}),(0,e.jsx)("p",{className:"mt-1 text-xs text-slate-500",children:"Maximum clients each advisor can manage"})]})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-lg font-semibold text-white mb-4",children:"Fee Structure"}),(0,e.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Management Fee (%)"}),(0,e.jsx)(N,{min:0,max:5,step:.1,value:i,onChange:y=>u(parseFloat(y.target.value)||1),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-purple-500"}),(0,e.jsx)("p",{className:"mt-1 text-xs text-slate-500",children:"Annual management fee as % of AUM"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Performance Fee (%)"}),(0,e.jsx)(N,{min:0,max:30,step:1,value:w,onChange:y=>r(parseFloat(y.target.value)||0),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-purple-500"}),(0,e.jsx)("p",{className:"mt-1 text-xs text-slate-500",children:"Performance fee on profits (0 if not applicable)"})]})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-lg font-semibold text-white mb-4",children:"Investment Guidelines"}),(0,e.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Max Single Position (%)"}),(0,e.jsx)(N,{min:1,max:100,step:1,value:p,onChange:y=>j(parseFloat(y.target.value)||10),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-purple-500"}),(0,e.jsx)("p",{className:"mt-1 text-xs text-slate-500",children:"Maximum % of portfolio in a single position"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Max Sector Concentration (%)"}),(0,e.jsx)(N,{min:1,max:100,step:1,value:m,onChange:y=>f(parseFloat(y.target.value)||25),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-purple-500"}),(0,e.jsx)("p",{className:"mt-1 text-xs text-slate-500",children:"Maximum % of portfolio in any sector"})]})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-lg font-semibold text-white mb-4",children:"Compliance & Reporting"}),(0,e.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[{key:"suitabilityRequired",value:v,setter:s,label:"Suitability Assessment",desc:"Require risk assessment before onboarding clients"},{key:"quarterlyReporting",value:o,setter:k,label:"Quarterly Reports",desc:"Auto-generate quarterly performance reports"},{key:"adv2Disclosure",value:T,setter:R,label:"ADV Part 2 Disclosure",desc:"Require ADV disclosure acknowledgment"}
2,{key:"custodyCompliance",value:C,setter:S,label:"Custody Compliance",desc:"Enable custody safeguards and audits"}].map(y=>(0,e.jsxs)("div",{className:"flex items-center justify-between p-4 bg-slate-900 rounded-xl border border-slate-700",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"font-medium text-white",children:y.label}),(0,e.jsx)("p",{className:"text-sm text-slate-400",children:y.desc})]}),(0,e.jsx)("button",{type:"button",onClick:()=>y.setter(!y.value),className:`relative w-14 h-7 rounded-full transition-all duration-200 ${y.value?"bg-gradient-to-r from-purple-500 to-purple-600 shadow-lg shadow-purple-500/30":"bg-slate-600"}`,children:(0,e.jsx)("span",{className:`absolute top-0.5 left-0.5 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-200 ${y.value?"translate-x-7":"translate-x-0"}`})})]},y.key))})]}),(0,e.jsxs)("div",{className:"p-4 bg-slate-900 rounded-xl border border-slate-700",children:[(0,e.jsx)("h4",{className:"text-sm font-medium text-slate-300 mb-3",children:"Rule Summary"}),(0,e.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[(0,e.jsxs)("div",{className:"flex flex-col",children:[(0,e.jsx)("span",{className:"text-slate-500",children:"Min Account"}),(0,e.jsxs)("span",{className:"text-purple-400 font-semibold",children:["$",n.toLocaleString()]})]}),(0,e.jsxs)("div",{className:"flex flex-col",children:[(0,e.jsx)("span",{className:"text-slate-500",children:"Mgmt Fee"}),(0,e.jsxs)("span",{className:"text-purple-400 font-semibold",children:[i,"%"]})]}),(0,e.jsxs)("div",{className:"flex flex-col",children:[(0,e.jsx)("span",{className:"text-slate-500",children:"Max Position"}),(0,e.jsxs)("span",{className:"text-blue-400 font-semibold",children:[p,"%"]})]}),(0,e.jsxs)("div",{className:"flex flex-col",children:[(0,e.jsx)("span",{className:"text-slate-500",children:"Max Sector"}),(0,e.jsxs)("span",{className:"text-blue-400 font-semibold",children:[m,"%"]})]})]})]}),(0,e.jsx)("div",{className:"pt-4 border-t border-slate-700",children:(0,e.jsx)(H,{customRules:E,onChange:A})}),(0,e.jsxs)("button",{onClick:V,disabled:c,className:"px-6 py-3 bg-purple-600 hover:bg-purple-500 text-white rounded-lg font-medium flex items-center gap-2 disabled:opacity-50",children:[c?(0,e.jsx)("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):(0,e.jsx)(L,{className:"w-4 h-4"}),"Save Compliance Rules"]})]})},ds=({org:t,onSave:d,isSaving:c})=>{const[a,n]=(0,l.useState)(()=>t?.accountTiers?.length>0?t.accountTiers:Ue.map(r=>({value:r.value,label:r.label,description:r.description,rules:{maxDailyLoss:r.rules?.maxDailyLoss||5,maxTotalDrawdown:r.rules?.maxTotalDrawdown||10,profitTarget:r.rules?.profitTarget||10,minTradingDays:r.rules?.minTradingDays||5,maxLeverage:r.rules?.maxLeverage||10,newsTrading:r.rules?.newsTrading??!1,weekendHolding:r.rules?.weekendHolding??!1}}))),[x,h]=(0,l.useState)(null),[g,i]=(0,l.useState)(!1),u=(r,p,j)=>{n(m=>m.map(f=>f.value===r?{...f,rules:{...f.rules,[p]:j}}:f)),i(!0)},w=()=>{d({accountTiers:a}),i(!1),h(null)};return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"p-4 bg-blue-500/10 border border-blue-500/30 rounded-xl flex items-start gap-3",children:[(0,e.jsx)(ee,{className:"w-5 h-5 text-blue-400 flex-shrink-0 mt-0.5"}),(0,e.jsx)("div",{children:(0,e.jsxs)("p",{className:"text-sm text-blue-200",children:[(0,e.jsx)("strong",{children:"Account Tier Rules"})," - Configure specific risk limits for each account size. These rules will be automatically applied when generating invite links."]})})]}),(0,e.jsx)("div",{className:"space-y-4",children:a.map(r=>{const p=x===r.value;return(0,e.jsxs)(M.div,{className:`p-4 rounded-xl border transition-all ${p?"bg-slate-800 border-green-500":"bg-slate-800/50 border-slate-700 hover:border-slate-600"}`,children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)("div",{className:"p-2 bg-green-500/20 rounded-lg",children:(0,e.jsx)(P,{className:"w-5 h-5 text-green-400"})}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h4",{className:"text-lg font-bold text-white",children:r.label}),(0,e.jsxs)("p",{className:"text-sm text-slate-400",children:[r.description," Account"]})]})]}),(0,e.jsx)("button",{onClick:()=>h(p?null:r.value),className:`px-3 py-1.5 rounded-lg text-sm font-medium transition-all ${p?"bg-slate-700 text-slate-300":"bg-blue-500/20 text-blue-400 hover:bg-blue-500/30"}`,children:p?"Close":"Edit Rules"})]}),(0,e.jsxs)("div",{className:`grid grid-cols-2 sm:grid-cols-4 gap-2 sm:gap-3 ${p?"":"opacity-80"}`,children:[(0,e.jsxs)("div",{className:"p-3 bg-slate-900 rounded-lg",children:[(0,e.jsx)("label",{className:"block text-xs text-slate-400 mb-1",children:"Daily Loss Limit"}),p?(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(N,{min:1,max:20,step:.5,value:r.rules?.maxDailyLoss||5,onChange:j=>u(r.value,"maxDailyLoss",parseFloat(j.target.value)),className:"w-full px-2 py-1 bg-slate-800 border border-slate-600 rounded text-white text-sm"}),(0,e.jsx)("span",{className:"text-slate-400 text-sm",children:"%"})]}):(0,e.jsxs)("p",{className:"text-red-400 font-semibold",children:[r.rules?.maxDailyLoss||5,"%"]})]}),(0,e.jsxs)("div",{className:"p-3 bg-slate-900 rounded-lg",children:[(0,e.jsx)("label",{className:"block text-xs text-slate-400 mb-1",children:"Max Drawdown"}),p?(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(N,{min:1,max:50,step:.5,value:r.rules?.maxTotalDrawdown||10,onChange:j=>u(r.value,"maxTotalDrawdown",parseFloat(j.target.value)),className:"w-full px-2 py-1 bg-slate-800 border border-slate-600 rounded text-white text-sm"}),(0,e.jsx)("span",{className:"text-slate-400 text-sm",children:"%"})]}):(0,e.jsxs)("p",{className:"text-orange-400 font-semibold",children:[r.rules?.maxTotalDrawdown||10,"%"]})]}),(0,e.jsxs)("div",{className:"p-3 bg-slate-900 rounded-lg",children:[(0,e.jsx)("label",{className:"block text-xs text-slate-400 mb-1",children:"Profit Target"}),p?(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(N,{min:1,max:50,step:.5,value:r.rules?.profitTarget||10,onChange:j=>u(r.value,"profitTarget",parseFloat(j.target.value)),className:"w-full px-2 py-1 bg-slate-800 border border-slate-600 rounded text-white text-sm"}),(0,e.jsx)("span",{className:"text-slate-400 text-sm",children:"%"})]}):(0,e.jsxs)("p",{className:"text-green-400 font-semibold",children:[r.rules?.profitTarget||10,"%"]})]}),(0,e.jsxs)("div",{className:"p-3 bg-slate-900 rounded-lg",children:[(0,e.jsx)("label",{className:"block text-xs text-slate-400 mb-1",children:"Min Trading Days"}),p?(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(N,{min:1,max:60,value:r.rules?.minTradingDays||5,onChange:j=>u(r.value,"minTradingDays",parseInt(j.target.value)),className:"w-full px-2 py-1 bg-slate-800 border border-slate-600 rounded text-white text-sm"}),(0,e.jsx)("span",{className:"text-slate-400 text-sm",children:"days"})]}):(0,e.jsxs)("p",{className:"text-blue-400 font-semibold",children:[r.rules?.minTradingDays||5," days"]})]})]}),p&&(0,e.jsxs)("div",{className:"mt-4 pt-4 border-t border-slate-700",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-slate-300 mb-3",children:"Additional Rules"}),(0,e.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2 sm:gap-3",children:[(0,e.jsxs)("div",{className:"p-3 bg-slate-900 rounded-lg",children:[(0,e.jsx)("label",{className:"block text-xs text-slate-400 mb-1",children:"Max Leverage"}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(N,{min:1,max:500,value:r.rules?.maxLeverage||10,onChange:j=>u(r.value,"maxLeverage",parseInt(j.target.value)),className:"w-full px-2 py-1 bg-slate-800 border border-slate-600 rounded text-white text-sm"}),(0,e.jsx)("span",{className:"text-slate-400 text-sm",children:"x"})]})]}),(0,e.jsxs)("div",{className:"p-3 bg-slate-900 rounded-lg",children:[(0,e.jsx)("label",{className:"block text-xs text-slate-400 mb-1",children:"News Trading"}),(0,e.jsx)("button",{onClick:()=>u(r.value,"newsTrading",!r.rules?.newsTrading),className:`w-full px-3 py-1.5 rounded text-sm font-medium transition-all ${r.rules?.newsTrading?"bg-green-500/20 text-green-400 border border-green-500/50":"bg-red-500/20 text-red-400 border border-red-500/50"}`,children:r.rules?.newsTrading?"Allowed":"Not Allowed"})]}),(0,e.jsxs)("div",{className:"p-3 bg-slate-900 rounded-lg",children:[(0,e.jsx)("label",{className:"block text-xs text-slate-400 mb-1",children:"Weekend Holding"}),(0,e.jsx)("button",{onClick:()=>u(r.value,"weekendHolding",!r.rules?.weekendHolding),className:`w-full px-3 py-1.5 rounded text-sm font-medium transition-all ${r.rules?.weekendHolding?"bg-green-500/20 text-green-400 border border-green-500/50":"bg-red-500/20 text-red-400 border border-red-500/50"}`,children:r.rules?.weekendHolding?"Allowed":"Not Allowed"})]})]})]})]},r.value)})}),g&&(0,e.jsx)(M.div,{initial:{opacity:0,y:20}
2,animate:{opacity:1,y:0},className:"sticky bottom-4",children:(0,e.jsxs)("button",{onClick:w,disabled:c,className:"w-full px-6 py-4 bg-green-600 hover:bg-green-500 text-white rounded-xl font-semibold flex items-center justify-center gap-2 shadow-lg disabled:opacity-50",children:[c?(0,e.jsx)(qe,{className:"w-5 h-5 animate-spin"}):(0,e.jsx)(L,{className:"w-5 h-5"}),"Save Account Tier Rules"]})})]})},cs=({org:t,onSave:d,isSaving:c})=>{const a=t?.riskRules||{},n=t?.settings||{},[x,h]=(0,l.useState)(a.accountBalance||n.accountBalance||5e4),[g,i]=(0,l.useState)(a.maxDailyLoss||n.dailyLossLimit||1e3),[u,w]=(0,l.useState)(a.maxTotalDrawdown||n.maxDrawdownPercent||10),[r,p]=(0,l.useState)(n.maxPositionSize||1e5),[j,m]=(0,l.useState)(a.profitTarget||1e4),[f,v]=(0,l.useState)(a.minTradingDays||10),[s,o]=(0,l.useState)(n.maxTradesPerDay||50),[k,T]=(0,l.useState)(n.profitSplit||80),[R,C]=(0,l.useState)(n.drawdownType||"end_of_day"),[S,E]=(0,l.useState)(n.dailyLossRule??!0),[A,V]=(0,l.useState)(n.consistencyRule??!1),[y,me]=(0,l.useState)(n.consistencyPercent||30),[q,ue]=(0,l.useState)(n.newsRule??!1),[F,be]=(0,l.useState)(n.newsBlackoutMinutes||5),[Y,he]=(0,l.useState)(n.scalingPlan??!1),[te,ge]=(0,l.useState)(n.maxAccounts||5),[ae,pe]=(0,l.useState)(n.bufferRequirement??!1),[B,fe]=(0,l.useState)(n.minDaysToWithdraw||0),[O,je]=(0,l.useState)(n.maxWithdrawalPercent||100),[W,ve]=(0,l.useState)(n.overnightPositions??!0),[z,Ne]=(0,l.useState)(n.weekendPositions??!0),[_,we]=(0,l.useState)(n.phaseDuration||30),[$,ye]=(0,l.useState)(a.warnAtPercent??n.warnAtPercent??75),[I,ke]=(0,l.useState)(a.criticalAtPercent??n.criticalAtPercent??90),[le,Se]=(0,l.useState)(a.customRules||[]),Ce=()=>{d({riskRules:{accountBalance:x,maxDailyLoss:g,maxTotalDrawdown:u,maxDrawdownPercent:u,profitTarget:j,minTradingDays:f,drawdownType:R,consistencyRule:A,maxConsistencyPercent:y,newsTrading:!q,newsBlackoutMinutes:F,overnightPositions:W,weekendPositions:z,scalingPlan:Y,phaseDuration:_,customRules:le,warnAtPercent:$,criticalAtPercent:I},settings:{...n,accountBalance:x,maxDrawdownPercent:u,maxPositionSize:r,dailyLossLimit:g,maxTradesPerDay:s,profitSplit:k,drawdownType:R,dailyLossRule:S,consistencyRule:A,consistencyPercent:y,newsRule:q,newsBlackoutMinutes:F,scalingPlan:Y,maxAccounts:te,bufferRequirement:ae,minDaysToWithdraw:B,maxWithdrawalPercent:O,overnightPositions:W,weekendPositions:z,phaseDuration:_,warnAtPercent:$,criticalAtPercent:I}})};return t?.type==="brokerage"?(0,e.jsx)(is,{org:t,onSave:d,isSaving:c}):t?.type==="ria"?(0,e.jsx)(os,{org:t,onSave:d,isSaving:c}):t?.type==="trading_group"?(0,e.jsx)(ns,{org:t,onSave:d,isSaving:c}):(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-xl flex items-start gap-3",children:[(0,e.jsx)(D,{className:"w-5 h-5 text-yellow-400 flex-shrink-0 mt-0.5"}),(0,e.jsx)("p",{className:"text-sm text-yellow-200",children:"Changes to risk rules will apply to all new evaluations. Existing traders will continue with their current rules until they reset or start a new phase."})]}),(0,e.jsxs)("div",{className:"p-5 bg-gradient-to-r from-blue-500/10 to-purple-500/10 border border-blue-500/30 rounded-xl",children:[(0,e.jsxs)("h3",{className:"text-lg font-semibold text-white mb-2 flex items-center gap-2",children:[(0,e.jsx)(P,{className:"w-5 h-5 text-blue-400"}),"Account Balance (Funded Amount)"]}),(0,e.jsx)("p",{className:"text-sm text-slate-400 mb-4",children:"Set the starting capital for trader accounts. All percentage-based risk rules will be calculated from this balance."}),(0,e.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2 sm:gap-3",children:[25e3,5e4,1e5,15e4,2e5,25e4].map(b=>(0,e.jsxs)("button",{type:"button",onClick:()=>h(b),className:`px-4 py-3 rounded-lg font-semibold transition-all ${x===b?"bg-blue-600 text-white border-2 border-blue-400":"bg-slate-800 text-slate-300 border border-slate-600 hover:border-blue-500"}`,children:["$",b.toLocaleString()]},b))}),(0,e.jsxs)("div",{className:"mt-4",children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Custom Amount ($)"}),(0,e.jsx)(N,{min:1e3,step:1e3,value:x,onChange:b=>h(parseFloat(b.target.value)||5e4),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500"})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-lg font-semibold text-white mb-4",children:"Core Risk Limits"}),(0,e.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Max Daily Loss ($)"}),(0,e.jsx)(N,{min:0,step:100,value:g,onChange:b=>i(parseFloat(b.target.value)||0),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,e.jsxs)("p",{className:"mt-1 text-xs text-slate-500",children:["Maximum loss allowed per trading day (",(g/x*100).toFixed(1),"% of balance)"]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Max Drawdown (%)"}),(0,e.jsx)(N,{min:1,max:100,step:.5,value:u,onChange:b=>
2w(parseFloat(b.target.value)||0),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,e.jsxs)("p",{className:"mt-1 text-xs text-slate-500",children:["Maximum drawdown from peak equity ($",(u/100*x).toLocaleString(),")"]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Max Position Size ($)"}),(0,e.jsx)(N,{min:0,step:1e3,value:r,onChange:b=>p(parseFloat(b.target.value)||0),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,e.jsx)("p",{className:"mt-1 text-xs text-slate-500",children:"Maximum position size per trade"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Max Trades Per Day"}),(0,e.jsx)(N,{min:1,max:500,value:s,onChange:b=>o(parseInt(b.target.value)||50),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,e.jsx)("p",{className:"mt-1 text-xs text-slate-500",children:"Maximum number of trades per day"})]})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-lg font-semibold text-white mb-4",children:"Drawdown Configuration"}),(0,e.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[{value:"end_of_day",label:"End of Day",desc:"Calculated at market close"},{value:"intraday",label:"Intraday",desc:"Real-time tracking"},{value:"trailing",label:"Trailing",desc:"Moves with high water mark"}].map(b=>(0,e.jsxs)("button",{type:"button",onClick:()=>C(b.value),className:`p-4 rounded-xl border-2 text-left transition-all ${R===b.value?"border-blue-500 bg-blue-500/10":"border-slate-700 bg-slate-800 hover:border-slate-600"}`,children:[(0,e.jsx)("span",{className:"font-semibold text-white",children:b.label}),(0,e.jsx)("p",{className:"text-sm text-slate-400 mt-1",children:b.desc})]},b.value))})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-lg font-semibold text-white mb-4",children:"Evaluation Targets"}),(0,e.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Profit Target ($)"}),(0,e.jsx)(N,{min:0,step:500,value:j,onChange:b=>m(parseFloat(b.target.value)||0),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,e.jsxs)("p",{className:"mt-1 text-xs text-slate-500",children:["Profit target to pass evaluation (",(j/x*100).toFixed(1),"% of balance)"]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Min Trading Days"}),(0,e.jsx)(N,{min:1,max:90,value:f,onChange:b=>v(parseInt(b.target.value)||10),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,e.jsx)("p",{className:"mt-1 text-xs text-slate-500",children:"Minimum days before evaluation completes"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Profit Split (%) - Trader"}),(0,e.jsx)(N,{min:50,max:100,value:k,onChange:b=>T(parseInt(b.target.value)||80),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,e.jsxs)("p",{className:"mt-1 text-xs text-slate-500",children:[k,"/",100-k," split (Trader/Firm)"]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Max Accounts Per Trader"}),(0,e.jsx)(N,{min:1,max:20,value:te,onChange:b=>ge(parseInt(b.target.value)||5),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,e.jsx)("p",{className:"mt-1 text-xs text-slate-500",children:"Maximum funded accounts per trader"})]})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-lg font-semibold text-white mb-4",children:"Withdrawal Rules"}),(0,e.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Min Days Until First Withdrawal"}),(0,e.jsx)(N,{min:0,max:90,value:B,onChange:b=>fe(parseInt(b.target.value)||0),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,e.jsx)("p",{className:"mt-1 text-xs text-slate-500",children:B===0?"Immediate withdrawals allowed":`${B} days before first withdrawal`})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Max Withdrawal Per Request (%)"}),(0,e.jsx)(N,{min:10,max:100,value:O,onChange:b=>je(parseInt(b.target.value)||100),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,e.jsx)("p",{className:"mt-1 text-xs text-slate-500",children:O===100?"No limit on withdrawal amount":`Max ${O}% of profits per withdrawal`})]})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-lg font-semibold text-white mb-4",children:"Phase Duration"}),(0,e.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Evaluation Phase Duration (Days)"}
2),(0,e.jsx)(N,{min:7,max:365,value:_,onChange:b=>we(parseInt(b.target.value)||30),className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,e.jsxs)("p",{className:"mt-1 text-xs text-slate-500",children:["Traders must complete evaluation within ",_," days or phase expires"]})]})})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-lg font-semibold text-white mb-4",children:"Advanced Trading Rules"}),(0,e.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[{key:"dailyLossRule",value:S,setter:E,label:"Daily Loss Rule",desc:"Enforce maximum daily loss limit"},{key:"consistencyRule",value:A,setter:V,label:"Consistency Rule",desc:`No single day can exceed ${y}% of total profit`},{key:"newsRule",value:q,setter:ue,label:"News Trading Rule",desc:`Block trades ±${F} min around major news`},{key:"overnightPositions",value:!W,setter:()=>ve(!W),label:"No Overnight Positions",desc:"Positions must be closed before market close"},{key:"weekendPositions",value:!z,setter:()=>Ne(!z),label:"No Weekend Positions",desc:"Positions must be closed before weekend"},{key:"scalingPlan",value:Y,setter:he,label:"Scaling Plan",desc:"Enable account scaling based on performance"},{key:"bufferRequirement",value:ae,setter:pe,label:"Buffer Requirement",desc:"Require profit buffer before withdrawals"}].map(b=>(0,e.jsxs)("div",{className:"flex items-center justify-between p-4 bg-slate-900 rounded-xl border border-slate-700",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"font-medium text-white",children:b.label}),(0,e.jsx)("p",{className:"text-sm text-slate-400",children:b.desc})]}),(0,e.jsx)("button",{type:"button",onClick:()=>b.setter(!b.value),className:`relative w-14 h-7 rounded-full transition-all duration-200 ${b.value?"bg-gradient-to-r from-blue-500 to-blue-600 shadow-lg shadow-blue-500/30":"bg-slate-600"}`,children:(0,e.jsx)("span",{className:`absolute top-0.5 left-0.5 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-200 ${b.value?"translate-x-7":"translate-x-0"}`})})]},b.key))}),A&&(0,e.jsxs)("div",{className:"mt-4 p-4 bg-slate-900/50 rounded-xl border border-slate-700",children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"Consistency Rule Percentage (%)"}),(0,e.jsx)(N,{min:10,max:50,value:y,onChange:b=>me(parseInt(b.target.value)||30),className:"w-32 px-3 py-2 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,e.jsxs)("p",{className:"mt-1 text-xs text-slate-500",children:["No single trading day can exceed ",y,"% of total profits"]})]}),q&&(0,e.jsxs)("div",{className:"mt-4 p-4 bg-slate-900/50 rounded-xl border border-slate-700",children:[(0,e.jsx)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:"News Blackout Window (Minutes)"}),(0,e.jsx)(N,{min:1,max:60,value:F,onChange:b=>be(parseInt(b.target.value)||5),className:"w-32 px-3 py-2 bg-slate-900 border border-slate-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500"}),(0,e.jsxs)("p",{className:"mt-1 text-xs text-slate-500",children:["Trading blocked ",F," minutes before and after major economic events"]})]})]}),(0,e.jsxs)("div",{className:"p-4 bg-slate-900 rounded-xl border border-slate-700",children:[(0,e.jsx)("h4",{className:"text-sm font-medium text-slate-300 mb-3",children:"Rule Summary"}),(0,e.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-6 gap-4 text-sm",children:[(0,e.jsxs)("div",{className:"flex flex-col",children:[(0,e.jsx)("span",{className:"text-slate-500",children:"Account Size"}),(0,e.jsxs)("span",{className:"text-blue-400 font-semibold",children:["$",x.toLocaleString()]})]}),(0,e.jsxs)("div",{className:"flex flex-col",children:[(0,e.jsx)("span",{className:"text-slate-500",children:"Daily Loss"}),(0,e.jsxs)("span",{className:"text-red-400 font-semibold",children:["$",g.toLocaleString()]})]}),(0,e.jsxs)("div",{className:"flex flex-col",children:[(0,e.jsx)("span",{className:"text-slate-500",children:"Max Drawdown"}),(0,e.jsxs)("span",{className:"text-red-400 font-semibold",children:[u,"% (",R,")"]})]}),(0,e.jsxs)("div",{className:"flex flex-col",children:[(0,e.jsx)("span",{className:"text-slate-500",children:"Profit Target"}),(0,e.jsxs)("span",{className:"text-green-400 font-semibold",children:["$",j.toLocaleStr
2ing()]})]}),(0,e.jsxs)("div",{className:"flex flex-col",children:[(0,e.jsx)("span",{className:"text-slate-500",children:"Profit Split"}),(0,e.jsxs)("span",{className:"text-blue-400 font-semibold",children:[k,"/",100-k]})]}),(0,e.jsxs)("div",{className:"flex flex-col",children:[(0,e.jsx)("span",{className:"text-slate-500",children:"Phase Duration"}),(0,e.jsxs)("span",{className:"text-purple-400 font-semibold",children:[_," days"]})]})]})]}),(0,e.jsxs)("div",{className:"p-5 bg-slate-800/50 border border-slate-700 rounded-xl space-y-5",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[(0,e.jsx)(D,{className:"w-4 h-4 text-orange-400"}),"Alert Thresholds"]}),(0,e.jsx)("p",{className:"text-sm text-slate-400 mt-1",children:"When a trader's drawdown or daily loss reaches these percentages of their limit, they are flagged in the Risk Monitor."})]}),(0,e.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-5",children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:["Warning Level — ",(0,e.jsxs)("span",{className:"text-yellow-400",children:[$,"% of limit"]})]}),(0,e.jsx)("input",{type:"range",min:50,max:90,value:$,onChange:b=>ye(Number(b.target.value)),className:"w-full accent-yellow-400"}),(0,e.jsxs)("div",{className:"flex justify-between text-xs text-slate-500 mt-1",children:[(0,e.jsx)("span",{children:"50%"}),(0,e.jsxs)("span",{className:"font-medium text-yellow-400",children:["yellow badge at ",$,"%"]}),(0,e.jsx)("span",{children:"90%"})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:["Critical Level — ",(0,e.jsxs)("span",{className:"text-red-400",children:[I,"% of limit"]})]}),(0,e.jsx)("input",{type:"range",min:70,max:99,value:I,onChange:b=>ke(Number(b.target.value)),className:"w-full accent-red-400"}),(0,e.jsxs)("div",{className:"flex justify-between text-xs text-slate-500 mt-1",children:[(0,e.jsx)("span",{children:"70%"}),(0,e.jsxs)("span",{className:"font-medium text-red-400",children:["red badge at ",I,"%"]}),(0,e.jsx)("span",{children:"99%"})]})]})]})]}),(0,e.jsx)("div",{className:"pt-4 border-t border-slate-700",children:(0,e.jsx)(H,{customRules:le,onChange:Se})}),(0,e.jsxs)("button",{onClick:Ce,disabled:c,className:"px-6 py-3 bg-blue-600 hover:bg-blue-500 text-white rounded-lg font-medium flex items-center gap-2 disabled:opacity-50",children:[c?(0,e.jsx)("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):(0,e.jsx)(L,{className:"w-4 h-4"}),"Save Risk Rules"]})]})},ie={active:"bg-green-500/20 text-green-400",trialing:"bg-blue-500/20 text-blue-400",pending_payment:"bg-yellow-500/20 text-yellow-400",past_due:"bg-red-500/20 text-red-400",canceled:"bg-slate-500/20 text-slate-400",not_applicable:"bg-slate-500/20 text-slate-400"},xs={active:"Active",trialing:"Trial",pending_payment:"Payment Required",past_due:"Past Due",canceled:"Canceled",not_applicable:"Not Billed"},ms=({org:t})=>{const[d,c]=(0,l.useState)(null),[a,n]=(0,l.useState)(!1),x=t?.subscription||{},h=t?.type,g=t?.billingStatus||x.status||(["prop_firm","brokerage","ria","educator"].includes(h)?"pending_payment":"not_applicable"),i=Be(h),u=h==="educator",w=u?i?.tiers?.find(m=>m.id===x.tier)||i?.tiers?.[0]:null,r=u?w?.price:i?.price,p=async()=>{if(!(!t?.id||!i)){c(null),n(!0);try{const m=Ye(h,x.tier||"starter");if(!m)throw new Error("No Stripe price configured for this org type yet");await ze(t.id,m)}catch(m){console.error("[SubscriptionSettings] Checkout error:",m),c(m.message||"Could not start checkout. Please try again."),n(!1)}}},j=async()=>{if(t?.id){c(null),n(!0);
2try{await Qe(t.id)}catch(m){console.error("[SubscriptionSettings] Billing portal error:",m),c(m.message||"Could not open billing portal. Please try again."),n(!1)}}};return i?(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"bg-slate-800/50 rounded-xl border border-slate-700 p-6",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-xl font-semibold text-white",children:"Your Subscription"}),(0,e.jsxs)("p",{className:"text-slate-400",children:[i.label,u&&w?` — ${w.label}`:""]})]}),(0,e.jsx)("span",{className:`px-3 py-1 text-sm font-medium rounded-full ${ie[g]||ie.canceled}`,children:xs[g]||g})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between p-4 bg-gradient-to-r from-blue-500/10 to-purple-500/10 rounded-xl border border-blue-500/30",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"font-semibold text-white",children:"Monthly Total"}),(0,e.jsx)("p",{className:"text-sm text-slate-400",children:"Billed monthly via Stripe"})]}),(0,e.jsx)("p",{className:"text-2xl font-bold text-green-400",children:r?`$${r.toLocaleString()}/mo`:"—"})]}),g==="past_due"&&(0,e.jsx)("div",{className:"mt-4 p-3 bg-red-500/10 border border-red-500/30 rounded-lg text-sm text-red-400",children:"Your last payment failed. Update your payment method to avoid losing access."})]}),(0,e.jsxs)("div",{className:"bg-slate-800/50 rounded-xl border border-slate-700 p-6",children:[(0,e.jsx)("h4",{className:"text-lg font-semibold text-white mb-4",children:"What's Included"}),(0,e.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:["Unlimited account templates","Custom evaluation rules","Risk management tools","Real-time trader monitoring","Performance analytics","Team chat & collaboration","API access","Priority support"].map((m,f)=>(0,e.jsxs)("div",{className:"flex items-center gap-2 text-slate-300",children:[(0,e.jsx)(de,{className:"w-4 h-4 text-green-400 flex-shrink-0"}),m]},f))})]}),d&&(0,e.jsx)("div",{className:"p-3 bg-red-500/10 border border-red-500/30 rounded-xl text-sm text-red-400",children:d}),(0,e.jsx)("div",{className:"flex flex-wrap gap-4",children:g==="pending_payment"?(0,e.jsx)("button",{onClick:p,disabled:a,className:"px-6 py-3 bg-green-600 hover:bg-green-500 text-white rounded-xl font-medium transition-colors disabled:opacity-50",children:a?"Redirecting to Stripe...":"Complete Payment"}):(0,e.jsx)("button",{onClick:j,disabled:a,className:"px-6 py-3 bg-blue-600 hover:bg-blue-500 text-white rounded-xl font-medium transition-colors disabled:opacity-50",children:a?"Opening Billing Portal...":"Manage Billing"})})]}):(0,e.jsxs)("div",{className:"bg-slate-800/50 rounded-xl border border-slate-700 p-6",children:[(0,e.jsx)("h3",{className:"text-xl font-semibold text-white mb-2",children:"No Billing for This Org Type"}),(0,e.jsx)("p",{className:"text-slate-400",children:"This organization type isn't billed through Redline."})]})},us=({org:t,onDelete:d})=>{const[c,a]=(0,l.useState)(""),n=c===t?.name;return(0,e.jsx)("div",{className:"space-y-6",children:(0,e.jsxs)("div",{className:"p-6 bg-red-500/10 border border-red-500/30 rounded-xl",children:[(0,e.jsxs)("h3",{className:"text-lg font-semibold text-red-400 mb-2 flex items-center gap-2",children:[(0,e.jsx)(D,{className:"w-5 h-5"}),"Delete Organization"]}),(0,e.jsx)("p",{className:"text-slate-400 mb-4",children:"Once you delete your organization, there is no going back. This will permanently delete all data, including trader accounts, trade logs, and analytics. Please be certain."}),(0,e.jsxs)("div",{className:"mb-4",children:[(0,e.jsxs)("label",{className:"block text-sm font-medium text-slate-300 mb-2",children:["Type ",(0,e.jsx)("span",{className:"font-semibold text-white",children:t?.name})," to confirm"]}),(0,e.jsx)("input",{type:"text",value:c,onChange:x=>a(x.target.value),placeholder:"Type organization name...",className:"w-full px-4 py-3 bg-slate-900 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-red-500"})]}),(0,e.jsxs)("button",{onClick:d,disabled:!n,className:"px-6 py-3 bg-red-600 hover:bg-red-500 text-white rounded-lg font-medium flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,e.jsx)(se,{className:"w-4 h-4"}),"Delete Organization"]})]})})},bs=({orgId:t})=>(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"flex items-center justify-between",children:(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-lg font-semibold text-white",children:"Audit Logs"}),(0,e.jsx)("p",{className:"text-sm text-slate-400",children:"Immutable record of all organization actions"})]})}),(0,e.jsx)(as,{orgId:t,maxLogs:100})]}),hs=t=>{switch(t){case"ria":return"Compliance Rules";case"trading_group":return"Team Rules";case"prop_firm":return"Risk Rules";default:return"Rules"}},vs=()=>{const t=Pe(),{currentOrg:d,updateOrganization:c,updateOrgSettings:a,hasPermission:n}=He(),x=[{id:"general",label:"General",icon:ce},{id:"tiers",label:"Account Tiers",icon:P},{id:"risk",label:hs(d?.type),icon:X},{id:"audit",label:"Audit Logs",icon:G},{id:"subscription",label:"Subscription",icon:P},{id:"danger",label:"Danger Zone",icon:D}],[h]=De(),[g,i]=(0,l.useState)(h.get("tab")==="subscription"||h.get("billing")?"subscription":"general"),[u,w]=(0,l.useState)(!1),r=async v=>{w(!0);const{settings:s,...o}=v;let k=await c(d.id,o);k&&s&&(k=await a(d.id,s)),w(!1)},p=async v=>{w(!0);const{riskRules:s,complianceRules:o,teamRules:k,brokerageRules:T,settings:R}=v;let C=!0;s&&(C=await c(d.id,{riskRules:s})),o&&(C=await c(d.id,{complianceRules:o})),k&&(C=await c(d.id,{teamRules:k})),T&&(C=await c(d.id,{brokerageRules:T})),C&&R&&(C=await a(d.id,R)),w(!1),C&&(d?.type==="ria"||d?.type==="trading_group"||d?.type)},j=async()=>{window.confirm("Are you absolutely sure? This action cannot be undone.")},m=async v=>{w(!0);const s=await c(d.id,{accountTiers:v.accountTiers});w(!1)};if(!n("edit_org_settings"))return(0,e.jsx)("div",{className:"min-h-screen bg-slate-900 flex items-center justify-center p-8",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)(D,{className:"w-16 h-16 text-red-400 mx-auto mb-4"}),(0,e.jsx)("h1",{className:"text-2xl font-bold text-white mb-2",children:"Access Denied"}),(0,e.jsx)("p",{className:"text-slate-400 mb-6",children:"You don't have permission to edit organization settings."}),(0,e.jsx)("button",{onClick:()=>
2t("/org/dashboard"),className:"px-6 py-3 bg-blue-600 hover:bg-blue-500 text-white rounded-xl font-medium",children:"Back to Dashboard"})]})});const f=()=>{switch(g){case"general":return(0,e.jsx)(ls,{org:d,onSave:r,isSaving:u});case"tiers":return(0,e.jsx)(ds,{org:d,onSave:m,isSaving:u});case"risk":return(0,e.jsx)(cs,{org:d,onSave:p,isSaving:u});case"audit":return(0,e.jsx)(bs,{orgId:d?.id});case"subscription":return(0,e.jsx)(ms,{org:d});case"danger":return(0,e.jsx)(us,{org:d,onDelete:j});default:return null}};return(0,e.jsxs)("div",{className:"min-h-screen overflow-y-auto bg-slate-900",children:[(0,e.jsx)("div",{className:"bg-slate-800 border-b border-slate-700 px-3 sm:px-6 py-3 sm:py-4",children:(0,e.jsxs)("div",{className:"flex items-center gap-3 sm:gap-4",children:[(0,e.jsx)("button",{onClick:()=>t("/org/dashboard"),className:"p-2 hover:bg-slate-700 rounded-lg transition-colors flex-shrink-0",children:(0,e.jsx)(Oe,{className:"w-5 h-5 text-slate-400"})}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("h1",{className:"text-lg sm:text-2xl font-bold text-white truncate",children:"Organization Settings"}),(0,e.jsx)("p",{className:"text-xs sm:text-sm text-slate-400 truncate",children:d?.name})]})]})}),(0,e.jsx)("div",{className:"p-3 sm:p-6",children:(0,e.jsxs)("div",{className:"max-w-4xl mx-auto",children:[(0,e.jsx)("div",{className:"flex gap-1 sm:gap-2 mb-4 sm:mb-6 overflow-x-auto pb-2 -mx-1 px-1",children:x.map(v=>{const s=v.icon;return(0,e.jsxs)("button",{onClick:()=>i(v.id),className:`px-2.5 sm:px-4 py-2 sm:py-2.5 rounded-lg font-medium flex items-center gap-1.5 sm:gap-2 whitespace-nowrap transition-colors text-sm sm:text-base flex-shrink-0 ${g===v.id?"bg-blue-600 text-white":v.id==="danger"?"text-red-400 hover:bg-red-500/10":"text-slate-400 hover:bg-slate-800 hover:text-white"}`,children:[(0,e.jsx)(s,{className:"w-4 h-4"}),(0,e.jsx)("span",{className:"hidden sm:inline",children:v.label}),(0,e.jsx)("span",{className:"sm:hidden",children:v.label.split(" ")[0]})]},v.id)})}),(0,e.jsx)(M.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"bg-slate-800 rounded-xl border border-slate-700 p-3 sm:p-6",children:f()},g)]})})]})};export{vs 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.