@nabeeltahirdeveloper/chart-sdk 2.4.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chart-sdk.es.js +2 -2
- package/dist/chart-sdk.umd.js +1 -1
- package/package.json +1 -1
package/dist/chart-sdk.es.js
CHANGED
|
@@ -31351,14 +31351,14 @@ const LT = ({
|
|
|
31351
31351
|
"td",
|
|
31352
31352
|
{
|
|
31353
31353
|
className: `px-3 py-2 text-right text-md ${Q.change >= 0 ? o ? "text-blue-600" : "text-sky-400" : o ? "text-rose-600" : "text-rose-400"}`,
|
|
31354
|
-
children: Q
|
|
31354
|
+
children: Number(Q?.bid)?.toFixed(5)
|
|
31355
31355
|
}
|
|
31356
31356
|
),
|
|
31357
31357
|
/* @__PURE__ */ c(
|
|
31358
31358
|
"td",
|
|
31359
31359
|
{
|
|
31360
31360
|
className: `px-3 py-2 text-right text-md ${Q.change >= 0 ? o ? "text-blue-600" : "text-sky-400" : o ? "text-rose-600" : "text-rose-400"}`,
|
|
31361
|
-
children: Q
|
|
31361
|
+
children: Number(Q?.ask)?.toFixed(5)
|
|
31362
31362
|
}
|
|
31363
31363
|
),
|
|
31364
31364
|
/* @__PURE__ */ z(
|
package/dist/chart-sdk.umd.js
CHANGED
|
@@ -46,4 +46,4 @@
|
|
|
46
46
|
.scrollbar-light::-webkit-scrollbar-thumb:hover {
|
|
47
47
|
background: #94a3b8;
|
|
48
48
|
}
|
|
49
|
-
`}),a.jsxs("div",{style:{width:`${i}px`,minWidth:"220px",maxWidth:"1500px"},className:`border-l flex flex-col h-full shrink-0 ${o?"bg-white border-slate-200":"bg-[#12161d] border-slate-700"}`,children:[a.jsxs("div",{className:`p-3 border-b flex justify-center items-center gap-2 ${o?"border-slate-200":"border-slate-700"}`,children:[a.jsx(Mx,{className:o?"text-2xl text-slate-500":"text-2xl text-slate-400"}),a.jsx("input",{type:"text",placeholder:"Search symbol",value:l,onChange:Q=>c(Q.target.value),className:`w-full px-3 py-1.5 rounded text-md focus:outline-none focus:border-sky-500 ${o?"bg-white border border-slate-200 text-slate-800 placeholder:text-slate-400":"bg-slate-800 border border-slate-600 text-slate-100 placeholder:text-slate-400"}`})]}),a.jsx("div",{className:`flex-1 overflow-y-auto ${o?"scrollbar-light":"scrollbar-dark"}`,style:{scrollbarWidth:"thin",scrollbarColor:o?"#cbd5e1 #ffffff":"#1e293b #12161d"},children:r?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("div",{className:`text-sm ${o?"text-slate-700":"text-slate-200"}`,children:"Loading symbols..."})}):h.length===0?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("div",{className:`text-sm text-center px-4 ${o?"text-slate-700":"text-slate-200"}`,children:e.length===0?"No symbols found. Please check server connection.":"No symbols match your search."})}):a.jsxs("table",{className:"w-full text-xs",children:[a.jsx("thead",{className:`sticky top-0 z-10 ${o?"bg-white border-b border-slate-200":"bg-[#12161d] border-b border-slate-700"}`,children:a.jsxs("tr",{children:[a.jsx("th",{className:`px-3 py-2 text-left text-md ${o?"text-slate-700":"text-slate-300"}`,children:"Symbol"}),a.jsx("th",{className:`px-3 py-2 text-right text-md ${o?"text-slate-700":"text-slate-300"}`,children:"Bid"}),a.jsx("th",{className:`px-3 py-2 text-right text-md ${o?"text-slate-700":"text-slate-300"}`,children:"Ask"}),a.jsx("th",{className:`px-3 py-2 text-right text-md ${o?"text-slate-700":"text-slate-300"}`,children:"Change"})]})}),a.jsxs("tbody",{children:[d.length>0&&a.jsx("tr",{className:o?"bg-slate-50":"bg-slate-900",children:a.jsx("td",{colSpan:4,className:`px-3 py-2 text-xs font-semibold ${o?"text-sky-600":"text-sky-400"}`,children:"FOREX"})}),d.map(Q=>a.jsxs("tr",{onClick:()=>A(Q.symbol),className:`cursor-pointer transition-colors ${t===Q.symbol?o?"bg-sky-50 border-l-2 border-sky-500":"bg-slate-800 border-l-2 border-sky-500":o?"hover:bg-slate-50":"hover:bg-slate-800"}`,children:[a.jsxs("td",{className:`px-3 flex items-center justify-start gap-2 py-2 text-md font-medium ${o?"text-slate-800":"text-slate-100"}`,children:[Q.change>0?a.jsx("span",{className:"w-6 flex items-center justify-center",children:a.jsx(Sx,{className:"text-2xl text-emerald-500"})}):Q.change<0?a.jsx("span",{className:"w-6 flex items-center justify-center",children:a.jsx(Ux,{className:"text-2xl text-red-500"})}):a.jsx("span",{className:"w-6 flex items-center justify-center",children:a.jsx(Nm,{className:`text-[8px] ${o?"text-sky-600":"text-gray-300"}`})}),a.jsx("span",{children:Q.symbol})]}),a.jsx("td",{className:`px-3 py-2 text-right text-md ${Q.change>=0?o?"text-blue-600":"text-sky-400":o?"text-rose-600":"text-rose-400"}`,children:Number(Q.bid).toFixed(5)}),a.jsx("td",{className:`px-3 py-2 text-right text-md ${Q.change>=0?o?"text-blue-600":"text-sky-400":o?"text-rose-600":"text-rose-400"}`,children:Number(Q.ask).toFixed(5)}),a.jsxs("td",{className:`px-3 py-2 text-right font-medium ${Q.change>=0?o?"text-emerald-600":"text-emerald-400":o?"text-rose-600":"text-rose-400"}`,children:[Q.change>=0?"+":"",Q.change,"%"]})]},Q.symbol)),y.length>0&&a.jsx("tr",{className:o?"bg-slate-50":"bg-slate-900",children:a.jsx("td",{colSpan:4,className:`px-3 py-2 text-xs font-semibold ${o?"text-emerald-600":"text-emerald-400"}`,children:"CRYPTO"})}),y.map(Q=>a.jsxs("tr",{onClick:()=>A(Q.symbol),className:`cursor-pointer transition-colors ${t===Q.symbol?o?"bg-sky-50 border-l-2 border-sky-500":"bg-slate-800 border-l-2 border-sky-500":o?"hover:bg-slate-50":"hover:bg-slate-800"}`,children:[a.jsx("td",{className:`px-3 py-2 text-md font-medium ${o?"text-slate-800":"text-slate-100"}`,children:Q.symbol}),a.jsx("td",{className:`px-3 py-2 text-right text-md ${Q.change>=0?o?"text-blue-600":"text-sky-400":o?"text-rose-600":"text-rose-400"}`,children:Q.bid.toFixed(5)}),a.jsx("td",{className:`px-3 py-2 text-right text-md ${Q.change>=0?o?"text-blue-600":"text-sky-400":o?"text-rose-600":"text-rose-400"}`,children:Q.ask.toFixed(5)}),a.jsxs("td",{className:`px-3 py-2 text-right font-medium ${Q.change>=0?o?"text-emerald-600":"text-emerald-400":o?"text-rose-600":"text-rose-400"}`,children:[Q.change>=0?"+":"",Q.change,"%"]})]},Q.symbol))]})]})})]})]})},Ix=({accountSummary:i,orders:e,onClose:t,height:A,onNewOrder:r})=>{const{accountSummary:n,orders:s,theme:o,isShow:l,setIsShow:c,historyOrders:h,fetchHistoryOrders:d,setIsTradeOpenModal:y,isTradeOpenModal:Q,selectedTradeForModify:b,setSelectedTradeForModify:C}=Lt(),U=i||n,M=e?.length>0?e:s,E=h||[],I=o==="light",R=l?"history":"trade";j.useEffect(()=>{l&&d&&d()},[l,d]);const L="#26A69A",O="#EF5350",Y=I?"#f8fafc":"#12161D",X=I?"#e2e8f0":"#1e293b",Ae=I?"#f1f5f9":"#12161D",oe=I?"#F0F5F9":"#2B3543",W=I?"#f8fafc":"#131c2e",ce=I?"#12161D":"#fff",$=I?"#64748b":"#fff",Be=(M||[]).filter(ue=>ue.status==="OPEN"||!ue.closeAt),Ce=U?.balance||0,ee=U?.equity??Ce,Z=U?.margin||0,re=U?.freeMargin??ee-Z,fe=Z>0?ee/Z*100:0,we=Be.reduce((ue,ae)=>ue+(ae.livePnL??ae.profit??0),0),ve=ue=>{const ae=parseFloat(ue);return Number.isFinite(ae)?ae.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):"0.00"},xe=ue=>{const ae=parseFloat(ue);return!ae||isNaN(ae)?"—":ae>=1e4?ae.toFixed(2):ae>=10?ae.toFixed(4):ae.toFixed(5)},me=ue=>{const ae=parseFloat(ue);return isNaN(ae)?"—":(ae>=0?"+":"")+ae.toFixed(2)},Se=ue=>{const ae=parseFloat(ue);return isNaN(ae)?"—":ae.toFixed(2)},He=ue=>{if(!ue)return"—";const ae=new Date(ue);return isNaN(ae.getTime())?String(ue):`${ae.toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"2-digit"})} ${ae.toTimeString().slice(0,8)}`},Ee=j.useCallback((ue,ae)=>{ue.stopPropagation(),t&&t(ae.id,ae)},[t]),_e=j.useCallback(ue=>{b&&b.id===ue.id?(C(null),y(!1)):(C(ue),y(!0),r&&r())},[C,y,b,r]),Qe=j.useCallback((ue,ae)=>{ue.stopPropagation(),_e(ae)},[_e]),Ie={fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, monospace",backgroundColor:Y,borderTop:`1px solid ${X}`,display:"flex",flexDirection:"column",height:A?`${A}px`:"auto",overflow:"hidden",fontSize:"11px",color:ce},Ze={display:"flex",alignItems:"center",gap:"0",padding:"5px 10px",backgroundColor:oe,borderBottom:`1px solid ${X}`,flexShrink:0,flexWrap:"wrap",rowGap:"2px"},We={display:"flex",alignItems:"center",gap:"4px",paddingRight:"14px",marginRight:"14px",borderRight:`1px solid ${X}`,whiteSpace:"nowrap"},Te={color:$,fontWeight:600,fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.05em"},it={fontFamily:"monospace",fontWeight:700,fontSize:"11px"},Ge={display:"flex",borderBottom:`1px solid ${X}`,flexShrink:0,backgroundColor:Ae},Ve=ue=>({padding:"5px 14px",fontSize:"11px",fontWeight:ue?700:500,color:ue?I?"#0ea5e9":"#38bdf8":$,borderBottom:ue?`2px solid ${I?"#0ea5e9":"#38bdf8"}`:"2px solid transparent",background:"none",border:"none",cursor:"pointer",transition:"color 0.15s",outline:"none"}),De={padding:"4px 8px",textAlign:"left",color:$,fontWeight:700,fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.05em",borderBottom:`1px solid ${X}`,whiteSpace:"nowrap",backgroundColor:Ae,position:"sticky",top:0,zIndex:1},Pe={padding:"3px 8px",borderBottom:`1px solid ${X}`,whiteSpace:"nowrap",fontFamily:"monospace",fontSize:"11px",color:ce};return a.jsxs("div",{style:Ie,children:[a.jsxs("div",{style:Ze,children:[a.jsxs("div",{style:We,children:[a.jsx("span",{style:Te,children:"Balance:"}),a.jsxs("span",{style:{...it,color:ce},children:["$",ve(Ce)]})]}),a.jsxs("div",{style:We,children:[a.jsx("span",{style:Te,children:"Equity:"}),a.jsxs("span",{style:{...it,color:ee>=Ce?L:O},children:["$",ve(ee)]})]}),a.jsxs("div",{style:We,children:[a.jsx("span",{style:Te,children:"Margin:"}),a.jsxs("span",{style:{...it,color:ce},children:["$",ve(Z)]})]}),a.jsxs("div",{style:We,children:[a.jsx("span",{style:Te,children:"Free Margin:"}),a.jsxs("span",{style:{...it,color:re>=0?ce:O},children:["$",ve(re)]})]}),a.jsxs("div",{style:{...We,borderRight:"none",marginRight:0,paddingRight:0},children:[a.jsx("span",{style:Te,children:"Margin Level:"}),a.jsx("span",{style:{...it,color:fe>=100?L:O},children:Z>0?fe.toFixed(2)+"%":"—"})]}),Be.length>0&&a.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"4px"},children:[a.jsx("span",{style:Te,children:"Float P/L:"}),a.jsxs("span",{style:{...it,color:we>=0?L:O,fontWeight:700},children:[we>=0?"+":"",ve(we)]})]})]}),a.jsxs("div",{style:Ge,children:[a.jsx("button",{style:Ve(R==="trade"),onClick:()=>c&&c(!1),children:"Trade"}),a.jsx("button",{style:Ve(R==="history"),onClick:()=>c&&c(!0),children:"History"})]}),R==="trade"&&a.jsx("div",{style:{overflowY:"auto",flex:1},children:a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",minWidth:"800px"},children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{style:De,children:"Symbol"}),a.jsx("th",{style:De,children:"Ticket"}),a.jsx("th",{style:De,children:"Time"}),a.jsx("th",{style:De,children:"Type"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"Volume"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"Price"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"S/L"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"T/P"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"Current"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"Profit"}),a.jsx("th",{style:{...De,textAlign:"center"},children:"Action"}),a.jsx("th",{style:{...De,textAlign:"center"},children:"Close"})]})}),a.jsx("tbody",{children:Be.length===0?a.jsx("tr",{children:a.jsx("td",{colSpan:12,style:{...Pe,textAlign:"center",padding:"16px",color:$},children:"No open positions"})}):Be.map(ue=>{const ae=ue.livePnL??ue.profit??0,he=ae>=0?L:O,Fe=b&&b.id===ue.id;return a.jsxs("tr",{style:{cursor:"pointer",backgroundColor:Fe?I?"#e0f2fe":"#1e3a5f":"transparent"},onClick:()=>_e(ue),onMouseEnter:Le=>{Fe||(Le.currentTarget.style.backgroundColor=W)},onMouseLeave:Le=>{Fe||(Le.currentTarget.style.backgroundColor="transparent")},children:[a.jsx("td",{style:{...Pe,fontWeight:700,color:ce,letterSpacing:"0.02em"},children:ue.symbol}),a.jsx("td",{style:{...Pe,color:$,fontSize:"10px"},children:String(ue.id||"").slice(0,8).toUpperCase()}),a.jsx("td",{style:{...Pe,color:$},children:He(ue.openAt||ue.time)}),a.jsx("td",{style:{...Pe,fontWeight:700,color:ue.type==="BUY"?L:O},children:ue.type}),a.jsx("td",{style:{...Pe,textAlign:"right"},children:Se(ue.volume)}),a.jsx("td",{style:{...Pe,textAlign:"right"},children:xe(ue.price??ue.openPrice)}),a.jsx("td",{style:{...Pe,textAlign:"right",color:ue.stopLoss?O:$},children:ue.stopLoss?xe(ue.stopLoss):"—"}),a.jsx("td",{style:{...Pe,textAlign:"right",color:ue.takeProfit?L:$},children:ue.takeProfit?xe(ue.takeProfit):"—"}),a.jsx("td",{style:{...Pe,textAlign:"right",color:$}}),a.jsx("td",{style:{...Pe,textAlign:"right",fontWeight:700,color:he},children:me(ae)}),a.jsx("td",{style:{...Pe,textAlign:"center"},children:a.jsx("button",{onClick:Le=>Qe(Le,ue),title:"Modify TP/SL",style:{background:"none",border:"none",cursor:"pointer",color:$,padding:"2px 4px",borderRadius:"3px",fontSize:"11px",lineHeight:1},onMouseEnter:Le=>Le.currentTarget.style.color="#f59e0b",onMouseLeave:Le=>Le.currentTarget.style.color=$,children:"✎"})}),a.jsx("td",{style:{...Pe,textAlign:"right",fontWeight:700,color:he},children:a.jsx("button",{onClick:Le=>Ee(Le,ue),title:"Close position",style:{padding:"2px 8px",backgroundColor:"#7f1d1d",border:"1px solid #991b1b",borderRadius:"3px",color:"#fca5a5",fontSize:"10px",fontWeight:700,cursor:"pointer"},onMouseEnter:Le=>Le.currentTarget.style.backgroundColor="#991b1b",onMouseLeave:Le=>Le.currentTarget.style.backgroundColor="#7f1d1d",children:"Close"})})]},ue.id)})})]})}),R==="history"&&a.jsx("div",{style:{overflowY:"auto",flex:1},children:a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",minWidth:"900px"},children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{style:De,children:"Symbol"}),a.jsx("th",{style:De,children:"Ticket"}),a.jsx("th",{style:De,children:"Open Time"}),a.jsx("th",{style:De,children:"Type"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"Volume"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"Open Price"}),a.jsx("th",{style:De,children:"Close Time"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"Close Price"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"S/L"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"T/P"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"Profit"})]})}),a.jsx("tbody",{children:E.length===0?a.jsx("tr",{children:a.jsx("td",{colSpan:11,style:{...Pe,textAlign:"center",padding:"16px",color:$},children:"No trade history"})}):E.map(ue=>{const ae=ue.profit??0,he=ae>=0?L:O;return a.jsxs("tr",{style:{cursor:"default"},onMouseEnter:Fe=>Fe.currentTarget.style.backgroundColor=W,onMouseLeave:Fe=>Fe.currentTarget.style.backgroundColor="transparent",children:[a.jsx("td",{style:{...Pe,fontWeight:700,color:ce,letterSpacing:"0.02em"},children:ue.symbol}),a.jsx("td",{style:{...Pe,color:$,fontSize:"10px"},children:String(ue.id||"").slice(0,8).toUpperCase()}),a.jsx("td",{style:{...Pe,color:$},children:He(ue.openAt)}),a.jsx("td",{style:{...Pe,fontWeight:700,color:ue.type==="BUY"?L:O},children:ue.type}),a.jsx("td",{style:{...Pe,textAlign:"right"},children:Se(ue.volume)}),a.jsx("td",{style:{...Pe,textAlign:"right"},children:xe(ue.openPrice)}),a.jsx("td",{style:{...Pe,color:$},children:He(ue.closeAt)}),a.jsx("td",{style:{...Pe,textAlign:"right"},children:xe(ue.closePrice)}),a.jsx("td",{style:{...Pe,textAlign:"right",color:ue.stopLoss?O:$},children:ue.stopLoss?xe(ue.stopLoss):"—"}),a.jsx("td",{style:{...Pe,textAlign:"right",color:ue.takeProfit?L:$},children:ue.takeProfit?xe(ue.takeProfit):"—"}),a.jsx("td",{style:{...Pe,textAlign:"right",fontWeight:700,color:he},children:me(ae)})]},ue.id)})})]})})]})},rp={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Px=({onModify:i,onClosePosition:e,priceFormatter:t})=>{const{isTradeOpenModal:A,setIsTradeOpenModal:r,selectedTradeForModify:n,setSelectedTradeForModify:s,symbols:o,theme:l,baseUrl:c,setOrders:h,fetchOrders:d}=Lt(),y=!!(A&&n),Q=n,b=l==="light",[C,U]=j.useState(""),[M,E]=j.useState(""),[I,R]=j.useState(""),[L,O]=j.useState(!1),[Y,X]=j.useState(""),[Ae,oe]=j.useState(0),[W,ce]=j.useState(0),[$,Be]=j.useState("inherit"),[Ce,ee]=j.useState("inherit"),Z=j.useRef(0),re=j.useRef(0),fe=j.useRef(null),we=j.useRef(null),ve=j.useRef(null),xe=j.useRef(null);j.useEffect(()=>{if(!y||!Q){xe.current=null;return}const Re=Q.id;xe.current!==Re&&(xe.current=Re,U(Q.stopLoss!=null?String(Q.stopLoss):""),E(Q.takeProfit!=null?String(Q.takeProfit):""),R(Q.comment||""),X(""),fe.current=Q.stopLoss??null,we.current=Q.takeProfit??null)},[y,Q?.id]),j.useEffect(()=>{if(!y||!Q?.symbol)return;const Re=o.find(rt=>rt.symbol===Q.symbol);if(Re){const rt=parseFloat(Re.bid)||0,ke=parseFloat(Re.ask)||0;rt>0&&(oe(rt),Z.current=rt),ke>0&&(ce(ke),re.current=ke)}const Ne=vn.getSocket(),ct=rt=>{if(!rt?.symbol||rt.symbol.toUpperCase()!==Q.symbol.toUpperCase())return;const ke=parseFloat(rt.bid)||0,mt=parseFloat(rt.ask)||0;ke>0&&(Be(ke>Z.current?"text-green-400":ke<Z.current?"text-red-400":""),setTimeout(()=>Be(""),500),oe(ke),Z.current=ke),mt>0&&(ee(mt>re.current?"text-green-400":mt<re.current?"text-red-400":""),setTimeout(()=>ee(""),500),ce(mt),re.current=mt)};return Ne.on("priceUpdate",ct),()=>Ne.off("priceUpdate",ct)},[y,Q?.symbol,o]),j.useEffect(()=>{if(!(!y||!s))return clearTimeout(ve.current),ve.current=setTimeout(()=>{const Re=C!==""?parseFloat(C):null,Ne=M!==""?parseFloat(M):null;fe.current=Re,we.current=Ne,s(ct=>!ct||ct.stopLoss===Re&&ct.takeProfit===Ne?ct:{...ct,stopLoss:Re,takeProfit:Ne})},150),()=>clearTimeout(ve.current)},[C,M,y,s]),j.useEffect(()=>{if(!y||!Q)return;const Re=Q.stopLoss??null,Ne=Q.takeProfit??null,ct=(rt,ke)=>rt===ke||rt!=null&&ke!=null&&Math.abs(rt-ke)<1e-6;ct(Re,fe.current)||(fe.current=Re,U(Re!=null?String(Re):"")),ct(Ne,we.current)||(we.current=Ne,E(Ne!=null?String(Ne):""))},[Q?.stopLoss,Q?.takeProfit,y]);const me=j.useCallback(Re=>{if(t)return t(Re,Q?.symbol);const Ne=parseFloat(Re);return!Ne||isNaN(Ne)?"—":Ne>=1e3?Ne.toFixed(3):Ne>=10?Ne.toFixed(4):Ne.toFixed(5)},[t,Q?.symbol]),Se=String(Q?.symbol||"").toUpperCase().includes("JPY"),He=Se?3:5,Ee=Se?.01:1e-4,_e=Q?.type==="BUY",Qe=_e?Ae:W,Ie=parseFloat(Q?.price||Q?.openPrice||0),Ze=parseFloat(Q?.volume||0),We=String(Q?.symbol||"").toUpperCase(),Te=We.includes("XAU")?100:We.includes("XAG")?5e3:We.endsWith("USDT")||We.includes("BTC")||We.includes("ETH")?1:1e5,Ge=(_e?Qe-Ie:Ie-Qe)*Ze*Te,Ve=isNaN(Ge)?"0.00":Ge.toFixed(2),De=Ge>=0,Pe=(Ze*Te).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),ue=We.slice(3)||"",ae=Re=>{const Ne=parseFloat(C),ct=Number.isFinite(Ne)&&Ne>0?Ne:_e?Qe-Ee*50:Qe+Ee*50;U((ct+Re*Ee).toFixed(He)),X("")},he=Re=>{const Ne=parseFloat(M),ct=Number.isFinite(Ne)&&Ne>0?Ne:_e?Qe+Ee*50:Qe-Ee*50;E((ct+Re*Ee).toFixed(He)),X("")},Le=We.includes("XAU")?.5:Se?.05:2e-4,Ye=()=>{const Re=C!==""?parseFloat(C):null,Ne=M!==""?parseFloat(M):null;if(Re!==null){if(isNaN(Re)||Re<=0)return"Stop Loss must be a valid positive number";if(_e&&Re>=Ie)return`SL must be below entry price (${me(Ie)}) for BUY`;if(!_e&&Re<=Ie)return`SL must be above entry price (${me(Ie)}) for SELL`;if(Qe>0){if(_e&&Re>=Qe-Le)return`SL ${me(Re)} is too close to current bid ${me(Qe)} — move it at least ${(Le*1e4).toFixed(0)} pips lower`;if(!_e&&Re<=Qe+Le)return`SL ${me(Re)} is too close to current ask ${me(Qe)} — move it at least ${(Le*1e4).toFixed(0)} pips higher`}}if(Ne!==null){if(isNaN(Ne)||Ne<=0)return"Take Profit must be a valid positive number";if(_e&&Ne<=Ie)return`TP must be above entry price (${me(Ie)}) for BUY`;if(!_e&&Ne>=Ie)return`TP must be below entry price (${me(Ie)}) for SELL`;if(Qe>0){if(_e&&Ne<=Qe+Le)return`TP ${me(Ne)} is too close to current bid ${me(Qe)} — move it at least ${(Le*1e4).toFixed(0)} pips higher`;if(!_e&&Ne>=Qe-Le)return`TP ${me(Ne)} is too close to current ask ${me(Qe)} — move it at least ${(Le*1e4).toFixed(0)} pips lower`}}return null},qe=async()=>{if(!Q)return;const Re=Ye();if(Re){X(Re);return}X(""),O(!0);const Ne=C!==""?parseFloat(C):null,ct=M!==""?parseFloat(M):null;console.log("[ModifyTradeModal] Submitting modify:",{tradeId:Q.id,stopLoss:Ne,takeProfit:ct,tradeType:Q.type,entryPrice:Ie,currentClosePrice:Qe});try{if(i)await i(Q.id,{stopLoss:Ne,takeProfit:ct});else{const rt=localStorage.getItem("token"),ke=c||rp?.VITE_BASE_URL||"http://localhost:8000";await ut.patch(`${ke}/trades/${Q.id}/modify`,{stopLoss:Ne,takeProfit:ct},{headers:{Authorization:`Bearer ${rt}`,"Content-Type":"application/json"}}),h&&h(mt=>mt.map(vt=>vt.id===Q.id?{...vt,stopLoss:Ne,takeProfit:ct}:vt)),d&&d()}tA()}catch(rt){const ke=rt?.response?.data?.message||rt?.message||"Modify failed";X(ke),console.error("[ModifyTradeModal] Modify error:",rt)}finally{O(!1)}},Qt=async()=>{if(Q){if(!Qe||Qe<=0){X("Current price not available — cannot close");return}O(!0),console.log("[ModifyTradeModal] Closing position:",{tradeId:Q.id,closePrice:Qe,tradeType:Q.type});try{if(e)await e(Q.id,Qe);else{const Re=localStorage.getItem("token"),Ne=c||rp?.VITE_BASE_URL||"http://localhost:8000";await ut.patch(`${Ne}/trades/${Q.id}`,{closePrice:Qe},{headers:{Authorization:`Bearer ${Re}`,"Content-Type":"application/json"}}),h&&h(ct=>ct.filter(rt=>rt.id!==Q.id)),d&&d()}tA()}catch(Re){X(Re?.response?.data?.message||Re?.message||"Close failed"),console.error("[ModifyTradeModal] Close error:",Re)}finally{O(!1)}}},tA=()=>{s(null),r(!1),xe.current=null,X(""),clearTimeout(ve.current)};if(!y||!Q)return null;const $t=Q.ticket||String(Q.id||"").replace(/-/g,"").slice(0,10),ei=(Q.type||"").toLowerCase(),Je={bg:b?"#ffffff":"#12161d",border:b?"#e2e8f0":"#1e293b",inputBg:b?"#ffffff":"#0f172a",inputBorder:b?"#cbd5e1":"#1e293b",stepperBg:b?"#f1f5f9":"#1e293b",priceBg:b?"#f8fafc":"#1a2332",closeBtnBg:b?"#f1f5f9":"#1e293b",text:b?"#1e293b":"#f1f5f9",label:b?"#475569":"#cbd5e1",muted:b?"#64748b":"#94a3b8"};return a.jsxs("div",{className:"w-full h-full flex flex-col pointer-events-auto overflow-hidden text-sm",style:{background:Je.bg,color:Je.text},children:[a.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b shrink-0",style:{borderColor:Je.border},children:[a.jsxs("span",{className:"font-mono text-xs font-semibold truncate",style:{color:Je.text},children:["#",$t," ",ei," ",parseFloat(Q.volume||0).toFixed(2)," ",Q.symbol," ",me(Ie)]}),a.jsx("button",{onClick:tA,className:"ml-2 shrink-0 p-1 rounded transition-colors hover:bg-white/10",style:{color:Je.muted},children:a.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-3 space-y-3",children:[Y&&a.jsx("div",{className:"p-2 rounded border text-xs leading-snug",style:{background:"rgba(239,68,68,0.08)",borderColor:"rgba(239,68,68,0.3)",color:"#f87171"},children:Y}),a.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 rounded text-xs border",style:{background:Je.priceBg,borderColor:Je.border},children:[a.jsxs("div",{children:[a.jsx("span",{style:{color:Je.muted},children:"SELL "}),a.jsx("span",{className:"font-mono font-bold transition-colors duration-300",style:{color:$?void 0:Je.text},...$?{className:`font-mono font-bold transition-colors duration-300 ${$}`}:{},children:Ae>0?me(Ae):"—"})]}),a.jsx("span",{className:"font-semibold text-xs",style:{color:Je.muted},children:Q.symbol}),a.jsxs("div",{children:[a.jsx("span",{style:{color:Je.muted},children:"BUY "}),a.jsx("span",{className:"font-mono font-bold transition-colors duration-300",style:{color:Ce?void 0:Je.text},...Ce?{className:`font-mono font-bold transition-colors duration-300 ${Ce}`}:{},children:W>0?me(W):"—"})]})]}),a.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{label:"Volume",sub:`${Pe} ${ue}`,val:parseFloat(Q.volume||0).toFixed(2)},{label:"Price",sub:null,val:me(Ie)}].map(({label:Re,sub:Ne,val:ct})=>a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("span",{className:"text-xs font-medium",style:{color:Je.label},children:Re}),Ne&&a.jsx("span",{className:"text-xs font-mono",style:{color:Je.muted},children:Ne})]}),a.jsxs("div",{className:"relative flex items-center",children:[a.jsx("button",{className:"absolute left-1 w-7 h-7 flex items-center justify-center rounded text-sm z-10 opacity-40 cursor-default",style:{background:Je.stepperBg,color:Je.text},children:"−"}),a.jsx("input",{type:"text",value:ct,readOnly:!0,className:"w-full px-8 py-1.5 rounded text-xs text-center font-mono border cursor-default focus:outline-none",style:{background:Je.inputBg,borderColor:Je.inputBorder,color:Je.text}}),a.jsx("button",{className:"absolute right-1 w-7 h-7 flex items-center justify-center rounded text-sm z-10 opacity-40 cursor-default",style:{background:Je.stepperBg,color:Je.text},children:"+"})]})]},Re))}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("span",{className:"text-xs font-medium",style:{color:Je.label},children:"Stop Loss"}),C!==""&&a.jsx("button",{onClick:()=>{U(""),X("")},className:"hover:text-red-400 transition-colors",style:{color:Je.muted},title:"Clear Stop Loss",children:a.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M6 18L18 6M6 6l12 12"})})})]}),a.jsxs("div",{className:"relative flex items-center",children:[a.jsx("button",{onClick:()=>ae(-1),className:"absolute left-1 w-7 h-7 flex items-center justify-center rounded text-sm z-10 transition-colors hover:opacity-80",style:{background:Je.stepperBg,color:Je.text},children:"−"}),a.jsx("input",{type:"text",value:C,onChange:Re=>{const Ne=Re.target.value;(Ne===""||/^\d*\.?\d*$/.test(Ne))&&(U(Ne),X(""))},onBlur:Re=>{const Ne=parseFloat(Re.target.value);!isNaN(Ne)&&Ne>0?U(Ne.toFixed(He)):Re.target.value!==""&&Re.target.value!=="."&&U("")},placeholder:"—",className:"w-full px-8 py-1.5 rounded text-xs text-center font-mono border focus:outline-none transition-colors",style:C!==""?{background:"rgba(239,68,68,0.05)",borderColor:"rgba(239,68,68,0.5)",color:"#f87171"}:{background:Je.inputBg,borderColor:Je.inputBorder,color:Je.text}}),a.jsx("button",{onClick:()=>ae(1),className:"absolute right-1 w-7 h-7 flex items-center justify-center rounded text-sm z-10 transition-colors hover:opacity-80",style:{background:Je.stepperBg,color:Je.text},children:"+"})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("span",{className:"text-xs font-medium",style:{color:Je.label},children:"Take Profit"}),M!==""&&a.jsx("button",{onClick:()=>{E(""),X("")},className:"hover:text-red-400 transition-colors",style:{color:Je.muted},title:"Clear Take Profit",children:a.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M6 18L18 6M6 6l12 12"})})})]}),a.jsxs("div",{className:"relative flex items-center",children:[a.jsx("button",{onClick:()=>he(-1),className:"absolute left-1 w-7 h-7 flex items-center justify-center rounded text-sm z-10 transition-colors hover:opacity-80",style:{background:Je.stepperBg,color:Je.text},children:"−"}),a.jsx("input",{type:"text",value:M,onChange:Re=>{const Ne=Re.target.value;(Ne===""||/^\d*\.?\d*$/.test(Ne))&&(E(Ne),X(""))},onBlur:Re=>{const Ne=parseFloat(Re.target.value);!isNaN(Ne)&&Ne>0?E(Ne.toFixed(He)):Re.target.value!==""&&Re.target.value!=="."&&E("")},placeholder:"—",className:"w-full px-8 py-1.5 rounded text-xs text-center font-mono border focus:outline-none transition-colors",style:M!==""?{background:"rgba(34,197,94,0.05)",borderColor:"rgba(34,197,94,0.5)",color:"#4ade80"}:{background:Je.inputBg,borderColor:Je.inputBorder,color:Je.text}}),a.jsx("button",{onClick:()=>he(1),className:"absolute right-1 w-7 h-7 flex items-center justify-center rounded text-sm z-10 transition-colors hover:opacity-80",style:{background:Je.stepperBg,color:Je.text},children:"+"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium mb-1",style:{color:Je.label},children:"Comment"}),a.jsx("textarea",{value:I,onChange:Re=>R(Re.target.value),rows:2,className:"w-full px-2 py-1.5 rounded text-xs font-mono border resize-none focus:outline-none",style:{background:Je.inputBg,borderColor:Je.inputBorder,color:Je.text}})]}),a.jsx("button",{onClick:qe,disabled:L,className:"w-full py-2.5 bg-blue-600 hover:bg-blue-700 active:bg-blue-800 disabled:opacity-50 disabled:cursor-not-allowed text-white font-semibold rounded text-sm transition-colors",children:L?a.jsxs("span",{className:"flex items-center justify-center gap-2",children:[a.jsxs("svg",{className:"animate-spin h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",children:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Modifying..."]}):"Modify"}),a.jsxs("button",{onClick:Qt,disabled:L||!Qe,className:"w-full py-2 rounded text-xs font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",style:{background:Je.closeBtnBg,color:Je.muted},children:[a.jsxs("span",{className:"block",children:["Close #",$t," ",ei," ",parseFloat(Q.volume||0).toFixed(2)," ",Q.symbol]}),a.jsxs("span",{className:"block font-mono mt-0.5",children:[me(Ie)," at ",Qe>0?me(Qe):"—"," with"," ",a.jsxs("span",{className:De?"text-green-400":"text-red-400",children:[De?"Profit":"Loss"," ",De?"+":"",Ve]})]})]})]})]})},Dx="2.3.2";et.AccountPanel=Ix,et.BuySellPanel=Sh,et.Chart=gx,et.ChartTypeSelector=xx,et.CoinSelector=qd,et.DrawingTools=Ap,et.LeftSidebar=Lx,et.MarketExecutionModal=Eh,et.MarketWatch=Hx,et.ModifyTradeModal=Px,et.PositionsPanel=bx,et.SYMBOL_CONFIG=Xa,et.StopLoss=ep,et.TakeProfit=tp,et.TimeframeSelector=Cx,et.ToolCustomizationModal=Ph,et.TopBar=Ex,et.TradePanel=Tx,et.TradingProvider=Qm,et.TradingToolbar=Bx,et.VolumeControl=jd,et.alignToTimeframe=ze,et.detectGaps=vp,et.getSymbolConfig=zi,et.is24x7Symbol=Cp,et.isCryptoSymbol=yp,et.isForexSymbol=Bp,et.isWithinTradingSession=xp,et.normalizeCandleTimes=Ja,et.normalizeTime=ie,et.processCandles=el,et.processSingleCandle=tl,et.setSocketBaseUrl=xh,et.timeframeToSeconds=iA,et.useTrading=Lt,et.validateTimeOrdering=Tp,et.version=Dx,Object.defineProperty(et,Symbol.toStringTag,{value:"Module"})}));
|
|
49
|
+
`}),a.jsxs("div",{style:{width:`${i}px`,minWidth:"220px",maxWidth:"1500px"},className:`border-l flex flex-col h-full shrink-0 ${o?"bg-white border-slate-200":"bg-[#12161d] border-slate-700"}`,children:[a.jsxs("div",{className:`p-3 border-b flex justify-center items-center gap-2 ${o?"border-slate-200":"border-slate-700"}`,children:[a.jsx(Mx,{className:o?"text-2xl text-slate-500":"text-2xl text-slate-400"}),a.jsx("input",{type:"text",placeholder:"Search symbol",value:l,onChange:Q=>c(Q.target.value),className:`w-full px-3 py-1.5 rounded text-md focus:outline-none focus:border-sky-500 ${o?"bg-white border border-slate-200 text-slate-800 placeholder:text-slate-400":"bg-slate-800 border border-slate-600 text-slate-100 placeholder:text-slate-400"}`})]}),a.jsx("div",{className:`flex-1 overflow-y-auto ${o?"scrollbar-light":"scrollbar-dark"}`,style:{scrollbarWidth:"thin",scrollbarColor:o?"#cbd5e1 #ffffff":"#1e293b #12161d"},children:r?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("div",{className:`text-sm ${o?"text-slate-700":"text-slate-200"}`,children:"Loading symbols..."})}):h.length===0?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("div",{className:`text-sm text-center px-4 ${o?"text-slate-700":"text-slate-200"}`,children:e.length===0?"No symbols found. Please check server connection.":"No symbols match your search."})}):a.jsxs("table",{className:"w-full text-xs",children:[a.jsx("thead",{className:`sticky top-0 z-10 ${o?"bg-white border-b border-slate-200":"bg-[#12161d] border-b border-slate-700"}`,children:a.jsxs("tr",{children:[a.jsx("th",{className:`px-3 py-2 text-left text-md ${o?"text-slate-700":"text-slate-300"}`,children:"Symbol"}),a.jsx("th",{className:`px-3 py-2 text-right text-md ${o?"text-slate-700":"text-slate-300"}`,children:"Bid"}),a.jsx("th",{className:`px-3 py-2 text-right text-md ${o?"text-slate-700":"text-slate-300"}`,children:"Ask"}),a.jsx("th",{className:`px-3 py-2 text-right text-md ${o?"text-slate-700":"text-slate-300"}`,children:"Change"})]})}),a.jsxs("tbody",{children:[d.length>0&&a.jsx("tr",{className:o?"bg-slate-50":"bg-slate-900",children:a.jsx("td",{colSpan:4,className:`px-3 py-2 text-xs font-semibold ${o?"text-sky-600":"text-sky-400"}`,children:"FOREX"})}),d.map(Q=>a.jsxs("tr",{onClick:()=>A(Q.symbol),className:`cursor-pointer transition-colors ${t===Q.symbol?o?"bg-sky-50 border-l-2 border-sky-500":"bg-slate-800 border-l-2 border-sky-500":o?"hover:bg-slate-50":"hover:bg-slate-800"}`,children:[a.jsxs("td",{className:`px-3 flex items-center justify-start gap-2 py-2 text-md font-medium ${o?"text-slate-800":"text-slate-100"}`,children:[Q.change>0?a.jsx("span",{className:"w-6 flex items-center justify-center",children:a.jsx(Sx,{className:"text-2xl text-emerald-500"})}):Q.change<0?a.jsx("span",{className:"w-6 flex items-center justify-center",children:a.jsx(Ux,{className:"text-2xl text-red-500"})}):a.jsx("span",{className:"w-6 flex items-center justify-center",children:a.jsx(Nm,{className:`text-[8px] ${o?"text-sky-600":"text-gray-300"}`})}),a.jsx("span",{children:Q.symbol})]}),a.jsx("td",{className:`px-3 py-2 text-right text-md ${Q.change>=0?o?"text-blue-600":"text-sky-400":o?"text-rose-600":"text-rose-400"}`,children:Number(Q.bid).toFixed(5)}),a.jsx("td",{className:`px-3 py-2 text-right text-md ${Q.change>=0?o?"text-blue-600":"text-sky-400":o?"text-rose-600":"text-rose-400"}`,children:Number(Q.ask).toFixed(5)}),a.jsxs("td",{className:`px-3 py-2 text-right font-medium ${Q.change>=0?o?"text-emerald-600":"text-emerald-400":o?"text-rose-600":"text-rose-400"}`,children:[Q.change>=0?"+":"",Q.change,"%"]})]},Q.symbol)),y.length>0&&a.jsx("tr",{className:o?"bg-slate-50":"bg-slate-900",children:a.jsx("td",{colSpan:4,className:`px-3 py-2 text-xs font-semibold ${o?"text-emerald-600":"text-emerald-400"}`,children:"CRYPTO"})}),y.map(Q=>a.jsxs("tr",{onClick:()=>A(Q.symbol),className:`cursor-pointer transition-colors ${t===Q.symbol?o?"bg-sky-50 border-l-2 border-sky-500":"bg-slate-800 border-l-2 border-sky-500":o?"hover:bg-slate-50":"hover:bg-slate-800"}`,children:[a.jsx("td",{className:`px-3 py-2 text-md font-medium ${o?"text-slate-800":"text-slate-100"}`,children:Q.symbol}),a.jsx("td",{className:`px-3 py-2 text-right text-md ${Q.change>=0?o?"text-blue-600":"text-sky-400":o?"text-rose-600":"text-rose-400"}`,children:Number(Q?.bid)?.toFixed(5)}),a.jsx("td",{className:`px-3 py-2 text-right text-md ${Q.change>=0?o?"text-blue-600":"text-sky-400":o?"text-rose-600":"text-rose-400"}`,children:Number(Q?.ask)?.toFixed(5)}),a.jsxs("td",{className:`px-3 py-2 text-right font-medium ${Q.change>=0?o?"text-emerald-600":"text-emerald-400":o?"text-rose-600":"text-rose-400"}`,children:[Q.change>=0?"+":"",Q.change,"%"]})]},Q.symbol))]})]})})]})]})},Ix=({accountSummary:i,orders:e,onClose:t,height:A,onNewOrder:r})=>{const{accountSummary:n,orders:s,theme:o,isShow:l,setIsShow:c,historyOrders:h,fetchHistoryOrders:d,setIsTradeOpenModal:y,isTradeOpenModal:Q,selectedTradeForModify:b,setSelectedTradeForModify:C}=Lt(),U=i||n,M=e?.length>0?e:s,E=h||[],I=o==="light",R=l?"history":"trade";j.useEffect(()=>{l&&d&&d()},[l,d]);const L="#26A69A",O="#EF5350",Y=I?"#f8fafc":"#12161D",X=I?"#e2e8f0":"#1e293b",Ae=I?"#f1f5f9":"#12161D",oe=I?"#F0F5F9":"#2B3543",W=I?"#f8fafc":"#131c2e",ce=I?"#12161D":"#fff",$=I?"#64748b":"#fff",Be=(M||[]).filter(ue=>ue.status==="OPEN"||!ue.closeAt),Ce=U?.balance||0,ee=U?.equity??Ce,Z=U?.margin||0,re=U?.freeMargin??ee-Z,fe=Z>0?ee/Z*100:0,we=Be.reduce((ue,ae)=>ue+(ae.livePnL??ae.profit??0),0),ve=ue=>{const ae=parseFloat(ue);return Number.isFinite(ae)?ae.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):"0.00"},xe=ue=>{const ae=parseFloat(ue);return!ae||isNaN(ae)?"—":ae>=1e4?ae.toFixed(2):ae>=10?ae.toFixed(4):ae.toFixed(5)},me=ue=>{const ae=parseFloat(ue);return isNaN(ae)?"—":(ae>=0?"+":"")+ae.toFixed(2)},Se=ue=>{const ae=parseFloat(ue);return isNaN(ae)?"—":ae.toFixed(2)},He=ue=>{if(!ue)return"—";const ae=new Date(ue);return isNaN(ae.getTime())?String(ue):`${ae.toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"2-digit"})} ${ae.toTimeString().slice(0,8)}`},Ee=j.useCallback((ue,ae)=>{ue.stopPropagation(),t&&t(ae.id,ae)},[t]),_e=j.useCallback(ue=>{b&&b.id===ue.id?(C(null),y(!1)):(C(ue),y(!0),r&&r())},[C,y,b,r]),Qe=j.useCallback((ue,ae)=>{ue.stopPropagation(),_e(ae)},[_e]),Ie={fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, monospace",backgroundColor:Y,borderTop:`1px solid ${X}`,display:"flex",flexDirection:"column",height:A?`${A}px`:"auto",overflow:"hidden",fontSize:"11px",color:ce},Ze={display:"flex",alignItems:"center",gap:"0",padding:"5px 10px",backgroundColor:oe,borderBottom:`1px solid ${X}`,flexShrink:0,flexWrap:"wrap",rowGap:"2px"},We={display:"flex",alignItems:"center",gap:"4px",paddingRight:"14px",marginRight:"14px",borderRight:`1px solid ${X}`,whiteSpace:"nowrap"},Te={color:$,fontWeight:600,fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.05em"},it={fontFamily:"monospace",fontWeight:700,fontSize:"11px"},Ge={display:"flex",borderBottom:`1px solid ${X}`,flexShrink:0,backgroundColor:Ae},Ve=ue=>({padding:"5px 14px",fontSize:"11px",fontWeight:ue?700:500,color:ue?I?"#0ea5e9":"#38bdf8":$,borderBottom:ue?`2px solid ${I?"#0ea5e9":"#38bdf8"}`:"2px solid transparent",background:"none",border:"none",cursor:"pointer",transition:"color 0.15s",outline:"none"}),De={padding:"4px 8px",textAlign:"left",color:$,fontWeight:700,fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.05em",borderBottom:`1px solid ${X}`,whiteSpace:"nowrap",backgroundColor:Ae,position:"sticky",top:0,zIndex:1},Pe={padding:"3px 8px",borderBottom:`1px solid ${X}`,whiteSpace:"nowrap",fontFamily:"monospace",fontSize:"11px",color:ce};return a.jsxs("div",{style:Ie,children:[a.jsxs("div",{style:Ze,children:[a.jsxs("div",{style:We,children:[a.jsx("span",{style:Te,children:"Balance:"}),a.jsxs("span",{style:{...it,color:ce},children:["$",ve(Ce)]})]}),a.jsxs("div",{style:We,children:[a.jsx("span",{style:Te,children:"Equity:"}),a.jsxs("span",{style:{...it,color:ee>=Ce?L:O},children:["$",ve(ee)]})]}),a.jsxs("div",{style:We,children:[a.jsx("span",{style:Te,children:"Margin:"}),a.jsxs("span",{style:{...it,color:ce},children:["$",ve(Z)]})]}),a.jsxs("div",{style:We,children:[a.jsx("span",{style:Te,children:"Free Margin:"}),a.jsxs("span",{style:{...it,color:re>=0?ce:O},children:["$",ve(re)]})]}),a.jsxs("div",{style:{...We,borderRight:"none",marginRight:0,paddingRight:0},children:[a.jsx("span",{style:Te,children:"Margin Level:"}),a.jsx("span",{style:{...it,color:fe>=100?L:O},children:Z>0?fe.toFixed(2)+"%":"—"})]}),Be.length>0&&a.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"4px"},children:[a.jsx("span",{style:Te,children:"Float P/L:"}),a.jsxs("span",{style:{...it,color:we>=0?L:O,fontWeight:700},children:[we>=0?"+":"",ve(we)]})]})]}),a.jsxs("div",{style:Ge,children:[a.jsx("button",{style:Ve(R==="trade"),onClick:()=>c&&c(!1),children:"Trade"}),a.jsx("button",{style:Ve(R==="history"),onClick:()=>c&&c(!0),children:"History"})]}),R==="trade"&&a.jsx("div",{style:{overflowY:"auto",flex:1},children:a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",minWidth:"800px"},children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{style:De,children:"Symbol"}),a.jsx("th",{style:De,children:"Ticket"}),a.jsx("th",{style:De,children:"Time"}),a.jsx("th",{style:De,children:"Type"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"Volume"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"Price"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"S/L"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"T/P"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"Current"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"Profit"}),a.jsx("th",{style:{...De,textAlign:"center"},children:"Action"}),a.jsx("th",{style:{...De,textAlign:"center"},children:"Close"})]})}),a.jsx("tbody",{children:Be.length===0?a.jsx("tr",{children:a.jsx("td",{colSpan:12,style:{...Pe,textAlign:"center",padding:"16px",color:$},children:"No open positions"})}):Be.map(ue=>{const ae=ue.livePnL??ue.profit??0,he=ae>=0?L:O,Fe=b&&b.id===ue.id;return a.jsxs("tr",{style:{cursor:"pointer",backgroundColor:Fe?I?"#e0f2fe":"#1e3a5f":"transparent"},onClick:()=>_e(ue),onMouseEnter:Le=>{Fe||(Le.currentTarget.style.backgroundColor=W)},onMouseLeave:Le=>{Fe||(Le.currentTarget.style.backgroundColor="transparent")},children:[a.jsx("td",{style:{...Pe,fontWeight:700,color:ce,letterSpacing:"0.02em"},children:ue.symbol}),a.jsx("td",{style:{...Pe,color:$,fontSize:"10px"},children:String(ue.id||"").slice(0,8).toUpperCase()}),a.jsx("td",{style:{...Pe,color:$},children:He(ue.openAt||ue.time)}),a.jsx("td",{style:{...Pe,fontWeight:700,color:ue.type==="BUY"?L:O},children:ue.type}),a.jsx("td",{style:{...Pe,textAlign:"right"},children:Se(ue.volume)}),a.jsx("td",{style:{...Pe,textAlign:"right"},children:xe(ue.price??ue.openPrice)}),a.jsx("td",{style:{...Pe,textAlign:"right",color:ue.stopLoss?O:$},children:ue.stopLoss?xe(ue.stopLoss):"—"}),a.jsx("td",{style:{...Pe,textAlign:"right",color:ue.takeProfit?L:$},children:ue.takeProfit?xe(ue.takeProfit):"—"}),a.jsx("td",{style:{...Pe,textAlign:"right",color:$}}),a.jsx("td",{style:{...Pe,textAlign:"right",fontWeight:700,color:he},children:me(ae)}),a.jsx("td",{style:{...Pe,textAlign:"center"},children:a.jsx("button",{onClick:Le=>Qe(Le,ue),title:"Modify TP/SL",style:{background:"none",border:"none",cursor:"pointer",color:$,padding:"2px 4px",borderRadius:"3px",fontSize:"11px",lineHeight:1},onMouseEnter:Le=>Le.currentTarget.style.color="#f59e0b",onMouseLeave:Le=>Le.currentTarget.style.color=$,children:"✎"})}),a.jsx("td",{style:{...Pe,textAlign:"right",fontWeight:700,color:he},children:a.jsx("button",{onClick:Le=>Ee(Le,ue),title:"Close position",style:{padding:"2px 8px",backgroundColor:"#7f1d1d",border:"1px solid #991b1b",borderRadius:"3px",color:"#fca5a5",fontSize:"10px",fontWeight:700,cursor:"pointer"},onMouseEnter:Le=>Le.currentTarget.style.backgroundColor="#991b1b",onMouseLeave:Le=>Le.currentTarget.style.backgroundColor="#7f1d1d",children:"Close"})})]},ue.id)})})]})}),R==="history"&&a.jsx("div",{style:{overflowY:"auto",flex:1},children:a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",minWidth:"900px"},children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{style:De,children:"Symbol"}),a.jsx("th",{style:De,children:"Ticket"}),a.jsx("th",{style:De,children:"Open Time"}),a.jsx("th",{style:De,children:"Type"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"Volume"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"Open Price"}),a.jsx("th",{style:De,children:"Close Time"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"Close Price"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"S/L"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"T/P"}),a.jsx("th",{style:{...De,textAlign:"right"},children:"Profit"})]})}),a.jsx("tbody",{children:E.length===0?a.jsx("tr",{children:a.jsx("td",{colSpan:11,style:{...Pe,textAlign:"center",padding:"16px",color:$},children:"No trade history"})}):E.map(ue=>{const ae=ue.profit??0,he=ae>=0?L:O;return a.jsxs("tr",{style:{cursor:"default"},onMouseEnter:Fe=>Fe.currentTarget.style.backgroundColor=W,onMouseLeave:Fe=>Fe.currentTarget.style.backgroundColor="transparent",children:[a.jsx("td",{style:{...Pe,fontWeight:700,color:ce,letterSpacing:"0.02em"},children:ue.symbol}),a.jsx("td",{style:{...Pe,color:$,fontSize:"10px"},children:String(ue.id||"").slice(0,8).toUpperCase()}),a.jsx("td",{style:{...Pe,color:$},children:He(ue.openAt)}),a.jsx("td",{style:{...Pe,fontWeight:700,color:ue.type==="BUY"?L:O},children:ue.type}),a.jsx("td",{style:{...Pe,textAlign:"right"},children:Se(ue.volume)}),a.jsx("td",{style:{...Pe,textAlign:"right"},children:xe(ue.openPrice)}),a.jsx("td",{style:{...Pe,color:$},children:He(ue.closeAt)}),a.jsx("td",{style:{...Pe,textAlign:"right"},children:xe(ue.closePrice)}),a.jsx("td",{style:{...Pe,textAlign:"right",color:ue.stopLoss?O:$},children:ue.stopLoss?xe(ue.stopLoss):"—"}),a.jsx("td",{style:{...Pe,textAlign:"right",color:ue.takeProfit?L:$},children:ue.takeProfit?xe(ue.takeProfit):"—"}),a.jsx("td",{style:{...Pe,textAlign:"right",fontWeight:700,color:he},children:me(ae)})]},ue.id)})})]})})]})},rp={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Px=({onModify:i,onClosePosition:e,priceFormatter:t})=>{const{isTradeOpenModal:A,setIsTradeOpenModal:r,selectedTradeForModify:n,setSelectedTradeForModify:s,symbols:o,theme:l,baseUrl:c,setOrders:h,fetchOrders:d}=Lt(),y=!!(A&&n),Q=n,b=l==="light",[C,U]=j.useState(""),[M,E]=j.useState(""),[I,R]=j.useState(""),[L,O]=j.useState(!1),[Y,X]=j.useState(""),[Ae,oe]=j.useState(0),[W,ce]=j.useState(0),[$,Be]=j.useState("inherit"),[Ce,ee]=j.useState("inherit"),Z=j.useRef(0),re=j.useRef(0),fe=j.useRef(null),we=j.useRef(null),ve=j.useRef(null),xe=j.useRef(null);j.useEffect(()=>{if(!y||!Q){xe.current=null;return}const Re=Q.id;xe.current!==Re&&(xe.current=Re,U(Q.stopLoss!=null?String(Q.stopLoss):""),E(Q.takeProfit!=null?String(Q.takeProfit):""),R(Q.comment||""),X(""),fe.current=Q.stopLoss??null,we.current=Q.takeProfit??null)},[y,Q?.id]),j.useEffect(()=>{if(!y||!Q?.symbol)return;const Re=o.find(rt=>rt.symbol===Q.symbol);if(Re){const rt=parseFloat(Re.bid)||0,ke=parseFloat(Re.ask)||0;rt>0&&(oe(rt),Z.current=rt),ke>0&&(ce(ke),re.current=ke)}const Ne=vn.getSocket(),ct=rt=>{if(!rt?.symbol||rt.symbol.toUpperCase()!==Q.symbol.toUpperCase())return;const ke=parseFloat(rt.bid)||0,mt=parseFloat(rt.ask)||0;ke>0&&(Be(ke>Z.current?"text-green-400":ke<Z.current?"text-red-400":""),setTimeout(()=>Be(""),500),oe(ke),Z.current=ke),mt>0&&(ee(mt>re.current?"text-green-400":mt<re.current?"text-red-400":""),setTimeout(()=>ee(""),500),ce(mt),re.current=mt)};return Ne.on("priceUpdate",ct),()=>Ne.off("priceUpdate",ct)},[y,Q?.symbol,o]),j.useEffect(()=>{if(!(!y||!s))return clearTimeout(ve.current),ve.current=setTimeout(()=>{const Re=C!==""?parseFloat(C):null,Ne=M!==""?parseFloat(M):null;fe.current=Re,we.current=Ne,s(ct=>!ct||ct.stopLoss===Re&&ct.takeProfit===Ne?ct:{...ct,stopLoss:Re,takeProfit:Ne})},150),()=>clearTimeout(ve.current)},[C,M,y,s]),j.useEffect(()=>{if(!y||!Q)return;const Re=Q.stopLoss??null,Ne=Q.takeProfit??null,ct=(rt,ke)=>rt===ke||rt!=null&&ke!=null&&Math.abs(rt-ke)<1e-6;ct(Re,fe.current)||(fe.current=Re,U(Re!=null?String(Re):"")),ct(Ne,we.current)||(we.current=Ne,E(Ne!=null?String(Ne):""))},[Q?.stopLoss,Q?.takeProfit,y]);const me=j.useCallback(Re=>{if(t)return t(Re,Q?.symbol);const Ne=parseFloat(Re);return!Ne||isNaN(Ne)?"—":Ne>=1e3?Ne.toFixed(3):Ne>=10?Ne.toFixed(4):Ne.toFixed(5)},[t,Q?.symbol]),Se=String(Q?.symbol||"").toUpperCase().includes("JPY"),He=Se?3:5,Ee=Se?.01:1e-4,_e=Q?.type==="BUY",Qe=_e?Ae:W,Ie=parseFloat(Q?.price||Q?.openPrice||0),Ze=parseFloat(Q?.volume||0),We=String(Q?.symbol||"").toUpperCase(),Te=We.includes("XAU")?100:We.includes("XAG")?5e3:We.endsWith("USDT")||We.includes("BTC")||We.includes("ETH")?1:1e5,Ge=(_e?Qe-Ie:Ie-Qe)*Ze*Te,Ve=isNaN(Ge)?"0.00":Ge.toFixed(2),De=Ge>=0,Pe=(Ze*Te).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),ue=We.slice(3)||"",ae=Re=>{const Ne=parseFloat(C),ct=Number.isFinite(Ne)&&Ne>0?Ne:_e?Qe-Ee*50:Qe+Ee*50;U((ct+Re*Ee).toFixed(He)),X("")},he=Re=>{const Ne=parseFloat(M),ct=Number.isFinite(Ne)&&Ne>0?Ne:_e?Qe+Ee*50:Qe-Ee*50;E((ct+Re*Ee).toFixed(He)),X("")},Le=We.includes("XAU")?.5:Se?.05:2e-4,Ye=()=>{const Re=C!==""?parseFloat(C):null,Ne=M!==""?parseFloat(M):null;if(Re!==null){if(isNaN(Re)||Re<=0)return"Stop Loss must be a valid positive number";if(_e&&Re>=Ie)return`SL must be below entry price (${me(Ie)}) for BUY`;if(!_e&&Re<=Ie)return`SL must be above entry price (${me(Ie)}) for SELL`;if(Qe>0){if(_e&&Re>=Qe-Le)return`SL ${me(Re)} is too close to current bid ${me(Qe)} — move it at least ${(Le*1e4).toFixed(0)} pips lower`;if(!_e&&Re<=Qe+Le)return`SL ${me(Re)} is too close to current ask ${me(Qe)} — move it at least ${(Le*1e4).toFixed(0)} pips higher`}}if(Ne!==null){if(isNaN(Ne)||Ne<=0)return"Take Profit must be a valid positive number";if(_e&&Ne<=Ie)return`TP must be above entry price (${me(Ie)}) for BUY`;if(!_e&&Ne>=Ie)return`TP must be below entry price (${me(Ie)}) for SELL`;if(Qe>0){if(_e&&Ne<=Qe+Le)return`TP ${me(Ne)} is too close to current bid ${me(Qe)} — move it at least ${(Le*1e4).toFixed(0)} pips higher`;if(!_e&&Ne>=Qe-Le)return`TP ${me(Ne)} is too close to current ask ${me(Qe)} — move it at least ${(Le*1e4).toFixed(0)} pips lower`}}return null},qe=async()=>{if(!Q)return;const Re=Ye();if(Re){X(Re);return}X(""),O(!0);const Ne=C!==""?parseFloat(C):null,ct=M!==""?parseFloat(M):null;console.log("[ModifyTradeModal] Submitting modify:",{tradeId:Q.id,stopLoss:Ne,takeProfit:ct,tradeType:Q.type,entryPrice:Ie,currentClosePrice:Qe});try{if(i)await i(Q.id,{stopLoss:Ne,takeProfit:ct});else{const rt=localStorage.getItem("token"),ke=c||rp?.VITE_BASE_URL||"http://localhost:8000";await ut.patch(`${ke}/trades/${Q.id}/modify`,{stopLoss:Ne,takeProfit:ct},{headers:{Authorization:`Bearer ${rt}`,"Content-Type":"application/json"}}),h&&h(mt=>mt.map(vt=>vt.id===Q.id?{...vt,stopLoss:Ne,takeProfit:ct}:vt)),d&&d()}tA()}catch(rt){const ke=rt?.response?.data?.message||rt?.message||"Modify failed";X(ke),console.error("[ModifyTradeModal] Modify error:",rt)}finally{O(!1)}},Qt=async()=>{if(Q){if(!Qe||Qe<=0){X("Current price not available — cannot close");return}O(!0),console.log("[ModifyTradeModal] Closing position:",{tradeId:Q.id,closePrice:Qe,tradeType:Q.type});try{if(e)await e(Q.id,Qe);else{const Re=localStorage.getItem("token"),Ne=c||rp?.VITE_BASE_URL||"http://localhost:8000";await ut.patch(`${Ne}/trades/${Q.id}`,{closePrice:Qe},{headers:{Authorization:`Bearer ${Re}`,"Content-Type":"application/json"}}),h&&h(ct=>ct.filter(rt=>rt.id!==Q.id)),d&&d()}tA()}catch(Re){X(Re?.response?.data?.message||Re?.message||"Close failed"),console.error("[ModifyTradeModal] Close error:",Re)}finally{O(!1)}}},tA=()=>{s(null),r(!1),xe.current=null,X(""),clearTimeout(ve.current)};if(!y||!Q)return null;const $t=Q.ticket||String(Q.id||"").replace(/-/g,"").slice(0,10),ei=(Q.type||"").toLowerCase(),Je={bg:b?"#ffffff":"#12161d",border:b?"#e2e8f0":"#1e293b",inputBg:b?"#ffffff":"#0f172a",inputBorder:b?"#cbd5e1":"#1e293b",stepperBg:b?"#f1f5f9":"#1e293b",priceBg:b?"#f8fafc":"#1a2332",closeBtnBg:b?"#f1f5f9":"#1e293b",text:b?"#1e293b":"#f1f5f9",label:b?"#475569":"#cbd5e1",muted:b?"#64748b":"#94a3b8"};return a.jsxs("div",{className:"w-full h-full flex flex-col pointer-events-auto overflow-hidden text-sm",style:{background:Je.bg,color:Je.text},children:[a.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b shrink-0",style:{borderColor:Je.border},children:[a.jsxs("span",{className:"font-mono text-xs font-semibold truncate",style:{color:Je.text},children:["#",$t," ",ei," ",parseFloat(Q.volume||0).toFixed(2)," ",Q.symbol," ",me(Ie)]}),a.jsx("button",{onClick:tA,className:"ml-2 shrink-0 p-1 rounded transition-colors hover:bg-white/10",style:{color:Je.muted},children:a.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-3 space-y-3",children:[Y&&a.jsx("div",{className:"p-2 rounded border text-xs leading-snug",style:{background:"rgba(239,68,68,0.08)",borderColor:"rgba(239,68,68,0.3)",color:"#f87171"},children:Y}),a.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 rounded text-xs border",style:{background:Je.priceBg,borderColor:Je.border},children:[a.jsxs("div",{children:[a.jsx("span",{style:{color:Je.muted},children:"SELL "}),a.jsx("span",{className:"font-mono font-bold transition-colors duration-300",style:{color:$?void 0:Je.text},...$?{className:`font-mono font-bold transition-colors duration-300 ${$}`}:{},children:Ae>0?me(Ae):"—"})]}),a.jsx("span",{className:"font-semibold text-xs",style:{color:Je.muted},children:Q.symbol}),a.jsxs("div",{children:[a.jsx("span",{style:{color:Je.muted},children:"BUY "}),a.jsx("span",{className:"font-mono font-bold transition-colors duration-300",style:{color:Ce?void 0:Je.text},...Ce?{className:`font-mono font-bold transition-colors duration-300 ${Ce}`}:{},children:W>0?me(W):"—"})]})]}),a.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{label:"Volume",sub:`${Pe} ${ue}`,val:parseFloat(Q.volume||0).toFixed(2)},{label:"Price",sub:null,val:me(Ie)}].map(({label:Re,sub:Ne,val:ct})=>a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("span",{className:"text-xs font-medium",style:{color:Je.label},children:Re}),Ne&&a.jsx("span",{className:"text-xs font-mono",style:{color:Je.muted},children:Ne})]}),a.jsxs("div",{className:"relative flex items-center",children:[a.jsx("button",{className:"absolute left-1 w-7 h-7 flex items-center justify-center rounded text-sm z-10 opacity-40 cursor-default",style:{background:Je.stepperBg,color:Je.text},children:"−"}),a.jsx("input",{type:"text",value:ct,readOnly:!0,className:"w-full px-8 py-1.5 rounded text-xs text-center font-mono border cursor-default focus:outline-none",style:{background:Je.inputBg,borderColor:Je.inputBorder,color:Je.text}}),a.jsx("button",{className:"absolute right-1 w-7 h-7 flex items-center justify-center rounded text-sm z-10 opacity-40 cursor-default",style:{background:Je.stepperBg,color:Je.text},children:"+"})]})]},Re))}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("span",{className:"text-xs font-medium",style:{color:Je.label},children:"Stop Loss"}),C!==""&&a.jsx("button",{onClick:()=>{U(""),X("")},className:"hover:text-red-400 transition-colors",style:{color:Je.muted},title:"Clear Stop Loss",children:a.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M6 18L18 6M6 6l12 12"})})})]}),a.jsxs("div",{className:"relative flex items-center",children:[a.jsx("button",{onClick:()=>ae(-1),className:"absolute left-1 w-7 h-7 flex items-center justify-center rounded text-sm z-10 transition-colors hover:opacity-80",style:{background:Je.stepperBg,color:Je.text},children:"−"}),a.jsx("input",{type:"text",value:C,onChange:Re=>{const Ne=Re.target.value;(Ne===""||/^\d*\.?\d*$/.test(Ne))&&(U(Ne),X(""))},onBlur:Re=>{const Ne=parseFloat(Re.target.value);!isNaN(Ne)&&Ne>0?U(Ne.toFixed(He)):Re.target.value!==""&&Re.target.value!=="."&&U("")},placeholder:"—",className:"w-full px-8 py-1.5 rounded text-xs text-center font-mono border focus:outline-none transition-colors",style:C!==""?{background:"rgba(239,68,68,0.05)",borderColor:"rgba(239,68,68,0.5)",color:"#f87171"}:{background:Je.inputBg,borderColor:Je.inputBorder,color:Je.text}}),a.jsx("button",{onClick:()=>ae(1),className:"absolute right-1 w-7 h-7 flex items-center justify-center rounded text-sm z-10 transition-colors hover:opacity-80",style:{background:Je.stepperBg,color:Je.text},children:"+"})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("span",{className:"text-xs font-medium",style:{color:Je.label},children:"Take Profit"}),M!==""&&a.jsx("button",{onClick:()=>{E(""),X("")},className:"hover:text-red-400 transition-colors",style:{color:Je.muted},title:"Clear Take Profit",children:a.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M6 18L18 6M6 6l12 12"})})})]}),a.jsxs("div",{className:"relative flex items-center",children:[a.jsx("button",{onClick:()=>he(-1),className:"absolute left-1 w-7 h-7 flex items-center justify-center rounded text-sm z-10 transition-colors hover:opacity-80",style:{background:Je.stepperBg,color:Je.text},children:"−"}),a.jsx("input",{type:"text",value:M,onChange:Re=>{const Ne=Re.target.value;(Ne===""||/^\d*\.?\d*$/.test(Ne))&&(E(Ne),X(""))},onBlur:Re=>{const Ne=parseFloat(Re.target.value);!isNaN(Ne)&&Ne>0?E(Ne.toFixed(He)):Re.target.value!==""&&Re.target.value!=="."&&E("")},placeholder:"—",className:"w-full px-8 py-1.5 rounded text-xs text-center font-mono border focus:outline-none transition-colors",style:M!==""?{background:"rgba(34,197,94,0.05)",borderColor:"rgba(34,197,94,0.5)",color:"#4ade80"}:{background:Je.inputBg,borderColor:Je.inputBorder,color:Je.text}}),a.jsx("button",{onClick:()=>he(1),className:"absolute right-1 w-7 h-7 flex items-center justify-center rounded text-sm z-10 transition-colors hover:opacity-80",style:{background:Je.stepperBg,color:Je.text},children:"+"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium mb-1",style:{color:Je.label},children:"Comment"}),a.jsx("textarea",{value:I,onChange:Re=>R(Re.target.value),rows:2,className:"w-full px-2 py-1.5 rounded text-xs font-mono border resize-none focus:outline-none",style:{background:Je.inputBg,borderColor:Je.inputBorder,color:Je.text}})]}),a.jsx("button",{onClick:qe,disabled:L,className:"w-full py-2.5 bg-blue-600 hover:bg-blue-700 active:bg-blue-800 disabled:opacity-50 disabled:cursor-not-allowed text-white font-semibold rounded text-sm transition-colors",children:L?a.jsxs("span",{className:"flex items-center justify-center gap-2",children:[a.jsxs("svg",{className:"animate-spin h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",children:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Modifying..."]}):"Modify"}),a.jsxs("button",{onClick:Qt,disabled:L||!Qe,className:"w-full py-2 rounded text-xs font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed",style:{background:Je.closeBtnBg,color:Je.muted},children:[a.jsxs("span",{className:"block",children:["Close #",$t," ",ei," ",parseFloat(Q.volume||0).toFixed(2)," ",Q.symbol]}),a.jsxs("span",{className:"block font-mono mt-0.5",children:[me(Ie)," at ",Qe>0?me(Qe):"—"," with"," ",a.jsxs("span",{className:De?"text-green-400":"text-red-400",children:[De?"Profit":"Loss"," ",De?"+":"",Ve]})]})]})]})]})},Dx="2.3.2";et.AccountPanel=Ix,et.BuySellPanel=Sh,et.Chart=gx,et.ChartTypeSelector=xx,et.CoinSelector=qd,et.DrawingTools=Ap,et.LeftSidebar=Lx,et.MarketExecutionModal=Eh,et.MarketWatch=Hx,et.ModifyTradeModal=Px,et.PositionsPanel=bx,et.SYMBOL_CONFIG=Xa,et.StopLoss=ep,et.TakeProfit=tp,et.TimeframeSelector=Cx,et.ToolCustomizationModal=Ph,et.TopBar=Ex,et.TradePanel=Tx,et.TradingProvider=Qm,et.TradingToolbar=Bx,et.VolumeControl=jd,et.alignToTimeframe=ze,et.detectGaps=vp,et.getSymbolConfig=zi,et.is24x7Symbol=Cp,et.isCryptoSymbol=yp,et.isForexSymbol=Bp,et.isWithinTradingSession=xp,et.normalizeCandleTimes=Ja,et.normalizeTime=ie,et.processCandles=el,et.processSingleCandle=tl,et.setSocketBaseUrl=xh,et.timeframeToSeconds=iA,et.useTrading=Lt,et.validateTimeOrdering=Tp,et.version=Dx,Object.defineProperty(et,Symbol.toStringTag,{value:"Module"})}));
|