@kodiak-finance/orderly-ui-tradingview 2.7.4

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.
@@ -0,0 +1,137 @@
1
+ import * as React$1 from 'react';
2
+ import React__default from 'react';
3
+ import { LocaleCode } from '@kodiak-finance/orderly-i18n';
4
+
5
+ /**
6
+ * Color styling options for the loading screen (spinner)
7
+ */
8
+ interface LoadingScreenOptions {
9
+ /** Colour of the spinner on the loading screen */
10
+ foregroundColor?: string;
11
+ /** Background color for the loading screen */
12
+ backgroundColor?: string;
13
+ }
14
+ type LanguageCode =
15
+ | 'ar'
16
+ | 'zh'
17
+ | 'ca_ES'
18
+ | 'en'
19
+ | 'fr'
20
+ | 'de'
21
+ | 'he_IL'
22
+ | 'id_ID'
23
+ | 'it'
24
+ | 'ja'
25
+ | 'ko'
26
+ | 'pl'
27
+ | 'pt'
28
+ | 'ru'
29
+ | 'es'
30
+ | 'sv'
31
+ | 'th'
32
+ | 'tr'
33
+ | 'vi'
34
+ | 'ms_MY'
35
+ | 'zh_TW';
36
+
37
+ declare enum ChartMode {
38
+ BASIC = 0,
39
+ ADVANCED = 1,
40
+ UNLIMITED = 2,
41
+ MOBILE = 3
42
+ }
43
+ interface ColorConfigInterface {
44
+ chartBG?: string;
45
+ upColor?: string;
46
+ downColor?: string;
47
+ pnlUpColor?: string;
48
+ pnlDownColor?: string;
49
+ pnlZoreColor?: string;
50
+ textColor?: string;
51
+ qtyTextColor?: string;
52
+ font?: string;
53
+ closeIcon?: string;
54
+ volumeUpColor?: string;
55
+ volumeDownColor?: string;
56
+ }
57
+
58
+ type TradingviewLocaleCode = LanguageCode;
59
+ interface TradingviewWidgetPropsInterface {
60
+ symbol?: string;
61
+ mode?: ChartMode;
62
+ scriptSRC?: string;
63
+ library_path?: string;
64
+ overrides?: Record<string, string>;
65
+ studiesOverrides?: Record<string, string>;
66
+ customCssUrl?: string;
67
+ colorConfig?: ColorConfigInterface;
68
+ libraryPath?: string;
69
+ fullscreen?: boolean;
70
+ theme?: string;
71
+ loadingScreen?: LoadingScreenOptions;
72
+ /**
73
+ * The locale of the tradingview.
74
+ * If locale does not match in TradingviewLocaleCode, it will default to "en".
75
+ * If locale is a function, you can use the current locale to return the TradingviewLocaleCode.
76
+ */
77
+ locale?: TradingviewLocaleCode | ((localeCode: LocaleCode) => TradingviewLocaleCode);
78
+ onFullScreenChange?: (isFullScreen: boolean) => void;
79
+ classNames?: {
80
+ root?: string;
81
+ content?: string;
82
+ };
83
+ }
84
+ interface TradingviewUIPropsInterface {
85
+ tradingViewScriptSrc?: string;
86
+ chartRef: React.Ref<HTMLDivElement>;
87
+ interval?: string;
88
+ changeDisplaySetting: (setting: DisplayControlSettingInterface) => void;
89
+ displayControlState: DisplayControlSettingInterface;
90
+ changeInterval: (newInterval: string) => void;
91
+ lineType: string;
92
+ changeLineType: (newLineType: string) => void;
93
+ openChartSetting: () => void;
94
+ openChartIndicators: () => void;
95
+ symbol?: string;
96
+ onFullScreenChange: () => void;
97
+ classNames?: {
98
+ root?: string;
99
+ content?: string;
100
+ };
101
+ fullscreen?: boolean;
102
+ }
103
+ interface DisplayControlSettingInterface {
104
+ position: boolean;
105
+ buySell: boolean;
106
+ limitOrders: boolean;
107
+ stopOrders: boolean;
108
+ tpsl: boolean;
109
+ positionTpsl: boolean;
110
+ trailingStop: boolean;
111
+ }
112
+
113
+ declare const TradingviewWidget: React$1.ForwardRefExoticComponent<TradingviewWidgetPropsInterface & React$1.RefAttributes<HTMLDivElement>>;
114
+
115
+ declare const TradingviewUI: React__default.ForwardRefExoticComponent<TradingviewUIPropsInterface & React__default.RefAttributes<HTMLDivElement>>;
116
+
117
+ declare function useTradingviewScript(props: TradingviewWidgetPropsInterface): {
118
+ tradingViewScriptSrc: string | undefined;
119
+ chartRef: React$1.RefObject<HTMLDivElement>;
120
+ changeDisplaySetting: (newSetting: DisplayControlSettingInterface) => void;
121
+ displayControlState: DisplayControlSettingInterface;
122
+ interval: string;
123
+ changeInterval: (newInterval: string) => void;
124
+ lineType: string;
125
+ changeLineType: (newLineType: string) => void;
126
+ openChartSetting: () => void;
127
+ openChartIndicators: () => void;
128
+ symbol: string | undefined;
129
+ onFullScreenChange: () => void;
130
+ classNames: {
131
+ root?: string;
132
+ content?: string;
133
+ } | undefined;
134
+ fullscreen: any;
135
+ };
136
+
137
+ export { type DisplayControlSettingInterface, type TradingviewLocaleCode, TradingviewUI, type TradingviewUIPropsInterface, TradingviewWidget, type TradingviewWidgetPropsInterface, useTradingviewScript };
@@ -0,0 +1,137 @@
1
+ import * as React$1 from 'react';
2
+ import React__default from 'react';
3
+ import { LocaleCode } from '@kodiak-finance/orderly-i18n';
4
+
5
+ /**
6
+ * Color styling options for the loading screen (spinner)
7
+ */
8
+ interface LoadingScreenOptions {
9
+ /** Colour of the spinner on the loading screen */
10
+ foregroundColor?: string;
11
+ /** Background color for the loading screen */
12
+ backgroundColor?: string;
13
+ }
14
+ type LanguageCode =
15
+ | 'ar'
16
+ | 'zh'
17
+ | 'ca_ES'
18
+ | 'en'
19
+ | 'fr'
20
+ | 'de'
21
+ | 'he_IL'
22
+ | 'id_ID'
23
+ | 'it'
24
+ | 'ja'
25
+ | 'ko'
26
+ | 'pl'
27
+ | 'pt'
28
+ | 'ru'
29
+ | 'es'
30
+ | 'sv'
31
+ | 'th'
32
+ | 'tr'
33
+ | 'vi'
34
+ | 'ms_MY'
35
+ | 'zh_TW';
36
+
37
+ declare enum ChartMode {
38
+ BASIC = 0,
39
+ ADVANCED = 1,
40
+ UNLIMITED = 2,
41
+ MOBILE = 3
42
+ }
43
+ interface ColorConfigInterface {
44
+ chartBG?: string;
45
+ upColor?: string;
46
+ downColor?: string;
47
+ pnlUpColor?: string;
48
+ pnlDownColor?: string;
49
+ pnlZoreColor?: string;
50
+ textColor?: string;
51
+ qtyTextColor?: string;
52
+ font?: string;
53
+ closeIcon?: string;
54
+ volumeUpColor?: string;
55
+ volumeDownColor?: string;
56
+ }
57
+
58
+ type TradingviewLocaleCode = LanguageCode;
59
+ interface TradingviewWidgetPropsInterface {
60
+ symbol?: string;
61
+ mode?: ChartMode;
62
+ scriptSRC?: string;
63
+ library_path?: string;
64
+ overrides?: Record<string, string>;
65
+ studiesOverrides?: Record<string, string>;
66
+ customCssUrl?: string;
67
+ colorConfig?: ColorConfigInterface;
68
+ libraryPath?: string;
69
+ fullscreen?: boolean;
70
+ theme?: string;
71
+ loadingScreen?: LoadingScreenOptions;
72
+ /**
73
+ * The locale of the tradingview.
74
+ * If locale does not match in TradingviewLocaleCode, it will default to "en".
75
+ * If locale is a function, you can use the current locale to return the TradingviewLocaleCode.
76
+ */
77
+ locale?: TradingviewLocaleCode | ((localeCode: LocaleCode) => TradingviewLocaleCode);
78
+ onFullScreenChange?: (isFullScreen: boolean) => void;
79
+ classNames?: {
80
+ root?: string;
81
+ content?: string;
82
+ };
83
+ }
84
+ interface TradingviewUIPropsInterface {
85
+ tradingViewScriptSrc?: string;
86
+ chartRef: React.Ref<HTMLDivElement>;
87
+ interval?: string;
88
+ changeDisplaySetting: (setting: DisplayControlSettingInterface) => void;
89
+ displayControlState: DisplayControlSettingInterface;
90
+ changeInterval: (newInterval: string) => void;
91
+ lineType: string;
92
+ changeLineType: (newLineType: string) => void;
93
+ openChartSetting: () => void;
94
+ openChartIndicators: () => void;
95
+ symbol?: string;
96
+ onFullScreenChange: () => void;
97
+ classNames?: {
98
+ root?: string;
99
+ content?: string;
100
+ };
101
+ fullscreen?: boolean;
102
+ }
103
+ interface DisplayControlSettingInterface {
104
+ position: boolean;
105
+ buySell: boolean;
106
+ limitOrders: boolean;
107
+ stopOrders: boolean;
108
+ tpsl: boolean;
109
+ positionTpsl: boolean;
110
+ trailingStop: boolean;
111
+ }
112
+
113
+ declare const TradingviewWidget: React$1.ForwardRefExoticComponent<TradingviewWidgetPropsInterface & React$1.RefAttributes<HTMLDivElement>>;
114
+
115
+ declare const TradingviewUI: React__default.ForwardRefExoticComponent<TradingviewUIPropsInterface & React__default.RefAttributes<HTMLDivElement>>;
116
+
117
+ declare function useTradingviewScript(props: TradingviewWidgetPropsInterface): {
118
+ tradingViewScriptSrc: string | undefined;
119
+ chartRef: React$1.RefObject<HTMLDivElement>;
120
+ changeDisplaySetting: (newSetting: DisplayControlSettingInterface) => void;
121
+ displayControlState: DisplayControlSettingInterface;
122
+ interval: string;
123
+ changeInterval: (newInterval: string) => void;
124
+ lineType: string;
125
+ changeLineType: (newLineType: string) => void;
126
+ openChartSetting: () => void;
127
+ openChartIndicators: () => void;
128
+ symbol: string | undefined;
129
+ onFullScreenChange: () => void;
130
+ classNames: {
131
+ root?: string;
132
+ content?: string;
133
+ } | undefined;
134
+ fullscreen: any;
135
+ };
136
+
137
+ export { type DisplayControlSettingInterface, type TradingviewLocaleCode, TradingviewUI, type TradingviewUIPropsInterface, TradingviewWidget, type TradingviewWidgetPropsInterface, useTradingviewScript };
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var R = require('react');
5
+ var orderlyI18n = require('@kodiak-finance/orderly-i18n');
6
+ var orderlyUi = require('@kodiak-finance/orderly-ui');
7
+ var orderlyHooks = require('@kodiak-finance/orderly-hooks');
8
+ var orderlyTypes = require('@kodiak-finance/orderly-types');
9
+ var orderlyUtils = require('@kodiak-finance/orderly-utils');
10
+ var dateFns = require('date-fns');
11
+
12
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
+
14
+ var R__default = /*#__PURE__*/_interopDefault(R);
15
+
16
+ var Jr=Object.defineProperty;var K=(r,e)=>()=>(r&&(e=r(r=0)),e);var Ve=(r,e)=>{for(var t in e)Jr(r,t,{get:e[t],enumerable:true});};var $,ke,at,ar,lr,cr,ur,dr,pr,mr,gr,hr,Z=K(()=>{$=r=>jsxRuntime.jsx("svg",{viewBox:"0 0 12 12",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...r,children:jsxRuntime.jsx("g",{id:"Caret-down",children:jsxRuntime.jsx("path",{id:"Vector",d:"M3.00349 3.9978C2.59149 3.9978 2.36564 4.4653 2.61289 4.7948C2.98789 5.2948 5.23784 8.29479 5.61289 8.79479C5.81289 9.06128 6.20974 9.06128 6.40974 8.79479L9.40974 4.7948C9.65694 4.4653 9.41554 3.9978 9.00349 3.9978H3.00349Z"})})}),ke=r=>jsxRuntime.jsx("svg",{viewBox:"0 0 18 18",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...r,children:jsxRuntime.jsx("g",{id:"Display settings",children:jsxRuntime.jsx("path",{id:"Union",fillRule:"evenodd",clipRule:"evenodd",d:"M15.0571 10.9856L11.6295 5.06523L8.71377 10.8968C8.38933 11.5456 7.54464 11.7223 6.98733 11.2579L5.75311 10.2294L2.83709 14.7654L1.57532 13.9543L4.49134 9.41824C4.97892 8.65978 6.0207 8.49981 6.71338 9.07705L7.58387 9.80246L10.5991 3.77192C10.9997 2.97082 12.1302 2.93624 12.579 3.71137L14.6517 7.29147C14.7714 7.03643 15.0305 6.85983 15.3309 6.85983C15.7451 6.85983 16.0809 7.19562 16.0809 7.60983C16.0809 8.02405 15.7451 8.35983 15.3309 8.35983C15.31 8.35983 15.2892 8.35897 15.2687 8.35729L16.3553 10.2341L15.0571 10.9856ZM2.58093 6.85983C2.16672 6.85983 1.83093 7.19562 1.83093 7.60983C1.83093 8.02405 2.16672 8.35983 2.58093 8.35983C2.99515 8.35983 3.33093 8.02405 3.33093 7.60983C3.33093 7.19562 2.99515 6.85983 2.58093 6.85983ZM4.83093 6.85983C4.41672 6.85983 4.08093 7.19562 4.08093 7.60983C4.08093 8.02405 4.41672 8.35983 4.83093 8.35983C5.24515 8.35983 5.58093 8.02405 5.58093 7.60983C5.58093 7.19562 5.24515 6.85983 4.83093 6.85983ZM6.33093 7.60983C6.33093 7.19562 6.66672 6.85983 7.08093 6.85983C7.49515 6.85983 7.83093 7.19562 7.83093 7.60983C7.83093 8.02405 7.49515 8.35983 7.08093 8.35983C6.66672 8.35983 6.33093 8.02405 6.33093 7.60983ZM11.5809 6.85983C11.1667 6.85983 10.8309 7.19562 10.8309 7.60983C10.8309 8.02405 11.1667 8.35983 11.5809 8.35983C11.9951 8.35983 12.3309 8.02405 12.3309 7.60983C12.3309 7.19562 11.9951 6.85983 11.5809 6.85983Z"})})}),at=r=>jsxRuntime.jsx("svg",{viewBox:"0 0 18 18",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...r,children:jsxRuntime.jsx("g",{id:"Indicators",children:jsxRuntime.jsx("path",{id:"Union",fillRule:"evenodd",clipRule:"evenodd",d:"M9.74483 2.25C8.96145 2.25 8.26885 2.76459 8.04549 3.51818L7.46202 5.48254H5.06262V7.08339H6.98652L5.00539 13.7532L4.31554 13.1112L3.22498 14.2831L4.4777 15.4489C5.08739 16.015 6.08317 15.7469 6.32134 14.945L8.65649 7.08339H11.6032V5.48254H9.13198L9.58033 3.97311C9.60167 3.90112 9.66833 3.85084 9.74483 3.85084H11.69V2.25H9.74483ZM10.6234 11.2354L10.2638 11.5172C10.0153 11.712 9.65591 11.6684 9.46115 11.4199C9.26639 11.1713 9.30998 10.812 9.55852 10.6172L10.1451 10.1575C10.5693 9.82514 11.1868 9.94011 11.4642 10.4005L11.4682 10.407L12.1304 11.5752L13.4594 10.3111C13.6882 10.0935 14.05 10.1025 14.2677 10.3313C14.4853 10.5601 14.4763 10.922 14.2475 11.1396L12.7116 12.6006L13.3897 13.797L13.6482 13.4503C13.8369 13.1972 14.1951 13.145 14.4483 13.3337C14.7014 13.5225 14.7536 13.8807 14.5649 14.1338L13.9917 14.9025L13.94 14.9457C13.5178 15.2981 12.8837 15.1886 12.6003 14.7226L12.5958 14.7151L11.8576 13.4129L10.3563 14.841C10.1275 15.0586 9.76561 15.0495 9.54798 14.8208C9.33036 14.592 9.3394 14.2301 9.56819 14.0125L11.2764 12.3875L10.6234 11.2354Z"})})}),ar=r=>jsxRuntime.jsx("svg",{viewBox:"0 0 18 18",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...r,children:jsxRuntime.jsx("g",{id:"Setting",children:jsxRuntime.jsx("path",{id:"Vector",d:"M6.72589 1.84154C5.66239 2.17904 4.74515 2.72954 3.93665 3.48254C3.6869 3.71504 3.6104 4.09604 3.7724 4.39604C4.37315 5.50679 3.74464 6.69554 2.38939 6.76379C2.05789 6.78029 1.76465 7.0263 1.68665 7.34955C1.5524 7.9083 1.49915 8.37629 1.49915 8.98979C1.49915 9.50504 1.55464 10.0885 1.66339 10.6075C1.73089 10.9315 2.0129 11.1648 2.3429 11.1933C3.7064 11.311 4.3814 12.3513 3.7724 13.6773C3.6374 13.972 3.6989 14.3245 3.93665 14.545C4.73315 15.2815 5.64814 15.8013 6.72589 16.1388C7.03339 16.2348 7.38064 16.1185 7.56964 15.8575C8.40364 14.7033 9.6134 14.6995 10.4054 15.8575C10.5921 16.1298 10.9341 16.261 11.2491 16.162C12.2894 15.8343 13.2584 15.277 14.0616 14.545C14.3091 14.3193 14.3744 13.954 14.2259 13.654C13.6019 12.3948 14.3197 11.239 15.6082 11.2165C15.9502 11.2105 16.2547 10.9863 16.3349 10.654C16.4647 10.1163 16.4991 9.64829 16.4991 8.98979C16.4991 8.42429 16.4324 7.86704 16.3116 7.32629C16.2351 6.98354 15.9359 6.74054 15.5849 6.73979C14.3167 6.73754 13.6056 5.49104 14.2259 4.39604C14.3984 4.09154 14.3444 3.71804 14.0849 3.48254C13.2674 2.74004 12.2706 2.15954 11.2259 1.84154C10.9049 1.74404 10.5636 1.86404 10.3821 2.14604C9.65764 3.27179 8.30465 3.29129 7.5929 2.17004C7.41065 1.88204 7.04989 1.73879 6.72589 1.84154ZM11.2844 3.43455C11.7966 3.64905 12.2009 3.8733 12.6651 4.22505C12.1206 5.9478 13.0439 7.73729 14.9564 8.17304C15.0036 8.48279 14.9991 8.67029 14.9991 8.98979C14.9991 9.37154 15.0044 9.50579 14.9609 9.78179C13.0566 10.1763 12.1146 11.9155 12.6449 13.7538C12.1889 14.0845 11.8626 14.314 11.2904 14.5353C9.94639 13.1673 8.0804 13.1073 6.7079 14.5443C6.1724 14.3088 5.76066 14.0995 5.34441 13.7478C5.86041 11.881 4.98815 10.2693 3.05165 9.7803C2.9654 9.4383 2.9999 8.4723 3.0494 8.17905C5.0519 7.69905 5.8409 5.92679 5.34365 4.21979C5.78315 3.88904 6.1784 3.6483 6.69215 3.4398C7.9859 4.75605 9.92839 4.8873 11.2844 3.43455ZM8.99915 5.98979C7.3424 5.98979 5.99915 7.33304 5.99915 8.98979C5.99915 10.6473 7.3424 11.9898 8.99915 11.9898C10.6559 11.9898 11.9991 10.6473 11.9991 8.98979C11.9991 7.33304 10.6559 5.98979 8.99915 5.98979ZM8.99915 7.48979C9.8279 7.48979 10.4991 8.16179 10.4991 8.98979C10.4991 9.81855 9.8279 10.4898 8.99915 10.4898C8.1704 10.4898 7.49915 9.81855 7.49915 8.98979C7.49915 8.16179 8.1704 7.48979 8.99915 7.48979Z"})})}),lr=r=>jsxRuntime.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...r,children:jsxRuntime.jsx("g",{id:"Bars",children:jsxRuntime.jsx("path",{id:"Union",fillRule:"evenodd",clipRule:"evenodd",d:"M12.5 15.5C12.5 15.7761 12.7239 16 13 16H14C14.2761 16 14.5 15.7761 14.5 15.5V14H16C16.2761 14 16.5 13.7761 16.5 13.5V12.5C16.5 12.2239 16.2761 12 16 12H14.5V2.5C14.5 2.22386 14.2761 2 14 2H13C12.7239 2 12.5 2.22386 12.5 2.5V4H11C10.7239 4 10.5 4.22386 10.5 4.5V5.5C10.5 5.77614 10.7239 6 11 6H12.5V15.5ZM5.5 17.5C5.5 17.7761 5.72386 18 6 18H7C7.27614 18 7.5 17.7761 7.5 17.5V10H9C9.27614 10 9.5 9.77614 9.5 9.5V8.5C9.5 8.22386 9.27614 8 9 8H7.5V4.5C7.5 4.22386 7.27614 4 7 4H6C5.72386 4 5.5 4.22386 5.5 4.5V14H4C3.72386 14 3.5 14.2239 3.5 14.5V15.5C3.5 15.7761 3.72386 16 4 16H5.5V17.5Z"})})}),cr=r=>jsxRuntime.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...r,children:jsxRuntime.jsx("g",{id:"Candles",children:jsxRuntime.jsx("path",{id:"Union",fillRule:"evenodd",clipRule:"evenodd",d:"M7.25 2.5V4H8.5C8.77614 4 9 4.22386 9 4.5V15.5C9 15.7761 8.77614 16 8.5 16H7.25V17.5C7.25 17.7761 7.02614 18 6.75 18H6.25C5.97386 18 5.75 17.7761 5.75 17.5V16H4.5C4.22386 16 4 15.7761 4 15.5V4.5C4 4.22386 4.22386 4 4.5 4H5.75V2.5C5.75 2.22386 5.97386 2 6.25 2H6.75C7.02614 2 7.25 2.22386 7.25 2.5ZM5.5 5.5V14.5H7.5V5.5H5.5ZM14.25 4.5V7H15.5C15.7761 7 16 7.22386 16 7.5V15.5C16 15.7761 15.7761 16 15.5 16H14.25V17.5C14.25 17.7761 14.0261 18 13.75 18H13.25C12.9739 18 12.75 17.7761 12.75 17.5V16H11.5C11.2239 16 11 15.7761 11 15.5V7.5C11 7.22386 11.2239 7 11.5 7H12.75V4.5C12.75 4.22386 12.9739 4 13.25 4H13.75C14.0261 4 14.25 4.22386 14.25 4.5ZM12.5 8.5V14.5H14.5V8.5H12.5Z"})})}),ur=r=>jsxRuntime.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...r,children:jsxRuntime.jsxs("g",{id:"Hollow Candles",children:[jsxRuntime.jsx("path",{id:"Subtract",fillRule:"evenodd",clipRule:"evenodd",d:"M5.5 14.5V5.5H7.5V14.5H5.5Z",fill:"white",fillOpacity:"0.12"}),jsxRuntime.jsx("path",{id:"Union",fillRule:"evenodd",clipRule:"evenodd",d:"M7.25 2.5V4H8.5C8.77614 4 9 4.22386 9 4.5V15.5C9 15.7761 8.77614 16 8.5 16H7.25V17.5C7.25 17.7761 7.02614 18 6.75 18H6.25C5.97386 18 5.75 17.7761 5.75 17.5V16H4.5C4.22386 16 4 15.7761 4 15.5V4.5C4 4.22386 4.22386 4 4.5 4H5.75V2.5C5.75 2.22386 5.97386 2 6.25 2H6.75C7.02614 2 7.25 2.22386 7.25 2.5ZM5.5 5.5V14.5H7.5V5.5H5.5ZM14.25 4.5V7H15.5C15.7761 7 16 7.22386 16 7.5V15.5C16 15.7761 15.7761 16 15.5 16H14.25V17.5C14.25 17.7761 14.0261 18 13.75 18H13.25C12.9739 18 12.75 17.7761 12.75 17.5V16H11.5C11.2239 16 11 15.7761 11 15.5V7.5C11 7.22386 11.2239 7 11.5 7H12.75V4.5C12.75 4.22386 12.9739 4 13.25 4H13.75C14.0261 4 14.25 4.22386 14.25 4.5ZM12.5 8.5V14.5H14.5V8.5H12.5Z"})]})}),dr=r=>jsxRuntime.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...r,children:jsxRuntime.jsx("g",{id:"Line",children:jsxRuntime.jsx("path",{id:"Vector 16 (Stroke)",fillRule:"evenodd",clipRule:"evenodd",d:"M18.3 2.72288C18.542 2.85596 18.6303 3.15999 18.4972 3.40195L13.495 12.4968C13.0776 13.2557 12.1061 13.5044 11.3754 13.0394L7.19878 10.3816L2.97738 17.558C2.83737 17.796 2.53092 17.8754 2.2929 17.7354L1.43097 17.2284C1.19295 17.0884 1.1135 16.7819 1.25351 16.5439L5.73746 8.92122C6.16792 8.18943 7.1194 7.96045 7.83567 8.41626L11.9995 11.0659L16.7448 2.43811C16.8778 2.19615 17.1819 2.10788 17.4238 2.24096L18.3 2.72288Z"})})}),pr=r=>jsxRuntime.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...r,children:jsxRuntime.jsxs("g",{id:"Area",children:[jsxRuntime.jsx("path",{id:"Vector 16 (Stroke)",fillRule:"evenodd",clipRule:"evenodd",d:"M18.3 2.72288C18.542 2.85596 18.6303 3.15999 18.4972 3.40195L13.495 12.4968C13.0776 13.2557 12.1061 13.5044 11.3754 13.0394L7.19878 10.3816L2.97738 17.558C2.83737 17.796 2.53092 17.8754 2.2929 17.7354L1.43097 17.2284C1.19295 17.0884 1.1135 16.7819 1.25351 16.5439L5.73746 8.92122C6.16792 8.18943 7.1194 7.96045 7.83567 8.41626L11.9995 11.0659L16.7448 2.43811C16.8778 2.19615 17.1819 2.10788 17.4238 2.24096L18.3 2.72288Z"}),jsxRuntime.jsx("path",{id:"Subtract",fillRule:"evenodd",clipRule:"evenodd",d:"M2.7608 17.7562C2.84602 17.899 3.00106 18 3.19016 18H16.362C17.4665 18 18.362 17.1046 18.362 16V3.94663C18.362 3.86618 18.3453 3.79397 18.3162 3.73108L13.495 12.4968C13.0776 13.2557 12.1061 13.5044 11.3754 13.0394L7.19881 10.3816L2.9774 17.558C2.92465 17.6477 2.84826 17.7148 2.7608 17.7562Z",fill:"white",fillOpacity:"0.12"})]})}),mr=r=>jsxRuntime.jsx("svg",{viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...r,children:jsxRuntime.jsx("g",{id:"Baseline",children:jsxRuntime.jsx("path",{id:"Union",fillRule:"evenodd",clipRule:"evenodd",d:"M6.05938 2.93544C6.55642 1.71198 8.27766 1.68139 8.81785 2.88642L11.4361 8.72723H9.24438L7.4717 4.77279L5.86521 8.72723H3.70647L6.05938 2.93544ZM13.9282 14.2865L13.0051 12.2272H10.8133L12.5586 16.1204C13.088 17.3014 14.7641 17.3026 15.2952 16.1224L17.048 12.2272H14.8549L13.9282 14.2865ZM2.28459 12.2272H4.44333L1.85293 18.6036L0 17.8509L2.28459 12.2272ZM16.4299 8.72723H18.623L19.3384 7.13759L17.5145 6.31686L16.4299 8.72723ZM1.42645 10.2272C1.42645 9.95109 1.65031 9.72723 1.92645 9.72723H2.92645C3.20259 9.72723 3.42645 9.95109 3.42645 10.2272V10.7272C3.42645 11.0034 3.20259 11.2272 2.92645 11.2272H1.92645C1.65031 11.2272 1.42645 11.0034 1.42645 10.7272V10.2272ZM4.42645 10.2272C4.42645 9.95109 4.65031 9.72723 4.92645 9.72723H5.92645C6.20259 9.72723 6.42645 9.95109 6.42645 10.2272V10.7272C6.42645 11.0034 6.20259 11.2272 5.92645 11.2272H4.92645C4.65031 11.2272 4.42645 11.0034 4.42645 10.7272V10.2272ZM7.92645 9.72723C7.65031 9.72723 7.42645 9.95109 7.42645 10.2272V10.7272C7.42645 11.0034 7.65031 11.2272 7.92645 11.2272H8.92645C9.20259 11.2272 9.42645 11.0034 9.42645 10.7272V10.2272C9.42645 9.95109 9.20259 9.72723 8.92645 9.72723H7.92645ZM10.4265 10.2272C10.4265 9.95109 10.6503 9.72723 10.9265 9.72723H11.9265C12.2026 9.72723 12.4265 9.95109 12.4265 10.2272V10.7272C12.4265 11.0034 12.2026 11.2272 11.9265 11.2272H10.9265C10.6503 11.2272 10.4265 11.0034 10.4265 10.7272V10.2272ZM13.9265 9.72723C13.6503 9.72723 13.4265 9.95109 13.4265 10.2272V10.7272C13.4265 11.0034 13.6503 11.2272 13.9265 11.2272H14.9265C15.2026 11.2272 15.4265 11.0034 15.4265 10.7272V10.2272C15.4265 9.95109 15.2026 9.72723 14.9265 9.72723H13.9265ZM16.4265 10.2272C16.4265 9.95109 16.6503 9.72723 16.9265 9.72723H17.9265C18.2026 9.72723 18.4265 9.95109 18.4265 10.2272V10.7272C18.4265 11.0034 18.2026 11.2272 17.9265 11.2272H16.9265C16.6503 11.2272 16.4265 11.0034 16.4265 10.7272V10.2272Z"})})}),gr=r=>jsxRuntime.jsx("svg",{viewBox:"0 0 12 12",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...r,children:jsxRuntime.jsx("g",{id:"Unselected",children:jsxRuntime.jsx("path",{id:"Vector",d:"M6.00684 0.999023C3.24544 0.999023 1.00684 3.23752 1.00684 5.99902C1.00684 8.76051 3.24544 10.999 6.00684 10.999C8.76834 10.999 11.0068 8.76051 11.0068 5.99902C11.0068 3.23752 8.76834 0.999023 6.00684 0.999023ZM6.00684 1.99902C8.21584 1.99902 10.0068 3.79002 10.0068 5.99902C10.0068 8.20801 8.21584 9.99901 6.00684 9.99901C3.79769 9.99901 2.00684 8.20801 2.00684 5.99902C2.00684 3.79002 3.79769 1.99902 6.00684 1.99902Z",fill:"white",fillOpacity:"0.2"})})}),hr=r=>jsxRuntime.jsx("svg",{viewBox:"0 0 12 12",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...r,children:jsxRuntime.jsx("g",{id:"Selected-Multiple Choices-fill",children:jsxRuntime.jsx("path",{id:"Subtract",fillRule:"evenodd",clipRule:"evenodd",d:"M1.00684 5.99902C1.00684 3.23752 3.24544 0.999023 6.00684 0.999023C8.76834 0.999023 11.0068 3.23752 11.0068 5.99902C11.0068 8.76051 8.76834 10.999 6.00684 10.999C3.24544 10.999 1.00684 8.76051 1.00684 5.99902ZM8.49243 3.65563C8.60602 3.54726 8.76156 3.49957 8.91068 3.49957C9.05981 3.49957 9.21534 3.54726 9.32893 3.65563C9.5567 3.87231 9.5567 4.23649 9.32893 4.45317L5.25362 8.33706C5.02644 8.55374 4.6443 8.55374 4.41712 8.33706L2.67014 6.67253C2.44296 6.45585 2.44296 6.09161 2.67014 5.87499C2.89791 5.65831 3.28004 5.65831 3.50722 5.87499L4.83537 7.1407L8.49243 3.65563Z",fill:"#608CFF"})})});});var Lr={};Ve(Lr,{default:()=>Lo});var Io,Lo,Or=K(()=>{Z();Io=r=>{let[e,t]=R.useState(false),{t:i}=orderlyI18n.useTranslation(),o=R.useMemo(()=>[{icon:jsxRuntime.jsx(lr,{fill:"currentColor",className:"oui-w-5 oui-h-5"}),label:i("tradingView.lineType.bars"),value:"0"},{icon:jsxRuntime.jsx(cr,{fill:"currentColor",className:"oui-w-5 oui-h-5"}),label:i("tradingView.lineType.candles"),value:"1"},{icon:jsxRuntime.jsx(ur,{fill:"currentColor",className:"oui-w-5 oui-h-5"}),label:i("tradingView.lineType.hollowCandles"),value:"9"},{icon:jsxRuntime.jsx(dr,{fill:"currentColor",className:"oui-w-5 oui-h-5"}),label:i("tradingView.lineType.line"),value:"2"},{icon:jsxRuntime.jsx(pr,{fill:"currentColor",className:"oui-w-5 oui-h-5"}),label:i("tradingView.lineType.area"),value:"3"},{icon:jsxRuntime.jsx(mr,{fill:"currentColor",className:"oui-w-5 oui-h-5"}),label:i("tradingView.lineType.baseline"),value:"10"}],[i]),s=R.useMemo(()=>{let n=o.find(a=>a.value===r.lineType);return n?n.icon:o[1].icon},[r.lineType]);return jsxRuntime.jsxs(orderlyUi.DropdownMenuRoot,{open:e,onOpenChange:t,children:[jsxRuntime.jsx(orderlyUi.DropdownMenuTrigger,{asChild:true,children:jsxRuntime.jsx(orderlyUi.Box,{className:orderlyUi.cn("oui-w-[18px] oui-h-[18px] oui-cursor-pointer oui-text-base-contrast-36 hover:oui-text-base-contrast-80",e&&"oui-text-base-contrast-80"),children:s})}),jsxRuntime.jsx(orderlyUi.DropdownMenuPortal,{children:jsxRuntime.jsx(orderlyUi.DropdownMenuContent,{onCloseAutoFocus:n=>n.preventDefault(),onClick:n=>n.stopPropagation(),align:"start",sideOffset:20,className:"oui-bg-base-8",children:jsxRuntime.jsx(orderlyUi.Flex,{direction:"column",gap:4,px:5,py:5,width:240,justify:"start",itemAlign:"start",children:o.map(n=>jsxRuntime.jsxs(orderlyUi.Flex,{justify:"start",itemAlign:"center",gap:2,className:orderlyUi.cn("oui-text-base-contrast-36 oui-cursor-pointer oui-w-full hover:oui-text-base-contrast",r.lineType===n.value&&"oui-text-base-contrast"),onClick:()=>r.changeLineType(n.value),children:[n.icon,jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-sm",children:n.label})]},n.value))})})})]})},Lo=Io;});var wr={};Ve(wr,{MobileTimeInterval:()=>xr,TimeInterval:()=>Ao});var Pr,Ao,Bo,xr,Vo,Rr=K(()=>{Z();Pr=()=>{let{t:r}=orderlyI18n.useTranslation();return {mobileTimeIntervalMoreMap:R.useMemo(()=>[[{value:"3",label:r("tradingView.timeInterval.3m")},{value:"5",label:r("tradingView.timeInterval.5m")},{value:"30",label:r("tradingView.timeInterval.30m")},{value:"120",label:r("tradingView.timeInterval.2h")}],[{value:"360",label:r("tradingView.timeInterval.6h")},{value:"720",label:r("tradingView.timeInterval.12h")},{value:"3d",label:r("tradingView.timeInterval.3d")},{value:"1M",label:r("tradingView.timeInterval.1M")}]],[r])}},Ao=r=>orderlyHooks.useMediaQuery(orderlyTypes.MEDIA_TABLET)?jsxRuntime.jsx(xr,{...r}):jsxRuntime.jsx(Bo,{...r}),Bo=r=>{let{t:e}=orderlyI18n.useTranslation(),t=R.useMemo(()=>[{value:"1",label:e("tradingView.timeInterval.1m")},{value:"3",label:e("tradingView.timeInterval.3m")},{value:"5",label:e("tradingView.timeInterval.5m")},{value:"15",label:e("tradingView.timeInterval.15m")},{value:"30",label:e("tradingView.timeInterval.30m")},{value:"60",label:e("tradingView.timeInterval.1h")},{value:"240",label:e("tradingView.timeInterval.4h")},{value:"720",label:e("tradingView.timeInterval.12h")},{value:"1D",label:e("tradingView.timeInterval.1d")},{value:"1W",label:e("tradingView.timeInterval.1w")},{value:"1M",label:e("tradingView.timeInterval.1M")}],[e]);return jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-text-2xs oui-text-base-contrast-36 oui-flex oui-gap-[2px] oui-items-center oui-mr-3 oui-font-semibold","oui-overflow-hidden"),children:t.map(i=>jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-cursor-pointer oui-px-2","hover:oui-text-base-contrast-80","oui-break-normal oui-whitespace-nowrap",r.interval===i.value&&"oui-text-base-contrast-80 oui-bg-white/[.06] oui-rounded"),id:i.value,onClick:()=>r.changeInterval(i.value),children:i.label},i.value))})},xr=r=>{let{t:e}=orderlyI18n.useTranslation(),t=R.useMemo(()=>[{value:"1",label:e("tradingView.timeInterval.1m")},{value:"15",label:e("tradingView.timeInterval.15m")},{value:"60",label:e("tradingView.timeInterval.1h")},{value:"240",label:e("tradingView.timeInterval.4h")},{value:"1D",label:e("tradingView.timeInterval.1d")},{value:"1W",label:e("tradingView.timeInterval.1w")}],[e]),{mobileTimeIntervalMoreMap:i}=Pr(),o=R.useMemo(()=>{for(let s of i)for(let n of s)if(n.value===r.interval)return n.label;return null},[r.interval,i]);return jsxRuntime.jsxs(orderlyUi.Flex,{justify:"start",itemAlign:"center",gap:3,className:orderlyUi.cn("oui-text-2xs oui-text-base-contrast-36","oui-overflow-hidden"),children:[jsxRuntime.jsx("div",{className:" oui-flex oui-gap-1 oui-items-center oui-mr-3 oui-font-semibold",children:t.map(s=>jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-px-2","oui-break-normal oui-whitespace-nowrap",r.interval===s.value&&"oui-text-base-contrast-80 oui-bg-white/[.06] oui-rounded"),onClick:()=>r.changeInterval(s.value),children:s.label},s.value))}),jsxRuntime.jsx(Vo,{...r,children:o?jsxRuntime.jsx("div",{className:"oui-text-base-contrast-80",children:o}):jsxRuntime.jsx(orderlyUi.Text,{className:"oui-break-normal oui-whitespace-nowrap",children:e("tradingView.timeInterval.more")})})]})},Vo=r=>{let[e,t]=R__default.default.useState(false),{mobileTimeIntervalMoreMap:i}=Pr();return jsxRuntime.jsxs(orderlyUi.DropdownMenuRoot,{open:e,onOpenChange:t,children:[jsxRuntime.jsx(orderlyUi.DropdownMenuTrigger,{asChild:true,children:jsxRuntime.jsxs("div",{className:"oui-flex oui-justify-start oui-items-center oui-gap-0.5",children:[r.children,jsxRuntime.jsx($,{className:orderlyUi.cn("oui-w-3 oui-h-3",e&&"oui-text-base-contrast-80 oui-rotate-180")})]})}),jsxRuntime.jsx(orderlyUi.DropdownMenuPortal,{children:jsxRuntime.jsx(orderlyUi.DropdownMenuContent,{onCloseAutoFocus:o=>o.preventDefault(),onClick:o=>o.stopPropagation(),align:"start",alignOffset:0,sideOffset:0,className:orderlyUi.cn("oui-markets-dropdown-menu-content oui-bg-base-9 oui-w-screen oui-flex oui-flex-col oui-gap-2 oui-p-3"),children:i.map((o,s)=>jsxRuntime.jsx("div",{className:"oui-flex oui-gap-2",children:o.map(n=>jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-w-full oui-text-2xs oui-flex oui-items-center oui-justify-center oui-h-6 oui-rounded",n.value===r.interval?"oui-text-base-contrast oui-bg-primary-darken":"oui-text-base-contrast-36 oui-bg-base-5"),onClick:()=>{r.changeInterval(n.value);},children:jsxRuntime.jsx("div",{children:n.label})},n.value))},s))})})]})};});var Er,kr=K(()=>{Z();Er=r=>{let{displayControlState:e,changeDisplayControlState:t}=r,[i,o]=R.useState(false),{t:s}=orderlyI18n.useTranslation(),n=R.useMemo(()=>[{label:s("common.position"),id:"position"},{label:s("tradingView.displayControl.buySell"),id:"buySell"},{label:s("tradingView.displayControl.limitOrders"),id:"limitOrders"},{label:s("tradingView.displayControl.stopOrders"),id:"stopOrders"},{label:s("common.tpsl"),id:"tpsl"},{label:s("tpsl.positionTpsl"),id:"positionTpsl"},{label:s("orderEntry.orderType.trailingStop"),id:"trailingStop"}],[s]);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs(orderlyUi.DropdownMenuRoot,{open:i,onOpenChange:o,children:[jsxRuntime.jsx(orderlyUi.DropdownMenuTrigger,{asChild:true,children:jsxRuntime.jsxs(orderlyUi.Flex,{justify:"start",itemAlign:"center",className:"oui-gap-[2px] oui-cursor-pointer oui-text-base-contrast-36 hover:oui-text-base-contrast-80",children:[jsxRuntime.jsx(ke,{className:orderlyUi.cn("oui-w-[18px] oui-h-[18px] ",i&&"oui-text-base-contrast-80")}),jsxRuntime.jsx($,{className:orderlyUi.cn("oui-w-3 oui-h-3",i&&"oui-text-base-contrast-80 oui-rotate-180")})]})}),jsxRuntime.jsx(orderlyUi.DropdownMenuPortal,{children:jsxRuntime.jsx(orderlyUi.DropdownMenuContent,{onCloseAutoFocus:a=>a.preventDefault(),onClick:a=>a.stopPropagation(),align:"start",className:"oui-bg-base-8",children:jsxRuntime.jsx(orderlyUi.Flex,{direction:"column",gap:4,px:5,py:5,width:240,justify:"start",itemAlign:"start",children:n.map(a=>jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",itemAlign:"center",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{className:orderlyUi.cn("oui-text-sm oui-text-base-contrast-80",!e[a.id]&&"oui-text-base-contrast-36"),children:a.label}),jsxRuntime.jsx(orderlyUi.Switch,{className:"oui-h-4 oui-w-8",checked:e[a.id],onCheckedChange:c=>{t({...e,[a.id]:c});}})]},a.id))})})})]})})};});var Mr,Dr=K(()=>{Z();Mr=r=>{let[e,t]=R.useState(false),{t:i}=orderlyI18n.useTranslation(),o=R.useMemo(()=>[[{label:i("common.position"),id:"position"},{label:i("tradingView.displayControl.limitOrders"),id:"limitOrders"}],[{label:i("tradingView.displayControl.stopOrders"),id:"stopOrders"},{label:i("common.tpsl"),id:"tpsl"}],[{label:i("tpsl.positionTpsl"),id:"positionTpsl"},{label:i("tradingView.displayControl.buySell"),id:"buySell"}],[{label:i("orderEntry.orderType.trailingStop"),id:"trailingStop"},{}]],[i]);return jsxRuntime.jsxs(orderlyUi.DropdownMenuRoot,{open:e,onOpenChange:t,children:[jsxRuntime.jsx(orderlyUi.DropdownMenuTrigger,{asChild:true,children:jsxRuntime.jsxs("div",{className:orderlyUi.cn("oui-flex oui-items-center oui-justify-center oui-gap-0.5 oui-text-base-contrast-36",e&&"oui-text-base-contrast-8"),children:[jsxRuntime.jsx(ke,{className:orderlyUi.cn("oui-size-[18px] ",e&&"oui-text-base-contrast-80")}),jsxRuntime.jsx($,{className:orderlyUi.cn("oui-size-3",e&&"oui-rotate-180 oui-text-base-contrast-80")})]})}),jsxRuntime.jsx(orderlyUi.DropdownMenuPortal,{children:jsxRuntime.jsx(orderlyUi.DropdownMenuContent,{onCloseAutoFocus:s=>s.preventDefault(),onClick:s=>s.stopPropagation(),align:"start",alignOffset:0,sideOffset:0,className:orderlyUi.cn("oui-tradingview-display-control-dropdown-menu-content oui-flex oui-w-screen oui-flex-col oui-gap-2 oui-bg-base-9 oui-p-3"),children:o.map((s,n)=>jsxRuntime.jsx("div",{className:"oui-flex oui-gap-2",children:s.map((a,c)=>jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-flex oui-h-6 oui-w-full oui-items-center oui-justify-between","oui-rounded oui-px-2 oui-text-2xs",a.id&&"oui-bg-base-5",r.displayControlState[a.id]?"oui-text-base-contrast":"oui-text-base-contrast-36"),onClick:()=>{a.id&&r.changeDisplayControlState({...r.displayControlState,[a.id]:!r.displayControlState[a.id]});},children:a.id&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{children:a.label}),r.displayControlState[a.id]?jsxRuntime.jsx(hr,{className:"oui-size-3"}):jsxRuntime.jsx(gr,{className:"oui-size-3"})]})},a.id||c))},n))})})]})};});var gt={};Ve(gt,{DesktopDisplayControl:()=>Er,MobileDisplayControl:()=>Mr});var ht=K(()=>{kr();Dr();});var Xr="#008676",ei="#D92D6B",Ne="#131519",ti="#00B49E",ri="#FF447C",ii="#333948",oi="#FFFFFF",ni="#F4F7F9",si="regular 11px Manrope",Tt={upColor:Xr,downColor:ei,chartBG:Ne,pnlUpColor:ti,pnlDownColor:ri,pnlZoreColor:ii,textColor:oi,qtyTextColor:ni,font:si,volumeUpColor:"#0C3E3A",volumeDownColor:"#5A1E36",closeIcon:"rgba(255, 255, 255, 0.8)"},It=(r,e)=>{let t={"paneProperties.background":r.chartBG,"paneProperties.backgroundType":"solid","mainSeriesProperties.candleStyle.upColor":r.upColor,"mainSeriesProperties.candleStyle.downColor":r.downColor,"mainSeriesProperties.candleStyle.borderColor":r.upColor,"mainSeriesProperties.candleStyle.borderUpColor":r.upColor,"mainSeriesProperties.candleStyle.borderDownColor":r.downColor,"mainSeriesProperties.candleStyle.wickUpColor":r.upColor,"mainSeriesProperties.candleStyle.wickDownColor":r.downColor,"paneProperties.separatorColor":"#2B2833","paneProperties.vertGridProperties.color":"#26232F","paneProperties.horzGridProperties.color":"#26232F","scalesProperties.fontSize":e?8:12,"scalesProperties.textColor":"#97969B","paneProperties.legendProperties.showSeriesTitle":!e,"mainSeriesProperties.statusViewStyle.symbolTextSource":"ticker"},i={"volume.volume.color.0":r.volumeDownColor,"volume.volume.color.1":r.volumeUpColor};return {overrides:t,studiesOverrides:i}},ce="Orderly",I=r=>r.includes(":")?r.split(":")[1]:r,ue=r=>r.startsWith(`${ce}:`)?r:`${ce}:${r}`;var ci=(r,e)=>{let i,o=s=>[null,"limit","MARKET","STOP_MARKET","STOP_LIMIT"][s];return {symbolInfo:async s=>(i=e.getSymbolInfo(I(s)),{qty:{min:i?.baseMin??0,max:i?.baseMax??0,step:i?.baseTick??0},pipValue:0,pipSize:i?.quoteTick??0,minTick:i?.quoteTick??0,description:""}),placeOrder:async s=>{let n=["SELL","BUY"][+(s.side>0)],a=s.qty.toString();(s.limitPrice??0).toString();(s.stopPrice??0).toString();let u=I(s.symbol),m=o(s.type);m==="MARKET"?e.sendMarketOrder({side:n,order_quantity:a,symbol:u,order_type:orderlyTypes.OrderType.MARKET}):"LIMIT";},orders:()=>[],positions:()=>[],executions:()=>[],connectionStatus:()=>1,chartContextMenuActions:s=>r.defaultContextMenuActions(s),isTradable:async()=>true,accountManagerInfo:()=>({}),currentAccount:()=>"1",accountsMetainfo:async()=>[{id:"1"}],remove:()=>r?.silentOrdersPlacement().unsubscribe()}},Lt=ci;function V(r){return r===void 0?"":typeof r=="string"?r:r.message}var pe=class{constructor(e,t,i){this._datafeedUrl=e,this._requester=t,this._limitedServerResponse=i;}getBars(e,t,i){let o={symbol:e.ticker||"",resolution:t,from:i.from,to:i.to};return i.countBack!==void 0&&(o.countback=i.countBack),e.currency_code!==void 0&&(o.currencyCode=e.currency_code),e.unit_id!==void 0&&(o.unitId=e.unit_id),new Promise(async(s,n)=>{try{let a=await this._requester.sendRequest(this._datafeedUrl,"history",o),c=this._processHistoryResponse(a);this._limitedServerResponse&&await this._processTruncatedResponse(c,o),s(c);}catch(a){if(a instanceof Error||typeof a=="string"){let c=V(a);n(c);}}})}async _processTruncatedResponse(e,t){let i=e.bars.length;try{for(;this._limitedServerResponse&&this._limitedServerResponse.maxResponseLength>0&&this._limitedServerResponse.maxResponseLength===i&&t.from<t.to;){t.countback&&(t.countback=t.countback-i),this._limitedServerResponse.expectedOrder==="earliestFirst"?t.from=Math.round(e.bars[e.bars.length-1].time/1e3):t.to=Math.round(e.bars[0].time/1e3);let o=await this._requester.sendRequest(this._datafeedUrl,"history",t),s=this._processHistoryResponse(o);i=s.bars.length,this._limitedServerResponse.expectedOrder==="earliestFirst"?(s.bars[0].time===e.bars[e.bars.length-1].time&&s.bars.shift(),e.bars.push(...s.bars)):(s.bars[s.bars.length-1].time===e.bars[0].time&&s.bars.pop(),e.bars.unshift(...s.bars));}}catch(o){if(o instanceof Error||typeof o=="string"){V(o);}}}_processHistoryResponse(e){if(e.s!=="ok"&&e.s!=="no_data")throw new Error(e.errmsg);let t=[],i={noData:false};if(e.s==="no_data")i.noData=true,i.nextTime=e.nextTime;else {let o=e.v!==void 0,s=e.o!==void 0;for(let n=0;n<e.t.length;++n){let a={time:e.t[n]*1e3,close:parseFloat(e.c[n]),open:parseFloat(e.c[n]),high:parseFloat(e.c[n]),low:parseFloat(e.c[n])};s&&(a.open=parseFloat(e.o[n]),a.high=parseFloat(e.h[n]),a.low=parseFloat(e.l[n])),o&&(a.volume=parseFloat(e.v[n])),t.push(a);}}return {bars:t,meta:i}}};var me=class{constructor(e){e&&(this._headers=e);}sendRequest(e,t,i){if(i!==void 0){let s=Object.keys(i);s.length!==0&&(t+="?"),t+=s.map(n=>`${encodeURIComponent(n)}=${encodeURIComponent(i[n].toString())}`).join("&");}""+t;let o={credentials:"same-origin"};return this._headers!==void 0&&(o.headers=this._headers),fetch(`${e}/${t}`,o).then(s=>s.text()).then(s=>JSON.parse(s))}};function f(r,e,t,i){let o=r[e];return Array.isArray(o)&&(!i||Array.isArray(o[0]))?o[t]:o}function ge(r,e,t){return r+(e!==void 0?"_%|#|%_"+e:"")+(t!==void 0?"_%|#|%_"+t:"")}var he=class{constructor(e,t,i){this._exchangesList=["Orderly"];this._symbolsInfo={};this._symbolsList=[];this._datafeedUrl=e,this._datafeedSupportedResolutions=t,this._requester=i,this._readyPromise=this._init(),this._readyPromise.catch(o=>{});}resolveSymbol(e,t,i){return this._readyPromise.then(()=>{let o=this._symbolsInfo[ge(e,t,i)];return o===void 0?Promise.reject("invalid symbol"):Promise.resolve(o)})}searchSymbols(e,t,i,o){return this._readyPromise.then(()=>{let s=[],n=e.length===0;e=e.toUpperCase();for(let c of this._symbolsList){let l=this._symbolsInfo[c];if(l===void 0||i.length>0&&l.type!==i||t&&t.length>0&&l.exchange!==t)continue;let u=l.name.toUpperCase().indexOf(e),m=l.description.toUpperCase().indexOf(e);if((n||u>=0||m>=0)&&!s.some(g=>g.symbolInfo===l)){let g=u>=0?u:8e3+m;s.push({symbolInfo:l,weight:g});}}let a=s.sort((c,l)=>c.weight-l.weight).slice(0,o).map(c=>{let l=c.symbolInfo;return {symbol:l.name,full_name:`${l.exchange}:${l.name}`,description:l.description,exchange:l.exchange,params:[],type:l.type,ticker:l.name}});return Promise.resolve(a)})}_init(){let e=[],t={};for(let i of this._exchangesList)t[i]||(t[i]=true,e.push(this._requestExchangeData(i)));return Promise.all(e).then(()=>{this._symbolsList.sort();})}_requestExchangeData(e){return new Promise((t,i)=>{this._requester.sendRequest(this._datafeedUrl,"symbol_info",{group:e}).then(o=>{try{this._onExchangeDataReceived(e,o);}catch(s){i(s instanceof Error?s:new Error(`SymbolsStorage: Unexpected exception ${s}`));return}t();}).catch(o=>{`${e}${V(o)}`,t();});})}_onExchangeDataReceived(e,t){let i=0;try{let o=t.symbol.length,s=t.ticker!==void 0;for(;i<o;++i){let n=t.symbol[i],a=f(t,"exchange-listed",i),c=f(t,"exchange-traded",i),l=c+":"+n,u=f(t,"currency-code",i),m=f(t,"unit-id",i),y=s?f(t,"ticker",i):n,g={ticker:y,name:n,base_name:[a+":"+n],listed_exchange:a,exchange:c,currency_code:u,original_currency_code:f(t,"original-currency-code",i),unit_id:m,original_unit_id:f(t,"original-unit-id",i),unit_conversion_types:f(t,"unit-conversion-types",i,!0),description:f(t,"description",i),has_intraday:q(f(t,"has-intraday",i),!1),visible_plots_set:q(f(t,"visible-plots-set",i),"ohlcv"),minmov:f(t,"minmovement",i)||f(t,"minmov",i)||0,minmove2:f(t,"minmove2",i)||f(t,"minmov2",i),fractional:f(t,"fractional",i),pricescale:f(t,"pricescale",i),type:f(t,"type",i),session:f(t,"session-regular",i),session_holidays:f(t,"session-holidays",i),corrections:f(t,"corrections",i),timezone:f(t,"timezone",i),supported_resolutions:q(f(t,"supported-resolutions",i,!0),this._datafeedSupportedResolutions),has_daily:q(f(t,"has-daily",i),!0),intraday_multipliers:q(f(t,"intraday-multipliers",i,!0),["1","5","15","30","60"]),has_weekly_and_monthly:f(t,"has-weekly-and-monthly",i),has_empty_bars:f(t,"has-empty-bars",i),volume_precision:q(f(t,"volume-precision",i),0),format:"price"};this._symbolsInfo[y]=g,this._symbolsInfo[n]=g,this._symbolsInfo[l]=g,(u!==void 0||m!==void 0)&&(this._symbolsInfo[ge(y,u,m)]=g,this._symbolsInfo[ge(n,u,m)]=g,this._symbolsInfo[ge(l,u,m)]=g),this._symbolsList.push(n);}}catch(o){throw new Error(`SymbolsStorage: API error when processing exchange ${e} symbol #${i} (${t.symbol[i]}): ${Object(o).message}`)}}};function q(r,e){return r!==void 0?r:e}var fe=class{constructor(e){this._configuration=Pt();this._symbolsStorage=null;this._datafeedURL=e,this._requester=new me,this._historyProvider=new pe(e,this._requester),this._configurationReadyPromise=this._requestConfiguration().then(t=>{t===null&&(t=Pt()),this._setupWithConfiguration(t);});}getBars(e,t,i,o,s){this._historyProvider.getBars(e,t,i).then(n=>{o(n.bars,n.meta);}).catch(s);}onReady(e){this._configurationReadyPromise.then(()=>{e(this._configuration);});}searchSymbols(e,t,i,o){if(this._symbolsStorage===null)throw new Error("Datafeed: inconsistent configuration (symbols storage)");this._symbolsStorage.searchSymbols(e,t,i,30).then(o).catch(o.bind(null,[]));}resolveSymbol(e,t,i,o){let s=o&&o.currencyCode,n=o&&o.unitId;function c(l){t(l);}if(this._symbolsStorage===null)throw new Error("Datafeed: inconsistent configuration (symbols storage)");this._symbolsStorage.resolveSymbol(e,s,n).then(c).catch(i);}getMarks(){}getTimescaleMarks(){}getServerTime(){}_requestConfiguration(){return this._send("config").catch(e=>(`${V(e)}`,null))}_send(e,t){return this._requester.sendRequest(this._datafeedURL,e,t)}_setupWithConfiguration(e){if(this._configuration=e,e.exchanges===void 0&&(e.exchanges=[]),!e.supports_search&&!e.supports_group_request)throw new Error("Unsupported datafeed configuration. Must either support search, or support group request");(e.supports_group_request||!e.supports_search)&&(this._symbolsStorage=new he(this._datafeedURL,e.supported_resolutions||[],this._requester)),`${JSON.stringify(e)}`;}};function Pt(){return {supports_search:false,supports_group_request:true,supported_resolutions:["1","3","5","15","30","60","120","240","480","720","1D","3D","1W","1M"],supports_marks:false,supports_timescale_marks:false}}var be=class{constructor(){this.subscribers=new Map;}subscribe(e,t){return this.subscribers.has(e)||this.subscribers.set(e,[]),this.subscribers.get(e).push(t),()=>{this.unsubscribe(e,t);}}unsubscribe(e,t){if(this.subscribers.has(e)){let i=this.subscribers.get(e);this.subscribers.set(e,i.filter(o=>o!==t)),this.subscribers.get(e).length===0&&this.subscribers.delete(e);}}publish(e,t){this.subscribers.has(e)&&this.subscribers.get(e).forEach(o=>{o(t);});}};var He=r=>{let e="1d";switch(r){case "1":e="1m";break;case "3":e="3m";break;case "5":e="5m";break;case "15":e="15m";break;case "30":e="30m";break;case "60":e="1h";break;case "120":e="2h";break;case "240":e="4h";break;case "480":e="8h";break;case "720":e="12h";break;case "D":case "1D":e="1d";break;case "3D":e="3d";break;case "1W":e="1w";break;case "1M":e="1M ";break;}return e},N={interval:"TradingviewSDK.lastUsedTimeBasedResolution",lineType:"TradingviewSDK.lastUsedStyle",displayControlSetting:"TradingviewSDK.displaySetting"};var Fe=(r,e)=>`${r}kline_${e}`,ui=r=>["trade"].map(t=>`${r}@${t}`),k=class k{constructor(e){this.klineSubscribeIdMap=new Map;this.klineOnTickCallback=new Map;this.subscribeCachedTopics=new Map;this.wsInstance=null;this.klineData=new Map;return k._created||(this.wsInstance=e,k._instance=this,k._created=true),k._instance}subscribeKline(e,t,i,o){let s=He(i);this.klineSubscribeIdMap.set(e,{symbol:t,resolution:i});let n=Fe(t,s);if(this.klineOnTickCallback.has(n)){let a=this.klineOnTickCallback.get(n);a[e]=o;}else {this.klineOnTickCallback.set(n,{[e]:o});let a=this.wsInstance?.subscribe({event:"subscribe",topic:`${t}@kline_${s}`,id:`${t}@kline_${s}`,ts:new Date().getTime()},{onMessage:c=>{let{open:l,close:u,high:m,low:y,volume:g,startTime:b}=c,z=Fe(c.symbol,c.type);this.updateKline(z,{time:b,close:u,open:l,high:m,low:y,volume:g});}});this.subscribeCachedTopics.set(`${t}@kline_${s}`,a);}}unsubscribeKline(e){if(!this.klineSubscribeIdMap.has(e))return;let{symbol:t,resolution:i}=this.klineSubscribeIdMap.get(e),o=He(i),s=Fe(t,o);if(this.klineOnTickCallback.has(s)){let n=this.klineOnTickCallback.get(s);delete n[e],Object.keys(n).length===0&&(this.klineOnTickCallback.delete(s),this.subscribeCachedTopics.get(`${t}@kline_${o}`)());}delete this.klineSubscribeIdMap[e];}subscribeSymbol(e){ui(e).forEach(i=>{if(!this.subscribeCachedTopics.has(i)){let o=this.wsInstance?.subscribe({event:"subscribe",topic:i,id:i,ts:new Date().getTime()},{onMessage:s=>{this.updateKlineByLastPrice(s.symbol,s.price);}});this.subscribeCachedTopics.set(i,o);}});}updateKlineByLastPrice(e,t){this.klineOnTickCallback.forEach((i,o)=>{if(o.startsWith(e)){let s=this.klineData.get(o);s&&this.updateKline(o,{...s,close:t});}});}updateKline(e,t){let i=this.klineOnTickCallback.get(e);i&&t&&(this.klineData.set(e,t),Object.keys(i).forEach(o=>{let s=i[o];s&&typeof s=="function"&&s(t);}));}};k._created=false,k._instance=null;var G=k;var di=(()=>{let r=0;return ()=>r++})(),ye=class extends fe{constructor(t,i){let o=`${t}/tv`;super(o);this.bbosMap=new Map;this.tickersMap=new Map;this.eventBus=new be;this._subscribeQuoteMap=new Map,this._prefixId=di(),this._publicWs=new G(i),this.bbosMap=new Map,i.on("tickers",s=>{for(let n of s.data)n.change=n.close-n.open,n.perChange=n.open?+(100*n.change/n.open).toFixed(2):0,this.tickersMap.set(n.symbol,n);this.eventBus.publish("tickerUpdate",{message:"ticker"});}),i.subscribe({event:"subscribe",topic:"bbos"},{formatter:s=>s,onMessage:s=>{for(let n of s.data)this.bbosMap.set(n.symbol,{ask:n.ask,bid:n.bid,askSize:n.askSize,bidSize:n.bidSize});this.eventBus.publish("tickerUpdate",{message:"bbos"});}});}remove(){Array.from(this._subscribeQuoteMap.values()).forEach(t=>t?.());}getSubscriptionId(t){return `${this._prefixId}${t}`}subscribeBars(t,i,o,s,n){window.onResetCacheNeededCallback=n,this._publicWs.subscribeKline(`${this._prefixId}${s}`,t.ticker,i,o);}unsubscribeBars(t){this._publicWs.unsubscribeKline(`${this._prefixId}${t}`);}getQuotes(t,i){let o=this.getSubscriptionId("getQuotes");this.unsubscribeQuotes("getQuotes");let s=this.eventBus.subscribe("tickerUpdate",n=>{let a=new Map;t.forEach(c=>{let l=this.bbosMap.get(I(c)),u=this.tickersMap.get(I(c));if(!l||!u)return;let m={...u,ask:l.ask,bid:l.bid};a.set(I(c),m);}),a.size&&i(Array.from(a.values()).map(c=>this._toUDFTicker(c)));});this._subscribeQuoteMap.set(o,s);}subscribeQuotes(t,i,o,s){let n=`${this._prefixId}${s}`;if(t.length>0){this.unsubscribeQuotes(n);let a=this.eventBus.subscribe("tickerUpdate",c=>{let l=new Map;t.forEach(u=>{let m=this.bbosMap.get(I(u)),y=this.tickersMap.get(I(u));if(!m||!y)return;let g={...y,ask:m.ask,bid:m.bid};l.set(I(u),g);}),l.size&&o(Array.from(l.values()).map(u=>this._toUDFTicker(u)));});this._subscribeQuoteMap.set(n,a);}}unsubscribeQuotes(t){let i=this.getSubscriptionId(t),o=this._subscribeQuoteMap.get(i);o&&(o(),this._subscribeQuoteMap.delete(i));}_toUDFTicker(t){return {n:ue(t.symbol),s:"ok",v:{ask:t.ask,bid:t.bid,ch:t.change,chp:t.perChange/100,description:"",exchange:ce,hight_price:t.high,low_price:t.low,lp:t.close,open_price:t.open,prev_close_price:0,volume:t.volume}}}};var mi=2,gi="--",Ke=["BRACKET","STOP_BRACKET"],Ce=["POSITIONAL_TP_SL","TP_SL"];var qe=r=>r.root_algo_order_id!==r.algo_order_id&&(r.algo_type==="TAKE_PROFIT"||r.algo_type==="STOP_LOSS"),hi=r=>!!r&&Ke.includes(r);var Ge=r=>r.type==="CLOSE_POSITION",Rt=r=>Ge(r)&&r.is_activated,Et=r=>qe(r)&&r.is_activated,We=r=>r.root_algo_order_algo_type==="TP_SL"||hi(r.root_algo_order_algo_type)&&r.is_activated,kt=(r,e)=>{let t=r.algo_type,i={TAKE_PROFIT:orderlyI18n.i18n.t("tpsl.takeProfit"),STOP_LOSS:orderlyI18n.i18n.t("tpsl.stopLoss")}[t];return i||null},Mt=r=>{let e=new Map,t=1;return [...r].reverse().filter(We).forEach(i=>{i.root_algo_order_id&&!e.has(i.root_algo_order_id)&&e.set(i.root_algo_order_id,t++);}),e},Dt=(r,e)=>{let t=Math.abs(r.type==="CLOSE_POSITION"?e.balance:r.quantity),i=r.side==="SELL"?1:-1,o=e.open.toString();return {estPnl:new orderlyUtils.Decimal(r.trigger_price).minus(o??0).times(t).times(i).toString(),quantity:t,openPrice:o}},At=r=>r!==void 0&&r!==""?new orderlyUtils.Decimal(r).todp(mi,orderlyUtils.Decimal.ROUND_FLOOR):gi;function Qe(){let[r,{cancelOrder:e,cancelAlgoOrder:t,cancelTPSLChildOrder:i}]=orderlyHooks.useOrderStream({status:orderlyTypes.OrderStatus.INCOMPLETE});return R.useCallback(o=>{if(o.algo_order_id){if(Ce.includes(o.root_algo_order_algo_type)){let s=r?.find(a=>a.algo_order_id===o.root_algo_order_id);return s.child_orders.every(a=>!!a.trigger_price)?i(o.algo_order_id,o.root_algo_order_id):t(s.algo_order_id,o.symbol).then()}return t(o.algo_order_id,o.symbol).then()}return e(o.order_id,o.symbol).then()},[e,r])}function $e(r){orderlyHooks.useEventEmitter();let [,{updateOrder:t,cancelAlgoOrder:i,updateAlgoOrder:o,updateTPSLOrder:s}]=orderlyHooks.useOrderStream({status:orderlyTypes.OrderStatus.INCOMPLETE});return R.useCallback((n,a)=>{if(n.algo_order_id)if(Ce.includes(n.root_algo_order_algo_type)){let l=[{order_id:n.algo_order_id,trigger_price:new orderlyUtils.Decimal(a.value).toString()}];return s(n.root_algo_order_id,l).then(u=>{}).catch(u=>{r&&r.error(u.message);})}else {if(Ke.includes(n.algo_type))return o(n.algo_order_id,{order_price:new orderlyUtils.Decimal(a.value).toString()}).then(l=>{}).catch(l=>{r&&r.error(l.message);});{let l={quantity:n.quantity,trigger_price:n.trigger_price,symbol:n.symbol,price:n.price,algo_order_id:n.algo_order_id};return n.order_tag&&(l.order_tag=n.order_tag),n.client_order_id&&(l.client_order_id=n.client_order_id),a.type==="price"&&(l.price=new orderlyUtils.Decimal(a.value).toString()),a.type==="trigger_price"&&(l.trigger_price=new orderlyUtils.Decimal(a.value).toString()),o(n.algo_order_id,l).then(u=>{}).catch(u=>{r&&r.error(u.message);})}}let c={order_price:n.price?.toString(),order_quantity:n.quantity.toString(),symbol:n.symbol,order_type:n.type,side:n.side,visible_quantity:0,reduce_only:n.reduce_only};return new orderlyUtils.Decimal(n.visible_quantity??n.visible??0).eq(n.quantity)&&delete c.visible_quantity,Object.keys(n).includes("reduce_only")||delete c.reduce_only,n.order_tag&&(c.order_tag=n.order_tag),n.client_order_id&&(c.client_order_id=n.client_order_id),a.type==="price"&&(c.order_price=new orderlyUtils.Decimal(a.value).toString()),t(n.order_id,c).then(l=>{}).catch(l=>{r.error(l.message);})},[t])}function Ze(r){let {onSubmit:e}=orderlyHooks.useOrderEntry_deprecated({symbol:r,side:orderlyTypes.OrderSide.BUY,order_type:orderlyTypes.OrderType.MARKET},{watchOrderbook:true});return {sendLimitOrder:()=>{},sendMarketOrder:s=>(s.reduce_only=false,e(s).catch(n=>{orderlyUi.toast.error(n);}))}}var wi=r=>e=>r(e),Ri=({closeConfirm:r,colorConfig:e,onToast:t,mode:i,symbol:o})=>{let s=Qe(),n=$e(t),a=orderlyHooks.useSymbolsInfo(),c=R.useCallback(g=>r&&r(g),[r]),{sendMarketOrder:l,sendLimitOrder:u}=Ze(o),m=R.useCallback(g=>{if(a)return {baseMin:a[g]("base_min"),baseMax:a[g]("base_max"),baseTick:a[g]("base_tick"),quoteTick:a[g]("quote_tick")}},[a]),y=R.useRef({cancelOrder:s,closePosition:c,editOrder:n,colorConfig:e,sendLimitOrder:u,getSymbolInfo:m,sendMarketOrder:wi(l),mode:i});return R.useEffect(()=>{y.current.getSymbolInfo=m;},[a]),R.useEffect(()=>{y.current.sendLimitOrder=u,y.current.sendMarketOrder=l;},[u,l]),R.useEffect(()=>{y.current.closePosition=c;},[r]),R.useEffect(()=>{y.current.cancelOrder=s;},[s]),y.current},Vt=Ri;var Ft={1:{startOf:"minute",period:0},3:{startOf:"hour",period:3*60*1e3},5:{startOf:"hour",period:5*60*1e3},15:{startOf:"hour",period:15*60*1e3},30:{startOf:"hour",period:30*60*1e3},60:{startOf:"hour",period:0},120:{startOf:"day",period:2*60*60*1e3},240:{startOf:"day",period:4*60*60*1e3},480:{startOf:"day",period:8*60*60*1e3},720:{startOf:"day",period:12*60*60*1e3},D:{startOf:"day",period:0},"1D":{startOf:"day",period:0},"3D":{startOf:"year",period:3*24*60*60*1e3},"5D":{startOf:"year",period:5*24*60*60*1e3},"1W":{startOf:"week",period:0},"1M":{startOf:"month",period:0}};function Ht(r,e,t,i){let{startOf:o,period:s}=Ft[t],n=new Date(r.updated_time).getTime(),a=dateFns.startOfSecond(n).getTime();o==="minute"?a=dateFns.startOfMinute(n).getTime():o==="hour"?a=dateFns.startOfHour(n).getTime():o==="day"?a=dateFns.startOfDay(n).getTime():o==="month"?a=dateFns.startOfMonth(n).getTime():o==="year"?a=dateFns.startOfYear(n).getTime():o==="week"?a=dateFns.startOfWeek(n).getTime():o==="month"&&(a=dateFns.startOfMonth(n).getTime());let c=s===0?a:Math.floor((n-a)/s)*s+a;e[c]||(e[c]={BUY:[],SELL:[]}),e[c][r.side].length<5&&(e[c][r.side].push(r),i.push(r));}var Ut=(r,e)=>{let t=[],i={};return Ft[e]?(r.forEach(o=>{if(o.child_orders)for(let s of o.child_orders)s.is_activated&&s.algo_status===orderlyTypes.OrderStatus.FILLED&&Ht(s,i,e,t);else Ht(o,i,e,t);}),t):[]};var _e=class r{constructor(e,t){this.interval="1D";this.changeInterval=e=>{let t=()=>{this.renderExecutions(this.filledOrders,this.basePriceDecimal),this.instance.activeChart().onDataLoaded().unsubscribe(null,t);};this.interval=e,this.instance.activeChart().onDataLoaded().subscribe(null,t);};this.instance=e,this.executions=[],this.filledOrders=[],this.basePriceDecimal=0,this.broker=t,this.subscribeIntervalChange();}async subscribeIntervalChange(){this.interval=this.instance.symbolInterval().interval;let e=this.changeInterval;this.instance.activeChart().onIntervalChanged().subscribe(null,e);}renderExecutions(e,t){this.filledOrders=e,this.basePriceDecimal=t,this.interval&&(this.removeAll(),Ut(e,this.interval).forEach(i=>{this.executions.push(this.drawExecution(i,t));}));}removeAll(){this.executions.forEach(e=>e.remove()),this.executions=[];}static getExecutionInfo(e,t){let i=e.side,o=e.average_executed_price||e.child_orders?.find(n=>!!n.average_executed_price)?.average_executed_price||0,s=new orderlyUtils.Decimal(o).todp(t,orderlyUtils.Decimal.ROUND_FLOOR).toString();return `${i==="BUY"?orderlyI18n.i18n.t("common.buy"):orderlyI18n.i18n.t("common.sell")} ${e.total_executed_quantity} @${orderlyUtils.commify(s)}`}drawExecution(e,t){let i=e.side,o=e.average_executed_price||e.child_orders?.find(a=>!!a.average_executed_price)?.average_executed_price||0,s=new Date(e.updated_time).getTime()/1e3,n=this.broker.colorConfig;return this.instance.activeChart().createExecutionShape().setArrowHeight(9).setTooltip(r.getExecutionInfo(e,t)).setTime(s).setPrice(o).setArrowColor(i==="BUY"?n.upColor:n.downColor).setDirection(i==="BUY"?"buy":"sell")}unsubscribeIntervalChange(){let e=this.changeInterval;try{this.instance.activeChart().onIntervalChanged().unsubscribe(null,e);}catch(t){t instanceof Error&&t.message;}}destroy(){this.removeAll(),this.unsubscribeIntervalChange();}};var J=r=>{if(r!=null)return r.algo_order_id||r.order_id};var Se=class{constructor(){this.quantityTpslNoMap=new Map,this.tpslPnlMap=new Map,this.positions=null;}getQuantityTpslNoMap(){return this.quantityTpslNoMap}getTpslPnlMap(){return this.tpslPnlMap}getFormattedEstPnl(e){if(this.positions===null)return "";let t=this.positions[0];if(!t)return "";let{estPnl:i}=Dt(e,t);return At(i)}prepareTpslPnlMap(e){let t=[];return e.forEach(i=>{let o=J(i);if(o&&Et(i)){let s=this.tpslPnlMap.get(o),n=this.getFormattedEstPnl(i);s!==n&&(t.push(o),this.tpslPnlMap.set(o,n));}}),t}prepareQuantityTpslNoMap(e){this.quantityTpslNoMap=Mt(e);}recalculatePnl(e,t){return this.positions=e,this.prepareTpslPnlMap(t)}clear(){this.positions=null,this.quantityTpslNoMap.clear(),this.tpslPnlMap.clear();}};var P=class P{constructor(e,t){this.instance=e,this.pendingOrderLineMap=new Map,this.pendingOrders=[],this.broker=t,this.tpslCalService=new Se;}renderPendingOrders(e){e&&(this.pendingOrders=e),this.cleanOldPendingOrders(this.pendingOrders),this.tpslCalService.prepareTpslPnlMap(this.pendingOrders),this.tpslCalService.prepareQuantityTpslNoMap(this.pendingOrders),this.pendingOrders.forEach(t=>this.renderPendingOrder(t));}updatePositions(e){let t=this.tpslCalService.recalculatePnl(e,this.pendingOrders);this.pendingOrders.filter(i=>t.includes(J(i))).forEach(i=>this.renderPendingOrder(i));}renderPendingOrder(e){let t=P.getOrderId(e);if(!t)return;let i=this.drawOrderLine(t,e);i&&this.pendingOrderLineMap.set(t,i);}cleanOldPendingOrders(e){let t=new Set(e.map(i=>P.getOrderId(i)));this.pendingOrderLineMap.forEach((i,o)=>!t.has(o)&&this.removePendingOrder(o));}removePendingOrder(e){if(e===void 0)return;let t=this.pendingOrderLineMap.get(e);t&&(this.pendingOrderLineMap.delete(e),t.remove());}getBaseOrderLine(){let e=this.broker.colorConfig;return this.instance.activeChart().createOrderLine().setCancelTooltip(orderlyI18n.i18n.t("orders.cancelOrder")).setQuantityTextColor(e.qtyTextColor).setQuantityBackgroundColor(e.chartBG).setBodyBackgroundColor(e.chartBG).setCancelButtonBackgroundColor(e.chartBG).setLineStyle(1).setBodyFont(e.font).setQuantityFont(e.font)}static getCombinationType(e){let{algo_type:t,type:i}=e;if((t==="STOP_LOSS"||t==="TAKE_PROFIT"||t==="STOP")&&i==="LIMIT")return "STOP_LIMIT";if((t==="STOP_LOSS"||t==="TAKE_PROFIT"||t==="STOP")&&i==="MARKET")return "STOP_MARKET";if(t==="BRACKET"){if(i==="LIMIT")return "BRACKET_LIMIT";if(i==="MARKET")return "BRACKET_MARKET"}return t==="TRAILING_STOP"?"TRAILING_STOP":"LIMIT"}static getText(e){let t=P.getCombinationType(e);return t==="STOP_LIMIT"||t==="STOP_MARKET"||t==="STOP_BRACKET_LIMIT"||t==="STOP_BRACKET_MARKET"?e.type==="LIMIT"?`${orderlyI18n.i18n.t("orderEntry.orderType.stopLimit")} ${orderlyUtils.commify(e.price)}`:orderlyI18n.i18n.t("orderEntry.orderType.stopMarket"):t==="TRAILING_STOP"?orderlyI18n.i18n.t("orderEntry.trailing"):orderlyI18n.i18n.t("orderEntry.orderType.limit")}static getOrderPrice(e){return e.algo_type==="TRAILING_STOP"?orderlyUtils.getTrailingStopPrice(e):e.trigger_price||e.price}getTPSLTextWithTpsl(e,t){return J(t),e}getTPSLText(e){let t=kt(e,this.tpslCalService.getQuantityTpslNoMap());return t?this.getTPSLTextWithTpsl(t,e):null}getOrderQuantity(e){if(e.algo_order_id){if(Rt(e)||Ge(e))return "100%";if(We(e)){let i=new orderlyUtils.Decimal(e.quantity).minus(e.executed??0).div(new orderlyUtils.Decimal(e.position_qty)).mul(100).todp(2).toNumber();return `${Math.min(Math.abs(i),100).toString()}%`}}return orderlyUtils.commify(new orderlyUtils.Decimal(e.quantity).toString())}drawOrderLine(e,t){let i=qe(t)?this.getTPSLText(t):P.getText(t);if(i===null)return null;let o=this.broker.colorConfig,s=this.pendingOrderLineMap.get(e)??this.getBaseOrderLine(),n=t.side==="BUY"?o.upColor:o.downColor;t.side==="BUY"?o.pnlUpColor:o.pnlDownColor;let c=P.getOrderPrice(t),l=100,u=this.getOrderQuantity(t),m=o.textColor;return s.setText(i).setCancelButtonIconColor(o.closeIcon).setCancelButtonBorderColor(n).setBodyTextColor(m).setBodyBorderColor(n).setQuantityBorderColor(n).setQuantityTextColor(n).setLineColor(n).setLineLength(l).setQuantity(u??"").setPrice(c),this.broker.mode!==3?(s.onCancel(null,()=>this.broker.cancelOrder(t)),this.applyEditOnMove(s,t)):s.setEditable(false).setCancellable(false),s}static getOrderEditKey(e){let t=this.getCombinationType(e);if(["LIMIT","BRACKET_LIMIT"].includes(t))return "price";if(t==="STOP_LIMIT"||t==="STOP_MARKET"||e.rootAlgoOrderAlgoType==="POSITIONAL_TP_SL"||e.rootAlgoOrderAlgoType==="TP_SL"||e.rootAlgoOrderAlgoType==="BRACKET"||e.rootAlgoOrderAlgoType==="STOP_BRACKET")return "trigger_price"}applyEditOnMove(e,t){let i=P.getOrderEditKey(t);i&&e.onMove(()=>{this.broker.editOrder(t,{type:i,value:`${e.getPrice()}`}).then(o=>{o.success||this.renderPendingOrder(t);}).catch(()=>this.renderPendingOrder(t));});}removeAll(){this.pendingOrderLineMap.forEach(e=>e.remove()),this.pendingOrderLineMap.clear(),this.pendingOrders=[],this.tpslCalService.clear();}};P.getOrderId=e=>{if(e!=null)return e.algo_order_id||e.order_id};var Te=P;var Ie=class r{constructor(e,t){this.instance=e,this.currentSymbol="",this.broker=t,this.positionLines={},this.lastPositions=null;}renderPositions(e){if(e===null||e.length===0){this.removePositions();return}this.lastPositions?.length!==e.length&&this.removePositions(),e[0].symbol!==this.currentSymbol&&(this.removePositions(),this.currentSymbol=e[0].symbol),e.forEach((t,i)=>this.drawPositionLine(t,i)),this.lastPositions=e;}getBasePositionLine(){return this.instance.activeChart().createPositionLine().setTooltip(orderlyI18n.i18n.t("positions.closePosition")).setQuantityBackgroundColor(this.broker.colorConfig.chartBG).setCloseButtonBackgroundColor(this.broker.colorConfig.chartBG).setBodyTextColor(this.broker.colorConfig.textColor).setQuantityTextColor(this.broker.colorConfig.qtyTextColor).setBodyFont(this.broker.colorConfig.font).setQuantityFont(this.broker.colorConfig.font).setLineLength(100).setLineStyle(1)}static getPositionQuantity(e){return orderlyUtils.commify(new orderlyUtils.Decimal(e).todp(4,orderlyUtils.Decimal.ROUND_DOWN).toString())}static getPositionPnL(e,t){let i=orderlyI18n.i18n.t("tpsl.pnl"),o=new orderlyUtils.Decimal(e).toFixed(t,orderlyUtils.Decimal.ROUND_DOWN);return new orderlyUtils.Decimal(e).eq(0)?`${i} 0`:new orderlyUtils.Decimal(e).greaterThan(0)?`${i} +${orderlyUtils.commify(o)}`:`${i} ${orderlyUtils.commify(o)}`}removePositions(){Object.keys(this.positionLines).forEach(e=>{this.positionLines[Number(e)].remove(),delete this.positionLines[Number(e)];});}drawPositionLine(e,t){let i=this.broker.colorConfig,o=e.unrealPnl>=0,s=e.balance>=0,n=i.pnlZoreColor,a=new orderlyUtils.Decimal(e.unrealPnl);a.greaterThan(0)?n=i.upColor:a.lessThan(0)&&(n=i.downColor);o?i.pnlUpColor:i.pnlDownColor;let l=s?i.upColor:i.downColor,u=new orderlyUtils.Decimal(e.open).toNumber();this.positionLines[t]=this.positionLines[t]??this.getBasePositionLine(),this.positionLines[t].setQuantity(r.getPositionQuantity(e.balance)).setPrice(u).setCloseButtonIconColor(i.closeIcon).setCloseButtonBorderColor(l).setBodyBackgroundColor(n).setQuantityTextColor(l).setBodyBorderColor(n).setLineColor(l).setQuantityBorderColor(l).setText(r.getPositionPnL(e.unrealPnl,e.unrealPnlDecimal)),this.broker.mode!==3&&this.positionLines[t].onClose(null,()=>{this.broker.closePosition(e);});}};var zt=10;var Le=class{constructor(e,t){this.interactiveMode=0;this.tpslElRemoveTimer=null;this.currentPosition=null;this.tpslOrderLine=null;this.tpslPnLVerticalLineEntityId=null;this.tpslVerticalLineTime=null;this.tpslStartCircleEntityId=null;this.tpslEndCircleEntityId=null;this.threshold=10;this.lastArgs=null;this.instance=e,this.broker=t,this.lastPositions=null,this.tpslElRemoveTimer=null,this.currentPosition=null,this.bindEvent();}bindEvent(){this.chart.crossHairMoved().subscribe(null,e=>{if(this.lastArgs=e,this.interactiveMode===2){this.clearTpslElRemoveTimer();return}let t=this.getIntersectantPosition(e);if(!(this.currentPosition&&t&&this.currentPosition.symbol===t.symbol)){if(!t){this.clearTPSLElements();return}t&&(this.clearTpslElRemoveTimer(),this.currentPosition=t,this.createTPSLTriggerButton(e));}});}clearTpslElRemoveTimer(){this.tpslElRemoveTimer&&(clearTimeout(this.tpslElRemoveTimer),this.tpslElRemoveTimer=null);}showTPSLDialog(e){let t=new orderlyUtils.Decimal(e.price).minus(this.currentPosition.open).mul(this.currentPosition?.balance??0);orderlyUi.modal.show("TPSLSimpleDialogId",{title:t.gt(0)?orderlyI18n.i18n.t("tpsl.TPOrderConfirm"):orderlyI18n.i18n.t("tpsl.SLOrderConfirm"),triggerPrice:e.price,type:t.gt(0)?"tp":"sl",symbol:this.currentPosition.symbol,onComplete:()=>{this.clearTPSLElements(),this.chart.setScrollEnabled(true),this.chart.setZoomEnabled(true),this.interactiveMode=0;},showAdvancedTPSLDialog:i=>{this.showAdvancedTPSLDialog({type:t.gt(0)?"tp":"sl",triggerPrice:e.price,qty:i.qty});}}).then(()=>{},i=>{}).finally(()=>{this.clearTPSLElements(),this.chart.setScrollEnabled(true),this.chart.setZoomEnabled(true),this.interactiveMode=0;});}showAdvancedTPSLDialog({type:e,triggerPrice:t,qty:i}){orderlyUi.modal.show("TPSLDialogId",{withTriggerPrice:true,type:e,triggerPrice:t,symbol:this.currentPosition?.symbol,qty:i,onComplete:()=>{this.clearTPSLElements(),this.chart.setScrollEnabled(true),this.chart.setZoomEnabled(true),this.interactiveMode=0;}}).then(()=>{},o=>{}).finally(()=>{this.clearTPSLElements(),this.chart.setScrollEnabled(true),this.chart.setZoomEnabled(true),this.interactiveMode=0;});}updatePositions(e){this.lastPositions=e,this.threshold=this.generateThreshold();}generateThreshold(){let e=this.chart.getPanes()[0]?.getRightPriceScales()[0];if(!e)return zt;let t=e.getVisiblePriceRange();return t?(t.to-t.from)*.02:zt}drawTPSL(e){let{price:t}=e,i=new orderlyUtils.Decimal(t).minus(this.currentPosition.open).mul(this.currentPosition?.balance??0),{tpslOrderLine:o,verticalLine:s}=this.ensureTPSLElements({price:t,pnl:i}),n=i.gt(0)?orderlyI18n.i18n.t("tpsl.tp"):orderlyI18n.i18n.t("tpsl.sl"),a=i.gt(0)?this.broker.colorConfig.upColor:this.broker.colorConfig.downColor;o?.setText(`${n} ${i.toDecimalPlaces(2).toNumber()}`).setBodyTextColor(a).setBodyBorderColor(a).setLineColor(a),this.tpslVerticalLineTime&&s?.setPoints([{price:this.currentPosition?.open,time:this.tpslVerticalLineTime},{time:this.tpslVerticalLineTime,price:t}]);}ensureTPSLElements(e){let t=this.tpslOrderLine,i;if(t||(this.tpslOrderLine=this.createTPSLOrderLine()),this.tpslPnLVerticalLineEntityId&&(i=this.chart.getShapeById(this.tpslPnLVerticalLineEntityId)),!i){if(!this.currentPosition||!this.tpslVerticalLineTime)return {};this.tpslPnLVerticalLineEntityId=this.chart.createMultipointShape([{price:this.currentPosition.open,time:this.tpslVerticalLineTime},{time:this.tpslVerticalLineTime,price:e.price}],{shape:"trend_line",lock:true,disableSave:true,disableSelection:true,disableUndo:true,zOrder:"top",overrides:{linecolor:"rgba(255,255,255, 0.2)",linewidth:1,rightEnd:1,leftEnd:1}});}return i?.setProperties({linecolor:e.pnl.gt(0)?this.broker.colorConfig.upColor:this.broker.colorConfig.downColor,linewidth:1}),{tpslOrderLine:t,verticalLine:i}}createTPSLTriggerButton(e){this.tpslOrderLine||(this.tpslOrderLine=this.createTPSLOrderLine()),this.tpslOrderLine.onMove(()=>{let t=this.tpslOrderLine?.getPrice();this.showTPSLDialog({price:t??0});}),this.tpslOrderLine.onMoving(()=>{this.interactiveMode=2;let t=this.tpslOrderLine?.getPrice();this.verticalLineTime(),this.drawTPSL({price:t??0});});}createTPSLOrderLine(){return this.chart.createOrderLine().setCancellable(false).setExtendLeft(true).setTooltip(orderlyI18n.i18n.t("tpsl.dragToSet")).setPrice(this.currentPosition.open).setLineLength(-200,"pixel").setText(orderlyI18n.i18n.t("tpsl.advanced.title")).setQuantity("").setBodyTextColor(this.broker.colorConfig.textColor).setBodyBackgroundColor(this.broker.colorConfig.chartBG).setBodyBorderColor(this.broker.colorConfig.pnlZoreColor).setQuantityBackgroundColor(this.broker.colorConfig.chartBG).setQuantityBorderColor(this.broker.colorConfig.pnlZoreColor).setQuantityTextColor(this.broker.colorConfig.qtyTextColor).setBodyFont(this.broker.colorConfig.font).setQuantityFont(this.broker.colorConfig.font).setLineStyle(3)}verticalLineTime(){let e=this.chart.getVisibleRange();this.tpslVerticalLineTime=this.getTimeAtPercentage(e.from,e.to,90);}clearTPSLElements(){this.tpslElRemoveTimer||(this.tpslElRemoveTimer=setTimeout(()=>{this.currentPosition=null,this.tpslOrderLine&&(this.tpslOrderLine.remove(),this.tpslOrderLine=null),this.tpslPnLVerticalLineEntityId&&(this.chart.removeEntity(this.tpslPnLVerticalLineEntityId),this.tpslPnLVerticalLineEntityId=null),this.tpslElRemoveTimer=null;},100));}getIntersectantPosition(e){if(!Array.isArray(this.lastPositions)||this.lastPositions.length===0)return null;let{price:t,time:i}=e,o=null;for(let s of this.lastPositions)if(s&&Math.abs(s.open-t)<this.threshold){o=s;break}return o}get chart(){return this.instance.activeChart()}getTimeAtPercentage(e,t,i){if(typeof e!="number"||typeof t!="number"||typeof i!="number"||i<0||i>100||e>t)return null;let o=t-e,s=i/100,n=o*s,a=e+n;return Math.round(a)}};var Oe=class{constructor(e,t,i){this.instance=e,this.positionLineService=new Ie(e,i),this.orderLineService=new Te(e,i),this.executionService=new _e(e,i),this.tpslService=new Le(e,i);}async renderPositions(e){await this.chartReady(),await this.onDataLoaded(),this.positionLineService.renderPositions(e),this.orderLineService.updatePositions(e),this.tpslService.updatePositions(e);}async renderPendingOrders(e){await this.chartReady(),this.orderLineService.renderPendingOrders(e);}async renderFilledOrders(e,t){await this.chartReady(),await this.onDataLoaded(),this.executionService.renderExecutions(e,t);}remove(){this.orderLineService.removeAll(),this.positionLineService.removePositions(),this.executionService.destroy();}onDataLoaded(){return this.instance.activeChart().symbolExt()?Promise.resolve():new Promise(e=>this.instance.activeChart().onDataLoaded().subscribe(null,()=>{e();},true))}chartReady(){return new Promise(e=>this.instance.onChartReady(()=>{try{this.instance.activeChart().dataReady(()=>e());}catch(t){t.toString().includes("tradingViewApi");}}))}};function Xe(r,e){let[t,i]=R.useState(),o=R.useRef(),{state:s}=orderlyHooks.useAccount(),[n]=orderlyHooks.useLocalStorage("unPnlPriceBasis","markPrice"),[{rows:a},c]=orderlyHooks.usePositionStream(r,{calcMode:n}),[l]=orderlyHooks.useOrderStream({status:orderlyTypes.OrderStatus.INCOMPLETE,symbol:r}),m=orderlyHooks.useSymbolsInfo()?.[r],y=m("quote_dp"),[g]=orderlyHooks.useOrderStream({symbol:r,status:orderlyTypes.OrderStatus.FILLED,size:500}),b=R.useRef((S,v,A,F)=>{o.current&&o.current.remove(),o.current=new Oe(S,v,A),i(o.current);}),z=R.useRef(()=>{o.current?.remove(),o.current=void 0;});return R.useEffect(()=>{if(s.status<orderlyTypes.AccountStatusEnum.EnableTrading&&s.status!==orderlyTypes.AccountStatusEnum.EnableTradingWithoutConnected){t?.renderPositions([]);return}if(!e||!e.position){t?.renderPositions([]);return}let S=(a??[]).filter(v=>v.symbol===r).map(v=>({symbol:v.symbol,open:v.average_open_price,balance:v.position_qty,closablePosition:9999,unrealPnl:v.unrealized_pnl??0,interest:0,unrealPnlDecimal:2,basePriceDecimal:4}));t?.renderPositions(S);},[t,a,r,e,s]),R.useEffect(()=>{if(!e||!e.buySell){t?.renderFilledOrders([],6);return}let S=g?.filter(v=>v.symbol===r);t?.renderFilledOrders(S??[],y??6);},[t,g,r,y,e]),R.useEffect(()=>{let S=[],v=[],A=[],F=[],B=[],U=[];if(s.status<orderlyTypes.AccountStatusEnum.EnableTrading&&s.status!==orderlyTypes.AccountStatusEnum.EnableTradingWithoutConnected){t?.renderPendingOrders([]);return}let ne=(a??[]).find(C=>C.symbol===r);l?.forEach(C=>{if(r===C.symbol){if(!C.algo_order_id)A.push(C);else if(C.algo_order_id)if(C.algo_type==="POSITIONAL_TP_SL")for(let T of C.child_orders)T.root_algo_order_algo_type=C.algo_type,T.trigger_price&&T.status!==orderlyTypes.OrderStatus.FILLED&&v.push(T);else if(C.algo_type==="TP_SL"){if(ne)for(let T of C.child_orders)T.root_algo_order_algo_type=C.algo_type,T.position_qty=ne.position_qty,T.trigger_price&&T.status!==orderlyTypes.OrderStatus.FILLED&&S.push(T);}else C.algo_type==="STOP_LOSS"||C.algo_type==="TAKE_PROFIT"?F.push(C):C.algo_type==="BRACKET"?B.push(C):C.algo_type==="TRAILING_STOP"&&C.is_activated&&C.extreme_price&&U.push(C);}}),e&&(e.positionTpsl||(v=[]),e.tpsl||(S=[]),e.limitOrders||(A=[],B=[]),e.stopOrders||(F=[]),e.trailingStop||(U=[])),t?.renderPendingOrders(S.concat(v).concat(A).concat(F).concat(B).concat(U));},[t,l,r,e,a,s.status]),[b.current,z.current]}function Wi(r){r.setBrokerConnectionAdapter=function(e){let t={subscribe:()=>{},unsubscribe:()=>{},unsubscribeAll:()=>{}};Object.defineProperty(e,"_ordersCache",{get:function(){return {start:()=>{},stop:()=>{},update:()=>{},partialUpdate:()=>{},fullUpdate:()=>{},getObjects:async()=>[],updateDelegate:t,partialUpdateDelegate:t}},set:()=>{}}),e._waitForOrderModification=async()=>true,this._adapter=e;};}function Qi(r,e){r.onChartReady(()=>{e.silentOrdersPlacement().subscribe(t=>{t||(e.silentOrdersPlacement().setValue(true),r&&(r._iFrame.contentDocument.querySelector(".wrapper-3X2QgaDd").className="wrapper-3X2QgaDd highButtons-3X2QgaDd"),e.sellBuyButtonsVisibility()?.setValue(false));});});}function et(r,e){Wi(e),Qi(r,e);}var Yt=(r,e)=>new Promise(t=>{let i=r.querySelector(e);i&&t(i);let o=new MutationObserver(()=>{let s=r.querySelector(e);s&&(t(s),o.disconnect());});o.observe(r,{childList:true,subtree:true});});var we=class{constructor({iframeDocument:e}){this.iframeDocument=e;}defaultHack(){this.showFavoriteStarByDefault();}showFavoriteStarByDefault(){Yt(this.iframeDocument,".dropdown-2R6OKuTS").then(()=>{this.iframeDocument.querySelectorAll(".toolbox-2IihgTnv.showOnHover-2IihgTnv").forEach(t=>{t.style.opacity="1";});});}};var $i=r=>{let e=["header_symbol_search","volume_force_overlay","trading_account_manager","drawing_templates","open_account_manager","right_toolbar","support_multicharts","header_layouttoggle","order_panel","order_info","trading_notifications","display_market_status","broker_button","add_to_watchlist","chart_crosshair_menu","header_fullscreen_button","header_widget"];return r===3&&(e=[...e,"left_toolbar","timeframes_toolbar","go_to_date","timezone_menu","create_volume_indicator_by_default","buy_sell_buttons"]),r===0?e=[...e,"header_widget","left_toolbar","timeframes_toolbar","buy_sell_buttons"]:r===1&&(e=[...e,"left_toolbar","timeframes_toolbar","buy_sell_buttons"]),e};function tt(r,e){return {...r,disabled_features:$i(e),enabled_features:["hide_left_toolbar_by_default","order_panel_close_button","iframe_loading_compatibility_mode"],auto_save_delay:.1,broker_config:{configFlags:{supportStopLimitOrders:true,supportReversePosition:false}}}}var rt=r=>`${r}_adapter`,Re={"trading.chart.proterty":JSON.stringify({showSellBuyButtons:0,noConfirmEnabled:1,qweqrq:0,showPricesWithZeroVolume:1,showSpread:1,orderExecutedSoundParams:'{"enabled":0,"name":"alert/alarm_clock"}'}),"hint.startFocusedZoom":"true"},D=new Map;var Zi=(r,e,t)=>{let i=rt(r);try{let o=e,s=o?JSON.parse(o):void 0,n=t?JSON.parse(t):Re;return o&&D.set(r,o),t&&D.set(i,t),{savedData:s,adapterSetting:n}}catch{}return {savedData:void 0,adapterSetting:Re}},Jt=async(r,e)=>{let t=rt(r),i=localStorage.getItem(r)||"",o=localStorage.getItem(t)||"";try{if(D.has(r)&&D.has(t))return {savedData:JSON.parse(D.get(r)),adapterSetting:JSON.parse(D.get(t))}}catch{}return Zi(r,i,o)},Xt=async(r,e,t)=>{e&&(localStorage.setItem(r,e),D.set(r,e));},er=async(r,e,t)=>{let i=rt(r);e&&(localStorage.setItem(i,e),D.set(i,e));};var tr=(r,e)=>{let t=null,i=(...o)=>{t&&window.clearTimeout(t),t=setTimeout(()=>{r(...o);},e);};return i.cancel=()=>{t&&window.clearTimeout(t),t=null;},i},zi="chartProp_default",rr=300,Ee=class{constructor(e){this._instance=null;this._onClick=null;this._datafeed=null;this._chartKey=zi;this._adapterSetting=Re;this._savedData=null;this._isLoggedIn=false;this.debounceSaveChart=tr(()=>{try{this._instance?.save(e=>{Object.is(this._savedData,e)||(this._savedData=e,Xt(this._chartKey,JSON.stringify(e),this._isLoggedIn));});}catch{}},rr*2);this.debounceSaveChartAdapterSetting=tr(()=>{er(this._chartKey,JSON.stringify(this._adapterSetting),this._isLoggedIn);},rr);this._create(e);}remove(){this.unsubscribeClick(),this._datafeed?.remove(),this._broker?.remove(),this._instance?.remove(),this.debounceSaveChart.cancel(),this.debounceSaveChartAdapterSetting.cancel();}updateOverrides(e){this.instance&&this.instance.applyOverrides(e);}setSymbol(e,t,i){try{this._instance?.onChartReady(()=>{let o=t??this._instance?.symbolInterval()?.interval;o||(o=1),this._instance?.setSymbol(e,o,i);});}catch{}}executeActionById(e){try{this._instance?.onChartReady(()=>{this._instance?.activeChart().executeActionById(e);});}catch{}}changeLineType(e){try{this._instance?.onChartReady(()=>{this._instance?.activeChart().setChartType(e);});}catch{}}subscribeClick(e){this._onClick=e,this._instance?.onChartReady(()=>{this._instance?._iFrame.contentDocument?.addEventListener("click",this._onClick);});}unsubscribeClick(){this._instance?._iFrame.contentDocument?.removeEventListener("click",this._onClick);}get instance(){return this._instance}chartHack(){this._instance?.onChartReady(()=>{let e=this._instance._iFrame.contentWindow.document;new we({iframeDocument:e}).defaultHack();});}subscribeAutoSave(){this._instance?.onChartReady(()=>{this._instance?.subscribe("onAutoSaveNeeded",()=>{this.debounceSaveChart();}),this._instance?.activeChart().onVisibleRangeChanged().subscribe(null,()=>{this.debounceSaveChart();});});}async _create({options:e,chartKey:t,mode:i,onClick:o}){let s=e.getBroker,n={fullscreen:e.fullscreen??true,autosize:e.autosize??false,timezone:e.timezone,symbol:e.symbol,library_path:e.libraryPath,interval:e.interval??"1",custom_css_url:e.customCssUrl,custom_font_family:e.customFontFamily,datafeed:e.datafeed,studies_overrides:e.studiesOverrides,locale:e.locale,theme:e.theme,loading_screen:e.loadingScreen,overrides:e.overrides,container:e.container,favorites:{intervals:["1","3","5","15","30","60","240","1D","1W","1M"],chartTypes:["Area","Line"]},broker_factory:s?l=>(this._broker&&this._broker.remove(),this._broker=s(this._instance,l),this._broker):void 0};this._datafeed=e.datafeed,t&&(this._chartKey=t);let{savedData:a,adapterSetting:c}=await Jt(this._chartKey,this._isLoggedIn);this._adapterSetting=c,this._savedData=a,this._instance=new TradingView.widget({...tt(n,i),interval:c["chart.lastUsedTimeBasedResolution"]??n.interval,saved_data:a,settings_adapter:{initialSettings:c,setValue:(l,u)=>{this._adapterSetting={...this._adapterSetting,[l]:u},this.debounceSaveChartAdapterSetting();},removeValue:()=>{}}}),this._instance.onChartReady(()=>{e.symbol&&this._instance?.activeChart().symbol()!==I(e.symbol)&&this.setSymbol(e.symbol);}),this.subscribeAutoSave(),this.subscribeClick(o),this.chartHack();}};var ao="SDK_Tradingview",lo="SDK_Moblie_Tradingview",co=r=>r?lo:ao,uo=r=>r==="id"?"id_ID":r;function st(r){let{scriptSRC:e,libraryPath:t,customCssUrl:i,overrides:o,studiesOverrides:s,symbol:n,theme:a,loadingScreen:c,mode:l,colorConfig:u,locale:m=uo,classNames:y}=r,g=orderlyI18n.useLocaleCode(),b=R.useRef(null),z=orderlyHooks.useConfig("apiBaseUrl"),{state:S}=orderlyHooks.useAccount(),[v,A]=R.useState(orderlyTypes.OrderSide.SELL),F=orderlyHooks.useSymbolsInfo(),[B,U]=orderlyHooks.useLocalStorage(orderlyTypes.TradingviewFullscreenKey,false),{onSubmit:ne,submitting:C}=orderlyHooks.useOrderEntry_deprecated({symbol:n??"",side:v,order_type:orderlyTypes.OrderType.MARKET},{watchOrderbook:true}),[T,Vr]=R.useState(()=>{let d=localStorage.getItem(N.displayControlSetting);return d?JSON.parse(d):{position:true,buySell:true,limitOrders:true,stopOrders:true,tpsl:true,positionTpsl:true,trailingStop:true}}),[yt,Nr]=R.useState(()=>{let d=localStorage.getItem(N.interval);return d||"15"}),[Hr,Fr]=R.useState(()=>{let d=localStorage.getItem(N.lineType);return d||"1"}),De=orderlyHooks.useMediaQuery(orderlyTypes.MEDIA_TABLET),Ae=R.useMemo(()=>Object.assign({},Tt,u??{}),[u]),Ur=R.useMemo(()=>typeof c=="object"?c:{backgroundColor:Ne},[c]),se=orderlyHooks.useWS(),[j,Kr]=R.useState(false),qr=d=>{let ae=F[n];if(!ae)return;let le=new orderlyUtils.Decimal(d.balance).greaterThan(0)?orderlyTypes.OrderSide.SELL:orderlyTypes.OrderSide.BUY,_t={order_quantity:new orderlyUtils.Decimal(d.balance).abs().toNumber(),symbol:n,order_type:orderlyTypes.OrderType.MARKET,side:le,reduce_only:true};A(le),orderlyUi.modal.show("MarketCloseConfirmID",{base:ae("base"),quantity:d.balance,onConfirm:async()=>ne(_t).catch(Y=>{typeof Y=="string"?orderlyUi.toast.error(Y):orderlyUi.toast.error(Y.message);}),submitting:C});},E=R.useRef(null),Ct=R.useMemo(()=>!(S.status<orderlyTypes.AccountStatusEnum.EnableTrading&&S.status!==orderlyTypes.AccountStatusEnum.EnableTradingWithoutConnected),[S]),vt=Vt({closeConfirm:qr,colorConfig:Ae,onToast:orderlyUi.toast,symbol:n??"",mode:l}),[Gr,Wr]=Xe(n,T),Qr=()=>{U(!B),r.onFullScreenChange?.(!B);},$r=d=>{b.current&&(localStorage.setItem(N.interval,d),Nr(d),b.current?.setSymbol(n??"",d));},Zr=d=>{b.current&&(localStorage.setItem(N.lineType,d),Fr(d),b.current?.changeLineType(Number(d)));},zr=d=>{localStorage.setItem(N.displayControlSetting,JSON.stringify(d)),Vr(d);},jr=()=>{b.current&&b.current.executeActionById("chartProperties");},Yr=()=>{b.current&&b.current.executeActionById("insertIndicator");};return R.useEffect(()=>{if(e&&E.current&&!j){let d=document.createElement("script");d.setAttribute("data-nscript","afterInteractive"),d.src=e,d.async=true,d.type="text/javascript",d.onload=()=>{Kr(true);},d.onerror=()=>{},E.current.appendChild(d);}},[E,j,e]),R.useEffect(()=>{if(!n||!j||!e)return;let d=It(Ae,De),ae=o?Object.assign({},d.overrides,o):d.overrides,le=s?Object.assign({},d.studiesOverrides,s):d.studiesOverrides;if(E.current){let Y={options:{fullscreen:false,autosize:true,symbol:ue(n),locale:typeof m=="function"?m(g):m,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,container:E.current,libraryPath:t,customCssUrl:i,interval:yt??"1",theme:a??"dark",loadingScreen:Ur??{},overrides:ae,studiesOverrides:le,datafeed:new ye(z,se),contextMenu:{items_processor:async Be=>Be},getBroker:(Be,St)=>(et(Be,St),Lt(St,vt))},chartKey:co(De),mode:l,onClick:()=>{}};b.current=new Ee(Y);}return ()=>{b.current?.remove();}},[j,De,l,b,E,j,e,Ae,m,g]),R.useEffect(()=>{se.on("status:change",d=>{!d.isPrivate&&d.isReconnect&&typeof window.onResetCacheNeededCallback=="function"&&(window.onResetCacheNeededCallback(),b.current?.instance&&b.current?.instance.activeChart()?.resetData());},"tradingview");},[se]),R.useEffect(()=>(b.current&&b.current?.instance&&b.current?.instance?.onChartReady(()=>{Ct&&b.current?.instance&&Gr(b.current.instance,void 0,vt,E.current);}),()=>{Wr();}),[b.current,Ct]),R.useEffect(()=>{if(!n||!b.current)return;b.current?.setSymbol(n);let d=new G(se);return d.subscribeSymbol(n),()=>{d.unsubscribeKline(n);}},[n]),{tradingViewScriptSrc:e,chartRef:E,changeDisplaySetting:zr,displayControlState:T,interval:yt,changeInterval:$r,lineType:Hr,changeLineType:Zr,openChartSetting:jr,openChartIndicators:Yr,symbol:n,onFullScreenChange:Qr,classNames:y,fullscreen:B}}Z();var yr=r=>{let{url:e,children:t}=r;return jsxRuntime.jsx("span",{onClick:()=>window.open(e),className:"oui-cursor-pointer oui-px-0.5 oui-text-primary-light oui-underline",children:t})},Cr=()=>{let{t:r}=orderlyI18n.useTranslation();return jsxRuntime.jsx("div",{className:"oui-absolute oui-inset-0 oui-z-0 oui-flex oui-flex-col oui-items-center oui-justify-start oui-p-2 oui-text-base-contrast-80 md:oui-justify-center md:oui-p-10",children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"oui-mb-6 oui-text-xs",children:r("tradingView.noScriptSrc")}),jsxRuntime.jsx("p",{className:"oui-mb-3 oui-pl-0 oui-text-2xs oui-text-base-contrast-54 md:oui-pl-2 md:oui-text-base md:oui-text-base-contrast-80",children:jsxRuntime.jsx(orderlyI18n.Trans,{i18nKey:"tradingView.noScriptSrc.1",components:[jsxRuntime.jsx(yr,{url:"https://www.tradingview.com/advanced-charts"},"tradingview-advanced-charts")]})}),jsxRuntime.jsx("p",{className:"oui-pl-0 oui-text-2xs oui-text-base-contrast-54 md:oui-pl-2 md:oui-text-base md:oui-text-base-contrast-80",children:jsxRuntime.jsx(orderlyI18n.Trans,{i18nKey:"tradingView.noScriptSrc.2",components:[jsxRuntime.jsx(yr,{url:"https://orderly.network/docs/sdks/react/components/trading#tradingviewconfig"},"tradingview-config")]})})]})})};var go=r=>jsxRuntime.jsx("div",{className:"top-toolbar oui-flex oui-h-[44px] oui-justify-between md:oui-justify-start oui-items-center oui-p-2 md:oui-px-3 md:oui-pt-3 md:oui-pb-[14px]",children:r.children}),vr=go;var ln=R__default.default.lazy(()=>Promise.resolve().then(()=>(Or(),Lr))),Br=R__default.default.lazy(()=>Promise.resolve().then(()=>(Rr(),wr)).then(r=>({default:r.TimeInterval}))),cn=R__default.default.lazy(()=>Promise.resolve().then(()=>(ht(),gt)).then(r=>({default:r.MobileDisplayControl}))),un=R__default.default.lazy(()=>Promise.resolve().then(()=>(ht(),gt)).then(r=>({default:r.DesktopDisplayControl}))),ft=({children:r,onClick:e})=>jsxRuntime.jsx(orderlyUi.Box,{onClick:e,className:"oui-cursor-pointer oui-w-[18px] oui-h-[18px] oui-text-base-contrast-36 hover:oui-text-base-contrast-80",children:r}),dn=r=>jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"currentColor",...r,children:jsxRuntime.jsx("path",{d:"M15.0008 2.24304C14.8088 2.24304 14.6085 2.30755 14.4615 2.4538L11.2508 5.66455V3.74304H9.75079V7.49304C9.75079 7.90704 10.0868 8.24304 10.5008 8.24304H14.2508V6.74304H12.3285L15.54 3.53229C15.8325 3.23904 15.8325 2.74705 15.54 2.4538C15.393 2.30755 15.1928 2.24304 15.0008 2.24304ZM3.7508 9.74303V11.243H5.67231L2.46156 14.4538C2.16906 14.747 2.16906 15.239 2.46156 15.5323C2.75481 15.8248 3.2468 15.8248 3.54005 15.5323L6.7508 12.3215V14.243H8.25079V10.493C8.25079 10.079 7.9148 9.74303 7.5008 9.74303H3.7508Z"})}),pn=r=>jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"currentColor",...r,children:jsxRuntime.jsx("path",{d:"M7.49219 9.74304C7.30026 9.74304 7.09964 9.80755 6.95309 9.9538L3.74219 13.1646V11.243H2.24219V14.993C2.24219 15.407 2.57796 15.743 2.99219 15.743H6.74219V14.243H4.82031L8.03121 11.0323C8.32416 10.739 8.32416 10.247 8.03121 9.9538C7.88481 9.80755 7.68404 9.74304 7.49219 9.74304ZM11.2509 2.24304V3.74304H13.1728L9.96186 6.9538C9.66899 7.24705 9.66899 7.73904 9.96186 8.03229C10.2547 8.32479 10.7471 8.32479 11.04 8.03229L14.2509 4.82153V6.74304H15.7509V2.99304C15.7509 2.57904 15.4151 2.24304 15.0009 2.24304H11.2509Z"})}),bt=R.forwardRef((r,e)=>{let{chartRef:t,interval:i,changeDisplaySetting:o,displayControlState:s,tradingViewScriptSrc:n,changeInterval:a,lineType:c,changeLineType:l,openChartSetting:u,openChartIndicators:m,onFullScreenChange:y}=r,g=orderlyHooks.useMediaQuery(orderlyTypes.MEDIA_TABLET);return jsxRuntime.jsx("div",{ref:e,className:orderlyUi.cn("oui-relative oui-size-full",r.classNames?.root),children:n?jsxRuntime.jsxs("div",{className:orderlyUi.cn("oui-absolute oui-inset-0 oui-z-[1] oui-flex oui-flex-col",r.classNames?.content),children:[jsxRuntime.jsx(vr,{children:g?jsxRuntime.jsxs(orderlyUi.Flex,{gapX:2,width:"100%",justify:"between",className:"oui-hide-scrollbar oui-overflow-x-scroll",children:[jsxRuntime.jsx(R__default.default.Suspense,{fallback:null,children:jsxRuntime.jsx(Br,{interval:i??"15",changeInterval:a})}),jsxRuntime.jsx(ft,{onClick:m,children:jsxRuntime.jsx(at,{})}),jsxRuntime.jsx(R__default.default.Suspense,{fallback:null,children:jsxRuntime.jsx(cn,{displayControlState:s,changeDisplayControlState:o})})]}):jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",itemAlign:"center",width:"100%",children:[jsxRuntime.jsxs(orderlyUi.Flex,{children:[jsxRuntime.jsx(R__default.default.Suspense,{fallback:null,children:jsxRuntime.jsx(Br,{interval:i??"1",changeInterval:a})}),jsxRuntime.jsx(orderlyUi.Divider,{direction:"vertical",className:"oui-h-4",mx:2,intensity:8}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"start",itemAlign:"center",gap:2,children:[jsxRuntime.jsx(R__default.default.Suspense,{fallback:null,children:jsxRuntime.jsx(un,{displayControlState:s,changeDisplayControlState:o})}),jsxRuntime.jsx(ft,{onClick:m,children:jsxRuntime.jsx(at,{})}),jsxRuntime.jsx(R__default.default.Suspense,{fallback:null,children:jsxRuntime.jsx(ln,{lineType:c,changeLineType:l})}),jsxRuntime.jsx(ft,{onClick:u,children:jsxRuntime.jsx(ar,{})})]})]}),jsxRuntime.jsx(orderlyUi.Flex,{children:r.fullscreen?jsxRuntime.jsx(dn,{className:"oui-text-base-contrast-54 hover:oui-text-base-contrast oui-cursor-pointer",onClick:y}):jsxRuntime.jsx(pn,{className:"oui-text-base-contrast-54 hover:oui-text-base-contrast oui-cursor-pointer",onClick:y})})]})}),jsxRuntime.jsx("div",{ref:t,className:"oui-size-full oui-overflow-hidden"})]}):jsxRuntime.jsx(Cr,{})})});var gn=R.forwardRef((r,e)=>{let t=st(r);return jsxRuntime.jsx(bt,{...t,ref:e})});
17
+
18
+ exports.TradingviewUI = bt;
19
+ exports.TradingviewWidget = gn;
20
+ exports.useTradingviewScript = st;
21
+ //# sourceMappingURL=out.js.map
22
+ //# sourceMappingURL=index.js.map