@backtest-kit/ui 7.4.0 → 7.5.0

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.
Files changed (25) hide show
  1. package/build/modules/frontend/build/assets/{Article-C5-2kK-h.js → Article-Z1gwQi4C.js} +1 -1
  2. package/build/modules/frontend/build/assets/{Background-Cw2iN6KJ.js → Background-DS1gKl45.js} +1 -1
  3. package/build/modules/frontend/build/assets/{IconPhoto-B9wAeXe1.js → IconPhoto-BitDk5sL.js} +1 -1
  4. package/build/modules/frontend/build/assets/{KeyboardArrowLeft-C1qRm69Y.js → KeyboardArrowLeft-BT0IHVDD.js} +1 -1
  5. package/build/modules/frontend/build/assets/{Refresh-TNgz_b0v.js → Refresh-BgupECvn.js} +1 -1
  6. package/build/modules/frontend/build/assets/emitters-BJfdDGbd.js +1 -0
  7. package/build/modules/frontend/build/assets/{hasRouteMatch-CYLF108Z.js → hasRouteMatch-CcXyiBjV.js} +1 -1
  8. package/build/modules/frontend/build/assets/{html2canvas-BiE4mNf-.js → html2canvas-CxpxaxUC.js} +1 -1
  9. package/build/modules/frontend/build/assets/{index-D_xsPZ0X.js → index-1kyziIc7.js} +1 -1
  10. package/build/modules/frontend/build/assets/{index-AF9AvKwr.js → index-3ZYgMfYi.js} +1 -1
  11. package/build/modules/frontend/build/assets/{index-HmxUvvMu.js → index-9YHmY3Zv.js} +1 -1
  12. package/build/modules/frontend/build/assets/{index-UiRxh0X0.js → index-BR0aHfoe.js} +1 -1
  13. package/build/modules/frontend/build/assets/{index-C_jQT6Zw.js → index-Bg2qm7TJ.js} +1 -1
  14. package/build/modules/frontend/build/assets/{index-Cle4ryUi.js → index-C4dzv30q.js} +1 -1
  15. package/build/modules/frontend/build/assets/{index-C4_OGd1K.js → index-C8Wdopwt.js} +1 -1
  16. package/build/modules/frontend/build/assets/{index-mHMR_sVK.js → index-CWErSuod.js} +1 -1
  17. package/build/modules/frontend/build/assets/{index-BCP4aeGv.js → index-CnRuFJIf.js} +1 -1
  18. package/build/modules/frontend/build/assets/{index-DycIUKAc.js → index-DzrwP4k5.js} +5 -5
  19. package/build/modules/frontend/build/assets/{index-DDXw0lYL.js → index-J3hGIAw0.js} +1 -1
  20. package/build/modules/frontend/build/assets/{index-Coo1fwWW.js → index-nfZ8sdZp.js} +1 -1
  21. package/build/modules/frontend/build/assets/{index.es-qA9pRd9t.js → index.es-Du6U2Hyj.js} +1 -1
  22. package/build/modules/frontend/build/assets/{markdownit-B5MND-Q3.js → markdownit-SQF1Xc8y.js} +1 -1
  23. package/build/modules/frontend/build/index.html +1 -1
  24. package/package.json +3 -3
  25. package/build/modules/frontend/build/assets/emitters-Uy5NDw0B.js +0 -1
@@ -1 +1 @@
1
- import{r as e,f as a,P as i,B as r,N as n,az as t,T as o,ae as s,K as c,am as l,F as d,aA as p,M as m,aB as u,aC as b,aD as v,aE as y,au as g,aF as h,aG as x,aH as k,aI as f,aJ as $,aK as S,aL as P,i as w,ap as C,X as _,aq as E,v as L,w as A,aM as F,aN as z,z as D}from"./index-DycIUKAc.js";import{C as O,R as j}from"./Refresh-TNgz_b0v.js";import{K as B}from"./KeyboardArrowLeft-C1qRm69Y.js";const T=e=>{const i={color:"white",fontSize:28};switch(e.type){case"signal.opened":case"partial_profit.available":case"partial_profit.commit":return a(S,{sx:i});case"signal.closed":case"signal_sync.close":case"close_pending.commit":return a(g,{sx:i});case"signal.scheduled":return a(P,{sx:i});case"signal.cancelled":case"cancel_scheduled.commit":return a(h,{sx:i});case"partial_loss.available":case"partial_loss.commit":case"average_buy.commit":return a(f,{sx:i});case"breakeven.available":case"breakeven.commit":return a($,{sx:i});case"activate_scheduled.commit":case"signal_sync.open":return a(x,{sx:i});case"trailing_stop.commit":case"trailing_take.commit":return a(k,{sx:i});case"risk.rejection":return a(y,{sx:i});case"error.info":case"error.validation":case"signal.info":return a(b,{sx:i});case"error.critical":return a(v,{sx:i});default:return a(u,{sx:i})}},I=e=>{switch(e.type){case"signal.opened":return`${l("Opened")} ${e.position.toUpperCase()} ${e.symbol}`;case"signal.closed":return`${l("Closed")} ${e.symbol} (${e.pnlPercentage>0?"+":""}${e.pnlPercentage.toFixed(2)}%)`;case"signal.scheduled":return`${l("Scheduled")} ${e.position.toUpperCase()} ${e.symbol}`;case"signal.cancelled":return`${l("Cancelled")} ${e.symbol}`;case"partial_profit.available":return`${l("Partial profit")} ${e.level}% ${e.symbol}`;case"partial_profit.commit":return`${l("Profit fixed")} ${e.percentToClose}% ${e.symbol}`;case"partial_loss.available":return`${l("Partial loss")} ${e.level}% ${e.symbol}`;case"partial_loss.commit":return`${l("Loss fixed")} ${e.percentToClose}% ${e.symbol}`;case"breakeven.available":return`${l("Breakeven available")} ${e.symbol}`;case"breakeven.commit":return`${l("Breakeven set")} ${e.symbol}`;case"activate_scheduled.commit":return`${l("Activated")} ${e.position.toUpperCase()} ${e.symbol}`;case"average_buy.commit":return`${l("Average Buy")} ${e.symbol}`;case"trailing_stop.commit":return`${l("Trailing stop")} ${e.symbol}`;case"trailing_take.commit":return`${l("Trailing take")} ${e.symbol}`;case"signal_sync.open":return`${l("Sync Open")} ${e.position.toUpperCase()} ${e.symbol}`;case"signal_sync.close":return`${l("Sync Close")} ${e.symbol} (${e.pnlPercentage>0?"+":""}${e.pnlPercentage.toFixed(2)}%)`;case"cancel_scheduled.commit":return`${l("Cancel Scheduled")} ${e.symbol}`;case"close_pending.commit":return`${l("Close Pending")} ${e.symbol}`;case"risk.rejection":return`${l("Rejected")} ${e.position.toUpperCase()} ${e.symbol}`;case"error.info":return`${l("Error")}: ${e.message}`;case"error.validation":return`${l("Validation")}: ${e.message}`;case"error.critical":return`${l("Critical")}: ${e.message}`;case"signal.info":return`${l("Signal Info")} ${e.symbol} (${e.pnlPercentage>0?"+":""}${e.pnlPercentage.toFixed(2)}%)`;default:return l("Unknown")}},R=e=>{switch(e.type){case"signal.opened":return l("Signal Opened");case"signal.closed":return l("Signal Closed");case"signal.scheduled":return l("Signal Scheduled");case"signal.cancelled":return l("Signal Cancelled");case"partial_profit.available":return l("Partial Profit Available");case"partial_profit.commit":return l("Partial Profit Commit");case"partial_loss.available":return l("Partial Loss Available");case"partial_loss.commit":return l("Partial Loss Commit");case"breakeven.available":return l("Breakeven Available");case"breakeven.commit":return l("Breakeven Commit");case"activate_scheduled.commit":return l("Activated Scheduled");case"average_buy.commit":return l("Average Buy");case"trailing_stop.commit":return l("Trailing Stop");case"trailing_take.commit":return l("Trailing Take");case"signal_sync.open":return l("Signal Sync Open");case"signal_sync.close":return l("Signal Sync Close");case"cancel_scheduled.commit":return l("Cancel Scheduled");case"close_pending.commit":return l("Close Pending");case"risk.rejection":return l("Risk Rejection");case"error.info":return l("Info Error");case"error.validation":return l("Validation Error");case"error.critical":return l("Critical Error");case"signal.info":return l("Signal Info");default:return l("Unknown")}},N=e=>"symbol"in e,U=e=>"position"in e,W=e=>"priceOpen"in e&&"priceTakeProfit"in e&&"priceStopLoss"in e,M=e=>"pnlPercentage"in e,H=e=>"level"in e,K=e=>"percentToClose"in e,Y=e=>"currentPrice"in e,V=e=>"duration"in e,q=e=>"closeReason"in e,G=e=>"cancelReason"in e,J=e=>"percentShift"in e,X=e=>"signal.opened"===e.type?"note"in e&&!!e.note:"signal.info"===e.type?"note"in e&&!!e.note&&!!e.notificationId:"activate_scheduled.commit"===e.type?"note"in e&&!!e.note&&!!e.activateId:"close_pending.commit"===e.type?"note"in e&&!!e.note&&!!e.closeId:"cancel_scheduled.commit"===e.type&&("note"in e&&!!e.note&&!!e.cancelId),Q=e=>"message"in e,Z=e=>"rejectionNote"in e,ee=e=>"activePositionCount"in e,ae=e=>"effectivePriceOpen"in e,ie=e=>"totalEntries"in e&&e.totalEntries>1,re=e=>"originalPriceOpen"in e&&"priceOpen"in e&&e.originalPriceOpen!==e.priceOpen,ne=e=>"totalPartials"in e&&e.totalPartials>0,te=e=>"cost"in e,oe=e=>"pnlPriceOpen"in e&&"pnlPriceClose"in e&&"pnlCost"in e&&"pnlEntries"in e,se=e=>"peakProfitPriceClose"in e,ce=e=>"maxDrawdownPriceClose"in e,le=e.forwardRef(({item:e,className:u,style:b,sx:v},y)=>{const g=(e=>{switch(e.type){case"signal.opened":case"activate_scheduled.commit":case"signal_sync.open":return"#4CAF50";case"signal.closed":case"signal_sync.close":return"#2196F3";case"signal.scheduled":case"average_buy.commit":case"error.info":case"error.validation":return"#FF9800";case"signal.cancelled":case"cancel_scheduled.commit":default:return"#9E9E9E";case"partial_profit.available":case"partial_profit.commit":return"#8BC34A";case"partial_loss.available":case"partial_loss.commit":return"#FF5722";case"breakeven.available":case"breakeven.commit":return"#00BCD4";case"trailing_stop.commit":case"trailing_take.commit":return"#673AB7";case"close_pending.commit":return"#607D8B";case"risk.rejection":return"#F44336";case"error.critical":return"#D32F2F";case"signal.info":return"#9C27B0"}})(e),h=(e=>"timestamp"in e)(e)?e.timestamp:Date.now();return a("div",{className:u,style:b,ref:y,children:a(i,{variant:"outlined",onClick:()=>(e=>{switch(e.type){case"risk.rejection":w.layoutService.pickRisk(e.id);break;case"signal.opened":w.layoutService.pickSignalOpened(e.id);break;case"signal.closed":w.layoutService.pickSignalClosed(e.id);break;case"signal.scheduled":w.layoutService.pickSignalScheduled(e.id);break;case"signal.cancelled":w.layoutService.pickSignalCancelled(e.id);break;case"partial_profit.available":w.layoutService.pickPartialProfitAvailable(e.id);break;case"partial_profit.commit":w.layoutService.pickPartialProfitCommit(e.id);break;case"partial_loss.available":w.layoutService.pickPartialLossAvailable(e.id);break;case"partial_loss.commit":w.layoutService.pickPartialLossCommit(e.id);break;case"breakeven.available":w.layoutService.pickBreakevenAvailable(e.id);break;case"breakeven.commit":w.layoutService.pickBreakevenCommit(e.id);break;case"trailing_stop.commit":w.layoutService.pickTrailingStop(e.id);break;case"trailing_take.commit":w.layoutService.pickTrailingTake(e.id);break;case"activate_scheduled.commit":w.layoutService.pickActivateScheduled(e.id);break;case"average_buy.commit":w.layoutService.pickAverageBuyCommit(e.id);break;case"signal_sync.open":w.layoutService.pickSignalSyncOpen(e.id);break;case"signal_sync.close":w.layoutService.pickSignalSyncClose(e.id);break;case"cancel_scheduled.commit":w.layoutService.pickCancelScheduled(e.id);break;case"close_pending.commit":w.layoutService.pickClosePending(e.id);break;case"signal.info":w.layoutService.pickSignalNotify(e.id)}})(e),sx:{transition:"box-shadow 0.2s ease",cursor:"pointer",display:"flex",alignItems:"stretch",justifyContent:"stretch","&:hover":{boxShadow:4},...v},children:a(r,{sx:{flex:1,position:"relative",overflow:"clip",height:"100%",width:"100%",borderRadius:"12px"},children:[a(n,{direction:"row",spacing:2,sx:{p:2},children:[a(t,{sx:{width:56,height:56,background:g},children:T(e)}),a(n,{flex:1,spacing:1,children:[a(n,{direction:"row",justifyContent:"space-between",alignItems:"flex-start",children:[a(o,{variant:"h6",sx:{fontWeight:600},children:I(e)}),a(o,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"nowrap",ml:2},children:s(h).format("HH:mm DD/MM/YYYY")})]}),a(n,{mt:-1,direction:"row",flexWrap:"wrap",children:[a(c,{size:"small",label:R(e),sx:{background:g,mt:1,mr:1,color:"white",fontWeight:500}}),N(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:e.symbol,variant:"outlined"}),U(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:e.position.toUpperCase(),variant:"outlined",color:"long"===e.position?"success":"error"}),M(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`PnL: ${e.pnlPercentage>0?"+":""}${e.pnlPercentage.toFixed(2)}%`,color:e.pnlPercentage>=0?"success":"error",variant:"outlined"}),H(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`${l("Level")}: ${e.level}%`,variant:"outlined"}),K(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`${l("Close")}: ${e.percentToClose}%`,variant:"outlined"}),V(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`${l("Duration")}: ${e.duration} ${l("min")}`,variant:"outlined"}),q(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:e.closeReason,variant:"outlined",color:"info"}),G(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:e.cancelReason,variant:"outlined",color:"info"}),J(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`${l("Shift")}: ${e.percentShift>0?"+":""}${e.percentShift}%`,variant:"outlined"}),ee(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`${l("Active")}: ${e.activePositionCount}`,variant:"outlined"}),ie(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`${l("Entries")}: ${e.totalEntries}`,variant:"outlined"}),ne(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`${l("Partials")}: ${e.totalPartials}`,variant:"outlined"}),te(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`${l("Cost")}: ${e.cost.toFixed(2)}$`,variant:"outlined"}),ae(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`${l("Avg entry")}: ${e.effectivePriceOpen}`,variant:"outlined",color:"warning"}),re(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`${l("Orig entry")}: ${e.originalPriceOpen}`,variant:"outlined"})]}),W(e)&&a(d,{children:[a(p,{sx:{my:1}}),a(n,{direction:"row",spacing:3,flexWrap:"wrap",children:[Y(e)&&a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Current"),":"," "]}),e.currentPrice]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Take Profit"),":"," "]}),e.priceTakeProfit]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Stop Loss"),":"," "]}),e.priceStopLoss]})]})]}),oe(e)&&a(d,{children:[a(p,{sx:{my:1}}),a(n,{direction:"row",spacing:3,flexWrap:"wrap",children:[a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("PnL Entry"),":"," "]}),e.pnlPriceOpen]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("PnL Exit"),":"," "]}),e.pnlPriceClose]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("PnL"),":"," "]}),a(o,{component:"span",color:e.pnlCost>=0?"success.main":"error.main",children:[e.pnlCost>=0?"+":"",e.pnlCost.toFixed(2),"$"]})]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Invested"),":"," "]}),e.pnlEntries.toFixed(2),"$"]})]})]}),se(e)&&a(d,{children:[a(p,{sx:{my:1}}),a(n,{direction:"row",spacing:3,flexWrap:"wrap",children:[a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Peak Entry"),":"," "]}),e.peakProfitPriceOpen]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Peak Exit"),":"," "]}),e.peakProfitPriceClose]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Peak"),":"," "]}),a(o,{component:"span",color:e.peakProfitCost>=0?"success.main":"error.main",children:[e.peakProfitCost>=0?"+":"",e.peakProfitCost.toFixed(2),"$"]})]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Invested"),":"," "]}),e.peakProfitEntries.toFixed(2),"$"]})]})]}),ce(e)&&a(d,{children:[a(p,{sx:{my:1}}),a(n,{direction:"row",spacing:3,flexWrap:"wrap",children:[a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Drawdown Entry"),":"," "]}),e.maxDrawdownPriceOpen]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Drawdown Exit"),":"," "]}),e.maxDrawdownPriceClose]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Drawdown"),":"," "]}),a(o,{component:"span",color:e.maxDrawdownCost>=0?"success.main":"error.main",children:[e.maxDrawdownCost>=0?"+":"",e.maxDrawdownCost.toFixed(2),"$"]})]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Invested"),":"," "]}),e.maxDrawdownEntries.toFixed(2),"$"]})]})]})]})]}),X(e)&&a(r,{onClick:e=>{e.preventDefault(),e.stopPropagation()},sx:{px:2,pb:2},children:[a(p,{sx:{mb:1.5}}),a(r,{component:"pre",sx:{m:0,whiteSpace:"pre-wrap",wordWrap:"break-word"},children:a(m,{content:e.note})})]}),Z(e)&&a(r,{sx:{px:2,pb:2},children:[a(p,{sx:{mb:1.5}}),a(o,{variant:"body2",color:"error",children:e.rejectionNote})]}),Q(e)&&!X(e)&&a(r,{sx:{px:2,pb:2},children:[a(p,{sx:{mb:1.5}}),a(o,{variant:"body2",color:"text.secondary",children:e.message})]}),a(r,{sx:{position:"absolute",top:0,left:0,bottom:0,width:6,zIndex:1,background:g}})]})})})}),de=[{action:"update-now",label:"Refresh manually",icon:()=>a(D,{icon:j,color:"#4caf50"})}],pe=[{type:A.Link,action:"back-action",label:a(B,{sx:{display:"block"}})},{type:A.Link,action:"back-action",label:"Main"},{type:A.Link,action:"back-action",label:"Notifications"}],me=new _,ue=()=>{const{data:e,hasMore:i,loading:r,onSkip:n}=C({handler:async(e,a)=>{const i=await w.notificationViewService.getList(),r=E(e,a);for(const n of i)if(r([n]).done)break;return r().rows},onLoadStart:()=>w.layoutService.setAppbarLoader(!0),onLoadEnd:()=>w.layoutService.setAppbarLoader(!1),reloadSubject:me});return a(O,{children:[a(L,{items:pe,actions:de,onAction:async e=>{"back-action"===e&&w.routerService.push("/"),"update-now"===e&&await me.next()}}),a(F,{sx:{height:"calc(100vh - 155px)"},withScrollbar:!0,minHeight:72,loading:r,onDataRequest:n,bufferSize:z,hasMore:i,children:e.map(e=>a(le,{item:e,sx:{mb:1}},e.id))})]})};export{ue as NotificationPage,ue as default};
1
+ import{r as e,f as a,P as i,B as r,N as n,az as t,T as o,ae as s,K as c,am as l,F as d,aA as p,M as m,aB as u,aC as b,aD as v,aE as y,au as g,aF as h,aG as x,aH as k,aI as f,aJ as $,aK as S,aL as P,i as w,ap as C,X as _,aq as E,v as L,w as A,aM as F,aN as z,z as D}from"./index-DzrwP4k5.js";import{C as O,R as j}from"./Refresh-BgupECvn.js";import{K as B}from"./KeyboardArrowLeft-BT0IHVDD.js";const T=e=>{const i={color:"white",fontSize:28};switch(e.type){case"signal.opened":case"partial_profit.available":case"partial_profit.commit":return a(S,{sx:i});case"signal.closed":case"signal_sync.close":case"close_pending.commit":return a(g,{sx:i});case"signal.scheduled":return a(P,{sx:i});case"signal.cancelled":case"cancel_scheduled.commit":return a(h,{sx:i});case"partial_loss.available":case"partial_loss.commit":case"average_buy.commit":return a(f,{sx:i});case"breakeven.available":case"breakeven.commit":return a($,{sx:i});case"activate_scheduled.commit":case"signal_sync.open":return a(x,{sx:i});case"trailing_stop.commit":case"trailing_take.commit":return a(k,{sx:i});case"risk.rejection":return a(y,{sx:i});case"error.info":case"error.validation":case"signal.info":return a(b,{sx:i});case"error.critical":return a(v,{sx:i});default:return a(u,{sx:i})}},I=e=>{switch(e.type){case"signal.opened":return`${l("Opened")} ${e.position.toUpperCase()} ${e.symbol}`;case"signal.closed":return`${l("Closed")} ${e.symbol} (${e.pnlPercentage>0?"+":""}${e.pnlPercentage.toFixed(2)}%)`;case"signal.scheduled":return`${l("Scheduled")} ${e.position.toUpperCase()} ${e.symbol}`;case"signal.cancelled":return`${l("Cancelled")} ${e.symbol}`;case"partial_profit.available":return`${l("Partial profit")} ${e.level}% ${e.symbol}`;case"partial_profit.commit":return`${l("Profit fixed")} ${e.percentToClose}% ${e.symbol}`;case"partial_loss.available":return`${l("Partial loss")} ${e.level}% ${e.symbol}`;case"partial_loss.commit":return`${l("Loss fixed")} ${e.percentToClose}% ${e.symbol}`;case"breakeven.available":return`${l("Breakeven available")} ${e.symbol}`;case"breakeven.commit":return`${l("Breakeven set")} ${e.symbol}`;case"activate_scheduled.commit":return`${l("Activated")} ${e.position.toUpperCase()} ${e.symbol}`;case"average_buy.commit":return`${l("Average Buy")} ${e.symbol}`;case"trailing_stop.commit":return`${l("Trailing stop")} ${e.symbol}`;case"trailing_take.commit":return`${l("Trailing take")} ${e.symbol}`;case"signal_sync.open":return`${l("Sync Open")} ${e.position.toUpperCase()} ${e.symbol}`;case"signal_sync.close":return`${l("Sync Close")} ${e.symbol} (${e.pnlPercentage>0?"+":""}${e.pnlPercentage.toFixed(2)}%)`;case"cancel_scheduled.commit":return`${l("Cancel Scheduled")} ${e.symbol}`;case"close_pending.commit":return`${l("Close Pending")} ${e.symbol}`;case"risk.rejection":return`${l("Rejected")} ${e.position.toUpperCase()} ${e.symbol}`;case"error.info":return`${l("Error")}: ${e.message}`;case"error.validation":return`${l("Validation")}: ${e.message}`;case"error.critical":return`${l("Critical")}: ${e.message}`;case"signal.info":return`${l("Signal Info")} ${e.symbol} (${e.pnlPercentage>0?"+":""}${e.pnlPercentage.toFixed(2)}%)`;default:return l("Unknown")}},R=e=>{switch(e.type){case"signal.opened":return l("Signal Opened");case"signal.closed":return l("Signal Closed");case"signal.scheduled":return l("Signal Scheduled");case"signal.cancelled":return l("Signal Cancelled");case"partial_profit.available":return l("Partial Profit Available");case"partial_profit.commit":return l("Partial Profit Commit");case"partial_loss.available":return l("Partial Loss Available");case"partial_loss.commit":return l("Partial Loss Commit");case"breakeven.available":return l("Breakeven Available");case"breakeven.commit":return l("Breakeven Commit");case"activate_scheduled.commit":return l("Activated Scheduled");case"average_buy.commit":return l("Average Buy");case"trailing_stop.commit":return l("Trailing Stop");case"trailing_take.commit":return l("Trailing Take");case"signal_sync.open":return l("Signal Sync Open");case"signal_sync.close":return l("Signal Sync Close");case"cancel_scheduled.commit":return l("Cancel Scheduled");case"close_pending.commit":return l("Close Pending");case"risk.rejection":return l("Risk Rejection");case"error.info":return l("Info Error");case"error.validation":return l("Validation Error");case"error.critical":return l("Critical Error");case"signal.info":return l("Signal Info");default:return l("Unknown")}},N=e=>"symbol"in e,U=e=>"position"in e,W=e=>"priceOpen"in e&&"priceTakeProfit"in e&&"priceStopLoss"in e,M=e=>"pnlPercentage"in e,H=e=>"level"in e,K=e=>"percentToClose"in e,Y=e=>"currentPrice"in e,V=e=>"duration"in e,q=e=>"closeReason"in e,G=e=>"cancelReason"in e,J=e=>"percentShift"in e,X=e=>"signal.opened"===e.type?"note"in e&&!!e.note:"signal.info"===e.type?"note"in e&&!!e.note&&!!e.notificationId:"activate_scheduled.commit"===e.type?"note"in e&&!!e.note&&!!e.activateId:"close_pending.commit"===e.type?"note"in e&&!!e.note&&!!e.closeId:"cancel_scheduled.commit"===e.type&&("note"in e&&!!e.note&&!!e.cancelId),Q=e=>"message"in e,Z=e=>"rejectionNote"in e,ee=e=>"activePositionCount"in e,ae=e=>"effectivePriceOpen"in e,ie=e=>"totalEntries"in e&&e.totalEntries>1,re=e=>"originalPriceOpen"in e&&"priceOpen"in e&&e.originalPriceOpen!==e.priceOpen,ne=e=>"totalPartials"in e&&e.totalPartials>0,te=e=>"cost"in e,oe=e=>"pnlPriceOpen"in e&&"pnlPriceClose"in e&&"pnlCost"in e&&"pnlEntries"in e,se=e=>"peakProfitPriceClose"in e,ce=e=>"maxDrawdownPriceClose"in e,le=e.forwardRef(({item:e,className:u,style:b,sx:v},y)=>{const g=(e=>{switch(e.type){case"signal.opened":case"activate_scheduled.commit":case"signal_sync.open":return"#4CAF50";case"signal.closed":case"signal_sync.close":return"#2196F3";case"signal.scheduled":case"average_buy.commit":case"error.info":case"error.validation":return"#FF9800";case"signal.cancelled":case"cancel_scheduled.commit":default:return"#9E9E9E";case"partial_profit.available":case"partial_profit.commit":return"#8BC34A";case"partial_loss.available":case"partial_loss.commit":return"#FF5722";case"breakeven.available":case"breakeven.commit":return"#00BCD4";case"trailing_stop.commit":case"trailing_take.commit":return"#673AB7";case"close_pending.commit":return"#607D8B";case"risk.rejection":return"#F44336";case"error.critical":return"#D32F2F";case"signal.info":return"#9C27B0"}})(e),h=(e=>"timestamp"in e)(e)?e.timestamp:Date.now();return a("div",{className:u,style:b,ref:y,children:a(i,{variant:"outlined",onClick:()=>(e=>{switch(e.type){case"risk.rejection":w.layoutService.pickRisk(e.id);break;case"signal.opened":w.layoutService.pickSignalOpened(e.id);break;case"signal.closed":w.layoutService.pickSignalClosed(e.id);break;case"signal.scheduled":w.layoutService.pickSignalScheduled(e.id);break;case"signal.cancelled":w.layoutService.pickSignalCancelled(e.id);break;case"partial_profit.available":w.layoutService.pickPartialProfitAvailable(e.id);break;case"partial_profit.commit":w.layoutService.pickPartialProfitCommit(e.id);break;case"partial_loss.available":w.layoutService.pickPartialLossAvailable(e.id);break;case"partial_loss.commit":w.layoutService.pickPartialLossCommit(e.id);break;case"breakeven.available":w.layoutService.pickBreakevenAvailable(e.id);break;case"breakeven.commit":w.layoutService.pickBreakevenCommit(e.id);break;case"trailing_stop.commit":w.layoutService.pickTrailingStop(e.id);break;case"trailing_take.commit":w.layoutService.pickTrailingTake(e.id);break;case"activate_scheduled.commit":w.layoutService.pickActivateScheduled(e.id);break;case"average_buy.commit":w.layoutService.pickAverageBuyCommit(e.id);break;case"signal_sync.open":w.layoutService.pickSignalSyncOpen(e.id);break;case"signal_sync.close":w.layoutService.pickSignalSyncClose(e.id);break;case"cancel_scheduled.commit":w.layoutService.pickCancelScheduled(e.id);break;case"close_pending.commit":w.layoutService.pickClosePending(e.id);break;case"signal.info":w.layoutService.pickSignalNotify(e.id)}})(e),sx:{transition:"box-shadow 0.2s ease",cursor:"pointer",display:"flex",alignItems:"stretch",justifyContent:"stretch","&:hover":{boxShadow:4},...v},children:a(r,{sx:{flex:1,position:"relative",overflow:"clip",height:"100%",width:"100%",borderRadius:"12px"},children:[a(n,{direction:"row",spacing:2,sx:{p:2},children:[a(t,{sx:{width:56,height:56,background:g},children:T(e)}),a(n,{flex:1,spacing:1,children:[a(n,{direction:"row",justifyContent:"space-between",alignItems:"flex-start",children:[a(o,{variant:"h6",sx:{fontWeight:600},children:I(e)}),a(o,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"nowrap",ml:2},children:s(h).format("HH:mm DD/MM/YYYY")})]}),a(n,{mt:-1,direction:"row",flexWrap:"wrap",children:[a(c,{size:"small",label:R(e),sx:{background:g,mt:1,mr:1,color:"white",fontWeight:500}}),N(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:e.symbol,variant:"outlined"}),U(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:e.position.toUpperCase(),variant:"outlined",color:"long"===e.position?"success":"error"}),M(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`PnL: ${e.pnlPercentage>0?"+":""}${e.pnlPercentage.toFixed(2)}%`,color:e.pnlPercentage>=0?"success":"error",variant:"outlined"}),H(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`${l("Level")}: ${e.level}%`,variant:"outlined"}),K(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`${l("Close")}: ${e.percentToClose}%`,variant:"outlined"}),V(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`${l("Duration")}: ${e.duration} ${l("min")}`,variant:"outlined"}),q(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:e.closeReason,variant:"outlined",color:"info"}),G(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:e.cancelReason,variant:"outlined",color:"info"}),J(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`${l("Shift")}: ${e.percentShift>0?"+":""}${e.percentShift}%`,variant:"outlined"}),ee(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`${l("Active")}: ${e.activePositionCount}`,variant:"outlined"}),ie(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`${l("Entries")}: ${e.totalEntries}`,variant:"outlined"}),ne(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`${l("Partials")}: ${e.totalPartials}`,variant:"outlined"}),te(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`${l("Cost")}: ${e.cost.toFixed(2)}$`,variant:"outlined"}),ae(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`${l("Avg entry")}: ${e.effectivePriceOpen}`,variant:"outlined",color:"warning"}),re(e)&&a(c,{size:"small",sx:{mt:1,mr:1},label:`${l("Orig entry")}: ${e.originalPriceOpen}`,variant:"outlined"})]}),W(e)&&a(d,{children:[a(p,{sx:{my:1}}),a(n,{direction:"row",spacing:3,flexWrap:"wrap",children:[Y(e)&&a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Current"),":"," "]}),e.currentPrice]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Take Profit"),":"," "]}),e.priceTakeProfit]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Stop Loss"),":"," "]}),e.priceStopLoss]})]})]}),oe(e)&&a(d,{children:[a(p,{sx:{my:1}}),a(n,{direction:"row",spacing:3,flexWrap:"wrap",children:[a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("PnL Entry"),":"," "]}),e.pnlPriceOpen]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("PnL Exit"),":"," "]}),e.pnlPriceClose]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("PnL"),":"," "]}),a(o,{component:"span",color:e.pnlCost>=0?"success.main":"error.main",children:[e.pnlCost>=0?"+":"",e.pnlCost.toFixed(2),"$"]})]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Invested"),":"," "]}),e.pnlEntries.toFixed(2),"$"]})]})]}),se(e)&&a(d,{children:[a(p,{sx:{my:1}}),a(n,{direction:"row",spacing:3,flexWrap:"wrap",children:[a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Peak Entry"),":"," "]}),e.peakProfitPriceOpen]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Peak Exit"),":"," "]}),e.peakProfitPriceClose]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Peak"),":"," "]}),a(o,{component:"span",color:e.peakProfitCost>=0?"success.main":"error.main",children:[e.peakProfitCost>=0?"+":"",e.peakProfitCost.toFixed(2),"$"]})]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Invested"),":"," "]}),e.peakProfitEntries.toFixed(2),"$"]})]})]}),ce(e)&&a(d,{children:[a(p,{sx:{my:1}}),a(n,{direction:"row",spacing:3,flexWrap:"wrap",children:[a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Drawdown Entry"),":"," "]}),e.maxDrawdownPriceOpen]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Drawdown Exit"),":"," "]}),e.maxDrawdownPriceClose]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Drawdown"),":"," "]}),a(o,{component:"span",color:e.maxDrawdownCost>=0?"success.main":"error.main",children:[e.maxDrawdownCost>=0?"+":"",e.maxDrawdownCost.toFixed(2),"$"]})]}),a(o,{variant:"body2",children:[a(o,{component:"span",color:"text.secondary",children:[l("Invested"),":"," "]}),e.maxDrawdownEntries.toFixed(2),"$"]})]})]})]})]}),X(e)&&a(r,{onClick:e=>{e.preventDefault(),e.stopPropagation()},sx:{px:2,pb:2},children:[a(p,{sx:{mb:1.5}}),a(r,{component:"pre",sx:{m:0,whiteSpace:"pre-wrap",wordWrap:"break-word"},children:a(m,{content:e.note})})]}),Z(e)&&a(r,{sx:{px:2,pb:2},children:[a(p,{sx:{mb:1.5}}),a(o,{variant:"body2",color:"error",children:e.rejectionNote})]}),Q(e)&&!X(e)&&a(r,{sx:{px:2,pb:2},children:[a(p,{sx:{mb:1.5}}),a(o,{variant:"body2",color:"text.secondary",children:e.message})]}),a(r,{sx:{position:"absolute",top:0,left:0,bottom:0,width:6,zIndex:1,background:g}})]})})})}),de=[{action:"update-now",label:"Refresh manually",icon:()=>a(D,{icon:j,color:"#4caf50"})}],pe=[{type:A.Link,action:"back-action",label:a(B,{sx:{display:"block"}})},{type:A.Link,action:"back-action",label:"Main"},{type:A.Link,action:"back-action",label:"Notifications"}],me=new _,ue=()=>{const{data:e,hasMore:i,loading:r,onSkip:n}=C({handler:async(e,a)=>{const i=await w.notificationViewService.getList(),r=E(e,a);for(const n of i)if(r([n]).done)break;return r().rows},onLoadStart:()=>w.layoutService.setAppbarLoader(!0),onLoadEnd:()=>w.layoutService.setAppbarLoader(!1),reloadSubject:me});return a(O,{children:[a(L,{items:pe,actions:de,onAction:async e=>{"back-action"===e&&w.routerService.push("/"),"update-now"===e&&await me.next()}}),a(F,{sx:{height:"calc(100vh - 155px)"},withScrollbar:!0,minHeight:72,loading:r,onDataRequest:n,bufferSize:z,hasMore:i,children:e.map(e=>a(le,{item:e,sx:{mb:1}},e.id))})]})};export{ue as NotificationPage,ue as default};
@@ -1 +1 @@
1
- import{h as e,f as t,c as n,r,i,S as o,m as a,U as l}from"./index-DycIUKAc.js";const[c,s]=e("pine-code-context"),u=e=>t(c,{initialState:'//@version=5\nindicator("Simple MA", overlay=true)\n\nlength = input.int(20, "Length")\nsma = ta.sma(close, length)\n\nplot(sma, "SMA", color.blue, linewidth=2)',children:e.children}),[d,h]=e("pine-from-date-context"),v=e=>t(d,{initialState:"",children:e.children}),[m,p]=e("pine-limit-context"),g=e=>t(m,{initialState:250,children:e.children}),[f,y]=e("pine-symbol-context"),b=e=>t(f,{initialState:"BTCUSDT",children:e.children}),[C,D]=e("pine-timeframe-context"),x=e=>t(C,{initialState:"1",children:e.children}),[S,w]=e("pine-to-date-context"),T=e=>t(S,{initialState:"",children:e.children}),k=n(e=>t("div",{style:e.v0,children:[t("input",{type:"text",value:e.v1,onChange:e.v2,style:e.v3,placeholder:"BTCUSDT"}),t("select",{value:e.v4,onChange:e.v5,style:e.v6,children:e.v7}),t("input",{type:"number",value:e.v8,min:100,step:100,onChange:e.v9,style:e.v10,title:"Bars limit"}),t("input",{type:"date",value:e.v11,onChange:e.v12,style:e.v13,title:"From date"}),t("input",{type:"date",value:e.v14,onChange:e.v15,style:e.v16,title:"To date"}),t("button",{onClick:e.v17,disabled:e.v18,style:e.v19,children:e.v20}),e.v21]}),{name:"Toolbar_1",portals:["v7","v20","v21"]}),R=function({symbol:e,timeframe:n,fromDate:r,toDate:i,limit:o,running:a,status:l,onSymbolChange:c,onTimeframeChange:s,onFromDateChange:u,onToDateChange:d,onLimitChange:h,onRun:v}){return t(k,{v0:{display:"flex",gap:8,padding:"8px 12px",background:"#1e293b",alignItems:"center",flexShrink:0},v1:e,v2:e=>c(e.target.value.toUpperCase()),v3:{...B,width:100},v4:n,v5:e=>s(e.target.value),v6:B,v7:z.map(e=>t("option",{children:e},e)),v8:o,v9:e=>h(Number(e.target.value)),v10:{...B,width:80},v11:r,v12:e=>u(e.target.value),v13:F,v14:i,v15:e=>d(e.target.value),v16:F,v17:v,v18:a,v19:{background:"#3b82f6",color:"#fff",border:"none",borderRadius:4,padding:"5px 16px",fontSize:13,cursor:"pointer"},v20:a?"...":"▶ Run",v21:l&&t("span",{style:{fontSize:12,color:"#94a3b8",marginLeft:8},children:l})})},z=["1","5","15","60","D"],B={background:"#1e293b",color:"#e2e8f0",border:"1px solid #334155",borderRadius:4,padding:"4px 8px",fontSize:13},F={...B,colorScheme:"dark"},U=n(e=>t("textarea",{value:e.v0,onChange:e.v1,onKeyDown:e.v2,spellCheck:!1,style:e.v3}),{name:"CodeEditor_1"}),E=function({value:e,onChange:n,onRun:r}){return t(U,{v0:e,v1:e=>n(e.target.value),v2:e=>{e.ctrlKey&&"Enter"===e.key&&(e.preventDefault(),r())},v3:{width:320,flexShrink:0,resize:"none",background:"#1e293b",color:"#e2e8f0",border:"none",borderRight:"1px solid #334155",padding:12,fontFamily:"monospace",fontSize:13,lineHeight:1.5,outline:"none"}})},$={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h",360:"6h",480:"8h","1D":"1d",D:"1d"};function L(e){return{time:e.openTime,open:e.open,high:e.high,low:e.low,close:e.close,volume:e.volume}}class I{async getMarketData(e,t,n,r,o){const a=e.toUpperCase().replace(/^BINANCE:|^BYBIT:|^OKX:/,""),l=$[t]??t;return(await i.exchangeViewService.getRangeCandles({symbol:a,interval:l,limit:n,sDate:r,eDate:o})).map(e=>({openTime:e.timestamp,open:e.open,high:e.high,low:e.low,close:e.close,volume:e.volume}))}async getSymbolInfo(e){const t=e.toUpperCase().replace(/^BINANCE:|^BYBIT:|^OKX:/,""),n=t.replace(/USDT$|BUSD$|USD$/,""),r=t.replace(n,"");return{ticker:t,tickerid:t,description:`${n}/${r}`,type:"crypto",basecurrency:n,currency:r||"USDT",timezone:"UTC"}}}const M=()=>t(o,{children:"\n #root > .MuiBox-root {\n padding-left: 0;\n padding-right: 0;\n }\n "}),P=()=>{const e=r.useRef(null),[n,i]=s(),[o,l]=y(),[c,u]=D(),[d,v]=h(),[m,g]=w(),[f,b]=p(),{run:C,status:x,running:S}=function(){const e=r.useRef(null),t=r.useRef(null),n=r.useRef(null),[i,o]=r.useState(""),[a,l]=r.useState(!1);function c(){if(n.current){try{n.current.stop()}catch{}n.current=null}}function s(){e.current&&(e.current.destroy(),e.current=null,t.current=null)}function u(e){o(`Error: ${e.message}`),l(!1)}return r.useEffect(()=>{const t=()=>{var t;return null==(t=e.current)?void 0:t.resize()};return window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t),c(),s()}},[]),{run:function({symbol:r,timeframe:i,fromDate:a,toDate:d,limit:h,code:v,containerRef:m}){if(!m.current)return;l(!0),o("Connecting..."),c(),s();const p=/indicator\([^)]*overlay\s*=\s*true/i.test(v);let g=!1;try{const c=a?new Date(a).getTime():void 0,s=d?new Date(d).getTime():void 0,f=new I,y=new PineTS(f,r,i,h,c,s).stream(v,{pageSize:500,live:!0,interval:3e3});n.current=y,y.on("data",a=>{var c,s;if(n.current===y)if(g)t.current&&a.plots&&t.current.updateData(a.plots),null==(s=e.current)||s.updateData([L(a.marketData[a.marketData.length-1])]);else{g=!0;const n=a.marketData.map(L);m.current.innerHTML="",e.current=new QFChart.QFChart(m.current,{title:`${r} · ${i}`,backgroundColor:"#0f172a",height:"100%",padding:.1,databox:{position:"right",triggerOn:"mousemove"},dataZoom:{visible:!0,position:"top",height:6,start:80,end:101},layout:{mainPaneHeight:"70%",gap:5},controls:{collapse:!1,maximize:!1,fullscreen:!1}}),e.current.setMarketData(n);const s=(null==(c=a.fullContext)?void 0:c.plots)??a.plots;t.current=e.current.addIndicator("indicator",s,{overlay:p,height:p?void 0:30,controls:{collapse:!1,maximize:!1}}),e.current.registerPlugin(new QFChart.MeasureTool),e.current.registerPlugin(new QFChart.LineTool),e.current.registerPlugin(new QFChart.FibonacciTool),o(`${n.length} bars loaded`),l(!1)}}),y.on("error",u)}catch(f){u(f)}},status:i,running:a}}();function T(){C({symbol:o,timeframe:c,fromDate:d,toDate:m,limit:f,code:n,containerRef:e})}return t(a,{children:t("div",{style:{display:"flex",flexDirection:"column",height:"100vh",background:"#0f172a",color:"#e2e8f0",fontFamily:"monospace"},children:[t(R,{symbol:o,timeframe:c,fromDate:d,toDate:m,limit:f,running:S,status:x,onSymbolChange:l,onTimeframeChange:u,onFromDateChange:v,onToDateChange:g,onLimitChange:b,onRun:T}),t("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[t(E,{value:n,onChange:i,onRun:T}),t("div",{style:{flex:1},children:t("div",{ref:e,style:{width:"100%",height:"100%"},children:t("p",{style:{color:"#475569",textAlign:"center",marginTop:"20%"},children:["Press ",t("b",{children:"▶ Run"})," or ",t("b",{children:"Ctrl+Enter"})," to load the chart"]})})})]}),t(M,{})]})})},A=l(e=>t(u,{children:e}),e=>t(v,{children:e}),e=>t(T,{children:e}),e=>t(g,{children:e}),e=>t(b,{children:e}),e=>t(x,{children:e})),N=()=>A(t(P,{}));export{N as PinePage,N as default};
1
+ import{h as e,f as t,c as n,r,i,S as o,m as a,U as l}from"./index-DzrwP4k5.js";const[c,s]=e("pine-code-context"),u=e=>t(c,{initialState:'//@version=5\nindicator("Simple MA", overlay=true)\n\nlength = input.int(20, "Length")\nsma = ta.sma(close, length)\n\nplot(sma, "SMA", color.blue, linewidth=2)',children:e.children}),[d,h]=e("pine-from-date-context"),v=e=>t(d,{initialState:"",children:e.children}),[m,p]=e("pine-limit-context"),g=e=>t(m,{initialState:250,children:e.children}),[f,y]=e("pine-symbol-context"),b=e=>t(f,{initialState:"BTCUSDT",children:e.children}),[C,D]=e("pine-timeframe-context"),x=e=>t(C,{initialState:"1",children:e.children}),[S,w]=e("pine-to-date-context"),T=e=>t(S,{initialState:"",children:e.children}),k=n(e=>t("div",{style:e.v0,children:[t("input",{type:"text",value:e.v1,onChange:e.v2,style:e.v3,placeholder:"BTCUSDT"}),t("select",{value:e.v4,onChange:e.v5,style:e.v6,children:e.v7}),t("input",{type:"number",value:e.v8,min:100,step:100,onChange:e.v9,style:e.v10,title:"Bars limit"}),t("input",{type:"date",value:e.v11,onChange:e.v12,style:e.v13,title:"From date"}),t("input",{type:"date",value:e.v14,onChange:e.v15,style:e.v16,title:"To date"}),t("button",{onClick:e.v17,disabled:e.v18,style:e.v19,children:e.v20}),e.v21]}),{name:"Toolbar_1",portals:["v7","v20","v21"]}),R=function({symbol:e,timeframe:n,fromDate:r,toDate:i,limit:o,running:a,status:l,onSymbolChange:c,onTimeframeChange:s,onFromDateChange:u,onToDateChange:d,onLimitChange:h,onRun:v}){return t(k,{v0:{display:"flex",gap:8,padding:"8px 12px",background:"#1e293b",alignItems:"center",flexShrink:0},v1:e,v2:e=>c(e.target.value.toUpperCase()),v3:{...B,width:100},v4:n,v5:e=>s(e.target.value),v6:B,v7:z.map(e=>t("option",{children:e},e)),v8:o,v9:e=>h(Number(e.target.value)),v10:{...B,width:80},v11:r,v12:e=>u(e.target.value),v13:F,v14:i,v15:e=>d(e.target.value),v16:F,v17:v,v18:a,v19:{background:"#3b82f6",color:"#fff",border:"none",borderRadius:4,padding:"5px 16px",fontSize:13,cursor:"pointer"},v20:a?"...":"▶ Run",v21:l&&t("span",{style:{fontSize:12,color:"#94a3b8",marginLeft:8},children:l})})},z=["1","5","15","60","D"],B={background:"#1e293b",color:"#e2e8f0",border:"1px solid #334155",borderRadius:4,padding:"4px 8px",fontSize:13},F={...B,colorScheme:"dark"},U=n(e=>t("textarea",{value:e.v0,onChange:e.v1,onKeyDown:e.v2,spellCheck:!1,style:e.v3}),{name:"CodeEditor_1"}),E=function({value:e,onChange:n,onRun:r}){return t(U,{v0:e,v1:e=>n(e.target.value),v2:e=>{e.ctrlKey&&"Enter"===e.key&&(e.preventDefault(),r())},v3:{width:320,flexShrink:0,resize:"none",background:"#1e293b",color:"#e2e8f0",border:"none",borderRight:"1px solid #334155",padding:12,fontFamily:"monospace",fontSize:13,lineHeight:1.5,outline:"none"}})},$={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h",360:"6h",480:"8h","1D":"1d",D:"1d"};function L(e){return{time:e.openTime,open:e.open,high:e.high,low:e.low,close:e.close,volume:e.volume}}class I{async getMarketData(e,t,n,r,o){const a=e.toUpperCase().replace(/^BINANCE:|^BYBIT:|^OKX:/,""),l=$[t]??t;return(await i.exchangeViewService.getRangeCandles({symbol:a,interval:l,limit:n,sDate:r,eDate:o})).map(e=>({openTime:e.timestamp,open:e.open,high:e.high,low:e.low,close:e.close,volume:e.volume}))}async getSymbolInfo(e){const t=e.toUpperCase().replace(/^BINANCE:|^BYBIT:|^OKX:/,""),n=t.replace(/USDT$|BUSD$|USD$/,""),r=t.replace(n,"");return{ticker:t,tickerid:t,description:`${n}/${r}`,type:"crypto",basecurrency:n,currency:r||"USDT",timezone:"UTC"}}}const M=()=>t(o,{children:"\n #root > .MuiBox-root {\n padding-left: 0;\n padding-right: 0;\n }\n "}),P=()=>{const e=r.useRef(null),[n,i]=s(),[o,l]=y(),[c,u]=D(),[d,v]=h(),[m,g]=w(),[f,b]=p(),{run:C,status:x,running:S}=function(){const e=r.useRef(null),t=r.useRef(null),n=r.useRef(null),[i,o]=r.useState(""),[a,l]=r.useState(!1);function c(){if(n.current){try{n.current.stop()}catch{}n.current=null}}function s(){e.current&&(e.current.destroy(),e.current=null,t.current=null)}function u(e){o(`Error: ${e.message}`),l(!1)}return r.useEffect(()=>{const t=()=>{var t;return null==(t=e.current)?void 0:t.resize()};return window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t),c(),s()}},[]),{run:function({symbol:r,timeframe:i,fromDate:a,toDate:d,limit:h,code:v,containerRef:m}){if(!m.current)return;l(!0),o("Connecting..."),c(),s();const p=/indicator\([^)]*overlay\s*=\s*true/i.test(v);let g=!1;try{const c=a?new Date(a).getTime():void 0,s=d?new Date(d).getTime():void 0,f=new I,y=new PineTS(f,r,i,h,c,s).stream(v,{pageSize:500,live:!0,interval:3e3});n.current=y,y.on("data",a=>{var c,s;if(n.current===y)if(g)t.current&&a.plots&&t.current.updateData(a.plots),null==(s=e.current)||s.updateData([L(a.marketData[a.marketData.length-1])]);else{g=!0;const n=a.marketData.map(L);m.current.innerHTML="",e.current=new QFChart.QFChart(m.current,{title:`${r} · ${i}`,backgroundColor:"#0f172a",height:"100%",padding:.1,databox:{position:"right",triggerOn:"mousemove"},dataZoom:{visible:!0,position:"top",height:6,start:80,end:101},layout:{mainPaneHeight:"70%",gap:5},controls:{collapse:!1,maximize:!1,fullscreen:!1}}),e.current.setMarketData(n);const s=(null==(c=a.fullContext)?void 0:c.plots)??a.plots;t.current=e.current.addIndicator("indicator",s,{overlay:p,height:p?void 0:30,controls:{collapse:!1,maximize:!1}}),e.current.registerPlugin(new QFChart.MeasureTool),e.current.registerPlugin(new QFChart.LineTool),e.current.registerPlugin(new QFChart.FibonacciTool),o(`${n.length} bars loaded`),l(!1)}}),y.on("error",u)}catch(f){u(f)}},status:i,running:a}}();function T(){C({symbol:o,timeframe:c,fromDate:d,toDate:m,limit:f,code:n,containerRef:e})}return t(a,{children:t("div",{style:{display:"flex",flexDirection:"column",height:"100vh",background:"#0f172a",color:"#e2e8f0",fontFamily:"monospace"},children:[t(R,{symbol:o,timeframe:c,fromDate:d,toDate:m,limit:f,running:S,status:x,onSymbolChange:l,onTimeframeChange:u,onFromDateChange:v,onToDateChange:g,onLimitChange:b,onRun:T}),t("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[t(E,{value:n,onChange:i,onRun:T}),t("div",{style:{flex:1},children:t("div",{ref:e,style:{width:"100%",height:"100%"},children:t("p",{style:{color:"#475569",textAlign:"center",marginTop:"20%"},children:["Press ",t("b",{children:"▶ Run"})," or ",t("b",{children:"Ctrl+Enter"})," to load the chart"]})})})]}),t(M,{})]})})},A=l(e=>t(u,{children:e}),e=>t(v,{children:e}),e=>t(T,{children:e}),e=>t(g,{children:e}),e=>t(b,{children:e}),e=>t(x,{children:e})),N=()=>A(t(P,{}));export{N as PinePage,N as default};