diff --git a/changelog.md b/changelog.md index bee53982..9da1d032 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,43 @@ +## Version 26.002 + +*Date: Mon Sep 18 2023* + +**Improvements** + +- **IOrderLineAdapter and IPositionLineAdapter now support positioning with pixel units.** The +[setLineLength](https://www.tradingview.com/charting-library-docs/latest/api/interfaces/Charting_Library.IOrderLineAdapter#getlinelength) +method in the IOrderLineAdapter (returned by +[createOrderLine](https://www.tradingview.com/charting-library-docs/latest/api/interfaces/Charting_Library.IChartWidgetApi#createorderline)) +and IPositionLineAdapter +([createPositionLine](https://www.tradingview.com/charting-library-docs/latest/api/interfaces/Charting_Library.IChartWidgetApi#createpositionline)) +interfaces now support setting the unit to `'pixel'`. + - Additionally, when using pixel unit, you can specify a negative number to + position from the left edge of the chart instead. +- **Added keyboard navigation.** Keyboard navigation (activated via alt/opt + z keyboard shortcut) and many other accessability improvements have been added to the library. + - A featureset [accessibility](https://www.tradingview.com/charting-library-docs/latest/customization/Featuresets#accessibility) (on by default) has been added to control this behaviour. +- **Menu name is provided to items_processor (context menu API).** [items_processor](https://www.tradingview.com/charting-library-docs/latest/api/interfaces/Charting_Library.ContextMenuOptions#items_processor) within the [context_menu](https://www.tradingview.com/charting-library-docs/latest/api/interfaces/Charting_Library.ChartingLibraryWidgetOptions#context_menu) API now includes details about the name of menu, and the ids of the related item (such as the series, drawing, study, order, or position). +- **Support more kinds of extended sessions.** The library now supports specifying only one of the postmarket or premarket sessions without the other. + +**Bug Fixes** + +- **On mobile devices, fixed an issue for when scrolling the pricescale with one finger while another one was holding the crosshair.** +- **Fixed an issue where it wasn't possible to set the background colour of a candle to transparent..** +- **52 Week High/Low indicator compatibility with empty supported_resolutions array.** Fixes [#7884](https://github.com/tradingview/charting_library/issues/7884) issue. +- **Fixed an issue where any added indicator on the chart couldn't be undone.** +- **Fixed issue with locking visible time range while resizing chart.** When resizing the chart window with percentage right margin, and the `lock_visible_time_range_on_resize` featureset enabled then the visible range wasn't locked correctly. +- **SuperTrend Indicator Starting Point.** The SuperTrend would previously start drawing from zero for the first bar, instead of only drawing the indicator after the initial length (defined in the indicator's inputs) when all the possible data for a symbol has been loaded. +- **Changing the LineStyle for a position is again available.** +- **Styles tab for Pivot Point Standard indicator.** Resolved an issue where the style tab for the Pivot Point Standard indicator would not function correctly when the type option was set to 'Floor'. + +**Other** + +- **Custom Translation Function.** The following changes have been made to the [custom_translate_function](https://www.tradingview.com/charting-library-docs/latest/api/interfaces/Charting_Library.ChartingLibraryWidgetOptions#custom_translate_function) + - The interface name for the options has changed from `TranslateOptions` to `CustomTranslateOptions`. + - The `plural` field in `CustomTranslateOptions` can now be either a single string, or an array of strings. + - A third boolean argument is now provided. When this is true then the key provided is already translated. ## Version 26.001 @@ -40,7 +77,6 @@ **New Features** -- **Adding more layouts to Trading Platform.** Users can display up to 16 charts on Trading Platform. (`Trading Platform Only`) - **In bottom toolbar, tooltip text for date ranges has changed.** Hovering over the time frame buttons will provide more details to understand how chart is constructed. - **Add setting for visibility of A (auto) and L (log) scale buttons.** In Chart settings, Scale tab, a new setting has been introduced to enable shortcuts for Auto & Logarithmic modes. - **Bug in compare data displayed in Data window.** There was an issue where OHLC values would only be displayed in the data window widget when using the cross hair selection instead of displaying the data from the latest available bar if nothing was selected. Fixes [#7769](https://github.com/tradingview/charting_library/issues/7769) diff --git a/charting_library/bundles/1564.94d55d014a317059a934.js b/charting_library/bundles/1564.5d23a32481002f127c65.js similarity index 99% rename from charting_library/bundles/1564.94d55d014a317059a934.js rename to charting_library/bundles/1564.5d23a32481002f127c65.js index fa832032..0424a15c 100644 --- a/charting_library/bundles/1564.94d55d014a317059a934.js +++ b/charting_library/bundles/1564.5d23a32481002f127c65.js @@ -20,7 +20,7 @@ r.default)(e))===u||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0 ;if("function"!=typeof e)throw new TypeError("Expected a function");return(0,u.default)(n)&&(o="leading"in n?!!n.leading:o,d="trailing"in n?!!n.trailing:d),(0,r.default)(e,t,{leading:o,maxWait:t,trailing:d})}},68877:(e,t,n)=>{"use strict";n.d(t,{default:()=>c});var r=n(98279),u=n(8875),o=/^\s+|\s+$/g,d=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,a=/^0o[0-7]+$/i,s=parseInt;const c=function(e){if("number"==typeof e)return e;if((0,u.default)(e))return NaN;if((0,r.default)(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=(0,r.default)(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(o,"");var n=i.test(e);return n||a.test(e)?s(e.slice(2),n?2:8):d.test(e)?NaN:+e}},15736:(e,t,n)=>{"use strict";n.d(t,{default:()=>c});var r=n(23151);const u=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0};var o=n(80838);const d=function(e,t,n){var r=-1,u=e.length;t<0&&(t=-t>u?0:u+t),(n=n>u?u:n)<0&&(n+=u),u=t>n?0:n-t>>>0,t>>>=0;for(var o=Array(u);++r{"use strict";var n,r=!("undefined"==typeof window||!window.document||!window.document.createElement);function u(){if(n)return n;if(!r||!window.document.body)return"indeterminate";var e=window.document.createElement("div");return e.appendChild(document.createTextNode("ABCD")),e.dir="rtl",e.style.fontSize="14px",e.style.width="4px",e.style.height="1px",e.style.position="absolute",e.style.top="-1000px",e.style.overflow="scroll",document.body.appendChild(e),n="reverse",e.scrollLeft>0?n="default":(e.scrollLeft=1,0===e.scrollLeft&&(n="negative")),document.body.removeChild(e),n}t.detectScrollType=u,t.getNormalizedScrollLeft=function(e,t){var n=e.scrollLeft;if("rtl"!==t)return n;var r=u();if("indeterminate"===r)return Number.NaN;switch(r){case"negative":return e.scrollWidth-e.clientWidth+n;case"reverse":return e.scrollWidth-e.clientWidth-n}return n}},32563:(e,t,n)=>{"use strict";n.d(t,{mobiletouch:()=>u,setClasses:()=>d,touch:()=>o});var r=n(5325);const u=r.mobiletouch,o=r.touch;function d(){document.documentElement.classList.add(r.touch?"feature-touch":"feature-no-touch",r.mobiletouch?"feature-mobiletouch":"feature-no-mobiletouch")}},49483:(e,t,n)=>{"use strict";n.r(t),n.d(t,{CheckMobile:()=>f,appVersion:()=>c,checkPageType:()=>h,className:()=>m,desktopAppVersion:()=>s,isChrome:()=>p,isDesktopApp:()=>a,isEdge:()=>v,isFF:()=>b,isLinux:()=>i,isMac:()=>o,isSafari:()=>g,isWindows:()=>d,onGoPro:()=>y,onMainPage:()=>w,onWidget:()=>l,supportTouch:()=>_});var r=n(5325);const u=window.TradingView=window.TradingView||{};function o(){return r.isMac}function d(){return r.isWindows}function i(){return r.isLinux}function a(){return/TVDesktop/i.test(navigator.userAgent)}function s(){const e=navigator.userAgent.match(/TVDesktop\/([^\s]+)/);return e&&e[1]}function c(){const e=navigator.userAgent.match(/TradingView\/([^\s]+)/) ;return e&&e[1]}const f={Android:()=>r.isAndroid,BlackBerry:()=>r.isBlackBerry,iOS:()=>r.isIOS,Opera:()=>r.isOperaMini,isIPad:()=>r.isIPad,any:()=>r.isAnyMobile};function l(){const e=["^widgetembed/?$","^cmewidgetembed/?$","^([0-9a-zA-Z-]+)/widgetembed/?$","^([0-9a-zA-Z-]+)/widgetstatic/?$","^([0-9a-zA-Z-]+)?/?mediumwidgetembed/?$","^twitter-chart/?$","^embed(-static)?/([0-9a-zA-Z]{8})/?$","^widgetpopup/?$","^extension/?$","^chatwidgetembed/?$","^ideaswidgetembed/?$","^ideas-widget/?$","^view-idea-widget/([0-9a-zA-Z]{8})/?$","^idea-popup/?$","^hotlistswidgetembed/?$","^([0-9a-zA-Z-]+)/hotlistswidgetembed/?$","^marketoverviewwidgetembed/?$","^([0-9a-zA-Z-]+)/marketoverviewwidgetembed/?$","^eventswidgetembed/?$","^tickerswidgetembed/?$","^forexcrossrateswidgetembed/?$","^forexheatmapwidgetembed/?$","^marketquoteswidgetembed/?$","^screenerwidget/?$","^cryptomktscreenerwidget/?$","^([0-9a-zA-Z-]+)/cryptomktscreenerwidget/?$","^([0-9a-zA-Z-]+)/marketquoteswidgetembed/?$","^technical-analysis-widget-embed/$","^singlequotewidgetembed/?$","^([0-9a-zA-Z-]+)/singlequotewidgetembed/?$","^embed-widget/([0-9a-zA-Z-]+)/(([0-9a-zA-Z-]+)/)?$"],t=window.location.pathname.replace(/^\//,"");let n;for(let r=e.length-1;r>=0;r--)if(n=new RegExp(e[r]),n.test(t))return!0;return!1}function _(){return r.mobiletouch||r.touch||r.isAnyMobile}function h(e){return new URLSearchParams(window.location.search).get("page_type")===e}u.isMobile=f,u.onWidget=l;const p=r.isChrome,b=r.isFF,v=r.isEdge,g=r.isSafari;function m(e){for(const[t,n]of Object.entries(u))if(n===e)return t;return null}function y(){return"/gopro/"===window.location.pathname}function w(){return"/"===window.location.pathname}u.className=m},28865:(e,t,n)=>{"use strict";n.d(t,{getIsoLanguageCodeFromLanguage:()=>u});const r={ar_AE:"ar",br:"pt",de_DE:"de",ca_ES:"ca",he_IL:"he",id_ID:"id",in:"en",kr:"ko",ms_MY:"ms",sv_SE:"sv",th_TH:"th",uk:"en",vi_VN:"vi",zh_CN:"zh-Hans",zh_TW:"zh-Hant",zh:"zh-Hans"};function u(e){return r[e]||e}},87795:e=>{"use strict";const t=55296,n=127995,r=127999,u=[776,2359,2359,2367,2367,2984,3007,3021,3633,3635,3648,3657,4352,4449,4520];function o(e){if("string"!=typeof e)throw new Error("string cannot be undefined or null");const t=[];let n=0,r=0;for(;n=t&&e<=n}e.exports=o,e.exports.substr=function(e,t,n){ const r=o(e);if(void 0===t)return e;if(t>=r.length)return"";const u=r.length-t;let d=t+(void 0===n?u:n);return d>t+u&&(d=void 0),r.slice(t,d).join("")}},14483:(e,t,n)=>{"use strict";n.r(t),n.d(t,{disable:()=>f,enable:()=>c,enabled:()=>a,getAllFeatures:()=>l,setEnabled:()=>s}) -;const r=JSON.parse('{"14851":{},"custom_items_in_context_menu":{},"countdown":{},"symbol_search_parser_mixin":{},"pay_attention_to_ticker_not_symbol":{},"graying_disabled_tools_enabled":{},"update_study_formatter_on_symbol_resolve":{},"constraint_dialogs_movement":{},"phone_verification":{},"show_trading_notifications_history":{},"show_interval_dialog_on_key_press":{},"header_interval_dialog_button":{"subsets":["show_interval_dialog_on_key_press"]},"header_fullscreen_button":{},"header_symbol_search":{},"symbol_search_hot_key":{},"header_resolutions":{"subsets":["header_interval_dialog_button"]},"header_chart_type":{},"header_settings":{},"header_indicators":{},"header_compare":{},"header_undo_redo":{},"header_screenshot":{},"header_saveload":{},"study_on_study":{},"scales_date_format":{},"scales_time_hours_format":{},"header_widget":{"subsets":["header_widget_dom_node","header_symbol_search","header_resolutions","header_chart_type","header_settings","header_indicators","header_compare","header_undo_redo","header_fullscreen_button","compare_symbol","header_screenshot"]},"legend_widget":{},"compare_symbol":{"subsets":["header_compare"]},"property_pages":{"subsets":["show_chart_property_page","chart_property_page"]},"show_chart_property_page":{},"chart_property_page":{"subsets":["chart_property_page_scales","chart_property_page_trading","chart_property_page_right_margin_editor"]},"left_toolbar":{},"right_toolbar":{},"hide_left_toolbar_by_default":{},"control_bar":{},"widget_logo":{},"timeframes_toolbar":{},"edit_buttons_in_legend":{"subsets":["show_hide_button_in_legend","format_button_in_legend","study_buttons_in_legend","delete_button_in_legend"]},"show_hide_button_in_legend":{},"object_tree_legend_mode":{},"format_button_in_legend":{},"study_buttons_in_legend":{},"delete_button_in_legend":{},"broker_button":{},"buy_sell_buttons":{"subsets":["broker_button"]},"pane_context_menu":{},"scales_context_menu":{},"legend_context_menu":{},"context_menus":{"subsets":["pane_context_menu","scales_context_menu","legend_context_menu","objects_tree_context_menu"]},"items_favoriting":{},"save_chart_properties_to_local_storage":{},"use_localstorage_for_settings":{"subsets":["items_favoriting","save_chart_properties_to_local_storage"]},"handle_scale":{"subsets":["mouse_wheel_scale","pinch_scale","axis_pressed_mouse_move_scale"]},"handle_scroll":{"subsets":["mouse_wheel_scroll","pressed_mouse_move_scroll","horz_touch_drag_scroll","vert_touch_drag_scroll"]},"plain_studymarket":{},"disable_resolution_rebuild":{},"border_around_the_chart":{},"charting_library_debug_mode":{},"saveload_requires_authentication":{},"saveload_storage_customization":{},"volume_force_overlay":{},"create_volume_indicator_by_default":{},"create_volume_indicator_by_default_once":{},"saved_charts_count_restriction":{},"lean_chart_load":{},"stop_study_on_restart":{},"star_some_intervals_by_default":{},"move_logo_to_main_pane":{},"show_animated_logo":{},"link_to_tradingview":{},"logo_without_link":{},"logo_always_maximized":{},"right_bar_stays_on_scroll":{},"chart_content_overrides_by_defaults":{},"snapshot_trading_drawings":{},"allow_supported_resolutions_set_only":{},"widgetbar_tabs":{"subsets":["right_toolbar"]},"show_object_tree":{"subsets":["right_toolbar"]},"dom_widget":{"subsets":["right_toolbar"]},"collapsible_header":{},"study_templates":{},"side_toolbar_in_fullscreen_mode":{},"header_in_fullscreen_mode":{},"remove_library_container_border":{},"whotrades_auth_only":{},"support_multicharts":{},"display_market_status":{},"display_data_mode":{},"datasource_copypaste":{},"drawing_templates":{"subsets":["linetoolpropertieswidget_template_button"]},"expand_symbolsearch_items":{},"symbol_search_three_columns_exchanges":{},"symbol_search_flags":{},"symbol_search_limited_exchanges":{},"bugreport_button":{"subsets":["right_toolbar"]},"footer_publish_idea_button":{},"text_notes":{},"show_source_code":{},"symbol_info":{},"no_bars_status":{},"clear_bars_on_series_error":{},"hide_loading_screen_on_series_error":{},"seconds_resolution":{},"dont_show_boolean_study_arguments":{},"hide_last_na_study_output":{},"price_scale_always_last_bar_value":{},"study_dialog_fundamentals_economy_addons":{},"uppercase_instrument_names":{},"trading_notifications":{},"chart_crosshair_menu":{},"japanese_chart_styles":{},"hide_series_legend_item":{},"hide_study_overlay_legend_item":{},"hide_study_compare_legend_item":{},"linetoolpropertieswidget_template_button":{},"use_overrides_for_overlay":{},"timezone_menu":{},"main_series_scale_menu":{},"show_login_dialog":{},"remove_img_from_rss":{},"bars_marks":{},"chart_scroll":{},"chart_zoom":{},"source_selection_markers":{},"low_density_bars":{},"end_of_period_timescale_marks":{},"open_account_manager":{},"show_order_panel_on_start":{},"order_panel":{"subsets":["order_panel_close_button","order_panel_undock","right_toolbar","order_info"]},"multiple_watchlists":{},"watchlist_import_export":{},"study_overlay_compare_legend_option":{},"mobile_app_action_open_details_webview":{},"custom_resolutions":{},"referral_program_for_widget_owners":{},"mobile_trading":{},"real_brokers":{},"no_min_chart_width":{},"lock_visible_time_range_on_resize":{},"pricescale_currency":{},"cropped_tick_marks":{},"trading_account_manager":{},"disable_sameinterval_aligning":{},"display_legend_on_all_charts":{},"chart_style_hilo":{},"chart_style_hilo_last_price":{},"pricescale_unit":{},"show_spread_operators":{},"hide_exponentiation_spread_operator":{},"hide_reciprocal_spread_operator":{},"compare_symbol_search_spread_operators":{},"studies_symbol_search_spread_operators":{},"hide_resolution_in_legend":{},"hide_unresolved_symbols_in_legend":{},"fix_left_edge":{},"study_symbol_ticker_description":{},"two_character_bar_marks_labels":{},"tick_resolution":{},"secondary_series_extend_time_scale":{},"hide_volume_ma":{},"small_no_display":{},"charting_library_single_symbol_request":{},"use_ticker_on_symbol_info_update":{},"show_zoom_and_move_buttons_on_touch":{},"hide_main_series_symbol_from_indicator_legend":{},"chart_hide_close_position_button":{},"chart_hide_close_order_button":{},"hide_price_scale_global_last_bar_value":{"subsets":["use_last_visible_bar_value_in_legend"]},"keep_object_tree_widget_in_right_toolbar":{},"show_average_close_price_line_and_label":{},"hide_image_invalid_symbol":{},"hide_object_tree_and_price_scale_exchange_label":{},"confirm_overwrite_if_chart_layout_with_name_exists":{},"determine_first_data_request_size_using_visible_range":{},"use_na_string_for_not_available_values":{},"show_last_price_and_change_only_in_series_legend":{},"show_context_menu_in_crosshair_if_only_one_item":{},"iframe_loading_compatibility_mode":{},"show_percent_option_for_right_margin":{},"watchlist_context_menu":{},"app_phone":{},"app_tablet":{},"tv_production":{"subsets":["auto_enable_symbol_labels","symbol_search_parser_mixin","header_fullscreen_button","header_widget","dont_show_boolean_study_arguments","left_toolbar","right_toolbar","buy_sell_buttons","control_bar","symbol_search_hot_key","context_menus","edit_buttons_in_legend","object_tree_legend_mode","uppercase_instrument_names","use_localstorage_for_settings","saveload_requires_authentication","volume_force_overlay","saved_charts_count_restriction","create_volume_indicator_by_default","create_volume_indicator_by_default_once","charts_auto_save","save_old_chart_before_save_as","chart_content_overrides_by_defaults","alerts","header_saveload","header_layouttoggle","datasource_copypaste","show_saved_watchlists","watchlists_from_to_file","add_to_watchlist","property_pages","support_multicharts","display_market_status","display_data_mode","show_chart_warn_message","support_manage_drawings","widgetbar_tabs","study_templates","collapsible_header","drawing_templates","footer_publish_idea_button","text_notes","show_source_code","symbol_info","linetoolpropertieswidget_template_button","trading_notifications","symbol_search_three_columns_exchanges","symbol_search_flags","symbol_search_limited_exchanges","phone_verification","custom_resolutions","compare_symbol","study_on_study","japanese_chart_styles","show_login_dialog","dom_widget","bars_marks","chart_scroll","chart_zoom","show_trading_notifications_history","source_selection_markers","study_dialog_fundamentals_economy_addons","multiple_watchlists","marked_symbols","order_panel","pricescale_currency","show_animated_logo","pricescale_currency","show_object_tree","watchlist_import_export","scales_date_format","scales_time_hours_format","popup_hints","show_right_widgets_panel_by_default","compare_recent_symbols_enabled","adaptive_trading_sources","chart_style_hilo_last_price"]},"widget":{"subsets":["auto_enable_symbol_labels","symbol_search_parser_mixin","uppercase_instrument_names","left_toolbar","right_toolbar","control_bar","symbol_search_hot_key","context_menus","edit_buttons_in_legend","object_tree_legend_mode","use_localstorage_for_settings","saveload_requires_authentication","volume_force_overlay","create_volume_indicator_by_default","create_volume_indicator_by_default_once","dont_show_boolean_study_arguments","header_widget_dom_node","header_symbol_search","header_resolutions","header_chart_type","header_compare","header_indicators","star_some_intervals_by_default","display_market_status","display_data_mode","show_chart_warn_message","symbol_info","linetoolpropertieswidget_template_button","symbol_search_three_columns_exchanges","symbol_search_flags","symbol_search_limited_exchanges","widgetbar_tabs","compare_symbol","show_login_dialog","plain_studymarket","japanese_chart_styles","bars_marks","chart_scroll","chart_zoom","source_selection_markers","property_pages","show_right_widgets_panel_by_default","chart_style_hilo_last_price"]},"bovespa_widget":{"subsets":["widget","header_settings","linetoolpropertieswidget_template_button","compare_recent_symbols_enabled"]},"charting_library_base":{"subsets":["14851","allow_supported_resolutions_set_only","auto_enable_symbol_labels","border_around_the_chart","collapsible_header","constraint_dialogs_movement","context_menus","control_bar","create_volume_indicator_by_default","custom_items_in_context_menu","datasource_copypaste","uppercase_instrument_names","display_market_status","edit_buttons_in_legend","object_tree_legend_mode","graying_disabled_tools_enabled","header_widget","legend_widget","header_saveload","dont_show_boolean_study_arguments","lean_chart_load","left_toolbar","right_toolbar","link_to_tradingview","pay_attention_to_ticker_not_symbol","plain_studymarket","refresh_saved_charts_list_on_dialog_show","right_bar_stays_on_scroll","saveload_storage_customization","stop_study_on_restart","timeframes_toolbar","symbol_search_hot_key","update_study_formatter_on_symbol_resolve","update_timeframes_set_on_symbol_resolve","use_localstorage_for_settings","volume_force_overlay","widget_logo","countdown","use_overrides_for_overlay","trading_notifications","compare_symbol","symbol_info","timezone_menu","main_series_scale_menu","create_volume_indicator_by_default_once","bars_marks","chart_scroll","chart_zoom","source_selection_markers","property_pages","go_to_date","adaptive_logo","show_animated_logo","handle_scale","handle_scroll","shift_visible_range_on_new_bar","chart_content_overrides_by_defaults","cropped_tick_marks","scales_date_format","scales_time_hours_format","popup_hints","save_shortcut","show_right_widgets_panel_by_default","show_object_tree","insert_indicator_dialog_shortcut","compare_recent_symbols_enabled","hide_main_series_symbol_from_indicator_legend","chart_style_hilo","request_only_visible_range_on_reset","clear_price_scale_on_error_or_empty_bars","show_symbol_logo_in_legend","show_symbol_logo_for_compare_studies"]},"charting_library":{"subsets":["charting_library_base"]},"static_charts_service":{"subsets":["charting_library","disable_resolution_rebuild"]},"trading_terminal":{"subsets":["charting_library_base","support_multicharts","header_layouttoggle","japanese_chart_styles","chart_property_page_trading","add_to_watchlist","open_account_manager","show_dom_first_time","order_panel","buy_sell_buttons","multiple_watchlists","show_trading_notifications_history","always_pass_called_order_to_modify","show_object_tree","watchlist_import_export","drawing_templates","trading_account_manager","chart_crosshair_menu","compare_recent_symbols_enabled","adaptive_trading_sources","watchlist_context_menu","show_symbol_logo_in_account_manager","watchlist_sections"]}}') +;const r=JSON.parse('{"14851":{},"custom_items_in_context_menu":{},"countdown":{},"symbol_search_parser_mixin":{},"pay_attention_to_ticker_not_symbol":{},"graying_disabled_tools_enabled":{},"update_study_formatter_on_symbol_resolve":{},"constraint_dialogs_movement":{},"phone_verification":{},"show_trading_notifications_history":{},"show_interval_dialog_on_key_press":{},"header_interval_dialog_button":{"subsets":["show_interval_dialog_on_key_press"]},"header_fullscreen_button":{},"header_symbol_search":{},"symbol_search_hot_key":{},"header_resolutions":{"subsets":["header_interval_dialog_button"]},"header_chart_type":{},"header_settings":{},"header_indicators":{},"header_compare":{},"header_undo_redo":{},"header_screenshot":{},"header_saveload":{},"study_on_study":{},"scales_date_format":{},"scales_time_hours_format":{},"header_widget":{"subsets":["header_widget_dom_node","header_symbol_search","header_resolutions","header_chart_type","header_settings","header_indicators","header_compare","header_undo_redo","header_fullscreen_button","compare_symbol","header_screenshot"]},"legend_widget":{},"compare_symbol":{"subsets":["header_compare"]},"property_pages":{"subsets":["show_chart_property_page","chart_property_page"]},"show_chart_property_page":{},"chart_property_page":{"subsets":["chart_property_page_scales","chart_property_page_trading","chart_property_page_right_margin_editor"]},"left_toolbar":{},"right_toolbar":{},"hide_left_toolbar_by_default":{},"control_bar":{},"widget_logo":{},"timeframes_toolbar":{},"edit_buttons_in_legend":{"subsets":["show_hide_button_in_legend","format_button_in_legend","study_buttons_in_legend","delete_button_in_legend"]},"show_hide_button_in_legend":{},"object_tree_legend_mode":{},"format_button_in_legend":{},"study_buttons_in_legend":{},"delete_button_in_legend":{},"broker_button":{},"buy_sell_buttons":{"subsets":["broker_button"]},"pane_context_menu":{},"scales_context_menu":{},"legend_context_menu":{},"context_menus":{"subsets":["pane_context_menu","scales_context_menu","legend_context_menu","objects_tree_context_menu"]},"items_favoriting":{},"save_chart_properties_to_local_storage":{},"use_localstorage_for_settings":{"subsets":["items_favoriting","save_chart_properties_to_local_storage"]},"handle_scale":{"subsets":["mouse_wheel_scale","pinch_scale","axis_pressed_mouse_move_scale"]},"handle_scroll":{"subsets":["mouse_wheel_scroll","pressed_mouse_move_scroll","horz_touch_drag_scroll","vert_touch_drag_scroll"]},"plain_studymarket":{},"disable_resolution_rebuild":{},"border_around_the_chart":{},"charting_library_debug_mode":{},"saveload_requires_authentication":{},"saveload_storage_customization":{},"volume_force_overlay":{},"create_volume_indicator_by_default":{},"create_volume_indicator_by_default_once":{},"saved_charts_count_restriction":{},"lean_chart_load":{},"stop_study_on_restart":{},"star_some_intervals_by_default":{},"move_logo_to_main_pane":{},"show_animated_logo":{},"link_to_tradingview":{},"logo_without_link":{},"logo_always_maximized":{},"right_bar_stays_on_scroll":{},"chart_content_overrides_by_defaults":{},"snapshot_trading_drawings":{},"allow_supported_resolutions_set_only":{},"widgetbar_tabs":{"subsets":["right_toolbar"]},"show_object_tree":{"subsets":["right_toolbar"]},"dom_widget":{"subsets":["right_toolbar"]},"collapsible_header":{},"study_templates":{},"side_toolbar_in_fullscreen_mode":{},"header_in_fullscreen_mode":{},"remove_library_container_border":{},"whotrades_auth_only":{},"support_multicharts":{},"display_market_status":{},"display_data_mode":{},"datasource_copypaste":{},"drawing_templates":{"subsets":["linetoolpropertieswidget_template_button"]},"expand_symbolsearch_items":{},"symbol_search_three_columns_exchanges":{},"symbol_search_flags":{},"symbol_search_limited_exchanges":{},"bugreport_button":{"subsets":["right_toolbar"]},"footer_publish_idea_button":{},"text_notes":{},"show_source_code":{},"symbol_info":{},"no_bars_status":{},"clear_bars_on_series_error":{},"hide_loading_screen_on_series_error":{},"seconds_resolution":{},"dont_show_boolean_study_arguments":{},"hide_last_na_study_output":{},"price_scale_always_last_bar_value":{},"study_dialog_fundamentals_economy_addons":{},"uppercase_instrument_names":{},"trading_notifications":{},"chart_crosshair_menu":{},"japanese_chart_styles":{},"hide_series_legend_item":{},"hide_study_overlay_legend_item":{},"hide_study_compare_legend_item":{},"linetoolpropertieswidget_template_button":{},"use_overrides_for_overlay":{},"timezone_menu":{},"main_series_scale_menu":{},"show_login_dialog":{},"remove_img_from_rss":{},"bars_marks":{},"chart_scroll":{},"chart_zoom":{},"source_selection_markers":{},"low_density_bars":{},"end_of_period_timescale_marks":{},"open_account_manager":{},"show_order_panel_on_start":{},"order_panel":{"subsets":["order_panel_close_button","order_panel_undock","right_toolbar","order_info"]},"multiple_watchlists":{},"watchlist_import_export":{},"study_overlay_compare_legend_option":{},"mobile_app_action_open_details_webview":{},"custom_resolutions":{},"referral_program_for_widget_owners":{},"mobile_trading":{},"real_brokers":{},"no_min_chart_width":{},"lock_visible_time_range_on_resize":{},"pricescale_currency":{},"cropped_tick_marks":{},"trading_account_manager":{},"disable_sameinterval_aligning":{},"display_legend_on_all_charts":{},"chart_style_hilo":{},"chart_style_hilo_last_price":{},"pricescale_unit":{},"show_spread_operators":{},"hide_exponentiation_spread_operator":{},"hide_reciprocal_spread_operator":{},"compare_symbol_search_spread_operators":{},"studies_symbol_search_spread_operators":{},"hide_resolution_in_legend":{},"hide_unresolved_symbols_in_legend":{},"fix_left_edge":{},"study_symbol_ticker_description":{},"two_character_bar_marks_labels":{},"tick_resolution":{},"secondary_series_extend_time_scale":{},"hide_volume_ma":{},"small_no_display":{},"charting_library_single_symbol_request":{},"use_ticker_on_symbol_info_update":{},"show_zoom_and_move_buttons_on_touch":{},"hide_main_series_symbol_from_indicator_legend":{},"chart_hide_close_position_button":{},"chart_hide_close_order_button":{},"hide_price_scale_global_last_bar_value":{"subsets":["use_last_visible_bar_value_in_legend"]},"keep_object_tree_widget_in_right_toolbar":{},"show_average_close_price_line_and_label":{},"hide_image_invalid_symbol":{},"hide_object_tree_and_price_scale_exchange_label":{},"confirm_overwrite_if_chart_layout_with_name_exists":{},"determine_first_data_request_size_using_visible_range":{},"use_na_string_for_not_available_values":{},"show_last_price_and_change_only_in_series_legend":{},"show_context_menu_in_crosshair_if_only_one_item":{},"iframe_loading_compatibility_mode":{},"show_percent_option_for_right_margin":{},"watchlist_context_menu":{},"app_phone":{},"app_tablet":{},"tv_production":{"subsets":["auto_enable_symbol_labels","symbol_search_parser_mixin","header_fullscreen_button","header_widget","dont_show_boolean_study_arguments","left_toolbar","right_toolbar","buy_sell_buttons","control_bar","symbol_search_hot_key","context_menus","edit_buttons_in_legend","object_tree_legend_mode","uppercase_instrument_names","use_localstorage_for_settings","saveload_requires_authentication","volume_force_overlay","saved_charts_count_restriction","create_volume_indicator_by_default","create_volume_indicator_by_default_once","charts_auto_save","save_old_chart_before_save_as","chart_content_overrides_by_defaults","alerts","header_saveload","header_layouttoggle","datasource_copypaste","show_saved_watchlists","watchlists_from_to_file","add_to_watchlist","property_pages","support_multicharts","display_market_status","display_data_mode","show_chart_warn_message","support_manage_drawings","widgetbar_tabs","study_templates","collapsible_header","drawing_templates","footer_publish_idea_button","text_notes","show_source_code","symbol_info","linetoolpropertieswidget_template_button","trading_notifications","symbol_search_three_columns_exchanges","symbol_search_flags","symbol_search_limited_exchanges","phone_verification","custom_resolutions","compare_symbol","study_on_study","japanese_chart_styles","show_login_dialog","dom_widget","bars_marks","chart_scroll","chart_zoom","show_trading_notifications_history","source_selection_markers","study_dialog_fundamentals_economy_addons","multiple_watchlists","marked_symbols","order_panel","pricescale_currency","show_animated_logo","pricescale_currency","show_object_tree","watchlist_import_export","scales_date_format","scales_time_hours_format","popup_hints","show_right_widgets_panel_by_default","compare_recent_symbols_enabled","adaptive_trading_sources","chart_style_hilo_last_price"]},"widget":{"subsets":["auto_enable_symbol_labels","symbol_search_parser_mixin","uppercase_instrument_names","left_toolbar","right_toolbar","control_bar","symbol_search_hot_key","context_menus","edit_buttons_in_legend","object_tree_legend_mode","use_localstorage_for_settings","saveload_requires_authentication","volume_force_overlay","create_volume_indicator_by_default","create_volume_indicator_by_default_once","dont_show_boolean_study_arguments","header_widget_dom_node","header_symbol_search","header_resolutions","header_chart_type","header_compare","header_indicators","star_some_intervals_by_default","display_market_status","display_data_mode","show_chart_warn_message","symbol_info","linetoolpropertieswidget_template_button","symbol_search_three_columns_exchanges","symbol_search_flags","symbol_search_limited_exchanges","widgetbar_tabs","compare_symbol","show_login_dialog","plain_studymarket","japanese_chart_styles","bars_marks","chart_scroll","chart_zoom","source_selection_markers","property_pages","show_right_widgets_panel_by_default","chart_style_hilo_last_price"]},"bovespa_widget":{"subsets":["widget","header_settings","linetoolpropertieswidget_template_button","compare_recent_symbols_enabled"]},"charting_library_base":{"subsets":["14851","allow_supported_resolutions_set_only","auto_enable_symbol_labels","border_around_the_chart","collapsible_header","constraint_dialogs_movement","context_menus","control_bar","create_volume_indicator_by_default","custom_items_in_context_menu","datasource_copypaste","uppercase_instrument_names","display_market_status","edit_buttons_in_legend","object_tree_legend_mode","graying_disabled_tools_enabled","header_widget","legend_widget","header_saveload","dont_show_boolean_study_arguments","lean_chart_load","left_toolbar","right_toolbar","link_to_tradingview","pay_attention_to_ticker_not_symbol","plain_studymarket","refresh_saved_charts_list_on_dialog_show","right_bar_stays_on_scroll","saveload_storage_customization","stop_study_on_restart","timeframes_toolbar","symbol_search_hot_key","update_study_formatter_on_symbol_resolve","update_timeframes_set_on_symbol_resolve","use_localstorage_for_settings","volume_force_overlay","widget_logo","countdown","use_overrides_for_overlay","trading_notifications","compare_symbol","symbol_info","timezone_menu","main_series_scale_menu","create_volume_indicator_by_default_once","bars_marks","chart_scroll","chart_zoom","source_selection_markers","property_pages","go_to_date","adaptive_logo","show_animated_logo","handle_scale","handle_scroll","shift_visible_range_on_new_bar","chart_content_overrides_by_defaults","cropped_tick_marks","scales_date_format","scales_time_hours_format","popup_hints","save_shortcut","show_right_widgets_panel_by_default","show_object_tree","insert_indicator_dialog_shortcut","compare_recent_symbols_enabled","hide_main_series_symbol_from_indicator_legend","chart_style_hilo","request_only_visible_range_on_reset","clear_price_scale_on_error_or_empty_bars","show_symbol_logo_in_legend","show_symbol_logo_for_compare_studies","accessibility"]},"charting_library":{"subsets":["charting_library_base"]},"static_charts_service":{"subsets":["charting_library","disable_resolution_rebuild"]},"trading_terminal":{"subsets":["charting_library_base","support_multicharts","header_layouttoggle","japanese_chart_styles","chart_property_page_trading","add_to_watchlist","open_account_manager","show_dom_first_time","order_panel","buy_sell_buttons","multiple_watchlists","show_trading_notifications_history","always_pass_called_order_to_modify","show_object_tree","watchlist_import_export","drawing_templates","trading_account_manager","chart_crosshair_menu","compare_recent_symbols_enabled","adaptive_trading_sources","watchlist_context_menu","show_symbol_logo_in_account_manager","watchlist_sections"]}}') ;var u=n.t(r,2);const o=new Map,d=new Map,i=new Set;function a(e){const t=o.get(e);if(void 0!==t)return t;const n=d.get(e);return!!n&&n.some(a)}function s(e,t){o.set(String(e),Boolean(t))}function c(e){s(e,!0)}function f(e){s(e,!1)}function l(){const e=Object.create(null);for(const t of i)e[t]=a(t);return e}!function(){for(const[e,t]of Object.entries(u))if(i.add(e),"subsets"in t)for(const n of t.subsets){i.add(n);let t=d.get(n);void 0===t&&(t=[],d.set(n,t)),t.push(e)}"object"==typeof __initialDisabledFeaturesets&&Array.isArray(__initialDisabledFeaturesets)&&__initialDisabledFeaturesets.forEach(f),"object"==typeof __initialEnabledFeaturesets&&Array.isArray(__initialEnabledFeaturesets)&&__initialEnabledFeaturesets.forEach(c)}()},1722:function(e,t,n){var r;e=n.nmd(e);var u=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},o=function(e){return"object"==typeof e&&null!==e};function d(e){return"number"==typeof e&&isFinite(e)}function i(e){return null!=e&&(e.constructor===Function||"[object Function]"===Object.prototype.toString.call(e))}function a(e,t){e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}"undefined"!=typeof window?(r=window.TradingView=window.TradingView||{},window.isNumber=d,window.isFunction=i,window.inherit=a,window.isArray=u):r=this.TradingView=this.TradingView||{},r.isNaN=function(e){return!(e<=0||e>0)},r.isAbsent=function(e){return null==e},r.isExistent=function(e){return null!=e},Number.isNaN=Number.isNaN||function(e){return e!=e},r.isSameType=function(e,t){return Number.isNaN(e)||Number.isNaN(t)?Number.isNaN(e)===Number.isNaN(t):{}.toString.call(e)==={}.toString.call(t)},r.isInteger=function(e){return"number"==typeof e&&e%1==0},r.isString=function(e){return null!=e&&e.constructor===String},r.isInherited=function(e,t){if(null==e||null==e.prototype)throw new TypeError("isInherited: child should be a constructor function");if(null==t||null==t.prototype)throw new TypeError("isInherited: parent should be a constructor function");return e.prototype instanceof t||e.prototype===t.prototype},r.clone=function(e){if(!e||"object"!=typeof e)return e;var t,n,u;for(n in t="function"==typeof e.pop?[]:{},e)e.hasOwnProperty(n)&&(u=e[n],t[n]=u&&"object"==typeof u?r.clone(u):u);return t},r.deepEquals=function(e,t,n){if(n||(n=""),e===t)return[!0,n];if(i(e)&&(e=void 0),i(t)&&(t=void 0),void 0===e&&void 0!==t)return[!1,n];if(void 0===t&&void 0!==e)return[!1,n];if(null===e&&null!==t)return[!1,n];if(null===t&&null!==e)return[!1,n];if("object"!=typeof e&&"object"!=typeof t)return[e===t,n];if(Array.isArray(e)&&Array.isArray(t)){var o=e.length;if(o!==t.length)return[!1,n];for(var d=0;d{"use strict";n.r(t);var r=n(1722);const u=/{(\w+)}/g,o=/{(\d+)}/g;String.prototype.format=function(...e){const t=(0,r.isObject)(e[0]),n=t?u:o,d=t?(t,n)=>{const r=e[0];return void 0!==r[n]?r[n]:t}:(t,n)=>{const r=parseInt(n,10),u=e[r];return void 0!==u?u:t};return this.replace(n,d)}},95374:()=>{"use strict";var e,t,n,r,u,o;window.parent!==window&&window.CanvasRenderingContext2D&&window.TextMetrics&&(t=window.CanvasRenderingContext2D.prototype)&&t.hasOwnProperty("font")&&t.hasOwnProperty("mozTextStyle")&&"function"==typeof t.__lookupSetter__&&(n=t.__lookupSetter__("font"))&&(t.__defineSetter__("font",(function(e){try{return n.call(this,e)}catch(e){if("NS_ERROR_FAILURE"!==e.name)throw e}})),r=t.measureText,e=function(){this.width=0,this.isFake=!0,this.__proto__=window.TextMetrics.prototype},t.measureText=function(t){try{return r.apply(this,arguments)}catch(t){if("NS_ERROR_FAILURE"!==t.name)throw t;return new e}},u=t.fillText,t.fillText=function(e,t,n,r){try{u.apply(this,arguments)}catch(e){if("NS_ERROR_FAILURE"!==e.name)throw e}},o=t.strokeText,t.strokeText=function(e,t,n,r){try{o.apply(this,arguments)}catch(e){if("NS_ERROR_FAILURE"!==e.name)throw e}})},18438:(e,t,n)=>{"use strict";n.d(t,{default:()=>r});const r=function(){var e={base:"https://twemoji.maxcdn.com/v/13.0.1/",ext:".png",size:"72x72",className:"emoji",convert:{fromCodePoint:function(e){var t="string"==typeof e?parseInt(e,16):e;if(t<65536)return i(t);return i(55296+((t-=65536)>>10),56320+(1023&t))},toCodePoint:v},onerror:function(){this.parentNode&&this.parentNode.replaceChild(a(this.alt,!1),this)},parse:function(t,n){n&&"function"!=typeof n||(n={callback:n});return("string"==typeof t?_:l)(t,{callback:n.callback||s,attributes:"function"==typeof n.attributes?n.attributes:p,base:"string"==typeof n.base?n.base:e.base,ext:n.ext||e.ext,size:n.folder||(r=n.size||e.size,"number"==typeof r?r+"x"+r:r), className:n.className||e.className,onerror:n.onerror||e.onerror});var r},replace:b,test:function(e){n.lastIndex=0;var t=n.test(e);return n.lastIndex=0,t}},t={"&":"&","<":"<",">":">","'":"'",'"':""" diff --git a/charting_library/bundles/5901.bf6858d021c8e6c577d5.js b/charting_library/bundles/5901.3f691f17bd266aac284c.js similarity index 74% rename from charting_library/bundles/5901.bf6858d021c8e6c577d5.js rename to charting_library/bundles/5901.3f691f17bd266aac284c.js index 6fe6cb00..1ab883a2 100644 --- a/charting_library/bundles/5901.bf6858d021c8e6c577d5.js +++ b/charting_library/bundles/5901.3f691f17bd266aac284c.js @@ -12,17 +12,17 @@ const{initialMode:t="symbolSearch",autofocus:n=!0,defaultValue:l,showSpreadActio return"#"+[255*s,255*r,255*a].map((e=>("0"+Math.round(e).toString(16)).replace(/.+?([a-f0-9]{2})$/i,"$1"))).join("")}(e)||T;this.setState({color:t,inputColor:t.replace(/^#/,""),hsv:e}),this.props.onSelect(t)},this._handleInput=e=>{const t=e.currentTarget.value;try{const e=y(t),n=`#${t}`;this.setState({color:n,inputColor:t,hsv:e}),this.props.onSelect(n)}catch(e){this.setState({inputColor:t})}},this._handleAddColor=()=>this.props.onAdd(this.state.color);const t=e.color||T;this.state={color:t,inputColor:t.replace(/^#/,""),hsv:y(t)}}render(){const{color:e,hsv:t,inputColor:n}=this.state;return o.createElement("div",{className:N.container},o.createElement("div",{className:N.form},o.createElement("div",{className:N.swatch,style:{backgroundColor:e}}),o.createElement("div",{className:N.inputWrap},o.createElement("span",{className:N.inputHash},"#"),o.createElement("input",{type:"text",className:N.input,value:n,onChange:this._handleInput})),o.createElement("div",{className:N.buttonWrap},o.createElement(C.Button,{size:"s",onClick:this._handleAddColor},I))),o.createElement("div",{className:N.hueSaturationWrap},o.createElement(w,{className:N.saturation,hsv:t,onChange:this._handleHSV}),o.createElement(_,{className:N.hue,hsv:t,onChange:this._handleHSV})))}}var P=n(93402);const B=a.t(null,{context:"Color Picker"},n(53585)),D=a.t(null,{context:"Color Picker"},n(81865));class M extends o.PureComponent{constructor(e){super(e),this._handleAddColor=e=>{this.setState({isCustom:!1}),this._onToggleCustom(!1);const{onAddColor:t}=this.props;t&&t(e)},this._handleSelectColor=e=>{const{onColorChange:t}=this.props,{isCustom:n}=this.state;t&&t(e,n)},this._handleCustomClick=()=>{this.setState({isCustom:!0}),this._onToggleCustom(!0)},this._handleOpacity=e=>{const{onOpacityChange:t}=this.props;t&&t(e)},this.state={isCustom:!1}}componentDidUpdate(e,t){e.selectOpacity!==this.props.selectOpacity&&this.props.menu&&this.props.menu.update()}render(){const{color:e,opacity:t,selectCustom:n,selectOpacity:s,customColors:a,onRemoveCustomColor:i}=this.props,{isCustom:l}=this.state,c="number"==typeof t?t:1;return l?o.createElement(k,{color:e,onSelect:this._handleSelectColor,onAdd:this._handleAddColor}):o.createElement("div",{className:P.container},o.createElement(b,{colors:h.basic,color:e,onSelect:this._handleSelectColor}),o.createElement(b,{colors:h.extended,color:e,onSelect:this._handleSelectColor}),o.createElement("div",{className:P.separator}),o.createElement(d.Provider,{value:i},o.createElement(b,{colors:a,color:e,onSelect:this._handleSelectColor},n&&o.createElement("div",{className:r()(P.customButton,"apply-common-tooltip"),onClick:this._handleCustomClick,title:B}))),s&&o.createElement(o.Fragment,null,o.createElement("div",{className:P.sectionTitle},D),o.createElement(f.Opacity,{color:e,opacity:c,onChange:this._handleOpacity})))}_onToggleCustom(e){const{onToggleCustom:t}=this.props;t&&t(e)}}},54368:(e,t,n)=>{"use strict";n.d(t,{Opacity:()=>l});var o=n(50959),s=n(97754),r=n(50151),a=n(37160),i=n(30099);class l extends o.PureComponent{constructor(e){super(e), this._container=null,this._pointer=null,this._raf=null,this._refContainer=e=>{this._container=e},this._refPointer=e=>{this._pointer=e},this._handlePosition=e=>{null===this._raf&&(this._raf=requestAnimationFrame((()=>{const t=(0,r.ensureNotNull)(this._container),n=(0,r.ensureNotNull)(this._pointer),o=t.getBoundingClientRect(),s=n.offsetWidth,i=e.clientX-s/2-o.left,l=(0,a.clamp)(i/(o.width-s),0,1);this.setState({inputOpacity:Math.round(100*l).toString()}),this.props.onChange(l),this._raf=null})))},this._onSliderClick=e=>{this._handlePosition(e.nativeEvent),this._dragSubscribe()},this._mouseUp=e=>{this.setState({isPointerDragged:!1}),this._dragUnsubscribe(),this._handlePosition(e)},this._mouseMove=e=>{this.setState({isPointerDragged:!0}),this._handlePosition(e)},this._onTouchStart=e=>{this._handlePosition(e.nativeEvent.touches[0])},this._handleTouch=e=>{this.setState({isPointerDragged:!0}),this._handlePosition(e.nativeEvent.touches[0])},this._handleTouchEnd=()=>{this.setState({isPointerDragged:!1})},this._handleInput=e=>{const t=e.currentTarget.value,n=Number(t)/100;this.setState({inputOpacity:t}),Number.isNaN(n)||n>1||this.props.onChange(n)},this.state={inputOpacity:Math.round(100*e.opacity).toString(),isPointerDragged:!1}}componentWillUnmount(){null!==this._raf&&(cancelAnimationFrame(this._raf),this._raf=null),this._dragUnsubscribe()}render(){const{color:e,opacity:t,hideInput:n}=this.props,{inputOpacity:r,isPointerDragged:a}=this.state,l={color:e||void 0};return o.createElement("div",{className:i.opacity},o.createElement("div",{className:i.opacitySlider,style:l,ref:this._refContainer,onMouseDown:this._onSliderClick,onTouchStart:this._onTouchStart,onTouchMove:this._handleTouch,onTouchEnd:this._handleTouchEnd},o.createElement("div",{className:i.opacitySliderGradient,style:{backgroundImage:`linear-gradient(90deg, transparent, ${e})`}}),o.createElement("div",{className:i.opacityPointerWrap},o.createElement("div",{className:s(i.pointer,a&&i.dragged),style:{left:100*t+"%"},ref:this._refPointer}))),!n&&o.createElement("div",{className:i.opacityInputWrap},o.createElement("input",{type:"text",className:i.opacityInput,value:r,onChange:this._handleInput}),o.createElement("span",{className:i.opacityInputPercent},"%")))}_dragSubscribe(){const e=(0,r.ensureNotNull)(this._container).ownerDocument;e&&(e.addEventListener("mouseup",this._mouseUp),e.addEventListener("mousemove",this._mouseMove))}_dragUnsubscribe(){const e=(0,r.ensureNotNull)(this._container).ownerDocument;e&&(e.removeEventListener("mousemove",this._mouseMove),e.removeEventListener("mouseup",this._mouseUp))}}},6914:(e,t,n)=>{"use strict";n.d(t,{basic:()=>i,extended:()=>c,white:()=>s});var o=n(48891);const s=o.colorsPalette["color-white"],r=["ripe-red","tan-orange","banana-yellow","iguana-green","minty-green","sky-blue","tv-blue","deep-blue","grapes-purple","berry-pink"],a=[200,300,400,500,600,700,800,900].map((e=>`color-cold-gray-${e}`));a.unshift("color-white"),a.push("color-black"),r.forEach((e=>{a.push(`color-${e}-500`)}));const i=a.map((e=>o.colorsPalette[e])),l=[] ;[100,200,300,400,700,900].forEach((e=>{r.forEach((t=>{l.push(`color-${t}-${e}`)}))}));const c=l.map((e=>o.colorsPalette[e]))},59054:(e,t,n)=>{"use strict";n.d(t,{ControlDisclosureView:()=>g});var o=n(50959),s=n(97754),r=n.n(s),a=n(38528),i=n(67029),l=n(78274),c=n(4523),u=n(9745),p=n(2948),d=n(23428);function h(e){const{isDropped:t}=e;return o.createElement(u.Icon,{className:r()(d.icon,t&&d.dropped),icon:p})}function m(e){const{className:t,disabled:n,isDropped:s}=e;return o.createElement("span",{className:r()(d.button,n&&d.disabled,t)},o.createElement(h,{isDropped:s}))}var v=n(66986);const g=o.forwardRef(((e,t)=>{const{listboxId:n,className:s,listboxClassName:u,listboxTabIndex:p,hideArrowButton:d,matchButtonAndListboxWidths:h,popupPosition:g,disabled:b,isOpened:f,scrollWrapReference:C,repositionOnScroll:y,closeOnHeaderOverlap:E,listboxReference:S,size:w="small",onClose:x,onOpen:_,onListboxFocus:N,onListboxBlur:T,onListboxKeyDown:I,buttonChildren:k,children:P,caretClassName:B,listboxAria:D,...M}=e,V=(0,o.useRef)(null),O=!d&&o.createElement(l.EndSlot,null,o.createElement(m,{isDropped:f,disabled:b,className:B}));return o.createElement(c.PopupMenuDisclosureView,{buttonRef:V,listboxId:n,listboxClassName:u,listboxTabIndex:p,isOpened:f,onClose:x,onOpen:_,listboxReference:S,scrollWrapReference:C,onListboxFocus:N,onListboxBlur:T,onListboxKeyDown:I,listboxAria:D,matchButtonAndListboxWidths:h,popupPosition:g,button:o.createElement(i.ControlSkeleton,{...M,"data-role":"listbox",disabled:b,className:r()(v.button,s),size:w,ref:(0,a.useMergedRefs)([V,t]),middleSlot:o.createElement(l.MiddleSlot,null,o.createElement("span",{className:r()(v["button-children"],d&&v.hiddenArrow)},k)),endSlot:O}),popupChildren:P,repositionOnScroll:y,closeOnHeaderOverlap:E})}));g.displayName="ControlDisclosureView"},56512:(e,t,n)=>{"use strict";n.d(t,{useCustomColors:()=>l});var o=n(50959),s=n(56840),r=n(76422);function a(e,t){(0,o.useEffect)((()=>(r.subscribe(e,t,null),()=>{r.unsubscribe(e,t,null)})),[e,t])}var i=n(24377);function l(){const[e,t]=(0,o.useState)((0,s.getJSON)("pickerCustomColors",[]));a("add_new_custom_color",(n=>t(c(n,e)))),a("remove_custom_color",(n=>t(u(n,e))));const n=(0,o.useCallback)((t=>{const n=t?(0,i.parseRgb)(t):null;e.some((e=>null!==e&&null!==n&&(0,i.areEqualRgb)((0,i.parseRgb)(e),n)))||(r.emit("add_new_custom_color",t),(0,s.setJSON)("pickerCustomColors",c(t,e)))}),[e]),l=(0,o.useCallback)((t=>{(t>=0||t29&&n.shift(),n}function u(e,t){return t.filter(((t,n)=>e!==n))}},90405:(e,t,n)=>{"use strict";n.d(t,{Select:()=>C});var o=n(50959),s=n(22064),r=n(38528),a=n(16921),i=n(16396),l=n(12481),c=n(43370);var u=n(36762),p=n(26597),d=n(59054),h=n(36104),m=n(38223),v=n(60673);function g(e){return!e.readonly}function b(e,t){var n;return null!==(n=null==t?void 0:t.id)&&void 0!==n?n:(0,s.createDomId)(e,"item",null==t?void 0:t.value)}function f(e){var t,n -;const{selectedItem:s,placeholder:r}=e;if(!s)return o.createElement("span",{className:v.placeholder},r);const a=null!==(n=null!==(t=s.selectedContent)&&void 0!==t?t:s.content)&&void 0!==n?n:s.value;return o.createElement("span",null,a)}const C=o.forwardRef(((e,t)=>{const{id:n,menuClassName:v,menuItemClassName:C,tabIndex:y,disabled:E,highlight:S,intent:w,hideArrowButton:x,placeholder:_,addPlaceholderToItems:N=!0,value:T,"aria-labelledby":I,onFocus:k,onBlur:P,onClick:B,onChange:D,onKeyDown:M,repositionOnScroll:V=!0,openMenuOnEnter:O=!0,"aria-describedby":F,"aria-invalid":R,...L}=e;let{items:W}=e;if(_&&N){W=[{value:void 0,content:_,id:(0,s.createDomId)(n,"placeholder")},...W]}const{listboxId:A,isOpened:q,isFocused:U,buttonTabIndex:z,listboxTabIndex:Z,highlight:G,intent:H,open:K,onOpen:Y,close:$,toggle:j,buttonFocusBindings:X,onButtonClick:Q,buttonRef:J,listboxRef:ee,buttonAria:te}=(0,h.useControlDisclosure)({id:n,disabled:E,buttonTabIndex:y,intent:w,highlight:S,onFocus:k,onBlur:P,onClick:B}),ne=W.filter(g),oe=ne.find((e=>e.value===T)),[se,re,ae]=(0,a.useKeepActiveItemIntoView)({activeItem:oe}),ie=(0,s.joinDomIds)(I,n),le=ie.length>0?ie:void 0,ce=(0,o.useMemo)((()=>({role:"listbox","aria-labelledby":I,"aria-activedescendant":b(n,oe)})),[I,oe]),ue=(0,o.useCallback)((e=>e.value===T),[T]),pe=(0,o.useCallback)((e=>D&&D(e.value)),[D]),de=(0,u.useItemsKeyboardNavigation)(m.isRtl,ne,ue,pe,!1,{next:[40],previous:[38]}),he=(0,p.useKeyboardToggle)(j,q||O),me=(0,p.useKeyboardClose)(q,$),ve=(0,p.useKeyboardOpen)(q,K),ge=(0,p.useKeyboardEventHandler)([he,me,ve]),be=(0,p.useKeyboardEventHandler)([de,he,me]),fe=function(e){const t=(0,o.useRef)(""),n=(0,o.useMemo)((()=>(0,l.default)((()=>{t.current=""}),500)),[]),s=(0,o.useMemo)((()=>(0,c.default)(e,200)),[e]);return(0,o.useCallback)((e=>{e.key.length>0&&e.key.length<3&&(t.current+=e.key,s(t.current,e),n())}),[n,s])}(((t,n)=>{const o=function(e,t,n){return e.find((e=>{var o;const s=t.toLowerCase();return!e.readonly&&(n?n(e).toLowerCase().startsWith(s):!e.readonly&&("string"==typeof e.content&&e.content.toLowerCase().startsWith(s)||"string"==typeof e.textContent&&e.textContent.toLowerCase().startsWith(s)||String(null!==(o=e.value)&&void 0!==o?o:"").toLowerCase().startsWith(s)))}))}(ne,t,e.getSearchKey);void 0!==o&&D&&(n.stopPropagation(),q||K(),D(o.value))}));return o.createElement(d.ControlDisclosureView,{...L,...te,...X,id:n,role:"button",tabIndex:z,"aria-owns":te["aria-controls"],"aria-haspopup":"listbox","aria-labelledby":le,disabled:E,hideArrowButton:x,isFocused:U,isOpened:q,highlight:G,intent:H,ref:(0,r.useMergedRefs)([J,t]),onClick:Q,onOpen:function(){ae(oe,{duration:0}),Y()},onClose:$,onKeyDown:function(e){ge(e),M&&M(e);e.defaultPrevented||fe(e)},listboxId:A,listboxTabIndex:Z,listboxClassName:v,listboxAria:ce,"aria-describedby":F,"aria-invalid":R,listboxReference:ee,scrollWrapReference:se,onListboxKeyDown:function(e){be(e),e.defaultPrevented||fe(e)},buttonChildren:o.createElement(f,{selectedItem:oe,placeholder:_}),repositionOnScroll:V},W.map(((e,t)=>{var s +;const{selectedItem:s,placeholder:r}=e;if(!s)return o.createElement("span",{className:v.placeholder},r);const a=null!==(n=null!==(t=s.selectedContent)&&void 0!==t?t:s.content)&&void 0!==n?n:s.value;return o.createElement("span",null,a)}const C=o.forwardRef(((e,t)=>{const{id:n,menuClassName:v,menuItemClassName:C,tabIndex:y,disabled:E,highlight:S,intent:w,hideArrowButton:x,placeholder:_,addPlaceholderToItems:N=!0,value:T,"aria-labelledby":I,onFocus:k,onBlur:P,onClick:B,onChange:D,onKeyDown:M,repositionOnScroll:V=!0,openMenuOnEnter:O=!0,"aria-describedby":F,"aria-invalid":R,...L}=e;let{items:W}=e;if(_&&N){W=[{value:void 0,content:_,id:(0,s.createDomId)(n,"placeholder")},...W]}const{listboxId:A,isOpened:q,isFocused:U,buttonTabIndex:z,listboxTabIndex:Z,highlight:G,intent:H,open:K,onOpen:$,close:Y,toggle:j,buttonFocusBindings:X,onButtonClick:Q,buttonRef:J,listboxRef:ee,buttonAria:te}=(0,h.useControlDisclosure)({id:n,disabled:E,buttonTabIndex:y,intent:w,highlight:S,onFocus:k,onBlur:P,onClick:B}),ne=W.filter(g),oe=ne.find((e=>e.value===T)),[se,re,ae]=(0,a.useKeepActiveItemIntoView)({activeItem:oe}),ie=(0,s.joinDomIds)(I,n),le=ie.length>0?ie:void 0,ce=(0,o.useMemo)((()=>({role:"listbox","aria-labelledby":I,"aria-activedescendant":b(n,oe)})),[I,oe]),ue=(0,o.useCallback)((e=>e.value===T),[T]),pe=(0,o.useCallback)((e=>D&&D(e.value)),[D]),de=(0,u.useItemsKeyboardNavigation)(m.isRtl,ne,ue,pe,!1,{next:[40],previous:[38]}),he=(0,p.useKeyboardToggle)(j,q||O),me=(0,p.useKeyboardClose)(q,Y),ve=(0,p.useKeyboardOpen)(q,K),ge=(0,p.useKeyboardEventHandler)([he,me,ve]),be=(0,p.useKeyboardEventHandler)([de,he,me]),fe=function(e){const t=(0,o.useRef)(""),n=(0,o.useMemo)((()=>(0,l.default)((()=>{t.current=""}),500)),[]),s=(0,o.useMemo)((()=>(0,c.default)(e,200)),[e]);return(0,o.useCallback)((e=>{e.key.length>0&&e.key.length<3&&(t.current+=e.key,s(t.current,e),n())}),[n,s])}(((t,n)=>{const o=function(e,t,n){return e.find((e=>{var o;const s=t.toLowerCase();return!e.readonly&&(n?n(e).toLowerCase().startsWith(s):!e.readonly&&("string"==typeof e.content&&e.content.toLowerCase().startsWith(s)||"string"==typeof e.textContent&&e.textContent.toLowerCase().startsWith(s)||String(null!==(o=e.value)&&void 0!==o?o:"").toLowerCase().startsWith(s)))}))}(ne,t,e.getSearchKey);void 0!==o&&D&&(n.stopPropagation(),q||K(),D(o.value))}));return o.createElement(d.ControlDisclosureView,{...L,...te,...X,id:n,role:"button",tabIndex:z,"aria-owns":te["aria-controls"],"aria-haspopup":"listbox","aria-labelledby":le,disabled:E,hideArrowButton:x,isFocused:U,isOpened:q,highlight:G,intent:H,ref:(0,r.useMergedRefs)([J,t]),onClick:Q,onOpen:function(){ae(oe,{duration:0}),$()},onClose:Y,onKeyDown:function(e){ge(e),M&&M(e);e.defaultPrevented||fe(e)},listboxId:A,listboxTabIndex:Z,listboxClassName:v,listboxAria:ce,"aria-describedby":F,"aria-invalid":R,listboxReference:ee,scrollWrapReference:se,onListboxKeyDown:function(e){be(e),e.defaultPrevented||fe(e)},buttonChildren:o.createElement(f,{selectedItem:oe,placeholder:_}),repositionOnScroll:V},W.map(((e,t)=>{var s ;if(e.readonly)return o.createElement(o.Fragment,{key:`readonly_item_${t}`},e.content);const r=b(n,e);return o.createElement(i.PopupMenuItem,{key:r,id:r,className:C,role:"option","aria-selected":T===e.value,isActive:T===e.value,label:null!==(s=e.content)&&void 0!==s?s:e.value,onClick:Ce,onClickArg:e.value,isDisabled:e.disabled,reference:t=>re(e,t)})})));function Ce(e){D&&D(e)}}));C.displayName="Select"},86656:(e,t,n)=>{"use strict";n.d(t,{TouchScrollContainer:()=>i});var o=n(50959),s=n(59142),r=n(50151),a=n(49483);const i=(0,o.forwardRef)(((e,t)=>{const{children:n,...r}=e,i=(0,o.useRef)(null);return(0,o.useImperativeHandle)(t,(()=>i.current)),(0,o.useLayoutEffect)((()=>{if(a.CheckMobile.iOS())return null!==i.current&&(0,s.disableBodyScroll)(i.current,{allowTouchMove:l(i)}),()=>{null!==i.current&&(0,s.enableBodyScroll)(i.current)}}),[]),o.createElement("div",{ref:i,...r},n)}));function l(e){return t=>{const n=(0,r.ensureNotNull)(e.current),o=document.activeElement;return!n.contains(t)||null!==o&&n.contains(o)&&o.contains(t)}}},26278:e=>{e.exports={titleWrap:"titleWrap-Izz3hpJc",groupFooter:"groupFooter-Izz3hpJc"}},49934:e=>{e.exports={wrapper:"wrapper-JXHzsa7P"}},17611:e=>{e.exports={inlineRow:"inlineRow-D8g11qqA"}},93071:e=>{e.exports={container:"container-QyF09i7Y",hasTooltip:"hasTooltip-QyF09i7Y",datePickerWrapper:"datePickerWrapper-QyF09i7Y",timePickerWrapper:"timePickerWrapper-QyF09i7Y"}},27698:e=>{e.exports={input:"input-ZOx_CVY3",symbol:"symbol-ZOx_CVY3",checkbox:"checkbox-ZOx_CVY3",label:"label-ZOx_CVY3",dropdownMenu:"dropdownMenu-ZOx_CVY3",sessionStart:"sessionStart-ZOx_CVY3",sessionEnd:"sessionEnd-ZOx_CVY3",sessionInputContainer:"sessionInputContainer-ZOx_CVY3",sessionDash:"sessionDash-ZOx_CVY3",inputGroup:"inputGroup-ZOx_CVY3",textarea:"textarea-ZOx_CVY3",inlineGroup:"inlineGroup-ZOx_CVY3",hasTooltip:"hasTooltip-ZOx_CVY3"}},24712:e=>{e.exports={content:"content-tBgV1m0B",cell:"cell-tBgV1m0B",inner:"inner-tBgV1m0B",first:"first-tBgV1m0B",inlineCell:"inlineCell-tBgV1m0B",fill:"fill-tBgV1m0B",top:"top-tBgV1m0B",topCenter:"topCenter-tBgV1m0B",offset:"offset-tBgV1m0B",inlineRow:"inlineRow-tBgV1m0B",grouped:"grouped-tBgV1m0B",separator:"separator-tBgV1m0B",groupSeparator:"groupSeparator-tBgV1m0B",big:"big-tBgV1m0B",adaptive:"adaptive-tBgV1m0B",checkableTitle:"checkableTitle-tBgV1m0B"}},80128:e=>{e.exports={wrap:"wrap-QutFvTLS",labelWrap:"labelWrap-QutFvTLS",label:"label-QutFvTLS",hasTooltip:"hasTooltip-QutFvTLS"}},82161:(e,t,n)=>{"use strict";n.d(t,{splitThousands:()=>s});var o=n(50335);function s(e,t=" "){let n=e+"";-1!==n.indexOf("e")&&(n=function(e){return(0,o.fixComputationError)(e).toFixed(10).replace(/\.?0+$/,"")}(Number(e)));const s=n.split(".");return s[0].replace(/\B(?=(\d{3})+(?!\d))/g,t)+(s[1]?"."+s[1]:"")}},83207:(e,t,n)=>{"use strict";n.d(t,{bind:()=>a,setter:()=>i});var o=n(50959),s=n(76917),r=n(27365);function a(e){var t;return t=class extends o.PureComponent{constructor(){super(...arguments),this._onChange=(e,t,n)=>{const{setValue:o}=this.context,{onChange:s}=this.props;i(o,s)(e,t,n)}} render(){const{input:t}=this.props,{values:n,model:s}=this.context;return o.createElement(e,{...this.props,value:n[t.id],tzName:(0,r.getTimezoneName)(s),onChange:this._onChange})}},t.contextType=s.PropertyContext,t}function i(e,t){return(n,o,s)=>{e(o,n,s),t&&t(n,o,s)}}},76917:(e,t,n)=>{"use strict";n.d(t,{PropertyContainer:()=>u,PropertyContext:()=>c});var o=n(50959),s=n(50151),r=n(44352),a=n(36298);const i=(0,n(59224).getLogger)("Platform.GUI.StudyInputPropertyContainer"),l=new a.TranslatedString("change {propertyName} property",r.t(null,void 0,n(18567))),c=o.createContext(null);class u extends o.PureComponent{constructor(e){super(e),this._setValue=(e,t,o)=>{const{property:c,model:u}=this.props,p=(0,s.ensureDefined)(c.child(e));i.logNormal(`Changing property "${e}" value from "${c.value()}" to "${t}"`);const d=new a.TranslatedString(o,function(e){return r.t(e,{context:"input"},n(88601))}(o));u.setProperty(p,t,l.format({propertyName:d}))};const{property:t}=e,o={};t.childNames().forEach((e=>{const n=(0,s.ensureDefined)(t.child(e));o.hasOwnProperty(e)||(o[e]=n.value())})),this.state=o}componentDidMount(){const{property:e,onStudyInputChange:t}=this.props;e.childNames().forEach((n=>{(0,s.ensureDefined)(e.child(n)).subscribe(this,(e=>{const o=e.value();i.logNormal(`Property "${n}" updated to value "${o}"`),this.setState({[n]:o}),null==t||t(o,n)}))}))}componentWillUnmount(){const{property:e}=this.props;e.childNames().forEach((t=>{(0,s.ensureDefined)(e.child(t)).unsubscribeAll(this)}))}render(){const{study:e,model:t,children:n}=this.props,s={study:e,model:t,values:this.state,setValue:this._setValue};return o.createElement(c.Provider,{value:s},n)}}},51717:(e,t,n)=>{"use strict";n.d(t,{ModelContext:()=>s,bindModel:()=>r});var o=n(50959);const s=o.createContext(null);function r(e,t){return o.createElement(s.Consumer,null,(n=>n?o.createElement(e,{...Object.assign({model:n},t)}):null))}},41594:(e,t,n)=>{"use strict";n.d(t,{StylePropertyContainer:()=>a,StylePropertyContext:()=>r,bindPropertyContext:()=>i});var o=n(50959),s=n(51717);const r=o.createContext(null);class a extends o.PureComponent{constructor(){super(...arguments),this._setValue=(e,t,n)=>{const{model:o}=this.props;o.setProperty(e,t,n)}}componentDidMount(){const{property:e}=this.props;e.subscribe(this,(()=>this.forceUpdate()))}componentWillUnmount(){const{property:e}=this.props;e.unsubscribeAll(this)}render(){const e={setValue:this._setValue};return o.createElement(r.Provider,{value:e},this.props.children)}}function i(e,t){return(0,s.bindModel)((({model:n})=>o.createElement(a,{model:n,property:t.property},o.createElement(e,{...t}))),t)}},76694:(e,t,n)=>{"use strict";n.d(t,{IconGroupWrapper:()=>r});var o=n(50959),s=n(49934);function r(e){const{children:t}=e;return o.createElement("div",{className:s.wrapper},t)}},39847:(e,t,n)=>{"use strict";n.d(t,{InputTooltip:()=>E});var o=n(50959),s=n(97754),r=n(90186),a=n(9745),i=n(5325);function l(){const[e,t]=(0,o.useState)(!1);return(0,o.useEffect)((()=>{t(i.mobiletouch)}),[]),e} var c=n(38952),u=n(38528),p=n(82353),d=n(27941),h=n(99084),m=n(30162),v=n(78370),g=n.n(v);const b={info:d,question:p,check:h,exclamation:m};function f(e){return o.createElement("span",{...(0,c.renameRef)(e),className:s(e.className,g()["no-active-state"])})}function C(e){const{icon:t,intent:n="default",ariaLabel:i,tooltip:c,className:p,reference:d,showTooltipOnTouch:h=!0,renderComponent:m=f,showTooltip:v,hideTooltip:C,onFocus:y,onBlur:E,onClick:S,tabIndex:w}=e,x=l()?h:Boolean(c),_=o.useRef(null),N=(0,u.useMergedRefs)([d,_]),T=function(e){const{tabIndex:t=0,showTooltip:n,hideTooltip:s,onFocus:r,onBlur:a,onClick:i,ref:c}=e,u=l();return{onBlur:(0,o.useCallback)((e=>{s&&s(),a&&a(e)}),[s,a]),onFocus:(0,o.useCallback)((e=>{n&&n(e.currentTarget,{tooltipDelay:200}),r&&r(e)}),[n,r]),onClick:(0,o.useCallback)((e=>{var t;u&&(null===(t=c.current)||void 0===t||t.focus()),i&&i(e)}),[i]),tabIndex:t}}({showTooltip:v,hideTooltip:C,onFocus:y,onBlur:E,onClick:S,ref:_,tabIndex:w}),I=o.useMemo((()=>function(e,t){return t?b[t]:"success"===e?b.check:b.exclamation}(n,t)),[t,n]);return o.createElement(m,{className:s(p,g()["icon-wrapper"],g()[`intent-${n}`],x&&c&&g()["with-tooltip"],x&&c&&"apply-common-tooltip"),title:x?c:void 0,"aria-label":i,reference:N,...(0,r.filterDataProps)(e),...T},o.createElement(a.Icon,{"aria-hidden":!0,icon:I,className:g().icon}))}var y=n(38780);function E(e){const{className:t,title:n}=e;return o.createElement(C,{icon:"info",className:t,ariaLabel:n,showTooltip:y.showOnElement,hideTooltip:y.hide,tooltip:n,tabIndex:-1})}},12949:(e,t,n)=>{"use strict";n.d(t,{InputRow:()=>ne});var o=n(44352),s=n(50959),r=n(50151),a=n(33703),i=n(96438),l=n(47510),c=n(4781),u=n(97754),p=n.n(u),d=n(31261),h=n(83207),m=n(90009),v=n(27698);class g extends s.PureComponent{constructor(){super(...arguments),this._onChange=e=>{const{input:{id:t,name:n},onChange:o}=this.props;o(e.currentTarget.value,t,n)}}render(){const{input:{defval:e},value:t,disabled:n,onBlur:o,onKeyDown:r,hasTooltip:a}=this.props;return s.createElement(d.InputControl,{className:p()(v.input,a&&v.hasTooltip),value:void 0===t?e:t,onChange:this._onChange,onBlur:o,onKeyDown:r,disabled:n,maxLength:4096})}}const b=(0,m.debounced)(g),f=(0,h.bind)(b);var C=n(55141),y=n(11062);function E(e){const{className:t}=e,n=(0,s.useContext)(y.PropertyTable.InlineRowContext);return s.createElement("div",{className:u(v.inputGroup,n&&v.inlineGroup,t)},e.children)}var S=n(36565);function w(e=""){const[,t="",n="",o="",s=""]=Array.from(e.match(/^(\d\d)(\d\d)-(\d\d)(\d\d)/)||[]);return[`${t}:${n}`,`${o}:${s}`]}class x extends s.PureComponent{constructor(e){super(e),this._onStartPick=e=>{this.setState({startTime:e},this._onChange)},this._onEndPick=e=>{this.setState({endTime:e},this._onChange)},this._onChange=()=>{const{input:{id:e,name:t},onChange:n}=this.props,{startTime:o,endTime:s}=this.state;n(o.replace(":","")+"-"+s.replace(":",""),e,t)};const t=e.value||e.input.defval,[n,o]=w(t);this.state={prevValue:t,startTime:n,endTime:o}}render(){ const{startTime:e,endTime:t}=this.state,{hasTooltip:n,disabled:o}=this.props;return s.createElement(E,{className:p()(n&&v.hasTooltip)},s.createElement("div",{className:v.sessionStart},s.createElement(S.TimeInput,{className:p()(v.input,v.sessionInputContainer),name:"start",value:(0,r.ensureDefined)(e),onChange:this._onStartPick,disabled:o}),s.createElement("span",{className:v.sessionDash}," — ")),s.createElement("div",{className:v.sessionEnd},s.createElement(S.TimeInput,{className:p()(v.input,v.sessionInputContainer),name:"end",value:(0,r.ensureDefined)(t),onChange:this._onEndPick,disabled:o})))}static getDerivedStateFromProps(e,t){if(e.value===t.prevValue)return t;const[n,o]=w(e.value);return{prevValue:e.value,startTime:n,endTime:o}}}const _=(0,h.bind)(x);var N=n(14483),T=n(42856),I=n(37591),k=n(76917),P=n(90405);class B extends s.PureComponent{constructor(){super(...arguments),this._onChange=e=>{const{input:{id:t,name:n},onChange:o}=this.props;o(e,t,n)}}render(){const{input:{id:e,defval:t,options:r,optionsTitles:a},value:i,disabled:l,hasTooltip:c}=this.props,u=r.map((e=>{const t=a&&a[e]?a[e]:e;return{value:e,content:o.t(t,{context:"input"},n(88601))}})),d=void 0!==i&&r.includes(i)?i:t;return s.createElement(P.Select,{id:e,className:p()(v.input,c&&v.hasTooltip),menuClassName:v.dropdownMenu,value:d,items:u,onChange:this._onChange,disabled:l})}}const D=(0,h.bind)(B);var M=n(73146),V=n(28853);const O={open:o.t(null,void 0,n(38466)),high:o.t(null,void 0,n(39337)),low:o.t(null,void 0,n(3919)),close:o.t(null,void 0,n(36962)),hl2:o.t(null,void 0,n(91815)),hlc3:o.t(null,void 0,n(40771)),ohlc4:o.t(null,void 0,n(12504)),hlcc4:o.t(null,void 0,n(9523))};class F extends s.PureComponent{render(){const{input:e}=this.props,{study:t,model:n}=this.context;let o={...O};delete o.hlcc4;const i=(0,M.createAdapter)(t);if(t&&this._isStudy(t)&&t.isChildStudy()){const t=(0,a.getInputValue)(i.inputs()[e.id]),n=i.parentSourceForInput(t);if((0,V.isStudy)(n)){const t=n.title(I.TitleDisplayTarget.StatusLine),s=T.StudyMetaInfo.getChildSourceInputTitles(e,n.metaInfo(),t);o={...o,...s}}}if(N.enabled("study_on_study")&&t&&this._isStudy(t)&&(t.isChildStudy()||T.StudyMetaInfo.canBeChild(t.metaInfo()))){const e=[t,...i.getAllChildren()];n.model().allStudies().filter((t=>t.canHaveChildren()&&!e.includes(t))).forEach((e=>{const t=e.title(I.TitleDisplayTarget.StatusLine,!0,void 0,!0),n=e.id(),s=e.metaInfo(),a=s.styles,i=s.plots||[];if(1===i.length)o[n+"$0"]=t;else if(i.length>1){const e=i.reduce(((e,o,s)=>{if(!T.StudyMetaInfo.canPlotBeSourceOfChildStudy(o.type))return e;let i;try{i=(0,r.ensureDefined)((0,r.ensureDefined)(a)[o.id]).title}catch(e){i=o.id}return{...e,[`${n}$${s}`]:`${t}: ${i}`}}),{});o={...o,...e}}}))}const l={...e,type:"text",options:Object.keys(o),optionsTitles:o};return s.createElement(D,{...this.props,input:l})}_isStudy(e){return!e.hasOwnProperty("isInputsStudy")}}F.contextType=k.PropertyContext;var R=n(36274),L=n(94025) -;const W=void 0,A=["1","3","5","15","30","45","60","120","180","240","1D","1W","1M","3M","6M","12M"],q=["1S","5S","10S","15S","30S"];class U extends s.PureComponent{constructor(){super(...arguments),this._onChange=e=>{const{input:{id:t,name:n},onChange:o}=this.props;o(e,t,n)}}render(){const{input:e,value:t,disabled:r,hasTooltip:a}=this.props,i=R.Interval.parse(void 0===t?e.defval:t),l=i.isValid()?i.value():t,c=W?W.get().filter((e=>!R.Interval.parse(e).isRange())):[],u=(0,L.mergeResolutions)(A,(0,L.isSecondsEnabled)()?q:[],c);return u.unshift(""),s.createElement(P.Select,{id:e.id,className:p()(v.input,v.resolution,a&&v.hasTooltip),menuClassName:p()(v.dropdownMenu,v.resolution),items:(d=u,d.map((e=>({value:e,content:""===e?o.t(null,void 0,n(94551)):(0,L.getTranslatedResolutionModel)(e).hint})))),value:l,onChange:this._onChange,disabled:r});var d}}const z=(0,h.bind)(U);var Z=n(41552),G=n(41594);class H extends s.PureComponent{render(){return s.createElement(k.PropertyContext.Consumer,null,(e=>e?this._getColorInputWithContext(e):null))}_getColorInputWithContext(e){var t;const{input:{id:n},disabled:o,hasTooltip:r}=this.props,{model:a,study:i}=e;if("properties"in i||"tempProperties"in i){const e="properties"in i?i.properties().inputs[n]:null===(t=i.tempProperties)||void 0===t?void 0:t.inputs.child(n);return s.createElement(G.StylePropertyContainer,{model:a,property:e},s.createElement(Z.ColorWithThicknessSelect,{className:p()(r&&v.hasTooltip),color:e,disabled:o}))}return null}}var K=n(85528),Y=n(76056),$=n(23935),j=n(27365),X=n(93071);const Q=(0,h.bind)((function(e){const{value:t,onChange:n,input:o,tzName:r,hasTooltip:a}=e,{id:i,name:l,defval:c}=o,u=(0,s.useMemo)((()=>Number(null!=t?t:c)),[t,c]),d=(0,s.useMemo)((()=>(0,j.getChartTimezoneOffsetMs)(u,r)),[u,r]),h=(0,s.useMemo)((()=>{const e=new Date(u+d+v(u));return e.setSeconds(0),e}),[u,d]),m=(0,s.useMemo)((()=>(0,$.twoDigitsFormat)(h.getHours())+":"+(0,$.twoDigitsFormat)(h.getMinutes())),[h]);return s.createElement("div",{className:p()(X.container,a&&X.hasTooltip)},s.createElement("div",{className:X.datePickerWrapper},s.createElement(K.DatePicker,{InputComponent:Y.DateInput,initial:h,onPick:function(e){if(null===e)return;const t=new Date(h);t.setFullYear(e.getFullYear()),t.setMonth(e.getMonth()),t.setDate(e.getDate()),n(g(t),i,l)},revertInvalidData:!0})),s.createElement("div",{className:X.timePickerWrapper},s.createElement(S.TimeInput,{value:m,onChange:function(e){const[t,o]=e.split(":"),s=new Date(h);s.setHours(Number(t)),s.setMinutes(Number(o)),n(g(s),i,l)}})));function v(e){return 60*new Date(e).getTimezoneOffset()*1e3}function g(e){return e.valueOf()-d-v(u)}}));class J extends s.PureComponent{render(){const{input:e,disabled:t,onChange:n,tzName:o,hasTooltip:r}=this.props;if((0,a.isStudyInputOptionsInfo)(e))return s.createElement(D,{input:e,disabled:t,onChange:n,hasTooltip:r});switch(e.type){case"integer":return s.createElement(i.IntegerInput,{input:e,disabled:t,onChange:n,hasTooltip:r});case"float":case"price":return s.createElement(l.FloatInput,{input:e,disabled:t, -onChange:n,hasTooltip:r});case"bool":return s.createElement(c.BoolInput,{input:e,disabled:t,onChange:n,hasTooltip:r});case"text":return s.createElement(f,{input:e,disabled:t,onChange:n,hasTooltip:r});case"symbol":return s.createElement(C.SymbolInput,{input:e,disabled:t,onChange:n,hasTooltip:r});case"session":return s.createElement(_,{input:e,disabled:t,onChange:n,hasTooltip:r});case"source":return s.createElement(F,{input:e,disabled:t,onChange:n,hasTooltip:r});case"resolution":return s.createElement(z,{input:e,disabled:t,onChange:n,hasTooltip:r});case"time":return s.createElement(Q,{input:e,tzName:o,onChange:n,hasTooltip:r});case"color":return s.createElement(H,{input:e,disabled:t,onChange:n,hasTooltip:r});default:return null}}}var ee=n(39847),te=n(76694);class ne extends s.PureComponent{render(){const{label:e,children:t,input:a,disabled:i,onChange:l,labelAlign:c,grouped:u,tooltip:p,solutionId:d,offset:h}=this.props,m=Boolean(p);return s.createElement(y.PropertyTable.Row,null,s.createElement(y.PropertyTable.Cell,{placement:"first",verticalAlign:c,grouped:u,offset:h},void 0!==e?e:o.t((0,r.ensureDefined)(a).name,{context:"input"},n(88601))),s.createElement(y.PropertyTable.Cell,{placement:"last",grouped:u},t||s.createElement(J,{input:(0,r.ensureDefined)(a),onChange:l,disabled:i,hasTooltip:m}),m&&s.createElement(te.IconGroupWrapper,null,p&&s.createElement(ee.InputTooltip,{title:p}),!1)))}}},39828:(e,t,n)=>{"use strict";n.d(t,{InputsTabContent:()=>A});var o,s=n(50959),r=n(50151),a=n(44352),i=n(76917),l=n(11062),c=n(57733),u=n(97754),p=n.n(u),d=n(88400),h=n.n(d);const m=(0,c.makeSwitchGroupItem)(((o=class extends s.PureComponent{constructor(){super(...arguments),this._onChange=()=>{this.props.onChange&&this.props.onChange(this.props.value)}}render(){const e=u(this.props.className,h().radio,{[h().reverse]:Boolean(this.props.labelPositionReverse)}),t=u(h().label,{[h().disabled]:this.props.disabled}),n=u(h().box,{[h().noOutline]:-1===this.props.tabIndex});let o=null;return this.props.label&&(o=s.createElement("span",{className:t},this.props.label)),s.createElement("label",{className:e},s.createElement("span",{className:h().wrapper,title:this.props.title},s.createElement("input",{id:this.props.id,tabIndex:this.props.tabIndex,autoFocus:this.props.autoFocus,role:this.props.role,className:h().input,type:"radio",name:this.props.name,checked:this.props.checked,disabled:this.props.disabled,value:this.props.value,onChange:this._onChange,ref:this.props.reference,"aria-describedby":this.props["aria-describedby"],"aria-invalid":this.props["aria-invalid"]}),s.createElement("span",{className:n})),o)}}).defaultProps={value:"on"},o));var v=n(55141),g=n(83207),b=n(39847),f=n(76694),C=n(27698);function y(e){const{children:t,input:o,disabled:u,onChange:p,grouped:d,tooltip:h,solutionId:y}=e,E=(0,s.useContext)(i.PropertyContext),{values:S,setValue:w}=(0,r.ensureNotNull)(E),x=S[o.id],[_,N]=(0,s.useState)(x?"another-symbol":"main-symbol"),[T,I]=(0,s.useState)(x),k=Boolean(h);return(0,s.useEffect)((()=>{x&&I(x)}),[x]), -s.createElement(c.SwitchGroup,{name:`symbol-source-${o.id}`,values:[_],onChange:function(e){N(e),"main-symbol"===e?(0,g.setter)(w)("",o.id,o.name):"another-symbol"===e&&T&&(0,g.setter)(w,p)(T,o.id,o.name)}},s.createElement(l.PropertyTable.Row,null,s.createElement(l.PropertyTable.Cell,{colSpan:2,placement:"first",grouped:d},s.createElement(m,{value:"main-symbol",className:C.checkbox,disabled:u,label:s.createElement("span",{className:C.label},a.t(null,{context:"input"},n(88046)))}))),s.createElement(l.PropertyTable.Row,null,s.createElement(l.PropertyTable.Cell,{placement:"first",grouped:d},s.createElement(m,{value:"another-symbol",className:C.checkbox,disabled:u,label:s.createElement("span",{className:C.label},a.t(null,{context:"input"},n(73755)))})),s.createElement(l.PropertyTable.Cell,{placement:"last",grouped:d},t||s.createElement(v.SymbolInput,{input:(0,r.ensureDefined)(o),onChange:p,disabled:u||"main-symbol"===_,hasTooltip:k}),k&&s.createElement(f.IconGroupWrapper,null,h&&s.createElement(b.InputTooltip,{title:h}),!1))))}var E=n(4781);class S extends s.PureComponent{render(){const{label:e,input:t,tooltip:n,solutionId:o}=this.props,r=Boolean(n);return s.createElement(l.PropertyTable.Row,null,s.createElement(l.PropertyTable.Cell,{placement:"first",colSpan:2},s.createElement(E.BoolInput,{label:e,input:t,hasTooltip:r}),r&&s.createElement(f.IconGroupWrapper,null,n&&s.createElement(b.InputTooltip,{title:n}),!1)))}}var w=n(12949),x=n(2568),_=n(67029),N=n(90009);class T extends s.PureComponent{constructor(){super(...arguments),this._onChange=e=>{const{input:{id:t,name:n},onChange:o}=this.props;o(e.currentTarget.value,t,n)}}render(){const{input:{defval:e},value:t,disabled:n,onBlur:o,onKeyDown:r}=this.props;return s.createElement(x.Textarea,{className:p()(C.input,C.textarea,_.InputClasses.FontSizeMedium),value:void 0===t?e:t,onChange:this._onChange,onBlur:o,onKeyDown:r,disabled:n,maxLength:4096})}}const I=(0,N.debounced)(T),k=(0,g.bind)(I);var P=n(80128);function B(e){const{input:t,label:n,tooltip:o,solutionId:r}=e,a=Boolean(o);return s.createElement(l.PropertyTable.Row,null,s.createElement(l.PropertyTable.Cell,{placement:"first",colSpan:2,className:P.wrap},s.createElement("div",{className:P.labelWrap},s.createElement("span",{className:p()(P.label,a&&P.hasTooltip)},n),a&&s.createElement(f.IconGroupWrapper,null,o&&s.createElement(b.InputTooltip,{title:o}),!1)),s.createElement(k,{input:t})))}function D(e){const{input:t,tooltip:o,solutionId:r}=e;return"symbol"===t.type&&t.optional?s.createElement(y,{input:t,tooltip:o,solutionId:r}):"bool"===t.type?s.createElement(S,{label:a.t(t.name,{context:"input"},n(88601)),input:t,tooltip:o,solutionId:r}):"text_area"===t.type?s.createElement(B,{label:a.t(t.name,{context:"input"},n(88601)),input:t,tooltip:o,solutionId:r}):s.createElement(w.InputRow,{labelAlign:function(e){switch(e){case"session":return"adaptive";case"time":return"topCenter";default:return}}(t.type),input:t,tooltip:o,solutionId:r})}var M=n(86067),V=n(17611);function O(e){const{content:t}=e;let n -;return s.createElement(l.PropertyTable.InlineRowContext.Provider,{value:!0},s.createElement("div",{className:V.inlineRow},t.children.map(((e,o)=>(void 0!==e.tooltip&&(n=e.tooltip),s.createElement(D,{key:e.id,input:e,tooltip:o===t.children.length-1?n:void 0}))))))}var F=n(64420),R=n(26278);function L(e){const{content:t}=e;return(0,F.isGroup)(t)?(0,F.isInputInlines)(t)?s.createElement(O,{content:t}):s.createElement(s.Fragment,null,s.createElement("div",{className:R.titleWrap},s.createElement(M.GroupTitleSection,{title:a.t(t.id,{context:"input"},n(88601)),name:t.id})),t.children.map((e=>(0,F.isGroup)(e)?s.createElement(O,{key:e.id,content:e}):s.createElement(D,{key:e.id,input:e,tooltip:e.tooltip,solutionId:e.solutionId}))),s.createElement("div",{className:R.groupFooter})):s.createElement(D,{input:t,tooltip:t.tooltip,solutionId:t.solutionId})}const W={offset:a.t(null,void 0,n(89298))};class A extends s.PureComponent{render(){const{reference:e,inputs:t,property:n,study:o,studyMetaInfo:a,model:i,onStudyInputChange:c,className:u}=this.props,{offset:p,offsets:d}=n;return s.createElement(l.PropertyTable,{reference:e,className:u},s.createElement(q,{study:o,model:i,property:n.inputs,inputs:t,onStudyInputChange:c}),p&&this._createOffsetSection(p,(0,r.ensureDefined)(a.offset)),d&&d.childNames().map((e=>{var t;const n=d.childs()[e];return this._createOffsetSection(n,(0,r.ensureDefined)(null===(t=a.offsets)||void 0===t?void 0:t[e]))})))}_createOffsetSection(e,t){const n=e.childs();return s.createElement(q,{key:`offset_${t.title}`,study:this.props.study,model:this.props.model,inputs:[U(n,t)],property:e})}}function q(e){const{study:t,model:n,inputs:o,property:r,onStudyInputChange:a}=e,l=o,c=(0,s.useMemo)((()=>(0,F.getInputGroups)(l)),[l]);return s.createElement(i.PropertyContainer,{property:r,study:t,model:n,onStudyInputChange:a},!1,!1,c.map((e=>s.createElement(s.Fragment,{key:e.id},s.createElement(L,{content:e}),!1))))}function U(e,t){return{id:"val",name:t.title||W.offset,defval:e.val.value(),type:"integer",min:t.min,max:t.max}}},4781:(e,t,n)=>{"use strict";n.d(t,{BoolInput:()=>u,BoolInputComponent:()=>c});var o=n(50959),s=n(15294),r=n(97754),a=n.n(r),i=n(83207),l=n(27698);class c extends o.PureComponent{constructor(){super(...arguments),this._onChange=()=>{const{input:{id:e,name:t},value:n,onChange:o}=this.props;o(!n,e,t)}}render(){const{input:{defval:e},value:t,disabled:n,label:r,hasTooltip:i}=this.props,c=void 0===t?e:t;return o.createElement(s.Checkbox,{className:a()(l.checkbox,i&&l.hasTooltip),disabled:n,checked:c,onChange:this._onChange,label:o.createElement("span",{className:l.label},r),labelAlignBaseline:!0})}}const u=(0,i.bind)(c)},90009:(e,t,n)=>{"use strict";n.d(t,{debounced:()=>r});var o=n(50959);const s={blur:0,commit:0,change:1/0};function r(e,t=s){return class extends o.PureComponent{constructor(e){super(e),this._onChange=(e,n,o)=>{const s=t.change;s?(clearTimeout(this._timeout),this.setState({value:e},(()=>{s!==1/0&&(this._timeout=setTimeout((()=>this._flush()),s))}))):this._flush(e)},this._onBlur=()=>{ -this._debounce(t.blur);const{onBlur:e}=this.props;e&&e()},this._onKeyDown=e=>{13===e.keyCode&&this._debounce(t.commit)},this.state={prevValue:e.value,value:e.value}}componentWillUnmount(){this._flush()}render(){const{value:t}=this.state;return o.createElement(e,{...this.props,value:t,onChange:this._onChange,onBlur:this._onBlur,onKeyDown:this._onKeyDown})}static getDerivedStateFromProps(e,t){return e.value===t.prevValue?t:{prevValue:e.value,value:e.value}}_debounce(e){e?(clearTimeout(this._timeout),e!==1/0&&(this._timeout=setTimeout((()=>this._flush()),e))):this.setState((e=>{this._flush(e.value)}))}_flush(e){const{input:{id:t,name:n},onChange:o}=this.props,{prevValue:s,value:r}=this.state;clearTimeout(this._timeout);const a=void 0!==e?e:r;void 0!==a&&a!==s&&o(a,t,n)}}}},47510:(e,t,n)=>{"use strict";n.d(t,{FloatInput:()=>d,FloatInputComponent:()=>p});var o=n(50959),s=n(97754),r=n.n(s),a=n(95052),i=n(83207),l=n(90009),c=n(27698);class u extends o.PureComponent{render(){const{hasTooltip:e}=this.props;return o.createElement(a.NumericInput,{...this.props,className:r()(c.input,e&&c.hasTooltip),stretch:!1})}}const p=(0,l.debounced)(u,{change:1/0,commit:0,blur:0}),d=(0,i.bind)(p)},96438:(e,t,n)=>{"use strict";n.d(t,{IntegerInput:()=>d,IntegerInputComponent:()=>p});var o=n(50959),s=n(97754),r=n.n(s),a=n(83207),i=n(90009),l=n(95052),c=n(27698);class u extends o.PureComponent{render(){const{hasTooltip:e}=this.props;return o.createElement(l.NumericInput,{...this.props,mode:"integer",className:r()(c.input,e&&c.hasTooltip),stretch:!1})}}const p=(0,i.debounced)(u,{change:1/0,commit:0,blur:0}),d=(0,a.bind)(p)},95052:(e,t,n)=>{"use strict";n.d(t,{NumericInput:()=>y});var o=n(50959),s=n(50151),r=n(44352),a=n(60521),i=n(49483),l=n(92399),c=n(82161),u=n(38223);var p=n(87663),d=n(37160);const h=r.t(null,void 0,n(35563)),m=new class{constructor(e=" "){this._divider=e}format(e){const t=(0,c.splitThousands)(e,this._divider);return(0,u.isRtl)()?(0,u.startWithLTR)(t):t}parse(e){const t=(0,u.stripLTRMarks)(e).split(this._divider).join(""),n=Number(t);return isNaN(n)||/e/i.test(t)?{res:!1}:{res:!0,value:n,suggest:this.format(n)}}},v=/^-?[0-9]*$/,g=9e15;class b extends o.PureComponent{constructor(e){super(e),this._onFocus=e=>{this.setState({focused:!0}),this.props.onFocus&&this.props.onFocus(e)},this._onBlur=e=>{this.setState({focused:!1}),!1!==this.props.shouldApplyValueOnBlur&&(this.setState({displayValue:f(this.props,this.props.value)}),this.props.errorHandler&&this.props.errorHandler(!1)),this.props.onBlur&&this.props.onBlur(e)},this._onValueChange=e=>{const t=e.target.value;if(void 0!==this.props.onEmptyString&&""===t&&this.props.onEmptyString(),"integer"===this.props.mode&&!v.test(t))return;const n=C(t,this.props.formatter),o=n.res?this._checkValueBoundaries(n.value):{isPassed:!1,msg:void 0},s=n.res&&!o.isPassed,r=n.res&&n.suggest&&!this.state.focused?n.suggest:t,a=s&&o.msg?o.msg:h;this.setState({displayValue:r,errorMsg:a}),n.res&&o.isPassed&&this.props.onValueChange(n.value,"input"), -this.props.errorHandler&&this.props.errorHandler(!n.res||s)},this._onValueByStepChange=e=>{const{roundByStep:t=!0,step:n=1,uiStep:o,min:s=n,formatter:r}=this.props,i=C(this.state.displayValue,r),l=null!=o?o:n;let c=n;if(i.res){const o=new a.Big(i.value),r=o.minus(s).mod(n);let u=o.plus(e*l);!r.eq(0)&&t&&(u=u.plus((e>0?0:1)*l).minus(r)),c=u.toNumber()}const{isPassed:u,clampedValue:p}=this._checkValueBoundaries(c);c=u?c:p,this.setState({displayValue:f(this.props,c)}),this.props.onValueChange(c,"step"),this.props.errorHandler&&this.props.errorHandler(!1)};const{value:t}=e;this.state={value:t,displayValue:f(e,t),focused:!1,errorMsg:h}}render(){var e;return o.createElement(l.NumberInputView,{id:this.props.id,inputMode:null!==(e=this.props.inputMode)&&void 0!==e?e:i.CheckMobile.iOS()?void 0:"numeric",borderStyle:this.props.borderStyle,fontSizeStyle:this.props.fontSizeStyle,value:this.state.displayValue,forceShowControls:this.props.forceShowControls,className:this.props.className,inputClassName:this.props.inputClassName,button:this.props.button,placeholder:this.props.placeholder,innerLabel:this.props.innerLabel,endSlot:this.props.endSlot,disabled:this.props.disabled,warning:this.props.warning,error:this.props.error,errorMessage:this.props.errorMessage||this.state.errorMsg,onValueChange:this._onValueChange,onValueByStepChange:this._onValueByStepChange,containerReference:this.props.containerReference,inputReference:this.props.inputReference,onClick:this.props.onClick,onFocus:this._onFocus,onBlur:this._onBlur,onKeyDown:this.props.onKeyDown,controlDecKeyCodes:this.props.controlDecKeyCodes,controlIncKeyCodes:this.props.controlIncKeyCodes,title:this.props.title,intent:this.props.intent,highlight:this.props.highlight,highlightRemoveRoundBorder:this.props.highlightRemoveRoundBorder,stretch:this.props.stretch,autoSelectOnFocus:!i.CheckMobile.any(),"data-name":this.props["data-name"]})}getClampedValue(){const{min:e=-1/0,max:t=g}=this.props,n=C(this.state.displayValue,this.props.formatter);return n.res?(0,d.clamp)(n.value,e,t):null}static getDerivedStateFromProps(e,t){const{alwaysUpdateValueFromProps:n,value:o}=e;return t.focused&&!n||t.value===o?null:{value:o,displayValue:f(e,o)}}_checkValueBoundaries(e){var t,o,s,a;const{min:i=-1/0,max:l=g}=this.props,c=function(e,t,n){const o=e>=t,s=e<=n;return{passMin:o,passMax:s,pass:o&&s,clamped:(0,d.clamp)(e,t,n)}}(e,i,l);let u;return c.passMax||(u=null!==(o=null===(t=this.props.boundariesErrorMessages)||void 0===t?void 0:t.greaterThanMax)&&void 0!==o?o:r.t(null,{replace:{max:String(l)}},n(2607))),c.passMin||(u=null!==(a=null===(s=this.props.boundariesErrorMessages)||void 0===s?void 0:s.lessThanMin)&&void 0!==a?a:r.t(null,{replace:{min:String(i)}},n(53669))),{isPassed:c.pass,msg:u,clampedValue:c.clamped}}}function f(e,t){const{useFormatter:n=!0,formatter:o,mode:s}=e;return n&&"integer"!==s?function(e,t=m){return null!==e?t.format(e):""}(t,o):function(e){if(null===e)return"";return p.NumericFormatter.formatNoE(e)}(t)}function C(e,t=m){return t.parse?t.parse(e):{res:!1, -error:"Formatter does not support parse"}}class y extends o.PureComponent{constructor(){super(...arguments),this._container=null,this._handleContainerRef=e=>this._container=e,this._onChange=(e,t)=>{const{input:{id:n,name:o},onChange:s,onBlur:r}=this.props;s(e,n,o),"step"===t&&r&&r()},this._onBlur=e=>{const{onBlur:t}=this.props;if(t){const n=(0,s.ensureNotNull)(this._container);n.contains(document.activeElement)||n.contains(e.relatedTarget)||t()}}}render(){const{input:{defval:e,min:t,max:n,step:s},value:r,disabled:a,onKeyDown:i,className:l,mode:c,stretch:u}=this.props;return o.createElement(b,{className:l,value:Number(void 0===r?e:r),min:t,max:n,step:s,mode:c,onBlur:this._onBlur,onValueChange:this._onChange,onKeyDown:i,disabled:a,containerReference:this._handleContainerRef,fontSizeStyle:"medium",roundByStep:!1,stretch:u})}}},55141:(e,t,n)=>{"use strict";n.d(t,{SymbolInput:()=>p,getInternalSymbolName:()=>c});var o=n(50959),s=n(50151),r=n(76917),a=n(83207),i=n(73146),l=n(48897);function c(e,t){const n=(0,i.createAdapter)(t).resolvedSymbolInfoBySymbol(e);return n&&(n.ticker||n.full_name)?n.ticker||n.full_name:e}function u(e,t){const n=(0,i.createAdapter)(t).resolvedSymbolInfoBySymbol(e);return null===n?e:n.name}const p=(0,a.bind)((function(e){const t=(0,o.useContext)(r.PropertyContext),{study:n}=(0,s.ensureNotNull)(t),{input:{defval:a},value:i}=e;return o.createElement(l.SymbolInputsButton,{...e,value:u(i||a||"",n),study:n})}))},41552:(e,t,n)=>{"use strict";n.d(t,{ColorWithThicknessSelect:()=>g});var o=n(50959),s=n(24377),r=n(44352),a=n(36298),i=n(87095),l=n(41594),c=n(58593),u=n(17948),p=n(51768);const d=new a.TranslatedString("change thickness",r.t(null,void 0,n(95657))),h=new a.TranslatedString("change color",r.t(null,void 0,n(13066))),m=new a.TranslatedString("change opacity",r.t(null,void 0,n(17023))),v=[1,2,3,4];class g extends o.PureComponent{constructor(){super(...arguments),this._trackEventLabel=null,this._getTransparencyValue=()=>{const{transparency:e}=this.props;return e?e.value():0},this._getOpacityValue=()=>{const{color:e}=this.props,t=(0,u.getPropertyValue)(e);if(t)return(0,i.isHexColor)(t)?(0,i.transparencyToAlpha)(this._getTransparencyValue()):(0,s.parseRgba)(t)[3]},this._getColorValueInHex=()=>{const{color:e}=this.props,t=(0,u.getPropertyValue)(e);return t?(0,i.isHexColor)(t)?t:(0,s.rgbToHexString)((0,s.parseRgb)(t)):null},this._onThicknessChange=e=>{const{thickness:t}=this.props;void 0!==t&&this._setProperty(t,e,d)},this._onColorChange=e=>{const{color:t,isPaletteColor:n}=this.props,o=(0,u.getPropertyValue)(t);let r=0;o&&(r=(0,i.isHexColor)(o)?this._getTransparencyValue():(0,i.alphaToTransparency)((0,s.parseRgba)(o)[3])),this._setProperty(t,(0,i.generateColor)(String(e),r,!0),h),this._trackEventLabel="Plot color > "+(n?"Palette":"Single")},this._onOpacityChange=e=>{const{color:t}=this.props,n=(0,u.getPropertyValue)(t);this._setProperty(t,(0,i.generateColor)(n,(0,i.alphaToTransparency)(e),!0),m)},this._onPopupClose=()=>{this._trackEventLabel&&((0, -p.trackEvent)("GUI","Study settings",this._trackEventLabel),this._trackEventLabel=null)}}componentWillUnmount(){this._onPopupClose()}render(){const{selectOpacity:e=!0,disabled:t,className:n}=this.props;return o.createElement(c.ColorSelect,{className:n,disabled:t,color:this._getColorValueInHex(),selectOpacity:e,opacity:this._getOpacityValue(),thickness:this._getThicknessValue(),thicknessItems:v,onColorChange:this._onColorChange,onOpacityChange:this._onOpacityChange,onThicknessChange:this._onThicknessChange,onPopupClose:this._onPopupClose})}_getThicknessValue(){const{thickness:e}=this.props;return e?(0,u.getPropertyValue)(e):void 0}_setProperty(e,t,n){const{setValue:o}=this.context;(0,u.setPropertyValue)(e,(e=>o(e,t,n)))}}g.contextType=l.StylePropertyContext},11062:(e,t,n)=>{"use strict";n.d(t,{PropertyTable:()=>l});var o=n(50959),s=n(97754),r=n(90186),a=n(24712);const i=o.createContext(!1);class l extends o.PureComponent{render(){return o.createElement("div",{ref:this.props.reference,className:s(a.content,this.props.className)},this.props.children)}}l.InlineRowContext=i,l.Row=function(e){const{children:t}=e;return(0,o.useContext)(i)?o.createElement("span",{className:a.inlineRow},t):o.createElement(o.Fragment,null,t)},l.Cell=function(e){const t=(0,o.useContext)(i),n=s(a.cell,e.offset&&a.offset,e.grouped&&a.grouped,t&&a.inlineCell,"top"===e.verticalAlign&&a.top,"topCenter"===e.verticalAlign&&a.topCenter,"adaptive"===e.verticalAlign&&a.adaptive,e.checkableTitle&&a.checkableTitle,2===e.colSpan&&a.fill,"first"===e.placement&&2!==e.colSpan&&a.first,"last"===e.placement&&2!==e.colSpan&&a.last),l=(0,r.filterDataProps)(e);return o.createElement("div",{...l,className:n},o.createElement("div",{className:s(a.inner,e.className)},e.children))},l.Separator=function(e){return o.createElement(l.Row,null,o.createElement("div",{className:s(a.cell,a.separator,a.fill)}))},l.GroupSeparator=function(e){const t=e.size||0;return o.createElement(l.Row,null,o.createElement("div",{className:s(a.cell,a.groupSeparator,a.fill,1===t&&a.big)}))}},17948:(e,t,n)=>{"use strict";function o(e){return Array.isArray(e)?e[0].value():e.value()}function s(e,t){if(Array.isArray(e))for(const n of e)t(n);else t(e)}n.d(t,{getPropertyValue:()=>o,setPropertyValue:()=>s})},99084:e=>{e.exports=''},30162:e=>{e.exports=''},27941:e=>{ -e.exports=''},82353:e=>{e.exports=''},65890:e=>{e.exports=''},93929:e=>{e.exports=''}}]); \ No newline at end of file +;const W=void 0,A=["1","3","5","15","30","45","60","120","180","240","1D","1W","1M","3M","6M","12M"],q=["1S","5S","10S","15S","30S"];class U extends s.PureComponent{constructor(){super(...arguments),this._onChange=e=>{const{input:{id:t,name:n},onChange:o}=this.props;o(e,t,n)}}render(){const{input:e,value:t,disabled:r,hasTooltip:a}=this.props,i=R.Interval.parse(void 0===t?e.defval:t),l=i.isValid()?i.value():t,c=W?W.get().filter((e=>!R.Interval.parse(e).isRange())):[],u=(0,L.mergeResolutions)(A,(0,L.isSecondsEnabled)()?q:[],c);return u.unshift(""),s.createElement(P.Select,{id:e.id,className:p()(v.input,v.resolution,a&&v.hasTooltip),menuClassName:p()(v.dropdownMenu,v.resolution),items:(d=u,d.map((e=>({value:e,content:""===e?o.t(null,void 0,n(94551)):(0,L.getTranslatedResolutionModel)(e).hint})))),value:l,onChange:this._onChange,disabled:r});var d}}const z=(0,h.bind)(U);var Z=n(41552),G=n(41594);class H extends s.PureComponent{render(){return s.createElement(k.PropertyContext.Consumer,null,(e=>e?this._getColorInputWithContext(e):null))}_getColorInputWithContext(e){var t;const{input:{id:n},disabled:o,hasTooltip:r}=this.props,{model:a,study:i}=e;if("properties"in i||"tempProperties"in i){const e="properties"in i?i.properties().inputs[n]:null===(t=i.tempProperties)||void 0===t?void 0:t.inputs.child(n);return s.createElement(G.StylePropertyContainer,{model:a,property:e},s.createElement(Z.ColorWithThicknessSelect,{className:p()(r&&v.hasTooltip),color:e,disabled:o}))}return null}}var K=n(85528),$=n(76056),Y=n(23935),j=n(27365),X=n(93071);const Q=(0,h.bind)((function(e){const{value:t,onChange:n,input:o,tzName:r,hasTooltip:a}=e,{id:i,name:l,defval:c}=o,u=(0,s.useMemo)((()=>Number(null!=t?t:c)),[t,c]),d=(0,s.useMemo)((()=>(0,j.getChartTimezoneOffsetMs)(u,r)),[u,r]),h=(0,s.useMemo)((()=>{const e=new Date(u+d+v(u));return e.setSeconds(0),e}),[u,d]),m=(0,s.useMemo)((()=>(0,Y.twoDigitsFormat)(h.getHours())+":"+(0,Y.twoDigitsFormat)(h.getMinutes())),[h]);return s.createElement("div",{className:p()(X.container,a&&X.hasTooltip)},s.createElement("div",{className:X.datePickerWrapper},s.createElement(K.DatePicker,{InputComponent:$.DateInput,initial:h,onPick:function(e){if(null===e)return;const t=new Date(h);t.setFullYear(e.getFullYear()),t.setMonth(e.getMonth()),t.setDate(e.getDate()),n(g(t),i,l)},revertInvalidData:!0})),s.createElement("div",{className:X.timePickerWrapper},s.createElement(S.TimeInput,{value:m,onChange:function(e){const[t,o]=e.split(":"),s=new Date(h);s.setHours(Number(t)),s.setMinutes(Number(o)),n(g(s),i,l)}})));function v(e){return 60*new Date(e).getTimezoneOffset()*1e3}function g(e){return e.valueOf()-d-v(u)}}));class J extends s.PureComponent{render(){const{input:e,disabled:t,onChange:n,tzName:o,hasTooltip:r}=this.props;if((0,a.isStudyInputOptionsInfo)(e))return s.createElement(D,{input:e,disabled:t,onChange:n,hasTooltip:r});switch(e.type){case"integer":return s.createElement(i.IntegerInput,{input:e,disabled:t,onChange:n,hasTooltip:r});case"float":case"price":return s.createElement(l.FloatInput,{input:e,disabled:t, +onChange:n,hasTooltip:r});case"bool":return s.createElement(c.BoolInput,{input:e,disabled:t,onChange:n,hasTooltip:r});case"text":return s.createElement(f,{input:e,disabled:t,onChange:n,hasTooltip:r});case"symbol":return s.createElement(C.SymbolInput,{input:e,disabled:t,onChange:n,hasTooltip:r});case"session":return s.createElement(_,{input:e,disabled:t,onChange:n,hasTooltip:r});case"source":return s.createElement(F,{input:e,disabled:t,onChange:n,hasTooltip:r});case"resolution":return s.createElement(z,{input:e,disabled:t,onChange:n,hasTooltip:r});case"time":return s.createElement(Q,{input:e,tzName:o,onChange:n,hasTooltip:r});case"color":return s.createElement(H,{input:e,disabled:t,onChange:n,hasTooltip:r});default:return null}}}var ee=n(39847),te=n(76694);class ne extends s.PureComponent{render(){const{label:e,children:t,input:a,disabled:i,onChange:l,labelAlign:c,grouped:u,tooltip:p,solutionId:d,offset:h}=this.props,m=Boolean(p);return s.createElement(y.PropertyTable.Row,null,s.createElement(y.PropertyTable.Cell,{"data-study-input-name":(null==a?void 0:a.id)&&`${a.id}-label`,placement:"first",verticalAlign:c,grouped:u,offset:h},void 0!==e?e:o.t((0,r.ensureDefined)(a).name,{context:"input"},n(88601))),s.createElement(y.PropertyTable.Cell,{"data-study-input-name":(null==a?void 0:a.id)&&`${a.id}-input`,placement:"last",grouped:u},t||s.createElement(J,{input:(0,r.ensureDefined)(a),onChange:l,disabled:i,hasTooltip:m}),m&&s.createElement(te.IconGroupWrapper,null,p&&s.createElement(ee.InputTooltip,{title:p}),!1)))}}},39828:(e,t,n)=>{"use strict";n.d(t,{InputsTabContent:()=>A});var o,s=n(50959),r=n(50151),a=n(44352),i=n(76917),l=n(11062),c=n(57733),u=n(97754),p=n.n(u),d=n(88400),h=n.n(d);const m=(0,c.makeSwitchGroupItem)(((o=class extends s.PureComponent{constructor(){super(...arguments),this._onChange=()=>{this.props.onChange&&this.props.onChange(this.props.value)}}render(){const e=u(this.props.className,h().radio,{[h().reverse]:Boolean(this.props.labelPositionReverse)}),t=u(h().label,{[h().disabled]:this.props.disabled}),n=u(h().box,{[h().noOutline]:-1===this.props.tabIndex});let o=null;return this.props.label&&(o=s.createElement("span",{className:t},this.props.label)),s.createElement("label",{className:e},s.createElement("span",{className:h().wrapper,title:this.props.title},s.createElement("input",{id:this.props.id,tabIndex:this.props.tabIndex,autoFocus:this.props.autoFocus,role:this.props.role,className:h().input,type:"radio",name:this.props.name,checked:this.props.checked,disabled:this.props.disabled,value:this.props.value,onChange:this._onChange,ref:this.props.reference,"aria-describedby":this.props["aria-describedby"],"aria-invalid":this.props["aria-invalid"]}),s.createElement("span",{className:n})),o)}}).defaultProps={value:"on"},o));var v=n(55141),g=n(83207),b=n(39847),f=n(76694),C=n(27698);function y(e){const{children:t,input:o,disabled:u,onChange:p,grouped:d,tooltip:h,solutionId:y}=e,E=(0,s.useContext)(i.PropertyContext),{values:S,setValue:w}=(0,r.ensureNotNull)(E),x=S[o.id],[_,N]=(0, +s.useState)(x?"another-symbol":"main-symbol"),[T,I]=(0,s.useState)(x),k=Boolean(h);return(0,s.useEffect)((()=>{x&&I(x)}),[x]),s.createElement(c.SwitchGroup,{name:`symbol-source-${o.id}`,values:[_],onChange:function(e){N(e),"main-symbol"===e?(0,g.setter)(w)("",o.id,o.name):"another-symbol"===e&&T&&(0,g.setter)(w,p)(T,o.id,o.name)}},s.createElement(l.PropertyTable.Row,null,s.createElement(l.PropertyTable.Cell,{colSpan:2,placement:"first",grouped:d,"data-study-input-name":(null==o?void 0:o.id)&&`${o.id}-main-symbol`},s.createElement(m,{value:"main-symbol",className:C.checkbox,disabled:u,label:s.createElement("span",{className:C.label},a.t(null,{context:"input"},n(88046)))}))),s.createElement(l.PropertyTable.Row,null,s.createElement(l.PropertyTable.Cell,{placement:"first",grouped:d,"data-study-input-name":(null==o?void 0:o.id)&&`${o.id}-another-symbol-label`},s.createElement(m,{value:"another-symbol",className:C.checkbox,disabled:u,label:s.createElement("span",{className:C.label},a.t(null,{context:"input"},n(73755)))})),s.createElement(l.PropertyTable.Cell,{placement:"last",grouped:d,"data-study-input-name":(null==o?void 0:o.id)&&`${o.id}-another-symbol-input`},t||s.createElement(v.SymbolInput,{input:(0,r.ensureDefined)(o),onChange:p,disabled:u||"main-symbol"===_,hasTooltip:k}),k&&s.createElement(f.IconGroupWrapper,null,h&&s.createElement(b.InputTooltip,{title:h}),!1))))}var E=n(4781);class S extends s.PureComponent{render(){const{label:e,input:t,tooltip:n,solutionId:o}=this.props,r=Boolean(n);return s.createElement(l.PropertyTable.Row,null,s.createElement(l.PropertyTable.Cell,{placement:"first",colSpan:2,"data-study-input-name":(null==t?void 0:t.id)&&`${t.id}-checkbox`},s.createElement(E.BoolInput,{label:e,input:t,hasTooltip:r}),r&&s.createElement(f.IconGroupWrapper,null,n&&s.createElement(b.InputTooltip,{title:n}),!1)))}}var w=n(12949),x=n(2568),_=n(67029),N=n(90009);class T extends s.PureComponent{constructor(){super(...arguments),this._onChange=e=>{const{input:{id:t,name:n},onChange:o}=this.props;o(e.currentTarget.value,t,n)}}render(){const{input:{defval:e},value:t,disabled:n,onBlur:o,onKeyDown:r}=this.props;return s.createElement(x.Textarea,{className:p()(C.input,C.textarea,_.InputClasses.FontSizeMedium),value:void 0===t?e:t,onChange:this._onChange,onBlur:o,onKeyDown:r,disabled:n,maxLength:4096})}}const I=(0,N.debounced)(T),k=(0,g.bind)(I);var P=n(80128);function B(e){const{input:t,label:n,tooltip:o,solutionId:r}=e,a=Boolean(o);return s.createElement(l.PropertyTable.Row,null,s.createElement(l.PropertyTable.Cell,{placement:"first",colSpan:2,className:P.wrap,"data-study-input-name":(null==t?void 0:t.id)&&`${t.id}-textarea`},s.createElement("div",{className:P.labelWrap},s.createElement("span",{className:p()(P.label,a&&P.hasTooltip)},n),a&&s.createElement(f.IconGroupWrapper,null,o&&s.createElement(b.InputTooltip,{title:o}),!1)),s.createElement(k,{input:t})))}function D(e){const{input:t,tooltip:o,solutionId:r}=e;return"symbol"===t.type&&t.optional?s.createElement(y,{input:t,tooltip:o,solutionId:r +}):"bool"===t.type?s.createElement(S,{label:a.t(t.name,{context:"input"},n(88601)),input:t,tooltip:o,solutionId:r}):"text_area"===t.type?s.createElement(B,{label:a.t(t.name,{context:"input"},n(88601)),input:t,tooltip:o,solutionId:r}):s.createElement(w.InputRow,{labelAlign:function(e){switch(e){case"session":return"adaptive";case"time":return"topCenter";default:return}}(t.type),input:t,tooltip:o,solutionId:r})}var M=n(86067),V=n(17611);function O(e){const{content:t}=e;let n;return s.createElement(l.PropertyTable.InlineRowContext.Provider,{value:!0},s.createElement("div",{className:V.inlineRow},t.children.map(((e,o)=>(void 0!==e.tooltip&&(n=e.tooltip),s.createElement(D,{key:e.id,input:e,tooltip:o===t.children.length-1?n:void 0}))))))}var F=n(64420),R=n(26278);function L(e){const{content:t}=e;return(0,F.isGroup)(t)?(0,F.isInputInlines)(t)?s.createElement(O,{content:t}):s.createElement(s.Fragment,null,s.createElement("div",{className:R.titleWrap},s.createElement(M.GroupTitleSection,{title:a.t(t.id,{context:"input"},n(88601)),name:t.id})),t.children.map((e=>(0,F.isGroup)(e)?s.createElement(O,{key:e.id,content:e}):s.createElement(D,{key:e.id,input:e,tooltip:e.tooltip,solutionId:e.solutionId}))),s.createElement("div",{className:R.groupFooter})):s.createElement(D,{input:t,tooltip:t.tooltip,solutionId:t.solutionId})}const W={offset:a.t(null,void 0,n(89298))};class A extends s.PureComponent{render(){const{reference:e,inputs:t,property:n,study:o,studyMetaInfo:a,model:i,onStudyInputChange:c,className:u}=this.props,{offset:p,offsets:d}=n;return s.createElement(l.PropertyTable,{reference:e,className:u},s.createElement(q,{study:o,model:i,property:n.inputs,inputs:t,onStudyInputChange:c}),p&&this._createOffsetSection(p,(0,r.ensureDefined)(a.offset)),d&&d.childNames().map((e=>{var t;const n=d.childs()[e];return this._createOffsetSection(n,(0,r.ensureDefined)(null===(t=a.offsets)||void 0===t?void 0:t[e]))})))}_createOffsetSection(e,t){const n=e.childs();return s.createElement(q,{key:`offset_${t.title}`,study:this.props.study,model:this.props.model,inputs:[U(n,t)],property:e})}}function q(e){const{study:t,model:n,inputs:o,property:r,onStudyInputChange:a}=e,l=o,c=(0,s.useMemo)((()=>(0,F.getInputGroups)(l)),[l]);return s.createElement(i.PropertyContainer,{property:r,study:t,model:n,onStudyInputChange:a},!1,!1,c.map((e=>s.createElement(s.Fragment,{key:e.id},s.createElement(L,{content:e}),!1))))}function U(e,t){return{id:"val",name:t.title||W.offset,defval:e.val.value(),type:"integer",min:t.min,max:t.max}}},4781:(e,t,n)=>{"use strict";n.d(t,{BoolInput:()=>u,BoolInputComponent:()=>c});var o=n(50959),s=n(15294),r=n(97754),a=n.n(r),i=n(83207),l=n(27698);class c extends o.PureComponent{constructor(){super(...arguments),this._onChange=()=>{const{input:{id:e,name:t},value:n,onChange:o}=this.props;o(!n,e,t)}}render(){const{input:{defval:e},value:t,disabled:n,label:r,hasTooltip:i}=this.props,c=void 0===t?e:t;return o.createElement(s.Checkbox,{className:a()(l.checkbox,i&&l.hasTooltip),disabled:n,checked:c,onChange:this._onChange, +label:o.createElement("span",{className:l.label},r),labelAlignBaseline:!0})}}const u=(0,i.bind)(c)},90009:(e,t,n)=>{"use strict";n.d(t,{debounced:()=>r});var o=n(50959);const s={blur:0,commit:0,change:1/0};function r(e,t=s){return class extends o.PureComponent{constructor(e){super(e),this._onChange=(e,n,o)=>{const s=t.change;s?(clearTimeout(this._timeout),this.setState({value:e},(()=>{s!==1/0&&(this._timeout=setTimeout((()=>this._flush()),s))}))):this._flush(e)},this._onBlur=()=>{this._debounce(t.blur);const{onBlur:e}=this.props;e&&e()},this._onKeyDown=e=>{13===e.keyCode&&this._debounce(t.commit)},this.state={prevValue:e.value,value:e.value}}componentWillUnmount(){this._flush()}render(){const{value:t}=this.state;return o.createElement(e,{...this.props,value:t,onChange:this._onChange,onBlur:this._onBlur,onKeyDown:this._onKeyDown})}static getDerivedStateFromProps(e,t){return e.value===t.prevValue?t:{prevValue:e.value,value:e.value}}_debounce(e){e?(clearTimeout(this._timeout),e!==1/0&&(this._timeout=setTimeout((()=>this._flush()),e))):this.setState((e=>{this._flush(e.value)}))}_flush(e){const{input:{id:t,name:n},onChange:o}=this.props,{prevValue:s,value:r}=this.state;clearTimeout(this._timeout);const a=void 0!==e?e:r;void 0!==a&&a!==s&&o(a,t,n)}}}},47510:(e,t,n)=>{"use strict";n.d(t,{FloatInput:()=>d,FloatInputComponent:()=>p});var o=n(50959),s=n(97754),r=n.n(s),a=n(95052),i=n(83207),l=n(90009),c=n(27698);class u extends o.PureComponent{render(){const{hasTooltip:e}=this.props;return o.createElement(a.NumericInput,{...this.props,className:r()(c.input,e&&c.hasTooltip),stretch:!1})}}const p=(0,l.debounced)(u,{change:1/0,commit:0,blur:0}),d=(0,i.bind)(p)},96438:(e,t,n)=>{"use strict";n.d(t,{IntegerInput:()=>d,IntegerInputComponent:()=>p});var o=n(50959),s=n(97754),r=n.n(s),a=n(83207),i=n(90009),l=n(95052),c=n(27698);class u extends o.PureComponent{render(){const{hasTooltip:e}=this.props;return o.createElement(l.NumericInput,{...this.props,mode:"integer",className:r()(c.input,e&&c.hasTooltip),stretch:!1})}}const p=(0,i.debounced)(u,{change:1/0,commit:0,blur:0}),d=(0,a.bind)(p)},95052:(e,t,n)=>{"use strict";n.d(t,{NumericInput:()=>y});var o=n(50959),s=n(50151),r=n(44352),a=n(60521),i=n(49483),l=n(92399),c=n(82161),u=n(38223);var p=n(87663),d=n(37160);const h=r.t(null,void 0,n(35563)),m=new class{constructor(e=" "){this._divider=e}format(e){const t=(0,c.splitThousands)(e,this._divider);return(0,u.isRtl)()?(0,u.startWithLTR)(t):t}parse(e){const t=(0,u.stripLTRMarks)(e).split(this._divider).join(""),n=Number(t);return isNaN(n)||/e/i.test(t)?{res:!1}:{res:!0,value:n,suggest:this.format(n)}}},v=/^-?[0-9]*$/,g=9e15;class b extends o.PureComponent{constructor(e){super(e),this._onFocus=e=>{this.setState({focused:!0}),this.props.onFocus&&this.props.onFocus(e)},this._onBlur=e=>{this.setState({focused:!1}),!1!==this.props.shouldApplyValueOnBlur&&(this.setState({displayValue:f(this.props,this.props.value)}),this.props.errorHandler&&this.props.errorHandler(!1)),this.props.onBlur&&this.props.onBlur(e)},this._onValueChange=e=>{ +const t=e.target.value;if(void 0!==this.props.onEmptyString&&""===t&&this.props.onEmptyString(),"integer"===this.props.mode&&!v.test(t))return;const n=C(t,this.props.formatter),o=n.res?this._checkValueBoundaries(n.value):{isPassed:!1,msg:void 0},s=n.res&&!o.isPassed,r=n.res&&n.suggest&&!this.state.focused?n.suggest:t,a=s&&o.msg?o.msg:h;this.setState({displayValue:r,errorMsg:a}),n.res&&o.isPassed&&this.props.onValueChange(n.value,"input"),this.props.errorHandler&&this.props.errorHandler(!n.res||s)},this._onValueByStepChange=e=>{const{roundByStep:t=!0,step:n=1,uiStep:o,min:s=n,formatter:r}=this.props,i=C(this.state.displayValue,r),l=null!=o?o:n;let c=n;if(i.res){const o=new a.Big(i.value),r=o.minus(s).mod(n);let u=o.plus(e*l);!r.eq(0)&&t&&(u=u.plus((e>0?0:1)*l).minus(r)),c=u.toNumber()}const{isPassed:u,clampedValue:p}=this._checkValueBoundaries(c);c=u?c:p,this.setState({displayValue:f(this.props,c)}),this.props.onValueChange(c,"step"),this.props.errorHandler&&this.props.errorHandler(!1)};const{value:t}=e;this.state={value:t,displayValue:f(e,t),focused:!1,errorMsg:h}}render(){var e;return o.createElement(l.NumberInputView,{id:this.props.id,inputMode:null!==(e=this.props.inputMode)&&void 0!==e?e:i.CheckMobile.iOS()?void 0:"numeric",borderStyle:this.props.borderStyle,fontSizeStyle:this.props.fontSizeStyle,value:this.state.displayValue,forceShowControls:this.props.forceShowControls,className:this.props.className,inputClassName:this.props.inputClassName,button:this.props.button,placeholder:this.props.placeholder,innerLabel:this.props.innerLabel,endSlot:this.props.endSlot,disabled:this.props.disabled,warning:this.props.warning,error:this.props.error,errorMessage:this.props.errorMessage||this.state.errorMsg,onValueChange:this._onValueChange,onValueByStepChange:this._onValueByStepChange,containerReference:this.props.containerReference,inputReference:this.props.inputReference,onClick:this.props.onClick,onFocus:this._onFocus,onBlur:this._onBlur,onKeyDown:this.props.onKeyDown,controlDecKeyCodes:this.props.controlDecKeyCodes,controlIncKeyCodes:this.props.controlIncKeyCodes,title:this.props.title,intent:this.props.intent,highlight:this.props.highlight,highlightRemoveRoundBorder:this.props.highlightRemoveRoundBorder,stretch:this.props.stretch,autoSelectOnFocus:!i.CheckMobile.any(),"data-name":this.props["data-name"]})}getClampedValue(){const{min:e=-1/0,max:t=g}=this.props,n=C(this.state.displayValue,this.props.formatter);return n.res?(0,d.clamp)(n.value,e,t):null}static getDerivedStateFromProps(e,t){const{alwaysUpdateValueFromProps:n,value:o}=e;return t.focused&&!n||t.value===o?null:{value:o,displayValue:f(e,o)}}_checkValueBoundaries(e){var t,o,s,a;const{min:i=-1/0,max:l=g}=this.props,c=function(e,t,n){const o=e>=t,s=e<=n;return{passMin:o,passMax:s,pass:o&&s,clamped:(0,d.clamp)(e,t,n)}}(e,i,l);let u;return c.passMax||(u=null!==(o=null===(t=this.props.boundariesErrorMessages)||void 0===t?void 0:t.greaterThanMax)&&void 0!==o?o:r.t(null,{replace:{max:String(l)}},n(2607))), +c.passMin||(u=null!==(a=null===(s=this.props.boundariesErrorMessages)||void 0===s?void 0:s.lessThanMin)&&void 0!==a?a:r.t(null,{replace:{min:String(i)}},n(53669))),{isPassed:c.pass,msg:u,clampedValue:c.clamped}}}function f(e,t){const{useFormatter:n=!0,formatter:o,mode:s}=e;return n&&"integer"!==s?function(e,t=m){return null!==e?t.format(e):""}(t,o):function(e){if(null===e)return"";return p.NumericFormatter.formatNoE(e)}(t)}function C(e,t=m){return t.parse?t.parse(e):{res:!1,error:"Formatter does not support parse"}}class y extends o.PureComponent{constructor(){super(...arguments),this._container=null,this._handleContainerRef=e=>this._container=e,this._onChange=(e,t)=>{const{input:{id:n,name:o},onChange:s,onBlur:r}=this.props;s(e,n,o),"step"===t&&r&&r()},this._onBlur=e=>{const{onBlur:t}=this.props;if(t){const n=(0,s.ensureNotNull)(this._container);n.contains(document.activeElement)||n.contains(e.relatedTarget)||t()}}}render(){const{input:{defval:e,min:t,max:n,step:s},value:r,disabled:a,onKeyDown:i,className:l,mode:c,stretch:u}=this.props;return o.createElement(b,{className:l,value:Number(void 0===r?e:r),min:t,max:n,step:s,mode:c,onBlur:this._onBlur,onValueChange:this._onChange,onKeyDown:i,disabled:a,containerReference:this._handleContainerRef,fontSizeStyle:"medium",roundByStep:!1,stretch:u})}}},55141:(e,t,n)=>{"use strict";n.d(t,{SymbolInput:()=>p,getInternalSymbolName:()=>c});var o=n(50959),s=n(50151),r=n(76917),a=n(83207),i=n(73146),l=n(48897);function c(e,t){const n=(0,i.createAdapter)(t).resolvedSymbolInfoBySymbol(e);return n&&(n.ticker||n.full_name)?n.ticker||n.full_name:e}function u(e,t){const n=(0,i.createAdapter)(t).resolvedSymbolInfoBySymbol(e);return null===n?e:n.name}const p=(0,a.bind)((function(e){const t=(0,o.useContext)(r.PropertyContext),{study:n}=(0,s.ensureNotNull)(t),{input:{defval:a},value:i}=e;return o.createElement(l.SymbolInputsButton,{...e,value:u(i||a||"",n),study:n})}))},41552:(e,t,n)=>{"use strict";n.d(t,{ColorWithThicknessSelect:()=>g});var o=n(50959),s=n(24377),r=n(44352),a=n(36298),i=n(87095),l=n(41594),c=n(58593),u=n(17948),p=n(51768);const d=new a.TranslatedString("change thickness",r.t(null,void 0,n(95657))),h=new a.TranslatedString("change color",r.t(null,void 0,n(13066))),m=new a.TranslatedString("change opacity",r.t(null,void 0,n(17023))),v=[1,2,3,4];class g extends o.PureComponent{constructor(){super(...arguments),this._trackEventLabel=null,this._getTransparencyValue=()=>{const{transparency:e}=this.props;return e?e.value():0},this._getOpacityValue=()=>{const{color:e}=this.props,t=(0,u.getPropertyValue)(e);if(t)return(0,i.isHexColor)(t)?(0,i.transparencyToAlpha)(this._getTransparencyValue()):(0,s.parseRgba)(t)[3]},this._getColorValueInHex=()=>{const{color:e}=this.props,t=(0,u.getPropertyValue)(e);return t?(0,i.isHexColor)(t)?t:(0,s.rgbToHexString)((0,s.parseRgb)(t)):null},this._onThicknessChange=e=>{const{thickness:t}=this.props;void 0!==t&&this._setProperty(t,e,d)},this._onColorChange=e=>{const{color:t,isPaletteColor:n}=this.props,o=(0,u.getPropertyValue)(t);let r=0;o&&(r=(0, +i.isHexColor)(o)?this._getTransparencyValue():(0,i.alphaToTransparency)((0,s.parseRgba)(o)[3])),this._setProperty(t,(0,i.generateColor)(String(e),r,!0),h),this._trackEventLabel="Plot color > "+(n?"Palette":"Single")},this._onOpacityChange=e=>{const{color:t}=this.props,n=(0,u.getPropertyValue)(t);this._setProperty(t,(0,i.generateColor)(n,(0,i.alphaToTransparency)(e),!0),m)},this._onPopupClose=()=>{this._trackEventLabel&&((0,p.trackEvent)("GUI","Study settings",this._trackEventLabel),this._trackEventLabel=null)}}componentWillUnmount(){this._onPopupClose()}render(){const{selectOpacity:e=!0,disabled:t,className:n}=this.props;return o.createElement(c.ColorSelect,{className:n,disabled:t,color:this._getColorValueInHex(),selectOpacity:e,opacity:this._getOpacityValue(),thickness:this._getThicknessValue(),thicknessItems:v,onColorChange:this._onColorChange,onOpacityChange:this._onOpacityChange,onThicknessChange:this._onThicknessChange,onPopupClose:this._onPopupClose})}_getThicknessValue(){const{thickness:e}=this.props;return e?(0,u.getPropertyValue)(e):void 0}_setProperty(e,t,n){const{setValue:o}=this.context;(0,u.setPropertyValue)(e,(e=>o(e,t,n)))}}g.contextType=l.StylePropertyContext},11062:(e,t,n)=>{"use strict";n.d(t,{PropertyTable:()=>l});var o=n(50959),s=n(97754),r=n(90186),a=n(24712);const i=o.createContext(!1);class l extends o.PureComponent{render(){return o.createElement("div",{ref:this.props.reference,className:s(a.content,this.props.className)},this.props.children)}}l.InlineRowContext=i,l.Row=function(e){const{children:t}=e;return(0,o.useContext)(i)?o.createElement("span",{className:a.inlineRow},t):o.createElement(o.Fragment,null,t)},l.Cell=function(e){const t=(0,o.useContext)(i),n=s(a.cell,e.offset&&a.offset,e.grouped&&a.grouped,t&&a.inlineCell,"top"===e.verticalAlign&&a.top,"topCenter"===e.verticalAlign&&a.topCenter,"adaptive"===e.verticalAlign&&a.adaptive,e.checkableTitle&&a.checkableTitle,2===e.colSpan&&a.fill,"first"===e.placement&&2!==e.colSpan&&a.first,"last"===e.placement&&2!==e.colSpan&&a.last),l=(0,r.filterDataProps)(e);return o.createElement("div",{...l,className:n},o.createElement("div",{className:s(a.inner,e.className)},e.children))},l.Separator=function(e){return o.createElement(l.Row,null,o.createElement("div",{className:s(a.cell,a.separator,a.fill)}))},l.GroupSeparator=function(e){const t=e.size||0;return o.createElement(l.Row,null,o.createElement("div",{className:s(a.cell,a.groupSeparator,a.fill,1===t&&a.big)}))}},17948:(e,t,n)=>{"use strict";function o(e){return Array.isArray(e)?e[0].value():e.value()}function s(e,t){if(Array.isArray(e))for(const n of e)t(n);else t(e)}n.d(t,{getPropertyValue:()=>o,setPropertyValue:()=>s})},99084:e=>{e.exports=''},30162:e=>{ +e.exports=''},27941:e=>{e.exports=''},82353:e=>{e.exports=''},65890:e=>{e.exports=''},93929:e=>{e.exports=''}}]); \ No newline at end of file diff --git a/charting_library/bundles/library.0f3decc3cfc32a3eb326.js b/charting_library/bundles/library.5bb35e99444d9b20e189.js similarity index 63% rename from charting_library/bundles/library.0f3decc3cfc32a3eb326.js rename to charting_library/bundles/library.5bb35e99444d9b20e189.js index 40c1cd81..aabb6399 100644 --- a/charting_library/bundles/library.0f3decc3cfc32a3eb326.js +++ b/charting_library/bundles/library.5bb35e99444d9b20e189.js @@ -3,8 +3,8 @@ mobiletouch:()=>n,touch:()=>o});const s="undefined"!=typeof window&&"undefined"!=typeof navigator,r=s&&"ontouchstart"in window,n=s&&r&&"onorientationchange"in window,o=s&&(r||!!navigator.maxTouchPoints),a=s&&window.chrome&&window.chrome.runtime,l=s&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,c=s&&/\sEdge\/\d\d\b/.test(navigator.userAgent),h=s&&Boolean(navigator.vendor)&&navigator.vendor.indexOf("Apple")>-1&&-1===navigator.userAgent.indexOf("CriOS")&&-1===navigator.userAgent.indexOf("FxiOS"),d=s&&/mac/i.test(navigator.platform),u=s&&/Win32|Win64/i.test(navigator.platform),p=s&&/Linux/i.test(navigator.platform),_=s&&/Android/i.test(navigator.userAgent),m=s&&/BlackBerry/i.test(navigator.userAgent),g=s&&/iPhone|iPad|iPod/.test(navigator.platform),f=s&&/Opera Mini/i.test(navigator.userAgent),v=s&&("MacIntel"===navigator.platform&&navigator.maxTouchPoints>1||/iPad/.test(navigator.platform)),S=_||m||g||f},48891:(e,t,i)=>{"use strict";i.r(t),i.d(t,{colorsPalette:()=>d,getHexColorByName:()=>u}) ;const s=JSON.parse('{"color-white":"#ffffff","color-black":"#000000","color-cold-gray-50":"#F8F9FD","color-cold-gray-100":"#F0F3FA","color-cold-gray-150":"#E0E3EB","color-cold-gray-200":"#D1D4DC","color-cold-gray-250":"#C1C4CD","color-cold-gray-300":"#B2B5BE","color-cold-gray-350":"#A3A6AF","color-cold-gray-400":"#9598A1","color-cold-gray-450":"#868993","color-cold-gray-500":"#787B86","color-cold-gray-550":"#6A6D78","color-cold-gray-600":"#5D606B","color-cold-gray-650":"#50535E","color-cold-gray-700":"#434651","color-cold-gray-750":"#363A45","color-cold-gray-800":"#2A2E39","color-cold-gray-850":"#1E222D","color-cold-gray-900":"#131722","color-cold-gray-950":"#0C0E15","color-ripe-red-50":"#FFEBEC","color-ripe-red-100":"#FCCBCD","color-ripe-red-200":"#FAA1A4","color-ripe-red-300":"#F77C80","color-ripe-red-400":"#F7525F","color-ripe-red-500":"#F23645","color-ripe-red-600":"#CC2F3C","color-ripe-red-700":"#B22833","color-ripe-red-800":"#991F29","color-ripe-red-900":"#801922","color-ripe-red-a100":"#FF8080","color-ripe-red-a200":"#FF5252","color-ripe-red-a400":"#FF3333","color-ripe-red-a600":"#CC2929","color-ripe-red-a700":"#802028","color-ripe-red-a800":"#4D191D","color-ripe-red-a900":"#331F20","color-tan-orange-50":"#FFF3E0","color-tan-orange-100":"#FFE0B2","color-tan-orange-200":"#FFCC80","color-tan-orange-300":"#ffb74d","color-tan-orange-400":"#FFA726","color-tan-orange-500":"#FF9800","color-tan-orange-600":"#FB8C00","color-tan-orange-700":"#F57C00","color-tan-orange-800":"#EF6C00","color-tan-orange-900":"#e65100","color-tan-orange-a200":"#ffab40","color-tan-orange-a400":"#FF9100","color-tan-orange-a600":"#CC7014","color-tan-orange-a700":"#8C541C","color-tan-orange-a800":"#593A1B","color-tan-orange-a900":"#33261A","color-iguana-green-100":"#C8E6C9","color-iguana-green-200":"#A5D6A7","color-iguana-green-300":"#81c784","color-iguana-green-400":"#66BB6A","color-iguana-green-500":"#4caf50","color-iguana-green-600":"#43a047","color-iguana-green-700":"#388e3c","color-iguana-green-800":"#2E7D32","color-iguana-green-900":"#1B5E20","color-iguana-green-a700":"#00c853","color-banana-yellow-100":"#FFF9C4","color-banana-yellow-200":"#FFF59D","color-banana-yellow-300":"#FFF176","color-banana-yellow-400":"#ffee58","color-banana-yellow-500":"#ffeb3b","color-banana-yellow-600":"#fdd835","color-banana-yellow-700":"#fbc02d","color-banana-yellow-800":"#f9a825","color-banana-yellow-900":"#F57F17","color-banana-yellow-a400":"#ffea00","color-banana-yellow-a700":"#ffd600","color-tv-blue-50":"#E3EFFD","color-tv-blue-100":"#BBD9FB","color-tv-blue-200":"#90BFF9","color-tv-blue-300":"#5B9CF6","color-tv-blue-400":"#3179F5","color-tv-blue-500":"#2962FF","color-tv-blue-600":"#1E53E5","color-tv-blue-700":"#1848CC","color-tv-blue-800":"#143EB3","color-tv-blue-900":"#0C3299","color-tv-blue-a100":"#82b1ff","color-tv-blue-a200":"#448aff","color-tv-blue-a400":"#2979ff","color-tv-blue-a600":"#2962FF","color-tv-blue-a700":"#143A87","color-tv-blue-a800":"#142E61","color-tv-blue-a900":"#132042","color-deep-blue-50":"#EDE7F6","color-deep-blue-100":"#D1C4E9","color-deep-blue-200":"#B39DDB","color-deep-blue-300":"#9575cd","color-deep-blue-400":"#7e57c2","color-deep-blue-500":"#673ab7","color-deep-blue-700":"#512da8","color-deep-blue-800":"#4527A0","color-deep-blue-900":"#311B92","color-deep-blue-a100":"#b388ff","color-deep-blue-a200":"#7C4DFF","color-deep-blue-a400":"#651FFF","color-deep-blue-a700":"#6200EA","color-minty-green-50":"#DAF2EE","color-minty-green-100":"#ACE5DC","color-minty-green-200":"#70CCBD","color-minty-green-300":"#42BDA8","color-minty-green-400":"#22AB94","color-minty-green-500":"#089981","color-minty-green-600":"#06806B","color-minty-green-700":"#056656","color-minty-green-800":"#004D40","color-minty-green-900":"#00332A","color-minty-green-a400":"#2BD9BC","color-minty-green-a700":"#24B29B","color-minty-green-a900":"#082621","color-grapes-purple-50":"#F3E5F5","color-grapes-purple-100":"#E1BEE7","color-grapes-purple-200":"#CE93D8","color-grapes-purple-300":"#ba68c8","color-grapes-purple-400":"#ab47bc","color-grapes-purple-500":"#9c27b0","color-grapes-purple-600":"#8e24aa","color-grapes-purple-700":"#7b1fa2","color-grapes-purple-800":"#6A1B9A","color-grapes-purple-900":"#4A148C","color-grapes-purple-a100":"#EA80FC","color-grapes-purple-a200":"#E040FB","color-grapes-purple-a400":"#D500F9","color-grapes-purple-a700":"#aa00ff","color-berry-pink-100":"#F8BBD0","color-berry-pink-200":"#f48fb1","color-berry-pink-300":"#f06292","color-berry-pink-400":"#ec407a","color-berry-pink-500":"#e91e63","color-berry-pink-600":"#D81B60","color-berry-pink-700":"#C2185B","color-berry-pink-800":"#AD1457","color-berry-pink-900":"#880E4F","color-berry-pink-a100":"#ff80ab","color-berry-pink-a200":"#ff4081","color-berry-pink-a400":"#f50057","color-sky-blue-100":"#B2EBF2","color-sky-blue-200":"#80DEEA","color-sky-blue-300":"#4dd0e1","color-sky-blue-400":"#26c6da","color-sky-blue-500":"#00bcd4","color-sky-blue-600":"#00acc1","color-sky-blue-700":"#0097A7","color-sky-blue-800":"#00838F","color-sky-blue-900":"#006064","color-sky-blue-a400":"#00e5ff","color-sky-blue-a700":"#00B8D4","color-deep-blue-600":"#5E35B1","color-forest-green-50":"#DAF2E6","color-forest-green-100":"#ACE5C9","color-forest-green-200":"#70CC9E","color-forest-green-300":"#42BD7F","color-forest-green-400":"#22AB67","color-forest-green-500":"#089950","color-forest-green-600":"#068043","color-forest-green-700":"#056636","color-forest-green-800":"#004D27","color-forest-green-900":"#1A3326","color-facebook":"#1877F2","color-deep-facebook":"#1564CA","color-twitter":"#1DA1F2","color-deep-twitter":"#188CD3","color-youtube":"#FF0000","color-linkedin":"#007BB5","color-aqua-spring":"#ebf9f5","color-army-green":"#3d2c12","color-army-green-2":"#31230d","color-athens-gray-1":"#f2f3f5","color-athens-gray-2":"#f7f8fa","color-athens-gray-3":"#eceff2","color-black-180":"#b4b4b4","color-blue-dianne":"#21384d","color-bluish":"#2185cc","color-bright-gray":"#363c4e","color-brownish-grey":"#8d6e63","color-carnation":"#f04561","color-catskill-white":"#e1ecf2","color-charade":"#2f3241","color-charcoal-grey":"#323337","color-curious-blue":"#299dcd","color-dark-blue-grey":"#123440","color-darkness-blue-grey":"#12213b","color-dark-grey":"#292a2d","color-dark-grey-blue":"#28415a","color-dark-sky-blue":"#37a6ef","color-deep-sea-blue":"#016087","color-ebony-clay":"#262b3e","color-foam":"#d7f0fb","color-gull-gray":"#9db2bd","color-humming-bird":"#d3eef9","color-keppel-1":"#37bc9b","color-keppel-2":"#34b293","color-lavender-blush":"#ffedf0","color-lightish-purple":"#a75ee8","color-loblolly":"#c5cbce","color-manatee":"#878ca8","color-mandy":"#eb4d5c","color-medium-blue":"#2e7bb2","color-milk-chocolate":"#6f2626","color-mirage-1":"#131722","color-mirage-2":"#171b29","color-mirage-3":"#1c2030","color-mischka":"#d6d8e0","color-morning-glory":"#9addcc","color-oslo-gray":"#8b8e95","color-pale":"#fff2cf","color-pale-grey-1":"#f9fafb","color-pale-grey-2":"#e7ebee","color-pale-sky":"#6b7988","color-picton-blue-1":"#3bb3e4","color-puerto-rico":"#3bc2a1","color-purple-brown":"#4e2934","color-purple-brown-2":"#3d2028","color-radical-red":"#ff4a68","color-regent-gray":"#8797a5","color-scooter":"#38acdb","color-silver-tree":"#53b987","color-slate-gray":"#758696","color-sundown":"#ffa4b3","color-sunglow":"#ffca3b","color-tan-hide":"#ff9850","color-trout-1":"#4c525e","color-trout-2":"#4f5966","color-violet-1":"#332738","color-violet-2":"#271d2b","color-white-ice":"#ebf7fc","color-wild-watermelon":"#ff5773","color-readonly-input":"#b4b4b4","color-brand-dark":"#2a2c39","color-seeking-alpha-brand":"#ff7200"}'),r=JSON.parse('{"color-header-bg":"color-white","color-body-bg":"color-white","color-body-secondary-bg":"color-cold-gray-100","color-bg-primary":"color-white","color-bg-primary-hover":"color-cold-gray-100","color-bg-secondary":"color-white","color-bg-highlight":"color-cold-gray-50","color-bg-scroll-buttons":"color-cold-gray-100","color-legacy-bg-scroll-buttons":"color-cold-gray-850","color-legacy-bg-widget":"color-white","color-text-primary":"color-cold-gray-900","color-text-secondary":"color-cold-gray-550","color-text-tertiary":"color-cold-gray-400","color-text-disabled":"color-cold-gray-300","color-accent-content":"color-cold-gray-900","color-box-shadow":"color-cold-gray-300","color-divider":"color-cold-gray-150","color-divider-hover":"color-cold-gray-100","color-divider-secondary":"color-cold-gray-100","color-active-hover-text":"color-cold-gray-900","color-alert-text":"color-cold-gray-900","color-border-table":"color-cold-gray-100","color-brand":"color-tv-blue-500","color-brand-active":"color-tv-blue-700","color-brand-hover":"color-tv-blue-600","color-chart-page-bg":"color-cold-gray-150","color-common-tooltip-bg":"color-cold-gray-800","color-danger":"color-ripe-red-400","color-danger-hover":"color-ripe-red-500","color-danger-active":"color-ripe-red-600","color-depthrenderer-stroke-style":"color-cold-gray-100","color-halal":"color-iguana-green-400","color-continuous":"color-cold-gray-500","color-highlight-new":"color-tan-orange-50","color-input-bg":"color-white","color-input-publish-bg":"color-white","color-link":"color-tv-blue-500","color-link-hover":"color-tv-blue-600","color-link-active":"color-tv-blue-700","color-list-nth-child-bg":"color-cold-gray-50","color-pane-bg":"color-white","color-pane-secondary-bg":"color-cold-gray-100","color-popup-menu-item-hover-bg":"color-cold-gray-100","color-popup-menu-separator":"color-cold-gray-150","color-primary-symbol":"color-sky-blue-500","color-screener-description":"color-cold-gray-650","color-success":"color-minty-green-500","color-success-hover":"color-minty-green-600","color-success-active":"color-minty-green-700","color-toolbar-button-text":"color-cold-gray-900","color-toolbar-button-text-hover":"color-cold-gray-900","color-toolbar-button-text-active":"color-tv-blue-500","color-toolbar-button-text-active-hover":"color-tv-blue-600","color-toolbar-button-background-hover":"color-cold-gray-100","color-toolbar-button-background-secondary-hover":"color-cold-gray-150","color-toolbar-button-background-active":"color-tv-blue-50","color-toolbar-button-background-active-hover":"color-tv-blue-100","color-toolbar-toggle-button-background-active":"color-tv-blue-500","color-toolbar-toggle-button-background-active-hover":"color-tv-blue-600","color-toolbar-toggle-button-icon":"color-cold-gray-200","color-toolbar-interactive-element-text-normal":"color-cold-gray-900","color-toolbar-opened-element-bg":"color-cold-gray-100","color-toolbar-divider-background":"color-cold-gray-150","color-popup-background":"color-white","color-popup-element-text":"color-cold-gray-900","color-popup-element-text-hover":"color-cold-gray-900","color-popup-element-background-hover":"color-cold-gray-100","color-popup-element-secondary-text":"color-cold-gray-500","color-popup-element-hint-text":"color-cold-gray-400","color-popup-element-text-active":"color-white","color-popup-element-background-active":"color-tv-blue-500","color-popup-element-toolbox-text":"color-cold-gray-500","color-popup-element-toolbox-text-hover":"color-cold-gray-900","color-popup-element-toolbox-text-active-hover":"color-tv-blue-200","color-popup-element-toolbox-background-hover":"color-cold-gray-150","color-popup-element-toolbox-background-active-hover":"color-tv-blue-700","color-tooltip-bg":"color-cold-gray-800","color-tv-dialog-caption":"color-cold-gray-650","color-tv-dropdown-item-hover-bg":"color-cold-gray-100","color-underlined-text":"color-cold-gray-550","color-widget-pages-bg":"color-white","color-warning":"color-tan-orange-500","color-growing":"color-minty-green-500","color-falling":"color-ripe-red-500","color-forex-icon":"color-cold-gray-750","color-list-item-active-bg":"color-tv-blue-400","color-list-item-hover-bg":"color-tv-blue-50","color-list-item-text":"color-cold-gray-800","color-price-axis-label-back":"color-cold-gray-150","color-price-axis-label-text":"color-cold-gray-650","color-price-axis-gear":"color-cold-gray-900","color-price-axis-gear-hover":"color-black","color-price-axis-highlight":"color-cold-gray-150","color-bid":"color-tv-blue-500","color-border":"color-cold-gray-150","color-border-chat-fields":"color-cold-gray-250","color-border-hover":"color-cold-gray-250","color-button-hover-bg":"color-cold-gray-150","color-depthrenderer-fill-style":"color-cold-gray-650","color-disabled-border-and-color":"color-cold-gray-150","color-disabled-input":"color-cold-gray-150","color-empty-container-message":"color-cold-gray-550","color-icons":"color-cold-gray-550","color-input-textarea-readonly":"color-cold-gray-650","color-input-placeholder-text":"color-cold-gray-350","color-item-active-blue":"color-tv-blue-50","color-item-hover-active-bg":"color-tv-blue-100","color-item-hover-bg":"color-tv-blue-100","color-item-hover-blue":"color-tv-blue-100","color-item-selected-blue":"color-tv-blue-50","color-item-active-text":"color-white","color-item-active-bg":"color-tv-blue-500","color-list-item":"color-cold-gray-550","color-news-highlight":"color-tv-blue-100","color-placeholder":"color-cold-gray-350","color-row-hover-active-bg":"color-cold-gray-100","color-sb-scrollbar-body-bg":"color-cold-gray-200","color-section-separator-border":"color-cold-gray-300","color-separator-table-chat":"color-cold-gray-150","color-tag-active-bg":"color-cold-gray-200","color-tag-hover-bg":"color-cold-gray-150","color-text-regular":"color-cold-gray-700","color-tv-button-checked":"color-cold-gray-550","color-scroll-bg":"color-cold-gray-400","color-scroll-border":"color-cold-gray-100","color-widget-border":"color-cold-gray-100","color-scroll-buttons-arrow":"color-white","color-control-intent-default":"color-cold-gray-200","color-control-intent-success":"color-minty-green-500","color-control-intent-primary":"color-tv-blue-500","color-control-intent-warning":"color-tan-orange-500","color-control-intent-danger":"color-ripe-red-500","color-goto-label-background":"color-cold-gray-800","color-pre-market":"color-tan-orange-600","color-pre-market-bg":"color-tan-orange-400","color-post-market":"color-tv-blue-500","color-post-market-bg":"color-tv-blue-400","color-market-open":"color-minty-green-500","color-market-open-bg":"color-minty-green-400","color-market-closed":"color-cold-gray-400","color-market-holiday":"color-cold-gray-400","color-market-expired":"color-ripe-red-500","color-invalid-symbol":"color-ripe-red-400","color-invalid-symbol-hover":"color-ripe-red-700","color-replay-mode":"color-tv-blue-500","color-replay-mode-point-select":"color-cold-gray-350","color-replay-mode-icon":"color-white","color-replay-mode-hover":"color-tv-blue-600","color-notaccurate-mode":"color-berry-pink-600","color-delay-mode":"color-tan-orange-700","color-delay-mode-bg":"color-tan-orange-400","color-eod-mode":"color-grapes-purple-700","color-eod-mode-bg":"color-grapes-purple-400","color-data-problem":"color-ripe-red-600","color-data-problem-bg":"color-ripe-red-400","color-data-problem-hover":"color-ripe-red-700","color-list-item-bg-highlighted":"color-tv-blue-50","color-list-item-bg-selected":"color-tv-blue-100","color-list-item-bg-highlighted-hover":"color-tv-blue-100","color-list-item-bg-selected-hover":"color-tv-blue-200","color-screener-header-bg":"color-white","color-screener-header-bg-hover":"color-cold-gray-100","color-marker-flagged":"color-ripe-red-400","color-marker-flagged-hovered":"color-ripe-red-600","color-ask":"color-ripe-red-400","color-sell":"color-ripe-red-400","color-buy":"color-tv-blue-500","color-neutral":"color-cold-gray-550","color-pro":"color-minty-green-400","color-pro-hover":"color-minty-green-600","color-pro-plus":"color-tv-blue-500","color-pro-plus-hover":"color-tv-blue-600","color-pro-premium":"color-tan-orange-500","color-pro-premium-hover":"color-tan-orange-700","color-trial":"color-cold-gray-550","color-trial-hover":"color-cold-gray-550","color-mod":"color-ripe-red-400","color-mod-hover":"color-ripe-red-600","color-ad":"color-tan-orange-500","color-broker-featured":"color-minty-green-400","color-broker-featured-hover":"color-minty-green-600","color-alert-status-active":"color-minty-green-400","color-alert-status-stopped":"color-ripe-red-500","color-alert-status-triggered":"color-tan-orange-500","color-overlay":"color-cold-gray-400","color-search-button-hover":"color-cold-gray-150","color-boost-button-content-selected":"color-tv-blue-600","color-boost-button-content-hover":"color-cold-gray-900","color-boost-button-bg-hover":"color-cold-gray-150","color-boost-button-border-hover":"color-cold-gray-150","color-boost-button-border-default":"color-cold-gray-150","color-common-tooltip-text":"color-cold-gray-100","color-replay-data-mode":"color-radical-red","color-legacy-success":"color-keppel-1","color-collapse-tabs-border":"color-athens-gray-3","color-site-widget-hover":"color-athens-gray-1","color-attention":"color-sunglow","color-card-border":"color-cold-gray-150","color-card-border-hover":"color-cold-gray-300","color-background-special-primary":"color-white","color-stroke-special-primary":"color-cold-gray-150","color-selection-bg":"color-tv-blue-100","color-default-gray":"color-cold-gray-550","color-featured-broker-badge-bg":"color-cold-gray-900","color-featured-broker-badge-bg-hover":"color-cold-gray-800","color-featured-broker-badge-text":"color-white"}') ;var n=i(50151);const o={...s,...r},a={},l=Object.keys(o).length,c=/^#[0-9A-F]{6}$/i;function h(e,t=[]){const i=o[e];if(!i)return null;if(c.test(i))return i;const s=i;return t.push(e),-1!==t.indexOf(s)?(console.warn("Colors definitions cycled"),i):t.length>l?(console.warn("Too many variables-link in HEX-color search: "+t[0]),null):h(s,t)}Object.keys(o).forEach((e=>{const t=h(e);a[e]=(0,n.ensureNotNull)(t)}));const d=a;function u(e){const t=d[e];if(!t)throw new Error("No such color "+e);return t}},74991:(e,t,i)=>{"use strict";i.d(t,{CubicBezier:()=>n,dur:()=>s,easingFunc:()=>r});const s=350,r={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>e*(2-e),easeInOutQuad:e=>e<.5?2*e*e:(4-2*e)*e-1,easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1,easeInQuart:e=>e*e*e*e,easeOutQuart:e=>1- --e*e*e*e,easeInOutQuart:e=>e<.5?8*e*e*e*e:1-8*--e*e*e*e,easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>1+--e*e*e*e*e,easeInOutQuint:e=>e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e};class n{constructor(e,t,i,s){this._mX1=e,this._mY1=t,this._mX2=i,this._mY2=s}easingFunc(e){return this._mX1===this._mY1&&this._mX2===this._mY2?e:this._calcBezier(this._getTForX(e))}_a(e,t){return 1-3*t+3*e}_b(e,t){return 3*t-6*e}_c(e){return 3*e}_calcBezier(e){return((this._a(this._mY1,this._mY2)*e+this._b(this._mY1,this._mY2))*e+this._c(this._mY1))*e}_getSlope(e){return 3*this._a(this._mX1,this._mX2)*e*e+2*this._b(this._mX1,this._mX2)*e+this._c(this._mX1)}_getTForX(e){let t=e;for(let i=0;i<4;++i){const i=this._getSlope(t);if(0===i)return t;t-=(this._calcBezier(t)-e)/i}return t}}},58096:(e,t,i)=>{"use strict";i.d(t,{DEFAULT_SIZE:()=>s,spinnerSizeMap:()=>r});const s="large",r={mini:"xsmall",xsmall:"xsmall",small:"small",medium:"medium",large:"large"}},94194:(e,t,i)=>{"use strict";i.d(t,{getTooltipData:()=>r,setTooltipData:()=>n});const s=new WeakMap;function r(e,t){const i=s.get(e);return i instanceof Function?i(t):i&&i[t]}function n(e,t,i){if(i instanceof Function)return void s.set(e,i);const r=s.get(e),n=void 0===r||r instanceof Function?{}:r;n[t]=i,s.set(e,n)}},61814:(e,t,i)=>{"use strict";i.d(t,{hotKeyDeserialize:()=>n,hotKeySerialize:()=>r});var s=i(54358);function r(e){return(0,s.clean)(JSON.stringify(e))}function n(e){return JSON.parse((0,s.clean)(e,!0))}},38780:(e,t,i)=>{"use strict";i.d(t,{hide:()=>G,show:()=>U,showOnElement:()=>z});var s=i(32563);let r=0,n=0,o=0;function a(){clearTimeout(r),clearTimeout(n),clearTimeout(o)}function l(e,t){r=setTimeout(e,t)}const c="tooltip-root-element";let h;function d(){const e=document.getElementById(c);e?h=e:(h=document.createElement("div"),h.id=c,document.body.appendChild(h))}function u(){h&&(h.innerHTML="")}"interactive"===document.readyState?d():document.addEventListener("DOMContentLoaded",d);var p=i(50151);const _={default:"",white:"theme-white",chart:"theme-chart","round-shadow":"theme-round-shadow"},m=Object.keys(_);var g=i(94194),f=i(61814),v=i(70027),S=i(38223),y=(i(42053),i(21861)),b=i(37160),w=i(49483),P=i(68477);function C(e){const t=function(e){ -const t=e.hasAttribute("data-tooltip")?e.getAttribute("data-tooltip"):e.getAttribute("title");return t&&((0,g.setTooltipData)(e,"text",t),e.removeAttribute("title")),(0,g.getTooltipData)(e,"text")||""}(e),i=e.getBoundingClientRect(),s={h:i.height,w:i.width,x:i.left,y:i.top},r=e.getAttribute("data-color-theme")||"",n=e.classList.contains("common-tooltip-html"),o=parseInt(e.getAttribute("data-tooltip-delay")||""),a=parseInt(e.getAttribute("data-tooltip-debounce")||"");let l={type:"none"};return t&&(l={type:n?"html":"text",data:t}),{above:e.classList.contains("common-tooltip-above"),below:e.classList.contains("common-tooltip-below"),otl:e.classList.contains("common-tooltip-otl"),otr:e.classList.contains("common-tooltip-otr"),vertical:e.classList.contains("common-tooltip-vertical"),hotkey:e.getAttribute("data-tooltip-hotkey"),narrow:e.classList.contains("common-tooltip-narrow"),wide:e.classList.contains("common-tooltip-wide"),colorTheme:r,tooltipDelay:o,tooltipDebounce:a,rect:s,content:l,target:e}}function x(e){const t=D.cloneNode(!0),i=B(t),{content:s}=e;switch(s.type){case"element":i.innerHTML="",i.appendChild(s.data);break;case"html":i.innerHTML=s.data;break;case"text":if(e.hotkey){const e=E.cloneNode(!0);e.innerText=s.data,i.appendChild(e)}else i.innerText=s.data}if(e.hotkey){const t="none"!==s.type,r=V.cloneNode(!0),n=(0,f.hotKeyDeserialize)(e.hotkey),o=n.keys.map((e=>`${e}`));r.innerHTML=function(e,t){const i=/{\d}|{hotkey_\d}/gi;return e.replace(i,(e=>{const i=Number(e.match(/\d/));return t[i]}))}(n.text,o).replace(/\s\+\s/g,`+`),i.classList.add(P["common-tooltip__body--with-hotkey"]),t&&r.classList.add(P["common-tooltip__hotkey-block--divider"]),i.appendChild(r)}return t.addEventListener("contextmenu",y.preventDefault),t}function T(e,t){const i=t.rect;if(!i)return;!function(e,t){const i=m.includes(t)?_[t]:"";e.classList.remove(...m.map((e=>_[e])).filter((e=>!!e))),i&&!e.classList.contains(i)&&e.classList.add(i)}(e,t.colorTheme||"default"),t.addClass&&e.classList.add(t.addClass);const s=B(e),r=e.querySelector(`.${P["common-tooltip__button-container"]}`);s.classList.toggle(P["common-tooltip__body--width_wide"],Boolean(t.wide)),s.classList.toggle(P["common-tooltip__body--no-padding"],Boolean(t.noPadding)),s.classList.toggle(P["common-tooltip__body--width_narrow"],Boolean(t.narrow)),s.classList.toggle(P["common-tooltip__body--no-buttons"],!0),s.style.left=M(0),s.style.width=M(s.clientWidth+(Boolean(t.noPadding)?0:2));const n=document.body.clientWidth,o=w.CheckMobile.iOS()||(0,w.supportTouch)()&&(0,w.isMac)()?window.innerHeight:document.body.clientHeight,a=t.vertical,l=t.extendMargin||a&&i.w<20||!a&&i.h<20;e.classList.toggle(P["common-tooltip--farther"],l),e.classList.toggle(P["common-tooltip--vertical"],a),e.classList.toggle(P["common-tooltip--horizontal"],!a);const c=function(e){return e.querySelector(`.${P["common-tooltip__ear-holder"]}`)}(e),h=e.offsetHeight;if(a){ -const a=10,l=o-10,d=12,u=a+d,p=l-d,_=(0,b.clamp)(i.y+i.h/2,u,p)-h/2,m=_+h;e.style.left=M(i.x+i.w),e.style.top=M(_),_l&&(s.style.top=r.style.top=M(l-m));const{right:g}=(e.querySelector(":last-child")||s).getBoundingClientRect(),f=g+10>n;e.classList.toggle(P["common-tooltip--direction_reversed"],f),e.classList.toggle(P["common-tooltip--direction_normal"],!f);let v=f?"after":"before";(0,S.isRtl)()?(v=t.otr?"after":v,v=t.otl?"before":v):(v=t.otr?"before":v,v=t.otl?"after":v),c.classList.toggle(P["common-tooltip__ear-holder--before"],"before"===v),c.classList.toggle(P["common-tooltip__ear-holder--after"],"after"===v),"after"===v&&(e.style.left="auto",e.style.right=M(n-i.x))}else{const a=i.x-(s.offsetWidth-i.w)/2,l=n-10-e.offsetWidth,d=Math.max(10,Math.min(a,l));e.style.left=M(d);const u=l\n\t\t
\n\t\t\t
\n\t\t
\n\t\t
\n\t\n`,A=`\n\t
\n`,k=`\n\t
\n`,D=(0,v.parseHtmlElement)(L),V=(0,v.parseHtmlElement)(A),E=(0,v.parseHtmlElement)(k);function B(e){return e.querySelector(`.${P["common-tooltip__body"]}`)}function R(e,t){return 10+e{W&&(W.destroy(),W=null)};for(const t of r){if("buttons"in e){if(1&e.buttons)continue}else if(1===e.which)continue;const i=()=>z(t);if(i()){const e=e=>{e.target instanceof Element&&e.target.contains(t)&&s(null,!0)},s=(r,o=!1)=>{t.removeEventListener("common-tooltip-update",i),t.removeEventListener("mouseleave",s),t.removeEventListener("mousedown",s),document.removeEventListener("scroll",e,{capture:!0}),n(),G(o)} +const t=e.hasAttribute("data-tooltip")?e.getAttribute("data-tooltip"):e.getAttribute("title");return t&&((0,g.setTooltipData)(e,"text",t),e.removeAttribute("title")),(0,g.getTooltipData)(e,"text")||""}(e),i=e.getBoundingClientRect(),s={h:i.height,w:i.width,x:i.left,y:i.top},r=e.getAttribute("data-color-theme")||"",n=e.classList.contains("common-tooltip-html"),o=parseInt(e.getAttribute("data-tooltip-delay")||""),a=parseInt(e.getAttribute("data-tooltip-debounce")||"");let l={type:"none"};return t&&(l={type:n?"html":"text",data:t}),{above:e.classList.contains("common-tooltip-above"),below:e.classList.contains("common-tooltip-below"),otl:e.classList.contains("common-tooltip-otl"),otr:e.classList.contains("common-tooltip-otr"),vertical:e.classList.contains("common-tooltip-vertical"),hotkey:e.getAttribute("data-tooltip-hotkey"),narrow:e.classList.contains("common-tooltip-narrow"),wide:e.classList.contains("common-tooltip-wide"),colorTheme:r,tooltipDelay:o,tooltipDebounce:a,rect:s,content:l,target:e}}function x(e){const t=D.cloneNode(!0),i=B(t),{content:s}=e;switch(s.type){case"element":i.innerHTML="",i.appendChild(s.data);break;case"html":i.innerHTML=s.data;break;case"text":if(e.hotkey){const e=V.cloneNode(!0);e.innerText=s.data,i.appendChild(e)}else i.innerText=s.data}if(e.hotkey){const t="none"!==s.type,r=E.cloneNode(!0),n=(0,f.hotKeyDeserialize)(e.hotkey),o=n.keys.map((e=>`${e}`));r.innerHTML=function(e,t){const i=/{\d}|{hotkey_\d}/gi;return e.replace(i,(e=>{const i=Number(e.match(/\d/));return t[i]}))}(n.text,o).replace(/\s\+\s/g,`+`),i.classList.add(P["common-tooltip__body--with-hotkey"]),t&&r.classList.add(P["common-tooltip__hotkey-block--divider"]),i.appendChild(r)}return t.addEventListener("contextmenu",y.preventDefault),t}function T(e,t){const i=t.rect;if(!i)return;!function(e,t){const i=m.includes(t)?_[t]:"";e.classList.remove(...m.map((e=>_[e])).filter((e=>!!e))),i&&!e.classList.contains(i)&&e.classList.add(i)}(e,t.colorTheme||"default"),t.addClass&&e.classList.add(t.addClass);const s=B(e),r=e.querySelector(`.${P["common-tooltip__button-container"]}`);s.classList.toggle(P["common-tooltip__body--width_wide"],Boolean(t.wide)),s.classList.toggle(P["common-tooltip__body--no-padding"],Boolean(t.noPadding)),s.classList.toggle(P["common-tooltip__body--width_narrow"],Boolean(t.narrow)),s.classList.toggle(P["common-tooltip__body--no-buttons"],!0),s.style.left=M(0),s.style.width=M(s.clientWidth+(Boolean(t.noPadding)?0:2));const n=document.body.clientWidth,o=w.CheckMobile.iOS()||(0,w.supportTouch)()&&(0,w.isMac)()?window.innerHeight:document.body.clientHeight,a=t.vertical,l=t.extendMargin||a&&i.w<20||!a&&i.h<20;e.classList.toggle(P["common-tooltip--farther"],l),e.classList.toggle(P["common-tooltip--vertical"],a),e.classList.toggle(P["common-tooltip--horizontal"],!a);const c=function(e){return e.querySelector(`.${P["common-tooltip__ear-holder"]}`)}(e),h=e.offsetHeight;if(a){ +const a=10,l=o-10,d=12,u=a+d,p=l-d,_=(0,b.clamp)(i.y+i.h/2,u,p)-h/2,m=_+h;e.style.left=M(i.x+i.w),e.style.top=M(_),_l&&(s.style.top=r.style.top=M(l-m));const{right:g}=(e.querySelector(":last-child")||s).getBoundingClientRect(),f=g+10>n;e.classList.toggle(P["common-tooltip--direction_reversed"],f),e.classList.toggle(P["common-tooltip--direction_normal"],!f);let v=f?"after":"before";(0,S.isRtl)()?(v=t.otr?"after":v,v=t.otl?"before":v):(v=t.otr?"before":v,v=t.otl?"after":v),c.classList.toggle(P["common-tooltip__ear-holder--before"],"before"===v),c.classList.toggle(P["common-tooltip__ear-holder--after"],"after"===v),"after"===v&&(e.style.left="auto",e.style.right=M(n-i.x))}else{const a=i.x-(s.offsetWidth-i.w)/2,l=n-10-e.offsetWidth,d=Math.max(10,Math.min(a,l));e.style.left=M(d);const u=l\n\t\t
\n\t\t\t
\n\t\t
\n\t\t
\n\t\n`,A=`\n\t
\n`,k=`\n\t
\n`,D=(0,v.parseHtmlElement)(L),E=(0,v.parseHtmlElement)(A),V=(0,v.parseHtmlElement)(k);function B(e){return e.querySelector(`.${P["common-tooltip__body"]}`)}function R(e,t){return 10+e{W&&(W.destroy(),W=null)};for(const t of r){if("buttons"in e){if(1&e.buttons)continue}else if(1===e.which)continue;const i=()=>z(t);if(i()){const e=e=>{e.target instanceof Element&&e.target.contains(t)&&s(null,!0)},s=(r,o=!1)=>{t.removeEventListener("common-tooltip-update",i),t.removeEventListener("mouseleave",s),t.removeEventListener("mousedown",s),document.removeEventListener("scroll",e,{capture:!0}),n(),G(o)} ;t.addEventListener("common-tooltip-update",i),t.addEventListener("mouseleave",s),t.addEventListener("mousedown",s),document.addEventListener("scroll",e,{capture:!0}),null===W&&(W=(0,N.createGroup)({desc:"Tooltip"}),W.add({desc:"Hide",hotkey:27,handler:s}));break}}}),!0);const H=new MutationObserver((()=>{if(F&&F.options.target){let e;e="isConnected"in F.options.target?F.options.target.isConnected:document.body.contains(F.options.target),e||G()}})),z=(e,t={})=>{const{content:i,...s}=Y(t),r=C(e),n=Object.assign(r,s);return"none"!==i.type&&(n.content=i),!("none"===n.content.type&&!n.hotkey)&&(n.target=e,U(n),!0)},U=e=>{const t=Y(e),i=x(t);var s;if(F={options:t,element:i},s=i,u(),h&&h.appendChild(s),a(),!O)return I(i),void l((()=>q(i)),function(e){return"number"!=typeof e.tooltipDelay||isNaN(e.tooltipDelay)?500:e.tooltipDelay}(t));const{tooltipDebounce:r}=e;"number"!=typeof r||isNaN(r)?q(i):l((()=>q(i)),r)};function j(){u(),O=!1,F=null}const G=e=>{if(a(),H.disconnect(),!F)return;if(!e&&!O)return;const{element:t,options:i}=F,s=()=>{t.removeEventListener("mouseleave",s),I(t),e?j():o=setTimeout((()=>{j()}),250)};var r,l;i.tooltipHideDelay?(r=()=>{t.querySelector(":hover")?t.addEventListener("mouseleave",s):s()},l=i.tooltipHideDelay,n=setTimeout(r,l)):s()};function q(e){const{options:t}=(0,p.ensureNotNull)(F);if(T(e,t),function(e){e.classList.toggle(P["common-tooltip--hidden"],!1)}(e),H.observe(document,{childList:!0,subtree:!0}),O=!0,t.forceHideOnMove){const e=()=>{document.removeEventListener("mousemove",e),document.removeEventListener("touchmove",e),G()};document.addEventListener("mousemove",e),document.addEventListener("touchmove",e)}}function $(e){return e&&(e.nodeType===Node.ELEMENT_NODE?e:null)}function Y(e){if(function(e){return"content"in e}(e))return e;const{inner:t,html:i,text:s,...r}=e;let n={type:"none"};return t&&(n={type:"element",data:t}),s&&(n={type:i?"html":"text",data:s}),{content:n,...r}}},31940:(e,t,i)=>{"use strict";i.d(t,{ResizerDetacherState:()=>n});var s=i(50151),r=i(97145);class n{constructor(e){this._alive=new r.WatchedValue,this._container=new r.WatchedValue,this._width=new r.WatchedValue,this._height=new r.WatchedValue,this._fullscreen=new r.WatchedValue,this._detachable=new r.WatchedValue,this._fullscreenable=new r.WatchedValue,this._visible=new r.WatchedValue,this._availWidth=new r.WatchedValue,this._availHeight=new r.WatchedValue,this._owner=new r.WatchedValue,this._ownersStack=[],this.owner=this._owner.readonly(),this._bridge={alive:this._alive.readonly(),container:this._container.readonly(),width:this._width.readonly(),height:this._height.readonly(),fullscreen:this._fullscreen.readonly(),detachable:this._detachable.readonly(),fullscreenable:this._fullscreenable.readonly(),visible:this._visible.readonly(),availWidth:this._availWidth.readonly(),availHeight:this._availHeight.readonly(),remove:()=>{const e=this._owner.value();e&&e.remove&&e.remove()},negotiateWidth:e=>{const t=this._owner.value();t&&t.negotiateWidth&&t.negotiateWidth(e)},negotiateHeight:e=>{const t=this._owner.value() ;t&&t.negotiateHeight&&t.negotiateHeight(e)},requestFullscreen:()=>{const e=this._owner.value();e&&e.requestFullscreen&&e.requestFullscreen()},exitFullscreen:()=>{const e=this._owner.value();e&&e.exitFullscreen&&e.exitFullscreen()},detach:e=>{const t=this._owner.value();t&&t.detach&&t.detach(e)},attach:()=>{const e=this._owner.value();e&&e.attach&&e.attach()}},e&&this.pushOwner(e)}bridge(){return this._bridge}pushOwner(e){if(!e.alive.value())return;for(const e of this._ownersStack)this._unsubscribeOwner(e);const t={owner:e};this._ownersStack.push(t),this._subscribeOwner(t)}_subscribeOwner(e){const t=e.owner;if(e.deathWatcher||(this._alive.setValue(!0),e.deathWatcher=t.alive.spawn(),e.deathWatcher.subscribe((t=>{t||this._deadHandler(e)}))),this._owner.setValue(t),!e.subscriptions){const i=e.subscriptions=[];this._visible.setValue(!1);const s=(e,t)=>{if(e){const s=e.spawn();i.push(s),s.subscribe((e=>{t.setValue(e)}),{callWithLast:!0})}else t.deleteValue()};s(t.container,this._container),s(t.width,this._width),s(t.height,this._height),s(t.fullscreen,this._fullscreen),s(t.detachable,this._detachable),s(t.fullscreenable,this._fullscreenable),s(t.availWidth,this._availWidth),s(t.availHeight,this._availHeight),s(t.visible,this._visible)}}_unsubscribeOwner(e,t){if(e.subscriptions){for(const t of e.subscriptions)t.unsubscribe();e.subscriptions=null}t&&e.deathWatcher&&(e.deathWatcher.unsubscribe(),e.deathWatcher=null)}_deadHandler(e){const t=this._ownersStack.indexOf(e);(0,s.assert)(-1!==t,"sanitized owner should be in stack");for(let e=this._ownersStack.length-1;e>=t;e--)this._unsubscribeOwner(this._ownersStack[e],!0);this._ownersStack.length=t,t>0?this._subscribeOwner(this._ownersStack[t-1]):(this._alive.setValue(!1),this._owner.deleteValue())}}},45973:(e,t,i)=>{"use strict";i.r(t),i.d(t,{entityForDataSource:()=>c,lineToolEntityInfo:()=>o,seriesEntityInfo:()=>l,studyEntityInfo:()=>a});var s=i(28853),r=i(88913),n=i(92249);function o(e){return{id:e.id(),name:(t=e.toolname,Object.keys(r.supportedLineTools).find((e=>r.supportedLineTools[e].name===t))||null)};var t}function a(e){return{id:e.id(),name:e.metaInfo().description}}function l(e){return{id:e.id(),name:"Main Series"}}function c(e,t){return t===e.mainSeries()?l(e.mainSeries()):(0,s.isStudy)(t)?a(t):(0,n.isLineTool)(t)?o(t):null}},68582:(e,t,i)=>{"use strict";i.r(t),i.d(t,{LineDataSourceApi:()=>c,isLineToolRiskReward:()=>a});var s=i(50151),r=i(1722);const n=new Map([["LineToolRiskRewardLong",2],["LineToolRiskRewardShort",2],["LineToolBezierQuadro",3],["LineToolBezierCubic",4]]);function o(e){const t=n.get(e.toolname);if(void 0!==t)return t;const i=e.pointsCount();return-1===i?e.points().length:i}function a(e){return"LineToolRiskRewardLong"===e||"LineToolRiskRewardShort"===e}const l=["alwaysShowStats","entryPrice","inputs.first bar time","inputs.last bar time","interval","linesWidths","points","snapTo45Degrees","stopPrice","symbol","symbolStateVersion","currencyId","unitId","targetPrice","zOrderVersion"];class c{constructor(e,t,i){this._source=e,this._undoModel=t, this._model=t.model(),this._pointsConverter=i}isSelectionEnabled(){return this._source.isSelectionEnabled()}setSelectionEnabled(e){this._source.setSelectionEnabled(e)}isSavingEnabled(){return this._source.isSavedInChart()}setSavingEnabled(e){this._source.setSavingInChartEnabled(e)}isShowInObjectsTreeEnabled(){return this._source.showInObjectTree()}setShowInObjectsTreeEnabled(e){this._source.setShowInObjectsTreeEnabled(e)}isUserEditEnabled(){return this._source.userEditEnabled()}setUserEditEnabled(e){this._source.setUserEditEnabled(e)}bringToFront(){this._model.bringToFront([this._source])}sendToBack(){this._model.sendToBack([this._source])}getProperties(){return this._source.properties().state(l,!0)}setProperties(e){this._setProps(this._source.properties(),e,"")}getPoints(){let e=this._source.points();const t=o(this._source);return e.length>t&&((0,s.assert)(a(this._source.toolname)),e=e.slice(0,t)),this._pointsConverter.dataSourcePointsToPriced(e)}setPoints(e){if(this._source.isFixed())return;const t=o(this._source);if(t!==e.length)throw new Error(`Wrong points count. Required: ${t}, provided: ${e.length}`);const i=this._pointsConverter.apiPointsToDataSource(e);this._model.startChangingLinetool(this._source),this._model.changeLinePoints(this._source,i),this._model.endChangingLinetool(!0),this._source.createServerPoints()}getAnchoredPosition(){return this._source.positionPercents()}setAnchoredPosition(e){const t=this._source.fixedPoint(),i=this._source.linkKey().value(),s=void 0===t?null:this._source.screenPointToPoint(t);if(!this._source.isFixed()||void 0===t||null===i||null===s)return;const r={logical:s,screen:t},n=new Map;n.set(i,e),this._model.startMovingSources([this._source],r,null,new Map),this._model.moveSources(r,n),this._model.endMovingSources(!0)}ownerSourceId(){return(0,s.ensureNotNull)(this._source.ownerSource()).id()}changePoint(e,t){if(this._source.isFixed())return;const i=this._pointsConverter.apiPointsToDataSource([e])[0];this._model.startChangingLinetool(this._source,{...i},t),this._model.changeLinePoint({...i}),this._model.endChangingLinetool(!1),this._source.createServerPoints()}isHidden(){return this._source.isSourceHidden()}getRawPoints(){return this._source.points()}setRawPoint(e,t){this._model.startChangingLinetool(this._source,{...t},e),this._model.changeLinePoint({...t}),this._model.endChangingLinetool(!1)}move(e,t){this._model.startMovingSources([this._source],{logical:e},null,new Map),this._model.moveSources({logical:t},new Map),this._model.endMovingSources(!1)}dataAndViewsReady(){return this._source.dataAndViewsReady()}zorder(){return this._source.zorder()}symbol(){return this._source.properties().symbol.value()}currency(){return this._source.properties().currencyId.value()}unit(){return this._source.properties().unitId.value()}share(e){this._undoModel.shareLineTools([this._source],e)}setVisible(e,t=!1){this._undoModel.setProperty(this._source.properties().visible,e,null,t)}sharingMode(){return this._source.sharingMode().value()}_setProps(e,t,i){for(const s in t){ @@ -22,25 +22,25 @@ this.isAvailable?this.localStorage.clear():this.localStorage={},this._updateLeng ;var _,m=TradingView.onWidget()?"tradingview-widget":"tradingview",g=m+".",f={},v=[/^widgetbar\.widget\.watchlist.+/,/.+quicks$/,/^widgetbar\.layout-settings$/,/^ChartSideToolbarWidget\.visible$/,/^onwidget\.watchlist$/,/^chart\.favoriteDrawings$/,/^chart\.favoriteDrawingsPosition$/,/^chart\.favoriteLibraryIndicators$/,/^loadChartDialog.favorites$/,/^ChartFavoriteDrawingToolbarWidget\.visible/,/^trading\.chart\.proterty$/,/^trading_floating_toolbar\.position$/,/^trading\.orderWidgetMode\./,/^symbolWatermark$/,/^pinereference\.size$/,/^pinereference\.position$/,/^hint\.+/,/^ChartDrawingToolbarWidget\.visible/];function S(e){return g+e}function y(e){return e.substring(g.length)}function b(e,t){var i=f[e];return null==i?t:i}function w(e,t,i){i=i||{};var s=""+t;return f[e]!==s&&(f[e]=s,C(e)),i.forceFlush&&!_&&(_=setTimeout((function(){_=void 0,x()}),10)),h}function P(e,t){return t=t||{},null!=f[e]&&(delete f[e],C(e)),t.forceFlush&&x(),h}function C(e){if(t)null==f[e]?t.removeValue(e):t.setValue(e,f[e]);else if(i())try{null==f[e]?n.removeItem(S(e)):n.setItem(S(e),f[e])}catch(e){}else 0;r.emit("settings",JSON.stringify({key:e,value:f[e]}))}function x(e){}function T(){return Object.keys(f)}function I(e){for(var t=0;t=0;n--)e.test(i[n])&&r.push(i[n]),e.lastIndex=0;return r},sync:function(e){null!==e?(t?L(t.initialSettings||{}):i()?(function(){if(TradingView.onWidget()&&l.includes(window.location.host))for(var e="tradingview.",t=n.length;t--;){var i=n.key(t);if(0===i.indexOf(e)){var s=i.replace(e,m+".");n.setItem(s,n.getItem(i)),n.removeItem(i)}}}(),function(){f={};for(var e=!a.enabled("save_chart_properties_to_local_storage"),t=n.length;t--;){var i=n.key(t);if(i&&M(i)){var s=i.substring(g.length);e&&!I(s)||(f[s]=n.getItem(i))}}}()):L(e||{}),A.fire()):!0},onSync:A,setSettingsAdapter:function(e){t=e}}}() ;e&&e.exports&&(e.exports=h)},88145:(e,t,i)=>{"use strict";function s(e){return e.includes("crypto")}i.d(t,{hasCryptoTypespec:()=>s})},26843:(e,t,i)=>{"use strict";i.d(t,{StdTheme:()=>a.StdTheme,getStdChartTheme:()=>h,getStdThemeNames:()=>c,isStdTheme:()=>u,translateThemeName:()=>d});var s=i(44352),r=i(24377) ;const n=JSON.parse('{"content":{"chartProperties":{"scalesProperties":{"textColor":"#131722","lineColor":"rgba(42, 46, 57, 0)","backgroundColor":"#ffffff"},"paneProperties":{"vertGridProperties":{"color":"rgba(42, 46, 57, 0.06)"},"horzGridProperties":{"color":"rgba(42, 46, 57, 0.06)"},"crossHairProperties":{"color":"#9598A1"},"background":"#ffffff","backgroundGradientStartColor":"#ffffff","backgroundGradientEndColor":"#ffffff","separatorColor":"#E0E3EB"}},"sessions":{"graphics":{"backgrounds":{"outOfSession":{"color":"#2962FF","transparency":92},"preMarket":{"color":"#FF9800","transparency":92},"postMarket":{"color":"#2962FF","transparency":92}},"vertlines":{"sessBreaks":{"color":"#4985e7","style":2,"width":1}}}},"mainSourceProperties":{"baseLineColor":"#B2B5BE","candleStyle":{"borderColor":"#378658","upColor":"#089981","wickColor":"#737375","wickUpColor":"#089981","wickDownColor":"#F23645","downColor":"#F23645","borderUpColor":"#089981","borderDownColor":"#F23645"},"haStyle":{"borderColor":"#378658","upColor":"#089981","wickColor":"#737375","wickUpColor":"#089981","wickDownColor":"#F23645","downColor":"#F23645","borderUpColor":"#089981","borderDownColor":"#F23645"},"barStyle":{"downColor":"#F23645","upColor":"#089981"},"pnfStyle":{"downColor":"#F23645","upColor":"#089981","upColorProjection":"#a9dcc3","downColorProjection":"#f5a6ae"},"baselineStyle":{"baselineColor":"#758696","topFillColor1":"rgba(8, 153, 129, 0.28)","topFillColor2":"rgba(8, 153, 129, 0.05)","bottomFillColor1":"rgba(242, 54, 69, 0.05)","bottomFillColor2":"rgba(242, 54, 69, 0.28)","topLineColor":"#089981","bottomLineColor":"#F23645"},"areaStyle":{"transparency":100,"color1":"rgba(41, 98, 255, 0.28)","color2":"#2962FF","linecolor":"#2962FF","linewidth":2,"linestyle":0},"hiloStyle":{"color":"#2962FF","borderColor":"#2962FF","labelColor":"#2962FF"},"columnStyle":{"upColor":"rgba(8, 153, 129, 0.5)","downColor":"rgba(242, 54, 69, 0.5)","priceSource":"close"},"renkoStyle":{"upColor":"#089981","downColor":"#F23645","borderUpColor":"#089981","borderDownColor":"#F23645","upColorProjection":"#a9dcc3","downColorProjection":"#f5a6ae","borderUpColorProjection":"#a9dcc3","borderDownColorProjection":"#f5a6ae","wickUpColor":"#089981","wickDownColor":"#F23645"},"lineStyle":{"color":"#2962FF","linewidth":2,"linestyle":0},"lineWithMarkersStyle":{"color":"#2962FF","linewidth":2,"linestyle":0},"steplineStyle":{"color":"#2962FF","linewidth":2,"linestyle":0},"kagiStyle":{"downColor":"#F23645","upColor":"#089981","upColorProjection":"#a9dcc3","downColorProjection":"#f5a6ae"},"pbStyle":{"upColor":"#089981","downColor":"#F23645","borderUpColor":"#089981","borderDownColor":"#F23645","upColorProjection":"#a9dcc3","downColorProjection":"#f5a6ae","borderUpColorProjection":"#a9dcc3","borderDownColorProjection":"#f5a6ae"},"rangeStyle":{"upColor":"#089981","downColor":"#F23645","upColorProjection":"#a9dcc3","downColorProjection":"#f5a6ae"}}}}'),o=JSON.parse('{"content":{"chartProperties":{"scalesProperties":{"textColor":"#B2B5BE","lineColor":"rgba(240, 243, 250, 0)","backgroundColor":"#ffffff"},"paneProperties":{"vertGridProperties":{"color":"rgba(240, 243, 250, 0.06)"},"horzGridProperties":{"color":"rgba(240, 243, 250, 0.06)"},"crossHairProperties":{"color":"#9598A1"},"background":"#131722","backgroundGradientStartColor":"#181C27","backgroundGradientEndColor":"#131722","backgroundType":"gradient","separatorColor":"#2A2E39"}},"sessions":{"graphics":{"backgrounds":{"outOfSession":{"color":"#2962FF","transparency":92},"preMarket":{"color":"#FF9800","transparency":92},"postMarket":{"color":"#2962FF","transparency":92}},"vertlines":{"sessBreaks":{"color":"#4985e7","style":2,"width":1}}}},"mainSourceProperties":{"baseLineColor":"#5d606b","candleStyle":{"borderColor":"#378658","upColor":"#089981","wickColor":"#B5B5B8","wickUpColor":"#089981","wickDownColor":"#F23645","downColor":"#F23645","borderUpColor":"#089981","borderDownColor":"#F23645"},"haStyle":{"borderColor":"#378658","upColor":"#089981","wickColor":"#B5B5B8","wickUpColor":"#089981","wickDownColor":"#F23645","downColor":"#F23645","borderUpColor":"#089981","borderDownColor":"#F23645"},"barStyle":{"downColor":"#F23645","upColor":"#089981"},"pnfStyle":{"downColor":"#F23645","upColor":"#089981","upColorProjection":"#336854","downColorProjection":"#7f323f"},"baselineStyle":{"baselineColor":"#758696","topFillColor1":"rgba(8, 153, 129, 0.28)","topFillColor2":"rgba(8, 153, 129, 0.05)","bottomFillColor1":"rgba(242, 54, 69, 0.05)","bottomFillColor2":"rgba(242, 54, 69, 0.28)","topLineColor":"#089981","bottomLineColor":"#F23645"},"areaStyle":{"transparency":100,"color1":"rgba(41, 98, 255, 0.28)","color2":"#2962FF","linecolor":"#2962FF","linewidth":2,"linestyle":0},"hiloStyle":{"color":"#2962FF","borderColor":"#2962FF","labelColor":"#2962FF"},"columnStyle":{"upColor":"rgba(8, 153, 129, 0.5)","downColor":"rgba(242, 54, 69, 0.5)","priceSource":"close"},"renkoStyle":{"upColor":"#089981","downColor":"#F23645","borderUpColor":"#089981","borderDownColor":"#F23645","upColorProjection":"#336854","downColorProjection":"#7f323f","borderUpColorProjection":"#336854","borderDownColorProjection":"#7f323f","wickUpColor":"#089981","wickDownColor":"#F23645"},"lineStyle":{"color":"#2962FF","linewidth":2,"linestyle":0},"lineWithMarkersStyle":{"color":"#2962FF","linewidth":2,"linestyle":0},"steplineStyle":{"color":"#2962FF","linewidth":2,"linestyle":0},"kagiStyle":{"downColor":"#F23645","upColor":"#089981","upColorProjection":"#336854","downColorProjection":"#7f323f"},"pbStyle":{"upColor":"#089981","downColor":"#F23645","borderUpColor":"#089981","borderDownColor":"#F23645","upColorProjection":"#336854","downColorProjection":"#7f323f","borderUpColorProjection":"#336854","borderDownColorProjection":"#7f323f"},"rangeStyle":{"upColor":"#089981","downColor":"#F23645","upColorProjection":"#336854","downColorProjection":"#7f323f"}}}}') -;var a=i(24633);function l(){return{[a.StdTheme.Light]:JSON.parse(JSON.stringify(n)),[a.StdTheme.Dark]:JSON.parse(JSON.stringify(o))}}function c(){return[a.StdTheme.Light,a.StdTheme.Dark]}function h(e){return l()[e]}function d(e){return{[a.StdTheme.Light]:s.t(null,{context:"colorThemeName"},i(69841)),[a.StdTheme.Dark]:s.t(null,{context:"colorThemeName"},i(14642))}[e]||e}function u(e){const t=l();return c().some((i=>p(t[i],e)))}function p(e,t){let i=e.content===t.content;return function(e={},t){try{_(e,[],t)}catch(e){return}}(e.content,((e,s)=>{const n=function(e,t={}){let i=t;for(let t=0;t{"use strict";var s;i.d(t,{StdTheme:()=>s}),function(e){e.Light="light",e.Dark="dark"}(s||(s={}))},5286:(e,t,i)=>{"use strict";i.r(t),i.d(t,{DEFAULT_THEME:()=>h,extractThemeFromModel:()=>E,getCurrentTheme:()=>g,getStdTheme:()=>T,getStdThemeNames:()=>C,getStdThemedValue:()=>I,getTheme:()=>w,getThemeNames:()=>P,getThemedColor:()=>f,isPublicTheme:()=>m,isStdTheme:()=>V,isStdThemeName:()=>x,isStdThemedDefaultValue:()=>M,isThemeExist:()=>k,loadTheme:()=>v,removeTheme:()=>A,restoreTheme:()=>S,saveTheme:()=>L,savedThemeName:()=>y,syncTheme:()=>b,themes:()=>_,translateStdThemeName:()=>D});var s=i(24377),r=i(85804),n=i(56840);function o(){return(0,n.getValue)("current_theme.name")||null}const a=i(58844);var l=i(26843),c=i(45345);const h="light";var d=i(44352) +;var a=i(24633);function l(){return{[a.StdTheme.Light]:JSON.parse(JSON.stringify(n)),[a.StdTheme.Dark]:JSON.parse(JSON.stringify(o))}}function c(){return[a.StdTheme.Light,a.StdTheme.Dark]}function h(e){return l()[e]}function d(e){return{[a.StdTheme.Light]:s.t(null,{context:"colorThemeName"},i(69841)),[a.StdTheme.Dark]:s.t(null,{context:"colorThemeName"},i(14642))}[e]||e}function u(e){const t=l();return c().some((i=>p(t[i],e)))}function p(e,t){let i=e.content===t.content;return function(e={},t){try{_(e,[],t)}catch(e){return}}(e.content,((e,s)=>{const n=function(e,t={}){let i=t;for(let t=0;t{"use strict";var s;i.d(t,{StdTheme:()=>s}),function(e){e.Light="light",e.Dark="dark"}(s||(s={}))},5286:(e,t,i)=>{"use strict";i.r(t),i.d(t,{DEFAULT_THEME:()=>h,extractThemeFromModel:()=>V,getCurrentTheme:()=>g,getStdTheme:()=>T,getStdThemeNames:()=>C,getStdThemedValue:()=>I,getTheme:()=>w,getThemeNames:()=>P,getThemedColor:()=>f,isPublicTheme:()=>m,isStdTheme:()=>E,isStdThemeName:()=>x,isStdThemedDefaultValue:()=>M,isThemeExist:()=>k,loadTheme:()=>v,removeTheme:()=>A,restoreTheme:()=>S,saveTheme:()=>L,savedThemeName:()=>y,syncTheme:()=>b,themes:()=>_,translateStdThemeName:()=>D});var s=i(24377),r=i(85804),n=i(56840);function o(){return(0,n.getValue)("current_theme.name")||null}const a=i(58844);var l=i(26843),c=i(45345);const h="light";var d=i(44352) ;const u=JSON.parse('{"color-header-bg":"color-black","color-body-bg":"color-black","color-body-secondary-bg":"color-cold-gray-900","color-bg-primary":"color-cold-gray-850","color-bg-primary-hover":"color-cold-gray-800","color-bg-secondary":"color-cold-gray-900","color-bg-highlight":"color-cold-gray-900","color-bg-scroll-buttons":"color-cold-gray-800","color-legacy-bg-scroll-buttons":"color-cold-gray-550","color-legacy-bg-widget":"color-cold-gray-900","color-text-primary":"color-cold-gray-200","color-text-secondary":"color-cold-gray-450","color-text-tertiary":"color-cold-gray-400","color-text-disabled":"color-cold-gray-650","color-accent-content":"color-white","color-divider":"color-cold-gray-700","color-divider-hover":"color-cold-gray-800","color-divider-secondary":"color-cold-gray-800","color-box-shadow":"color-cold-gray-900","color-active-hover-text":"color-cold-gray-200","color-alert-text":"color-cold-gray-200","color-border":"color-cold-gray-750","color-border-chat-fields":"color-cold-gray-750","color-border-hover":"color-cold-gray-650","color-border-table":"color-cold-gray-800","color-brand":"color-tv-blue-500","color-brand-hover":"color-tv-blue-600","color-brand-active":"color-tv-blue-700","color-button-hover-bg":"color-cold-gray-850","color-chart-page-bg":"color-cold-gray-800","color-common-tooltip-bg":"color-cold-gray-750","color-danger":"color-ripe-red-600","color-danger-hover":"color-ripe-red-500","color-danger-active":"color-ripe-red-400","color-depthrenderer-fill-style":"color-cold-gray-150","color-depthrenderer-stroke-style":"color-cold-gray-650","color-disabled-border-and-color":"color-cold-gray-800","color-disabled-input":"color-cold-gray-750","color-empty-container-message":"color-cold-gray-450","color-halal":"color-iguana-green-400","color-continuous":"color-cold-gray-500","color-highlight-new":"color-tv-blue-a800","color-icons":"color-cold-gray-450","color-input-bg":"color-cold-gray-800","color-input-textarea-readonly":"color-cold-gray-650","color-input-placeholder-text":"color-cold-gray-700","color-input-publish-bg":"color-cold-gray-900","color-item-active-blue":"color-tv-blue-a900","color-item-hover-active-bg":"color-cold-gray-800","color-item-hover-bg":"color-cold-gray-800","color-item-hover-blue":"color-tv-blue-a800","color-item-selected-blue":"color-tv-blue-a800","color-item-active-text":"color-cold-gray-200","color-item-active-bg":"color-tv-blue-500","color-link":"color-tv-blue-500","color-link-hover":"color-tv-blue-600","color-link-active":"color-tv-blue-700","color-list-item":"color-cold-gray-450","color-list-nth-child-bg":"color-cold-gray-850","color-news-highlight":"color-cold-gray-800","color-pane-bg":"color-cold-gray-900","color-pane-secondary-bg":"color-cold-gray-850","color-placeholder":"color-cold-gray-650","color-popup-menu-item-hover-bg":"color-cold-gray-800","color-popup-menu-separator":"color-cold-gray-700","color-primary-symbol":"color-sky-blue-500","color-row-hover-active-bg":"color-cold-gray-800","color-sb-scrollbar-body-bg":"color-cold-gray-650","color-screener-description":"color-cold-gray-200","color-section-separator-border":"color-cold-gray-750","color-search-button-hover":"color-cold-gray-700","color-separator-table-chat":"color-cold-gray-750","color-success":"color-minty-green-700","color-success-hover":"color-minty-green-600","color-success-active":"color-minty-green-500","color-tag-active-bg":"color-cold-gray-750","color-tag-hover-bg":"color-cold-gray-800","color-text-regular":"color-cold-gray-200","color-toolbar-button-text":"color-cold-gray-200","color-toolbar-button-text-hover":"color-cold-gray-200","color-toolbar-button-text-active":"color-tv-blue-500","color-toolbar-button-text-active-hover":"color-tv-blue-600","color-toolbar-button-background-hover":"color-cold-gray-800","color-toolbar-button-background-secondary-hover":"color-cold-gray-750","color-toolbar-button-background-active":"color-tv-blue-a900","color-toolbar-button-background-active-hover":"color-tv-blue-a800","color-toolbar-toggle-button-background-active":"color-tv-blue-500","color-toolbar-toggle-button-background-active-hover":"color-tv-blue-600","color-toolbar-toggle-button-icon":"color-cold-gray-650","color-toolbar-interactive-element-text-normal":"color-cold-gray-200","color-toolbar-opened-element-bg":"color-cold-gray-800","color-toolbar-divider-background":"color-cold-gray-700","color-popup-background":"color-cold-gray-850","color-popup-element-text":"color-cold-gray-200","color-popup-element-text-hover":"color-cold-gray-250","color-popup-element-background-hover":"color-cold-gray-800","color-popup-element-secondary-text":"color-cold-gray-500","color-popup-element-hint-text":"color-cold-gray-600","color-popup-element-text-active":"color-cold-gray-200","color-popup-element-background-active":"color-tv-blue-500","color-popup-element-toolbox-text":"color-cold-gray-500","color-popup-element-toolbox-text-hover":"color-cold-gray-200","color-popup-element-toolbox-text-active-hover":"color-tv-blue-200","color-popup-element-toolbox-background-hover":"color-cold-gray-750","color-popup-element-toolbox-background-active-hover":"color-tv-blue-700","color-tooltip-bg":"color-cold-gray-750","color-tv-button-checked":"color-cold-gray-450","color-tv-dialog-caption":"color-cold-gray-50","color-tv-dropdown-item-hover-bg":"color-cold-gray-800","color-underlined-text":"color-cold-gray-450","color-widget-pages-bg":"color-cold-gray-900","color-warning":"color-tan-orange-700","color-forex-icon":"color-white","color-list-item-active-bg":"color-tv-blue-500","color-list-item-hover-bg":"color-cold-gray-800","color-list-item-text":"color-cold-gray-200","color-price-axis-label-back":"color-cold-gray-800","color-price-axis-label-text":"color-cold-gray-500","color-price-axis-gear":"color-cold-gray-200","color-price-axis-gear-hover":"color-cold-gray-400","color-price-axis-highlight":"color-cold-gray-800","color-bid":"color-tv-blue-500","color-scroll-bg":"color-cold-gray-750","color-scroll-border":"color-cold-gray-850","color-widget-border":"color-cold-gray-800","color-scroll-buttons-arrow":"color-white","color-control-intent-default":"color-cold-gray-650","color-control-intent-success":"color-minty-green-500","color-control-intent-primary":"color-tv-blue-500","color-control-intent-warning":"color-tan-orange-500","color-control-intent-danger":"color-ripe-red-500","color-growing":"color-minty-green-500","color-falling":"color-ripe-red-500","color-goto-label-background":"color-cold-gray-650","color-pre-market":"color-tan-orange-600","color-pre-market-bg":"color-tan-orange-400","color-post-market":"color-tv-blue-500","color-post-market-bg":"color-tv-blue-400","color-market-open":"color-minty-green-500","color-market-open-bg":"color-minty-green-400","color-market-closed":"color-cold-gray-400","color-market-holiday":"color-cold-gray-400","color-market-expired":"color-ripe-red-500","color-invalid-symbol":"color-ripe-red-400","color-invalid-symbol-hover":"color-ripe-red-500","color-replay-mode":"color-tv-blue-500","color-replay-mode-point-select":"color-cold-gray-250","color-replay-mode-icon":"color-tv-blue-50","color-replay-mode-hover":"color-tv-blue-600","color-notaccurate-mode":"color-berry-pink-600","color-delay-mode":"color-tan-orange-700","color-delay-mode-bg":"color-tan-orange-400","color-eod-mode":"color-grapes-purple-700","color-eod-mode-bg":"color-grapes-purple-400","color-data-problem":"color-ripe-red-600","color-data-problem-bg":"color-ripe-red-400","color-data-problem-hover":"color-ripe-red-500","color-list-item-bg-highlighted":"color-tv-blue-a900","color-list-item-bg-selected":"color-tv-blue-a800","color-list-item-bg-highlighted-hover":"color-tv-blue-a800","color-list-item-bg-selected-hover":"color-tv-blue-a700","color-screener-header-bg":"color-cold-gray-850","color-screener-header-bg-hover":"color-cold-gray-800","color-overlay":"color-cold-gray-950","color-boost-button-content-selected":"color-tv-blue-100","color-boost-button-content-hover":"color-white","color-boost-button-bg-hover":"color-cold-gray-750","color-boost-button-border-hover":"color-cold-gray-750","color-boost-button-border-default":"color-cold-gray-700","color-card-border":"color-cold-gray-700","color-card-border-hover":"color-cold-gray-600","color-background-special-primary":"color-black","color-stroke-special-primary":"color-cold-gray-800","color-selection-bg":"color-tv-blue-a700","color-default-gray":"color-cold-gray-450","color-featured-broker-badge-bg":"color-white","color-featured-broker-badge-bg-hover":"color-cold-gray-100","color-featured-broker-badge-text":"color-cold-gray-900"}') -;var p=i(48891);const _={[l.StdTheme.Light]:{name:l.StdTheme.Light,label:()=>d.t(null,{context:"colorThemeName"},i(69841)),order:2,getThemedColor:e=>(0,p.getHexColorByName)(e)},[l.StdTheme.Dark]:{name:l.StdTheme.Dark,label:()=>d.t(null,{context:"colorThemeName"},i(14642)),order:1,getThemedColor:e=>{const t=u[e]||e;return(0,p.getHexColorByName)(t)}}};function m(e){return!e.isPrivate}function g(){return _[c.watchedTheme.value()]||_[h]}function f(e){return g().getThemedColor(e)}async function v(e,t){const{themeName:i,standardTheme:s,syncState:n=!0,noUndo:o=!1,applyOverrides:a=!1,onlyActiveChart:l=!1}=t,c=await(s?Promise.resolve(T(i)):w(i)),h=!s;if(void 0!==c.content){const t=!s||l;a&&(void 0!==(d=c.content).chartProperties&&(0,r.applyDefaultsOverrides)(d.chartProperties),void 0!==d.mainSourceProperties&&(0,r.applyDefaultsOverrides)(d.mainSourceProperties,void 0,!0,"mainSeriesProperties")),await e.applyTheme({theme:c.content,onlyActiveChart:t,restoreNonThemeDefaults:h,themeName:i,standardTheme:s,syncState:n,noUndo:o})}var d;return c}function S(){(0,c.setTheme)(o()||h)}function y(){return o()}function b(){var e;e=g().name,(0,n.setValue)("current_theme.name",e,{forceFlush:!0})}function w(e){return a.loadTheme(e)}function P(){return a.loadThemes()}function C(){return l.getStdThemeNames()}function x(e){return C().includes(e)}function T(e){return l.getStdChartTheme(e)||{content:void 0}}function I(e,t){const i=t||g().name,s=l.getStdChartTheme(i),r=0!==e.length&&e.split(".");return s&&s.content&&r?r.reduce(((e,t)=>e[t]),s.content):null}function M(e,t,i){const r=I(e,i);return null!==r&&(0,s.areEqualRgba)((0,s.parseRgba)(r),(0,s.parseRgba)(String(t)))}function L(e,t){return a.saveTheme(e,t)}function A(e){return a.removeTheme(e)}function k(e){return a.isThemeExist(e)}function D(e){return l.translateThemeName(e)}function V(e){return l.isStdTheme(e)}function E(e){return{content:{chartProperties:{paneProperties:e.model().properties().childs().paneProperties.state(),scalesProperties:e.model().properties().childs().scalesProperties.state()},sessions:e.model().sessions().properties().state(),mainSourceProperties:e.model().mainSeries().properties().state(),version:e.model().version()}}}},45345:(e,t,i)=>{"use strict";i.d(t,{setTheme:()=>r,watchedTheme:()=>s});const s=new(i(97145).WatchedValue);function r(e){s.setValue(e)}s.subscribe((e=>{!function(e,t=window){const i="theme-"+e,s=t.document.documentElement.classList;for(const e of Array.from(s))e.startsWith("theme-")&&e!==i&&s.remove(e);s.add(i)}(e,window)}))},51768:(e,t,i)=>{"use strict";i.d(t,{disableTrackingEvents:()=>c,trackEvent:()=>l});var s=i(76422),r=i(14483);const n=(0,i(59224).getLogger)("Common.TrackEvent"),o=[/Study_(Drawing)_(.*)/,/(Study)_(.*)@tv-basicstudies/,/(Study)_(.*)/,/(Chart Style) (.*)/];let a=!1;const l=(e,t,i)=>{if(a)return;if(r.enabled("charting_library_base"))return void((e,t,i)=>{t=t||e||i||"";let r="";for(let e=0;e{"use strict";i.d(t,{TVXWindowEvents:()=>o});i(42053);var s=i(59224),r=i(11417);const n=(0,s.getLogger)("XWindowEvents");var o;!function(e){const t="tvxwevents.",i={};let s;window.BroadcastChannel?(s=new BroadcastChannel("tvxwevents"),s.addEventListener("message",(function(e){const{data:{event:t,value:s}}=e;i[t]&&i[t].forEach((e=>{e(s)}))})),function(){const e=[],i=performance.now();for(let i=0;i{t(e.newValue)}));r.TVLocalStorage.removeItem(n)})),e.on=function(e,t){i[e]||(i[e]=[]),i[e].push(t)},e.off=function(e,t){if(!i[e])return;const s=i[e].indexOf(t);-1!==s&&(1===i[e].length?delete i[e]:i[e].splice(s,1))},e.emit=function(e,i=Date.now()){try{s?s.postMessage({event:e,value:i}):r.TVLocalStorage.setItem(t+e,i.toString())}catch(e){n.logError(e.message)}}}(o||(o={}))},44352:(e,t,i)=>{"use strict";i.r(t),i.d(t,{t:()=>s});i(42053);function s(e,t={},n){if(null===e)return Array.isArray(n)?(n[r(t.count)]||n[0]).format(t.replace||t):"object"==typeof n?s(null,t,n[i.g.language]||n.en):s(n,t);if(n&&e){const i=`${e}${t.context?`_${t.context}`:""}`;if(n[i])return s(null,t,n[i])}if("number"==typeof e)return e.toString();if("string"!=typeof e)return"";if(i.g.customTranslateFunction){const s=i.g.customTranslateFunction(e,t);if(null!==s)return s}return(t.plural&&1!=+t.count?t.plural:e).format(t.replace||t)}const r={ca_ES:(e=1)=>+(1!=e),cs:(e=1)=>+(1==e?0:e>=2&&e<=4?1:2),el:(e=1)=>+(1!=e),da_DK:(e=1)=>+(1!=e),en:(e=1)=>+(1!=e),et_EE:(e=1)=>+(1!=e),fa:(e=1)=>0,hu_HU:(e=1)=>0,id_ID:(e=1)=>0,it:(e=1)=>+(1!=e),ms_MY:(e=1)=>0,no:(e=1)=>+(1!=e),nl_NL:(e=1)=>+(1!=e),ro:(e=1)=>+(1==e?0:e%100>19||e%100==0&&0!=e?2:1),sk_SK:(e=1)=>+(1==e?0:e>=2&&e<=4?1:2),sv:(e=1)=>+(1!=e),zh:(e=1)=>0,zh_TW:(e=1)=>0,de:(e=1)=>+(1!=e),es:(e=1)=>+(1!=e),fr:(e=1)=>+(e>1),he_IL:(e=1)=>+(1==e?0:2==e?1:e>10&&e%10==0?2:3),ko:(e=1)=>0,ja:(e=1)=>0,pl:(e=1)=>+(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2),pt:(e=1)=>+(1!=e),tr:(e=1)=>+(1!=e),vi:(e=1)=>0,ar:(e=1)=>+(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11&&e%100<=99?4:5),ru:(e=1)=>+(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2), -th:(e=1)=>0}[i.g.language]},82723:(e,t,i)=>{"use strict";i.r(t),i.d(t,{activateKeyPressHandler:()=>m,showDialog:()=>g});const s=[];let r=null;function n(e){for(let t=0;t=0&&!0!==s[t].func(e);t--);}window.addEventListener("keypress",o,!1);var a=i(31330),l=i(14483),c=i(54270),h=i(43960),d=i(13702),u=i(51768);let p=null;function _(e){if(!(0,a.globalKeypressMatches)(e))return!1;e.preventDefault();const t=String.fromCharCode(e.charCode);return l.enabled("show_interval_dialog_on_key_press")&&function(e){return/[1-9]/.test(e)}(t)?(0,c.showChangeIntervalDialogAsync)({initVal:t}):l.enabled("symbol_search_hot_key")&&(g({defaultValue:t,selectSearchOnInit:!1,source:"keyboard"}),(0,u.trackEvent)("GUI","SS","hotkey")),!0}function m(){(0,h.loadChangeIntervalDialog)(),function(e,t){const i={name:e,func:t},r=n(i.name);r>-1&&s.splice(r,1),s.unshift(i)}("symbolEdit",_)}function g(e){const t=p=(0,d.loadNewSymbolSearch)().then((i=>{t===p&&i.showDefaultSearchDialog(e)}));return t}},78136:(e,t,i)=>{"use strict";let s;function r(){return s}function n(e){s=e}i.d(t,{getSearchRequestDelay:()=>r,setSearchRequestDelay:()=>n})},52092:(e,t,i)=>{"use strict";i.d(t,{CLOSE_POPUPS_AND_DIALOGS_COMMAND:()=>s});const s="CLOSE_POPUPS_AND_DIALOGS_COMMAND"},42120:(e,t,i)=>{"use strict";i.d(t,{CompareDialogRenderer:()=>n});var s=i(85067);var r=i(76422);class n extends s.DialogRenderer{constructor(e){super(),this._dialog=null,this._subscribe=e=>{this._setVisibility(e)},this._chartWidgetCollection=e}show(e){this._load().then((t=>{var i,s;null===(i=this._dialog)||void 0===i||i.hide(),null===(s=this._dialog)||void 0===s||s.visible().unsubscribe(this._subscribe),this._dialog=t,t.visible().subscribe(this._subscribe),t.show(e),r.emit("compare_add")}))}hide(){var e;null===(e=this._dialog)||void 0===e||e.hide()}_load(){return Promise.all([i.e(7271).then(i.bind(i,56217)),Promise.all([i.e(2666),i.e(1013),i.e(4015),i.e(5145),i.e(855),i.e(6),i.e(5993),i.e(5649),i.e(8056),i.e(2587),i.e(3502),i.e(2639),i.e(2109),i.e(9842),i.e(7232),i.e(6949),i.e(5163),i.e(962),i.e(8385),i.e(3016),i.e(9727),i.e(731)]).then(i.bind(i,89035))]).then((([e,t])=>{const i=new e.CompareModel(this._chartWidgetCollection);return t.getCompareDialogRenderer(i)}))}}},3615:(e,t,i)=>{"use strict";async function s(e,t){const s=await Promise.all([i.e(2666),i.e(1013),i.e(6),i.e(2191),i.e(6221),i.e(6639),i.e(3610),i.e(3717),i.e(962),i.e(3016),i.e(4717),i.e(8890)]).then(i.bind(i,70493));return s.showSimpleDialog(e,s.renameModule,t)}async function r(e,t){const s=await Promise.all([i.e(2666),i.e(1013),i.e(6),i.e(2191),i.e(6221),i.e(6639),i.e(3610),i.e(3717),i.e(962),i.e(3016),i.e(4717),i.e(8890)]).then(i.bind(i,70493));return s.showSimpleDialog(e,s.confirmModule,t)}async function n(e,t){const s=await Promise.all([i.e(2666),i.e(1013),i.e(6),i.e(2191),i.e(6221),i.e(6639),i.e(3610),i.e(3717),i.e(962),i.e(3016),i.e(4717),i.e(8890)]).then(i.bind(i,70493));return s.showSimpleDialog(e,s.warningModule,t)}i.d(t,{showConfirm:()=>r, -showRename:()=>s,showWarning:()=>n})},14881:(e,t,i)=>{"use strict";i.d(t,{hideStateChange:()=>s});const s=new(i(57898).Delegate)},90995:(e,t,i)=>{"use strict";i.d(t,{getHideOptions:()=>h,getSavedHideMode:()=>u,toggleHideMode:()=>d});var s=i(50151),r=i(44352),n=i(56840),o=i(40493),a=i(88348),l=i(14881);let c=null;function h(){if(null!==c)return c;const e=(0,o.tradingService)();return c=new Map([["drawings",{label:r.t(null,void 0,i(13277)),dataName:"hide-drawing-tools",tooltip:{active:r.t(null,void 0,i(98116)),inactive:r.t(null,void 0,i(95551))},getBoxedValue:()=>(0,a.hideAllDrawings)(),trackLabel:"hide drawings"}],["indicators",{label:r.t(null,void 0,i(44177)),dataName:"hide-indicators",tooltip:{active:r.t(null,void 0,i(49982)),inactive:r.t(null,void 0,i(86306))},getBoxedValue:()=>(0,a.hideAllIndicators)(),trackLabel:"hide indicators"}],["positions",{label:r.t(null,void 0,i(90540)),dataName:"hide-positions-and-orders",tooltip:{active:r.t(null,void 0,i(62632)),inactive:r.t(null,void 0,i(70803))},getBoxedValue:()=>(0,s.ensureNotNull)(e).showTradedSources,inverted:!0,trackLabel:"hide positions"}],["all",{label:r.t(null,void 0,i(33911)),dataName:"hide-all",tooltip:{active:e?r.t(null,void 0,i(38293)):r.t(null,void 0,i(39046)),inactive:e?r.t(null,void 0,i(67927)):r.t(null,void 0,i(44312))},trackLabel:"hide all"}]]),e||c.delete("positions"),c}function d(e){e?n.setValue("ChartToolsHideMode",e):e=u();const t=p();let i=!t;return"all"===e?(_(((e,t,s)=>{e.setValue(s?!i:i)})),l.hideStateChange.fire({hideMode:e,isActive:i}),i):(_(((s,r,n)=>{if(r===e){const e=t?!n:!s.value();s.setValue(e),i=n?!e:e}else s.setValue(Boolean(n))})),l.hideStateChange.fire({hideMode:e,isActive:i}),i)}function u(){const e=n.getValue("ChartToolsHideMode","drawings");return h().has(e)?e:"drawings"}function p(){let e=!0;return _(((t,i,s)=>{const r=t.value();e=e&&(s?!r:r)})),e}function _(e){h().forEach(((t,i)=>{var s;const r=null===(s=t.getBoxedValue)||void 0===s?void 0:s.call(t);r&&e(r,i,t.inverted)}))}},13323:(e,t,i)=>{"use strict";i.d(t,{GeneralChartPropertiesRenderer:()=>r});var s=i(85067);class r extends s.DialogRenderer{constructor(e){super(),this._dialog=null,this._subscribe=e=>{this._setVisibility(e)},this._chartWidgetCollection=e}show(e){const t=this._chartWidgetCollection,s=t.activeChartWidget.value();return s.generalPropertiesDefinitions().then((r=>Promise.all([i.e(77),i.e(2666),i.e(1013),i.e(3842),i.e(4015),i.e(5145),i.e(855),i.e(6),i.e(5993),i.e(5649),i.e(2191),i.e(6221),i.e(8056),i.e(2587),i.e(3502),i.e(8149),i.e(2639),i.e(2109),i.e(9842),i.e(4215),i.e(7232),i.e(6625),i.e(9327),i.e(7194),i.e(6884),i.e(6036),i.e(2984),i.e(3980),i.e(5403),i.e(7350),i.e(7871),i.e(962),i.e(8385),i.e(9727),i.e(4403),i.e(4713),i.e(5901),i.e(769),i.e(9795),i.e(7078)]).then(i.bind(i,72811)).then((i=>{var n,o;const a=new i.GeneralChartPropertiesDialogRenderer({chartWidgetCollection:t,propertyPages:r,activePageId:this._activePageId,model:s.model()});return null===(n=this._dialog)||void 0===n||n.hide(), -null===(o=this._dialog)||void 0===o||o.visible().unsubscribe(this._subscribe),this._dialog=a,a.visible().subscribe(this._subscribe),a.show(e),this._activePageId=void 0,a}))))}hide(){var e;null===(e=this._dialog)||void 0===e||e.hide()}isVisible(){return this.visible().value()}focusOnText(){}setActivePage(e){this._activePageId=e}}},25812:(e,t,i)=>{"use strict";var s;i.d(t,{ToolboxType:()=>s}),function(e){e[e.Delete=0]="Delete"}(s||(s={}))},59064:(e,t,i)=>{"use strict";i.d(t,{globalCloseDelegate:()=>s,globalCloseMenu:()=>r});const s=new(i(57898).Delegate);function r(){s.fire()}},62995:e=>{e.exports={"css-value-header-toolbar-height":"38px"}},81501:e=>{e.exports={chartsSplitter:"chartsSplitter-L0xapso5",hovered:"hovered-L0xapso5","i-active":"i-active-L0xapso5"}},71332:e=>{e.exports={"css-value-pane-controls-padding-left":"1px","css-value-pane-controls-padding-right":"4px"}},30383:e=>{e.exports={paneSeparator:"paneSeparator-uqBaC1Ki",handle:"handle-uqBaC1Ki",hovered:"hovered-uqBaC1Ki",active:"active-uqBaC1Ki"}},58035:e=>{e.exports={priceScaleModeButtons:"priceScaleModeButtons-PEm49B2T",priceScaleModeButtons__button:"priceScaleModeButtons__button-PEm49B2T",priceScaleModeButtons__button_activated:"priceScaleModeButtons__button_activated-PEm49B2T"}},18792:(e,t,i)=>{"use strict";var s=i(1722).declareClassAsPureInterface;function r(){}TradingView.WEB_SOCKET_WAS_CONNECTED=!1,r.prototype.defaultResolutions=function(){},r.prototype.availableCurrencies=function(){},r.prototype.availableUnits=function(){},r.prototype.supportedSymbolsTypes=function(){},r.prototype.symbolsGrouping=function(){},r.prototype.quoteCreateSession=function(e){},r.prototype.quoteDeleteSession=function(e){},r.prototype.quoteSetFields=function(e,t){},r.prototype.quoteAddSymbols=function(e,t){},r.prototype.quoteRemoveSymbols=function(e,t){},r.prototype.quoteFastSymbols=function(e,t){},r.prototype.depthCreateSession=function(e,t,i){},r.prototype.depthDeleteSession=function(e){},r.prototype.depthSetSymbol=function(e,t){},r.prototype.depthClearSymbol=function(e){},r.prototype.depthSetScale=function(e,t){},r.prototype.chartCreateSession=function(e,t){},r.prototype.chartDeleteSession=function(e){},r.prototype.createSession=function(e,t){},r.prototype.removeSession=function(e){},r.prototype.connected=function(){},r.prototype.connect=function(){},r.prototype.disconnect=function(){},r.prototype.switchTimezone=function(e,t){},r.prototype.resolveSymbol=function(e,t,i,s){},r.prototype.createSeries=function(e,t,i,s,r,n,o,a){},r.prototype.removeSeries=function(e,t,i){},r.prototype.modifySeries=function(e,t,i,s,r,n,o){},r.prototype.requestMoreData=function(e,t,i,s){},r.prototype.requestMetadata=function(e,t,i){},r.prototype.canCreateStudy=function(e,t){},r.prototype.createStudy=function(e,t,i,s,r,n,o){},r.prototype.getStudyCounter=function(){},r.prototype.rebindStudy=function(e,t,i,s,r,n,o,a){},r.prototype.removeStudy=function(e,t,i){},r.prototype.modifyStudy=function(e,t,i,s,r){},r.prototype.createPointset=function(e,t,i,s,r,n,o){}, -r.prototype.modifyPointset=function(e,t,i,s,r){},r.prototype.removePointset=function(e,t,i){},r.prototype.requestMoreTickmarks=function(e,t,i,s){},r.prototype.requestFirstBarTime=function(e,t,i,s){},r.prototype._invokeHandler=function(e,t){},r.prototype._sendRequest=function(e,t){},r.prototype._onMessage=function(e){},r.prototype._dispatchNotification=function(e){},r.prototype._invokeNotificationHandler=function(e,t,i){},r.prototype._notifySessions=function(e){},r.prototype.unpack=function(e){},r.prototype.searchSymbols=function(e,t,i,s,r,n,o,a,l,c){},r.prototype.serverTimeOffset=function(){},r.prototype.getMarks=function(e,t,i,s,r){},r.prototype.getTimescaleMarks=function(e,t,i,s,r){},s(r,"ChartApiInterface"),e.exports.ChartApiInterface=r},58844:(e,t,i)=>{"use strict";i.r(t),i.d(t,{getChartContent:()=>w,getCharts:()=>S,getChartsCount:()=>v,getDrawingTemplates:()=>E,getStandardStudyTemplateContentById:()=>A,getStudyTemplateContent:()=>x,getStudyTemplateContentById:()=>L,getStudyTemplatesList:()=>I,initialize:()=>g,invalidateStudyTemplatesList:()=>M,isThemeExist:()=>z,loadChart:()=>P,loadDrawingTemplate:()=>B,loadTheme:()=>O,loadThemes:()=>F,removeChart:()=>y,removeDrawingTemplate:()=>R,removeStudyTemplate:()=>C,removeStudyTemplateById:()=>k,removeTheme:()=>H,renameStudyTemplate:()=>D,replaceStudyTemplate:()=>V,saveChart:()=>b,saveDrawingTemplate:()=>N,saveStudyTemplate:()=>T,saveTheme:()=>W,setCustomAdapter:()=>m,updateUser:()=>f});var s=i(76422),r=i(59224),n=i(93544);const o=(0,r.getLogger)("Chart.SaveloadAdapter.Library"),a={error:""};let l,c,h,d,u=null,p=null;function _(e){return`${h}/${encodeURIComponent(d)}/${e}?client=${encodeURIComponent(l)}&user=${encodeURIComponent(c)}`}function m(e){u=e}function g(e,t,i,s){l=e,c=t,h=i,d=s}function f(e){c=e}function v(e,t){throw new Error("Not implemented")}async function S(){const e=e=>e.map((e=>({id:e.id,name:e.name,image_url:String(e.id),modified_iso:e.timestamp,short_symbol:e.symbol,interval:e.resolution})));if(u)return u.getAllCharts().then(e);try{const t=await fetch(`${_("charts")}`,{credentials:"same-origin"});if(!t.ok)throw new Error(`Getting chart content response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Get chart content request failed: "+i.message);return e(i.data)}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function y(e){if(u)return u.removeChart(e);try{const t=await fetch(`${_("charts")}&chart=${encodeURIComponent(e)}`,{method:"DELETE",credentials:"same-origin"});if(!t.ok)throw new Error(`Remove chart response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Remove drawing template request failed: "+i.message)}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function b(e,t,i,s,r){var a;const l=r.id.value(),c={name:e,content:JSON.stringify(s),symbol:t,resolution:i};if(u)return u.saveChart({...c,id:l});try{const e=new FormData;for(const t in c)e.append(t,c[t]);let t=_("charts");null!=l&&(t+=`&chart=${encodeURIComponent(l)}`) -;const i=await fetch(t,{credentials:"same-origin",method:"POST",body:e});if(!i.ok)throw new Error(`Saving chart content response was not OK. Status: ${i.status}.`);const s=await i.json();if("ok"!==s.status)throw new Error("Saving chart content request failed: "+s.message);return(null!==(a=s.id)&&void 0!==a?a:l).toString()}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function w(e){const t=t=>{const i=JSON.parse(t);return i.uid=e.id,i};if(u)return u.getChartContent(e.id).then((e=>t(e)));try{const i=await fetch(`${_("charts")}&chart=${encodeURIComponent(e.id)}`,{credentials:"same-origin"});if(!i.ok)throw new Error(`Getting chart content response was not OK. Status: ${i.status}.`);const s=await i.json();if("ok"!==s.status)throw new Error("Get chart content request failed: "+s.message);return t(s.data.content)}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}function P(e){w(e).then((e=>{s.emit("chart_load_requested",e)}),(()=>{o.logWarn("Error loading chart")}))}async function C(e){try{if(u)return u.removeStudyTemplate({name:e});const t=await fetch(`${_("study_templates")}&template=${encodeURIComponent(e)}`,{method:"DELETE",credentials:"same-origin"});if(!t.ok)throw new Error(`Remove study template response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Remove study template request failed: "+i.message)}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function x(e){try{if(u){return{content:await u.getStudyTemplateContent({name:e})}}const t=await fetch(`${_("study_templates")}&template=${encodeURIComponent(e)}`,{credentials:"same-origin"});if(!t.ok)throw new Error(`Get study template response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Get study template request failed: "+i.message);return i.data}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function T(e){try{if(u)return u.saveStudyTemplate(e).then((()=>({error:""}))).catch((e=>({error:null!=e?(0,n.errorToString)(e):"error"})));const t=new FormData;t.append("name",e.name),t.append("content",e.content);const i=await fetch(_("study_templates"),{method:"POST",body:t,credentials:"same-origin"});if(!i.ok)throw new Error(`Save study template response was not OK. Status: ${i.status}.`);const s=await i.json();return{error:"ok"===s.status?"":s.status}}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function I(){try{if(p)return p;p=[];const e=e=>(p=e.map((e=>({is_default:!1,name:e.name}))),p);if(u)return u.getAllStudyTemplates().then(e);const t=await fetch(_("study_templates"),{method:"GET",credentials:"same-origin"});if(!t.ok)throw new Error(`Study templates list response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Study templates list request failed: "+i.message);return e(i.data)}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}function M(){p=null}function L(e,t){throw new Error("Not implemented")}function A(e,t){throw new Error("Not implemented")}function k(e,t){ -throw new Error("Not implemented")}function D(e,t,i){throw new Error("Not implemented")}function V(e,t,i){throw new Error("Not implemented")}async function E(e){throw new Error("Not implemented")}async function B(e,t){throw new Error("Not implemented")}async function R(e,t){throw new Error("Not implemented")}async function N(e,t,i){throw new Error("Not implemented")}function O(e){if(null!==u)return u.getChartTemplateContent(e);throw new Error("Not implemented")}function F(){return null!==u?u.getAllChartTemplates():Promise.resolve([])}async function W(e,t){if(null!==u)try{return await u.saveChartTemplate(e,t),a}catch(e){return console.error(e),{error:e instanceof Error?e.message:e.toString()}}throw new Error("Not implemented")}async function H(e){if(null!==u)try{return await u.removeChartTemplate(e),a}catch(e){return console.error(e),{error:e instanceof Error?e.message:e.toString()}}throw new Error("Not implemented")}function z(e){return O(e).then((e=>Boolean(e.content)))}},2269:(e,t,i)=>{"use strict";var s=i(50151).ensureNotNull,r=i(60156),n=i(36274).Interval,o=i(94141),a=i(60325),l=i(18792).ChartApiInterface,c=i(47327).HandlerInfo,h=i(1722).requireFullInterfaceImplementation,d=i(59224).getLogger("Chart.ChartApiLocal"),u=i(17133).TIMEFRAMETYPE,p=i(77475).createDwmAligner;TradingView.STUDY_COUNT_LIMIT=210;JSServer.ChartApi=function(e){this._notificationHandlers={},this._sessions={},this.studyCounter=0,this._connected=!1,this._enabled=!1,this._studyEngine=new o(e),this._callbacks={},this._serverTimeOffset=0;var t=this;this._studyEngine.on("configuration_received",(function(){t._fireEvent("configuration_received")})),this._studyEngine.on("realtime_tick",(function(e){var i={time:e.value[0]/1e3,open:e.value[1],high:e.value[2],low:e.value[3],close:e.value[4],volume:e.value[5]};t._fireEvent("realtime_tick",i,!0)})),this._setVisibleRangeTimeout={}},JSServer.ChartApi.prototype.destroy=function(){this._studyEngine.destroy(),this._studyEngine=null},JSServer.ChartApi.prototype.purgeCache=function(e){this._studyEngine.purgeCache(),this._studyEngine.purgeDataCache()},JSServer.ChartApi.prototype.defaultResolutions=function(){return this._studyEngine.supportedResolutions()||["1","3","5","15","30","45","60","120","180","240","1D","1W","1M"]},JSServer.ChartApi.prototype.availableCurrencies=function(){var e=this._studyEngine.supportedCurrencies().map((function(e){return"string"==typeof e?{id:e,code:e}:e}));return Promise.resolve(e)},JSServer.ChartApi.prototype.availableUnits=function(){return Promise.resolve(this._studyEngine.supportedUnits())},JSServer.ChartApi.prototype.availablePriceSources=function(e){return this._studyEngine.supportedPriceSources(e)},JSServer.ChartApi.prototype.supportedSymbolsTypes=function(){return this._studyEngine.supportedSymbolsTypes()},JSServer.ChartApi.prototype.symbolsGrouping=function(){return this._studyEngine.symbolsGrouping()},JSServer.ChartApi.prototype.start=function(){this._enabled=!0,this._fireEvent("start_enabled")},JSServer.ChartApi.prototype.unsubscribe=function(e,t){var i=this._callbacks[e] -;i&&i.splice(i.indexOf(t),1)},JSServer.ChartApi.prototype.on=function(e,t){return this._callbacks.hasOwnProperty(e)||(this._callbacks[e]=[]),this._callbacks[e].push(t),this},JSServer.ChartApi.prototype._fireEvent=function(e,t,i){if(this._callbacks.hasOwnProperty(e)){var s=this._callbacks[e].slice(0);i||(this._callbacks[e]=[]);for(var r=0;rn||(TradingView.ChartapiMessagerInstances[e].onSeriesTimeframeUpdate(t,i,_,n,a),l&&setTimeout(l,0))}}}if(this._studyEngine.isTimeScaleExtendedTo(e,1e3*r))_();else{var m=TradingView.ChartapiMessagerInstances[e].seriesCompleted,g=TradingView.ChartapiMessagerInstances[e].seriesError;void 0!==this._setVisibleRangeTimeout[e]&&clearTimeout(this._setVisibleRangeTimeout[e]),this._setVisibleRangeTimeout[e]=setTimeout(function(){delete this._setVisibleRangeTimeout[e],m.subscribe(null,f,!0),g.subscribe(null,v,!0),this._studyEngine.ensureExtendedTo(t,e,1e3*r)}.bind(this),0)}function f(e,s){e===t&&s===i&&(m.unsubscribe(null,f),g.unsubscribe(null,v),_())}function v(e,s){e===t&&s===i&&m.unsubscribe(null,f)}},JSServer.ChartApi.prototype._applyTimeFrame=function(e,t,i,s,o){var a,l,c={},h=!0;if(o.type===u.PeriodBack){var d=this._studyEngine.getSeriesLastBarTime(e,i);if(null===d)return;l=d/1e3;var _=n.parse(o.value),m=this._studyEngine.getSeriesSymbolInfo(e,i);a=r.alignPeriodsBackForVisibleRange(m.session,m.session_holidays,m.corrections,_.letter(),_.multiplier(),1,d)/1e3;var g=p(this._studyEngine.getSeriesInterval(e,i),m);null!==g&&(l=g.timeToExchangeTradingDay(1e3*l)/1e3,a=g.timeToExchangeTradingDay(1e3*a)/1e3),c={applyDefaultRightMargin:!0},h=!1}else a=o.from,l=o.to;this.setVisibleTimeRange(e,i,s,a,l,h,c)},JSServer.ChartApi.prototype.modifySeries=function(e,t,i,s,r,n,o,a){var l=this;this._notificationHandlers[e][t]=new c((function(r){"series_completed"===r.method&&null!==o&&(l._applyTimeFrame(e,s,t,i,o),o=null),a(r)}),t),this._studyEngine.modifySeries(e,t,s,r,i,n)},JSServer.ChartApi.prototype.requestMoreData=function(e,t){this._studyEngine.extendSeriesRange(e,t)},JSServer.ChartApi.prototype.setStudiesAccessController=function(e){this.studiesAccessController=e},JSServer.ChartApi.prototype.allStudiesMetadata=function(){return this._studyEngine.studiesMetadata()},JSServer.ChartApi.prototype.requestMetadata=function(e,t,i){this._notificationHandlers[e][t]=new c(i,t);var s=this.studiesAccessController.getEnabledTools();TradingView.ChartapiMessagerInstances[e].onRequestMetadata(t,s)},JSServer.ChartApi.prototype.canCreateStudy=function(){return this.studyCounterd.t(null,{context:"colorThemeName"},i(69841)),order:2,getThemedColor:e=>(0,p.getHexColorByName)(e)},[l.StdTheme.Dark]:{name:l.StdTheme.Dark,label:()=>d.t(null,{context:"colorThemeName"},i(14642)),order:1,getThemedColor:e=>{const t=u[e]||e;return(0,p.getHexColorByName)(t)}}};function m(e){return!e.isPrivate}function g(){return _[c.watchedTheme.value()]||_[h]}function f(e){return g().getThemedColor(e)}async function v(e,t){const{themeName:i,standardTheme:s,syncState:n=!0,noUndo:o=!1,applyOverrides:a=!1,onlyActiveChart:l=!1}=t,c=await(s?Promise.resolve(T(i)):w(i)),h=!s;if(void 0!==c.content){const t=!s||l;a&&(void 0!==(d=c.content).chartProperties&&(0,r.applyDefaultsOverrides)(d.chartProperties),void 0!==d.mainSourceProperties&&(0,r.applyDefaultsOverrides)(d.mainSourceProperties,void 0,!0,"mainSeriesProperties")),await e.applyTheme({theme:c.content,onlyActiveChart:t,restoreNonThemeDefaults:h,themeName:i,standardTheme:s,syncState:n,noUndo:o})}var d;return c}function S(){(0,c.setTheme)(o()||h)}function y(){return o()}function b(){var e;e=g().name,(0,n.setValue)("current_theme.name",e,{forceFlush:!0})}function w(e){return a.loadTheme(e)}function P(){return a.loadThemes()}function C(){return l.getStdThemeNames()}function x(e){return C().includes(e)}function T(e){return l.getStdChartTheme(e)||{content:void 0}}function I(e,t){const i=t||g().name,s=l.getStdChartTheme(i),r=0!==e.length&&e.split(".");return s&&s.content&&r?r.reduce(((e,t)=>e[t]),s.content):null}function M(e,t,i){const r=I(e,i);return null!==r&&(0,s.areEqualRgba)((0,s.parseRgba)(r),(0,s.parseRgba)(String(t)))}function L(e,t){return a.saveTheme(e,t)}function A(e){return a.removeTheme(e)}function k(e){return a.isThemeExist(e)}function D(e){return l.translateThemeName(e)}function E(e){return l.isStdTheme(e)}function V(e){return{content:{chartProperties:{paneProperties:e.model().properties().childs().paneProperties.state(),scalesProperties:e.model().properties().childs().scalesProperties.state()},sessions:e.model().sessions().properties().state(),mainSourceProperties:e.model().mainSeries().properties().state(),version:e.model().version()}}}},45345:(e,t,i)=>{"use strict";i.d(t,{setTheme:()=>r,watchedTheme:()=>s});const s=new(i(97145).WatchedValue);function r(e){s.setValue(e)}s.subscribe((e=>{!function(e,t=window){const i="theme-"+e,s=t.document.documentElement.classList;for(const e of Array.from(s))e.startsWith("theme-")&&e!==i&&s.remove(e);s.add(i)}(e,window)}))},51768:(e,t,i)=>{"use strict";i.d(t,{disableTrackingEvents:()=>c,trackEvent:()=>l});var s=i(76422),r=i(14483);const n=(0,i(59224).getLogger)("Common.TrackEvent"),o=[/Study_(Drawing)_(.*)/,/(Study)_(.*)@tv-basicstudies/,/(Study)_(.*)/,/(Chart Style) (.*)/];let a=!1;const l=(e,t,i)=>{if(a)return;if(r.enabled("charting_library_base"))return void((e,t,i)=>{t=t||e||i||"";let r="";for(let e=0;e{"use strict";i.d(t,{TVXWindowEvents:()=>o});i(42053);var s=i(59224),r=i(11417);const n=(0,s.getLogger)("XWindowEvents");var o;!function(e){const t="tvxwevents.",i={};let s;window.BroadcastChannel?(s=new BroadcastChannel("tvxwevents"),s.addEventListener("message",(function(e){const{data:{event:t,value:s}}=e;i[t]&&i[t].forEach((e=>{e(s)}))})),function(){const e=[],i=performance.now();for(let i=0;i{t(e.newValue)}));r.TVLocalStorage.removeItem(n)})),e.on=function(e,t){i[e]||(i[e]=[]),i[e].push(t)},e.off=function(e,t){if(!i[e])return;const s=i[e].indexOf(t);-1!==s&&(1===i[e].length?delete i[e]:i[e].splice(s,1))},e.emit=function(e,i=Date.now()){try{s?s.postMessage({event:e,value:i}):r.TVLocalStorage.setItem(t+e,i.toString())}catch(e){n.logError(e.message)}}}(o||(o={}))},44352:(e,t,i)=>{"use strict";i.r(t),i.d(t,{t:()=>s});i(42053);function s(e,t={},n){if(null===e){if(Array.isArray(n)){if(i.g.customTranslateFunction){const e={...t};n.length>1?e.plural=n.slice(1):e.plural&&delete e.plural;const s=i.g.customTranslateFunction(n[0],e,!0);if(null!==s)return s}return(n[r(t.count)]||n[0]).format(t.replace||t)}return"object"==typeof n?s(null,t,n[i.g.language]||n.en):s(n,t)}if(n&&e){const i=`${e}${t.context?`_${t.context}`:""}`;if(n[i])return s(null,t,n[i])}if("number"==typeof e)return e.toString();if("string"!=typeof e)return"";if(i.g.customTranslateFunction){const s=i.g.customTranslateFunction(e,t);if(null!==s)return s}return(t.plural&&1!=+t.count?t.plural:e).format(t.replace||t)}const r={ca_ES:(e=1)=>+(1!=e),cs:(e=1)=>+(1==e?0:e>=2&&e<=4?1:2),el:(e=1)=>+(1!=e),da_DK:(e=1)=>+(1!=e),en:(e=1)=>+(1!=e),et_EE:(e=1)=>+(1!=e),fa:(e=1)=>0,hu_HU:(e=1)=>0,id_ID:(e=1)=>0,it:(e=1)=>+(1!=e),ms_MY:(e=1)=>0,no:(e=1)=>+(1!=e),nl_NL:(e=1)=>+(1!=e),ro:(e=1)=>+(1==e?0:e%100>19||e%100==0&&0!=e?2:1),sk_SK:(e=1)=>+(1==e?0:e>=2&&e<=4?1:2),sv:(e=1)=>+(1!=e),zh:(e=1)=>0,zh_TW:(e=1)=>0,de:(e=1)=>+(1!=e),es:(e=1)=>+(1!=e),fr:(e=1)=>+(e>1),he_IL:(e=1)=>+(1==e?0:2==e?1:e>10&&e%10==0?2:3),ko:(e=1)=>0,ja:(e=1)=>0,pl:(e=1)=>+(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2),pt:(e=1)=>+(1!=e), +tr:(e=1)=>+(1!=e),vi:(e=1)=>0,ar:(e=1)=>+(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11&&e%100<=99?4:5),ru:(e=1)=>+(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2),th:(e=1)=>0}[i.g.language]},82723:(e,t,i)=>{"use strict";i.r(t),i.d(t,{activateKeyPressHandler:()=>m,showDialog:()=>g});const s=[];let r=null;function n(e){for(let t=0;t=0&&!0!==s[t].func(e);t--);}window.addEventListener("keypress",o,!1);var a=i(31330),l=i(14483),c=i(54270),h=i(43960),d=i(13702),u=i(51768);let p=null;function _(e){if(!(0,a.globalKeypressMatches)(e))return!1;e.preventDefault();const t=String.fromCharCode(e.charCode);return l.enabled("show_interval_dialog_on_key_press")&&function(e){return/[1-9]/.test(e)}(t)?(0,c.showChangeIntervalDialogAsync)({initVal:t}):l.enabled("symbol_search_hot_key")&&(g({defaultValue:t,selectSearchOnInit:!1,source:"keyboard"}),(0,u.trackEvent)("GUI","SS","hotkey")),!0}function m(){(0,h.loadChangeIntervalDialog)(),function(e,t){const i={name:e,func:t},r=n(i.name);r>-1&&s.splice(r,1),s.unshift(i)}("symbolEdit",_)}function g(e){const t=p=(0,d.loadNewSymbolSearch)().then((i=>{t===p&&i.showDefaultSearchDialog(e)}));return t}},78136:(e,t,i)=>{"use strict";let s;function r(){return s}function n(e){s=e}i.d(t,{getSearchRequestDelay:()=>r,setSearchRequestDelay:()=>n})},52092:(e,t,i)=>{"use strict";i.d(t,{CLOSE_POPUPS_AND_DIALOGS_COMMAND:()=>s});const s="CLOSE_POPUPS_AND_DIALOGS_COMMAND"},42120:(e,t,i)=>{"use strict";i.d(t,{CompareDialogRenderer:()=>n});var s=i(85067);var r=i(76422);class n extends s.DialogRenderer{constructor(e){super(),this._dialog=null,this._subscribe=e=>{this._setVisibility(e)},this._chartWidgetCollection=e}show(e){this._load().then((t=>{var i,s;null===(i=this._dialog)||void 0===i||i.hide(),null===(s=this._dialog)||void 0===s||s.visible().unsubscribe(this._subscribe),this._dialog=t,t.visible().subscribe(this._subscribe),t.show(e),r.emit("compare_add")}))}hide(){var e;null===(e=this._dialog)||void 0===e||e.hide()}_load(){return Promise.all([i.e(7271).then(i.bind(i,56217)),Promise.all([i.e(2666),i.e(1013),i.e(4015),i.e(5145),i.e(855),i.e(6),i.e(5993),i.e(5649),i.e(8056),i.e(2587),i.e(3502),i.e(2639),i.e(2109),i.e(9842),i.e(7232),i.e(6949),i.e(5163),i.e(962),i.e(8385),i.e(3016),i.e(9727),i.e(731)]).then(i.bind(i,89035))]).then((([e,t])=>{const i=new e.CompareModel(this._chartWidgetCollection);return t.getCompareDialogRenderer(i)}))}}},3615:(e,t,i)=>{"use strict";async function s(e,t){const s=await Promise.all([i.e(2666),i.e(1013),i.e(6),i.e(2191),i.e(6221),i.e(6639),i.e(3610),i.e(3717),i.e(962),i.e(3016),i.e(4717),i.e(8890)]).then(i.bind(i,70493));return s.showSimpleDialog(e,s.renameModule,t)}async function r(e,t){const s=await Promise.all([i.e(2666),i.e(1013),i.e(6),i.e(2191),i.e(6221),i.e(6639),i.e(3610),i.e(3717),i.e(962),i.e(3016),i.e(4717),i.e(8890)]).then(i.bind(i,70493));return s.showSimpleDialog(e,s.confirmModule,t)}async function n(e,t){ +const s=await Promise.all([i.e(2666),i.e(1013),i.e(6),i.e(2191),i.e(6221),i.e(6639),i.e(3610),i.e(3717),i.e(962),i.e(3016),i.e(4717),i.e(8890)]).then(i.bind(i,70493));return s.showSimpleDialog(e,s.warningModule,t)}i.d(t,{showConfirm:()=>r,showRename:()=>s,showWarning:()=>n})},14881:(e,t,i)=>{"use strict";i.d(t,{hideStateChange:()=>s});const s=new(i(57898).Delegate)},90995:(e,t,i)=>{"use strict";i.d(t,{getHideOptions:()=>h,getSavedHideMode:()=>u,toggleHideMode:()=>d});var s=i(50151),r=i(44352),n=i(56840),o=i(40493),a=i(88348),l=i(14881);let c=null;function h(){if(null!==c)return c;const e=(0,o.tradingService)();return c=new Map([["drawings",{label:r.t(null,void 0,i(13277)),dataName:"hide-drawing-tools",tooltip:{active:r.t(null,void 0,i(98116)),inactive:r.t(null,void 0,i(95551))},getBoxedValue:()=>(0,a.hideAllDrawings)(),trackLabel:"hide drawings"}],["indicators",{label:r.t(null,void 0,i(44177)),dataName:"hide-indicators",tooltip:{active:r.t(null,void 0,i(49982)),inactive:r.t(null,void 0,i(86306))},getBoxedValue:()=>(0,a.hideAllIndicators)(),trackLabel:"hide indicators"}],["positions",{label:r.t(null,void 0,i(90540)),dataName:"hide-positions-and-orders",tooltip:{active:r.t(null,void 0,i(62632)),inactive:r.t(null,void 0,i(70803))},getBoxedValue:()=>(0,s.ensureNotNull)(e).showTradedSources,inverted:!0,trackLabel:"hide positions"}],["all",{label:r.t(null,void 0,i(33911)),dataName:"hide-all",tooltip:{active:e?r.t(null,void 0,i(38293)):r.t(null,void 0,i(39046)),inactive:e?r.t(null,void 0,i(67927)):r.t(null,void 0,i(44312))},trackLabel:"hide all"}]]),e||c.delete("positions"),c}function d(e){e?n.setValue("ChartToolsHideMode",e):e=u();const t=p();let i=!t;return"all"===e?(_(((e,t,s)=>{e.setValue(s?!i:i)})),l.hideStateChange.fire({hideMode:e,isActive:i}),i):(_(((s,r,n)=>{if(r===e){const e=t?!n:!s.value();s.setValue(e),i=n?!e:e}else s.setValue(Boolean(n))})),l.hideStateChange.fire({hideMode:e,isActive:i}),i)}function u(){const e=n.getValue("ChartToolsHideMode","drawings");return h().has(e)?e:"drawings"}function p(){let e=!0;return _(((t,i,s)=>{const r=t.value();e=e&&(s?!r:r)})),e}function _(e){h().forEach(((t,i)=>{var s;const r=null===(s=t.getBoxedValue)||void 0===s?void 0:s.call(t);r&&e(r,i,t.inverted)}))}},13323:(e,t,i)=>{"use strict";i.d(t,{GeneralChartPropertiesRenderer:()=>r});var s=i(85067);class r extends s.DialogRenderer{constructor(e){super(),this._dialog=null,this._subscribe=e=>{this._setVisibility(e)},this._chartWidgetCollection=e}show(e){const t=this._chartWidgetCollection,s=t.activeChartWidget.value();return s.generalPropertiesDefinitions().then((r=>Promise.all([i.e(77),i.e(2666),i.e(1013),i.e(3842),i.e(4015),i.e(5145),i.e(855),i.e(6),i.e(5993),i.e(5649),i.e(2191),i.e(6221),i.e(8056),i.e(2587),i.e(3502),i.e(8149),i.e(2639),i.e(2109),i.e(9842),i.e(4215),i.e(7232),i.e(6625),i.e(9327),i.e(7194),i.e(6884),i.e(6036),i.e(2984),i.e(3980),i.e(5403),i.e(7350),i.e(7871),i.e(962),i.e(8385),i.e(9727),i.e(4403),i.e(4713),i.e(5901),i.e(769),i.e(9795),i.e(7078)]).then(i.bind(i,72811)).then((i=>{var n,o +;const a=new i.GeneralChartPropertiesDialogRenderer({chartWidgetCollection:t,propertyPages:r,activePageId:this._activePageId,model:s.model()});return null===(n=this._dialog)||void 0===n||n.hide(),null===(o=this._dialog)||void 0===o||o.visible().unsubscribe(this._subscribe),this._dialog=a,a.visible().subscribe(this._subscribe),a.show(e),this._activePageId=void 0,a}))))}hide(){var e;null===(e=this._dialog)||void 0===e||e.hide()}isVisible(){return this.visible().value()}focusOnText(){}setActivePage(e){this._activePageId=e}}},25812:(e,t,i)=>{"use strict";var s;i.d(t,{ToolboxType:()=>s}),function(e){e[e.Delete=0]="Delete"}(s||(s={}))},59064:(e,t,i)=>{"use strict";i.d(t,{globalCloseDelegate:()=>s,globalCloseMenu:()=>r});const s=new(i(57898).Delegate);function r(){s.fire()}},62995:e=>{e.exports={"css-value-header-toolbar-height":"38px"}},81501:e=>{e.exports={chartsSplitter:"chartsSplitter-L0xapso5",hovered:"hovered-L0xapso5","i-active":"i-active-L0xapso5"}},71332:e=>{e.exports={"css-value-pane-controls-padding-left":"1px","css-value-pane-controls-padding-right":"4px"}},30383:e=>{e.exports={paneSeparator:"paneSeparator-uqBaC1Ki",handle:"handle-uqBaC1Ki",hovered:"hovered-uqBaC1Ki",active:"active-uqBaC1Ki"}},58035:e=>{e.exports={priceScaleModeButtons:"priceScaleModeButtons-PEm49B2T",priceScaleModeButtons__button:"priceScaleModeButtons__button-PEm49B2T",priceScaleModeButtons__button_activated:"priceScaleModeButtons__button_activated-PEm49B2T"}},18792:(e,t,i)=>{"use strict";var s=i(1722).declareClassAsPureInterface;function r(){}TradingView.WEB_SOCKET_WAS_CONNECTED=!1,r.prototype.defaultResolutions=function(){},r.prototype.availableCurrencies=function(){},r.prototype.availableUnits=function(){},r.prototype.supportedSymbolsTypes=function(){},r.prototype.symbolsGrouping=function(){},r.prototype.quoteCreateSession=function(e){},r.prototype.quoteDeleteSession=function(e){},r.prototype.quoteSetFields=function(e,t){},r.prototype.quoteAddSymbols=function(e,t){},r.prototype.quoteRemoveSymbols=function(e,t){},r.prototype.quoteFastSymbols=function(e,t){},r.prototype.depthCreateSession=function(e,t,i){},r.prototype.depthDeleteSession=function(e){},r.prototype.depthSetSymbol=function(e,t){},r.prototype.depthClearSymbol=function(e){},r.prototype.depthSetScale=function(e,t){},r.prototype.chartCreateSession=function(e,t){},r.prototype.chartDeleteSession=function(e){},r.prototype.createSession=function(e,t){},r.prototype.removeSession=function(e){},r.prototype.connected=function(){},r.prototype.connect=function(){},r.prototype.disconnect=function(){},r.prototype.switchTimezone=function(e,t){},r.prototype.resolveSymbol=function(e,t,i,s){},r.prototype.createSeries=function(e,t,i,s,r,n,o,a){},r.prototype.removeSeries=function(e,t,i){},r.prototype.modifySeries=function(e,t,i,s,r,n,o){},r.prototype.requestMoreData=function(e,t,i,s){},r.prototype.requestMetadata=function(e,t,i){},r.prototype.canCreateStudy=function(e,t){},r.prototype.createStudy=function(e,t,i,s,r,n,o){},r.prototype.getStudyCounter=function(){}, +r.prototype.rebindStudy=function(e,t,i,s,r,n,o,a){},r.prototype.removeStudy=function(e,t,i){},r.prototype.modifyStudy=function(e,t,i,s,r){},r.prototype.createPointset=function(e,t,i,s,r,n,o){},r.prototype.modifyPointset=function(e,t,i,s,r){},r.prototype.removePointset=function(e,t,i){},r.prototype.requestMoreTickmarks=function(e,t,i,s){},r.prototype.requestFirstBarTime=function(e,t,i,s){},r.prototype._invokeHandler=function(e,t){},r.prototype._sendRequest=function(e,t){},r.prototype._onMessage=function(e){},r.prototype._dispatchNotification=function(e){},r.prototype._invokeNotificationHandler=function(e,t,i){},r.prototype._notifySessions=function(e){},r.prototype.unpack=function(e){},r.prototype.searchSymbols=function(e,t,i,s,r,n,o,a,l,c){},r.prototype.serverTimeOffset=function(){},r.prototype.getMarks=function(e,t,i,s,r){},r.prototype.getTimescaleMarks=function(e,t,i,s,r){},s(r,"ChartApiInterface"),e.exports.ChartApiInterface=r},58844:(e,t,i)=>{"use strict";i.r(t),i.d(t,{getChartContent:()=>w,getCharts:()=>S,getChartsCount:()=>v,getDrawingTemplates:()=>V,getStandardStudyTemplateContentById:()=>A,getStudyTemplateContent:()=>x,getStudyTemplateContentById:()=>L,getStudyTemplatesList:()=>I,initialize:()=>g,invalidateStudyTemplatesList:()=>M,isThemeExist:()=>z,loadChart:()=>P,loadDrawingTemplate:()=>B,loadTheme:()=>O,loadThemes:()=>F,removeChart:()=>y,removeDrawingTemplate:()=>R,removeStudyTemplate:()=>C,removeStudyTemplateById:()=>k,removeTheme:()=>H,renameStudyTemplate:()=>D,replaceStudyTemplate:()=>E,saveChart:()=>b,saveDrawingTemplate:()=>N,saveStudyTemplate:()=>T,saveTheme:()=>W,setCustomAdapter:()=>m,updateUser:()=>f});var s=i(76422),r=i(59224),n=i(93544);const o=(0,r.getLogger)("Chart.SaveloadAdapter.Library"),a={error:""};let l,c,h,d,u=null,p=null;function _(e){return`${h}/${encodeURIComponent(d)}/${e}?client=${encodeURIComponent(l)}&user=${encodeURIComponent(c)}`}function m(e){u=e}function g(e,t,i,s){l=e,c=t,h=i,d=s}function f(e){c=e}function v(e,t){throw new Error("Not implemented")}async function S(){const e=e=>e.map((e=>({id:e.id,name:e.name,image_url:String(e.id),modified_iso:e.timestamp,short_symbol:e.symbol,interval:e.resolution})));if(u)return u.getAllCharts().then(e);try{const t=await fetch(`${_("charts")}`,{credentials:"same-origin"});if(!t.ok)throw new Error(`Getting chart content response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Get chart content request failed: "+i.message);return e(i.data)}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function y(e){if(u)return u.removeChart(e);try{const t=await fetch(`${_("charts")}&chart=${encodeURIComponent(e)}`,{method:"DELETE",credentials:"same-origin"});if(!t.ok)throw new Error(`Remove chart response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Remove drawing template request failed: "+i.message)}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function b(e,t,i,s,r){var a;const l=r.id.value(),c={name:e,content:JSON.stringify(s),symbol:t, +resolution:i};if(u)return u.saveChart({...c,id:l});try{const e=new FormData;for(const t in c)e.append(t,c[t]);let t=_("charts");null!=l&&(t+=`&chart=${encodeURIComponent(l)}`);const i=await fetch(t,{credentials:"same-origin",method:"POST",body:e});if(!i.ok)throw new Error(`Saving chart content response was not OK. Status: ${i.status}.`);const s=await i.json();if("ok"!==s.status)throw new Error("Saving chart content request failed: "+s.message);return(null!==(a=s.id)&&void 0!==a?a:l).toString()}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function w(e){const t=t=>{const i=JSON.parse(t);return i.uid=e.id,i};if(u)return u.getChartContent(e.id).then((e=>t(e)));try{const i=await fetch(`${_("charts")}&chart=${encodeURIComponent(e.id)}`,{credentials:"same-origin"});if(!i.ok)throw new Error(`Getting chart content response was not OK. Status: ${i.status}.`);const s=await i.json();if("ok"!==s.status)throw new Error("Get chart content request failed: "+s.message);return t(s.data.content)}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}function P(e){w(e).then((e=>{s.emit("chart_load_requested",e)}),(()=>{o.logWarn("Error loading chart")}))}async function C(e){try{if(u)return u.removeStudyTemplate({name:e});const t=await fetch(`${_("study_templates")}&template=${encodeURIComponent(e)}`,{method:"DELETE",credentials:"same-origin"});if(!t.ok)throw new Error(`Remove study template response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Remove study template request failed: "+i.message)}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function x(e){try{if(u){return{content:await u.getStudyTemplateContent({name:e})}}const t=await fetch(`${_("study_templates")}&template=${encodeURIComponent(e)}`,{credentials:"same-origin"});if(!t.ok)throw new Error(`Get study template response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Get study template request failed: "+i.message);return i.data}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function T(e){try{if(u)return u.saveStudyTemplate(e).then((()=>({error:""}))).catch((e=>({error:null!=e?(0,n.errorToString)(e):"error"})));const t=new FormData;t.append("name",e.name),t.append("content",e.content);const i=await fetch(_("study_templates"),{method:"POST",body:t,credentials:"same-origin"});if(!i.ok)throw new Error(`Save study template response was not OK. Status: ${i.status}.`);const s=await i.json();return{error:"ok"===s.status?"":s.status}}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function I(){try{if(p)return p;p=[];const e=e=>(p=e.map((e=>({is_default:!1,name:e.name}))),p);if(u)return u.getAllStudyTemplates().then(e);const t=await fetch(_("study_templates"),{method:"GET",credentials:"same-origin"});if(!t.ok)throw new Error(`Study templates list response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Study templates list request failed: "+i.message);return e(i.data)}catch(e){throw o.logWarn((0, +n.errorToString)(e)),e}}function M(){p=null}function L(e,t){throw new Error("Not implemented")}function A(e,t){throw new Error("Not implemented")}function k(e,t){throw new Error("Not implemented")}function D(e,t,i){throw new Error("Not implemented")}function E(e,t,i){throw new Error("Not implemented")}async function V(e){throw new Error("Not implemented")}async function B(e,t){throw new Error("Not implemented")}async function R(e,t){throw new Error("Not implemented")}async function N(e,t,i){throw new Error("Not implemented")}function O(e){if(null!==u)return u.getChartTemplateContent(e);throw new Error("Not implemented")}function F(){return null!==u?u.getAllChartTemplates():Promise.resolve([])}async function W(e,t){if(null!==u)try{return await u.saveChartTemplate(e,t),a}catch(e){return console.error(e),{error:e instanceof Error?e.message:e.toString()}}throw new Error("Not implemented")}async function H(e){if(null!==u)try{return await u.removeChartTemplate(e),a}catch(e){return console.error(e),{error:e instanceof Error?e.message:e.toString()}}throw new Error("Not implemented")}function z(e){return O(e).then((e=>Boolean(e.content)))}},2269:(e,t,i)=>{"use strict";var s=i(50151).ensureNotNull,r=i(60156),n=i(36274).Interval,o=i(94141),a=i(60325),l=i(18792).ChartApiInterface,c=i(47327).HandlerInfo,h=i(1722).requireFullInterfaceImplementation,d=i(59224).getLogger("Chart.ChartApiLocal"),u=i(17133).TIMEFRAMETYPE,p=i(77475).createDwmAligner;TradingView.STUDY_COUNT_LIMIT=210;JSServer.ChartApi=function(e){this._notificationHandlers={},this._sessions={},this.studyCounter=0,this._connected=!1,this._enabled=!1,this._studyEngine=new o(e),this._callbacks={},this._serverTimeOffset=0;var t=this;this._studyEngine.on("configuration_received",(function(){t._fireEvent("configuration_received")})),this._studyEngine.on("realtime_tick",(function(e){var i={time:e.value[0]/1e3,open:e.value[1],high:e.value[2],low:e.value[3],close:e.value[4],volume:e.value[5]};t._fireEvent("realtime_tick",i,!0)})),this._setVisibleRangeTimeout={}},JSServer.ChartApi.prototype.destroy=function(){this._studyEngine.destroy(),this._studyEngine=null},JSServer.ChartApi.prototype.purgeCache=function(e){this._studyEngine.purgeCache(),this._studyEngine.purgeDataCache()},JSServer.ChartApi.prototype.defaultResolutions=function(){return this._studyEngine.supportedResolutions()||["1","3","5","15","30","45","60","120","180","240","1D","1W","1M"]},JSServer.ChartApi.prototype.availableCurrencies=function(){var e=this._studyEngine.supportedCurrencies().map((function(e){return"string"==typeof e?{id:e,code:e}:e}));return Promise.resolve(e)},JSServer.ChartApi.prototype.availableUnits=function(){return Promise.resolve(this._studyEngine.supportedUnits())},JSServer.ChartApi.prototype.availablePriceSources=function(e){return this._studyEngine.supportedPriceSources(e)},JSServer.ChartApi.prototype.supportedSymbolsTypes=function(){return this._studyEngine.supportedSymbolsTypes()},JSServer.ChartApi.prototype.symbolsGrouping=function(){return this._studyEngine.symbolsGrouping()}, +JSServer.ChartApi.prototype.start=function(){this._enabled=!0,this._fireEvent("start_enabled")},JSServer.ChartApi.prototype.unsubscribe=function(e,t){var i=this._callbacks[e];i&&i.splice(i.indexOf(t),1)},JSServer.ChartApi.prototype.on=function(e,t){return this._callbacks.hasOwnProperty(e)||(this._callbacks[e]=[]),this._callbacks[e].push(t),this},JSServer.ChartApi.prototype._fireEvent=function(e,t,i){if(this._callbacks.hasOwnProperty(e)){var s=this._callbacks[e].slice(0);i||(this._callbacks[e]=[]);for(var r=0;rn||(TradingView.ChartapiMessagerInstances[e].onSeriesTimeframeUpdate(t,i,m,n,a,c),l&&setTimeout(l,0))}}}if(this._studyEngine.isTimeScaleExtendedTo(e,1e3*r))m();else{var g=TradingView.ChartapiMessagerInstances[e].beforeSeriesCompleted,f=TradingView.ChartapiMessagerInstances[e].seriesError;void 0!==this._setVisibleRangeTimeout[e]&&clearTimeout(this._setVisibleRangeTimeout[e]),this._setVisibleRangeTimeout[e]=setTimeout(function(){delete this._setVisibleRangeTimeout[e],g.subscribe(null,v,!0),f.subscribe(null,S,!0),this._studyEngine.ensureExtendedTo(t,e,1e3*r)}.bind(this),0)}function v(e,s){e===t&&s===i&&(g.unsubscribe(null,v),f.unsubscribe(null,S),m())}function S(e,s){e===t&&s===i&&g.unsubscribe(null,v)}},JSServer.ChartApi.prototype._applyTimeFrame=function(e,t,i,s,o){var a,l,c={},h=!0;if(o.type===u.PeriodBack){var d=this._studyEngine.getSeriesLastBarTime(e,i);if(null===d)return;l=d/1e3;var _=n.parse(o.value),m=this._studyEngine.getSeriesSymbolInfo(e,i);a=r.alignPeriodsBackForVisibleRange(m.session,m.session_holidays,m.corrections,_.letter(),_.multiplier(),1,d)/1e3;var g=p(this._studyEngine.getSeriesInterval(e,i),m);null!==g&&(l=g.timeToExchangeTradingDay(1e3*l)/1e3,a=g.timeToExchangeTradingDay(1e3*a)/1e3),c={applyDefaultRightMargin:!0},h=!1}else a=o.from,l=o.to;this.setVisibleTimeRange(e,i,s,a,l,h,c,void 0,o)},JSServer.ChartApi.prototype.modifySeries=function(e,t,i,s,r,n,o,a){var l=this;this._notificationHandlers[e][t]=new c((function(r){"series_completed"===r.method&&null!==o&&(l._applyTimeFrame(e,s,t,i,o),o=null),a(r)}),t),this._studyEngine.modifySeries(e,t,s,r,i,n)},JSServer.ChartApi.prototype.requestMoreData=function(e,t){this._studyEngine.extendSeriesRange(e,t)},JSServer.ChartApi.prototype.setStudiesAccessController=function(e){this.studiesAccessController=e},JSServer.ChartApi.prototype.allStudiesMetadata=function(){return this._studyEngine.studiesMetadata()},JSServer.ChartApi.prototype.requestMetadata=function(e,t,i){this._notificationHandlers[e][t]=new c(i,t);var s=this.studiesAccessController.getEnabledTools();TradingView.ChartapiMessagerInstances[e].onRequestMetadata(t,s)},JSServer.ChartApi.prototype.canCreateStudy=function(){return this.studyCounter{"use strict";var s=i(57898).Delegate,r=function(e,t){this._server=e,this._session=t, -this.seriesCompleted=new s,this.seriesError=new s};r.prototype.onRequestMetadata=function(e,t){this._server.receiveLocalResponse({method:"studies_metadata",params:[this._session,e,{errors:[],hash:"",metainfo:t,migrations:[]}]})},r.prototype.onSymbolResolved=function(e,t){this._server.receiveLocalResponse({method:"symbol_resolved",params:[this._session,e,t]})},r.prototype.onSymbolError=function(e,t){this._server.receiveLocalResponse({method:"symbol_error",params:[this._session,e,t]})},r.prototype.onStudyError=function(e,t,i){this._server.receiveLocalResponse({method:"study_error",params:[this._session,e,t,i]})},r.prototype.onSeriesLoading=function(e,t){this._server.receiveLocalResponse({method:"series_loading",params:[this._session,e,t]})},r.prototype.onSeriesCompleted=function(e,t,i){this._server.receiveLocalResponse({method:"series_completed",params:[this._session,e,i,t]}),this.seriesCompleted.fire(e,t)},r.prototype.onSeriesError=function(e,t,i){this._server.receiveLocalResponse({method:"series_error",params:[this._session,e,t,i]}),this.seriesError.fire(e,t)},r.prototype.onStudyCompleted=function(e,t){this._server.receiveLocalResponse({method:"study_completed",params:[this._session,e,t]})},r.prototype.onStudyLoading=function(e,t){this._server.receiveLocalResponse({method:"study_loading",params:[this._session,e,t]})},r.prototype.onTickmarksUpdated=function(e,t){var i={method:"tickmark_update",params:[this._session,{index:e,zoffset:0,changes:[],marks:t,index_diff:[]}]};this._server.receiveLocalResponse(i)},r.prototype.onTimescaleUpdate=function(e,t){var i={method:"timescale_update",params:[this._session,this._prepareDataUpdateObjects(t),{index:e.pointsIndex,zoffset:0,changes:e.points,marks:e.marks,index_diff:e.indexChange,baseIndex:e.baseIndex}]};this._server.receiveLocalResponse(i)},r.prototype.onTimescaleCompleted=function(e){this._server.receiveLocalResponse({method:"timescale_completed",params:[this._session,e]})},r.prototype.onSeriesTimeframeUpdate=function(e,t,i,s,r){var n={method:"series_timeframe",params:[this._session,e,t,i,s,null,!0,r]};this._server.receiveLocalResponse(n)},r.prototype.onPointsetDataUpdate=function(e,t,i){this.onDataUpdate(e,t,i,null)},r.prototype._prepareDataUpdateObjects=function(e){var t={};return e.forEach((function(e){t[e.objId]={series:e.data,turnaround:e.turnaround},e.nonSeriesData&&(e.nonSeriesData.data?t[e.objId].nonseries={d:JSON.stringify(e.nonSeriesData.data),indexes:e.nonSeriesData.indexes}:t[e.objId].nonseries={d:"",indexes:[]})})),t},r.prototype.onDataUpdate=function(e,t,i,s){var r={method:"data_update",params:[this._session,this._prepareDataUpdateObjects([{objId:e,turnaround:t,data:i,nonSeriesData:s}])]};this._server.receiveLocalResponse(r)},r.prototype.onQuotesData=function(e){this._server.receiveLocalResponse({method:"quote_symbol_data",params:e})},r.prototype.onDepthData=function(e){this._server.receiveLocalResponse({method:"dd",params:e})},r.prototype.onDepthUpdate=function(e){this._server.receiveLocalResponse({method:"dpu",params:e})},r.prototype.onClearData=function(e){ -this._server.receiveLocalResponse({method:"clear_data",params:[this._session,e]})},TradingView.ChartapiMessagerInstances=[],e.exports=r},79850:(e,t,i)=>{"use strict";i.d(t,{DatafeedRequestsCachedProcessor:()=>_});var s=i(50151),r=i(36274),n=i(78071),o=i(74649),a=i(14483),l=i(60156),c=i(77475),h=i(32923);i(42053);function d(e,t){return e.ticker+(e.currency_code?"_#_"+e.currency_code:"")+(e.unit_id?"_#_"+e.unit_id:"")+(e.subsession_id?"_#_"+e.subsession_id:"")+"_#_"+t}function u(e){return new Date(e).toISOString()}class p{constructor(e,t,i,s,n,o){this._cache={bars:[]},this._nextSubscriptionId=0,this._pendingSubscribers=[],this._subscribers=[],this._requesting=!1,this._leftDate=null,this._nextTime=null,this._realtimeOn=!1,this._endOfData=!1,this._resetCacheTimeout=null,this._errorMessage=null,this._destroyed=!1,this._emptyResponsesCount=0,this._firstDataRequest=!0,this._datafeed=e,this._symbolInfo=t,this._interval=r.Interval.parse(i),this._resolution=this._interval.value(),this._dwmAligner=n,this._serverTimeOffsetGetter=s,this._resetCacheTimePeriod=void 0===o?1e4:o,this._sessionSpec=new h.SessionSpec(t.timezone,t.session,t.session_holidays,t.corrections),this._updateDatesFromExpirationDate()}destroy(){0!==this._subscribers.length&&console.warn("Destroying with not-empty state"),this._clearResetCacheTimeout(),this._unsubscribeRealtime(),this._purgeCache(),delete this._datafeed,this._destroyed=!0}addSubscription(e,t,i){const s=this._getNextSubscriptionId();this._pendingSubscribers.push({key:s,range:e,onHistoryCallback:t,onErrorCallback:i}),r.Interval.isDWM(this._resolution)&&void 0!==e.to&&null!==this._dwmAligner&&e.to%864e5&&console.warn(`${this._logMessagePrefix()}Internal error: invalid date for DWM resolution ${u(e.to)}, expected time without a time part`),this._clearResetCacheTimeout();return setTimeout((()=>{this._destroyed||this._processPendingSubscribers()}),0),s}removeSubscription(e){const t=this._pendingSubscribers.find((t=>t.key===e));if(t)return void this._pendingSubscribers.splice(this._pendingSubscribers.indexOf(t),1);const i=this._subscribers.find((t=>t.key===e));if(i)return this._subscribers.splice(this._subscribers.indexOf(i),1),void(this._subscribers.length||(this._resetCacheTimeout=setTimeout((()=>{this._resetCacheTimeout=null,this._purgeCache(),this._unsubscribeRealtime()}),this._resetCacheTimePeriod)));console.warn("Unknown subscription symbol={0}, resolution={1}, key={2}".format(this._symbolInfo.name,this._resolution,e))}_logMessage(e,t){(a.enabled("charting_library_debug_mode")||t)&&console.log(`${this._logMessagePrefix()}${e}`)}_logMessagePrefix(){const e=this._symbolInfo.currency_code,t=this._symbolInfo.unit_id;return`FEED [${this._symbolInfo.name}|${this._resolution}${e?"|"+e:""}${t?"|"+t:""}]: `}_clearResetCacheTimeout(){null!==this._resetCacheTimeout&&(clearTimeout(this._resetCacheTimeout),this._resetCacheTimeout=null)}_purgeCache(){this._logMessage("Reset cache"),this._cache={bars:[]},this._errorMessage=null,this._leftDate=null,this._endOfData=!1,this._firstDataRequest=!0, -this._updateDatesFromExpirationDate()}_updateDatesFromExpirationDate(){void 0!==this._symbolInfo.expiration_date&&(this._nextTime=1e3*this._symbolInfo.expiration_date,this._leftDate=1e3*(this._symbolInfo.expiration_date+1))}_dealignTime(e){return null===this._dwmAligner?e:this._dwmAligner.timeToExchangeTradingDay(e)}_normalizeRange(e){const t=void 0!==e.to?e.to:this._dealignTime(this._now());if(0===this._cache.bars.length||void 0!==e.to&&t<=(0,s.ensureNotNull)(this._leftDate))return{countBack:e.countBack,to:t};const i=null!==this._dwmAligner?this._dwmAligner.timeToSessionStart(t):t,r=(0,n.lowerbound)(this._cache.bars,i,((e,t)=>e.time{e.onErrorCallback(t)}))}let t=this._normalizeRange(e[0].range);for(const i of e.map((e=>this._normalizeRange(e.range))))(i.tot.countBack)&&(t=i);this._logMessage(`Leftmost subscriber requires ${t.countBack} bars prior ${u(t.to)}`);!(null===this._leftDate||t.to{const t=this._moveSubscriberToRealtime(e);this._returnHistoryDataToSubscriber(e,t)})),this._subscribeRealtimeIfNeeded()):this._ensureRequestedTo(t)}_moveSubscriberToRealtime(e){const t={key:e.key,onHistoryCallback:e.onHistoryCallback,barset:null};return this._subscribers.push(t),t}_isSymbolExpired(){return this._symbolInfo.expired||void 0!==this._symbolInfo.expiration_date}_subscribeRealtimeIfNeeded(){!this._subscribers.length||this._realtimeOn||this._isSymbolExpired()||this._subscribeRealtime()}_subscribeRealtime(){if(this._symbolInfo.expired||this._realtimeOn)return;this._realtimeOn=!0,this._datafeed.subscribeBars(this._symbolInfo,this._resolution,(e=>{null!==this._dwmAligner&&(e.time=this._dwmAligner.timeToSessionStart(e.time)),this._putToCacheNewBar(e),this._subscribers.forEach((t=>{const i=t.barset;if(null===i)throw new Error("subscriber.barset is null");i.add(e),t.onHistoryCallback(i)}))}),d(this._symbolInfo,this._resolution),(()=>{this._unsubscribeRealtime();const e=this._leftDate;this._purgeCache(),null===e||a.enabled("request_only_visible_range_on_reset")||this._ensureRequestedTo({to:e,countBack:0})})),this._logMessage("Subscribed to realtime")}_unsubscribeRealtime(){!this._isSymbolExpired()&&this._realtimeOn&&(this._datafeed.unsubscribeBars(d(this._symbolInfo,this._resolution)),this._logMessage("Unsubscribed from realtime"),this._realtimeOn=!1)} -_returnHistoryDataToSubscriber(e,t){const i=this._normalizeRange(e.range),s=this._createBarsetForRange(i);s.count()>0?this._logMessage("Bars to return for request {0}: total {1} bars in [{2} ... {3}] ".format(e.key,s.count(),u(s.bars[0].time),u(s.bars[s.count()-1].time))):this._logMessage("Request {0}. Nothing to return.".format(e.key)),t.barset=s,this._endOfData&&null!==this._leftDate&&i.to<=this._leftDate&&(s.endOfData=!0),e.onHistoryCallback(s)}_createBarsetForRange(e){const t=null!==this._dwmAligner?this._dwmAligner.timeToSessionStart(e.to):e.to,i=(0,n.lowerbound)(this._cache.bars,t,((e,t)=>e.time{if(!this._destroyed)if(a)this._logMessage("getBars callback is already called before",!0);else{if(a=!0,e.length>0){const t=` [${u(e[0].time)} ... ${u(e[e.length-1].time)}]`;this._logMessage(`Receiving bars: total ${e.length} bars in ${t}, requested range: ${o}`)}else this._logMessage(`Receiving bars: barset is empty, requested range: ${o}`);this._requesting=!1,this._processBars(e,t)}}),(e=>{this._destroyed||(a?this._logMessage("getBars callback is already called before",!0):(a=!0,this._requesting=!1,this._errorMessage=e||null, -this._processPendingSubscribers()))}))}_processBars(e,t){this._checkBars(e),this._alignBarsTime(e),e.length>0?(this._emptyResponsesCount=0,this._processFullBarset(e,t)):(this._emptyResponsesCount+=1,this._processEmptyBarset(t)),this._processPendingSubscribers()}_processEmptyBarset(e){e&&e.nextTime?(this._logMessage("Next time received: `{0}`".format(u(1e3*e.nextTime))),this._nextTime=1e3*e.nextTime):e&&e.noData?(this._logMessage("EOD received"),this._setEndOfData()):this._logMessage("nextTime or noData should present in metainfo when empty barset is returned"),50===this._emptyResponsesCount&&(this._logMessage("EOD detected due 50 empty responses in a row"),this._setEndOfData())}_setEndOfData(){this._endOfData=!0,this._cache.bars.length&&(this._leftDate=this._dealignTime(this._cache.bars[0].time))}_processFullBarset(e,t){this._putToCache(e)?null!==this._leftDate&&0!==this._cache.bars.length&&(this._interval.isTicks()?this._leftDate=this._dealignTime(this._cache.bars[0].time):this._leftDate=Math.min(this._leftDate,this._dealignTime(this._cache.bars[0].time))):this._logMessage("Incremental update failed. Starting full update. Returned data should be in the requested range.",!0),t&&t.nextTime?console.warn(`${this._logMessagePrefix()}nextTime should be set when there is no data in the requested period only`):t&&t.noData&&console.warn(`${this._logMessagePrefix()}noData should be set when there is no data in the requested period and earlier only`)}_getNextSubscriptionId(){return this._nextSubscriptionId++}_checkBars(e,t=!1){if(a.enabled("charting_library_debug_mode"))for(let i=1;i"number"!=typeof e[i][t]||!isFinite(e[i][t])))&&console.error(`${this._logMessagePrefix()}Wrong bars values: all OHLC values should be numbers`)}}_putToCache(e){if(0===e.length)return!0;if(this._cache.bars.length===e.length&&this._cache.bars[0].time===e[0].time&&this._cache.bars[this._cache.bars.length-1].time===e[e.length-1].time)return this._logMessage("Time range of received data is the same as cached one. Skip the update."),!0;if(0!==this._cache.bars.length&&e[e.length-1].time===this._cache.bars[0].time&&this._cache.bars.splice(0,1),0!==this._cache.bars.length&&e[e.length-1].time>=this._cache.bars[0].time){const t=this._cache.bars[this._cache.bars.length-1].time===e[e.length-1].time;if(this._cache.bars=[],!t)return this._leftDate=null,!1;this._logMessage("Received history up to now instead of incremental update. Return exactly what is requested.")}return this._cache.bars=[...e,...this._cache.bars],this._checkBars(this._cache.bars,!0),!0}_putToCacheNewBar(e){const t=this._cache.bars.length,i=e.time,s=0===t?NaN:this._cache.bars[t-1].time +this.beforeSeriesCompleted=new s,this.seriesError=new s};r.prototype.onRequestMetadata=function(e,t){this._server.receiveLocalResponse({method:"studies_metadata",params:[this._session,e,{errors:[],hash:"",metainfo:t,migrations:[]}]})},r.prototype.onSymbolResolved=function(e,t){this._server.receiveLocalResponse({method:"symbol_resolved",params:[this._session,e,t]})},r.prototype.onSymbolError=function(e,t){this._server.receiveLocalResponse({method:"symbol_error",params:[this._session,e,t]})},r.prototype.onStudyError=function(e,t,i){this._server.receiveLocalResponse({method:"study_error",params:[this._session,e,t,i]})},r.prototype.onSeriesLoading=function(e,t){this._server.receiveLocalResponse({method:"series_loading",params:[this._session,e,t]})},r.prototype.onSeriesCompleted=function(e,t,i){this.beforeSeriesCompleted.fire(e,t),this._server.receiveLocalResponse({method:"series_completed",params:[this._session,e,i,t]})},r.prototype.onSeriesError=function(e,t,i){this._server.receiveLocalResponse({method:"series_error",params:[this._session,e,t,i]}),this.seriesError.fire(e,t)},r.prototype.onStudyCompleted=function(e,t){this._server.receiveLocalResponse({method:"study_completed",params:[this._session,e,t]})},r.prototype.onStudyLoading=function(e,t){this._server.receiveLocalResponse({method:"study_loading",params:[this._session,e,t]})},r.prototype.onTickmarksUpdated=function(e,t){var i={method:"tickmark_update",params:[this._session,{index:e,zoffset:0,changes:[],marks:t,index_diff:[]}]};this._server.receiveLocalResponse(i)},r.prototype.onTimescaleUpdate=function(e,t){var i={method:"timescale_update",params:[this._session,this._prepareDataUpdateObjects(t),{index:e.pointsIndex,zoffset:0,changes:e.points,marks:e.marks,index_diff:e.indexChange,baseIndex:e.baseIndex}]};this._server.receiveLocalResponse(i)},r.prototype.onTimescaleCompleted=function(e){this._server.receiveLocalResponse({method:"timescale_completed",params:[this._session,e]})},r.prototype.onSeriesTimeframeUpdate=function(e,t,i,s,r,n){var o={method:"series_timeframe",params:[this._session,e,t,i,s,n||null,!0,r]};this._server.receiveLocalResponse(o)},r.prototype.onPointsetDataUpdate=function(e,t,i){this.onDataUpdate(e,t,i,null)},r.prototype._prepareDataUpdateObjects=function(e){var t={};return e.forEach((function(e){t[e.objId]={series:e.data,turnaround:e.turnaround},e.nonSeriesData&&(e.nonSeriesData.data?t[e.objId].nonseries={d:JSON.stringify(e.nonSeriesData.data),indexes:e.nonSeriesData.indexes}:t[e.objId].nonseries={d:"",indexes:[]})})),t},r.prototype.onDataUpdate=function(e,t,i,s){var r={method:"data_update",params:[this._session,this._prepareDataUpdateObjects([{objId:e,turnaround:t,data:i,nonSeriesData:s}])]};this._server.receiveLocalResponse(r)},r.prototype.onQuotesData=function(e){this._server.receiveLocalResponse({method:"quote_symbol_data",params:e})},r.prototype.onDepthData=function(e){this._server.receiveLocalResponse({method:"dd",params:e})},r.prototype.onDepthUpdate=function(e){this._server.receiveLocalResponse({method:"dpu",params:e})}, +r.prototype.onClearData=function(e){this._server.receiveLocalResponse({method:"clear_data",params:[this._session,e]})},TradingView.ChartapiMessagerInstances=[],e.exports=r},79850:(e,t,i)=>{"use strict";i.d(t,{DatafeedRequestsCachedProcessor:()=>_});var s=i(50151),r=i(36274),n=i(78071),o=i(74649),a=i(14483),l=i(60156),c=i(77475),h=i(32923);i(42053);function d(e,t){return e.ticker+(e.currency_code?"_#_"+e.currency_code:"")+(e.unit_id?"_#_"+e.unit_id:"")+(e.subsession_id?"_#_"+e.subsession_id:"")+"_#_"+t}function u(e){return new Date(e).toISOString()}class p{constructor(e,t,i,s,n,o){this._cache={bars:[]},this._nextSubscriptionId=0,this._pendingSubscribers=[],this._subscribers=[],this._requesting=!1,this._leftDate=null,this._nextTime=null,this._realtimeOn=!1,this._endOfData=!1,this._resetCacheTimeout=null,this._errorMessage=null,this._destroyed=!1,this._emptyResponsesCount=0,this._firstDataRequest=!0,this._datafeed=e,this._symbolInfo=t,this._interval=r.Interval.parse(i),this._resolution=this._interval.value(),this._dwmAligner=n,this._serverTimeOffsetGetter=s,this._resetCacheTimePeriod=void 0===o?1e4:o,this._sessionSpec=new h.SessionSpec(t.timezone,t.session,t.session_holidays,t.corrections),this._updateDatesFromExpirationDate()}destroy(){0!==this._subscribers.length&&console.warn("Destroying with not-empty state"),this._clearResetCacheTimeout(),this._unsubscribeRealtime(),this._purgeCache(),delete this._datafeed,this._destroyed=!0}addSubscription(e,t,i){const s=this._getNextSubscriptionId();this._pendingSubscribers.push({key:s,range:e,onHistoryCallback:t,onErrorCallback:i}),r.Interval.isDWM(this._resolution)&&void 0!==e.to&&null!==this._dwmAligner&&e.to%864e5&&console.warn(`${this._logMessagePrefix()}Internal error: invalid date for DWM resolution ${u(e.to)}, expected time without a time part`),this._clearResetCacheTimeout();return setTimeout((()=>{this._destroyed||this._processPendingSubscribers()}),0),s}removeSubscription(e){const t=this._pendingSubscribers.find((t=>t.key===e));if(t)return void this._pendingSubscribers.splice(this._pendingSubscribers.indexOf(t),1);const i=this._subscribers.find((t=>t.key===e));if(i)return this._subscribers.splice(this._subscribers.indexOf(i),1),void(this._subscribers.length||(this._resetCacheTimeout=setTimeout((()=>{this._resetCacheTimeout=null,this._purgeCache(),this._unsubscribeRealtime()}),this._resetCacheTimePeriod)));console.warn("Unknown subscription symbol={0}, resolution={1}, key={2}".format(this._symbolInfo.name,this._resolution,e))}_logMessage(e,t){(a.enabled("charting_library_debug_mode")||t)&&console.log(`${this._logMessagePrefix()}${e}`)}_logMessagePrefix(){const e=this._symbolInfo.currency_code,t=this._symbolInfo.unit_id;return`FEED [${this._symbolInfo.name}|${this._resolution}${e?"|"+e:""}${t?"|"+t:""}]: `}_clearResetCacheTimeout(){null!==this._resetCacheTimeout&&(clearTimeout(this._resetCacheTimeout),this._resetCacheTimeout=null)}_purgeCache(){this._logMessage("Reset cache"),this._cache={bars:[]},this._errorMessage=null,this._leftDate=null,this._endOfData=!1, +this._firstDataRequest=!0,this._updateDatesFromExpirationDate()}_updateDatesFromExpirationDate(){void 0!==this._symbolInfo.expiration_date&&(this._nextTime=1e3*this._symbolInfo.expiration_date,this._leftDate=1e3*(this._symbolInfo.expiration_date+1))}_dealignTime(e){return null===this._dwmAligner?e:this._dwmAligner.timeToExchangeTradingDay(e)}_normalizeRange(e){const t=void 0!==e.to?e.to:this._dealignTime(this._now());if(0===this._cache.bars.length||void 0!==e.to&&t<=(0,s.ensureNotNull)(this._leftDate))return{countBack:e.countBack,to:t};const i=null!==this._dwmAligner?this._dwmAligner.timeToSessionStart(t):t,r=(0,n.lowerbound)(this._cache.bars,i,((e,t)=>e.time{e.onErrorCallback(t)}))}let t=this._normalizeRange(e[0].range);for(const i of e.map((e=>this._normalizeRange(e.range))))(i.tot.countBack)&&(t=i);this._logMessage(`Leftmost subscriber requires ${t.countBack} bars prior ${u(t.to)}`);!(null===this._leftDate||t.to{const t=this._moveSubscriberToRealtime(e);this._returnHistoryDataToSubscriber(e,t)})),this._subscribeRealtimeIfNeeded()):this._ensureRequestedTo(t)}_moveSubscriberToRealtime(e){const t={key:e.key,onHistoryCallback:e.onHistoryCallback,barset:null};return this._subscribers.push(t),t}_isSymbolExpired(){return this._symbolInfo.expired||void 0!==this._symbolInfo.expiration_date}_subscribeRealtimeIfNeeded(){!this._subscribers.length||this._realtimeOn||this._isSymbolExpired()||this._subscribeRealtime()}_subscribeRealtime(){if(this._symbolInfo.expired||this._realtimeOn)return;this._realtimeOn=!0,this._datafeed.subscribeBars(this._symbolInfo,this._resolution,(e=>{null!==this._dwmAligner&&(e.time=this._dwmAligner.timeToSessionStart(e.time)),this._putToCacheNewBar(e),this._subscribers.forEach((t=>{const i=t.barset;if(null===i)throw new Error("subscriber.barset is null");i.add(e),t.onHistoryCallback(i)}))}),d(this._symbolInfo,this._resolution),(()=>{this._unsubscribeRealtime();const e=this._leftDate;this._purgeCache(),null===e||a.enabled("request_only_visible_range_on_reset")||this._ensureRequestedTo({to:e,countBack:0})})),this._logMessage("Subscribed to realtime")}_unsubscribeRealtime(){!this._isSymbolExpired()&&this._realtimeOn&&(this._datafeed.unsubscribeBars(d(this._symbolInfo,this._resolution)),this._logMessage("Unsubscribed from realtime"), +this._realtimeOn=!1)}_returnHistoryDataToSubscriber(e,t){const i=this._normalizeRange(e.range),s=this._createBarsetForRange(i);s.count()>0?this._logMessage("Bars to return for request {0}: total {1} bars in [{2} ... {3}] ".format(e.key,s.count(),u(s.bars[0].time),u(s.bars[s.count()-1].time))):this._logMessage("Request {0}. Nothing to return.".format(e.key)),t.barset=s,this._endOfData&&null!==this._leftDate&&i.to<=this._leftDate&&(s.endOfData=!0),e.onHistoryCallback(s)}_createBarsetForRange(e){const t=null!==this._dwmAligner?this._dwmAligner.timeToSessionStart(e.to):e.to,i=(0,n.lowerbound)(this._cache.bars,t,((e,t)=>e.time{if(!this._destroyed)if(a)this._logMessage("getBars callback is already called before",!0);else{if(a=!0,e.length>0){const t=` [${u(e[0].time)} ... ${u(e[e.length-1].time)}]`;this._logMessage(`Receiving bars: total ${e.length} bars in ${t}, requested range: ${o}`)}else this._logMessage(`Receiving bars: barset is empty, requested range: ${o}`);this._requesting=!1,this._processBars(e,t)}}),(e=>{this._destroyed||(a?this._logMessage("getBars callback is already called before",!0):(a=!0,this._requesting=!1, +this._errorMessage=e||null,this._processPendingSubscribers()))}))}_processBars(e,t){this._checkBars(e),this._alignBarsTime(e),e.length>0?(this._emptyResponsesCount=0,this._processFullBarset(e,t)):(this._emptyResponsesCount+=1,this._processEmptyBarset(t)),this._processPendingSubscribers()}_processEmptyBarset(e){e&&e.nextTime?(this._logMessage("Next time received: `{0}`".format(u(1e3*e.nextTime))),this._nextTime=1e3*e.nextTime):e&&e.noData?(this._logMessage("EOD received"),this._setEndOfData()):this._logMessage("nextTime or noData should present in metainfo when empty barset is returned"),50===this._emptyResponsesCount&&(this._logMessage("EOD detected due 50 empty responses in a row"),this._setEndOfData())}_setEndOfData(){this._endOfData=!0,this._cache.bars.length&&(this._leftDate=this._dealignTime(this._cache.bars[0].time))}_processFullBarset(e,t){this._putToCache(e)?null!==this._leftDate&&0!==this._cache.bars.length&&(this._interval.isTicks()?this._leftDate=this._dealignTime(this._cache.bars[0].time):this._leftDate=Math.min(this._leftDate,this._dealignTime(this._cache.bars[0].time))):this._logMessage("Incremental update failed. Starting full update. Returned data should be in the requested range.",!0),t&&t.nextTime?console.warn(`${this._logMessagePrefix()}nextTime should be set when there is no data in the requested period only`):t&&t.noData&&console.warn(`${this._logMessagePrefix()}noData should be set when there is no data in the requested period and earlier only`)}_getNextSubscriptionId(){return this._nextSubscriptionId++}_checkBars(e,t=!1){if(a.enabled("charting_library_debug_mode"))for(let i=1;i"number"!=typeof e[i][t]||!isFinite(e[i][t])))&&console.error(`${this._logMessagePrefix()}Wrong bars values: all OHLC values should be numbers`)}}_putToCache(e){if(0===e.length)return!0;if(this._cache.bars.length===e.length&&this._cache.bars[0].time===e[0].time&&this._cache.bars[this._cache.bars.length-1].time===e[e.length-1].time)return this._logMessage("Time range of received data is the same as cached one. Skip the update."),!0;if(0!==this._cache.bars.length&&e[e.length-1].time===this._cache.bars[0].time&&this._cache.bars.splice(0,1),0!==this._cache.bars.length&&e[e.length-1].time>=this._cache.bars[0].time){const t=this._cache.bars[this._cache.bars.length-1].time===e[e.length-1].time;if(this._cache.bars=[],!t)return this._leftDate=null,!1;this._logMessage("Received history up to now instead of incremental update. Return exactly what is requested.")}return this._cache.bars=[...e,...this._cache.bars],this._checkBars(this._cache.bars,!0),!0}_putToCacheNewBar(e){const t=this._cache.bars.length,i=e.time,s=0===t?NaN:this._cache.bars[t-1].time ;0===t||st.destroy())),this._threads={},delete this._datafeed}purgeCache(){this._forEachThread(((e,t)=>t.destroy())),this._threads={}}subscribe(e,t,i,s,r){const n=d(e,t);this._threads[n]||(this._threads[n]=this._createThread(e,t));return n+'"'+this._threads[n].addSubscription(i,s,r)}unsubscribe(e){const t=e.split('"');if(2!==t.length)return void console.warn("Wrong guid format");const i=t[0],s=parseInt(t[1]);this._threads.hasOwnProperty(i)?this._threads[i].removeSubscription(s):console.warn("Data thread doesnt exist: "+e)}_createThread(e,t){return new p(this._datafeed,e,t,this._serverTimeOffsetGetter,(0,c.createDwmAligner)(t,e),this._resetCacheTimePeriod)}_forEachThread(e){Object.keys(this._threads).forEach((t=>e(t,this._threads[t])))}}},13041:(e,t,i)=>{"use strict";i.d(t,{barTimeToEndOfPeriod:()=>r,endOfPeriodToBarTime:()=>n});var s=i(60062);function r(e,t,i){if(i.isDays())return t;if(e.moveTo(1e3*t),i.isIntraday()){const i=e.indexOfBar(1e3*t);if(i<0)throw new Error(`${t} is out of the instrument session `);return e.endOfBar(i)/1e3}return e.startOfBar(s.SessionStage.LASTBAR_SESSION)/1e3}function n(e,t,i){if(i.isDays())return t;const s=1e3*t-1;if(e.moveTo(s),i.isIntraday()){const i=e.indexOfBar(s);if(i<0)throw new Error(`${t} is out of the instrument session `);return e.startOfBar(i)/1e3}return t=e.startOfBar(0)/1e3}},48739:(e,t,i)=>{"use strict";i.d(t,{replaceGraphicsTimesWithTimePointIndexIndex:()=>n});const s=new Map([["horizlines",e=>[e.startIndex,e.endIndex]],["hhists",e=>[e.firstBarTime,e.firstBarTime]],["vertlines",e=>[e.index]],["polygons",e=>e.points.map((e=>e.index))],["horizlines",e=>[e.startIndex,e.endIndex]],["hhists",e=>[e.firstBarTime,e.firstBarTime]],["vertlines",e=>[e.index]],["polygons",e=>e.points.map((e=>e.index))],["backgrounds",e=>[e.start,e.stop]]]),r=new Map([["horizlines",(e,t)=>{const i=e;i.startIndex=t.get(i.startIndex),i.endIndex=t.get(i.endIndex)}],["hhists",(e,t)=>{const i=e;i.firstBarTime=t.get(i.firstBarTime),i.lastBarTime=t.get(i.lastBarTime)}],["vertlines",(e,t)=>{const i=e;i.index=t.get(i.index)}],["polygons",(e,t)=>{const i=e;for(const e of i.points)e.index=t.get(e.index)}],["backgrounds",(e,t)=>{const i=e;i.start=t.get(i.start),i.stop=t.get(i.stop)}]]);function n(e){const t=e.data&&e.data.graphicsCmds&&e.data.graphicsCmds.create;if(!t)return[];const i=new Map,n=new Set;s.forEach(((e,s)=>{const r=t[s];if(r)for(const t of r)for(const s of t.data){const t=e(s) ;for(const e of t)i.set(e,-1),n.add(e)}}));const o=Array.from(n).sort(((e,t)=>e-t));return o.forEach(((e,t)=>i.set(e,t))),r.forEach(((e,s)=>{const r=t[s];if(r)for(const t of r)for(const s of t.data)e(s,i)})),o}},26665:(e,t,i)=>{"use strict";var s=i(14483);window.onload=function(){location.hostname.indexOf(".")>=0&&!function(){try{return/^(192|172|10)\.[0-9][0-9][0-9]\.[0-9][0-9][0-9]\.[0-9][0-9][0-9]/.test(location.hostname)||/^.*((?:\.local)|localhost)$/.test(location.hostname)}catch(e){return!1}}()&&setTimeout((function(){try{var e=function(){var e=0;return JSON.parse(urlParams.logo).image&&(e="C",s.enabled("link_to_tradingview")||(e="D")),e}();window.ga&&(0!==e&&window.ga("send","event","s",e),urlParams.utm||window.ga("send","event","l"))}catch(e){}}),3e4)}},3035:(e,t,i)=>{"use strict";var s,r=i(60156),n={};e.exports=function(e,t,i){var o,a,l={},c=n[i]||"out_of_session",h=!1,d=i,u=t,p=null,_=null;function m(){var e={};e.symbolname=d,e.status="ok",e.values={},e.values.current_session=c,n[d]=c,TradingView.ChartapiMessagerInstances[u].onQuotesData([u].concat([e]))}function g(){if(o)if(a)c="out_of_session";else{var e=r.isTradingNow((new Date).getTime(),o)?"market":"out_of_session";e!==c&&(c=e)}}return e(i,null,(function(e){h||function(e){o=new r.SessionInfo(e.timezone,e.session,e.session_holidays,e.corrections),a=e.expired;const t=60-new Date(Date.now()).getSeconds();s&&s?.ticker===e.ticker||(s={ticker:e.ticker,timer:t},clearTimeout(s.timeout)),_=setTimeout((()=>{p=setInterval((()=>{g(),m()}),6e4),g(),m()}),1e3*s.timer),s&&void 0!==s?.timeout||(s.timeout=_),g(),m()}(e)}),(function(){})),l.stop=function(){h=!0,p&&clearInterval(p),_&&clearInterval(_)},l.marketStatus=function(){return c},l}},36454:(e,t,i)=>{"use strict";i.d(t,{getChartStyleStudy:()=>n});var s=i(81337);class r{main(e){const t=e.new_var(s.Std.open(e)),i=e.new_var(s.Std.close(e)),r=t.get(1),n=i.get(1),o=s.Std.ohlc4(e),a=s.Std.na(t.get(1))?(s.Std.open(e)+s.Std.close(e))/2:(r+n)/2;t.set(a),i.set(o);const l=s.Std.max(s.Std.high(e),s.Std.max(a,o)),c=s.Std.min(s.Std.low(e),s.Std.min(a,o)),h=s.Std.volume(e),d=e.symbol;return[d.time,a,l,c,o,h,d.updatetime,d.isBarClosed]}}function n(e){if(0===e.type.indexOf("BarSetHeikenAshi@tv-basicstudies-"))return new r;const t=`unknown builder type: ${e.type}`;throw console.error(t),new Error(t)}},90961:(e,t,i)=>{"use strict";i.d(t,{Context:()=>r});var s=i(37040);class r{constructor(e){this.minimumAdditionalDepth=null,this._vars=[],this._varsIndex=0,this._ctx=[],this._ctxIndex=0,this.symbol=e}new_sym(e,t,i,s,r){return this.symbol.script.add_sym(e,t,i,s,r)}select_sym(e){this.symbol=this.symbol.script.get_sym(e)}is_main_symbol(e){return void 0!==e&&e===this.symbol.script.get_sym(0)}new_var(e){const t=this._vars;t.length<=this._varsIndex&&t.push(new s.Series(this.symbol));const i=t[this._varsIndex++];return arguments.length>0&&void 0!==e&&i.set(e),i}new_unlimited_var(e){const t=this._vars;t.length<=this._varsIndex&&t.push(new s.UnlimitedSeries(this.symbol));const i=t[this._varsIndex++];return arguments.length>0&&i.set(e),i} new_ctx(){return this._ctx.length<=this._ctxIndex&&this._ctx.push(new r(this.symbol)),this._ctx[this._ctxIndex++]}prepare(e){this._ctxIndex=0,this._varsIndex=0;for(let t=0;te&&(e=i)}return e}stop(){this.symbol=null,this._vars=null}setMinimumAdditionalDepth(e){this.minimumAdditionalDepth=e}}},61476:(e,t,i)=>{"use strict";var s=i(36274).Interval,r=i(77475).isAlignmentEnabled,n=i(36454).getChartStyleStudy,o=i(27856).decodeExtendedSymbol,a=i(47609).findSuitableResolutionToBuildFrom,l=i(66846).SubsessionId,c=function(){var e=i(74649),t=e.StudyEngine,c=e.BarBuilder,h=e.BarSet;function d(e){this.host=e,this.cache={}}function u(t){console.error(t),e.Std.error(t)}d.prototype.getCache=function(e){return this.cache[e]},d.prototype.putCache=function(e,t){this.cache[e]=t},d.prototype.subscribe=function(e,t,i,s,r,n,o,a,l,c,h){var d=l(o),u=function(e,t,i,s,r,n,o,a,l){var c=r.has_empty_bars?"_":"";return n+e+s+(t||"")+(i||"")+(l||"")+c+"_"+o.countBack+"_"+o.to+"_"+Boolean(a)}(e,t,i,s,o,a,d,c,h),p=this.getCache(u);return p||(p=this.createItem(e,t,i,s,o,d,a,c,h),this.putCache(u,p)),p.listeners.addListener(r,n),{key:u,listener:r}},d.prototype.unsubscribe=function(e){var t=this.getCache(e.key);t&&t.listeners.removeListener(e.listener)},d.prototype.removeUnused=function(){var e=[];for(var t in this.cache){if(this.cache[t])0===this.cache[t].listeners.listenersCount()&&e.push(t)}if(0!==e.length){for(var i=0;ie.id===c.Regular)),i=e.subsessions.find((e=>e.id===c.PreMarket)),s=e.subsessions.find((e=>e.id===c.PostMarket));void 0!==t&&(this.regularSubsession=new h(e.timezone,t.session,e.session_holidays,t["session-correction"])),void 0!==i&&(this.preMarketSubsession=new h(e.timezone,i.session,e.session_holidays,i["session-correction"])),void 0!==s&&(this.postMarketSubsession=new h(e.timezone,s.session,e.session_holidays,s["session-correction"]))}}isdwm(){return""!==this.resolution&&"S"!==this.resolution&&"T"!==this.resolution}enable_dwm_aligning(e,t){this.dwm_aligner=g.newBarBuilder(this.period,e,t)}bartime(){var e=this.time;if(!this.isdwm()||isNaN(e))return e;var t=m.utc_to_cal(this.timezone,e);return this.session.spec.correctTradingDay(t),m.cal_to_utc(this.timezone,t)}lastbar(e){if(!isNaN(e.time)){var t=e.time;this.dwm_aligner&&(this.dwm_aligner.moveTo(t),t=this.dwm_aligner.startOfBar(0));var i=this.time!==t;i&&this.index>=0&&!this.isBarClosed&&(this.isNewBar=!1,this.isBarClosed=!0,this.script.calc(this)),this.time=t,this.open=e.open,this.high=e.high,this.low=e.low,this.close=e.close,this.volume=e.volume,this.updatetime=e.updatetime,this.isNewBar=i,this.isBarClosed=e.isBarClosed,this.isLastBar=e.isLastBar,this.isNewBar&&(this.index++,this.isFirstBar=0===this.index),this.script.calc(this)}}}class S{constructor(e,t,i,s,r,n,o,a,l,c,h){this.body=n,this.symbols=[],this.runner=r,this.inputCallback=a,this.out=o,this.nonseriesOut=l,this.ctx=new p(this.add_sym(e,t,i,s,c,h)),this.init()}calc(e){var t=this.ctx,i=this.body;t.prepare(e);var s=i.main(t,this.inputCallback,e);if(s&&"composite"===s.type)for(let e=0;e1&&this.runner.host.enableDwmAligning&&o.enable_dwm_aligning(this.symbols[0].session,o.session),o}maxAdditionalDepth(){return this.symbols[0].isAdditionalDepthAllowed?this.ctx.maxAdditionalDepth():0}stop(){this.symbols=null,this.ctx.stop(),this.ctx=null}get_sym(e){return this.symbols[e]}}class y{constructor(e){this.symbols=[],this.barsets=[],this.subscription=[],this.host=e,this.isRecalculated=!1,this.isStarted=!1,this.start()}add_sym(e,t,i,s,r,n,o){ var a=new v(e,t,i,s,r,n,o);return this.symbols.push(a),a}get_sym(e){return this.symbols[e]}out(e,t){if(this.nonseriesUpdate){var i=Object.assign({},this.nonseriesUpdate);t.splice(0,0,e.time),i.lastBar=t,this.host.nonseriesOut(e,i)}else this.host.out(e,t)}start(){this.isStarted=!0;var e=this.host;this._script=new S(e.tickerid,e.period,e.currencyCode,e.unitId,this,e.body,this.out.bind(this),e.input,e.nonseriesOut,e.symbolInfo,e.subsessionId);var t=this,i=[],s=this.symbols,a=Object.assign({},e.dataRange,{countBack:e.dataRange.countBack+t._script.maxAdditionalDepth()}),l=s[0];function c(t,s,r){i.push(y.feed.subscribe(t.tickerid,t.currencyCode,t.unitId,t.period,r,e.onErrorCallback,e.symbolInfo,e.sessionId,s,e.forceAlignBars,t.subsessionId))}function h(i,s){"series"===(s.nonseries?"nonseries":"series")?t.update(i,s):s.lastBar?(t.nonseriesUpdate=s,s.lastBar.isLastBar=!0,t.symbols[0].lastbar(s.lastBar),t.nonseriesUpdate=null):e.nonseriesOut(p,s)}function d(){return a}c(l,d,(function(e){!e.nonseries&&Number.isFinite(e.firstLoadedTimeMs)&&function(e){function i(i,s){var r=o(i,s)(e),a=n(i,s);return null!==a&&(r=a.timeToExchangeTradingDay(r)),{to:r,countBack:t._script.maxAdditionalDepth()}}for(var a=1;a=0;i--)for(var s=e[i],r=this.barsets[i],n=r.count(),o=0;o{"use strict";i.d(t,{Series:()=>n,UnlimitedSeries:()=>o});var s=i(78071),r=i(81337);class n{constructor(e){this.mindepth=0,this.original=NaN,this.modified=!1,this._hist=null,this._histPos=0,this.symbol=e}valueOf(){return this.get(0)}get(e){return isNaN(e)&&(e=0),e=e||0,this._hist?e>=this._hist.length?(console.error("not enough depth: "+this),NaN):this._get(e):(this.mindepth=r.Std.max(this.mindepth,e),NaN)}set(e){this._hist&&(this._hist[this._histPos]=e,this.modified=!0)}prepare(e){e===this.symbol&&(e.isNewBar?(this.original=this.get(0),!this.modified&&this._hist||this.add_hist()):this.set(this.original),this.modified=!1)}add_hist(){if(!this._hist){let e=r.Std.na(this.mindepth)?r.Std.max_series_default_size:r.Std.max(this.mindepth+1,1);e=Math.round(e);const t=new Array(e);for(let i=0;i{"use strict";const s=i(48891).getHexColorByName;var r=i(74649);i(24172);var n=i(82808).pivotPointsStandardStudyItem,o=i(72365).volumeProfileVisibleRangeStudyItem,a=i(82597).volumeProfileFixedRangeVbPStudyItem,l=i(82597).volumeProfileFixedRangeBSStudyItem,c=i(39944).spreadStudyItem,h=i(81821).ratioStudyItem,d=i(65097).regressionTrendStudyItem,u=i(53130).anchoredVWAPStudyItem;const p=s("color-ripe-red-400"),_=s("color-minty-green-400");JSServer.studyLibrary=JSServer.studyLibrary.concat([{name:"Compare",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!0,defaults:{styles:{compare:{linestyle:0,linewidth:2,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#9C27B0"}},inputs:{source:"close",symbol:""}},plots:[{id:"compare",type:"line"}],styles:{compare:{title:"Plot",histogramBase:0}},description:"Compare",shortDescription:"Compare",is_price_study:!0,inputs:[{defval:"close",id:"source",name:"Source",options:["open","high","low","close","hl2","hlc3","ohlc4"],type:"text"},{id:"symbol",name:"Symbol",type:"symbol",isHidden:!0}],id:"Compare@tv-basicstudies-1",format:{type:"inherit"}},constructor:function(){this.init=function(e,t){this._context=e,this._context.new_sym(t(1),r.Std.period(this._context))},this.main=function(e,t){this._context=e;var i=this._context.new_unlimited_var(this._context.symbol.time);this._context.select_sym(1);var s=this._context.new_unlimited_var(this._context.symbol.time),n=r.Std[t(0)](this._context),o=this._context.new_unlimited_var(n);return this._context.select_sym(0),[o.adopt(s,i,0)]}}},{name:"Overlay",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!0,defaults:{styles:{},inputs:{symbol:"",extendTimeScale:!1}},plots:[{id:"open",type:"line"},{id:"high",type:"line"},{id:"low",type:"line"},{id:"close",type:"line"}],styles:{open:{title:"Open"},high:{title:"High"},low:{title:"Low"},close:{title:"Close"}},description:"Overlay",shortDescription:"Overlay",is_price_study:!1,inputs:[{id:"symbol",name:"symbol",defval:"",type:"symbol",isHidden:!0},{id:"extendTimeScale",name:"extendTimeScale",defval:!1,type:"boolean",isHidden:!0}],id:"Overlay@tv-basicstudies-1",format:{type:"price", -precision:4},canExtendTimeScale:!0},constructor:function(){this.init=function(e,t){this._context=e,this._context.new_sym(t(0),r.Std.period(this._context))},this.main=function(e,t){this._context=e;var i=!1===t(1),s=this._context.new_unlimited_var(this._context.symbol.time);this._context.select_sym(1);var n=this._context.new_unlimited_var(this._context.symbol.time),o=this._context.new_unlimited_var(r.Std.open(this._context)),a=this._context.new_unlimited_var(r.Std.high(this._context)),l=this._context.new_unlimited_var(r.Std.low(this._context)),c=this._context.new_unlimited_var(r.Std.close(this._context));return i?(this._context.select_sym(0),[o.adopt(n,s,1),a.adopt(n,s,1),l.adopt(n,s,1),c.adopt(n,s,1)]):[o.get(0),a.get(0),l.get(0),c.get(0)]}}},{name:"Volume",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{vol:{linestyle:0,linewidth:1,plottype:5,trackPrice:!1,transparency:50,visible:!0,color:"#000080"},vol_ma:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1,color:"#2196F3"},smoothedMA:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1,color:"#2196F3"}},palettes:{volumePalette:{colors:{0:{color:p,width:1,style:0},1:{color:_,width:1,style:0}}}},inputs:{showMA:!1,length:20,col_prev_close:!1,symbol:"",smoothingLine:"SMA",smoothingLength:9}},plots:[{id:"vol",type:"line"},{id:"volumePalette",palette:"volumePalette",target:"vol",type:"colorer"},{id:"vol_ma",type:"line"},{id:"smoothedMA",type:"line"}],styles:{vol:{title:"Volume",histogramBase:0},vol_ma:{title:"Volume MA",histogramBase:0},smoothedMA:{title:"Smoothed MA",histogramBase:0}},description:"Volume",shortDescription:"Volume",is_price_study:!1,palettes:{volumePalette:{colors:{0:{name:"Falling"},1:{name:"Growing"}}}},inputs:[{id:"symbol",name:"Other Symbol",defval:"",type:"symbol",optional:!0,isHidden:!1},{id:"showMA",name:"show MA",defval:!1,type:"bool",isHidden:!0},{id:"length",name:"MA Length",defval:20,type:"integer",min:1,max:2e3},{defval:!1,id:"col_prev_close",name:"Color based on previous close",type:"bool"},{id:"smoothingLine",name:"Smoothing Line",defval:"SMA",type:"text",options:["SMA","EMA","WMA"]},{id:"smoothingLength",name:"Smoothing Length",defval:9,type:"integer",min:1,max:1e4}],id:"Volume@tv-basicstudies-1",format:{type:"volume"}},constructor:function(){this.init=function(e,t){this._context=e,""!==t(0)&&this._context.new_sym(t(0),r.Std.period(this._context))},this.f_0=function(e,t){return r.Std.gt(e,t)?0:1},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.volume(this._context),s=r.Std.open(this._context),n=r.Std.close(this._context),o=this._context.new_var(this._context.symbol.time),a=this._input(4),l=this._input(5);if(this._context.setMinimumAdditionalDepth(this._input(2)+l),""!==this._input(0)){this._context.select_sym(1);var c=this._context.new_var(this._context.symbol.time),h=this._context.new_var(r.Std.volume(this._context)),d=this._context.new_var(r.Std.open(this._context)),u=this._context.new_var(r.Std.close(this._context)) -;i=h.adopt(c,o,1),s=d.adopt(c,o,1),n=u.adopt(c,o,1),this._context.select_sym(0)}var p,_,m=this._context.new_var(i),g=r.Std.sma(m,this._input(2),this._context),f=this._context.new_var(g),v=this._context.new_var(n);return p=v.get(1)&&this._input(3)?this.f_0(v.get(1),n):this.f_0(s,n),"EMA"===a?_=r.Std.ema(f,l,this._context):"WMA"===a?_=r.Std.wma(f,l,this._context):"SMA"===a&&(_=r.Std.sma(f,l,this._context)),[i,p,g,_]}}},{name:"ZigZag",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:2,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:5,in_1:10}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",target:"plot_0",type:"dataoffset"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Zig Zag",shortDescription:"ZigZag",is_price_study:!0,classId:"ScriptWithDataOffset",inputs:[{id:"in_0",name:"deviation",defval:5,type:"float",min:.001,max:100},{id:"in_1",name:"depth",defval:10,type:"integer",min:2,max:1e3}],id:"ZigZag@tv-basicstudies-1",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=i/100,o=Math.ceil(s/2);return[r.Std.zigzag(n,o,this._context),r.Std.zigzagbars(n,o,this._context)]}}},{name:"Sessions",metainfo:{_metainfoVersion:52,defaults:{graphics:{vertlines:{sessBreaks:{color:"#4985e7",style:2,visible:!1,width:1}},backgrounds:{preMarket:{color:"#FF9800",transparency:92,visible:!0},postMarket:{color:"#2196F3",transparency:92,visible:!0}}},linkedToSeries:!0},description:"Sessions",graphics:{vertlines:{sessBreaks:{name:"Session Break",halign:"left"}},backgrounds:{preMarket:{name:"Pre market"},postMarket:{name:"Post market"}}},id:"Sessions@tv-basicstudies-1",inputs:[],is_hidden_study:!0,is_price_study:!0,name:"Sessions@tv-basicstudies",palettes:{},plots:[],shortDescription:"Sessions",format:{type:"inherit"}},constructor:function(){function e(e,t){return{id:e,index:e,extendBottom:!0,extendTop:!0}}function t(e){return{id:e.start,start:e.start,stop:e.stop}}this.init=function(){this._times=[]},this._getVerticalLineData=function(t){return r.Std.selectSessionBreaks(t,this._times).map(e)},this._getPreAndPostMarketBackgroundsData=function(e){const i=r.Std.selectPreAndPostMarketTimes(e,this._times);return{preMarket:i.preMarket.map(t),postMarket:i.postMarket.map(t)}},this.main=function(e,t){if(r.Std.isdwm(e))return null;var i=r.Std.time(e);if(isNaN(i))return null;var s=this._times.length;if(0!==s&&this._times[s-1]===i||this._times.push(i),!e.symbol.isLastBar||!e.symbol.isNewBar)return null;var n=this._getVerticalLineData(e),o=this._getPreAndPostMarketBackgroundsData(e);return 0===n.length&&0===o.preMarket.length&&0===o.postMarket?null:{nonseries:!0,type:"study_graphics",data:{graphicsCmds:{create:{vertlines:[{styleId:"sessBreaks",data:n}],backgrounds:[{styleId:"preMarket",data:o.preMarket},{styleId:"postMarket",data:o.postMarket}]},erase:[{action:"all"}]}}}}}},{name:"SuperTrend",metainfo:{_metainfoVersion:52, -isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:3,plottype:0,trackPrice:!1,transparency:35,visible:!0,color:"#000080"},plot_2:{linestyle:0,linewidth:3,plottype:"shape_arrow_up",trackPrice:!1,location:"BelowBar",transparency:35,visible:!0,color:"#00FF00"},plot_3:{linestyle:0,linewidth:3,plottype:"shape_arrow_down",trackPrice:!1,location:"AboveBar",transparency:35,visible:!0,color:"#FF0000"}},palettes:{palette_0:{colors:{0:{color:"#008000",width:3,style:0},1:{color:"#800000",width:3,style:0}}}},inputs:{in_0:10,in_1:3}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",palette:"palette_0",target:"plot_0",type:"colorer"},{id:"plot_2",type:"shapes"},{id:"plot_3",type:"shapes"}],styles:{plot_0:{title:"SuperTrend",histogramBase:0,joinPoints:!1,isHidden:!1},plot_2:{title:"Up Arrow",histogramBase:0,joinPoints:!1,isHidden:!1},plot_3:{title:"Down Arrow",histogramBase:0,joinPoints:!1,isHidden:!1}},description:"SuperTrend",shortDescription:"SuperTrend",is_price_study:!0,palettes:{palette_0:{colors:{0:{name:"Color 0"},1:{name:"Color 1"}},valToIndex:{0:0,1:1}}},inputs:[{id:"in_0",name:"Length",defval:10,type:"integer",min:1,max:100},{id:"in_1",name:"Factor",defval:3,type:"float",min:1,max:100}],id:"SuperTrend@tv-basicstudies-1",scriptIdPart:"",name:"SuperTrend",isCustomIndicator:!0,format:{type:"inherit"}},constructor:function(){this.main=function(e,t){var i=t(0),s=t(1),[n,o]=r.Std.supertrend(s,i,e),a=e.new_var(o).get(1);return[n,-1===o?0:1,-1===o&&a!==o?1:NaN,1===o&&a!==o?1:NaN]}}},n,o,a,l,c,h,d,u])},81337:(e,t,i)=>{"use strict";i.d(t,{Std:()=>d});var s=i(60156),r=i(41249);function n(e,t){return null!==t&&t.to>e&&e>=t.from}class o{constructor(e,t,i){this._timezone=e,this._preMarketSessionSpec=t,this._postMarketSessionSpec=i}getPreAndPostMarketTimes(e){if(0===e.length)return{preMarket:[],postMarket:[]};const t=[],i=[];let s=null,n=null,o=e[0],a=(0,r.utc_to_cal)(this._timezone,o);this._isInPreMarketSession(a)&&(n=o),this._isInPostMarketSession(a)&&(s=o);for(let l=1;le?1:0,d={};function u(e,t,i,s,r){let n=r,o=0;if(isNaN(e.get(t-1)))return{index:NaN,value:NaN};for(let i=0;ie.symbol.index+1, -d.nz=(e,t=0)=>isFinite(e)?e:t,d.na=function(e){return 0===arguments.length?NaN:isNaN(e)?1:0},d.isZero=e=>Math.abs(e)<=1e-10?1:0,d.toBool=e=>isFinite(e)&&!d.isZero(e),d.eq=(e,t)=>d.isZero(e-t),d.neq=(e,t)=>h(!d.eq(e,t)),d.ge=(e,t)=>h(d.isZero(e-t)||e>t),d.gt=(e,t)=>h(!d.isZero(e-t)&&e>t),d.lt=(e,t)=>h(!d.isZero(e-t)&&eh(d.isZero(e-t)||eisNaN(e)||isNaN(t)?NaN:d.isZero(e)||d.isZero(t)?0:1,d.or=(e,t)=>isNaN(e)||isNaN(t)?NaN:d.isZero(e)&&d.isZero(t)?0:1,d.not=e=>isNaN(e)?NaN:d.isZero(e)?1:0,d.eps=()=>c,d.greaterOrEqual=(e,t,i)=>t-e<(i||c),d.lessOrEqual=(e,t,i)=>e-t<(i||c),d.equal=(e,t,i)=>Math.abs(e-t)<(i||c),d.greater=(e,t,i)=>e-t>(i||c),d.less=(e,t,i)=>t-e>(i||c),d.compare=(e,t,i)=>d.equal(e,t,i)?0:d.greater(e,t,i)?1:-1,d.max=Math.max,d.min=Math.min,d.pow=Math.pow,d.abs=Math.abs,d.log=Math.log,d.log10=e=>Math.log(e)/Math.LN10,d.sqrt=Math.sqrt,d.sign=e=>isNaN(e)?NaN:d.isZero(e)?0:e>0?1:-1,d.exp=Math.exp,d.sin=Math.sin,d.cos=Math.cos,d.tan=Math.tan,d.asin=Math.asin,d.acos=Math.acos,d.atan=Math.atan,d.floor=Math.floor,d.ceil=Math.ceil,d.round=Math.round,d.avg=(...e)=>{if(2===e.length)return(e[0]+e[1])/2;let t=0;for(let i=0;ie.symbol.open,d.high=e=>e.symbol.high,d.low=e=>e.symbol.low,d.close=e=>e.symbol.close,d.hl2=e=>(e.symbol.high+e.symbol.low)/2,d.hlc3=e=>(e.symbol.high+e.symbol.low+e.symbol.close)/3,d.ohlc4=e=>(e.symbol.open+e.symbol.high+e.symbol.low+e.symbol.close)/4,d.volume=e=>e.symbol.volume,d.updatetime=e=>e.symbol.updatetime,d.time=e=>e.symbol.bartime(),d.period=e=>e.symbol.period,d.tickerid=e=>e.symbol.tickerid,d.currencyCode=e=>e.symbol.currencyCode,d.unitId=e=>e.symbol.unitId,d.ticker=e=>e.symbol.ticker,d.interval=e=>e.symbol.interval,d.isdwm=e=>e.symbol.isdwm(),d.isintraday=e=>!e.symbol.isdwm(),d.isdaily=e=>"D"===e.symbol.resolution,d.isweekly=e=>"W"===e.symbol.resolution,d.ismonthly=e=>"M"===e.symbol.resolution,d.year=(e,t)=>d.timepart(e.symbol,r.YEAR,t),d.month=(e,t)=>d.timepart(e.symbol,r.MONTH,t),d.weekofyear=(e,t)=>d.timepart(e.symbol,r.WEEK_OF_YEAR,t),d.dayofmonth=(e,t)=>d.timepart(e.symbol,r.DAY_OF_MONTH,t),d.dayofweek=(e,t)=>d.timepart(e.symbol,r.DAY_OF_WEEK,t),d.hour=(e,t)=>d.timepart(e.symbol,r.HOUR_OF_DAY,t),d.minute=(e,t)=>d.timepart(e.symbol,r.MINUTE,t),d.second=(e,t)=>d.timepart(e.symbol,r.SECOND,t),d.add_days_considering_dst=(e,t,i)=>r.add_days_considering_dst(r.get_timezone(e),t,i),d.add_years_considering_dst=(e,t,i)=>r.add_years_considering_dst(r.get_timezone(e),t,i),d.selectSessionBreaks=(e,t)=>{if(d.isdwm(e)||void 0===e.symbol.session.timezone)return[];const i=(0,s.newBarBuilder)(e.symbol.period,e.symbol.session,null),r=[],n=t.length;if(i.moveTo(t[n-1]),1===n&&i.startOfBar(0)===t[0])r.push(t[0]);else{for(let e=n-2;e>=0;--e){const s=t[e];if(s>=i.startOfBar(0))continue;i.moveTo(s);const n=t[e+1];r.push(n)}r.reverse()}return r},d.selectPreAndPostMarketTimes=(e,t)=>{if(d.isdwm(e)||void 0===e.symbol.session.timezone)return{preMarket:[],postMarket:[]} -;if(null==e.symbol.preMarketSubsession||null==e.symbol.postMarketSubsession)return{preMarket:[],postMarket:[]};return new o(e.symbol.session.timezone,e.symbol.preMarketSubsession,e.symbol.postMarketSubsession).getPreAndPostMarketTimes(t)},d.iff=(e,t,i)=>d.not(e)?i:t,d.rising=(e,t)=>{for(let i=1;ie.get(0))return 0;return 1},d.falling=(e,t)=>{for(let i=1;i{const s=r.utc_to_cal(e.session.timezone,i||e.bartime());return r.get_part(s,t)},d.rsi=(e,t)=>d.isZero(t)?100:d.isZero(e)?0:100-100/(1+e/t),d.sum=(e,t,i)=>{const s=i.new_var(),r=d.nz(e.get())+d.nz(s.get(1))-d.nz(e.get(t));return s.set(r),r},d.sma=(e,t,i)=>{const s=d.sum(e,t,i);return d.na(e.get(t-1))?NaN:s/t},d.smma=(e,t,i)=>{const s=i.new_var(e),r=d.sma(s,t,i),n=i.new_var(),o=(n.get(1)*(t-1)+e)/t;return n.set(d.na(n.get(1))?r:o),n.get(0)},d.rma=(e,t,i)=>{const s=d.sum(e,t,i),r=t-1,n=e.get(r),o=i.new_var(),a=o.get(1),l=e.get(),c=d.na(n)?NaN:d.na(a)?s/t:(l+a*r)/t;return o.set(c),c},d.fixnan=(e,t)=>{const i=t.new_var();return isNaN(e)?i.get(1):(i.set(e),e)},d.tr=(e,t)=>{let i=t.new_var(d.close(t)).get(1);return e&&isNaN(i)&&(i=d.close(t)),d.max(d.max(d.high(t)-d.low(t),d.abs(d.high(t)-i)),d.abs(d.low(t)-i))},d.atr=(e,t)=>{const i=t.new_var(d.tr(void 0,t));return d.rma(i,e,t)},d.ema=(e,t,i)=>{const s=d.sum(e,t,i),r=i.new_var(),n=e.get(0),o=e.get(t-1),a=r.get(1),l=d.na(o)?NaN:d.na(a)?s/t:2*(n-a)/(t+1)+a;return r.set(l),l},d.wma=(e,t,i)=>{let s=0;for(let i=t=Math.round(t);i>=0;i--){s+=(t-i)*e.get(i)}return 2*s/(t*(t+1))},d.vwma=(e,t,i)=>{const s=i.new_var(d.volume(i)),r=i.new_var(e.get(0)*d.volume(i));return d.sma(r,t,i)/d.sma(s,t,i)},d.swma=(e,t)=>(e.get(0)+2*e.get(1)+2*e.get(2)+e.get(3))/6,d.supertrend=(e,t,i)=>{const s=d.atr(t,i),r=i.new_var(s).get(1),n=d.hl2(i);let o=n+s*e,a=n-s*e;const l=d.close(i),c=i.new_var(l).get(1),h=i.new_var(),u=d.nz(h.get(1)),p=i.new_var(),_=d.nz(p.get(1));a=d.gt(a,u)||d.lt(c,u)?a:u,h.set(a),o=d.lt(o,_)||d.gt(c,_)?o:_,p.set(o);let m=d.na();const g=i.new_var(),f=g.get(1);m=d.na(r)?1:f===_?l>o?-1:1:l-u(e,t,0,((e,t)=>d.lt(e,t)),Number.MAX_VALUE).index,d.lowest=(e,t,i)=>u(e,t,0,((e,t)=>d.lt(e,t)),Number.MAX_VALUE).value,d.highestbars=(e,t,i)=>-u(e,t,0,((e,t)=>d.gt(e,t)),Number.MIN_VALUE).index,d.highest=(e,t,i)=>u(e,t,0,((e,t)=>d.gt(e,t)),Number.MIN_VALUE).value,d.cum=(e,t)=>{const i=t.new_var(),s=d.nz(i.get(1))+e;return i.set(s),s},d.accdist=e=>{const t=d.high(e),i=d.low(e),s=d.close(e),r=d.volume(e);return d.cum(s===t&&s===i||t===i?0:r*(2*s-i-t)/(t-i),e)},d.correlation=(e,t,i,s)=>{const r=d.sma(e,i,s),n=d.sma(t,i,s),o=s.new_var(e.get()*t.get());return(d.sma(o,i,s)-r*n)/Math.sqrt(d.variance2(e,r,i)*d.variance2(t,n,i))},d.stoch=(e,t,i,s,r)=>{const n=d.highest(t,s,r),o=d.lowest(i,s,r);return d.fixnan(100*(e.get()-o)/(n-o),r)},d.tsi=(e,t,i,s)=>{const r=s.new_var(d.change(e)),n=s.new_var(d.abs(d.change(e))),o=s.new_var(d.ema(r,i,s)),a=s.new_var(d.ema(n,i,s));return d.ema(o,t,s)/d.ema(a,t,s) -},d.cross=(e,t,i)=>{if(isNaN(e)||isNaN(t))return!1;const s=i.new_var((r=e-t)<0?-1:0===r?0:1);var r;return!isNaN(s.get(1))&&s.get(1)!==s.get()},d.linreg=(e,t,i)=>{let s=0,r=0,n=0,o=0;for(let i=0;i{const r=s.new_var(),n=s.new_var(),o=s.new_var(),a=d.high(s),l=d.low(s),c=d.close(s),h=s.new_var(a),u=s.new_var(l),p=s.new_var(c),_=s.new_var();let m=_.get(1),g=n.get(1),f=o.get(1);n.set(g),o.set(f);let v=!1;const S=u.get(1),y=u.get(2),b=h.get(1),w=h.get(2),P=p.get(),C=p.get(1);2===d.n(s)&&(d.greater(P,C)?(r.set(1),o.set(h.get()),m=S,f=h.get()):(r.set(-1),o.set(u.get()),m=b,f=u.get()),v=!0,n.set(e),g=e);let x=m+g*(f-m);return 1===r.get()?d.greater(x,u.get())&&(v=!0,r.set(-1),x=Math.max(h.get(),o.get()),o.set(u.get()),n.set(e)):d.less(x,h.get())&&(v=!0,r.set(1),x=Math.min(u.get(),o.get()),o.set(h.get()),n.set(e)),v||(1===r.get()?d.greater(h.get(),o.get())&&(o.set(h.get()),n.set(Math.min(n.get()+t,i))):d.less(u.get(),o.get())&&(o.set(u.get()),n.set(Math.min(n.get()+t,i)))),1===r.get()?(x=Math.min(x,S),d.n(s)>2&&(x=Math.min(x,y))):(x=Math.max(x,b),d.n(s)>2&&(x=Math.max(x,w))),_.set(x),x},d.alma=(e,t,i,s)=>{const r=Math.floor(i*(t-1)),n=t/s*(t/s),o=[];let a=0;for(let e=0;ee.get()-e.get(1),d.roc=(e,t)=>{const i=e.get(t);return 100*(e.get()-i)/i},d.dev=(e,t,i)=>{const s=d.sma(e,t,i);return d.dev2(e,t,s)},d.dev2=(e,t,i)=>{let s=0;for(let r=0;r{const s=d.variance(e,t,i);return d.sqrt(s)},d.variance=(e,t,i)=>{const s=d.sma(e,t,i);return d.variance2(e,s,t)},d.variance2=(e,t,i)=>{let s=0;for(let r=0;r{if(d.na(e.get(t-1)))return NaN;let i=0;const s=e.get();for(let r=1;r{if(void 0===e.symbol.session.timezone)return()=>!1;const t=(0,s.newBarBuilder)(e.symbol.period,e.symbol.session,null);return e=>t.indexOfBar(e)===a.SessionStage.POST_SESSION&&(t.moveTo(e),!0)},d.error=e=>{throw new l(e)},d.dmi=(e,t,i)=>{const s=i.new_var(d.high(i)),r=i.new_var(d.low(i)),n=d.change(s),o=-d.change(r),a=i.new_var(d.na(n)||d.na(o)?d.na():d.and(d.gt(n,o),d.gt(n,0))?n:0),l=i.new_var(d.na(o)?d.na():d.and(d.gt(o,n),d.gt(o,0))?o:0),c=d.atr(e,i),h=d.fixnan(100*d.rma(a,e,i)/c,i),u=d.fixnan(100*d.rma(l,e,i)/c,i);let p=h+u;d.isZero(p)&&(p+=1);const _=Math.abs(h-u)/p*100,m=i.new_var(_),g=d.rma(m,t,i),f=i.new_var(g);return[h,u,_,g,(f.get(0)+f.get(e-1))/2]},d.zigzag=(e,t,i)=>new g(e,t,i).lastPrice(),d.zigzagbars=(e,t,i)=>{const s=new g(e,t,i);return-1===s.lastIndex()?NaN:s.lastIndex()-d.n(i)};const p=0,_=1;class m{constructor(e,t,i,s,r){this._areaRight=e,this._areaLeft=t,this._pivotType=i,this._series=s,this._currentIndex=r.new_var(0), -this._currentValue=r.new_var(NaN),this._pivotIndex=r.new_var(-1),this._index=d.n(r),this._isNewBar=r.symbol.isNewBar;const n=this._currentIndex.get(1),o=this._currentValue.get(1),a=this._pivotIndex.get(1);this._index>1&&(this._currentIndex.set(n),this._currentValue.set(o),this._pivotIndex.set(a))}isPivotFound(){return-1!==this._pivotIndex.get()}pivotIndex(){return this._pivotIndex.get()}currentValue(){return this._currentValue.get()}pivotType(){return this._pivotType}reset(){this._currentValue.set(NaN),this._currentIndex.set(0),this._pivotIndex.set(-1)}isRightSideOk(e){return e-this._currentIndex.get()===this._areaRight}isViolate(e,t){if(e<1||isNaN(this._currentValue.get()))return!0;const i=this._series.get(this._index-e);return!!isNaN(i)||(i===this._currentValue.get()?t:this._pivotType===_?i>this._currentValue.get():ithis._areaRight}update(){if(this._isNewBar&&this.isPivotFound()&&this.reset(),this.processPoint(this._index),this.isRightSideOk(this._index)){if(-1===this._pivotIndex.get()){let e=!0;for(let t=0;t1&&this.addPivot(n,o,a),this.processPivot(this._pivotHigh),this.processPivot(this._pivotLow)}addPivot(e,t,i){this._lastIndex.set(e),this._lastVal.set(t),this._lastType.set(i)}updatePivot(e,t){this._lastIndex.set(e),this._lastVal.set(t)}lastPrice(){return this._lastVal.get()}lastIndex(){return this._lastIndex.get()}addPoint(e,t,i){if(isNaN(this._lastVal.get()))return void this.addPivot(e,t,i);const s=this._lastVal.get();if(this._lastType.get()===i){return void((i===_?t>s:tthis._deviation&&this.addPivot(e,t,i)}processPivot(e){e.update(),this._isBarClosed&&e.isPivotFound()&&this.addPoint(e.pivotIndex(),e.currentValue(),e.pivotType())}}},53130:(e,t,i)=>{"use strict";i.d(t,{anchoredVWAPStudyItem:()=>n});var s=i(50151),r=i(81337);const n={name:"Anchored VWAP",metainfo:{_metainfoVersion:51,description:"Anchored VWAP",shortDescription:"Anchored VWAP",format:{type:"inherit"},id:"AnchoredVWAP@tv-basicstudies-1",is_hidden_study:!0,is_price_study:!0,defaults:{inputs:{start_time:0,source:"hlc3"},styles:{VWAP:{color:"#1e88e5",linestyle:0, -linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,display:15}}},inputs:[{defval:0,id:"start_time",isHidden:!0,max:253370764800,min:-253370764800,name:"Start time",type:"time"},{defval:"hlc3",id:"source",name:"Source",options:["open","high","low","close","hl2","hlc3","ohlc4"],type:"source"}],plots:[{id:"VWAP",type:"line"}],styles:{VWAP:{histogramBase:0,title:"VWAP"}}},constructor:class{constructor(){this._isNewSession=null,this._firstBarTime=0}init(e,t){this._firstBarTime=t(0),this._isNewSession=null}main(e,t,i){if(void 0===i)return[NaN];(0,s.assert)(e.symbol.time===i.time);const n=i.time;if(n&&n{"use strict";i.d(t,{pivotPointsStandardStudyItem:()=>d});var s=i(36274),r=i(47609),n=i(81337);class o{constructor(){this.p=NaN,this.r1=NaN,this.s1=NaN,this.r2=NaN,this.s2=NaN,this.r3=NaN,this.s3=NaN,this.r4=NaN,this.s4=NaN,this.r5=NaN,this.s5=NaN,this.startIndex__t=NaN,this.endIndex__t=NaN}}class a{constructor(){this.pivots=[]}}function l(e,t){e.setUTCMonth(e.getUTCMonth()+t)}function c(e,t){if(n.Std.ismonthly(e)){let i=new Date(t);return i.getUTCDay()=1&&t.multiplier()<=15?"1D":"1W";case s.ResolutionKind.Seconds:case s.ResolutionKind.Ticks:return"1D"}throw new Error("Unexpected resolution type: "+e.symbol.resolution)}(e);case"Daily":return"1D";case"Weekly":return"1W";case"Monthly":return"1M";case"Yearly":return"12M";default:throw new Error("No such pivTimeFrame: "+t)}}const d={name:"Pivot Points Standard",metainfo:{_metainfoVersion:44,defaults:{inputs:{kind:"Traditional",lookBack:15,pivTimeFrame:"Auto",showHistoricalPivots:!0},precision:"4"},description:"Pivot Points Standard",id:"PivotPointsStandard@tv-basicstudies-80",inputs:[{defval:"Traditional",id:"kind",name:"Type",options:["Traditional","Fibonacci","Woodie","Classic","DeMark","Camarilla","Floor"],type:"text"},{defval:!0,id:"showHistoricalPivots",name:"Show historical pivots",type:"bool"},{defval:"Auto",id:"pivTimeFrame",name:"Pivots Timeframe",options:["Auto","Daily","Weekly","Monthly","Yearly"],type:"text"},{ -defval:15,id:"lookBack",max:5e3,min:1,name:"Number of Pivots Back",type:"integer"}],is_price_study:!0,linkedToSeries:!0,shortDescription:"Pivots",format:{type:"price",precision:4}},constructor:class{constructor(){this._secondaryRes="1D",this._firstMainSeriesBarTime=NaN}init(e,t){const i=t(0),s=t(1),o=t(2),l=t(3);this._data=new a,this._firstMainSeriesBarTime=NaN,this._kindPP=function(e){switch(e){case"Traditional":return 0;case"Fibonacci":return 1;case"Woodie":return 2;case"Classic":return 3;case"DeMark":return 4;case"Camarilla":return 5;case"Floor":return 6;default:throw new Error("Unknown kind "+e)}}(i),this._showHistoricalPivots=s,this._historicalPivotsToKeep=l,this._pivTimeFrame=o,this._isValidResolution=function(e,t){return!(n.Std.isdaily(e)&&"Daily"===t||n.Std.isweekly(e)&&("Daily"===t||"Weekly"===t)||n.Std.ismonthly(e)&&("Daily"===t||"Weekly"===t||"Monthly"===t))}(e,this._pivTimeFrame),this._isValidResolution||n.Std.error("You cannot see this pivot timeframe on this resolution"),this._isValidResolution&&(this._secondaryRes=h(e,this._pivTimeFrame),void 0!==e.symbol.info&&(0,r.findSuitableResolutionToBuildFrom)(this._secondaryRes,e.symbol.info).error&&(this._isValidResolution=!1,n.Std.error(`Resolution ${this._secondaryRes} is not supported for this symbol`))),e.new_sym(e.symbol.tickerid,this._secondaryRes)}main(e,t,i){if(!this._isValidResolution)return null;if(e.is_main_symbol(i))return isNaN(this._firstMainSeriesBarTime)&&(this._firstMainSeriesBarTime=e.symbol.time,this._removeUnusedPivots()),e.symbol.isLastBar&&e.symbol.isNewBar?this._createResponse():null;e.select_sym(1);const s=e.new_var(n.Std.open(e)),r=e.new_var(n.Std.high(e)),a=e.new_var(n.Std.low(e)),l=e.new_var(n.Std.close(e)),h=e.new_var(n.Std.time(e)),d=this._data,u=s.get(0),p=h.get(0),_=s.get(1),m=r.get(1),g=a.get(1),f=l.get(1),v=e.symbol.isLastBar;if(0!==d.pivots.length&&e.symbol.isNewBar){const e=d.pivots[d.pivots.length-1];e.endIndex__t!==p&&(e.endIndex__t=p)}if(0===e.symbol.index||!e.symbol.isNewBar)return e.select_sym(0),null;const S=function(e,t,i,s,r,a,l,c){const h=new o;let d=NaN;const u=i-s;switch(c){case 0:d=(i+s+r)/3,h.p=d,h.r1=2*d-s,h.s1=2*d-i,h.r2=d+(i-s),h.s2=d-(i-s),h.r3=2*d+(i-2*s),h.s3=2*d-(2*i-s),h.r4=3*d+(i-3*s),h.s4=3*d-(3*i-s),h.r5=4*d+(i-4*s),h.s5=4*d-(4*i-s);break;case 1:d=(i+s+r)/3,h.p=d,h.r1=d+.382*u,h.s1=d-.382*u,h.r2=d+.618*u,h.s2=d-.618*u,h.r3=d+u,h.s3=d-u;break;case 2:d=(i+s+2*e)/4,h.p=d,h.r1=2*d-s,h.s1=2*d-i,h.r2=d+u,h.s2=d-u,h.r3=i+2*(d-s),h.s3=s-2*(i-d),h.r4=h.r3+u,h.s4=h.s3-u;break;case 3:d=(i+s+r)/3,h.p=d,h.r1=2*d-s,h.s1=2*d-i,h.r2=d+u,h.s2=d-u,h.r3=d+2*u,h.s3=d-2*u,h.r4=d+3*u,h.s4=d-3*u;break;case 4:let o=NaN;o=n.Std.equal(t,r)?i+s+2*r:n.Std.greater(r,t)?2*i+s+r:2*s+i+r,d=o/4,h.p=d,h.r1=o/2-s,h.s1=o/2-i;break;case 5:d=(i+s+r)/3,h.p=d,h.r1=r+1.1*u/12,h.s1=r-1.1*u/12,h.r2=r+1.1*u/6,h.s2=r-1.1*u/6,h.r3=r+1.1*u/4,h.s3=r-1.1*u/4,h.r4=r+1.1*u/2,h.s4=r-1.1*u/2;break;case 6:d=(i+s+r)/3,h.p=d,h.r1=2*d-s,h.s1=2*d-i,h.r2=d+(i-s),h.s2=d-(i-s),h.r3=d-h.s1+h.r2,h.s3=2*d-(2*i-s),h.r4=3*d+(i-3*s),h.s4=3*d-(3*i-s),h.r5=4*d+(i-4*s), -h.s5=4*d-(4*i-s);break;default:throw new Error("Unknown kind")}return h.startIndex__t=a,h.endIndex__t=l,h}(u,_,m,g,f,p,c(e,p),this._kindPP);return e.select_sym(0),this._showHistoricalPivots||(d.pivots=[]),d.pivots.push(S),d.pivots.length>this._historicalPivotsToKeep&&d.pivots.shift(),v?this._createResponse():null}_createResponse(){return 0===this._data.pivots.length?null:{nonseries:!0,type:"non_series_data",data:{data:this._data}}}_removeUnusedPivots(){const e=Math.max(this._data.pivots.findIndex((e=>e.startIndex__t>this._firstMainSeriesBarTime))-1,0);e>0&&this._data.pivots.splice(0,e)}}}},81821:(e,t,i)=>{"use strict";i.d(t,{ratioStudyItem:()=>n});var s=i(87302);class r extends s.SpreadRatioBase{_doCalculation(e,t,i,s){return e*t/(i*s)}}const n={name:"Ratio",metainfo:{_metainfoVersion:15,defaults:s.spreadRatioDefaults,plots:s.spreadRatioPlots,styles:s.spreadRatioStyles,description:"Ratio",shortDescription:"Ratio",is_price_study:!1,inputs:s.spreadRatioInputs,id:"Ratio@tv-basicstudies-1",format:{type:"price",precision:2}},constructor:r}},65097:(e,t,i)=>{"use strict";i.d(t,{regressionTrendStudyItem:()=>n});var s=i(81337);function r(e,t,i){const r={slope:NaN,average:NaN,intercept:NaN,stdDev:NaN,upDev:NaN,downDev:NaN,pearsons:NaN};return 0===e.length||(function(e,t){let i=0,s=0,r=0,n=0;for(let t=0;tn&&(n=u),u=d-i[s],u>o&&(o=u),u=e[s];const _=u-r.average,m=d-p;u-=d,a+=u*u,l+=_*_,c+=m*m,h+=_*m,d+=r.slope}r.stdDev=Math.sqrt(a/(0===u?1:u)),r.pearsons=s.Std.isZero(l)||s.Std.isZero(c)?0:h/Math.sqrt(l*c),r.upDev=n,r.downDev=o}(e,t,i,r)),r}const n={name:"Regression Trend",metainfo:{_metainfoVersion:51,description:"Regression Trend",format:{type:"inherit"},id:"RegressionTrend@tv-basicstudies-144",is_hidden_study:!0,is_price_study:!0,shortDescription:"Reg Trend",defaults:{inputs:{"first bar time":0,"last bar time":0,"lower diviation":-2,source:"close","upper diviation":2,"use lower diviation":!0,"use upper diviation":!0},styles:{}},inputs:[{defval:2,id:"upper diviation",max:500,min:-500,name:"Upper Deviation",type:"float"},{defval:-2,id:"lower diviation",max:500,min:-500,name:"Lower Deviation",type:"float"},{defval:!0,id:"use upper diviation",name:"Use Upper Deviation",type:"bool"},{defval:!0,id:"use lower diviation",name:"Use Lower Deviation",type:"bool"},{defval:0,id:"first bar time",isHidden:!0,max:253370764800,min:-253370764800,name:"First bar time",type:"time"},{defval:0,id:"last bar time",isHidden:!0,max:253370764800,min:-253370764800,name:"Last bar time",type:"time"},{defval:"close",id:"source",name:"Source",options:["open","high","low","close","hl2","hlc3","ohlc4"],type:"source"}],plots:[]},constructor:class{constructor(){this._resultSent=!1}init(e,t){this._resultSent=!1,this._data={baseLine:{startPrice:NaN, -endPrice:NaN},upLine:{startPrice:NaN,endPrice:NaN},downLine:{startPrice:NaN,endPrice:NaN},pearsons:NaN,startIndex__t:NaN,endIndex__t:NaN}}main(e,t){const i=t(6),n=e.new_unlimited_var(s.Std.time(e)),o=e.new_unlimited_var(s.Std.high(e)),a=e.new_unlimited_var(s.Std.low(e)),l=e.new_unlimited_var(s.Std[i](e));if(!e.symbol.isLastBar)return null;if(this._resultSent)return null;const c=t(0),h=t(1),d=t(2),u=t(3),p=t(4),_=t(5),m=n.indexOf(p),g=n.indexOf(_),f=[],v=[],S=[],y=[];for(let e=m;e>=g;--e)f.push(n.get(e)),v.push(o.get(e)),S.push(a.get(e)),y.push(l.get(e));return this._updateData(f,d,c,u,h,p,_,r(y,v,S)),this._resultSent=!0,{type:"non_series_data",nonseries:!0,data:{data:this._data}}}_updateData(e,t,i,s,r,n,o,a){const l=e.length-1;this._data.baseLine.startPrice=a.intercept,this._data.baseLine.endPrice=a.intercept+a.slope*l;const c=a.intercept+(t?a.stdDev*i:a.upDev);this._data.upLine.startPrice=c,this._data.upLine.endPrice=c+a.slope*l;const h=a.intercept+(s?a.stdDev*r:-a.downDev);this._data.downLine.startPrice=h,this._data.downLine.endPrice=h+a.slope*l,this._data.pearsons=a.pearsons,this._data.startIndex__t=n,this._data.endIndex__t=o}}}},87302:(e,t,i)=>{"use strict";i.d(t,{SpreadRatioBase:()=>r,spreadRatioDefaults:()=>n,spreadRatioInputs:()=>o,spreadRatioPlots:()=>a,spreadRatioStyles:()=>l});var s=i(81337);class r{init(e,t){e.new_sym(t(1),s.Std.period(e)),this._source=t(0),this._scaleFactor1=1,this._scaleFactor2=1}main(e,t){const i=e.symbol.time,r=s.Std[this._source](e);e.select_sym(1);const n=s.Std[this._source](e),o=e.new_unlimited_var(n),a=e.new_unlimited_var(e.symbol.time);if(e.select_sym(0),isNaN(i))return null;let l=a.indexOf(i);-1!==l&&a.get(l)!==i&&(l=-1);const c=l<0?NaN:o.get(l);return[this._doCalculation(this._scaleFactor1,r,this._scaleFactor2,c)]}}const n={styles:{plot1:{linestyle:0,linewidth:2,plottype:0,trackPrice:!1,transparency:35,color:"#800080",display:15}},precision:2,inputs:{source:"close",symbol2:""}},o=[{defval:"close",id:"source",name:"Source",options:["open","high","low","close","hl2","hlc3","ohlc4"],type:"text"},{id:"symbol2",name:"Symbol",type:"symbol",confirm:!0}],a=[{id:"plot1",type:"line"}],l={plot1:{title:"Plot",histogramBase:0}}},39944:(e,t,i)=>{"use strict";i.d(t,{spreadStudyItem:()=>n});var s=i(87302);class r extends s.SpreadRatioBase{_doCalculation(e,t,i,s){return e*t-i*s}}const n={name:"Spread",metainfo:{_metainfoVersion:15,defaults:s.spreadRatioDefaults,plots:s.spreadRatioPlots,styles:s.spreadRatioStyles,description:"Spread",shortDescription:"Spread",is_price_study:!1,inputs:s.spreadRatioInputs,id:"Spread@tv-basicstudies-1",format:{type:"price",precision:2}},constructor:r}},56437:(e,t,i)=>{"use strict";i.d(t,{VbPCheckHaveVolumeExpr:()=>r});var s=i(81337);class r{constructor(e){this._haveAnyVolume=!1,this._isDisabled=!1,this._seriesGetter=e}update(e,t){if(this._haveAnyVolume||this._isDisabled)return;const i=this._seriesGetter.volume().get(e);0!==i&&Number.isFinite(i)&&(this._haveAnyVolume=!0), -t&&(this._haveAnyVolume||s.Std.error("The data vendor doesn't provide volume data for this symbol."),this._isDisabled=!0)}}},89529:(e,t,i)=>{"use strict";i.d(t,{VolumeByPriceExpr:()=>_});var s=i(50151),r=i(37160),n=i(36274),o=i(29779);class a extends o.GraphicsObj{constructor(e,t,i,r,n,o){super(e),(0,s.assert)(t({index:e.index,offset:e.offset,level:e.level})))}}}class u extends o.GraphicsObj{constructor(e,t,i,s,r=!1,n=!1){super(e), -this._endIndex=this._mixinJSONObject.createTimeField(i,"endIndex"),this._extendLeft=this._mixinJSONObject.createField(r,"extendLeft"),this._extendRight=this._mixinJSONObject.createField(n,"extendRight"),this._level=this._mixinJSONObject.createDoubleField(s,"level"),this._startIndex=this._mixinJSONObject.createTimeField(t,"startIndex")}isNaN(){return super.isNaN()||Number.isNaN(this._level.get())||this._startIndex.get()<0||this._endIndex.get()<0||this._startIndex.get()===this._endIndex.get()&&!this._extendLeft.get()&&!this._extendRight.get()}jsonName(){return"horizlines"}primitiveData(){return{id:this.id(),startIndex:this._startIndex.get(),endIndex:this._endIndex.get(),extendLeft:this._extendLeft.get(),extendRight:this._extendRight.get(),level:this._level.get()}}startIndex(){return this._startIndex.get()}setStartIndex(e){this._startIndex.set(e)&&this._processObjUpdate()}endIndex(){return this._endIndex.get()}setEndIndex(e){this._endIndex.set(e)&&this._processObjUpdate()}level(){return this._level.get()}setLevel(e){this._level.set(e)&&this._processObjUpdate()}isExtendLeft(){return this._extendLeft.get()}setExtendLeft(e){this._extendLeft.set(e)&&this._processObjUpdate()}extendLeft(){return this.isExtendLeft()}isExtendRight(){return this._extendRight.get()}setExtendRight(e){this._extendRight.set(e)&&this._processObjUpdate()}extendRight(){return this.isExtendRight()}}class p{constructor(){this._map=new Map}get(e){const t=this._innerMap(e.start);return t&&t.get(e.end)}set(e,t){this._innerMap(e.start,!0).set(e.end,t)}clear(){this._map.clear()}size(){let e=0;return this._map.forEach((t=>e+=t.size)),e}_innerMap(e,t){let i=this._map.get(e);return void 0===i&&t&&(i=new Map,this._map.set(e,i)),i}}class _{constructor(e,t,i,r,n,o,a,c,h,d,u,_,m,g,f){this._freezedBoxes=new l.GraphicsList,this._freezedHists=new l.GraphicsList,this._freezedPocs=new l.GraphicsList,this._freezedVAHists=new l.GraphicsList,this._currentHistsGr=new l.GraphicsList,this._currentVAHistsGr=new l.GraphicsList,this._currentHists=[],this._currentHistsMap=new p,this._currentBox=null,this._currentPoc=null,this._historyBarSet=[],this._prevRtBar=null,this._minPrice=Number.POSITIVE_INFINITY,this._maxPrice=Number.NEGATIVE_INFINITY,this._leftBoxTime=null,this._rightBoxTime=null,this._actualRightBoxTime=null,this._needRecalc=!1,this._largestHistItem=null,this._rowsLayout=null,this._currentVAStart=0,this._currentVAEnd=0,this._previousVAStart=0,this._previousVAEnd=0,this._idsGenerator=null,(0,s.assert)(1===e||2===e),this._numOfSubHists=e,this._outHists=r,this._outBoxLines=n,this._outPocLines=o,this._extendPocLeftRight=a,this._outVAHists=c,this._vaVolumePercent=h,this._rowsLayoutSupplier=d,this._outHists.addStable(this._freezedHists),this._outVAHists.addStable(this._freezedVAHists),this._maxHHistItems=u,this._layoutIsAutoselected=g,this._leftBoxTimeMutable=_,this._rightBoxTimeMutable=m,this._actualRightBoxTime=null!=f?f:m,this._ctx=t,this._seriesGetter=i}update(e){this._supplyRowsLayout(this._ctx),null===this._currentBox&&this._initCurrentBox(), -null===this._currentPoc&&this._initCurrentPoc();const t=this._timeScale().get(e);this._leftBoxTime=this._leftBoxTimeMutable,this._rightBoxTime=this._rightBoxTimeMutable,this._ctx.symbol.isLastBar&&!Number.isNaN(this._rightBoxTime)&&(this._rightBoxTime=Math.min(t+n.Interval.parse(this._ctx.symbol.interval+this._ctx.symbol.resolution).inMilliseconds(t)-1,this._rightBoxTime));const i=c.Std.greaterOrEqual(this._seriesClose().get(e),this._seriesOpen().get(e)),s={high:this._seriesHigh().get(e),low:this._seriesLow().get(e),volume:this._seriesVol().get(e),isUp:i,time:t};this._updateCurrentHistogram(s),this._currentHists.length>0&&(this._largestHistItem=this._getLargestHistItem(),this._updateCurrentPoc(),this._seriesGetter.developingPoc().set(this._currentPoc.level()),this._updateValueArea(),this._vaVolumePercent>0&&(this._seriesGetter.developingVAHigh().set(this._currentHists[this._currentVAEnd].priceHigh()),this._seriesGetter.developingVALow().set(this._currentHists[this._currentVAStart].priceLow()))),this._updateCurrentBox(),this._rebuildOutData()}setIdsGeneratorProxy(e){this._idsGenerator=e}nextGraphicsObjId(){return(0,s.ensureNotNull)(this._idsGenerator).nextGraphicsObjId()}pushEraseObjCmd(e,t){(0,s.ensureNotNull)(this._idsGenerator).pushEraseObjCmd(e,t)}popEraseCmds(){return(0,s.ensureNotNull)(this._idsGenerator).popEraseCmds()}_timeScale(){return this._seriesGetter.time()}_seriesLow(){return this._seriesGetter.low()}_seriesHigh(){return this._seriesGetter.high()}_seriesVol(){return this._seriesGetter.volume()}_seriesOpen(){return this._seriesGetter.open()}_seriesClose(){return this._seriesGetter.close()}_freezeCurrentHistogramAndCleanup(){null!==this._currentBox&&this._freezedBoxes.add(this._currentBox),c.Std.greater(this._getVolume(this._currentHists),0)&&(this._freezedHists.addAll(this._currentHistsGr),this._freezedVAHists.addAll(this._currentVAHistsGr),null!==this._currentPoc&&this._freezedPocs.add(this._currentPoc)),this._currentHists=[],this._currentHistsGr.clear(),this._currentHistsMap.clear(),this._initCurrentBox(),this._initCurrentPoc(),this._currentVAHistsGr.clear(),this._historyBarSet=[],this._minPrice=Number.POSITIVE_INFINITY,this._maxPrice=Number.NEGATIVE_INFINITY,this._prevRtBar=null,this._leftBoxTime=null,this._rightBoxTime=null}_supplyRowsLayout(e){null===this._rowsLayout&&e.symbol.isFirstBar&&e.symbol.isNewBar&&(this._rowsLayout=this._rowsLayoutSupplier())}_updateCurrentHistogram(e){if(this._needRecalc=!1,c.Std.greater(this._minPrice,e.low)&&(this._minPrice=e.low,this._needRecalc=!0),c.Std.less(this._maxPrice,e.high)&&(this._maxPrice=e.high,this._needRecalc=!0),this._ctx.symbol.isBarClosed&&this._historyBarSet.length>0){const t=this._historyBarSet[this._historyBarSet.length-1];t.time===e.time&&(this._prevRtBar=t,this._historyBarSet.pop())}this._needRecalc&&0===(0,s.ensureNotNull)(this._rowsLayout).type()?(this._recalculateCurrentResultsOnHistoryBarSet(),this._applyUpdateToCurrentResults(e,!1)):this._applyUpdateToCurrentResults(e,!0),this._ctx.symbol.isBarClosed?((0, -s.assert)(null===this._prevRtBar||e.time===this._prevRtBar.time),this._historyBarSet.push(e),this._prevRtBar=null):this._prevRtBar=e}_getMidLevel(e){return(e.priceHigh()+e.priceLow())/2}_getMidLevelFromList(e){return e.length%2==0?e[e.length/2].priceLow():this._getMidLevel(e[Math.floor(e.length/2)])}_getLargestHistItem(){let e=[],t=this._currentHists[0];for(const i of this._currentHists)c.Std.greater(i.ratesSum(),t.ratesSum())?(t=i,e=[t]):c.Std.equal(i.ratesSum(),t.ratesSum())&&e.push(i);if(e.length>1){const i=this._getMidLevelFromList(this._currentHists);t=e[e.length-1];for(let s=e.length-2;s>=0;s--){const r=e[s];c.Std.lessOrEqual(Math.abs(this._getMidLevel(r)-i),Math.abs(this._getMidLevel(t)-i))&&(t=r)}}return t}_initCurrentPoc(){this._currentPoc=new u(this,0,0,0)}_updateCurrentPoc(){const e=(0,s.ensureNotNull)(this._currentPoc);e.setStartIndex((0,s.ensureNotNull)(this._leftBoxTime)),e.setEndIndex((0,s.ensureNotNull)(this._actualRightBoxTime)),e.setExtendLeft(this._extendPocLeftRight),e.setExtendRight(this._extendPocLeftRight);const t=this._getMidLevel((0,s.ensureNotNull)(this._largestHistItem));e.setLevel(t)}_getVolume(e){let t=0;for(const i of e)t+=i.ratesSum();return t}_getPocHistItemIndex(){for(let e=0;e=0,`ERROR - PocHistItemIndex == ${e}`),this._currentVAStart=e-1,this._currentVAEnd=e+1;const t=this._getVolume(this._currentHists)*this._vaVolumePercent*.01;let i=this._currentHists[e].ratesSum(),r=0,n=null;for(;c.Std.lessOrEqual(i+r,t)&&(i+=r,0===n?--this._currentVAStart:1===n&&++this._currentVAEnd,-1!==this._currentVAStart||this._currentVAEnd!==this._currentHists.length);){let t,i;if(this._currentVAStart>-1)if(t=this._currentHists[this._currentVAStart].ratesSum(),this._currentVAEndthis._getMidLevel(this._currentHists[this._currentVAStart])&&e.priceLow()0&&(e=this._currentHists[0].priceLow(),t=this._currentHists[this._currentHists.length-1].priceHigh());const i=[],r=(0,s.ensureNotNull)(this._leftBoxTime),n=(0,s.ensureNotNull)(this._actualRightBoxTime);i.push(new h(r,e)),i.push(new h(r,t)),i.push(new h(n,t)),i.push(new h(n,e)),(0,s.ensureNotNull)(this._currentBox).setPoints(i)}_recalculateCurrentResultsOnHistoryBarSet(){for(let e=0;e0&&(this._largestHistItem=this._getLargestHistItem(),this._updateCurrentPoc()),this._updateCurrentBox()}_applyUpdateToCurrentResults(e,t){t&&null!==this._prevRtBar&&this._addHistoryBarToHistogram(this._prevRtBar,this._historyBarSet.length-1,this._currentHists,this._currentHistsMap,-1),this._addHistoryBarToHistogram(e,this._historyBarSet.length-1,this._currentHists,this._currentHistsMap,1),this._updateLastBarTimeInHistogram(this._currentHists)}_addHistoryBarToHistogram(e,t,i,r,n){(0,s.assert)(-1===n||1===n,"Please set sign argument either +1 or -1");const o=e.low,a=e.high,l=isNaN(e.volume)?0:e.volume,h=e.isUp,d=(0,s.ensureNotNull)(this._rowsLayout);d.init(this._ctx.symbol.minTick,this._minPrice,this._maxPrice,o,a);const u=d.rowWidth();if(!c.Std.greater(u,0))return;d.calculate();const p=d.getIndexLowVbP(),_=d.getIndexHighVbP(),m=d.getStartPrice();if(p===_){const e=p*u+m,t=(p+1)*u+m;this._updateResult({start:e,end:t},n*l,h,i,r)}else{let e=0;for(let t=p;t<=_;t++){const s=t*u+m,c=(t+1)*u+m,d=this._rowCoeff(s,c,o,a),p=d*l;e+=d,this._updateResult({start:s,end:c},n*p,h,i,r)}(0,s.assert)(c.Std.equal(e,1,.05),`totalCoeff not equal 1! totalConf = ${e}`)}}_updateResult(e,t,i,r,n){const o=this._createRates(i,t);(0,s.assert)(null!==this._leftBoxTime,"leftBoxTime is not set (equals null)"),(0,s.assert)(null!==this._rightBoxTime,"rightBoxTime is not set (equals null)");const l=(0,s.ensureNotNull)(this._leftBoxTime),h=(0,s.ensureNotNull)(this._actualRightBoxTime);let d=n.get(e);if(void 0===d)d=new a(this,e.start,e.end,o,l,h),n.set(e,d),this._verifyHistogramSizeIsNotTooLarge(n.size()),this._currentHistsGr.add(d),_._addInOrder(d,r,0,r.length,((e,t)=>{let i=c.Std.compare(e.firstBarTime(),t.firstBarTime());return 0!==i?i:(i=c.Std.compare(e.priceLow(),t.priceLow()),0!==i?i:c.Std.compare(e.priceHigh(),t.priceHigh()))}));else{const e=[] -;for(let t=0;t0?_._addInOrder(e,t,o+1,s,n):t.splice(o,0,e)}}},19762:(e,t,i)=>{"use strict";i.d(t,{VolumeProfileBase:()=>u,maxHHistItems:()=>h,numOfSubHists:()=>d});var s=i(74649),r=i(36274);class n{constructor(e,t){this._minTick=NaN,this._minPrice=NaN,this._maxPrice=NaN,this._low=NaN,this._high=NaN,this._startPrice=NaN,this._indexLowVbP=NaN,this._indexHighVbP=NaN,this._rowSize=e,this._type=t}init(e,t,i,s,r){this._minTick=e,this._minPrice=t,this._maxPrice=i,this._low=s,this._high=r}getStartPrice(){return this._startPrice}setStartPrice(e){this._startPrice=e}getIndexLowVbP(){return this._indexLowVbP}setIndexLowVbP(e){this._indexLowVbP=e}getIndexHighVbP(){return this._indexHighVbP}setIndexHighVbP(e){this._indexHighVbP=e}type(){return this._type}}class o extends n{constructor(e){super(e,0)}calculate(){this.setStartPrice(this._minPrice);const e=this.rowWidth();let t=Math.floor((this._low-this._minPrice)/e),i=Math.ceil((this._high-this._minPrice)/e)-1;t=Math.max(t,0),i=Math.max(i,0),i=Math.min(i,this._rowSize-1),t=Math.min(t,i),this.setIndexLowVbP(t),this.setIndexHighVbP(i)}rowWidth(){return Math.max((this._maxPrice-this._minPrice)/this._rowSize,this._minTick)}}class a extends n{constructor(e){super(e,1)}calculate(){this.setStartPrice(0);const e=this.rowWidth();let t=Math.floor(this._low/e);const i=Math.ceil(this._high/e)-1;t=Math.min(t,i), -this.setIndexLowVbP(t),this.setIndexHighVbP(i)}rowWidth(){return this._minTick*this._rowSize}}var l=i(14483),c=i(81337);function h(){return 6e3}function d(e){switch(e){case"Delta":case"Up/Down":return 2;case"Total":return 1;default:c.Std.error(`Invalid study argument value: ${e}`)}}class u{findBasicResolutionForFromTo(e,t,i,n){const o=(0,s.getVolumeProfileResolutionForPeriod)(e.value(),t,i,n),a=r.Interval.parse(o);return l.enabled("charting_library_debug_mode")&&console.log(`Selected resolution ${a.value()} for (${e.value()}, ${t}, ${i})`),a}verifyRowSizeInput(e,t){"Number Of Rows"===t&&e>6e3&&c.Std.error('Histogram is too large, please reduce "Row Size" input.')}_getRowsLayout(e,t){return"Number Of Rows"===e?new o(t):new a(t)}}},82597:(e,t,i)=>{"use strict";i.d(t,{volumeProfileFixedRangeBSStudyItem:()=>w,volumeProfileFixedRangeVbPStudyItem:()=>b});var s=i(50151),r=i(19762),n=i(72877),o=i(90164),a=i(36274),l=i(79999),c=i(748),h=i(43945),d=i(31584),u=i(1386),p=i(56437),_=i(95586),m=i(89529);class g extends m.VolumeByPriceExpr{constructor(e,t,i,s,r,n,o,a,l,c,h,d,u){super(e,t,i,n,o,a,!1,l,c,(()=>h),d,s,r,!1,u),this._firstBarTime=s,this._lastBarTime=r}update(e){this._supplyRowsLayout(this._ctx),this.timeInRequestedRange(e)&&super.update(e)}timeInRequestedRange(e){const t=this._timeScale().get(e);return this._firstBarTime<=t&&t=this._firstBarTime){const e=this._developingPocSeries.getLeftOrEqual(n),t=this._developingVAHighSeries.getLeftOrEqual(n),i=this._developingVALowSeries.getLeftOrEqual(n);r.data.push([e,t,i])}else r.data.push([NaN,NaN,NaN])}return r}time(){return this._timeSeries}open(){return this._openSeries}high(){return this._highSeries}low(){return this._lowSeries}close(){return this._closeSeries}volume(){return this._volumeSeries}developingPoc(){return this._developingPocSeries}developingVAHigh(){return this._developingVAHighSeries}developingVALow(){return this._developingVALowSeries}}function y(e){return{constructor:S,name:e.description,metainfo:{_metainfoVersion:51,shortDescription:"VPFR",format:{type:"volume"},is_price_study:!0,defaults:{graphics:{hhists:{histBars2:{colors:["#1592e6","#fbc123"],direction:o.HHistDirection.LeftToRight,percentWidth:30,showValues:!1,transparencies:[76,76],valuesColor:"#424242",visible:!0}, -histBarsVA:{colors:["#1592e6","#fbc123"],direction:o.HHistDirection.LeftToRight,percentWidth:30,showValues:!1,transparencies:[30,30],valuesColor:"#424242",visible:!0}},horizlines:{pocLines:{color:"#ff0000",style:_.LineStyle.Solid,visible:!0,width:2}},polygons:{histBoxBg:{color:"#37a6ef",transparency:94}}},inputs:{first_bar_time:0,last_bar_time:0,rows:24,rowsLayout:"Number Of Rows",subscribeRealtime:!0,vaVolume:70,volume:"Up/Down"},styles:{developingPoc:{color:"#ff0000",linestyle:_.LineStyle.Solid,linewidth:1,plottype:n.LineStudyPlotStyle.StepLine,trackPrice:!1,transparency:0,display:0},developingVAHigh:{color:"#0000ff",linestyle:_.LineStyle.Solid,linewidth:1,plottype:n.LineStudyPlotStyle.StepLine,trackPrice:!1,transparency:0,display:0},developingVALow:{color:"#0000ff",linestyle:_.LineStyle.Solid,linewidth:1,plottype:n.LineStudyPlotStyle.StepLine,trackPrice:!1,transparency:0,display:0}}},graphics:{hhists:{histBars2:{location:o.HHistLocation.Absolute,title:"Volume Profile",titles:["Up Volume","Down Volume"]},histBarsVA:{location:o.HHistLocation.Absolute,title:"Value Area",titles:["Value Area Up","Value Area Down"]}},horizlines:{pocLines:{name:"POC",showPrice:!0}},polygons:{histBoxBg:{mouseTouchable:!1,name:"Histogram Box",showBorder:!1}}},inputs:[{defval:"Number Of Rows",id:"rowsLayout",name:"Rows Layout",options:["Number Of Rows","Ticks Per Row"],type:"text"},{defval:24,id:"rows",max:1e6,min:1,name:"Row Size",type:"integer"},{defval:"Up/Down",id:"volume",name:"Volume",options:["Up/Down","Total","Delta"],type:"text"},{defval:0,id:"first_bar_time",isHidden:!0,max:253370764800,min:-253370764800,name:"First Bar Time",type:"time"},{defval:0,id:"last_bar_time",isHidden:!0,max:253370764800,min:-253370764800,name:"Last Bar Time",type:"time"},{defval:70,id:"vaVolume",max:100,min:0,name:"Value Area Volume",type:"integer"},{defval:!0,id:"subscribeRealtime",isHidden:!0,name:"SubscribeRealtime",type:"bool"}],plots:[{id:"developingPoc",type:"line"},{id:"developingVAHigh",type:"line"},{id:"developingVALow",type:"line"}],styles:{developingPoc:{histogramBase:0,title:"Developing Poc"},developingVAHigh:{histogramBase:0,title:"Developing VA High"},developingVALow:{histogramBase:0,title:"Developing VA Low"}},...e}}}const b=y({id:"VbPFixed@tv-volumebyprice-57",description:"Volume Profile Fixed Range"}),w=y({id:"VbPFixed@tv-basicstudies-152",description:"Fixed Range",is_hidden_study:!0})},19999:(e,t,i)=>{"use strict";i.d(t,{VolumeProfileOutputSeries:()=>n});var s=i(50151),r=i(78071);class n{constructor(){this._histPos=-1,this._hist=new Float64Array(2e3),this._times=new Float64Array(2e3)}addHist(e){if(this._histPos>=0){const t=this._times[this._histPos];(0,s.assert)(t<=e,"History order violation"),this._histPos+=t===e?0:1}else this._histPos+=1;if(this._histPos===this._hist.length){const e=new Float64Array(2*this._hist.length);e.set(this._hist),this._hist=e;const t=new Float64Array(this._hist.length);t.set(this._times),this._times=t}this._hist[this._histPos]=NaN,this._times[this._histPos]=e}removeLastIfNaN(){ -Number.isNaN(this.get(0))&&(this._histPos-=1)}get(e){(0,s.assert)(0===e);const t=this._histPos-e;return this._hist[t]}getLeftOrEqual(e){const t=(0,r.upperbound)(this._times,e,((e,t)=>e{"use strict";i.d(t,{volumeProfileVisibleRangeStudyItem:()=>v});var s=i(50151),r=i(19762),n=i(90164),o=i(36274),a=i(79999),l=i(89529),c=i(31584);class h extends l.VolumeByPriceExpr{constructor(e,t,i,s,r,n,o,a,l,h,d){super(e,t,i,n,new c.GraphicsList,o,!0,a,l,(()=>h),d,s,r,!1),this._firstBarTime=s,this._lastBarTime=r}update(e){this._supplyRowsLayout(this._ctx),this.timeInRequestedRange(e)&&super.update(e)}timeInRequestedRange(e){const t=this._timeScale().get(e);return this._firstBarTime<=t&&t=this._firstBarTime){const e=this._developingPocSeries.getLeftOrEqual(n),t=this._developingVAHighSeries.getLeftOrEqual(n),i=this._developingVALowSeries.getLeftOrEqual(n);r.data.push([e,t,i])}else r.data.push([NaN,NaN,NaN])}return r}time(){return this._timeSeries}open(){return this._openSeries}high(){return this._highSeries}low(){return this._lowSeries}close(){return this._closeSeries}volume(){return this._volumeSeries}developingPoc(){return this._developingPocSeries}developingVAHigh(){return this._developingVAHighSeries}developingVALow(){return this._developingVALowSeries}}const v={constructor:f,name:"Volume Profile Visible Range",metainfo:{_metainfoVersion:51,id:"VbPVisible@tv-basicstudies-49",description:"Volume Profile Visible Range",shortDescription:"VPVR",format:{type:"volume"},is_price_study:!0,linkedToSeries:!0,palettes:{},inputs:[{id:"rowsLayout",name:"Rows Layout",defval:"Number Of Rows",options:["Number Of Rows","Ticks Per Row"],type:"text"},{id:"rows",name:"Row Size",defval:24,max:1e6,min:1,type:"integer"},{id:"volume",name:"Volume",defval:"Up/Down",options:["Up/Down","Total","Delta"],type:"text"},{id:"first_visible_bar_time",name:"First Visible Bar Time",defval:0,isHidden:!0,max:253370764800,min:-253370764800,type:"time"},{id:"last_visible_bar_time",name:"Last Visible Bar Time",defval:0,isHidden:!0,max:253370764800,min:-253370764800,type:"time"},{id:"vaVolume",name:"Value Area Volume",defval:70,max:100,min:0,type:"integer"}],plots:[{ -id:"developingPoc",type:"line"},{id:"developingVAHigh",type:"line"},{id:"developingVALow",type:"line"}],graphics:{hhists:{histBars2:{location:n.HHistLocation.Relative,title:"Volume Profile",titles:["Up Volume","Down Volume"]},histBarsVA:{location:n.HHistLocation.Relative,title:"Value Area",titles:["Value Area Up","Value Area Down"]}},horizlines:{pocLines:{name:"POC",showPrice:!0}}},defaults:{graphics:{hhists:{histBars2:{colors:["#1592e6","#fbc123"],direction:n.HHistDirection.RightToLeft,percentWidth:30,showValues:!1,transparencies:[76,76],valuesColor:"#424242",visible:!0},histBarsVA:{colors:["#1592e6","#fbc123"],direction:n.HHistDirection.RightToLeft,percentWidth:30,showValues:!1,transparencies:[30,30],valuesColor:"#424242",visible:!0}},horizlines:{pocLines:{color:"#ff0000",style:0,visible:!0,width:2}}},inputs:{first_visible_bar_time:0,last_visible_bar_time:0,rows:24,rowsLayout:"Number Of Rows",vaVolume:70,volume:"Up/Down"},styles:{developingPoc:{color:"#ff0000",linestyle:0,linewidth:1,plottype:9,trackPrice:!1,transparency:0,display:0},developingVAHigh:{color:"#0000ff",linestyle:0,linewidth:1,plottype:9,trackPrice:!1,transparency:0,display:0},developingVALow:{color:"#0000ff",linestyle:0,linewidth:1,plottype:9,trackPrice:!1,transparency:0,display:0}}},styles:{developingPoc:{histogramBase:0,title:"Developing Poc"},developingVAHigh:{histogramBase:0,title:"Developing VA High"},developingVALow:{histogramBase:0,title:"Developing VA Low"}}}}},43945:(e,t,i)=>{"use strict";i.d(t,{EraseAll:()=>r,EraseObj:()=>s,GraphicsCmds:()=>n});class s{constructor(e,t){this.id=e,this.type=t}primitiveData(){return{action:"one",id:this.id,type:this.type}}}class r{primitiveData(){return{action:"all"}}}class n{constructor(){this.erase=[],this.create=null,this._modified=!1}primitiveData(e){if(this.isNaN())return null;const t={},i=this.create&&this.create.primitiveData(e);return null!==i&&(t.create=i),null!==this.erase&&this.erase.length>0&&(t.erase=this.erase.map((e=>e.primitiveData()))),void 0===t.create&&void 0===t.erase?null:t}setCreate(e){this.create=e,this.create.forEachList((e=>e.setOwner(this)))}isNaN(){return(null===this.erase||0===this.erase.length)&&null===this.create}isModified(){return this._modified}setModified(e){this._modified=e}dirty(){this._modified=!0}setOwner(e){throw new Error("Unsupported")}}},79999:(e,t,i)=>{"use strict";i.d(t,{GraphicsListColl:()=>s});class s{constructor(){this._stable=[],this._variable=null,this._owner=null}addStable(e){e.setOwner(this),this._stable.push(e)}setVariable(e){this._variable=e,null!==this._variable&&this._variable.setOwner(this)}primitivesData(e){const t=[];return this._forEach((i=>t.push(...i.primitivesData(e)))),t}deleteErasedItems(){this._forEach((e=>e.deleteErasedItems()))}markPostedItems(){this._forEach((e=>e.markPostedItems()))}isNaN(){return this._all((e=>e.isNaN()))}dirty(){null!==this._owner&&this._owner.dirty()}setOwner(e){this._owner=e}_forEach(e){for(const t of this._stable)e(t);null!==this._variable&&e(this._variable)}_all(e){for(const t of this._stable)if(!e(t))return!1 -;return null===this._variable||e(this._variable)}}},31584:(e,t,i)=>{"use strict";i.d(t,{GraphicsList:()=>n});var s=i(29779),r=i(76958);class n{constructor(){this._items=[],this._owner=null}primitivesData(e){const t=[];for(const i of this._items)e.isIgnoredObj(i)||t.push(i.primitiveData());return t}get(e){return this._items[e]}set(e,t){return this.dirty(),t.setOwner(this),this._items[e]=t,t}addAtIndex(e,t){this.dirty(),t.setOwner(this),this._items[e]=t}clear(){this._unsetOwner(this._items),this._items=[],this.dirty()}addAllFromNumber(e,t){this.setOwner(t),this._items.splice(e,0,...t._items);return this._setCachedDataValid(!1),true}addAll(e){this.setOwner(e),this._items.push(...e._items);return this._setCachedDataValid(!1),true}remove(e){const t=this._items[e];return this._items.splice(e,1),t.unsetOwner(this),this.dirty(),t}getItems(){return this._items}size(){return this._items.length}add(e){e.setOwner(this),this._items.push(e);return this._setCachedDataValid(!1),true}deleteErasedItems(){this._items=this._items.filter((e=>!e.isErased()))}markPostedItems(){for(const e of this._items)e.markAsPosted()}isNaN(){if(0===this._items.length)return!0;for(const e of this._items){if(!(0,r.isNaNable)(e))return!1;if(!e.isNaN())return!1}return!0}setOwner(e){this._owner=e}dirty(){null!==this._owner&&this._owner.dirty()}_unsetOwner(e){for(const t of e)t instanceof s.GraphicsObj&&t.unsetOwner(this)}_setCachedDataValid(e){e||this.dirty()}}},29779:(e,t,i)=>{"use strict";i.d(t,{GraphicsObj:()=>l});var s=i(81337);class r{constructor(e,t,i,s){this._value=e,this._name=t,this._owner=i,this._comparer=void 0!==s?s:(e,t)=>null==e?null!=t:e===t}getName(){return this._name}set(e){const t=this._comparer(this._value,e);return t&&this._owner.dirty(),this._value=e,t}get(){return this._value}}class n{constructor(e,t,i){this._owner=null,this._value=e,this._name=t,this._owner=i}getName(){return this._name}set(e){return this._value!==e&&(this._value=e,null!==this._owner&&this._owner.dirty(),!0)}get(){return this._value}}class o extends r{constructor(e,t,i,s){super(e,t,i,s)}}class a{constructor(e){this._owner=e}createField(e,t){return new r(e,t,this)}createDoubleField(e,t){return new r(e,t,this,((e,t)=>!s.Std.equal(e,t)))}createDoubleArrayField(e,t){return new o(e,t,this,((e,t)=>{if(e===t)return!1;const i=e.length;if(t.length!==i)return!0;for(let r=0;r{"use strict";function s(e){return Boolean(e.isNaN)}i.d(t,{isNaNable:()=>s})},1386:(e,t,i)=>{"use strict";i.d(t,{JStudyDataUpdate:()=>d});var s=i(43945);class r{constructor(){this.isUpdate=!1,this.graphicsCmds=new s.GraphicsCmds,this._offsetsChanged=!1,this._disableGraphicsAndData=!1}isNaN(){return this.graphicsCmds.isNaN()}primitiveData(e){const t={};if(!this._disableGraphicsAndData){const i=this.graphicsCmds.primitiveData(e);null!==i&&(t.graphicsCmds=i)}return this.isUpdate&&(t.isUpdate=!0),void 0===t.graphicsCmds?void 0:t}disable(){this._disableGraphicsAndData=!0}checkForChangeAndResetChangedState(e){const t=this._offsetsChanged,i=this.graphicsCmds.isModified();this.graphicsCmds.setModified(!1),this._offsetsChanged=!1;return i||t||0!==e.length}}var n=i(1722),o=i(76958);function a(e){return Boolean(e.isPosted)}class l{isIgnoredObj(e,t){return l.isIgnoredObjDefault(e,t)}static isIgnoredObjDefault(e,t){if(void 0===t)return l.isIgnoredObjNaNable(e);const i=e[t];return l.isIgnoredByGeneralRules(e,t)||l.isIgnoredObjNaNable(i)||l.isIgnoredObjListOfNaNables(i)}static isIgnoredObjNaNable(e){return(0,o.isNaNable)(e)&&e.isNaN()}static isIgnoredObjListOfNaNables(e){if(!(0,n.isArray)(e))return!1;let t=!0;for(const i of e)if(!(0,o.isNaNable)(i)||!i.isNaN()){t=!1;break}return t}static isIgnoredObjPosted(e){return a(e)&&e.isPosted()}static isIgnoredObjErased(e){return a(e)&&e.isErased()}static isIgnoredByGeneralRules(e,t){const i=e[t];return(0,n.isArray)(i)&&0===i.length}}class c{isIgnoredObj(e,t){if(void 0===t)return l.isIgnoredObjDefault(e)||l.isIgnoredObjErased(e);const i=e[t];return l.isIgnoredObjDefault(e,t)||l.isIgnoredObjErased(i)}}class h{isIgnoredObj(e,t){if(void 0===t)return l.isIgnoredObjDefault(e)||l.isIgnoredObjErased(e)||l.isIgnoredObjPosted(e);const i=e[t];return l.isIgnoredObjDefault(e,t)||l.isIgnoredObjErased(i)||l.isIgnoredObjPosted(i)}}class d extends class extends class{constructor(e){this._dataObj=new r,this._isDirty=!1,this._eraseCmds=[],this._enableCmdDataStudy=e}init(e){this._dataObj.graphicsCmds.setCreate(e),this.update(!0)}dataObj(){return this._dataObj}setEraseCmds(e){this._eraseCmds=e}resetDirtyState(){this._isDirty=!1}disable(){this._dataObj.disable()}}{constructor(e){super(e),this._snapshotPredicate=new c,this._dataSnapShot={}}getData(){return this._dataSnapShot}getUpdate(){return this._isDirty?this._dataSnapShot:{}}update(e){(this._dataObj.checkForChangeAndResetChangedState(this._eraseCmds)||e)&&(null!==this._dataObj.graphicsCmds.create&&(this._dataObj.graphicsCmds.create.deleteErasedObjs(),this._dataObj.graphicsCmds.erase=[new s.EraseAll]),this._makeSnapshot(),this._isDirty=!0)}_makeSnapshot(){this._json=this._dataObj.primitiveData(this._snapshotPredicate),this._dataSnapShot={json:this._json}}}{constructor(e){super(e), -this._updatePredicate=new h,this._sendShapshotOnly=!0,this._isFirstNotForcedUpdate=!0}update(e){(this._dataObj.checkForChangeAndResetChangedState(this._eraseCmds)||e)&&(null!==this._dataObj.graphicsCmds.create&&(this._dataObj.graphicsCmds.erase=[new s.EraseAll]),this._dataObj.isUpdate=!0,this._makeSnapshot(),null!==this._dataObj.graphicsCmds.create&&(this._dataObj.graphicsCmds.erase=this._eraseCmds),this._dataObj.isUpdate=!0,this._jsonUpdate=this._dataObj.primitiveData(this._updatePredicate),null!==this._dataObj.graphicsCmds.create&&this._dataObj.graphicsCmds.create.deleteErasedAndMarkPostedObjs(),this._sendShapshotOnly=e||this._isFirstNotForcedUpdate,this._isFirstNotForcedUpdate=Boolean(e),this._isDirty=!0)}getUpdate(){return this._isDirty?this._enableCmdDataStudy?{json:this._sendShapshotOnly?this._json:void 0,jsonUpdate:this._sendShapshotOnly?void 0:this._jsonUpdate}:{json:this._json,jsonUpdate:this._sendShapshotOnly?void 0:this._jsonUpdate}:{}}}},748:(e,t,i)=>{"use strict";i.d(t,{Container:()=>n,StudyGraphicsData:()=>r});var s=i(50151);class r{constructor(){this._horizlines=[],this._hhists=[],this._polygons=[],this._vertlines=[],this._containersCache=[],this._containerNamesCache=[],this._containersMapCache=new Map,this._addToCache("horizlines",this._horizlines),this._addToCache("hhists",this._hhists),this._addToCache("polygons",this._polygons),this._addToCache("vertlines",this._vertlines)}primitiveData(e){const t={};let i=!1;for(const s of this._containerNamesCache){const r=[],n=this.getObjsContainer(s);for(const t of n){if(t.isNaN())continue;const i=t.primitiveData(e);i.data.length>0&&r.push(i)}r.length>0&&(t[s]=r,i=!0)}return i?t:null}deleteErasedAndMarkPostedObjs(){this.forEachList((e=>{e.deleteErasedItems(),e.markPostedItems()}))}deleteErasedObjs(){this.forEachList((e=>e.deleteErasedItems()))}getObjsContainer(e){return(0,s.ensureDefined)(this._containersMapCache.get(e))}forEachList(e){for(const t of this._containersCache)for(const i of t)e(i.data)}_addToCache(e,t){this._containersCache.push(t),this._containerNamesCache.push(e),this._containersMapCache.set(e,t)}}class n{constructor(e,t){this.styleId=e,this.data=t}isNaN(){return this.data.isNaN()}primitiveData(e){return{styleId:this.styleId,data:this.data.primitivesData(e)}}}},24172:(e,t,i)=>{"use strict";const s=i(48891).getHexColorByName;var r=i(74649);const n=s("color-ripe-red-100"),o=s("color-ripe-red-200"),a=s("color-ripe-red-500"),l=s("color-ripe-red-900"),c=s("color-ripe-red-a200"),h=s("color-minty-green-100"),d=s("color-minty-green-400"),u=s("color-minty-green-500");JSServer.studyLibrary=[{name:"Accumulation/Distribution",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Accumulation/Distribution",shortDescription:"Accum/Dist",is_price_study:!1,inputs:[], -id:"Accumulation/Distribution@tv-basicstudies-1",scriptIdPart:"",name:"Accumulation/Distribution",format:{type:"volume"}},constructor:function(){this.f_0=function(e,t,i,s){return r.Std.or(r.Std.and(r.Std.eq(e,t),r.Std.eq(e,i)),r.Std.eq(t,i))?0:(2*e-i-t)/(t-i)*s},this.main=function(e,t){this._context=e,this._input=t;var i=this.f_0(r.Std.close(this._context),r.Std.high(this._context),r.Std.low(this._context),r.Std.volume(this._context));return[r.Std.cum(i,this._context)]}}},{name:"Accumulative Swing Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:10}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"ASI",histogramBase:0,joinPoints:!1}},description:"Accumulative Swing Index",shortDescription:"ASI",is_price_study:!1,inputs:[{id:"in_0",name:"Limit Move Value",defval:10,type:"float",min:.1,max:1e5}],id:"Accumulative Swing Index@tv-basicstudies-1",scriptIdPart:"",name:"Accumulative Swing Index",format:{type:"volume"}},constructor:function(){this.f_0=function(e,t){var i=t.new_var(r.Std.open(t)),s=t.new_var(r.Std.high(t)),n=t.new_var(r.Std.low(t)),o=t.new_var(r.Std.close(t)),a=r.Std.abs(s-o.get(1)),l=r.Std.abs(n-o.get(1)),c=r.Std.abs(s-n),h=r.Std.abs(o.get(1)-i.get(1)),d=r.Std.max(a,l),u=r.Std.iff(a>=r.Std.max(l,c),a-.5*l+.25*h,r.Std.iff(l>=r.Std.max(a,c),l-.5*a+.25*h,c+.25*h));return r.Std.iff(0===u,0,(o-o.get(1)+.5*(o-i)+.25*(o.get(1)-i.get(1)))/u*d/e*50)},this.f_1=function(e,t){var i=this.f_0(e,t);return r.Std.cum(i,t)},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0);return[this.f_1(i,this._context)]}}},{name:"Advance/Decline",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:10}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Advance/Decline",shortDescription:"AD",is_price_study:!1,inputs:[{id:"in_0",name:"length",defval:10,type:"integer",min:1,max:2e3}],id:"Advance/Decline@tv-basicstudies-1",scriptIdPart:"",name:"Advance/Decline",format:{precision:2,type:"price"}},constructor:function(){this.f_0=function(e,t){return r.Std.gt(e,t)},this.f_1=function(e,t){return r.Std.lt(e,t)},this.f_2=function(e,t){return 0===t?e:e/t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this.f_0(r.Std.close(this._context),r.Std.open(this._context)),n=this._context.new_var(s),o=r.Std.sum(n,i,this._context),a=this.f_1(r.Std.close(this._context),r.Std.open(this._context)),l=this._context.new_var(a),c=r.Std.sum(l,i,this._context);return[this.f_2(o,c)]}}},{name:"Arnaud Legoux Moving Average",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{ -in_0:9,in_1:.85,in_2:6}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Arnaud Legoux Moving Average",shortDescription:"ALMA",is_price_study:!0,inputs:[{id:"in_0",name:"Window Size",defval:9,type:"integer",min:0,max:5e3},{id:"in_1",name:"Offset",defval:.85,type:"float",min:-1e12,max:1e12},{id:"in_2",name:"Sigma",defval:6,type:"float",min:-1e12,max:1e12}],id:"Arnaud Legoux Moving Average@tv-basicstudies-1",scriptIdPart:"",name:"Arnaud Legoux Moving Average",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.close(this._context),s=this._input(0),n=this._input(1),o=this._input(2),a=this._context.new_var(i);return[r.Std.alma(a,s,n,o)]}}},{name:"Aroon",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FB8C00"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:14}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],styles:{plot_0:{title:"Upper",histogramBase:0,joinPoints:!1},plot_1:{title:"Lower",histogramBase:0,joinPoints:!1}},description:"Aroon",shortDescription:"Aroon",is_price_study:!1,inputs:[{id:"in_0",name:"length",defval:14,type:"integer",min:1,max:2e3}],id:"Aroon@tv-basicstudies-1",scriptIdPart:"",name:"Aroon",format:{precision:2,type:"percent"}},constructor:function(){this.f_0=function(e,t){return 100*(e+t)/t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=r.Std.high(this._context),n=i+1,o=this._context.new_var(s),a=r.Std.highestbars(o,n,this._context),l=this.f_0(a,i),c=r.Std.low(this._context),h=this._context.new_var(c),d=r.Std.lowestbars(h,n,this._context);return[l,this.f_0(d,i)]}}},{name:"Average Price",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,id:"AveragePrice@tv-basicstudies-1",scriptIdPart:"",name:"Average Price",description:"Average Price",shortDescription:"Average Price",is_price_study:!0,plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#2196F3"}},inputs:{}},styles:{plot_0:{title:"Plot"}},inputs:[],format:{type:"inherit"}},constructor:function(){this.main=function(e,t){return this._context=e,this._input=t,[r.Std.ohlc4(this._context)]}}},{name:"Average Directional Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:c}},inputs:{in_0:14,in_1:14}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"ADX",histogramBase:0,joinPoints:!1,isHidden:!1}},description:"Average Directional Index",shortDescription:"ADX",is_price_study:!1,inputs:[{id:"in_0",name:"ADX Smoothing",defval:14,type:"integer",min:-1e12,max:1e12},{id:"in_1",name:"DI Length",defval:14,type:"integer",min:-1e12, -max:1e12}],id:"average_directional_Index@tv-basicstudies-1",scriptIdPart:"",name:"Average Directional Index",format:{precision:2,type:"price"}},constructor:function(){this.f_0=function(e){var t=this._context.new_var(r.Std.high(this._context)),i=r.Std.change(t),s=this._context.new_var(r.Std.low(this._context)),n=-r.Std.change(s),o=this._context.new_var(r.Std.tr(void 0,this._context)),a=r.Std.rma(o,e,this._context),l=this._context.new_var(r.Std.and(r.Std.gt(i,n),r.Std.gt(i,0))?i:0),c=r.Std.fixnan(100*r.Std.rma(l,e,this._context)/a,this._context),h=this._context.new_var(r.Std.and(r.Std.gt(n,i),r.Std.gt(n,0))?n:0);return[c,r.Std.fixnan(100*r.Std.rma(h,e,this._context)/a,this._context)]},this.f_1=function(e,t){var i=this.f_0(e),s=i[0],n=i[1],o=s+n,a=this._context.new_var(r.Std.abs(s-n)/(r.Std.eq(o,0)?1:o));return[100*r.Std.rma(a,t,this._context)]},this.main=function(e,t){return this._context=e,this._input=t,this._context.setMinimumAdditionalDepth(this._input(0)+this._input(1)),this.f_1(this._input(1),this._input(0))}}},{name:"Average True Range",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:l}},inputs:{in_0:14}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Average True Range",shortDescription:"ATR",is_price_study:!1,inputs:[{id:"in_0",name:"length",defval:14,type:"integer",min:1,max:2e3}],id:"Average True Range@tv-basicstudies-1",scriptIdPart:"",name:"Average True Range",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){var i=t(0);return[r.Std.atr(i,e)]}}},{name:"Awesome Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:1,trackPrice:!1,transparency:0,visible:!0,color:"#000080"}},palettes:{palette_0:{colors:{0:{color:a,width:1,style:0},1:{color:u,width:1,style:0}}}},inputs:{}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",palette:"palette_0",target:"plot_0",type:"colorer"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Awesome Oscillator",shortDescription:"AO",is_price_study:!1,palettes:{palette_0:{colors:{0:{name:"Color 0"},1:{name:"Color 1"}}}},inputs:[],id:"Awesome Oscillator@tv-basicstudies-1",scriptIdPart:"",name:"Awesome Oscillator",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return e-t},this.f_1=function(e){return r.Std.le(e,0)?0:1},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.hl2(this._context),s=this._context.new_var(i),n=r.Std.sma(s,5,this._context),o=this._context.new_var(i),a=r.Std.sma(o,34,this._context),l=this.f_0(n,a),c=l,h=this._context.new_var(l),d=r.Std.change(h);return[c,this.f_1(d)]}}},{name:"Accelerator Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:1,trackPrice:!1,transparency:0,visible:!0, -color:"#000080"}},palettes:{palette_0:{colors:{0:{color:a,width:1,style:0},1:{color:u,width:1,style:0}}}},inputs:{}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",palette:"palette_0",target:"plot_0",type:"colorer"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Accelerator Oscillator",shortDescription:"AO",is_price_study:!1,palettes:{palette_0:{colors:{0:{name:"Color 0"},1:{name:"Color 1"}}}},inputs:[],id:"Accelerator Oscillator@tv-basicstudies-1",scriptIdPart:"",name:"Accelerator Oscillator",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return e-t},this.f_1=function(e){return r.Std.le(e,0)?0:1},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.hl2(this._context),s=this._context.new_var(i),n=r.Std.sma(s,5,this._context),o=this._context.new_var(i),a=r.Std.sma(o,34,this._context),l=this.f_0(n,a),c=this._context.new_var(l),h=r.Std.sma(c,5,this._context),d=this.f_0(l,h),u=this._context.new_var(d),p=r.Std.change(u);return[d,this.f_1(p)]}}},{name:"Balance of Power",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:c}},inputs:{}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Balance of Power",shortDescription:"Balance of Power",is_price_study:!1,inputs:[],id:"Balance of Power@tv-basicstudies-1",scriptIdPart:"",name:"Balance of Power",format:{precision:2,type:"price"}},constructor:function(){this.f_0=function(e,t,i,s){return(e-t)/(i-s)},this.main=function(e,t){return this._context=e,this._input=t,[this.f_0(r.Std.close(this._context),r.Std.open(this._context),r.Std.high(this._context),r.Std.low(this._context))]}}},{name:"Bollinger Bands",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_2:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},filledAreasStyle:{fill_0:{color:"#2196F3",transparency:95,visible:!0}},inputs:{in_0:20,in_1:2}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"Median",histogramBase:0,joinPoints:!1},plot_1:{title:"Upper",histogramBase:0,joinPoints:!1},plot_2:{title:"Lower",histogramBase:0,joinPoints:!1}},description:"Bollinger Bands",shortDescription:"BB",is_price_study:!0,filledAreas:[{id:"fill_0",objAId:"plot_1",objBId:"plot_2",type:"plot_plot",title:"Plots Background"}],inputs:[{id:"in_0",name:"length",defval:20,type:"integer",min:1,max:1e4},{id:"in_1",name:"mult",defval:2,type:"float",min:.001,max:50}],id:"Bollinger Bands@tv-basicstudies-1",scriptIdPart:"",name:"Bollinger Bands",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return e*t},this.f_1=function(e,t){ -return e+t},this.f_2=function(e,t){return e-t},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.close(this._context),s=this._input(0),n=this._input(1),o=this._context.new_var(i),a=r.Std.sma(o,s,this._context),l=this._context.new_var(i),c=r.Std.stdev(l,s,this._context),h=this.f_0(n,c);return[a,this.f_1(a,h),this.f_2(a,h)]}}},{name:"Bollinger Bands %B",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:d}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:1},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],filledAreasStyle:{fill_0:{color:"#26A69A",transparency:90,visible:!0}},inputs:{in_0:20,in_1:2}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1}},description:"Bollinger Bands %B",shortDescription:"BB %B",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_1",name:"LowerLimit",zorder:-1.11}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",title:"Hlines Background",zorder:-2}],inputs:[{id:"in_0",name:"length",defval:20,type:"integer",min:1,max:1e4},{id:"in_1",name:"mult",defval:2,type:"float",min:.001,max:50}],id:"Bollinger Bands %B@tv-basicstudies-1",scriptIdPart:"",name:"Bollinger Bands %B",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t){return e*t},this.f_1=function(e,t){return e+t},this.f_2=function(e,t){return e-t},this.f_3=function(e,t,i){return(e-t)/(i-t)},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.close(this._context),s=this._input(0),n=this._input(1),o=this._context.new_var(i),a=r.Std.sma(o,s,this._context),l=this._context.new_var(i),c=r.Std.stdev(l,s,this._context),h=this.f_0(n,c),d=this.f_1(a,h),u=this.f_2(a,h);return[this.f_3(i,u,d)]}}},{name:"Bollinger Bands Width",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"}},inputs:{in_0:20,in_1:2}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Bollinger Bands Width",shortDescription:"BBW",is_price_study:!1,inputs:[{id:"in_0",name:"length",defval:20,type:"integer",min:1,max:1e4},{id:"in_1",name:"mult",defval:2,type:"float",min:.001,max:50}],id:"Bollinger Bands Width@tv-basicstudies-1",scriptIdPart:"",name:"Bollinger Bands Width",format:{precision:2,type:"price"}},constructor:function(){this.f_0=function(e,t){return e*t},this.f_1=function(e,t){return e+t},this.f_2=function(e,t){return e-t},this.f_3=function(e,t,i){return(e-t)/i},this.main=function(e,t){this._context=e,this._input=t -;var i=r.Std.close(this._context),s=this._input(0),n=this._input(1),o=this._context.new_var(i),a=r.Std.sma(o,s,this._context),l=this._context.new_var(i),c=r.Std.stdev(l,s,this._context),h=this.f_0(n,c),d=this.f_1(a,h),u=this.f_2(a,h);return[this.f_3(d,u,a)]}}},{name:"Chaikin Money Flow",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#43A047"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{in_0:20}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1}},description:"Chaikin Money Flow",shortDescription:"CMF",is_price_study:!1,bands:[{id:"hline_0",name:"Zero",zorder:-1}],inputs:[{id:"in_0",name:"length",defval:20,type:"integer",min:1,max:2e3}],id:"Chaikin Money Flow@tv-basicstudies-1",scriptIdPart:"",name:"Chaikin Money Flow",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t,i,s){return r.Std.or(r.Std.and(r.Std.eq(e,t),r.Std.eq(e,i)),r.Std.eq(t,i))?0:(2*e-i-t)/(t-i)*s},this.f_1=function(e,t){return e/t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this.f_0(r.Std.close(this._context),r.Std.high(this._context),r.Std.low(this._context),r.Std.volume(this._context)),n=this._context.new_var(s),o=r.Std.sum(n,i,this._context),a=r.Std.volume(this._context),l=this._context.new_var(a),c=r.Std.sum(l,i,this._context);return[this.f_1(o,c)]}}},{name:"Chaikin Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#EC407A"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{in_0:3,in_1:10}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1}},description:"Chaikin Oscillator",shortDescription:"Chaikin Osc",is_price_study:!1,bands:[{id:"hline_0",name:"Zero",zorder:-1}],inputs:[{id:"in_0",name:"short",defval:3,type:"integer",min:1,max:2e3},{id:"in_1",name:"long",defval:10,type:"integer",min:1,max:2e3}],id:"Chaikin Oscillator@tv-basicstudies-1",scriptIdPart:"",name:"Chaikin Oscillator",format:{type:"volume"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t){return e-t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=r.Std.accdist(this._context),o=this._context.new_var(n),a=r.Std.ema(o,i,this._context),l=this._context.new_var(n),c=r.Std.ema(l,s,this._context);return[this.f_0(a,c)]}}},{name:"Chaikin Volatility",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!1,id:"Chaikin Volatility@tv-basicstudies-1",scriptIdPart:"",name:"Chaikin Volatility",description:"Chaikin Volatility",shortDescription:"Chaikin Volatility",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0, -trackPrice:!1,transparency:0,color:"#AB47BC"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{periods:10,rocLookback:10}},styles:{plot_0:{title:"Plot",zorder:1}},bands:[{id:"hline_0",name:"Zero",zorder:-1}],inputs:[{id:"periods",type:"integer",name:"Periods"},{id:"rocLookback",type:"integer",name:"Rate of Change Lookback"}],format:{type:"volume"},usePlotsZOrder:!0},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this.period=this._input(0),this.rocLookback=this._input(1)},this.main=function(e,t){this._context=e,this._input=t,this._context.setMinimumAdditionalDepth(this.period+this.rocLookback);var i=this._context.new_var(r.Std.high(this._context)-r.Std.low(this._context)),s=this._context.new_var(r.Std.ema(i,this.period,this._context));return[r.Std.roc(s,this.rocLookback)]}}},{name:"Chande Kroll Stop",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"}},inputs:{in_0:10,in_1:1,in_2:9}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],styles:{plot_0:{title:"Long",histogramBase:0,joinPoints:!1},plot_1:{title:"Short",histogramBase:0,joinPoints:!1}},description:"Chande Kroll Stop",shortDescription:"Chande Kroll Stop",is_price_study:!0,inputs:[{id:"in_0",name:"p",defval:10,type:"integer",min:1,max:4999},{id:"in_1",name:"x",defval:1,type:"integer",min:1,max:1e12},{id:"in_2",name:"q",defval:9,type:"integer",min:1,max:1e12}],id:"Chande Kroll Stop@tv-basicstudies-1",scriptIdPart:"",name:"Chande Kroll Stop",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t,i){return e-t*i},this.f_1=function(e,t,i){return e+t*i},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=this._input(2),o=r.Std.high(this._context),a=this._context.new_var(o),l=r.Std.highest(a,i,this._context),c=r.Std.atr(i,this._context),h=this.f_0(l,s,c),d=this._context.new_var(o),u=r.Std.lowest(d,i,this._context),p=this.f_1(u,s,c),_=this._context.new_var(h),m=r.Std.highest(_,n,this._context),g=this._context.new_var(p);return[r.Std.lowest(g,n,this._context),m]}}},{name:"Chande Momentum Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:9}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Chande Momentum Oscillator",shortDescription:"ChandeMO",is_price_study:!1,inputs:[{id:"in_0",name:"length",defval:9,type:"integer",min:1,max:2e3}],id:"Chande Momentum Oscillator@tv-basicstudies-1",scriptIdPart:"",name:"Chande Momentum Oscillator",format:{type:"price",precision:2}},constructor:function(){this.f_0=function(e){return r.Std.ge(e,0)?e:0},this.f_1=function(e){ -return r.Std.ge(e,0)?0:-e},this.f_2=function(e,t){return 100*e/t},this.f_3=function(e,t){return this.f_2(e-t,e+t)},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=r.Std.close(this._context),n=this._context.new_var(s),o=r.Std.change(n),a=this.f_0(o),l=this.f_1(o),c=this._context.new_var(a),h=r.Std.sum(c,i,this._context),d=this._context.new_var(l),u=r.Std.sum(d,i,this._context);return[this.f_3(h,u)]}}},{name:"Chop Zone",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:5,trackPrice:!1,transparency:0,visible:!0,color:"#000080"}},palettes:{palette_0:{colors:{0:{color:"#26C6DA",width:1,style:0},1:{color:"#43A047",width:1,style:0},2:{color:"#A5D6A7",width:1,style:0},3:{color:u,width:1,style:0},4:{color:"#D50000",width:1,style:0},5:{color:"#E91E63",width:1,style:0},6:{color:"#FF6D00",width:1,style:0},7:{color:"#FFB74D",width:1,style:0},8:{color:"#FDD835",width:1,style:0}}}},inputs:{}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",palette:"palette_0",target:"plot_0",type:"colorer"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,isHidden:!1}},description:"Chop Zone",shortDescription:"Chop Zone",is_price_study:!1,palettes:{palette_0:{colors:{0:{name:"Color 0"},1:{name:"Color 1"},2:{name:"Color 2"},3:{name:"Color 3"},4:{name:"Color 4"},5:{name:"Color 5"},6:{name:"Color 6"},7:{name:"Color 7"},8:{name:"Color 8"}},valToIndex:{0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8}}},inputs:[],id:"chop_zone@tv-basicstudies-1",scriptIdPart:"",name:"Chop Zone",format:{precision:0,type:"price"}},constructor:function(){this.f_0=function(){var e=r.Std.close(this._context),t=r.Std.hlc3(this._context),i=this._context.new_var(r.Std.high(this._context)),s=r.Std.highest(i,30,this._context),n=r.Std.lowest(i,30,this._context),o=25/(s-n)*n,a=this._context.new_var(e),l=this._context.new_var(r.Std.ema(a,34,this._context)),c=(l.get(1)-l.get(0))/t*o,h=r.Std.sqrt(1+c*c),d=r.Std.round(180*r.Std.acos(1/h)/3.141592653589793),u=r.Std.iff(r.Std.gt(c,0),-d,d),p=r.Std.and(r.Std.gt(u,-2.14),r.Std.le(u,-.71))?7:8,_=r.Std.and(r.Std.gt(u,-3.57),r.Std.le(u,-2.14))?6:p,m=r.Std.and(r.Std.gt(u,-5),r.Std.le(u,-3.57))?5:_,g=r.Std.le(u,-5)?4:m,f=r.Std.and(r.Std.lt(u,2.14),r.Std.ge(u,.71))?3:g,v=r.Std.and(r.Std.lt(u,3.57),r.Std.ge(u,2.14))?2:f,S=r.Std.and(r.Std.lt(u,5),r.Std.ge(u,3.57))?1:v;return[1,r.Std.ge(u,5)?0:S]},this.main=function(e,t){return this._context=e,this._input=t,this.f_0()}}},{name:"Choppiness Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:61.8},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:38.2}],filledAreasStyle:{fill_0:{color:"#2196F3",transparency:90,visible:!0}},inputs:{in_0:14}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1}}, -description:"Choppiness Index",shortDescription:"CHOP",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_1",name:"LowerLimit",zorder:-1.11}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",title:"Hlines Background",zorder:-2}],inputs:[{id:"in_0",name:"length",defval:14,type:"integer",min:1,max:2e3}],id:"Choppiness Index@tv-basicstudies-1",scriptIdPart:"",name:"Choppiness Index",format:{type:"price",precision:2},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t,i,s){return 100*r.Std.log10(e/(t-i))/s},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=r.Std.atr(1,this._context),n=this._context.new_var(s),o=r.Std.sum(n,i,this._context),a=r.Std.high(this._context),l=this._context.new_var(a),c=r.Std.highest(l,i,this._context),h=r.Std.low(this._context),d=this._context.new_var(h),u=r.Std.lowest(d,i,this._context),p=r.Std.log10(i);return[this.f_0(o,c,u,p)]}}},{name:"Commodity Channel Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},smoothedMA:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:100},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:-100}],filledAreasStyle:{fill_0:{color:"#2196F3",transparency:90,visible:!0}},inputs:{in_0:20,smoothingLine:"SMA",smoothingLength:20}},plots:[{id:"plot_0",type:"line"},{id:"smoothedMA",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:2},smoothedMA:{title:"Smoothed MA",histogramBase:0,joinPoints:!1,zorder:1}},description:"Commodity Channel Index",shortDescription:"CCI",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_1",name:"LowerLimit",zorder:-1.11}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",title:"Hlines Background",zorder:-2}],inputs:[{id:"in_0",name:"length",defval:20,type:"integer",min:1,max:2e3},{id:"smoothingLine",name:"Smoothing Line",defval:"SMA",type:"text",options:["SMA","EMA","WMA"]},{id:"smoothingLength",name:"Smoothing Length",defval:20,type:"integer",min:1,max:1e4}],id:"Commodity Channel Index@tv-basicstudies-1",scriptIdPart:"",name:"Commodity Channel Index",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t,i){return(e-t)/(.015*i)},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.hlc3(this._context),s=this._input(0),n=this._input(1),o=this._input(2);this._context.setMinimumAdditionalDepth(s+o);var a,l=this._context.new_var(i),c=r.Std.sma(l,s,this._context),h=this._context.new_var(i),d=r.Std.dev(h,s,this._context),u=this.f_0(i,c,d),p=this._context.new_var(u);return"EMA"===n?a=r.Std.ema(p,o,this._context):"WMA"===n?a=r.Std.wma(p,o,this._context):"SMA"===n&&(a=r.Std.sma(p,o,this._context)),[u,a]}}},{name:"Connors RSI",metainfo:{_metainfoVersion:52, -isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:70},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:30}],filledAreasStyle:{fill_0:{color:"#2196F3",transparency:90,visible:!0}},inputs:{in_0:3,in_1:2,in_2:100}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"CRSI",histogramBase:0,joinPoints:!1,zorder:1}},description:"Connors RSI",shortDescription:"CRSI",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_1",name:"LowerLimit",zorder:-1.11}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",title:"Hlines Background",zorder:-2}],inputs:[{id:"in_0",name:"RSI Length",defval:3,type:"integer",min:1},{id:"in_1",name:"UpDown Length",defval:2,type:"integer",min:1},{id:"in_2",name:"ROC Length",defval:100,type:"integer",min:1}],id:"Connors RSI@tv-basicstudies-1",scriptIdPart:"",name:"Connors RSI",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){var e;this.f_1=function(e,t,i){var s=i.new_var(r.Std.max(r.Std.change(e),0));return r.Std.rma(s,t,i)},this.f_2=function(e,t,i){var s=i.new_var(-r.Std.min(r.Std.change(e),0));return r.Std.rma(s,t,i)},this.f_3=(e=0,function(t){var i=t.get(0),s=t.get(1);return e=i===s?0:i>s?r.Std.nz(e)<=0?1:r.Std.nz(e)+1:r.Std.nz(e)>=0?-1:r.Std.nz(e)-1,this._context.new_var(e)}),this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.close(this._context),s=this._context.new_var(i),n=this._input(0),o=this._input(1),a=this._input(2);this._context.setMinimumAdditionalDepth(a);var l=r.Std.rsi(this.f_1(s,n,this._context),this.f_2(s,n,this._context)),c=this.f_3(s),h=r.Std.rsi(this.f_1(c,o,this._context),this.f_2(c,o,this._context)),d=this._context.new_var(r.Std.roc(s,1)),u=r.Std.percentrank(d,a);return[r.Std.avg(l,h,u)]}}},{name:"Coppock Curve",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:10,in_1:14,in_2:11}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Coppock Curve",shortDescription:"Coppock Curve",is_price_study:!1,inputs:[{id:"in_0",name:"WMA Length",defval:10,type:"integer",min:-1e12,max:5e3},{id:"in_1",name:"Long RoC Length",defval:14,type:"integer",min:1,max:4999},{id:"in_2",name:"Short RoC Length",defval:11,type:"integer",min:1,max:4999}],id:"Coppock Curve@tv-basicstudies-1",scriptIdPart:"",name:"Coppock Curve",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return e+t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=this._input(2);this._context.setMinimumAdditionalDepth(i+Math.max(s,n)) -;var o=r.Std.close(this._context),a=this._context.new_var(o),l=r.Std.roc(a,s),c=this._context.new_var(o),h=r.Std.roc(c,n),d=this.f_0(l,h),u=this._context.new_var(d);return[r.Std.wma(u,i,this._context)]}}},{name:"Correlation Coeff",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:4,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:"",in_1:20}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Correlation Coefficient",shortDescription:"CC",is_price_study:!1,inputs:[{id:"in_0",name:"sym",defval:"",type:"symbol"},{id:"in_1",name:"length",defval:20,type:"integer",min:1,max:2e3}],id:"Correlation Coeff@tv-basicstudies-1",scriptIdPart:"",name:"Correlation Coeff",format:{precision:2,type:"price"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this._context.new_sym(this._input(0),r.Std.period(this._context))},this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_unlimited_var(this._context.symbol.time),s=(this._input(0),r.Std.period(this._context),r.Std.close(this._context)),n=this._input(1);this._context.select_sym(1);var o=this._context.new_unlimited_var(this._context.symbol.time),a=r.Std.close(this._context),l=this._context.new_unlimited_var(a);this._context.select_sym(0);var c=l.adopt(o,i,0),h=this._context.new_var(s),d=this._context.new_var(c);return[r.Std.correlation(h,d,n,this._context)]}}},{name:"Correlation - Log",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!1,id:"Correlation - Log@tv-basicstudies-1",scriptIdPart:"",name:"Correlation - Log",description:"Correlation - Log",shortDescription:"Correlation - Log",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#2196F3"}},inputs:{instrument:"",instrument2:"",periods:25}},styles:{plot_0:{title:"Plot"}},inputs:[{id:"instrument",name:"Instrument 1",type:"symbol",defval:"",confirm:!0},{id:"instrument2",name:"Instrument 2",type:"symbol",defval:"",confirm:!0},{id:"periods",name:"Periods",type:"integer",defval:25}],format:{precision:2,type:"price"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this._context.new_sym(this._input(0),r.Std.period(this._context)),this._context.new_sym(this._input(1),r.Std.period(this._context)),this.period=this._input(2)},this.correlationLog=function(e,t,i,s){var n=r.Std.sma(e,i,s),o=r.Std.sma(t,i,s),a=s.new_var(e.get()*t.get());return(r.Std.sma(a,i,s)-n*o)/Math.sqrt(r.Std.variance2(e,n,i)*r.Std.variance2(t,o,i))},this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_var(this._context.symbol.time);this._context.select_sym(2);var s=this._context.new_var(r.Std.close(this._context)),n=this._context.new_var(r.Std.log(s.get()/s.get(1))),o=this._context.new_var(this._context.symbol.time);this._context.select_sym(1) -;var a=this._context.new_var(this._context.symbol.time),l=this._context.new_var(r.Std.close(this._context)),c=this._context.new_var(r.Std.log(l.get()/l.get(1))),h=this._context.new_var(n.adopt(o,a,0)),d=this._context.new_var(this.correlationLog(c,h,this.period,this._context)),u=this._context.new_var(d.adopt(a,i,0)).get(),p=r.Std.round(1e3*u)/1e3;return this._context.select_sym(0),[p]}}},{name:"Detrended Price Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#43A047"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{in_0:21,in_1:!1}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"DPO",histogramBase:0,joinPoints:!1,isHidden:!1,zorder:1}},description:"Detrended Price Oscillator",shortDescription:"DPO",is_price_study:!1,is_hidden_study:!1,id:"detrended_price_oscillator@tv-basicstudies-1",bands:[{id:"hline_0",name:"Zero",isHidden:!1,zorder:-1}],inputs:[{id:"in_0",name:"Period",defval:21,type:"integer",min:1,max:1e12},{id:"in_1",name:"isCentered",defval:!1,type:"bool"}],scriptIdPart:"",name:"Detrended Price Oscillator",format:{type:"price",precision:2},usePlotsZOrder:!0},constructor:function(){this.f_0=function(){var e=this._input(0),t=this._input(1),i=Math.floor(e/2+1);this._context.setMinimumAdditionalDepth(e+i);var s=this._context.new_var(r.Std.close(this._context)),n=this._context.new_var(r.Std.sma(s,e,this._context)),o=this._context.new_var(r.Std.close(this._context)).get(i)-n,a=r.Std.close(this._context)-n.get(i);return[t?o:a,t?-i:0]},this.main=function(e,t){this._context=e,this._input=t;var i=this.f_0();return[{value:i[0],offset:i[1]}]}}},{name:"Directional Movement Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"},plot_3:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#F50057"},plot_2:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FFA726"},plot_4:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#ab47bc"}},inputs:{in_0:14,in_1:14}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"},{id:"plot_3",type:"line"},{id:"plot_4",type:"line"}],styles:{plot_0:{title:"+DI",histogramBase:0,joinPoints:!1},plot_1:{title:"-DI",histogramBase:0,joinPoints:!1},plot_2:{title:"DX",histogramBase:0,joinPoints:!1},plot_3:{title:"ADX",histogramBase:0,joinPoints:!1},plot_4:{title:"ADXR",histogramBase:0,joinPoints:!1}},description:"Directional Movement",shortDescription:"DMI",is_price_study:!1,inputs:[{id:"in_0",name:"DI Length",defval:14,type:"integer",min:1,max:2e3},{id:"in_1",name:"ADX Smoothing",defval:14,type:"integer",min:1,max:50}], -id:"Directional Movement Index@tv-basicstudies-1",scriptIdPart:"",name:"Directional Movement Index",format:{precision:4,type:"price"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1);return this._context.setMinimumAdditionalDepth(2*i+s),r.Std.dmi(i,s,this._context)}}},{name:"Donchian Channels",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_2:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"}},filledAreasStyle:{fill_0:{color:"#2196F3",transparency:95,visible:!0}},inputs:{in_0:20}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"Lower",histogramBase:0,joinPoints:!1},plot_1:{title:"Upper",histogramBase:0,joinPoints:!1},plot_2:{title:"Basis",histogramBase:0,joinPoints:!1}},description:"Donchian Channels",shortDescription:"DC",is_price_study:!0,filledAreas:[{id:"fill_0",objAId:"plot_1",objBId:"plot_0",type:"plot_plot",title:"Plots Background"}],inputs:[{id:"in_0",name:"length",defval:20,type:"integer",min:1,max:2e3}],id:"Donchian Channels@tv-basicstudies-1",scriptIdPart:"",name:"Donchian Channels",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=r.Std.low(this._context),n=this._context.new_var(s),o=r.Std.lowest(n,i,this._context),a=r.Std.high(this._context),l=this._context.new_var(a),c=r.Std.highest(l,i,this._context);return[o,c,r.Std.avg(c,o)]}}},{name:"Double Exponential Moving Average",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#43A047"}},inputs:{in_0:9}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Double EMA",shortDescription:"DEMA",is_price_study:!0,inputs:[{id:"in_0",name:"length",defval:9,type:"integer",min:1,max:1e4}],id:"Double Exponential Moving Average@tv-basicstudies-1",scriptIdPart:"",name:"Double Exponential Moving Average",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return 2*e-t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0);this._context.setMinimumAdditionalDepth(2*i);var s=r.Std.close(this._context),n=this._context.new_var(s),o=r.Std.ema(n,i,this._context),a=this._context.new_var(o),l=r.Std.ema(a,i,this._context);return[this.f_0(o,l)]}}},{name:"Ease of Movement",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#43A047"}},inputs:{in_0:1e4,in_1:14}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot", -histogramBase:0,joinPoints:!1}},description:"Ease Of Movement",shortDescription:"EOM",is_price_study:!1,inputs:[{id:"in_0",name:"Divisor",defval:1e4,type:"integer",min:1,max:1e9},{id:"in_1",name:"length",defval:14,type:"integer",min:1,max:2e3}],id:"Ease of Movement@tv-basicstudies-1",scriptIdPart:"",name:"Ease of Movement",format:{type:"volume"}},constructor:function(){this.f_0=function(e,t,i,s,r){return e*t*(i-s)/r},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=r.Std.hl2(this._context),o=this._context.new_var(n),a=r.Std.change(o),l=this.f_0(i,a,r.Std.high(this._context),r.Std.low(this._context),r.Std.volume(this._context)),c=this._context.new_var(l);return[r.Std.sma(c,s,this._context)]}}},{name:"Elders Force Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:a}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{in_0:13}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1}},description:"Elder's Force Index",shortDescription:"EFI",is_price_study:!1,bands:[{id:"hline_0",name:"Zero",zorder:-1}],inputs:[{id:"in_0",name:"length",defval:13,type:"integer",min:1,max:2e3}],id:"Elders Force Index@tv-basicstudies-1",scriptIdPart:"",name:"Elders Force Index",format:{type:"volume"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t){return e*t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=r.Std.close(this._context),n=this._context.new_var(s),o=r.Std.change(n),a=this.f_0(o,r.Std.volume(this._context)),l=this._context.new_var(a);return[r.Std.ema(l,i,this._context)]}}},{name:"EMA Cross",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#43A047"},plot_2:{linestyle:0,linewidth:4,plottype:3,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:9,in_1:26}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"Short",histogramBase:0,joinPoints:!1},plot_1:{title:"Long",histogramBase:0,joinPoints:!1},plot_2:{title:"Crosses",histogramBase:0,joinPoints:!1}},description:"EMA Cross",shortDescription:"EMA Cross",is_price_study:!0,inputs:[{id:"in_0",name:"Short",defval:9,type:"integer",min:1,max:2e3},{id:"in_1",name:"Long",defval:26,type:"integer",min:1,max:2e3}],id:"EMA Cross@tv-basicstudies-1",scriptIdPart:"",name:"EMA Cross",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return e?t:r.Std.na()},this.main=function(e,t){this._context=e,this._input=t -;var i=this._input(0),s=this._input(1),n=r.Std.close(this._context),o=this._context.new_var(n),a=r.Std.ema(o,i,this._context),l=this._context.new_var(n),c=r.Std.ema(l,s,this._context),h=a,d=c,u=r.Std.cross(a,c,this._context);return[h,d,this.f_0(u,a)]}}},{name:"Envelopes",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_2:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},filledAreasStyle:{fill_0:{color:"#2196F3",transparency:95,visible:!0}},inputs:{in_0:20,in_1:10,in_2:10,in_3:"Simple",in_4:"close"}},plots:[{id:"plot_1",type:"line"},{id:"plot_0",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"Average",histogramBase:0,joinPoints:!1},plot_1:{title:"Upper",histogramBase:0,joinPoints:!1},plot_2:{title:"Lower",histogramBase:0,joinPoints:!1}},description:"Envelopes",shortDescription:"Envelopes",is_price_study:!0,filledAreas:[{id:"fill_0",objAId:"plot_1",objBId:"plot_2",type:"plot_plot",title:"Plots Background"}],inputs:[{id:"in_0",name:"Length",defval:20,type:"integer",min:1,max:2e3},{id:"in_1",name:"Upper Percentage",defval:2,type:"float",min:0},{id:"in_2",name:"Lower Percentage",defval:2,type:"float",min:0},{id:"in_3",name:"Method",type:"text",defval:"Simple",options:["Simple","Exponential","Weighted"]},{id:"in_4",name:"Source",defval:"close",type:"source",options:["open","high","low","close","hl2","hlc3","ohlc4"]}],id:"Envelope@tv-basicstudies-1",scriptIdPart:"",name:"Envelopes",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return e*(1+t)},this.f_1=function(e,t){return e*(1-t)},this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_var(r.Std[this._input(4)](this._context)),s=r.Std.sma(i,this._input(0),this._context);return"Exponential"===this._input(3)?s=r.Std.ema(i,this._input(0),this._context):"Weighted"===this._input(3)&&(s=r.Std.wma(i,this._input(0),this._context)),[this.f_0(s,this._input(1)/100),s,this.f_1(s,this._input(2)/100)]}}},{name:"Standard Error",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!1,id:"Standard Error@tv-basicstudies-1",scriptIdPart:"",name:"Standard Error",description:"Standard Error",shortDescription:"Standard Error",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#FF6D00"}},inputs:{length:14}},styles:{plot_0:{title:"Plot"}},inputs:[{id:"length",type:"integer",name:"Length",min:3}],format:{precision:2,type:"price"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this.period=this._input(0)},this.main=function(e,t){this._context=e,this._input=t;for(var i,s,n=this._context.new_var(r.Std.close(this._context)),o=0,a=0,l=0;l0?1:3,i=r.Std.change(this._context.new_var(e));return t-(r.Std.le(i,0)?0:1)},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std[this._input(2)](this._context),s=this._input(0),n=this._input(1),o=this._input(3);this._context.setMinimumAdditionalDepth(Math.max(s,n)+o);var a=this._context.new_var(i),l=r.Std.ema(a,s,this._context),c=this._context.new_var(i),h=r.Std.ema(c,n,this._context),d=this.f_0(l,h),u=this._context.new_var(d),p=r.Std.ema(u,o,this._context),_=this.f_0(d,p);return[_,d,p,this.f_1(_)]}}},{name:"Moving Average Exponential",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},smoothedMA:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1}},inputs:{length:9,source:"close",offset:0,smoothingLine:"SMA",smoothingLength:9}},plots:[{id:"plot_0",type:"line"},{id:"smoothedMA",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1},smoothedMA:{title:"Smoothed MA",histogramBase:0,joinPoints:!1}},description:"Moving Average Exponential",shortDescription:"EMA",is_price_study:!0,inputs:[{id:"length",name:"Length",defval:9,type:"integer",min:1,max:1e4},{id:"source",name:"Source",defval:"close",type:"source",options:["open","high","low","close","hl2","hlc3","ohlc4"]},{id:"offset",name:"Offset",defval:0,type:"integer",min:-1e4,max:1e4},{id:"smoothingLine",name:"Smoothing Line",defval:"SMA",type:"text",options:["SMA","EMA","WMA"]},{id:"smoothingLength",name:"Smoothing Length",defval:9,type:"integer",min:1,max:1e4}],id:"Moving Average Exponential@tv-basicstudies-1",scriptIdPart:"",name:"Moving Average Exponential",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=r.Std[this._input(1)](this._context),s=this._input(0),n=this._input(2),o=this._input(3),a=this._input(4);this._context.setMinimumAdditionalDepth(s+a);var l,c=this._context.new_var(i),h=r.Std.ema(c,s,this._context),d=this._context.new_var(h);return"EMA"===o?l=r.Std.ema(d,a,this._context):"WMA"===o?l=r.Std.wma(d,a,this._context):"SMA"===o&&(l=r.Std.sma(d,a,this._context)),[{value:h,offset:n},{value:l,offset:n}]}}},{name:"Moving Average Weighted",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1, -is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:9,in_1:"close",in_2:0}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Moving Average Weighted",shortDescription:"WMA",is_price_study:!0,inputs:[{id:"in_0",name:"Length",defval:9,type:"integer",min:1,max:2e3},{id:"in_1",name:"Source",defval:"close",type:"source",options:["open","high","low","close","hl2","hlc3","ohlc4"]},{id:"in_2",name:"Offset",defval:0,type:"integer",min:-1e4,max:1e4}],id:"Moving Average Weighted@tv-basicstudies-1",scriptIdPart:"",name:"Moving Average Weighted",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=r.Std[this._input(1)](this._context),s=this._input(0),n=this._input(2),o=this._context.new_var(i);return[{value:r.Std.wma(o,s,this._context),offset:n}]}}},{name:"Moving Average Double",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,id:"Moving Average Double@tv-basicstudies-1",scriptIdPart:"",name:"Moving Average Double",description:"Moving Average Double",shortDescription:"Moving Average Double",is_price_study:!0,plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#FF6D00"},plot_1:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#2196F3"}},inputs:{firstPeriods:14,secondPeriods:21,method:"Simple"}},styles:{plot_0:{title:"Plot 1"},plot_1:{title:"Plot 2"}},inputs:[{id:"firstPeriods",name:"1st Period",type:"integer",defval:14,min:1,max:1e4},{id:"secondPeriods",name:"2nd Period",type:"integer",defval:21,min:1,max:1e4},{id:"method",name:"Method",type:"text",defval:"Simple",options:["Simple","Exponential","Weighted"]}],format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i,s,n=this._context.new_var(r.Std.close(this._context));return"Exponential"===this._input(2)?(i=r.Std.ema(n,this._input(0),this._context),s=r.Std.ema(n,this._input(1),this._context)):"Weighted"===this._input(2)?(i=r.Std.wma(n,this._input(0),this._context),s=r.Std.wma(n,this._input(1),this._context)):(i=r.Std.sma(n,this._input(0),this._context),s=r.Std.sma(n,this._input(1),this._context)),[i,s]}}},{name:"Moving Average Triple",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!0,id:"Moving Average Triple@tv-basicstudies-1",scriptIdPart:"",name:"Moving Average Triple",description:"Moving Average Triple",shortDescription:"Moving Average Triple",plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,transparency:0,trackPrice:!1,color:"#FF6D00"},plot_1:{linestyle:0,visible:!0,linewidth:1,transparency:0,plottype:0,trackPrice:!1,color:"#2196F3"},plot_2:{linestyle:0,visible:!0,linewidth:1, -transparency:0,plottype:0,trackPrice:!1,color:"#26C6DA"}},inputs:{firstPeriods:14,secondPeriods:21,thirdPeriods:35,method:"Simple"}},styles:{plot_0:{title:"Plot 1"},plot_1:{title:"Plot 2"},plot_2:{title:"Plot 3"}},inputs:[{id:"firstPeriods",name:"1st Period",type:"integer",defval:14,min:1,max:1e4},{id:"secondPeriods",name:"2nd Period",type:"integer",defval:21,min:1,max:1e4},{id:"thirdPeriods",name:"3rd Period",type:"integer",defval:35,min:1,max:1e4},{id:"method",name:"Method",type:"text",defval:"Simple",options:["Simple","Exponential","Weighted"]}],format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i,s,n,o=this._context.new_var(r.Std.close(this._context));return"Exponential"===this._input(3)?(i=r.Std.ema(o,this._input(0),this._context),s=r.Std.ema(o,this._input(1),this._context),n=r.Std.ema(o,this._input(2),this._context)):"Weighted"===this._input(3)?(i=r.Std.wma(o,this._input(0),this._context),s=r.Std.wma(o,this._input(1),this._context),n=r.Std.wma(o,this._input(2),this._context)):(i=r.Std.sma(o,this._input(0),this._context),s=r.Std.sma(o,this._input(1),this._context),n=r.Std.sma(o,this._input(2),this._context)),[i,s,n]}}},{name:"Moving Average Adaptive",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!0,id:"Moving Average Adaptive@tv-basicstudies-1",scriptIdPart:"",name:"Moving Average Adaptive",description:"Moving Average Adaptive",shortDescription:"Moving Average Adaptive",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,transparency:0,trackPrice:!1,color:"#AB47BC"}},inputs:{periods:10}},styles:{plot_0:{title:"Plot 1"}},inputs:[{id:"periods",name:"Period",type:"integer",defval:10,min:2,max:1e4}],format:{type:"inherit"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this.periods=this._input(0)},this.ama=function(e,t){var i=this.periods,s=this._context.new_var(),n=e.get(),o=r.Std.stdev(t,i,this._context),a=r.Std.log(n/e.get(i))/(o*Math.sqrt(i)),l=.1*Math.abs(a),c=(n-s.get(1))*l+s.get(1);return s.set(isNaN(c)?n:c),c},this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_var(r.Std.close(this._context)),s=this._context.new_var(r.Std.log(i.get()/i.get(1)));return[this.ama(i,s)]}}},{name:"Moving Average Hamming",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!0,id:"Moving Average Hamming@tv-basicstudies-1",scriptIdPart:"",name:"Moving Average Hamming",description:"Moving Average Hamming",shortDescription:"Moving Average Hamming",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,transparency:0,trackPrice:!1,color:"#4CAF50"}},inputs:{periods:10}},styles:{plot_0:{title:"Plot 1"}},inputs:[{id:"periods",name:"Period",type:"integer",defval:10,min:1,max:1e4}],format:{type:"inherit"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this.periods=this._input(0) -;for(var i=[],s=0,r=1;r<=this.periods;++r){var n=Math.sin((1+r)/this.periods*Math.PI/2);i.unshift(n),s+=n}this.hmaFactors=i,this.hmaFactorsSum=s},this.hma=function(e){for(var t=this.periods,i=0,s=0;sthis._context.new_var(s).get(1)?1:0,[100*r.Std.sma(this._context.new_var(i),this.rollingPeriod,this._context)]}}},{name:"Net Volume",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Net Volume",shortDescription:"Net Volume",is_price_study:!1,inputs:[],id:"Net Volume@tv-basicstudies-1",scriptIdPart:"",name:"Net Volume",format:{type:"volume"}},constructor:function(){this.f_0=function(e,t,i){return r.Std.gt(e,0)?t:r.Std.lt(i,0)?-t:0*t},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.close(this._context),s=this._context.new_var(i),n=r.Std.change(s);return[this.f_0(n,r.Std.volume(this._context),n)]}}},{name:"On Balance Volume",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},smoothedMA:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1}},inputs:{smoothingLine:"SMA",smoothingLength:9}},plots:[{id:"plot_0",type:"line"},{id:"smoothedMA",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1},smoothedMA:{title:"Smoothed MA",histogramBase:0,joinPoints:!1}},description:"On Balance Volume",shortDescription:"OBV",is_price_study:!1,inputs:[{id:"smoothingLine",name:"Smoothing Line",defval:"SMA",type:"text",options:["SMA","EMA","WMA"]},{id:"smoothingLength",name:"Smoothing Length",defval:9,type:"integer",min:1,max:1e4}],id:"On Balance Volume@tv-basicstudies-1",scriptIdPart:"",name:"On Balance Volume",format:{type:"volume"}},constructor:function(){this.f_0=function(e,t,i){return r.Std.gt(e,0)?t:r.Std.lt(i,0)?-t:0*t},this.main=function(e,t){this._context=e, -this._input=t;var i=this._input(0),s=this._input(1),n=r.Std.close(this._context),o=this._context.new_var(n),a=r.Std.change(o),l=this.f_0(a,r.Std.volume(this._context),a),c=r.Std.cum(l,this._context);this._context.setMinimumAdditionalDepth(s);var h,d=this._context.new_var(c);return"EMA"===i?h=r.Std.ema(d,s,this._context):"WMA"===i?h=r.Std.wma(d,s,this._context):"SMA"===i&&(h=r.Std.sma(d,s,this._context)),[c,h]}}},{name:"Parabolic SAR",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:3,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:.02,in_1:.02,in_2:.2}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Parabolic SAR",shortDescription:"SAR",is_price_study:!0,inputs:[{id:"in_0",name:"start",defval:.02,type:"float",min:-1e12,max:1e12},{id:"in_1",name:"increment",defval:.02,type:"float",min:-1e12,max:1e12},{id:"in_2",name:"maximum",defval:.2,type:"float",min:-1e12,max:1e12}],id:"Parabolic SAR@tv-basicstudies-1",scriptIdPart:"",name:"Parabolic SAR",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=this._input(2);return[r.Std.sar(i,s,n,this._context)]}}},{name:"Price Channel",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#F50057"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#F50057"},plot_2:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:20,in_1:0}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"Highprice Line",histogramBase:0,joinPoints:!1},plot_1:{title:"Lowprice Line",histogramBase:0,joinPoints:!1},plot_2:{title:"Centerprice Line",histogramBase:0,joinPoints:!1}},description:"Price Channel",shortDescription:"PC",is_price_study:!0,inputs:[{id:"in_0",name:"Length",defval:20,type:"integer",min:1,max:2e3},{id:"in_1",name:"Offset Length",defval:0,type:"integer",min:1,max:2e3}],id:"Price Channel@tv-basicstudies-1",scriptIdPart:"",name:"Price Channel",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.high(this._context),s=this._context.new_var(i),n=r.Std.low(this._context),o=this._context.new_var(n),a=this._input(0),l=this._input(1),c=r.Std.highest(s,a,this._context),h=r.Std.lowest(o,a,this._context);return[{value:c,offset:l},{value:h,offset:l},{value:r.Std.avg(c,h),offset:l}]}}},{name:"Price Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:u}},inputs:{in_0:10,in_1:21}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0, -joinPoints:!1}},description:"Price Oscillator",shortDescription:"PPO",is_price_study:!1,inputs:[{id:"in_0",name:"shortlen",defval:10,type:"integer",min:1,max:2e3},{id:"in_1",name:"longlen",defval:21,type:"integer",min:1,max:2e3}],id:"Price Oscillator@tv-basicstudies-1",scriptIdPart:"",name:"Price Oscillator",format:{type:"price",precision:2}},constructor:function(){this.f_0=function(e,t){return(e-t)/t*100},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.close(this._context),s=this._input(0),n=this._input(1),o=this._context.new_var(i),a=r.Std.sma(o,s,this._context),l=this._context.new_var(i),c=r.Std.sma(l,n,this._context);return[this.f_0(a,c)]}}},{name:"Price Volume Trend",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"PVT",histogramBase:0,joinPoints:!1,isHidden:!1}},description:"Price Volume Trend",shortDescription:"PVT",is_price_study:!1,is_hidden_study:!1,id:"price_volume_trend@tv-basicstudies-1",inputs:[],scriptIdPart:"",name:"Price Volume Trend",format:{type:"volume"}},constructor:function(){this.f_0=function(){var e=this._context.new_var(r.Std.close(this._context));return[r.Std.cum(r.Std.change(e)/e.get(1)*r.Std.volume(this._context),this._context)]},this.main=function(e,t){return this._context=e,this._input=t,[this.f_0()[0]]}}},{name:"Rate Of Change",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{in_0:9}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"ROC",histogramBase:0,joinPoints:!1,isHidden:!1,zorder:1}},description:"Rate Of Change",shortDescription:"ROC",is_price_study:!1,bands:[{id:"hline_0",name:"Zero Line",isHidden:!1,zorder:-1}],inputs:[{id:"in_0",name:"length",defval:9,type:"integer",min:1,max:1e12}],id:"rate_of_change@tv-basicstudies-1",scriptIdPart:"",name:"Rate Of Change",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_var(r.Std.close(this._context)),s=this._input(0);return[100*(i.get(0)-i.get(s))/i.get(s)]}}},{name:"Relative Strength Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#7E57C2"},smoothedMA:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:70,zorder:-1.1},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:50,zorder:-1.11},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:30,zorder:-1.111}],filledAreasStyle:{fill_0:{color:"#7E57C2",transparency:90,visible:!0}},inputs:{length:14, -smoothingLine:"SMA",smoothingLength:14}},plots:[{id:"plot_0",type:"line"},{id:"smoothedMA",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1},smoothedMA:{title:"Smoothed MA",histogramBase:0,joinPoints:!1,zorder:2}},description:"Relative Strength Index",shortDescription:"RSI",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_2",name:"MiddleLimit",zorder:-1.11},{id:"hline_1",name:"LowerLimit",zorder:-1.111}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",title:"Hlines Background",zorder:-2}],inputs:[{id:"length",name:"Length",defval:14,type:"integer",min:1,max:2e3},{id:"smoothingLine",name:"Smoothing Line",defval:"SMA",type:"text",options:["SMA","EMA","WMA"]},{id:"smoothingLength",name:"Smoothing Length",defval:14,type:"integer",min:1,max:1e4}],id:"Relative Strength Index@tv-basicstudies-1",scriptIdPart:"",name:"Relative Strength Index",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e){return r.Std.max(e,0)},this.f_1=function(e){return-r.Std.min(e,0)},this.f_2=function(e,t){return r.Std.eq(e,0)?100:r.Std.eq(t,0)?0:100-100/(1+t/e)},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.close(this._context),s=this._input(0),n=this._input(1),o=this._input(2);this._context.setMinimumAdditionalDepth(s+o);var a,l=this._context.new_var(i),c=r.Std.change(l),h=this.f_0(c),d=this._context.new_var(h),u=r.Std.rma(d,s,this._context),p=this.f_1(c),_=this._context.new_var(p),m=r.Std.rma(_,s,this._context),g=this.f_2(m,u),f=this._context.new_var(g);return"EMA"===n?a=r.Std.ema(f,o,this._context):"WMA"===n?a=r.Std.wma(f,o,this._context):"SMA"===n&&(a=r.Std.sma(f,o,this._context)),[{value:g},{value:a}]}}},{name:"Relative Vigor Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:u},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:a}},inputs:{in_0:10}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],styles:{plot_0:{title:"RVGI",histogramBase:0,joinPoints:!1},plot_1:{title:"Signal",histogramBase:0,joinPoints:!1}},description:"Relative Vigor Index",shortDescription:"RVGI",is_price_study:!1,inputs:[{id:"in_0",name:"Length",defval:10,type:"integer",min:1,max:2e3}],id:"Relative Vigor Index@tv-basicstudies-1",scriptIdPart:"",name:"Relative Vigor Index",format:{precision:4,type:"price"}},constructor:function(){this.f_0=function(e,t){return e-t},this.f_1=function(e,t){return e/t},this.main=function(e,t){this._context=e,this._input=t +this._hist[this._histPos]=this.original}reset_hist(){this._hist=null,this.add_hist()}adopt(e,t,i){this._hist||(this.mindepth=NaN);const s=t.get();let n=e.indexOf(s);if(0!==i){const i=t.get(1);if(!r.Std.na(i)){n=n===e.indexOf(i)?-1:n}}return n<0?NaN:this._get(n)}indexOf(e){if(!this._hist)return this.mindepth=NaN,-1;if(r.Std.na(e))return-1;const t=this._hist.length,i=this.symbol.index+1,n=Math.min(t,i),o=(0,s.upperbound_int)(this._hist,e,0,n);return 0===o?-1:n-o}_get(e){if(null===this._hist)return NaN;let t=this._histPos-e;return t<0&&(t+=this._hist.length),this._hist[t]}}class o extends n{add_hist(){if(this._hist||(this._hist=new Float64Array(2e3),this._histPos=-1),this._histPos=this._histPos+1,this._histPos===this._hist.length){const e=new Float64Array(2*this._hist.length);e.set(this._hist),this._hist=e}this._hist[this._histPos]=this.original}}},46544:(e,t,i)=>{"use strict";const s=i(14483),r=i(48891).getHexColorByName;var n=i(74649);i(24172);var o=i(82808).pivotPointsStandardStudyItem,a=i(72365).volumeProfileVisibleRangeStudyItem,l=i(82597).volumeProfileFixedRangeVbPStudyItem,c=i(82597).volumeProfileFixedRangeBSStudyItem,h=i(39944).spreadStudyItem,d=i(81821).ratioStudyItem,u=i(65097).regressionTrendStudyItem,p=i(53130).anchoredVWAPStudyItem;const _=r("color-ripe-red-400"),m=r("color-minty-green-400"),g=s.enabled("secondary_series_extend_time_scale");JSServer.studyLibrary=JSServer.studyLibrary.concat([{name:"Compare",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!0,defaults:{styles:{compare:{linestyle:0,linewidth:2,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#9C27B0"}},inputs:{source:"close",symbol:""}},plots:[{id:"compare",type:"line"}],styles:{compare:{title:"Plot",histogramBase:0}},description:"Compare",shortDescription:"Compare",is_price_study:!0,inputs:[{defval:"close",id:"source",name:"Source",options:["open","high","low","close","hl2","hlc3","ohlc4"],type:"text"},{id:"symbol",name:"Symbol",type:"symbol",isHidden:!0}],id:"Compare@tv-basicstudies-1",format:{type:"inherit"}},constructor:function(){this.init=function(e,t){this._context=e,this._context.new_sym(t(1),n.Std.period(this._context))},this.main=function(e,t){this._context=e;var i=this._context.new_unlimited_var(this._context.symbol.time);this._context.select_sym(1);var s=this._context.new_unlimited_var(this._context.symbol.time),r=n.Std[t(0)](this._context),o=this._context.new_unlimited_var(r);return this._context.select_sym(0),[o.adopt(s,i,0)]}}},{name:"Overlay",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!0,defaults:{styles:{},inputs:{symbol:"",extendTimeScale:!1}},plots:[{id:"open",type:"line"},{id:"high",type:"line"},{id:"low",type:"line"},{id:"close",type:"line"}],styles:{open:{title:"Open"},high:{title:"High"},low:{title:"Low"},close:{title:"Close"}},description:"Overlay",shortDescription:"Overlay",is_price_study:!1,inputs:[{id:"symbol",name:"symbol",defval:"",type:"symbol",isHidden:!0},{id:"extendTimeScale",name:"extendTimeScale",defval:!1,type:"boolean",isHidden:!0}], +id:"Overlay@tv-basicstudies-1",format:{type:"price",precision:4},canExtendTimeScale:!0},constructor:function(){this.init=function(e,t){this._context=e,this._context.new_sym(t(0),n.Std.period(this._context))},this.main=function(e,t){this._context=e;var i=!g||!0!==t(1),s=this._context.new_unlimited_var(this._context.symbol.time);this._context.select_sym(1);var r=this._context.new_unlimited_var(this._context.symbol.time),o=this._context.new_unlimited_var(n.Std.open(this._context)),a=this._context.new_unlimited_var(n.Std.high(this._context)),l=this._context.new_unlimited_var(n.Std.low(this._context)),c=this._context.new_unlimited_var(n.Std.close(this._context));return i?(this._context.select_sym(0),[o.adopt(r,s,1),a.adopt(r,s,1),l.adopt(r,s,1),c.adopt(r,s,1)]):[o.get(0),a.get(0),l.get(0),c.get(0)]}}},{name:"Volume",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{vol:{linestyle:0,linewidth:1,plottype:5,trackPrice:!1,transparency:50,visible:!0,color:"#000080"},vol_ma:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1,color:"#2196F3"},smoothedMA:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1,color:"#2196F3"}},palettes:{volumePalette:{colors:{0:{color:_,width:1,style:0},1:{color:m,width:1,style:0}}}},inputs:{showMA:!1,length:20,col_prev_close:!1,symbol:"",smoothingLine:"SMA",smoothingLength:9}},plots:[{id:"vol",type:"line"},{id:"volumePalette",palette:"volumePalette",target:"vol",type:"colorer"},{id:"vol_ma",type:"line"},{id:"smoothedMA",type:"line"}],styles:{vol:{title:"Volume",histogramBase:0},vol_ma:{title:"Volume MA",histogramBase:0},smoothedMA:{title:"Smoothed MA",histogramBase:0}},description:"Volume",shortDescription:"Volume",is_price_study:!1,palettes:{volumePalette:{colors:{0:{name:"Falling"},1:{name:"Growing"}}}},inputs:[{id:"symbol",name:"Other Symbol",defval:"",type:"symbol",optional:!0,isHidden:!1},{id:"showMA",name:"show MA",defval:!1,type:"bool",isHidden:!0},{id:"length",name:"MA Length",defval:20,type:"integer",min:1,max:2e3},{defval:!1,id:"col_prev_close",name:"Color based on previous close",type:"bool"},{id:"smoothingLine",name:"Smoothing Line",defval:"SMA",type:"text",options:["SMA","EMA","WMA"]},{id:"smoothingLength",name:"Smoothing Length",defval:9,type:"integer",min:1,max:1e4}],id:"Volume@tv-basicstudies-1",format:{type:"volume"}},constructor:function(){this.init=function(e,t){this._context=e,""!==t(0)&&this._context.new_sym(t(0),n.Std.period(this._context))},this.f_0=function(e,t){return n.Std.gt(e,t)?0:1},this.main=function(e,t){this._context=e,this._input=t;var i=n.Std.volume(this._context),s=n.Std.open(this._context),r=n.Std.close(this._context),o=this._context.new_var(this._context.symbol.time),a=this._input(4),l=this._input(5);if(this._context.setMinimumAdditionalDepth(this._input(2)+l),""!==this._input(0)){this._context.select_sym(1) +;var c=this._context.new_var(this._context.symbol.time),h=this._context.new_var(n.Std.volume(this._context)),d=this._context.new_var(n.Std.open(this._context)),u=this._context.new_var(n.Std.close(this._context));i=h.adopt(c,o,1),s=d.adopt(c,o,1),r=u.adopt(c,o,1),this._context.select_sym(0)}var p,_,m=this._context.new_var(i),g=n.Std.sma(m,this._input(2),this._context),f=this._context.new_var(g),v=this._context.new_var(r);return p=v.get(1)&&this._input(3)?this.f_0(v.get(1),r):this.f_0(s,r),"EMA"===a?_=n.Std.ema(f,l,this._context):"WMA"===a?_=n.Std.wma(f,l,this._context):"SMA"===a&&(_=n.Std.sma(f,l,this._context)),[i,p,g,_]}}},{name:"ZigZag",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:2,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:5,in_1:10}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",target:"plot_0",type:"dataoffset"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Zig Zag",shortDescription:"ZigZag",is_price_study:!0,classId:"ScriptWithDataOffset",inputs:[{id:"in_0",name:"deviation",defval:5,type:"float",min:.001,max:100},{id:"in_1",name:"depth",defval:10,type:"integer",min:2,max:1e3}],id:"ZigZag@tv-basicstudies-1",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),r=i/100,o=Math.ceil(s/2);return[n.Std.zigzag(r,o,this._context),n.Std.zigzagbars(r,o,this._context)]}}},{name:"Sessions",metainfo:{_metainfoVersion:52,defaults:{graphics:{vertlines:{sessBreaks:{color:"#4985e7",style:2,visible:!1,width:1}},backgrounds:{preMarket:{color:"#FF9800",transparency:92,visible:!0},postMarket:{color:"#2196F3",transparency:92,visible:!0}}},linkedToSeries:!0},description:"Sessions",graphics:{vertlines:{sessBreaks:{name:"Session Break",halign:"left"}},backgrounds:{preMarket:{name:"Pre market"},postMarket:{name:"Post market"}}},id:"Sessions@tv-basicstudies-1",inputs:[],is_hidden_study:!0,is_price_study:!0,name:"Sessions@tv-basicstudies",palettes:{},plots:[],shortDescription:"Sessions",format:{type:"inherit"}},constructor:function(){function e(e,t){return{id:e,index:e,extendBottom:!0,extendTop:!0}}function t(e){return{id:e.start,start:e.start,stop:e.stop}}this.init=function(){this._times=[]},this._getVerticalLineData=function(t){return n.Std.selectSessionBreaks(t,this._times).map(e)},this._getPreAndPostMarketBackgroundsData=function(e){const i=n.Std.selectPreAndPostMarketTimes(e,this._times);return{preMarket:i.preMarket.map(t),postMarket:i.postMarket.map(t)}},this.main=function(e,t){if(n.Std.isdwm(e))return null;var i=n.Std.time(e);if(isNaN(i))return null;var s=this._times.length;if(0!==s&&this._times[s-1]===i||this._times.push(i),!e.symbol.isLastBar||!e.symbol.isNewBar)return null;var r=this._getVerticalLineData(e),o=this._getPreAndPostMarketBackgroundsData(e);return 0===r.length&&0===o.preMarket.length&&0===o.postMarket?null:{nonseries:!0,type:"study_graphics",data:{graphicsCmds:{create:{vertlines:[{ +styleId:"sessBreaks",data:r}],backgrounds:[{styleId:"preMarket",data:o.preMarket},{styleId:"postMarket",data:o.postMarket}]},erase:[{action:"all"}]}}}}}},{name:"SuperTrend",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:3,plottype:0,trackPrice:!1,transparency:35,visible:!0,color:"#000080"},plot_2:{linestyle:0,linewidth:3,plottype:"shape_arrow_up",trackPrice:!1,location:"BelowBar",transparency:35,visible:!0,color:"#00FF00"},plot_3:{linestyle:0,linewidth:3,plottype:"shape_arrow_down",trackPrice:!1,location:"AboveBar",transparency:35,visible:!0,color:"#FF0000"}},palettes:{palette_0:{colors:{0:{color:"#008000",width:3,style:0},1:{color:"#800000",width:3,style:0}}}},inputs:{in_0:10,in_1:3}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",palette:"palette_0",target:"plot_0",type:"colorer"},{id:"plot_2",type:"shapes"},{id:"plot_3",type:"shapes"}],styles:{plot_0:{title:"SuperTrend",histogramBase:0,joinPoints:!1,isHidden:!1},plot_2:{title:"Up Arrow",histogramBase:0,joinPoints:!1,isHidden:!1},plot_3:{title:"Down Arrow",histogramBase:0,joinPoints:!1,isHidden:!1}},description:"SuperTrend",shortDescription:"SuperTrend",is_price_study:!0,palettes:{palette_0:{colors:{0:{name:"Color 0"},1:{name:"Color 1"}},valToIndex:{0:0,1:1}}},inputs:[{id:"in_0",name:"Length",defval:10,type:"integer",min:1,max:100},{id:"in_1",name:"Factor",defval:3,type:"float",min:1,max:100}],id:"SuperTrend@tv-basicstudies-1",scriptIdPart:"",name:"SuperTrend",isCustomIndicator:!0,format:{type:"inherit"}},constructor:function(){this.main=function(e,t){var i=t(0),s=t(1),[r,o]=n.Std.supertrend(s,i,e),a=e.new_var(o).get(1);return[r,-1===o?0:1,-1===o&&a!==o?1:NaN,1===o&&a!==o?1:NaN]}}},o,a,l,c,h,d,u,p])},81337:(e,t,i)=>{"use strict";i.d(t,{Std:()=>h});var s=i(60156),r=i(41249);class n{constructor(e,t,i){var s,r;this._timezone=e,this._preMarketSessionEntries=null!==(s=null==t?void 0:t.entries())&&void 0!==s?s:[],this._postMarketSessionEntries=null!==(r=null==i?void 0:i.entries())&&void 0!==r?r:[]}getPreAndPostMarketTimes(e){if(0===e.length)return{preMarket:[],postMarket:[]};const t=[],i=[];let s=null,n=null,o=e[0],a=(0,r.utc_to_cal)(this._timezone,o);this._isInPreMarketSession(a)&&(n=o),this._isInPostMarketSession(a)&&(s=o);for(let l=1;le?1:0,h={};function d(e,t,i,s,r){let n=r,o=0;if(isNaN(e.get(t-1)))return{index:NaN,value:NaN};for(let i=0;ie.symbol.index+1,h.nz=(e,t=0)=>isFinite(e)?e:t,h.na=function(e){return 0===arguments.length?NaN:isNaN(e)?1:0},h.isZero=e=>Math.abs(e)<=1e-10?1:0,h.toBool=e=>isFinite(e)&&!h.isZero(e),h.eq=(e,t)=>h.isZero(e-t),h.neq=(e,t)=>c(!h.eq(e,t)),h.ge=(e,t)=>c(h.isZero(e-t)||e>t),h.gt=(e,t)=>c(!h.isZero(e-t)&&e>t),h.lt=(e,t)=>c(!h.isZero(e-t)&&ec(h.isZero(e-t)||eisNaN(e)||isNaN(t)?NaN:h.isZero(e)||h.isZero(t)?0:1,h.or=(e,t)=>isNaN(e)||isNaN(t)?NaN:h.isZero(e)&&h.isZero(t)?0:1,h.not=e=>isNaN(e)?NaN:h.isZero(e)?1:0,h.eps=()=>l,h.greaterOrEqual=(e,t,i)=>t-e<(i||l),h.lessOrEqual=(e,t,i)=>e-t<(i||l),h.equal=(e,t,i)=>Math.abs(e-t)<(i||l),h.greater=(e,t,i)=>e-t>(i||l),h.less=(e,t,i)=>t-e>(i||l),h.compare=(e,t,i)=>h.equal(e,t,i)?0:h.greater(e,t,i)?1:-1,h.max=Math.max,h.min=Math.min,h.pow=Math.pow,h.abs=Math.abs,h.log=Math.log,h.log10=e=>Math.log(e)/Math.LN10,h.sqrt=Math.sqrt,h.sign=e=>isNaN(e)?NaN:h.isZero(e)?0:e>0?1:-1,h.exp=Math.exp,h.sin=Math.sin,h.cos=Math.cos,h.tan=Math.tan,h.asin=Math.asin,h.acos=Math.acos,h.atan=Math.atan,h.floor=Math.floor,h.ceil=Math.ceil,h.round=Math.round,h.avg=(...e)=>{if(2===e.length)return(e[0]+e[1])/2;let t=0;for(let i=0;ie.symbol.open,h.high=e=>e.symbol.high,h.low=e=>e.symbol.low,h.close=e=>e.symbol.close,h.hl2=e=>(e.symbol.high+e.symbol.low)/2,h.hlc3=e=>(e.symbol.high+e.symbol.low+e.symbol.close)/3,h.ohlc4=e=>(e.symbol.open+e.symbol.high+e.symbol.low+e.symbol.close)/4,h.volume=e=>e.symbol.volume,h.updatetime=e=>e.symbol.updatetime,h.time=e=>e.symbol.bartime(),h.period=e=>e.symbol.period,h.tickerid=e=>e.symbol.tickerid,h.currencyCode=e=>e.symbol.currencyCode,h.unitId=e=>e.symbol.unitId,h.ticker=e=>e.symbol.ticker,h.interval=e=>e.symbol.interval,h.isdwm=e=>e.symbol.isdwm(),h.isintraday=e=>!e.symbol.isdwm(),h.isdaily=e=>"D"===e.symbol.resolution,h.isweekly=e=>"W"===e.symbol.resolution,h.ismonthly=e=>"M"===e.symbol.resolution,h.year=(e,t)=>h.timepart(e.symbol,r.YEAR,t),h.month=(e,t)=>h.timepart(e.symbol,r.MONTH,t),h.weekofyear=(e,t)=>h.timepart(e.symbol,r.WEEK_OF_YEAR,t),h.dayofmonth=(e,t)=>h.timepart(e.symbol,r.DAY_OF_MONTH,t),h.dayofweek=(e,t)=>h.timepart(e.symbol,r.DAY_OF_WEEK,t),h.hour=(e,t)=>h.timepart(e.symbol,r.HOUR_OF_DAY,t),h.minute=(e,t)=>h.timepart(e.symbol,r.MINUTE,t),h.second=(e,t)=>h.timepart(e.symbol,r.SECOND,t),h.add_days_considering_dst=(e,t,i)=>r.add_days_considering_dst(r.get_timezone(e),t,i),h.add_years_considering_dst=(e,t,i)=>r.add_years_considering_dst(r.get_timezone(e),t,i),h.selectSessionBreaks=(e,t)=>{if(h.isdwm(e)||void 0===e.symbol.session.timezone)return[];const i=(0, +s.newBarBuilder)(e.symbol.period,e.symbol.session,null),r=[],n=t.length;if(i.moveTo(t[n-1]),1===n&&i.startOfBar(0)===t[0])r.push(t[0]);else{for(let e=n-2;e>=0;--e){const s=t[e];if(s>=i.startOfBar(0))continue;i.moveTo(s);const n=t[e+1];r.push(n)}r.reverse()}return r},h.selectPreAndPostMarketTimes=(e,t)=>{var i,s;if(h.isdwm(e)||void 0===e.symbol.session.timezone)return{preMarket:[],postMarket:[]};return new n(e.symbol.session.timezone,null!==(i=e.symbol.preMarketSubsession)&&void 0!==i?i:null,null!==(s=e.symbol.postMarketSubsession)&&void 0!==s?s:null).getPreAndPostMarketTimes(t)},h.iff=(e,t,i)=>h.not(e)?i:t,h.rising=(e,t)=>{for(let i=1;ie.get(0))return 0;return 1},h.falling=(e,t)=>{for(let i=1;i{const s=r.utc_to_cal(e.session.timezone,i||e.bartime());return r.get_part(s,t)},h.rsi=(e,t)=>h.isZero(t)?100:h.isZero(e)?0:100-100/(1+e/t),h.sum=(e,t,i)=>{const s=i.new_var(),r=h.nz(e.get())+h.nz(s.get(1))-h.nz(e.get(t));return s.set(r),r},h.sma=(e,t,i)=>{const s=h.sum(e,t,i);return h.na(e.get(t-1))?NaN:s/t},h.smma=(e,t,i)=>{const s=i.new_var(e),r=h.sma(s,t,i),n=i.new_var(),o=(n.get(1)*(t-1)+e)/t;return n.set(h.na(n.get(1))?r:o),n.get(0)},h.rma=(e,t,i)=>{const s=h.sum(e,t,i),r=t-1,n=e.get(r),o=i.new_var(),a=o.get(1),l=e.get(),c=h.na(n)?NaN:h.na(a)?s/t:(l+a*r)/t;return o.set(c),c},h.fixnan=(e,t)=>{const i=t.new_var();return isNaN(e)?i.get(1):(i.set(e),e)},h.tr=(e,t)=>{let i=t.new_var(h.close(t)).get(1);return e&&isNaN(i)&&(i=h.close(t)),h.max(h.max(h.high(t)-h.low(t),h.abs(h.high(t)-i)),h.abs(h.low(t)-i))},h.atr=(e,t)=>{const i=t.new_var(h.tr(void 0,t));return h.rma(i,e,t)},h.ema=(e,t,i)=>{const s=h.sum(e,t,i),r=i.new_var(),n=e.get(0),o=e.get(t-1),a=r.get(1),l=h.na(o)?NaN:h.na(a)?s/t:2*(n-a)/(t+1)+a;return r.set(l),l},h.wma=(e,t,i)=>{let s=0;for(let i=t=Math.round(t);i>=0;i--){s+=(t-i)*e.get(i)}return 2*s/(t*(t+1))},h.vwma=(e,t,i)=>{const s=i.new_var(h.volume(i)),r=i.new_var(e.get(0)*h.volume(i));return h.sma(r,t,i)/h.sma(s,t,i)},h.swma=(e,t)=>(e.get(0)+2*e.get(1)+2*e.get(2)+e.get(3))/6,h.supertrend=(e,t,i)=>{const s=h.atr(t,i),r=i.new_var(s).get(1),n=h.hl2(i);let o=n+s*e,a=n-s*e;const l=h.close(i),c=i.new_var(l).get(1),d=i.new_var(),u=h.nz(d.get(1)),p=i.new_var(),_=h.nz(p.get(1));a=h.gt(a,u)||h.lt(c,u)?a:u,d.set(a),o=h.lt(o,_)||h.gt(c,_)?o:_,p.set(o);let m=h.na();const g=i.new_var(),f=g.get(1);m=h.na(r)?1:f===_?l>o?-1:1:l-d(e,t,0,((e,t)=>h.lt(e,t)),Number.MAX_VALUE).index,h.lowest=(e,t,i)=>d(e,t,0,((e,t)=>h.lt(e,t)),Number.MAX_VALUE).value,h.highestbars=(e,t,i)=>-d(e,t,0,((e,t)=>h.gt(e,t)),Number.MIN_VALUE).index,h.highest=(e,t,i)=>d(e,t,0,((e,t)=>h.gt(e,t)),Number.MIN_VALUE).value,h.cum=(e,t)=>{const i=t.new_var(),s=h.nz(i.get(1))+e;return i.set(s),s},h.accdist=e=>{const t=h.high(e),i=h.low(e),s=h.close(e),r=h.volume(e);return h.cum(s===t&&s===i||t===i?0:r*(2*s-i-t)/(t-i),e)},h.correlation=(e,t,i,s)=>{ +const r=h.sma(e,i,s),n=h.sma(t,i,s),o=s.new_var(e.get()*t.get());return(h.sma(o,i,s)-r*n)/Math.sqrt(h.variance2(e,r,i)*h.variance2(t,n,i))},h.stoch=(e,t,i,s,r)=>{const n=h.highest(t,s,r),o=h.lowest(i,s,r);return h.fixnan(100*(e.get()-o)/(n-o),r)},h.tsi=(e,t,i,s)=>{const r=s.new_var(h.change(e)),n=s.new_var(h.abs(h.change(e))),o=s.new_var(h.ema(r,i,s)),a=s.new_var(h.ema(n,i,s));return h.ema(o,t,s)/h.ema(a,t,s)},h.cross=(e,t,i)=>{if(isNaN(e)||isNaN(t))return!1;const s=i.new_var((r=e-t)<0?-1:0===r?0:1);var r;return!isNaN(s.get(1))&&s.get(1)!==s.get()},h.linreg=(e,t,i)=>{let s=0,r=0,n=0,o=0;for(let i=0;i{const r=s.new_var(),n=s.new_var(),o=s.new_var(),a=h.high(s),l=h.low(s),c=h.close(s),d=s.new_var(a),u=s.new_var(l),p=s.new_var(c),_=s.new_var();let m=_.get(1),g=n.get(1),f=o.get(1);n.set(g),o.set(f);let v=!1;const S=u.get(1),y=u.get(2),b=d.get(1),w=d.get(2),P=p.get(),C=p.get(1);2===h.n(s)&&(h.greater(P,C)?(r.set(1),o.set(d.get()),m=S,f=d.get()):(r.set(-1),o.set(u.get()),m=b,f=u.get()),v=!0,n.set(e),g=e);let x=m+g*(f-m);return 1===r.get()?h.greater(x,u.get())&&(v=!0,r.set(-1),x=Math.max(d.get(),o.get()),o.set(u.get()),n.set(e)):h.less(x,d.get())&&(v=!0,r.set(1),x=Math.min(u.get(),o.get()),o.set(d.get()),n.set(e)),v||(1===r.get()?h.greater(d.get(),o.get())&&(o.set(d.get()),n.set(Math.min(n.get()+t,i))):h.less(u.get(),o.get())&&(o.set(u.get()),n.set(Math.min(n.get()+t,i)))),1===r.get()?(x=Math.min(x,S),h.n(s)>2&&(x=Math.min(x,y))):(x=Math.max(x,b),h.n(s)>2&&(x=Math.max(x,w))),_.set(x),x},h.alma=(e,t,i,s)=>{const r=Math.floor(i*(t-1)),n=t/s*(t/s),o=[];let a=0;for(let e=0;ee.get()-e.get(1),h.roc=(e,t)=>{const i=e.get(t);return 100*(e.get()-i)/i},h.dev=(e,t,i)=>{const s=h.sma(e,t,i);return h.dev2(e,t,s)},h.dev2=(e,t,i)=>{let s=0;for(let r=0;r{const s=h.variance(e,t,i);return h.sqrt(s)},h.variance=(e,t,i)=>{const s=h.sma(e,t,i);return h.variance2(e,s,t)},h.variance2=(e,t,i)=>{let s=0;for(let r=0;r{if(h.na(e.get(t-1)))return NaN;let i=0;const s=e.get();for(let r=1;r{if(void 0===e.symbol.session.timezone)return()=>!1;const t=(0,s.newBarBuilder)(e.symbol.period,e.symbol.session,null);return e=>t.indexOfBar(e)===o.SessionStage.POST_SESSION&&(t.moveTo(e),!0)},h.error=e=>{throw new a(e)},h.dmi=(e,t,i)=>{const s=i.new_var(h.high(i)),r=i.new_var(h.low(i)),n=h.change(s),o=-h.change(r),a=i.new_var(h.na(n)||h.na(o)?h.na():h.and(h.gt(n,o),h.gt(n,0))?n:0),l=i.new_var(h.na(o)?h.na():h.and(h.gt(o,n),h.gt(o,0))?o:0),c=h.atr(e,i),d=h.fixnan(100*h.rma(a,e,i)/c,i),u=h.fixnan(100*h.rma(l,e,i)/c,i);let p=d+u;h.isZero(p)&&(p+=1) +;const _=Math.abs(d-u)/p*100,m=i.new_var(_),g=h.rma(m,t,i),f=i.new_var(g);return[d,u,_,g,(f.get(0)+f.get(e-1))/2]},h.zigzag=(e,t,i)=>new m(e,t,i).lastPrice(),h.zigzagbars=(e,t,i)=>{const s=new m(e,t,i);return-1===s.lastIndex()?NaN:s.lastIndex()-h.n(i)};const u=0,p=1;class _{constructor(e,t,i,s,r){this._areaRight=e,this._areaLeft=t,this._pivotType=i,this._series=s,this._currentIndex=r.new_var(0),this._currentValue=r.new_var(NaN),this._pivotIndex=r.new_var(-1),this._index=h.n(r),this._isNewBar=r.symbol.isNewBar;const n=this._currentIndex.get(1),o=this._currentValue.get(1),a=this._pivotIndex.get(1);this._index>1&&(this._currentIndex.set(n),this._currentValue.set(o),this._pivotIndex.set(a))}isPivotFound(){return-1!==this._pivotIndex.get()}pivotIndex(){return this._pivotIndex.get()}currentValue(){return this._currentValue.get()}pivotType(){return this._pivotType}reset(){this._currentValue.set(NaN),this._currentIndex.set(0),this._pivotIndex.set(-1)}isRightSideOk(e){return e-this._currentIndex.get()===this._areaRight}isViolate(e,t){if(e<1||isNaN(this._currentValue.get()))return!0;const i=this._series.get(this._index-e);return!!isNaN(i)||(i===this._currentValue.get()?t:this._pivotType===p?i>this._currentValue.get():ithis._areaRight}update(){if(this._isNewBar&&this.isPivotFound()&&this.reset(),this.processPoint(this._index),this.isRightSideOk(this._index)){if(-1===this._pivotIndex.get()){let e=!0;for(let t=0;t1&&this.addPivot(n,o,a),this.processPivot(this._pivotHigh),this.processPivot(this._pivotLow)}addPivot(e,t,i){this._lastIndex.set(e),this._lastVal.set(t),this._lastType.set(i)}updatePivot(e,t){this._lastIndex.set(e),this._lastVal.set(t)}lastPrice(){return this._lastVal.get()}lastIndex(){return this._lastIndex.get()}addPoint(e,t,i){if(isNaN(this._lastVal.get()))return void this.addPivot(e,t,i);const s=this._lastVal.get();if(this._lastType.get()===i){return void((i===p?t>s:tthis._deviation&&this.addPivot(e,t,i)}processPivot(e){e.update(),this._isBarClosed&&e.isPivotFound()&&this.addPoint(e.pivotIndex(),e.currentValue(),e.pivotType())}}}, +53130:(e,t,i)=>{"use strict";i.d(t,{anchoredVWAPStudyItem:()=>n});var s=i(50151),r=i(81337);const n={name:"Anchored VWAP",metainfo:{_metainfoVersion:51,description:"Anchored VWAP",shortDescription:"Anchored VWAP",format:{type:"inherit"},id:"AnchoredVWAP@tv-basicstudies-1",is_hidden_study:!0,is_price_study:!0,defaults:{inputs:{start_time:0,source:"hlc3"},styles:{VWAP:{color:"#1e88e5",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,display:15}}},inputs:[{defval:0,id:"start_time",isHidden:!0,max:253370764800,min:-253370764800,name:"Start time",type:"time"},{defval:"hlc3",id:"source",name:"Source",options:["open","high","low","close","hl2","hlc3","ohlc4"],type:"source"}],plots:[{id:"VWAP",type:"line"}],styles:{VWAP:{histogramBase:0,title:"VWAP"}}},constructor:class{constructor(){this._isNewSession=null,this._firstBarTime=0}init(e,t){this._firstBarTime=t(0),this._isNewSession=null}main(e,t,i){if(void 0===i)return[NaN];(0,s.assert)(e.symbol.time===i.time);const n=i.time;if(n&&n{"use strict";i.d(t,{pivotPointsStandardStudyItem:()=>d});var s=i(36274),r=i(47609),n=i(81337);class o{constructor(){this.p=NaN,this.r1=NaN,this.s1=NaN,this.r2=NaN,this.s2=NaN,this.r3=NaN,this.s3=NaN,this.r4=NaN,this.s4=NaN,this.r5=NaN,this.s5=NaN,this.startIndex__t=NaN,this.endIndex__t=NaN}}class a{constructor(){this.pivots=[]}}function l(e,t){e.setUTCMonth(e.getUTCMonth()+t)}function c(e,t){if(n.Std.ismonthly(e)){let i=new Date(t);return i.getUTCDay()=1&&t.multiplier()<=15?"1D":"1W";case s.ResolutionKind.Seconds:case s.ResolutionKind.Ticks:return"1D"}throw new Error("Unexpected resolution type: "+e.symbol.resolution)}(e);case"Daily":return"1D";case"Weekly":return"1W";case"Monthly":return"1M";case"Yearly":return"12M";default:throw new Error("No such pivTimeFrame: "+t)}}const d={name:"Pivot Points Standard",metainfo:{_metainfoVersion:44,defaults:{inputs:{kind:"Traditional",lookBack:15,pivTimeFrame:"Auto",showHistoricalPivots:!0},precision:"4"},description:"Pivot Points Standard", +id:"PivotPointsStandard@tv-basicstudies-80",inputs:[{defval:"Traditional",id:"kind",name:"Type",options:["Traditional","Fibonacci","Woodie","Classic","DeMark","Camarilla","Floor"],type:"text"},{defval:!0,id:"showHistoricalPivots",name:"Show historical pivots",type:"bool"},{defval:"Auto",id:"pivTimeFrame",name:"Pivots Timeframe",options:["Auto","Daily","Weekly","Monthly","Yearly"],type:"text"},{defval:15,id:"lookBack",max:5e3,min:1,name:"Number of Pivots Back",type:"integer"}],is_price_study:!0,linkedToSeries:!0,shortDescription:"Pivots",format:{type:"price",precision:4}},constructor:class{constructor(){this._secondaryRes="1D",this._firstMainSeriesBarTime=NaN}init(e,t){const i=t(0),s=t(1),o=t(2),l=t(3);this._data=new a,this._firstMainSeriesBarTime=NaN,this._kindPP=function(e){switch(e){case"Traditional":return 0;case"Fibonacci":return 1;case"Woodie":return 2;case"Classic":return 3;case"DeMark":return 4;case"Camarilla":return 5;case"Floor":return 6;default:throw new Error("Unknown kind "+e)}}(i),this._showHistoricalPivots=s,this._historicalPivotsToKeep=l,this._pivTimeFrame=o,this._isValidResolution=function(e,t){return!(n.Std.isdaily(e)&&"Daily"===t||n.Std.isweekly(e)&&("Daily"===t||"Weekly"===t)||n.Std.ismonthly(e)&&("Daily"===t||"Weekly"===t||"Monthly"===t))}(e,this._pivTimeFrame),this._isValidResolution||n.Std.error("You cannot see this pivot timeframe on this resolution"),this._isValidResolution&&(this._secondaryRes=h(e,this._pivTimeFrame),void 0!==e.symbol.info&&(0,r.findSuitableResolutionToBuildFrom)(this._secondaryRes,e.symbol.info).error&&(this._isValidResolution=!1,n.Std.error(`Resolution ${this._secondaryRes} is not supported for this symbol`))),e.new_sym(e.symbol.tickerid,this._secondaryRes)}main(e,t,i){if(!this._isValidResolution)return null;if(e.is_main_symbol(i))return isNaN(this._firstMainSeriesBarTime)&&(this._firstMainSeriesBarTime=e.symbol.time,this._removeUnusedPivots()),e.symbol.isLastBar&&e.symbol.isNewBar?this._createResponse():null;e.select_sym(1);const s=e.new_var(n.Std.open(e)),r=e.new_var(n.Std.high(e)),a=e.new_var(n.Std.low(e)),l=e.new_var(n.Std.close(e)),h=e.new_var(n.Std.time(e)),d=this._data,u=s.get(0),p=h.get(0),_=s.get(1),m=r.get(1),g=a.get(1),f=l.get(1),v=e.symbol.isLastBar;if(0!==d.pivots.length&&e.symbol.isNewBar){const e=d.pivots[d.pivots.length-1];e.endIndex__t!==p&&(e.endIndex__t=p)}if(0===e.symbol.index||!e.symbol.isNewBar)return e.select_sym(0),null;const S=function(e,t,i,s,r,a,l,c){const h=new o;let d=NaN;const u=i-s;switch(c){case 0:d=(i+s+r)/3,h.p=d,h.r1=2*d-s,h.s1=2*d-i,h.r2=d+(i-s),h.s2=d-(i-s),h.r3=2*d+(i-2*s),h.s3=2*d-(2*i-s),h.r4=3*d+(i-3*s),h.s4=3*d-(3*i-s),h.r5=4*d+(i-4*s),h.s5=4*d-(4*i-s);break;case 1:d=(i+s+r)/3,h.p=d,h.r1=d+.382*u,h.s1=d-.382*u,h.r2=d+.618*u,h.s2=d-.618*u,h.r3=d+u,h.s3=d-u;break;case 2:d=(i+s+2*e)/4,h.p=d,h.r1=2*d-s,h.s1=2*d-i,h.r2=d+u,h.s2=d-u,h.r3=i+2*(d-s),h.s3=s-2*(i-d),h.r4=h.r3+u,h.s4=h.s3-u;break;case 3:d=(i+s+r)/3,h.p=d,h.r1=2*d-s,h.s1=2*d-i,h.r2=d+u,h.s2=d-u,h.r3=d+2*u,h.s3=d-2*u,h.r4=d+3*u,h.s4=d-3*u;break;case 4:let o=NaN +;o=n.Std.equal(t,r)?i+s+2*r:n.Std.greater(r,t)?2*i+s+r:2*s+i+r,d=o/4,h.p=d,h.r1=o/2-s,h.s1=o/2-i;break;case 5:d=(i+s+r)/3,h.p=d,h.r1=r+1.1*u/12,h.s1=r-1.1*u/12,h.r2=r+1.1*u/6,h.s2=r-1.1*u/6,h.r3=r+1.1*u/4,h.s3=r-1.1*u/4,h.r4=r+1.1*u/2,h.s4=r-1.1*u/2;break;case 6:d=(i+s+r)/3,h.p=d,h.r1=2*d-s,h.s1=2*d-i,h.r2=d+(i-s),h.s2=d-(i-s),h.r3=d-h.s1+h.r2,h.s3=2*d-(2*i-s);break;default:throw new Error("Unknown kind")}return h.startIndex__t=a,h.endIndex__t=l,h}(u,_,m,g,f,p,c(e,p),this._kindPP);return e.select_sym(0),this._showHistoricalPivots||(d.pivots=[]),d.pivots.push(S),d.pivots.length>this._historicalPivotsToKeep&&d.pivots.shift(),v?this._createResponse():null}_createResponse(){return 0===this._data.pivots.length?null:{nonseries:!0,type:"non_series_data",data:{data:this._data}}}_removeUnusedPivots(){const e=Math.max(this._data.pivots.findIndex((e=>e.startIndex__t>this._firstMainSeriesBarTime))-1,0);e>0&&this._data.pivots.splice(0,e)}}}},81821:(e,t,i)=>{"use strict";i.d(t,{ratioStudyItem:()=>n});var s=i(87302);class r extends s.SpreadRatioBase{_doCalculation(e,t,i,s){return e*t/(i*s)}}const n={name:"Ratio",metainfo:{_metainfoVersion:15,defaults:s.spreadRatioDefaults,plots:s.spreadRatioPlots,styles:s.spreadRatioStyles,description:"Ratio",shortDescription:"Ratio",is_price_study:!1,inputs:s.spreadRatioInputs,id:"Ratio@tv-basicstudies-1",format:{type:"price",precision:2}},constructor:r}},65097:(e,t,i)=>{"use strict";i.d(t,{regressionTrendStudyItem:()=>n});var s=i(81337);function r(e,t,i){const r={slope:NaN,average:NaN,intercept:NaN,stdDev:NaN,upDev:NaN,downDev:NaN,pearsons:NaN};return 0===e.length||(function(e,t){let i=0,s=0,r=0,n=0;for(let t=0;tn&&(n=u),u=d-i[s],u>o&&(o=u),u=e[s];const _=u-r.average,m=d-p;u-=d,a+=u*u,l+=_*_,c+=m*m,h+=_*m,d+=r.slope}r.stdDev=Math.sqrt(a/(0===u?1:u)),r.pearsons=s.Std.isZero(l)||s.Std.isZero(c)?0:h/Math.sqrt(l*c),r.upDev=n,r.downDev=o}(e,t,i,r)),r}const n={name:"Regression Trend",metainfo:{_metainfoVersion:51,description:"Regression Trend",format:{type:"inherit"},id:"RegressionTrend@tv-basicstudies-144",is_hidden_study:!0,is_price_study:!0,shortDescription:"Reg Trend",defaults:{inputs:{"first bar time":0,"last bar time":0,"lower diviation":-2,source:"close","upper diviation":2,"use lower diviation":!0,"use upper diviation":!0},styles:{}},inputs:[{defval:2,id:"upper diviation",max:500,min:-500,name:"Upper Deviation",type:"float"},{defval:-2,id:"lower diviation",max:500,min:-500,name:"Lower Deviation",type:"float"},{defval:!0,id:"use upper diviation",name:"Use Upper Deviation",type:"bool"},{defval:!0,id:"use lower diviation",name:"Use Lower Deviation",type:"bool"},{defval:0,id:"first bar time",isHidden:!0,max:253370764800,min:-253370764800,name:"First bar time",type:"time"},{defval:0, +id:"last bar time",isHidden:!0,max:253370764800,min:-253370764800,name:"Last bar time",type:"time"},{defval:"close",id:"source",name:"Source",options:["open","high","low","close","hl2","hlc3","ohlc4"],type:"source"}],plots:[]},constructor:class{constructor(){this._resultSent=!1}init(e,t){this._resultSent=!1,this._data={baseLine:{startPrice:NaN,endPrice:NaN},upLine:{startPrice:NaN,endPrice:NaN},downLine:{startPrice:NaN,endPrice:NaN},pearsons:NaN,startIndex__t:NaN,endIndex__t:NaN}}main(e,t){const i=t(6),n=e.new_unlimited_var(s.Std.time(e)),o=e.new_unlimited_var(s.Std.high(e)),a=e.new_unlimited_var(s.Std.low(e)),l=e.new_unlimited_var(s.Std[i](e));if(!e.symbol.isLastBar)return null;if(this._resultSent)return null;const c=t(0),h=t(1),d=t(2),u=t(3),p=t(4),_=t(5),m=n.indexOf(p),g=n.indexOf(_),f=[],v=[],S=[],y=[];for(let e=m;e>=g;--e)f.push(n.get(e)),v.push(o.get(e)),S.push(a.get(e)),y.push(l.get(e));return this._updateData(f,d,c,u,h,p,_,r(y,v,S)),this._resultSent=!0,{type:"non_series_data",nonseries:!0,data:{data:this._data}}}_updateData(e,t,i,s,r,n,o,a){const l=e.length-1;this._data.baseLine.startPrice=a.intercept,this._data.baseLine.endPrice=a.intercept+a.slope*l;const c=a.intercept+(t?a.stdDev*i:a.upDev);this._data.upLine.startPrice=c,this._data.upLine.endPrice=c+a.slope*l;const h=a.intercept+(s?a.stdDev*r:-a.downDev);this._data.downLine.startPrice=h,this._data.downLine.endPrice=h+a.slope*l,this._data.pearsons=a.pearsons,this._data.startIndex__t=n,this._data.endIndex__t=o}}}},87302:(e,t,i)=>{"use strict";i.d(t,{SpreadRatioBase:()=>r,spreadRatioDefaults:()=>n,spreadRatioInputs:()=>o,spreadRatioPlots:()=>a,spreadRatioStyles:()=>l});var s=i(81337);class r{init(e,t){e.new_sym(t(1),s.Std.period(e)),this._source=t(0),this._scaleFactor1=1,this._scaleFactor2=1}main(e,t){const i=e.symbol.time,r=s.Std[this._source](e);e.select_sym(1);const n=s.Std[this._source](e),o=e.new_unlimited_var(n),a=e.new_unlimited_var(e.symbol.time);if(e.select_sym(0),isNaN(i))return null;let l=a.indexOf(i);-1!==l&&a.get(l)!==i&&(l=-1);const c=l<0?NaN:o.get(l);return[this._doCalculation(this._scaleFactor1,r,this._scaleFactor2,c)]}}const n={styles:{plot1:{linestyle:0,linewidth:2,plottype:0,trackPrice:!1,transparency:35,color:"#800080",display:15}},precision:2,inputs:{source:"close",symbol2:""}},o=[{defval:"close",id:"source",name:"Source",options:["open","high","low","close","hl2","hlc3","ohlc4"],type:"text"},{id:"symbol2",name:"Symbol",type:"symbol",confirm:!0}],a=[{id:"plot1",type:"line"}],l={plot1:{title:"Plot",histogramBase:0}}},39944:(e,t,i)=>{"use strict";i.d(t,{spreadStudyItem:()=>n});var s=i(87302);class r extends s.SpreadRatioBase{_doCalculation(e,t,i,s){return e*t-i*s}}const n={name:"Spread",metainfo:{_metainfoVersion:15,defaults:s.spreadRatioDefaults,plots:s.spreadRatioPlots,styles:s.spreadRatioStyles,description:"Spread",shortDescription:"Spread",is_price_study:!1,inputs:s.spreadRatioInputs,id:"Spread@tv-basicstudies-1",format:{type:"price",precision:2}},constructor:r}},56437:(e,t,i)=>{"use strict";i.d(t,{VbPCheckHaveVolumeExpr:()=>r}) +;var s=i(81337);class r{constructor(e){this._haveAnyVolume=!1,this._isDisabled=!1,this._seriesGetter=e}update(e,t){if(this._haveAnyVolume||this._isDisabled)return;const i=this._seriesGetter.volume().get(e);0!==i&&Number.isFinite(i)&&(this._haveAnyVolume=!0),t&&(this._haveAnyVolume||s.Std.error("The data vendor doesn't provide volume data for this symbol."),this._isDisabled=!0)}}},89529:(e,t,i)=>{"use strict";i.d(t,{VolumeByPriceExpr:()=>_});var s=i(50151),r=i(37160),n=i(36274),o=i(29779);class a extends o.GraphicsObj{constructor(e,t,i,r,n,o){super(e),(0,s.assert)(t({index:e.index,offset:e.offset,level:e.level})))}}}class u extends o.GraphicsObj{constructor(e,t,i,s,r=!1,n=!1){super(e),this._endIndex=this._mixinJSONObject.createTimeField(i,"endIndex"),this._extendLeft=this._mixinJSONObject.createField(r,"extendLeft"),this._extendRight=this._mixinJSONObject.createField(n,"extendRight"),this._level=this._mixinJSONObject.createDoubleField(s,"level"),this._startIndex=this._mixinJSONObject.createTimeField(t,"startIndex")}isNaN(){return super.isNaN()||Number.isNaN(this._level.get())||this._startIndex.get()<0||this._endIndex.get()<0||this._startIndex.get()===this._endIndex.get()&&!this._extendLeft.get()&&!this._extendRight.get()}jsonName(){return"horizlines"}primitiveData(){return{id:this.id(),startIndex:this._startIndex.get(),endIndex:this._endIndex.get(),extendLeft:this._extendLeft.get(),extendRight:this._extendRight.get(),level:this._level.get()}}startIndex(){return this._startIndex.get()}setStartIndex(e){this._startIndex.set(e)&&this._processObjUpdate()}endIndex(){return this._endIndex.get()}setEndIndex(e){this._endIndex.set(e)&&this._processObjUpdate()}level(){return this._level.get()}setLevel(e){this._level.set(e)&&this._processObjUpdate()}isExtendLeft(){return this._extendLeft.get()}setExtendLeft(e){this._extendLeft.set(e)&&this._processObjUpdate()}extendLeft(){return this.isExtendLeft()}isExtendRight(){return this._extendRight.get()}setExtendRight(e){this._extendRight.set(e)&&this._processObjUpdate()}extendRight(){return this.isExtendRight()}}class p{constructor(){this._map=new Map}get(e){const t=this._innerMap(e.start);return t&&t.get(e.end)}set(e,t){this._innerMap(e.start,!0).set(e.end,t)}clear(){this._map.clear()}size(){let e=0;return this._map.forEach((t=>e+=t.size)),e}_innerMap(e,t){let i=this._map.get(e);return void 0===i&&t&&(i=new Map,this._map.set(e,i)),i}}class _{constructor(e,t,i,r,n,o,a,c,h,d,u,_,m,g,f){this._freezedBoxes=new l.GraphicsList,this._freezedHists=new l.GraphicsList,this._freezedPocs=new l.GraphicsList,this._freezedVAHists=new l.GraphicsList,this._currentHistsGr=new l.GraphicsList,this._currentVAHistsGr=new l.GraphicsList,this._currentHists=[],this._currentHistsMap=new p,this._currentBox=null,this._currentPoc=null,this._historyBarSet=[],this._prevRtBar=null,this._minPrice=Number.POSITIVE_INFINITY,this._maxPrice=Number.NEGATIVE_INFINITY,this._leftBoxTime=null,this._rightBoxTime=null,this._actualRightBoxTime=null,this._needRecalc=!1,this._largestHistItem=null,this._rowsLayout=null,this._currentVAStart=0,this._currentVAEnd=0,this._previousVAStart=0,this._previousVAEnd=0,this._idsGenerator=null,(0,s.assert)(1===e||2===e),this._numOfSubHists=e,this._outHists=r,this._outBoxLines=n,this._outPocLines=o,this._extendPocLeftRight=a,this._outVAHists=c,this._vaVolumePercent=h,this._rowsLayoutSupplier=d,this._outHists.addStable(this._freezedHists),this._outVAHists.addStable(this._freezedVAHists),this._maxHHistItems=u,this._layoutIsAutoselected=g,this._leftBoxTimeMutable=_, +this._rightBoxTimeMutable=m,this._actualRightBoxTime=null!=f?f:m,this._ctx=t,this._seriesGetter=i}update(e){this._supplyRowsLayout(this._ctx),null===this._currentBox&&this._initCurrentBox(),null===this._currentPoc&&this._initCurrentPoc();const t=this._timeScale().get(e);this._leftBoxTime=this._leftBoxTimeMutable,this._rightBoxTime=this._rightBoxTimeMutable,this._ctx.symbol.isLastBar&&!Number.isNaN(this._rightBoxTime)&&(this._rightBoxTime=Math.min(t+n.Interval.parse(this._ctx.symbol.interval+this._ctx.symbol.resolution).inMilliseconds(t)-1,this._rightBoxTime));const i=c.Std.greaterOrEqual(this._seriesClose().get(e),this._seriesOpen().get(e)),s={high:this._seriesHigh().get(e),low:this._seriesLow().get(e),volume:this._seriesVol().get(e),isUp:i,time:t};this._updateCurrentHistogram(s),this._currentHists.length>0&&(this._largestHistItem=this._getLargestHistItem(),this._updateCurrentPoc(),this._seriesGetter.developingPoc().set(this._currentPoc.level()),this._updateValueArea(),this._vaVolumePercent>0&&(this._seriesGetter.developingVAHigh().set(this._currentHists[this._currentVAEnd].priceHigh()),this._seriesGetter.developingVALow().set(this._currentHists[this._currentVAStart].priceLow()))),this._updateCurrentBox(),this._rebuildOutData()}setIdsGeneratorProxy(e){this._idsGenerator=e}nextGraphicsObjId(){return(0,s.ensureNotNull)(this._idsGenerator).nextGraphicsObjId()}pushEraseObjCmd(e,t){(0,s.ensureNotNull)(this._idsGenerator).pushEraseObjCmd(e,t)}popEraseCmds(){return(0,s.ensureNotNull)(this._idsGenerator).popEraseCmds()}_timeScale(){return this._seriesGetter.time()}_seriesLow(){return this._seriesGetter.low()}_seriesHigh(){return this._seriesGetter.high()}_seriesVol(){return this._seriesGetter.volume()}_seriesOpen(){return this._seriesGetter.open()}_seriesClose(){return this._seriesGetter.close()}_freezeCurrentHistogramAndCleanup(){null!==this._currentBox&&this._freezedBoxes.add(this._currentBox),c.Std.greater(this._getVolume(this._currentHists),0)&&(this._freezedHists.addAll(this._currentHistsGr),this._freezedVAHists.addAll(this._currentVAHistsGr),null!==this._currentPoc&&this._freezedPocs.add(this._currentPoc)),this._currentHists=[],this._currentHistsGr.clear(),this._currentHistsMap.clear(),this._initCurrentBox(),this._initCurrentPoc(),this._currentVAHistsGr.clear(),this._historyBarSet=[],this._minPrice=Number.POSITIVE_INFINITY,this._maxPrice=Number.NEGATIVE_INFINITY,this._prevRtBar=null,this._leftBoxTime=null,this._rightBoxTime=null}_supplyRowsLayout(e){null===this._rowsLayout&&e.symbol.isFirstBar&&e.symbol.isNewBar&&(this._rowsLayout=this._rowsLayoutSupplier())}_updateCurrentHistogram(e){if(this._needRecalc=!1,c.Std.greater(this._minPrice,e.low)&&(this._minPrice=e.low,this._needRecalc=!0),c.Std.less(this._maxPrice,e.high)&&(this._maxPrice=e.high,this._needRecalc=!0),this._ctx.symbol.isBarClosed&&this._historyBarSet.length>0){const t=this._historyBarSet[this._historyBarSet.length-1];t.time===e.time&&(this._prevRtBar=t,this._historyBarSet.pop())}this._needRecalc&&0===(0, +s.ensureNotNull)(this._rowsLayout).type()?(this._recalculateCurrentResultsOnHistoryBarSet(),this._applyUpdateToCurrentResults(e,!1)):this._applyUpdateToCurrentResults(e,!0),this._ctx.symbol.isBarClosed?((0,s.assert)(null===this._prevRtBar||e.time===this._prevRtBar.time),this._historyBarSet.push(e),this._prevRtBar=null):this._prevRtBar=e}_getMidLevel(e){return(e.priceHigh()+e.priceLow())/2}_getMidLevelFromList(e){return e.length%2==0?e[e.length/2].priceLow():this._getMidLevel(e[Math.floor(e.length/2)])}_getLargestHistItem(){let e=[],t=this._currentHists[0];for(const i of this._currentHists)c.Std.greater(i.ratesSum(),t.ratesSum())?(t=i,e=[t]):c.Std.equal(i.ratesSum(),t.ratesSum())&&e.push(i);if(e.length>1){const i=this._getMidLevelFromList(this._currentHists);t=e[e.length-1];for(let s=e.length-2;s>=0;s--){const r=e[s];c.Std.lessOrEqual(Math.abs(this._getMidLevel(r)-i),Math.abs(this._getMidLevel(t)-i))&&(t=r)}}return t}_initCurrentPoc(){this._currentPoc=new u(this,0,0,0)}_updateCurrentPoc(){const e=(0,s.ensureNotNull)(this._currentPoc);e.setStartIndex((0,s.ensureNotNull)(this._leftBoxTime)),e.setEndIndex((0,s.ensureNotNull)(this._actualRightBoxTime)),e.setExtendLeft(this._extendPocLeftRight),e.setExtendRight(this._extendPocLeftRight);const t=this._getMidLevel((0,s.ensureNotNull)(this._largestHistItem));e.setLevel(t)}_getVolume(e){let t=0;for(const i of e)t+=i.ratesSum();return t}_getPocHistItemIndex(){for(let e=0;e=0,`ERROR - PocHistItemIndex == ${e}`),this._currentVAStart=e-1,this._currentVAEnd=e+1;const t=this._getVolume(this._currentHists)*this._vaVolumePercent*.01;let i=this._currentHists[e].ratesSum(),r=0,n=null;for(;c.Std.lessOrEqual(i+r,t)&&(i+=r,0===n?--this._currentVAStart:1===n&&++this._currentVAEnd,-1!==this._currentVAStart||this._currentVAEnd!==this._currentHists.length);){let t,i;if(this._currentVAStart>-1)if(t=this._currentHists[this._currentVAStart].ratesSum(),this._currentVAEndthis._getMidLevel(this._currentHists[this._currentVAStart])&&e.priceLow()0&&(e=this._currentHists[0].priceLow(),t=this._currentHists[this._currentHists.length-1].priceHigh());const i=[],r=(0,s.ensureNotNull)(this._leftBoxTime),n=(0,s.ensureNotNull)(this._actualRightBoxTime);i.push(new h(r,e)),i.push(new h(r,t)),i.push(new h(n,t)),i.push(new h(n,e)),(0,s.ensureNotNull)(this._currentBox).setPoints(i)}_recalculateCurrentResultsOnHistoryBarSet(){for(let e=0;e0&&(this._largestHistItem=this._getLargestHistItem(),this._updateCurrentPoc()),this._updateCurrentBox()}_applyUpdateToCurrentResults(e,t){t&&null!==this._prevRtBar&&this._addHistoryBarToHistogram(this._prevRtBar,this._historyBarSet.length-1,this._currentHists,this._currentHistsMap,-1),this._addHistoryBarToHistogram(e,this._historyBarSet.length-1,this._currentHists,this._currentHistsMap,1),this._updateLastBarTimeInHistogram(this._currentHists)}_addHistoryBarToHistogram(e,t,i,r,n){(0,s.assert)(-1===n||1===n,"Please set sign argument either +1 or -1");const o=e.low,a=e.high,l=isNaN(e.volume)?0:e.volume,h=e.isUp,d=(0,s.ensureNotNull)(this._rowsLayout);d.init(this._ctx.symbol.minTick,this._minPrice,this._maxPrice,o,a);const u=d.rowWidth();if(!c.Std.greater(u,0))return;d.calculate();const p=d.getIndexLowVbP(),_=d.getIndexHighVbP(),m=d.getStartPrice();if(p===_){const e=p*u+m,t=(p+1)*u+m;this._updateResult({start:e,end:t},n*l,h,i,r)}else{let e=0;for(let t=p;t<=_;t++){const s=t*u+m,c=(t+1)*u+m,d=this._rowCoeff(s,c,o,a),p=d*l;e+=d,this._updateResult({start:s,end:c},n*p,h,i,r)}(0,s.assert)(c.Std.equal(e,1,.05),`totalCoeff not equal 1! totalConf = ${e}`)}}_updateResult(e,t,i,r,n){const o=this._createRates(i,t);(0,s.assert)(null!==this._leftBoxTime,"leftBoxTime is not set (equals null)"),(0,s.assert)(null!==this._rightBoxTime,"rightBoxTime is not set (equals null)");const l=(0,s.ensureNotNull)(this._leftBoxTime),h=(0,s.ensureNotNull)(this._actualRightBoxTime);let d=n.get(e);if(void 0===d)d=new a(this,e.start,e.end,o,l,h),n.set(e,d),this._verifyHistogramSizeIsNotTooLarge(n.size()), +this._currentHistsGr.add(d),_._addInOrder(d,r,0,r.length,((e,t)=>{let i=c.Std.compare(e.firstBarTime(),t.firstBarTime());return 0!==i?i:(i=c.Std.compare(e.priceLow(),t.priceLow()),0!==i?i:c.Std.compare(e.priceHigh(),t.priceHigh()))}));else{const e=[];for(let t=0;t0?_._addInOrder(e,t,o+1,s,n):t.splice(o,0,e)}}},19762:(e,t,i)=>{"use strict";i.d(t,{VolumeProfileBase:()=>u,maxHHistItems:()=>h,numOfSubHists:()=>d});var s=i(74649),r=i(36274);class n{constructor(e,t){this._minTick=NaN,this._minPrice=NaN,this._maxPrice=NaN,this._low=NaN,this._high=NaN,this._startPrice=NaN,this._indexLowVbP=NaN,this._indexHighVbP=NaN,this._rowSize=e,this._type=t}init(e,t,i,s,r){this._minTick=e,this._minPrice=t,this._maxPrice=i,this._low=s,this._high=r}getStartPrice(){return this._startPrice}setStartPrice(e){this._startPrice=e}getIndexLowVbP(){return this._indexLowVbP}setIndexLowVbP(e){this._indexLowVbP=e}getIndexHighVbP(){return this._indexHighVbP}setIndexHighVbP(e){this._indexHighVbP=e}type(){return this._type}}class o extends n{constructor(e){super(e,0)}calculate(){this.setStartPrice(this._minPrice);const e=this.rowWidth();let t=Math.floor((this._low-this._minPrice)/e),i=Math.ceil((this._high-this._minPrice)/e)-1;t=Math.max(t,0),i=Math.max(i,0),i=Math.min(i,this._rowSize-1),t=Math.min(t,i),this.setIndexLowVbP(t),this.setIndexHighVbP(i)}rowWidth(){ +return Math.max((this._maxPrice-this._minPrice)/this._rowSize,this._minTick)}}class a extends n{constructor(e){super(e,1)}calculate(){this.setStartPrice(0);const e=this.rowWidth();let t=Math.floor(this._low/e);const i=Math.ceil(this._high/e)-1;t=Math.min(t,i),this.setIndexLowVbP(t),this.setIndexHighVbP(i)}rowWidth(){return this._minTick*this._rowSize}}var l=i(14483),c=i(81337);function h(){return 6e3}function d(e){switch(e){case"Delta":case"Up/Down":return 2;case"Total":return 1;default:c.Std.error(`Invalid study argument value: ${e}`)}}class u{findBasicResolutionForFromTo(e,t,i,n){const o=(0,s.getVolumeProfileResolutionForPeriod)(e.value(),t,i,n),a=r.Interval.parse(o);return l.enabled("charting_library_debug_mode")&&console.log(`Selected resolution ${a.value()} for (${e.value()}, ${t}, ${i})`),a}verifyRowSizeInput(e,t){"Number Of Rows"===t&&e>6e3&&c.Std.error('Histogram is too large, please reduce "Row Size" input.')}_getRowsLayout(e,t){return"Number Of Rows"===e?new o(t):new a(t)}}},82597:(e,t,i)=>{"use strict";i.d(t,{volumeProfileFixedRangeBSStudyItem:()=>w,volumeProfileFixedRangeVbPStudyItem:()=>b});var s=i(50151),r=i(19762),n=i(72877),o=i(90164),a=i(36274),l=i(79999),c=i(748),h=i(43945),d=i(31584),u=i(1386),p=i(56437),_=i(95586),m=i(89529);class g extends m.VolumeByPriceExpr{constructor(e,t,i,s,r,n,o,a,l,c,h,d,u){super(e,t,i,n,o,a,!1,l,c,(()=>h),d,s,r,!1,u),this._firstBarTime=s,this._lastBarTime=r}update(e){this._supplyRowsLayout(this._ctx),this.timeInRequestedRange(e)&&super.update(e)}timeInRequestedRange(e){const t=this._timeScale().get(e);return this._firstBarTime<=t&&t=this._firstBarTime){const e=this._developingPocSeries.getLeftOrEqual(n),t=this._developingVAHighSeries.getLeftOrEqual(n),i=this._developingVALowSeries.getLeftOrEqual(n);r.data.push([e,t,i])}else r.data.push([NaN,NaN,NaN])}return r}time(){return this._timeSeries}open(){return this._openSeries}high(){return this._highSeries}low(){return this._lowSeries}close(){return this._closeSeries}volume(){return this._volumeSeries}developingPoc(){return this._developingPocSeries}developingVAHigh(){return this._developingVAHighSeries}developingVALow(){return this._developingVALowSeries}}function y(e){return{constructor:S, +name:e.description,metainfo:{_metainfoVersion:51,shortDescription:"VPFR",format:{type:"volume"},is_price_study:!0,defaults:{graphics:{hhists:{histBars2:{colors:["#1592e6","#fbc123"],direction:o.HHistDirection.LeftToRight,percentWidth:30,showValues:!1,transparencies:[76,76],valuesColor:"#424242",visible:!0},histBarsVA:{colors:["#1592e6","#fbc123"],direction:o.HHistDirection.LeftToRight,percentWidth:30,showValues:!1,transparencies:[30,30],valuesColor:"#424242",visible:!0}},horizlines:{pocLines:{color:"#ff0000",style:_.LineStyle.Solid,visible:!0,width:2}},polygons:{histBoxBg:{color:"#37a6ef",transparency:94}}},inputs:{first_bar_time:0,last_bar_time:0,rows:24,rowsLayout:"Number Of Rows",subscribeRealtime:!0,vaVolume:70,volume:"Up/Down"},styles:{developingPoc:{color:"#ff0000",linestyle:_.LineStyle.Solid,linewidth:1,plottype:n.LineStudyPlotStyle.StepLine,trackPrice:!1,transparency:0,display:0},developingVAHigh:{color:"#0000ff",linestyle:_.LineStyle.Solid,linewidth:1,plottype:n.LineStudyPlotStyle.StepLine,trackPrice:!1,transparency:0,display:0},developingVALow:{color:"#0000ff",linestyle:_.LineStyle.Solid,linewidth:1,plottype:n.LineStudyPlotStyle.StepLine,trackPrice:!1,transparency:0,display:0}}},graphics:{hhists:{histBars2:{location:o.HHistLocation.Absolute,title:"Volume Profile",titles:["Up Volume","Down Volume"]},histBarsVA:{location:o.HHistLocation.Absolute,title:"Value Area",titles:["Value Area Up","Value Area Down"]}},horizlines:{pocLines:{name:"POC",showPrice:!0}},polygons:{histBoxBg:{mouseTouchable:!1,name:"Histogram Box",showBorder:!1}}},inputs:[{defval:"Number Of Rows",id:"rowsLayout",name:"Rows Layout",options:["Number Of Rows","Ticks Per Row"],type:"text"},{defval:24,id:"rows",max:1e6,min:1,name:"Row Size",type:"integer"},{defval:"Up/Down",id:"volume",name:"Volume",options:["Up/Down","Total","Delta"],type:"text"},{defval:0,id:"first_bar_time",isHidden:!0,max:253370764800,min:-253370764800,name:"First Bar Time",type:"time"},{defval:0,id:"last_bar_time",isHidden:!0,max:253370764800,min:-253370764800,name:"Last Bar Time",type:"time"},{defval:70,id:"vaVolume",max:100,min:0,name:"Value Area Volume",type:"integer"},{defval:!0,id:"subscribeRealtime",isHidden:!0,name:"SubscribeRealtime",type:"bool"}],plots:[{id:"developingPoc",type:"line"},{id:"developingVAHigh",type:"line"},{id:"developingVALow",type:"line"}],styles:{developingPoc:{histogramBase:0,title:"Developing Poc"},developingVAHigh:{histogramBase:0,title:"Developing VA High"},developingVALow:{histogramBase:0,title:"Developing VA Low"}},...e}}}const b=y({id:"VbPFixed@tv-volumebyprice-57",description:"Volume Profile Fixed Range"}),w=y({id:"VbPFixed@tv-basicstudies-152",description:"Fixed Range",is_hidden_study:!0})},19999:(e,t,i)=>{"use strict";i.d(t,{VolumeProfileOutputSeries:()=>n});var s=i(50151),r=i(78071);class n{constructor(){this._histPos=-1,this._hist=new Float64Array(2e3),this._times=new Float64Array(2e3)}addHist(e){if(this._histPos>=0){const t=this._times[this._histPos];(0,s.assert)(t<=e,"History order violation"),this._histPos+=t===e?0:1 +}else this._histPos+=1;if(this._histPos===this._hist.length){const e=new Float64Array(2*this._hist.length);e.set(this._hist),this._hist=e;const t=new Float64Array(this._hist.length);t.set(this._times),this._times=t}this._hist[this._histPos]=NaN,this._times[this._histPos]=e}removeLastIfNaN(){Number.isNaN(this.get(0))&&(this._histPos-=1)}get(e){(0,s.assert)(0===e);const t=this._histPos-e;return this._hist[t]}getLeftOrEqual(e){const t=(0,r.upperbound)(this._times,e,((e,t)=>e{"use strict";i.d(t,{volumeProfileVisibleRangeStudyItem:()=>v});var s=i(50151),r=i(19762),n=i(90164),o=i(36274),a=i(79999),l=i(89529),c=i(31584);class h extends l.VolumeByPriceExpr{constructor(e,t,i,s,r,n,o,a,l,h,d){super(e,t,i,n,new c.GraphicsList,o,!0,a,l,(()=>h),d,s,r,!1),this._firstBarTime=s,this._lastBarTime=r}update(e){this._supplyRowsLayout(this._ctx),this.timeInRequestedRange(e)&&super.update(e)}timeInRequestedRange(e){const t=this._timeScale().get(e);return this._firstBarTime<=t&&t=this._firstBarTime){const e=this._developingPocSeries.getLeftOrEqual(n),t=this._developingVAHighSeries.getLeftOrEqual(n),i=this._developingVALowSeries.getLeftOrEqual(n);r.data.push([e,t,i])}else r.data.push([NaN,NaN,NaN])}return r}time(){return this._timeSeries}open(){return this._openSeries}high(){return this._highSeries}low(){return this._lowSeries}close(){return this._closeSeries}volume(){return this._volumeSeries}developingPoc(){return this._developingPocSeries}developingVAHigh(){return this._developingVAHighSeries}developingVALow(){return this._developingVALowSeries}}const v={constructor:f,name:"Volume Profile Visible Range",metainfo:{_metainfoVersion:51,id:"VbPVisible@tv-basicstudies-49",description:"Volume Profile Visible Range",shortDescription:"VPVR",format:{type:"volume"},is_price_study:!0,linkedToSeries:!0,palettes:{},inputs:[{id:"rowsLayout",name:"Rows Layout",defval:"Number Of Rows",options:["Number Of Rows","Ticks Per Row"],type:"text"},{id:"rows",name:"Row Size",defval:24,max:1e6,min:1,type:"integer"},{id:"volume",name:"Volume",defval:"Up/Down",options:["Up/Down","Total","Delta"],type:"text"},{id:"first_visible_bar_time",name:"First Visible Bar Time",defval:0,isHidden:!0, +max:253370764800,min:-253370764800,type:"time"},{id:"last_visible_bar_time",name:"Last Visible Bar Time",defval:0,isHidden:!0,max:253370764800,min:-253370764800,type:"time"},{id:"vaVolume",name:"Value Area Volume",defval:70,max:100,min:0,type:"integer"}],plots:[{id:"developingPoc",type:"line"},{id:"developingVAHigh",type:"line"},{id:"developingVALow",type:"line"}],graphics:{hhists:{histBars2:{location:n.HHistLocation.Relative,title:"Volume Profile",titles:["Up Volume","Down Volume"]},histBarsVA:{location:n.HHistLocation.Relative,title:"Value Area",titles:["Value Area Up","Value Area Down"]}},horizlines:{pocLines:{name:"POC",showPrice:!0}}},defaults:{graphics:{hhists:{histBars2:{colors:["#1592e6","#fbc123"],direction:n.HHistDirection.RightToLeft,percentWidth:30,showValues:!1,transparencies:[76,76],valuesColor:"#424242",visible:!0},histBarsVA:{colors:["#1592e6","#fbc123"],direction:n.HHistDirection.RightToLeft,percentWidth:30,showValues:!1,transparencies:[30,30],valuesColor:"#424242",visible:!0}},horizlines:{pocLines:{color:"#ff0000",style:0,visible:!0,width:2}}},inputs:{first_visible_bar_time:0,last_visible_bar_time:0,rows:24,rowsLayout:"Number Of Rows",vaVolume:70,volume:"Up/Down"},styles:{developingPoc:{color:"#ff0000",linestyle:0,linewidth:1,plottype:9,trackPrice:!1,transparency:0,display:0},developingVAHigh:{color:"#0000ff",linestyle:0,linewidth:1,plottype:9,trackPrice:!1,transparency:0,display:0},developingVALow:{color:"#0000ff",linestyle:0,linewidth:1,plottype:9,trackPrice:!1,transparency:0,display:0}}},styles:{developingPoc:{histogramBase:0,title:"Developing Poc"},developingVAHigh:{histogramBase:0,title:"Developing VA High"},developingVALow:{histogramBase:0,title:"Developing VA Low"}}}}},43945:(e,t,i)=>{"use strict";i.d(t,{EraseAll:()=>r,EraseObj:()=>s,GraphicsCmds:()=>n});class s{constructor(e,t){this.id=e,this.type=t}primitiveData(){return{action:"one",id:this.id,type:this.type}}}class r{primitiveData(){return{action:"all"}}}class n{constructor(){this.erase=[],this.create=null,this._modified=!1}primitiveData(e){if(this.isNaN())return null;const t={},i=this.create&&this.create.primitiveData(e);return null!==i&&(t.create=i),null!==this.erase&&this.erase.length>0&&(t.erase=this.erase.map((e=>e.primitiveData()))),void 0===t.create&&void 0===t.erase?null:t}setCreate(e){this.create=e,this.create.forEachList((e=>e.setOwner(this)))}isNaN(){return(null===this.erase||0===this.erase.length)&&null===this.create}isModified(){return this._modified}setModified(e){this._modified=e}dirty(){this._modified=!0}setOwner(e){throw new Error("Unsupported")}}},79999:(e,t,i)=>{"use strict";i.d(t,{GraphicsListColl:()=>s});class s{constructor(){this._stable=[],this._variable=null,this._owner=null}addStable(e){e.setOwner(this),this._stable.push(e)}setVariable(e){this._variable=e,null!==this._variable&&this._variable.setOwner(this)}primitivesData(e){const t=[];return this._forEach((i=>t.push(...i.primitivesData(e)))),t}deleteErasedItems(){this._forEach((e=>e.deleteErasedItems()))}markPostedItems(){this._forEach((e=>e.markPostedItems()))} +isNaN(){return this._all((e=>e.isNaN()))}dirty(){null!==this._owner&&this._owner.dirty()}setOwner(e){this._owner=e}_forEach(e){for(const t of this._stable)e(t);null!==this._variable&&e(this._variable)}_all(e){for(const t of this._stable)if(!e(t))return!1;return null===this._variable||e(this._variable)}}},31584:(e,t,i)=>{"use strict";i.d(t,{GraphicsList:()=>n});var s=i(29779),r=i(76958);class n{constructor(){this._items=[],this._owner=null}primitivesData(e){const t=[];for(const i of this._items)e.isIgnoredObj(i)||t.push(i.primitiveData());return t}get(e){return this._items[e]}set(e,t){return this.dirty(),t.setOwner(this),this._items[e]=t,t}addAtIndex(e,t){this.dirty(),t.setOwner(this),this._items[e]=t}clear(){this._unsetOwner(this._items),this._items=[],this.dirty()}addAllFromNumber(e,t){this.setOwner(t),this._items.splice(e,0,...t._items);return this._setCachedDataValid(!1),true}addAll(e){this.setOwner(e),this._items.push(...e._items);return this._setCachedDataValid(!1),true}remove(e){const t=this._items[e];return this._items.splice(e,1),t.unsetOwner(this),this.dirty(),t}getItems(){return this._items}size(){return this._items.length}add(e){e.setOwner(this),this._items.push(e);return this._setCachedDataValid(!1),true}deleteErasedItems(){this._items=this._items.filter((e=>!e.isErased()))}markPostedItems(){for(const e of this._items)e.markAsPosted()}isNaN(){if(0===this._items.length)return!0;for(const e of this._items){if(!(0,r.isNaNable)(e))return!1;if(!e.isNaN())return!1}return!0}setOwner(e){this._owner=e}dirty(){null!==this._owner&&this._owner.dirty()}_unsetOwner(e){for(const t of e)t instanceof s.GraphicsObj&&t.unsetOwner(this)}_setCachedDataValid(e){e||this.dirty()}}},29779:(e,t,i)=>{"use strict";i.d(t,{GraphicsObj:()=>l});var s=i(81337);class r{constructor(e,t,i,s){this._value=e,this._name=t,this._owner=i,this._comparer=void 0!==s?s:(e,t)=>null==e?null!=t:e===t}getName(){return this._name}set(e){const t=this._comparer(this._value,e);return t&&this._owner.dirty(),this._value=e,t}get(){return this._value}}class n{constructor(e,t,i){this._owner=null,this._value=e,this._name=t,this._owner=i}getName(){return this._name}set(e){return this._value!==e&&(this._value=e,null!==this._owner&&this._owner.dirty(),!0)}get(){return this._value}}class o extends r{constructor(e,t,i,s){super(e,t,i,s)}}class a{constructor(e){this._owner=e}createField(e,t){return new r(e,t,this)}createDoubleField(e,t){return new r(e,t,this,((e,t)=>!s.Std.equal(e,t)))}createDoubleArrayField(e,t){return new o(e,t,this,((e,t)=>{if(e===t)return!1;const i=e.length;if(t.length!==i)return!0;for(let r=0;r{"use strict";function s(e){return Boolean(e.isNaN)}i.d(t,{isNaNable:()=>s})},1386:(e,t,i)=>{"use strict";i.d(t,{JStudyDataUpdate:()=>d});var s=i(43945);class r{constructor(){this.isUpdate=!1,this.graphicsCmds=new s.GraphicsCmds,this._offsetsChanged=!1,this._disableGraphicsAndData=!1}isNaN(){return this.graphicsCmds.isNaN()}primitiveData(e){const t={};if(!this._disableGraphicsAndData){const i=this.graphicsCmds.primitiveData(e);null!==i&&(t.graphicsCmds=i)}return this.isUpdate&&(t.isUpdate=!0),void 0===t.graphicsCmds?void 0:t}disable(){this._disableGraphicsAndData=!0}checkForChangeAndResetChangedState(e){const t=this._offsetsChanged,i=this.graphicsCmds.isModified();this.graphicsCmds.setModified(!1),this._offsetsChanged=!1;return i||t||0!==e.length}}var n=i(1722),o=i(76958);function a(e){return Boolean(e.isPosted)}class l{isIgnoredObj(e,t){return l.isIgnoredObjDefault(e,t)}static isIgnoredObjDefault(e,t){if(void 0===t)return l.isIgnoredObjNaNable(e);const i=e[t];return l.isIgnoredByGeneralRules(e,t)||l.isIgnoredObjNaNable(i)||l.isIgnoredObjListOfNaNables(i)}static isIgnoredObjNaNable(e){return(0,o.isNaNable)(e)&&e.isNaN()}static isIgnoredObjListOfNaNables(e){if(!(0,n.isArray)(e))return!1;let t=!0;for(const i of e)if(!(0,o.isNaNable)(i)||!i.isNaN()){t=!1;break}return t}static isIgnoredObjPosted(e){return a(e)&&e.isPosted()}static isIgnoredObjErased(e){return a(e)&&e.isErased()}static isIgnoredByGeneralRules(e,t){const i=e[t];return(0,n.isArray)(i)&&0===i.length}}class c{isIgnoredObj(e,t){if(void 0===t)return l.isIgnoredObjDefault(e)||l.isIgnoredObjErased(e);const i=e[t];return l.isIgnoredObjDefault(e,t)||l.isIgnoredObjErased(i)}}class h{isIgnoredObj(e,t){if(void 0===t)return l.isIgnoredObjDefault(e)||l.isIgnoredObjErased(e)||l.isIgnoredObjPosted(e);const i=e[t];return l.isIgnoredObjDefault(e,t)||l.isIgnoredObjErased(i)||l.isIgnoredObjPosted(i)}}class d extends class extends class{constructor(e){this._dataObj=new r,this._isDirty=!1,this._eraseCmds=[],this._enableCmdDataStudy=e}init(e){this._dataObj.graphicsCmds.setCreate(e),this.update(!0)}dataObj(){return this._dataObj}setEraseCmds(e){this._eraseCmds=e}resetDirtyState(){this._isDirty=!1}disable(){this._dataObj.disable()}}{constructor(e){super(e),this._snapshotPredicate=new c,this._dataSnapShot={}}getData(){return this._dataSnapShot}getUpdate(){return this._isDirty?this._dataSnapShot:{}}update(e){ +(this._dataObj.checkForChangeAndResetChangedState(this._eraseCmds)||e)&&(null!==this._dataObj.graphicsCmds.create&&(this._dataObj.graphicsCmds.create.deleteErasedObjs(),this._dataObj.graphicsCmds.erase=[new s.EraseAll]),this._makeSnapshot(),this._isDirty=!0)}_makeSnapshot(){this._json=this._dataObj.primitiveData(this._snapshotPredicate),this._dataSnapShot={json:this._json}}}{constructor(e){super(e),this._updatePredicate=new h,this._sendShapshotOnly=!0,this._isFirstNotForcedUpdate=!0}update(e){(this._dataObj.checkForChangeAndResetChangedState(this._eraseCmds)||e)&&(null!==this._dataObj.graphicsCmds.create&&(this._dataObj.graphicsCmds.erase=[new s.EraseAll]),this._dataObj.isUpdate=!0,this._makeSnapshot(),null!==this._dataObj.graphicsCmds.create&&(this._dataObj.graphicsCmds.erase=this._eraseCmds),this._dataObj.isUpdate=!0,this._jsonUpdate=this._dataObj.primitiveData(this._updatePredicate),null!==this._dataObj.graphicsCmds.create&&this._dataObj.graphicsCmds.create.deleteErasedAndMarkPostedObjs(),this._sendShapshotOnly=e||this._isFirstNotForcedUpdate,this._isFirstNotForcedUpdate=Boolean(e),this._isDirty=!0)}getUpdate(){return this._isDirty?this._enableCmdDataStudy?{json:this._sendShapshotOnly?this._json:void 0,jsonUpdate:this._sendShapshotOnly?void 0:this._jsonUpdate}:{json:this._json,jsonUpdate:this._sendShapshotOnly?void 0:this._jsonUpdate}:{}}}},748:(e,t,i)=>{"use strict";i.d(t,{Container:()=>n,StudyGraphicsData:()=>r});var s=i(50151);class r{constructor(){this._horizlines=[],this._hhists=[],this._polygons=[],this._vertlines=[],this._containersCache=[],this._containerNamesCache=[],this._containersMapCache=new Map,this._addToCache("horizlines",this._horizlines),this._addToCache("hhists",this._hhists),this._addToCache("polygons",this._polygons),this._addToCache("vertlines",this._vertlines)}primitiveData(e){const t={};let i=!1;for(const s of this._containerNamesCache){const r=[],n=this.getObjsContainer(s);for(const t of n){if(t.isNaN())continue;const i=t.primitiveData(e);i.data.length>0&&r.push(i)}r.length>0&&(t[s]=r,i=!0)}return i?t:null}deleteErasedAndMarkPostedObjs(){this.forEachList((e=>{e.deleteErasedItems(),e.markPostedItems()}))}deleteErasedObjs(){this.forEachList((e=>e.deleteErasedItems()))}getObjsContainer(e){return(0,s.ensureDefined)(this._containersMapCache.get(e))}forEachList(e){for(const t of this._containersCache)for(const i of t)e(i.data)}_addToCache(e,t){this._containersCache.push(t),this._containerNamesCache.push(e),this._containersMapCache.set(e,t)}}class n{constructor(e,t){this.styleId=e,this.data=t}isNaN(){return this.data.isNaN()}primitiveData(e){return{styleId:this.styleId,data:this.data.primitivesData(e)}}}},24172:(e,t,i)=>{"use strict";const s=i(48891).getHexColorByName;var r=i(74649);const n=s("color-ripe-red-100"),o=s("color-ripe-red-200"),a=s("color-ripe-red-500"),l=s("color-ripe-red-900"),c=s("color-ripe-red-a200"),h=s("color-minty-green-100"),d=s("color-minty-green-400"),u=s("color-minty-green-500");JSServer.studyLibrary=[{name:"Accumulation/Distribution",metainfo:{_metainfoVersion:52, +isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Accumulation/Distribution",shortDescription:"Accum/Dist",is_price_study:!1,inputs:[],id:"Accumulation/Distribution@tv-basicstudies-1",scriptIdPart:"",name:"Accumulation/Distribution",format:{type:"volume"}},constructor:function(){this.f_0=function(e,t,i,s){return r.Std.or(r.Std.and(r.Std.eq(e,t),r.Std.eq(e,i)),r.Std.eq(t,i))?0:(2*e-i-t)/(t-i)*s},this.main=function(e,t){this._context=e,this._input=t;var i=this.f_0(r.Std.close(this._context),r.Std.high(this._context),r.Std.low(this._context),r.Std.volume(this._context));return[r.Std.cum(i,this._context)]}}},{name:"Accumulative Swing Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:10}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"ASI",histogramBase:0,joinPoints:!1}},description:"Accumulative Swing Index",shortDescription:"ASI",is_price_study:!1,inputs:[{id:"in_0",name:"Limit Move Value",defval:10,type:"float",min:.1,max:1e5}],id:"Accumulative Swing Index@tv-basicstudies-1",scriptIdPart:"",name:"Accumulative Swing Index",format:{type:"volume"}},constructor:function(){this.f_0=function(e,t){var i=t.new_var(r.Std.open(t)),s=t.new_var(r.Std.high(t)),n=t.new_var(r.Std.low(t)),o=t.new_var(r.Std.close(t)),a=r.Std.abs(s-o.get(1)),l=r.Std.abs(n-o.get(1)),c=r.Std.abs(s-n),h=r.Std.abs(o.get(1)-i.get(1)),d=r.Std.max(a,l),u=r.Std.iff(a>=r.Std.max(l,c),a-.5*l+.25*h,r.Std.iff(l>=r.Std.max(a,c),l-.5*a+.25*h,c+.25*h));return r.Std.iff(0===u,0,(o-o.get(1)+.5*(o-i)+.25*(o.get(1)-i.get(1)))/u*d/e*50)},this.f_1=function(e,t){var i=this.f_0(e,t);return r.Std.cum(i,t)},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0);return[this.f_1(i,this._context)]}}},{name:"Advance/Decline",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:10}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Advance/Decline",shortDescription:"AD",is_price_study:!1,inputs:[{id:"in_0",name:"length",defval:10,type:"integer",min:1,max:2e3}],id:"Advance/Decline@tv-basicstudies-1",scriptIdPart:"",name:"Advance/Decline",format:{precision:2,type:"price"}},constructor:function(){this.f_0=function(e,t){return r.Std.gt(e,t)},this.f_1=function(e,t){return r.Std.lt(e,t)},this.f_2=function(e,t){return 0===t?e:e/t},this.main=function(e,t){this._context=e,this._input=t +;var i=this._input(0),s=this.f_0(r.Std.close(this._context),r.Std.open(this._context)),n=this._context.new_var(s),o=r.Std.sum(n,i,this._context),a=this.f_1(r.Std.close(this._context),r.Std.open(this._context)),l=this._context.new_var(a),c=r.Std.sum(l,i,this._context);return[this.f_2(o,c)]}}},{name:"Arnaud Legoux Moving Average",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:9,in_1:.85,in_2:6}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Arnaud Legoux Moving Average",shortDescription:"ALMA",is_price_study:!0,inputs:[{id:"in_0",name:"Window Size",defval:9,type:"integer",min:0,max:5e3},{id:"in_1",name:"Offset",defval:.85,type:"float",min:-1e12,max:1e12},{id:"in_2",name:"Sigma",defval:6,type:"float",min:-1e12,max:1e12}],id:"Arnaud Legoux Moving Average@tv-basicstudies-1",scriptIdPart:"",name:"Arnaud Legoux Moving Average",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.close(this._context),s=this._input(0),n=this._input(1),o=this._input(2),a=this._context.new_var(i);return[r.Std.alma(a,s,n,o)]}}},{name:"Aroon",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FB8C00"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:14}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],styles:{plot_0:{title:"Upper",histogramBase:0,joinPoints:!1},plot_1:{title:"Lower",histogramBase:0,joinPoints:!1}},description:"Aroon",shortDescription:"Aroon",is_price_study:!1,inputs:[{id:"in_0",name:"length",defval:14,type:"integer",min:1,max:2e3}],id:"Aroon@tv-basicstudies-1",scriptIdPart:"",name:"Aroon",format:{precision:2,type:"percent"}},constructor:function(){this.f_0=function(e,t){return 100*(e+t)/t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=r.Std.high(this._context),n=i+1,o=this._context.new_var(s),a=r.Std.highestbars(o,n,this._context),l=this.f_0(a,i),c=r.Std.low(this._context),h=this._context.new_var(c),d=r.Std.lowestbars(h,n,this._context);return[l,this.f_0(d,i)]}}},{name:"Average Price",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,id:"AveragePrice@tv-basicstudies-1",scriptIdPart:"",name:"Average Price",description:"Average Price",shortDescription:"Average Price",is_price_study:!0,plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#2196F3"}},inputs:{}},styles:{plot_0:{title:"Plot"}},inputs:[],format:{type:"inherit"}},constructor:function(){this.main=function(e,t){return this._context=e,this._input=t,[r.Std.ohlc4(this._context)]}}},{name:"Average Directional Index",metainfo:{ +_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:c}},inputs:{in_0:14,in_1:14}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"ADX",histogramBase:0,joinPoints:!1,isHidden:!1}},description:"Average Directional Index",shortDescription:"ADX",is_price_study:!1,inputs:[{id:"in_0",name:"ADX Smoothing",defval:14,type:"integer",min:-1e12,max:1e12},{id:"in_1",name:"DI Length",defval:14,type:"integer",min:-1e12,max:1e12}],id:"average_directional_Index@tv-basicstudies-1",scriptIdPart:"",name:"Average Directional Index",format:{precision:2,type:"price"}},constructor:function(){this.f_0=function(e){var t=this._context.new_var(r.Std.high(this._context)),i=r.Std.change(t),s=this._context.new_var(r.Std.low(this._context)),n=-r.Std.change(s),o=this._context.new_var(r.Std.tr(void 0,this._context)),a=r.Std.rma(o,e,this._context),l=this._context.new_var(r.Std.and(r.Std.gt(i,n),r.Std.gt(i,0))?i:0),c=r.Std.fixnan(100*r.Std.rma(l,e,this._context)/a,this._context),h=this._context.new_var(r.Std.and(r.Std.gt(n,i),r.Std.gt(n,0))?n:0);return[c,r.Std.fixnan(100*r.Std.rma(h,e,this._context)/a,this._context)]},this.f_1=function(e,t){var i=this.f_0(e),s=i[0],n=i[1],o=s+n,a=this._context.new_var(r.Std.abs(s-n)/(r.Std.eq(o,0)?1:o));return[100*r.Std.rma(a,t,this._context)]},this.main=function(e,t){return this._context=e,this._input=t,this._context.setMinimumAdditionalDepth(this._input(0)+this._input(1)),this.f_1(this._input(1),this._input(0))}}},{name:"Average True Range",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:l}},inputs:{in_0:14}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Average True Range",shortDescription:"ATR",is_price_study:!1,inputs:[{id:"in_0",name:"length",defval:14,type:"integer",min:1,max:2e3}],id:"Average True Range@tv-basicstudies-1",scriptIdPart:"",name:"Average True Range",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){var i=t(0);return[r.Std.atr(i,e)]}}},{name:"Awesome Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:1,trackPrice:!1,transparency:0,visible:!0,color:"#000080"}},palettes:{palette_0:{colors:{0:{color:a,width:1,style:0},1:{color:u,width:1,style:0}}}},inputs:{}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",palette:"palette_0",target:"plot_0",type:"colorer"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Awesome Oscillator",shortDescription:"AO",is_price_study:!1,palettes:{palette_0:{colors:{0:{name:"Color 0"},1:{name:"Color 1"}}}},inputs:[],id:"Awesome Oscillator@tv-basicstudies-1",scriptIdPart:"",name:"Awesome Oscillator",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return e-t}, +this.f_1=function(e){return r.Std.le(e,0)?0:1},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.hl2(this._context),s=this._context.new_var(i),n=r.Std.sma(s,5,this._context),o=this._context.new_var(i),a=r.Std.sma(o,34,this._context),l=this.f_0(n,a),c=l,h=this._context.new_var(l),d=r.Std.change(h);return[c,this.f_1(d)]}}},{name:"Accelerator Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:1,trackPrice:!1,transparency:0,visible:!0,color:"#000080"}},palettes:{palette_0:{colors:{0:{color:a,width:1,style:0},1:{color:u,width:1,style:0}}}},inputs:{}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",palette:"palette_0",target:"plot_0",type:"colorer"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Accelerator Oscillator",shortDescription:"AO",is_price_study:!1,palettes:{palette_0:{colors:{0:{name:"Color 0"},1:{name:"Color 1"}}}},inputs:[],id:"Accelerator Oscillator@tv-basicstudies-1",scriptIdPart:"",name:"Accelerator Oscillator",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return e-t},this.f_1=function(e){return r.Std.le(e,0)?0:1},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.hl2(this._context),s=this._context.new_var(i),n=r.Std.sma(s,5,this._context),o=this._context.new_var(i),a=r.Std.sma(o,34,this._context),l=this.f_0(n,a),c=this._context.new_var(l),h=r.Std.sma(c,5,this._context),d=this.f_0(l,h),u=this._context.new_var(d),p=r.Std.change(u);return[d,this.f_1(p)]}}},{name:"Balance of Power",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:c}},inputs:{}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Balance of Power",shortDescription:"Balance of Power",is_price_study:!1,inputs:[],id:"Balance of Power@tv-basicstudies-1",scriptIdPart:"",name:"Balance of Power",format:{precision:2,type:"price"}},constructor:function(){this.f_0=function(e,t,i,s){return(e-t)/(i-s)},this.main=function(e,t){return this._context=e,this._input=t,[this.f_0(r.Std.close(this._context),r.Std.open(this._context),r.Std.high(this._context),r.Std.low(this._context))]}}},{name:"Bollinger Bands",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_2:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},filledAreasStyle:{fill_0:{color:"#2196F3",transparency:95,visible:!0}},inputs:{in_0:20,in_1:2}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"Median",histogramBase:0,joinPoints:!1},plot_1:{title:"Upper",histogramBase:0,joinPoints:!1 +},plot_2:{title:"Lower",histogramBase:0,joinPoints:!1}},description:"Bollinger Bands",shortDescription:"BB",is_price_study:!0,filledAreas:[{id:"fill_0",objAId:"plot_1",objBId:"plot_2",type:"plot_plot",title:"Plots Background"}],inputs:[{id:"in_0",name:"length",defval:20,type:"integer",min:1,max:1e4},{id:"in_1",name:"mult",defval:2,type:"float",min:.001,max:50}],id:"Bollinger Bands@tv-basicstudies-1",scriptIdPart:"",name:"Bollinger Bands",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return e*t},this.f_1=function(e,t){return e+t},this.f_2=function(e,t){return e-t},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.close(this._context),s=this._input(0),n=this._input(1),o=this._context.new_var(i),a=r.Std.sma(o,s,this._context),l=this._context.new_var(i),c=r.Std.stdev(l,s,this._context),h=this.f_0(n,c);return[a,this.f_1(a,h),this.f_2(a,h)]}}},{name:"Bollinger Bands %B",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:d}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:1},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],filledAreasStyle:{fill_0:{color:"#26A69A",transparency:90,visible:!0}},inputs:{in_0:20,in_1:2}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1}},description:"Bollinger Bands %B",shortDescription:"BB %B",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_1",name:"LowerLimit",zorder:-1.11}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",title:"Hlines Background",zorder:-2}],inputs:[{id:"in_0",name:"length",defval:20,type:"integer",min:1,max:1e4},{id:"in_1",name:"mult",defval:2,type:"float",min:.001,max:50}],id:"Bollinger Bands %B@tv-basicstudies-1",scriptIdPart:"",name:"Bollinger Bands %B",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t){return e*t},this.f_1=function(e,t){return e+t},this.f_2=function(e,t){return e-t},this.f_3=function(e,t,i){return(e-t)/(i-t)},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.close(this._context),s=this._input(0),n=this._input(1),o=this._context.new_var(i),a=r.Std.sma(o,s,this._context),l=this._context.new_var(i),c=r.Std.stdev(l,s,this._context),h=this.f_0(n,c),d=this.f_1(a,h),u=this.f_2(a,h);return[this.f_3(i,u,d)]}}},{name:"Bollinger Bands Width",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"}},inputs:{in_0:20,in_1:2}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Bollinger Bands Width",shortDescription:"BBW",is_price_study:!1,inputs:[{id:"in_0",name:"length",defval:20,type:"integer",min:1,max:1e4},{id:"in_1",name:"mult",defval:2,type:"float",min:.001,max:50}], +id:"Bollinger Bands Width@tv-basicstudies-1",scriptIdPart:"",name:"Bollinger Bands Width",format:{precision:2,type:"price"}},constructor:function(){this.f_0=function(e,t){return e*t},this.f_1=function(e,t){return e+t},this.f_2=function(e,t){return e-t},this.f_3=function(e,t,i){return(e-t)/i},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.close(this._context),s=this._input(0),n=this._input(1),o=this._context.new_var(i),a=r.Std.sma(o,s,this._context),l=this._context.new_var(i),c=r.Std.stdev(l,s,this._context),h=this.f_0(n,c),d=this.f_1(a,h),u=this.f_2(a,h);return[this.f_3(d,u,a)]}}},{name:"Chaikin Money Flow",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#43A047"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{in_0:20}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1}},description:"Chaikin Money Flow",shortDescription:"CMF",is_price_study:!1,bands:[{id:"hline_0",name:"Zero",zorder:-1}],inputs:[{id:"in_0",name:"length",defval:20,type:"integer",min:1,max:2e3}],id:"Chaikin Money Flow@tv-basicstudies-1",scriptIdPart:"",name:"Chaikin Money Flow",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t,i,s){return r.Std.or(r.Std.and(r.Std.eq(e,t),r.Std.eq(e,i)),r.Std.eq(t,i))?0:(2*e-i-t)/(t-i)*s},this.f_1=function(e,t){return e/t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this.f_0(r.Std.close(this._context),r.Std.high(this._context),r.Std.low(this._context),r.Std.volume(this._context)),n=this._context.new_var(s),o=r.Std.sum(n,i,this._context),a=r.Std.volume(this._context),l=this._context.new_var(a),c=r.Std.sum(l,i,this._context);return[this.f_1(o,c)]}}},{name:"Chaikin Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#EC407A"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{in_0:3,in_1:10}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1}},description:"Chaikin Oscillator",shortDescription:"Chaikin Osc",is_price_study:!1,bands:[{id:"hline_0",name:"Zero",zorder:-1}],inputs:[{id:"in_0",name:"short",defval:3,type:"integer",min:1,max:2e3},{id:"in_1",name:"long",defval:10,type:"integer",min:1,max:2e3}],id:"Chaikin Oscillator@tv-basicstudies-1",scriptIdPart:"",name:"Chaikin Oscillator",format:{type:"volume"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t){return e-t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=r.Std.accdist(this._context),o=this._context.new_var(n),a=r.Std.ema(o,i,this._context),l=this._context.new_var(n),c=r.Std.ema(l,s,this._context);return[this.f_0(a,c)]}}},{name:"Chaikin Volatility",metainfo:{ +_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!1,id:"Chaikin Volatility@tv-basicstudies-1",scriptIdPart:"",name:"Chaikin Volatility",description:"Chaikin Volatility",shortDescription:"Chaikin Volatility",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#AB47BC"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{periods:10,rocLookback:10}},styles:{plot_0:{title:"Plot",zorder:1}},bands:[{id:"hline_0",name:"Zero",zorder:-1}],inputs:[{id:"periods",type:"integer",name:"Periods"},{id:"rocLookback",type:"integer",name:"Rate of Change Lookback"}],format:{type:"volume"},usePlotsZOrder:!0},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this.period=this._input(0),this.rocLookback=this._input(1)},this.main=function(e,t){this._context=e,this._input=t,this._context.setMinimumAdditionalDepth(this.period+this.rocLookback);var i=this._context.new_var(r.Std.high(this._context)-r.Std.low(this._context)),s=this._context.new_var(r.Std.ema(i,this.period,this._context));return[r.Std.roc(s,this.rocLookback)]}}},{name:"Chande Kroll Stop",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"}},inputs:{in_0:10,in_1:1,in_2:9}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],styles:{plot_0:{title:"Long",histogramBase:0,joinPoints:!1},plot_1:{title:"Short",histogramBase:0,joinPoints:!1}},description:"Chande Kroll Stop",shortDescription:"Chande Kroll Stop",is_price_study:!0,inputs:[{id:"in_0",name:"p",defval:10,type:"integer",min:1,max:4999},{id:"in_1",name:"x",defval:1,type:"integer",min:1,max:1e12},{id:"in_2",name:"q",defval:9,type:"integer",min:1,max:1e12}],id:"Chande Kroll Stop@tv-basicstudies-1",scriptIdPart:"",name:"Chande Kroll Stop",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t,i){return e-t*i},this.f_1=function(e,t,i){return e+t*i},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=this._input(2),o=r.Std.high(this._context),a=this._context.new_var(o),l=r.Std.highest(a,i,this._context),c=r.Std.atr(i,this._context),h=this.f_0(l,s,c),d=this._context.new_var(o),u=r.Std.lowest(d,i,this._context),p=this.f_1(u,s,c),_=this._context.new_var(h),m=r.Std.highest(_,n,this._context),g=this._context.new_var(p);return[r.Std.lowest(g,n,this._context),m]}}},{name:"Chande Momentum Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:9}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Chande Momentum Oscillator", +shortDescription:"ChandeMO",is_price_study:!1,inputs:[{id:"in_0",name:"length",defval:9,type:"integer",min:1,max:2e3}],id:"Chande Momentum Oscillator@tv-basicstudies-1",scriptIdPart:"",name:"Chande Momentum Oscillator",format:{type:"price",precision:2}},constructor:function(){this.f_0=function(e){return r.Std.ge(e,0)?e:0},this.f_1=function(e){return r.Std.ge(e,0)?0:-e},this.f_2=function(e,t){return 100*e/t},this.f_3=function(e,t){return this.f_2(e-t,e+t)},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=r.Std.close(this._context),n=this._context.new_var(s),o=r.Std.change(n),a=this.f_0(o),l=this.f_1(o),c=this._context.new_var(a),h=r.Std.sum(c,i,this._context),d=this._context.new_var(l),u=r.Std.sum(d,i,this._context);return[this.f_3(h,u)]}}},{name:"Chop Zone",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:5,trackPrice:!1,transparency:0,visible:!0,color:"#000080"}},palettes:{palette_0:{colors:{0:{color:"#26C6DA",width:1,style:0},1:{color:"#43A047",width:1,style:0},2:{color:"#A5D6A7",width:1,style:0},3:{color:u,width:1,style:0},4:{color:"#D50000",width:1,style:0},5:{color:"#E91E63",width:1,style:0},6:{color:"#FF6D00",width:1,style:0},7:{color:"#FFB74D",width:1,style:0},8:{color:"#FDD835",width:1,style:0}}}},inputs:{}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",palette:"palette_0",target:"plot_0",type:"colorer"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,isHidden:!1}},description:"Chop Zone",shortDescription:"Chop Zone",is_price_study:!1,palettes:{palette_0:{colors:{0:{name:"Color 0"},1:{name:"Color 1"},2:{name:"Color 2"},3:{name:"Color 3"},4:{name:"Color 4"},5:{name:"Color 5"},6:{name:"Color 6"},7:{name:"Color 7"},8:{name:"Color 8"}},valToIndex:{0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8}}},inputs:[],id:"chop_zone@tv-basicstudies-1",scriptIdPart:"",name:"Chop Zone",format:{precision:0,type:"price"}},constructor:function(){this.f_0=function(){var e=r.Std.close(this._context),t=r.Std.hlc3(this._context),i=this._context.new_var(r.Std.high(this._context)),s=r.Std.highest(i,30,this._context),n=r.Std.lowest(i,30,this._context),o=25/(s-n)*n,a=this._context.new_var(e),l=this._context.new_var(r.Std.ema(a,34,this._context)),c=(l.get(1)-l.get(0))/t*o,h=r.Std.sqrt(1+c*c),d=r.Std.round(180*r.Std.acos(1/h)/3.141592653589793),u=r.Std.iff(r.Std.gt(c,0),-d,d),p=r.Std.and(r.Std.gt(u,-2.14),r.Std.le(u,-.71))?7:8,_=r.Std.and(r.Std.gt(u,-3.57),r.Std.le(u,-2.14))?6:p,m=r.Std.and(r.Std.gt(u,-5),r.Std.le(u,-3.57))?5:_,g=r.Std.le(u,-5)?4:m,f=r.Std.and(r.Std.lt(u,2.14),r.Std.ge(u,.71))?3:g,v=r.Std.and(r.Std.lt(u,3.57),r.Std.ge(u,2.14))?2:f,S=r.Std.and(r.Std.lt(u,5),r.Std.ge(u,3.57))?1:v;return[1,r.Std.ge(u,5)?0:S]},this.main=function(e,t){return this._context=e,this._input=t,this.f_0()}}},{name:"Choppiness Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}}, +bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:61.8},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:38.2}],filledAreasStyle:{fill_0:{color:"#2196F3",transparency:90,visible:!0}},inputs:{in_0:14}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1}},description:"Choppiness Index",shortDescription:"CHOP",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_1",name:"LowerLimit",zorder:-1.11}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",title:"Hlines Background",zorder:-2}],inputs:[{id:"in_0",name:"length",defval:14,type:"integer",min:1,max:2e3}],id:"Choppiness Index@tv-basicstudies-1",scriptIdPart:"",name:"Choppiness Index",format:{type:"price",precision:2},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t,i,s){return 100*r.Std.log10(e/(t-i))/s},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=r.Std.atr(1,this._context),n=this._context.new_var(s),o=r.Std.sum(n,i,this._context),a=r.Std.high(this._context),l=this._context.new_var(a),c=r.Std.highest(l,i,this._context),h=r.Std.low(this._context),d=this._context.new_var(h),u=r.Std.lowest(d,i,this._context),p=r.Std.log10(i);return[this.f_0(o,c,u,p)]}}},{name:"Commodity Channel Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},smoothedMA:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:100},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:-100}],filledAreasStyle:{fill_0:{color:"#2196F3",transparency:90,visible:!0}},inputs:{in_0:20,smoothingLine:"SMA",smoothingLength:20}},plots:[{id:"plot_0",type:"line"},{id:"smoothedMA",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:2},smoothedMA:{title:"Smoothed MA",histogramBase:0,joinPoints:!1,zorder:1}},description:"Commodity Channel Index",shortDescription:"CCI",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_1",name:"LowerLimit",zorder:-1.11}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",title:"Hlines Background",zorder:-2}],inputs:[{id:"in_0",name:"length",defval:20,type:"integer",min:1,max:2e3},{id:"smoothingLine",name:"Smoothing Line",defval:"SMA",type:"text",options:["SMA","EMA","WMA"]},{id:"smoothingLength",name:"Smoothing Length",defval:20,type:"integer",min:1,max:1e4}],id:"Commodity Channel Index@tv-basicstudies-1",scriptIdPart:"",name:"Commodity Channel Index",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t,i){return(e-t)/(.015*i)},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.hlc3(this._context),s=this._input(0),n=this._input(1),o=this._input(2);this._context.setMinimumAdditionalDepth(s+o) +;var a,l=this._context.new_var(i),c=r.Std.sma(l,s,this._context),h=this._context.new_var(i),d=r.Std.dev(h,s,this._context),u=this.f_0(i,c,d),p=this._context.new_var(u);return"EMA"===n?a=r.Std.ema(p,o,this._context):"WMA"===n?a=r.Std.wma(p,o,this._context):"SMA"===n&&(a=r.Std.sma(p,o,this._context)),[u,a]}}},{name:"Connors RSI",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:70},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:30}],filledAreasStyle:{fill_0:{color:"#2196F3",transparency:90,visible:!0}},inputs:{in_0:3,in_1:2,in_2:100}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"CRSI",histogramBase:0,joinPoints:!1,zorder:1}},description:"Connors RSI",shortDescription:"CRSI",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_1",name:"LowerLimit",zorder:-1.11}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",title:"Hlines Background",zorder:-2}],inputs:[{id:"in_0",name:"RSI Length",defval:3,type:"integer",min:1},{id:"in_1",name:"UpDown Length",defval:2,type:"integer",min:1},{id:"in_2",name:"ROC Length",defval:100,type:"integer",min:1}],id:"Connors RSI@tv-basicstudies-1",scriptIdPart:"",name:"Connors RSI",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){var e;this.f_1=function(e,t,i){var s=i.new_var(r.Std.max(r.Std.change(e),0));return r.Std.rma(s,t,i)},this.f_2=function(e,t,i){var s=i.new_var(-r.Std.min(r.Std.change(e),0));return r.Std.rma(s,t,i)},this.f_3=(e=0,function(t){var i=t.get(0),s=t.get(1);return e=i===s?0:i>s?r.Std.nz(e)<=0?1:r.Std.nz(e)+1:r.Std.nz(e)>=0?-1:r.Std.nz(e)-1,this._context.new_var(e)}),this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.close(this._context),s=this._context.new_var(i),n=this._input(0),o=this._input(1),a=this._input(2);this._context.setMinimumAdditionalDepth(a);var l=r.Std.rsi(this.f_1(s,n,this._context),this.f_2(s,n,this._context)),c=this.f_3(s),h=r.Std.rsi(this.f_1(c,o,this._context),this.f_2(c,o,this._context)),d=this._context.new_var(r.Std.roc(s,1)),u=r.Std.percentrank(d,a);return[r.Std.avg(l,h,u)]}}},{name:"Coppock Curve",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:10,in_1:14,in_2:11}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Coppock Curve",shortDescription:"Coppock Curve",is_price_study:!1,inputs:[{id:"in_0",name:"WMA Length",defval:10,type:"integer",min:-1e12,max:5e3},{id:"in_1",name:"Long RoC Length",defval:14,type:"integer",min:1,max:4999},{id:"in_2",name:"Short RoC Length",defval:11,type:"integer",min:1,max:4999}],id:"Coppock Curve@tv-basicstudies-1",scriptIdPart:"",name:"Coppock Curve",format:{type:"inherit"} +},constructor:function(){this.f_0=function(e,t){return e+t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=this._input(2);this._context.setMinimumAdditionalDepth(i+Math.max(s,n));var o=r.Std.close(this._context),a=this._context.new_var(o),l=r.Std.roc(a,s),c=this._context.new_var(o),h=r.Std.roc(c,n),d=this.f_0(l,h),u=this._context.new_var(d);return[r.Std.wma(u,i,this._context)]}}},{name:"Correlation Coeff",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:4,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:"",in_1:20}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Correlation Coefficient",shortDescription:"CC",is_price_study:!1,inputs:[{id:"in_0",name:"sym",defval:"",type:"symbol"},{id:"in_1",name:"length",defval:20,type:"integer",min:1,max:2e3}],id:"Correlation Coeff@tv-basicstudies-1",scriptIdPart:"",name:"Correlation Coeff",format:{precision:2,type:"price"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this._context.new_sym(this._input(0),r.Std.period(this._context))},this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_unlimited_var(this._context.symbol.time),s=(this._input(0),r.Std.period(this._context),r.Std.close(this._context)),n=this._input(1);this._context.select_sym(1);var o=this._context.new_unlimited_var(this._context.symbol.time),a=r.Std.close(this._context),l=this._context.new_unlimited_var(a);this._context.select_sym(0);var c=l.adopt(o,i,0),h=this._context.new_var(s),d=this._context.new_var(c);return[r.Std.correlation(h,d,n,this._context)]}}},{name:"Correlation - Log",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!1,id:"Correlation - Log@tv-basicstudies-1",scriptIdPart:"",name:"Correlation - Log",description:"Correlation - Log",shortDescription:"Correlation - Log",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#2196F3"}},inputs:{instrument:"",instrument2:"",periods:25}},styles:{plot_0:{title:"Plot"}},inputs:[{id:"instrument",name:"Instrument 1",type:"symbol",defval:"",confirm:!0},{id:"instrument2",name:"Instrument 2",type:"symbol",defval:"",confirm:!0},{id:"periods",name:"Periods",type:"integer",defval:25}],format:{precision:2,type:"price"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this._context.new_sym(this._input(0),r.Std.period(this._context)),this._context.new_sym(this._input(1),r.Std.period(this._context)),this.period=this._input(2)},this.correlationLog=function(e,t,i,s){var n=r.Std.sma(e,i,s),o=r.Std.sma(t,i,s),a=s.new_var(e.get()*t.get());return(r.Std.sma(a,i,s)-n*o)/Math.sqrt(r.Std.variance2(e,n,i)*r.Std.variance2(t,o,i))},this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_var(this._context.symbol.time) +;this._context.select_sym(2);var s=this._context.new_var(r.Std.close(this._context)),n=this._context.new_var(r.Std.log(s.get()/s.get(1))),o=this._context.new_var(this._context.symbol.time);this._context.select_sym(1);var a=this._context.new_var(this._context.symbol.time),l=this._context.new_var(r.Std.close(this._context)),c=this._context.new_var(r.Std.log(l.get()/l.get(1))),h=this._context.new_var(n.adopt(o,a,0)),d=this._context.new_var(this.correlationLog(c,h,this.period,this._context)),u=this._context.new_var(d.adopt(a,i,0)).get(),p=r.Std.round(1e3*u)/1e3;return this._context.select_sym(0),[p]}}},{name:"Detrended Price Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#43A047"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{in_0:21,in_1:!1}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"DPO",histogramBase:0,joinPoints:!1,isHidden:!1,zorder:1}},description:"Detrended Price Oscillator",shortDescription:"DPO",is_price_study:!1,is_hidden_study:!1,id:"detrended_price_oscillator@tv-basicstudies-1",bands:[{id:"hline_0",name:"Zero",isHidden:!1,zorder:-1}],inputs:[{id:"in_0",name:"Period",defval:21,type:"integer",min:1,max:1e12},{id:"in_1",name:"isCentered",defval:!1,type:"bool"}],scriptIdPart:"",name:"Detrended Price Oscillator",format:{type:"price",precision:2},usePlotsZOrder:!0},constructor:function(){this.f_0=function(){var e=this._input(0),t=this._input(1),i=Math.floor(e/2+1);this._context.setMinimumAdditionalDepth(e+i);var s=this._context.new_var(r.Std.close(this._context)),n=this._context.new_var(r.Std.sma(s,e,this._context)),o=this._context.new_var(r.Std.close(this._context)).get(i)-n,a=r.Std.close(this._context)-n.get(i);return[t?o:a,t?-i:0]},this.main=function(e,t){this._context=e,this._input=t;var i=this.f_0();return[{value:i[0],offset:i[1]}]}}},{name:"Directional Movement Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"},plot_3:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#F50057"},plot_2:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FFA726"},plot_4:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#ab47bc"}},inputs:{in_0:14,in_1:14}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"},{id:"plot_3",type:"line"},{id:"plot_4",type:"line"}],styles:{plot_0:{title:"+DI",histogramBase:0,joinPoints:!1},plot_1:{title:"-DI",histogramBase:0,joinPoints:!1},plot_2:{title:"DX",histogramBase:0,joinPoints:!1},plot_3:{title:"ADX",histogramBase:0,joinPoints:!1},plot_4:{title:"ADXR",histogramBase:0,joinPoints:!1}},description:"Directional Movement", +shortDescription:"DMI",is_price_study:!1,inputs:[{id:"in_0",name:"DI Length",defval:14,type:"integer",min:1,max:2e3},{id:"in_1",name:"ADX Smoothing",defval:14,type:"integer",min:1,max:50}],id:"Directional Movement Index@tv-basicstudies-1",scriptIdPart:"",name:"Directional Movement Index",format:{precision:4,type:"price"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1);return this._context.setMinimumAdditionalDepth(2*i+s),r.Std.dmi(i,s,this._context)}}},{name:"Donchian Channels",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_2:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"}},filledAreasStyle:{fill_0:{color:"#2196F3",transparency:95,visible:!0}},inputs:{in_0:20}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"Lower",histogramBase:0,joinPoints:!1},plot_1:{title:"Upper",histogramBase:0,joinPoints:!1},plot_2:{title:"Basis",histogramBase:0,joinPoints:!1}},description:"Donchian Channels",shortDescription:"DC",is_price_study:!0,filledAreas:[{id:"fill_0",objAId:"plot_1",objBId:"plot_0",type:"plot_plot",title:"Plots Background"}],inputs:[{id:"in_0",name:"length",defval:20,type:"integer",min:1,max:2e3}],id:"Donchian Channels@tv-basicstudies-1",scriptIdPart:"",name:"Donchian Channels",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=r.Std.low(this._context),n=this._context.new_var(s),o=r.Std.lowest(n,i,this._context),a=r.Std.high(this._context),l=this._context.new_var(a),c=r.Std.highest(l,i,this._context);return[o,c,r.Std.avg(c,o)]}}},{name:"Double Exponential Moving Average",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#43A047"}},inputs:{in_0:9}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Double EMA",shortDescription:"DEMA",is_price_study:!0,inputs:[{id:"in_0",name:"length",defval:9,type:"integer",min:1,max:1e4}],id:"Double Exponential Moving Average@tv-basicstudies-1",scriptIdPart:"",name:"Double Exponential Moving Average",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return 2*e-t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0);this._context.setMinimumAdditionalDepth(2*i);var s=r.Std.close(this._context),n=this._context.new_var(s),o=r.Std.ema(n,i,this._context),a=this._context.new_var(o),l=r.Std.ema(a,i,this._context);return[this.f_0(o,l)]}}},{name:"Ease of Movement",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{ +plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#43A047"}},inputs:{in_0:1e4,in_1:14}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Ease Of Movement",shortDescription:"EOM",is_price_study:!1,inputs:[{id:"in_0",name:"Divisor",defval:1e4,type:"integer",min:1,max:1e9},{id:"in_1",name:"length",defval:14,type:"integer",min:1,max:2e3}],id:"Ease of Movement@tv-basicstudies-1",scriptIdPart:"",name:"Ease of Movement",format:{type:"volume"}},constructor:function(){this.f_0=function(e,t,i,s,r){return e*t*(i-s)/r},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=r.Std.hl2(this._context),o=this._context.new_var(n),a=r.Std.change(o),l=this.f_0(i,a,r.Std.high(this._context),r.Std.low(this._context),r.Std.volume(this._context)),c=this._context.new_var(l);return[r.Std.sma(c,s,this._context)]}}},{name:"Elders Force Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:a}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{in_0:13}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1}},description:"Elder's Force Index",shortDescription:"EFI",is_price_study:!1,bands:[{id:"hline_0",name:"Zero",zorder:-1}],inputs:[{id:"in_0",name:"length",defval:13,type:"integer",min:1,max:2e3}],id:"Elders Force Index@tv-basicstudies-1",scriptIdPart:"",name:"Elders Force Index",format:{type:"volume"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t){return e*t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=r.Std.close(this._context),n=this._context.new_var(s),o=r.Std.change(n),a=this.f_0(o,r.Std.volume(this._context)),l=this._context.new_var(a);return[r.Std.ema(l,i,this._context)]}}},{name:"EMA Cross",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#43A047"},plot_2:{linestyle:0,linewidth:4,plottype:3,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:9,in_1:26}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"Short",histogramBase:0,joinPoints:!1},plot_1:{title:"Long",histogramBase:0,joinPoints:!1},plot_2:{title:"Crosses",histogramBase:0,joinPoints:!1}},description:"EMA Cross",shortDescription:"EMA Cross",is_price_study:!0,inputs:[{id:"in_0",name:"Short",defval:9,type:"integer",min:1,max:2e3},{id:"in_1",name:"Long",defval:26,type:"integer",min:1,max:2e3}],id:"EMA Cross@tv-basicstudies-1",scriptIdPart:"",name:"EMA Cross",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return e?t:r.Std.na()},this.main=function(e,t){ +this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=r.Std.close(this._context),o=this._context.new_var(n),a=r.Std.ema(o,i,this._context),l=this._context.new_var(n),c=r.Std.ema(l,s,this._context),h=a,d=c,u=r.Std.cross(a,c,this._context);return[h,d,this.f_0(u,a)]}}},{name:"Envelopes",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_2:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},filledAreasStyle:{fill_0:{color:"#2196F3",transparency:95,visible:!0}},inputs:{in_0:20,in_1:10,in_2:10,in_3:"Simple",in_4:"close"}},plots:[{id:"plot_1",type:"line"},{id:"plot_0",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"Average",histogramBase:0,joinPoints:!1},plot_1:{title:"Upper",histogramBase:0,joinPoints:!1},plot_2:{title:"Lower",histogramBase:0,joinPoints:!1}},description:"Envelopes",shortDescription:"Envelopes",is_price_study:!0,filledAreas:[{id:"fill_0",objAId:"plot_1",objBId:"plot_2",type:"plot_plot",title:"Plots Background"}],inputs:[{id:"in_0",name:"Length",defval:20,type:"integer",min:1,max:2e3},{id:"in_1",name:"Upper Percentage",defval:2,type:"float",min:0},{id:"in_2",name:"Lower Percentage",defval:2,type:"float",min:0},{id:"in_3",name:"Method",type:"text",defval:"Simple",options:["Simple","Exponential","Weighted"]},{id:"in_4",name:"Source",defval:"close",type:"source",options:["open","high","low","close","hl2","hlc3","ohlc4"]}],id:"Envelope@tv-basicstudies-1",scriptIdPart:"",name:"Envelopes",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return e*(1+t)},this.f_1=function(e,t){return e*(1-t)},this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_var(r.Std[this._input(4)](this._context)),s=r.Std.sma(i,this._input(0),this._context);return"Exponential"===this._input(3)?s=r.Std.ema(i,this._input(0),this._context):"Weighted"===this._input(3)&&(s=r.Std.wma(i,this._input(0),this._context)),[this.f_0(s,this._input(1)/100),s,this.f_1(s,this._input(2)/100)]}}},{name:"Standard Error",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!1,id:"Standard Error@tv-basicstudies-1",scriptIdPart:"",name:"Standard Error",description:"Standard Error",shortDescription:"Standard Error",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#FF6D00"}},inputs:{length:14}},styles:{plot_0:{title:"Plot"}},inputs:[{id:"length",type:"integer",name:"Length",min:3}],format:{precision:2,type:"price"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this.period=this._input(0)},this.main=function(e,t){this._context=e,this._input=t +;for(var i,s,n=this._context.new_var(r.Std.close(this._context)),o=0,a=0,l=0;l0?1:3,i=r.Std.change(this._context.new_var(e));return t-(r.Std.le(i,0)?0:1)},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std[this._input(2)](this._context),s=this._input(0),n=this._input(1),o=this._input(3);this._context.setMinimumAdditionalDepth(Math.max(s,n)+o);var a=this._context.new_var(i),l=r.Std.ema(a,s,this._context),c=this._context.new_var(i),h=r.Std.ema(c,n,this._context),d=this.f_0(l,h),u=this._context.new_var(d),p=r.Std.ema(u,o,this._context),_=this.f_0(d,p);return[_,d,p,this.f_1(_)]}}},{name:"Moving Average Exponential",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},smoothedMA:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1}},inputs:{length:9,source:"close",offset:0,smoothingLine:"SMA",smoothingLength:9}},plots:[{id:"plot_0",type:"line"},{id:"smoothedMA",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1},smoothedMA:{title:"Smoothed MA",histogramBase:0,joinPoints:!1}},description:"Moving Average Exponential",shortDescription:"EMA",is_price_study:!0,inputs:[{id:"length",name:"Length",defval:9,type:"integer",min:1,max:1e4},{id:"source",name:"Source",defval:"close",type:"source",options:["open","high","low","close","hl2","hlc3","ohlc4"]},{id:"offset",name:"Offset",defval:0,type:"integer",min:-1e4,max:1e4},{id:"smoothingLine",name:"Smoothing Line",defval:"SMA",type:"text",options:["SMA","EMA","WMA"]},{id:"smoothingLength",name:"Smoothing Length",defval:9,type:"integer",min:1,max:1e4}],id:"Moving Average Exponential@tv-basicstudies-1",scriptIdPart:"",name:"Moving Average Exponential",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=r.Std[this._input(1)](this._context),s=this._input(0),n=this._input(2),o=this._input(3),a=this._input(4);this._context.setMinimumAdditionalDepth(s+a);var l,c=this._context.new_var(i),h=r.Std.ema(c,s,this._context),d=this._context.new_var(h) +;return"EMA"===o?l=r.Std.ema(d,a,this._context):"WMA"===o?l=r.Std.wma(d,a,this._context):"SMA"===o&&(l=r.Std.sma(d,a,this._context)),[{value:h,offset:n},{value:l,offset:n}]}}},{name:"Moving Average Weighted",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:9,in_1:"close",in_2:0}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Moving Average Weighted",shortDescription:"WMA",is_price_study:!0,inputs:[{id:"in_0",name:"Length",defval:9,type:"integer",min:1,max:2e3},{id:"in_1",name:"Source",defval:"close",type:"source",options:["open","high","low","close","hl2","hlc3","ohlc4"]},{id:"in_2",name:"Offset",defval:0,type:"integer",min:-1e4,max:1e4}],id:"Moving Average Weighted@tv-basicstudies-1",scriptIdPart:"",name:"Moving Average Weighted",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=r.Std[this._input(1)](this._context),s=this._input(0),n=this._input(2),o=this._context.new_var(i);return[{value:r.Std.wma(o,s,this._context),offset:n}]}}},{name:"Moving Average Double",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,id:"Moving Average Double@tv-basicstudies-1",scriptIdPart:"",name:"Moving Average Double",description:"Moving Average Double",shortDescription:"Moving Average Double",is_price_study:!0,plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#FF6D00"},plot_1:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#2196F3"}},inputs:{firstPeriods:14,secondPeriods:21,method:"Simple"}},styles:{plot_0:{title:"Plot 1"},plot_1:{title:"Plot 2"}},inputs:[{id:"firstPeriods",name:"1st Period",type:"integer",defval:14,min:1,max:1e4},{id:"secondPeriods",name:"2nd Period",type:"integer",defval:21,min:1,max:1e4},{id:"method",name:"Method",type:"text",defval:"Simple",options:["Simple","Exponential","Weighted"]}],format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i,s,n=this._context.new_var(r.Std.close(this._context));return"Exponential"===this._input(2)?(i=r.Std.ema(n,this._input(0),this._context),s=r.Std.ema(n,this._input(1),this._context)):"Weighted"===this._input(2)?(i=r.Std.wma(n,this._input(0),this._context),s=r.Std.wma(n,this._input(1),this._context)):(i=r.Std.sma(n,this._input(0),this._context),s=r.Std.sma(n,this._input(1),this._context)),[i,s]}}},{name:"Moving Average Triple",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!0,id:"Moving Average Triple@tv-basicstudies-1",scriptIdPart:"",name:"Moving Average Triple",description:"Moving Average Triple",shortDescription:"Moving Average Triple",plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line" +}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,transparency:0,trackPrice:!1,color:"#FF6D00"},plot_1:{linestyle:0,visible:!0,linewidth:1,transparency:0,plottype:0,trackPrice:!1,color:"#2196F3"},plot_2:{linestyle:0,visible:!0,linewidth:1,transparency:0,plottype:0,trackPrice:!1,color:"#26C6DA"}},inputs:{firstPeriods:14,secondPeriods:21,thirdPeriods:35,method:"Simple"}},styles:{plot_0:{title:"Plot 1"},plot_1:{title:"Plot 2"},plot_2:{title:"Plot 3"}},inputs:[{id:"firstPeriods",name:"1st Period",type:"integer",defval:14,min:1,max:1e4},{id:"secondPeriods",name:"2nd Period",type:"integer",defval:21,min:1,max:1e4},{id:"thirdPeriods",name:"3rd Period",type:"integer",defval:35,min:1,max:1e4},{id:"method",name:"Method",type:"text",defval:"Simple",options:["Simple","Exponential","Weighted"]}],format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i,s,n,o=this._context.new_var(r.Std.close(this._context));return"Exponential"===this._input(3)?(i=r.Std.ema(o,this._input(0),this._context),s=r.Std.ema(o,this._input(1),this._context),n=r.Std.ema(o,this._input(2),this._context)):"Weighted"===this._input(3)?(i=r.Std.wma(o,this._input(0),this._context),s=r.Std.wma(o,this._input(1),this._context),n=r.Std.wma(o,this._input(2),this._context)):(i=r.Std.sma(o,this._input(0),this._context),s=r.Std.sma(o,this._input(1),this._context),n=r.Std.sma(o,this._input(2),this._context)),[i,s,n]}}},{name:"Moving Average Adaptive",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!0,id:"Moving Average Adaptive@tv-basicstudies-1",scriptIdPart:"",name:"Moving Average Adaptive",description:"Moving Average Adaptive",shortDescription:"Moving Average Adaptive",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,transparency:0,trackPrice:!1,color:"#AB47BC"}},inputs:{periods:10}},styles:{plot_0:{title:"Plot 1"}},inputs:[{id:"periods",name:"Period",type:"integer",defval:10,min:2,max:1e4}],format:{type:"inherit"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this.periods=this._input(0)},this.ama=function(e,t){var i=this.periods,s=this._context.new_var(),n=e.get(),o=r.Std.stdev(t,i,this._context),a=r.Std.log(n/e.get(i))/(o*Math.sqrt(i)),l=.1*Math.abs(a),c=(n-s.get(1))*l+s.get(1);return s.set(isNaN(c)?n:c),c},this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_var(r.Std.close(this._context)),s=this._context.new_var(r.Std.log(i.get()/i.get(1)));return[this.ama(i,s)]}}},{name:"Moving Average Hamming",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!0,id:"Moving Average Hamming@tv-basicstudies-1",scriptIdPart:"",name:"Moving Average Hamming",description:"Moving Average Hamming",shortDescription:"Moving Average Hamming",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,transparency:0,trackPrice:!1,color:"#4CAF50"}},inputs:{periods:10}}, +styles:{plot_0:{title:"Plot 1"}},inputs:[{id:"periods",name:"Period",type:"integer",defval:10,min:1,max:1e4}],format:{type:"inherit"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this.periods=this._input(0);for(var i=[],s=0,r=1;r<=this.periods;++r){var n=Math.sin((1+r)/this.periods*Math.PI/2);i.unshift(n),s+=n}this.hmaFactors=i,this.hmaFactorsSum=s},this.hma=function(e){for(var t=this.periods,i=0,s=0;sthis._context.new_var(s).get(1)?1:0,[100*r.Std.sma(this._context.new_var(i),this.rollingPeriod,this._context)]}}},{name:"Net Volume",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Net Volume",shortDescription:"Net Volume",is_price_study:!1,inputs:[],id:"Net Volume@tv-basicstudies-1",scriptIdPart:"",name:"Net Volume",format:{type:"volume"}},constructor:function(){this.f_0=function(e,t,i){return r.Std.gt(e,0)?t:r.Std.lt(i,0)?-t:0*t},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.close(this._context),s=this._context.new_var(i),n=r.Std.change(s);return[this.f_0(n,r.Std.volume(this._context),n)]}}},{name:"On Balance Volume",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},smoothedMA:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1}},inputs:{smoothingLine:"SMA",smoothingLength:9}},plots:[{id:"plot_0",type:"line"},{id:"smoothedMA",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1},smoothedMA:{title:"Smoothed MA",histogramBase:0,joinPoints:!1}},description:"On Balance Volume",shortDescription:"OBV",is_price_study:!1,inputs:[{id:"smoothingLine",name:"Smoothing Line",defval:"SMA",type:"text",options:["SMA","EMA","WMA"]},{id:"smoothingLength", +name:"Smoothing Length",defval:9,type:"integer",min:1,max:1e4}],id:"On Balance Volume@tv-basicstudies-1",scriptIdPart:"",name:"On Balance Volume",format:{type:"volume"}},constructor:function(){this.f_0=function(e,t,i){return r.Std.gt(e,0)?t:r.Std.lt(i,0)?-t:0*t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=r.Std.close(this._context),o=this._context.new_var(n),a=r.Std.change(o),l=this.f_0(a,r.Std.volume(this._context),a),c=r.Std.cum(l,this._context);this._context.setMinimumAdditionalDepth(s);var h,d=this._context.new_var(c);return"EMA"===i?h=r.Std.ema(d,s,this._context):"WMA"===i?h=r.Std.wma(d,s,this._context):"SMA"===i&&(h=r.Std.sma(d,s,this._context)),[c,h]}}},{name:"Parabolic SAR",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:3,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:.02,in_1:.02,in_2:.2}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Parabolic SAR",shortDescription:"SAR",is_price_study:!0,inputs:[{id:"in_0",name:"start",defval:.02,type:"float",min:-1e12,max:1e12},{id:"in_1",name:"increment",defval:.02,type:"float",min:-1e12,max:1e12},{id:"in_2",name:"maximum",defval:.2,type:"float",min:-1e12,max:1e12}],id:"Parabolic SAR@tv-basicstudies-1",scriptIdPart:"",name:"Parabolic SAR",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=this._input(2);return[r.Std.sar(i,s,n,this._context)]}}},{name:"Price Channel",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#F50057"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#F50057"},plot_2:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:20,in_1:0}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"Highprice Line",histogramBase:0,joinPoints:!1},plot_1:{title:"Lowprice Line",histogramBase:0,joinPoints:!1},plot_2:{title:"Centerprice Line",histogramBase:0,joinPoints:!1}},description:"Price Channel",shortDescription:"PC",is_price_study:!0,inputs:[{id:"in_0",name:"Length",defval:20,type:"integer",min:1,max:2e3},{id:"in_1",name:"Offset Length",defval:0,type:"integer",min:1,max:2e3}],id:"Price Channel@tv-basicstudies-1",scriptIdPart:"",name:"Price Channel",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.high(this._context),s=this._context.new_var(i),n=r.Std.low(this._context),o=this._context.new_var(n),a=this._input(0),l=this._input(1),c=r.Std.highest(s,a,this._context),h=r.Std.lowest(o,a,this._context);return[{value:c,offset:l},{value:h,offset:l},{value:r.Std.avg(c,h),offset:l}]}}},{name:"Price Oscillator", +metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:u}},inputs:{in_0:10,in_1:21}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Price Oscillator",shortDescription:"PPO",is_price_study:!1,inputs:[{id:"in_0",name:"shortlen",defval:10,type:"integer",min:1,max:2e3},{id:"in_1",name:"longlen",defval:21,type:"integer",min:1,max:2e3}],id:"Price Oscillator@tv-basicstudies-1",scriptIdPart:"",name:"Price Oscillator",format:{type:"price",precision:2}},constructor:function(){this.f_0=function(e,t){return(e-t)/t*100},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.close(this._context),s=this._input(0),n=this._input(1),o=this._context.new_var(i),a=r.Std.sma(o,s,this._context),l=this._context.new_var(i),c=r.Std.sma(l,n,this._context);return[this.f_0(a,c)]}}},{name:"Price Volume Trend",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"PVT",histogramBase:0,joinPoints:!1,isHidden:!1}},description:"Price Volume Trend",shortDescription:"PVT",is_price_study:!1,is_hidden_study:!1,id:"price_volume_trend@tv-basicstudies-1",inputs:[],scriptIdPart:"",name:"Price Volume Trend",format:{type:"volume"}},constructor:function(){this.f_0=function(){var e=this._context.new_var(r.Std.close(this._context));return[r.Std.cum(r.Std.change(e)/e.get(1)*r.Std.volume(this._context),this._context)]},this.main=function(e,t){return this._context=e,this._input=t,[this.f_0()[0]]}}},{name:"Rate Of Change",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{in_0:9}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"ROC",histogramBase:0,joinPoints:!1,isHidden:!1,zorder:1}},description:"Rate Of Change",shortDescription:"ROC",is_price_study:!1,bands:[{id:"hline_0",name:"Zero Line",isHidden:!1,zorder:-1}],inputs:[{id:"in_0",name:"length",defval:9,type:"integer",min:1,max:1e12}],id:"rate_of_change@tv-basicstudies-1",scriptIdPart:"",name:"Rate Of Change",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_var(r.Std.close(this._context)),s=this._input(0);return[100*(i.get(0)-i.get(s))/i.get(s)]}}},{name:"Relative Strength Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#7E57C2"},smoothedMA:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1}},bands:[{color:"#787B86", +linestyle:2,linewidth:1,visible:!0,value:70,zorder:-1.1},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:50,zorder:-1.11},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:30,zorder:-1.111}],filledAreasStyle:{fill_0:{color:"#7E57C2",transparency:90,visible:!0}},inputs:{length:14,smoothingLine:"SMA",smoothingLength:14}},plots:[{id:"plot_0",type:"line"},{id:"smoothedMA",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1},smoothedMA:{title:"Smoothed MA",histogramBase:0,joinPoints:!1,zorder:2}},description:"Relative Strength Index",shortDescription:"RSI",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_2",name:"MiddleLimit",zorder:-1.11},{id:"hline_1",name:"LowerLimit",zorder:-1.111}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",title:"Hlines Background",zorder:-2}],inputs:[{id:"length",name:"Length",defval:14,type:"integer",min:1,max:2e3},{id:"smoothingLine",name:"Smoothing Line",defval:"SMA",type:"text",options:["SMA","EMA","WMA"]},{id:"smoothingLength",name:"Smoothing Length",defval:14,type:"integer",min:1,max:1e4}],id:"Relative Strength Index@tv-basicstudies-1",scriptIdPart:"",name:"Relative Strength Index",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e){return r.Std.max(e,0)},this.f_1=function(e){return-r.Std.min(e,0)},this.f_2=function(e,t){return r.Std.eq(e,0)?100:r.Std.eq(t,0)?0:100-100/(1+t/e)},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.close(this._context),s=this._input(0),n=this._input(1),o=this._input(2);this._context.setMinimumAdditionalDepth(s+o);var a,l=this._context.new_var(i),c=r.Std.change(l),h=this.f_0(c),d=this._context.new_var(h),u=r.Std.rma(d,s,this._context),p=this.f_1(c),_=this._context.new_var(p),m=r.Std.rma(_,s,this._context),g=this.f_2(m,u),f=this._context.new_var(g);return"EMA"===n?a=r.Std.ema(f,o,this._context):"WMA"===n?a=r.Std.wma(f,o,this._context):"SMA"===n&&(a=r.Std.sma(f,o,this._context)),[{value:g},{value:a}]}}},{name:"Relative Vigor Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:u},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:a}},inputs:{in_0:10}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],styles:{plot_0:{title:"RVGI",histogramBase:0,joinPoints:!1},plot_1:{title:"Signal",histogramBase:0,joinPoints:!1}},description:"Relative Vigor Index",shortDescription:"RVGI",is_price_study:!1,inputs:[{id:"in_0",name:"Length",defval:10,type:"integer",min:1,max:2e3}],id:"Relative Vigor Index@tv-basicstudies-1",scriptIdPart:"",name:"Relative Vigor Index",format:{precision:4,type:"price"}},constructor:function(){this.f_0=function(e,t){return e-t},this.f_1=function(e,t){return e/t},this.main=function(e,t){this._context=e,this._input=t ;var i=this._input(0),s=this.f_0(r.Std.close(this._context),r.Std.open(this._context)),n=this._context.new_var(s),o=r.Std.swma(n,this._context),a=this._context.new_var(o),l=r.Std.sum(a,i,this._context),c=this.f_0(r.Std.high(this._context),r.Std.low(this._context)),h=this._context.new_var(c),d=r.Std.swma(h,this._context),u=this._context.new_var(d),p=r.Std.sum(u,i,this._context),_=this.f_1(l,p),m=this._context.new_var(_);return[_,r.Std.swma(m,this._context)]}}},{name:"Relative Volatility Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#7E57C2"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:80},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:20}],filledAreasStyle:{fill_0:{color:"#7E57C2",transparency:90,visible:!0}},inputs:{in_0:10}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1}},description:"Relative Volatility Index",shortDescription:"RVI",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_1",name:"LowerLimit",zorder:-1.11}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",title:"Hlines Background",zorder:-2}],inputs:[{id:"in_0",name:"length",defval:10,type:"integer",min:1,max:2e3}],id:"Relative Volatility Index@tv-basicstudies-1",scriptIdPart:"",name:"Relative Volatility Index",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t){return r.Std.le(e,0)?0:t},this.f_1=function(e,t){return r.Std.gt(e,0)?0:t},this.f_2=function(e,t){return e/(e+t)*100},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0);this._context.setMinimumAdditionalDepth(i+12);var s=r.Std.close(this._context),n=this._context.new_var(s),o=r.Std.stdev(n,i,this._context),a=this._context.new_var(s),l=r.Std.change(a),c=this.f_0(l,o),h=this._context.new_var(c),d=r.Std.ema(h,14,this._context),u=this.f_1(l,o),p=this._context.new_var(u),_=r.Std.ema(p,14,this._context);return[this.f_2(d,_)]}}},{name:"SMI Ergodic Indicator/Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"},plot_2:{linestyle:0,linewidth:1,plottype:1,trackPrice:!1,transparency:0,visible:!0,color:c}},inputs:{in_0:5,in_1:20,in_2:5}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"Indicator",histogramBase:0,joinPoints:!1},plot_1:{title:"Signal",histogramBase:0,joinPoints:!1},plot_2:{title:"Oscillator",histogramBase:0,joinPoints:!1}},description:"SMI Ergodic Indicator/Oscillator",shortDescription:"SMIIO",is_price_study:!1,inputs:[{id:"in_0",name:"shortlen",defval:5,type:"integer",min:1,max:2e3},{id:"in_1",name:"longlen",defval:20, type:"integer",min:1,max:2e3},{id:"in_2",name:"siglen",defval:5,type:"integer",min:1,max:2e3}],id:"SMI Ergodic Indicator/Oscillator@tv-basicstudies-1",scriptIdPart:"",name:"SMI Ergodic Indicator/Oscillator",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return e-t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=this._input(2);this._context.setMinimumAdditionalDepth(i+s+n);var o=r.Std.close(this._context),a=this._context.new_var(o),l=r.Std.tsi(a,i,s,this._context),c=this._context.new_var(l),h=r.Std.ema(c,n,this._context);return[l,h,this.f_0(l,h)]}}},{name:"Smoothed Moving Average",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#673AB7"}},inputs:{in_0:7,in_1:"close"}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,isHidden:!1}},description:"Smoothed Moving Average",shortDescription:"SMMA",is_price_study:!0,inputs:[{id:"in_0",name:"Length",defval:7,type:"integer",min:1,max:1e12},{id:"in_1",name:"Source",defval:"close",type:"source",options:["open","high","low","close","hl2","hlc3","ohlc4"]}],id:"smoothed_moving_average@tv-basicstudies-1",scriptIdPart:"",name:"Smoothed Moving Average",format:{type:"inherit"}},constructor:function(){this.f_0=function(){var e=this._input(0),t=r.Std[this._input(1)](this._context);return[r.Std.smma(t,e,this._context)]},this.main=function(e,t){return this._context=e,this._input=t,this.f_0()}}},{name:"Standard Deviation",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,id:"Standard Deviation@tv-basicstudies-1",scriptIdPart:"",name:"Standard Deviation",description:"Standard Deviation",shortDescription:"Standard Deviation",is_price_study:!1,plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:u}},inputs:{periods:5,deviations:1}},styles:{plot_0:{title:"Plot"}},inputs:[{id:"periods",name:"Periods",type:"integer"},{id:"deviations",name:"Deviations",type:"float"}],format:{precision:2,type:"price"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=this._context.new_var(r.Std.close(this._context));return[r.Std.stdev(n,i,this._context)*s]}}},{name:"Stochastic",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:80},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:20}],filledAreasStyle:{fill_0:{color:"#2196F3",transparency:90,visible:!0}},inputs:{in_0:14,in_1:1,in_2:3}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],styles:{plot_0:{ title:"%K",histogramBase:0,joinPoints:!1,zorder:1.1},plot_1:{title:"%D",histogramBase:0,joinPoints:!1,zorder:1.11}},description:"Stochastic",shortDescription:"Stoch",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_1",name:"LowerLimit",zorder:-1.11}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",title:"Hlines Background",zorder:-2}],inputs:[{id:"in_0",name:"K",defval:14,type:"integer",min:1,max:1e4},{id:"in_1",name:"D",defval:1,type:"integer",min:1,max:1e4},{id:"in_2",name:"smooth",defval:3,type:"integer",min:1,max:1e4}],id:"Stochastic@tv-basicstudies-1",scriptIdPart:"",name:"Stochastic",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=this._input(2);this._context.setMinimumAdditionalDepth(i+s+n);var o=r.Std.close(this._context),a=r.Std.high(this._context),l=r.Std.low(this._context),c=this._context.new_var(o),h=this._context.new_var(a),d=this._context.new_var(l),u=r.Std.stoch(c,h,d,i,this._context),p=this._context.new_var(u),_=r.Std.sma(p,s,this._context),m=this._context.new_var(_);return[_,r.Std.sma(m,n,this._context)]}}},{name:"Stochastic RSI",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:80},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:20}],filledAreasStyle:{fill_0:{color:"#2196F3",transparency:90,visible:!0}},inputs:{in_0:14,in_1:14,in_2:3,in_3:3}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],styles:{plot_0:{title:"%K",histogramBase:0,joinPoints:!1,zorder:1.1},plot_1:{title:"%D",histogramBase:0,joinPoints:!1,zorder:1.11}},description:"Stochastic RSI",shortDescription:"Stoch RSI",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_1",name:"LowerLimit",zorder:-1.11}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",title:"Hlines Background",zorder:-2}],inputs:[{id:"in_0",name:"lengthRSI",defval:14,type:"integer",min:1,max:1e4},{id:"in_1",name:"lengthStoch",defval:14,type:"integer",min:1,max:1e4},{id:"in_2",name:"smoothK",defval:3,type:"integer",min:1,max:1e4},{id:"in_3",name:"smoothD",defval:3,type:"integer",min:1,max:1e4}],id:"Stochastic RSI@tv-basicstudies-1",scriptIdPart:"",name:"Stochastic RSI",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.f_1=function(e,t,i){var s=i.new_var(r.Std.max(r.Std.change(e),0));return r.Std.rma(s,t,i)},this.f_2=function(e,t,i){var s=i.new_var(-r.Std.min(r.Std.change(e),0));return r.Std.rma(s,t,i)},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.close(this._context),s=this._input(0),n=this._input(1),o=this._input(2),a=this._input(3) @@ -122,27 +122,27 @@ plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{line in_4:5,in_5:3}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"Jaw",histogramBase:0,joinPoints:!1},plot_1:{title:"Teeth",histogramBase:0,joinPoints:!1},plot_2:{title:"Lips",histogramBase:0,joinPoints:!1}},description:"Williams Alligator",shortDescription:"Alligator",is_price_study:!0,inputs:[{id:"in_0",name:"Jaw Length",defval:21,type:"integer",min:1,max:2e3},{id:"in_1",name:"Teeth Length",defval:13,type:"integer",min:1,max:2e3},{id:"in_2",name:"Lips Length",defval:8,type:"integer",min:1,max:2e3},{id:"in_3",name:"Jaw Offset",defval:8,type:"integer",min:1,max:2e3},{id:"in_4",name:"Teeth Offset",defval:5,type:"integer",min:1,max:2e3},{id:"in_5",name:"Lips Offset",defval:3,type:"integer",min:1,max:2e3}],id:"Williams Alligator@tv-basicstudies-1",scriptIdPart:"",name:"Williams Alligator",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=this._input(2),o=this._input(3),a=this._input(4),l=this._input(5),c=r.Std.hl2(this._context);return[{value:r.Std.smma(c,i,this._context),offset:o},{value:r.Std.smma(c,s,this._context),offset:a},{value:r.Std.smma(c,n,this._context),offset:l}]}}},{name:"Williams Fractals",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,defaults:{styles:{plot_0:{plottype:"shape_triangle_down",visible:!0,location:"BelowBar",transparency:0,color:a},plot_1:{plottype:"shape_triangle_up",visible:!0,location:"AboveBar",transparency:0,color:u}},inputs:{in_0:2}},plots:[{id:"plot_0",type:"shapes"},{id:"plot_1",type:"shapes"}],styles:{plot_0:{title:"Down fractals",isHidden:!1},plot_1:{title:"Up fractals",isHidden:!1}},description:"Williams Fractal",shortDescription:"Fractals",is_price_study:!0,is_hidden_study:!1,id:"Williams Fractals@tv-basicstudies-1",inputs:[{id:"in_0",name:"Periods",defval:2,type:"integer",min:2,max:1e12}],scriptIdPart:"",name:"Williams Fractals",isCustomIndicator:!0,format:{type:"inherit"}},constructor:function(){this.f_0=function(){for(var e=this._input(0),t=this._context.new_var(r.Std.high(this._context)),i=!0,s=!0,n=!0,o=!0,a=!0,l=!0,c=1;c<=e;c++)i=r.Std.and(i,r.Std.lt(t.get(e-c),t.get(e))),s=r.Std.and(s,r.Std.lt(t.get(e+c),t.get(e))),n=r.Std.and(n,r.Std.and(r.Std.le(t.get(e+1),t.get(e)),r.Std.lt(t.get(e+c+1),t.get(e)))),o=r.Std.and(o,r.Std.and(r.Std.le(t.get(e+1),t.get(e)),r.Std.and(r.Std.le(t.get(e+2),t.get(e)),r.Std.lt(t.get(e+c+2),t.get(e))))),a=r.Std.and(a,r.Std.and(r.Std.le(t.get(e+1),t.get(e)),r.Std.and(r.Std.le(t.get(e+2),t.get(e)),r.Std.and(r.Std.le(t.get(e+3),t.get(e)),r.Std.lt(t.get(e+c+3),t.get(e)))))),l=r.Std.and(l,r.Std.and(r.Std.le(t.get(e+1),t.get(e)),r.Std.and(r.Std.le(t.get(e+2),t.get(e)),r.Std.and(r.Std.le(t.get(e+3),t.get(e)),r.Std.and(r.Std.le(t.get(e+4),t.get(e)),r.Std.lt(t.get(e+c+4),t.get(e)))))));var h=r.Std.or(s,r.Std.or(n,r.Std.or(o,r.Std.or(a,l)))),d=r.Std.and(i,h),u=this._context.new_var(r.Std.low(this._context)),p=1,_=1,m=1,g=1,f=1,v=1;for(c=1;c<=e;c++)p=r.Std.and(p,r.Std.gt(u.get(e-c),u.get(e))), _=r.Std.and(_,r.Std.gt(u.get(e+c),u.get(e))),m=r.Std.and(m,r.Std.and(r.Std.ge(u.get(e+1),u.get(e)),r.Std.gt(u.get(e+c+1),u.get(e)))),g=r.Std.and(g,r.Std.and(r.Std.ge(u.get(e+1),u.get(e)),r.Std.and(r.Std.ge(u.get(e+2),u.get(e)),r.Std.gt(u.get(e+c+2),u.get(e))))),f=r.Std.and(f,r.Std.and(r.Std.ge(u.get(e+1),u.get(e)),r.Std.and(r.Std.ge(u.get(e+2),u.get(e)),r.Std.and(r.Std.ge(u.get(e+3),u.get(e)),r.Std.gt(u.get(e+c+3),u.get(e)))))),v=r.Std.and(v,r.Std.and(r.Std.ge(u.get(e+1),u.get(e)),r.Std.and(r.Std.ge(u.get(e+2),u.get(e)),r.Std.and(r.Std.ge(u.get(e+3),u.get(e)),r.Std.and(r.Std.ge(u.get(e+4),u.get(e)),r.Std.gt(u.get(e+c+4),u.get(e)))))));var S=r.Std.or(_,r.Std.or(m,r.Std.or(g,r.Std.or(f,v))));return[r.Std.and(p,S),d]},this.main=function(e,t){this._context=e,this._input=t;var i=this.f_0();return[{value:i[0],offset:-this._input(0)},{value:i[1],offset:-this._input(0)}]}}},{name:"Guppy Multiple Moving Average",metainfo:{isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,description:"Guppy Multiple Moving Average",shortDescription:"GMMA",is_price_study:!0,id:"Guppy Multiple Moving Average@tv-basicstudies-1",_metainfoVersion:52,format:{type:"inherit"},defaults:{inputs:{traderEMA1Length:3,traderEMA2Length:5,traderEMA3Length:8,traderEMA4Length:10,traderEMA5Length:12,traderEMA6Length:15,investorEMA1Length:30,investorEMA2Length:35,investorEMA3Length:40,investorEMA4Length:45,investorEMA5Length:50,investorEMA6Length:60},styles:{traderEMA1:{color:"#00FFFF",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:15,visible:!0},traderEMA2:{color:"#00FFFF",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:12,visible:!0},traderEMA3:{color:"#00FFFF",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:9,visible:!0},traderEMA4:{color:"#00FFFF",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:6,visible:!0},traderEMA5:{color:"#00FFFF",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:3,visible:!0},traderEMA6:{color:"#00FFFF",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0},investorEMA1:{color:"#FF0000",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:15,visible:!0},investorEMA2:{color:"#FF0000",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:12,visible:!0},investorEMA3:{color:"#FF0000",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:9,visible:!0},investorEMA4:{color:"#FF0000",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:6,visible:!0},investorEMA5:{color:"#FF0000",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:3,visible:!0},investorEMA6:{color:"#FF0000",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0}}},inputs:[{defval:3,id:"traderEMA1Length",max:1e3,min:1,name:"Trader EMA 1 length",type:"integer"},{defval:5,id:"traderEMA2Length",max:1e3,min:1,name:"Trader EMA 2 length",type:"integer"},{defval:8,id:"traderEMA3Length",max:1e3,min:1,name:"Trader EMA 3 length",type:"integer"},{defval:10,id:"traderEMA4Length",max:1e3,min:1,name:"Trader EMA 4 length",type:"integer"},{ defval:12,id:"traderEMA5Length",max:1e3,min:1,name:"Trader EMA 5 length",type:"integer"},{defval:15,id:"traderEMA6Length",max:1e3,min:1,name:"Trader EMA 6 length",type:"integer"},{defval:30,id:"investorEMA1Length",max:1e3,min:1,name:"Investor EMA 1 length",type:"integer"},{defval:35,id:"investorEMA2Length",max:1e3,min:1,name:"Investor EMA 2 length",type:"integer"},{defval:40,id:"investorEMA3Length",max:1e3,min:1,name:"Investor EMA 3 length",type:"integer"},{defval:45,id:"investorEMA4Length",max:1e3,min:1,name:"Investor EMA 4 length",type:"integer"},{defval:50,id:"investorEMA5Length",max:1e3,min:1,name:"Investor EMA 5 length",type:"integer"},{defval:60,id:"investorEMA6Length",max:1e3,min:1,name:"Investor EMA 6 length",type:"integer"}],plots:[{id:"traderEMA1",type:"line"},{id:"traderEMA2",type:"line"},{id:"traderEMA3",type:"line"},{id:"traderEMA4",type:"line"},{id:"traderEMA5",type:"line"},{id:"traderEMA6",type:"line"},{id:"investorEMA1",type:"line"},{id:"investorEMA2",type:"line"},{id:"investorEMA3",type:"line"},{id:"investorEMA4",type:"line"},{id:"investorEMA5",type:"line"},{id:"investorEMA6",type:"line"}],styles:{traderEMA1:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Trader EMA 1"},traderEMA2:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Trader EMA 2"},traderEMA3:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Trader EMA 3"},traderEMA4:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Trader EMA 4"},traderEMA5:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Trader EMA 5"},traderEMA6:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Trader EMA 6"},investorEMA1:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Investor EMA 1"},investorEMA2:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Investor EMA 2"},investorEMA3:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Investor EMA 3"},investorEMA4:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Investor EMA 4"},investorEMA5:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Investor EMA 5"},investorEMA6:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Investor EMA 6"}}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_var(r.Std.close(this._context)),s=this._input(0),n=this._input(1),o=this._input(2),a=this._input(3),l=this._input(4),c=this._input(5),h=r.Std.ema(i,s,this._context),d=r.Std.ema(i,n,this._context),u=r.Std.ema(i,o,this._context),p=r.Std.ema(i,a,this._context),_=r.Std.ema(i,l,this._context),m=r.Std.ema(i,c,this._context),g=this._input(6),f=this._input(7),v=this._input(8),S=this._input(9),y=this._input(10),b=this._input(11);return[h,d,u,p,_,m,r.Std.ema(i,g,this._context),r.Std.ema(i,f,this._context),r.Std.ema(i,v,this._context),r.Std.ema(i,S,this._context),r.Std.ema(i,y,this._context),r.Std.ema(i,b,this._context)]}}},{name:"52 Week High/Low",metainfo:{_metainfoVersion:52,id:"52 Week High/Low@tv-basicstudies-1",description:"52 Week High/Low",shortDescription:"52W H/L",is_price_study:!0,format:{type:"inherit"},plots:[],graphics:{horizlines:{highest:{name:"Highest"},lowest:{name:"Lowest"}}}, -inputs:[{defval:"close",id:"highestSource",name:"High source",options:["close","high"],type:"text"},{defval:"close",id:"lowestSource",name:"Low source",options:["close","low"],type:"text"}],defaults:{graphics:{horizlines:{highest:{color:"rgb(93, 96, 107)",showPrice:!0,style:1,visible:!0,width:2},lowest:{color:"rgb(93, 96, 107)",showPrice:!0,style:1,visible:!0,width:2}}},inputs:{highestSource:"close",lowestSource:"close"}}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this._symbolSupports1DResolution=-1!==this._context.symbol.info.supported_resolutions.indexOf("1D"),this._symbolSupports1DResolution&&"1D"!==r.Std.period(this._context)&&this._context.new_sym(this._context.symbol.ticker,"1D")},this.main=function(e,t){this._symbolSupports1DResolution||r.Std.error(`Daily bars are not available for ${this._context.symbol.info.name}`),this._context=e,this._input=t,"1D"!==r.Std.period(this._context)&&this._context.select_sym(1);const i=this._input(0),s=this._input(1),n=r.Std.time(this._context),o=this._context.new_unlimited_var(n),a=this._context.new_unlimited_var(r.Std[i](this._context)),l=this._context.new_unlimited_var(r.Std[s](this._context));if(o.get(365),!this._context.symbol.isLastBar||!this._context.symbol.isNewBar)return null;const c=r.Std.add_years_considering_dst(this._context.symbol.info.timezone,new Date(n),-1),h=o.indexOf(c.getTime());return{nonseries:!0,type:"study_graphics",data:{graphicsCmds:{create:{horizlines:[{styleId:"highest",data:[{startIndex:n,endIndex:n,level:r.Std.highest(a,h,this._context),extendLeft:!0,extendRight:!0}]},{styleId:"lowest",data:[{startIndex:n,endIndex:n,level:r.Std.lowest(l,h,this._context),extendLeft:!0,extendRight:!0}]}]},erase:[{action:"all"}]}}}}}}]},66846:(e,t,i)=>{"use strict";var s;i.d(t,{SubsessionId:()=>s}),function(e){e.Regular="regular",e.Extended="extended",e.PreMarket="premarket",e.PostMarket="postmarket"}(s||(s={}))},34108:(e,t,i)=>{"use strict";i.d(t,{PointsetsManager:()=>n});var s=i(36274);const r=(0,i(59224).getLogger)("ChartApi.PointsetsManager");class n{constructor(){this._pointsetsDataBySymbol=new Map}destroy(){this._pointsetsDataBySymbol.clear()}createPointset(e,t,i,s,n){let o=this._pointsetsDataBySymbol.get(t);void 0===o&&(o=new Map,this._pointsetsDataBySymbol.set(t,o));const a=[];for(const t of s){const[i,s]=t;"number"!=typeof i||Number.isNaN(i)?r.logWarn(`Pointset time is invalid: id=${e}, ${i} of type ${typeof i}`):a.push({point:t,extrapolation:n.extrapolateTimeWithOffsetToTime(1e3*i,s)})}s.length===a.length&&o.set(e,{resolution:i,points:a})}removePointset(e){const t=[];this._pointsetsDataBySymbol.forEach(((i,s)=>{i.delete(e),0===i.size&&t.push(s)}));for(const e of t)this._pointsetsDataBySymbol.delete(e)}invalidatePointsetsForSymbol(e,t){const i=this._pointsetsDataBySymbol.get(e);void 0!==i&&i.forEach(((e,i)=>{if(s.Interval.isEqual(e.resolution,t))for(const t of e.points)null!==t.extrapolation&&t.extrapolation.exact&&(t.extrapolation.exact=!1)}))}getUpdatesForSymbol(e,t,i,s){const r=new Map,n=this._pointsetsDataBySymbol.get(e) -;return void 0!==n&&n.forEach(((e,n)=>{const o=this._refreshPointsetData(e,t,i,s);null!==o&&r.set(n,o)})),r}_refreshPointsetData(e,t,i,n){if(s.Interval.isEqual(e.resolution,t))for(let t=0;t ${t}`),null;o.push({index:i,value:[a.index,a.timeMs/1e3]})}return o}}},21125:(e,t,i)=>{"use strict";i.d(t,{SessionTimeScale:()=>v});var s=i(50151),r=i(14483),n=i(41249),o=i(78071),a=i(77475),l=i(61401),c=i(13041);function h(e){return 60*e*60*1e3}function d(e){return 60*e*1e3}const u=[{divisor:1,weight:18},{divisor:(p=1,1e3*p),weight:19},{divisor:d(1),weight:20},{divisor:d(5),weight:21},{divisor:d(30),weight:22},{divisor:h(1),weight:30},{divisor:h(3),weight:31},{divisor:h(6),weight:32},{divisor:h(12),weight:33}];var p;function _(e,t){if(null!==t){if(e.getUTCFullYear()!==t.getUTCFullYear())return 70;if(e.getUTCMonth()!==t.getUTCMonth())return 60;if(e.getUTCDate()!==t.getUTCDate())return 50;const i=t.getTime(),s=e.getTime();for(let e=u.length-1;e>=0;--e)if(Math.floor(i/u[e].divisor)!==Math.floor(s/u[e].divisor))return u[e].weight}return 18}function m(e,t,i=0){if(0===e.length)return[];let s=i,r=i;const n=[];for(;s=t.length?(n.push({old:s,new:l.INVALID_TIME_POINT_INDEX}),s++):e[s].timeMs===t[r].timeMs?(s!==r&&n.push({old:s,new:r}),s++,r++):e[s].timeMs{if(e.new===t.new&&e.new===l.INVALID_TIME_POINT_INDEX)return e.old-t.old;if(e.new===l.INVALID_TIME_POINT_INDEX)return-1;if(t.new===l.INVALID_TIME_POINT_INDEX)return 1;const i=e.old-e.new,s=t.old-t.new;return i>0?s>0?e.old-t.old:-1:s<0?t.new-e.new:1}))}function g(e,t){return{span:e.markWeight,time:e.displayTime,index:t}}const f=r.enabled("end_of_period_timescale_marks");class v{constructor(){this._completed=!0,this._mainSymbolExtrapolator=null,this._pointDataByTimePoint=new Map,this._instanceIds=new Set,this._displayTimezone=null,this._minFutureBarsCount=0,this._sortedTimePoints=[]}destroy(){this.clearTimeScale()}setCompleted(e){this._completed=e}isCompleted(){return this._completed}clearTimeScale(){return this._pointDataByTimePoint.clear(),this._instanceIds.clear(),this._sortedTimePoints=[],{baseIndex:null,pointsIndex:0,indexChange:[],marks:[],points:[]}}indexOfTime(e){if(0===this._sortedTimePoints.length)return null===this._mainSymbolExtrapolator?null:this._mainSymbolExtrapolator.indexOfTime(e);if(ethis._sortedTimePoints[this._sortedTimePoints.length-1].timeMs){if(null===this._mainSymbolExtrapolator)return null;const t=this._mainSymbolExtrapolator.indexOfTime(e),i=this._mainSymbolExtrapolator.indexOfTime(this._sortedTimePoints[this._sortedTimePoints.length-1].timeMs);if(null===t||null===i)return null;const s=t.index-i.index-1;return{index:this._sortedTimePoints.length+s,timeMs:t.timeMs}}let t=(0,o.lowerbound)(this._sortedTimePoints,e,((e,t)=>e.timeMs({timeMs:e,markWeight:0,displayTime:NaN})));this._fillPointsData(i,0,0!==this._sortedTimePoints.length?this._sortedTimePoints[this._sortedTimePoints.length-1].displayTime:null);const r=[];for(let t=e;tg(e,i+t)));return r.concat(n)}setTimezone(e){this._displayTimezone="exchange"===e?null:(0,n.get_timezone)(e),this._fillPointsData(this._sortedTimePoints,0)}fillIndexesInRows(e){if(0===e.length)return;let t=-1,i=(0,o.lowerbound)(this._sortedTimePoints,Math.round(1e3*e[0].value[0]),((e,t)=>e.timeMse.timeMs{for(;i=this._sortedTimePoints.length){const t=this.indexOfTime(e);if(null===t)return l.INVALID_TIME_POINT_INDEX;i=t.timeMs!==e?t.index+1:t.index}return(0,s.assert)(i>t,"data must have unique sorted times"),t=i,i}))}firstSeriesBarTime(){return 0===this._sortedTimePoints.length?null:this._sortedTimePoints[0].timeMs}replaceBarsTimesTail(e,t){if(0===t.length)return null;if(!this._instanceIds.has(e))return this.setSeriesBarsTimes(e,t);const i=[],s=(0, -o.lowerbound)(this._sortedTimePoints,t[0],((e,t)=>e.timeMs({timeMs:e.timeMs,pointData:e.pointData,markWeight:0,displayTime:NaN})));for(let e=s;ee.timeMs-t.timeMs));const a=this._updateTimeScalePointsTail(n);return this._applyTimeScaleChanges(a,!1)}setSeriesBarsTimes(e,t){return this._setBarsTimes(e,t)}setStudyBarsTimes(e,t){return this._setBarsTimes(e,t)}_setBarsTimes(e,t){const i=0!==this._pointDataByTimePoint.size;if(this._instanceIds.has(e))for(const t of this._sortedTimePoints)t.pointData.instances.delete(e);0===t.length?this._instanceIds.delete(e):this._instanceIds.add(e),this._addBarsTimesToInstance(e,t,!1),i&&this._cleanupPointsData(this._sortedTimePoints);const s=[];this._pointDataByTimePoint.forEach(((e,t)=>{s.push({markWeight:0,timeMs:t,displayTime:NaN,pointData:e})})),s.sort(((e,t)=>e.timeMs-t.timeMs));const r=this._updateTimeScalePoints(s);return this._applyTimeScaleChanges(r,!1)}_updateFutureBars(){if(0===this._minFutureBarsCount||null===this._mainSymbolExtrapolator)return;if(0!==this._sortedTimePoints.length){const e=this._sortedTimePoints[this._sortedTimePoints.length-1].timeMs;this._mainSymbolExtrapolator.ensureExtrapolatedToFutureTime(e)}const e=this._futureBarsFirstPointIndex();this._mainSymbolExtrapolator.setMinFutureBarsCount(e+this._minFutureBarsCount)}_addBarsTimesToInstance(e,t,i){const s=i?[]:null;for(const i of t){const t=this._pointDataByTimePoint.get(i);if(void 0===t){const t=new Set;t.add(e);const r={index:0,instances:t};this._pointDataByTimePoint.set(i,r),null!==s&&s.push({timeMs:i,pointData:r})}else t.instances.add(e)}return s}_futureBarsFirstPointIndex(){if(null===this._mainSymbolExtrapolator||0===this._sortedTimePoints.length)return 0;const e=this._mainSymbolExtrapolator.futureBars();return(0,o.upperbound_int)(e,this._sortedTimePoints[this._sortedTimePoints.length-1].timeMs)}_futureBars(){return null===this._mainSymbolExtrapolator?[]:this._mainSymbolExtrapolator.futureBars().slice(this._futureBarsFirstPointIndex(),this._futureBarsFirstPointIndex()+1e3)}_cleanupPointsData(e){for(const t of e)0===t.pointData.instances.size&&this._pointDataByTimePoint.delete(t.timeMs)}_updateTimeScalePoints(e){let t=-1;for(let i=0;ie.timeMs=this._sortedTimePoints.length)continue;this._sortedTimePoints[n].timeMs!==r.timeMs&&-1===i&&(i=n)}const s=t+e.length;if(i=S(i,this._sortedTimePoints.length,s),-1===i)return null;this._fillPointsData(e,0,0===t||0===this._sortedTimePoints.length?null:this._sortedTimePoints[t-1].displayTime);const r=m(this._sortedTimePoints.slice(t),e).map((e=>({old:e.old+t,new:e.new===l.INVALID_TIME_POINT_INDEX?e.new:e.new+t})));{const i=this._sortedTimePoints;let r=0;for(;t+r1&&null===i){const t=Math.ceil(n/(e.length-1)),i=new Date(1e3*(e[0].displayTime-t));e[0].markWeight=_(new Date(1e3*e[0].displayTime),i)}}(e,t,i)}_applyTimeScaleChanges(e,t){if(null===e)return t?(this._fillPointsData(this._sortedTimePoints,0),{points:[],pointsIndex:0,baseIndex:this._getBaseIndex(),indexChange:[],marks:this.tickMarks(0)}):null;let i=e.pointsIndex;if(0!==i&&t&&(this._fillPointsData(this._sortedTimePoints,0),i=0),0===this._sortedTimePoints.length)return{baseIndex:null,pointsIndex:0,indexChange:[],marks:[],points:[]};const s=[];for(let t=e.pointsIndex;t{"use strict";var s=i(3035),r=i(74649),n=i(61476),o=i(76537).SymbolExtrapolator,a=i(21125).SessionTimeScale,l=i(34108).PointsetsManager,c=i(60156),h=i(77475).createDwmAligner,d=i(36274).Interval,u=i(76422),p=i(2663).visitObject,_=i(1722).isObject;i(24172),i(60325) -;var m=i(79850).DatafeedRequestsCachedProcessor,g=i(38618).timezoneIsAvailable,f=i(77475).isAlignmentEnabled,v=i(27856),S=v.isEncodedExtendedSymbol,y=v.decodeExtendedSymbol,b=i(42960).extractSymbolNameFromSymbolInfo,w=i(48739).replaceGraphicsTimesWithTimePointIndexIndex,P=i(14483),C=i(66846).SubsessionId,x=i(60156).getPeriodsBetweenDates;const T="pre_post_market_sessions",I=P.enabled(T);var M=-5e6;function L(e){var t=e.findIndex((function(e){return e.index!==M}));return-1===t?[]:0===t?e:e.slice(t)}function A(e,t,i){if(e){if("string"==typeof e)return void console.warn("`logo_urls` should be an array of urls, not a string.");const[t,s]=e;s?(i["base-currency-logoid"]=t,i["currency-logoid"]=s):i.logoid=e}t&&(i.provider_id=t)}function k(e,t){return e+"_"+t}function D(e){if(null===e||"number"==typeof e)return e;if("object"==typeof e&&Array.isArray(e)){switch(e[0]){case"bar_count":return e[2];case"from_to":return e.length>=3?e[2]:null}}return null}var V=function(e){var t=this;this._studiesCache={},this._objectsDataCache={},this._studiesNonSeriesTimes={},this._metainfoCache=[],this._barsCoefficientsCache={},this._externalDatafeed=e,e.getVolumeProfileResolutionForPeriod&&r.overwriteVolumeProfileResolutionForPeriodGetter((function(t,i,s,r){return e.getVolumeProfileResolutionForPeriod(t,i,s,r)})),this._datafeedConfiguration=null,this._marketStatusWatchers={},this._resolveRequests={},this._resolvePromisesBySymbolId=new Map,this._symbolIdToSymbolRequestString=new Map,this._callbacks={},this._serverTimeOffset=0,t._logMessage("Datafeed settings received: {0}".format(JSON.stringify(window.configurationData))),t._datafeedConfiguration=t._adoptConfigurationData(window.configurationData),t._fireEvent("configuration_received"),t._externalDatafeed.getServerTime&&t._externalDatafeed.getServerTime((function(e){t._serverTimeOffset=e-(new Date).valueOf()/1e3})),this._invalidatedPointsetSessions=new Set,this._refreshPointsetsTimerId=null,this._pointsetsManagers={},this._quotesInfo=[],this._depthInfo=[],this._endOfData={},this._computeStudyCounter=0,this._symbolExtrapolators={},this._timeScales={},this._cachedDatafeed=new m(e,this.serverTimeOffset.bind(this),this._datafeedConfiguration.reset_cache_timeout),n.setupFeed({resolve:function(e,i,s,r){t._resolveSymbolByName(e,i,s,r)},subscribe:function(e,i,s,r,n){return t._cachedDatafeed.subscribe(e,i,s,function(e,i,s){var r=new c.SessionInfo(e.timezone,e.session,e.session_holidays,e.corrections),n=c.newBarBuilder(i,r,r);return function(e){if(e&&e.count()){var i=1e3*t.getCurrentUTCTime();n.moveTo(i),n.indexOfBar(i)>=0&&e.setLastBarClosed(!1)}s(e)}}(e,i,r),n)},unsubscribe:function(e){return t._cachedDatafeed.unsubscribe(e)}})};function E(e,t){return e+"_"+t}function B(e,t,i,s){return e+(t?"_#_"+t:"")+(i?"_#_"+i:"")+(s?"_#_"+s:"")}V.prototype._getSymbolExtrapolator=function(e,t,i){var s=d.normalize(i),r=function(e,t,i){const s=void 0!==t.subsession_id?","+t.subsession_id:"";return e+","+t.full_name+","+i+s}(e,t,s),n=this._symbolExtrapolators[r];return void 0===n&&(n=new o(t,s), -this._symbolExtrapolators[r]=n),n},V.prototype._barsCoefficients=function(e,t){if(void 0===y(e).type)return{};var i=e+t;return this._barsCoefficientsCache[i]||(this._barsCoefficientsCache[i]={}),this._barsCoefficientsCache[i]},V.prototype.destroy=function(){this._cachedDatafeed.destroy(),this._externalDatafeed=null,Object.keys(this._pointsetsManagers).forEach((function(e){this._pointsetsManagers[e].destroy()}),this),this._pointsetsManagers={}},V.prototype.purgeCache=function(){this._endOfData={},this._resolveRequests={},this._objectsDataCache={},this._studiesNonSeriesTimes={},this._studiesCache={},this._resolvePromisesBySymbolId.clear(),this._symbolIdToSymbolRequestString.clear(),Object.keys(this._pointsetsManagers).forEach((function(e){this._pointsetsManagers[e].destroy()}),this),this._pointsetsManagers={},Object.keys(this._timeScales).forEach((function(e){this._timeScales[e].destroy()}),this),this._timeScales={},Object.keys(this._symbolExtrapolators).forEach((function(e){this._symbolExtrapolators[e].destroy()}),this),this._symbolExtrapolators={}},V.prototype.purgeDataCache=function(){this._cachedDatafeed.purgeCache()},V.prototype._logMessage=function(e){P.enabled("charting_library_debug_mode")&&console.log(e)},V.prototype.on=function(e,t){return this._callbacks.hasOwnProperty(e)||(this._callbacks[e]=[]),this._callbacks[e].push(t),this},V.prototype._fireEvent=function(e,t,i){if(this._callbacks.hasOwnProperty(e)){for(var s=this._callbacks[e],r=0;r{this._resolveSymbolImpl(e,(e=>{t(e.price_sources)}),(e=>{i(e)}))}))},V.prototype.supportedSymbolsTypes=function(){return this._datafeedConfiguration.symbols_types||[]},V.prototype.symbolsGrouping=function(){return this._datafeedConfiguration.symbols_grouping||{futures:/$a/}},V.prototype._findStudyObject=function(e){e.endsWith("!")&&(e=e.slice(0,-1));var t=e.split("@")[0],i=JSServer.studyLibrary.filter((function(i){return i.metainfo.id===e||i.metainfo.shortDescription===t}));return 0===i.length?null:i[0]},V.prototype.getMarks=function(e,t,i,s,r){var n={red:6,green:5,blue:4,yellow:3};if(this._externalDatafeed.getMarks&&this._datafeedConfiguration.supports_marks){this._logMessage("Requesting bars marks: symbol {0}, resolution {1}, range [{2} ... {3}]".format(e.full_name,r,new Date(1e3*t).toUTCString(),new Date(1e3*i).toUTCString()));var o=this -;this._externalDatafeed.getMarks(e,t,i,(function(t){var i=t.map((function(e){return e.time=parseInt(e.time),e}));o._logMessage("Received bars marks: symbol {0}, resolution {1}, marks {2}".format(e.full_name,r,JSON.stringify(i)));var a=h(r,e),l=P.enabled("two_character_bar_marks_labels"),c=i.map((function(e){return e.tickmark=null!==a?a.timeToSessionStart(1e3*e.time)/1e3:e.time,e.direction=n[e.color],e.onClicked=function(){u.emit("onMarkClick",e.id)},e.label=!!e.label&&(l?e.label.slice(0,2):e.label[0]),e}));s(c)}),r)}},V.prototype.getTimescaleMarks=function(e,t,i,s,r){if(this._externalDatafeed.getTimescaleMarks&&this._datafeedConfiguration.supports_timescale_marks){this._logMessage("Requesting timescale marks: symbol {0}, resolution {1}, range [{2} ... {3}]".format(e.full_name,r,new Date(1e3*t).toUTCString(),new Date(1e3*i).toUTCString()));var n=this;this._externalDatafeed.getTimescaleMarks(e,t,i,(function(t){n._logMessage("Received timescale marks: symbol {0}, resolution {1}, marks {2}".format(e.full_name,r,JSON.stringify(t)));var i=h(r,e),o=t.map((function(e){return e.tickmark=null!==i?i.timeToSessionStart(1e3*e.time)/1e3:e.time,e}));s(o)}),r)}},V.prototype.getSeriesLastBarTime=function(e,t){var i=this._getSeriesData(e,t);return null===i||0===i.length?null:i[i.length-1].timeMs},V.prototype.getSeriesInterval=function(e,t){var i=this._studiesCache[e][t];return i?i.resolution:null},V.prototype.getSeriesSymbolInfo=function(e,t){var i=this._studiesCache[e][t];return i?i.symbolInfo:null},V.prototype._getSeriesData=function(e,t){return this._objectsDataCache[E(e,t)]||null},V.prototype._computeStudy=async function(e,t,i,s,n,o,a,l,c,u){var p=!0,_=[];null!==l&&(this._objectsDataCache[l]=null),this._timeScales[e].setCompleted(!1);var m=this._computeStudyCounter++;function g(e,t){if(e_[a].timeMs;l?_.push({index:g(s,_.length),value:[s/1e3].concat(r),timeMs:s}):(_[a].index=g(s,a),_[a].value=[s/1e3].concat(r),_[a].timeMs=s),p||u.onRealtimeCallback([_[_.length-1]],l,_.length,v,i)}(e,t,i)},nonseriesOut:function(e,t){u.onNonSeriesDataUpdate(t,i)},setNoMoreData:function(){S=!0},recalc:function(e,s){p=!1,_.endOfData=S,_.emptyBarCount=s.emptyBarCount,t.error&&null!==t.error()||(null!==l&&(y._objectsDataCache[l]=_),u.onDataReadyCallback(_,v,i,s))}});if(!y._studiesCache[e]||!y._studiesCache[e][n])throw Error("This should never happen");y._studiesCache[e][n].engine=w}catch(e){if(!e.studyError)throw e;u.onErrorCallback(e.message)}}else u.onErrorCallback("Unsupported resolution. Did you forget to set has_intraday to true?")}(w,C)},V.prototype._createStudy=function(e,t,i,s,r,n,o,a){var l=this;function c(e,t,i){if(l._studiesCache[s][r].completed=!0,e=L(e),l._setEndOfData(s,r,n,!0),l._studyCanExtendTimeScale(s,r)){const t=e.map((function(e){return e.timeMs})),i=l._timeScales[s].setStudyBarsTimes(r,t);l._applyTimeScaleUpdate(s,i)}l._timeScales[s].fillIndexesInRows(e),TradingView.ChartapiMessagerInstances[s].onDataUpdate(r,n,e,t),TradingView.ChartapiMessagerInstances[s].onStudyCompleted(r,n),l._updateTimeScaleState(s)}function h(e){var t={};if(0!==e.size){var i={},n=l._studiesCache[s][r].metainfo;e.forEach((function(e,t){i[n.plots[t].id]=e})),t.data={offsets:i}}return t}a=function(e){if(Array.isArray(e))return e;for(var t=[],i=l._studiesCache[s][r].metainfo.inputs,n=0;n=0},V.prototype.ensureExtendedTo=function(e,t,i){if(!this._studiesCache[t][e])throw Error("This should never happen");var s=this;setTimeout((function(){s._recreateSourcesForDataRange(t,{to:i})}),0)},V.prototype.extendSeriesRange=function(e,t){var i=this._timeScales[e].firstSeriesBarTime();if(null!==i){var s=this._mainSeriesRecord(e);if(d.isDWM(s.resolution)&&null!=s.symbolInfo){var r=h(s.resolution,s.symbolInfo);null!==r&&(i=r.timeToExchangeTradingDay(i))}var n=this._symbolIdToSymbolRequestString.get(k(e,s.symbolId)),o=this._barsCoefficients(n,s.resolution),a=o.barsCoefficient||1;if(!o.barsCoefficient){var l=this._getSeriesData(e,s.guid);null!==l&&(o.expectedBarsCount=l.length+t)}var c=this;setTimeout((function(){c._recreateSourcesForDataRange(e,{to:i,countBack:(t+2)*a})}),0) -}else this._logMessage("Nothing to extend - there is no points on time scale")},V.prototype.seriesTurnaround=function(e,t){return this._studiesCache[e]&&this._studiesCache[e][t]&&this._studiesCache[e][t].turnaround},V.prototype._seriesDataRange=function(e,t){var i=this._studiesCache[e][t];return null!==i.firstLoadedTimeMs?{to:i.firstLoadedTimeMs,countBack:0}:i.dataRange},V.prototype._applyTimeScaleUpdate=function(e,t){if(null!==t){var i=[];for(var s in this._studiesCache[e]){var r=this._studiesCache[e][s];if(r&&"study"===r.type){var n=this._studiesNonSeriesTimes[e][s];if(n){var o={indexes:this._timeScales[e].convertTimesToIndexes(n),data:{indexes_replace:!0}};i.push({objId:s,turnaround:r.turnaround,data:[],nonSeriesData:o})}}}TradingView.ChartapiMessagerInstances[e].onTimescaleUpdate(t,i),Promise.resolve().then(function(){var t=this._mainSeriesRecord(e);if(null!==t&&null!=t.symbolInfo){var i=this._getSymbolExtrapolator(e,t.symbolInfo,t.resolution);this._pointsetsManagers[e].getUpdatesForSymbol(t.symbolInfo.full_name,t.resolution,i,this._timeScales[e]).forEach((function(t,i){TradingView.ChartapiMessagerInstances[e].onPointsetDataUpdate(i,null,t)}))}}.bind(this))}},V.prototype._updateMainTsBuilder=function(e){var t=this._mainSeriesRecord(e);if(null!==t&&null!=t.symbolInfo){var i=this._getSymbolExtrapolator(e,t.symbolInfo,t.resolution);this._timeScales[e].setMainSymbolExtrapolator(i)}},V.prototype._updateTimeScaleState=function(e){var t=!0,i=!0;for(var s in this._studiesCache[e]){var r=this._studiesCache[e][s];i=i&&this._isEndOfData(e,s,r.turnaround),t=t&&r.completed}this._timeScales[e].isCompleted()!==t&&(this._timeScales[e].setCompleted(t),t&&TradingView.ChartapiMessagerInstances[e].onTimescaleCompleted(i))},V.prototype._mainSeriesRecord=function(e){var t=null,i=null;for(var s in this._studiesCache[e]){var r=this._studiesCache[e][s];if("series"===r.type&&(null===t&&(t=r),r.isMain)){i=r;break}}return null===i&&(i=t),null!==i&&(i.isMain=!0),i},V.prototype._seriesCount=function(e){var t=0;for(var i in this._studiesCache[e]){"series"===this._studiesCache[e][i].type&&(t+=1)}return t},V.prototype._prepareSeriesNonSeriesData=function(e,t,i){var s=i.data[i.data.length-1],r=this._getSeriesData(e,t),n=null===r?[]:i.data;return{data:{data:{reversalAmount:i.reversalAmount,boxSize:i.boxSize,price:s?s[4]:i.price,bars:n.map((function(e,t){return{time:t,open:e[1],high:e[2],low:e[3],close:e[4],volume:e[5],factor:e[6],additionalPrice:e[6]}}))}},indexes:this._timeScales[e].convertTimesToIndexes(n.map((function(e){var t=e[0]||0;return t<0?r[r.length+t].timeMs:i.projectionTime+t})))}},V.prototype.createSeries=function(e,t,i,s,n,o,a){this._setEndOfData(e,t,i,!1);var l=new r.OHLCV;this._studiesCache[e]=this._studiesCache[e]||{};var c=this._getSeriesData(e,t),h=this._studiesCache[e][t],u=this._seriesCount(e),p=this._mainSeriesRecord(e);if(!h||d.isEqual(h.resolution,n)&&h.symbolId===s)void 0!==o.countBack&&null!==c&&0!==c.length&&(o.to=c[0].timeMs), -h&&null!=h.firstLoadedTimeMs?o.to=void 0!==o.to?Math.min(h.firstLoadedTimeMs,o.to):h.firstLoadedTimeMs:h||0===u||null!==p&&(null!=p.firstLoadedTimeMs?(o.to=p.firstLoadedTimeMs,o.countBack=0):o=Object.assign({},p.dataRange));else if(1===u)o=Object.assign({},h.initialDatarange);else{var _=this._timeScales[e].firstSeriesBarTime();(void 0===o.to||null!==_&&_{A(e.logo_urls,e.exchange_logo,e)})),s(e)}))},V.prototype.resolveSymbol=function(e,t,i){var s=this;this._symbolIdToSymbolRequestString.set(k(e,t),i),this._resolvePromisesBySymbolId.set(k(e,t),new Promise((function(r,n){s._resolveSymbolImpl(i,(function(s){TradingView.ChartapiMessagerInstances[e].onSymbolResolved(t,s),r({symbolInfo:s,requestedSymbol:i})}),(function(i){TradingView.ChartapiMessagerInstances[e].onSymbolError(t,i),n(i)}))})))},V.prototype._resolveSymbolImpl=function(e,t,i){S(e)||console.error("Expect to get symbol encoded string, but got the following instead: "+e);var s=y(e),r="string"==typeof s.symbol?s:s.symbol,n=r.symbol,o=r["currency-id"],a=r["unit-id"],l=r.session===C.Regular?void 0:r.session;this._resolveSymbolByName(n,{currency:o,unit:a,session:l},t,i)},V.prototype._resolveSymbolByName=function(e,t,i,s){var r,n=t&&t.currency,o=t&&t.unit,a=t&&t.session,l=B(e,n,o,a);if(this._resolveRequests[l])r=this._resolveRequests[l];else{r=this._resolveSymbolInternal(e,n||void 0,o||void 0,a||void 0),this._resolveRequests[l]=r;var c=this;r.then((function(t){c._resolveRequests[B(e,t.currency_id,t.unit_id,t.subsession_id)]=r,c._resolveRequests[B(b(t,null),t.currency_id,t.unit_id,t.subsession_id)]=r,c._resolveRequests[B(b(t,null),n,o,a)]=r})).catch((function(){}))}r.then(i).catch(s)},V.prototype._resolveSymbolInternal=function(e,t,i,s){var r=this;return new Promise(function(n,o){this._logMessage("Symbol resolve requested: `{0}` ".format(e));var a=!0;this._externalDatafeed.resolveSymbol(e,(function(t){a&&console.warn("`resolveSymbol` should return result asynchronously. Use `setTimeout` with 0 interval to execute the callback function."),r._logMessage("Symbol resolved: `{0}`, SymbolInfo in server response {1}".format(e,JSON.stringify(t))),function(e){if(e.base_name||(e.base_name=[e.name]),e.legs||(e.legs=[e.name]),e.exchange||(e.exchange=e["exchange-listed"]),e.full_name||(e.full_name=e.ticker||(e.exchange?e.exchange+":"+e.name:e.name)),e.pro_name||(e.pro_name=e.full_name),e.data_status||(e.data_status="streaming"),e.ticker||(e.ticker=e.symbol||e.name), -!e.session&&e["session-regular"]&&(e.session=e["session-regular"]),!e.minmov&&e.minmovement&&(e.minmov=e.minmovement),e.currency_code&&(e.currency_id=e.currency_code),e.original_currency_code&&(e.original_currency_id=e.original_currency_code),e.holidays&&(e.session_holidays=e.holidays),void 0!==e.has_no_volume&&(e.visible_plots_set=e.has_no_volume?"ohlc":"ohlcv"),e.supported_resolutions)for(var t=0;t{"use strict";i.d(t,{SymbolExtrapolator:()=>c});var s=i(50151),r=i(78071),n=i(60156),o=i(94421),a=i(36274);function l(e,t){return e.length>t}class c{constructor(e,t,i=2e5){this._firstRealBarTimeMs=null,this._historyBarsCache=[],this._projectionFirstIndex=1/0,this._barsTimes=[],this._minFutureBarsCount=0,this._lastRealBarTimeMs=null,this._futureBarsCache=[],this._symbolInfo=e,this._interval=a.Interval.parse(t),this._extrapolateLimit=i,this._barBuilder=(0,n.newBarBuilder)(t,new n.SessionInfo(e.timezone,e.session,e.session_holidays,e.corrections),null)}destroy(){this.clear()}interval(){return this._interval}barBuilder(){return this._barBuilder}symbolInfo(){return this._symbolInfo}clear(){this._firstRealBarTimeMs=null,this._historyBarsCache=[],this._barsTimes=[],this._lastRealBarTimeMs=null,this._futureBarsCache=[],this._minFutureBarsCount=0,this._projectionFirstIndex=1/0}firstFutureBarIndex(){return this._barsTimes.length}futureBars(){return this._futureBarsCache}replaceBarsTimesTail(e,t=e.length){if(0===e.length)return;if(0===this._barsTimes.length)return void this.setBarsTimes(e,t);const i=e[0],n=this._barsTimes[this._barsTimes.length-1],o=i>n?this._barsTimes.length:(0,r.lowerbound_int)(this._barsTimes,i) -;0!==o?(this._barsTimes.splice(o,this._barsTimes.length,...e),this._projectionFirstIndex=t===e.length?this._barsTimes.length:this._barsTimes.indexOf(e[t]),(0,s.assert)(-1!==this._projectionFirstIndex,"something went wrong"),n!==e[e.length-1]&&this._setLastRealBarTime(e[e.length-1])):this.setBarsTimes(e,t)}setBarsTimes(e,t=e.length){const i=this._barsTimes;if(this._barsTimes=e.slice(),this._projectionFirstIndex=0===this._barsTimes.length?1/0:t,0===e.length)return this._historyBarsCache=[],this._futureBarsCache=[],this._firstRealBarTimeMs=null,void(this._lastRealBarTimeMs=null);0!==i.length&&i[i.length-1]===e[e.length-1]||this._setLastRealBarTime(e[e.length-1]),0!==i.length&&i[0]===e[0]||(this._historyBarsCache=[],this._firstRealBarTimeMs=e[0])}extrapolateTimeWithOffsetToTime(e,t){if(0===t)return{timeMs:e,exact:!0};0===this._barsTimes.length&&(t<0?null===this._firstRealBarTimeMs?this._firstRealBarTimeMs=e:(this._extendHistoryCacheToTimeFromRight(Math.min(e,null!==this._lastRealBarTimeMs?this._lastRealBarTimeMs:1/0)),this._ensureExtrapolatedToHistoryTime(e)):null===this._lastRealBarTimeMs?this._lastRealBarTimeMs=e:(this._extendFutureCacheToTimeFromLeft(Math.max(e,null!==this._firstRealBarTimeMs?this._firstRealBarTimeMs:1/0)),this._ensureExtrapolatedToFutureTime(e)));const i=this.indexOfTime(e);if(null===i)return null;const s=this._timeOfBarIndex(i.index+t);return null===s?null:((i.index<0||this._projectionFirstIndex<=i.index)&&(s.exact=!1),s)}indexOfTime(e){if(null!==this._firstRealBarTimeMs&&ethis._lastRealBarTimeMs){this._ensureExtrapolatedToFutureTime(e);let t=(0,r.lowerbound_int)(this._futureBarsCache,e);if(0!==this._futureBarsCache.length&&t===this._futureBarsCache.length&&e>this._futureBarsCache[this._futureBarsCache.length-1])return null;this._futureBarsCache[t]!==e&&(t-=1);const i=Math.max(1,this._barsTimes.length)+t;return{index:i,timeMs:i===this._barsTimes.length-1?(0,s.ensureNotNull)(this._lastRealBarTimeMs):this._futureBarsCache[t]}}if(0===this._barsTimes.length)return null!==this._firstRealBarTimeMs&&this._firstRealBarTimeMs<=e||null!==this._lastRealBarTimeMs&&e<=this._lastRealBarTimeMs?{index:0,timeMs:(0,s.ensureNotNull)(this._timeOfBarIndex(0)).timeMs}:null;let t=(0,r.lowerbound_int)(this._barsTimes,e);return this._barsTimes[t]!==e&&(t-=1),{index:t,timeMs:this._barsTimes[t]}}setMinFutureBarsCount(e){this._minFutureBarsCount=e,0!==this._barsTimes.length&&this._ensureExtrapolatedToFutureBar(e)}ensureExtrapolatedToFutureTime(e){this._ensureExtrapolatedToFutureTime(e)}_setLastRealBarTime(e){const t=this._futureBarsCache.length,i=(0,r.upperbound_int)(this._futureBarsCache,e) -;0===i?this._extendFutureCacheToTimeFromLeft(e):(this._lastRealBarTimeMs=e,this._futureBarsCache=this._futureBarsCache.slice(i)),this._ensureExtrapolatedToFutureBar(Math.max(t,this._minFutureBarsCount))}_timeOfBarIndex(e){var t;if(e<0){const t=Math.abs(e);this._ensureExtrapolatedToHistoryBar(t);const i=this._historyBarsCache.length-t;return i<0?null:{timeMs:this._historyBarsCache[i],exact:!1}}if(0===e&&0===this._barsTimes.length)return{timeMs:(0,s.ensureNotNull)(null!==(t=this._firstRealBarTimeMs)&&void 0!==t?t:this._lastRealBarTimeMs),exact:!1};if(e>=this._barsTimes.length){const t=e-Math.max(1,this._barsTimes.length);return this._ensureExtrapolatedToFutureBar(t+1),t>=this._futureBarsCache.length?null:{timeMs:this._futureBarsCache[t],exact:!1}}return{timeMs:this._barsTimes[e],exact:e=e)return;if((0,s.assert)(0===this._barsTimes.length,"bars should be empty"),this._firstRealBarTimeMs=e,0===this._historyBarsCache.length)return;const t=(0,o.extrapolateBarsFrontToTime)(this._barBuilder,this._historyBarsCache[this._historyBarsCache.length-1],e-1,this._extrapolateLimit,!0).times;this._historyBarsCache=this._historyBarsCache.concat(t)}_ensureExtrapolatedToFutureBar(e){return!(this._futureBarsCache.length>=e||l(this._futureBarsCache,this._extrapolateLimit))&&this._extendFutureCacheFromRight(((t,i)=>(0,o.extrapolateBarsFrontByCount)(this._barBuilder,t,e-i,!0).times))}_ensureExtrapolatedToFutureTime(e){null!==this._lastRealBarTimeMs&&this._lastRealBarTimeMs>=e||l(this._futureBarsCache,this._extrapolateLimit)||0!==this._futureBarsCache.length&&this._futureBarsCache[this._futureBarsCache.length-1]>=e||(this._extendFutureCacheFromRight(((t,i)=>(0,o.extrapolateBarsFrontToTime)(this._barBuilder,t,e,this._extrapolateLimit,!0).times)),this._futureBarsCache[this._futureBarsCache.length-1]=e||l(this._historyBarsCache,this._extrapolateLimit)||this._extendHistoryCacheFromLeft(((t,i)=>(0,o.extrapolateBarsFrontByCount)(this._barBuilder,t,-(e-i),!0).times.reverse()))}_ensureExtrapolatedToHistoryTime(e){null!==this._firstRealBarTimeMs&&this._firstRealBarTimeMs<=e||l(this._historyBarsCache,this._extrapolateLimit)||0!==this._historyBarsCache.length&&this._historyBarsCache[0]<=e||(this._extendHistoryCacheFromLeft(((t,i)=>{const s=(0,o.extrapolateBarsFrontToTime)(this._barBuilder,t-1,e-1,this._extrapolateLimit,!0).times;return s[s.length-1]===t?s.slice(0,-1):s})),(0===this._historyBarsCache.length||this._historyBarsCache[0]>e)&&this._ensureExtrapolatedToHistoryBar(this._historyBarsCache.length+1))}}},61595:(e,t,i)=>{"use strict";i.d(t,{backend:()=>s});const s=i(58844)},47327:(e,t,i)=>{"use strict";i.d(t,{HandlerInfo:()=>s});class s{constructor(e,t){this.handler=e,this.customId=t}}},17133:(e,t,i)=>{"use strict";var s,r;function n(e,t){return"period-back"===e.type&&"period-back"===t.type?e.value===t.value:"time-range"===e.type&&"time-range"===t.type&&(e.from===t.from&&e.to===t.to)}i.d(t,{TIMEFRAMETYPE:()=>r,areEqualTimeFrames:()=>n}),function(e){e.extractErrorReason=function(e){return e.params[1]}}(s||(s={})),function(e){e.PeriodBack="period-back",e.TimeRange="time-range"}(r||(r={}))},89173:()=>{"use strict";TradingView.Pro=function(){this.hasPackage=function(){return!1}},window.user={is_pro:!1,settings:{}},TradingView.Pro.prototype.isPaidPro=function(){return!1},TradingView.Pro.prototype.isSupportAvailable=function(){return!1},TradingView.Pro.prototype.getProduct=function(){return{}},TradingView.Pro.prototype.getStudiesOrder=function(){return[]}},67545:(e,t,i)=>{"use strict";i.r(t),i.d(t,{QUOTE_FIELDS:()=>n,QUOTE_FIELDS_CACHE:()=>o,QuoteCache:()=>r});var s=i(50151);class r{constructor(e){this._cache=new Map,this._fields=[...e.fields]}update(e,t,i){const r=(0,s.ensureDefined)(e.symbolname);if(this._cache.has(r)||this._cache.set(r,{symbolname:r,status:e.status,values:{}}),"error"===e.status)return;const n=(0,s.ensureDefined)(this._cache.get(r));n.status=e.status;for(const s of this._fields)t.has(s)&&(i||void 0!==e.values[s])&&(n.values[s]=e.values[s])}get(e){var t;return null!==(t=this._cache.get(e))&&void 0!==t?t:null}fields(){return this._fields}} +inputs:[{defval:"close",id:"highestSource",name:"High source",options:["close","high"],type:"text"},{defval:"close",id:"lowestSource",name:"Low source",options:["close","low"],type:"text"}],defaults:{graphics:{horizlines:{highest:{color:"rgb(93, 96, 107)",showPrice:!0,style:1,visible:!0,width:2},lowest:{color:"rgb(93, 96, 107)",showPrice:!0,style:1,visible:!0,width:2}}},inputs:{highestSource:"close",lowestSource:"close"}}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this._symbolSupports1DResolution=0===this._context.symbol.info.supported_resolutions.length||-1!==this._context.symbol.info.supported_resolutions.indexOf("1D"),this._symbolSupports1DResolution&&"1D"!==r.Std.period(this._context)&&this._context.new_sym(this._context.symbol.ticker,"1D")},this.main=function(e,t){this._symbolSupports1DResolution||r.Std.error(`Daily bars are not available for ${this._context.symbol.info.name}`),this._context=e,this._input=t,"1D"!==r.Std.period(this._context)&&this._context.select_sym(1);const i=this._input(0),s=this._input(1),n=r.Std.time(this._context),o=this._context.new_unlimited_var(n),a=this._context.new_unlimited_var(r.Std[i](this._context)),l=this._context.new_unlimited_var(r.Std[s](this._context));if(o.get(365),!this._context.symbol.isLastBar||!this._context.symbol.isNewBar)return null;const c=r.Std.add_years_considering_dst(this._context.symbol.info.timezone,new Date(n),-1),h=o.indexOf(c.getTime());return{nonseries:!0,type:"study_graphics",data:{graphicsCmds:{create:{horizlines:[{styleId:"highest",data:[{startIndex:n,endIndex:n,level:r.Std.highest(a,h,this._context),extendLeft:!0,extendRight:!0}]},{styleId:"lowest",data:[{startIndex:n,endIndex:n,level:r.Std.lowest(l,h,this._context),extendLeft:!0,extendRight:!0}]}]},erase:[{action:"all"}]}}}}}}]},66846:(e,t,i)=>{"use strict";var s;i.d(t,{SubsessionId:()=>s}),function(e){e.Regular="regular",e.Extended="extended",e.PreMarket="premarket",e.PostMarket="postmarket"}(s||(s={}))},34108:(e,t,i)=>{"use strict";i.d(t,{PointsetsManager:()=>n});var s=i(36274);const r=(0,i(59224).getLogger)("ChartApi.PointsetsManager");class n{constructor(){this._pointsetsDataBySymbol=new Map}destroy(){this._pointsetsDataBySymbol.clear()}createPointset(e,t,i,s,n){let o=this._pointsetsDataBySymbol.get(t);void 0===o&&(o=new Map,this._pointsetsDataBySymbol.set(t,o));const a=[];for(const t of s){const[i,s]=t;"number"!=typeof i||Number.isNaN(i)?r.logWarn(`Pointset time is invalid: id=${e}, ${i} of type ${typeof i}`):a.push({point:t,extrapolation:n.extrapolateTimeWithOffsetToTime(1e3*i,s)})}s.length===a.length&&o.set(e,{resolution:i,points:a})}removePointset(e){const t=[];this._pointsetsDataBySymbol.forEach(((i,s)=>{i.delete(e),0===i.size&&t.push(s)}));for(const e of t)this._pointsetsDataBySymbol.delete(e)}invalidatePointsetsForSymbol(e,t){const i=this._pointsetsDataBySymbol.get(e);void 0!==i&&i.forEach(((e,i)=>{if(s.Interval.isEqual(e.resolution,t))for(const t of e.points)null!==t.extrapolation&&t.extrapolation.exact&&(t.extrapolation.exact=!1)}))} +getUpdatesForSymbol(e,t,i,s){const r=new Map,n=this._pointsetsDataBySymbol.get(e);return void 0!==n&&n.forEach(((e,n)=>{const o=this._refreshPointsetData(e,t,i,s);null!==o&&r.set(n,o)})),r}_refreshPointsetData(e,t,i,n){if(s.Interval.isEqual(e.resolution,t))for(let t=0;t ${t}`),null;o.push({index:i,value:[a.index,a.timeMs/1e3]})}return o}}},21125:(e,t,i)=>{"use strict";i.d(t,{SessionTimeScale:()=>v});var s=i(50151),r=i(14483),n=i(41249),o=i(78071),a=i(77475),l=i(61401),c=i(13041);function h(e){return 60*e*60*1e3}function d(e){return 60*e*1e3}const u=[{divisor:1,weight:18},{divisor:(p=1,1e3*p),weight:19},{divisor:d(1),weight:20},{divisor:d(5),weight:21},{divisor:d(30),weight:22},{divisor:h(1),weight:30},{divisor:h(3),weight:31},{divisor:h(6),weight:32},{divisor:h(12),weight:33}];var p;function _(e,t){if(null!==t){if(e.getUTCFullYear()!==t.getUTCFullYear())return 70;if(e.getUTCMonth()!==t.getUTCMonth())return 60;if(e.getUTCDate()!==t.getUTCDate())return 50;const i=t.getTime(),s=e.getTime();for(let e=u.length-1;e>=0;--e)if(Math.floor(i/u[e].divisor)!==Math.floor(s/u[e].divisor))return u[e].weight}return 18}function m(e,t,i=0){if(0===e.length)return[];let s=i,r=i;const n=[];for(;s=t.length?(n.push({old:s,new:l.INVALID_TIME_POINT_INDEX}),s++):e[s].timeMs===t[r].timeMs?(s!==r&&n.push({old:s,new:r}),s++,r++):e[s].timeMs{if(e.new===t.new&&e.new===l.INVALID_TIME_POINT_INDEX)return e.old-t.old;if(e.new===l.INVALID_TIME_POINT_INDEX)return-1;if(t.new===l.INVALID_TIME_POINT_INDEX)return 1;const i=e.old-e.new,s=t.old-t.new;return i>0?s>0?e.old-t.old:-1:s<0?t.new-e.new:1}))}function g(e,t){return{span:e.markWeight,time:e.displayTime,index:t}}const f=r.enabled("end_of_period_timescale_marks");class v{constructor(){this._completed=!0,this._mainSymbolExtrapolator=null,this._pointDataByTimePoint=new Map,this._instanceIds=new Set,this._displayTimezone=null,this._minFutureBarsCount=0,this._sortedTimePoints=[]}destroy(){this.clearTimeScale()}setCompleted(e){this._completed=e}isCompleted(){return this._completed}clearTimeScale(){return this._pointDataByTimePoint.clear(),this._instanceIds.clear(),this._sortedTimePoints=[],{baseIndex:null,pointsIndex:0,indexChange:[],marks:[],points:[]}}indexOfTime(e){if(0===this._sortedTimePoints.length)return null===this._mainSymbolExtrapolator?null:this._mainSymbolExtrapolator.indexOfTime(e);if(ethis._sortedTimePoints[this._sortedTimePoints.length-1].timeMs){if(null===this._mainSymbolExtrapolator)return null;const t=this._mainSymbolExtrapolator.indexOfTime(e),i=this._mainSymbolExtrapolator.indexOfTime(this._sortedTimePoints[this._sortedTimePoints.length-1].timeMs);if(null===t||null===i)return null;const s=t.index-i.index-1;return{index:this._sortedTimePoints.length+s,timeMs:t.timeMs}}let t=(0,o.lowerbound)(this._sortedTimePoints,e,((e,t)=>e.timeMs({timeMs:e,markWeight:0,displayTime:NaN})));this._fillPointsData(i,0,0!==this._sortedTimePoints.length?this._sortedTimePoints[this._sortedTimePoints.length-1].displayTime:null);const r=[];for(let t=e;tg(e,i+t)));return r.concat(n)}setTimezone(e){this._displayTimezone="exchange"===e?null:(0,n.get_timezone)(e),this._fillPointsData(this._sortedTimePoints,0)}fillIndexesInRows(e){if(0===e.length)return;let t=-1,i=(0,o.lowerbound)(this._sortedTimePoints,Math.round(1e3*e[0].value[0]),((e,t)=>e.timeMse.timeMs{for(;i=this._sortedTimePoints.length){const t=this.indexOfTime(e);if(null===t)return l.INVALID_TIME_POINT_INDEX;i=t.timeMs!==e?t.index+1:t.index}return(0,s.assert)(i>t,"data must have unique sorted times"),t=i,i}))}firstSeriesBarTime(){return 0===this._sortedTimePoints.length?null:this._sortedTimePoints[0].timeMs} +replaceBarsTimesTail(e,t){if(0===t.length)return null;if(!this._instanceIds.has(e))return this.setSeriesBarsTimes(e,t);const i=[],s=(0,o.lowerbound)(this._sortedTimePoints,t[0],((e,t)=>e.timeMs({timeMs:e.timeMs,pointData:e.pointData,markWeight:0,displayTime:NaN})));for(let e=s;ee.timeMs-t.timeMs));const a=this._updateTimeScalePointsTail(n);return this._applyTimeScaleChanges(a,!1)}setSeriesBarsTimes(e,t){return this._setBarsTimes(e,t)}setStudyBarsTimes(e,t){return this._setBarsTimes(e,t)}_setBarsTimes(e,t){const i=0!==this._pointDataByTimePoint.size;if(this._instanceIds.has(e))for(const t of this._sortedTimePoints)t.pointData.instances.delete(e);0===t.length?this._instanceIds.delete(e):this._instanceIds.add(e),this._addBarsTimesToInstance(e,t,!1),i&&this._cleanupPointsData(this._sortedTimePoints);const s=[];this._pointDataByTimePoint.forEach(((e,t)=>{s.push({markWeight:0,timeMs:t,displayTime:NaN,pointData:e})})),s.sort(((e,t)=>e.timeMs-t.timeMs));const r=this._updateTimeScalePoints(s);return this._applyTimeScaleChanges(r,!1)}_updateFutureBars(){if(0===this._minFutureBarsCount||null===this._mainSymbolExtrapolator)return;if(0!==this._sortedTimePoints.length){const e=this._sortedTimePoints[this._sortedTimePoints.length-1].timeMs;this._mainSymbolExtrapolator.ensureExtrapolatedToFutureTime(e)}const e=this._futureBarsFirstPointIndex();this._mainSymbolExtrapolator.setMinFutureBarsCount(e+this._minFutureBarsCount)}_addBarsTimesToInstance(e,t,i){const s=i?[]:null;for(const i of t){const t=this._pointDataByTimePoint.get(i);if(void 0===t){const t=new Set;t.add(e);const r={index:0,instances:t};this._pointDataByTimePoint.set(i,r),null!==s&&s.push({timeMs:i,pointData:r})}else t.instances.add(e)}return s}_futureBarsFirstPointIndex(){if(null===this._mainSymbolExtrapolator||0===this._sortedTimePoints.length)return 0;const e=this._mainSymbolExtrapolator.futureBars();return(0,o.upperbound_int)(e,this._sortedTimePoints[this._sortedTimePoints.length-1].timeMs)}_futureBars(){return null===this._mainSymbolExtrapolator?[]:this._mainSymbolExtrapolator.futureBars().slice(this._futureBarsFirstPointIndex(),this._futureBarsFirstPointIndex()+1e3)}_cleanupPointsData(e){for(const t of e)0===t.pointData.instances.size&&this._pointDataByTimePoint.delete(t.timeMs)}_updateTimeScalePoints(e){let t=-1;for(let i=0;ie.timeMs=this._sortedTimePoints.length)continue;this._sortedTimePoints[n].timeMs!==r.timeMs&&-1===i&&(i=n)}const s=t+e.length;if(i=S(i,this._sortedTimePoints.length,s),-1===i)return null;this._fillPointsData(e,0,0===t||0===this._sortedTimePoints.length?null:this._sortedTimePoints[t-1].displayTime);const r=m(this._sortedTimePoints.slice(t),e).map((e=>({old:e.old+t,new:e.new===l.INVALID_TIME_POINT_INDEX?e.new:e.new+t})));{const i=this._sortedTimePoints;let r=0;for(;t+r1&&null===i){const t=Math.ceil(n/(e.length-1)),i=new Date(1e3*(e[0].displayTime-t));e[0].markWeight=_(new Date(1e3*e[0].displayTime),i)}}(e,t,i)}_applyTimeScaleChanges(e,t){if(null===e)return t?(this._fillPointsData(this._sortedTimePoints,0),{points:[],pointsIndex:0,baseIndex:this._getBaseIndex(),indexChange:[],marks:this.tickMarks(0)}):null;let i=e.pointsIndex;if(0!==i&&t&&(this._fillPointsData(this._sortedTimePoints,0),i=0),0===this._sortedTimePoints.length)return{baseIndex:null,pointsIndex:0,indexChange:[],marks:[],points:[]};const s=[];for(let t=e.pointsIndex;t{"use strict" +;var s=i(3035),r=i(74649),n=i(61476),o=i(76537).SymbolExtrapolator,a=i(21125).SessionTimeScale,l=i(34108).PointsetsManager,c=i(60156),h=i(77475).createDwmAligner,d=i(36274).Interval,u=i(76422),p=i(2663).visitObject,_=i(1722).isObject;i(24172),i(60325);var m=i(79850).DatafeedRequestsCachedProcessor,g=i(38618).timezoneIsAvailable,f=i(77475).isAlignmentEnabled,v=i(27856),S=v.isEncodedExtendedSymbol,y=v.decodeExtendedSymbol,b=i(42960).extractSymbolNameFromSymbolInfo,w=i(48739).replaceGraphicsTimesWithTimePointIndexIndex,P=i(14483),C=i(66846).SubsessionId,x=i(60156).getPeriodsBetweenDates;const T="pre_post_market_sessions",I=P.enabled(T);var M=-5e6;function L(e){var t=e.findIndex((function(e){return e.index!==M}));return-1===t?[]:0===t?e:e.slice(t)}function A(e,t,i){if(e){if("string"==typeof e)return void console.warn("`logo_urls` should be an array of urls, not a string.");const[t,s]=e;s?(i["base-currency-logoid"]=t,i["currency-logoid"]=s):i.logoid=e}t&&(i.provider_id=t)}function k(e,t){return e+"_"+t}function D(e){if(null===e||"number"==typeof e)return e;if("object"==typeof e&&Array.isArray(e)){switch(e[0]){case"bar_count":return e[2];case"from_to":return e.length>=3?e[2]:null}}return null}var E=function(e){var t=this;this._studiesCache={},this._objectsDataCache={},this._studiesNonSeriesTimes={},this._metainfoCache=[],this._barsCoefficientsCache={},this._externalDatafeed=e,e.getVolumeProfileResolutionForPeriod&&r.overwriteVolumeProfileResolutionForPeriodGetter((function(t,i,s,r){return e.getVolumeProfileResolutionForPeriod(t,i,s,r)})),this._datafeedConfiguration=null,this._marketStatusWatchers={},this._resolveRequests={},this._resolvePromisesBySymbolId=new Map,this._symbolIdToSymbolRequestString=new Map,this._callbacks={},this._serverTimeOffset=0,t._logMessage("Datafeed settings received: {0}".format(JSON.stringify(window.configurationData))),t._datafeedConfiguration=t._adoptConfigurationData(window.configurationData),t._fireEvent("configuration_received"),t._externalDatafeed.getServerTime&&t._externalDatafeed.getServerTime((function(e){t._serverTimeOffset=e-(new Date).valueOf()/1e3})),this._invalidatedPointsetSessions=new Set,this._refreshPointsetsTimerId=null,this._pointsetsManagers={},this._quotesInfo=[],this._depthInfo=[],this._endOfData={},this._computeStudyCounter=0,this._symbolExtrapolators={},this._timeScales={},this._cachedDatafeed=new m(e,this.serverTimeOffset.bind(this),this._datafeedConfiguration.reset_cache_timeout),n.setupFeed({resolve:function(e,i,s,r){t._resolveSymbolByName(e,i,s,r)},subscribe:function(e,i,s,r,n){return t._cachedDatafeed.subscribe(e,i,s,function(e,i,s){var r=new c.SessionInfo(e.timezone,e.session,e.session_holidays,e.corrections),n=c.newBarBuilder(i,r,r);return function(e){if(e&&e.count()){var i=1e3*t.getCurrentUTCTime();n.moveTo(i),n.indexOfBar(i)>=0&&e.setLastBarClosed(!1)}s(e)}}(e,i,r),n)},unsubscribe:function(e){return t._cachedDatafeed.unsubscribe(e)}})};function V(e,t){return e+"_"+t}function B(e,t,i,s){return e+(t?"_#_"+t:"")+(i?"_#_"+i:"")+(s?"_#_"+s:"")} +E.prototype._getSymbolExtrapolator=function(e,t,i){var s=d.normalize(i),r=function(e,t,i){const s=void 0!==t.subsession_id?","+t.subsession_id:"";return e+","+t.full_name+","+i+s}(e,t,s),n=this._symbolExtrapolators[r];return void 0===n&&(n=new o(t,s),this._symbolExtrapolators[r]=n),n},E.prototype._barsCoefficients=function(e,t){if(void 0===y(e).type)return{};var i=e+t;return this._barsCoefficientsCache[i]||(this._barsCoefficientsCache[i]={}),this._barsCoefficientsCache[i]},E.prototype.destroy=function(){this._cachedDatafeed.destroy(),this._externalDatafeed=null,Object.keys(this._pointsetsManagers).forEach((function(e){this._pointsetsManagers[e].destroy()}),this),this._pointsetsManagers={}},E.prototype.purgeCache=function(){this._endOfData={},this._resolveRequests={},this._objectsDataCache={},this._studiesNonSeriesTimes={},this._studiesCache={},this._resolvePromisesBySymbolId.clear(),this._symbolIdToSymbolRequestString.clear(),Object.keys(this._pointsetsManagers).forEach((function(e){this._pointsetsManagers[e].destroy()}),this),this._pointsetsManagers={},Object.keys(this._timeScales).forEach((function(e){this._timeScales[e].destroy()}),this),this._timeScales={},Object.keys(this._symbolExtrapolators).forEach((function(e){this._symbolExtrapolators[e].destroy()}),this),this._symbolExtrapolators={}},E.prototype.purgeDataCache=function(){this._cachedDatafeed.purgeCache()},E.prototype._logMessage=function(e){P.enabled("charting_library_debug_mode")&&console.log(e)},E.prototype.on=function(e,t){return this._callbacks.hasOwnProperty(e)||(this._callbacks[e]=[]),this._callbacks[e].push(t),this},E.prototype._fireEvent=function(e,t,i){if(this._callbacks.hasOwnProperty(e)){for(var s=this._callbacks[e],r=0;r{this._resolveSymbolImpl(e,(e=>{t(e.price_sources)}),(e=>{i(e)}))}))},E.prototype.supportedSymbolsTypes=function(){return this._datafeedConfiguration.symbols_types||[]},E.prototype.symbolsGrouping=function(){return this._datafeedConfiguration.symbols_grouping||{futures:/$a/}},E.prototype._findStudyObject=function(e){e.endsWith("!")&&(e=e.slice(0,-1));var t=e.split("@")[0],i=JSServer.studyLibrary.filter((function(i){return i.metainfo.id===e||i.metainfo.shortDescription===t}));return 0===i.length?null:i[0]},E.prototype.getMarks=function(e,t,i,s,r){var n={red:6,green:5,blue:4,yellow:3} +;if(this._externalDatafeed.getMarks&&this._datafeedConfiguration.supports_marks){this._logMessage("Requesting bars marks: symbol {0}, resolution {1}, range [{2} ... {3}]".format(e.full_name,r,new Date(1e3*t).toUTCString(),new Date(1e3*i).toUTCString()));var o=this;this._externalDatafeed.getMarks(e,t,i,(function(t){var i=t.map((function(e){return e.time=parseInt(e.time),e}));o._logMessage("Received bars marks: symbol {0}, resolution {1}, marks {2}".format(e.full_name,r,JSON.stringify(i)));var a=h(r,e),l=P.enabled("two_character_bar_marks_labels"),c=i.map((function(e){return e.tickmark=null!==a?a.timeToSessionStart(1e3*e.time)/1e3:e.time,e.direction=n[e.color],e.onClicked=function(){u.emit("onMarkClick",e.id)},e.label=!!e.label&&(l?e.label.slice(0,2):e.label[0]),e}));s(c)}),r)}},E.prototype.getTimescaleMarks=function(e,t,i,s,r){if(this._externalDatafeed.getTimescaleMarks&&this._datafeedConfiguration.supports_timescale_marks){this._logMessage("Requesting timescale marks: symbol {0}, resolution {1}, range [{2} ... {3}]".format(e.full_name,r,new Date(1e3*t).toUTCString(),new Date(1e3*i).toUTCString()));var n=this;this._externalDatafeed.getTimescaleMarks(e,t,i,(function(t){n._logMessage("Received timescale marks: symbol {0}, resolution {1}, marks {2}".format(e.full_name,r,JSON.stringify(t)));var i=h(r,e),o=t.map((function(e){return e.tickmark=null!==i?i.timeToSessionStart(1e3*e.time)/1e3:e.time,e}));s(o)}),r)}},E.prototype.getSeriesLastBarTime=function(e,t){var i=this._getSeriesData(e,t);return null===i||0===i.length?null:i[i.length-1].timeMs},E.prototype.getSeriesInterval=function(e,t){var i=this._studiesCache[e][t];return i?i.resolution:null},E.prototype.getSeriesSymbolInfo=function(e,t){var i=this._studiesCache[e][t];return i?i.symbolInfo:null},E.prototype._getSeriesData=function(e,t){return this._objectsDataCache[V(e,t)]||null},E.prototype._computeStudy=async function(e,t,i,s,n,o,a,l,c,u){var p=!0,_=[];null!==l&&(this._objectsDataCache[l]=null),this._timeScales[e].setCompleted(!1);var m=this._computeStudyCounter++;function g(e,t){if(e_[a].timeMs;l?_.push({index:g(s,_.length),value:[s/1e3].concat(r),timeMs:s}):(_[a].index=g(s,a),_[a].value=[s/1e3].concat(r),_[a].timeMs=s),p||u.onRealtimeCallback([_[_.length-1]],l,_.length,v,i)}(e,t,i)},nonseriesOut:function(e,t){u.onNonSeriesDataUpdate(t,i)},setNoMoreData:function(){S=!0},recalc:function(e,s){p=!1,_.endOfData=S,_.emptyBarCount=s.emptyBarCount,t.error&&null!==t.error()||(null!==l&&(y._objectsDataCache[l]=_),u.onDataReadyCallback(_,v,i,s))}});if(!y._studiesCache[e]||!y._studiesCache[e][n])throw Error("This should never happen");y._studiesCache[e][n].engine=w}catch(e){if(!e.studyError)throw e;u.onErrorCallback(e.message)}}else u.onErrorCallback("Unsupported resolution. Did you forget to set has_intraday to true?")}(w,C)},E.prototype._createStudy=function(e,t,i,s,r,n,o,a){var l=this;function c(e,t,i){if(l._studiesCache[s][r].completed=!0,e=L(e),l._setEndOfData(s,r,n,!0),l._studyCanExtendTimeScale(s,r)){const t=e.map((function(e){return e.timeMs})),i=l._timeScales[s].setStudyBarsTimes(r,t);l._applyTimeScaleUpdate(s,i)}l._timeScales[s].fillIndexesInRows(e),TradingView.ChartapiMessagerInstances[s].onDataUpdate(r,n,e,t),TradingView.ChartapiMessagerInstances[s].onStudyCompleted(r,n),l._updateTimeScaleState(s)}function h(e){var t={};if(0!==e.size){var i={},n=l._studiesCache[s][r].metainfo;e.forEach((function(e,t){i[n.plots[t].id]=e})),t.data={offsets:i}}return t}a=function(e){if(Array.isArray(e))return e;for(var t=[],i=l._studiesCache[s][r].metainfo.inputs,n=0;n=0},E.prototype.ensureExtendedTo=function(e,t,i){if(!this._studiesCache[t][e])throw Error("This should never happen");var s=this;setTimeout((function(){s._recreateSourcesForDataRange(t,{to:i})}),0)},E.prototype.extendSeriesRange=function(e,t){var i=this._timeScales[e].firstSeriesBarTime();if(null!==i){var s=this._mainSeriesRecord(e);if(d.isDWM(s.resolution)&&null!=s.symbolInfo){var r=h(s.resolution,s.symbolInfo);null!==r&&(i=r.timeToExchangeTradingDay(i))} +var n=this._symbolIdToSymbolRequestString.get(k(e,s.symbolId)),o=this._barsCoefficients(n,s.resolution),a=o.barsCoefficient||1;if(!o.barsCoefficient){var l=this._getSeriesData(e,s.guid);null!==l&&(o.expectedBarsCount=l.length+t)}var c=this;setTimeout((function(){c._recreateSourcesForDataRange(e,{to:i,countBack:(t+2)*a})}),0)}else this._logMessage("Nothing to extend - there is no points on time scale")},E.prototype.seriesTurnaround=function(e,t){return this._studiesCache[e]&&this._studiesCache[e][t]&&this._studiesCache[e][t].turnaround},E.prototype._seriesDataRange=function(e,t){var i=this._studiesCache[e][t];return null!==i.firstLoadedTimeMs?{to:i.firstLoadedTimeMs,countBack:0}:i.dataRange},E.prototype._applyTimeScaleUpdate=function(e,t){if(null!==t){var i=[];for(var s in this._studiesCache[e]){var r=this._studiesCache[e][s];if(r&&"study"===r.type){var n=this._studiesNonSeriesTimes[e][s];if(n){var o={indexes:this._timeScales[e].convertTimesToIndexes(n),data:{indexes_replace:!0}};i.push({objId:s,turnaround:r.turnaround,data:[],nonSeriesData:o})}}}TradingView.ChartapiMessagerInstances[e].onTimescaleUpdate(t,i),Promise.resolve().then(function(){var t=this._mainSeriesRecord(e);if(null!==t&&null!=t.symbolInfo){var i=this._getSymbolExtrapolator(e,t.symbolInfo,t.resolution);this._pointsetsManagers[e].getUpdatesForSymbol(t.symbolInfo.full_name,t.resolution,i,this._timeScales[e]).forEach((function(t,i){TradingView.ChartapiMessagerInstances[e].onPointsetDataUpdate(i,null,t)}))}}.bind(this))}},E.prototype._updateMainTsBuilder=function(e){var t=this._mainSeriesRecord(e);if(null!==t&&null!=t.symbolInfo){var i=this._getSymbolExtrapolator(e,t.symbolInfo,t.resolution);this._timeScales[e].setMainSymbolExtrapolator(i)}},E.prototype._updateTimeScaleState=function(e){var t=!0,i=!0;for(var s in this._studiesCache[e]){var r=this._studiesCache[e][s];i=i&&this._isEndOfData(e,s,r.turnaround),t=t&&r.completed}this._timeScales[e].isCompleted()!==t&&(this._timeScales[e].setCompleted(t),t&&TradingView.ChartapiMessagerInstances[e].onTimescaleCompleted(i))},E.prototype._mainSeriesRecord=function(e){var t=null,i=null;for(var s in this._studiesCache[e]){var r=this._studiesCache[e][s];if("series"===r.type&&(null===t&&(t=r),r.isMain)){i=r;break}}return null===i&&(i=t),null!==i&&(i.isMain=!0),i},E.prototype._seriesCount=function(e){var t=0;for(var i in this._studiesCache[e]){"series"===this._studiesCache[e][i].type&&(t+=1)}return t},E.prototype._prepareSeriesNonSeriesData=function(e,t,i){var s=i.data[i.data.length-1],r=this._getSeriesData(e,t),n=null===r?[]:i.data;return{data:{data:{reversalAmount:i.reversalAmount,boxSize:i.boxSize,price:s?s[4]:i.price,bars:n.map((function(e,t){return{time:t,open:e[1],high:e[2],low:e[3],close:e[4],volume:e[5],factor:e[6],additionalPrice:e[6]}}))}},indexes:this._timeScales[e].convertTimesToIndexes(n.map((function(e){var t=e[0]||0;return t<0?r[r.length+t].timeMs:i.projectionTime+t})))}},E.prototype.createSeries=function(e,t,i,s,n,o,a){this._setEndOfData(e,t,i,!1);var l=new r.OHLCV +;this._studiesCache[e]=this._studiesCache[e]||{};var c=this._getSeriesData(e,t),h=this._studiesCache[e][t],u=this._seriesCount(e),p=this._mainSeriesRecord(e);if(!h||d.isEqual(h.resolution,n)&&h.symbolId===s)void 0!==o.countBack&&null!==c&&0!==c.length&&(o.to=c[0].timeMs),h&&null!=h.firstLoadedTimeMs?o.to=void 0!==o.to?Math.min(h.firstLoadedTimeMs,o.to):h.firstLoadedTimeMs:h||0===u||null!==p&&(null!=p.firstLoadedTimeMs?(o.to=p.firstLoadedTimeMs,o.countBack=0):o=Object.assign({},p.dataRange));else if(1===u)o=Object.assign({},h.initialDatarange);else{var _=this._timeScales[e].firstSeriesBarTime();(void 0===o.to||null!==_&&_{A(e.logo_urls,e.exchange_logo,e)})),s(e)}))},E.prototype.resolveSymbol=function(e,t,i){var s=this;this._symbolIdToSymbolRequestString.set(k(e,t),i),this._resolvePromisesBySymbolId.set(k(e,t),new Promise((function(r,n){s._resolveSymbolImpl(i,(function(s){TradingView.ChartapiMessagerInstances[e].onSymbolResolved(t,s),r({symbolInfo:s,requestedSymbol:i})}),(function(i){TradingView.ChartapiMessagerInstances[e].onSymbolError(t,i),n(i)}))})))},E.prototype._resolveSymbolImpl=function(e,t,i){S(e)||console.error("Expect to get symbol encoded string, but got the following instead: "+e);var s=y(e),r="string"==typeof s.symbol?s:s.symbol,n=r.symbol,o=r["currency-id"],a=r["unit-id"],l=r.session===C.Regular?void 0:r.session;this._resolveSymbolByName(n,{currency:o,unit:a,session:l},t,i)},E.prototype._resolveSymbolByName=function(e,t,i,s){var r,n=t&&t.currency,o=t&&t.unit,a=t&&t.session,l=B(e,n,o,a);if(this._resolveRequests[l])r=this._resolveRequests[l];else{r=this._resolveSymbolInternal(e,n||void 0,o||void 0,a||void 0),this._resolveRequests[l]=r;var c=this;r.then((function(t){c._resolveRequests[B(e,t.currency_id,t.unit_id,t.subsession_id)]=r,c._resolveRequests[B(b(t,null),t.currency_id,t.unit_id,t.subsession_id)]=r,c._resolveRequests[B(b(t,null),n,o,a)]=r})).catch((function(){}))}r.then(i).catch(s)},E.prototype._resolveSymbolInternal=function(e,t,i,s){var r=this;return new Promise(function(n,o){this._logMessage("Symbol resolve requested: `{0}` ".format(e));var a=!0;this._externalDatafeed.resolveSymbol(e,(function(t){a&&console.warn("`resolveSymbol` should return result asynchronously. Use `setTimeout` with 0 interval to execute the callback function."),r._logMessage("Symbol resolved: `{0}`, SymbolInfo in server response {1}".format(e,JSON.stringify(t))),function(e){ +if(e.base_name||(e.base_name=[e.name]),e.legs||(e.legs=[e.name]),e.exchange||(e.exchange=e["exchange-listed"]),e.full_name||(e.full_name=e.ticker||(e.exchange?e.exchange+":"+e.name:e.name)),e.pro_name||(e.pro_name=e.full_name),e.data_status||(e.data_status="streaming"),e.ticker||(e.ticker=e.symbol||e.name),!e.session&&e["session-regular"]&&(e.session=e["session-regular"]),!e.minmov&&e.minmovement&&(e.minmov=e.minmovement),e.currency_code&&(e.currency_id=e.currency_code),e.original_currency_code&&(e.original_currency_id=e.original_currency_code),e.holidays&&(e.session_holidays=e.holidays),void 0!==e.has_no_volume&&(e.visible_plots_set=e.has_no_volume?"ohlc":"ohlcv"),e.supported_resolutions)for(var t=0;t{"use strict";i.d(t,{SymbolExtrapolator:()=>c});var s=i(50151),r=i(78071),n=i(60156),o=i(94421),a=i(36274);function l(e,t){return e.length>t}class c{constructor(e,t,i=2e5){this._firstRealBarTimeMs=null,this._historyBarsCache=[],this._projectionFirstIndex=1/0,this._barsTimes=[],this._minFutureBarsCount=0,this._lastRealBarTimeMs=null,this._futureBarsCache=[],this._symbolInfo=e,this._interval=a.Interval.parse(t),this._extrapolateLimit=i,this._barBuilder=(0,n.newBarBuilder)(t,new n.SessionInfo(e.timezone,e.session,e.session_holidays,e.corrections),null)}destroy(){this.clear()}interval(){return this._interval}barBuilder(){return this._barBuilder}symbolInfo(){return this._symbolInfo}clear(){this._firstRealBarTimeMs=null,this._historyBarsCache=[],this._barsTimes=[],this._lastRealBarTimeMs=null,this._futureBarsCache=[],this._minFutureBarsCount=0,this._projectionFirstIndex=1/0}firstFutureBarIndex(){return this._barsTimes.length}futureBars(){return this._futureBarsCache}replaceBarsTimesTail(e,t=e.length){if(0===e.length)return +;if(0===this._barsTimes.length)return void this.setBarsTimes(e,t);const i=e[0],n=this._barsTimes[this._barsTimes.length-1],o=i>n?this._barsTimes.length:(0,r.lowerbound_int)(this._barsTimes,i);0!==o?(this._barsTimes.splice(o,this._barsTimes.length,...e),this._projectionFirstIndex=t===e.length?this._barsTimes.length:this._barsTimes.indexOf(e[t]),(0,s.assert)(-1!==this._projectionFirstIndex,"something went wrong"),n!==e[e.length-1]&&this._setLastRealBarTime(e[e.length-1])):this.setBarsTimes(e,t)}setBarsTimes(e,t=e.length){const i=this._barsTimes;if(this._barsTimes=e.slice(),this._projectionFirstIndex=0===this._barsTimes.length?1/0:t,0===e.length)return this._historyBarsCache=[],this._futureBarsCache=[],this._firstRealBarTimeMs=null,void(this._lastRealBarTimeMs=null);0!==i.length&&i[i.length-1]===e[e.length-1]||this._setLastRealBarTime(e[e.length-1]),0!==i.length&&i[0]===e[0]||(this._historyBarsCache=[],this._firstRealBarTimeMs=e[0])}extrapolateTimeWithOffsetToTime(e,t){if(0===t)return{timeMs:e,exact:!0};0===this._barsTimes.length&&(t<0?null===this._firstRealBarTimeMs?this._firstRealBarTimeMs=e:(this._extendHistoryCacheToTimeFromRight(Math.min(e,null!==this._lastRealBarTimeMs?this._lastRealBarTimeMs:1/0)),this._ensureExtrapolatedToHistoryTime(e)):null===this._lastRealBarTimeMs?this._lastRealBarTimeMs=e:(this._extendFutureCacheToTimeFromLeft(Math.max(e,null!==this._firstRealBarTimeMs?this._firstRealBarTimeMs:1/0)),this._ensureExtrapolatedToFutureTime(e)));const i=this.indexOfTime(e);if(null===i)return null;const s=this._timeOfBarIndex(i.index+t);return null===s?null:((i.index<0||this._projectionFirstIndex<=i.index)&&(s.exact=!1),s)}indexOfTime(e){if(null!==this._firstRealBarTimeMs&&ethis._lastRealBarTimeMs){this._ensureExtrapolatedToFutureTime(e);let t=(0,r.lowerbound_int)(this._futureBarsCache,e);if(0!==this._futureBarsCache.length&&t===this._futureBarsCache.length&&e>this._futureBarsCache[this._futureBarsCache.length-1])return null;this._futureBarsCache[t]!==e&&(t-=1);const i=Math.max(1,this._barsTimes.length)+t;return{index:i,timeMs:i===this._barsTimes.length-1?(0,s.ensureNotNull)(this._lastRealBarTimeMs):this._futureBarsCache[t]}}if(0===this._barsTimes.length)return null!==this._firstRealBarTimeMs&&this._firstRealBarTimeMs<=e||null!==this._lastRealBarTimeMs&&e<=this._lastRealBarTimeMs?{index:0,timeMs:(0,s.ensureNotNull)(this._timeOfBarIndex(0)).timeMs}:null;let t=(0,r.lowerbound_int)(this._barsTimes,e);return this._barsTimes[t]!==e&&(t-=1),{index:t,timeMs:this._barsTimes[t]}}setMinFutureBarsCount(e){this._minFutureBarsCount=e,0!==this._barsTimes.length&&this._ensureExtrapolatedToFutureBar(e)}ensureExtrapolatedToFutureTime(e){ +this._ensureExtrapolatedToFutureTime(e)}_setLastRealBarTime(e){const t=this._futureBarsCache.length,i=(0,r.upperbound_int)(this._futureBarsCache,e);0===i?this._extendFutureCacheToTimeFromLeft(e):(this._lastRealBarTimeMs=e,this._futureBarsCache=this._futureBarsCache.slice(i)),this._ensureExtrapolatedToFutureBar(Math.max(t,this._minFutureBarsCount))}_timeOfBarIndex(e){var t;if(e<0){const t=Math.abs(e);this._ensureExtrapolatedToHistoryBar(t);const i=this._historyBarsCache.length-t;return i<0?null:{timeMs:this._historyBarsCache[i],exact:!1}}if(0===e&&0===this._barsTimes.length)return{timeMs:(0,s.ensureNotNull)(null!==(t=this._firstRealBarTimeMs)&&void 0!==t?t:this._lastRealBarTimeMs),exact:!1};if(e>=this._barsTimes.length){const t=e-Math.max(1,this._barsTimes.length);return this._ensureExtrapolatedToFutureBar(t+1),t>=this._futureBarsCache.length?null:{timeMs:this._futureBarsCache[t],exact:!1}}return{timeMs:this._barsTimes[e],exact:e=e)return;if((0,s.assert)(0===this._barsTimes.length,"bars should be empty"),this._firstRealBarTimeMs=e,0===this._historyBarsCache.length)return;const t=(0,o.extrapolateBarsFrontToTime)(this._barBuilder,this._historyBarsCache[this._historyBarsCache.length-1],e-1,this._extrapolateLimit,!0).times;this._historyBarsCache=this._historyBarsCache.concat(t)}_ensureExtrapolatedToFutureBar(e){return!(this._futureBarsCache.length>=e||l(this._futureBarsCache,this._extrapolateLimit))&&this._extendFutureCacheFromRight(((t,i)=>(0,o.extrapolateBarsFrontByCount)(this._barBuilder,t,e-i,!0).times))}_ensureExtrapolatedToFutureTime(e){null!==this._lastRealBarTimeMs&&this._lastRealBarTimeMs>=e||l(this._futureBarsCache,this._extrapolateLimit)||0!==this._futureBarsCache.length&&this._futureBarsCache[this._futureBarsCache.length-1]>=e||(this._extendFutureCacheFromRight(((t,i)=>(0,o.extrapolateBarsFrontToTime)(this._barBuilder,t,e,this._extrapolateLimit,!0).times)), +this._futureBarsCache[this._futureBarsCache.length-1]=e||l(this._historyBarsCache,this._extrapolateLimit)||this._extendHistoryCacheFromLeft(((t,i)=>(0,o.extrapolateBarsFrontByCount)(this._barBuilder,t,-(e-i),!0).times.reverse()))}_ensureExtrapolatedToHistoryTime(e){null!==this._firstRealBarTimeMs&&this._firstRealBarTimeMs<=e||l(this._historyBarsCache,this._extrapolateLimit)||0!==this._historyBarsCache.length&&this._historyBarsCache[0]<=e||(this._extendHistoryCacheFromLeft(((t,i)=>{const s=(0,o.extrapolateBarsFrontToTime)(this._barBuilder,t-1,e-1,this._extrapolateLimit,!0).times;return s[s.length-1]===t?s.slice(0,-1):s})),(0===this._historyBarsCache.length||this._historyBarsCache[0]>e)&&this._ensureExtrapolatedToHistoryBar(this._historyBarsCache.length+1))}}},61595:(e,t,i)=>{"use strict";i.d(t,{backend:()=>s});const s=i(58844)},47327:(e,t,i)=>{"use strict";i.d(t,{HandlerInfo:()=>s});class s{constructor(e,t){this.handler=e,this.customId=t}}},17133:(e,t,i)=>{"use strict";var s,r;function n(e,t){return"period-back"===e.type&&"period-back"===t.type?e.value===t.value:"time-range"===e.type&&"time-range"===t.type&&(e.from===t.from&&e.to===t.to)}i.d(t,{TIMEFRAMETYPE:()=>r,areEqualTimeFrames:()=>n}),function(e){e.extractErrorReason=function(e){return e.params[1]}}(s||(s={})),function(e){e.PeriodBack="period-back",e.TimeRange="time-range"}(r||(r={}))},89173:()=>{"use strict";TradingView.Pro=function(){this.hasPackage=function(){return!1}},window.user={is_pro:!1,settings:{}},TradingView.Pro.prototype.isPaidPro=function(){return!1},TradingView.Pro.prototype.isSupportAvailable=function(){return!1},TradingView.Pro.prototype.getProduct=function(){return{}},TradingView.Pro.prototype.getStudiesOrder=function(){return[]}},67545:(e,t,i)=>{"use strict";i.r(t),i.d(t,{QUOTE_FIELDS:()=>n,QUOTE_FIELDS_CACHE:()=>o,QuoteCache:()=>r});var s=i(50151);class r{constructor(e){this._cache=new Map,this._fields=[...e.fields]}update(e,t,i){const r=(0,s.ensureDefined)(e.symbolname);if(this._cache.has(r)||this._cache.set(r,{symbolname:r,status:e.status,values:{}}),"error"===e.status)return;const n=(0,s.ensureDefined)(this._cache.get(r));n.status=e.status;for(const s of this._fields)t.has(s)&&(i||void 0!==e.values[s])&&(n.values[s]=e.values[s])}get(e){var t;return null!==(t=this._cache.get(e))&&void 0!==t?t:null}fields(){return this._fields}} const n=new Set(["pro_name","base_name","logoid","currency-logoid","base-currency-logoid","source-logoid","short_name","timezone","current_session","last_price","lp_time","prev_close_price","open_price","high_price","low_price","price_52_week_high","price_52_week_low","ask","ask_size","bid","bid_size","rch","rchp","rtc","data_frequency","reference-last-period-start","business_description","web_site_url","number_of_employees","float_shares_outstanding","earnings_release_next_calendar_date","root","description","exchange","listed_exchange","type","country_code","provider_id","sector","typespecs","visible-plots-set","industry","currency_id","last_price","fractional","minmov","minmove2","pricescale","change","change_percent","volume","average_volume","market_cap_basic","total_revenue","earnings_per_share_basic_ttm","price_earnings_ttm","beta_1_year","dps_common_stock_prim_issue_fy","dividends_yield","earnings_release_next_date","earnings_per_share_forecast_next_fq","earnings_release_date","earnings_per_share_fq","fundamental_currency_code","number_of_employees","web_site_url","business_description","founded","ceo","float_shares_outstanding","total_shares_outstanding","dividend_payout_ratio_ttm","dividends_yield_current","dividend_ex_date_upcoming","dividend_amount_upcoming","dividend_amount_recent","dividend_ex_date_recent","total_revenue_fq_h","total_revenue_fy_h","net_income_fy_h","net_income_fq_h","total_assets_fy_h","total_assets_fq_h","total_liabilities_fy_h","total_liabilities_fq_h","cash_f_operating_activities_fy_h","cash_f_operating_activities_fq_h","cash_f_investing_activities_fy_h","cash_f_investing_activities_fq_h","cash_f_financing_activities_fy_h","cash_f_financing_activities_fq_h","fiscal_period_fy_h","fiscal_period_fq_h","earnings_release_date_fq_h","earnings_release_next_date_fq","earnings_per_share_forecast_next_fq","earnings_per_share_forecast_fq_h","earnings_per_share_fq_h","earnings_fiscal_period_fq_h","next_earnings_fiscal_period_fq","earnings_release_next_time","is_next_earnings_release_date_estimated","symbol-primaryname","currency_code","rates_mc","rates_fy","rates_ttm","value_unit_id","value-unit-id","update_mode","language","local_description","short_description","source","source2","format","recommendation_mark","last_report_frequency","price_target_estimates_num","price_target_average","update_mode_seconds","recommendation_total","recommendation_buy","recommendation_over","recommendation_hold","recommendation_under","recommendation_sell","recommendation_total","price_target_high","price_target_low","rates_pt","rates_pt","total_revenue_fy_h","total_revenue_fq_h","total_revenue_fh_h","net_income_fy_h","net_income_fq_h","net_income_fh_h","total_assets_fy_h","total_assets_fq_h","total_assets_fh_h","total_liabilities_fy_h","total_liabilities_fq_h","total_liabilities_fh_h","cash_f_operating_activities_fy_h","cash_f_operating_activities_fq_h","cash_f_operating_activities_fh_h","cash_f_investing_activities_fy_h","cash_f_investing_activities_fq_h","cash_f_investing_activities_fh_h","cash_f_financing_activities_fy_h","cash_f_financing_activities_fq_h","cash_f_financing_activities_fh_h","fiscal_period_fy_h","fiscal_period_fq_h","fiscal_period_fh_h","fiscal_period_fy","earnings_release_date_fq_h","earnings_release_date_fy_h","earnings_release_date_fh_h","earnings_release_next_date_fq","earnings_release_next_date_fy","earnings_release_next_date_fh","earnings_release_next_time","is_next_earnings_release_date_estimated","earnings_per_share_forecast_next_fq","earnings_per_share_forecast_next_fy","earnings_per_share_forecast_next_fh","earnings_per_share_forecast_fq_h","earnings_per_share_forecast_fy_h","earnings_per_share_forecast_fh_h","earnings_per_share_fq_h","earnings_per_share_fy_h","earnings_per_share_fh_h","earnings_fiscal_period_fq_h","earnings_fiscal_period_fy_h","earnings_fiscal_period_fh_h","next_earnings_fiscal_period_fq","next_earnings_fiscal_period_fy","next_earnings_fiscal_period_fh","revenue_fq_h","revenue_fy_h","revenue_fh_h","revenue_forecast_fq_h","revenue_forecast_fy_h","revenue_forecast_fh_h","revenue_forecast_next_fq","revenue_forecast_next_fy","revenue_forecast_next_fh","revenue_seg_by_business_h","revenue_seg_by_region_h","dividend_payout_ratio_ttm","dividends_yield_current","dividend_ex_date_upcoming","dividend_amount_upcoming","dividend_amount_recent","dividend_ex_date_recent","dividend_amount_h","total_revenue_fy","gross_profit_fy","ebitda_fy","ebit_fy","net_income_fy","total_debt_fy_h","free_cash_flow_fy_h","cash_n_equivalents_fy_h","total_current_assets_fy","total_current_liabilities_fy","total_non_current_assets_fy","total_non_current_liabilities_fy","price_sales_fy_h","price_earnings_fy_h","diluted_net_income_ttm","total_revenue_ttm","price_earnings_current","price_sales_current","isin","website","doc","reddit","twitter","facebook","telegram","forum","explorer","chat","sources","contracts","crypto_common_categories","crypto_asset","dividends_availability","earnings_availability","financials_availability"]),o=new r({ fields:n})},2438:(e,t,i)=>{"use strict";i.d(t,{destroyQuoteSessions:()=>a,getQuoteSessionInstance:()=>o});var s=i(49326),r=i.n(s);const n={};function o(e="full"){return n[e]||function(e="full",t){n[e]=t}(e,new(r())(e)),n[e]}function a(){for(const e in n)if(n.hasOwnProperty(e)){const t=n[e];void 0!==t&&t.destroy(),delete n[e]}}},47562:(e,t,i)=>{"use strict";i.d(t,{QuoteSession:()=>r});var s=i(36174);class r{constructor(e,t=(0,s.randomHash)()){this._sessionstarted=!1,this._globalHandler=null,this._chartApi=e,this._sessionid="qs_"+t}destroy(){this._sessionstarted&&(this._chartApi.quoteDeleteSession(this._sessionid),this._sessionstarted=!1)}connected(){return this._chartApi.connected()}connect(e){this._globalHandler=e,this._chartApi.createSession(this._sessionid,this),this._chartApi.connect()}disconnect(){this._chartApi.disconnect()}quoteAddSymbols(e){this._chartApi.quoteAddSymbols(this._sessionid,e)}quoteRemoveSymbols(e){this._chartApi.quoteRemoveSymbols(this._sessionid,e)}quoteFastSymbols(e){this._chartApi.quoteFastSymbols(this._sessionid,e)}quoteSetFields(e){this._chartApi.quoteSetFields(this._sessionid,e)}onMessage(e){var t;switch(e.method){case"connected":this._sessionstarted||(this._chartApi.quoteCreateSession(this._sessionid),this._sessionstarted=!0);break;case"disconnected":this._sessionstarted=!1}null===(t=this._globalHandler)||void 0===t||t.call(this,e)}quoteHibernateAll(){this._chartApi.quoteHibernateAll(this._sessionid)}}window.TradingView.QuoteSession=r},49326:(e,t,i)=>{"use strict";e=i.nmd(e);var s=i(43370).default,r=i(12481).default,n=i(61146).PriceFormatter;const{uniq:o}=i(15051);var a=i(36174);const{normalizeUpdateMode:l}=i(5370);var c=i(30888).deepExtend;const{QUOTE_FIELDS_CACHE:h,QUOTE_FIELDS:d}=i(67545);var u,p=i(57898).Delegate;function _(e,t){this.options=Object.assign({throttleTimeout:125},t),this._connected=!1,this._symbol_data={},this._subscriptions={},this.onConnect=new p,this.onDisconnect=new p,this._quoteApi=new u(window.ChartApiInstance),this._type=e||"full",this._delayUpdateFastSymbols=r(this._updateFastSymbols,250),this._throttledSymbolData={},this._formatterValuesCache={},this._waitingForFormatters={},this._snapshotValuesCache={},this._waitingForSnapshot={},this.connect()}u=i(47562).QuoteSession,_.prototype.destroy=function(){this._quoteApi.destroy(),this._quoteApi=null,this._connected=!1,this.onDisconnect.fire()},_.prototype.typeFields={},_.prototype.typeFields.simple=["base-currency-logoid","ch","chp","currency-logoid","currency_code","currency_id","base_currency_id","current_session","description","exchange","format","fractional","is_tradable","language","local_description","listed_exchange","logoid","lp","lp_time","minmov","minmove2","original_name","pricescale","pro_name","short_name","type","typespecs","update_mode","volume","value_unit_id"], _.prototype.typeFields.simpleDetailed=[].concat(_.prototype.typeFields.simple,["ask","bid","fundamentals","high_price","is_tradable","low_price","open_price","prev_close_price","rch","rchp","rtc","rtc_time","status","basic_eps_net_income","beta_1_year","earnings_per_share_basic_ttm","industry","market_cap_basic","price_earnings_ttm","sector","volume","dividends_yield","timezone"]),_.prototype.typeFields.full=[],_.prototype.typeFields.watchlist=[].concat(_.prototype.typeFields.simple,["rchp","rtc","country_code","provider_id"]),_.prototype.typeFields.portfolio=["pro_name","short_name","exchange","listed_exchange","description","sector","type","typespecs","industry","currency_code","currency_id","ch","chp","logoid","currency-logoid","base-currency-logoid","earnings_per_share_forecast_next_fq","earnings_release_next_date","earnings_release_date","earnings_per_share_fq","lp","fractional","minmov","minmove2","pricescale","volume","average_volume","market_cap_basic","total_revenue","earnings_per_share_basic_ttm","price_earnings_ttm","beta_1_year","dps_common_stock_prim_issue_fy","dividends_yield","fundamental_currency_code","rates_mc","rates_fy","rates_ttm","format"],_.prototype.typeFields.notes=["short_name","pro_name","logoid","currency-logoid","base-currency-logoid","symbol-primaryname","type","typespecs"],_.prototype.connect=function(e){this._quoteApi.connect(this.quoteHandler.bind(this))},_.prototype.quoteHandler=function(e){var t=e.method,i=e.params;switch(t){case"connected":this._connected||(this._connected=!0,this.onConnected());break;case"quote_list_fields":break;case"quote_symbol_data":this._connected&&this.onSymbolData(i[0]);break;case"quote_completed":this._connected&&this.onSymbolData({symbolname:i[0],complete:performance.now(),values:{}});break;case"disconnected":this._connected&&(this._connected=!1,this.onDisconnect.fire())}},_.prototype.onConnected=function(){this.setFields();var e=Object.keys(this._symbol_data);e.length&&(this._quoteApi.quoteAddSymbols(e),this._delayUpdateFastSymbols()),this.onConnect.fire()},_.prototype.setFields=function(){var e=_.prototype.typeFields[this._type];e&&e.length&&this._quoteApi.quoteSetFields(e)},_.prototype.onSymbolData=function(e){try{e.status&&h.update(e,d,!1)}catch(e){}var t=e.symbolname,i=this._throttledSymbolData[t];i||(i=this._throttledSymbolData[t]={fnDispatch:s(this.dipatchSymbolData.bind(this),this.options.throttleTimeout)}),i.cache?c(i.cache,e):i.cache=e,i.fnDispatch(t)},_.prototype._parseUpdateMode=function(e){l(e)},_.prototype.dipatchSymbolData=function(e){var t=this._symbol_data[e],i=this._throttledSymbolData[e].cache;if(delete this._throttledSymbolData[e].cache,this._symbol_data[e])for(var s in c(t,i),t.values&&this._parseUpdateMode(t.values),this._subscriptions){var r=this._subscriptions[s];r.has(e)&&[...r.get(e)].forEach((function(e){e(t,i)}))}},_.prototype.subscribe=function(e,t,i){this._subscriptions[e]=this._subscriptions[e]||new Map;var s=this._subscriptions[e];t=[].concat(t);var r=[];t.forEach((function(e){ @@ -211,289 +211,289 @@ s.assert)(!isNaN(n),"Bad version string: "+e),new r(i,n)}throw new Error("Bad ve ;for(;i!==e&&null!==i;){const e=getComputedStyle(i);if("none"===e.display||"visible"!==e.visibility)return!1;i=i.parentElement}return!0}}function n(e,t){return e===t?0:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function o(e){return Array.from(e.querySelectorAll('button:not([disabled], [aria-disabled], [tabindex="-1"]), [tabindex]:not([disabled], [aria-disabled], [tabindex="-1"])')).filter(r(e))}function a(e){return Array.from(e.querySelectorAll("button:not([disabled], [aria-disabled]), [tabindex]:not([disabled], [aria-disabled])")).filter(r(e))}function l(){window.dispatchEvent(new CustomEvent("keyboard-navigation-activation",{bubbles:!0}))}},9438:(e,t,i)=>{"use strict";i.d(t,{TOOLBAR_WIDTH_COLLAPSED:()=>r,TOOLBAR_WIDTH_EXPANDED:()=>s});const s=52,r=5},14873:(e,t,i)=>{"use strict";i.d(t,{isDrawingToolbarVisible:()=>l});var s=i(56840),r=i(14483),n=i(97145);const o=!r.enabled("hide_left_toolbar_by_default"),a=s.getBool("ChartDrawingToolbarWidget.visible",o),l=new n.WatchedValue(a)},69774:(e,t,i)=>{"use strict";i.d(t,{HEADER_TOOLBAR_HEIGHT_COLLAPSED:()=>n,HEADER_TOOLBAR_HEIGHT_EXPANDED:()=>r});var s=i(62995);const r=parseInt(s["css-value-header-toolbar-height"]),n=3},35423:(e,t,i)=>{"use strict";i.d(t,{FavoriteStudyTemplateService:()=>r});var s=i(68456);class r extends s.CommonJsonStoreService{constructor(e,t){super(e,t,"FAVORITE_STUDY_TEMPLATES_CHANGED","StudyTemplates.quicks",[])}remove(e){this.set(this.get().filter((t=>t!==e)))}}},95059:(e,t,i)=>{"use strict";var s;i.d(t,{ACTION_ID:()=>s}),function(e){e.TVActionId="TVActionId",e.ChartApplyIndicatorsToAllCharts="Chart.ApplyIndicatorsToAllCharts",e.ChartChangeTimeZone="Chart.ChangeTimeZone",e.ChartDialogsShowChangeInterval="Chart.Dialogs.ShowChangeInterval",e.ChartDialogsShowChangeSymbol="Chart.Dialogs.ShowChangeSymbol",e.ChartDialogsShowCompareOrAddSymbol="Chart.Dialogs.ShowCompareOrAddSymbol",e.ChartDialogsShowGeneralSettings="Chart.Dialogs.ShowGeneralSettings",e.ChartDialogsShowGeneralSettingsSymbolTab="Chart.Dialogs.ShowGeneralSettings.SymbolTab",e.ChartDialogsShowGoToDate="Chart.Dialogs.ShowGoToDate",e.ChartDialogsShowInsertIndicators="Chart.Dialogs.ShowInsertIndicators",e.ChartDialogsShowSymbolInfo="Chart.Dialogs.ShowSymbolInfo",e.ChartDrawingToolbarToggleVisibility="Chart.DrawingToolbar.ToggleVisibility",e.ChartLinesToggleBidAskLinesVisibility="Chart.Lines.ToggleBidAskLinesVisibility",e.ChartLinesToggleHighLowLinesVisibility="Chart.Lines.ToggleHighLowLinesVisibility",e.ChartLinesToggleAverageLineVisibility="Chart.Lines.ToggleAverageLineVisibility",e.ChartLinesToggleSeriesPrevCloseLineVisibility="Chart.Lines.ToggleSeriesPrevCloseLineVisibility",e.ChartLinesToggleSeriesPriceLineVisibility="Chart.Lines.ToggleSeriesPriceLineVisibility",e.ChartLineToolPitchforkChangeTypeToInside="Chart.LineTool.Pitchfork.ChangeTypeToInside",e.ChartLineToolPitchforkChangeTypeToModifiedSchiff="Chart.LineTool.Pitchfork.ChangeTypeToModifiedSchiff",e.ChartLineToolPitchforkChangeTypeToOriginal="Chart.LineTool.Pitchfork.ChangeTypeToOriginal", e.ChartLineToolPitchforkChangeTypeToSchiff="Chart.LineTool.Pitchfork.ChangeTypeToSchiff",e.ChartMarksToggleVisibility="Chart.Marks.ToggleVisibility",e.ChartMoveChartInLayout="Chart.MoveChartInLayout",e.ChartMoveChartInLayoutBack="Chart.MoveChartInLayout.Back",e.ChartMoveChartInLayoutForward="Chart.MoveChartInLayout.Forward",e.ChartObjectTreeShow="Chart.ObjectTree.Show",e.ChartDataWindowShow="Chart.DataWindow.Show",e.ChartPriceScaleLabelsToggleBidAskLabelsVisibility="Chart.PriceScale.Labels.ToggleBidAskLabelsVisibility",e.ChartPriceScaleLabelsToggleHighLowPriceLabelsVisibility="Chart.PriceScale.Labels.ToggleHighLowPriceLabelsVisibility",e.ChartPriceScaleLabelsToggleAveragePriceLabelVisibility="Chart.PriceScale.Labels.ToggleAveragePriceLabelVisibility",e.ChartPriceScaleLabelsToggleIndicatorsNameLabelsVisibility="Chart.PriceScale.Labels.ToggleIndicatorsNameLabelsVisibility",e.ChartPriceScaleLabelsToggleIndicatorsValueLabelsVisibility="Chart.PriceScale.Labels.ToggleIndicatorsValueLabelsVisibility",e.ChartPriceScaleLabelsToggleSeriesLastValueVisibility="Chart.PriceScale.Labels.ToggleSeriesLastValueVisibility",e.ChartPriceScaleLabelsToggleSymbolNameLabelsVisibility="Chart.PriceScale.Labels.ToggleSymbolNameLabelsVisibility",e.ChartPriceScaleLabelsToggleSymbolPrevCloseValueVisibility="Chart.PriceScale.Labels.ToggleSymbolPrevCloseValueVisibility",e.ChartPriceScaleMergeAllScalesToLeft="Chart.PriceScale.MergeAllScalesToLeft",e.ChartPriceScaleMergeAllScalesToRight="Chart.PriceScale.MergeAllScalesToRight",e.ChartPriceScaleMoveToLeft="Chart.PriceScale.MoveToLeft",e.ChartPriceScaleMoveToRight="Chart.PriceScale.MoveToRight",e.ChartPriceScaleToggleAddOrderPlusButtonVisibility="Chart.PriceScale.ToggleAddOrderPlusButtonVisibility",e.ChartPriceScaleToggleAutoScaleSeriesOnly="Chart.PriceScale.ToggleAutoScaleSeriesOnly",e.ChartPriceScaleToggleCountdownToBarCloseVisibility="Chart.PriceScale.ToggleCountdownToBarCloseVisibility",e.ChartRedo="Chart.Redo",e.ChartRemoveAllIndicators="Chart.RemoveAllIndicators",e.ChartRemoveAllIndicatorsAndLineTools="Chart.RemoveAllIndicatorsAndLineTools",e.ChartRemoveAllLineTools="Chart.RemoveAllLineTools",e.ChartScalesReset="Chart.Scales.Reset",e.ChartScalesToggleLockPriceToBarRatio="Chart.Scales.ToggleLockPriceToBarRatio",e.ChartSelectedObjectHide="Chart.SelectedObject.Hide",e.ChartSelectedObjectRemove="Chart.SelectedObject.Remove",e.ChartSelectedObjectShowSettingsDialog="Chart.SelectedObject.ShowSettingsDialog",e.ChartSelectedObjectToggleLocked="Chart.SelectedObject.ToggleLocked",e.ChartSeriesPriceScaleToggleAutoScale="Chart.Series.PriceScale.ToggleAutoScale",e.ChartSeriesPriceScaleToggleIndexedTo100="Chart.Series.PriceScale.ToggleIndexedTo100",e.ChartSeriesPriceScaleToggleInvertPriceScale="Chart.Series.PriceScale.ToggleInvertPriceScale",e.ChartSeriesPriceScaleToggleLogarithmic="Chart.Series.PriceScale.ToggleLogarithmic",e.ChartSeriesPriceScaleTogglePercentage="Chart.Series.PriceScale.TogglePercentage",e.ChartSeriesPriceScaleToggleRegular="Chart.Series.PriceScale.ToggleRegular", e.ChartSessionBreaksToggleVisibility="Chart.SessionBreaks.ToggleVisibility",e.ChartTimeScaleReset="Chart.TimeScale.Reset",e.ChartUndo="Chart.Undo",e.ChartSourceIntervalsVisibility="Chart.Source.IntervalsVisibility",e.ChartSourceIntervalsVisibilityCurrentAndAbove="Chart.Source.IntervalsVisibility.CurrentAndAbove",e.ChartSourceIntervalsVisibilityCurrentAndBelow="Chart.Source.IntervalsVisibility.CurrentAndBelow",e.ChartSourceIntervalsVisibilityOnlyCurrent="Chart.Source.IntervalsVisibility.Current",e.ChartSourceIntervalsVisibilityAll="Chart.Source.IntervalsVisibility.All"}(s||(s={}))},39347:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Action:()=>a,ActionAsync:()=>l,Loader:()=>h,Separator:()=>c});var s=i(50151),r=i(57898),n=i(68335),o=i(36174);class a{constructor(e,t=o.guid()){this.type="action",this._destroyed=!1,this._binding=null,(0,s.assert)(void 0!==e.actionId,"actionId must be defined"),this.id=t,this._onUpdate=new r.Delegate,this._options=e,this.update(e)}execute(){this._options.checkable&&this.update({checked:!this._options.checked}),this._options.onExecute&&this._options.onExecute(this)}getLabel(){return this._options.label||""}getSubItems(){return this._options.subItems||[]}isDisabled(){return!0===this._options.disabled}isActive(){return!0===this._options.active}isCheckable(){return!0===this._options.checkable}isChecked(){return!0===this._options.checked}isLoading(){return!0===this._options.loading}getSize(){var e;return null!==(e=this._options.size)&&void 0!==e?e:"normal"}getPayload(){return this._options.payload}update(e){this._destroyed||(this._unbindShortcut(),e.hotkeyHash&&(this._options.shortcutHint=(0,n.humanReadableHash)(e.hotkeyHash)),this._options=Object.assign(this._options,e),this._bindShortcut(),this._onUpdate.fire(this))}onUpdate(){return this._onUpdate}getState(){return{actionId:this._options.actionId,label:this.getLabel(),disabled:this.isDisabled(),active:this.isActive(),subItems:this.getSubItems(),checkable:this.isCheckable(),checked:this.isChecked(),loading:this.isLoading(),size:this.getSize(),doNotCloseOnClick:this._options.doNotCloseOnClick||!1,shortcutHint:this._options.shortcutHint,hint:this._options.hint,icon:this._options.icon,iconChecked:this._options.iconChecked,toolbox:this._options.toolbox,showToolboxOnHover:this._options.showToolboxOnHover||!1,statName:this._options.statName,name:this._options.name,invisibleHotkey:this._options.invisibleHotkey,noInteractive:this._options.noInteractive}}getBinding(){return this._binding}setBinding(e){this._binding=e}destroy(){var e,t;this._destroyed=!0,this._onUpdate.destroy(),null!==this._binding&&this._binding.destroy(),this._unbindShortcut(),null===(t=(e=this._options).onDestroy)||void 0===t||t.call(e)}options(){return this._options}_bindShortcut(){if(!this._options.hotkeyGroup||!this._options.hotkeyHash)return;const e="string"==typeof this._options.label?this._options.label:this._options.name;this._hotkeyAction=this._options.hotkeyGroup.add({hotkey:this._options.hotkeyHash,desc:e,handler:()=>this.execute(),isDisabled:()=>this.isDisabled()})} -_unbindShortcut(){this._hotkeyAction&&(this._hotkeyAction.destroy(),delete this._hotkeyAction)}}class l extends a{constructor(e,t,i){super({actionId:e},i),this._loader=t,this._loaded=!1}loadOptions(){return this._loadingPromise||(this._loadingPromise=this._loader().then((e=>{this._loaded=!0,this.update(e)}))),this._loadingPromise}getState(){return this.loadOptions(),super.getState()}isLoading(){return!this.isLoaded()}isLoaded(){return this._loaded}}class c{constructor(e){this.type="separator",this.id=o.guid(),this._hint=e}getHint(){return this._hint}}class h extends a{constructor(e){super({actionId:e})}isLoading(){return!0}getSize(){return"big"}}},73212:(e,t,i)=>{"use strict";i.d(t,{ActionsProvider:()=>Je,createActionCopyPrice:()=>Ye,createChangeIntervalsVisibilitiesAction:()=>$e,createLinesAction:()=>Ze,createMTPredictorActions:()=>Ke,createPasteAction:()=>Ge,createSyncDrawingActions:()=>Xe,createVisualOrderAction:()=>qe,defaultContextMenuOptions:()=>je});var s=i(50151),r=i(59224),n=(i(60521),i(1722)),o=i(44352),a=i(14483),l=i(39347),c=i(77212),h=i(10688),d=i(37591),u=i(28853),p=(i(14787),i(26426)),_=i(96362),m=i(68335),g=(i(25812),i(64063)),f=i(8561),v=i(5894),S=i(69618),y=i(92249),b=i(18611),w=i(53180),P=i(36298),C=(i(88348),i(36274)),x=i(4949),T=i(93352),I=i(33703),M=i(59452),L=i.n(M);(0,r.getLogger)("Chart.ActionsProvider"),new P.TranslatedString("show alert label lines",o.t(null,void 0,i(16237))),new P.TranslatedString("hide alert label lines",o.t(null,void 0,i(91842)));const A=new P.TranslatedString("change visibility",o.t(null,void 0,i(21511))),k=new P.TranslatedString("pin to scale {label}",o.t(null,void 0,i(56015))),D=new P.TranslatedString("pin to right scale",o.t(null,void 0,i(22615))),V=new P.TranslatedString("pin to left scale",o.t(null,void 0,i(84018))),E=(new P.TranslatedString("change earnings visibility",o.t(null,void 0,i(88217))),new P.TranslatedString("change dividends visibility",o.t(null,void 0,i(84944))),new P.TranslatedString("change splits visibility",o.t(null,void 0,i(74488))),new P.TranslatedString("change continuous contract switch visibility",o.t(null,void 0,i(7017))),new P.TranslatedString("change futures contract expiration visibility",o.t(null,void 0,i(28288))),new P.TranslatedString("change latest news and Minds visibility",o.t(null,void 0,i(19839))),new P.TranslatedString("show all ideas",o.t(null,void 0,i(13622)))),B=new P.TranslatedString("show ideas of followed users",o.t(null,void 0,i(26267))),R=new P.TranslatedString("show my ideas only",o.t(null,void 0,i(40061))),N=(new P.TranslatedString("change events visibility on chart",o.t(null,void 0,i(79574))),new P.TranslatedString("add this symbol to entire layout",o.t(null,void 0,i(27982)))),O=new P.TranslatedString("add this indicator to entire layout",o.t(null,void 0,i(82388))),F=(new P.TranslatedString("add this strategy to entire layout",o.t(null,void 0,i(94292))),new P.TranslatedString("add this financial metric to entire layout",o.t(null,void 0,i(22856))), -new P.TranslatedString("apply drawing template",o.t(null,void 0,i(49037))),new P.TranslatedString("lock objects",o.t(null,void 0,i(68163)))),W=new P.TranslatedString("unlock objects",o.t(null,void 0,i(66824))),H=new P.TranslatedString("change visibility at current interval and above",o.t(null,void 0,i(78422))),z=new P.TranslatedString("change visibility at current interval and below",o.t(null,void 0,i(49529))),U=new P.TranslatedString("change visibility at current interval",o.t(null,void 0,i(16698))),j=new P.TranslatedString("change visibility at all intervals",o.t(null,void 0,i(66927))),G=(o.t(null,void 0,i(8700)),o.t(null,void 0,i(64615)),o.t(null,void 0,i(7005)),(0,w.appendEllipsis)(o.t(null,void 0,i(93512)))),q=(o.t(null,void 0,i(27558)),o.t(null,void 0,i(13737)),o.t(null,void 0,i(87085)),(0,w.appendEllipsis)(o.t(null,void 0,i(52302))),o.t(null,void 0,i(81428))),$=o.t(null,void 0,i(31971)),Y=(o.t(null,void 0,i(11156)),o.t(null,void 0,i(15682)),o.t(null,void 0,i(66631)),o.t(null,void 0,i(37422)),o.t(null,void 0,i(5716)),o.t(null,void 0,i(50352)),o.t(null,void 0,i(19263)),o.t(null,void 0,i(15818)),o.t(null,void 0,i(5897)),o.t(null,void 0,i(58976)),o.t(null,void 0,i(11661)),o.t(null,void 0,i(66560)),o.t(null,void 0,i(53958)),o.t(null,void 0,i(34150)),o.t(null,void 0,i(83927)),o.t(null,void 0,i(15644)),o.t(null,void 0,i(42660)),o.t(null,void 0,i(44788)),o.t(null,void 0,i(70437)),o.t(null,void 0,i(71263)),o.t(null,void 0,i(70573)),o.t(null,void 0,i(59560)),o.t(null,void 0,i(14125))),K=o.t(null,void 0,i(44538)),Z=o.t(null,void 0,i(56948)),X=o.t(null,void 0,i(20207)),J=o.t(null,void 0,i(65810)),Q=o.t(null,void 0,i(3822)),ee=o.t(null,void 0,i(97324)),te=o.t(null,void 0,i(764)),ie=o.t(null,void 0,i(8128)),se=o.t(null,void 0,i(61201)),re=o.t(null,void 0,i(32156)),ne=o.t(null,void 0,i(91130)),oe=o.t(null,void 0,i(37680)),ae=o.t(null,void 0,i(43707)),le=o.t(null,void 0,i(39065)),ce=o.t(null,void 0,i(54727)),he=o.t(null,void 0,i(66156)),de=o.t(null,void 0,i(76598)),ue=o.t(null,void 0,i(3485)),pe=o.t(null,void 0,i(45828)),_e=o.t(null,void 0,i(2899)),me=o.t(null,void 0,i(40887)),ge=o.t(null,void 0,i(53387)),fe=o.t(null,void 0,i(96712)),ve=o.t(null,void 0,i(26354)),Se=o.t(null,void 0,i(19796)),ye=o.t(null,void 0,i(59901)),be=o.t(null,void 0,i(23221)),we=o.t(null,void 0,i(22198)),Pe=o.t(null,void 0,i(27557)),Ce=o.t(null,void 0,i(98486)),xe=o.t(null,void 0,i(73106)),Te=o.t(null,void 0,i(85964)),Ie=o.t(null,void 0,i(59192)),Me=o.t(null,void 0,i(83182)),Le=((0,w.appendEllipsis)(o.t(null,void 0,i(92206))),(0,w.appendEllipsis)(o.t(null,void 0,i(3612))),(0,w.appendEllipsis)(o.t(null,void 0,i(89517)))),Ae=(o.t(null,void 0,i(13345)),(0,w.appendEllipsis)(o.t(null,void 0,i(9908))),o.t(null,void 0,i(35216))),ke=o.t(null,void 0,i(52977)),De=(o.t(null,void 0,i(19611)),o.t(null,void 0,i(38342))),Ve=o.t(null,void 0,i(15101)),Ee=o.t(null,void 0,i(42284)),Be=(o.t(null,void 0,i(46771)),o.t(null,void 0,i(66263)),o.t(null,void 0,i(30816)),o.t(null,void 0,i(24620)),o.t(null,void 0,i(84813)),o.t(null,void 0,i(72973)), +_unbindShortcut(){this._hotkeyAction&&(this._hotkeyAction.destroy(),delete this._hotkeyAction)}}class l extends a{constructor(e,t,i){super({actionId:e},i),this._loader=t,this._loaded=!1}loadOptions(){return this._loadingPromise||(this._loadingPromise=this._loader().then((e=>{this._loaded=!0,this.update(e)}))),this._loadingPromise}getState(){return this.loadOptions(),super.getState()}isLoading(){return!this.isLoaded()}isLoaded(){return this._loaded}}class c{constructor(e){this.type="separator",this.id=o.guid(),this._hint=e}getHint(){return this._hint}}class h extends a{constructor(e){super({actionId:e})}isLoading(){return!0}getSize(){return"big"}}},73212:(e,t,i)=>{"use strict";i.d(t,{ActionsProvider:()=>Je,createActionCopyPrice:()=>Ye,createChangeIntervalsVisibilitiesAction:()=>$e,createLinesAction:()=>Ze,createMTPredictorActions:()=>Ke,createPasteAction:()=>Ge,createSyncDrawingActions:()=>Xe,createVisualOrderAction:()=>qe,defaultContextMenuOptions:()=>je});var s=i(50151),r=i(59224),n=(i(60521),i(1722)),o=i(44352),a=i(14483),l=i(39347),c=i(77212),h=i(10688),d=i(37591),u=i(28853),p=(i(14787),i(26426)),_=i(96362),m=i(68335),g=(i(25812),i(64063)),f=i(8561),v=i(5894),S=i(69618),y=i(92249),b=i(18611),w=i(53180),P=i(36298),C=(i(88348),i(36274)),x=i(4949),T=i(93352),I=i(33703),M=i(59452),L=i.n(M);(0,r.getLogger)("Chart.ActionsProvider"),new P.TranslatedString("show alert label lines",o.t(null,void 0,i(16237))),new P.TranslatedString("hide alert label lines",o.t(null,void 0,i(91842)));const A=new P.TranslatedString("change visibility",o.t(null,void 0,i(21511))),k=new P.TranslatedString("pin to scale {label}",o.t(null,void 0,i(56015))),D=new P.TranslatedString("pin to right scale",o.t(null,void 0,i(22615))),E=new P.TranslatedString("pin to left scale",o.t(null,void 0,i(84018))),V=(new P.TranslatedString("change earnings visibility",o.t(null,void 0,i(88217))),new P.TranslatedString("change dividends visibility",o.t(null,void 0,i(84944))),new P.TranslatedString("change splits visibility",o.t(null,void 0,i(74488))),new P.TranslatedString("change continuous contract switch visibility",o.t(null,void 0,i(7017))),new P.TranslatedString("change futures contract expiration visibility",o.t(null,void 0,i(28288))),new P.TranslatedString("change latest news and Minds visibility",o.t(null,void 0,i(19839))),new P.TranslatedString("show all ideas",o.t(null,void 0,i(13622)))),B=new P.TranslatedString("show ideas of followed users",o.t(null,void 0,i(26267))),R=new P.TranslatedString("show my ideas only",o.t(null,void 0,i(40061))),N=(new P.TranslatedString("change events visibility on chart",o.t(null,void 0,i(79574))),new P.TranslatedString("add this symbol to entire layout",o.t(null,void 0,i(27982)))),O=new P.TranslatedString("add this indicator to entire layout",o.t(null,void 0,i(82388))),F=(new P.TranslatedString("add this strategy to entire layout",o.t(null,void 0,i(94292))),new P.TranslatedString("add this financial metric to entire layout",o.t(null,void 0,i(22856))), +new P.TranslatedString("apply drawing template",o.t(null,void 0,i(49037))),new P.TranslatedString("lock objects",o.t(null,void 0,i(68163)))),W=new P.TranslatedString("unlock objects",o.t(null,void 0,i(66824))),H=new P.TranslatedString("change visibility at current interval and above",o.t(null,void 0,i(78422))),z=new P.TranslatedString("change visibility at current interval and below",o.t(null,void 0,i(49529))),U=new P.TranslatedString("change visibility at current interval",o.t(null,void 0,i(16698))),j=new P.TranslatedString("change visibility at all intervals",o.t(null,void 0,i(66927))),G=(o.t(null,void 0,i(8700)),o.t(null,void 0,i(64615)),o.t(null,void 0,i(7005)),(0,w.appendEllipsis)(o.t(null,void 0,i(93512)))),q=(o.t(null,void 0,i(27558)),o.t(null,void 0,i(13737)),o.t(null,void 0,i(87085)),(0,w.appendEllipsis)(o.t(null,void 0,i(52302))),o.t(null,void 0,i(81428))),$=o.t(null,void 0,i(31971)),Y=(o.t(null,void 0,i(11156)),o.t(null,void 0,i(15682)),o.t(null,void 0,i(66631)),o.t(null,void 0,i(37422)),o.t(null,void 0,i(5716)),o.t(null,void 0,i(50352)),o.t(null,void 0,i(19263)),o.t(null,void 0,i(15818)),o.t(null,void 0,i(5897)),o.t(null,void 0,i(58976)),o.t(null,void 0,i(11661)),o.t(null,void 0,i(66560)),o.t(null,void 0,i(53958)),o.t(null,void 0,i(34150)),o.t(null,void 0,i(83927)),o.t(null,void 0,i(15644)),o.t(null,void 0,i(42660)),o.t(null,void 0,i(44788)),o.t(null,void 0,i(70437)),o.t(null,void 0,i(71263)),o.t(null,void 0,i(70573)),o.t(null,void 0,i(59560)),o.t(null,void 0,i(14125))),K=o.t(null,void 0,i(44538)),Z=o.t(null,void 0,i(56948)),X=o.t(null,void 0,i(20207)),J=o.t(null,void 0,i(65810)),Q=o.t(null,void 0,i(3822)),ee=o.t(null,void 0,i(97324)),te=o.t(null,void 0,i(764)),ie=o.t(null,void 0,i(8128)),se=o.t(null,void 0,i(61201)),re=o.t(null,void 0,i(32156)),ne=o.t(null,void 0,i(91130)),oe=o.t(null,void 0,i(37680)),ae=o.t(null,void 0,i(43707)),le=o.t(null,void 0,i(39065)),ce=o.t(null,void 0,i(54727)),he=o.t(null,void 0,i(66156)),de=o.t(null,void 0,i(76598)),ue=o.t(null,void 0,i(3485)),pe=o.t(null,void 0,i(45828)),_e=o.t(null,void 0,i(2899)),me=o.t(null,void 0,i(40887)),ge=o.t(null,void 0,i(53387)),fe=o.t(null,void 0,i(96712)),ve=o.t(null,void 0,i(26354)),Se=o.t(null,void 0,i(19796)),ye=o.t(null,void 0,i(59901)),be=o.t(null,void 0,i(23221)),we=o.t(null,void 0,i(22198)),Pe=o.t(null,void 0,i(27557)),Ce=o.t(null,void 0,i(98486)),xe=o.t(null,void 0,i(73106)),Te=o.t(null,void 0,i(85964)),Ie=o.t(null,void 0,i(59192)),Me=o.t(null,void 0,i(83182)),Le=((0,w.appendEllipsis)(o.t(null,void 0,i(92206))),(0,w.appendEllipsis)(o.t(null,void 0,i(3612))),(0,w.appendEllipsis)(o.t(null,void 0,i(89517)))),Ae=(o.t(null,void 0,i(13345)),(0,w.appendEllipsis)(o.t(null,void 0,i(9908))),o.t(null,void 0,i(35216))),ke=o.t(null,void 0,i(52977)),De=(o.t(null,void 0,i(19611)),o.t(null,void 0,i(38342))),Ee=o.t(null,void 0,i(15101)),Ve=o.t(null,void 0,i(42284)),Be=(o.t(null,void 0,i(46771)),o.t(null,void 0,i(66263)),o.t(null,void 0,i(30816)),o.t(null,void 0,i(24620)),o.t(null,void 0,i(84813)),o.t(null,void 0,i(72973)), o.t(null,void 0,i(48284))),Re=o.t(null,void 0,i(87933)),Ne=o.t(null,void 0,i(58669)),Oe=((0,w.appendEllipsis)(o.t(null,void 0,i(89517))),o.t(null,void 0,i(8251)),o.t(null,void 0,i(34059))),Fe=o.t(null,void 0,i(64288)),We=(o.t(null,void 0,i(77920)),o.t(null,void 0,i(75669)),o.t(null,void 0,i(8886)),o.t(null,void 0,i(18008)),o.t(null,void 0,i(33606)),(0,w.appendEllipsis)(o.t(null,void 0,i(65986)))),He=(0,w.appendEllipsis)(o.t(null,void 0,i(18001))),ze=o.t(null,void 0,i(29682)),Ue=o.t(null,void 0,i(28851)),je={general:!0,mainSeries:!0,mainSeriesTrade:!1,esdStudies:!0,studies:!0,fundamentals:!0,lineTools:!0,publishedCharts:!0,ordersAndPositions:!0,alerts:!0,chartEvents:!0,objectTree:!0,gotoLineTool:!1};function Ge(e,t){return!t.isEmpty()&&a.enabled("datasource_copypaste")?new l.Action({actionId:"Chart.Clipboard.PasteSource",label:ze.trim(),shortcutHint:(0,m.humanReadableHash)(m.Modifiers.Mod+86),statName:"Paste",onExecute:()=>e.chartWidgetCollection().clipboard.uiRequestPaste(t)}):null}function qe(e,t){const s=e.model(),r=s.availableZOrderOperations(t),n=[new l.Action({actionId:"Chart.Source.VisualOrder.BringToFront",label:ve,statName:"BringToFront",disabled:!r.bringToFrontEnabled,onExecute:()=>s.bringToFront(t)}),new l.Action({actionId:"Chart.Source.VisualOrder.SendToBack",label:Se,statName:"SendToBack",disabled:!r.sendToBackEnabled,onExecute:()=>s.sendToBack(t)}),new l.Action({actionId:"Chart.Source.VisualOrder.BringForward",label:ye,statName:"BringForward",disabled:!r.bringForwardEnabled,onExecute:()=>s.bringForward(t)}),new l.Action({actionId:"Chart.Source.VisualOrder.SendBackward",label:be,statName:"SendBackward",disabled:!r.sendBackwardEnabled,onExecute:()=>s.sendBackward(t)})];return new l.Action({actionId:"Chart.Source.VisualOrder",label:we,icon:i(77067),statName:"VisualOrder",subItems:n})}function $e(e,t){const i=e.model(),s=(e,s)=>{const r=C.Interval.parse(i.mainSeries().interval()),n=(0,x.getIntervalsVisibilitiesForMode)(r,e),o=[],a=[];t.forEach((e=>{const t=e.properties().intervalsVisibilities.childs();o.push(t.ticks),a.push(n.ticks),o.push(t.seconds),a.push(n.seconds),o.push(t.secondsFrom),a.push(n.secondsFrom),o.push(t.secondsTo),a.push(n.secondsTo),o.push(t.minutes),a.push(n.minutes),o.push(t.minutesFrom),a.push(n.minutesFrom),o.push(t.minutesTo),a.push(n.minutesTo),o.push(t.hours),a.push(n.hours),o.push(t.hoursFrom),a.push(n.hoursFrom),o.push(t.hoursTo),a.push(n.hoursTo),o.push(t.days),a.push(n.days),o.push(t.daysFrom),a.push(n.daysFrom),o.push(t.daysTo),a.push(n.daysTo),o.push(t.weeks),a.push(n.weeks),o.push(t.weeksFrom),a.push(n.weeksFrom),o.push(t.weeksTo),a.push(n.weeksTo),o.push(t.months),a.push(n.months),o.push(t.monthsFrom),a.push(n.monthsFrom),o.push(t.monthsTo),a.push(n.monthsTo),o.push(t.ranges),a.push(n.ranges)})),i.setProperties(o,a,s)},r=[new l.Action({actionId:"Chart.Source.IntervalsVisibility.CurrentAndAbove",label:Ce,statName:"currentAndAboveIntervals",onExecute:()=>s(3,H)}),new l.Action({actionId:"Chart.Source.IntervalsVisibility.CurrentAndBelow",label:xe, statName:"currentAndBelowIntervals",onExecute:()=>s(2,z)}),new l.Action({actionId:"Chart.Source.IntervalsVisibility.Current",label:Te,statName:"currentInterval",onExecute:()=>s(1,U)}),new l.Action({actionId:"Chart.Source.IntervalsVisibility.All",label:Ie,statName:"allIntervals",onExecute:()=>s(0,j)})];return new l.Action({actionId:"Chart.Source.IntervalsVisibility",label:Pe,statName:"IntervalsVisibility",subItems:r})}function Ye(e,t){var i,s,r;const n=e.defaultPriceScale(),o=void 0!==t?n.coordinateToPrice(t,null!==(s=null===(i=e.mainDataSource())||void 0===i?void 0:i.firstValue())&&void 0!==s?s:0):e.model().mainSeries().lastValueData(4,!0,!0).price,a=null===(r=e.mainDataSource())||void 0===r?void 0:r.formatter();if(void 0===o||!a)return null;const c=a.format(o);return new l.Action({actionId:"Chart.Clipboard.CopyPrice",label:`${Ue} ${c}`,statName:"CopyPrice",onExecute:()=>(0,T.getClipboard)().writeText(c)})}function Ke(e,t,i,s){return null}function Ze(e){const t=e.actions(),i=[t.showPriceLine];return i.push(t.showHighLowPriceLines),a.enabled("show_average_close_price_line_and_label")&&i.push(t.showAverageClosePriceLine),new l.Action({actionId:"Chart.Lines",label:Me,statName:"Lines",subItems:i})}function Xe(e,t){return[]}class Je{constructor(e,t){this._chartWidget=e,this._options=(0,n.merge)((0,n.clone)(je),t||{})}async contextMenuActionsForSources(e,t,i){const s=e[0],r=this._options;if(s===this._chartWidget.model().mainSeries()&&r.mainSeries)return this._contextMenuActionsForSeries(s,t);if((0,u.isStudy)(s)&&r.studies)return this._contextMenuActionsForStudy(s,t);if((0,y.isLineTool)(s)&&r.lineTools){const t=e.filter(y.isLineTool);return this._contextMenuActionsForLineTool(t)}return[]}_isReadOnly(){return this._chartWidget.readOnly()}_createActionHide(e){return new l.Action({actionId:"Chart.SelectedObject.Hide",label:$,icon:i(84959),statName:"HideSelectedObject",onExecute:this._chartWidget.hideDataSources.bind(this._chartWidget,[e])})}_createActionShow(e){const t=new l.Action({actionId:"Chart.SelectedObject.Show",checkable:!0,label:q,icon:i(16911),statName:"ToggleShow"}),s=new c.ActionBinder(t,e.properties().visible,this._chartWidget.model(),A);return t.setBinding(s),s.setValue(e.properties().visible.value()),t}_createActionScale(e){const t=(0,s.ensureNotNull)(e.priceScale()),r=this._chartWidget.model().model(),n=(0,s.ensureNotNull)(r.paneForSource(e)),o=n.priceScalePosition(t),a=("left"===o?n.leftPriceScales():n.rightPriceScales()).indexOf(t),c=r.priceScaleSlotsCount().totallySlots<2?"dontneedname":"needname",d="overlay"===o?"":(0,h.getPriceAxisNameInfo)(o,a).label,u=le.format({label:d}),p={"left-needname":u,"left-dontneedname":he,"right-needname":u,"right-dontneedname":de,"overlay-needname":ce,"overlay-dontneedname":ce}[o+"-"+c];return new l.Action({actionId:"Chart.Source.ChangePriceScale",label:p,icon:i(25191),subItems:this._createActionScaleItems(e)})}_createActionResetInputPoints(e){const t=e.metaInfo(),s=t.inputs.filter(I.isTimeOrPriceNotHiddenInput);return 0===s.length?null:new l.Action({ actionId:"Chart.Source.ResetInputPoints",label:He,onExecute:async()=>{let r;try{const n=e.properties().childs().inputs.state();for(const e of Object.keys(n))s.find((t=>t.id===e))||delete n[e];const o=new(L())({inputs:n}),a=await Promise.all([i.e(77),i.e(2666),i.e(1013),i.e(3842),i.e(4015),i.e(5145),i.e(855),i.e(6),i.e(5993),i.e(2191),i.e(6221),i.e(8056),i.e(2587),i.e(3502),i.e(2639),i.e(2109),i.e(9842),i.e(4215),i.e(7232),i.e(6625),i.e(9327),i.e(7194),i.e(6884),i.e(2984),i.e(1762),i.e(962),i.e(8385),i.e(3016),i.e(3179),i.e(9727),i.e(4403),i.e(4713),i.e(5901),i.e(3030)]).then(i.bind(i,73339));r=(await a.selectInputValuesOnChart(this._chartWidget,s,o,t.shortDescription,t.inputs)).customSourceId,e.properties().mergeAndFire(o.state())}finally{void 0!==r&&this._chartWidget.model().model().removeCustomSource(r)}}})}_createActionLayoutChartsSync(){return new LayoutChartsSyncContextMenuAction(this._chartWidget.linkingGroupIndex().readonly(),(e=>this._chartWidget.model().setLinkingGroupIndex(e)))}_createActionScaleDetach(e,t,i,r){const n=this._chartWidget.model().model(),o=(0,s.ensureNotNull)(n.paneForSource(e));if(!o.canCreateNewPriceScale())return null;const a=(0,s.ensureNotNull)(e.priceScale()),c=a.canDetachSource(e),d=o.priceScalePosition(a),u=c||d!==t;if(!u)return null;const p=n.priceScaleSlotsCount(),_={left:{labelled:ee,sided:oe},right:{labelled:ee,sided:ae}},m="left"===t?o.leftPriceScales().length:o.rightPriceScales().length,g=p[t]>m?"labelled":"sided",f=(0,h.getPriceAxisNameInfo)(t,m).label,v=_[t][g].format({label:f});return new l.Action({actionId:"Chart.Source.ChangePriceScale",checkable:!1,disabled:!u,label:v,statName:r,payload:e,onExecute:i})}_onDetachLeft(e){const t=e.getPayload(),i=this._chartWidget.model().model(),r=(0,s.ensureNotNull)(i.paneForSource(t));this._chartWidget.model().detachToLeft(t,r)}_onDetachRight(e){const t=e.getPayload(),i=this._chartWidget.model().model(),r=(0,s.ensureNotNull)(i.paneForSource(t));this._chartWidget.model().detachToRight(t,r)}_createActionScaleDetachLeft(e){return this._createActionScaleDetach(e,"left",this._onDetachLeft.bind(this),"ToggleScaleLeft")}_createActionScaleDetachRight(e){return this._createActionScaleDetach(e,"right",this._onDetachRight.bind(this),"ToggleScaleRight")}_onMoveToScale(e){const t=e.getPayload();if(t.datasource.priceScale()===t.priceScale)return;const i=this._chartWidget.model().model(),r=(0,s.ensureNotNull)(i.paneForSource(t.datasource));this._chartWidget.model().moveToScale(t.datasource,r,t.priceScale,t.undoText)}_createMoveToScaleAction(e,t,i,s){const r=e.priceScale()===t;return new l.Action({actionId:"Chart.Source.MoveToOtherScale",checkable:!0,checked:r,label:i,statName:"ToggleScale",payload:{datasource:e,priceScale:t,undoText:s},onExecute:this._onMoveToScale.bind(this)})}_onNoScale(e){const t=e.getPayload().datasource,i=this._chartWidget.model().model(),r=(0,s.ensureNotNull)(i.paneForSource(t));r.isOverlay(t)||this._chartWidget.model().detachNoScale(t,r)}_createActionNoScale(e){const t=this._chartWidget.model().model(),i=(0, -s.ensureNotNull)(t.paneForSource(e)),r=i.actionNoScaleIsEnabled(e);return new l.Action({actionId:"Chart.Source.MoveToNoScale",checkable:!0,checked:i.isOverlay(e),label:ue,disabled:!r,statName:"ToggleNoScale",payload:{datasource:e},onExecute:this._onNoScale.bind(this)})}_createActionScaleItems(e){const t=[],i=this._chartWidget.model().model(),r=(0,s.ensureNotNull)(i.paneForSource(e)),n=i.priceScaleSlotsCount().totallySlots>1,o=r.rightPriceScales(),a=r.leftPriceScales(),c=this._createActionScaleDetachRight(e),d=this._createActionScaleDetachLeft(e),u=o.length+a.length+(null===c?0:1)+(null===d?0:1)>2,p={right:{hidden:{checked:{labelled:Y,sided:K},unchecked:{labelled:Z,sided:X}},visible:{checked:{labelled:J,sided:Q},unchecked:{labelled:ee,sided:te}}},left:{hidden:{checked:{labelled:Y,sided:ie},unchecked:{labelled:Z,sided:se}},visible:{checked:{labelled:J,sided:re},unchecked:{labelled:ee,sided:ne}}}},_={right:D,left:V},m={left:r.visibleLeftPriceScales(),right:r.visibleRightPriceScales()},g=(t,i)=>{const s=("right"===i?o:a)[t],r=m[i].includes(s)?"visible":"hidden",l=e.priceScale()===s?"checked":"unchecked",c=n?"labelled":"sided",d=p[i],u=(0,h.getPriceAxisNameInfo)(i,t).label;return{actionText:d[r][l][c].format({label:u}),undoText:n?k.format({label:u}):_[i]}};t.push(...o.map(((t,i)=>{const s=g(i,"right");return this._createMoveToScaleAction(e,t,s.actionText,s.undoText)}))),null!==c&&t.push(c);u&&(o.length>0||null!==c)&&t.push(new l.Separator);t.push(...a.map(((t,i)=>{const s=g(i,"left");return this._createMoveToScaleAction(e,t,s.actionText,s.undoText)}))),null!==d&&t.push(d);u&&(a.length>0||null!==d)&&t.push(new l.Separator);return t.push(this._createActionNoScale(e)),t}_createActionMergeUp(e){const t=this._chartWidget.model();return t.model().isMergeUpAvailableForSource(e)?new l.Action({actionId:"Chart.Source.MergeUp",label:_e,statName:"MergeUp",onExecute:()=>t.mergeSourceUp(e)}):null}_createActionUnmergeUp(e){const t=this._chartWidget.model();return t.model().isUnmergeAvailableForSource(e)?new l.Action({actionId:"Chart.Source.UnmergeUp",label:me,statName:"UnmergeUp",onExecute:()=>t.unmergeSourceUp(e)}):null}_createActionMergeDown(e){const t=this._chartWidget.model();return t.model().isMergeDownAvailableForSource(e)?new l.Action({actionId:"Chart.Source.MergeDown",label:ge,statName:"MergeDown",onExecute:()=>t.mergeSourceDown(e)}):null}_createActionUnmergeDown(e){const t=this._chartWidget.model();return t.model().isUnmergeAvailableForSource(e)?new l.Action({actionId:"Chart.Source.UnmergeDown",label:fe,statName:"UnmergeDown",onExecute:()=>t.unmergeSourceDown(e)}):null}_mergeContentMenuItems(e){return[this._createActionMergeUp(e),this._createActionUnmergeUp(e),this._createActionMergeDown(e),this._createActionUnmergeDown(e)].filter(n.notNull)}_createActionMove(e){const t=this._mergeContentMenuItems(e);return t.length>0?new l.Action({actionId:"Chart.Source.MoveToPane",label:pe,icon:i(54190),subItems:t}):null}_contextMenuActionsForSeries(e,t){var i +s.ensureNotNull)(t.paneForSource(e)),r=i.actionNoScaleIsEnabled(e);return new l.Action({actionId:"Chart.Source.MoveToNoScale",checkable:!0,checked:i.isOverlay(e),label:ue,disabled:!r,statName:"ToggleNoScale",payload:{datasource:e},onExecute:this._onNoScale.bind(this)})}_createActionScaleItems(e){const t=[],i=this._chartWidget.model().model(),r=(0,s.ensureNotNull)(i.paneForSource(e)),n=i.priceScaleSlotsCount().totallySlots>1,o=r.rightPriceScales(),a=r.leftPriceScales(),c=this._createActionScaleDetachRight(e),d=this._createActionScaleDetachLeft(e),u=o.length+a.length+(null===c?0:1)+(null===d?0:1)>2,p={right:{hidden:{checked:{labelled:Y,sided:K},unchecked:{labelled:Z,sided:X}},visible:{checked:{labelled:J,sided:Q},unchecked:{labelled:ee,sided:te}}},left:{hidden:{checked:{labelled:Y,sided:ie},unchecked:{labelled:Z,sided:se}},visible:{checked:{labelled:J,sided:re},unchecked:{labelled:ee,sided:ne}}}},_={right:D,left:E},m={left:r.visibleLeftPriceScales(),right:r.visibleRightPriceScales()},g=(t,i)=>{const s=("right"===i?o:a)[t],r=m[i].includes(s)?"visible":"hidden",l=e.priceScale()===s?"checked":"unchecked",c=n?"labelled":"sided",d=p[i],u=(0,h.getPriceAxisNameInfo)(i,t).label;return{actionText:d[r][l][c].format({label:u}),undoText:n?k.format({label:u}):_[i]}};t.push(...o.map(((t,i)=>{const s=g(i,"right");return this._createMoveToScaleAction(e,t,s.actionText,s.undoText)}))),null!==c&&t.push(c);u&&(o.length>0||null!==c)&&t.push(new l.Separator);t.push(...a.map(((t,i)=>{const s=g(i,"left");return this._createMoveToScaleAction(e,t,s.actionText,s.undoText)}))),null!==d&&t.push(d);u&&(a.length>0||null!==d)&&t.push(new l.Separator);return t.push(this._createActionNoScale(e)),t}_createActionMergeUp(e){const t=this._chartWidget.model();return t.model().isMergeUpAvailableForSource(e)?new l.Action({actionId:"Chart.Source.MergeUp",label:_e,statName:"MergeUp",onExecute:()=>t.mergeSourceUp(e)}):null}_createActionUnmergeUp(e){const t=this._chartWidget.model();return t.model().isUnmergeAvailableForSource(e)?new l.Action({actionId:"Chart.Source.UnmergeUp",label:me,statName:"UnmergeUp",onExecute:()=>t.unmergeSourceUp(e)}):null}_createActionMergeDown(e){const t=this._chartWidget.model();return t.model().isMergeDownAvailableForSource(e)?new l.Action({actionId:"Chart.Source.MergeDown",label:ge,statName:"MergeDown",onExecute:()=>t.mergeSourceDown(e)}):null}_createActionUnmergeDown(e){const t=this._chartWidget.model();return t.model().isUnmergeAvailableForSource(e)?new l.Action({actionId:"Chart.Source.UnmergeDown",label:fe,statName:"UnmergeDown",onExecute:()=>t.unmergeSourceDown(e)}):null}_mergeContentMenuItems(e){return[this._createActionMergeUp(e),this._createActionUnmergeUp(e),this._createActionMergeDown(e),this._createActionUnmergeDown(e)].filter(n.notNull)}_createActionMove(e){const t=this._mergeContentMenuItems(e);return t.length>0?new l.Action({actionId:"Chart.Source.MoveToPane",label:pe,icon:i(54190),subItems:t}):null}_contextMenuActionsForSeries(e,t){var i ;const r=[],n=e.properties().childs().visible.value(),o=this._chartWidget.model().model(),c=(0,s.ensureNotNull)(o.paneForSource(e)),h=this._chartWidget.actions(),d=t&&"localY"in t?t.localY:void 0;if(this._isReadOnly())r.push(n?this._createActionHide(e):this._createActionShow(e)),r.push(new l.Separator),r.push(this._createActionScale(e));else{0,r.length>0&&!(r[r.length-1]instanceof l.Separator)&&r.push(new l.Separator),a.enabled("symbol_info")&&r.push(h.showSymbolInfoDialog);o.mainSeries().symbolInfo();if(r.length>0&&!(r[r.length-1]instanceof l.Separator)&&r.push(new l.Separator),!c.isEmpty()&&a.enabled("datasource_copypaste")){const e=Ye(c,d),t=Ge(this._chartWidget,c);(e||t)&&(e&&r.push(e),t&&r.push(t),r.push(new l.Separator))}r.push(qe(this._chartWidget,[e]));const t=this._createActionMove(e);null!==t&&r.push(t),r.push(this._createActionScale(e)),r.push(n?this._createActionHide(e):this._createActionShow(e)),r.push(new l.Separator);Boolean(null===(i=window.widgetbar)||void 0===i?void 0:i.widget("watchlist"))&&h.addToWatchlist&&r.push(h.addToWatchlist),a.enabled("text_notes")&&r.push(h.addToTextNotes),r[r.length-1]instanceof l.Separator||r.push(new l.Separator),a.enabled("show_chart_property_page")&&!this._chartWidget.onWidget()&&r.push(h.mainSeriesPropertiesAction),r[r.length-1]instanceof l.Separator&&r.pop()}return r}_createActionAddChildStudy(e){throw new Error("unsupported")}_createActionAddFundamentals(e){return null}_createActionShowSymbolInfoDialog(e,t){const s=this._chartWidget.model().model();return new l.Action({actionId:"Chart.Dialogs.ShowSymbolInfo",label:We,icon:i(37924),checkable:!1,statName:"SymbolInfo",onExecute:()=>{const i=e.symbol(),r={symbolInfo:e.symbolInfo(),unitDescription:e=>t.description(e),dateFormatter:s.dateFormatter()};(0,v.showSymbolInfoDialog)(i,r)}})}_createActionShowProperties(e){return new l.Action({actionId:"Chart.Indicator.ShowSettingsDialog",label:Le,icon:i(51983),statName:"EditSelectedObject",onExecute:()=>this._chartWidget.showSourceProperties(e)})}async _contextMenuActionsForStudy(e,t){const i=this._chartWidget.actions(),s=e.properties().childs().visible.value(),r=(t&&"localY"in t&&t.localY,[]);if(!e.userEditEnabled())return r;if(this._chartWidget.readOnly())r.push(s?this._createActionHide(e):this._createActionShow(e)),r.push(new l.Separator),(0,p.isNonSeriesStudy)(e)||r.push(this._createActionScale(e));else{0,a.enabled("study_on_study")&&e.canHaveChildren()&&r.push(this._createActionAddChildStudy(e));const t=this._createApplyToEntireLayoutCommand(e);if(null!==t&&r.push(t),r.length>0&&!(r[r.length-1]instanceof l.Separator)&&r.push(new l.Separator),a.enabled("symbol_info")&&(e instanceof f.StudyCompare||e instanceof g.study_Overlay)&&null!==e.symbolInfo()&&(r.push(this._createActionShowSymbolInfoDialog(e,this._chartWidget.model().model().availableUnits())),r.push(new l.Separator)),r.push(qe(this._chartWidget,[e])),r.push($e(this._chartWidget,[e])),!(0,p.isNonSeriesStudy)(e)){const t=this._createActionMove(e);null!==t&&r.push(t),r.push(this._createActionScale(e))} -r.push(new l.Separator);const n=e.metaInfo();if(e.copiable()){const t=new l.Action({actionId:"Chart.Clipboard.CopySource",label:Ae,shortcutHint:(0,m.humanReadableHash)(m.Modifiers.Mod+67),statName:"Copy",onExecute:()=>{this._chartWidget.chartWidgetCollection().clipboard.uiRequestCopy([e])}});r.push(t)}r.push(s?this._createActionHide(e):this._createActionShow(e)),r.push(i.studyRemove);const o=this._options.objectTree&&i.paneObjectTree,c=!1;(o||c)&&(r.push(new l.Separator),o&&r.push(i.paneObjectTree),c&&r.push(this._chartWidget.actions().showDataWindow)),r.push(new l.Separator),a.enabled("property_pages")&&new _.MetaInfoHelper(n).hasUserEditableOptions()&&r.push(this._createActionShowProperties(e)),r[r.length-1]instanceof l.Separator&&r.pop()}return r}_createEditAlertDrawingAction(e){return new TVAction({label:G.format({title:e.title(d.TitleDisplayTarget.StatusLine)}),icon:TbbiEditAlertSvg,statName:"EditAlert",onExecute:()=>{window.runOrSignIn((()=>{e.editAlert("pane_context_menu_edit_alert")}),{source:"Alert edit from pane context menu"})}})}_createLineToolTemplateAction(e){return null}_createActionToggleLockLineTools(e){const t=e[0].properties().frozen.value(),s=t?Ve:Ee;return new l.Action({actionId:"Chart.SelectedObject.ToggleLocked",label:s,statName:"ToggleLockSelectedObject",checkable:!0,icon:i(t?97874:2872),onExecute:()=>{if(1===e.length)this._chartWidget.toggleLockSelectedObject();else{const i=t?W:F,s=this._chartWidget.model();s.withMacro(i,(()=>{e.forEach((e=>{s.setProperty(e.properties().frozen,!t,i)}))}))}}})}async _contextMenuActionsForLineTool(e){const t=[],s=this._chartWidget.actions(),r=(this._chartWidget.model().model(),()=>{t.push(qe(this._chartWidget,e))}),n=()=>{t.push($e(this._chartWidget,e))},o=()=>{const s=e.filter((e=>e.cloneable()));if(s.length>0){const e=new l.Action({actionId:"Chart.LineTool.Clone",label:ke,icon:i(1457),shortcutHint:(0,m.humanReadableModifiers)(m.Modifiers.Mod)+"Drag",statName:"Clone",onExecute:()=>this._chartWidget.model().cloneLineTools(s,!1)},"Clone");t.push(e)}return!!s.length},c=()=>{const i=e.filter((e=>e.copiable()));if(i.length>0){const e=new l.Action({actionId:"Chart.Clipboard.CopyLineTools",label:Ae,shortcutHint:(0,m.humanReadableHash)(m.Modifiers.Mod+67),statName:"Copy",onExecute:()=>this._chartWidget.chartWidgetCollection().clipboard.uiRequestCopy(i)},"Copy");t.push(e)}return!!i.length},h=()=>{const e=(this._chartWidget,[]);return t.push(...e),e.length>0},u=e=>{const i=new l.Action({actionId:"Chart.ScrollToLineTool",label:De.format({lineToolName:e.title(d.TitleDisplayTarget.StatusLine)}),statName:"GoToLineTool",checkable:!1,onExecute:async()=>this._chartWidget.model().scrollToLineTool(e)});t.push(i)},p=e=>{const t=this._chartWidget.model().model().lineToolsGroupModel(),i=e.map((e=>t.groupForLineTool(e)));return new Set(i).size<=1};if(1===e.length){const i=e[0];if(this._chartWidget.readOnly())t.push(s.lineHide);else if(i.userEditEnabled()){0,r(),n(),this._options.objectTree&&s.paneObjectTree&&t.push(s.paneObjectTree),t.push(new l.Separator);let e=o();e=c()||e, -e=h()||e,e&&t.push(new l.Separator),t.push(this._createActionToggleLockLineTools([i])),t.push(s.lineHide),t.push(s.lineRemove),i.points().length>0&&this._options.gotoLineTool&&(t.push(new l.Separator),u(i));const d=await this._chartWidget.propertiesDefinitionsForSource(i);if(a.enabled("property_pages")&&null!==d&&(t.push(new l.Separator),t.push(s.format)),i.additionalActions){t.push(new l.Separator);const e=i.additionalActions(this._chartWidget.model());t.push(...e)}}}else this._options.objectTree&&s.paneObjectTree&&t.push(s.paneObjectTree),p(e)&&r(),n(),t.length>0&&t.push(new l.Separator),o(),c(),h(),t.push(new l.Separator),t.push(this._createActionToggleLockLineTools(e)),t.push(s.lineHide),t.push(s.lineRemove),a.enabled("property_pages")&&(t.push(new l.Separator),t.push(s.format));return t}_createEarningsShow(){return null}_createDividendsShow(){return null}_createSplitsShow(){return null}_contextMenuActionsForESD(){return[]}_contextMenuActionsForRollDates(){return[]}_contextMenuActionsForFuturesContractExpiration(){return[]}_contextMenuActionsForisLatestUpdates(){return[]}_contextMenuActionsForPublishedTimeline(e){const t=this._chartWidget.actions(),i=[];if(i.push(t.lineHide),window.is_authenticated){const t=e.properties().childs().filter,s=new TVAction({checked:t.value()===PublishedChartsFilter.None,checkable:!0,label:Be,name:"ToggleAllIdeas",statName:"ToggleAllIdeas",onExecute:()=>this._chartWidget.model().setProperty(t,PublishedChartsFilter.None,E)}),r=new TVAction({checked:t.value()===PublishedChartsFilter.Following,checkable:!0,label:Re,name:"ToggleIdeasOfPeopleAndUser",statName:"ToggleIdeasOfPeopleAndUser",onExecute:()=>this._chartWidget.model().setProperty(t,PublishedChartsFilter.Following,B)}),n=new TVAction({checked:t.value()===PublishedChartsFilter.Private,checkable:!0,label:Ne,name:"ToggleUserIdeas",statName:"ToggleUserIdeas",onExecute:()=>this._chartWidget.model().setProperty(t,PublishedChartsFilter.Private,R)});i.push(new l.Separator,s,r,n)}return i}_contextMenuActionsForTradingDrawings(e){return e.contextMenuItems()}_createAlertToggleHorzLineLabelAction(e){throw new Error("Not implemented")}_createAlertChangeColorAction(){throw new Error("Not implemented")}_contextMenuActionsForAlertLabel(e,t){throw new Error("Not implemented")}_contextMenuActionsForChartEvents(e){return[]}_createApplyToEntireLayoutCommand(e){if(!this._chartWidget.chartWidgetCollection().applyIndicatorsToAllChartsAvailable())return null;const t=this._chartWidget.model().model();if(e.parentSources().length>0)return null;const i=(0,s.ensureNotNull)(t.paneForSource(e)),r=t.paneForSource(t.mainSeries())===i,n=e instanceof f.StudyCompare&&e.priceScale()===t.mainSeries().priceScale()&&(0,s.ensureNotNull)(e.priceScale()).isPercentage(),o=r?void 0:t.panes().indexOf(i);let a=Fe,c=O,h="AddStudyToEntireLayout";return(0,b.isActingAsSymbolSource)(e)&&(a=Oe,c=N,h="AddSymbolToEntireLayout"),new l.Action({actionId:"Chart.AddIndicatorToAllCharts",label:a,statName:h,onExecute:()=>{const i=(0,s.ensureNotNull)((0, +r.push(new l.Separator);const n=e.metaInfo();if(e.copiable()){const t=new l.Action({actionId:"Chart.Clipboard.CopySource",label:Ae,shortcutHint:(0,m.humanReadableHash)(m.Modifiers.Mod+67),statName:"Copy",onExecute:()=>{this._chartWidget.chartWidgetCollection().clipboard.uiRequestCopy([e])}});r.push(t)}r.push(s?this._createActionHide(e):this._createActionShow(e)),r.push(i.studyRemove);const o=this._options.objectTree&&i.paneObjectTree,c=!1;(o||c)&&(r.push(new l.Separator),o&&r.push(i.paneObjectTree),c&&r.push(this._chartWidget.actions().showDataWindow)),r.push(new l.Separator),a.enabled("property_pages")&&new _.MetaInfoHelper(n).hasUserEditableOptions()&&r.push(this._createActionShowProperties(e)),r[r.length-1]instanceof l.Separator&&r.pop()}return r}_createEditAlertDrawingAction(e){return new TVAction({label:G.format({title:e.title(d.TitleDisplayTarget.StatusLine)}),icon:TbbiEditAlertSvg,statName:"EditAlert",onExecute:()=>{window.runOrSignIn((()=>{e.editAlert("pane_context_menu_edit_alert")}),{source:"Alert edit from pane context menu"})}})}_createLineToolTemplateAction(e){return null}_createActionToggleLockLineTools(e){const t=e[0].properties().frozen.value(),s=t?Ee:Ve;return new l.Action({actionId:"Chart.SelectedObject.ToggleLocked",label:s,statName:"ToggleLockSelectedObject",checkable:!0,icon:i(t?97874:2872),onExecute:()=>{if(1===e.length)this._chartWidget.toggleLockSelectedObject();else{const i=t?W:F,s=this._chartWidget.model();s.withMacro(i,(()=>{e.forEach((e=>{s.setProperty(e.properties().frozen,!t,i)}))}))}}})}async _contextMenuActionsForLineTool(e){const t=[],s=this._chartWidget.actions(),r=(this._chartWidget.model().model(),()=>{t.push(qe(this._chartWidget,e))}),n=()=>{t.push($e(this._chartWidget,e))},o=()=>{const s=e.filter((e=>e.cloneable()));if(s.length>0){const e=new l.Action({actionId:"Chart.LineTool.Clone",label:ke,icon:i(1457),shortcutHint:(0,m.humanReadableModifiers)(m.Modifiers.Mod)+"Drag",statName:"Clone",onExecute:()=>this._chartWidget.model().cloneLineTools(s,!1)},"Clone");t.push(e)}return!!s.length},c=()=>{const i=e.filter((e=>e.copiable()));if(i.length>0){const e=new l.Action({actionId:"Chart.Clipboard.CopyLineTools",label:Ae,shortcutHint:(0,m.humanReadableHash)(m.Modifiers.Mod+67),statName:"Copy",onExecute:()=>this._chartWidget.chartWidgetCollection().clipboard.uiRequestCopy(i)},"Copy");t.push(e)}return!!i.length},h=()=>{const e=(this._chartWidget,[]);return t.push(...e),e.length>0},u=e=>{const i=new l.Action({actionId:"Chart.ScrollToLineTool",label:De.format({lineToolName:e.title(d.TitleDisplayTarget.StatusLine)}),statName:"GoToLineTool",checkable:!1,onExecute:async()=>this._chartWidget.model().scrollToLineTool(e)});t.push(i)},p=e=>{const t=this._chartWidget.model().model().lineToolsGroupModel(),i=e.map((e=>t.groupForLineTool(e)));return new Set(i).size<=1};if(1===e.length){const i=e[0];if(this._chartWidget.readOnly())t.push(s.lineHide);else if(i.userEditEnabled()){0,r(),n(),this._options.objectTree&&s.paneObjectTree&&t.push(s.paneObjectTree),t.push(new l.Separator);let e=o();e=c()||e, +e=h()||e,e&&t.push(new l.Separator),t.push(this._createActionToggleLockLineTools([i])),t.push(s.lineHide),t.push(s.lineRemove),i.points().length>0&&this._options.gotoLineTool&&(t.push(new l.Separator),u(i));const d=await this._chartWidget.propertiesDefinitionsForSource(i);if(a.enabled("property_pages")&&null!==d&&(t.push(new l.Separator),t.push(s.format)),i.additionalActions){t.push(new l.Separator);const e=i.additionalActions(this._chartWidget.model());t.push(...e)}}}else this._options.objectTree&&s.paneObjectTree&&t.push(s.paneObjectTree),p(e)&&r(),n(),t.length>0&&t.push(new l.Separator),o(),c(),h(),t.push(new l.Separator),t.push(this._createActionToggleLockLineTools(e)),t.push(s.lineHide),t.push(s.lineRemove),a.enabled("property_pages")&&(t.push(new l.Separator),t.push(s.format));return t}_createEarningsShow(){return null}_createDividendsShow(){return null}_createSplitsShow(){return null}_contextMenuActionsForESD(){return[]}_contextMenuActionsForRollDates(){return[]}_contextMenuActionsForFuturesContractExpiration(){return[]}_contextMenuActionsForisLatestUpdates(){return[]}_contextMenuActionsForPublishedTimeline(e){const t=this._chartWidget.actions(),i=[];if(i.push(t.lineHide),window.is_authenticated){const t=e.properties().childs().filter,s=new TVAction({checked:t.value()===PublishedChartsFilter.None,checkable:!0,label:Be,name:"ToggleAllIdeas",statName:"ToggleAllIdeas",onExecute:()=>this._chartWidget.model().setProperty(t,PublishedChartsFilter.None,V)}),r=new TVAction({checked:t.value()===PublishedChartsFilter.Following,checkable:!0,label:Re,name:"ToggleIdeasOfPeopleAndUser",statName:"ToggleIdeasOfPeopleAndUser",onExecute:()=>this._chartWidget.model().setProperty(t,PublishedChartsFilter.Following,B)}),n=new TVAction({checked:t.value()===PublishedChartsFilter.Private,checkable:!0,label:Ne,name:"ToggleUserIdeas",statName:"ToggleUserIdeas",onExecute:()=>this._chartWidget.model().setProperty(t,PublishedChartsFilter.Private,R)});i.push(new l.Separator,s,r,n)}return i}_contextMenuActionsForTradingDrawings(e){return e.contextMenuItems()}_createAlertToggleHorzLineLabelAction(e){throw new Error("Not implemented")}_createAlertChangeColorAction(){throw new Error("Not implemented")}_contextMenuActionsForAlertLabel(e,t){throw new Error("Not implemented")}_contextMenuActionsForChartEvents(e){return[]}_createApplyToEntireLayoutCommand(e){if(!this._chartWidget.chartWidgetCollection().applyIndicatorsToAllChartsAvailable())return null;const t=this._chartWidget.model().model();if(e.parentSources().length>0)return null;const i=(0,s.ensureNotNull)(t.paneForSource(e)),r=t.paneForSource(t.mainSeries())===i,n=e instanceof f.StudyCompare&&e.priceScale()===t.mainSeries().priceScale()&&(0,s.ensureNotNull)(e.priceScale()).isPercentage(),o=r?void 0:t.panes().indexOf(i);let a=Fe,c=O,h="AddStudyToEntireLayout";return(0,b.isActingAsSymbolSource)(e)&&(a=Oe,c=N,h="AddSymbolToEntireLayout"),new l.Action({actionId:"Chart.AddIndicatorToAllCharts",label:a,statName:h,onExecute:()=>{const i=(0,s.ensureNotNull)((0, S.clipboardDataForSources)(t.id(),[e])),a=this._chartWidget.chartWidgetCollection(),l={isOnMainPane:r,asCompare:n,paneIndex:o};a.applyIndicatorToAllCharts(this._chartWidget,i,l,c)}},"applyStudyToEntireLayout")}}},88913:(e,t,i)=>{"use strict";i.r(t),i.d(t,{supportedLineTools:()=>s});const s={cursor:{name:"cursor",onlySelectable:!0},dot:{name:"dot",onlySelectable:!0},arrow_cursor:{name:"arrow",onlySelectable:!0},eraser:{name:"eraser",onlySelectable:!0},measure:{name:"measure",onlySelectable:!0},zoom:{name:"zoom",onlySelectable:!0},brush:{name:"LineToolBrush"},highlighter:{name:"LineToolHighlighter"},text:{name:"LineToolText"},anchored_text:{name:"LineToolTextAbsolute",isAnchored:!0},note:{name:"LineToolNote"},anchored_note:{name:"LineToolNoteAbsolute",isAnchored:!0},signpost:{name:"LineToolSignpost"},callout:{name:"LineToolCallout"},balloon:{name:"LineToolBalloon"},comment:{name:"LineToolComment"},arrow_up:{name:"LineToolArrowMarkUp"},arrow_down:{name:"LineToolArrowMarkDown"},arrow_left:{name:"LineToolArrowMarkLeft"},arrow_right:{name:"LineToolArrowMarkRight"},price_label:{name:"LineToolPriceLabel"},price_note:{name:"LineToolPriceNote"},arrow_marker:{name:"LineToolArrowMarker"},flag:{name:"LineToolFlagMark"},vertical_line:{name:"LineToolVertLine"},horizontal_line:{name:"LineToolHorzLine"},cross_line:{name:"LineToolCrossLine"},horizontal_ray:{name:"LineToolHorzRay"},trend_line:{name:"LineToolTrendLine"},info_line:{name:"LineToolInfoLine"},trend_angle:{name:"LineToolTrendAngle"},arrow:{name:"LineToolArrow"},ray:{name:"LineToolRay"},extended:{name:"LineToolExtended"},parallel_channel:{name:"LineToolParallelChannel"},disjoint_angle:{name:"LineToolDisjointAngle"},flat_bottom:{name:"LineToolFlatBottom"},anchored_vwap:{name:"LineToolAnchoredVWAP"},pitchfork:{name:"LineToolPitchfork"},schiff_pitchfork_modified:{name:"LineToolSchiffPitchfork"},schiff_pitchfork:{name:"LineToolSchiffPitchfork2"},inside_pitchfork:{name:"LineToolInsidePitchfork"},pitchfan:{name:"LineToolPitchfan"},gannbox:{name:"LineToolGannSquare"},gannbox_square:{name:"LineToolGannComplex"},gannbox_fixed:{name:"LineToolGannFixed"},gannbox_fan:{name:"LineToolGannFan"},fib_retracement:{name:"LineToolFibRetracement"},fib_trend_ext:{name:"LineToolTrendBasedFibExtension"},fib_speed_resist_fan:{name:"LineToolFibSpeedResistanceFan"},fib_timezone:{name:"LineToolFibTimeZone"},fib_trend_time:{name:"LineToolTrendBasedFibTime"},fib_circles:{name:"LineToolFibCircles"},fib_spiral:{name:"LineToolFibSpiral"},fib_speed_resist_arcs:{name:"LineToolFibSpeedResistanceArcs"},fib_wedge:{name:"LineToolFibWedge"},fib_channel:{name:"LineToolFibChannel"},xabcd_pattern:{name:"LineTool5PointsPattern"},cypher_pattern:{name:"LineToolCypherPattern"},abcd_pattern:{name:"LineToolABCD"},triangle_pattern:{name:"LineToolTrianglePattern"},"3divers_pattern":{name:"LineToolThreeDrivers"},head_and_shoulders:{name:"LineToolHeadAndShoulders"},elliott_impulse_wave:{name:"LineToolElliottImpulse"},elliott_triangle_wave:{name:"LineToolElliottTriangle"},elliott_triple_combo:{name:"LineToolElliottTripleCombo"}, elliott_correction:{name:"LineToolElliottCorrection"},elliott_double_combo:{name:"LineToolElliottDoubleCombo"},cyclic_lines:{name:"LineToolCircleLines"},time_cycles:{name:"LineToolTimeCycles"},sine_line:{name:"LineToolSineLine"},long_position:{name:"LineToolRiskRewardLong"},short_position:{name:"LineToolRiskRewardShort"},forecast:{name:"LineToolPrediction"},date_range:{name:"LineToolDateRange"},price_range:{name:"LineToolPriceRange"},date_and_price_range:{name:"LineToolDateAndPriceRange"},bars_pattern:{name:"LineToolBarsPattern"},ghost_feed:{name:"LineToolGhostFeed"},projection:{name:"LineToolProjection"},rectangle:{name:"LineToolRectangle"},rotated_rectangle:{name:"LineToolRotatedRectangle"},circle:{name:"LineToolCircle"},ellipse:{name:"LineToolEllipse"},triangle:{name:"LineToolTriangle"},polyline:{name:"LineToolPolyline"},path:{name:"LineToolPath"},curve:{name:"LineToolBezierQuadro"},double_curve:{name:"LineToolBezierCubic"},arc:{name:"LineToolArc"},icon:{name:"LineToolIcon"},emoji:{name:"LineToolEmoji"},sticker:{name:"LineToolSticker"},regression_trend:{name:"LineToolRegressionTrend"},fixed_range_volume_profile:{name:"LineToolFixedRangeVolumeProfile"}}},69618:(e,t,i)=>{"use strict";i.d(t,{clipboardDataForSources:()=>a});var s=i(50151),r=i(37591),n=i(28853),o=i(92249);function a(e,t){if(1===t.length&&(0,n.isStudy)(t[0])){const e=t[0];return{title:e.title(r.TitleDisplayTarget.StatusLine),sources:[{source:(0,s.ensureNotNull)(e.state()),type:"study"}]}}const i={sources:[],title:""};return i.sources=t.filter((e=>e.copiable()&&(0,o.isLineTool)(e))).map((t=>{const i={type:"drawing",geometry:t.geometry(),source:{...t.state(!1),points:t.normalizedPoints()},modelId:e};return delete i.source.alertId,i})),i.sources.length>0?(1===i.sources.length?i.title=t[0].title(r.TitleDisplayTarget.StatusLine):i.title="Drawings",i):null}},74359:(e,t,i)=>{"use strict";i.d(t,{addExclusionArea:()=>w,addExclusionAreaByScope:()=>b,calcTextHorizontalShift:()=>S,clearRect:()=>p,createBoundCanvas:()=>v,createDisconnectedBoundCanvas:()=>g,createDisconnectedCanvas:()=>m,disableSelection:()=>y,drawScaled:()=>_,fillRect:()=>u,getBindingPixelRatio:()=>l,getContext2D:()=>c,getPrescaledContext2D:()=>h,getPretransformedContext2D:()=>d,measureText:()=>C});var s=i(27714),r=i(50151),n=i(31964),o=i(38223),a=i(49483);function l(e){return(0,n.getCanvasDevicePixelRatio)(e.canvasElement)}function c(e){const t=(0,r.ensureNotNull)(e.getContext("2d"));return t.setTransform(1,0,0,1,0,0),t}function h(e){const t=(0,r.ensureNotNull)(e.getContext("2d")),i=(0,n.getCanvasDevicePixelRatio)(e);return t.setTransform(i,0,0,i,0,0),t}function d(e,t){const i=(0,r.ensureNotNull)(e.canvasElement.getContext("2d")),s=l(e);return i.setTransform(s,0,0,s,0,0),t||i.translate(.5,.5),i}function u(e,t,i,s,r,n){e.save(),e.translate(-.5,-.5),e.fillStyle=n,e.fillRect(t,i,s,r),e.restore()}function p(e,t,i,s,r,n){e.save(),e.translate(-.5,-.5),e.globalCompositeOperation="copy",e.fillStyle=n,e.fillRect(t,i,s,r),e.restore()}function _(e,t,i,s){e.save(),e.scale(t,i),s(),e.restore()} function m(e,t,i){const s=f(e);return void 0===i&&(i=(0,n.getCanvasDevicePixelRatio)(s)),s.width=t.width*i,s.height=t.height*i,s}function g(e,t){const i=f(e),r=(0,s.bindCanvasElementBitmapSizeTo)(i,{type:"device-pixel-content-box",transform:(e,t)=>({width:Math.max(e.width,t.width),height:Math.max(e.height,t.height)})});return r.resizeCanvasElement(t),r}function f(e){const t=e.createElement("canvas");return y(t),t}function v(e,t){const i=f((0,r.ensureNotNull)(e.ownerDocument));e.appendChild(i);const n=(0,s.bindCanvasElementBitmapSizeTo)(i,{type:"device-pixel-content-box",transform:(e,t)=>({width:Math.max(e.width,t.width),height:Math.max(e.height,t.height)})});return n.resizeCanvasElement(t),n}function S(e,t){return"center"===e.textAlign?0:(0,o.isRtl)()?"start"===e.textAlign||"right"===e.textAlign?t:0:"start"===e.textAlign||"left"===e.textAlign?0:t}function y(e){e.style.userSelect="none",e.style.webkitUserSelect="none",e.style.msUserSelect="none",e.style.MozUserSelect="none",e.style.webkitTapHighlightColor="transparent"}function b(e,t){const{context:i,horizontalPixelRatio:s,verticalPixelRatio:r,bitmapSize:n}=e;i.beginPath(),i.rect(0,0,n.width,n.height);for(let e=0;e{"use strict";i.d(t,{ChartChangesWatcher:()=>n,changedAll:()=>r});var s=i(57898);const r=3;class n{constructor(e,t,i){this._undoHistoryHasChanges=!1,this._changesMask=0,this._recursiveLoopingGuard=!1,this._handleMetainfoChanged=()=>{this._changesMask=1|this._changesMask},this._recalculateHaveChanges=(e,t)=>{if(!this._recursiveLoopingGuard)try{this._recursiveLoopingGuard=!0;const e=this._undoHistoryHasChanges?1:0;let i=this._lineToolsHaveChanges.value()?2:0;const s=this._changesMask;this._changesMask=e|i,s!==this._changesMask&&(this._changesMask&&(this._chartWidgetCollection.getAll().forEach((e=>{var i;null===(i=e.lineToolsSynchronizer())||void 0===i||i.markAsValidatedBecauseOfSavingToContent(!!t)})),i=this._lineToolsHaveChanges.value()?2:0,this._changesMask=e|i),this._onValueChanged.fire(0!==this._changesMask))}finally{this._recursiveLoopingGuard=!1}},this._chartWidgetCollection=e,this._undoHistory=e.undoHistory,this._lineToolsHaveChanges=e.lineToolsSynchronizerHasChanges,this._chartSaver=t,this._globalEvents=i,this._onValueChanged=new s.Delegate,this._subscribe()}destroy(){this._unsubscribe(),this._onValueChanged.destroy()}changes(){return this._changesMask}hasChanges(){return this._changesMask>0}getOnChange(){ return this._onValueChanged}_subscribe(){var e;this._globalEvents.subscribe("chart_loaded",this._handleChartLoaded,this),this._globalEvents.subscribe("chart_migrated",this._handleChartMigrated,this),this._undoHistory.undoStack().onChange().subscribe(this,this._handleUndoHistoryChange),null===(e=this._chartSaver)||void 0===e||e.chartSaved().subscribe(this,this._handleChartSaved),this._lineToolsHaveChanges.subscribe(this._recalculateHaveChanges);this._chartWidgetCollection.metaInfo.name.subscribe(this._handleMetainfoChanged)}_unsubscribe(){var e;this._globalEvents.unsubscribe("chart_loaded",this._handleChartLoaded,this),this._globalEvents.unsubscribe("chart_migrated",this._handleChartMigrated,this),this._undoHistory.undoStack().onChange().unsubscribe(this,this._handleUndoHistoryChange),null===(e=this._chartSaver)||void 0===e||e.chartSaved().unsubscribe(this,this._handleChartSaved),this._lineToolsHaveChanges.unsubscribe(this._recalculateHaveChanges);this._chartWidgetCollection.metaInfo.name.unsubscribe(this._handleMetainfoChanged)}_setUndoHistoryHasChanges(e,t){this._undoHistoryHasChanges=e,this._recalculateHaveChanges(e,t)}_handleChartLoaded(){this._setUndoHistoryHasChanges(!1)}_handleUndoHistoryChange(e){e&&!e.customFlag("doesnt_affect_save")&&this._setUndoHistoryHasChanges(!0)}_handleChartMigrated(){this._setUndoHistoryHasChanges(!0)}_handleChartSaved(e){e&&this._setUndoHistoryHasChanges(!1,!0)}}},28571:(e,t,i)=>{"use strict";i.d(t,{ChartHotkeysListener:()=>v,globalEnvironmentState:()=>f,modifierPressed:()=>g,shiftPressed:()=>m});var s,r,n,o=i(4741),a=i(68335),l=i(35749),c=i(97145),h=i(81155);const d=new c.WatchedValue(Boolean((null!==(s=o.pressedKeys.value())&&void 0!==s?s:0)&a.Modifiers.Shift)),u=new c.WatchedValue(Boolean((null!==(r=o.pressedKeys.value())&&void 0!==r?r:0)&a.Modifiers.Mod)),p=new c.WatchedValue(Boolean((null!==(n=o.pressedKeys.value())&&void 0!==n?n:0)&a.Modifiers.Alt)),_=[a.Modifiers.None,a.Modifiers.Alt,a.Modifiers.Mod,a.Modifiers.Alt+a.Modifiers.Shift];function m(){return d}function g(){return u}function f(){return new h.EnvironmentState({altKey:p.value(),ctrlKey:g().value(),metaKey:g().value(),shiftKey:m().value()})}o.pressedKeys.subscribe(((e=0)=>{d.setValue(Boolean(e&a.Modifiers.Shift)),u.setValue(Boolean(e&a.Modifiers.Mod)),p.setValue(Boolean(e&a.Modifiers.Alt))}));class v{constructor(e,t){this._pressedKeyCode=null,this._boundKeydownHandler=null,this._boundKeyupHandler=null,this._chartWidget=e,this._parent=t,this._boundKeydownHandler=this._keydownHandler.bind(this),this._boundKeyupHandler=this._keyupHandler.bind(this),this._parent.ownerDocument.addEventListener("keydown",this._boundKeydownHandler),this._parent.ownerDocument.addEventListener("keyup",this._boundKeyupHandler)}destroy(){null!==this._boundKeydownHandler&&(this._parent.ownerDocument.removeEventListener("keydown",this._boundKeydownHandler),this._boundKeydownHandler=null),null!==this._boundKeyupHandler&&(this._parent.ownerDocument.removeEventListener("keyup",this._boundKeyupHandler),this._boundKeyupHandler=null)}_keydownHandler(e){ this._chartWidget.hasModel()&&window.document.activeElement===window.document.body&&this._chartWidget.isActive()&&(this._handleMoveDrawingsKeyDown(e)||this._handleScrollKeyDown(e)||this._handleZoomKeyDown(e))&&e.preventDefault()}_keyupHandler(e){this._chartWidget.hasModel()&&this._handleScrollKeyUp(e)}_handleMoveDrawingsKeyDown(e){const t=255&(0,a.hashFromEvent)(e),i=this._chartWidget.model();switch(t){case 37:return i.moveSelectedToolsLeft();case 39:return i.moveSelectedToolsRight();case 38:return i.moveSelectedToolsUp();case 40:return i.moveSelectedToolsDown()}return!1}_handleScrollKeyDown(e){if(null!==this._pressedKeyCode)return!1;const t=(0,a.hashFromEvent)(e),i=255&t,s=(0,a.modifiersFromEvent)(e);let r;if(37===i)r=1;else{if(39!==i)return!1;r=-1}return!(a.isMacKeyboard&&s===a.Modifiers.Mod||!_.includes(s))&&(!(0,l.isNativeUIInteraction)(t,e.target)&&(this._pressedKeyCode=i,s===a.Modifiers.None?this._chartWidget.scrollHelper().moveByBar(r):s===a.Modifiers.Alt||s===a.Modifiers.Mod?this._chartWidget.scrollHelper().move(r):-1===r?this._chartWidget.model().timeScale().scrollToRealtime(!0):this._chartWidget.model().timeScale().scrollToFirstBar(),!0))}_handleScrollKeyUp(e){if(null===this._pressedKeyCode)return!1;const t=(0,a.hashFromEvent)(e);if((0,l.isNativeUIInteraction)(t,e.target))return!1;return(255&t)===this._pressedKeyCode&&(this._pressedKeyCode=null,this._chartWidget.scrollHelper().stopMove(),!0)}_handleZoomKeyDown(e){const t=(0,a.hashFromEvent)(e),i=255&t;if((0,a.modifiersFromEvent)(e)!==a.Modifiers.Mod||(0,l.isNativeUIInteraction)(t,e.target))return!1;const s=this._chartWidget.model();if(38===i)s.zoomIn();else{if(40!==i)return!1;s.zoomOut()}return!0}}},75444:(e,t,i)=>{"use strict";i.d(t,{ChartWidgetApiBase:()=>ee});var s=i(50151),r=i(44352),n=i(36298),o=i(36274),a=i(19386),l=i(60156),c=i(13041);class h{constructor(e){this._timeScale=e}coordinateToTime(e){const t=this._timeScale.coordinateToIndex(e);return this._timeScale.indexToTimePoint(t)}barSpacingChanged(){return this._timeScale.barSpacingChanged()}rightOffsetChanged(){return this._timeScale.rightOffsetChanged()}setRightOffset(e){this._timeScale.setRightOffset(e)}setBarSpacing(e){this._timeScale.setBarSpacing(e)}barSpacing(){return this._timeScale.barSpacing()}rightOffset(){return this._timeScale.rightOffset()}width(){return this._timeScale.width()}defaultRightOffset(){return this._timeScale.defaultRightOffset().spawn()}defaultRightOffsetPercentage(){return this._timeScale.defaultRightOffsetPercentage().spawn()}usePercentageRightOffset(){return this._timeScale.usePercentageRightOffset().spawn()}isEmpty(){return this._timeScale.isEmpty()}scrollToFirstBar(e){this._timeScale.scrollToFirstBar(e)}scrollToRealtime(e){this._timeScale.scrollToRealtime(!1,e)}pointsCount(){return this._timeScale.points().size()}}var d=i(57898),u=i(38618);const p=new n.TranslatedString("change timezone",r.t(null,void 0,i(20505)));class _{constructor(e){this._onTimezoneChanged=new d.Delegate,this._chartWidget=e,this._timezoneProperty=e.properties().childs().timezone, this._timezoneProperty.subscribe(this,(e=>{this._onTimezoneChanged.fire(e.value())})),e.onAboutToBeDestroyed().subscribe(this,(()=>{this._timezoneProperty.unsubscribeAll(this)}),!0)}availableTimezones(){return u.availableTimezones}getTimezone(){const e=this._timezoneProperty.value();return(0,s.ensureDefined)(this.availableTimezones().find((t=>t.id===e)))}setTimezone(e,t){(0,s.assert)((0,u.timezoneIsAvailable)(e),`Incorrect timezone: ${e}`),(null==t?void 0:t.disableUndo)?this._timezoneProperty.setValue(e):this._chartWidget.model().setProperty(this._timezoneProperty,e,p)}onTimezoneChanged(){return this._onTimezoneChanged}}class m{constructor(e,t){this._chartUndoModel=e,this._chartModel=e.model(),this._priceScale=t}getMode(){const e=this._priceScale.properties().childs();return e.percentage.value()?2:e.indexedTo100.value()?3:e.log.value()?1:0}setMode(e){this._priceScale.setMode({percentage:2===e,log:1===e,indexedTo100:3===e})}isInverted(){return this._priceScale.isInverted()}setInverted(e){this._priceScale.properties().childs().isInverted.setValue(e)}isLocked(){return this._priceScale.isLockScale()}setLocked(e){this._priceScale.setMode({lockScale:e})}isAutoScale(){return this._priceScale.isAutoScale()}setAutoScale(e){this._priceScale.setMode({autoScale:e})}getVisiblePriceRange(){return this._priceScale.priceRangeInPrice()}setVisiblePriceRange(e){this._priceScale.setPriceRangeInPrice(e),this._chartModel.lightUpdate()}hasMainSeries(){return this._priceScale.hasMainSeries()}getStudies(){return this._priceScale.getStudies().map((e=>e.id()))}coordinateToPrice(e){var t;const i=null===(t=this._priceScale.mainSource())||void 0===t?void 0:t.firstValue();return null==i?null:this._priceScale.coordinateToPrice(e,i)}currency(){const e=this._priceScale.currency(this._chartModel.availableCurrencies());return null===e?null:{selectedCurrency:e.selectedCurrency,readOnly:e.readOnly}}setCurrency(e){this._chartUndoModel.setPriceScaleCurrency(this._priceScale,e)}unit(){const e=this._priceScale.unit(this._chartModel.availableUnits());return null===e?null:{selectedUnit:e.selectedUnit,readOnly:0===e.availableGroups.size,availableGroups:Array.from(e.availableGroups)}}setUnit(e){this._chartUndoModel.setPriceScaleUnit(this._priceScale,e)}measureUnitId(){const e=this._priceScale.measureUnitId(this._chartModel.availableUnits());return null===e?null:{selectedMeasureUnitId:e.selectedMeasureUnitId}}}var g=i(45973),f=i(1722),v=i(62591);const S=new n.TranslatedString("change pane height",r.t(null,void 0,i(87510)));class y extends v.UndoCommand{constructor(e,t,i){super(S),this._model=e,this._paneIndex=t,this._paneHeight=i,this._prevStretchFactors=this._model.panes().map((e=>e.stretchFactor()))}redo(){this._model.changePanesHeight(this._paneIndex,this._paneHeight)}undo(){const e=this._model.panes();for(let t=0;t(0,g.entityForDataSource)(e,t))).filter(f.notNull).filter((e=>null!==e.name))}getHeight(){return this._pane.height()}setHeight(e){const t=this._chartWidget.model().model(),i=t.panes();(0,s.assert)(i.length>1,"Unable to change pane's height if there is only one pane");const r=i.indexOf(this._pane);(0,s.assert)(-1!==r,"Invalid pane index");const n=new y(t,r,e);this._chartWidget.model().undoHistory().pushUndoCommand(n)}moveTo(e){const t=this.paneIndex();t!==e&&((0,s.assert)(e>=0&&e{this._study.onStatusChanged().unsubscribeAll(this),this._study.onAboutToBeDestroyed().unsubscribeAll(this)})),this._study.onStatusChanged().subscribe(this,(e=>{switch(e.type){case k.StudyStatusType.Completed:this._onStudyCompleted.fire();break;case k.StudyStatusType.Error:this._onStudyError.fire()}}))}isUserEditEnabled(){return this._study.userEditEnabled()}setUserEditEnabled(e){this._study.setUserEditEnabled(e)}getInputsInfo(){return(0,D.getStudyInputsInfo)(this._study.metaInfo())} -getInputValues(){const e=this._study.inputs({symbolsForChartApi:!1,asObject:!0});return Object.keys(e).map((t=>{const i=e[t];return{id:t,value:(0,f.isObject)(i)?i.v:i}}))}getStyleInfo(){return(0,V.getStudyStylesInfo)(this._study.metaInfo())}getStyleValues(){const{styles:e,bands:t,filledAreas:i,palettes:s,graphics:r,ohlcPlots:n,filledAreasStyle:o}=this._study.properties().state();return{styles:e,bands:t,filledAreas:i,palettes:s,graphics:r,ohlcPlots:n,filledAreasStyle:o}}setInputValues(e){const t=this.getInputValues();for(const i of e){void 0!==t.find((e=>e.id===i.id))?this._study.properties().childs().inputs.childs()[i.id].setValue(i.value):console.warn(`There is no such input: "${i.id}"`)}}mergeUp(){this._model.isMergeUpAvailableForSource(this._study)&&new T.MergeUpUndoCommand(this._model,this._study,null).redo()}mergeDown(){this._model.isMergeDownAvailableForSource(this._study)&&new T.MergeDownUndoCommand(this._model,this._study,null).redo()}unmergeUp(){this._model.isUnmergeAvailableForSource(this._study)&&new x.UnmergeUpUndoCommand(this._model,this._study,null).redo()}unmergeDown(){this._model.isUnmergeAvailableForSource(this._study)&&new x.UnmergeDownUndoCommand(this._model,this._study,null).redo()}onDataLoaded(){return this._onStudyCompleted}onStudyError(){return this._onStudyError}mergeUpWithUndo(){this._model.isMergeUpAvailableForSource(this._study)&&this._undoModel.mergeSourceUp(this._study)}mergeDownWithUndo(){this._model.isMergeDownAvailableForSource(this._study)&&this._undoModel.mergeSourceDown(this._study)}unmergeUpWithUndo(){this._model.isUnmergeAvailableForSource(this._study)&&this._undoModel.unmergeSourceUp(this._study)}unmergeDownWithUndo(){this._model.isUnmergeAvailableForSource(this._study)&&this._undoModel.unmergeSourceDown(this._study)}priceScale(){return new m(this._undoModel,(0,s.ensureNotNull)(this._study.priceScale()))}symbolSource(){const e=(0,s.ensureNotNull)(this._study.symbolSource());return{symbol:e.symbol(),currencyId:e.currency(),unitId:e.unit()}}currency(){return this._study.currency()}changePriceScale(e){const t=(0,s.ensureNotNull)(this._model.paneForSource(this._model.mainSeries())),i=(0,s.ensureNotNull)(this._model.paneForSource(this._study));switch(e){case"no-scale":(0,s.assert)(i.actionNoScaleIsEnabled(this._study),"Unable to leave a pane without any non-overlay price scale"),new I.MoveToNewPriceScaleUndoCommand(this._model,this._study,i,"overlay",null).redo();break;case"as-series":(0,s.assert)(i===t,"Study should be on the main pane"),new I.MoveToExistingPriceScaleUndoCommand(this._model,this._study,i,this._model.mainSeries().priceScale(),null).redo();break;case"new-left":new I.MoveToNewPriceScaleUndoCommand(this._model,this._study,i,"left",null).redo();break;case"new-right":new I.MoveToNewPriceScaleUndoCommand(this._model,this._study,i,"right",null).redo();break;default:const r=this._model.dataSourceForId(e);if(null===r)throw new Error(`There is no study with entityId='${e}'`);const n=i===this._model.paneForSource(r);(0,s.assert)(n,"Both studies should be on the same pane") +return this._pane.containsMainSeries()}getLeftPriceScales(){return this._pane.leftPriceScales().map(this._getPriceScaleApi,this)}getRightPriceScales(){return this._pane.rightPriceScales().map(this._getPriceScaleApi,this)}getMainSourcePriceScale(){const e=this._pane.mainDataSource();if(null===e)return null;const t=e.priceScale();return null===t||this._pane.isOverlay(e)?null:this._getPriceScaleApi(t)}setMaximized(e){if(this._pane.maximized().value()!==e)for(const e of this._chartWidget.paneWidgets())if(e.state()===this._pane){this._chartWidget.toggleMaximizePane(e);break}}legendLoaded(){const e=this._chartWidget.paneByState(this._pane);return Boolean(e&&e.statusWidget())}getAllEntities(){const e=this._pane.model();return this._pane.sourcesByGroup().allIncludingHidden().map((t=>(0,g.entityForDataSource)(e,t))).filter(f.notNull).filter((e=>null!==e.name))}getHeight(){return this._pane.height()}setHeight(e){const t=this._chartWidget.model().model(),i=t.panes();(0,s.assert)(i.length>1,"Unable to change pane's height if there is only one pane");const r=i.indexOf(this._pane);(0,s.assert)(-1!==r,"Invalid pane index");const n=new y(t,r,e);this._chartWidget.model().undoHistory().pushUndoCommand(n)}moveTo(e){const t=this.paneIndex();t!==e&&((0,s.assert)(e>=0&&e{this._study.onStatusChanged().unsubscribeAll(this),this._study.onAboutToBeDestroyed().unsubscribeAll(this)})),this._study.onStatusChanged().subscribe(this,(e=>{switch(e.type){case k.StudyStatusType.Completed:this._onStudyCompleted.fire();break;case k.StudyStatusType.Error:this._onStudyError.fire()}}))}isUserEditEnabled(){return this._study.userEditEnabled()}setUserEditEnabled(e){this._study.setUserEditEnabled(e)}getInputsInfo(){return(0,D.getStudyInputsInfo)(this._study.metaInfo())} +getInputValues(){const e=this._study.inputs({symbolsForChartApi:!1,asObject:!0});return Object.keys(e).map((t=>{const i=e[t];return{id:t,value:(0,f.isObject)(i)?i.v:i}}))}getStyleInfo(){return(0,E.getStudyStylesInfo)(this._study.metaInfo())}getStyleValues(){const{styles:e,bands:t,filledAreas:i,palettes:s,graphics:r,ohlcPlots:n,filledAreasStyle:o}=this._study.properties().state();return{styles:e,bands:t,filledAreas:i,palettes:s,graphics:r,ohlcPlots:n,filledAreasStyle:o}}setInputValues(e){const t=this.getInputValues();for(const i of e){void 0!==t.find((e=>e.id===i.id))?this._study.properties().childs().inputs.childs()[i.id].setValue(i.value):console.warn(`There is no such input: "${i.id}"`)}}mergeUp(){this._model.isMergeUpAvailableForSource(this._study)&&new T.MergeUpUndoCommand(this._model,this._study,null).redo()}mergeDown(){this._model.isMergeDownAvailableForSource(this._study)&&new T.MergeDownUndoCommand(this._model,this._study,null).redo()}unmergeUp(){this._model.isUnmergeAvailableForSource(this._study)&&new x.UnmergeUpUndoCommand(this._model,this._study,null).redo()}unmergeDown(){this._model.isUnmergeAvailableForSource(this._study)&&new x.UnmergeDownUndoCommand(this._model,this._study,null).redo()}onDataLoaded(){return this._onStudyCompleted}onStudyError(){return this._onStudyError}mergeUpWithUndo(){this._model.isMergeUpAvailableForSource(this._study)&&this._undoModel.mergeSourceUp(this._study)}mergeDownWithUndo(){this._model.isMergeDownAvailableForSource(this._study)&&this._undoModel.mergeSourceDown(this._study)}unmergeUpWithUndo(){this._model.isUnmergeAvailableForSource(this._study)&&this._undoModel.unmergeSourceUp(this._study)}unmergeDownWithUndo(){this._model.isUnmergeAvailableForSource(this._study)&&this._undoModel.unmergeSourceDown(this._study)}priceScale(){return new m(this._undoModel,(0,s.ensureNotNull)(this._study.priceScale()))}symbolSource(){const e=(0,s.ensureNotNull)(this._study.symbolSource());return{symbol:e.symbol(),currencyId:e.currency(),unitId:e.unit()}}currency(){return this._study.currency()}changePriceScale(e){const t=(0,s.ensureNotNull)(this._model.paneForSource(this._model.mainSeries())),i=(0,s.ensureNotNull)(this._model.paneForSource(this._study));switch(e){case"no-scale":(0,s.assert)(i.actionNoScaleIsEnabled(this._study),"Unable to leave a pane without any non-overlay price scale"),new I.MoveToNewPriceScaleUndoCommand(this._model,this._study,i,"overlay",null).redo();break;case"as-series":(0,s.assert)(i===t,"Study should be on the main pane"),new I.MoveToExistingPriceScaleUndoCommand(this._model,this._study,i,this._model.mainSeries().priceScale(),null).redo();break;case"new-left":new I.MoveToNewPriceScaleUndoCommand(this._model,this._study,i,"left",null).redo();break;case"new-right":new I.MoveToNewPriceScaleUndoCommand(this._model,this._study,i,"right",null).redo();break;default:const r=this._model.dataSourceForId(e);if(null===r)throw new Error(`There is no study with entityId='${e}'`);const n=i===this._model.paneForSource(r);(0,s.assert)(n,"Both studies should be on the same pane") ;const o=(0,s.ensureNotNull)(r.priceScale()),a=(0,C.sourceNewCurrencyOnPinningToPriceScale)(this._study,o,this._model),l=(0,L.sourceNewUnitOnPinningToPriceScale)(this._study,o,this._model);new I.MoveToExistingPriceScaleUndoCommand(this._model,this._study,i,o,null).redo(),null!==a&&new P.SetPriceScaleCurrencyUndoCommand(o,a,this._undoModel.chartWidget(),null).redo(),null!==l&&new A.SetPriceScaleUnitUndoCommand(o,l,this._undoModel.chartWidget(),null).redo()}}isVisible(){return this._study.properties().childs().visible.value()}setVisible(e){this._study.properties().childs().visible.setValue(e)}bringToFront(){this._model.bringToFront([this._study])}sendToBack(){this._model.sendToBack([this._study])}applyOverrides(e){(0,a.applyOverridesToStudy)(this._study,e)}dataLength(){return this._study.status().type!==k.StudyStatusType.Completed?0:this._study.metaInfo().plots.length>0?this._study.data().size():this._model.mainSeries().bars().size()}isLoading(){return this._study.isLoading()}properties(){return this._study.properties()}async applyToEntireLayout(){const e=new M.ActionsProvider(this._chartWidget),t=(await e.contextMenuActionsForSources([this._study])).find((e=>"applyStudyToEntireLayout"===e.id));t&&t.execute()}status(){return{...this._study.status()}}title(){return this._study.title(w.TitleDisplayTarget.StatusLine)}symbolsResolved(){return this._study.symbolsResolved()}}var B=i(68582);class R{constructor(e,t){this._series=e,this._undoModel=t,this._model=t.model()}isUserEditEnabled(){return this._series.userEditEnabled()}setUserEditEnabled(e){this._series.setUserEditEnabled(e)}mergeUp(){this._model.isMergeUpAvailableForSource(this._series)&&new T.MergeUpUndoCommand(this._model,this._series,null).redo()}mergeDown(){this._model.isMergeDownAvailableForSource(this._series)&&new T.MergeDownUndoCommand(this._model,this._series,null).redo()}unmergeUp(){this._model.isUnmergeAvailableForSource(this._series)&&new x.UnmergeUpUndoCommand(this._model,this._series,null).redo()}unmergeDown(){this._model.isUnmergeAvailableForSource(this._series)&&new x.UnmergeDownUndoCommand(this._model,this._series,null).redo()}detachToRight(){new I.MoveToNewPriceScaleUndoCommand(this._model,this._series,this._pane(),"right",null).redo()}detachToLeft(){new I.MoveToNewPriceScaleUndoCommand(this._model,this._series,this._pane(),"left",null).redo()}detachNoScale(){new I.MoveToNewPriceScaleUndoCommand(this._model,this._series,this._pane(),"overlay",null).redo()}changePriceScale(e){const t=(0,s.ensureNotNull)(this._model.paneForSource(this._series));switch(e){case"new-left":new I.MoveToNewPriceScaleUndoCommand(this._model,this._series,t,"left",null).redo();break;case"new-right":new I.MoveToNewPriceScaleUndoCommand(this._model,this._series,t,"right",null).redo();break;case"no-scale":(0,s.assert)(t.actionNoScaleIsEnabled(this._series),"Unable to leave a pane without any non-overlay price scale"),new I.MoveToNewPriceScaleUndoCommand(this._model,this._series,t,"overlay",null).redo();break;default:const i=this._model.dataSourceForId(e) ;if(null===i)throw new Error(`There is no study with entityId='${e}'`);const r=this._model.paneForSource(i)===t;(0,s.assert)(r,"Study should be on the main pane");const n=(0,s.ensureNotNull)(i.priceScale());new I.MoveToExistingPriceScaleUndoCommand(this._model,this._series,t,n,null).redo()}}isVisible(){return this._series.properties().childs().visible.value()}setVisible(e){this._series.properties().childs().visible.setValue(e)}bringToFront(){this._model.bringToFront([this._series])}sendToBack(){this._model.sendToBack([this._series])}entityId(){return this._series.id()}chartStyleProperties(e){return this._series.properties().childs()[N(e)].state(["inputs","inputsInfo"])}setChartStyleProperties(e,t){this._series.properties().childs()[N(e)].mergeAndFire(t)}barsCount(){return this._series.bars().size()}symbolSource(){return{symbol:this._series.symbol(),currencyId:this._series.currency(),unitId:this._series.unit()}}isLoading(){return this._series.isLoading()}data(){return this._series.data()}priceScale(){return new m(this._undoModel,this._series.priceScale())}_pane(){return(0,s.ensureNotNull)(this._model.paneForSource(this._series))}}function N(e){switch(e){case 0:return"barStyle";case 1:return"candleStyle";case 2:return"lineStyle";case 14:return"lineWithMarkersStyle";case 15:return"steplineStyle";case 3:return"areaStyle";case 16:return"hlcAreaStyle";case 4:return"renkoStyle";case 5:return"kagiStyle";case 6:return"pnfStyle";case 7:return"pbStyle";case 8:return"haStyle";case 9:return"hollowCandleStyle";case 10:return"baselineStyle";case 11:return"rangeStyle";case 12:return"hiloStyle";case 13:return"columnStyle";default:(0,s.ensureNever)(e)}throw new Error(`unsupported chart style: ${e}`)}var O=i(32112),F=i(95367),W=i(610);function H(e,t){const i=()=>{e.completed().unsubscribe(null,s),t(!1)},s=()=>{e.error().unsubscribe(null,i),t(!0)};e.completed().subscribe(null,i,!0),e.error().subscribe(null,s,!0)}var z=i(21866),U=i(42856),j=i(88348),G=i(88913),q=i(66764),$=i(97145),Y=i(77475),K=i(5286),Z=i(80842);const X=new n.TranslatedString("change price to bar ratio",r.t(null,void 0,i(69510))),J=new n.TranslatedString("toggle lock scale",r.t(null,void 0,i(21203))),Q=new n.TranslatedString("change series style",r.t(null,void 0,i(53438)));class ee{constructor(e,t){this._visibleBarsChanged=new d.Delegate,this._crosshairMoved=new d.Delegate,this._dataSourceHovered=new d.Delegate,this._ranges=null,this._panes=new WeakMap,this._studies=new WeakMap,this._lineDataSources=new WeakMap,this._selectionApi=null,this._prevVisibleRange=null,this._prevHoveredSourceId=null,this._chartWidget=e,this._activateChart=t,this._timezoneApi=new _(e),this._chartWidget.withModel(this,(()=>{this._chartWidget.model().crossHairSource().moved().subscribe(this,this._onCrosshairMoved),this._chartWidget.model().model().hoveredSourceChanged().subscribe(this,this._onHoveredSourceChanged),this._chartWidget.model().timeScale().logicalRangeChanged().subscribe(this,this._onLogicalRangeChanged)})),this._widgetLinkingGroupIndex=e.linkingGroupIndex().spawn(), this._widgetLinkingGroupIndex.subscribe((e=>this._apiLinkingGroupIndex.setValue(e))),this._apiLinkingGroupIndex=new $.WatchedValue(this._widgetLinkingGroupIndex.value()),this._apiLinkingGroupIndex.subscribe((e=>{this._widgetLinkingGroupIndex.value()!==e&&(this._chartWidget.hasModel()?this._chartWidget.model().setLinkingGroupIndex(e):this._widgetLinkingGroupIndex.setValue(e))})),this._chartWidget.onAboutToBeDestroyed().subscribe(this,this._destroy,!0)}setActive(){this._activateChart()}getPriceToBarRatio(){return this._chartWidget.model().model().mainSeriesScaleRatioProperty().value()}setPriceToBarRatio(e,t){const i=this._chartWidget.model(),s=i.model(),r=s.mainSeriesScaleRatioProperty();(null==t?void 0:t.disableUndo)?new W.SetScaleRatioPropertiesCommand(r,e,null,s).redo():i.setScaleRatioProperty(r,e,X)}isPriceToBarRatioLocked(){return this._chartWidget.model().model().mainSeries().priceScale().isLockScale()}setPriceToBarRatioLocked(e,t){const i=this._chartWidget.model(),s=i.model(),r=s.mainSeries().priceScale();(null==t?void 0:t.disableUndo)?new F.SetPriceScaleModeCommand({lockScale:e},r,null,s).redo():i.setPriceScaleMode({lockScale:e},r,J)}id(){return this._chartWidget.id()}onDataLoaded(){return this._makeSubscriptionFromDelegate(this._chartWidget.model().mainSeries().dataEvents().completed())}onSymbolChanged(){return this._makeSubscriptionFromDelegate(this._chartWidget.model().mainSeries().dataEvents().symbolResolved())}onIntervalChanged(){return this._makeSubscriptionFromDelegate(this._chartWidget.model().mainSeries().onIntervalChanged())}onVisibleRangeChanged(){return this._makeSubscriptionFromDelegate(this._visibleBarsChanged)}onChartTypeChanged(){return this._makeSubscriptionFromDelegate(this._chartWidget.model().mainSeries().onStyleChanged())}onSeriesTimeframe(){return this._makeSubscriptionFromDelegate(this._chartWidget.model().mainSeries().dataEvents().seriesTimeFrame())}whenChartReady(e){this._chartWidget.withModel(this,e)}crossHairMoved(){return this._makeSubscriptionFromDelegate(this._crosshairMoved)}onHoveredSourceChanged(){return this._makeSubscriptionFromDelegate(this._dataSourceHovered)}setVisibleRange(e,t){return new Promise((i=>{this._chartWidget.setVisibleTimeRange(e.from,e.to,t,i)}))}setSymbol(e,t){(0,f.isFunction)(t)&&(t={dataReady:t});const{dataReady:i,doNotActivateChart:s}=t||{};if(e===this.symbol())return void(null==i||i());const r=e=>{!e&&i&&i()},n=this._chartWidget.model().mainSeries().dataEvents();i&&H(n,r),s||this._activateChart(),this._chartWidget.setSymbol(e)}setResolution(e,t){(0,f.isFunction)(t)&&(t={dataReady:t});const{dataReady:i,doNotActivateChart:s}=t||{};let r=o.Interval.normalize(e);if(null!==r&&(r=this._chartWidget.model().mainSeries().getSupportedResolution(r)),null===r||r===this.resolution())return void(null==i||i());const n=e=>{!e&&i&&i()},a=this._chartWidget.model().mainSeries().dataEvents();i&&H(a,n),s||this._activateChart(),this._chartWidget.setResolution(r)}setChartType(e,t){const i=this._chartWidget.model().mainSeries().properties().childs().style ;if(i.value()===e)return void(null==t||t());const s=e=>{!e&&t&&t()},r=this._chartWidget.model().mainSeries().dataEvents();t&&H(r,s),this._chartWidget.model().setChartStyleProperty(i,e,Q)}resetData(){this._chartWidget.model().mainSeries().rerequestData()}getBarsMarksSources(){return this._chartWidget.model().barsMarksSources()}getAllStudies(){return this._chartWidget.model().model().allStudies(!0).map(g.studyEntityInfo)}getAllPanesHeight(){const e=this._chartWidget.model().model().panes();if(this._chartWidget.isMaximizedPane()){let t=0,i=0;e.forEach((e=>{t+=e.height(),i+=e.stretchFactor()}));const s=i/t;return e.map((e=>Math.round(e.stretchFactor()/s*100)/100))}return e.map((e=>e.height()))}setAllPanesHeight(e){const t=this._chartWidget.model().model(),i=t.panes();(0,s.assert)(i.length===e.length,"There`s a mismatch between the number of heights you provided and the number of panes.");const r=i.reduce(((e,t)=>e+t.stretchFactor()),0)/e.reduce(((e,t)=>e+t));e.forEach(((e,t)=>{const s=e*r;i[t].setStretchFactor(s)})),t.fullUpdate()}maximizeChart(){this._chartWidget.requestFullscreen()}isMaximized(){return this._chartWidget.inFullscreen()}restoreChart(){this._chartWidget.exitFullscreen()}sessions(){return this._chartWidget.model().model().sessions()}chartModel(){return this._chartWidget.model().model()}getTimeScaleLogicalRange(){return this._chartWidget.model().timeScale().logicalRange()}createStudy(e,t,i,s,r,n){if("function"==typeof r)return console.warn('"createStudy" does not take "callback" parameter anymore'),Promise.resolve(null);if(n=n||{},"string"!=typeof e)return this._createStudy(e);if(n.checkLimit&&!this._chartWidget.model().canCreateStudy())return(0,z.showTooManyStudiesNotice)(),Promise.resolve(null);e=e.toLowerCase();const o=n.disableUndo?this._chartWidget.model().model():this._chartWidget.model(),l=U.StudyMetaInfo.findStudyMetaInfoByDescription(o.studiesMetaData(),e),c=o.createStudyInserter({type:"java",studyId:l.id},[]);if(c.setForceOverlay(!!t),n.priceScale&&c.setPreferredPriceScale(function(e){switch(e){case"no-scale":return"overlay";case"as-series":return"as-series";case"new-left":return"left";case"new-right":return"right";default:throw new Error('The pricescale "'+e+'" is invalid, the only valid options are "no-scale", "as-series", "new-left" and "new-right".')}}(n.priceScale)),n.allowChangeCurrency&&c.setAllowChangeCurrency(!0),n.allowChangeUnit&&c.setAllowChangeUnit(!0),Array.isArray(s)){console.warn("Passing study inputs as an ordered array is now deprecated. Please use an object where keys correspond to the inputs of your study instead.");const e={};for(let t=0;tPromise.resolve({inputs:s||{},parentSources:[]}))).then((e=>(r&&(0,a.applyOverridesToStudy)(e,r),i&&e.setUserEditEnabled(!1),e.id())))}getStudyById(e){const t=this._chartWidget.model().model().getStudyById(e);if(null===t)throw new Error("There is no such study");return this._getStudyApi(t)}getSeries(){const e=this._chartWidget.model(),t=e.mainSeries();return new R(t,e)} getShapeById(e){const t=this._chartWidget.model().model().getLineToolById(e);if(null===t)throw new Error("There is no such shape");return this._getLineDataSourceApi(t)}selection(){return null===this._selectionApi&&(this._selectionApi=new O.SelectionApi(this._chartWidget.model().model())),this._selectionApi}symbol(){return this._chartWidget.symbolWV().value()}symbolExt(){const e=this._chartWidget.model().mainSeries().symbolInfo();return null===e?null:{symbol:e.name,full_name:e.full_name,exchange:e.exchange,description:e.description,type:e.type,pro_name:e.pro_name,typespecs:e.typespecs,delay:e.delay}}resolution(){return this._chartWidget.model().mainSeries().interval()}marketStatus(){return this._chartWidget.model().mainSeries().marketStatusModel().status().spawn()}getVisibleRange(){const e={from:0,to:0},t=this._chartWidget.model().timeScale(),i=t.visibleBarsStrictRange();if(null===i)return e;const r=i.firstBar(),n=i.lastBar(),o=this._convertIndexToPublicTime(n);if(null===o)return e;const a=Math.max((0,s.ensureNotNull)(t.points().range().value()).firstIndex,r);return e.from=(0,s.ensureNotNull)(this._convertIndexToPublicTime(a)),e.to=o,e}getTimezoneApi(){return this._timezoneApi}getPanes(){return this._chartWidget.model().model().panes().map((e=>this._getPaneApi(e)))}exportData(e){const t={...e};return void 0!==t.from&&(t.from=this._convertTimeFromPublic(t.from)),void 0!==t.to&&(t.to=this._convertTimeFromPublic(t.to)),i.e(9498).then(i.bind(i,50210)).then((e=>e.exportData(this._chartWidget.model().model(),t)))}isSelectBarRequested(){return this._chartWidget.selectPointMode().value()!==j.SelectPointMode.None}barTimeToEndOfPeriod(e){const t=this._prepareEndOfPeriodArgs();return(0,c.barTimeToEndOfPeriod)(t.barBuilder,e,t.intervalObj)}endOfPeriodToBarTime(e){const t=this._prepareEndOfPeriodArgs();return(0,c.endOfPeriodToBarTime)(t.barBuilder,e,t.intervalObj)}createAnchoredShape(e,t){if(!0!==G.supportedLineTools[t.shape].isAnchored)return console.warn(`${t.shape} is not an anchored shape. It can be created using createShape or createMultipointShape`),null;const i=this._chartWidget.model().model(),s=i.mainSeries();if(i.timeScale().isEmpty())return null;const r=void 0!==t.ownerStudyId?i.dataSourceForId(t.ownerStudyId):s,n=this._convertPositionPercentToPricedPoint(e,r);return null===n?null:this.createMultipointShape([n],t)}properties(){return this._chartWidget.properties()}setBarSpacing(e){this._chartWidget.model().timeScale().setBarSpacing(e)}scrollChartByBar(e){this._chartWidget.model().scrollChartByBar(e)}mergeAllScales(e){this._chartWidget.model().mergeAllScales(e)}chartPainted(){return this._chartWidget.chartPainted()}applyOverrides(e){this._chartWidget.applyOverrides(e)}addOverlayStudy(e,t,i){return this._chartWidget.addOverlayStudy(e,t,i)}lineToolsSynchronizer(){return this._chartWidget.lineToolsSynchronizer()}cloneLineTool(e){const t=this._chartWidget.model(),i=t.model().dataSourceForId(e);t.cloneLineTools([i],!1)}shareLineTools(e,t){const i=this._chartWidget.model(),s=e.map((e=>i.model().dataSourceForId(e))) ;i.shareLineTools(s,t)}linkingGroupIndex(){return this._apiLinkingGroupIndex.spawn()}ranges(){throw new Error("not implemented")}getTimeScale(){return new h(this._chartWidget.model().timeScale())}async loadChartTemplate(e){await(0,K.loadTheme)(this._chartWidget.chartWidgetCollection(),{themeName:e,standardTheme:!1,noUndo:!1,onlyActiveChart:!0})}setTimeFrame(e){this.setActive(),this._chartWidget.loadRange(e)}_destroy(){this._chartWidget.hasModel()&&(this._chartWidget.model().crossHairSource().moved().unsubscribeAll(this),this._chartWidget.model().timeScale().logicalRangeChanged().unsubscribe(this,this._onLogicalRangeChanged)),this._widgetLinkingGroupIndex.destroy()}_createStudy(e){return Promise.reject("Pine Script™ and java studies are not supported")}_convertTimeToPublic(e){return this._getTimeConverter().convertInternalTimeToPublicTime(e)}_convertIndexToPublicTime(e){return null===this._chartWidget.model().mainSeries().symbolInfo()?null:this._getTimeConverter().convertTimePointIndexToPublicTime(e)}_getDefaultCreateMultipointShapeOptions(){return{filled:!0}}_convertPositionPercentToPricedPoint(e,t){const i=this._chartWidget.model().timeScale(),s=t.priceScale(),r=t.firstValue();if(null==r||!isFinite(r)||null===s)return null;const n=i.coordinateToIndex(e.x*i.width()),o=i.indexToTimePoint(n);if(null===o)return null;return{price:s.coordinateToPrice(e.y*s.height(),r),time:o}}_convertUserPointsToDataSource(e){const t=this._chartWidget.model().model(),i=t.mainSeries(),r=t.timeScale().points(),n=i.data();if(t.timeScale().isEmpty())return null;const o=e.map((e=>e.time||0)),a=this._alignPoints(o),l=(e,t,o)=>{const a=r.closestIndexLeft(e)||0,l={index:a,price:NaN},c=(0,s.ensureNotNull)(r.valueAt(a)),h=(0,s.ensureNotNull)(r.range().value());if(e>c&&a===h.lastIndex){const t=(0,s.ensureNotNull)(i.syncModel()).distance(c,e);t.success&&(l.index=l.index+t.result)}else if(ee.visible()&&0!==e.title().length)).map((e=>({title:e.title(),value:e.value()})));h.entityValues[t.id()]={isHovered:s,values:r,title:i.header()}}this._crosshairMoved.fire(h)}_makeSubscriptionFromDelegate(e){return{subscribe:e.subscribe.bind(e),unsubscribe:e.unsubscribe.bind(e),unsubscribeAll:e.unsubscribeAll.bind(e)}}_prepareEndOfPeriodArgs(){const e=this._chartWidget.model().model(),t=e.timezone(),i=(0,s.ensureNotNull)(e.mainSeries().symbolInfo()),r=e.mainSeries().interval(),n=new l.SessionInfo(t,i.session,i.session_holidays,i.corrections);return{barBuilder:(0,l.newBarBuilder)(r,n,n),intervalObj:o.Interval.parse(r)}}_getPaneApi(e){let t=this._panes.get(e);return void 0===t&&(t=new b(e,this._chartWidget),this._panes.set(e,t)),t}_getStudyApi(e){let t=this._studies.get(e);return void 0===t&&(t=new E(e,this._chartWidget),this._studies.set(e,t)),t}_getLineDataSourceApi(e){let t=this._lineDataSources.get(e);return void 0===t&&(t=new B.LineDataSourceApi(e,this._chartWidget.model(),{apiPointsToDataSource:this._convertUserPointsToDataSource.bind(this),dataSourcePointsToPriced:e=>{const t=(0,s.ensureNotNull)(this._chartWidget.model().mainSeries().syncModel()),i=this._chartWidget.model().timeScale();return e.map((e=>{const s=i.normalizeBarIndex(e.index);return{price:e.price,time:this._convertTimeToPublic(t.projectTime(s.time_t,s.offset))}}))}}),this._lineDataSources.set(e,t)),t}_alignPoints(e){const t=this._chartWidget.model().model(),i=t.mainSeries(),s=i.interval(),r=i.symbolInfo();if(t.timeScale().isEmpty()||!o.Interval.isDWM(s)||null===r)return e;const n=(0,Y.createDwmAligner)(s,r);return null===n?e:e.map((e=>n.timeToSessionStart(1e3*e)/1e3))}_onLogicalRangeChanged(){const e=this._chartWidget.model().mainSeries(),t=e.data().isEmpty();if(null!==this._chartWidget.model().timeScale().visibleBarsStrictRange()&&t)return void e.dataEvents().completed().subscribe(this,this._onLogicalRangeChanged,!0);const i=this.getVisibleRange();null!==this._prevVisibleRange&&(0,f.deepEquals)(this._prevVisibleRange,i)[0]||(this._prevVisibleRange=i,this._visibleBarsChanged.fire(i))}}},66764:(e,t,i)=>{"use strict";i.d(t,{getChartWidgetApiTimeConverter:()=>o});var s=i(50151),r=i(77475);const n=new Map;function o(e,t,i){const s=function(e,t){return e+t.session+t.timezone+(t.corrections||"")+(t.session_holidays||"")}(e,t);let o=n.get(s);return void 0!==o||(o=new a((0,r.createDwmAligner)(e,t),i), +;const r=this._chartWidget.offsetInDocument(s),n=this.chartModel().timeScale(),o=null===(t=s.mainDataSource())||void 0===t?void 0:t.priceScale(),a=n.indexToUserTime(e.index),l=n.indexToCoordinate(e.index),c=null==o?void 0:o.priceToCoordinate(e.price,(null===(i=s.mainDataSource())||void 0===i?void 0:i.firstValue())||0);if(void 0===l||void 0===c||null===a)return;const h={price:e.price,time:a.getTime()/1e3,entityValues:{},offsetX:l+r.left,offsetY:c+r.top},d=this.chartModel().priceDataSources();for(let e=0;ee.visible()&&0!==e.title().length)).map((e=>({title:e.title(),value:e.value()})));h.entityValues[t.id()]={isHovered:s,values:r,title:i.header()}}this._crosshairMoved.fire(h)}_makeSubscriptionFromDelegate(e){return{subscribe:e.subscribe.bind(e),unsubscribe:e.unsubscribe.bind(e),unsubscribeAll:e.unsubscribeAll.bind(e)}}_prepareEndOfPeriodArgs(){const e=this._chartWidget.model().model(),t=e.timezone(),i=(0,s.ensureNotNull)(e.mainSeries().symbolInfo()),r=e.mainSeries().interval(),n=new l.SessionInfo(t,i.session,i.session_holidays,i.corrections);return{barBuilder:(0,l.newBarBuilder)(r,n,n),intervalObj:o.Interval.parse(r)}}_getPaneApi(e){let t=this._panes.get(e);return void 0===t&&(t=new b(e,this._chartWidget),this._panes.set(e,t)),t}_getStudyApi(e){let t=this._studies.get(e);return void 0===t&&(t=new V(e,this._chartWidget),this._studies.set(e,t)),t}_getLineDataSourceApi(e){let t=this._lineDataSources.get(e);return void 0===t&&(t=new B.LineDataSourceApi(e,this._chartWidget.model(),{apiPointsToDataSource:this._convertUserPointsToDataSource.bind(this),dataSourcePointsToPriced:e=>{const t=(0,s.ensureNotNull)(this._chartWidget.model().mainSeries().syncModel()),i=this._chartWidget.model().timeScale();return e.map((e=>{const s=i.normalizeBarIndex(e.index);return{price:e.price,time:this._convertTimeToPublic(t.projectTime(s.time_t,s.offset))}}))}}),this._lineDataSources.set(e,t)),t}_alignPoints(e){const t=this._chartWidget.model().model(),i=t.mainSeries(),s=i.interval(),r=i.symbolInfo();if(t.timeScale().isEmpty()||!o.Interval.isDWM(s)||null===r)return e;const n=(0,Y.createDwmAligner)(s,r);return null===n?e:e.map((e=>n.timeToSessionStart(1e3*e)/1e3))}_onLogicalRangeChanged(){const e=this._chartWidget.model().mainSeries(),t=e.data().isEmpty();if(null!==this._chartWidget.model().timeScale().visibleBarsStrictRange()&&t)return void e.dataEvents().completed().subscribe(this,this._onLogicalRangeChanged,!0);const i=this.getVisibleRange();null!==this._prevVisibleRange&&(0,f.deepEquals)(this._prevVisibleRange,i)[0]||(this._prevVisibleRange=i,this._visibleBarsChanged.fire(i))}}},66764:(e,t,i)=>{"use strict";i.d(t,{getChartWidgetApiTimeConverter:()=>o});var s=i(50151),r=i(77475);const n=new Map;function o(e,t,i){const s=function(e,t){return e+t.session+t.timezone+(t.corrections||"")+(t.session_holidays||"")}(e,t);let o=n.get(s);return void 0!==o||(o=new a((0,r.createDwmAligner)(e,t),i), n.set(s,o)),o}class a{constructor(e,t){this._dwmAligner=e,this._chartModel=t}convertPublicTimeToInternalTime(e){return null!==this._dwmAligner?this._dwmAligner.timeToSessionStart(1e3*e)/1e3:e}convertInternalTimeToPublicTime(e){return null!==this._dwmAligner?this._dwmAligner.timeToExchangeTradingDay(1e3*e)/1e3:e}convertTimePointIndexToPublicTime(e){let t=this.convertTimePointIndexToInternalTime(e);return null!==t&&(t=this.convertInternalTimeToPublicTime(t)),t}convertTimePointIndexToInternalTime(e){const t=this._chartModel.timeScale();if(t.isEmpty())return null;const i=t.points(),{firstIndex:r,lastIndex:n}=(0,s.ensureNotNull)(i.range().value());let o=null;if(r<=e&&e<=n)o=i.valueAt(e);else if(e>n){const i=this._chartModel.mainSeries().syncModel();if(null!==i){const r=(0,s.ensureNotNull)(t.indexToTimePoint(n));o=i.projectTime(r,e-n)}}return o}}},94557:(e,t,i)=>{"use strict";i.d(t,{ChartWidgetBase:()=>Ui});var s=i(27714),r=i(50151),n=i(3343),o=i(44352),a=i(59224);function l(e,t){const i=Object.create(Object.getPrototypeOf(e));for(const s of t)Object.prototype.hasOwnProperty.call(e,s)&&(i[s]=e[s]);return i}var c=i(56840),h=i(49483),d=i(51608),u=i(76422),p=i(85067);let _;class m extends p.DialogRenderer{constructor(){super(),this._dialog=null,this._subscribe=e=>{this._setVisibility(e)}}show(){this._load().then((e=>e.show()))}hide(){var e;null===(e=this._dialog)||void 0===e||e.hide()}static getInstance(){return _||(_=new m),_}_load(){return Promise.all([i.e(2666),i.e(1013),i.e(3842),i.e(4015),i.e(5145),i.e(855),i.e(6),i.e(5993),i.e(5649),i.e(6221),i.e(8056),i.e(6752),i.e(8149),i.e(6106),i.e(1054),i.e(4387),i.e(962),i.e(8385),i.e(4062),i.e(3016),i.e(3179),i.e(5050),i.e(5711),i.e(4862)]).then(i.bind(i,67165)).then((e=>{var t,i;return null===(t=this._dialog)||void 0===t||t.hide(),null===(i=this._dialog)||void 0===i||i.visible().unsubscribe(this._subscribe),this._dialog=new e.ObjectTreeDialogRenderer,this._dialog.visible().subscribe(this._subscribe),this._dialog}))}}i(83135);var g=i(70027),f=i(58096);const v=(0,g.parseHtmlElement)(function(e=""){return`
`}());class S{constructor(e){this._shown=!1,this._el=v.cloneNode(!0),this.setSize(f.spinnerSizeMap[e||f.DEFAULT_SIZE])}spin(e){return this._el.classList.add("tv-spinner--shown"),void 0===this._container&&(this._container=e,void 0!==e&&e.appendChild(this._el)),this._shown=!0,this}stop(e){return e&&void 0!==this._container&&this._container.removeChild(this._el),this._el&&this._el.classList.remove("tv-spinner--shown"),this._shown=!1,this}setStyle(e){return Object.keys(e).forEach((t=>{const i=e[t];void 0!==i&&this._el.style.setProperty(t,i)})),this}style(){return this._el.style}setSize(e){const t=void 0!==e?`tv-spinner--size_${e}`:"";return this._el.className=`tv-spinner ${t} ${this._shown?"tv-spinner--shown":""}`,this}getEl(){return this._el}destroy(){this.stop(),delete this._el,delete this._container}}var y=i(1722),b=i(97906),w=i(74007),P=i(94792);var C=i(39347),x=i(42856),T=i(97087),I=i(18923);const M=(0, a.getLogger)("Chart.Studies.StudyMetaInfoRepository",{color:"#606"});class L{constructor(e){this._nextRequestNumber=1,this._rawStudiesMetaInfo=[],this._isReady=!1,this._metaInfoQueryQueue=[],this._javaMetaInfoQueryQueue=[],this._javaStudiesMetaInfo=[],this._pineMetaInfoCache=[],this._studiesMigrations=[],this._gateway=e}requestMetaInfo(){this._requestStarted();const e=this._makeNextRequestId();return M.logNormal(`Requesting metainfo #${e}`),new Promise((t=>{M.logNormal(`Requesting studies metadata #${e}`),this._gateway.requestMetadata(e,(i=>{M.logNormal(`Requesting studies metadata #${e} finished`);const s=i.params[1].metainfo.slice();this._processLibraryMetaInfo(s),this._requestFinished(),t()}))}))}findById(e){if(!this._isReady)return this._enqueueMetaInfoQuery(e);const t=this._findStudyMetaInfo(e);return null!==t?Promise.resolve(t):"pine"===e.type?this._compilePine(e):Promise.reject(`unexpected study id=${e.studyId} with type=${e.type}`)}findByIdSync(e){return this._findStudyMetaInfo(e)}isReady(){return this._isReady}findAllJavaStudies(){return this._isReady?Promise.resolve(this._javaStudiesMetaInfo):this._enqueueJavaMetaInfoQuery()}getInternalMetaInfoArray(){return this._javaStudiesMetaInfo}getMigrations(){return this._studiesMigrations}addPineMetaInfo(e){return k(this._pineMetaInfoCache,e)}async getLatestMetaInfoForPineStudy(e,t){return null}_processMigrations(e){throw new Error("not implemented")}_processSiteMetaInfo(e,t){throw new Error("not implemented")}_processLibraryMetaInfo(e){for(const t of e)A(t),k(this._javaStudiesMetaInfo,t);this._javaStudiesMetaInfo=this._javaStudiesMetaInfo.sort(((e,t)=>{const i=e.description_localized||e.description,s=t.description_localized||t.description;return i>s?1:i{this._metaInfoQueryQueue.push({studyDescriptor:e,resolver:t})}))}_enqueueJavaMetaInfoQuery(){return new Promise((e=>{this._javaMetaInfoQueryQueue.push({resolver:e})}))}_processPendingMetaInfoQueries(){for(;this._metaInfoQueryQueue.length;){const e=this._metaInfoQueryQueue.shift();this.findById(e.studyDescriptor).then(e.resolver)}}_processPendingFullMetaInfoQueries(){for(;this._javaMetaInfoQueryQueue.length;){this._javaMetaInfoQueryQueue.shift().resolver(this._javaStudiesMetaInfo)}}_findStudyMetaInfo(e){return"java"===e.type?this._javaStudiesMetaInfo.find((t=>t.id===e.studyId))||null:this._pineMetaInfoCache.find((t=>t.scriptIdPart===e.pineId&&(void 0===e.pineVersion||(0,r.ensureDefined)(t.pine).version===e.pineVersion)))||null}_makeNextRequestId(){return"metadata_"+this._nextRequestNumber++}_compilePine(e){throw new Error("unsupported")}}function A(e){e.description_localized=o.t(e.description,{context:"study"},i(68716))}function k(e,t){ -const i=new x.StudyMetaInfo(t);(0,T.migrateMetaInfoAndPropState)(i);let s=!0;const r=e.findIndex((e=>e.id===i.id));if(-1===r)e.push(i);else{const t=e[r],n=void 0!==t.pine?I.Version.parse(t.pine.version):null,o=void 0!==i.pine?I.Version.parse(i.pine.version):null;null===o||null===n||o.isGreaterOrEqual(n)?(t.removeDefaults(),e[r]=i):s=!1}return s&&i.createDefaults(),i}var D,V=i(92249),E=i(15367),B=i(28853),R=i(46100),N=i(91280),O=i(16230);!function(e){e.Default="default",e.Success="success",e.Warning="warning",e.Danger="danger"}(D||(D={}));var F=i(86441),W=i(48891),H=i(90995),z=i(36298),U=i(38325),j=i(30888),G=i(18807),q=i(67980),$=i(81155),Y=i(3587),K=i(88348),Z=i(68452),X=i(42184),J=i(74359),Q=i(68441),ee=i(29764),te=i(5286),ie=i(7983),se=i(49668),re=i(46501);const ne=parseInt(se.labelheight),oe=parseInt(se.bottommargin);function ae(e){return e/11}class le{constructor(){this._wrapper=document.createElement("div"),this._element=document.createElement("div"),this._labelElement=document.createElement("div"),this._gearElement=document.createElement("div"),this._currentScale=1,this._info=null,this._mode="auto",this._wrapper.appendChild(this._element),this._wrapper.classList.add(se.wrapper),this._element.classList.add(se.label),this._labelElement.className=se.symbol,this._element.appendChild(this._labelElement),this._gearElement.className=se.gear,this._gearElement.innerHTML=ie,this._element.appendChild(this._gearElement)}getElement(){return this._wrapper}setMode(e){this._mode!==e&&(this._mode=e)}align(e,t){const i=ae(t);Math.abs(i-this._currentScale)>.1&&(this._currentScale=i,Math.abs(this._currentScale-1)>.1?this._element.style.transform=`scale(${this._currentScale})`:(this._currentScale=1,this._element.style.transform=""))}drawLabelForScreenshot(e,t){if(null===this._info||"gear"===this._mode)return;const i=(0,ee.makeFont)(t.fontSize,re.CHART_FONT_FAMILY);e.fillStyle=te.themes[t.theme].getThemedColor("color-price-axis-label-back"),e.globalAlpha=.5,e.beginPath();const s=ae(t.fontSize)*ne/2,r=(0,F.point)(t.offset+t.width/2,t.height/2);e.arc(r.x,r.y,s,0,2*Math.PI,!0),e.fill(),e.globalAlpha=1,e.fillStyle=te.themes[t.theme].getThemedColor("color-price-axis-label-text"),e.textAlign="center",e.font=i,e.textBaseline="middle",e.fillText(this._info.label,r.x,r.y)}setAxisNameInfo(e){this._info=e,null!==e&&(this._labelElement.textContent=e.label)}static height(e){return(ne+oe)*e}}var ce=i(57898),he=i(10643),de=i(94194);const ue={enableTooltip:!0,showLabels:!0,enableMenu:!0,enableHighlight:!0};class pe{constructor(e,t,i,r,n,o=null){this._invalidated=!0,this._size=(0,s.size)({width:0,height:0}),this._offset=0,this._axisInfo=null,this._onLabelHovered=new ce.Delegate,this._highlighted=!1,this._labelMode="auto",this._fixedLabelMode=null,this._canvasConfiguredHandler=()=>this.update(),this._timeAxisWidget=o,this._isLeft="left"===e,this._rendererOptionsProvider=r.rendererOptionsProvider,this._sourcesTitlesProvider=r.sourcesTitlesProvider,this._contextMenuItemsProvider=r.contextMenuItemsProvider, +const i=new x.StudyMetaInfo(t);(0,T.migrateMetaInfoAndPropState)(i);let s=!0;const r=e.findIndex((e=>e.id===i.id));if(-1===r)e.push(i);else{const t=e[r],n=void 0!==t.pine?I.Version.parse(t.pine.version):null,o=void 0!==i.pine?I.Version.parse(i.pine.version):null;null===o||null===n||o.isGreaterOrEqual(n)?(t.removeDefaults(),e[r]=i):s=!1}return s&&i.createDefaults(),i}var D,E=i(92249),V=i(15367),B=i(28853),R=i(46100),N=i(91280),O=i(16230);!function(e){e.Default="default",e.Success="success",e.Warning="warning",e.Danger="danger"}(D||(D={}));var F=i(86441),W=i(48891),H=i(90995),z=i(36298),U=i(38325),j=i(30888),G=i(18807),q=i(67980),$=i(81155),Y=i(3587),K=i(88348),Z=i(68452),X=i(42184),J=i(74359),Q=i(68441),ee=i(29764),te=i(5286),ie=i(7983),se=i(49668),re=i(46501);const ne=parseInt(se.labelheight),oe=parseInt(se.bottommargin);function ae(e){return e/11}class le{constructor(){this._wrapper=document.createElement("div"),this._element=document.createElement("div"),this._labelElement=document.createElement("div"),this._gearElement=document.createElement("div"),this._currentScale=1,this._info=null,this._mode="auto",this._wrapper.appendChild(this._element),this._wrapper.classList.add(se.wrapper),this._element.classList.add(se.label),this._labelElement.className=se.symbol,this._element.appendChild(this._labelElement),this._gearElement.className=se.gear,this._gearElement.innerHTML=ie,this._element.appendChild(this._gearElement)}getElement(){return this._wrapper}setMode(e){this._mode!==e&&(this._mode=e)}align(e,t){const i=ae(t);Math.abs(i-this._currentScale)>.1&&(this._currentScale=i,Math.abs(this._currentScale-1)>.1?this._element.style.transform=`scale(${this._currentScale})`:(this._currentScale=1,this._element.style.transform=""))}drawLabelForScreenshot(e,t){if(null===this._info||"gear"===this._mode)return;const i=(0,ee.makeFont)(t.fontSize,re.CHART_FONT_FAMILY);e.fillStyle=te.themes[t.theme].getThemedColor("color-price-axis-label-back"),e.globalAlpha=.5,e.beginPath();const s=ae(t.fontSize)*ne/2,r=(0,F.point)(t.offset+t.width/2,t.height/2);e.arc(r.x,r.y,s,0,2*Math.PI,!0),e.fill(),e.globalAlpha=1,e.fillStyle=te.themes[t.theme].getThemedColor("color-price-axis-label-text"),e.textAlign="center",e.font=i,e.textBaseline="middle",e.fillText(this._info.label,r.x,r.y)}setAxisNameInfo(e){this._info=e,null!==e&&(this._labelElement.textContent=e.label)}static height(e){return(ne+oe)*e}}var ce=i(57898),he=i(10643),de=i(94194);const ue={enableTooltip:!0,showLabels:!0,enableMenu:!0,enableHighlight:!0};class pe{constructor(e,t,i,r,n,o=null){this._invalidated=!0,this._size=(0,s.size)({width:0,height:0}),this._offset=0,this._axisInfo=null,this._onLabelHovered=new ce.Delegate,this._highlighted=!1,this._labelMode="auto",this._fixedLabelMode=null,this._canvasConfiguredHandler=()=>this.update(),this._timeAxisWidget=o,this._isLeft="left"===e,this._rendererOptionsProvider=r.rendererOptionsProvider,this._sourcesTitlesProvider=r.sourcesTitlesProvider,this._contextMenuItemsProvider=r.contextMenuItemsProvider, this._backgroundBasedTheme=r.backgroundBasedTheme,this._getBackgroundTopColor=r.getBackgroundTopColor,this._getBackgroundBottomColor=r.getBackgroundBottomColor,this._showHorizontalBorder=Boolean(r.showHorizontalBorder),this._properties=t,this._axisInfo=i,this._labelOptions={...ue,...n},this._properties.lineColor.subscribe(this,this._onPropertyChanged),this._cell=document.createElement("div"),this._cell.classList.add(se["price-axis-stub"]),this._labelOptions.enableTooltip&&this._cell.classList.add("apply-common-tooltip"),this._cell.style.width="25px",this._cell.style.height="100%",this._cell.style.position="absolute",this._cell.style.left="0",this._cell.style.overflow="hidden",this._labelOptions.showLabels?(this._label=new le,this._label.setAxisNameInfo(this._axisInfo),this._cell.appendChild(this._label.getElement()),this._labelOptions.enableTooltip&&(0,de.setTooltipData)(this._cell,"text",(e=>this._tooltipContent()))):this._label=null,this._mouseEventHandler=new X.MouseEventHandler(this._cell,this,{treatHorzTouchDragAsPageScroll:!0,treatVertTouchDragAsPageScroll:!0}),this._canvasBinding=(0,J.createBoundCanvas)(this._cell,(0,s.size)({width:16,height:16})),this._canvasBinding.subscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler);const a=this._canvasBinding.canvasElement;a.style.position="absolute",a.style.left="0",a.style.top="0"}destroy(){this._canvasBinding.unsubscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler),this._canvasBinding.dispose(),this._properties.lineColor.unsubscribe(this,this._onPropertyChanged),this._mouseEventHandler.destroy()}mouseEnterEvent(e){this._mouseOrTouchEnterEvent(e)}touchStartEvent(e){this._mouseOrTouchEnterEvent(e)}mouseLeaveEvent(e){this._mouseOrTouchLeaveEvent(e)}touchEndEvent(e){this._mouseOrTouchLeaveEvent(e)}mouseClickEvent(e){this._mouseClickOrTapEvent(e)}tapEvent(e){this._mouseClickOrTapEvent(e)}update(){}getElement(){return this._cell}onLabelHovered(){return this._onLabelHovered}setSizeAndOffset(e,t){(0,s.equalSizes)(this._size,e)||(this._size=e,this._canvasBinding.resizeCanvasElement(e),this._cell.style.width=`${e.width}px`,this._cell.style.minWidth=`${e.width}px`,this._cell.style.height=`${e.height}px`,this._invalidated=!0),this._offset!==t&&(this._offset=t,this._cell.style.left=`${t}px`)}paint(e){if(e{this.setLabelMode((0,r.ensureNotNull)(this._fixedLabelMode)),this._fixedLabelMode=null}))}}var _e=i(10688);class me{constructor(e,t,i,r,n,o=null){this._axises=[],this._stubs=[],this._size=(0,s.size)({width:0,height:0}),this._onLabelHovered=new ce.Delegate,this._scalesProperties=e, this._priceAxisWidgetFactory=i,this._timeAxisWidget=o,this._rendererOptionsProvider=r.rendererOptionsProvider,this._titlesProvider=r.titlesProvider,this._stubContextMenuProvider=r.stubContextMenuProvider,this._backgroundBasedTheme=r.backgroundBasedTheme,this._getBackgroundTopColor=r.getBackgroundTopColor,this._getBackgroundBottomColor=r.getBackgroundBottomColor,this._showHorisontalBorder=Boolean(r.showHorizontalBorder),this._labelsOptions={...ue,...n};const a=this._scalesProperties.childs();this._stubProperties={lineColor:a.lineColor,fontSize:a.fontSize},this._side=t,this._cell=document.createElement("td"),this._cell.classList.add("chart-markup-table","price-axis-container"),this._cell.style.width="25px",this._cell.style.position="relative"}destroy(){this.setScales([],0,0,0)}onLabelHovered(){return this._onLabelHovered}setScales(e,t,i,s){for(;e.length>this._axises.length&&this._axises.lengtho;){const e=(0,r.ensureDefined)(this._stubs.pop());e.onLabelHovered().unsubscribeAll(this),this._cell.removeChild(e.getElement()),e.destroy()}for(;this._stubs.length{this._labelsOptions.showLabels&&this._labelsOptions.enableHighlight&&this._onLabelHovered.fire({owner:t,axis:(0,r.ensureNotNull)(e)},i)})),this._stubs.push(t),this._cell.appendChild(t.getElement())}const a=this._labelsOptions.enableMenu;1===s?this._stubs.forEach(((e,t)=>e.setLabelMode(a?"gear":"symbol"))):this._stubs.forEach(((e,t)=>e.setLabelMode(te.updateCurrencyLabel()))}optimalWidths(){return this._axises.map((e=>e.optimalWidth()))}setSizes(e,t){this._size=(0,s.size)({width:t.reduce(((e,t)=>e+t),0),height:e}),this._cell.style.width=this._size.width+"px",this._cell.style.minWidth=this._size.width+"px",this._cell.style.height=this._size.height+"px",t.length!==this._axises.length+this._stubs.length&&(0,r.assert)(t.length===this._axises.length+this._stubs.length,"Widgets count should be the same as widths one");let i=0;this._forEachWidgetFromLeft(((r,n)=>{const o=t[n];r.setSizeAndOffset((0,s.size)({width:o,height:e}),i),i+=o}))}update(){this._axises.forEach((e=>e.update())),this._stubs.forEach((e=>e.update()))}paint(e){this._axises.forEach(((t,i)=>t.paint(e(i)))), this._stubs.forEach(((t,i)=>t.paint(e(i))))}paintStubs(e){this._stubs.forEach((t=>t.paint(e)))}restoreDefaultCursor(){this._axises.forEach((e=>e.restoreDefaultCursor()))}getWidth(){return this._size.width}findAxisWidgetForScale(e){const t=this._axises.find((t=>t.priceScale()===e));return void 0===t?null:t}getScreenshotData(){const e=this._getImage();return{canvas:e,content:e.toDataURL(),contentHeight:this._size.height,contentWidth:this._size.width}}getImage(){return this._getImage()}slotsCount(){return this._axises.length+this._stubs.length}highlightPriceAxisByLabel(e){this._axises.forEach((t=>{const i=t.axisInfo();t.setHighlighted(null!==i&&i.equals(e))}))}axes(){return this._axises}_stubParams(e){return{rendererOptionsProvider:this._rendererOptionsProvider,backgroundBasedTheme:this._backgroundBasedTheme,sourcesTitlesProvider:()=>this._titlesProvider(this._side,e),contextMenuItemsProvider:()=>this._stubContextMenuProvider(this._side,e),getBackgroundTopColor:this._getBackgroundTopColor,getBackgroundBottomColor:this._getBackgroundBottomColor,showHorizontalBorder:this._showHorisontalBorder}}_getImage(){const e=(0,J.createDisconnectedCanvas)(document,this._size),t=(0,J.getPrescaledContext2D)(e);let i=0;return this._forEachWidgetFromLeft(((e,s)=>{const r=e.getWidth();0!==r&&0!==this._size.height&&(t.drawImage(e.getImage(),i,0,r,this._size.height),i+=r)})),e}_forEachWidgetFromLeft(e){const t=[...this._axises,...this._stubs],i="left"===this._side,s=i?-1:t.length,r=i?-1:1;for(let n=i?t.length-1:0;n!==s;n+=r)e(t[n],n,t)}}var ge=i(31964),fe=i(97145),ve=i(34565),Se=i(51768),ye=i(37160),be=i(55824),we=i(60682);class Pe{constructor(){this._width=null,this._currencyInfo=null,this._unitInfo=null,this._measureUnitIdInfo=null,this._fontSize=0,this._currencyAndUnitLabelsWrapper=document.createElement("div"),this._currencyAndUnitLabelsWrapper.className=we["price-axis-currency-label-wrapper"],this._currencyAndUnitLabelsWrapper.setAttribute("data-name","currency-unit-label-wrapper"),this._controlsContainer=document.createElement("div"),this._controlsContainer.className=we["price-axis-currency-label"],this._currencyAndUnitLabelsWrapper.appendChild(this._controlsContainer),this._currencyLabelDiv=document.createElement("div"),this._currencyLabelDiv.className=we.row,this._currencyLabelDiv.classList.add("apply-common-tooltip"),(0,de.setTooltipData)(this._currencyLabelDiv,"text",(e=>this._currencyTooltipContent())),this._currencyText=document.createElement("div"),this._currencyText.className=we["price-axis-currency-label-text"],this._currencyLabelDiv.appendChild(this._currencyText),this._currencyArrowDown=document.createElement("div"),this._currencyArrowDown.className=we["price-axis-currency-label-arrow-down"],this._currencyArrowDown.innerHTML=be,this._currencyLabelDiv.appendChild(this._currencyArrowDown),this._measureUnitIdLabelDiv=document.createElement("div"),this._measureUnitIdLabelDiv.className=we.row,this._measureUnitIdLabelDiv.classList.add("apply-common-tooltip"),this._measureUnitIdLabelDiv.classList.add("readonly"),(0, de.setTooltipData)(this._measureUnitIdLabelDiv,"text",(e=>this._measureUnitIdTooltipContent())),this._measureUnitIdText=document.createElement("div"),this._measureUnitIdText.className=we["price-axis-currency-label-text"],this._measureUnitIdLabelDiv.appendChild(this._measureUnitIdText),this._unitLabelDiv=document.createElement("div"),this._unitLabelDiv.className=we.row,this._unitLabelDiv.classList.add("apply-common-tooltip"),(0,de.setTooltipData)(this._unitLabelDiv,"text",(e=>this._unitTooltipContent())),this._unitText=document.createElement("div"),this._unitText.className=we["price-axis-currency-label-text"],this._unitLabelDiv.appendChild(this._unitText),this._unitArrowDown=document.createElement("div"),this._unitArrowDown.className=we["price-axis-currency-label-arrow-down"],this._unitArrowDown.innerHTML=be,this._unitLabelDiv.appendChild(this._unitArrowDown),this._controlsContainer.appendChild(this._currencyLabelDiv),this._controlsContainer.appendChild(this._measureUnitIdLabelDiv),this._controlsContainer.appendChild(this._unitLabelDiv),this.disableCurrency(),this.disableUnit()}element(){return this._currencyAndUnitLabelsWrapper}currencyLabelElement(){return this._currencyLabelDiv}unitLabelElement(){return this._unitLabelDiv}isEnabled(){return this.currencyLabelEnabled()||this.unitLabelEnabled()||this.measureUnitIdLableEnabled()}setCurrencyExpanded(e){this._currencyLabelDiv.classList.toggle(we.expanded,e)}setUnitExpanded(e){this._unitLabelDiv.classList.toggle(we.expanded,e)}width(){if(null!==this._width)return this._width;let e=0;if(this.currencyLabelEnabled()){const t=this._currencyText.getBoundingClientRect(),i=this._currencyArrowDown.getBoundingClientRect();e=Math.max(e,t.width+i.width+2*this._textMarginAndPadding())}if(this.measureUnitIdLableEnabled()){const t=this._measureUnitIdText.getBoundingClientRect();e=Math.max(e,t.width+2*this._textMarginAndPadding())}if(this.unitLabelEnabled()){const t=this._unitText.getBoundingClientRect(),i=this._unitArrowDown.getBoundingClientRect();e=Math.max(e,t.width+i.width+2*this._textMarginAndPadding())}return this._width=e}drawLabel(e,t,i){var s,r,n;if(!this.isEnabled())return;const o=Math.round(Number(we.css_wrapper_margin)*i),a=(0,ye.ceiledEven)(t*i)-2*o,l=Math.round(this.labelBottom()*i),c=Math.round(Number(we.css_value_currency_label_radius)*i);e.fillStyle=getComputedStyle(this._currencyAndUnitLabelsWrapper).backgroundColor,e.fillRect(0,0,Math.ceil(t*i),l+Math.round(2*Number(we.css_wrapper_margin)*i));const h=[];h.push(this.currencyLabelEnabled()&&null!==(s=this._currencyText.textContent)&&void 0!==s?s:""),h.push(this.measureUnitIdLableEnabled()&&null!==(r=this._measureUnitIdText.textContent)&&void 0!==r?r:""),h.push(this.unitLabelEnabled()&&null!==(n=this._unitText.textContent)&&void 0!==n?n:""),e.font=(0,ee.makeFont)(this._fontSize,re.CHART_FONT_FAMILY);const d=new ve.TextWidthCache,u=h.map((t=>""===t?0:d.yMidCorrection(e,t)));e.beginPath();const p=getComputedStyle(this._controlsContainer);e.fillStyle=p.backgroundColor,e.strokeStyle=p.borderColor,(0, Q.drawRoundRect)(e,o,o,a,l,c),e.fill(),e.stroke(),e.fillStyle=getComputedStyle(this._currencyLabelDiv).color,e.textBaseline="middle",e.textAlign="left";const _=Math.round(Number(we.css_first_row_top_padding)*i),m=Math.round(this._textMarginAndPadding()*i)+o,g=this._oneLineHeight()/2*i;let f=_+g;h.forEach(((t,s)=>{""!==t&&((0,J.drawScaled)(e,i,i,(()=>{e.fillText(t,m/i,(f+u[s])/i)})),f=Math.ceil(f+2*g))}))}setHidden(e){this._currencyAndUnitLabelsWrapper.classList.toggle(we.hidden,e)}enableCurrency(){this._currencyLabelDiv.classList.remove("js-hidden"),this._width=null,this._updateVisibility()}disableCurrency(){this._currencyLabelDiv.classList.add("js-hidden"),this._width=null,this._updateVisibility()}enableUnit(){this._unitLabelDiv.classList.remove("js-hidden"),this._width=null,this._updateVisibility()}disableUnit(){this._unitLabelDiv.classList.add("js-hidden"),this._width=null,this._updateVisibility()}enableMeasureUnitId(){this._measureUnitIdLabelDiv.classList.remove("js-hidden"),this._width=null,this._updateVisibility()}disableMeasureUnitId(){this._measureUnitIdLabelDiv.classList.add("js-hidden"),this._width=null,this._updateVisibility()}currencyLabelEnabled(){return!this._currencyLabelDiv.classList.contains("js-hidden")}unitLabelEnabled(){return!this._unitLabelDiv.classList.contains("js-hidden")}measureUnitIdLableEnabled(){return!this._measureUnitIdLabelDiv.classList.contains("js-hidden")}currencyConversionAvailable(){return!this._currencyLabelDiv.classList.contains("readonly")}unitConversionAvailable(){return!this._unitLabelDiv.classList.contains("readonly")}setCurrencyInfo(e){if(this._currencyInfo===e)return!1;this._currencyInfo=e;const t=null===e.selectedCurrency?o.t(null,void 0,i(95093)):(0,r.ensureDefined)(e.displayedValues.get(e.selectedCurrency));return this._currencyText.textContent!==t&&(this._currencyText.textContent=t,this._width=null),this._currencyArrowDown.classList.contains("js-hidden")!==e.readOnly&&(this._currencyArrowDown.classList.toggle("js-hidden",e.readOnly),this._currencyLabelDiv.classList.toggle("readonly",e.readOnly),this._width=null),!0}setUnitInfo(e){if(null!==this._unitInfo&&this._unitInfo.selectedUnit===e.selectedUnit&&0===this._unitInfo.availableGroups.size==(0===e.availableGroups.size)&&this._unitInfo.originalUnits.size===e.originalUnits.size)return this._unitInfo=e,!1;this._unitInfo=e;const t=null===e.selectedUnit?o.t(null,void 0,i(95093)):(0,r.ensureDefined)(e.names.get(e.selectedUnit));return this._unitText.textContent!==t&&(this._unitText.textContent=t,this._width=null),this._unitArrowDown.classList.contains("js-hidden")!==(0===e.availableGroups.size)&&(this._unitArrowDown.classList.toggle("js-hidden",0===e.availableGroups.size),this._unitLabelDiv.classList.toggle("readonly",0===e.availableGroups.size),this._width=null),!0}setMeasureUnitIdInfo(e){if(this._measureUnitIdInfo===e)return!1;this._measureUnitIdInfo=e;const t=null===e.selectedMeasureUnitId?o.t(null,void 0,i(95093)):(0,r.ensureDefined)(e.names.get(e.selectedMeasureUnitId)) -;return this._measureUnitIdText.textContent!==t&&(this._measureUnitIdText.textContent=t,this._width=null),this._measureUnitIdLabelDiv.classList.contains("js-hidden")!==(0===e.names.size)&&(this._measureUnitIdLabelDiv.classList.toggle("js-hidden",0===e.names.size),this._width=null),!0}updateColors(e,t){this._currencyAndUnitLabelsWrapper.style.backgroundColor=e}currencyInfo(){return this._currencyInfo}unitInfo(){return this._unitInfo}measureUnitIdInfo(){return this._measureUnitIdInfo}setFontSize(e){this._fontSize!==e&&(this._fontSize=e,this._currencyLabelDiv.style.fontSize=e+"px",this._measureUnitIdLabelDiv.style.fontSize=e+"px",this._unitLabelDiv.style.fontSize=e+"px",this._width=null)}labelBottom(){const e=this._oneLineHeight();let t=(this.currencyLabelEnabled()?e:0)+(this.measureUnitIdLableEnabled()?e:0)+(this.unitLabelEnabled()?e:0);return t>0&&(t+=Number(we.css_first_row_top_padding)),t}_textMarginAndPadding(){return Number(we.css_wrapper_margin)+Number(we.css_row_left_right_padding)+2}_currencyTooltipContent(){const e=this._currencyInfo;return null===e?"":null===e.selectedCurrency?Array.from(e.currencies).map((t=>(0,r.ensureDefined)(e.displayedValues.get(t)))).join(", "):e.displayedValues.get(e.selectedCurrency)||""}_unitTooltipContent(){const e=this._unitInfo;return null===e?"":null===e.selectedUnit?Array.from(e.units).map((t=>(0,r.ensureDefined)(e.names.get(t)))).join(", "):e.descriptions.get(e.selectedUnit)||""}_measureUnitIdTooltipContent(){const e=this._measureUnitIdInfo;return null===e?"":null===e.selectedMeasureUnitId?Array.from(e.measureUnitIds).map((t=>(0,r.ensureDefined)(e.names.get(t)))).join(", "):e.descriptions.get(e.selectedMeasureUnitId)||""}_updateVisibility(){const e=this.isEnabled();this._currencyAndUnitLabelsWrapper.classList.toggle("js-hidden",!e)}_oneLineHeight(){return 3+this._fontSize}}async function Ce(e,t,s,r){const{UnitConversionRenderer:n}=await Promise.all([i.e(2666),i.e(1013),i.e(3842),i.e(4015),i.e(5145),i.e(855),i.e(6),i.e(2587),i.e(6752),i.e(6036),i.e(6025),i.e(7111),i.e(962),i.e(3016),i.e(3179),i.e(2704)]).then(i.bind(i,28587));return new n(e,s,t,r)}function xe(e,t){let{deltaX:i,deltaY:s}=e;switch(i/=100,s/=100,t.deltaMode){case t.DOM_DELTA_PAGE:i*=120,s*=120;break;case t.DOM_DELTA_LINE:i*=32,s*=32}return{deltaX:i,deltaY:s}}class Te{constructor(){this._totalDeltaX=0,this._totalDeltaY=0,this._prevWheelTime=0}processWheel(e){e.timeStamp-this._prevWheelTime>100&&this._reset(),this._totalDeltaX+=e.deltaX,this._totalDeltaY+=e.deltaY,this._prevWheelTime=e.timeStamp;const t={deltaX:e.deltaX,deltaY:e.deltaY};return 0===this._totalDeltaX||0===this._totalDeltaY||(Math.abs(this._totalDeltaX)>=Math.abs(3*this._totalDeltaY)&&(t.deltaY=0),Math.abs(this._totalDeltaY)>=Math.abs(3*this._totalDeltaX)&&(t.deltaX=0)),xe(t,e)}_reset(){this._totalDeltaX=0,this._totalDeltaY=0}}var Ie=i(68335),Me=i(77212),Le=i(10786),Ae=i(14483),ke=i(73212),De=i(42226),Ve=i(39875),Ee=i(97754),Be=i.n(Ee),Re=i(58035);class Ne{constructor({setMode:e,className:t=""}){const s=this._wrapper=document.createElement("div") -;s.classList.add(t);const r=s.appendChild(document.createElement("div"));r.className=Re.priceScaleModeButtons,this._autoScaleButton=r.appendChild(this._createButton({title:o.t(null,{context:'The first letter of the "auto" word'},i(9846)),tooltip:o.t(null,void 0,i(50834)),onClick:()=>e("auto")})),this._logarithmButton=r.appendChild(this._createButton({title:o.t(null,{context:'The first letter of the "logarithmic" word'},i(55765)),tooltip:o.t(null,void 0,i(12285)),onClick:()=>e("log")}))}element(){return this._wrapper}width(){return 52}updateMode(e){const{log:t,autoScale:i}=e;this._logarithmButton.classList.toggle(Re.priceScaleModeButtons__button_activated,!!t),this._autoScaleButton.classList.toggle(Re.priceScaleModeButtons__button_activated,!!i)}_createButton(e){const{title:t,tooltip:i,onClick:s}=e,r=document.createElement("button");return r.className=Be()(Re.priceScaleModeButtons__button,"apply-common-tooltip"),r.textContent=t,r.dataset.tooltip=i,r.addEventListener("click",s),r}}var Oe=i(39267);i(47184);const Fe=new z.TranslatedString("change no overlapping labels",o.t(null,void 0,i(83935))),We=new z.TranslatedString("toggle auto scale",o.t(null,void 0,i(63060))),He=new z.TranslatedString("toggle log scale",o.t(null,void 0,i(60166))),ze=o.t(null,void 0,i(75633)),Ue=o.t(null,void 0,i(94420)),je=o.t(null,void 0,i(81520)),Ge=o.t(null,void 0,i(25933)),qe=o.t(null,void 0,i(17258)),$e=o.t(null,void 0,i(50834)),Ye=o.t(null,{context:"scale_menu"},i(70361)),Ke=o.t(null,{context:"scale_menu"},i(47807)),Ze=o.t(null,{context:"scale_menu"},i(34727)),Xe=o.t(null,{context:"scale_menu"},i(72116)),Je=o.t(null,{context:"scale_menu"},i(19238)),Qe=o.t(null,{context:"scale_menu"},i(54138));const et=function(e){const t=new Le.LimitedPrecisionNumericFormatter(e);return(e,i)=>(0,y.isNumber)(i)&&!e.isLog()?t.format(i):""}(4),tt={contextMenuEnabled:!0,currencyConversionEnabled:!1,unitConversionEnabled:!1,countdownEnabled:!0,contextMenu:{general:!0,source:!0},pressedMouseMoveScale:!0,mouseWheelScale:!0,pinchScale:!0,croppedTickMarks:!0};class it{constructor(e,t,i,r,n,o,a,l,c){this._actions=null,this._priceScale=null,this._scaleModeButtons=null,this._widthCache=new ve.TextWidthCache(1e3),this._color=null,this._fontSize=null,this._currencyFontSize=0,this._currencyLabelWidth=null,this._isVisible=!0,this._currencyMenu=null,this._unitMenu=null,this._size=(0,s.size)({width:0,height:0}),this._currentCursorClassName="",this._destroyed=!1,this._highlighted=!1,this._mouseWheelHelper=null,this._dragScaleActive=!1,this._offset=NaN,this._pinching=!1,this._lastHittestResult=null,this._isHovered=new fe.WatchedValue(!1),this._recalcCurrencyAndUnitVisibility=()=>{if(null===this._currencyLabel)return;let e=!0;switch((0,De.currencyUnitVisibilityProperty)().value()){case"alwaysOff":e=!1;break;case"visibleOnMouseOver":const t=this._chart.anyPriceAxisHovered().value(),i=null!==this._currencyMenu&&this._currencyMenu.isOpened(),s=null!==this._unitMenu&&this._unitMenu.isOpened();e=t||i||s}this._currencyLabel.setHidden(!e)}, -this._handleAutoLogButtonsVisibilityProperty=e=>{const t=e.value();"alwaysOff"===t?this._scaleModeButtons&&this._destroyScaleModeButtons():(this._scaleModeButtons||this._createScaleModeButtons(),"alwaysOn"===t?(this._isHovered.unsubscribe(this._updatePriceScaleModeButtonsVisibility),this._updatePriceScaleModeButtonsVisibility(!0)):this._isHovered.subscribe(this._updatePriceScaleModeButtonsVisibility,{callWithLast:!0}))},this._updatePriceScaleModeButtonsVisibility=e=>{var t;null===(t=this._scaleModeButtons)||void 0===t||t.element().classList.toggle("price-axis__modeButtons_hidden",!e)},this._updateScaleModeButtons=()=>{var e;this._priceScale&&(null===(e=this._scaleModeButtons)||void 0===e||e.updateMode(this._priceScale.mode()))},this._chart=e,this._pane=t,this._undoModel=i,this._properties=r,this._isLeft="left"===o,this._options=(0,y.merge)((0,y.clone)(tt),a),this._rendererOptionsProvider=n,this._backgroundBasedTheme=c,this._cell=document.createElement("div"),this._cell.className="price-axis",this._cell.style.width="25px",this._cell.style.left="0",this._canvasConfiguredHandler=()=>{this._undoModel.model().lightUpdate()},this._canvasBinding=(0,J.createBoundCanvas)(this._cell,(0,s.size)({width:16,height:16})),this._canvasBinding.subscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler);const h=this._canvasBinding.canvasElement;h.style.position="absolute",h.style.zIndex="1",h.style.left="0",h.style.top="0",this._topCanvasBinding=(0,J.createBoundCanvas)(this._cell,(0,s.size)({width:16,height:16})),this._topCanvasBinding.subscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler);const d=this._topCanvasBinding.canvasElement;d.style.position="absolute",d.style.zIndex="2",d.style.left="0",d.style.top="0",this._mouseEventHandler=new X.MouseEventHandler(this._cell,this,{treatVertTouchDragAsPageScroll:!1,treatHorzTouchDragAsPageScroll:!0}),this._options.currencyConversionEnabled||this._options.unitConversionEnabled?(this._currencyLabel=new Pe,this._cell.appendChild(this._currencyLabel.element())):this._currencyLabel=null,this._properties.childs().fontSize.subscribe(this,this._onFontSizeChanged),this._options.mouseWheelScale&&(this._mouseWheelHelper=new Te,this._cell.addEventListener("wheel",this._onMousewheel.bind(this),{passive:!1})),this._axisInfo=l,this._offset=0,this.restoreDefaultCursor(),(0,De.currencyUnitVisibilityProperty)().subscribe(this,this._recalcCurrencyAndUnitVisibility),(0,Ve.autoLogButtonsVisibilityProperty)().subscribe(this,this._handleAutoLogButtonsVisibilityProperty),this._handleAutoLogButtonsVisibilityProperty((0,Ve.autoLogButtonsVisibilityProperty)()),this._chart.anyPriceAxisHovered().subscribe(this._recalcCurrencyAndUnitVisibility,{callWithLast:!0}),this.update()}getContextMenuActions(){this._initActions();const e=(0,r.ensureNotNull)(this._actions),t=this._chart.actions(),i=[];return i.push(e.reset,new C.Separator),i.push(this._autoScaleAction()),this._isMainSeriesAxis()&&i.push(this._lockScaleAction()), -i.push(t.scaleSeriesOnly,this._invertAction(),new C.Separator,this._regularScaleAction(),this._percentageAction(),this._indexedTo100Action(),this._logAction(),new C.Separator),h.CheckMobile.any()||(i.push(this._createMergeScalesAction()),i.push(new C.Separator)),Ae.enabled("fundamental_widget")||i.push(new C.Action({actionId:"Chart.PriceScale.Labels",label:Ue,subItems:[t.showSymbolLabelsAction,t.showSeriesLastValue,null,null,t.showHighLowPriceLabels,Ae.enabled("show_average_close_price_line_and_label")?t.showAverageClosePriceLabel:null,null,t.showStudyPlotNamesAction,t.showStudyLastValue,e.alignLabels].filter(Boolean)})),i.push((0,ke.createLinesAction)(this._chart)),this._options.countdownEnabled&&i.push(t.showCountdown),this._undoModel.crossHairSource().isMenuEnabled()&&i.push(t.addPlusButton),!(0,h.onWidget)()&&Ae.enabled("show_chart_property_page")&&Ae.enabled("chart_property_page_scales")&&t.scalesProperties&&i.push(new C.Separator,t.scalesProperties),i}getElement(){return this._cell}onOptimalWidthNeedToBeRecalculated(e){(this._size.width0&&(s=Math.max(s,this._widthCache.measureText(t,n[0].label),this._widthCache.measureText(t,n[n.length-1].label)));const o=(null===(e=r.mainSource())||void 0===e?void 0:e.firstValue())||null;if(null!==o){const e=r.coordinateToPrice(1,o),i=r.coordinateToPrice(this._size.height-2,o);if(Math.abs(e-i)>1e-14){const n=r.formatPrice(Math.floor(Math.min(e,i))+.11111111111111,o),a=r.formatPrice(Math.ceil(Math.max(e,i))-.11111111111111,o);s=Math.max(s,this._widthCache.measureText(t,n),this._widthCache.measureText(t,a))}}}let o=0;this._isCurrencyLabelEnabled()&&(null===this._currencyLabelWidth&&(this._currencyLabelWidth=(0,r.ensureNotNull)(this._currencyLabel).width()),o=Math.round(this._currencyLabelWidth));const a=s||34;let l=Math.max(o,null!==(i=null===(t=this._scaleModeButtons)||void 0===t?void 0:t.width())&&void 0!==i?i:0,Math.ceil(n.borderSize+n.additionalPaddingInner+n.paddingInner+n.paddingOuter+a+4));return l+=l%2,l}backLabels(e){const t=[],i=this._grouppedSources(),s=s=>{for(const r of s){if(!e&&i.topLevelSources.has(r))continue;const s=r.priceAxisViews(this._pane.state(),this.priceScale());if(s)for(const e of s)t.push(e)}};return s(i.sources),s(this._pane.state().customSources()),t}setSizeAndOffset(e,t){(0,s.equalSizes)(this._size,e)||(this._size=e,this._canvasBinding.resizeCanvasElement(e),this._topCanvasBinding.resizeCanvasElement(e), -this._cell.style.width=e.width+"px",this._cell.style.height=e.height+"px",this._cell.style.minWidth=e.width+"px"),this._offset!==t&&(this._offset=t,this._cell.style.left=t+"px")}getWidth(){return this._size.width}getImage(){const e=this._size,t=(0,J.createDisconnectedCanvas)(document,e);return(0,J.getPrescaledContext2D)(t).drawImage(this._canvasBinding.canvasElement,0,0,e.width,e.height),null!==this._currencyLabel&&this._currencyLabel.isEnabled()&&this._currencyLabel.drawLabel((0,J.getContext2D)(t),e.width,(0,ge.getCanvasDevicePixelRatio)(t)),t}update(){null!==this._priceScale&&(this._priceScale.marks(),this._updateCurrencyLabelFont(),this.rendererOptions())}paint(e){if(!this._isVisible||0===this._size.width||0===this._size.height)return;if(e===N.InvalidationLevel.None)return;const t=this._pane.state(),i=!t.maximized().value()&&t.collapsed().value();if(this._canvasBinding.applySuggestedBitmapSize(),this._topCanvasBinding.applySuggestedBitmapSize(),e>N.InvalidationLevel.Cursor){const e=(0,J.getContext2D)(this._canvasBinding.canvasElement),t=(0,J.getBindingPixelRatio)(this._canvasBinding);i||this._alignLabels(),this._drawBackground(e,t),this._drawBorder(e,t),this._pane.hasState()&&(this.updateCurrencyLabel(),this._scaleModeButtons&&(this._scaleModeButtons.element().style.background=this.backgroundColor()),i||(this._drawTickMarks(e,t),this._drawBackLabels(e,t)))}if(this._pane.hasState()&&!i){const e=(0,J.getContext2D)(this._topCanvasBinding.canvasElement),t=(0,J.getBindingPixelRatio)(this._topCanvasBinding);e.clearRect(0,0,Math.ceil(this._size.width*t)+1,Math.ceil(this._size.height*t)+1),this._drawCrossHairLabel(e,t)}}restoreDefaultCursor(){this._setCursor("")}priceScale(){return(0,r.ensureNotNull)(this._priceScale)}setPriceScale(e){this._priceScale!==e&&(null!==this._priceScale&&(this._priceScale.onMarksChanged().unsubscribe(this,this.onOptimalWidthNeedToBeRecalculated),this._priceScale.modeChanged().unsubscribeAll(this)),this._priceScale=e,null!==e&&(e.onMarksChanged().subscribe(this,this.onOptimalWidthNeedToBeRecalculated),e.modeChanged().subscribe(this,(()=>this.onOptimalWidthNeedToBeRecalculated(!0))),this.onOptimalWidthNeedToBeRecalculated(),this._scaleModeButtons&&(e.modeChanged().subscribe(this,this._updateScaleModeButtons),this._updateScaleModeButtons())))}isVisible(){return this._isVisible}setVisible(e){(e=!!e)!==this._isVisible&&(this._cell.style.display=e?"table-cell":"none",this._isVisible=e)}destroy(){null!==this._currencyMenu&&(this._currencyMenu.close(),this._currencyMenu=null),null!==this._unitMenu&&(this._unitMenu.close(),this._unitMenu=null),this._topCanvasBinding.unsubscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler),this._topCanvasBinding.dispose(),this._canvasBinding.unsubscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler),this._canvasBinding.dispose(),null!==this._priceScale&&(this._priceScale.onMarksChanged().unsubscribe(this,this.onOptimalWidthNeedToBeRecalculated),this._priceScale.modeChanged().unsubscribeAll(this)),this._priceScale=null, -this._mouseEventHandler.destroy(),this._properties.childs().fontSize.unsubscribe(this,this._onFontSizeChanged),null!==this._actions&&this._actions.reset&&this._actions.reset.destroy(),(0,De.currencyUnitVisibilityProperty)().unsubscribeAll(this),this._chart.anyPriceAxisHovered().unsubscribe(this._recalcCurrencyAndUnitVisibility),(0,Ve.autoLogButtonsVisibilityProperty)().unsubscribeAll(this),this._chart.setPriceAxisHovered(this,!1),this._destroyScaleModeButtons(),this._destroyed=!0}axisInfo(){return this._axisInfo}setHighlighted(e){this._highlighted=e}backgroundColor(){return this._pane.state().model().backgroundColor().value()}backgroundTopColor(){return this._pane.state().model().backgroundTopColor().value()}lineColor(){return this._properties.childs().lineColor.value()}textColor(){return this._properties.childs().textColor.value()}fontSize(){return this._properties.childs().fontSize.value()}baseFont(){return(0,ee.makeFont)(this.fontSize(),re.CHART_FONT_FAMILY,"")}rendererOptions(){let e=this._rendererOptionsProvider.options();return this._color===e.color&&this._fontSize===e.fontSize||(this._color=e.color),this._fontSize!==e.fontSize&&(this._widthCache.reset(),this._fontSize=e.fontSize,this._currencyLabelWidth=null,this._currencyFontSize=0,this._updateCurrencyLabelFont(),this.onOptimalWidthNeedToBeRecalculated()),e}mouseEnterEvent(e){this._chart.setPriceAxisHovered(this,!0),this._isHovered.setValue(!0),this._mouseEnterOrTouchStartEvent(e)}mouseMoveEvent(e){this._mouseOrTouchMoveEvent(e)}mouseDownEvent(e){this._mouseDownOrTouchStartEvent(e)}touchStartEvent(e){this._mouseOrTouchMoveEvent(e),this._mouseEnterOrTouchStartEvent(e),this._mouseDownOrTouchStartEvent(e)}pressedMouseMoveEvent(e){this._pressedMouseOrTouchMoveEvent(e)}touchMoveEvent(e){this._pressedMouseOrTouchMoveEvent(e)}pinchStartEvent(){}pinchEvent(e,t,i){if(this._zoomAvailable()&&this._options.pinchScale){if(this._dragScaleActive&&this._finishScale(),!this._pinching)return this._pinching=!0,void this._undoModel.startTwoPointsScalePrice(this._pane.state(),this.priceScale(),t.y,i.y);this._undoModel.twoPointsScalePriceTo(this._pane.state(),this.priceScale(),t.y,i.y)}}pinchEndEvent(){this._pinching=!1,this._undoModel.endTwoPointsScalePrice(this._pane.state(),this.priceScale())}mouseDownOutsideEvent(){this._finishScale()}touchStartOutsideEvent(){this._finishScale()}mouseUpEvent(e){this._mouseUpOrTouchEndEvent(e)}touchEndEvent(e){this._mouseLeaveOrTouchEndEvent(e),this._mouseUpOrTouchEndEvent(e)}mouseClickEvent(e){this._mouseClickOrTapEvent(e)}tapEvent(e){this._mouseClickOrTapEvent(e)}mouseLeaveEvent(e){this._chart.setPriceAxisHovered(this,!1),this._isHovered.setValue(!1),this._mouseLeaveOrTouchEndEvent(e)}mouseDoubleClickEvent(e){this._mouseDoubleClickOrDoubleTapEvent(e)}doubleTapEvent(e){this._mouseDoubleClickOrDoubleTapEvent(e)}contextMenuEvent(e){this._contextMenuOrTouchContextMenuEvent(e)}touchContextMenuEvent(e){this._contextMenuOrTouchContextMenuEvent(e)}dataSourceAtPoint(e,t){const i=this._pane.state() -;if(!i.maximized().value()&&i.collapsed().value())return null;const s=this._grouppedSources(),r=[...s.sources,...s.topLevelSources,...i.customSources()];let n=null,o=null;if(!this._priceScale)return null;const a=(e,t)=>{var i;const s=null!==(i=null==o?void 0:o.target())&&void 0!==i?i:0;e.target()>s&&(o=e,n=t)},l=new F.Point(e,t);for(let e=r.length-1;e>=0;--e){const t=r[e],s=t.priceAxisViews(i,this._priceScale);if(s&&0!==s.length)for(let e=s.length-1;e>=0;--e){const i=s[e].renderer();if(void 0!==i.hitTest){const e=i.hitTest(l,this._size.width,this._isLeft?"left":"right");null!==e&&a(e,t)}}}return this._lastHittestResult=o,n}reset(){const e=this._pane.state(),t=this.priceScale();this._undoModel.resetPriceScale(e,t),this.onOptimalWidthNeedToBeRecalculated(!0)}updateCurrencyLabel(){if(null===this._currencyLabel)return;let e=!1;if(this._options.currencyConversionEnabled){const t=this.priceScale().currency(this._undoModel.model().availableCurrencies());null===t||"alwaysOff"===(0,De.currencyUnitVisibilityProperty)().value()?(e=this._currencyLabel.currencyLabelEnabled(),this._currencyLabel.disableCurrency()):(e=!this._currencyLabel.currencyLabelEnabled(),this._currencyLabel.enableCurrency(),this._currencyLabel.updateColors(this.backgroundTopColor(),this.textColor()),e=this._currencyLabel.setCurrencyInfo(t)||e)}else this._currencyLabel.disableCurrency();if(this._options.unitConversionEnabled){const t="alwaysOff"===(0,De.currencyUnitVisibilityProperty)().value(),i=this._undoModel.model().availableUnits(),s=this.priceScale().unit(i);null===s||t?(e=e||this._currencyLabel.unitLabelEnabled(),this._currencyLabel.disableUnit()):(e=e||!this._currencyLabel.unitLabelEnabled(),this._currencyLabel.enableUnit(),this._currencyLabel.updateColors(this.backgroundTopColor(),this.textColor()),e=this._currencyLabel.setUnitInfo(s)||e);const r=this.priceScale().measureUnitId(i);null===r||t?(e=e||this._currencyLabel.measureUnitIdLableEnabled(),this._currencyLabel.disableMeasureUnitId()):(e=e||!this._currencyLabel.measureUnitIdLableEnabled(),this._currencyLabel.enableMeasureUnitId(),this._currencyLabel.updateColors(this.backgroundTopColor(),this.textColor()),e=this._currencyLabel.setMeasureUnitIdInfo(r)||e)}else this._currencyLabel.disableUnit(),this._currencyLabel.disableMeasureUnitId();this._updateCurrencyLabelFont(),e&&(this._currencyLabelWidth=null)}_grouppedSources(){var e;const t=this._pane,i=t.state().model(),s=this._sameSideSources().slice(),r=t.state(),n=this.priceScale(),o=new Set,a=null!==(e=i.lineBeingEdited())&&void 0!==e?e:i.lineBeingCreated();a&&o.add(a);const l=i.customSourceBeingMoved();null!==l&&o.add(l),i.sourcesBeingMoved().forEach((e=>o.add(e))),i.selection().allSources().forEach((e=>o.add(e)));const c=i.hoveredSource();null!==c&&o.add(c);if(n===r.defaultPriceScale()){const e=this._pane.state().dataSources();for(const t of e)r.isOverlay(t)&&s.push(t)}return{sources:s,topLevelSources:o}}_isCurrencyLabelEnabled(){return null!==this._currencyLabel&&this._currencyLabel.isEnabled()}_updateCurrencyLabelFont(){ -if(null===this._currencyLabel)return;const e=this.fontSize();e!==this._currencyFontSize&&(this._currencyLabel.setFontSize(e),this._currencyFontSize=e,this._currencyLabelWidth=null,this.onOptimalWidthNeedToBeRecalculated())}_alignLabels(){var e,t;const i=this._size.height;let s=i/2;const r=[],n=this.priceScale(),o=n.orderedSources().slice(),a=this._pane.state(),l=this.rendererOptions();if(n===a.defaultPriceScale()){const e=a.priceDataSources();for(let t=0;t{if(e.ignoreAlignment()||!e.isVisible())return!1;const{total:t}=e.topBottomTotalHeight(l),s=e.floatCoordinate();return s>-t&&se.floatCoordinate()<=s)),d=r.filter((e=>e.floatCoordinate()>s));h.sort(((e,t)=>t.floatCoordinate()-e.floatCoordinate())),h.length>0&&d.length>0&&d.push(h[0]),d.sort(((e,t)=>e.floatCoordinate()-t.floatCoordinate()));for(const e of r)e.setFixedCoordinate(e.coordinate());if(n.properties().childs().alignLabels.value()){if(d.length>0||h.length>0){{const t=null!==(e=h[0])&&void 0!==e?e:d[0],s=t.getFixedCoordinate(),{top:r,bottom:n,total:o}=t.topBottomTotalHeight(l);o0&&t.setFixedCoordinate(r)}{const e=null!==(t=d[0])&&void 0!==t?t:h[0],s=e.getFixedCoordinate(),{top:r,bottom:n,total:o}=e.topBottomTotalHeight(l);oi&&e.setFixedCoordinate(i-n)}}for(let e=1;ea-n)t.setFixedCoordinate(a-n);else if(a>0&&o-s<0&&o+r>0){const{top:e}=i.topBottomTotalHeight(l);t.setFixedCoordinate(Math.min(a-e-r,s))}}for(let e=1;ei&&t.setFixedCoordinate(Math.max(a+r+e,i-s))}}}}_drawTickMarks(e,t){const i=this.priceScale().marks();e.save(),e.font=this.baseFont();const s=this.rendererOptions(),n=this._isLeft?Math.floor((this._size.width-s.additionalPaddingInner)*t):0,o=this._isLeft?Math.round(n-s.paddingInner*t):Math.round(n+(s.additionalPaddingInner+s.paddingInner)*t),a=this.fontSize(),l=this._isCurrencyLabelEnabled()?(0,r.ensureNotNull)(this._currencyLabel).labelBottom():0,c=i.map((t=>{if(this._options.croppedTickMarks)return{visible:!0,yCorrection:this._widthCache.yMidCorrection(e,t.label)};const i=t.coord-a/2,s=t.coord+a/2,r=!(s>this._size.height||ithis._size.height||i{for(let s=i.length;s--;){if(!c[s].visible)continue;const r=i[s] -;e.fillText(r.label,o/t,r.coord+c[s].yCorrection)}})),e.restore()}_hasAlertLabel(){return!1}async _showCurrenciesContextMenu(){var e;if(null!==this._currencyMenu&&this._currencyMenu.isOpened())return void this._currencyMenu.close();(0,Se.trackEvent)("GUI","Currency conversion");const{currencyActions:t}=await Promise.all([i.e(2666),i.e(1013),i.e(3842),i.e(4015),i.e(5145),i.e(855),i.e(6),i.e(2587),i.e(6752),i.e(6036),i.e(6025),i.e(7111),i.e(962),i.e(3016),i.e(3179),i.e(2704)]).then(i.bind(i,84298)),s=await Ce(je,(()=>t(this._undoModel,(0,r.ensureNotNull)(this._currencyLabel).currencyInfo(),this.priceScale())),(0,r.ensureNotNull)(this._currencyLabel).currencyLabelElement(),(()=>{var e;this._recalcCurrencyAndUnitVisibility(),null===(e=this._currencyLabel)||void 0===e||e.setCurrencyExpanded(!1)}));null===(e=this._currencyLabel)||void 0===e||e.setCurrencyExpanded(!0),this._destroyed?s.close():this._currencyMenu=s}async _showUnitsContextMenu(){var e;if(null!==this._unitMenu&&this._unitMenu.isOpened())return void this._unitMenu.close();(0,Se.trackEvent)("GUI","Unit conversion");const{unitActions:t}=await Promise.all([i.e(2666),i.e(1013),i.e(3842),i.e(4015),i.e(5145),i.e(855),i.e(6),i.e(2587),i.e(6752),i.e(6036),i.e(6025),i.e(7111),i.e(962),i.e(3016),i.e(3179),i.e(2704)]).then(i.bind(i,14818)),s=await Ce(Ge,(()=>t(this._undoModel,(0,r.ensureNotNull)(this._currencyLabel).unitInfo(),this.priceScale())),(0,r.ensureNotNull)(this._currencyLabel).unitLabelElement(),(()=>{var e;this._recalcCurrencyAndUnitVisibility(),null===(e=this._currencyLabel)||void 0===e||e.setUnitExpanded(!1)}));null===(e=this._currencyLabel)||void 0===e||e.setUnitExpanded(!0),this._destroyed?s.close():this._unitMenu=s}_onFontSizeChanged(){this._currencyLabelWidth=null,this._currencyFontSize=0,this._updateCurrencyLabelFont(),this.onOptimalWidthNeedToBeRecalculated()}_mouseOrTouchMoveEvent(e){var t,i,s,r;if(!this._priceScale)return;if(e.localX<0||e.localY<0||e.localX>=this._size.width||e.localY>=this._size.height)return;let n=!0;const o=this.dataSourceAtPoint(e.localX,e.localY);o?(this._setCursorClassName("pointer"),(null===(i=null===(t=this._lastHittestResult)||void 0===t?void 0:t.data())||void 0===i?void 0:i.hoverModelFromAxis)&&(this._undoModel.model().setHoveredSource(o,null!==(r=null===(s=this._lastHittestResult)||void 0===s?void 0:s.data())&&void 0!==r?r:null),n=!1)):this._setResizeCursor(),n&&this._undoModel.model().setHoveredSource(null,null)}_mouseDownOrTouchStartEvent(e){this._zoomAvailable()&&this._options.pressedMouseMoveScale&&!this._pinching&&(this._dragScaleActive=!0,this._undoModel.startScalePrice(this._pane.state(),this.priceScale(),e.localY))}_mouseEnterOrTouchStartEvent(e){this._setResizeCursor()}_pressedMouseOrTouchMoveEvent(e){if(this._dragScaleActive){const t=this.priceScale();this._undoModel.scalePriceTo(this._pane.state(),t,e.localY)}}_mouseUpOrTouchEndEvent(e){this._finishScale()}_finishScale(){this._dragScaleActive&&(this._undoModel.endScalePrice(this._pane.state(),this.priceScale()),this.restoreDefaultCursor(), -this._dragScaleActive=!1)}_mouseClickOrTapEvent(e){if(this._currencyLabel){if(this._currencyLabel.currencyConversionAvailable()&&this._currencyLabel.currencyLabelElement().contains(e.target))return this._showCurrenciesContextMenu(),void e.preventDefault();if(this._currencyLabel.unitConversionAvailable()&&this._currencyLabel.unitLabelElement().contains(e.target))return this._showUnitsContextMenu(),void e.preventDefault()}const t=this.dataSourceAtPoint(e.localX,e.localY);t&&this._undoModel.selectionMacro((e=>{var i,s,r;e.selection().isSelected(t)&&this._undoModel.model().lastSelectedHittestData()===(null===(i=this._lastHittestResult)||void 0===i?void 0:i.data())||(e.clearSelection(),e.addSourceToSelection(t,null!==(r=null===(s=this._lastHittestResult)||void 0===s?void 0:s.data())&&void 0!==r?r:null))}))}_mouseLeaveOrTouchEndEvent(e){this._setCursorClassName("")}_mouseDoubleClickOrDoubleTapEvent(e){var t;const i=this.dataSourceAtPoint(e.localX,e.localY);i?this._pane.processDoubleClickOnSource(i,null!==(t=this._lastHittestResult)&&void 0!==t?t:void 0,{origin:"price_scale"}):(this.reset(),(0,Se.trackEvent)("GUI","Double click price scale"))}_contextMenuOrTouchContextMenuEvent(e){if(this._options.contextMenuEnabled){const t=this.dataSourceAtPoint(e.localX,e.localY);if(null!==t&&this._options.contextMenu.source){return void this._undoModel.model().selectionMacro((i=>{i.selection().isSelected(t)||(i.clearSelection(),i.addSourceToSelection(t)),this._pane.showContextMenuForSelection(e,{origin:"price_scale"})}))}this._options.contextMenu.general&&he.ContextMenuManager.showMenu(this.getContextMenuActions(),e,{statName:"PriceScaleContextMenu"},{menuName:"PriceScaleContextMenu"})}}_setResizeCursor(){const e=this.priceScale();e.isPercentage()||e.isIndexedTo100()?this._setCursorClassName(""):this._zoomAvailable()&&(this._options.pressedMouseMoveScale||this._options.mouseWheelScale)&&this._setCursorClassName("ns-resize")}_setCursorClassName(e){let t="";e&&(t="price-axis--cursor-"+e),this._currentCursorClassName!==t&&(this._currentCursorClassName&&this._cell.classList.remove(this._currentCursorClassName),t&&this._cell.classList.add(t),this._currentCursorClassName=t)}_zoomAvailable(){return!this.priceScale().isEmpty()&&this._undoModel.model().zoomEnabled()}_onMousewheel(e){if(!this._zoomAvailable()||!this._options.mouseWheelScale)return;const t=(0,r.ensureNotNull)(this._mouseWheelHelper).processWheel(e).deltaY;if(0===t)return;e.cancelable&&e.preventDefault();const i=this._undoModel,s=this._pane.state(),n=this.priceScale(),o=this._cell.getBoundingClientRect(),a=e.clientY-o.top,l=a+15*t;i.startScalePrice(s,this.priceScale(),a,!0),i.scalePriceTo(s,n,l),i.endScalePrice(s,n),e.stopPropagation()}_drawCrossHairLabel(e,t){var i,s;e.save();const r=this._pane.state(),n=r.model(),o=this.priceScale(),a=[],l=this.priceScale()===r.defaultPriceScale(),c=null!==(i=n.lineBeingEdited())&&void 0!==i?i:n.lineBeingCreated();if(c&&(c.priceScale()===o||l&&r.isOverlay(c))){const e=c.priceAxisViews(r,o);e&&e.length&&a.push(e)}const h=n.customSourceBeingMoved() -;this._addViewsOrMaxMin(null===h?[]:[h],a),this._addViewsOrMaxMin(n.sourcesBeingMoved(),a),this._addViewsOrMaxMin(n.selection().allSources(),a);const d=n.hoveredSource();if(d){const e=r.customSources().includes(d)?o:d.priceScale();if(!n.selection().isSelected(d)&&(this._isFromSameSide(e)||l&&r.isOverlay(d))){const e=null===(s=n.hoveredSource())||void 0===s?void 0:s.priceAxisViews(r,o);e&&e.length&&a.push(e)}}const u=n.crossHairSource().priceAxisViews(r,o);u&&u.length&&a.push(u);const p=this.rendererOptions(),_=this._isLeft?"right":"left";a.forEach((i=>{i.forEach((i=>{e.save(),i.renderer().draw(e,p,this._widthCache,this._size.width,this._size.height,_,t),e.restore()}))})),e.restore()}_drawBackground(e,t){const i=Math.ceil(this._size.width*t),s=Math.ceil(this._size.height*t),r=this.backgroundTopColor(),n=this.backgroundColor();if(r===n?(0,J.clearRect)(e,0,0,i+1,s+1,this.backgroundColor()):(0,Q.clearRectWithGradient)(e,0,0,i+1,s+1,r,n),this._highlighted){e.globalAlpha=.5;const t=te.themes[this._backgroundBasedTheme.value()].getThemedColor("color-price-axis-highlight");(0,J.fillRect)(e,0,0,i+1,s+1,t),e.globalAlpha=1}const o=this._pane.state().model(),a=this.priceScale(),l=o.selection().lineDataSources().filter((e=>e.priceScale()===a)).reduce(((e,t)=>{const i=t.priceAxisPoints();return 0===i.length?e:e.concat(i)}),[]);l.length>0&&this._hightlightBackground(e,l,this.priceScale().mainSource(),t);const c=o.crossHairSource();c.startMeasurePoint()&&this._hightlightBackground(e,c.measurePoints(),this.priceScale().mainSource(),t)}_drawBorder(e,t){e.save(),e.fillStyle=this.lineColor();const i=Math.max(1,Math.floor(this.rendererOptions().borderSize*t)),s=this._isLeft?Math.floor(this._size.width*t)-i:0;e.fillRect(s,0,i,Math.ceil(this._size.height*t)+1),e.restore()}_drawBackLabels(e,t){e.save();const i=this.backLabels(),s=this.rendererOptions(),r=this._isLeft?"right":"left";for(const n of i)n.isAxisLabelVisible()&&(e.save(),n.renderer().draw(e,s,this._widthCache,this._size.width,this._size.height,r,t),e.restore());e.restore()}_hightlightBackground(e,t,i,s){if(!i)return;const r=i.firstValue();if(null===r)return;let n=t[0].price,o=t[0].price;for(let e=1;ei.isOverlay(e)||this._isFromSameSide(e.priceScale())))),0!==e.length)if(1===e.length){const r=e[0].priceAxisViews(i,s);r&&r.length&&t.push(r)}else t.push(this._minMaxViews(e))}_minMaxViews(e){const t=this._pane.state(),i=this.priceScale(),s=[];let r=1/0,n=-1/0,o=null,a=null;for(const s of e){const e=s.priceAxisViews(t,i);if(e&&e.length)for(let t=0;t=n&&(n=s,a=i),s<=r&&(r=s,o=i)}}return a&&s.push(a),o&&s.push(o),s}_isFromSameSide(e){ -return null!==e&&(this._isLeft?this._pane.state().leftPriceScales():this._pane.state().rightPriceScales()).includes(e)}_sameSideSources(){const e=this._pane.state().sourcesByGroup();return this._isLeft?e.leftPriceScalesSources():e.rightPriceScalesSources()}_initActions(){if(!this._pane.hasState()||null!==this._actions)return;const e=this._undoModel,t=new C.Action({actionId:"Chart.PriceScale.Reset",label:qe,icon:Oe,shortcutHint:(0,Ie.humanReadableHash)(Ie.Modifiers.Alt+82),statName:"ResetScale",onExecute:()=>this.reset()}),i=new C.Action({actionId:"Chart.PriceScale.ToggleAutoScale",label:$e,checkable:!0,checked:!0,statName:"ToggleAutoScale",onExecute:()=>{e.togglePriceScaleAutoScaleMode(this.priceScale()),this._updateScalesActions()}}),s=new C.Action({actionId:"Chart.PriceScale.TogglePercentage",label:Ye,checkable:!0,checked:this.priceScale().isPercentage(),statName:"TogglePercantage",onExecute:()=>{e.togglePriceScalePercentageScaleMode(this.priceScale()),this._updateScalesActions()}}),r=new C.Action({actionId:"Chart.PriceScale.ToggleIndexedTo100",label:Ke,checkable:!0,checked:this.priceScale().isIndexedTo100(),statName:"ToggleIndexedTo100",onExecute:()=>{e.togglePriceScaleIndexedTo100ScaleMode(this.priceScale()),this._updateScalesActions()}}),n=new C.Action({actionId:"Chart.PriceScale.ToggleLogarithmic",label:Ze,checkable:!0,checked:this.priceScale().isLog(),statName:"ToggleLogScale",onExecute:()=>{e.togglePriceScaleLogScaleMode(this.priceScale()),this._updateScalesActions()}}),o=new C.Action({actionId:"Chart.PriceScale.ToggleRegular",label:Xe,checkable:!0,checked:this.priceScale().isRegular(),statName:"ToggleRegularScale",onExecute:()=>{e.setPriceScaleRegularScaleMode(this.priceScale()),this._updateScalesActions()}}),a=new C.Action({actionId:"Chart.PriceScale.Labels.ToggleNoOverlappingLabelsVisibility",label:Je,checkable:!0,checked:this.priceScale().properties().childs().alignLabels.value(),statName:"TogglePreciseLabels"});a.setBinding(new Me.ActionBinder(a,this.priceScale().properties().childs().alignLabels,e,Fe));const l=new C.Action({actionId:"Chart.PriceScale.ToggleInvertScale",label:Qe,checkable:!0,checked:this.priceScale().isInverted(),statName:"Invert Scale",onExecute:()=>{e.invertPriceScale(this.priceScale()),this._updateScalesActions()}});this._actions={reset:t,setAutoScale:i,setPercentage:s,setIndexedTo100:r,setLog:n,setRegular:o,alignLabels:a,invertScale:l},this._updateScalesActions()}_logAction(){return this._isMainSeriesAxis()?this._chart.actions().logSeriesScale:(0,r.ensureNotNull)(this._actions).setLog}_percentageAction(){return this._isMainSeriesAxis()?this._chart.actions().percentSeriesScale:(0,r.ensureNotNull)(this._actions).setPercentage}_indexedTo100Action(){return this._isMainSeriesAxis()?this._chart.actions().indexedTo100SeriesScale:(0,r.ensureNotNull)(this._actions).setIndexedTo100}_autoScaleAction(){return this._isMainSeriesAxis()?this._chart.actions().autoSeriesScale:(0,r.ensureNotNull)(this._actions).setAutoScale}_regularScaleAction(){ -return this._isMainSeriesAxis()?this._chart.actions().regularSeriesScale:(0,r.ensureNotNull)(this._actions).setRegular}_lockScaleAction(){const e=this._chart.actions().lockSeriesScale,t=et(this.priceScale(),this._undoModel.model().mainSeriesScaleRatio());return e.update({hint:t}),e}_invertAction(){return this._isMainSeriesAxis()?this._chart.actions().invertSeriesScale:(0,r.ensureNotNull)(this._actions).invertScale}_isMainSeriesAxis(){return this.priceScale().hasMainSeries()}_updateScalesActions(){const e=this.priceScale(),t=this._isMainSeriesAxis(),i=(0,r.ensureNotNull)(e.mainSource()).properties(),s=t&&e.isLockScale(),n=t&&6===i.style.value(),o=(0,r.ensureNotNull)(this._actions);o.setRegular.update({checked:e.isRegular(),disabled:s||n}),o.setPercentage.update({checked:e.isPercentage(),disabled:s||n}),o.setIndexedTo100.update({checked:e.isIndexedTo100(),disabled:s||n}),o.setLog.update({checked:e.isLog(),disabled:s||n}),o.setAutoScale.update({checked:e.isAutoScale(),disabled:e.properties().childs().autoScaleDisabled.value()})}_createMergeScalesAction(){const e=this._chart.actions(),t=this._undoModel.model().priceScaleSlotsCount();if(t.left+t.right===1)return 0===t.left?e.moveScaleToLeft:e.moveScaleToRight;const i=[];return i.push(e.mergeLeftScalesAction),i.push(e.mergeRightScalesAction),new C.Action({actionId:"Chart.PriceScale.MergeAllScales",label:ze,subItems:i})}_setCursor(e){let t="";"grabbing"!==e&&"ns-resize"!==e||(t="price-axis--cursor-"+e),this._currentCursorClassName!==t&&(this._currentCursorClassName&&this._cell.classList.remove(this._currentCursorClassName),t&&this._cell.classList.add(t),this._currentCursorClassName=t,this._cell.style.cursor)}_createScaleModeButtons(){var e;const t=this._scaleModeButtons=new Ne({className:"price-axis__modeButtons",setMode:e=>{this._priceScale&&("log"===e?this._chart.model().setPriceScaleMode({log:!this._priceScale.isLog()},this._priceScale,He):this._chart.model().setPriceScaleMode({autoScale:!this._priceScale.isAutoScale()},this._priceScale,We))}});return t.element().style.background=this.backgroundColor(),this._cell.appendChild(t.element()),null===(e=this._priceScale)||void 0===e||e.modeChanged().subscribe(this,this._updateScaleModeButtons),this._updateScaleModeButtons(),t}_destroyScaleModeButtons(){var e;this._scaleModeButtons&&(this._isHovered.unsubscribe(this._updatePriceScaleModeButtonsVisibility),null===(e=this._priceScale)||void 0===e||e.modeChanged().unsubscribe(this,this._updateScaleModeButtons),this._scaleModeButtons.element().remove(),this._scaleModeButtons=null)}}function st(e,t){return e.position-t.position}function rt(e,t,i){const s=(e.position-t.position)/(e.time-t.time);return Math.sign(s)*Math.min(Math.abs(s),i)}class nt{constructor(e,t,i,s){this._position1=null,this._position2=null,this._position3=null,this._position4=null,this._animationStartPosition=null,this._durationMsecs=0,this._speedPxPerMsec=0,this._terminated=!1,this._minSpeed=e,this._maxSpeed=t,this._dumpingCoeff=i,this._minMove=s}addPosition(e,t){if(null!==this._position1){ -if(this._position1.time===t)return void(this._position1.position=e);if(Math.abs(this._position1.position-e)50)return;let i=0;const s=rt(this._position1,this._position2,this._maxSpeed),r=st(this._position1,this._position2),n=[s],o=[r];if(i+=r,null!==this._position3){const e=rt(this._position2,this._position3,this._maxSpeed);if(Math.sign(e)===Math.sign(s)){const t=st(this._position2,this._position3);if(n.push(e),o.push(t),i+=t,null!==this._position4){const e=rt(this._position3,this._position4,this._maxSpeed);if(Math.sign(e)===Math.sign(s)){const t=st(this._position3,this._position4);n.push(e),o.push(t),i+=t}}}}let a=0;for(let e=0;ea&&(e.result={hittest:t,source:i,renderer:s,isCustom:r})}const Et={contextMenuEnabled:!0,contextMenu:ke.defaultContextMenuOptions,priceScaleContextMenuEnabled:!0,legendWidgetEnabled:!0,controlsEnabled:!0,propertyPagesEnabled:!0, -sourceSelectionEnabled:!0,countdownEnabled:!0},Bt=new Map([[G.AreaName.Text,"Text"],[G.AreaName.Style,"Style"]]),Rt=!Ae.enabled("display_legend_on_all_charts");let Nt=null;function Ot(e,t){return!(0,G.shouldDefaultActionBeExecuted)(e,t,"pressedMouseMoveHandler","touchMoveHandler")}class Ft{constructor(e,t,i,r){this._legendWidget=null,this._paneControls=null,this._isDestroyed=!1,this._trackCrosshairOnlyAfterLongTap=(0,U.lastMouseOrTouchEventInfo)().isTouch,this._startTrackPoint=null,this._exitTrackingModeOnNextTry=!1,this._startMoveSourceParams=null,this._startChangeLineToolParams=null,this._preventSourceChange=!1,this._clonningAtMoveLineTools=null,this._startCloningPoint=null,this._size=(0,s.size)({width:0,height:0}),this._themedTopColor=null,this._initCrossHairPosition=null,this._firstZoomPoint=null,this._editDialog=null,this._processing=!1,this._pressedMoveStage=0,this._touchMove=!1,this._startTouchPoint=null,this._isSelecting=!1,this._prevHoveredHittest=null,this._contextMenuX=0,this._contextMenuY=0,this._startScrollingPos=null,this._isScrolling=!1,this._scrollPriceScale=null,this._scrollXAnimation=null,this._prevPinchScale=1,this._pinching=!1,this._wasPinched=!1,this._longTap=!1,this._contextMenuOpenedOnLastTap=!1,this._paneControlsResizeObserver=null,this._lastClickedSource=null,this._customLegendWidgetsFactoryMap=new Map,this._prevMoveEventPosition=null,this._onMagnetStateChangedListener=this._onMagnetStateChanged.bind(this),this._onShiftKeyStateChangedListener=this._onShiftKeyStateChanged.bind(this),this._currentCursorClassName="",this._lastFinishedToolId=null,this._needResetMeasureLater=!1,this._currentChangingLineToolHitTest=null,this._currentMovingHitTest=null,this._prevTooltipData=null,this._errorRenderer=null,this._highlightedPriceAxis=new fe.WatchedValue({owner:"",axis:null}),this._visuallyCollapsed=new fe.WatchedValue(!1),this._endOfSeriesDataBanner=null,this._canvasConfiguredHandler=()=>this._state&&this._chartModel().lightUpdate(),this._updateVisuallyCollapsed=()=>{this._visuallyCollapsed.setValue(!this.state().maximized().value()&&this.state().collapsed().value())},this._chart=e,this._state=t,this._options=(0,y.merge)((0,y.clone)(Et),i),this._paneWidgetsSharedState=r,this._state&&this._subscribeToState();const n={contextMenuEnabled:this._options.priceScaleContextMenuEnabled,pressedMouseMoveScale:this._options.handleScale.axisPressedMouseMove.price,mouseWheelScale:this._options.handleScale.mouseWheel,currencyConversionEnabled:this._options.currencyConversionEnabled,unitConversionEnabled:this._options.unitConversionEnabled,countdownEnabled:this._options.countdownEnabled,croppedTickMarks:this._options.croppedTickMarks};void 0!==this._options.priceScaleContextMenu&&(n.contextMenu=this._options.priceScaleContextMenu);const o=(e,t,i,s,r)=>new it(this._chart,this,this._chartUndoModel(),i,t,e,n,s,r),a=e.properties().childs().scalesProperties,l=this._chartModel().rendererOptionsProvider(),c={backgroundBasedTheme:e.backgroundBasedTheme(),rendererOptionsProvider:l, -getBackgroundTopColor:()=>this._chartModel().backgroundTopColor().value(),getBackgroundBottomColor:()=>this._chartModel().backgroundColor().value()},h={showLabels:!1};this._lhsPriceAxisesContainer=new me(a,"left",o,c,h),this._rhsPriceAxisesContainer=new me(a,"right",o,c,h),this._paneCell=document.createElement("td"),this._paneCell.classList.add("chart-markup-table","pane"),this._div=document.createElement("div"),this._div.classList.add("chart-gui-wrapper"),this._div.setAttribute("data-name","pane-widget-chart-gui-wrapper"),this._paneCell.appendChild(this._div),this._canvasBinding=(0,J.createBoundCanvas)(this._div,(0,s.size)({width:16,height:16})),this._canvasBinding.subscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler);const d=this._canvasBinding.canvasElement;d.style.position="absolute",d.style.left="0",d.style.top="0",this._topCanvasBinding=(0,J.createBoundCanvas)(this._div,(0,s.size)({width:16,height:16})),this._topCanvasBinding.subscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler);const u=this._topCanvasBinding.canvasElement;u.style.position="absolute",u.style.left="0",u.style.top="0",this._rowElement=document.createElement("tr"),this._rowElement.appendChild(this._lhsPriceAxisesContainer.getElement()),this._rowElement.appendChild(this._paneCell),this._rowElement.appendChild(this._rhsPriceAxisesContainer.getElement()),this._options.legendWidgetEnabled&&(this._options.customLegendWidgetFactories&&(this._customLegendWidgetsFactoryMap=this._options.customLegendWidgetFactories),this._loadAndCreateLegendWidget()),this._state&&!this._chart.readOnly()&&this._options.controlsEnabled&&this._loadAndCreatePaneControlsWidget(),(0,_t.magnetEnabled)().subscribe(this._onMagnetStateChangedListener),(0,mt.shiftPressed)().subscribe(this._onShiftKeyStateChangedListener),this._paneCell.addEventListener("dragover",(e=>{e.dataTransfer&&Array.from(e.dataTransfer.files).some(blobImageFilter)&&e.preventDefault()})),this.setCursorForTool(),this._mouseEventHandler=new X.MouseEventHandler(this._topCanvasBinding.canvasElement,this,{treatVertTouchDragAsPageScroll:!this._options.handleScroll.vertTouchDrag,treatHorzTouchDragAsPageScroll:!this._options.handleScroll.horzTouchDrag}),this._prevHoveredHittest=null,this._highlightedPriceAxis.subscribe((e=>this._highlightPriceAxisByLabel(e.axis))),this._prevPinchScale=0,this._isDestroyed=!1}destroy(){var e;this._chart.onPaneWidgetDestroyed(this),this._customLegendWidgetsFactoryMap.clear(),this._topCanvasBinding.unsubscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler),this._topCanvasBinding.dispose(),this._canvasBinding.unsubscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler),this._canvasBinding.dispose(),this._legendWidget&&(this._legendWidget.destroy(),this._legendWidget=null),null!==this._paneControlsResizeObserver&&this._paneControlsResizeObserver.disconnect(),null!==this._paneControls&&(this._paneControls.destroy(),this._paneControls=null),this._lhsPriceAxisesContainer.destroy(),this._rhsPriceAxisesContainer.destroy(), -this.hasState()&&this._unsubscribeFromState(),(0,_t.magnetEnabled)().unsubscribe(this._onMagnetStateChangedListener),(0,mt.shiftPressed)().unsubscribe(this._onShiftKeyStateChangedListener),this._paneWidgetsSharedState.onPaneDestroyed(this),this._errorRenderer&&this._errorRenderer.then((e=>{e.destroy(),this._errorRenderer=null})),this._prevHoveredHittest=null,this._mouseEventHandler.destroy(),null===(e=this._rowElement.parentElement)||void 0===e||e.removeChild(this._rowElement),this._isDestroyed=!0}size(){return this._size}setSize(e){(0,s.equalSizes)(this._size,e)||(this._size=e,this._canvasBinding.resizeCanvasElement(e),this._topCanvasBinding.resizeCanvasElement(e),this._paneCell.style.width=e.width+"px",this._paneCell.style.height=e.height+"px",this._div.style.width=e.width+"px",this._div.style.height=e.height+"px",this._rowElement.classList.toggle("js-hidden",0===e.height),null!==this._legendWidget&&this._legendWidget.updateWidgetModeBySize(e),null!==this._paneControls&&this._paneControls.updateWidgetModeByWidth(e.width))}width(){return this._size.width}height(){return this._size.height}backgroundColor(){return this._chartModel().backgroundColor().value()}highlightedPriceAxis(){return this._highlightedPriceAxis}processDoubleClickOnSource(e,t,i){(0,Y.isDataSource)(e)&&e.id()!==this._lastFinishedToolId&&this._showEditDialogForSource(e,t)}stretchFactor(){return this._state?this._state.stretchFactor():0}setStretchFactor(e){this.hasState()&&this.state().setStretchFactor(e)}setCursorForTool(e,t,i){if(t&&t.mod()&&e&&e!==this._chartModel().crossHairSource())return void this._setCursorClassName("pointer");if(void 0!==i){switch(i){case dt.PaneCursorType.VerticalResize:this._setCursorClassName("ns-resize");break;case dt.PaneCursorType.HorizontalResize:this._setCursorClassName("ew-resize");break;case dt.PaneCursorType.DiagonalNeSwResize:this._setCursorClassName("nesw-resize");break;case dt.PaneCursorType.DiagonalNwSeResize:this._setCursorClassName("nwse-resize");break;case dt.PaneCursorType.Default:this._setCursorClassName("default");break;case dt.PaneCursorType.Pointer:this._setCursorClassName("pointer");break;case dt.PaneCursorType.Grabbing:this._setCursorClassName("grabbing")}return}const s=K.tool.value();if((0,K.toolIsCursor)(s)){if(null!==this._paneWidgetsSharedState.draggingSource()||this._isScrolling||this._chartUndoModel()&&this._chartUndoModel().model().sourcesBeingMoved().length)return void this._setCursorClassName("grabbing");if(e&&this._options.sourceSelectionEnabled)return void this._setCursorClassName("pointer")}if("eraser"===s)return void this._setCursorClassName("eraser");if("zoom"===s)return void this._setCursorClassName("zoom-in");const r=K.cursorTool.value();"dot"!==r?"arrow"!==r?this._setCursorClassName(""):this._setCursorClassName("default"):this._setCursorClassName("dot")}showContextMenuForSelection(e,t){const i=this._chartUndoModel().selection();if(i.isEmpty())return;const s=i.dataSources().filter((e=>e.hasContextMenu()));this.showContextMenuForSources(s,e,void 0,t)} -async showContextMenuForSources(e,t,i,s){var r;if(!e.length)return Promise.resolve(null);const n=e[0],o=(0,y.merge)((0,y.clone)(this._options.contextMenu),i||{}),a=new ke.ActionsProvider(this._chart,o);if(n===this._chartUndoModel().crossHairSource())return n.handleContextMenuEvent(t),Promise.resolve(null);{const i=await a.contextMenuActionsForSources(e,t,null==s?void 0:s.origin);if(0===i.length)return Promise.resolve(null);{let e;return e=n instanceof ft.Series?{menuName:"ObjectTreeContextMenu",detail:{type:"series",id:n.instanceId()}}:(0,V.isLineTool)(n)?{menuName:"ObjectTreeContextMenu",detail:{type:"shape",id:null!==(r=null==n?void 0:n.id())&&void 0!==r?r:null}}:{menuName:"ObjectTreeContextMenu",detail:{type:"study",id:(null==n?void 0:n.id())||null}},he.ContextMenuManager.createMenu(i,void 0,e).then((e=>(e.show(t),e)))}}}leftPriceAxisesContainer(){return this._lhsPriceAxisesContainer}rightPriceAxisesContainer(){return this._rhsPriceAxisesContainer}setPriceAxisSizes(e,t,i){this._priceAxisesContainer(e).setSizes(t,i)}state(){return(0,r.ensureNotNull)(this._state)}hasState(){return null!==this._state}setState(e){this._state!==e&&(this.hasState()&&this._unsubscribeFromState(),this._state=e,this.hasState()&&(this._subscribeToState(),this.updatePriceAxisWidgetsStates()))}getScreenshotData(e){var t,i,s,r;const n=[],o=[];let a,l=[];const c=this.state().sourcesByGroup().priceSources().slice().reverse(),h=this._chart.properties().childs().paneProperties.childs().legendProperties.childs();for(const d of c){const c=d.statusView();if((0,B.isStudy)(d)&&(h.showLegend.value()||(null==e?void 0:e.showCollapsedStudies))){const s=h.showStudyTitles.value(),r=s;if(d.properties().childs().visible.value()&&c&&r){n.push(s?d.statusProvider(null==e?void 0:e.status).text():"");const r=Ae.enabled("use_last_visible_bar_value_in_legend")&&null!==(i=null===(t=this._chartModel().timeScale().visibleBarsStrictRange())||void 0===t?void 0:t.lastBar())&&void 0!==i?i:null,a=d.valuesProvider().getValues(r);o.push(a)}}else if(d===this._chartModel().mainSeries()&&c&&h.showSeriesTitle.value()){a=d.statusProvider((null==e?void 0:e.status)||{}).text();const t=Ae.enabled("use_last_visible_bar_value_in_legend")&&null!==(r=null===(s=this._chartModel().timeScale().visibleBarsStrictRange())||void 0===s?void 0:s.lastBar())&&void 0!==r?r:null;l=d.valuesProvider().getValues(t)}}return{type:"pane",leftAxis:this._lhsPriceAxisesContainer.getScreenshotData(),rightAxis:this._rhsPriceAxisesContainer.getScreenshotData(),content:this._canvasBinding.canvasElement.toDataURL(),canvas:this._canvasBinding.canvasElement,contentWidth:this._size.width,contentHeight:this._size.height,studies:n,studiesValues:o,containsMainSeries:this.containsMainSeries(),mainSeriesText:a,mainSeriesValues:l}}updatePriceAxisWidgetsStates(){if(!this.hasState())return;const e=this._chartModel(),t=e.paneForSource(e.mainSeries());if(!t)return;const i=e.priceScaleSlotsCount(),s=this.state(),r=s.visibleLeftPriceScales(),n=s.visibleRightPriceScales() -;this._lhsPriceAxisesContainer.setScales(r,i.left,t.leftPriceScales().length,i.left+i.right),this._rhsPriceAxisesContainer.setScales(n,i.right,t.rightPriceScales().length,i.left+i.right)}updatePriceAxisWidgets(){this._lhsPriceAxisesContainer.update(),this._rhsPriceAxisesContainer.update()}update(){this.hasState()&&(this.updatePriceAxisWidgets(),null!==this._legendWidget&&this._legendWidget.update(),this.updateControls())}updateStatusWidget(e){this.hasState()&&null!==this._legendWidget&&(e.legendWidgetLayoutInvalidated()?this._legendWidget.updateLayout():this._legendWidget.update())}updateControls(){this.hasState()&&null!==this._paneControls&&this._paneControls.update()}updateThemedColors(e){this._themedTopColor=e.topColor,this._updateByThemedColors()}statusWidget(){return this._legendWidget}getElement(){return this._rowElement}canvasElement(){return this._canvasBinding.canvasElement}hasCanvas(e){return this._canvasBinding.canvasElement===e||this._topCanvasBinding.canvasElement===e}pinchStartEvent(){null===this._paneWidgetsSharedState.scrollingPane()&&null===this._paneWidgetsSharedState.pinchingPane()&&(this._onTouchEvent(),this._options.handleScale.pinch&&(this._chartModel().stopTimeScaleAnimation(),this._prevPinchScale=1,this._pinching=!0,this._wasPinched=!0,this._paneWidgetsSharedState.setPinchingPane(this)))}pinchEvent(e,t,i,s){if(null!==this._paneWidgetsSharedState.scrollingPane()||this._paneWidgetsSharedState.pinchingPane()!==this)return;if(this._onTouchEvent(),!this._options.handleScale.pinch)return;const r=10*(s-this._prevPinchScale);this._prevPinchScale=s,this._chartModel().zoomTime(e.x,r,!0),this._prevPinchScale=s}pinchEndEvent(){null===this._paneWidgetsSharedState.scrollingPane()&&this._paneWidgetsSharedState.pinchingPane()===this&&(this._onTouchEvent(),this._pinching=!1,this._paneWidgetsSharedState.setPinchingPane(null))}mouseClickEvent(e){this._onMouseEvent(),this._mouseClickOrTapEvent(e)}tapEvent(e){this._preventTouchEventsExceptPinch()||(this._onTouchEvent(),this._mouseClickOrTapEvent(e))}mouseDownEvent(e){this._onMouseEvent(),this.hasState()&&this._mouseDownOrTouchStartEvent(e,this._dataSourceAtPoint(e.localX,e.localY))}touchStartEvent(e){if(this._paneWidgetsSharedState.startTouch(this),this._preventTouchEventsExceptPinch())return;const t=!this._trackCrosshairOnlyAfterLongTap&&null!==Nt&&Nt.stateId===this.state().id()&&Math.abs(Nt.x-e.localX)+Math.abs(Nt.y-e.localY)<5;this._onTouchEvent(),this._chart.setActivePaneWidget(this);const i=this._dataSourceAtPoint(e.localX,e.localY);if(t){const t=this._chartModel().crossHairSource();null!==i&&i.source===t||t.selectPointMode().value()!==K.SelectPointMode.None?this.startTrackingMode(new F.Point(e.localX,e.localY),new F.Point(e.localX,e.localY)):!this._chart.readOnly()&&null!==i&&(0,V.isLineTool)(i.source)&&i.source.userEditEnabled()&&this._chartUndoModel().selectionMacro((e=>{e.clearSelection(),e.addSourceToSelection(i.source,i.hittest.data())}))}this._mouseDownOrTouchStartEvent(e,i),this._mouseOrTouchMoveEvent(e)}mouseUpEvent(e){this._onMouseEvent(), -this._mouseUpOrTouchEndEvent(e)}touchEndEvent(e){this._paneWidgetsSharedState.endTouch(this),this._preventTouchEventsExceptPinch()||(this._onTouchEvent(),this._mouseOrTouchLeaveEvent(e),this._mouseUpOrTouchEndEvent(e))}mouseMoveEvent(e){this._onMouseEvent(),this._mouseOrTouchMoveEvent(e)}pressedMouseMoveEvent(e){this._onMouseEvent(),this._pressedMouseOrTouchMoveEvent(e)}touchMoveEvent(e){this._preventTouchEventsExceptPinch()||(this._onTouchEvent(),this._pressedMouseOrTouchMoveEvent(e))}mouseLeaveEvent(e){this._onMouseEvent(),this._updateHoveredSource(null,new $.EnvironmentState(e)),this._mouseOrTouchLeaveEvent(e)}mouseDoubleClickEvent(e){this._onMouseEvent(),this._mouseDoubleClickOrDoubleTapEvent(e)}wheelClickEvent(e){if(this._chart.readOnly())return;const t=this._dataSourceAtPoint(e.localX,e.localY);if(null===t||t.isCustom)return;if((t.hittest.target()||0)<=G.HitTarget.MovePointBackground)return;const i=new $.EnvironmentState(e),s=t.hittest.eraseMarker();if(i.mod()&&void 0!==s&&t.source.processErase)return void t.source.processErase(this._chartUndoModel(),s);const n=this._chartUndoModel();n.selection().isSelected(t.source)||n.selectionMacro((e=>{e.clearSelection();const i=(0,r.ensureNotNull)(t.source);e.addSourceToSelection(i,Dt(t,i))})),this._chart.removeSelectedSources()}doubleTapEvent(e){this._preventTouchEventsExceptPinch()||(this._onTouchEvent(),this._mouseDoubleClickOrDoubleTapEvent(e))}longTapEvent(e){if(null===this._state||this._preventTouchEventsExceptPinch())return;if(this._onTouchEvent(),this._longTap=!0,null!==this._startTrackPoint||!this._trackingModeShouldBeActive())return;const t=this._chartModel().selection();if(!t.isEmpty()){const i=this._dataSourceAtPoint(e.localX,e.localY);if(null!==i&&t.isSelected(i.source))return}this.startTrackingMode(new F.Point(e.localX,e.localY),new F.Point(e.localX,e.localY),new $.EnvironmentState(e))}mouseEnterEvent(e){if(this._onMouseEvent(),!this.hasState())return;this._chart.setActivePaneWidget(this);const t=this._dataSourceAtPoint(e.localX,e.localY);this._updateHoveredSource(t,new $.EnvironmentState(e)),this._setCursorPosition(e.localX,e.localY,new $.EnvironmentState(e))}contextMenuEvent(e){this._onMouseEvent(),this._contextMenuEvent(e)}touchContextMenuEvent(e){this._preventTouchEventsExceptPinch()||(this._onTouchEvent(),this._contextMenuEvent(e))}mouseDownOutsideEvent(e){this._processOutsideClick(null,e)}touchStartOutsideEvent(e){this._processOutsideClick(null,e)}cancelZoom(){this._chartModel().crossHairSource().clearSelection(),this._firstZoomPoint=null,this._preventCrossHairMove()&&this._clearCursorPosition()}startTrackingMode(e,t,i){this._startChangeLineToolParams=null,this._startMoveSourceParams=null,this._currentChangingLineToolHitTest=null,this._currentMovingHitTest=null,this._chartUndoModel().selectionMacro((e=>e.clearSelection())),this._startTrackPoint=e,this._exitTrackingModeOnNextTry=!1,this._setCursorPosition(t.x,t.y,i),this._initCrossHairPosition=this._chartModel().crossHairSource().currentPoint()}setDragToAnotherPaneCursor(){ -this._setCursorClassName("grabbing")}cloneLineTools(e,t){return this._chartUndoModel().cloneLineTools(e,t)}exitTrackingMode(){null!==this._state&&null!==this._startTrackPoint&&(this._exitTrackingModeOnNextTry=!0,this._tryExitTrackingMode())}trackingModeEnabled(){return null!==this._state&&null!==this._startTrackPoint}addCustomWidgetToLegend(e,t){this._options.legendWidgetEnabled&&(this._customLegendWidgetsFactoryMap.set(e,t),null!==this._legendWidget&&this._legendWidget.addCustomWidgetToLegend(e,t))}containsMainSeries(){return!!this.hasState()&&this.state().containsMainSeries()}paint(e){if(!this._chartUndoModel()||!this.hasState()||0===this._size.width||0===this._size.height)return;this._canvasBinding.applySuggestedBitmapSize(),this._topCanvasBinding.applySuggestedBitmapSize(),this._state&&(e.priceScaleSideMaxLevel("left")>N.InvalidationLevel.Cursor||e.priceScaleSideMaxLevel("right")>N.InvalidationLevel.Cursor)&&(this._recalculatePriceScales((0,vt.viewportChangeEvent)()),null!==Nt&&Nt.stateId===this.state().id()&&this._setCursorPosition(Nt.x,Nt.y,Nt.envState));const t=e.fullInvalidation();if(t>N.InvalidationLevel.Cursor&&null!==Nt&&Nt.stateId===this.state().id()){const e=this._dataSourceAtPoint(Nt.x,Nt.y);this._updateHoveredSource(e,(0,mt.globalEnvironmentState)())}if(this._lhsPriceAxisesContainer.paint(e.getterForPriceScaleInvalidationLevelBySide("left")),this._rhsPriceAxisesContainer.paint(e.getterForPriceScaleInvalidationLevelBySide("right")),t===N.InvalidationLevel.None)return;const i=this._state&&(this._state.maximized().value()||!this._state.collapsed().value());if(t>N.InvalidationLevel.Cursor){const e=(0,r.ensureNotNull)(this._canvasBinding.canvasElement.getContext("2d"));e.setTransform(1,0,0,1,0,0),this._makeSureIsUpdated();const t=this._canvasRenderParams();this._drawBackground(e,t),i&&this._drawSources(e,t)}if(null!==this._state){const e=(0,r.ensureNotNull)(this._topCanvasBinding.canvasElement.getContext("2d"));e.setTransform(1,0,0,1,0,0);const t=this._topCanvasRenderParams();e.clearRect(0,0,Math.ceil(this._size.width*t.pixelRatio),Math.ceil(this._size.height*t.pixelRatio)),i&&this._drawSeriesTopViews(e,t),this._drawCrossHair(e,t),i&&this._drawActiveLineTools(e,t)}}cancelCreatingLineTool(){const e=this._chartUndoModel(),t=this._chartUndoModel().lineBeingCreated();if(t)if(t.pointsCount()<=0&&!(0,E.isLineDrawnWithPressedButton)(t.toolname)){const i=t.points();if(i.length>2){const s=i[i.length-2];e.continueCreatingLine(s),this._finishTool(t)}else e.cancelCreatingLine()}else e.cancelCreatingLine();null!==this._firstZoomPoint&&this.cancelZoom(),this.setCursorForTool()}drawRightThere(e){if((0,E.isLineToolName)(e)&&this.hasState()){const t=this._chartUndoModel(),i=t.crossHairSource(),s=t.model().magnet().align(i.price,i.index,this.state());t.createLineTool({pane:this.state(),point:{index:i.index,price:s},linetool:e})}}cancelMeasuring(){this._chartUndoModel().crossHairSource().clearMeasure(),(0,K.resetToCursor)(),this.setCursorForTool()}async setErrorMessage(e){var t,i,s -;e&&!this._errorRenderer&&(this._errorRenderer=this._createErrorBlock()),null===(t=await this._errorRenderer)||void 0===t||t.update({message:null==e?void 0:e.message,icon:(null===(i=this._state)||void 0===i?void 0:i.containsMainSeries())||(null===(s=this._state)||void 0===s?void 0:s.maximized().value())?null==e?void 0:e.icon:void 0,backgroundColor:`linear-gradient(${this._chartModel().backgroundTopColor().value()}, ${this._chartModel().backgroundColor().value()})`,textColor:this._chartModel().dark().value()?Pt:wt,solutionId:null==e?void 0:e.solutionId})}collapsedHeight(){var e,t;return Math.max(Math.ceil(null!==(t=null===(e=this._paneControls)||void 0===e?void 0:e.bottomWithMargin())&&void 0!==t?t:0),33)}_topCanvasRenderParams(){return{pixelRatio:(0,J.getBindingPixelRatio)(this._topCanvasBinding),physicalWidth:this._topCanvasBinding.canvasElement.width,physicalHeight:this._topCanvasBinding.canvasElement.height,cssWidth:this._chartModel().timeScale().width(),cssHeight:this.height()}}_canvasRenderParams(){return{pixelRatio:(0,J.getBindingPixelRatio)(this._canvasBinding),physicalWidth:this._canvasBinding.canvasElement.width,physicalHeight:this._canvasBinding.canvasElement.height,cssWidth:this._chartModel().timeScale().width(),cssHeight:this.height()}}_tryExitTrackingMode(e){this._exitTrackingModeOnNextTry&&(this._startTrackPoint=null,e||this._clearCursorPosition())}_tryStartMeasure(e,t,i,s,r){return!(!(0,K.toolIsMeasure)(K.tool.value())||t.startMeasurePoint())&&(e.isTouch||this._preventCrossHairMove()||this._setCursorPosition(e.localX,e.localY,i),s=this._chartModel().magnet().align(s,r,this.state()),t.startMeasuring({price:s,index:r},this.state()),!0)}_tryFinishMeasure(e,t){if(t.startMeasurePoint()&&!t.endMeasurePoint()){let i=t.price;const s=t.index;return i=this._chartModel().magnet().align(i,s,this.state()),t.finishMeasure({price:i,index:s}),e.isTouch?(0,K.resetToCursor)():this._needResetMeasureLater=!0,this._preventCrossHairMove()&&this._clearCursorPosition(),!0}return!1}_tryStartZoom(e,t,i,s){const r=this._chart.model().model().zoomEnabled();if("zoom"===K.tool.value()&&r){const r=this._chartUndoModel(),n=r.timeScale().indexToCoordinate(i)-.5*r.timeScale().barSpacing();return this._firstZoomPoint={price:t,index:i,x:n,y:e.localY},this._preventCrossHairMove()||this._setCursorPosition(e.localX,e.localY,s),this._chartModel().crossHairSource().startSelection(this.state()),!0}return!1}_finishZoom(e){const t=this.state(),i=t.defaultPriceScale(),s=(0,r.ensureNotNull)(t.mainDataSource()).firstValue(),n=i.coordinateToPrice(e.localY,(0,r.ensureNotNull)(s)),o=this._chartUndoModel(),a=Math.round(o.timeScale().coordinateToIndex(e.localX)),l=(0,r.ensureNotNull)(this._firstZoomPoint);a!==l.index&&o.zoomToViewport(l.index,a,l.price,n,t),this._chartModel().crossHairSource().clearSelection(),this._firstZoomPoint=null,(0,K.resetToCursor)(),this._preventCrossHairMove()&&this._clearCursorPosition()}_tryFinishZoom(e){return null!==this._firstZoomPoint&&(this._finishZoom(e),!0)}_tryHandleEraserMouseDown(e,t){ -if(!("eraser"!==K.tool.value()||e.isCustom||(i=e.source,i&&i.customization&&i.customization.disableErasing))){const i=this._chartUndoModel();if((0,V.isLineTool)(e.source)||(0,B.isStudy)(e.source)){const s=e.hittest.eraseMarker();return t.mod()&&void 0!==s&&e.source.processErase?e.source.processErase(i,s):i.removeSource(e.source,!1),!0}}var i;return!1}_tryStartChangingLineTool(e,t,i,s){var n,o,a;if(e.isTouch&&null!==this._startTrackPoint)return!1;const l=t.hittest;if((!e.isTouch||!this._preventSourceChange)&&l&&(0,V.isLineTool)(t.source)&&l.target()===G.HitTarget.ChangePoint){const c=this._chartUndoModel(),h=(0,r.ensure)(null===(n=this.state().mainDataSource())||void 0===n?void 0:n.firstValue()),d=(0,r.ensureNotNull)(t.source.priceScale()).coordinateToPrice(e.localY,h);c.selectionMacro((e=>{e.clearSelection(),e.addSourceToSelection(t.source,l.data())}));let u=d;t.source.priceScale()===c.mainSeries().priceScale()&&(u=c.model().magnet().align(d,s,this.state()));const p=null===(o=l.data())||void 0===o?void 0:o.nonDiscreteIndex;p&&(s=c.timeScale().coordinateToFloatIndex(e.localX));const _=null===(a=l.data())||void 0===a?void 0:a.pointIndex;return this._startChangeLineToolParams={source:t.source,startPoint:{index:s,price:u,nonDiscreteIndex:p},screenPoint:{x:e.localX,y:e.localY},pointIndex:_,envState:i},!0}return this._startChangeLineToolParams=null,!1}_tryStartCloning(e,t,i,s){if(i.mod()){const t=this._chartUndoModel().selection().dataSources().filter((e=>e.cloneable()));if(s&&s.cloneable()&&t.push(s),t.length>0)return this._clonningAtMoveLineTools=t.map((e=>e.id())),this._startCloningPoint=new F.Point(e.localX,e.localY),!0}return!1}_tryFinishClonning(e,t,i){const s=this._chartUndoModel(),n=this._chartModel();if(t.mod()&&this._clonningAtMoveLineTools){const o=new F.Point(e.localX,e.localY),a=(0,r.ensureNotNull)(this._startCloningPoint).subtract(o).length(),l=[];for(const e of this._clonningAtMoveLineTools){const t=n.dataSourceForId(e);null!==t&&l.push(t)}if(0===l.length)return!1;if(a>8){const n=this.cloneLineTools(l,!0).map((e=>(0,r.ensureNotNull)(s.model().dataSourceForId(e))));s.selectionMacro((e=>{e.clearSelection();let t=null;n.forEach((s=>{null===t&&(t=Dt(i,s)),e.addSourceToSelection(s,t)}))}));const o=new F.Point(e.localX,e.localY),a=(0,r.ensureNotNull)(n[0].priceScale()),c=(0,r.ensureNotNull)(this.state().mainDataSource()).firstValue(),h={index:s.timeScale().coordinateToIndex(e.localX),price:a.coordinateToPrice(e.localY,(0,r.ensureNotNull)(c))};s.startMovingSources(n,{logical:h,screen:o},null,t),this._clonningAtMoveLineTools=null,this._startCloningPoint=null}return!0}return!1}_mouseDownEventForLineTool(e,t,i,s){var n,o;const a=K.tool.value();if(!this.hasState()||(0,E.isLineToolDrawWithoutPoints)(a))return;const l=this._chartUndoModel();let c=!1,h=null;(0,K.hideAllDrawings)().value()&&(0,H.toggleHideMode)(),(0,K.lockDrawings)().setValue(!1),e.isTouch&&!e.stylus&&((0,E.isLineToolName)(a)&&!(0,E.isLineDrawnWithPressedButton)(a)||l.lineBeingCreated())&&this._initToolCreationModeParams(e);const d=l.lineBeingCreated() -;if(d&&!(0,E.isLineDrawnWithPressedButton)(d.toolname)){const a=(0,r.ensure)(null===(n=d.ownerSource())||void 0===n?void 0:n.firstValue());if(e.isTouch&&!e.stylus){if(!this._startTouchPoint){this._startTouchPoint=new F.Point(e.pageX,e.pageY);const t=d.points(),i=t[t.length-1],s=l.timeScale().indexToCoordinate(i.index),n=(0,r.ensureNotNull)(d.priceScale()).priceToCoordinate(i.price,a);return void(this._initCrossHairPosition=new F.Point(s,n))}}else if(!e.isTouch){h=d;const n=l.model().paneForSource(d);if(n!==this._state&&null!==n){const i=this._externalPaneXCoord(n,e.localX),s=this._externalPaneYCoord(n,e.localY);c=l.continueCreatingLine({index:Math.round(l.timeScale().coordinateToIndex(i)),price:(0,r.ensure)(null===(o=d.priceScale())||void 0===o?void 0:o.coordinateToPrice(s,a))},t)}else{const e=l.model().magnet().align(s,i,this.state());c=l.continueCreatingLine({index:i,price:e},t)}}}else if(!e.isTouch||e.stylus||(0,E.isLineDrawnWithPressedButton)(a)){const e={index:i,price:l.model().magnet().align(s,i,this.state())};h=l.createLineTool({pane:this.state(),point:e,linetool:a}),l.lineBeingCreated()||(c=!0)}const u=this._dataSourceAtPoint(e.localX,e.localY);h&&l.selectionMacro((e=>{e.addSourceToSelection((0,r.ensureNotNull)(h),null==u?void 0:u.hittest.data())})),c&&h&&(this._finishTool(h,u),e.preventDefault())}_handleSelectionMouseDownAndGetJustDeselectedSource(e,t,i){const s=this._chartUndoModel();let r=null;return(null===t||t.source.isSelectionEnabled())&&s.selectionMacro((s=>{!this._preventSourceChange&&null!==t&&(e.isTouch?t.hittest.target()>=G.HitTarget.MovePointBackground:t.hittest.target()>G.HitTarget.MovePointBackground)?(i.mod()||s.selection().isSelected(t.source)||s.clearSelection(),i.mod()&&s.selection().isSelected(t.source)?(r=t.source,s.removeSourceFromSelection(t.source)):s.addSourceToSelection(t.source,t.hittest.data()),s.selection().allSources().length>1&&(0,Se.trackEvent)("GUI","Multiselect","Click Select")):i.mod()||s.clearSelection()})),r}_processMouseMoveWhileZoom(e,t){this._preventCrossHairMove()||this._setCursorPosition(e.localX,e.localY,t)}_updateCommonTooltip(e,t){let i=null;if(null!==e&&null!==e.hittest){const t=e.hittest.data();t&&(i=t.tooltip||null)}if(null===this._prevTooltipData&&null===i)return;if(null===i||""===i.text)return this._prevTooltipData=null,void(0,ut.hide)(t);if(this._prevTooltipData&&(0,O.default)(i,this._prevTooltipData))return;this._prevTooltipData=i;const s=(0,y.clone)(i);if(void 0!==s.rect){const e=this._paneCell.getBoundingClientRect();s.rect.x+=e.left,s.rect.y+=e.top}(0,ut.show)(s)}_setCursorPositionOnExternalPane(e,t,i,s){t=this._externalPaneXCoord(e,t),i=this._externalPaneYCoord(e,i);this._chart.paneByState(e)._setCursorPosition(t,i,s)}_setCursorPosition(e,t,i){this._updateLastCrosshairPosition(e,t,i),this._chartModel().setAndSaveCurrentPosition(this._correctXCoord(e),this._correctYCoord(t),this.state(),i)}_updateLastCrosshairPosition(e,t,i){const s=this.state().id();Nt={x:e,y:t,envState:i,stateId:s}}_setCursorClassName(e){let t="";e&&(t="pane--cursor-"+e), -this._currentCursorClassName!==t&&(this._currentCursorClassName&&this._paneCell.classList.remove(this._currentCursorClassName),t&&this._paneCell.classList.add(t),this._currentCursorClassName=t,this._paneCell.style.cursor)}_processMouseUpOrTouchEndHandler(e){const t=this._dataSourceAtPoint(e.localX,e.localY);null!==t&&t.hittest.tryCallMouseUpOrTouchEndHandler(e)}_crossHairShouldBeVisible(){const e=this._chartModel().crossHairSource();return(0,E.isLineToolName)(K.tool.value())||(0,K.toolIsMeasure)(K.tool.value())||e.startMeasurePoint()&&!e.endMeasurePoint()||null!==this._firstZoomPoint||null!==this._chartModel().lineBeingEdited()||null!==this._chartModel().lineBeingCreated()}_clearCursorPosition(){Nt=null,this._chartModel().clearCurrentPosition()}_dataSourceAtPoint(e,t){if(!this.hasState())return null;const i={result:null},s=this._chartUndoModel();if((0,E.isLineToolName)(K.tool.value())||null!==s.lineBeingCreated())return i.result;if(this._currentChangingLineToolHitTest)return this._currentChangingLineToolHitTest;if(this._currentMovingHitTest)return this._currentMovingHitTest;const r=this.state(),n=r.height(),o=r.width();this._makeSureIsUpdated();const a=Vt.bind(null,i),l=this._canvasRenderParams(),c=new F.Point(e,t);if(!this.state().maximized().value()&&this.state().collapsed().value()||(0,U.lastMouseOrTouchEventInfo)().isTouch&&(K.activePointSelectionMode.value()!==K.SelectPointMode.None||null!==this._startTrackPoint))return this._hitTestSources(l,[s.crossHairSource()],c,a,!1),i.result;const h=r.sourcesByGroup(),d=s.selection();this._hitTestSources(l,d.dataSources(),c,a,!1),this._hitTestSources(l,d.customSources(),c,a,!0);const u=new Set(d.allSources().map((e=>e.id())));this._hitTestSources(l,[s.crossHairSource()],c,a,!1,u),this._hitTestSources(l,r.customSources(q.CustomSourceLayer.Topmost),c,a,!0,u),this._hitTestSources(l,h.tradingSources(),c,a,!1,u),this._hitTestSources(l,r.customSources(q.CustomSourceLayer.Foreground),c,a,!0,u);const p=[...this._chartModel().multiPaneSources(r),...h.hitTestSources()];if(this._hitTestSources(l,p,c,a,!1,u),this.containsMainSeries()){const e=s.activeStrategySource().value();if(null!==e){const t=e.strategyOrdersPaneView();if(null!==t){const s=t.renderer(n,o);if(null!==s){const t=s.hitTest(c,l);t&&Vt(i,t,e,s,!1)}}}}return null===i.result&&this._hitTestSources(l,r.customSources(q.CustomSourceLayer.Background),c,a,!0,u),i.result}_hitTestSources(e,t,i,s,n,o){const a=(0,r.ensureNotNull)(this._state),l=a.height(),c=a.width();for(let r=t.length-1;r>=0;--r){const h=t[r];if(void 0!==o&&o.has(h.id()))continue;const d=h.paneViews(a);if(null!==d&&0!==d.length)for(let t=d.length-1;t>=0;--t){const r=d[t].renderer(l,c);if(r&&r.hitTest){const t=r.hitTest(i,e);null!==t&&s(t,h,r,n)}}}}_tryStartMovingLineTool(e,t,i,s){var n;if(null===t.source||!t.source.movable()||null!==this._startTrackPoint)return!1;if(!this._preventSourceChange){const o=this._chartUndoModel(),a=(0,r.ensureNotNull)((0,r.ensureNotNull)(this._state).mainDataSource()).firstValue(),l=(0, -r.ensureNotNull)(t.source.priceScale()).coordinateToPrice(e.localY,(0,r.ensureNotNull)(a));let c=(t.source.isSelectionEnabled()?o.selection().allSources():[t.source]).filter(gt);const h=c.filter(V.isLineTool);c=h.length>0?h:c.includes(t.source)?[t.source]:[c[0]];const d=new F.Point(e.localX,e.localY),u={index:s,price:l},p=null===(n=t.hittest.data())||void 0===n?void 0:n.activeItem;return this._startMoveSourceParams={source:c,startPoint:{logical:u,screen:d},activeItem:void 0===p?null:p,envState:i},!0}return this._startMoveSourceParams=null,!1}_chartModel(){return this._chart.model().model()}_chartUndoModel(){return this._chart.model()}_externalPaneXCoord(e,t){t+=this._div.getBoundingClientRect().left+document.body.scrollLeft;const i=(0,r.ensureNotNull)(this._chart.paneByState(e)),s=i._div.getBoundingClientRect().left+document.body.scrollLeft;return i._correctXCoord(t-s)}_externalPaneYCoord(e,t){t+=this._div.getBoundingClientRect().top+document.body.scrollTop;const i=(0,r.ensureNotNull)(this._chart.paneByState(e)),s=i._div.getBoundingClientRect().top+document.body.scrollTop;return i._correctYCoord(t-s)}_correctXCoord(e){return Math.max(0,Math.min(e,this._size.width-1))}_correctYCoord(e){return Math.max(0,Math.min(e,this._size.height-1))}_processScroll(e){if(!this._chart.model().model().scrollEnabled())return;const t=performance.now();this._startScrollingPos||this._preventScroll()||(this._startScrollingPos={x:e.clientX,y:e.clientY,timestamp:t,localX:e.localX,localY:e.localY});const i=this._chartUndoModel(),s=this._chartModel().timeScale();let r=this.state().defaultPriceScale();if(this._startScrollingPos&&!this._isScrolling&&(this._startScrollingPos.x!==e.clientX||this._startScrollingPos.y!==e.clientY)){if(i.beginUndoMacro(Ct,!0),null===this._scrollXAnimation&&this._options.useKineticScroll){const e=s.barSpacing();this._scrollXAnimation=new nt(.2/e,7/e,.997,15/e),this._scrollXAnimation.addPosition(s.rightOffset(),this._startScrollingPos.timestamp)}return i.selection().isEmpty()||(r=i.selection().allSources()[0].priceScale()),null===r||r.isEmpty()||(this._scrollPriceScale=r,i.startScrollPrice(this.state(),r,e.localY)),i.startScrollTime(e.localX),this._isScrolling=!0,this.setCursorForTool(),void this._paneWidgetsSharedState.setScrollingPane(this)}this._isScrolling&&(null!==this._scrollPriceScale&&i.scrollPriceTo(this.state(),this._scrollPriceScale,e.localY),i.scrollTimeTo(e.localX),null!==this._scrollXAnimation&&this._scrollXAnimation.addPosition(s.rightOffset(),t))}_finishScroll(){const e=this._chartUndoModel();e.endScrollTime(),null!==this._scrollPriceScale&&e.endScrollPrice(this.state(),this._scrollPriceScale),e.endUndoMacro(),this._isScrolling=!1,this._startScrollingPos=null,this._scrollPriceScale=null,this.setCursorForTool(),this._paneWidgetsSharedState.setScrollingPane(null)}_endScroll(e){if(!this._isScrolling)return!1;this._finishScroll();const t=this._scrollUndoCommandInStack(),i=performance.now(),s=this._chartUndoModel().timeScale() -;return null!==this._scrollXAnimation&&(this._scrollXAnimation.start(s.rightOffset(),i),this._scrollXAnimation.finished(i)||(this._chartModel().setTimeScaleAnimation(this._scrollXAnimation),this._scrollXAnimation=null)),t}_preventScroll(){return this._trackCrosshairOnlyAfterLongTap&&this._longTap||this._contextMenuOpenedOnLastTap||(0,E.isLineToolName)(K.tool.value())||Boolean(this._chartUndoModel().lineBeingCreated())||null!==this._startTrackPoint}_isSelectPointModeEnabled(){return this._chartUndoModel().crossHairSource().selectPointMode().value()!==K.SelectPointMode.None}_preventCrossHairMove(){return!!this._trackCrosshairOnlyAfterLongTap&&(null===this._chart.trackingModePaneWidget()&&(!!this._contextMenuOpenedOnLastTap||!this._crossHairShouldBeVisible()&&null===this._startTrackPoint))}_finishTool(e,t=null){const i=this._chartUndoModel(),s=e.toolname;if(s===K.tool.value()&&(0,K.resetToCursor)(),this._preventCrossHairMove()&&this._clearCursorPosition(),i.selectionMacro((i=>{i.addSourceToSelection(e,Dt(t,e))})),(0,E.isTextToolName)(s)){const t=i.createUndoCheckpoint();this._chart.showChartPropertiesForSource(e,ht.TabNames.text,void 0,t).then((e=>{0}))}this._lastFinishedToolId=e.id(),(0,u.emit)("drawing_event",e.id(),"create"),(0,ct.trackDrawingCreated)(e)}_alignSourcesThatBeingMoved(e,t,i,s){const r=this._chartUndoModel(),n=r.timeScale().coordinateToIndex(t);r.model().sourcesBeingMoved().forEach((e=>{var o;let a=n,l=e.convertYCoordinateToPriceForMoving(i,this.state().mainDataSource());if(null!==l){if((0,B.isStudy)(e)){const e=r.mainSeries(),t=e.bars().firstIndex(),i=e.bars().lastIndex();null!==t&&null!==i&&(a=Math.min(Math.max(n,t),i)),l=this._chartModel().magnet().align(l,n,this.state())}null!==this._currentMovingHitTest&&void 0!==(null===(o=this._currentMovingHitTest.hittest.data())||void 0===o?void 0:o.cursorType)||this.setCursorForTool(),r.moveSources({screen:new F.Point(t,i),logical:{index:a,price:l}},s)}}))}_resetMeasureIfRequired(){this._needResetMeasureLater&&((0,K.resetToCursor)(),this._needResetMeasureLater=!1)}_makeSureIsUpdated(){var e;const t=this.state(),i=[...t.dataSources(),...t.customSources()],s=t.height(),r=t.width();for(const n of i){const i=n.paneViews(t);if(null!==i)for(const t of i)null===(e=t.makeSureIsUpdated)||void 0===e||e.call(t,s,r)}}_drawBackground(e,t){const i=Math.ceil(t.pixelRatio*this._size.width),s=Math.ceil(t.pixelRatio*this._size.height),r=this._chartModel(),n=r.backgroundTopColor().value(),o=r.backgroundColor().value();n===o?(0,J.clearRect)(e,0,0,i+1,s+1,o):(0,Q.clearRectWithGradient)(e,0,0,i+1,s+1,n,o)}_drawWatermark(e,t){const i=this._chartModel().watermarkSource();if(null===i)return;const s=this.state();if(!s.containsMainSeries())return;const r=i.paneViews(),n=s.height(),o=s.width();for(const i of r){e.save();const s=i.renderer(n,o);s&&s.draw(e,t),e.restore()}}_drawCrossHair(e,t){const i=this._chartUndoModel().crossHairSource();i.invalidateLockPosition(),i.visible||null===K.crosshairLock.value()||i.updateAllViews((0,vt.sourceChangeEvent)(i.id())), -this._drawSourceImpl(e,t,Mt,It,i)}_drawActiveLineTools(e,t){const i=this._chartModel(),s=[i.lineBeingCreated(),i.lineBeingEdited(),...i.sourcesBeingMoved(),i.customSourceBeingMoved()].filter((e=>!!e));for(const r of s){(i.paneForSource(r)===this.state()||(0,Y.isDataSource)(r)&&r.isMultiPaneEnabled())&&this._drawSourceImpl(e,t,Mt,It,r)}}_drawSeriesTopViews(e,t){this.state().containsMainSeries()&&this._drawSourceImpl(e,t,Lt,It,this._chartUndoModel().mainSeries())}_drawSources(e,t){const i=this.state(),s=i.model(),r=i.sourcesByGroup(),n=r.tradingSources(),o=[...s.multiPaneSources(i),...r.generalSources()],a=r.phantomSources(),l=i.customSources(q.CustomSourceLayer.Background).slice(),c=i.customSources(q.CustomSourceLayer.Foreground).slice(),h=i.customSources(q.CustomSourceLayer.Topmost).slice();{const e=s.panes();for(let t=e.length-1;t>=0;t--)e[t].createDrawingsCaches()}this._drawSourceImpl(e,t,Mt,It,s.gridSource()),this._drawWatermark(e,t);for(const i of l)this._drawSourceImpl(e,t,Mt,Tt,i);for(const i of o)this._drawSourceImpl(e,t,Mt,Tt,i);for(const i of c)this._drawSourceImpl(e,t,Mt,Tt,i);for(const i of a)this._drawSourceImpl(e,t,Mt,Tt,i);const d=new Set;[s.lineBeingCreated(),s.lineBeingEdited(),...s.sourcesBeingMoved(),s.customSourceBeingMoved()].filter(y.notNull).forEach((e=>d.add(e.id())));let u=s.hoveredSource();null!==u&&((0,Y.isDataSource)(u)&&!u.showOnTopOnHovering()||d.has(u.id())||(0,Y.isDataSource)(u)&&!o.includes(u)?u=null:d.add(u.id()));const p=s.selection().allSources().filter((e=>!((0,Y.isDataSource)(e)&&!o.includes(e))&&!d.has(e.id())));p.forEach((e=>d.add(e.id())));{for(const i of l)this._drawSourceImpl(e,t,Mt,It,i,d);for(const i of o)this._drawSourceImpl(e,t,Mt,It,i,d);for(const i of c)this._drawSourceImpl(e,t,Mt,It,i,d);const i=s.activeStrategySource().value();i&&this.containsMainSeries()&&this._drawSourceImpl(e,t,kt,It,i)}for(const i of n)this._drawSourceImpl(e,t,Mt,Tt,i);for(const i of h)this._drawSourceImpl(e,t,Mt,Tt,i);for(const i of o)this._drawSourceImpl(e,t,At,It,i,d);for(const i of c)this._drawSourceImpl(e,t,At,It,i,d);for(const i of n)this._drawSourceImpl(e,t,Mt,It,i,d);for(const i of h)this._drawSourceImpl(e,t,Mt,It,i,d);for(const i of p)this._drawSourceImpl(e,t,Mt,It,i);for(const i of p)this._drawSourceImpl(e,t,At,It,i);u&&(this._drawSourceImpl(e,t,Mt,It,u),this._drawSourceImpl(e,t,At,It,u));for(const i of a)this._drawSourceImpl(e,t,Mt,It,i,d);{const e=s.panes();for(let t=e.length-1;t>=0;t--)e[t].clearDrawingCaches()}}_drawSourceImpl(e,t,i,s,r,n){if(n&&n.has(r.id()))return;const o=this.state(),a=o.height(),l=o.width(),c=i(r,this.state());if(c)for(const i of c){const r=i.renderer(a,l);r&&(e.save(),s(r,e,t),e.restore())}}_updateByThemedColors(){null!==this._legendWidget&&this._legendWidget.updateThemedColors(this._themedTopColor),null!==this._paneControls&&this._paneControls.updateThemedColors(this._themedTopColor)}_scrollUndoCommandInStack(){const e=this._chartUndoModel().undoHistory().undoStack();if(e.isEmpty())return!1;const t=e.head();if(!(t instanceof Z.UndoMacroCommand))return!1 -;if(t.isEmpty())return!1;const i=t.commands()[0];return i instanceof at.PriceScaleChangeUndoCommand||i instanceof ot.TimeScaleChangeUndoCommand}_onStateDestroyed(){this.setState(null)}_onDataSourcesCollectionChanged(){this._startMoveSourceParams=null}_processMouseEnterLeaveMoveHandlers(e,t){var i,s,r,n;null===this._prevHoveredHittest||this._prevHoveredHittest.renderer===(null==e?void 0:e.renderer)&&(null===(i=this._prevHoveredHittest.hittest.data())||void 0===i?void 0:i.activeItem)===(null===(s=e.hittest.data())||void 0===s?void 0:s.activeItem)||((0,G.tryCallHandler)(t,null===(r=this._prevHoveredHittest.hittest.data())||void 0===r?void 0:r.mouseLeaveHandler),this._prevHoveredHittest=null),t.isTouch||null!==e&&((null===(n=this._prevHoveredHittest)||void 0===n?void 0:n.renderer)!==e.renderer&&(e.hittest.tryCallMouseEnterHandler(t),this._prevHoveredHittest=e),e.hittest.tryCallMouseMoveHandler(t))}_startChangeOrMoveLineToolIfNeeded(){if(null!==this._startChangeLineToolParams){const e=this._startChangeLineToolParams;this._chartUndoModel().startChangingLinetool(e.source,e.startPoint,e.pointIndex,e.envState)}if(null!==this._startMoveSourceParams){const e=this._startMoveSourceParams;this._chartUndoModel().startMovingSources(e.source,e.startPoint,e.activeItem,e.envState)}this._startMoveSourceParams=null,this._startChangeLineToolParams=null}_trackingModeShouldBeActive(){return!(!this._trackCrosshairOnlyAfterLongTap||this._contextMenuOpenedOnLastTap||this._crossHairShouldBeVisible())&&this._longTap}_processOutsideClick(e,t){var i;let s=null;const r=this._chartModel();if(null!==e&&(s=e.isCustom?r.customSourceName(e.source):e.source.id()),null!==this._lastClickedSource&&this._lastClickedSource.id!==s){const e=this._lastClickedSource.id;let i=this._lastClickedSource.isCustom?r.customSourceForName(e):r.dataSourceForId(e);null!==i||this._lastClickedSource.isCustom||(i=r.dataSourceForId(e)),null!==i&&i.onClickOutside&&(i.onClickOutside(t),this._chartModel().updateSource(i))}this._lastClickedSource=null!==s?{id:s,isCustom:null!==(i=null==e?void 0:e.isCustom)&&void 0!==i&&i}:null}_mouseClickOrTapEvent(e){var t;if(!this.hasState())return;const i=this._dataSourceAtPoint(e.localX,e.localY),s=i&&i.source,n=this._chartUndoModel(),o=Boolean(null===(t=null==i?void 0:i.hittest.data())||void 0===t?void 0:t.hideCrosshairLinesOnHover);this._processOutsideClick(i,e),!this._isSelectPointModeEnabled()||o||e.isTouch&&this.trackingModeEnabled()&&!this._exitTrackingModeOnNextTry||n.crossHairSource().trySelectCurrentPoint(),null!==i&&i.hittest.tryCallClickOrTapHandler(e)&&n.model().updateSource((0,r.ensureNotNull)(s)),!e.isTouch||this._isSelectPointModeEnabled()||i&&i.source===n.crossHairSource()||this._tryExitTrackingMode(),s&&(0,V.isLineTool)(s)&&this._lastFinishedToolId!==s.id()&&(0,u.emit)("drawing_event",s.id(),"click"),this._resetMeasureIfRequired()}_mouseDownOrTouchStartEvent(e,t){var i,s,n,o,a;if(this._pressedMoveStage=1,e.isTouch&&(this._longTap=!1,this._exitTrackingModeOnNextTry=null!==this._startTrackPoint, -this._paneWidgetsSharedState.clearDraggingSource()),this._contextMenuOpenedOnLastTap=!1,this._lastFinishedToolId=null,this._chartModel().stopTimeScaleAnimation(),e.isTouch&&this._switchTrackingModeFromAnotherPaneIfNeeded(e),document.activeElement!==document.body&&document.activeElement!==document.documentElement)document.activeElement&&document.activeElement.blur?document.activeElement.blur():document.body.focus();else{const e=document.getSelection();null!==e&&e.removeAllRanges()}(0,u.emit)("mouse_down",{clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY,screenX:e.screenX,screenY:e.screenY}),this._updateCommonTooltip(null);const l=this._chartUndoModel(),c=new $.EnvironmentState(e);l.mainSeries().clearGotoDateResult();const h=this.state().defaultPriceScale();if(h.isEmpty()||l.timeScale().isEmpty())return;const d=l.crossHairSource();if(!e.isTouch&&!(0,E.isLineDrawnWithPressedButton)(K.tool.value())){const t=l.lineBeingCreated(),i=null!==t?l.model().paneForSource(t):null;null!==i&&i!==this._state?this._setCursorPositionOnExternalPane(i,e.localX,e.localY,c):this._setCursorPosition(e.localX,e.localY,c)}e.isTouch&&(0,E.isLineToolName)(K.tool.value())&&((0,E.isLineDrawnWithPressedButton)(K.tool.value())||null!==d.pane?(0,E.isLineDrawnWithPressedButton)(K.tool.value())&&this._clearCursorPosition():this._chart.updateCrossHairPositionIfNeeded());const p=(0,r.ensureNotNull)(this.state().mainDataSource()).firstValue();if(null===p)return void(this._chart.readOnly()||(this._handleSelectionMouseDownAndGetJustDeselectedSource(e,t,c),null!==t&&(0,lt.isPriceDataSource)(t.source)&&t.source.isDraggable()&&this._paneWidgetsSharedState.trySetDraggingSource(t.source,this)));let _=h.coordinateToPrice(e.localY,p),m=this._chartModel().timeScale().coordinateToIndex(e.localX);if(d.startMeasurePoint()&&d.endMeasurePoint()&&d.clearMeasure(),c.shift()&&(null===t||!(null===(s=null===(i=t.hittest.data())||void 0===i?void 0:i.hasOwnShortcutsBehaviourFor)||void 0===s?void 0:s.shiftKey))&&(0,K.toolIsCursor)(K.tool.value())&&l.selection().isEmpty()&&K.tool.setValue("measure"),(e.isTouch&&!e.stylus||!this._tryStartMeasure(e,d,c,_,m))&&(e.isTouch&&!e.stylus||!this._tryFinishMeasure(e,d))&&!this._tryFinishZoom(e)&&!this._tryStartZoom(e,_,m,c)){if(e.isTouch&&(null!==this._startTrackPoint?(this._initCrossHairPosition=d.currentPoint(),this._startTrackPoint=new F.Point(e.localX,e.localY)):this._isSelectPointModeEnabled()&&null===this._chart.trackingModePaneWidget()&&this.startTrackingMode(new F.Point(e.localX,e.localY),new F.Point(e.localX,e.localY),new $.EnvironmentState(e))),e.isTouch&&(this._preventSourceChange=null===t||!l.selection().isSelected(t.source)),!this._isSelectPointModeEnabled()&&!this._isScrolling){if(e.isTouch&&!e.stylus&&((0,K.toolIsMeasure)(K.tool.value())||null!==d.measurePane().value()))return void this._initToolCreationModeParams(e);if((0,E.isLineToolName)(K.tool.value())||l.lineBeingCreated())return c.shift()||l.selectionMacro((e=>e.clearSelection())),void this._mouseDownEventForLineTool(e,c,m,_)} -if(null!==t&&t.hittest.tryCallMouseDownOrTouchStartHandler(e),!this._chart.readOnly()){const i=this._handleSelectionMouseDownAndGetJustDeselectedSource(e,t,c);if(null!==t&&!this._preventSourceChange){const i=t.hittest.data();if(t.isCustom){if(t.hittest.hasPressedMoveHandler(e))return l.model().setMovingCustomSource(t.source,i),this._currentMovingHitTest=t,void l.selectionMacro((e=>{e.clearSelection(),e.addSourceToSelection((0,r.ensureNotNull)(t.source),(0,r.ensureNotNull)(i))}))}else if((null==i?void 0:i.areaName)===G.AreaName.SourceItemMove){const s=null==i?void 0:i.activeItem;if(void 0!==s)return l.startCustomMoving(t.source,s,e),this._currentMovingHitTest=t,void l.selectionMacro((e=>{e.clearSelection(),e.addSourceToSelection((0,r.ensureNotNull)(t.source),(0,r.ensureNotNull)(i))}))}}if(null!==t&&this._tryHandleEraserMouseDown(t,c))return;const s=null!==t&&(0,V.isLineTool)(t.source)&&t.source.isLocked&&t.source.isLocked();if(!((0,K.lockDrawings)().value()||s)&&null!==t&&!t.isCustom){if(!t.source.userEditEnabled())return;const s=null===(n=t.hittest.data())||void 0===n?void 0:n.snappingPrice,l=null===(o=t.hittest.data())||void 0===o?void 0:o.snappingIndex;let h=e.localY,d=e.localX;if(void 0!==s&&(h=(0,r.ensure)(null===(a=t.source)||void 0===a?void 0:a.priceScale()).priceToCoordinate(s,p),_=s),void 0!==l&&(d=this._chartModel().timeScale().indexToCoordinate(l),m=l),h===e.localY&&d===e.localX||(e={...e,localY:h,localX:d},this._setCursorPosition(e.localX,e.localY,c)),this._tryStartChangingLineTool(e,t,c,m))return void(this._currentChangingLineToolHitTest=t);if(this._currentChangingLineToolHitTest=null,(g=t.hittest.target())===G.HitTarget.MovePoint||g===G.HitTarget.MovePointBackground&&(0,U.lastMouseOrTouchEventInfo)().isTouch){if(this._tryStartCloning(e,t,c,i))return;if(this._tryStartMovingLineTool(e,t,c,m))return void(this._currentMovingHitTest=t);this._currentMovingHitTest=null}}if(null!==t&&(0,lt.isPriceDataSource)(t.source)&&t.source.isDraggable()&&this._paneWidgetsSharedState.trySetDraggingSource(t.source,this))return}var g;null!==t&&t.hittest.target()===G.HitTarget.Regular||(this._processing=!0)}}_mouseUpOrTouchEndEvent(e){var t,i;if(!this.hasState())return;this._pressedMoveStage=0;const s=e.isTouch&&null!==this._startTrackPoint,n=e.isTouch&&this._wasPinched;e.isTouch&&(this._wasPinched=!1,this._longTap=!1),this._startMoveSourceParams=null,this._startChangeLineToolParams=null,this._currentChangingLineToolHitTest=null,this._currentMovingHitTest=null;const o=this._chartUndoModel(),a=o.model().customSourceMovingHitTestData();null!==a||o.customMoveBeingProcessed()||this._processMouseUpOrTouchEndHandler(e),this._isSelecting=!1;const l=o.model(),c=l.crossHairSource(),h=this._dataSourceAtPoint(e.localX,e.localY);if(c.selection()&&null===this._firstZoomPoint){const e=this.state().lineToolsForArea(c.selection());o.selectionMacro((t=>{let i=null;e.forEach((e=>{null===i&&(i=Dt(h,e)),t.addSourceToSelection(e,i)}))})),c.clearSelection(),(0,Se.trackEvent)("GUI","Multiselect","Area Select")}(0,u.emit)("mouse_up",{ -clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY,screenX:e.screenX,screenY:e.screenY});const d=e.isTouch&&this._touchMove;e.isTouch&&(this._touchMove=!1);const p=new $.EnvironmentState(e),_=K.tool.value();if(e.isTouch&&((0,K.toolIsMeasure)(_)||null!==c.measurePane().value())){if(!d&&!e.stylus&&null===c.measurePane().value()&&c.pane!==this._state)return void this._setCursorPosition(e.localX,e.localY);if(!d&&!e.stylus&&this._tryStartMeasure(e,c,p,c.price,c.index))return;if((!d||e.stylus)&&this._tryFinishMeasure(e,c))return}if(e.isTouch&&!d&&!(0,E.isLineDrawnWithPressedButton)(_)&&(0,E.isLineToolName)(_)&&!o.lineBeingCreated()){if(this._chart.justActivated())return;if(c.pane!==this._state)return void this._setCursorPosition(e.localX,e.localY,p);const i=c.currentPoint(),s=this.state().defaultPriceScale(),n=(0,r.ensure)(null===(t=this.state().mainDataSource())||void 0===t?void 0:t.firstValue()),a={index:Math.round(o.timeScale().coordinateToIndex(i.x)),price:s.coordinateToPrice(i.y,n)},l=(0,r.ensureNotNull)(o.createLineTool({pane:this.state(),point:a,linetool:_}));return o.selectionMacro((e=>{e.addSourceToSelection(l)})),o.lineBeingCreated()||(this._finishTool(l,h),e.preventDefault()),void(this._startTouchPoint=null)}const m=o.lineBeingCreated();if(m&&!(0,E.isLineDrawnWithPressedButton)(m.toolname)&&e.isTouch&&(this._startTouchPoint||e.stylus)){if(this._startTouchPoint=null,!d||e.stylus){const t=m.points()[m.points().length-1],i=o.continueCreatingLine({index:t.index,price:t.price},new $.EnvironmentState(e));this._initCrossHairPosition=null,i&&(this._finishTool(m,h),e.preventDefault())}return}if(null!==this._firstZoomPoint&&this._firstZoomPoint.draggingMode)return void this._finishZoom(e);if(this._processing=!1,o.customMoveBeingProcessed())return void o.endCustomMoving();if(null!==a&&(a.beingMoved&&((0,G.tryCallHandler)(e,a.mouseUpHandler,a.touchEndHandler),this.setCursorForTool()),l.setMovingCustomSource(null,null),Ot(e,a)))return;if(l.lineBeingEdited())return o.endChangingLinetool(!1),void(this._preventCrossHairMove()&&this._clearCursorPosition());if((0,E.isLineDrawnWithPressedButton)(_)&&!this._isSelectPointModeEnabled()){const t=o.lineBeingCreated();null!==t&&((0,ct.trackDrawingCreated)(t),t.finish());const s=this.state().defaultPriceScale();if(s.isEmpty())return;if(!t)return;const n=(0,r.ensure)(null===(i=t.ownerSource())||void 0===i?void 0:i.firstValue()),a=s.coordinateToPrice(e.localY,n),l={index:Math.round(o.timeScale().coordinateToIndex(e.localX)),price:a};return void o.continueCreatingLine(l)}if(l.sourcesBeingMoved().length)return o.endMovingSource(!1,!1),l.sourcesBeingMoved().filter(V.isLineTool).forEach((e=>{this.setCursorForTool(e)})),void l.invalidate(N.InvalidationMask.cursor());if(!this._chart.readOnly()){const t=e.localX>=0&&e.localXG.HitTarget.MovePointBackground||(0,U.lastMouseOrTouchEventInfo)().isTouch)&&o.selectionMacro((e=>{e.clearSelection();const t=(0,r.ensureNotNull)(h.source);e.addSourceToSelection(t,Dt(h,t))})),e.isTouch&&(this._touchMove=!1)}_mouseOrTouchMoveEvent(e){if(!this.hasState())return;this._resetMeasureIfRequired();const t=this._dataSourceAtPoint(e.localX,e.localY);this._processMouseEnterLeaveMoveHandlers(t,e);const i=this._chartUndoModel();if(!i)return;const s=e.localX,r=e.localY;this._prevMoveEventPosition=new F.Point(s,r);const n=new $.EnvironmentState(e);if(null===this._firstZoomPoint){if(this._updateHoveredSource(t,n,e),!e.isTouch&&i.lineBeingCreated()){const e=i.lineBeingCreated(),t=null===e?null:i.model().paneForSource(e);if(null!==t&&t!==this._state)return void this._setCursorPositionOnExternalPane(t,s,r,n)}e.isTouch||this._setCursorPosition(s,r,n)}else this._processMouseMoveWhileZoom(e,n)}_pressedMouseOrTouchMoveEvent(e){var t;if(!this.hasState()||this._pinching||e.isTouch&&this._contextMenuOpenedOnLastTap)return;this._pressedMoveStage=2,this._resetMeasureIfRequired(),this._startChangeOrMoveLineToolIfNeeded(),e.isTouch&&(this._touchMove=!0,this._preventSourceChange=!1);const i=new $.EnvironmentState(e),s=this._chartUndoModel(),n=s.crossHairSource(),o=e.localX,a=e.localY;if(this._prevMoveEventPosition=new F.Point(o,a),null!==this._firstZoomPoint)return this._processMouseMoveWhileZoom(e),void(this._firstZoomPoint.draggingMode=!0);const l=K.tool.value();if(e.isTouch&&this._startTouchPoint&&(0,E.isLineToolName)(l)&&!(0,E.isLineDrawnWithPressedButton)(l)&&!s.lineBeingCreated()&&!this._isSelectPointModeEnabled())return void this._updateCrosshairPositionInToolCreationMode(e,this.state());const c=n.measurePane().value();if(e.isTouch&&(this._startTouchPoint||e.stylus)&&((0,K.toolIsMeasure)(l)||null!==c))return void(e.stylus?this._setCursorPosition(e.localX,e.localY,new $.EnvironmentState(e)):this._updateCrosshairPositionInToolCreationMode(e,c||this.state()));const h=s.lineBeingCreated();if(e.isTouch&&!e.stylus&&h&&!(0,E.isLineDrawnWithPressedButton)(h.toolname)){if(this._startTouchPoint){const t=(0, -r.ensureNotNull)(s.lineBeingCreated()),i=(0,r.ensureNotNull)(s.model().paneForSource(t));this._updateCrosshairPositionInToolCreationMode(e,i)}return}if(e.isTouch&&null!==this._startTrackPoint){this._exitTrackingModeOnNextTry=!1;const e=(0,r.ensureNotNull)(this._initCrossHairPosition),t=new F.Point(o,a).subtract(this._startTrackPoint),s=e.add(t);this._setCursorPosition(s.x,s.y,i)}else e.isTouch&&this._preventCrossHairMove()||this._setCursorPosition(o,a,i);const d=this._isSelectPointModeEnabled();if((0,E.isLineToolName)(l)&&!(0,E.isLineDrawnWithPressedButton)(l)&&!d&&!i.mod())return;if((0,E.isLineDrawnWithPressedButton)(l)&&!d){const i=this.state().defaultPriceScale();if(i.isEmpty())return;const n=s.lineBeingCreated();if(!n)return;const o=new F.Point(e.localX,e.localY),a=(0,r.ensure)(null===(t=n.ownerSource())||void 0===t?void 0:t.firstValue());return o.price=i.coordinateToPrice(e.localY,a),o.index=Math.round(s.timeScale().coordinateToIndex(e.localX)),void s.continueCreatingLine(o)}if(null!==this._paneWidgetsSharedState.draggingSource()){const t=e.target,i=this._chart.paneByCanvas(t);i&&(i!==this?i.setDragToAnotherPaneCursor():i.setCursorForTool());const s=this._chart.timeAxisByCanvas(t);s&&s.setCursor("grabbing")}if(s.timeScale().isEmpty())return;const u=this._options.handleScroll;if((!u.pressedMouseMove||e.isTouch)&&(!u.horzTouchDrag&&!u.vertTouchDrag||!e.isTouch))return;if(s.customMoveBeingProcessed())return void s.processCustomMove(e);const p=s.model().customSourceMovingHitTestData();if(null!==p&&(this._updateCommonTooltip(null,!0),s.model().processingCustomSourceMove(),(0,G.tryCallHandler)(e,p.pressedMouseMoveHandler,p.touchMoveHandler),Ot(e,p)))return;if(s.model().lineBeingEdited())return void this._setCursorPosition(o,a,i);if(s.model().sourcesBeingMoved().length)return void this._alignSourcesThatBeingMoved(s.model().sourcesBeingMoved(),e.localX,e.localY,i);const _=this._dataSourceAtPoint(e.localX,e.localY);if(this._tryFinishClonning(e,new $.EnvironmentState(e),_))return;const m=(0,K.toolIsMeasure)(l)||n.startMeasurePoint()&&n.endMeasurePoint();this._chart.readOnly()||!i.mod()||(0,E.isLineToolName)(l)||m||d?(this._processScroll(e),this._preventScroll()&&!this._preventCrossHairMove()&&null===this._startTrackPoint&&this._setCursorPosition(e.localX,e.localY,new $.EnvironmentState(e))):this._isSelecting||(n.startSelection(this.state()),this._isSelecting=!0)}_mouseOrTouchLeaveEvent(e){var t;if(!this.hasState())return;const i=this._chartUndoModel();if(!i)return;const s=i.crossHairSource();e.isTouch||null!==s.measurePane().value()&&null===s.endMeasurePoint()||this._clearCursorPosition(),i.model().setHoveredSource(null,null),null!==this._prevHoveredHittest&&((0,G.tryCallHandler)(e,null===(t=this._prevHoveredHittest.hittest.data())||void 0===t?void 0:t.mouseLeaveHandler),this._prevHoveredHittest=null),this._updateCommonTooltip(null),this._chart.unsetActivePaneWidget()}_mouseDoubleClickOrDoubleTapEvent(e){if(!this.hasState())return;const t=!this._chart.readOnly()&&!(0, -E.isLineToolName)(K.tool.value())&&this._dataSourceAtPoint(e.localX,e.localY)||null;if(null!==t&&t.isCustom)t.hittest.tryCallDblClickOrDblTapHandler(e);else if(null!==t&&(e.isTouch||t.hittest.target()>G.HitTarget.MovePointBackground))this.processDoubleClickOnSource(t.source,t.hittest?t.hittest:void 0);else if(!this._chart.readOnly()&&!(0,E.isLineToolName)(K.tool.value())&&!this._chartUndoModel().lineBeingCreated()&&this._chartUndoModel().selection().isEmpty()){const t=this.state();new $.EnvironmentState(e).mod()&&!t.maximized().value()?(t.collapsed().value()||this._chartModel().paneCollapsingAvailable().value())&&this._chart.toggleCollapsedPane(this):this._chart.toggleMaximizePane(this)}}_contextMenuEvent(e){const t=this._chartUndoModel();if(t.crossHairSource().startMeasurePoint()&&!this._trackCrosshairOnlyAfterLongTap)return t.crossHairSource().clearMeasure(),void(0,K.resetToCursor)(!0);if(this._pinching)return;if(null===this._firstZoomPoint||this._trackCrosshairOnlyAfterLongTap||this.cancelZoom(),!(0,K.toolIsCursor)(K.tool.value())||this._isSelectPointModeEnabled()){if(e.isTouch)return;return(0,K.resetToCursor)(!0),this.setCursorForTool(),void(t.lineBeingCreated()&&t.cancelCreatingLine())}if(!this._options.contextMenuEnabled)return;const i=this._dataSourceAtPoint(e.localX,e.localY),s=i?i.source:null;if(e.isTouch&&null!==this._startTrackPoint){if(this._preventSourceChange)return;this._clearCursorPosition()}e.isTouch&&(this._contextMenuOpenedOnLastTap=!0,this._startTrackPoint=null),this._contextMenuX=e.localX,this._contextMenuY=e.localY;const r=i&&i.hittest?i.hittest.target():0,n=r>=G.HitTarget.Regular||r>=G.HitTarget.MovePointBackground&&e.isTouch;this._chart.updateActions(),t.selectionMacro((t=>{null!==s&&n?t.selection().isSelected(s)||(t.clearSelection(),t.addSourceToSelection(s,Dt(i,s))):(this._options.contextMenu.general&&this._showContextMenu(e),t.clearSelection())})),null!==i&&n&&null!==s&&((0,Y.isDataSource)(s)&&s.hasContextMenu()?s.isSelectionEnabled()?this.showContextMenuForSelection(e):this.showContextMenuForSources([s],e):i.hittest.tryCallContextMenuHandler(e))}_onMouseEvent(){this._preventSourceChange=!1,this._startTrackPoint=null,this._trackCrosshairOnlyAfterLongTap=!1}_onTouchEvent(){this._trackCrosshairOnlyAfterLongTap=!0}_switchTrackingModeFromAnotherPaneIfNeeded(e){const t=this._chart.trackingModePaneWidget();if(null!==t&&t!==this){const i=this._chartModel().crossHairSource().currentPoint();t._exitTrackingModeOnNextTry=!0,t._tryExitTrackingMode(!0),this.startTrackingMode(new F.Point(e.localX,e.localY),new F.Point(i.x,e.localY),new $.EnvironmentState(e))}}_showContextMenu(e){const t=e=>e instanceof C.Separator,i=this._customActions(),s=this._initActions(e).filter((e=>null!==e));i.remove.forEach((e=>{for(let t=0;t0;e--)t(r[e])&&t(r[e-1])&&r.splice(e,1);r.length&&t(r[0])&&r.splice(0,1),r.length&&t(r[r.length-1])&&r.splice(r.length-1,1), -he.ContextMenuManager.showMenu(r,e,{statName:"ChartContextMenu"},{menuName:"ChartContextMenu"})}_initActions(e){var t,i;const s=this._chart.actions(),r=[];if(r.push(s.chartReset),r.push(new C.Separator),!this.state().isEmpty()&&Ae.enabled("datasource_copypaste")){const t=(0,ke.createActionCopyPrice)(this.state(),e.localY),i=(0,ke.createPasteAction)(this._chart,this.state());(t||i)&&(t&&r.push(t),i&&r.push(i),r.push(new C.Separator))}r[r.length-1]instanceof C.Separator||r.push(new C.Separator);return Boolean(null===(t=window.widgetbar)||void 0===t?void 0:t.widget("watchlist"))&&s.addToWatchlist&&r.push(s.addToWatchlist),Ae.enabled("text_notes")&&r.push(s.addToTextNotes),r[r.length-1]instanceof C.Separator||r.push(new C.Separator),r.push(this._createLockTimeAxisAction(e)),r.push(new C.Separator),!Ae.enabled("charting_library_base")&&s.applyColorTheme&&r.push(s.applyColorTheme),r[r.length-1]instanceof C.Separator||r.push(new C.Separator),this._chart.applyIndicatorsToAllChartsAvailable()&&(r.push(s.applyStudiesToAllCharts),r.push(new C.Separator)),r.push(s.paneRemoveAllDrawingTools),r.push(s.paneRemoveAllStudies),r.push(new C.Separator),(null===(i=window.pro)||void 0===i?void 0:i.hasPackage("mtp-mtpredictor"))&&this.state().containsMainSeries()&&r.push((0,ke.createMTPredictorActions)(this._chart,this.state(),this._contextMenuX,this._contextMenuY),new C.Separator),r.push(s.hideAllMarks),r.push(new C.Separator),Ae.enabled("show_chart_property_page")&&r.push(s.chartProperties),r[r.length-1]instanceof C.Separator&&r.pop(),r}_loadAndCreateLegendWidget(){Promise.all([i.e(2521),i.e(9842),i.e(9322),i.e(306),i.e(5093)]).then(i.bind(i,85109)).then((e=>{if(this._isDestroyed)return;const t=e.LegendWidget,i=(0,j.deepExtend)({},this._options.legendWidget);i.canShowSourceCode=!this._chart.onWidget()&&!h.CheckMobile.any(),i.readOnlyMode=i.readOnlyMode||this._chart.readOnly(),i.statusesWidgets={sourceStatusesEnabled:this._options.sourceStatusesWidgetEnabled,sourceStatuses:this._options.sourceStatusesWidget||{},marketStatusEnabled:this._options.marketStatusWidgetEnabled,dataUpdateModeEnabled:this._options.chartWarningWidgetEnabled,dataUpdateMode:this._options.chartWarningWidget||{},dataProblemEnabled:this._options.dataProblemWidgetEnabled};const s=(0,b.combine)(((e,t)=>Rt&&this._chart!==e&&!t),this._chart.chartWidgetCollection().activeChartWidget.weakReference(),this._chart.chartWidgetCollection().lock.crosshair.weakReference()),n=(0,b.combine)(((e,t)=>null!==e?e===this._state:(0,K.toolIsMeasure)(t)),this._chartModel().crossHairSource().measurePane().weakReference(),K.tool.weakReference());this._legendWidget=new t(this._chartUndoModel(),this,this._chart.backgroundTopTheme().spawnOwnership(),s.ownership(),this._visuallyCollapsed.spawnOwnership(),n.ownership(),i,{showContextMenuForSelection:this.showContextMenuForSelection.bind(this),showContextMenuForSources:this.showContextMenuForSources.bind(this),updateActions:this._chart.updateActions.bind(this._chart), -showChartPropertiesForSource:this._chart.showChartPropertiesForSource.bind(this._chart),showGeneralChartProperties:this._chart.showGeneralChartProperties.bind(this._chart),showObjectsTreeDialog:this._chart.showObjectsTreeDialog.bind(this._chart)}),this._div.appendChild(this._legendWidget.getElement()),this._legendWidget.updateLayout(),this._legendWidget.updateWidgetModeBySize(this._size),this._legendWidget.updateThemedColors(this._themedTopColor);for(const e of Array.from(this._customLegendWidgetsFactoryMap.keys()))this._legendWidget.addCustomWidgetToLegend(e,(0,r.ensureDefined)(this._customLegendWidgetsFactoryMap.get(e)))}))}_loadAndCreatePaneControlsWidget(){Promise.all([Promise.all([i.e(2521),i.e(9842),i.e(9322),i.e(306),i.e(5093)]).then(i.bind(i,69289)),Promise.all([i.e(2521),i.e(9842),i.e(9322),i.e(306),i.e(5093)]).then(i.bind(i,59255))]).then((([e,t])=>{var i;if(this._isDestroyed)return;const s=e.PaneControlsWidget;this._paneControls=new s(this._chartUndoModel(),this,{backgroundThemeName:this._chart.backgroundTopTheme()},{toggleMaximizePane:this._chart.toggleMaximizePane.bind(this._chart),toggleCollapsedPane:this._chart.toggleCollapsedPane.bind(this._chart)},this._div),this._paneControls.updateWidgetModeByWidth(this._size.width),this._paneControls.updateThemedColors(this._themedTopColor),this._paneControlsResizeObserver=new t.default(this._handleRestrictLegendWidth.bind(this)),this._paneControlsResizeObserver.observe(this._paneControls.getElement()),(null===(i=this._state)||void 0===i?void 0:i.collapsed().value())&&this._chartModel().fullUpdate()}))}_handleRestrictLegendWidth(e){if(null===this._legendWidget||null===this._paneControls)return;const t=e[e.length-1].contentRect.width,i=0===t?0:t+yt+bt;this._legendWidget.addMargin(i)}_onMagnetStateChanged(){this._chart.isActive()&&(this._isSelectPointModeEnabled()||this._isToolActionActiveOnPane(!0))&&this._chartModel().crossHairSource().visible&&this._updateLineToolUsingMagnetOrShift()}_onShiftKeyStateChanged(){this._chart.isActive()&&this._isToolActionActiveOnPane(!1)&&this._chartModel().crossHairSource().visible&&this._updateLineToolUsingMagnetOrShift($.EnvironmentState.create((0,mt.shiftPressed)().value()))}_isToolActionActiveOnPane(e){const t=this._chartModel(),i=t.lineBeingCreated()||t.lineBeingEdited()||t.sourcesBeingMoved().length>0&&t.sourcesBeingMoved()[0];return i?t.paneForSource(i)===this._state:e&&(0,E.isLineToolName)(K.tool.value())&&t.crossHairSource().pane===this._state}_updateLineToolUsingMagnetOrShift(e){if(null===this._prevMoveEventPosition)return;const{x:t,y:i}=this._prevMoveEventPosition,s=this._chartModel().sourcesBeingMoved();s.length>0?(K.isStudyEditingNow.value()&&this._setCursorPosition(t,i,e),this._alignSourcesThatBeingMoved(s,t,i,e)):this._setCursorPosition(t,i,e)}_showEditDialogForSource(e,t){if(this._options.propertyPagesEnabled&&e.userEditEnabled())if(e===this._chartUndoModel().mainSeries())this._chart.showGeneralChartProperties(ht.TabNames.symbol);else if((0,V.isLineTool)(e)||(0,B.isStudy)(e)){let i;const s=null==t?void 0:t.data() -;if(null!=s){const e=s.areaName;void 0!==e&&(i=Bt.get(e))}this._chart.showChartPropertiesForSource(e,i).then((e=>{this._editDialog=e}))}}_initToolCreationModeParams(e){this._startTouchPoint=new F.Point(e.pageX,e.pageY),this._initCrossHairPosition=this._chartModel().crossHairSource().currentPoint()}_updateCrosshairPositionInToolCreationMode(e,t){if(t!==this._state){const i=this._chart.paneByState(t);return i._startTouchPoint=this._startTouchPoint,i._initCrossHairPosition=this._initCrossHairPosition,void i._updateCrosshairPositionInToolCreationMode(e,t)}const i=this._chartModel().crossHairSource();this._chart.justActivated()&&(this._initCrossHairPosition=i.currentPoint());const s=e.pageX,n=e.pageY,o=(0,r.ensureNotNull)(this._initCrossHairPosition),a=new F.Point(s,n).subtract((0,r.ensureNotNull)(this._startTouchPoint)),l=o.add(a);this._setCursorPosition(l.x,l.y,new $.EnvironmentState(e))}_priceAxisesContainer(e){return"left"===e?this._lhsPriceAxisesContainer:this._rhsPriceAxisesContainer}_recalculatePriceScales(e){const t=this.state();for(const i of t.leftPriceScales())t.recalculatePriceScale(i,e);for(const i of t.rightPriceScales())t.recalculatePriceScale(i,e);for(const i of t.sourcesByGroup().overlayPriceScaleSources())(0,V.isLineTool)(i)||t.recalculatePriceScale(i.priceScale(),e)}_createLockTimeAxisAction(e){var t;const i=0===(null===(t=K.crosshairLock.value())||void 0===t?void 0:t.type);return new C.Action({actionId:"Chart.Crosshair.LockVerticalCursor",label:xt,statName:"LockCursorInTime",checkable:!0,checked:i,onExecute:()=>this._toggleLockTimeAxis(e.localX,!i)})}_toggleLockTimeAxis(e,t){if(t){const t=this._chartUndoModel().timeScale(),i=t.coordinateToIndex(e),s=t.points().roughTime(i);if(null!==s)return void K.crosshairLock.setValue({type:0,time:s})}K.crosshairLock.setValue(null)}_preventTouchEventsExceptPinch(){return this._paneWidgetsSharedState.hasTouchesOnOtherPanes(this)||null!==this._paneWidgetsSharedState.pinchingPane()}_updateHoveredSource(e,t,i){var s,r;const n=this._chartUndoModel(),o=n.model();let a=!1;const l=e&&e.source,c=this._chart.readOnly();if(o.crossHairSource().isReplaySelection())this._setCursorClassName("none");else if(!(!c||e&&(0,V.isLineTool)(e.source))||this._editDialog&&this._editDialog.visible().value())c&&(o.setHoveredSource(null,null),this.setCursorForTool());else{const h=K.tool.value();let d=null;if(!this._processing&&((0,K.toolIsCursor)(h)||"eraser"===h&&!c||t.mod()||!n.lineBeingCreated())){const t=null==e?void 0:e.hittest;a=Boolean(null===(s=null==t?void 0:t.data())||void 0===s?void 0:s.hideCrosshairLinesOnHover),t&&t.target()>G.HitTarget.MovePointBackground?(d=l,!(null==l?void 0:l.isHoveredEnabled())||"eraser"===h&&l===n.mainSeries()?o.setHoveredSource(null,null):o.setHoveredSource(l,t.data())):o.setHoveredSource(null,null)} -c?this.setCursorForTool(d,t,dt.PaneCursorType.Default):this._options.sourceSelectionEnabled&&(this._isSelectPointModeEnabled()?this._setCursorClassName("pointer"):this.setCursorForTool(d,t,null===(r=null==e?void 0:e.hittest.data())||void 0===r?void 0:r.cursorType));const u=o.customSourceBeingMoved(),p=null!==u?[u]:o.sourcesBeingMoved();if((!p.length||null!==e&&-1===p.indexOf(e.source))&&this._updateCommonTooltip(e),!c&&null!==e&&i&&e.hittest.hasPressedMoveHandler(i)){switch((e.hittest.data()||{}).cursorType){case dt.PaneCursorType.VerticalResize:this._setCursorClassName("ns-resize");break;case dt.PaneCursorType.HorizontalResize:this._setCursorClassName("we-resize");break;case dt.PaneCursorType.DiagonalNeSwResize:this._setCursorClassName("nesw-resize");break;case dt.PaneCursorType.DiagonalNwSeResize:this._setCursorClassName("nwse-resize")}}}this._preventCrossHairMove()&&this._clearCursorPosition(),1!==this._pressedMoveStage&&o.crossHairSource().setLinesShouldBeHidden(a)}async _createErrorBlock(){const e=new(await pt());return this._div.insertBefore(e.container,this._topCanvasBinding.canvasElement.nextSibling),e}_customActions(){const e={top:[],bottom:[],remove:[]},t=this._chartUndoModel().timeScale(),i=this._state&&this._state.defaultPriceScale();if(!Ae.enabled("custom_items_in_context_menu"))return e;const s=t.isEmpty()?void 0:t.indexToUserTime(t.coordinateToIndex(this._contextMenuX));let n;if(i&&!i.isEmpty()){const e=(0,r.ensureNotNull)(this.state().mainDataSource()).firstValue();n=i.coordinateToPrice(this._contextMenuY,(0,r.ensureNotNull)(e))}return(0,u.emit)("onContextMenu",{unixtime:null!=s?s.getTime()/1e3:void 0,price:n,callback:t=>{[...t].forEach((t=>{if(t.text)if(t.text.length>1&&"-"===t.text[0])e.remove.push(t.text.slice(1));else{let i;i="-"===t.text?new C.Separator:new C.Action({actionId:"Chart.ExternalActionId",label:t.text,onExecute:t.click}),t.position&&"top"===t.position?e.top.push(i):e.bottom.push(i)}}))}}),e}_highlightPriceAxisByLabel(e){this._lhsPriceAxisesContainer.highlightPriceAxisByLabel(e),this._rhsPriceAxisesContainer.highlightPriceAxisByLabel(e)}_subscribeToState(){const e=this.state();e.onDestroyed().subscribe(this,this._onStateDestroyed,!0),e.dataSourcesCollectionChanged().subscribe(this,this._onDataSourcesCollectionChanged),e.maximized().subscribe(this._updateVisuallyCollapsed),e.collapsed().subscribe(this._updateVisuallyCollapsed)}_unsubscribeFromState(){const e=this.state();e.onDestroyed().unsubscribeAll(this),e.dataSourcesCollectionChanged().unsubscribeAll(this),e.maximized().unsubscribe(this._updateVisuallyCollapsed),e.collapsed().unsubscribe(this._updateVisuallyCollapsed)}async _updateEndOfSeriesBanner(){}}var Wt=i(24377),Ht=i(30383);class zt{constructor(e,t,i){this._handleEl=null,this._resizeInfo=null,this._colorCache={lineColor:"",backgroundColor:"",color:""},this._chart=e,this._topPaneIndex=t,this._bottomPaneIndex=i,this._row=document.createElement("tr"),this._cell=document.createElement("td"),this._row.appendChild(this._cell),this._cell.classList.add(Ht.paneSeparator), -this._cell.setAttribute("colspan","3"),this._cell.style.background=this._color(),this.adjustSize(),this._cell.addEventListener("click",(()=>{}));const s=document.createElement("div");s.classList.add(Ht.handle),this._cell.appendChild(s),this._mouseEventHandler=new X.MouseEventHandler(s,this,{treatVertTouchDragAsPageScroll:!1,treatHorzTouchDragAsPageScroll:!0}),this._handleEl=s}destroy(){this._mouseEventHandler.destroy(),this._row.parentElement&&this._row.parentElement.removeChild(this._row)}getElement(){return this._row}hide(){this._row.classList.add("js-hidden")}show(){this._row.classList.remove("js-hidden")}adjustSize(){this._row.style.height=zt.height()+"px"}mouseEnterEvent(e){const{topPane:t,bottomPane:i}=this._topBottomPane(!0);null!==t&&null!==i&&(0,r.ensureNotNull)(this._handleEl).classList.add(Ht.hovered)}mouseLeaveEvent(e){(0,r.ensureNotNull)(this._handleEl).classList.remove(Ht.hovered)}mouseDownEvent(e){this._mouseDownOrTouchStartEvent(e)}touchStartEvent(e){this._mouseDownOrTouchStartEvent(e)}pressedMouseMoveEvent(e){this._pressedMouseOrTouchMoveEvent(e)}touchMoveEvent(e){this._pressedMouseOrTouchMoveEvent(e)}mouseUpEvent(e){this._mouseUpOrTouchEndEvent(e)}touchEndEvent(e){this._mouseUpOrTouchEndEvent(e)}update(){this._cell.style.background=this._color().toString()}paint(){}image(){const{topPane:e}=this._topBottomPane(!1),t=e.leftPriceAxisesContainer().getWidth(),i=e.width(),r=e.rightPriceAxisesContainer().getWidth(),n=this._color(),o=(0,J.createDisconnectedCanvas)(document,(0,s.size)({width:t,height:1})),a=(0,J.getPrescaledContext2D)(o);a.fillStyle=n,a.fillRect(0,0,t,1);const l=(0,J.createDisconnectedCanvas)(document,(0,s.size)({width:i,height:1})),c=(0,J.getPrescaledContext2D)(l);c.fillStyle=n,c.fillRect(0,0,i,1);const h=(0,J.createDisconnectedCanvas)(document,(0,s.size)({width:r,height:1})),d=(0,J.getPrescaledContext2D)(h);return d.fillStyle=n,d.fillRect(0,0,r,1),{type:"separator",leftAxis:{content:o.toDataURL(),canvas:o,contentWidth:t,contentHeight:1},rightAxis:{content:h.toDataURL(),canvas:h,contentWidth:r,contentHeight:1},content:l.toDataURL(),canvas:l,contentWidth:i,contentHeight:1}}static height(){const e=window.devicePixelRatio||1;return e>=1?1:1/e}_mouseDownOrTouchStartEvent(e){const{topPane:t,bottomPane:i}=this._topBottomPane(!0);if(null===t||null===i)return;const s=t.state().stretchFactor()+i.state().stretchFactor(),n=s/(t.height()+i.height()),o=30*n;s<=2*o||(this._resizeInfo={startY:e.pageY,prevStretchTopPane:t.state().stretchFactor(),maxPaneStretch:s-o,totalStretch:s,pixelStretchFactor:n,minPaneStretch:o},(0,r.ensureNotNull)(this._handleEl).classList.add(Ht.active))}_pressedMouseOrTouchMoveEvent(e){const{topPane:t,bottomPane:i}=this._topBottomPane(!0),s=this._resizeInfo;if(null===s||null===t||null===i)return;const r=(e.pageY-s.startY)*s.pixelStretchFactor,n=(0,ye.clamp)(s.prevStretchTopPane+r,s.minPaneStretch,s.maxPaneStretch);t.state().setStretchFactor(n),i.state().setStretchFactor(s.totalStretch-n),this._chart.model().model().fullUpdate()}_mouseUpOrTouchEndEvent(e){ -const{topPane:t,bottomPane:i}=this._topBottomPane(!0),s=this._resizeInfo;null!==s&&null!==t&&null!==i&&(this._chart.model().addPaneStretchFactorUndoCommand(t.state(),i.state(),s.prevStretchTopPane,t.state().stretchFactor()),this._resizeInfo=null,(0,r.ensureNotNull)(this._handleEl).classList.remove(Ht.active))}_color(){const e=this._chart.properties().childs().paneProperties.childs().separatorColor.value(),t=this._chart.model().model().backgroundColor().value();if(this._colorCache.lineColor!==e||this._colorCache.backgroundColor!==t){const i=(0,Wt.parseRgba)(t),s=(0,Wt.parseRgba)(e),r=0===i[3]&&0===s[3]?"rgba(0,0,0,0)":(0,Wt.rgbaToString)((0,Wt.blendRgba)(i,s));this._colorCache={lineColor:e,backgroundColor:t,color:r}}return this._colorCache.color}_topBottomPane(e){const t=this._chart.paneWidgets();let i=null,s=null;for(let s=this._topPaneIndex;s>=0;--s){const r=t[s];if(!e||!r.state().collapsed().value()){i=r;break}}for(let i=this._bottomPaneIndex;ithis.backgroundColor(),a=()=>{throw new Error("Time axis does not support real price scales")},l={titlesProvider:i,stubContextMenuProvider:(e,t)=>{const i=r(e,t),s=this.getContextMenuActions(!0);return 0===s.length?i:i.concat(new C.Separator,s)},backgroundBasedTheme:n,rendererOptionsProvider:e.model().model().rendererOptionsProvider(),getBackgroundTopColor:o,getBackgroundBottomColor:o,showHorizontalBorder:!0};this._lhsStubContainer=new me(this._properties,"left",a,l,this._options.priceAxisLabelsOptions,this),this._lhsStubContainer.onLabelHovered().subscribe(this,((e,t)=>{this._onLabelHovered.fire(e,t)})),this._rhsStubContainer=new me(this._properties,"right",a,l,this._options.priceAxisLabelsOptions,this),this._rhsStubContainer.onLabelHovered().subscribe(this,((e,t)=>{this._onLabelHovered.fire(e,t)})),this._element.appendChild(this._lhsStubContainer.getElement()),this._cell=document.createElement("td"),this._element.appendChild(this._cell),this._cell.classList.add("chart-markup-table","time-axis"),this._cell.style.height="25px",this._dv=document.createElement("div"),this._dv.style.width="100%",this._dv.style.height="100%",this._dv.style.position="relative",this._dv.style.overflow="hidden",this._cell.appendChild(this._dv),this._canvasConfiguredHandler=()=>this.chart.model().model().lightUpdate(),this._canvasBinding=(0,J.createBoundCanvas)(this._dv,(0,s.size)({width:16,height:16})), -this._canvasBinding.subscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler);const c=this._canvasBinding.canvasElement;c.style.position="absolute",c.style.zIndex="1",c.style.left="0",c.style.top="0",this._topCanvasBinding=(0,J.createBoundCanvas)(this._dv,(0,s.size)({width:16,height:16})),this._topCanvasBinding.subscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler);const h=this._topCanvasBinding.canvasElement;h.style.position="absolute",h.style.zIndex="2",h.style.left="0",h.style.top="0",this._element.appendChild(this._rhsStubContainer.getElement()),this.restoreDefaultCursor(),this.update(),this._minVisibleSpan=Ut.MINUTE_SPAN,this._mouseEventHandler=new X.MouseEventHandler(this._topCanvasBinding.canvasElement,this,{treatVertTouchDragAsPageScroll:!0,treatHorzTouchDragAsPageScroll:!1}),this.size=(0,s.size)({width:0,height:0}),(0,K.hideMarksOnBars)().subscribe(this,(()=>this.chart.model().model().lightUpdate()))}destroy(){this._mouseEventHandler.destroy(),this._topCanvasBinding.unsubscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler),this._topCanvasBinding.dispose(),this._canvasBinding.unsubscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler),this._canvasBinding.dispose(),this._rhsStubContainer.onLabelHovered().unsubscribeAll(this),this._lhsStubContainer.onLabelHovered().unsubscribeAll(this),this._lhsStubContainer.destroy(),this._rhsStubContainer.destroy(),this.chart.properties().childs().paneProperties.childs().background.unsubscribeAll(this),(0,K.hideMarksOnBars)().unsubscribeAll(this)}setCursor(e){let t="";"grabbing"!==e&&"ew-resize"!==e||(t="time-axis--cursor-"+e),this._currentCursorClassName!==t&&(this._currentCursorClassName&&this._cell.classList.remove(this._currentCursorClassName),t&&this._cell.classList.add(t),this._currentCursorClassName=t,this._cell.style.cursor)}restoreDefaultCursor(){this.setCursor("")}getElement(){return this._element}optimalHeight(){const e=this.rendererOptions();return Math.ceil(e.borderSize+e.offsetSize+e.fontSize+e.paddingTop+e.paddingBottom+e.labelBottomOffset)}setSizes(e,t,i){this.size&&(0,s.equalSizes)(this.size,e)||(this.size=e,this._canvasBinding.resizeCanvasElement(e),this._topCanvasBinding.resizeCanvasElement(e),this._cell.style.width=e.width+"px",this._cell.style.height=e.height+"px"),this._lhsStubContainer.setSizes(e.height,t),this._rhsStubContainer.setSizes(e.height,i)}rendererOptions(){if(!this._rendererOptions||this._rendererOptions.fontSize!==this.fontSize()){const e=this.fontSize();this._rendererOptions={borderSize:1,offsetSize:5,fontSize:e,font:(0,ee.makeFont)(e,re.CHART_FONT_FAMILY,""),widthCache:new ve.TextWidthCache,paddingTop:3*e/12,paddingBottom:3*e/12,paddingHorizontal:9*e/12,labelBottomOffset:4*e/12}}return this._rendererOptions}backgroundColor(){return this.chart.model().model().backgroundColor().value()}lineColor(){const e=this._properties.childs().lineColor.value();if(0===(0,Wt.parseRgba)(e)[3]){const e=this.chart.model().model().lastPane() -;if(e&&(e.collapsed().value()||e.isMainPane()&&this._areEventsEnabled()))return this.chart.properties().childs().paneProperties.childs().separatorColor.value()}return e}textColor(){return this._properties.childs().textColor.value()}fontSize(){return this._properties.childs().fontSize.value()}baseFont(){return(0,ee.makeFont)(this.fontSize(),re.CHART_FONT_FAMILY)}baseBoldFont(){return(0,ee.makeFont)(this.fontSize(),re.CHART_FONT_FAMILY,"","bold")}hasCanvas(e){return this._canvasBinding.canvasElement===e||this._topCanvasBinding.canvasElement===e}onLabelHovered(){return this._onLabelHovered}getScreenshotData(){return{content:this._canvasBinding.canvasElement.toDataURL(),canvas:this._canvasBinding.canvasElement,contentWidth:this.size.width,contentHeight:this.size.height,lhsStub:this._lhsStubContainer.getScreenshotData(),rhsStub:this._rhsStubContainer.getScreenshotData()}}getContextMenuActions(e){var t;const i=this.chart;i.updateActions();const s=i.actions(),r=[];if(e||(r.push(s.timeScaleReset),r.push(new C.Separator),this._options.timezoneMenuEnabled&&r.push(s.applyTimeZone),r.push(s.sessionBreaks)),!i.model().mainSeries().isDWM()){const e=null===(t=i.model())||void 0===t?void 0:t.mainSeries().symbolInfo();if(e){const t=i.model().mainSeries().properties().childs().sessionId,s=(e.subsessions||[]).filter((e=>!e.private));if(s.length>1){const e=s.map((e=>{const s={label:(0,jt.translateSessionDescription)(e.description),checkable:!0,checked:t.value()===e.id,statName:"SetSession",onExecute:()=>{i.model().setProperty(t,e.id,qt)}};return new C.Action({...s,actionId:"Chart.SetSession"})})),n={label:$t,statName:"SetSession",subItems:e},o=new C.Action({...n,actionId:"Chart.SetSession"});r.push(o)}}}return r}update(){if(!this.chart.hasModel())return;const e=this.chart.model().timeScale().marks();if(e){this._minVisibleSpan=Ut.YEAR_SPAN;for(const t of e)this._minVisibleSpan=Math.min(t.span,this._minVisibleSpan)}}updatePriceAxisStubs(){const e=this.chart.model().model(),t=this.chart.isMaximizedPane()?(0,r.ensureNotNull)(this.chart.maximizedPaneWidget()).state():e.paneForSource(e.mainSeries());if(!t)return;const i=e.priceScaleSlotsCount();this._lhsStubContainer.setScales([],i.left,t.leftPriceScales().length,i.left+i.right),this._rhsStubContainer.setScales([],i.right,t.rightPriceScales().length,i.left+i.right)}paint(e){if(e===N.InvalidationLevel.None||0===this.size.width||0===this.size.height)return;this._canvasBinding.applySuggestedBitmapSize(),this._topCanvasBinding.applySuggestedBitmapSize();const t=(0,J.getContext2D)(this._topCanvasBinding.canvasElement);if(e>N.InvalidationLevel.Cursor){const i=(0,J.getContext2D)(this._canvasBinding.canvasElement),s=(0,J.getBindingPixelRatio)(this._canvasBinding);this.drawBackground(i,s),this.chart.hasModel()&&(this.drawBorder(i,s),this.drawTickMarks(i,s),this.drawBackLabels(i,s),this.drawCrossHairLabel(t,s)),this._lhsStubContainer.paintStubs(e),this._rhsStubContainer.paintStubs(e)}this.drawCrossHairLabel(t,(0,J.getBindingPixelRatio)(this._topCanvasBinding))}drawBackground(e,t){if((0, -J.clearRect)(e,0,0,Math.ceil(this.size.width*t)+1,Math.ceil(this.size.height*t)+1,this.backgroundColor()),!this.chart.hasModel())return;const i=this.chart.model();if(!i.timeScale().isEmpty()){const s=i.model().selection().lineDataSources().reduce(((e,t)=>{const i=t.timeAxisPoints();return 0===i.length?e:e.concat(i)}),[]);s.length>0&&this._hightlightBackground(e,s,t)}const s=i.model().crossHairSource();s.startMeasurePoint()&&this._hightlightBackground(e,s.measurePoints(),t)}drawBorder(e,t){e.save(),e.fillStyle=this.lineColor();const i=Math.max(1,Math.floor(this.rendererOptions().borderSize*t)),s=Math.ceil(this.size.width*t);e.fillRect(0,0,s+1,i),e.restore()}drawTickMarks(e,t){const i=this.chart.model().timeScale().marks();if(!i||0===i.length)return;let s=i.reduce(((e,t)=>e.span>t.span?e:t),i[0]).span;s>30&&s<40&&(s=30),e.save(),e.strokeStyle=this.lineColor();const r=this.rendererOptions(),n=r.borderSize+r.offsetSize+r.paddingTop+r.fontSize/2;e.textAlign="center",e.textBaseline="middle",e.fillStyle=this.textColor(),(0,J.drawScaled)(e,t,t,(()=>{e.font=this.baseFont();for(let t=0;t=s&&e.fillText(r.label,r.coord,n)}})),e.restore()}drawBackLabels(e,t){var i;e.save();const s=new Set,r=this.chart.model().model();let n=r.dataSources();const o=r.selection().allSources();for(const e of o)s.add(e);r.hoveredSource()&&s.add(r.hoveredSource());for(const e of r.sourcesBeingMoved())s.add(e);const a=r.customSourceBeingMoved();null!==a&&s.add(a);const l=null!==(i=r.lineBeingEdited())&&void 0!==i?i:r.lineBeingCreated();l&&s.add(l),s.add(this.chart.model().crossHairSource()),n=n.concat(r.customSources());const c=this.rendererOptions();for(let i=0;i=s&&(s=a,n=o),a<=i&&(i=a,r=o)}}return n&&t.push(n),r&&t.push(r),t}_zoomAvailable(){return!this.chart.model().timeScale().isEmpty()&&this.chart.model().model().zoomEnabled()&&this._options.pressedMouseMoveScale}_mouseDownOrTouchStartEvent(e){if(this._mousedown||!this._zoomAvailable())return;this._mousedown=!0;const t=this.chart.model();t.timeScale().isEmpty()||t.startScaleTime(e.localX)}_pressedMouseOrTouchMoveEvent(e){this._zoomAvailable()&&this.chart.model().scaleTimeTo(e.localX)}_mouseUpOrTouchEndEvent(e){this._zoomAvailable()&&(this._mousedown=!1,this.chart.model().endScaleTime(),this.restoreDefaultCursor())}_contextMenuOrTouchContextMenuEvent(e){this._options.contextMenuEnabled&&he.ContextMenuManager.showMenu(this.getContextMenuActions(),e,{statName:"TimeScaleContextMenu"},{menuName:"TimeScaleContextMenu"})}_mouseOrTouchEnterEvent(e){this._zoomAvailable()&&this.setCursor("ew-resize")}_mouseOrTouchLeaveEvent(e){this.restoreDefaultCursor()}_mouseDoubleClickOrDoubleTapEvent(e){(0,Se.trackEvent)("GUI","Double click time scale"),this.chart.model().resetTimeScale()}_areEventsEnabled(){return!(0,K.hideMarksOnBars)().value()}}function Kt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Zt(e){return e.reduce(((e,t)=>{for(const i in t)if(Kt(t,i)){const s=t[i],r=e[i];r?r.push(s):e[i]=[s]}return e}),{})}var Xt=i(87095);const Jt=new z.TranslatedString("move left",o.t(null,void 0,i(15086))),Qt=new z.TranslatedString("move right",o.t(null,void 0,i(61711))),ei={moving:"wait_finishing",wait_finishing:"stop",stop:"moving"};class ti{constructor(e){ -this._chartModel=null,this._currentDistance=0,this._deferredFinishTimeout=0,this._finishingTimeout=0,this._moveType="",this._startTime=0,this._state="stop",this._movingTimeout=0,this._chart=e,this._chart.withModel(this,(()=>{this._chartModel=this._chart.model()}))}destroy(){clearTimeout(this._movingTimeout)}move(e){if(null!==this._chartModel&&"stop"===this._state&&this._chartModel.beginUndoMacro(1===e?Jt:Qt),this._state=ei.stop,this._moveType="animated",this._deferredFinishTimeout&&(clearTimeout(this._deferredFinishTimeout),this._deferredFinishTimeout=0),this._finishingTimeout&&(clearTimeout(this._finishingTimeout),this._finishingTimeout=0),this._startTime=Date.now(),0===this._movingTimeout){const t=this._startTime,i=10,s=()=>{this.moveStep(t,0,50*e,1e3),this._movingTimeout=setTimeout(s,i)};this._movingTimeout=setTimeout(s,i)}}moveStep(e,t,i,s){if(null!==this._chartModel&&!this._chartModel.timeScale().isEmpty()){const r=Date.now();r1||!isFinite(n))&&(n=1);const o=1-Math.pow(1-n,3);return this._currentDistance=(i-t)*o+t,this._chartModel.scrollChart(this._currentDistance),n}}moveByBar(e){if(null!==this._chartModel){const t=this._chartModel.timeScale();if(t.isEmpty())return;if("stop"===this._state&&this._chartModel.beginUndoMacro(1===e?Jt:Qt),null!==t.visibleBarsStrictRange()){const e=t.indexToCoordinate(t.visibleBarsStrictRange().lastBar())+t.barSpacing()/2;Math.abs(t.width()-e)>t.barSpacing()/6&&this._chartModel.scrollChart(t.width()-e)}if(this._state=ei.stop,this._moveType="by_bar",this._startTime=Date.now(),!this._movingTimeout){let t=0,i=150;const s=400,r=()=>{this._moveByBarStep(e),t++,i>100&&(i-=t/5*20),this._movingTimeout=setTimeout(r,i)};this._movingTimeout=setTimeout(r,s),this._moveByBarStep(e)}}}stopMove(){"by_bar"===this._moveType?this.stopMoveByBar():this._stopMove()}stopMoveByBar(){"moving"===this._state&&(clearTimeout(this._movingTimeout),this._movingTimeout=0,this._state=ei.wait_finishing,this._moveType="",this._movingTimeout=0,this._currentDistance=0,null!==this._chartModel&&this._chartModel.endUndoMacro())}scrollToRealtime(e){null!==this._chartModel&&this._chartModel.timeScale().scrollToRealtime(e)}_finishMove(){clearTimeout(this._movingTimeout),this._movingTimeout=0,this._deferredFinishTimeout=0;const e=this._currentDistance,t=Date.now(),i=()=>{const s=this.moveStep(t,e,0,700);s&&s<1?this._finishingTimeout=setTimeout(i,10):null!==this._chartModel&&(this._state=ei.wait_finishing,this._moveType="",this._movingTimeout=0,this._currentDistance=0,this._chartModel.endUndoMacro())};this._finishingTimeout=setTimeout(i,10)}_stopMove(){"moving"===this._state&&(this._state=ei.moving,Date.now()-this._startTime<200?this._deferredFinishTimeout=setTimeout(this._finishMove.bind(this),200-(Date.now()-this._startTime)):this._finishMove())}_moveByBarStep(e){if(null!==this._chartModel){if(this._chartModel.timeScale().isEmpty())return;this._chartModel.scrollChartByBar(e)}}}var ii=i(36174);const si=(0,a.getLogger)("ChartApi.AbstractSession");class ri extends class{constructor(e,t,i){ -this._isConnected=new fe.WatchedValue(!1),this._state=0,this._isConnectForbidden=!1,this._sessionId="",this._sessionIdChanged=new ce.Delegate,this._chartApi=e,this._sessionPrefix=t,this._shouldReconnectAfterCriticalError=i}destroy(){this._logNormal("Destroying session"),this._isConnected.unsubscribe(),this.disconnect(),this._sessionIdChanged.destroy(),delete this._chartApi,this._logNormal("Session has been destroyed")}isConnected(){return this._isConnected}sessionId(){return this._sessionId}onSessionIdChanged(){return this._sessionIdChanged}connect(){0===this._state&&((0,r.assert)(!this._isConnectForbidden,"Cannot call connect because it is forbidden at this moment"),this._setSessionId(`${this._sessionPrefix}_${(0,ii.randomHash)()}`),this._logNormal("Connecting session - wait until transport stay connected"),this._state=1,this._chartApi.createSession(this._sessionId,this))}disconnect(){0!==this._state&&((0,r.assert)(""!==this._sessionId,"sessionId must not be invalid"),this._logNormal("Disconnecting session..."),this._forbidConnectWhile((()=>{this._chartApi.connected()&&this._sendRemoveSession(),this._processDestroyingOnServer()})))}onMessage(e){switch(e.method){case"connected":return void this._onChartApiConnected();case"disconnected":return void this._onChartApiDisconnected();case"critical_error":const t=String(e.params[0]),i=String(e.params[1]);return void this._onCriticalError(t,i)}this._onMessage(e)}_getChartApi(){return this._chartApi}_generateLogMessage(e){return`[${this._sessionId}] ${e}`}_onCriticalError(e,t){this._logError(`Critical error. Reason=${e}, info=${t}.`),this._forbidConnectWhile((()=>{this._processDestroyingOnServer()})),this._shouldReconnectAfterCriticalError?(this._logNormal("Reconnecting after critical error..."),this.connect()):this._logNormal("Reconnecting after critical error skipped")}_onChartApiConnected(){(0,r.assert)(1===this._state,"Session is not registered"),this._logNormal("Transport is connected. Creating session on the server"),this._sendCreateSession(),this._state=2,this._isConnected.setValue(!0)}_onChartApiDisconnected(){this._logNormal("Transport is disconnected. Reconnecting..."),this._forbidConnectWhile((()=>{this._processDestroyingOnServer()})),this.connect()}_setSessionId(e){const t=this._sessionId;this._logNormal(`Changing sessionId: old=${t}, new=${e}`),this._sessionId=e,this._sessionIdChanged.fire(e,t)}_logNormal(e){si.logNormal(this._generateLogMessage(e))}_logError(e){si.logError(this._generateLogMessage(e))}_processDestroyingOnServer(){this._state=0,this._isConnected.setValue(!1),this._chartApi.removeSession(this._sessionId),this._setSessionId("")}_forbidConnectWhile(e){this._isConnectForbidden=!0,e(),this._isConnectForbidden=!1}}{constructor(e,t=!1){super(e,"cs",!1),this._sessionDisabled=!1,this._handler=null,this._criticalError=new ce.Delegate,this._symbolResolveMap=new Map,this._disableStatistics=t}destroy(){this._criticalError.destroy(),this._handler=null,this._symbolResolveMap.clear(),super.destroy()}serverTimeOffset(){ -return this._getChartApi().serverTimeOffset()}switchTimezone(e){return this._getChartApi().switchTimezone(this.sessionId(),e)}defaultResolutions(){return this._getChartApi().defaultResolutions()}availableCurrencies(){return this._getChartApi().availableCurrencies()}availableUnits(){return this._getChartApi().availableUnits()}availablePriceSources(e){return this._getChartApi().availablePriceSources(e)}resolveSymbol(e,t,i){if(this._symbolResolveMap.has(t)){const[e,s]=this._symbolResolveMap.get(t);return Array.isArray(s)?s.push(i):s.then(i),e}{const s=[i];return this._getChartApi().resolveSymbol(this.sessionId(),e,t,(i=>{"symbol_error"===i.method?this._symbolResolveMap.delete(t):this._symbolResolveMap.set(t,[e,Promise.resolve(i)]),s.forEach((e=>e(i)))})),this._symbolResolveMap.set(t,[e,s]),e}}requestFirstBarTime(e,t,i){return this._getChartApi().requestFirstBarTime(this.sessionId(),e,t,i)}createSeries(e,t,i,s,r,n,o){return this._getChartApi().createSeries(this.sessionId(),e,t,i,s,r,n,o)}modifySeries(e,t,i,s,r,n,o){return this._getChartApi().modifySeries(this.sessionId(),e,t,i,s,r,n,o)}removeSeries(e){return!!this.isConnected().value()&&this._getChartApi().removeSeries(this.sessionId(),e)}requestMoreData(e,t,i){return"number"==typeof e?this._getChartApi().requestMoreData(this.sessionId(),e):this._getChartApi().requestMoreData(this.sessionId(),e,t,i)}requestMoreTickmarks(e,t,i){return(0,y.isNumber)(e)?this._getChartApi().requestMoreTickmarks(this.sessionId(),e):this._getChartApi().requestMoreTickmarks(this.sessionId(),e,t,i)}requestMetadata(e,t){this._getChartApi().requestMetadata(this.sessionId(),e,t)}canCreateStudy(e){return this._getChartApi().canCreateStudy(e)}getStudyCounter(){return this._getChartApi().getStudyCounter()}createStudy(e,t,i,s,r,n,o){return this._getChartApi().createStudy(this.sessionId(),e,t,i,s,r,n,o)}rebindStudy(e,t,i,s,r,n,o){return this._getChartApi().rebindStudy(this.sessionId(),e,t,i,s,r,n,o)}modifyStudy(e,t,i,s,r){return this._getChartApi().modifyStudy(this.sessionId(),e,t,i,s,r)}removeStudy(e,t){return this._getChartApi().removeStudy(this.sessionId(),e,t)}createPointset(e,t,i,s,r,n){return this._getChartApi().createPointset(this.sessionId(),e,t,i,s,r,n)}modifyPointset(e,t,i,s){return this._getChartApi().modifyPointset(this.sessionId(),e,t,i,s)}removePointset(e){return this._getChartApi().removePointset(this.sessionId(),e)}setVisibleTimeRange(e,t,i,s,r,n){this._getChartApi().setVisibleTimeRange(this.sessionId(),e,t,i,s,!0,r,n)}criticalError(){return this._criticalError}connect(e=null){null!==e&&(this._handler=e),this._symbolResolveMap.clear(),super.connect()}setHandler(e){this._handler=e}connected(){return this.isConnected().value()&&!this._sessionDisabled}disable(){this._sessionDisabled=!0}chartApi(){return this._getChartApi()}_sendCreateSession(){Object.keys(this).forEach((e=>{/^(s|st|symbol_)\d+$/.test(e)&&delete this[e]})),this._getChartApi().chartCreateSession(this.sessionId(),this._disableStatistics)}_sendRemoveSession(){this._getChartApi().chartDeleteSession(this.sessionId())} -_onMessage(e){this._handler&&this._handler(e)}_onCriticalError(e,t){this._criticalError.fire(e,t),super._onCriticalError(e,t)}}var ni=i(42960),oi=i(94025);class ai{constructor(){this._draggingSource=null,this._activeTouchPanes=new Set,this._scrollingPane=null,this._pinchingPane=null}onPaneDestroyed(e){this._activeTouchPanes.delete(e),this._scrollingPane===e&&(this._scrollingPane=null),this._pinchingPane===e&&(this._pinchingPane=null)}startTouch(e){this._activeTouchPanes.add(e)}endTouch(e){this._activeTouchPanes.delete(e)}hasTouchesOnOtherPanes(e){return this._activeTouchPanes.size>1||1===this._activeTouchPanes.size&&!this._activeTouchPanes.has(e)}trySetDraggingSource(e,t){return!this.hasTouchesOnOtherPanes(t)&&((0,r.assert)(null===this._draggingSource||this._draggingSource===e),this._draggingSource=e,!0)}clearDraggingSource(){null!==this._draggingSource&&(this._draggingSource=null)}draggingSource(){return this._draggingSource}setScrollingPane(e){(0,r.assert)(null===e||null===this._scrollingPane||this._scrollingPane===e),this._scrollingPane=e}scrollingPane(){return this._scrollingPane}setPinchingPane(e){(0,r.assert)(null===e||null===this._pinchingPane||this._pinchingPane===e),this._pinchingPane=e}pinchingPane(){return this._pinchingPane}}let li=null;i(59744);function ci(e,t,s,r,n){return Promise.all([i.e(77),i.e(7201),i.e(8884),i.e(2666),i.e(1013),i.e(3842),i.e(4015),i.e(5145),i.e(855),i.e(6),i.e(5993),i.e(5649),i.e(2191),i.e(6221),i.e(8056),i.e(2587),i.e(3502),i.e(8149),i.e(2639),i.e(2109),i.e(9842),i.e(4215),i.e(7232),i.e(6625),i.e(9327),i.e(7194),i.e(6884),i.e(6036),i.e(2984),i.e(3980),i.e(5403),i.e(3889),i.e(4894),i.e(7391),i.e(7555),i.e(962),i.e(8385),i.e(9727),i.e(4403),i.e(4713),i.e(5901),i.e(769),i.e(9795),i.e(4378),i.e(6265)]).then(i.bind(i,63374)).then((i=>{const o=new(0,i.EditObjectDialogRenderer)(e,t,r,n);return o.show(s),o}))}let hi=null;var di=i(58229);const ui={[ht.TabNames.symbol]:"symbol",[ht.TabNames.legend]:"legend",[ht.TabNames.scales]:"scales",[ht.TabNames.trading]:"trading",[ht.TabNames.events]:"events",[ht.TabNames.timezoneSessions]:"canvas",[ht.TabNames.text]:"text",[ht.TabNames.style]:"style",[ht.TabNames.visibility]:"visibility"},pi={[ht.TabNames.style]:"style",[ht.TabNames.visibility]:"visibilities"};async function _i(e,t,s={},r,n){const o=r.activeChartWidget.value(),{initialTab:a,tabName:l}=s;if(l&&!a&&(s.initialTab=pi[l]),(0,V.isStudyLineTool)(e)&&function(e){return[di.LineToolVbPFixed,null].filter(y.notNull).some((t=>e instanceof t))}(e))return o.propertiesDefinitionsForSource(e).then((i=>null!==i?ci(e,t,s,n,i):null));if((0,B.isStudy)(e)&&function(e){const{shortId:t}=e.metaInfo();return"Overlay"===t}(e)||(0,V.isLineTool)(e))return o.propertiesDefinitionsForSource(e).then((r=>{if(null!==r){return function(e){ +;return this._measureUnitIdText.textContent!==t&&(this._measureUnitIdText.textContent=t,this._width=null),this._measureUnitIdLabelDiv.classList.contains("js-hidden")!==(0===e.names.size)&&(this._measureUnitIdLabelDiv.classList.toggle("js-hidden",0===e.names.size),this._width=null),!0}updateColors(e,t){this._currencyAndUnitLabelsWrapper.style.backgroundColor=e}currencyInfo(){return this._currencyInfo}unitInfo(){return this._unitInfo}measureUnitIdInfo(){return this._measureUnitIdInfo}setFontSize(e){this._fontSize!==e&&(this._fontSize=e,this._currencyLabelDiv.style.fontSize=e+"px",this._measureUnitIdLabelDiv.style.fontSize=e+"px",this._unitLabelDiv.style.fontSize=e+"px",this._width=null)}labelBottom(){const e=this._oneLineHeight();let t=(this.currencyLabelEnabled()?e:0)+(this.measureUnitIdLableEnabled()?e:0)+(this.unitLabelEnabled()?e:0);return t>0&&(t+=Number(we.css_first_row_top_padding)),t}_textMarginAndPadding(){return Number(we.css_wrapper_margin)+Number(we.css_row_left_right_padding)+2}_currencyTooltipContent(){const e=this._currencyInfo;return null===e?"":null===e.selectedCurrency?Array.from(e.currencies).map((t=>(0,r.ensureDefined)(e.displayedValues.get(t)))).join(", "):e.displayedValues.get(e.selectedCurrency)||""}_unitTooltipContent(){const e=this._unitInfo;return null===e?"":null===e.selectedUnit?Array.from(e.units).map((t=>(0,r.ensureDefined)(e.names.get(t)))).join(", "):e.descriptions.get(e.selectedUnit)||""}_measureUnitIdTooltipContent(){const e=this._measureUnitIdInfo;return null===e?"":null===e.selectedMeasureUnitId?Array.from(e.measureUnitIds).map((t=>(0,r.ensureDefined)(e.names.get(t)))).join(", "):e.descriptions.get(e.selectedMeasureUnitId)||""}_updateVisibility(){const e=this.isEnabled();this._currencyAndUnitLabelsWrapper.classList.toggle("js-hidden",!e)}_oneLineHeight(){return 3+this._fontSize}}async function Ce(e,t,s,r){const{UnitConversionRenderer:n}=await Promise.all([i.e(2666),i.e(1013),i.e(3842),i.e(4015),i.e(5145),i.e(855),i.e(6),i.e(2587),i.e(6752),i.e(6036),i.e(6025),i.e(7111),i.e(962),i.e(3016),i.e(3179),i.e(2704)]).then(i.bind(i,28587));return new n(e,s,t,r)}function xe(e,t){let{deltaX:i,deltaY:s}=e;switch(i/=100,s/=100,t.deltaMode){case t.DOM_DELTA_PAGE:i*=120,s*=120;break;case t.DOM_DELTA_LINE:i*=32,s*=32}return{deltaX:i,deltaY:s}}class Te{constructor(){this._totalDeltaX=0,this._totalDeltaY=0,this._prevWheelTime=0}processWheel(e){e.timeStamp-this._prevWheelTime>100&&this._reset(),this._totalDeltaX+=e.deltaX,this._totalDeltaY+=e.deltaY,this._prevWheelTime=e.timeStamp;const t={deltaX:e.deltaX,deltaY:e.deltaY};return 0===this._totalDeltaX||0===this._totalDeltaY||(Math.abs(this._totalDeltaX)>=Math.abs(3*this._totalDeltaY)&&(t.deltaY=0),Math.abs(this._totalDeltaY)>=Math.abs(3*this._totalDeltaX)&&(t.deltaX=0)),xe(t,e)}_reset(){this._totalDeltaX=0,this._totalDeltaY=0}}var Ie=i(68335),Me=i(77212),Le=i(10786),Ae=i(14483),ke=i(73212),De=i(42226),Ee=i(39875),Ve=i(97754),Be=i.n(Ve),Re=i(58035);class Ne{constructor({setMode:e,className:t=""}){const s=this._wrapper=document.createElement("div") +;s.classList.add(t),s.addEventListener("dblclick",this._stopPropagation,{capture:!0}),s.addEventListener("touchstart",this._stopPropagation,{capture:!0});const r=s.appendChild(document.createElement("div"));r.className=Re.priceScaleModeButtons,this._autoScaleButton=r.appendChild(this._createButton({title:o.t(null,{context:'The first letter of the "auto" word'},i(9846)),tooltip:o.t(null,void 0,i(50834)),onClick:()=>e("auto")})),this._logarithmButton=r.appendChild(this._createButton({title:o.t(null,{context:'The first letter of the "logarithmic" word'},i(55765)),tooltip:o.t(null,void 0,i(12285)),onClick:()=>e("log")}))}destroy(){this._wrapper.removeEventListener("dblclick",this._stopPropagation),this._wrapper.removeEventListener("touchstart",this._stopPropagation),this._autoScaleButton.remove(),this._logarithmButton.remove(),this._wrapper.remove()}element(){return this._wrapper}width(){return 52}updateMode(e){const{log:t,autoScale:i}=e;this._logarithmButton.classList.toggle(Re.priceScaleModeButtons__button_activated,!!t),this._autoScaleButton.classList.toggle(Re.priceScaleModeButtons__button_activated,!!i)}_createButton(e){const{title:t,tooltip:i,onClick:s}=e,r=document.createElement("button");return r.className=Be()(Re.priceScaleModeButtons__button,"apply-common-tooltip"),r.textContent=t,r.dataset.tooltip=i,r.addEventListener("click",s),r}_stopPropagation(e){e.stopPropagation()}}var Oe=i(39267);i(47184);const Fe=new z.TranslatedString("change no overlapping labels",o.t(null,void 0,i(83935))),We=new z.TranslatedString("toggle auto scale",o.t(null,void 0,i(63060))),He=new z.TranslatedString("toggle log scale",o.t(null,void 0,i(60166))),ze=o.t(null,void 0,i(75633)),Ue=o.t(null,void 0,i(94420)),je=o.t(null,void 0,i(81520)),Ge=o.t(null,void 0,i(25933)),qe=o.t(null,void 0,i(17258)),$e=o.t(null,void 0,i(50834)),Ye=o.t(null,{context:"scale_menu"},i(70361)),Ke=o.t(null,{context:"scale_menu"},i(47807)),Ze=o.t(null,{context:"scale_menu"},i(34727)),Xe=o.t(null,{context:"scale_menu"},i(72116)),Je=o.t(null,{context:"scale_menu"},i(19238)),Qe=o.t(null,{context:"scale_menu"},i(54138));const et=function(e){const t=new Le.LimitedPrecisionNumericFormatter(e);return(e,i)=>(0,y.isNumber)(i)&&!e.isLog()?t.format(i):""}(4),tt={contextMenuEnabled:!0,currencyConversionEnabled:!1,unitConversionEnabled:!1,countdownEnabled:!0,contextMenu:{general:!0,source:!0},pressedMouseMoveScale:!0,mouseWheelScale:!0,pinchScale:!0,croppedTickMarks:!0};class it{constructor(e,t,i,r,n,o,a,l,c){this._actions=null,this._priceScale=null,this._scaleModeButtons=null,this._widthCache=new ve.TextWidthCache(1e3),this._color=null,this._fontSize=null,this._currencyFontSize=0,this._currencyLabelWidth=null,this._isVisible=!0,this._currencyMenu=null,this._unitMenu=null,this._size=(0,s.size)({width:0,height:0}),this._currentCursorClassName="",this._destroyed=!1,this._highlighted=!1,this._mouseWheelHelper=null,this._dragScaleActive=!1,this._offset=NaN,this._pinching=!1,this._lastHittestResult=null,this._isHovered=new fe.WatchedValue(!1), +this._recalcCurrencyAndUnitVisibility=()=>{if(null===this._currencyLabel)return;let e=!0;switch((0,De.currencyUnitVisibilityProperty)().value()){case"alwaysOff":e=!1;break;case"visibleOnMouseOver":const t=this._chart.anyPriceAxisHovered().value(),i=null!==this._currencyMenu&&this._currencyMenu.isOpened(),s=null!==this._unitMenu&&this._unitMenu.isOpened();e=t||i||s}this._currencyLabel.setHidden(!e)},this._handleAutoLogButtonsVisibilityProperty=e=>{const t=e.value();"alwaysOff"===t?this._scaleModeButtons&&this._destroyScaleModeButtons():(this._scaleModeButtons||this._createScaleModeButtons(),"alwaysOn"===t?(this._isHovered.unsubscribe(this._updatePriceScaleModeButtonsVisibility),this._updatePriceScaleModeButtonsVisibility(!0)):this._isHovered.subscribe(this._updatePriceScaleModeButtonsVisibility,{callWithLast:!0}))},this._updatePriceScaleModeButtonsVisibility=e=>{var t;null===(t=this._scaleModeButtons)||void 0===t||t.element().classList.toggle("price-axis__modeButtons_hidden",!e)},this._updateScaleModeButtons=()=>{var e;this._priceScale&&(null===(e=this._scaleModeButtons)||void 0===e||e.updateMode(this._priceScale.mode()))},this._chart=e,this._pane=t,this._undoModel=i,this._properties=r,this._isLeft="left"===o,this._options=(0,y.merge)((0,y.clone)(tt),a),this._rendererOptionsProvider=n,this._backgroundBasedTheme=c,this._cell=document.createElement("div"),this._cell.className="price-axis",this._cell.style.width="25px",this._cell.style.left="0",this._canvasConfiguredHandler=()=>{this._undoModel.model().lightUpdate()},this._canvasBinding=(0,J.createBoundCanvas)(this._cell,(0,s.size)({width:16,height:16})),this._canvasBinding.subscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler);const h=this._canvasBinding.canvasElement;h.style.position="absolute",h.style.zIndex="1",h.style.left="0",h.style.top="0",this._topCanvasBinding=(0,J.createBoundCanvas)(this._cell,(0,s.size)({width:16,height:16})),this._topCanvasBinding.subscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler);const d=this._topCanvasBinding.canvasElement;d.style.position="absolute",d.style.zIndex="2",d.style.left="0",d.style.top="0",this._mouseEventHandler=new X.MouseEventHandler(this._cell,this,{treatVertTouchDragAsPageScroll:!1,treatHorzTouchDragAsPageScroll:!0}),this._options.currencyConversionEnabled||this._options.unitConversionEnabled?(this._currencyLabel=new Pe,this._cell.appendChild(this._currencyLabel.element())):this._currencyLabel=null,this._properties.childs().fontSize.subscribe(this,this._onFontSizeChanged),this._options.mouseWheelScale&&(this._mouseWheelHelper=new Te,this._cell.addEventListener("wheel",this._onMousewheel.bind(this),{passive:!1})),this._axisInfo=l,this._offset=0,this.restoreDefaultCursor(),(0,De.currencyUnitVisibilityProperty)().subscribe(this,this._recalcCurrencyAndUnitVisibility),(0,Ee.autoLogButtonsVisibilityProperty)().subscribe(this,this._handleAutoLogButtonsVisibilityProperty),this._handleAutoLogButtonsVisibilityProperty((0,Ee.autoLogButtonsVisibilityProperty)()), +this._chart.anyPriceAxisHovered().subscribe(this._recalcCurrencyAndUnitVisibility,{callWithLast:!0}),this.update()}getContextMenuActions(){this._initActions();const e=(0,r.ensureNotNull)(this._actions),t=this._chart.actions(),i=[];return i.push(e.reset,new C.Separator),i.push(this._autoScaleAction()),this._isMainSeriesAxis()&&i.push(this._lockScaleAction()),i.push(t.scaleSeriesOnly,this._invertAction(),new C.Separator,this._regularScaleAction(),this._percentageAction(),this._indexedTo100Action(),this._logAction(),new C.Separator),h.CheckMobile.any()||(i.push(this._createMergeScalesAction()),i.push(new C.Separator)),Ae.enabled("fundamental_widget")||i.push(new C.Action({actionId:"Chart.PriceScale.Labels",label:Ue,subItems:[t.showSymbolLabelsAction,t.showSeriesLastValue,null,null,t.showHighLowPriceLabels,Ae.enabled("show_average_close_price_line_and_label")?t.showAverageClosePriceLabel:null,null,t.showStudyPlotNamesAction,t.showStudyLastValue,e.alignLabels].filter(Boolean)})),i.push((0,ke.createLinesAction)(this._chart)),this._options.countdownEnabled&&i.push(t.showCountdown),this._undoModel.crossHairSource().isMenuEnabled()&&i.push(t.addPlusButton),!(0,h.onWidget)()&&Ae.enabled("show_chart_property_page")&&Ae.enabled("chart_property_page_scales")&&t.scalesProperties&&i.push(new C.Separator,t.scalesProperties),i}getElement(){return this._cell}onOptimalWidthNeedToBeRecalculated(e){(this._size.width0&&(s=Math.max(s,this._widthCache.measureText(t,n[0].label),this._widthCache.measureText(t,n[n.length-1].label)));const o=(null===(e=r.mainSource())||void 0===e?void 0:e.firstValue())||null;if(null!==o){const e=r.coordinateToPrice(1,o),i=r.coordinateToPrice(this._size.height-2,o);if(Math.abs(e-i)>1e-14){const n=r.formatPrice(Math.floor(Math.min(e,i))+.11111111111111,o),a=r.formatPrice(Math.ceil(Math.max(e,i))-.11111111111111,o);s=Math.max(s,this._widthCache.measureText(t,n),this._widthCache.measureText(t,a))}}}let o=0;this._isCurrencyLabelEnabled()&&(null===this._currencyLabelWidth&&(this._currencyLabelWidth=(0,r.ensureNotNull)(this._currencyLabel).width()),o=Math.round(this._currencyLabelWidth));const a=s||34;let l=Math.max(o,null!==(i=null===(t=this._scaleModeButtons)||void 0===t?void 0:t.width())&&void 0!==i?i:0,Math.ceil(n.borderSize+n.additionalPaddingInner+n.paddingInner+n.paddingOuter+a+4));return l+=l%2,l}backLabels(e){const t=[],i=this._grouppedSources(),s=s=>{for(const r of s){ +if(!e&&i.topLevelSources.has(r))continue;const s=r.priceAxisViews(this._pane.state(),this.priceScale());if(s)for(const e of s)t.push(e)}};return s(i.sources),s(this._pane.state().customSources()),t}setSizeAndOffset(e,t){(0,s.equalSizes)(this._size,e)||(this._size=e,this._canvasBinding.resizeCanvasElement(e),this._topCanvasBinding.resizeCanvasElement(e),this._cell.style.width=e.width+"px",this._cell.style.height=e.height+"px",this._cell.style.minWidth=e.width+"px"),this._offset!==t&&(this._offset=t,this._cell.style.left=t+"px")}getWidth(){return this._size.width}getImage(){const e=this._size,t=(0,J.createDisconnectedCanvas)(document,e);return(0,J.getPrescaledContext2D)(t).drawImage(this._canvasBinding.canvasElement,0,0,e.width,e.height),null!==this._currencyLabel&&this._currencyLabel.isEnabled()&&this._currencyLabel.drawLabel((0,J.getContext2D)(t),e.width,(0,ge.getCanvasDevicePixelRatio)(t)),t}update(){null!==this._priceScale&&(this._priceScale.marks(),this._updateCurrencyLabelFont(),this.rendererOptions())}paint(e){if(!this._isVisible||0===this._size.width||0===this._size.height)return;if(e===N.InvalidationLevel.None)return;const t=this._pane.state(),i=!t.maximized().value()&&t.collapsed().value();if(this._canvasBinding.applySuggestedBitmapSize(),this._topCanvasBinding.applySuggestedBitmapSize(),e>N.InvalidationLevel.Cursor){const e=(0,J.getContext2D)(this._canvasBinding.canvasElement),t=(0,J.getBindingPixelRatio)(this._canvasBinding);i||this._alignLabels(),this._drawBackground(e,t),this._drawBorder(e,t),this._pane.hasState()&&(this.updateCurrencyLabel(),this._scaleModeButtons&&(this._scaleModeButtons.element().style.background=this.backgroundColor()),i||(this._drawTickMarks(e,t),this._drawBackLabels(e,t)))}if(this._pane.hasState()&&!i){const e=(0,J.getContext2D)(this._topCanvasBinding.canvasElement),t=(0,J.getBindingPixelRatio)(this._topCanvasBinding);e.clearRect(0,0,Math.ceil(this._size.width*t)+1,Math.ceil(this._size.height*t)+1),this._drawCrossHairLabel(e,t)}}restoreDefaultCursor(){this._setCursor("")}priceScale(){return(0,r.ensureNotNull)(this._priceScale)}setPriceScale(e){this._priceScale!==e&&(null!==this._priceScale&&(this._priceScale.onMarksChanged().unsubscribe(this,this.onOptimalWidthNeedToBeRecalculated),this._priceScale.modeChanged().unsubscribeAll(this)),this._priceScale=e,null!==e&&(e.onMarksChanged().subscribe(this,this.onOptimalWidthNeedToBeRecalculated),e.modeChanged().subscribe(this,(()=>this.onOptimalWidthNeedToBeRecalculated(!0))),this.onOptimalWidthNeedToBeRecalculated(),this._scaleModeButtons&&(e.modeChanged().subscribe(this,this._updateScaleModeButtons),this._updateScaleModeButtons())))}isVisible(){return this._isVisible}setVisible(e){(e=!!e)!==this._isVisible&&(this._cell.style.display=e?"table-cell":"none",this._isVisible=e)}destroy(){null!==this._currencyMenu&&(this._currencyMenu.close(),this._currencyMenu=null),null!==this._unitMenu&&(this._unitMenu.close(),this._unitMenu=null),this._topCanvasBinding.unsubscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler), +this._topCanvasBinding.dispose(),this._canvasBinding.unsubscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler),this._canvasBinding.dispose(),null!==this._priceScale&&(this._priceScale.onMarksChanged().unsubscribe(this,this.onOptimalWidthNeedToBeRecalculated),this._priceScale.modeChanged().unsubscribeAll(this)),this._priceScale=null,this._mouseEventHandler.destroy(),this._properties.childs().fontSize.unsubscribe(this,this._onFontSizeChanged),null!==this._actions&&this._actions.reset&&this._actions.reset.destroy(),(0,De.currencyUnitVisibilityProperty)().unsubscribeAll(this),this._chart.anyPriceAxisHovered().unsubscribe(this._recalcCurrencyAndUnitVisibility),(0,Ee.autoLogButtonsVisibilityProperty)().unsubscribeAll(this),this._chart.setPriceAxisHovered(this,!1),this._destroyScaleModeButtons(),this._destroyed=!0}axisInfo(){return this._axisInfo}setHighlighted(e){this._highlighted=e}backgroundColor(){return this._pane.state().model().backgroundColor().value()}backgroundTopColor(){return this._pane.state().model().backgroundTopColor().value()}lineColor(){return this._properties.childs().lineColor.value()}textColor(){return this._properties.childs().textColor.value()}fontSize(){return this._properties.childs().fontSize.value()}baseFont(){return(0,ee.makeFont)(this.fontSize(),re.CHART_FONT_FAMILY,"")}rendererOptions(){let e=this._rendererOptionsProvider.options();return this._color===e.color&&this._fontSize===e.fontSize||(this._color=e.color),this._fontSize!==e.fontSize&&(this._widthCache.reset(),this._fontSize=e.fontSize,this._currencyLabelWidth=null,this._currencyFontSize=0,this._updateCurrencyLabelFont(),this.onOptimalWidthNeedToBeRecalculated()),e}mouseEnterEvent(e){this._chart.setPriceAxisHovered(this,!0),this._isHovered.setValue(!0),this._mouseEnterOrTouchStartEvent(e)}mouseMoveEvent(e){this._mouseOrTouchMoveEvent(e)}mouseDownEvent(e){this._mouseDownOrTouchStartEvent(e)}touchStartEvent(e){this._mouseOrTouchMoveEvent(e),this._mouseEnterOrTouchStartEvent(e),this._mouseDownOrTouchStartEvent(e)}pressedMouseMoveEvent(e){this._pressedMouseOrTouchMoveEvent(e)}touchMoveEvent(e){this._pressedMouseOrTouchMoveEvent(e)}pinchStartEvent(e,t,i,s){return s.bothPointsOnTargetElement}pinchEvent(e,t,i){if(this._zoomAvailable()&&this._options.pinchScale){if(this._dragScaleActive&&this._finishScale(),!this._pinching)return this._pinching=!0,void this._undoModel.startTwoPointsScalePrice(this._pane.state(),this.priceScale(),t.y,i.y);this._undoModel.twoPointsScalePriceTo(this._pane.state(),this.priceScale(),t.y,i.y)}}pinchEndEvent(){this._pinching=!1,this._undoModel.endTwoPointsScalePrice(this._pane.state(),this.priceScale())}mouseDownOutsideEvent(){this._finishScale()}touchStartOutsideEvent(){this._finishScale()}mouseUpEvent(e){this._mouseUpOrTouchEndEvent(e)}touchEndEvent(e){this._mouseLeaveOrTouchEndEvent(e),this._mouseUpOrTouchEndEvent(e)}mouseClickEvent(e){this._mouseClickOrTapEvent(e)}tapEvent(e){this._mouseClickOrTapEvent(e)}mouseLeaveEvent(e){this._chart.setPriceAxisHovered(this,!1),this._isHovered.setValue(!1), +this._mouseLeaveOrTouchEndEvent(e)}mouseDoubleClickEvent(e){this._mouseDoubleClickOrDoubleTapEvent(e)}doubleTapEvent(e){this._mouseDoubleClickOrDoubleTapEvent(e)}contextMenuEvent(e){this._contextMenuOrTouchContextMenuEvent(e)}touchContextMenuEvent(e){this._contextMenuOrTouchContextMenuEvent(e)}dataSourceAtPoint(e,t){const i=this._pane.state();if(!i.maximized().value()&&i.collapsed().value())return null;const s=this._grouppedSources(),r=[...s.sources,...s.topLevelSources,...i.customSources()];let n=null,o=null;if(!this._priceScale)return null;const a=(e,t)=>{var i;const s=null!==(i=null==o?void 0:o.target())&&void 0!==i?i:0;e.target()>s&&(o=e,n=t)},l=new F.Point(e,t);for(let e=r.length-1;e>=0;--e){const t=r[e],s=t.priceAxisViews(i,this._priceScale);if(s&&0!==s.length)for(let e=s.length-1;e>=0;--e){const i=s[e].renderer();if(void 0!==i.hitTest){const e=i.hitTest(l,this._size.width,this._isLeft?"left":"right");null!==e&&a(e,t)}}}return this._lastHittestResult=o,n}reset(){const e=this._pane.state(),t=this.priceScale();this._undoModel.resetPriceScale(e,t),this.onOptimalWidthNeedToBeRecalculated(!0)}updateCurrencyLabel(){if(null===this._currencyLabel)return;let e=!1;if(this._options.currencyConversionEnabled){const t=this.priceScale().currency(this._undoModel.model().availableCurrencies());null===t||"alwaysOff"===(0,De.currencyUnitVisibilityProperty)().value()?(e=this._currencyLabel.currencyLabelEnabled(),this._currencyLabel.disableCurrency()):(e=!this._currencyLabel.currencyLabelEnabled(),this._currencyLabel.enableCurrency(),this._currencyLabel.updateColors(this.backgroundTopColor(),this.textColor()),e=this._currencyLabel.setCurrencyInfo(t)||e)}else this._currencyLabel.disableCurrency();if(this._options.unitConversionEnabled){const t="alwaysOff"===(0,De.currencyUnitVisibilityProperty)().value(),i=this._undoModel.model().availableUnits(),s=this.priceScale().unit(i);null===s||t?(e=e||this._currencyLabel.unitLabelEnabled(),this._currencyLabel.disableUnit()):(e=e||!this._currencyLabel.unitLabelEnabled(),this._currencyLabel.enableUnit(),this._currencyLabel.updateColors(this.backgroundTopColor(),this.textColor()),e=this._currencyLabel.setUnitInfo(s)||e);const r=this.priceScale().measureUnitId(i);null===r||t?(e=e||this._currencyLabel.measureUnitIdLableEnabled(),this._currencyLabel.disableMeasureUnitId()):(e=e||!this._currencyLabel.measureUnitIdLableEnabled(),this._currencyLabel.enableMeasureUnitId(),this._currencyLabel.updateColors(this.backgroundTopColor(),this.textColor()),e=this._currencyLabel.setMeasureUnitIdInfo(r)||e)}else this._currencyLabel.disableUnit(),this._currencyLabel.disableMeasureUnitId();this._updateCurrencyLabelFont(),e&&(this._currencyLabelWidth=null)}_grouppedSources(){var e;const t=this._pane,i=t.state().model(),s=this._sameSideSources().slice(),r=t.state(),n=this.priceScale(),o=new Set,a=null!==(e=i.lineBeingEdited())&&void 0!==e?e:i.lineBeingCreated();a&&o.add(a);const l=i.customSourceBeingMoved();null!==l&&o.add(l),i.sourcesBeingMoved().forEach((e=>o.add(e))), +i.selection().allSources().forEach((e=>o.add(e)));const c=i.hoveredSource();null!==c&&o.add(c);if(n===r.defaultPriceScale()){const e=this._pane.state().dataSources();for(const t of e)r.isOverlay(t)&&s.push(t)}return{sources:s,topLevelSources:o}}_isCurrencyLabelEnabled(){return null!==this._currencyLabel&&this._currencyLabel.isEnabled()}_updateCurrencyLabelFont(){if(null===this._currencyLabel)return;const e=this.fontSize();e!==this._currencyFontSize&&(this._currencyLabel.setFontSize(e),this._currencyFontSize=e,this._currencyLabelWidth=null,this.onOptimalWidthNeedToBeRecalculated())}_alignLabels(){var e,t;const i=this._size.height;let s=i/2;const r=[],n=this.priceScale(),o=n.orderedSources().slice(),a=this._pane.state(),l=this.rendererOptions();if(n===a.defaultPriceScale()){const e=a.priceDataSources();for(let t=0;t{if(e.ignoreAlignment()||!e.isVisible())return!1;const{total:t}=e.topBottomTotalHeight(l),s=e.floatCoordinate();return s>-t&&se.floatCoordinate()<=s)),d=r.filter((e=>e.floatCoordinate()>s));h.sort(((e,t)=>t.floatCoordinate()-e.floatCoordinate())),h.length>0&&d.length>0&&d.push(h[0]),d.sort(((e,t)=>e.floatCoordinate()-t.floatCoordinate()));for(const e of r)e.setFixedCoordinate(e.coordinate());if(n.properties().childs().alignLabels.value()){if(d.length>0||h.length>0){{const t=null!==(e=h[0])&&void 0!==e?e:d[0],s=t.getFixedCoordinate(),{top:r,bottom:n,total:o}=t.topBottomTotalHeight(l);o0&&t.setFixedCoordinate(r)}{const e=null!==(t=d[0])&&void 0!==t?t:h[0],s=e.getFixedCoordinate(),{top:r,bottom:n,total:o}=e.topBottomTotalHeight(l);oi&&e.setFixedCoordinate(i-n)}}for(let e=1;ea-n)t.setFixedCoordinate(a-n);else if(a>0&&o-s<0&&o+r>0){const{top:e}=i.topBottomTotalHeight(l);t.setFixedCoordinate(Math.min(a-e-r,s))}}for(let e=1;ei&&t.setFixedCoordinate(Math.max(a+r+e,i-s))}}}}_drawTickMarks(e,t){const i=this.priceScale().marks();e.save(),e.font=this.baseFont();const s=this.rendererOptions(),n=this._isLeft?Math.floor((this._size.width-s.additionalPaddingInner)*t):0,o=this._isLeft?Math.round(n-s.paddingInner*t):Math.round(n+(s.additionalPaddingInner+s.paddingInner)*t),a=this.fontSize(),l=this._isCurrencyLabelEnabled()?(0,r.ensureNotNull)(this._currencyLabel).labelBottom():0,c=i.map((t=>{if(this._options.croppedTickMarks)return{visible:!0,yCorrection:this._widthCache.yMidCorrection(e,t.label)} +;const i=t.coord-a/2,s=t.coord+a/2,r=!(s>this._size.height||ithis._size.height||i{for(let s=i.length;s--;){if(!c[s].visible)continue;const r=i[s];e.fillText(r.label,o/t,r.coord+c[s].yCorrection)}})),e.restore()}_hasAlertLabel(){return!1}async _showCurrenciesContextMenu(){var e;if(null!==this._currencyMenu&&this._currencyMenu.isOpened())return void this._currencyMenu.close();(0,Se.trackEvent)("GUI","Currency conversion");const{currencyActions:t}=await Promise.all([i.e(2666),i.e(1013),i.e(3842),i.e(4015),i.e(5145),i.e(855),i.e(6),i.e(2587),i.e(6752),i.e(6036),i.e(6025),i.e(7111),i.e(962),i.e(3016),i.e(3179),i.e(2704)]).then(i.bind(i,84298)),s=await Ce(je,(()=>t(this._undoModel,(0,r.ensureNotNull)(this._currencyLabel).currencyInfo(),this.priceScale())),(0,r.ensureNotNull)(this._currencyLabel).currencyLabelElement(),(()=>{var e;this._recalcCurrencyAndUnitVisibility(),null===(e=this._currencyLabel)||void 0===e||e.setCurrencyExpanded(!1)}));null===(e=this._currencyLabel)||void 0===e||e.setCurrencyExpanded(!0),this._destroyed?s.close():this._currencyMenu=s}async _showUnitsContextMenu(){var e;if(null!==this._unitMenu&&this._unitMenu.isOpened())return void this._unitMenu.close();(0,Se.trackEvent)("GUI","Unit conversion");const{unitActions:t}=await Promise.all([i.e(2666),i.e(1013),i.e(3842),i.e(4015),i.e(5145),i.e(855),i.e(6),i.e(2587),i.e(6752),i.e(6036),i.e(6025),i.e(7111),i.e(962),i.e(3016),i.e(3179),i.e(2704)]).then(i.bind(i,14818)),s=await Ce(Ge,(()=>t(this._undoModel,(0,r.ensureNotNull)(this._currencyLabel).unitInfo(),this.priceScale())),(0,r.ensureNotNull)(this._currencyLabel).unitLabelElement(),(()=>{var e;this._recalcCurrencyAndUnitVisibility(),null===(e=this._currencyLabel)||void 0===e||e.setUnitExpanded(!1)}));null===(e=this._currencyLabel)||void 0===e||e.setUnitExpanded(!0),this._destroyed?s.close():this._unitMenu=s}_onFontSizeChanged(){this._currencyLabelWidth=null,this._currencyFontSize=0,this._updateCurrencyLabelFont(),this.onOptimalWidthNeedToBeRecalculated()}_mouseOrTouchMoveEvent(e){var t,i,s,r;if(!this._priceScale)return;if(e.localX<0||e.localY<0||e.localX>=this._size.width||e.localY>=this._size.height)return;let n=!0;const o=this.dataSourceAtPoint(e.localX,e.localY);o?(this._setCursorClassName("pointer"),(null===(i=null===(t=this._lastHittestResult)||void 0===t?void 0:t.data())||void 0===i?void 0:i.hoverModelFromAxis)&&(this._undoModel.model().setHoveredSource(o,null!==(r=null===(s=this._lastHittestResult)||void 0===s?void 0:s.data())&&void 0!==r?r:null),n=!1)):this._setResizeCursor(),n&&this._undoModel.model().setHoveredSource(null,null)}_mouseDownOrTouchStartEvent(e){this._zoomAvailable()&&this._options.pressedMouseMoveScale&&!this._pinching&&(this._dragScaleActive=!0,this._undoModel.startScalePrice(this._pane.state(),this.priceScale(),e.localY))}_mouseEnterOrTouchStartEvent(e){ +this._setResizeCursor()}_pressedMouseOrTouchMoveEvent(e){if(this._dragScaleActive){const t=this.priceScale();this._undoModel.scalePriceTo(this._pane.state(),t,e.localY)}}_mouseUpOrTouchEndEvent(e){this._finishScale()}_finishScale(){this._dragScaleActive&&(this._undoModel.endScalePrice(this._pane.state(),this.priceScale()),this.restoreDefaultCursor(),this._dragScaleActive=!1)}_mouseClickOrTapEvent(e){if(this._currencyLabel){if(this._currencyLabel.currencyConversionAvailable()&&this._currencyLabel.currencyLabelElement().contains(e.target))return this._showCurrenciesContextMenu(),void e.preventDefault();if(this._currencyLabel.unitConversionAvailable()&&this._currencyLabel.unitLabelElement().contains(e.target))return this._showUnitsContextMenu(),void e.preventDefault()}const t=this.dataSourceAtPoint(e.localX,e.localY);t&&this._undoModel.selectionMacro((e=>{var i,s,r;e.selection().isSelected(t)&&this._undoModel.model().lastSelectedHittestData()===(null===(i=this._lastHittestResult)||void 0===i?void 0:i.data())||(e.clearSelection(),e.addSourceToSelection(t,null!==(r=null===(s=this._lastHittestResult)||void 0===s?void 0:s.data())&&void 0!==r?r:null))}))}_mouseLeaveOrTouchEndEvent(e){this._setCursorClassName("")}_mouseDoubleClickOrDoubleTapEvent(e){var t;const i=this.dataSourceAtPoint(e.localX,e.localY);i?this._pane.processDoubleClickOnSource(i,null!==(t=this._lastHittestResult)&&void 0!==t?t:void 0,{origin:"price_scale"}):(this.reset(),(0,Se.trackEvent)("GUI","Double click price scale"))}_contextMenuOrTouchContextMenuEvent(e){if(this._options.contextMenuEnabled){const t=this.dataSourceAtPoint(e.localX,e.localY);if(null!==t&&this._options.contextMenu.source){return void this._undoModel.model().selectionMacro((i=>{i.selection().isSelected(t)||(i.clearSelection(),i.addSourceToSelection(t)),this._pane.showContextMenuForSelection(e,{origin:"price_scale"})}))}this._options.contextMenu.general&&he.ContextMenuManager.showMenu(this.getContextMenuActions(),e,{statName:"PriceScaleContextMenu"},{menuName:"PriceScaleContextMenu"})}}_setResizeCursor(){const e=this.priceScale();e.isPercentage()||e.isIndexedTo100()?this._setCursorClassName(""):this._zoomAvailable()&&(this._options.pressedMouseMoveScale||this._options.mouseWheelScale)&&this._setCursorClassName("ns-resize")}_setCursorClassName(e){let t="";e&&(t="price-axis--cursor-"+e),this._currentCursorClassName!==t&&(this._currentCursorClassName&&this._cell.classList.remove(this._currentCursorClassName),t&&this._cell.classList.add(t),this._currentCursorClassName=t)}_zoomAvailable(){return!this.priceScale().isEmpty()&&this._undoModel.model().zoomEnabled()}_onMousewheel(e){if(!this._zoomAvailable()||!this._options.mouseWheelScale)return;const t=(0,r.ensureNotNull)(this._mouseWheelHelper).processWheel(e).deltaY;if(0===t)return;e.cancelable&&e.preventDefault();const i=this._undoModel,s=this._pane.state(),n=this.priceScale(),o=this._cell.getBoundingClientRect(),a=e.clientY-o.top,l=a+15*t;i.startScalePrice(s,this.priceScale(),a,!0),i.scalePriceTo(s,n,l),i.endScalePrice(s,n),e.stopPropagation()} +_drawCrossHairLabel(e,t){var i,s;e.save();const r=this._pane.state(),n=r.model(),o=this.priceScale(),a=[],l=this.priceScale()===r.defaultPriceScale(),c=null!==(i=n.lineBeingEdited())&&void 0!==i?i:n.lineBeingCreated();if(c&&(c.priceScale()===o||l&&r.isOverlay(c))){const e=c.priceAxisViews(r,o);e&&e.length&&a.push(e)}const h=n.customSourceBeingMoved();this._addViewsOrMaxMin(null===h?[]:[h],a),this._addViewsOrMaxMin(n.sourcesBeingMoved(),a),this._addViewsOrMaxMin(n.selection().allSources(),a);const d=n.hoveredSource();if(d){const e=r.customSources().includes(d)?o:d.priceScale();if(!n.selection().isSelected(d)&&(this._isFromSameSide(e)||l&&r.isOverlay(d))){const e=null===(s=n.hoveredSource())||void 0===s?void 0:s.priceAxisViews(r,o);e&&e.length&&a.push(e)}}const u=n.crossHairSource().priceAxisViews(r,o);u&&u.length&&a.push(u);const p=this.rendererOptions(),_=this._isLeft?"right":"left";a.forEach((i=>{i.forEach((i=>{e.save(),i.renderer().draw(e,p,this._widthCache,this._size.width,this._size.height,_,t),e.restore()}))})),e.restore()}_drawBackground(e,t){const i=Math.ceil(this._size.width*t),s=Math.ceil(this._size.height*t),r=this.backgroundTopColor(),n=this.backgroundColor();if(r===n?(0,J.clearRect)(e,0,0,i+1,s+1,this.backgroundColor()):(0,Q.clearRectWithGradient)(e,0,0,i+1,s+1,r,n),this._highlighted){e.globalAlpha=.5;const t=te.themes[this._backgroundBasedTheme.value()].getThemedColor("color-price-axis-highlight");(0,J.fillRect)(e,0,0,i+1,s+1,t),e.globalAlpha=1}const o=this._pane.state().model(),a=this.priceScale(),l=o.selection().lineDataSources().filter((e=>e.priceScale()===a)).reduce(((e,t)=>{const i=t.priceAxisPoints();return 0===i.length?e:e.concat(i)}),[]);l.length>0&&this._hightlightBackground(e,l,this.priceScale().mainSource(),t);const c=o.crossHairSource();c.startMeasurePoint()&&this._hightlightBackground(e,c.measurePoints(),this.priceScale().mainSource(),t)}_drawBorder(e,t){e.save(),e.fillStyle=this.lineColor();const i=Math.max(1,Math.floor(this.rendererOptions().borderSize*t)),s=this._isLeft?Math.floor(this._size.width*t)-i:0;e.fillRect(s,0,i,Math.ceil(this._size.height*t)+1),e.restore()}_drawBackLabels(e,t){e.save();const i=this.backLabels(),s=this.rendererOptions(),r=this._isLeft?"right":"left";for(const n of i)n.isAxisLabelVisible()&&(e.save(),n.renderer().draw(e,s,this._widthCache,this._size.width,this._size.height,r,t),e.restore());e.restore()}_hightlightBackground(e,t,i,s){if(!i)return;const r=i.firstValue();if(null===r)return;let n=t[0].price,o=t[0].price;for(let e=1;ei.isOverlay(e)||this._isFromSameSide(e.priceScale())))),0!==e.length)if(1===e.length){const r=e[0].priceAxisViews(i,s) +;r&&r.length&&t.push(r)}else t.push(this._minMaxViews(e))}_minMaxViews(e){const t=this._pane.state(),i=this.priceScale(),s=[];let r=1/0,n=-1/0,o=null,a=null;for(const s of e){const e=s.priceAxisViews(t,i);if(e&&e.length)for(let t=0;t=n&&(n=s,a=i),s<=r&&(r=s,o=i)}}return a&&s.push(a),o&&s.push(o),s}_isFromSameSide(e){return null!==e&&(this._isLeft?this._pane.state().leftPriceScales():this._pane.state().rightPriceScales()).includes(e)}_sameSideSources(){const e=this._pane.state().sourcesByGroup();return this._isLeft?e.leftPriceScalesSources():e.rightPriceScalesSources()}_initActions(){if(!this._pane.hasState()||null!==this._actions)return;const e=this._undoModel,t=new C.Action({actionId:"Chart.PriceScale.Reset",label:qe,icon:Oe,shortcutHint:(0,Ie.humanReadableHash)(Ie.Modifiers.Alt+82),statName:"ResetScale",onExecute:()=>this.reset()}),i=new C.Action({actionId:"Chart.PriceScale.ToggleAutoScale",label:$e,checkable:!0,checked:!0,statName:"ToggleAutoScale",onExecute:()=>{e.togglePriceScaleAutoScaleMode(this.priceScale()),this._updateScalesActions()}}),s=new C.Action({actionId:"Chart.PriceScale.TogglePercentage",label:Ye,checkable:!0,checked:this.priceScale().isPercentage(),statName:"TogglePercantage",onExecute:()=>{e.togglePriceScalePercentageScaleMode(this.priceScale()),this._updateScalesActions()}}),r=new C.Action({actionId:"Chart.PriceScale.ToggleIndexedTo100",label:Ke,checkable:!0,checked:this.priceScale().isIndexedTo100(),statName:"ToggleIndexedTo100",onExecute:()=>{e.togglePriceScaleIndexedTo100ScaleMode(this.priceScale()),this._updateScalesActions()}}),n=new C.Action({actionId:"Chart.PriceScale.ToggleLogarithmic",label:Ze,checkable:!0,checked:this.priceScale().isLog(),statName:"ToggleLogScale",onExecute:()=>{e.togglePriceScaleLogScaleMode(this.priceScale()),this._updateScalesActions()}}),o=new C.Action({actionId:"Chart.PriceScale.ToggleRegular",label:Xe,checkable:!0,checked:this.priceScale().isRegular(),statName:"ToggleRegularScale",onExecute:()=>{e.setPriceScaleRegularScaleMode(this.priceScale()),this._updateScalesActions()}}),a=new C.Action({actionId:"Chart.PriceScale.Labels.ToggleNoOverlappingLabelsVisibility",label:Je,checkable:!0,checked:this.priceScale().properties().childs().alignLabels.value(),statName:"TogglePreciseLabels"});a.setBinding(new Me.ActionBinder(a,this.priceScale().properties().childs().alignLabels,e,Fe));const l=new C.Action({actionId:"Chart.PriceScale.ToggleInvertScale",label:Qe,checkable:!0,checked:this.priceScale().isInverted(),statName:"Invert Scale",onExecute:()=>{e.invertPriceScale(this.priceScale()),this._updateScalesActions()}});this._actions={reset:t,setAutoScale:i,setPercentage:s,setIndexedTo100:r,setLog:n,setRegular:o,alignLabels:a,invertScale:l},this._updateScalesActions()}_logAction(){return this._isMainSeriesAxis()?this._chart.actions().logSeriesScale:(0,r.ensureNotNull)(this._actions).setLog}_percentageAction(){return this._isMainSeriesAxis()?this._chart.actions().percentSeriesScale:(0,r.ensureNotNull)(this._actions).setPercentage} +_indexedTo100Action(){return this._isMainSeriesAxis()?this._chart.actions().indexedTo100SeriesScale:(0,r.ensureNotNull)(this._actions).setIndexedTo100}_autoScaleAction(){return this._isMainSeriesAxis()?this._chart.actions().autoSeriesScale:(0,r.ensureNotNull)(this._actions).setAutoScale}_regularScaleAction(){return this._isMainSeriesAxis()?this._chart.actions().regularSeriesScale:(0,r.ensureNotNull)(this._actions).setRegular}_lockScaleAction(){const e=this._chart.actions().lockSeriesScale,t=et(this.priceScale(),this._undoModel.model().mainSeriesScaleRatio());return e.update({hint:t}),e}_invertAction(){return this._isMainSeriesAxis()?this._chart.actions().invertSeriesScale:(0,r.ensureNotNull)(this._actions).invertScale}_isMainSeriesAxis(){return this.priceScale().hasMainSeries()}_updateScalesActions(){const e=this.priceScale(),t=this._isMainSeriesAxis(),i=(0,r.ensureNotNull)(e.mainSource()).properties(),s=t&&e.isLockScale(),n=t&&6===i.style.value(),o=(0,r.ensureNotNull)(this._actions);o.setRegular.update({checked:e.isRegular(),disabled:s||n}),o.setPercentage.update({checked:e.isPercentage(),disabled:s||n}),o.setIndexedTo100.update({checked:e.isIndexedTo100(),disabled:s||n}),o.setLog.update({checked:e.isLog(),disabled:s||n}),o.setAutoScale.update({checked:e.isAutoScale(),disabled:e.properties().childs().autoScaleDisabled.value()})}_createMergeScalesAction(){const e=this._chart.actions(),t=this._undoModel.model().priceScaleSlotsCount();if(t.left+t.right===1)return 0===t.left?e.moveScaleToLeft:e.moveScaleToRight;const i=[];return i.push(e.mergeLeftScalesAction),i.push(e.mergeRightScalesAction),new C.Action({actionId:"Chart.PriceScale.MergeAllScales",label:ze,subItems:i})}_setCursor(e){let t="";"grabbing"!==e&&"ns-resize"!==e||(t="price-axis--cursor-"+e),this._currentCursorClassName!==t&&(this._currentCursorClassName&&this._cell.classList.remove(this._currentCursorClassName),t&&this._cell.classList.add(t),this._currentCursorClassName=t,this._cell.style.cursor)}_createScaleModeButtons(){var e;const t=this._scaleModeButtons=new Ne({className:"price-axis__modeButtons",setMode:e=>{this._priceScale&&("log"===e?this._chart.model().setPriceScaleMode({log:!this._priceScale.isLog()},this._priceScale,He):this._chart.model().setPriceScaleMode({autoScale:!this._priceScale.isAutoScale()},this._priceScale,We))}});return t.element().style.background=this.backgroundColor(),this._cell.appendChild(t.element()),null===(e=this._priceScale)||void 0===e||e.modeChanged().subscribe(this,this._updateScaleModeButtons),this._updateScaleModeButtons(),t}_destroyScaleModeButtons(){var e;this._scaleModeButtons&&(this._isHovered.unsubscribe(this._updatePriceScaleModeButtonsVisibility),null===(e=this._priceScale)||void 0===e||e.modeChanged().unsubscribe(this,this._updateScaleModeButtons),this._scaleModeButtons.destroy(),this._scaleModeButtons=null)}}function st(e,t){return e.position-t.position}function rt(e,t,i){const s=(e.position-t.position)/(e.time-t.time);return Math.sign(s)*Math.min(Math.abs(s),i)}class nt{constructor(e,t,i,s){this._position1=null, +this._position2=null,this._position3=null,this._position4=null,this._animationStartPosition=null,this._durationMsecs=0,this._speedPxPerMsec=0,this._terminated=!1,this._minSpeed=e,this._maxSpeed=t,this._dumpingCoeff=i,this._minMove=s}addPosition(e,t){if(null!==this._position1){if(this._position1.time===t)return void(this._position1.position=e);if(Math.abs(this._position1.position-e)50)return;let i=0;const s=rt(this._position1,this._position2,this._maxSpeed),r=st(this._position1,this._position2),n=[s],o=[r];if(i+=r,null!==this._position3){const e=rt(this._position2,this._position3,this._maxSpeed);if(Math.sign(e)===Math.sign(s)){const t=st(this._position2,this._position3);if(n.push(e),o.push(t),i+=t,null!==this._position4){const e=rt(this._position3,this._position4,this._maxSpeed);if(Math.sign(e)===Math.sign(s)){const t=st(this._position3,this._position4);n.push(e),o.push(t),i+=t}}}}let a=0;for(let e=0;ea&&(e.result={hittest:t,source:i,renderer:s,isCustom:r})}const Vt={contextMenuEnabled:!0,contextMenu:ke.defaultContextMenuOptions,priceScaleContextMenuEnabled:!0,legendWidgetEnabled:!0,controlsEnabled:!0,propertyPagesEnabled:!0,sourceSelectionEnabled:!0,countdownEnabled:!0},Bt=new Map([[G.AreaName.Text,"Text"],[G.AreaName.Style,"Style"]]),Rt=!Ae.enabled("display_legend_on_all_charts");let Nt=null;function Ot(e,t){return!(0,G.shouldDefaultActionBeExecuted)(e,t,"pressedMouseMoveHandler","touchMoveHandler")}class Ft{constructor(e,t,i,r){this._legendWidget=null,this._paneControls=null,this._isDestroyed=!1,this._trackCrosshairOnlyAfterLongTap=(0,U.lastMouseOrTouchEventInfo)().isTouch,this._startTrackPoint=null,this._exitTrackingModeOnNextTry=!1,this._startMoveSourceParams=null,this._startChangeLineToolParams=null,this._preventSourceChange=!1,this._clonningAtMoveLineTools=null,this._startCloningPoint=null,this._size=(0,s.size)({width:0,height:0}),this._themedTopColor=null,this._initCrossHairPosition=null,this._firstZoomPoint=null,this._editDialog=null,this._processing=!1,this._pressedMoveStage=0,this._touchMove=!1,this._startTouchPoint=null,this._isSelecting=!1,this._prevHoveredHittest=null,this._contextMenuX=0,this._contextMenuY=0,this._startScrollingPos=null,this._isScrolling=!1,this._scrollPriceScale=null,this._scrollXAnimation=null,this._prevPinchScale=1,this._pinching=!1,this._wasPinched=!1,this._longTap=!1,this._contextMenuOpenedOnLastTap=!1,this._paneControlsResizeObserver=null,this._lastClickedSource=null,this._customLegendWidgetsFactoryMap=new Map,this._prevMoveEventPosition=null,this._onMagnetStateChangedListener=this._onMagnetStateChanged.bind(this),this._onShiftKeyStateChangedListener=this._onShiftKeyStateChanged.bind(this),this._currentCursorClassName="",this._lastFinishedToolId=null,this._needResetMeasureLater=!1,this._currentChangingLineToolHitTest=null,this._currentMovingHitTest=null,this._prevTooltipData=null,this._errorRenderer=null,this._highlightedPriceAxis=new fe.WatchedValue({owner:"",axis:null}),this._visuallyCollapsed=new fe.WatchedValue(!1),this._endOfSeriesDataBanner=null,this._canvasConfiguredHandler=()=>this._state&&this._chartModel().lightUpdate(),this._updateVisuallyCollapsed=()=>{this._visuallyCollapsed.setValue(!this.state().maximized().value()&&this.state().collapsed().value())},this._chart=e,this._state=t,this._options=(0,y.merge)((0,y.clone)(Vt),i),this._paneWidgetsSharedState=r,this._state&&this._subscribeToState();const n={contextMenuEnabled:this._options.priceScaleContextMenuEnabled,pressedMouseMoveScale:this._options.handleScale.axisPressedMouseMove.price,mouseWheelScale:this._options.handleScale.mouseWheel,currencyConversionEnabled:this._options.currencyConversionEnabled,unitConversionEnabled:this._options.unitConversionEnabled,countdownEnabled:this._options.countdownEnabled,croppedTickMarks:this._options.croppedTickMarks} +;void 0!==this._options.priceScaleContextMenu&&(n.contextMenu=this._options.priceScaleContextMenu);const o=(e,t,i,s,r)=>new it(this._chart,this,this._chartUndoModel(),i,t,e,n,s,r),a=e.properties().childs().scalesProperties,l=this._chartModel().rendererOptionsProvider(),c={backgroundBasedTheme:e.backgroundBasedTheme(),rendererOptionsProvider:l,getBackgroundTopColor:()=>this._chartModel().backgroundTopColor().value(),getBackgroundBottomColor:()=>this._chartModel().backgroundColor().value()},h={showLabels:!1};this._lhsPriceAxisesContainer=new me(a,"left",o,c,h),this._rhsPriceAxisesContainer=new me(a,"right",o,c,h),this._paneCell=document.createElement("td"),this._paneCell.classList.add("chart-markup-table","pane"),this._div=document.createElement("div"),this._div.classList.add("chart-gui-wrapper"),this._div.setAttribute("data-name","pane-widget-chart-gui-wrapper"),this._paneCell.appendChild(this._div),this._canvasBinding=(0,J.createBoundCanvas)(this._div,(0,s.size)({width:16,height:16})),this._canvasBinding.subscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler);const d=this._canvasBinding.canvasElement;d.style.position="absolute",d.style.left="0",d.style.top="0",this._topCanvasBinding=(0,J.createBoundCanvas)(this._div,(0,s.size)({width:16,height:16})),this._topCanvasBinding.subscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler);const u=this._topCanvasBinding.canvasElement;u.style.position="absolute",u.style.left="0",u.style.top="0",this._rowElement=document.createElement("tr"),this._rowElement.appendChild(this._lhsPriceAxisesContainer.getElement()),this._rowElement.appendChild(this._paneCell),this._rowElement.appendChild(this._rhsPriceAxisesContainer.getElement()),this._options.legendWidgetEnabled&&(this._options.customLegendWidgetFactories&&(this._customLegendWidgetsFactoryMap=this._options.customLegendWidgetFactories),this._loadAndCreateLegendWidget()),this._state&&!this._chart.readOnly()&&this._options.controlsEnabled&&this._loadAndCreatePaneControlsWidget(),(0,_t.magnetEnabled)().subscribe(this._onMagnetStateChangedListener),(0,mt.shiftPressed)().subscribe(this._onShiftKeyStateChangedListener),this._paneCell.addEventListener("dragover",(e=>{e.dataTransfer&&Array.from(e.dataTransfer.files).some(blobImageFilter)&&e.preventDefault()})),this.setCursorForTool(),this._mouseEventHandler=new X.MouseEventHandler(this._topCanvasBinding.canvasElement,this,{treatVertTouchDragAsPageScroll:!this._options.handleScroll.vertTouchDrag,treatHorzTouchDragAsPageScroll:!this._options.handleScroll.horzTouchDrag}),this._prevHoveredHittest=null,this._highlightedPriceAxis.subscribe((e=>this._highlightPriceAxisByLabel(e.axis))),this._prevPinchScale=0,this._isDestroyed=!1}destroy(){var e;this._chart.onPaneWidgetDestroyed(this),this._customLegendWidgetsFactoryMap.clear(),this._topCanvasBinding.unsubscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler),this._topCanvasBinding.dispose(),this._canvasBinding.unsubscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler),this._canvasBinding.dispose(), +this._legendWidget&&(this._legendWidget.destroy(),this._legendWidget=null),null!==this._paneControlsResizeObserver&&this._paneControlsResizeObserver.disconnect(),null!==this._paneControls&&(this._paneControls.destroy(),this._paneControls=null),this._lhsPriceAxisesContainer.destroy(),this._rhsPriceAxisesContainer.destroy(),this.hasState()&&this._unsubscribeFromState(),(0,_t.magnetEnabled)().unsubscribe(this._onMagnetStateChangedListener),(0,mt.shiftPressed)().unsubscribe(this._onShiftKeyStateChangedListener),this._paneWidgetsSharedState.onPaneDestroyed(this),this._errorRenderer&&this._errorRenderer.then((e=>{e.destroy(),this._errorRenderer=null})),this._prevHoveredHittest=null,this._mouseEventHandler.destroy(),null===(e=this._rowElement.parentElement)||void 0===e||e.removeChild(this._rowElement),this._isDestroyed=!0}size(){return this._size}setSize(e){(0,s.equalSizes)(this._size,e)||(this._size=e,this._canvasBinding.resizeCanvasElement(e),this._topCanvasBinding.resizeCanvasElement(e),this._paneCell.style.width=e.width+"px",this._paneCell.style.height=e.height+"px",this._div.style.width=e.width+"px",this._div.style.height=e.height+"px",this._rowElement.classList.toggle("js-hidden",0===e.height),null!==this._legendWidget&&this._legendWidget.updateWidgetModeBySize(e),null!==this._paneControls&&this._paneControls.updateWidgetModeByWidth(e.width))}width(){return this._size.width}height(){return this._size.height}backgroundColor(){return this._chartModel().backgroundColor().value()}highlightedPriceAxis(){return this._highlightedPriceAxis}processDoubleClickOnSource(e,t,i){(0,Y.isDataSource)(e)&&e.id()!==this._lastFinishedToolId&&this._showEditDialogForSource(e,t)}stretchFactor(){return this._state?this._state.stretchFactor():0}setStretchFactor(e){this.hasState()&&this.state().setStretchFactor(e)}setCursorForTool(e,t,i){if(t&&t.mod()&&e&&e!==this._chartModel().crossHairSource())return void this._setCursorClassName("pointer");if(void 0!==i){switch(i){case dt.PaneCursorType.VerticalResize:this._setCursorClassName("ns-resize");break;case dt.PaneCursorType.HorizontalResize:this._setCursorClassName("ew-resize");break;case dt.PaneCursorType.DiagonalNeSwResize:this._setCursorClassName("nesw-resize");break;case dt.PaneCursorType.DiagonalNwSeResize:this._setCursorClassName("nwse-resize");break;case dt.PaneCursorType.Default:this._setCursorClassName("default");break;case dt.PaneCursorType.Pointer:this._setCursorClassName("pointer");break;case dt.PaneCursorType.Grabbing:this._setCursorClassName("grabbing")}return}const s=K.tool.value();if((0,K.toolIsCursor)(s)){if(null!==this._paneWidgetsSharedState.draggingSource()||this._isScrolling||this._chartUndoModel()&&this._chartUndoModel().model().sourcesBeingMoved().length)return void this._setCursorClassName("grabbing");if(e&&this._options.sourceSelectionEnabled)return void this._setCursorClassName("pointer")}if("eraser"===s)return void this._setCursorClassName("eraser");if("zoom"===s)return void this._setCursorClassName("zoom-in");const r=K.cursorTool.value() +;"dot"!==r?"arrow"!==r?this._setCursorClassName(""):this._setCursorClassName("default"):this._setCursorClassName("dot")}showContextMenuForSelection(e,t){const i=this._chartUndoModel().selection();if(i.isEmpty())return;const s=i.dataSources().filter((e=>e.hasContextMenu()));this.showContextMenuForSources(s,e,void 0,t)}async showContextMenuForSources(e,t,i,s){var r;if(!e.length)return Promise.resolve(null);const n=e[0],o=(0,y.merge)((0,y.clone)(this._options.contextMenu),i||{}),a=new ke.ActionsProvider(this._chart,o);if(n===this._chartUndoModel().crossHairSource())return n.handleContextMenuEvent(t),Promise.resolve(null);{const i=await a.contextMenuActionsForSources(e,t,null==s?void 0:s.origin);if(0===i.length)return Promise.resolve(null);{let e;return e=n instanceof ft.Series?{menuName:"ObjectTreeContextMenu",detail:{type:"series",id:n.instanceId()}}:(0,E.isLineTool)(n)?{menuName:"ObjectTreeContextMenu",detail:{type:"shape",id:null!==(r=null==n?void 0:n.id())&&void 0!==r?r:null}}:{menuName:"ObjectTreeContextMenu",detail:{type:"study",id:(null==n?void 0:n.id())||null}},he.ContextMenuManager.createMenu(i,void 0,e).then((e=>(e.show(t),e)))}}}leftPriceAxisesContainer(){return this._lhsPriceAxisesContainer}rightPriceAxisesContainer(){return this._rhsPriceAxisesContainer}setPriceAxisSizes(e,t,i){this._priceAxisesContainer(e).setSizes(t,i)}state(){return(0,r.ensureNotNull)(this._state)}hasState(){return null!==this._state}setState(e){this._state!==e&&(this.hasState()&&this._unsubscribeFromState(),this._state=e,this.hasState()&&(this._subscribeToState(),this.updatePriceAxisWidgetsStates()))}getScreenshotData(e){var t,i,s,r;const n=[],o=[];let a,l=[];const c=this.state().sourcesByGroup().priceSources().slice().reverse(),h=this._chart.properties().childs().paneProperties.childs().legendProperties.childs();for(const d of c){const c=d.statusView();if((0,B.isStudy)(d)&&(h.showLegend.value()||(null==e?void 0:e.showCollapsedStudies))){const s=h.showStudyTitles.value(),r=s;if(d.properties().childs().visible.value()&&c&&r){n.push(s?d.statusProvider(null==e?void 0:e.status).text():"");const r=Ae.enabled("use_last_visible_bar_value_in_legend")&&null!==(i=null===(t=this._chartModel().timeScale().visibleBarsStrictRange())||void 0===t?void 0:t.lastBar())&&void 0!==i?i:null,a=d.valuesProvider().getValues(r);o.push(a)}}else if(d===this._chartModel().mainSeries()&&c&&h.showSeriesTitle.value()){a=d.statusProvider((null==e?void 0:e.status)||{}).text();const t=Ae.enabled("use_last_visible_bar_value_in_legend")&&null!==(r=null===(s=this._chartModel().timeScale().visibleBarsStrictRange())||void 0===s?void 0:s.lastBar())&&void 0!==r?r:null;l=d.valuesProvider().getValues(t)}}return{type:"pane",leftAxis:this._lhsPriceAxisesContainer.getScreenshotData(),rightAxis:this._rhsPriceAxisesContainer.getScreenshotData(),content:this._canvasBinding.canvasElement.toDataURL(),canvas:this._canvasBinding.canvasElement,contentWidth:this._size.width,contentHeight:this._size.height,studies:n,studiesValues:o,containsMainSeries:this.containsMainSeries(), +mainSeriesText:a,mainSeriesValues:l}}updatePriceAxisWidgetsStates(){if(!this.hasState())return;const e=this._chartModel(),t=e.paneForSource(e.mainSeries());if(!t)return;const i=e.priceScaleSlotsCount(),s=this.state(),r=s.visibleLeftPriceScales(),n=s.visibleRightPriceScales();this._lhsPriceAxisesContainer.setScales(r,i.left,t.leftPriceScales().length,i.left+i.right),this._rhsPriceAxisesContainer.setScales(n,i.right,t.rightPriceScales().length,i.left+i.right)}updatePriceAxisWidgets(){this._lhsPriceAxisesContainer.update(),this._rhsPriceAxisesContainer.update()}update(){this.hasState()&&(this.updatePriceAxisWidgets(),null!==this._legendWidget&&this._legendWidget.update(),this.updateControls())}updateStatusWidget(e){this.hasState()&&null!==this._legendWidget&&(e.legendWidgetLayoutInvalidated()?this._legendWidget.updateLayout():this._legendWidget.update())}updateControls(){this.hasState()&&null!==this._paneControls&&this._paneControls.update()}updateThemedColors(e){this._themedTopColor=e.topColor,this._updateByThemedColors()}statusWidget(){return this._legendWidget}getElement(){return this._rowElement}canvasElement(){return this._canvasBinding.canvasElement}hasCanvas(e){return this._canvasBinding.canvasElement===e||this._topCanvasBinding.canvasElement===e}pinchStartEvent(){return null===this._paneWidgetsSharedState.scrollingPane()&&null===this._paneWidgetsSharedState.pinchingPane()&&(this._onTouchEvent(),!!this._options.handleScale.pinch&&(this._chartModel().stopTimeScaleAnimation(),this._prevPinchScale=1,this._pinching=!0,this._wasPinched=!0,this._paneWidgetsSharedState.setPinchingPane(this),!0))}pinchEvent(e,t,i,s){if(null!==this._paneWidgetsSharedState.scrollingPane()||this._paneWidgetsSharedState.pinchingPane()!==this)return;if(this._onTouchEvent(),!this._options.handleScale.pinch)return;const r=10*(s-this._prevPinchScale);this._prevPinchScale=s,this._chartModel().zoomTime(e.x,r,!0),this._prevPinchScale=s}pinchEndEvent(){null===this._paneWidgetsSharedState.scrollingPane()&&this._paneWidgetsSharedState.pinchingPane()===this&&(this._onTouchEvent(),this._pinching=!1,this._paneWidgetsSharedState.setPinchingPane(null))}mouseClickEvent(e){this._onMouseEvent(),this._mouseClickOrTapEvent(e)}tapEvent(e){this._preventTouchEventsExceptPinch()||(this._onTouchEvent(),this._mouseClickOrTapEvent(e))}mouseDownEvent(e){this._onMouseEvent(),this.hasState()&&this._mouseDownOrTouchStartEvent(e,this._dataSourceAtPoint(e.localX,e.localY))}touchStartEvent(e){if(this._paneWidgetsSharedState.startTouch(this),this._preventTouchEventsExceptPinch())return;const t=!this._trackCrosshairOnlyAfterLongTap&&null!==Nt&&Nt.stateId===this.state().id()&&Math.abs(Nt.x-e.localX)+Math.abs(Nt.y-e.localY)<5;this._onTouchEvent(),this._chart.setActivePaneWidget(this);const i=this._dataSourceAtPoint(e.localX,e.localY);if(t){const t=this._chartModel().crossHairSource() +;null!==i&&i.source===t||t.selectPointMode().value()!==K.SelectPointMode.None?this.startTrackingMode(new F.Point(e.localX,e.localY),new F.Point(e.localX,e.localY)):!this._chart.readOnly()&&null!==i&&(0,E.isLineTool)(i.source)&&i.source.userEditEnabled()&&this._chartUndoModel().selectionMacro((e=>{e.clearSelection(),e.addSourceToSelection(i.source,i.hittest.data())}))}this._mouseDownOrTouchStartEvent(e,i),this._mouseOrTouchMoveEvent(e)}mouseUpEvent(e){this._onMouseEvent(),this._mouseUpOrTouchEndEvent(e)}touchEndEvent(e){this._paneWidgetsSharedState.endTouch(this),this._preventTouchEventsExceptPinch()||(this._onTouchEvent(),this._mouseOrTouchLeaveEvent(e),this._mouseUpOrTouchEndEvent(e))}mouseMoveEvent(e){this._onMouseEvent(),this._mouseOrTouchMoveEvent(e)}pressedMouseMoveEvent(e){this._onMouseEvent(),this._pressedMouseOrTouchMoveEvent(e)}touchMoveEvent(e){this._preventTouchEventsExceptPinch()||(this._onTouchEvent(),this._pressedMouseOrTouchMoveEvent(e))}mouseLeaveEvent(e){this._onMouseEvent(),this._updateHoveredSource(null,new $.EnvironmentState(e)),this._mouseOrTouchLeaveEvent(e)}mouseDoubleClickEvent(e){this._onMouseEvent(),this._mouseDoubleClickOrDoubleTapEvent(e)}wheelClickEvent(e){if(this._chart.readOnly())return;const t=this._dataSourceAtPoint(e.localX,e.localY);if(null===t||t.isCustom)return;if((t.hittest.target()||0)<=G.HitTarget.MovePointBackground)return;const i=new $.EnvironmentState(e),s=t.hittest.eraseMarker();if(i.mod()&&void 0!==s&&t.source.processErase)return void t.source.processErase(this._chartUndoModel(),s);const n=this._chartUndoModel();n.selection().isSelected(t.source)||n.selectionMacro((e=>{e.clearSelection();const i=(0,r.ensureNotNull)(t.source);e.addSourceToSelection(i,Dt(t,i))})),this._chart.removeSelectedSources()}doubleTapEvent(e){this._preventTouchEventsExceptPinch()||(this._onTouchEvent(),this._mouseDoubleClickOrDoubleTapEvent(e))}longTapEvent(e){if(null===this._state||this._preventTouchEventsExceptPinch())return;if(this._onTouchEvent(),this._longTap=!0,null!==this._startTrackPoint||!this._trackingModeShouldBeActive())return;const t=this._chartModel().selection();if(!t.isEmpty()){const i=this._dataSourceAtPoint(e.localX,e.localY);if(null!==i&&t.isSelected(i.source))return}this.startTrackingMode(new F.Point(e.localX,e.localY),new F.Point(e.localX,e.localY),new $.EnvironmentState(e))}mouseEnterEvent(e){if(this._onMouseEvent(),!this.hasState())return;this._chart.setActivePaneWidget(this);const t=this._dataSourceAtPoint(e.localX,e.localY);this._updateHoveredSource(t,new $.EnvironmentState(e)),this._setCursorPosition(e.localX,e.localY,new $.EnvironmentState(e))}contextMenuEvent(e){this._onMouseEvent(),this._contextMenuEvent(e)}touchContextMenuEvent(e){this._preventTouchEventsExceptPinch()||(this._onTouchEvent(),this._contextMenuEvent(e))}mouseDownOutsideEvent(e){this._processOutsideClick(null,e)}touchStartOutsideEvent(e){this._processOutsideClick(null,e)}cancelZoom(){this._chartModel().crossHairSource().clearSelection(),this._firstZoomPoint=null, +this._preventCrossHairMove()&&this._clearCursorPosition()}startTrackingMode(e,t,i){this._startChangeLineToolParams=null,this._startMoveSourceParams=null,this._currentChangingLineToolHitTest=null,this._currentMovingHitTest=null,this._chartUndoModel().selectionMacro((e=>e.clearSelection())),this._startTrackPoint=e,this._exitTrackingModeOnNextTry=!1,this._setCursorPosition(t.x,t.y,i),this._initCrossHairPosition=this._chartModel().crossHairSource().currentPoint()}setDragToAnotherPaneCursor(){this._setCursorClassName("grabbing")}cloneLineTools(e,t){return this._chartUndoModel().cloneLineTools(e,t)}exitTrackingMode(){null!==this._state&&null!==this._startTrackPoint&&(this._exitTrackingModeOnNextTry=!0,this._tryExitTrackingMode())}trackingModeEnabled(){return null!==this._state&&null!==this._startTrackPoint}addCustomWidgetToLegend(e,t){this._options.legendWidgetEnabled&&(this._customLegendWidgetsFactoryMap.set(e,t),null!==this._legendWidget&&this._legendWidget.addCustomWidgetToLegend(e,t))}containsMainSeries(){return!!this.hasState()&&this.state().containsMainSeries()}paint(e){if(!this._chartUndoModel()||!this.hasState()||0===this._size.width||0===this._size.height)return;this._canvasBinding.applySuggestedBitmapSize(),this._topCanvasBinding.applySuggestedBitmapSize(),this._state&&(e.priceScaleSideMaxLevel("left")>N.InvalidationLevel.Cursor||e.priceScaleSideMaxLevel("right")>N.InvalidationLevel.Cursor)&&(this._recalculatePriceScales((0,vt.viewportChangeEvent)()),null!==Nt&&Nt.stateId===this.state().id()&&this._setCursorPosition(Nt.x,Nt.y,Nt.envState));const t=e.fullInvalidation();if(t>N.InvalidationLevel.Cursor&&null!==Nt&&Nt.stateId===this.state().id()){const e=this._dataSourceAtPoint(Nt.x,Nt.y);this._updateHoveredSource(e,(0,mt.globalEnvironmentState)())}if(this._lhsPriceAxisesContainer.paint(e.getterForPriceScaleInvalidationLevelBySide("left")),this._rhsPriceAxisesContainer.paint(e.getterForPriceScaleInvalidationLevelBySide("right")),t===N.InvalidationLevel.None)return;const i=this._state&&(this._state.maximized().value()||!this._state.collapsed().value());if(t>N.InvalidationLevel.Cursor){const e=(0,r.ensureNotNull)(this._canvasBinding.canvasElement.getContext("2d"));e.setTransform(1,0,0,1,0,0),this._makeSureIsUpdated();const t=this._canvasRenderParams();this._drawBackground(e,t),i&&this._drawSources(e,t)}if(null!==this._state){const e=(0,r.ensureNotNull)(this._topCanvasBinding.canvasElement.getContext("2d"));e.setTransform(1,0,0,1,0,0);const t=this._topCanvasRenderParams();e.clearRect(0,0,Math.ceil(this._size.width*t.pixelRatio),Math.ceil(this._size.height*t.pixelRatio)),i&&this._drawSeriesTopViews(e,t),this._drawCrossHair(e,t),i&&this._drawActiveLineTools(e,t)}}cancelCreatingLineTool(){const e=this._chartUndoModel(),t=this._chartUndoModel().lineBeingCreated();if(t)if(t.pointsCount()<=0&&!(0,V.isLineDrawnWithPressedButton)(t.toolname)){const i=t.points();if(i.length>2){const s=i[i.length-2];e.continueCreatingLine(s),this._finishTool(t)}else e.cancelCreatingLine()}else e.cancelCreatingLine() +;null!==this._firstZoomPoint&&this.cancelZoom(),this.setCursorForTool()}drawRightThere(e){if((0,V.isLineToolName)(e)&&this.hasState()){const t=this._chartUndoModel(),i=t.crossHairSource(),s=t.model().magnet().align(i.price,i.index,this.state());t.createLineTool({pane:this.state(),point:{index:i.index,price:s},linetool:e})}}cancelMeasuring(){this._chartUndoModel().crossHairSource().clearMeasure(),(0,K.resetToCursor)(),this.setCursorForTool()}async setErrorMessage(e){var t,i,s;e&&!this._errorRenderer&&(this._errorRenderer=this._createErrorBlock()),null===(t=await this._errorRenderer)||void 0===t||t.update({message:null==e?void 0:e.message,icon:(null===(i=this._state)||void 0===i?void 0:i.containsMainSeries())||(null===(s=this._state)||void 0===s?void 0:s.maximized().value())?null==e?void 0:e.icon:void 0,backgroundColor:`linear-gradient(${this._chartModel().backgroundTopColor().value()}, ${this._chartModel().backgroundColor().value()})`,textColor:this._chartModel().dark().value()?Pt:wt,solutionId:null==e?void 0:e.solutionId})}collapsedHeight(){var e,t;return Math.max(Math.ceil(null!==(t=null===(e=this._paneControls)||void 0===e?void 0:e.bottomWithMargin())&&void 0!==t?t:0),33)}_topCanvasRenderParams(){return{pixelRatio:(0,J.getBindingPixelRatio)(this._topCanvasBinding),physicalWidth:this._topCanvasBinding.canvasElement.width,physicalHeight:this._topCanvasBinding.canvasElement.height,cssWidth:this._chartModel().timeScale().width(),cssHeight:this.height()}}_canvasRenderParams(){return{pixelRatio:(0,J.getBindingPixelRatio)(this._canvasBinding),physicalWidth:this._canvasBinding.canvasElement.width,physicalHeight:this._canvasBinding.canvasElement.height,cssWidth:this._chartModel().timeScale().width(),cssHeight:this.height()}}_tryExitTrackingMode(e){this._exitTrackingModeOnNextTry&&(this._startTrackPoint=null,e||this._clearCursorPosition())}_tryStartMeasure(e,t,i,s,r){return!(!(0,K.toolIsMeasure)(K.tool.value())||t.startMeasurePoint())&&(e.isTouch||this._preventCrossHairMove()||this._setCursorPosition(e.localX,e.localY,i),s=this._chartModel().magnet().align(s,r,this.state()),t.startMeasuring({price:s,index:r},this.state()),!0)}_tryFinishMeasure(e,t){if(t.startMeasurePoint()&&!t.endMeasurePoint()){let i=t.price;const s=t.index;return i=this._chartModel().magnet().align(i,s,this.state()),t.finishMeasure({price:i,index:s}),e.isTouch?(0,K.resetToCursor)():this._needResetMeasureLater=!0,this._preventCrossHairMove()&&this._clearCursorPosition(),!0}return!1}_tryStartZoom(e,t,i,s){const r=this._chart.model().model().zoomEnabled();if("zoom"===K.tool.value()&&r){const r=this._chartUndoModel(),n=r.timeScale().indexToCoordinate(i)-.5*r.timeScale().barSpacing();return this._firstZoomPoint={price:t,index:i,x:n,y:e.localY},this._preventCrossHairMove()||this._setCursorPosition(e.localX,e.localY,s),this._chartModel().crossHairSource().startSelection(this.state()),!0}return!1}_finishZoom(e){const t=this.state(),i=t.defaultPriceScale(),s=(0,r.ensureNotNull)(t.mainDataSource()).firstValue(),n=i.coordinateToPrice(e.localY,(0, +r.ensureNotNull)(s)),o=this._chartUndoModel(),a=Math.round(o.timeScale().coordinateToIndex(e.localX)),l=(0,r.ensureNotNull)(this._firstZoomPoint);a!==l.index&&o.zoomToViewport(l.index,a,l.price,n,t),this._chartModel().crossHairSource().clearSelection(),this._firstZoomPoint=null,(0,K.resetToCursor)(),this._preventCrossHairMove()&&this._clearCursorPosition()}_tryFinishZoom(e){return null!==this._firstZoomPoint&&(this._finishZoom(e),!0)}_tryHandleEraserMouseDown(e,t){if(!("eraser"!==K.tool.value()||e.isCustom||(i=e.source,i&&i.customization&&i.customization.disableErasing))){const i=this._chartUndoModel();if((0,E.isLineTool)(e.source)||(0,B.isStudy)(e.source)){const s=e.hittest.eraseMarker();return t.mod()&&void 0!==s&&e.source.processErase?e.source.processErase(i,s):i.removeSource(e.source,!1),!0}}var i;return!1}_tryStartChangingLineTool(e,t,i,s){var n,o,a;if(e.isTouch&&null!==this._startTrackPoint)return!1;const l=t.hittest;if((!e.isTouch||!this._preventSourceChange)&&l&&(0,E.isLineTool)(t.source)&&l.target()===G.HitTarget.ChangePoint){const c=this._chartUndoModel(),h=(0,r.ensure)(null===(n=this.state().mainDataSource())||void 0===n?void 0:n.firstValue()),d=(0,r.ensureNotNull)(t.source.priceScale()).coordinateToPrice(e.localY,h);c.selectionMacro((e=>{e.clearSelection(),e.addSourceToSelection(t.source,l.data())}));let u=d;t.source.priceScale()===c.mainSeries().priceScale()&&(u=c.model().magnet().align(d,s,this.state()));const p=null===(o=l.data())||void 0===o?void 0:o.nonDiscreteIndex;p&&(s=c.timeScale().coordinateToFloatIndex(e.localX));const _=null===(a=l.data())||void 0===a?void 0:a.pointIndex;return this._startChangeLineToolParams={source:t.source,startPoint:{index:s,price:u,nonDiscreteIndex:p},screenPoint:{x:e.localX,y:e.localY},pointIndex:_,envState:i},!0}return this._startChangeLineToolParams=null,!1}_tryStartCloning(e,t,i,s){if(i.mod()){const t=this._chartUndoModel().selection().dataSources().filter((e=>e.cloneable()));if(s&&s.cloneable()&&t.push(s),t.length>0)return this._clonningAtMoveLineTools=t.map((e=>e.id())),this._startCloningPoint=new F.Point(e.localX,e.localY),!0}return!1}_tryFinishClonning(e,t,i){const s=this._chartUndoModel(),n=this._chartModel();if(t.mod()&&this._clonningAtMoveLineTools){const o=new F.Point(e.localX,e.localY),a=(0,r.ensureNotNull)(this._startCloningPoint).subtract(o).length(),l=[];for(const e of this._clonningAtMoveLineTools){const t=n.dataSourceForId(e);null!==t&&l.push(t)}if(0===l.length)return!1;if(a>8){const n=this.cloneLineTools(l,!0).map((e=>(0,r.ensureNotNull)(s.model().dataSourceForId(e))));s.selectionMacro((e=>{e.clearSelection();let t=null;n.forEach((s=>{null===t&&(t=Dt(i,s)),e.addSourceToSelection(s,t)}))}));const o=new F.Point(e.localX,e.localY),a=(0,r.ensureNotNull)(n[0].priceScale()),c=(0,r.ensureNotNull)(this.state().mainDataSource()).firstValue(),h={index:s.timeScale().coordinateToIndex(e.localX),price:a.coordinateToPrice(e.localY,(0,r.ensureNotNull)(c))};s.startMovingSources(n,{logical:h,screen:o},null,t),this._clonningAtMoveLineTools=null, +this._startCloningPoint=null}return!0}return!1}_mouseDownEventForLineTool(e,t,i,s){var n,o;const a=K.tool.value();if(!this.hasState()||(0,V.isLineToolDrawWithoutPoints)(a))return;const l=this._chartUndoModel();let c=!1,h=null;(0,K.hideAllDrawings)().value()&&(0,H.toggleHideMode)(),(0,K.lockDrawings)().setValue(!1),e.isTouch&&!e.stylus&&((0,V.isLineToolName)(a)&&!(0,V.isLineDrawnWithPressedButton)(a)||l.lineBeingCreated())&&this._initToolCreationModeParams(e);const d=l.lineBeingCreated();if(d&&!(0,V.isLineDrawnWithPressedButton)(d.toolname)){const a=(0,r.ensure)(null===(n=d.ownerSource())||void 0===n?void 0:n.firstValue());if(e.isTouch&&!e.stylus){if(!this._startTouchPoint){this._startTouchPoint=new F.Point(e.pageX,e.pageY);const t=d.points(),i=t[t.length-1],s=l.timeScale().indexToCoordinate(i.index),n=(0,r.ensureNotNull)(d.priceScale()).priceToCoordinate(i.price,a);return void(this._initCrossHairPosition=new F.Point(s,n))}}else if(!e.isTouch){h=d;const n=l.model().paneForSource(d);if(n!==this._state&&null!==n){const i=this._externalPaneXCoord(n,e.localX),s=this._externalPaneYCoord(n,e.localY);c=l.continueCreatingLine({index:Math.round(l.timeScale().coordinateToIndex(i)),price:(0,r.ensure)(null===(o=d.priceScale())||void 0===o?void 0:o.coordinateToPrice(s,a))},t)}else{const e=l.model().magnet().align(s,i,this.state());c=l.continueCreatingLine({index:i,price:e},t)}}}else if(!e.isTouch||e.stylus||(0,V.isLineDrawnWithPressedButton)(a)){const e={index:i,price:l.model().magnet().align(s,i,this.state())};h=l.createLineTool({pane:this.state(),point:e,linetool:a}),l.lineBeingCreated()||(c=!0)}const u=this._dataSourceAtPoint(e.localX,e.localY);h&&l.selectionMacro((e=>{e.addSourceToSelection((0,r.ensureNotNull)(h),null==u?void 0:u.hittest.data())})),c&&h&&(this._finishTool(h,u),e.preventDefault())}_handleSelectionMouseDownAndGetJustDeselectedSource(e,t,i){const s=this._chartUndoModel();let r=null;return(null===t||t.source.isSelectionEnabled())&&s.selectionMacro((s=>{!this._preventSourceChange&&null!==t&&(e.isTouch?t.hittest.target()>=G.HitTarget.MovePointBackground:t.hittest.target()>G.HitTarget.MovePointBackground)?(i.mod()||s.selection().isSelected(t.source)||s.clearSelection(),i.mod()&&s.selection().isSelected(t.source)?(r=t.source,s.removeSourceFromSelection(t.source)):s.addSourceToSelection(t.source,t.hittest.data()),s.selection().allSources().length>1&&(0,Se.trackEvent)("GUI","Multiselect","Click Select")):i.mod()||s.clearSelection()})),r}_processMouseMoveWhileZoom(e,t){this._preventCrossHairMove()||this._setCursorPosition(e.localX,e.localY,t)}_updateCommonTooltip(e,t){let i=null;if(null!==e&&null!==e.hittest){const t=e.hittest.data();t&&(i=t.tooltip||null)}if(null===this._prevTooltipData&&null===i)return;if(null===i||""===i.text)return this._prevTooltipData=null,void(0,ut.hide)(t);if(this._prevTooltipData&&(0,O.default)(i,this._prevTooltipData))return;this._prevTooltipData=i;const s=(0,y.clone)(i);if(void 0!==s.rect){const e=this._paneCell.getBoundingClientRect();s.rect.x+=e.left,s.rect.y+=e.top}(0,ut.show)(s)} +_setCursorPositionOnExternalPane(e,t,i,s){t=this._externalPaneXCoord(e,t),i=this._externalPaneYCoord(e,i);this._chart.paneByState(e)._setCursorPosition(t,i,s)}_setCursorPosition(e,t,i){this._updateLastCrosshairPosition(e,t,i),this._chartModel().setAndSaveCurrentPosition(this._correctXCoord(e),this._correctYCoord(t),this.state(),i)}_updateLastCrosshairPosition(e,t,i){const s=this.state().id();Nt={x:e,y:t,envState:i,stateId:s}}_setCursorClassName(e){let t="";e&&(t="pane--cursor-"+e),this._currentCursorClassName!==t&&(this._currentCursorClassName&&this._paneCell.classList.remove(this._currentCursorClassName),t&&this._paneCell.classList.add(t),this._currentCursorClassName=t,this._paneCell.style.cursor)}_processMouseUpOrTouchEndHandler(e){const t=this._dataSourceAtPoint(e.localX,e.localY);null!==t&&t.hittest.tryCallMouseUpOrTouchEndHandler(e)}_crossHairShouldBeVisible(){const e=this._chartModel().crossHairSource();return(0,V.isLineToolName)(K.tool.value())||(0,K.toolIsMeasure)(K.tool.value())||e.startMeasurePoint()&&!e.endMeasurePoint()||null!==this._firstZoomPoint||null!==this._chartModel().lineBeingEdited()||null!==this._chartModel().lineBeingCreated()}_clearCursorPosition(){Nt=null,this._chartModel().clearCurrentPosition()}_dataSourceAtPoint(e,t){if(!this.hasState())return null;const i={result:null},s=this._chartUndoModel();if((0,V.isLineToolName)(K.tool.value())||null!==s.lineBeingCreated())return i.result;if(this._currentChangingLineToolHitTest)return this._currentChangingLineToolHitTest;if(this._currentMovingHitTest)return this._currentMovingHitTest;const r=this.state(),n=r.height(),o=r.width();this._makeSureIsUpdated();const a=Et.bind(null,i),l=this._canvasRenderParams(),c=new F.Point(e,t);if(!this.state().maximized().value()&&this.state().collapsed().value()||(0,U.lastMouseOrTouchEventInfo)().isTouch&&(K.activePointSelectionMode.value()!==K.SelectPointMode.None||null!==this._startTrackPoint))return this._hitTestSources(l,[s.crossHairSource()],c,a,!1),i.result;const h=r.sourcesByGroup(),d=s.selection();this._hitTestSources(l,d.dataSources(),c,a,!1),this._hitTestSources(l,d.customSources(),c,a,!0);const u=new Set(d.allSources().map((e=>e.id())));this._hitTestSources(l,[s.crossHairSource()],c,a,!1,u),this._hitTestSources(l,r.customSources(q.CustomSourceLayer.Topmost),c,a,!0,u),this._hitTestSources(l,h.tradingSources(),c,a,!1,u),this._hitTestSources(l,r.customSources(q.CustomSourceLayer.Foreground),c,a,!0,u);const p=[...this._chartModel().multiPaneSources(r),...h.hitTestSources()];if(this._hitTestSources(l,p,c,a,!1,u),this.containsMainSeries()){const e=s.activeStrategySource().value();if(null!==e){const t=e.strategyOrdersPaneView();if(null!==t){const s=t.renderer(n,o);if(null!==s){const t=s.hitTest(c,l);t&&Et(i,t,e,s,!1)}}}}return null===i.result&&this._hitTestSources(l,r.customSources(q.CustomSourceLayer.Background),c,a,!0,u),i.result}_hitTestSources(e,t,i,s,n,o){const a=(0,r.ensureNotNull)(this._state),l=a.height(),c=a.width();for(let r=t.length-1;r>=0;--r){const h=t[r];if(void 0!==o&&o.has(h.id()))continue +;const d=h.paneViews(a);if(null!==d&&0!==d.length)for(let t=d.length-1;t>=0;--t){const r=d[t].renderer(l,c);if(r&&r.hitTest){const t=r.hitTest(i,e);null!==t&&s(t,h,r,n)}}}}_tryStartMovingLineTool(e,t,i,s){var n;if(null===t.source||!t.source.movable()||null!==this._startTrackPoint)return!1;if(!this._preventSourceChange){const o=this._chartUndoModel(),a=(0,r.ensureNotNull)((0,r.ensureNotNull)(this._state).mainDataSource()).firstValue(),l=(0,r.ensureNotNull)(t.source.priceScale()).coordinateToPrice(e.localY,(0,r.ensureNotNull)(a));let c=(t.source.isSelectionEnabled()?o.selection().allSources():[t.source]).filter(gt);const h=c.filter(E.isLineTool);c=h.length>0?h:c.includes(t.source)?[t.source]:[c[0]];const d=new F.Point(e.localX,e.localY),u={index:s,price:l},p=null===(n=t.hittest.data())||void 0===n?void 0:n.activeItem;return this._startMoveSourceParams={source:c,startPoint:{logical:u,screen:d},activeItem:void 0===p?null:p,envState:i},!0}return this._startMoveSourceParams=null,!1}_chartModel(){return this._chart.model().model()}_chartUndoModel(){return this._chart.model()}_externalPaneXCoord(e,t){t+=this._div.getBoundingClientRect().left+document.body.scrollLeft;const i=(0,r.ensureNotNull)(this._chart.paneByState(e)),s=i._div.getBoundingClientRect().left+document.body.scrollLeft;return i._correctXCoord(t-s)}_externalPaneYCoord(e,t){t+=this._div.getBoundingClientRect().top+document.body.scrollTop;const i=(0,r.ensureNotNull)(this._chart.paneByState(e)),s=i._div.getBoundingClientRect().top+document.body.scrollTop;return i._correctYCoord(t-s)}_correctXCoord(e){return Math.max(0,Math.min(e,this._size.width-1))}_correctYCoord(e){return Math.max(0,Math.min(e,this._size.height-1))}_processScroll(e){if(!this._chart.model().model().scrollEnabled())return;const t=performance.now();this._startScrollingPos||this._preventScroll()||(this._startScrollingPos={x:e.clientX,y:e.clientY,timestamp:t,localX:e.localX,localY:e.localY});const i=this._chartUndoModel(),s=this._chartModel().timeScale();let r=this.state().defaultPriceScale();if(this._startScrollingPos&&!this._isScrolling&&(this._startScrollingPos.x!==e.clientX||this._startScrollingPos.y!==e.clientY)){if(i.beginUndoMacro(Ct,!0),null===this._scrollXAnimation&&this._options.useKineticScroll){const e=s.barSpacing();this._scrollXAnimation=new nt(.2/e,7/e,.997,15/e),this._scrollXAnimation.addPosition(s.rightOffset(),this._startScrollingPos.timestamp)}return i.selection().isEmpty()||(r=i.selection().allSources()[0].priceScale()),null===r||r.isEmpty()||(this._scrollPriceScale=r,i.startScrollPrice(this.state(),r,e.localY)),i.startScrollTime(e.localX),this._isScrolling=!0,this.setCursorForTool(),void this._paneWidgetsSharedState.setScrollingPane(this)}this._isScrolling&&(null!==this._scrollPriceScale&&i.scrollPriceTo(this.state(),this._scrollPriceScale,e.localY),i.scrollTimeTo(e.localX),null!==this._scrollXAnimation&&this._scrollXAnimation.addPosition(s.rightOffset(),t))}_finishScroll(){const e=this._chartUndoModel();e.endScrollTime(), +null!==this._scrollPriceScale&&e.endScrollPrice(this.state(),this._scrollPriceScale),e.endUndoMacro(),this._isScrolling=!1,this._startScrollingPos=null,this._scrollPriceScale=null,this.setCursorForTool(),this._paneWidgetsSharedState.setScrollingPane(null)}_endScroll(e){if(!this._isScrolling)return!1;this._finishScroll();const t=this._scrollUndoCommandInStack(),i=performance.now(),s=this._chartUndoModel().timeScale();return null!==this._scrollXAnimation&&(this._scrollXAnimation.start(s.rightOffset(),i),this._scrollXAnimation.finished(i)||(this._chartModel().setTimeScaleAnimation(this._scrollXAnimation),this._scrollXAnimation=null)),t}_preventScroll(){return this._trackCrosshairOnlyAfterLongTap&&this._longTap||this._contextMenuOpenedOnLastTap||(0,V.isLineToolName)(K.tool.value())||Boolean(this._chartUndoModel().lineBeingCreated())||null!==this._startTrackPoint}_isSelectPointModeEnabled(){return this._chartUndoModel().crossHairSource().selectPointMode().value()!==K.SelectPointMode.None}_preventCrossHairMove(){return!!this._trackCrosshairOnlyAfterLongTap&&(null===this._chart.trackingModePaneWidget()&&(!!this._contextMenuOpenedOnLastTap||!this._crossHairShouldBeVisible()&&null===this._startTrackPoint))}_finishTool(e,t=null){const i=this._chartUndoModel(),s=e.toolname;if(s===K.tool.value()&&(0,K.resetToCursor)(),this._preventCrossHairMove()&&this._clearCursorPosition(),i.selectionMacro((i=>{i.addSourceToSelection(e,Dt(t,e))})),(0,V.isTextToolName)(s)){const t=i.createUndoCheckpoint();this._chart.showChartPropertiesForSource(e,ht.TabNames.text,void 0,t).then((e=>{0}))}this._lastFinishedToolId=e.id(),(0,u.emit)("drawing_event",e.id(),"create"),(0,ct.trackDrawingCreated)(e)}_alignSourcesThatBeingMoved(e,t,i,s){const r=this._chartUndoModel(),n=r.timeScale().coordinateToIndex(t);r.model().sourcesBeingMoved().forEach((e=>{var o;let a=n,l=e.convertYCoordinateToPriceForMoving(i,this.state().mainDataSource());if(null!==l){if((0,B.isStudy)(e)){const e=r.mainSeries(),t=e.bars().firstIndex(),i=e.bars().lastIndex();null!==t&&null!==i&&(a=Math.min(Math.max(n,t),i)),l=this._chartModel().magnet().align(l,n,this.state())}null!==this._currentMovingHitTest&&void 0!==(null===(o=this._currentMovingHitTest.hittest.data())||void 0===o?void 0:o.cursorType)||this.setCursorForTool(),r.moveSources({screen:new F.Point(t,i),logical:{index:a,price:l}},s)}}))}_resetMeasureIfRequired(){this._needResetMeasureLater&&((0,K.resetToCursor)(),this._needResetMeasureLater=!1)}_makeSureIsUpdated(){var e;const t=this.state(),i=[...t.dataSources(),...t.customSources()],s=t.height(),r=t.width();for(const n of i){const i=n.paneViews(t);if(null!==i)for(const t of i)null===(e=t.makeSureIsUpdated)||void 0===e||e.call(t,s,r)}}_drawBackground(e,t){const i=Math.ceil(t.pixelRatio*this._size.width),s=Math.ceil(t.pixelRatio*this._size.height),r=this._chartModel(),n=r.backgroundTopColor().value(),o=r.backgroundColor().value();n===o?(0,J.clearRect)(e,0,0,i+1,s+1,o):(0,Q.clearRectWithGradient)(e,0,0,i+1,s+1,n,o)}_drawWatermark(e,t){const i=this._chartModel().watermarkSource() +;if(null===i)return;const s=this.state();if(!s.containsMainSeries())return;const r=i.paneViews(),n=s.height(),o=s.width();for(const i of r){e.save();const s=i.renderer(n,o);s&&s.draw(e,t),e.restore()}}_drawCrossHair(e,t){const i=this._chartUndoModel().crossHairSource();i.invalidateLockPosition(),i.visible||null===K.crosshairLock.value()||i.updateAllViews((0,vt.sourceChangeEvent)(i.id())),this._drawSourceImpl(e,t,Mt,It,i)}_drawActiveLineTools(e,t){const i=this._chartModel(),s=[i.lineBeingCreated(),i.lineBeingEdited(),...i.sourcesBeingMoved(),i.customSourceBeingMoved()].filter((e=>!!e));for(const r of s){(i.paneForSource(r)===this.state()||(0,Y.isDataSource)(r)&&r.isMultiPaneEnabled())&&this._drawSourceImpl(e,t,Mt,It,r)}}_drawSeriesTopViews(e,t){this.state().containsMainSeries()&&this._drawSourceImpl(e,t,Lt,It,this._chartUndoModel().mainSeries())}_drawSources(e,t){const i=this.state(),s=i.model(),r=i.sourcesByGroup(),n=r.tradingSources(),o=[...s.multiPaneSources(i),...r.generalSources()],a=r.phantomSources(),l=i.customSources(q.CustomSourceLayer.Background).slice(),c=i.customSources(q.CustomSourceLayer.Foreground).slice(),h=i.customSources(q.CustomSourceLayer.Topmost).slice();{const e=s.panes();for(let t=e.length-1;t>=0;t--)e[t].createDrawingsCaches()}this._drawSourceImpl(e,t,Mt,It,s.gridSource()),this._drawWatermark(e,t);for(const i of l)this._drawSourceImpl(e,t,Mt,Tt,i);for(const i of o)this._drawSourceImpl(e,t,Mt,Tt,i);for(const i of c)this._drawSourceImpl(e,t,Mt,Tt,i);for(const i of a)this._drawSourceImpl(e,t,Mt,Tt,i);const d=new Set;[s.lineBeingCreated(),s.lineBeingEdited(),...s.sourcesBeingMoved(),s.customSourceBeingMoved()].filter(y.notNull).forEach((e=>d.add(e.id())));let u=s.hoveredSource();null!==u&&((0,Y.isDataSource)(u)&&!u.showOnTopOnHovering()||d.has(u.id())||(0,Y.isDataSource)(u)&&!o.includes(u)?u=null:d.add(u.id()));const p=s.selection().allSources().filter((e=>!((0,Y.isDataSource)(e)&&!o.includes(e))&&!d.has(e.id())));p.forEach((e=>d.add(e.id())));{for(const i of l)this._drawSourceImpl(e,t,Mt,It,i,d);for(const i of o)this._drawSourceImpl(e,t,Mt,It,i,d);for(const i of c)this._drawSourceImpl(e,t,Mt,It,i,d);const i=s.activeStrategySource().value();i&&this.containsMainSeries()&&this._drawSourceImpl(e,t,kt,It,i)}for(const i of n)this._drawSourceImpl(e,t,Mt,Tt,i);for(const i of h)this._drawSourceImpl(e,t,Mt,Tt,i);for(const i of o)this._drawSourceImpl(e,t,At,It,i,d);for(const i of c)this._drawSourceImpl(e,t,At,It,i,d);for(const i of n)this._drawSourceImpl(e,t,Mt,It,i,d);for(const i of h)this._drawSourceImpl(e,t,Mt,It,i,d);for(const i of p)this._drawSourceImpl(e,t,Mt,It,i);for(const i of p)this._drawSourceImpl(e,t,At,It,i);u&&(this._drawSourceImpl(e,t,Mt,It,u),this._drawSourceImpl(e,t,At,It,u));for(const i of a)this._drawSourceImpl(e,t,Mt,It,i,d);{const e=s.panes();for(let t=e.length-1;t>=0;t--)e[t].clearDrawingCaches()}}_drawSourceImpl(e,t,i,s,r,n){if(n&&n.has(r.id()))return;const o=this.state(),a=o.height(),l=o.width(),c=i(r,this.state());if(c)for(const i of c){const r=i.renderer(a,l);r&&(e.save(),s(r,e,t), +e.restore())}}_updateByThemedColors(){null!==this._legendWidget&&this._legendWidget.updateThemedColors(this._themedTopColor),null!==this._paneControls&&this._paneControls.updateThemedColors(this._themedTopColor)}_scrollUndoCommandInStack(){const e=this._chartUndoModel().undoHistory().undoStack();if(e.isEmpty())return!1;const t=e.head();if(!(t instanceof Z.UndoMacroCommand))return!1;if(t.isEmpty())return!1;const i=t.commands()[0];return i instanceof at.PriceScaleChangeUndoCommand||i instanceof ot.TimeScaleChangeUndoCommand}_onStateDestroyed(){this.setState(null)}_onDataSourcesCollectionChanged(){this._startMoveSourceParams=null}_processMouseEnterLeaveMoveHandlers(e,t){var i,s,r,n;null===this._prevHoveredHittest||this._prevHoveredHittest.renderer===(null==e?void 0:e.renderer)&&(null===(i=this._prevHoveredHittest.hittest.data())||void 0===i?void 0:i.activeItem)===(null===(s=e.hittest.data())||void 0===s?void 0:s.activeItem)||((0,G.tryCallHandler)(t,null===(r=this._prevHoveredHittest.hittest.data())||void 0===r?void 0:r.mouseLeaveHandler),this._prevHoveredHittest=null),t.isTouch||null!==e&&((null===(n=this._prevHoveredHittest)||void 0===n?void 0:n.renderer)!==e.renderer&&(e.hittest.tryCallMouseEnterHandler(t),this._prevHoveredHittest=e),e.hittest.tryCallMouseMoveHandler(t))}_startChangeOrMoveLineToolIfNeeded(){if(null!==this._startChangeLineToolParams){const e=this._startChangeLineToolParams;this._chartUndoModel().startChangingLinetool(e.source,e.startPoint,e.pointIndex,e.envState)}if(null!==this._startMoveSourceParams){const e=this._startMoveSourceParams;this._chartUndoModel().startMovingSources(e.source,e.startPoint,e.activeItem,e.envState)}this._startMoveSourceParams=null,this._startChangeLineToolParams=null}_trackingModeShouldBeActive(){return!(!this._trackCrosshairOnlyAfterLongTap||this._contextMenuOpenedOnLastTap||this._crossHairShouldBeVisible())&&this._longTap}_processOutsideClick(e,t){var i;let s=null;const r=this._chartModel();if(null!==e&&(s=e.isCustom?r.customSourceName(e.source):e.source.id()),null!==this._lastClickedSource&&this._lastClickedSource.id!==s){const e=this._lastClickedSource.id;let i=this._lastClickedSource.isCustom?r.customSourceForName(e):r.dataSourceForId(e);null!==i||this._lastClickedSource.isCustom||(i=r.dataSourceForId(e)),null!==i&&i.onClickOutside&&(i.onClickOutside(t),this._chartModel().updateSource(i))}this._lastClickedSource=null!==s?{id:s,isCustom:null!==(i=null==e?void 0:e.isCustom)&&void 0!==i&&i}:null}_mouseClickOrTapEvent(e){var t;if(!this.hasState())return;const i=this._dataSourceAtPoint(e.localX,e.localY),s=i&&i.source,n=this._chartUndoModel(),o=Boolean(null===(t=null==i?void 0:i.hittest.data())||void 0===t?void 0:t.hideCrosshairLinesOnHover);this._processOutsideClick(i,e),!this._isSelectPointModeEnabled()||o||e.isTouch&&this.trackingModeEnabled()&&!this._exitTrackingModeOnNextTry||n.crossHairSource().trySelectCurrentPoint(),null!==i&&i.hittest.tryCallClickOrTapHandler(e)&&n.model().updateSource((0,r.ensureNotNull)(s)), +!e.isTouch||this._isSelectPointModeEnabled()||i&&i.source===n.crossHairSource()||this._tryExitTrackingMode(),s&&(0,E.isLineTool)(s)&&this._lastFinishedToolId!==s.id()&&(0,u.emit)("drawing_event",s.id(),"click"),this._resetMeasureIfRequired()}_mouseDownOrTouchStartEvent(e,t){var i,s,n,o,a;if(this._pressedMoveStage=1,e.isTouch&&(this._longTap=!1,this._exitTrackingModeOnNextTry=null!==this._startTrackPoint,this._paneWidgetsSharedState.clearDraggingSource()),this._contextMenuOpenedOnLastTap=!1,this._lastFinishedToolId=null,this._chartModel().stopTimeScaleAnimation(),e.isTouch&&this._switchTrackingModeFromAnotherPaneIfNeeded(e),document.activeElement!==document.body&&document.activeElement!==document.documentElement)document.activeElement&&document.activeElement.blur?document.activeElement.blur():document.body.focus();else{const e=document.getSelection();null!==e&&e.removeAllRanges()}(0,u.emit)("mouse_down",{clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY,screenX:e.screenX,screenY:e.screenY}),this._updateCommonTooltip(null);const l=this._chartUndoModel(),c=new $.EnvironmentState(e);l.mainSeries().clearGotoDateResult();const h=this.state().defaultPriceScale();if(h.isEmpty()||l.timeScale().isEmpty())return;const d=l.crossHairSource();if(!e.isTouch&&!(0,V.isLineDrawnWithPressedButton)(K.tool.value())){const t=l.lineBeingCreated(),i=null!==t?l.model().paneForSource(t):null;null!==i&&i!==this._state?this._setCursorPositionOnExternalPane(i,e.localX,e.localY,c):this._setCursorPosition(e.localX,e.localY,c)}e.isTouch&&(0,V.isLineToolName)(K.tool.value())&&((0,V.isLineDrawnWithPressedButton)(K.tool.value())||null!==d.pane?(0,V.isLineDrawnWithPressedButton)(K.tool.value())&&this._clearCursorPosition():this._chart.updateCrossHairPositionIfNeeded());const p=(0,r.ensureNotNull)(this.state().mainDataSource()).firstValue();if(null===p)return void(this._chart.readOnly()||(this._handleSelectionMouseDownAndGetJustDeselectedSource(e,t,c),null!==t&&(0,lt.isPriceDataSource)(t.source)&&t.source.isDraggable()&&this._paneWidgetsSharedState.trySetDraggingSource(t.source,this)));let _=h.coordinateToPrice(e.localY,p),m=this._chartModel().timeScale().coordinateToIndex(e.localX);if(d.startMeasurePoint()&&d.endMeasurePoint()&&d.clearMeasure(),c.shift()&&(null===t||!(null===(s=null===(i=t.hittest.data())||void 0===i?void 0:i.hasOwnShortcutsBehaviourFor)||void 0===s?void 0:s.shiftKey))&&(0,K.toolIsCursor)(K.tool.value())&&l.selection().isEmpty()&&K.tool.setValue("measure"),(e.isTouch&&!e.stylus||!this._tryStartMeasure(e,d,c,_,m))&&(e.isTouch&&!e.stylus||!this._tryFinishMeasure(e,d))&&!this._tryFinishZoom(e)&&!this._tryStartZoom(e,_,m,c)){if(e.isTouch&&(null!==this._startTrackPoint?(this._initCrossHairPosition=d.currentPoint(),this._startTrackPoint=new F.Point(e.localX,e.localY)):this._isSelectPointModeEnabled()&&null===this._chart.trackingModePaneWidget()&&this.startTrackingMode(new F.Point(e.localX,e.localY),new F.Point(e.localX,e.localY),new $.EnvironmentState(e))), +e.isTouch&&(this._preventSourceChange=null===t||!l.selection().isSelected(t.source)),!this._isSelectPointModeEnabled()&&!this._isScrolling){if(e.isTouch&&!e.stylus&&((0,K.toolIsMeasure)(K.tool.value())||null!==d.measurePane().value()))return void this._initToolCreationModeParams(e);if((0,V.isLineToolName)(K.tool.value())||l.lineBeingCreated())return c.shift()||l.selectionMacro((e=>e.clearSelection())),void this._mouseDownEventForLineTool(e,c,m,_)}if(null!==t&&t.hittest.tryCallMouseDownOrTouchStartHandler(e),!this._chart.readOnly()){const i=this._handleSelectionMouseDownAndGetJustDeselectedSource(e,t,c);if(null!==t&&!this._preventSourceChange){const i=t.hittest.data();if(t.isCustom){if(t.hittest.hasPressedMoveHandler(e))return l.model().setMovingCustomSource(t.source,i),this._currentMovingHitTest=t,void l.selectionMacro((e=>{e.clearSelection(),e.addSourceToSelection((0,r.ensureNotNull)(t.source),(0,r.ensureNotNull)(i))}))}else if((null==i?void 0:i.areaName)===G.AreaName.SourceItemMove){const s=null==i?void 0:i.activeItem;if(void 0!==s)return l.startCustomMoving(t.source,s,e),this._currentMovingHitTest=t,void l.selectionMacro((e=>{e.clearSelection(),e.addSourceToSelection((0,r.ensureNotNull)(t.source),(0,r.ensureNotNull)(i))}))}}if(null!==t&&this._tryHandleEraserMouseDown(t,c))return;const s=null!==t&&(0,E.isLineTool)(t.source)&&t.source.isLocked&&t.source.isLocked();if(!((0,K.lockDrawings)().value()||s)&&null!==t&&!t.isCustom){if(!t.source.userEditEnabled())return;const s=null===(n=t.hittest.data())||void 0===n?void 0:n.snappingPrice,l=null===(o=t.hittest.data())||void 0===o?void 0:o.snappingIndex;let h=e.localY,d=e.localX;if(void 0!==s&&(h=(0,r.ensure)(null===(a=t.source)||void 0===a?void 0:a.priceScale()).priceToCoordinate(s,p),_=s),void 0!==l&&(d=this._chartModel().timeScale().indexToCoordinate(l),m=l),h===e.localY&&d===e.localX||(e={...e,localY:h,localX:d},this._setCursorPosition(e.localX,e.localY,c)),this._tryStartChangingLineTool(e,t,c,m))return void(this._currentChangingLineToolHitTest=t);if(this._currentChangingLineToolHitTest=null,(g=t.hittest.target())===G.HitTarget.MovePoint||g===G.HitTarget.MovePointBackground&&(0,U.lastMouseOrTouchEventInfo)().isTouch){if(this._tryStartCloning(e,t,c,i))return;if(this._tryStartMovingLineTool(e,t,c,m))return void(this._currentMovingHitTest=t);this._currentMovingHitTest=null}}if(null!==t&&(0,lt.isPriceDataSource)(t.source)&&t.source.isDraggable()&&this._paneWidgetsSharedState.trySetDraggingSource(t.source,this))return}var g;null!==t&&t.hittest.target()===G.HitTarget.Regular||(this._processing=!0)}}_mouseUpOrTouchEndEvent(e){var t,i;if(!this.hasState())return;this._pressedMoveStage=0;const s=e.isTouch&&null!==this._startTrackPoint,n=e.isTouch&&this._wasPinched;e.isTouch&&(this._wasPinched=!1,this._longTap=!1),this._startMoveSourceParams=null,this._startChangeLineToolParams=null,this._currentChangingLineToolHitTest=null,this._currentMovingHitTest=null;const o=this._chartUndoModel(),a=o.model().customSourceMovingHitTestData() +;null!==a||o.customMoveBeingProcessed()||this._processMouseUpOrTouchEndHandler(e),this._isSelecting=!1;const l=o.model(),c=l.crossHairSource(),h=this._dataSourceAtPoint(e.localX,e.localY);if(c.selection()&&null===this._firstZoomPoint){const e=this.state().lineToolsForArea(c.selection());o.selectionMacro((t=>{let i=null;e.forEach((e=>{null===i&&(i=Dt(h,e)),t.addSourceToSelection(e,i)}))})),c.clearSelection(),(0,Se.trackEvent)("GUI","Multiselect","Area Select")}(0,u.emit)("mouse_up",{clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY,screenX:e.screenX,screenY:e.screenY});const d=e.isTouch&&this._touchMove;e.isTouch&&(this._touchMove=!1);const p=new $.EnvironmentState(e),_=K.tool.value();if(e.isTouch&&((0,K.toolIsMeasure)(_)||null!==c.measurePane().value())){if(!d&&!e.stylus&&null===c.measurePane().value()&&c.pane!==this._state)return void this._setCursorPosition(e.localX,e.localY);if(!d&&!e.stylus&&this._tryStartMeasure(e,c,p,c.price,c.index))return;if((!d||e.stylus)&&this._tryFinishMeasure(e,c))return}if(e.isTouch&&!d&&!(0,V.isLineDrawnWithPressedButton)(_)&&(0,V.isLineToolName)(_)&&!o.lineBeingCreated()){if(this._chart.justActivated())return;if(c.pane!==this._state)return void this._setCursorPosition(e.localX,e.localY,p);const i=c.currentPoint(),s=this.state().defaultPriceScale(),n=(0,r.ensure)(null===(t=this.state().mainDataSource())||void 0===t?void 0:t.firstValue()),a={index:Math.round(o.timeScale().coordinateToIndex(i.x)),price:s.coordinateToPrice(i.y,n)},l=(0,r.ensureNotNull)(o.createLineTool({pane:this.state(),point:a,linetool:_}));return o.selectionMacro((e=>{e.addSourceToSelection(l)})),o.lineBeingCreated()||(this._finishTool(l,h),e.preventDefault()),void(this._startTouchPoint=null)}const m=o.lineBeingCreated();if(m&&!(0,V.isLineDrawnWithPressedButton)(m.toolname)&&e.isTouch&&(this._startTouchPoint||e.stylus)){if(this._startTouchPoint=null,!d||e.stylus){const t=m.points()[m.points().length-1],i=o.continueCreatingLine({index:t.index,price:t.price},new $.EnvironmentState(e));this._initCrossHairPosition=null,i&&(this._finishTool(m,h),e.preventDefault())}return}if(null!==this._firstZoomPoint&&this._firstZoomPoint.draggingMode)return void this._finishZoom(e);if(this._processing=!1,o.customMoveBeingProcessed())return void o.endCustomMoving();if(null!==a&&(a.beingMoved&&((0,G.tryCallHandler)(e,a.mouseUpHandler,a.touchEndHandler),this.setCursorForTool()),l.setMovingCustomSource(null,null),Ot(e,a)))return;if(l.lineBeingEdited())return o.endChangingLinetool(!1),void(this._preventCrossHairMove()&&this._clearCursorPosition());if((0,V.isLineDrawnWithPressedButton)(_)&&!this._isSelectPointModeEnabled()){const t=o.lineBeingCreated();null!==t&&((0,ct.trackDrawingCreated)(t),t.finish());const s=this.state().defaultPriceScale();if(s.isEmpty())return;if(!t)return;const n=(0,r.ensure)(null===(i=t.ownerSource())||void 0===i?void 0:i.firstValue()),a=s.coordinateToPrice(e.localY,n),l={index:Math.round(o.timeScale().coordinateToIndex(e.localX)),price:a};return void o.continueCreatingLine(l)} +if(l.sourcesBeingMoved().length)return o.endMovingSource(!1,!1),l.sourcesBeingMoved().filter(E.isLineTool).forEach((e=>{this.setCursorForTool(e)})),void l.invalidate(N.InvalidationMask.cursor());if(!this._chart.readOnly()){const t=e.localX>=0&&e.localXG.HitTarget.MovePointBackground||(0,U.lastMouseOrTouchEventInfo)().isTouch)&&o.selectionMacro((e=>{e.clearSelection();const t=(0,r.ensureNotNull)(h.source);e.addSourceToSelection(t,Dt(h,t))})),e.isTouch&&(this._touchMove=!1)}_mouseOrTouchMoveEvent(e){if(!this.hasState())return;this._resetMeasureIfRequired();const t=this._dataSourceAtPoint(e.localX,e.localY);this._processMouseEnterLeaveMoveHandlers(t,e);const i=this._chartUndoModel();if(!i)return;const s=e.localX,r=e.localY;this._prevMoveEventPosition=new F.Point(s,r);const n=new $.EnvironmentState(e);if(null===this._firstZoomPoint){if(this._updateHoveredSource(t,n,e),!e.isTouch&&i.lineBeingCreated()){const e=i.lineBeingCreated(),t=null===e?null:i.model().paneForSource(e);if(null!==t&&t!==this._state)return void this._setCursorPositionOnExternalPane(t,s,r,n)}e.isTouch||this._setCursorPosition(s,r,n)}else this._processMouseMoveWhileZoom(e,n)}_pressedMouseOrTouchMoveEvent(e){var t;if(!this.hasState()||this._pinching||e.isTouch&&this._contextMenuOpenedOnLastTap)return;this._pressedMoveStage=2,this._resetMeasureIfRequired(),this._startChangeOrMoveLineToolIfNeeded(),e.isTouch&&(this._touchMove=!0,this._preventSourceChange=!1);const i=new $.EnvironmentState(e),s=this._chartUndoModel(),n=s.crossHairSource(),o=e.localX,a=e.localY;if(this._prevMoveEventPosition=new F.Point(o,a),null!==this._firstZoomPoint)return this._processMouseMoveWhileZoom(e),void(this._firstZoomPoint.draggingMode=!0);const l=K.tool.value();if(e.isTouch&&this._startTouchPoint&&(0,V.isLineToolName)(l)&&!(0, +V.isLineDrawnWithPressedButton)(l)&&!s.lineBeingCreated()&&!this._isSelectPointModeEnabled())return void this._updateCrosshairPositionInToolCreationMode(e,this.state());const c=n.measurePane().value();if(e.isTouch&&(this._startTouchPoint||e.stylus)&&((0,K.toolIsMeasure)(l)||null!==c))return void(e.stylus?this._setCursorPosition(e.localX,e.localY,new $.EnvironmentState(e)):this._updateCrosshairPositionInToolCreationMode(e,c||this.state()));const h=s.lineBeingCreated();if(e.isTouch&&!e.stylus&&h&&!(0,V.isLineDrawnWithPressedButton)(h.toolname)){if(this._startTouchPoint){const t=(0,r.ensureNotNull)(s.lineBeingCreated()),i=(0,r.ensureNotNull)(s.model().paneForSource(t));this._updateCrosshairPositionInToolCreationMode(e,i)}return}if(e.isTouch&&null!==this._startTrackPoint){this._exitTrackingModeOnNextTry=!1;const e=(0,r.ensureNotNull)(this._initCrossHairPosition),t=new F.Point(o,a).subtract(this._startTrackPoint),s=e.add(t);this._setCursorPosition(s.x,s.y,i)}else e.isTouch&&this._preventCrossHairMove()||this._setCursorPosition(o,a,i);const d=this._isSelectPointModeEnabled();if((0,V.isLineToolName)(l)&&!(0,V.isLineDrawnWithPressedButton)(l)&&!d&&!i.mod())return;if((0,V.isLineDrawnWithPressedButton)(l)&&!d){const i=this.state().defaultPriceScale();if(i.isEmpty())return;const n=s.lineBeingCreated();if(!n)return;const o=new F.Point(e.localX,e.localY),a=(0,r.ensure)(null===(t=n.ownerSource())||void 0===t?void 0:t.firstValue());return o.price=i.coordinateToPrice(e.localY,a),o.index=Math.round(s.timeScale().coordinateToIndex(e.localX)),void s.continueCreatingLine(o)}if(null!==this._paneWidgetsSharedState.draggingSource()){const t=e.target,i=this._chart.paneByCanvas(t);i&&(i!==this?i.setDragToAnotherPaneCursor():i.setCursorForTool());const s=this._chart.timeAxisByCanvas(t);s&&s.setCursor("grabbing")}if(s.timeScale().isEmpty())return;const u=this._options.handleScroll;if((!u.pressedMouseMove||e.isTouch)&&(!u.horzTouchDrag&&!u.vertTouchDrag||!e.isTouch))return;if(s.customMoveBeingProcessed())return void s.processCustomMove(e);const p=s.model().customSourceMovingHitTestData();if(null!==p&&(this._updateCommonTooltip(null,!0),s.model().processingCustomSourceMove(),(0,G.tryCallHandler)(e,p.pressedMouseMoveHandler,p.touchMoveHandler),Ot(e,p)))return;if(s.model().lineBeingEdited())return void this._setCursorPosition(o,a,i);if(s.model().sourcesBeingMoved().length)return void this._alignSourcesThatBeingMoved(s.model().sourcesBeingMoved(),e.localX,e.localY,i);const _=this._dataSourceAtPoint(e.localX,e.localY);if(this._tryFinishClonning(e,new $.EnvironmentState(e),_))return;const m=(0,K.toolIsMeasure)(l)||n.startMeasurePoint()&&n.endMeasurePoint();this._chart.readOnly()||!i.mod()||(0,V.isLineToolName)(l)||m||d?(this._processScroll(e),this._preventScroll()&&!this._preventCrossHairMove()&&null===this._startTrackPoint&&this._setCursorPosition(e.localX,e.localY,new $.EnvironmentState(e))):this._isSelecting||(n.startSelection(this.state()),this._isSelecting=!0)}_mouseOrTouchLeaveEvent(e){var t;if(!this.hasState())return +;const i=this._chartUndoModel();if(!i)return;const s=i.crossHairSource();e.isTouch||null!==s.measurePane().value()&&null===s.endMeasurePoint()||this._clearCursorPosition(),i.model().setHoveredSource(null,null),null!==this._prevHoveredHittest&&((0,G.tryCallHandler)(e,null===(t=this._prevHoveredHittest.hittest.data())||void 0===t?void 0:t.mouseLeaveHandler),this._prevHoveredHittest=null),this._updateCommonTooltip(null),this._chart.unsetActivePaneWidget()}_mouseDoubleClickOrDoubleTapEvent(e){if(!this.hasState())return;const t=!this._chart.readOnly()&&!(0,V.isLineToolName)(K.tool.value())&&this._dataSourceAtPoint(e.localX,e.localY)||null;if(null!==t&&t.isCustom)t.hittest.tryCallDblClickOrDblTapHandler(e);else if(null!==t&&(e.isTouch||t.hittest.target()>G.HitTarget.MovePointBackground))this.processDoubleClickOnSource(t.source,t.hittest?t.hittest:void 0);else if(!this._chart.readOnly()&&!(0,V.isLineToolName)(K.tool.value())&&!this._chartUndoModel().lineBeingCreated()&&this._chartUndoModel().selection().isEmpty()){const t=this.state();new $.EnvironmentState(e).mod()&&!t.maximized().value()?(t.collapsed().value()||this._chartModel().paneCollapsingAvailable().value())&&this._chart.toggleCollapsedPane(this):this._chart.toggleMaximizePane(this)}}_contextMenuEvent(e){const t=this._chartUndoModel();if(t.crossHairSource().startMeasurePoint()&&!this._trackCrosshairOnlyAfterLongTap)return t.crossHairSource().clearMeasure(),void(0,K.resetToCursor)(!0);if(this._pinching)return;if(null===this._firstZoomPoint||this._trackCrosshairOnlyAfterLongTap||this.cancelZoom(),!(0,K.toolIsCursor)(K.tool.value())||this._isSelectPointModeEnabled()){if(e.isTouch)return;return(0,K.resetToCursor)(!0),this.setCursorForTool(),void(t.lineBeingCreated()&&t.cancelCreatingLine())}if(!this._options.contextMenuEnabled)return;const i=this._dataSourceAtPoint(e.localX,e.localY),s=i?i.source:null;if(e.isTouch&&null!==this._startTrackPoint){if(this._preventSourceChange)return;this._clearCursorPosition()}e.isTouch&&(this._contextMenuOpenedOnLastTap=!0,this._startTrackPoint=null),this._contextMenuX=e.localX,this._contextMenuY=e.localY;const r=i&&i.hittest?i.hittest.target():0,n=r>=G.HitTarget.Regular||r>=G.HitTarget.MovePointBackground&&e.isTouch;this._chart.updateActions(),t.selectionMacro((t=>{null!==s&&n?t.selection().isSelected(s)||(t.clearSelection(),t.addSourceToSelection(s,Dt(i,s))):(this._options.contextMenu.general&&this._showContextMenu(e),t.clearSelection())})),null!==i&&n&&null!==s&&((0,Y.isDataSource)(s)&&s.hasContextMenu()?s.isSelectionEnabled()?this.showContextMenuForSelection(e):this.showContextMenuForSources([s],e):i.hittest.tryCallContextMenuHandler(e))}_onMouseEvent(){this._preventSourceChange=!1,this._startTrackPoint=null,this._trackCrosshairOnlyAfterLongTap=!1}_onTouchEvent(){this._trackCrosshairOnlyAfterLongTap=!0}_switchTrackingModeFromAnotherPaneIfNeeded(e){const t=this._chart.trackingModePaneWidget();if(null!==t&&t!==this){const i=this._chartModel().crossHairSource().currentPoint();t._exitTrackingModeOnNextTry=!0,t._tryExitTrackingMode(!0), +this.startTrackingMode(new F.Point(e.localX,e.localY),new F.Point(i.x,e.localY),new $.EnvironmentState(e))}}_showContextMenu(e){const t=e=>e instanceof C.Separator,i=this._customActions(),s=this._initActions(e).filter((e=>null!==e));i.remove.forEach((e=>{for(let t=0;t0;e--)t(r[e])&&t(r[e-1])&&r.splice(e,1);r.length&&t(r[0])&&r.splice(0,1),r.length&&t(r[r.length-1])&&r.splice(r.length-1,1),he.ContextMenuManager.showMenu(r,e,{statName:"ChartContextMenu"},{menuName:"ChartContextMenu"})}_initActions(e){var t,i;const s=this._chart.actions(),r=[];if(r.push(s.chartReset),r.push(new C.Separator),!this.state().isEmpty()&&Ae.enabled("datasource_copypaste")){const t=(0,ke.createActionCopyPrice)(this.state(),e.localY),i=(0,ke.createPasteAction)(this._chart,this.state());(t||i)&&(t&&r.push(t),i&&r.push(i),r.push(new C.Separator))}r[r.length-1]instanceof C.Separator||r.push(new C.Separator);return Boolean(null===(t=window.widgetbar)||void 0===t?void 0:t.widget("watchlist"))&&s.addToWatchlist&&r.push(s.addToWatchlist),Ae.enabled("text_notes")&&r.push(s.addToTextNotes),r[r.length-1]instanceof C.Separator||r.push(new C.Separator),r.push(this._createLockTimeAxisAction(e)),r.push(new C.Separator),!Ae.enabled("charting_library_base")&&s.applyColorTheme&&r.push(s.applyColorTheme),r[r.length-1]instanceof C.Separator||r.push(new C.Separator),this._chart.applyIndicatorsToAllChartsAvailable()&&(r.push(s.applyStudiesToAllCharts),r.push(new C.Separator)),r.push(s.paneRemoveAllDrawingTools),r.push(s.paneRemoveAllStudies),r.push(new C.Separator),(null===(i=window.pro)||void 0===i?void 0:i.hasPackage("mtp-mtpredictor"))&&this.state().containsMainSeries()&&r.push((0,ke.createMTPredictorActions)(this._chart,this.state(),this._contextMenuX,this._contextMenuY),new C.Separator),r.push(s.hideAllMarks),r.push(new C.Separator),Ae.enabled("show_chart_property_page")&&r.push(s.chartProperties),r[r.length-1]instanceof C.Separator&&r.pop(),r}_loadAndCreateLegendWidget(){Promise.all([i.e(2521),i.e(9842),i.e(9322),i.e(306),i.e(5093)]).then(i.bind(i,85109)).then((e=>{if(this._isDestroyed)return;const t=e.LegendWidget,i=(0,j.deepExtend)({},this._options.legendWidget);i.canShowSourceCode=!this._chart.onWidget()&&!h.CheckMobile.any(),i.readOnlyMode=i.readOnlyMode||this._chart.readOnly(),i.statusesWidgets={sourceStatusesEnabled:this._options.sourceStatusesWidgetEnabled,sourceStatuses:this._options.sourceStatusesWidget||{},marketStatusEnabled:this._options.marketStatusWidgetEnabled,dataUpdateModeEnabled:this._options.chartWarningWidgetEnabled,dataUpdateMode:this._options.chartWarningWidget||{},dataProblemEnabled:this._options.dataProblemWidgetEnabled};const s=(0,b.combine)(((e,t)=>Rt&&this._chart!==e&&!t),this._chart.chartWidgetCollection().activeChartWidget.weakReference(),this._chart.chartWidgetCollection().lock.crosshair.weakReference()),n=(0,b.combine)(((e,t)=>null!==e?e===this._state:(0, +K.toolIsMeasure)(t)),this._chartModel().crossHairSource().measurePane().weakReference(),K.tool.weakReference());this._legendWidget=new t(this._chartUndoModel(),this,this._chart.backgroundTopTheme().spawnOwnership(),s.ownership(),this._visuallyCollapsed.spawnOwnership(),n.ownership(),i,{showContextMenuForSelection:this.showContextMenuForSelection.bind(this),showContextMenuForSources:this.showContextMenuForSources.bind(this),updateActions:this._chart.updateActions.bind(this._chart),showChartPropertiesForSource:this._chart.showChartPropertiesForSource.bind(this._chart),showGeneralChartProperties:this._chart.showGeneralChartProperties.bind(this._chart),showObjectsTreeDialog:this._chart.showObjectsTreeDialog.bind(this._chart)}),this._div.appendChild(this._legendWidget.getElement()),this._legendWidget.updateLayout(),this._legendWidget.updateWidgetModeBySize(this._size),this._legendWidget.updateThemedColors(this._themedTopColor);for(const e of Array.from(this._customLegendWidgetsFactoryMap.keys()))this._legendWidget.addCustomWidgetToLegend(e,(0,r.ensureDefined)(this._customLegendWidgetsFactoryMap.get(e)))}))}_loadAndCreatePaneControlsWidget(){Promise.all([Promise.all([i.e(2521),i.e(9842),i.e(9322),i.e(306),i.e(5093)]).then(i.bind(i,69289)),Promise.all([i.e(2521),i.e(9842),i.e(9322),i.e(306),i.e(5093)]).then(i.bind(i,59255))]).then((([e,t])=>{var i;if(this._isDestroyed)return;const s=e.PaneControlsWidget;this._paneControls=new s(this._chartUndoModel(),this,{backgroundThemeName:this._chart.backgroundTopTheme()},{toggleMaximizePane:this._chart.toggleMaximizePane.bind(this._chart),toggleCollapsedPane:this._chart.toggleCollapsedPane.bind(this._chart)},this._div),this._paneControls.updateWidgetModeByWidth(this._size.width),this._paneControls.updateThemedColors(this._themedTopColor),this._paneControlsResizeObserver=new t.default(this._handleRestrictLegendWidth.bind(this)),this._paneControlsResizeObserver.observe(this._paneControls.getElement()),(null===(i=this._state)||void 0===i?void 0:i.collapsed().value())&&this._chartModel().fullUpdate()}))}_handleRestrictLegendWidth(e){if(null===this._legendWidget||null===this._paneControls)return;const t=e[e.length-1].contentRect.width,i=0===t?0:t+yt+bt;this._legendWidget.addMargin(i)}_onMagnetStateChanged(){this._chart.isActive()&&(this._isSelectPointModeEnabled()||this._isToolActionActiveOnPane(!0))&&this._chartModel().crossHairSource().visible&&this._updateLineToolUsingMagnetOrShift()}_onShiftKeyStateChanged(){this._chart.isActive()&&this._isToolActionActiveOnPane(!1)&&this._chartModel().crossHairSource().visible&&this._updateLineToolUsingMagnetOrShift($.EnvironmentState.create((0,mt.shiftPressed)().value()))}_isToolActionActiveOnPane(e){const t=this._chartModel(),i=t.lineBeingCreated()||t.lineBeingEdited()||t.sourcesBeingMoved().length>0&&t.sourcesBeingMoved()[0];return i?t.paneForSource(i)===this._state:e&&(0,V.isLineToolName)(K.tool.value())&&t.crossHairSource().pane===this._state}_updateLineToolUsingMagnetOrShift(e){if(null===this._prevMoveEventPosition)return +;const{x:t,y:i}=this._prevMoveEventPosition,s=this._chartModel().sourcesBeingMoved();s.length>0?(K.isStudyEditingNow.value()&&this._setCursorPosition(t,i,e),this._alignSourcesThatBeingMoved(s,t,i,e)):this._setCursorPosition(t,i,e)}_showEditDialogForSource(e,t){if(this._options.propertyPagesEnabled&&e.userEditEnabled())if(e===this._chartUndoModel().mainSeries())this._chart.showGeneralChartProperties(ht.TabNames.symbol);else if((0,E.isLineTool)(e)||(0,B.isStudy)(e)){let i;const s=null==t?void 0:t.data();if(null!=s){const e=s.areaName;void 0!==e&&(i=Bt.get(e))}this._chart.showChartPropertiesForSource(e,i).then((e=>{this._editDialog=e}))}}_initToolCreationModeParams(e){this._startTouchPoint=new F.Point(e.pageX,e.pageY),this._initCrossHairPosition=this._chartModel().crossHairSource().currentPoint()}_updateCrosshairPositionInToolCreationMode(e,t){if(t!==this._state){const i=this._chart.paneByState(t);return i._startTouchPoint=this._startTouchPoint,i._initCrossHairPosition=this._initCrossHairPosition,void i._updateCrosshairPositionInToolCreationMode(e,t)}const i=this._chartModel().crossHairSource();this._chart.justActivated()&&(this._initCrossHairPosition=i.currentPoint());const s=e.pageX,n=e.pageY,o=(0,r.ensureNotNull)(this._initCrossHairPosition),a=new F.Point(s,n).subtract((0,r.ensureNotNull)(this._startTouchPoint)),l=o.add(a);this._setCursorPosition(l.x,l.y,new $.EnvironmentState(e))}_priceAxisesContainer(e){return"left"===e?this._lhsPriceAxisesContainer:this._rhsPriceAxisesContainer}_recalculatePriceScales(e){const t=this.state();for(const i of t.leftPriceScales())t.recalculatePriceScale(i,e);for(const i of t.rightPriceScales())t.recalculatePriceScale(i,e);for(const i of t.sourcesByGroup().overlayPriceScaleSources())(0,E.isLineTool)(i)||t.recalculatePriceScale(i.priceScale(),e)}_createLockTimeAxisAction(e){var t;const i=0===(null===(t=K.crosshairLock.value())||void 0===t?void 0:t.type);return new C.Action({actionId:"Chart.Crosshair.LockVerticalCursor",label:xt,statName:"LockCursorInTime",checkable:!0,checked:i,onExecute:()=>this._toggleLockTimeAxis(e.localX,!i)})}_toggleLockTimeAxis(e,t){if(t){const t=this._chartUndoModel().timeScale(),i=t.coordinateToIndex(e),s=t.points().roughTime(i);if(null!==s)return void K.crosshairLock.setValue({type:0,time:s})}K.crosshairLock.setValue(null)}_preventTouchEventsExceptPinch(){return this._paneWidgetsSharedState.hasTouchesOnOtherPanes(this)||null!==this._paneWidgetsSharedState.pinchingPane()}_updateHoveredSource(e,t,i){var s,r;const n=this._chartUndoModel(),o=n.model();let a=!1;const l=e&&e.source,c=this._chart.readOnly();if(o.crossHairSource().isReplaySelection())this._setCursorClassName("none");else if(!(!c||e&&(0,E.isLineTool)(e.source))||this._editDialog&&this._editDialog.visible().value())c&&(o.setHoveredSource(null,null),this.setCursorForTool());else{const h=K.tool.value();let d=null;if(!this._processing&&((0,K.toolIsCursor)(h)||"eraser"===h&&!c||t.mod()||!n.lineBeingCreated())){const t=null==e?void 0:e.hittest +;a=Boolean(null===(s=null==t?void 0:t.data())||void 0===s?void 0:s.hideCrosshairLinesOnHover),t&&t.target()>G.HitTarget.MovePointBackground?(d=l,!(null==l?void 0:l.isHoveredEnabled())||"eraser"===h&&l===n.mainSeries()?o.setHoveredSource(null,null):o.setHoveredSource(l,t.data())):o.setHoveredSource(null,null)}c?this.setCursorForTool(d,t,dt.PaneCursorType.Default):this._options.sourceSelectionEnabled&&(this._isSelectPointModeEnabled()?this._setCursorClassName("pointer"):this.setCursorForTool(d,t,null===(r=null==e?void 0:e.hittest.data())||void 0===r?void 0:r.cursorType));const u=o.customSourceBeingMoved(),p=null!==u?[u]:o.sourcesBeingMoved();if((!p.length||null!==e&&-1===p.indexOf(e.source))&&this._updateCommonTooltip(e),!c&&null!==e&&i&&e.hittest.hasPressedMoveHandler(i)){switch((e.hittest.data()||{}).cursorType){case dt.PaneCursorType.VerticalResize:this._setCursorClassName("ns-resize");break;case dt.PaneCursorType.HorizontalResize:this._setCursorClassName("we-resize");break;case dt.PaneCursorType.DiagonalNeSwResize:this._setCursorClassName("nesw-resize");break;case dt.PaneCursorType.DiagonalNwSeResize:this._setCursorClassName("nwse-resize")}}}this._preventCrossHairMove()&&this._clearCursorPosition(),1!==this._pressedMoveStage&&o.crossHairSource().setLinesShouldBeHidden(a)}async _createErrorBlock(){const e=new(await pt());return this._div.insertBefore(e.container,this._topCanvasBinding.canvasElement.nextSibling),e}_customActions(){const e={top:[],bottom:[],remove:[]},t=this._chartUndoModel().timeScale(),i=this._state&&this._state.defaultPriceScale();if(!Ae.enabled("custom_items_in_context_menu"))return e;const s=t.isEmpty()?void 0:t.indexToUserTime(t.coordinateToIndex(this._contextMenuX));let n;if(i&&!i.isEmpty()){const e=(0,r.ensureNotNull)(this.state().mainDataSource()).firstValue();n=i.coordinateToPrice(this._contextMenuY,(0,r.ensureNotNull)(e))}return(0,u.emit)("onContextMenu",{unixtime:null!=s?s.getTime()/1e3:void 0,price:n,callback:t=>{[...t].forEach((t=>{if(t.text)if(t.text.length>1&&"-"===t.text[0])e.remove.push(t.text.slice(1));else{let i;i="-"===t.text?new C.Separator:new C.Action({actionId:"Chart.ExternalActionId",label:t.text,onExecute:t.click}),t.position&&"top"===t.position?e.top.push(i):e.bottom.push(i)}}))}}),e}_highlightPriceAxisByLabel(e){this._lhsPriceAxisesContainer.highlightPriceAxisByLabel(e),this._rhsPriceAxisesContainer.highlightPriceAxisByLabel(e)}_subscribeToState(){const e=this.state();e.onDestroyed().subscribe(this,this._onStateDestroyed,!0),e.dataSourcesCollectionChanged().subscribe(this,this._onDataSourcesCollectionChanged),e.maximized().subscribe(this._updateVisuallyCollapsed),e.collapsed().subscribe(this._updateVisuallyCollapsed)}_unsubscribeFromState(){const e=this.state();e.onDestroyed().unsubscribeAll(this),e.dataSourcesCollectionChanged().unsubscribeAll(this),e.maximized().unsubscribe(this._updateVisuallyCollapsed),e.collapsed().unsubscribe(this._updateVisuallyCollapsed)}async _updateEndOfSeriesBanner(){}}var Wt=i(24377),Ht=i(30383);class zt{constructor(e,t,i){this._handleEl=null, +this._resizeInfo=null,this._colorCache={lineColor:"",backgroundColor:"",color:""},this._chart=e,this._topPaneIndex=t,this._bottomPaneIndex=i,this._row=document.createElement("tr"),this._cell=document.createElement("td"),this._row.appendChild(this._cell),this._cell.classList.add(Ht.paneSeparator),this._cell.setAttribute("colspan","3"),this._cell.style.background=this._color(),this.adjustSize(),this._cell.addEventListener("click",(()=>{}));const s=document.createElement("div");s.classList.add(Ht.handle),this._cell.appendChild(s),this._mouseEventHandler=new X.MouseEventHandler(s,this,{treatVertTouchDragAsPageScroll:!1,treatHorzTouchDragAsPageScroll:!0}),this._handleEl=s}destroy(){this._mouseEventHandler.destroy(),this._row.parentElement&&this._row.parentElement.removeChild(this._row)}getElement(){return this._row}hide(){this._row.classList.add("js-hidden")}show(){this._row.classList.remove("js-hidden")}adjustSize(){this._row.style.height=zt.height()+"px"}mouseEnterEvent(e){const{topPane:t,bottomPane:i}=this._topBottomPane(!0);null!==t&&null!==i&&(0,r.ensureNotNull)(this._handleEl).classList.add(Ht.hovered)}mouseLeaveEvent(e){(0,r.ensureNotNull)(this._handleEl).classList.remove(Ht.hovered)}mouseDownEvent(e){this._mouseDownOrTouchStartEvent(e)}touchStartEvent(e){this._mouseDownOrTouchStartEvent(e)}pressedMouseMoveEvent(e){this._pressedMouseOrTouchMoveEvent(e)}touchMoveEvent(e){this._pressedMouseOrTouchMoveEvent(e)}mouseUpEvent(e){this._mouseUpOrTouchEndEvent(e)}touchEndEvent(e){this._mouseUpOrTouchEndEvent(e)}update(){this._cell.style.background=this._color().toString()}paint(){}image(){const{topPane:e}=this._topBottomPane(!1),t=e.leftPriceAxisesContainer().getWidth(),i=e.width(),r=e.rightPriceAxisesContainer().getWidth(),n=this._color(),o=(0,J.createDisconnectedCanvas)(document,(0,s.size)({width:t,height:1})),a=(0,J.getPrescaledContext2D)(o);a.fillStyle=n,a.fillRect(0,0,t,1);const l=(0,J.createDisconnectedCanvas)(document,(0,s.size)({width:i,height:1})),c=(0,J.getPrescaledContext2D)(l);c.fillStyle=n,c.fillRect(0,0,i,1);const h=(0,J.createDisconnectedCanvas)(document,(0,s.size)({width:r,height:1})),d=(0,J.getPrescaledContext2D)(h);return d.fillStyle=n,d.fillRect(0,0,r,1),{type:"separator",leftAxis:{content:o.toDataURL(),canvas:o,contentWidth:t,contentHeight:1},rightAxis:{content:h.toDataURL(),canvas:h,contentWidth:r,contentHeight:1},content:l.toDataURL(),canvas:l,contentWidth:i,contentHeight:1}}static height(){const e=window.devicePixelRatio||1;return e>=1?1:1/e}_mouseDownOrTouchStartEvent(e){const{topPane:t,bottomPane:i}=this._topBottomPane(!0);if(null===t||null===i)return;const s=t.state().stretchFactor()+i.state().stretchFactor(),n=s/(t.height()+i.height()),o=30*n;s<=2*o||(this._resizeInfo={startY:e.pageY,prevStretchTopPane:t.state().stretchFactor(),maxPaneStretch:s-o,totalStretch:s,pixelStretchFactor:n,minPaneStretch:o},(0,r.ensureNotNull)(this._handleEl).classList.add(Ht.active))}_pressedMouseOrTouchMoveEvent(e){const{topPane:t,bottomPane:i}=this._topBottomPane(!0),s=this._resizeInfo +;if(null===s||null===t||null===i)return;const r=(e.pageY-s.startY)*s.pixelStretchFactor,n=(0,ye.clamp)(s.prevStretchTopPane+r,s.minPaneStretch,s.maxPaneStretch);t.state().setStretchFactor(n),i.state().setStretchFactor(s.totalStretch-n),this._chart.model().model().fullUpdate()}_mouseUpOrTouchEndEvent(e){const{topPane:t,bottomPane:i}=this._topBottomPane(!0),s=this._resizeInfo;null!==s&&null!==t&&null!==i&&(this._chart.model().addPaneStretchFactorUndoCommand(t.state(),i.state(),s.prevStretchTopPane,t.state().stretchFactor()),this._resizeInfo=null,(0,r.ensureNotNull)(this._handleEl).classList.remove(Ht.active))}_color(){const e=this._chart.properties().childs().paneProperties.childs().separatorColor.value(),t=this._chart.model().model().backgroundColor().value();if(this._colorCache.lineColor!==e||this._colorCache.backgroundColor!==t){const i=(0,Wt.parseRgba)(t),s=(0,Wt.parseRgba)(e),r=0===i[3]&&0===s[3]?"rgba(0,0,0,0)":(0,Wt.rgbaToString)((0,Wt.blendRgba)(i,s));this._colorCache={lineColor:e,backgroundColor:t,color:r}}return this._colorCache.color}_topBottomPane(e){const t=this._chart.paneWidgets();let i=null,s=null;for(let s=this._topPaneIndex;s>=0;--s){const r=t[s];if(!e||!r.state().collapsed().value()){i=r;break}}for(let i=this._bottomPaneIndex;ithis.backgroundColor(),a=()=>{throw new Error("Time axis does not support real price scales")},l={titlesProvider:i,stubContextMenuProvider:(e,t)=>{const i=r(e,t),s=this.getContextMenuActions(!0);return 0===s.length?i:i.concat(new C.Separator,s)},backgroundBasedTheme:n,rendererOptionsProvider:e.model().model().rendererOptionsProvider(),getBackgroundTopColor:o,getBackgroundBottomColor:o,showHorizontalBorder:!0};this._lhsStubContainer=new me(this._properties,"left",a,l,this._options.priceAxisLabelsOptions,this),this._lhsStubContainer.onLabelHovered().subscribe(this,((e,t)=>{this._onLabelHovered.fire(e,t)})),this._rhsStubContainer=new me(this._properties,"right",a,l,this._options.priceAxisLabelsOptions,this),this._rhsStubContainer.onLabelHovered().subscribe(this,((e,t)=>{this._onLabelHovered.fire(e,t)})),this._element.appendChild(this._lhsStubContainer.getElement()),this._cell=document.createElement("td"),this._element.appendChild(this._cell),this._cell.classList.add("chart-markup-table","time-axis"),this._cell.style.height="25px",this._dv=document.createElement("div"),this._dv.style.width="100%", +this._dv.style.height="100%",this._dv.style.position="relative",this._dv.style.overflow="hidden",this._cell.appendChild(this._dv),this._canvasConfiguredHandler=()=>this.chart.model().model().lightUpdate(),this._canvasBinding=(0,J.createBoundCanvas)(this._dv,(0,s.size)({width:16,height:16})),this._canvasBinding.subscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler);const c=this._canvasBinding.canvasElement;c.style.position="absolute",c.style.zIndex="1",c.style.left="0",c.style.top="0",this._topCanvasBinding=(0,J.createBoundCanvas)(this._dv,(0,s.size)({width:16,height:16})),this._topCanvasBinding.subscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler);const h=this._topCanvasBinding.canvasElement;h.style.position="absolute",h.style.zIndex="2",h.style.left="0",h.style.top="0",this._element.appendChild(this._rhsStubContainer.getElement()),this.restoreDefaultCursor(),this.update(),this._minVisibleSpan=Ut.MINUTE_SPAN,this._mouseEventHandler=new X.MouseEventHandler(this._topCanvasBinding.canvasElement,this,{treatVertTouchDragAsPageScroll:!0,treatHorzTouchDragAsPageScroll:!1}),this.size=(0,s.size)({width:0,height:0}),(0,K.hideMarksOnBars)().subscribe(this,(()=>this.chart.model().model().lightUpdate()))}destroy(){this._mouseEventHandler.destroy(),this._topCanvasBinding.unsubscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler),this._topCanvasBinding.dispose(),this._canvasBinding.unsubscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler),this._canvasBinding.dispose(),this._rhsStubContainer.onLabelHovered().unsubscribeAll(this),this._lhsStubContainer.onLabelHovered().unsubscribeAll(this),this._lhsStubContainer.destroy(),this._rhsStubContainer.destroy(),this.chart.properties().childs().paneProperties.childs().background.unsubscribeAll(this),(0,K.hideMarksOnBars)().unsubscribeAll(this)}setCursor(e){let t="";"grabbing"!==e&&"ew-resize"!==e||(t="time-axis--cursor-"+e),this._currentCursorClassName!==t&&(this._currentCursorClassName&&this._cell.classList.remove(this._currentCursorClassName),t&&this._cell.classList.add(t),this._currentCursorClassName=t,this._cell.style.cursor)}restoreDefaultCursor(){this.setCursor("")}getElement(){return this._element}optimalHeight(){const e=this.rendererOptions();return Math.ceil(e.borderSize+e.offsetSize+e.fontSize+e.paddingTop+e.paddingBottom+e.labelBottomOffset)}setSizes(e,t,i){this.size&&(0,s.equalSizes)(this.size,e)||(this.size=e,this._canvasBinding.resizeCanvasElement(e),this._topCanvasBinding.resizeCanvasElement(e),this._cell.style.width=e.width+"px",this._cell.style.height=e.height+"px"),this._lhsStubContainer.setSizes(e.height,t),this._rhsStubContainer.setSizes(e.height,i)}rendererOptions(){if(!this._rendererOptions||this._rendererOptions.fontSize!==this.fontSize()){const e=this.fontSize();this._rendererOptions={borderSize:1,offsetSize:5,fontSize:e,font:(0,ee.makeFont)(e,re.CHART_FONT_FAMILY,""),widthCache:new ve.TextWidthCache,paddingTop:3*e/12,paddingBottom:3*e/12,paddingHorizontal:9*e/12,labelBottomOffset:4*e/12}}return this._rendererOptions} +backgroundColor(){return this.chart.model().model().backgroundColor().value()}lineColor(){const e=this._properties.childs().lineColor.value();if(0===(0,Wt.parseRgba)(e)[3]){const e=this.chart.model().model().lastPane();if(e&&(e.collapsed().value()||e.isMainPane()&&this._areEventsEnabled()))return this.chart.properties().childs().paneProperties.childs().separatorColor.value()}return e}textColor(){return this._properties.childs().textColor.value()}fontSize(){return this._properties.childs().fontSize.value()}baseFont(){return(0,ee.makeFont)(this.fontSize(),re.CHART_FONT_FAMILY)}baseBoldFont(){return(0,ee.makeFont)(this.fontSize(),re.CHART_FONT_FAMILY,"","bold")}hasCanvas(e){return this._canvasBinding.canvasElement===e||this._topCanvasBinding.canvasElement===e}onLabelHovered(){return this._onLabelHovered}getScreenshotData(){return{content:this._canvasBinding.canvasElement.toDataURL(),canvas:this._canvasBinding.canvasElement,contentWidth:this.size.width,contentHeight:this.size.height,lhsStub:this._lhsStubContainer.getScreenshotData(),rhsStub:this._rhsStubContainer.getScreenshotData()}}getContextMenuActions(e){var t;const i=this.chart;i.updateActions();const s=i.actions(),r=[];if(e||(r.push(s.timeScaleReset),r.push(new C.Separator),this._options.timezoneMenuEnabled&&r.push(s.applyTimeZone),r.push(s.sessionBreaks)),!i.model().mainSeries().isDWM()){const e=null===(t=i.model())||void 0===t?void 0:t.mainSeries().symbolInfo();if(e){const t=i.model().mainSeries().properties().childs().sessionId,s=(e.subsessions||[]).filter((e=>!e.private));if(s.length>1){const e=s.map((e=>{const s={label:(0,jt.translateSessionDescription)(e.description),checkable:!0,checked:t.value()===e.id,statName:"SetSession",onExecute:()=>{i.model().setProperty(t,e.id,qt)}};return new C.Action({...s,actionId:"Chart.SetSession"})})),n={label:$t,statName:"SetSession",subItems:e},o=new C.Action({...n,actionId:"Chart.SetSession"});r.push(o)}}}return r}update(){if(!this.chart.hasModel())return;const e=this.chart.model().timeScale().marks();if(e){this._minVisibleSpan=Ut.YEAR_SPAN;for(const t of e)this._minVisibleSpan=Math.min(t.span,this._minVisibleSpan)}}updatePriceAxisStubs(){const e=this.chart.model().model(),t=this.chart.isMaximizedPane()?(0,r.ensureNotNull)(this.chart.maximizedPaneWidget()).state():e.paneForSource(e.mainSeries());if(!t)return;const i=e.priceScaleSlotsCount();this._lhsStubContainer.setScales([],i.left,t.leftPriceScales().length,i.left+i.right),this._rhsStubContainer.setScales([],i.right,t.rightPriceScales().length,i.left+i.right)}paint(e){if(e===N.InvalidationLevel.None||0===this.size.width||0===this.size.height)return;this._canvasBinding.applySuggestedBitmapSize(),this._topCanvasBinding.applySuggestedBitmapSize();const t=(0,J.getContext2D)(this._topCanvasBinding.canvasElement);if(e>N.InvalidationLevel.Cursor){const i=(0,J.getContext2D)(this._canvasBinding.canvasElement),s=(0,J.getBindingPixelRatio)(this._canvasBinding);this.drawBackground(i,s),this.chart.hasModel()&&(this.drawBorder(i,s),this.drawTickMarks(i,s),this.drawBackLabels(i,s), +this.drawCrossHairLabel(t,s)),this._lhsStubContainer.paintStubs(e),this._rhsStubContainer.paintStubs(e)}this.drawCrossHairLabel(t,(0,J.getBindingPixelRatio)(this._topCanvasBinding))}drawBackground(e,t){if((0,J.clearRect)(e,0,0,Math.ceil(this.size.width*t)+1,Math.ceil(this.size.height*t)+1,this.backgroundColor()),!this.chart.hasModel())return;const i=this.chart.model();if(!i.timeScale().isEmpty()){const s=i.model().selection().lineDataSources().reduce(((e,t)=>{const i=t.timeAxisPoints();return 0===i.length?e:e.concat(i)}),[]);s.length>0&&this._hightlightBackground(e,s,t)}const s=i.model().crossHairSource();s.startMeasurePoint()&&this._hightlightBackground(e,s.measurePoints(),t)}drawBorder(e,t){e.save(),e.fillStyle=this.lineColor();const i=Math.max(1,Math.floor(this.rendererOptions().borderSize*t)),s=Math.ceil(this.size.width*t);e.fillRect(0,0,s+1,i),e.restore()}drawTickMarks(e,t){const i=this.chart.model().timeScale().marks();if(!i||0===i.length)return;let s=i.reduce(((e,t)=>e.span>t.span?e:t),i[0]).span;s>30&&s<40&&(s=30),e.save(),e.strokeStyle=this.lineColor();const r=this.rendererOptions(),n=r.borderSize+r.offsetSize+r.paddingTop+r.fontSize/2;e.textAlign="center",e.textBaseline="middle",e.fillStyle=this.textColor(),(0,J.drawScaled)(e,t,t,(()=>{e.font=this.baseFont();for(let t=0;t=s&&e.fillText(r.label,r.coord,n)}})),e.restore()}drawBackLabels(e,t){var i;e.save();const s=new Set,r=this.chart.model().model();let n=r.dataSources();const o=r.selection().allSources();for(const e of o)s.add(e);r.hoveredSource()&&s.add(r.hoveredSource());for(const e of r.sourcesBeingMoved())s.add(e);const a=r.customSourceBeingMoved();null!==a&&s.add(a);const l=null!==(i=r.lineBeingEdited())&&void 0!==i?i:r.lineBeingCreated();l&&s.add(l),s.add(this.chart.model().crossHairSource()),n=n.concat(r.customSources());const c=this.rendererOptions();for(let i=0;i=s&&(s=a,n=o),a<=i&&(i=a,r=o)}}return n&&t.push(n),r&&t.push(r),t}_zoomAvailable(){return!this.chart.model().timeScale().isEmpty()&&this.chart.model().model().zoomEnabled()&&this._options.pressedMouseMoveScale}_mouseDownOrTouchStartEvent(e){if(this._mousedown||!this._zoomAvailable())return;this._mousedown=!0;const t=this.chart.model();t.timeScale().isEmpty()||t.startScaleTime(e.localX)}_pressedMouseOrTouchMoveEvent(e){this._zoomAvailable()&&this.chart.model().scaleTimeTo(e.localX)}_mouseUpOrTouchEndEvent(e){this._zoomAvailable()&&(this._mousedown=!1,this.chart.model().endScaleTime(),this.restoreDefaultCursor())}_contextMenuOrTouchContextMenuEvent(e){this._options.contextMenuEnabled&&he.ContextMenuManager.showMenu(this.getContextMenuActions(),e,{statName:"TimeScaleContextMenu"},{menuName:"TimeScaleContextMenu"})}_mouseOrTouchEnterEvent(e){this._zoomAvailable()&&this.setCursor("ew-resize")}_mouseOrTouchLeaveEvent(e){this.restoreDefaultCursor()}_mouseDoubleClickOrDoubleTapEvent(e){(0,Se.trackEvent)("GUI","Double click time scale"),this.chart.model().resetTimeScale()}_areEventsEnabled(){return!(0,K.hideMarksOnBars)().value()}}function Kt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Zt(e){return e.reduce(((e,t)=>{for(const i in t)if(Kt(t,i)){const s=t[i],r=e[i];r?r.push(s):e[i]=[s]}return e}),{})}var Xt=i(87095) +;const Jt=new z.TranslatedString("move left",o.t(null,void 0,i(15086))),Qt=new z.TranslatedString("move right",o.t(null,void 0,i(61711))),ei={moving:"wait_finishing",wait_finishing:"stop",stop:"moving"};class ti{constructor(e){this._chartModel=null,this._currentDistance=0,this._deferredFinishTimeout=0,this._finishingTimeout=0,this._moveType="",this._startTime=0,this._state="stop",this._movingTimeout=0,this._chart=e,this._chart.withModel(this,(()=>{this._chartModel=this._chart.model()}))}destroy(){clearTimeout(this._movingTimeout)}move(e){if(null!==this._chartModel&&"stop"===this._state&&this._chartModel.beginUndoMacro(1===e?Jt:Qt),this._state=ei.stop,this._moveType="animated",this._deferredFinishTimeout&&(clearTimeout(this._deferredFinishTimeout),this._deferredFinishTimeout=0),this._finishingTimeout&&(clearTimeout(this._finishingTimeout),this._finishingTimeout=0),this._startTime=Date.now(),0===this._movingTimeout){const t=this._startTime,i=10,s=()=>{this.moveStep(t,0,50*e,1e3),this._movingTimeout=setTimeout(s,i)};this._movingTimeout=setTimeout(s,i)}}moveStep(e,t,i,s){if(null!==this._chartModel&&!this._chartModel.timeScale().isEmpty()){const r=Date.now();r1||!isFinite(n))&&(n=1);const o=1-Math.pow(1-n,3);return this._currentDistance=(i-t)*o+t,this._chartModel.scrollChart(this._currentDistance),n}}moveByBar(e){if(null!==this._chartModel){const t=this._chartModel.timeScale();if(t.isEmpty())return;if("stop"===this._state&&this._chartModel.beginUndoMacro(1===e?Jt:Qt),null!==t.visibleBarsStrictRange()){const e=t.indexToCoordinate(t.visibleBarsStrictRange().lastBar())+t.barSpacing()/2;Math.abs(t.width()-e)>t.barSpacing()/6&&this._chartModel.scrollChart(t.width()-e)}if(this._state=ei.stop,this._moveType="by_bar",this._startTime=Date.now(),!this._movingTimeout){let t=0,i=150;const s=400,r=()=>{this._moveByBarStep(e),t++,i>100&&(i-=t/5*20),this._movingTimeout=setTimeout(r,i)};this._movingTimeout=setTimeout(r,s),this._moveByBarStep(e)}}}stopMove(){"by_bar"===this._moveType?this.stopMoveByBar():this._stopMove()}stopMoveByBar(){"moving"===this._state&&(clearTimeout(this._movingTimeout),this._movingTimeout=0,this._state=ei.wait_finishing,this._moveType="",this._movingTimeout=0,this._currentDistance=0,null!==this._chartModel&&this._chartModel.endUndoMacro())}scrollToRealtime(e){null!==this._chartModel&&this._chartModel.timeScale().scrollToRealtime(e)}_finishMove(){clearTimeout(this._movingTimeout),this._movingTimeout=0,this._deferredFinishTimeout=0;const e=this._currentDistance,t=Date.now(),i=()=>{const s=this.moveStep(t,e,0,700);s&&s<1?this._finishingTimeout=setTimeout(i,10):null!==this._chartModel&&(this._state=ei.wait_finishing,this._moveType="",this._movingTimeout=0,this._currentDistance=0,this._chartModel.endUndoMacro())};this._finishingTimeout=setTimeout(i,10)}_stopMove(){"moving"===this._state&&(this._state=ei.moving,Date.now()-this._startTime<200?this._deferredFinishTimeout=setTimeout(this._finishMove.bind(this),200-(Date.now()-this._startTime)):this._finishMove())}_moveByBarStep(e){ +if(null!==this._chartModel){if(this._chartModel.timeScale().isEmpty())return;this._chartModel.scrollChartByBar(e)}}}var ii=i(36174);const si=(0,a.getLogger)("ChartApi.AbstractSession");class ri extends class{constructor(e,t,i){this._isConnected=new fe.WatchedValue(!1),this._state=0,this._isConnectForbidden=!1,this._sessionId="",this._sessionIdChanged=new ce.Delegate,this._chartApi=e,this._sessionPrefix=t,this._shouldReconnectAfterCriticalError=i}destroy(){this._logNormal("Destroying session"),this._isConnected.unsubscribe(),this.disconnect(),this._sessionIdChanged.destroy(),delete this._chartApi,this._logNormal("Session has been destroyed")}isConnected(){return this._isConnected}sessionId(){return this._sessionId}onSessionIdChanged(){return this._sessionIdChanged}connect(){0===this._state&&((0,r.assert)(!this._isConnectForbidden,"Cannot call connect because it is forbidden at this moment"),this._setSessionId(`${this._sessionPrefix}_${(0,ii.randomHash)()}`),this._logNormal("Connecting session - wait until transport stay connected"),this._state=1,this._chartApi.createSession(this._sessionId,this))}disconnect(){0!==this._state&&((0,r.assert)(""!==this._sessionId,"sessionId must not be invalid"),this._logNormal("Disconnecting session..."),this._forbidConnectWhile((()=>{this._chartApi.connected()&&this._sendRemoveSession(),this._processDestroyingOnServer()})))}onMessage(e){switch(e.method){case"connected":return void this._onChartApiConnected();case"disconnected":return void this._onChartApiDisconnected();case"critical_error":const t=String(e.params[0]),i=String(e.params[1]);return void this._onCriticalError(t,i)}this._onMessage(e)}_getChartApi(){return this._chartApi}_generateLogMessage(e){return`[${this._sessionId}] ${e}`}_onCriticalError(e,t){this._logError(`Critical error. Reason=${e}, info=${t}.`),this._forbidConnectWhile((()=>{this._processDestroyingOnServer()})),this._shouldReconnectAfterCriticalError?(this._logNormal("Reconnecting after critical error..."),this.connect()):this._logNormal("Reconnecting after critical error skipped")}_onChartApiConnected(){(0,r.assert)(1===this._state,"Session is not registered"),this._logNormal("Transport is connected. Creating session on the server"),this._sendCreateSession(),this._state=2,this._isConnected.setValue(!0)}_onChartApiDisconnected(){this._logNormal("Transport is disconnected. Reconnecting..."),this._forbidConnectWhile((()=>{this._processDestroyingOnServer()})),this.connect()}_setSessionId(e){const t=this._sessionId;this._logNormal(`Changing sessionId: old=${t}, new=${e}`),this._sessionId=e,this._sessionIdChanged.fire(e,t)}_logNormal(e){si.logNormal(this._generateLogMessage(e))}_logError(e){si.logError(this._generateLogMessage(e))}_processDestroyingOnServer(){this._state=0,this._isConnected.setValue(!1),this._chartApi.removeSession(this._sessionId),this._setSessionId("")}_forbidConnectWhile(e){this._isConnectForbidden=!0,e(),this._isConnectForbidden=!1}}{constructor(e,t=!1){super(e,"cs",!1),this._sessionDisabled=!1,this._handler=null, +this._criticalError=new ce.Delegate,this._symbolResolveMap=new Map,this._disableStatistics=t}destroy(){this._criticalError.destroy(),this._handler=null,this._symbolResolveMap.clear(),super.destroy()}serverTimeOffset(){return this._getChartApi().serverTimeOffset()}switchTimezone(e){return this._getChartApi().switchTimezone(this.sessionId(),e)}defaultResolutions(){return this._getChartApi().defaultResolutions()}availableCurrencies(){return this._getChartApi().availableCurrencies()}availableUnits(){return this._getChartApi().availableUnits()}availablePriceSources(e){return this._getChartApi().availablePriceSources(e)}resolveSymbol(e,t,i){if(this._symbolResolveMap.has(t)){const[e,s]=this._symbolResolveMap.get(t);return Array.isArray(s)?s.push(i):s.then(i),e}{const s=[i];return this._getChartApi().resolveSymbol(this.sessionId(),e,t,(i=>{"symbol_error"===i.method?this._symbolResolveMap.delete(t):this._symbolResolveMap.set(t,[e,Promise.resolve(i)]),s.forEach((e=>e(i)))})),this._symbolResolveMap.set(t,[e,s]),e}}requestFirstBarTime(e,t,i){return this._getChartApi().requestFirstBarTime(this.sessionId(),e,t,i)}createSeries(e,t,i,s,r,n,o){return this._getChartApi().createSeries(this.sessionId(),e,t,i,s,r,n,o)}modifySeries(e,t,i,s,r,n,o){return this._getChartApi().modifySeries(this.sessionId(),e,t,i,s,r,n,o)}removeSeries(e){return!!this.isConnected().value()&&this._getChartApi().removeSeries(this.sessionId(),e)}requestMoreData(e,t,i){return"number"==typeof e?this._getChartApi().requestMoreData(this.sessionId(),e):this._getChartApi().requestMoreData(this.sessionId(),e,t,i)}requestMoreTickmarks(e,t,i){return(0,y.isNumber)(e)?this._getChartApi().requestMoreTickmarks(this.sessionId(),e):this._getChartApi().requestMoreTickmarks(this.sessionId(),e,t,i)}requestMetadata(e,t){this._getChartApi().requestMetadata(this.sessionId(),e,t)}canCreateStudy(e){return this._getChartApi().canCreateStudy(e)}getStudyCounter(){return this._getChartApi().getStudyCounter()}createStudy(e,t,i,s,r,n,o){return this._getChartApi().createStudy(this.sessionId(),e,t,i,s,r,n,o)}rebindStudy(e,t,i,s,r,n,o){return this._getChartApi().rebindStudy(this.sessionId(),e,t,i,s,r,n,o)}modifyStudy(e,t,i,s,r){return this._getChartApi().modifyStudy(this.sessionId(),e,t,i,s,r)}removeStudy(e,t){return this._getChartApi().removeStudy(this.sessionId(),e,t)}createPointset(e,t,i,s,r,n){return this._getChartApi().createPointset(this.sessionId(),e,t,i,s,r,n)}modifyPointset(e,t,i,s){return this._getChartApi().modifyPointset(this.sessionId(),e,t,i,s)}removePointset(e){return this._getChartApi().removePointset(this.sessionId(),e)}setVisibleTimeRange(e,t,i,s,r,n){this._getChartApi().setVisibleTimeRange(this.sessionId(),e,t,i,s,!0,r,n)}criticalError(){return this._criticalError}connect(e=null){null!==e&&(this._handler=e),this._symbolResolveMap.clear(),super.connect()}setHandler(e){this._handler=e}connected(){return this.isConnected().value()&&!this._sessionDisabled}disable(){this._sessionDisabled=!0}chartApi(){return this._getChartApi()}_sendCreateSession(){Object.keys(this).forEach((e=>{ +/^(s|st|symbol_)\d+$/.test(e)&&delete this[e]})),this._getChartApi().chartCreateSession(this.sessionId(),this._disableStatistics)}_sendRemoveSession(){this._getChartApi().chartDeleteSession(this.sessionId())}_onMessage(e){this._handler&&this._handler(e)}_onCriticalError(e,t){this._criticalError.fire(e,t),super._onCriticalError(e,t)}}var ni=i(42960),oi=i(94025);class ai{constructor(){this._draggingSource=null,this._activeTouchPanes=new Set,this._scrollingPane=null,this._pinchingPane=null}onPaneDestroyed(e){this._activeTouchPanes.delete(e),this._scrollingPane===e&&(this._scrollingPane=null),this._pinchingPane===e&&(this._pinchingPane=null)}startTouch(e){this._activeTouchPanes.add(e)}endTouch(e){this._activeTouchPanes.delete(e)}hasTouchesOnOtherPanes(e){return this._activeTouchPanes.size>1||1===this._activeTouchPanes.size&&!this._activeTouchPanes.has(e)}trySetDraggingSource(e,t){return!this.hasTouchesOnOtherPanes(t)&&((0,r.assert)(null===this._draggingSource||this._draggingSource===e),this._draggingSource=e,!0)}clearDraggingSource(){null!==this._draggingSource&&(this._draggingSource=null)}draggingSource(){return this._draggingSource}setScrollingPane(e){(0,r.assert)(null===e||null===this._scrollingPane||this._scrollingPane===e),this._scrollingPane=e}scrollingPane(){return this._scrollingPane}setPinchingPane(e){(0,r.assert)(null===e||null===this._pinchingPane||this._pinchingPane===e),this._pinchingPane=e}pinchingPane(){return this._pinchingPane}}let li=null;i(59744);function ci(e,t,s,r,n){return Promise.all([i.e(77),i.e(7201),i.e(8884),i.e(2666),i.e(1013),i.e(3842),i.e(4015),i.e(5145),i.e(855),i.e(6),i.e(5993),i.e(5649),i.e(2191),i.e(6221),i.e(8056),i.e(2587),i.e(3502),i.e(8149),i.e(2639),i.e(2109),i.e(9842),i.e(4215),i.e(7232),i.e(6625),i.e(9327),i.e(7194),i.e(6884),i.e(6036),i.e(2984),i.e(3980),i.e(5403),i.e(3889),i.e(4894),i.e(7391),i.e(7555),i.e(962),i.e(8385),i.e(9727),i.e(4403),i.e(4713),i.e(5901),i.e(769),i.e(9795),i.e(4378),i.e(6265)]).then(i.bind(i,63374)).then((i=>{const o=new(0,i.EditObjectDialogRenderer)(e,t,r,n);return o.show(s),o}))}let hi=null;var di=i(58229);const ui={[ht.TabNames.symbol]:"symbol",[ht.TabNames.legend]:"legend",[ht.TabNames.scales]:"scales",[ht.TabNames.trading]:"trading",[ht.TabNames.events]:"events",[ht.TabNames.timezoneSessions]:"canvas",[ht.TabNames.text]:"text",[ht.TabNames.style]:"style",[ht.TabNames.visibility]:"visibility"},pi={[ht.TabNames.style]:"style",[ht.TabNames.visibility]:"visibilities"};async function _i(e,t,s={},r,n){const o=r.activeChartWidget.value(),{initialTab:a,tabName:l}=s;if(l&&!a&&(s.initialTab=pi[l]),(0,E.isStudyLineTool)(e)&&function(e){return[di.LineToolVbPFixed,null].filter(y.notNull).some((t=>e instanceof t))}(e))return o.propertiesDefinitionsForSource(e).then((i=>null!==i?ci(e,t,s,n,i):null));if((0,B.isStudy)(e)&&function(e){const{shortId:t}=e.metaInfo();return"Overlay"===t}(e)||(0,E.isLineTool)(e))return o.propertiesDefinitionsForSource(e).then((r=>{if(null!==r){return function(e){ return Promise.all([i.e(77),i.e(2666),i.e(1013),i.e(3842),i.e(4015),i.e(5145),i.e(855),i.e(6),i.e(5993),i.e(5649),i.e(2191),i.e(6221),i.e(8056),i.e(2587),i.e(3502),i.e(8149),i.e(2639),i.e(2109),i.e(9842),i.e(4215),i.e(7232),i.e(6625),i.e(9327),i.e(7194),i.e(6884),i.e(2984),i.e(3980),i.e(5403),i.e(3889),i.e(7391),i.e(8904),i.e(962),i.e(8385),i.e(9727),i.e(4403),i.e(4713),i.e(5901),i.e(769),i.e(9795),i.e(4378),i.e(6780)]).then(i.bind(i,75892)).then((t=>{const i=new(0,t.SourcePropertiesEditorRenderer)(e);return null!==hi&&hi.hide(),i.show({shouldReturnFocus:e.shouldReturnFocus}),hi=i,i}))}({propertyPages:r,model:t,source:e,activePageId:l&&ui[l],shouldReturnFocus:s.shouldReturnFocus})}return null}));if((0,B.isStudy)(e))return ci(e,t,s,n);{const e=l&&ui[l],t=r.getChartPropertiesDialogRenderer();return t.setActivePage(e),t.show(s)}}var mi=i(38618),gi=i(82723),fi=i(93613),vi=i(1803),Si=i(54355);class yi{constructor(e,t){this._showed=!1,this._cw=e,this._element=document.createElement("div"),this._element.classList.add(Si.screen),t.appendChild(this._element),this._cw.withModel(this,this._connectToModel)}show(e){if(e){const e=this._cw.model().mainSeries().status();if(1!==e&&2!==e)return}this._cw.setInLoadingState(!0),this._showed||(this._showed=!0,this._show())}hide(){this._cw.setInLoadingState(!1),this._showed&&this._hide()}isShown(){return this._showed}_connectToModel(){const e=this._cw.model().mainSeries().dataEvents();e.symbolError().subscribe(this,(e=>{e!==vi.permissionDenied&&this.hide()})),e.seriesError().subscribe(this,(()=>{(0,Ae.enabled)("hide_loading_screen_on_series_error")&&this.hide()})),e.completed().subscribe(this,this.hide)}_show(){const e=this._cw.properties().childs().paneProperties.childs();let t;if(e.backgroundType.value()===fi.ColorType.Solid)t=e.background.value();else{t=`linear-gradient(${e.backgroundGradientStartColor.value()},${e.backgroundGradientEndColor.value()})`}this._element.style.background=t,this._element.classList.add(Si.fade)}_hide(){this._showed=!1,this._element.classList.remove(Si.fade)}}var bi=i(78071),wi=i(4949),Pi=i(45345),Ci=i(24633);const xi=(0,W.getHexColorByName)("color-cold-gray-700"),Ti=(0,W.getHexColorByName)("color-cold-gray-400");class Ii{constructor(e){this._container=null,this._errorCardRenderer=null,this._mainSeriesErrorMessage=null,this._banErrorMessage=new fe.WatchedValue(null).spawn(),this._errorMessageHandler=e=>{this._chartWidget.hasModel()?this._updatePaneWidgets(e):this._renderErrorWithoutModel(e)},this._chartWidget=e,this._subscribeToMainSeriesErrors()}destroy(){var e,t;null===(e=this._mainSeriesErrorMessage)||void 0===e||e.destroy(),this._banErrorMessage.destroy(),null===(t=this._errorCardRenderer)||void 0===t||t.then((e=>{e.container.remove(),e.destroy()}))}updatePaneWidgets(){this._updatePaneWidgets()}setContainer(e){var t;if(this._container!==e){this._container=e,null===(t=this._errorCardRenderer)||void 0===t||t.then((e=>e.container.remove()));const i=this._getErrorMessage();i&&this._errorMessageHandler(i)}}_updatePaneWidgets(e=this._getErrorMessage()){ this._chartWidget.paneWidgets().forEach((t=>t.setErrorMessage(e)))}async _renderErrorWithoutModel(e){if(null===this._container||null===e&&null===this._errorCardRenderer)return;const t=await this._getErrorCardRenderer();this._container.contains(t.container)||this._container.appendChild(t.container),t.update(this._createErrorCardRendererState(e))}async _getErrorCardRenderer(){return this._errorCardRenderer||(this._errorCardRenderer=this._createErrorCardRenderer())}async _createErrorCardRenderer(){return new(await pt())}_createErrorCardRendererState(e){return e?{message:e.message,icon:e.icon,textColor:Pi.watchedTheme.value()===Ci.StdTheme.Dark?Ti:xi,backgroundColor:Pi.watchedTheme.value()===Ci.StdTheme.Dark?"#131722":"#FFF",solutionId:e.solutionId}:{message:null}}_subscribeToMainSeriesErrors(){const e=this._chartWidget;e.withModel(this,(()=>{const t=e.model().model().mainSeries();this._mainSeriesErrorMessage=(0,b.combine)(((e,t)=>{if(e)return e;switch(t){case"invalid_symbol":return{message:"Invalid symbol",icon:"ghost"};case"no_data":return{message:"No data here",icon:"ghost"};case null:return null}}),this._banErrorMessage.weakReference(),(0,ni.getSeriesDisplayErrorWV)(t).ownership()),this._mainSeriesErrorMessage.subscribe(this._errorMessageHandler,{callWithLast:!0})}))}_getErrorMessage(){var e;return this._banErrorMessage.value()||(null===(e=this._mainSeriesErrorMessage)||void 0===e?void 0:e.value())||null}}var Mi=i(33703),Li=i(59452),Ai=i.n(Li);async function ki(e,t,s,r,n,a="default"){let l,c=[];const h=e.model().model(),d=(0,y.clone)(t),u=new(Ai())({inputs:d}),p=function(e,t){return"symbol"===t?e.inputs.filter((t=>t.id===e.symbolInputId())):e.inputs.filter((e=>e.confirm))}(s,a),_=()=>{l&&h.removeCustomSource(l)},m=()=>{_(),n()},g=e=>{r({inputs:e,parentSources:c}),_()},f=p.filter(Mi.isTimeOrPriceNotHiddenInput);if(f.length>0)try{const t=await Promise.all([i.e(77),i.e(2666),i.e(1013),i.e(3842),i.e(4015),i.e(5145),i.e(855),i.e(6),i.e(5993),i.e(2191),i.e(6221),i.e(8056),i.e(2587),i.e(3502),i.e(2639),i.e(2109),i.e(9842),i.e(4215),i.e(7232),i.e(6625),i.e(9327),i.e(7194),i.e(6884),i.e(2984),i.e(1762),i.e(962),i.e(8385),i.e(3016),i.e(3179),i.e(9727),i.e(4403),i.e(4713),i.e(5901),i.e(3030)]).then(i.bind(i,73339)),r=await t.selectInputValuesOnChart(e,f,u,s.shortDescription,s.inputs);if(l=r.customSourceId,r.destPane){const e=r.destPane.mainDataSource();c=e===h.mainSeries()?[]:[e]}else c=[]}catch(e){return void m()}f.length!==p.length?Promise.all([i.e(77),i.e(2666),i.e(1013),i.e(3842),i.e(4015),i.e(5145),i.e(855),i.e(6),i.e(5993),i.e(2191),i.e(6221),i.e(8056),i.e(2587),i.e(3502),i.e(2639),i.e(2109),i.e(9842),i.e(4215),i.e(7232),i.e(6625),i.e(9327),i.e(7194),i.e(6884),i.e(2984),i.e(1762),i.e(962),i.e(8385),i.e(3016),i.e(3179),i.e(9727),i.e(4403),i.e(4713),i.e(5901),i.e(3030)]).then(i.bind(i,29638)).then((t=>{const r=new t.ConfirmInputsDialogRenderer(function(e){if("symbol"===e)return o.t(null,void 0,i(45743));return o.t(null,void 0,i(46689))}(a),p,u,a,s,e.model(),g,m);return r.show(),r})):g(u.state().inputs||{})} -var Di=i(60156),Vi=i(36274);var Ei=i(85804),Bi=i(75531),Ri=i(37591);i(37218);const Ni=(0,a.getLogger)("ChartWidget",{color:"#606"}),Oi=(0,Ae.enabled)("chart_content_overrides_by_defaults"),Fi=new z.TranslatedString("hide {title}",o.t(null,void 0,i(70301)));const Wi={addToWatchlistEnabled:!0,showFinancialsEnabled:!1,sourceSelectionEnabled:!0,propertyPagesEnabled:!0,paneContextMenuEnabled:!0,priceScaleContextMenuEnabled:!0,currencyConversionEnabled:!1,unitConversionEnabled:!1,goToDateEnabled:!1,marketStatusWidgetEnabled:!0,chartWarningWidgetEnabled:!0,dataProblemWidgetEnabled:!0,paneControlsEnabled:!0,isSymbolAvailable:e=>Promise.resolve(!0),legendWidgetEnabled:!0,chartEventsEnabled:!0,esdEnabled:!1,latestUpdatesEnabled:{news:!1,minds:!1},continuousContractSwitchesEnabled:!1,futuresContractExpirationEnabled:!1,croppedTickMarks:!0,countdownEnabled:!0,lastPriceAnimationEnabled:!0,useKineticScroll:h.CheckMobile.any(),indicatorsDialogShortcutEnabled:!0,handleScale:{mouseWheel:!0,pinch:!0,axisPressedMouseMove:{time:!0,price:!0}},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0}};function Hi(e,t,i,s=0){const r=t.mainSeries().syncModel(),n=e.mainSeries().syncModel();let o=i;if(null!==r&&null!==n){const t=e.createSyncPoint(r.syncSourceTarget(),n.syncSourceTarget());0!==s&&(i=r.projectTime(i,s)),o=t.sourceTimeToTargetTime(i)}return e.timeScale().points().roughIndex(o,n&&n.distance.bind(n))}const zi=["Overlay@tv-basicstudies","CorrelationCoefficient@tv-basicstudies","Correlation Coeff@tv-basicstudies","Spread@tv-basicstudies","Ratio@tv-basicstudies"];class Ui{constructor(e,t,i){this.activePaneWidget=null,this._model=null,this._paneWidgets=[],this._maximizedPaneWidget=null,this._timeAxisWidget=null,this._paneSeparators=[],this._controlBarNavigation=null,this._lineToolsSynchronizer=null,this._modelCreated=new ce.Delegate,this._isDestroyed=!1,this._customLegendWidgetsFactoryMap=new Map,this._backgroundTopTheme=new fe.WatchedValue("light"),this._backgroundBasedTheme=new fe.WatchedValue("light"),this._backgroundBottomTheme=new fe.WatchedValue("light"),this._lhsAxesWidth=0,this._rhsAxesWidth=0,this._lhsPriceAxisWidthChanged=new ce.Delegate,this._rhsPriceAxisWidthChanged=new ce.Delegate,this._mainDiv=null,this._parent=null,this._elTooltipDiv=null,this._hotkeysListener=null,this._mouseWheelHelper=null,this._onWheelBound=null,this._justActivated=!1,this._inited=!1,this._containsData=!1,this._initialLoading=!1,this._defTimeframe=void 0,this._removeMaximizeHotkey=null,this._metaInfoRepository=null,this._invalidationMask=null,this._drawPlanned=!1,this._drawRafId=0,this._inLoadingState=!1,this._timingsMeter=null,this._tagsChanged=new ce.Delegate,this._redraw=new ce.Delegate,this._isVisible=new fe.WatchedValue(!0),this._collapsed=new fe.WatchedValue(!1),this._dataWindowWidget=null,this._resizeHandler=null,this._spinner=null,this._keydownEventListener=null,this._properties=null,this._symbolWV=new fe.WatchedValue,this._resolutionWV=new fe.WatchedValue, +var Di=i(60156),Ei=i(36274);var Vi=i(85804),Bi=i(75531),Ri=i(37591);i(37218);const Ni=(0,a.getLogger)("ChartWidget",{color:"#606"}),Oi=(0,Ae.enabled)("chart_content_overrides_by_defaults"),Fi=new z.TranslatedString("hide {title}",o.t(null,void 0,i(70301)));const Wi={addToWatchlistEnabled:!0,showFinancialsEnabled:!1,sourceSelectionEnabled:!0,propertyPagesEnabled:!0,paneContextMenuEnabled:!0,priceScaleContextMenuEnabled:!0,currencyConversionEnabled:!1,unitConversionEnabled:!1,goToDateEnabled:!1,marketStatusWidgetEnabled:!0,chartWarningWidgetEnabled:!0,dataProblemWidgetEnabled:!0,paneControlsEnabled:!0,isSymbolAvailable:e=>Promise.resolve(!0),legendWidgetEnabled:!0,chartEventsEnabled:!0,esdEnabled:!1,latestUpdatesEnabled:{news:!1,minds:!1},continuousContractSwitchesEnabled:!1,futuresContractExpirationEnabled:!1,croppedTickMarks:!0,countdownEnabled:!0,lastPriceAnimationEnabled:!0,useKineticScroll:h.CheckMobile.any(),indicatorsDialogShortcutEnabled:!0,handleScale:{mouseWheel:!0,pinch:!0,axisPressedMouseMove:{time:!0,price:!0}},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0}};function Hi(e,t,i,s=0){const r=t.mainSeries().syncModel(),n=e.mainSeries().syncModel();let o=i;if(null!==r&&null!==n){const t=e.createSyncPoint(r.syncSourceTarget(),n.syncSourceTarget());0!==s&&(i=r.projectTime(i,s)),o=t.sourceTimeToTargetTime(i)}return e.timeScale().points().roughIndex(o,n&&n.distance.bind(n))}const zi=["Overlay@tv-basicstudies","CorrelationCoefficient@tv-basicstudies","Correlation Coeff@tv-basicstudies","Spread@tv-basicstudies","Ratio@tv-basicstudies"];class Ui{constructor(e,t,i){this.activePaneWidget=null,this._model=null,this._paneWidgets=[],this._maximizedPaneWidget=null,this._timeAxisWidget=null,this._paneSeparators=[],this._controlBarNavigation=null,this._lineToolsSynchronizer=null,this._modelCreated=new ce.Delegate,this._isDestroyed=!1,this._customLegendWidgetsFactoryMap=new Map,this._backgroundTopTheme=new fe.WatchedValue("light"),this._backgroundBasedTheme=new fe.WatchedValue("light"),this._backgroundBottomTheme=new fe.WatchedValue("light"),this._lhsAxesWidth=0,this._rhsAxesWidth=0,this._lhsPriceAxisWidthChanged=new ce.Delegate,this._rhsPriceAxisWidthChanged=new ce.Delegate,this._mainDiv=null,this._parent=null,this._elTooltipDiv=null,this._hotkeysListener=null,this._mouseWheelHelper=null,this._onWheelBound=null,this._justActivated=!1,this._inited=!1,this._containsData=!1,this._initialLoading=!1,this._defTimeframe=void 0,this._removeMaximizeHotkey=null,this._metaInfoRepository=null,this._invalidationMask=null,this._drawPlanned=!1,this._drawRafId=0,this._inLoadingState=!1,this._timingsMeter=null,this._tagsChanged=new ce.Delegate,this._redraw=new ce.Delegate,this._isVisible=new fe.WatchedValue(!0),this._collapsed=new fe.WatchedValue(!1),this._dataWindowWidget=null,this._resizeHandler=null,this._spinner=null,this._keydownEventListener=null,this._properties=null,this._symbolWV=new fe.WatchedValue,this._resolutionWV=new fe.WatchedValue, this._updateThemedColorBound=this._updateThemedColor.bind(this),this._disconnected=new ce.Delegate,this._reconnectBailout=new ce.Delegate,this._connected=new ce.Delegate,this._chartWidgetInitialized=new ce.Delegate,this._saveChartService=null,this._objectTreeDialogController=null,this._chartPaintedPromise=null,this._noExchangeSubscrptionWarning=null,this._paneWidgetsSharedState=new ai,this._brokerName="",this._onZoom=new ce.Delegate,this._onScroll=new ce.Delegate,this._availableScreen=null,this._hoveredPriceAxes=new Set,this._anyAxisHovered=new fe.WatchedValue(!1),this._linkingGroupIndex=new fe.WatchedValue(null),this._showDataWindowAction=null,this._activeHint=null,this._hintDefferedPromise=null,this._setSymbolIntervalContentOverrides={},this._invalidationHandler=e=>{if(!(e instanceof N.InvalidationMask))throw new Error("Invalid mask");null!==this._invalidationMask?this._invalidationMask.merge(e):this._invalidationMask=e,this._drawPlanned||(this._drawPlanned=!0,this._options.visible.when((()=>{const e=!document.hidden,t=this.screen&&this.screen.isShown();null!==this._timingsMeter&&e&&!t&&this._timingsMeter.startWaitingDraw();const i=(0,r.ensureNotNull)((0,r.ensureNotNull)(this._parent).ownerDocument.defaultView);this._drawRafId=i.requestAnimationFrame(this._invalidationRAFCallback.bind(this))})))},this._onChartSessionIsConnectedChanged=e=>{e?this._onConnection():this._onDisconnect()},this._subscribeToBanInfo=e=>{var t,i;e?null===(t=this._spinner)||void 0===t||t.stop():null===(i=this._spinner)||void 0===i||i.spin()},this._id=t,this._layoutId=i,this._options=(0,y.merge)((0,y.clone)(Wi),e),this._options.customLegendWidgetFactories&&(this._customLegendWidgetsFactoryMap=this._options.customLegendWidgetFactories),this._subscribeToDrawingState(),this._chartWidgetCollection=this._options.chartWidgetCollection,this.withModel(this,(()=>{const e=this.model().model();e.backgroundTopColor().subscribe(this._updateThemedColorBound),e.backgroundColor().subscribe(this._updateThemedColorBound)})),this._errorRenderer=new Ii(this),this._scrollHelper=new ti(this),this._objectTreeDialogController=m.getInstance(),this._properties=new R.DefaultProperty("chartproperties",void 0,void 0,this._options.useUserChartPreferences),this._properties.addExclusion("scalesProperties.axisHighlightColor"),this._properties.addExclusion("scalesProperties.axisLineToolLabelBackgroundColorActive"),this._properties.addExclusion("scalesProperties.axisLineToolLabelBackgroundColorCommon"),this._properties.addExclusion("scalesProperties.showPriceScaleCrosshairLabel"),this._properties.addExclusion("scalesProperties.showTimeScaleCrosshairLabel"),this._properties.addExclusion("scalesProperties.crosshairLabelBgColorLight"),this._properties.addExclusion("scalesProperties.crosshairLabelBgColorDark"),this._startSpinner(this._options.container.value()),this._chartSession=new ri(window.ChartApiInstance),this._metaInfoRepository=new L(this._chartSession),this._isMultipleLayout=(0,b.combine)((e=>(0,Bi.isMultipleLayout)(e)),this._chartWidgetCollection.layout.weakReference())} destroy(){var e,t;null===(e=this._lineToolsSynchronizer)||void 0===e||e.destroy(),null===(t=this._noExchangeSubscrptionWarning)||void 0===t||t.destroy(),window.loginStateChange.unsubscribe(this,this._handleLoginStateChanged),null!==this._model&&(this._model.model().backgroundTopColor().unsubscribe(this._updateThemedColorBound),this._model.model().backgroundColor().unsubscribe(this._updateThemedColorBound),this._model.destroy()),this._customLegendWidgetsFactoryMap.clear(),this._scrollHelper.destroy(),this._errorRenderer.destroy(),this._chartSession.criticalError().unsubscribe(this,this._onChartSessionCriticalError),this._chartSession.isConnected().unsubscribe(this._onChartSessionIsConnectedChanged),this._chartSession.destroy(),this._isDestroyed=!0}emulateCriticalError(){this._chartSession.removeSeries("-1")}chartSession(){return this._chartSession}onDisconnected(){return this._disconnected}onReconnectBailout(){return this._reconnectBailout}onConnected(){return this._connected}chartWidgetInitialized(){return this._chartWidgetInitialized}setVisibleTimeRange(e,t,i,s){{const n=this.model().mainSeries().seriesSource();this._chartSession.setVisibleTimeRange((0,r.ensureNotNull)(n.instanceId()),n.turnaround(),e,t,null!=i?i:{},null!=s?s:()=>{})}}fullSourceId(e){return{layoutId:this.layoutId(),chartId:this.id(),sourceId:e.id()}}lineToolsSynchronizer(){return this._lineToolsSynchronizer}requestFullscreen(){this.getResizerDetacher().requestFullscreen()}exitFullscreen(){this.getResizerDetacher().exitFullscreen()}inFullscreen(){return this.getResizerDetacher().fullscreen.value()}model(){return(0,r.ensureNotNull)(this._model)}id(){return this._id}layoutId(){return this._layoutId}crossHairSyncEnabled(){return this._chartWidgetCollection.lock.crosshair.value()}isVisible(){return this._isVisible.value()}setVisible(e){this._isVisible.setValue(e)}setCollapsed(e){this._collapsed.setValue(e)}isJustClonedChart(){return!!(this._options||{}).justCloned}getSymbol(e){var t,i,s,r;let n;return n=this._model?this._model.mainSeries().properties().childs():this.properties().childs().mainSeriesProperties.childs(),n?e&&n.shortName&&n.shortName.value()?null!==(i=null===(t=n.shortName)||void 0===t?void 0:t.value())&&void 0!==i?i:"":null!==(r=null===(s=n.symbol)||void 0===s?void 0:s.value())&&void 0!==r?r:"":""}setSymbol(e){this._model?(this._symbolWV.setValue(e),this._model.setSymbol(this._model.mainSeries(),e)):(this.properties().childs().mainSeriesProperties.merge({symbol:e}),this._symbolWV.setValue(e),this._setSymbolIntervalContentOverrides.symbol=e)}setResolution(e){this._model?(this._resolutionWV.setValue(e),this._model.setResolution(this._model.mainSeries(),e)):(this.properties().childs().mainSeriesProperties.merge({interval:e}),this._resolutionWV.setValue(e),this._setSymbolIntervalContentOverrides.interval=e)}getResolution(){return this._model?this._model.mainSeries().properties().childs().interval.value():this.properties().childs().mainSeriesProperties.childs().interval.value()}symbolWV(){return this._symbolWV.readonly()}resolutionWV(){ -return this._resolutionWV.readonly()}loadRange(e){if(this._model){this.screen.show();this._model.loadRange(e)||this.screen.hide()}}async showGeneralChartProperties(e,t){if(!Ae.enabled("show_chart_property_page"))return Promise.resolve(null);const s=await this._showChartProperties(this.model().mainSeries(),e,{doNotCloseOnBgClick:!0,onResetToDefault:async()=>{this.model().restorePreferences();const e=await Promise.resolve().then(i.bind(i,5286)),t=e.getCurrentTheme().name;e.loadTheme(this.chartWidgetCollection(),{themeName:t,standardTheme:!0})},shouldReturnFocus:null==t?void 0:t.shouldReturnFocus});if(null===s)return null;const r=()=>{s.hide(),this._chartWidgetCollection.activeChartWidget.unsubscribe(r)};return this._chartWidgetCollection.activeChartWidget.subscribe(r),s}showChartPropertiesForSource(e,t,i,s){return Ae.enabled("property_pages")&&e.userEditEnabled()?e===this.model().model().mainSeries()?this.showGeneralChartProperties(t):((i=i||{}).onResetToDefault=()=>{((0,V.isLineTool)(e)||(0,B.isStudy)(e))&&this.model().restorePropertiesForSource.bind(this._model,e)},this._showChartProperties(e,t,i,s)):Promise.resolve(null)}async showChartPropertiesForSources(e){if(!(0,Ae.enabled)("property_pages"))return Promise.resolve(null);const{sources:t,title:s,tabName:n,renamable:a}=e,l=(0,r.ensureNotNull)(this._model),c=Zt(t.map((e=>e.properties().childs()))),h=Zt(t.map((e=>e.properties().childs().intervalsVisibilities))),[{createPropertyPage:d},{getSelectionStylePropertiesDefinitions:u},{getSelectionIntervalsVisibilitiesPropertiesDefinition:p},{getSelectionCoordinatesPropertyDefinition:_}]=await Promise.all([Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,73955)),Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,43940)),Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,97456)),Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,41339))]);return async function(e){const{SourcesPropertiesEditorRenderer:t}=await Promise.all([i.e(77),i.e(2666),i.e(1013),i.e(3842),i.e(4015),i.e(5145),i.e(855),i.e(6),i.e(5993),i.e(5649),i.e(2191),i.e(6221),i.e(8056),i.e(2587),i.e(3502),i.e(8149),i.e(2639),i.e(2109),i.e(9842),i.e(4215),i.e(7232),i.e(6625),i.e(9327),i.e(7194),i.e(6884),i.e(2984),i.e(3980),i.e(5403),i.e(3889),i.e(7391),i.e(8904),i.e(962),i.e(8385),i.e(9727),i.e(4403),i.e(4713),i.e(5901),i.e(769),i.e(9795),i.e(4378),i.e(6780)]).then(i.bind(i,66512)),s=new t(e);return null!==li&&(li.hide(),li=s),s.show(),s}({sources:t,propertyPages:[d(u(c,l),"style",o.t(null,void 0,i(32733))),d({definitions:[_(t,l)]},"displacement",o.t(null,void 0,i(62764))),d(p(h,l),"visibility",o.t(null,void 0,i(21852)))],undoModel:l,title:s,activeTabId:n,renamable:a})}getPriceAxisWidthChangedByName(e){return"left"===e?this._lhsPriceAxisWidthChanged:this._rhsPriceAxisWidthChanged}getPriceAxisMaxWidthByName(e){return"left"===e?this._lhsAxesWidth:this._rhsAxesWidth}timeAxisHeight(){return null!==this._timeAxisWidget?this._timeAxisWidget.size.height:0} +return this._resolutionWV.readonly()}loadRange(e){if(this._model){this.screen.show();this._model.loadRange(e)||this.screen.hide()}}async showGeneralChartProperties(e,t){if(!Ae.enabled("show_chart_property_page"))return Promise.resolve(null);const s=await this._showChartProperties(this.model().mainSeries(),e,{doNotCloseOnBgClick:!0,onResetToDefault:async()=>{this.model().restorePreferences();const e=await Promise.resolve().then(i.bind(i,5286)),t=e.getCurrentTheme().name;e.loadTheme(this.chartWidgetCollection(),{themeName:t,standardTheme:!0})},shouldReturnFocus:null==t?void 0:t.shouldReturnFocus});if(null===s)return null;const r=()=>{s.hide(),this._chartWidgetCollection.activeChartWidget.unsubscribe(r)};return this._chartWidgetCollection.activeChartWidget.subscribe(r),s}showChartPropertiesForSource(e,t,i,s){return Ae.enabled("property_pages")&&e.userEditEnabled()?e===this.model().model().mainSeries()?this.showGeneralChartProperties(t):((i=i||{}).onResetToDefault=()=>{((0,E.isLineTool)(e)||(0,B.isStudy)(e))&&this.model().restorePropertiesForSource.bind(this._model,e)},this._showChartProperties(e,t,i,s)):Promise.resolve(null)}async showChartPropertiesForSources(e){if(!(0,Ae.enabled)("property_pages"))return Promise.resolve(null);const{sources:t,title:s,tabName:n,renamable:a}=e,l=(0,r.ensureNotNull)(this._model),c=Zt(t.map((e=>e.properties().childs()))),h=Zt(t.map((e=>e.properties().childs().intervalsVisibilities))),[{createPropertyPage:d},{getSelectionStylePropertiesDefinitions:u},{getSelectionIntervalsVisibilitiesPropertiesDefinition:p},{getSelectionCoordinatesPropertyDefinition:_}]=await Promise.all([Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,73955)),Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,43940)),Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,97456)),Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,41339))]);return async function(e){const{SourcesPropertiesEditorRenderer:t}=await Promise.all([i.e(77),i.e(2666),i.e(1013),i.e(3842),i.e(4015),i.e(5145),i.e(855),i.e(6),i.e(5993),i.e(5649),i.e(2191),i.e(6221),i.e(8056),i.e(2587),i.e(3502),i.e(8149),i.e(2639),i.e(2109),i.e(9842),i.e(4215),i.e(7232),i.e(6625),i.e(9327),i.e(7194),i.e(6884),i.e(2984),i.e(3980),i.e(5403),i.e(3889),i.e(7391),i.e(8904),i.e(962),i.e(8385),i.e(9727),i.e(4403),i.e(4713),i.e(5901),i.e(769),i.e(9795),i.e(4378),i.e(6780)]).then(i.bind(i,66512)),s=new t(e);return null!==li&&(li.hide(),li=s),s.show(),s}({sources:t,propertyPages:[d(u(c,l),"style",o.t(null,void 0,i(32733))),d({definitions:[_(t,l)]},"displacement",o.t(null,void 0,i(62764))),d(p(h,l),"visibility",o.t(null,void 0,i(21852)))],undoModel:l,title:s,activeTabId:n,renamable:a})}getPriceAxisWidthChangedByName(e){return"left"===e?this._lhsPriceAxisWidthChanged:this._rhsPriceAxisWidthChanged}getPriceAxisMaxWidthByName(e){return"left"===e?this._lhsAxesWidth:this._rhsAxesWidth}timeAxisHeight(){return null!==this._timeAxisWidget?this._timeAxisWidget.size.height:0} withModel(e,t){null!==this._model?t.call(e):this.modelCreated().subscribe(e,t,!0)}hasModel(){return null!==this._model}onRedraw(){return this._redraw}copyLineToOtherCharts(){const e=(0,r.ensureNotNull)(this._model),t=e.selection().lineDataSources().filter((e=>e.isSynchronizable()));e.model().copyToOtherCharts(t,!0)}hideDataSources(e){if(e.length){const t=e.map((e=>e.properties().visible)),i=e.map((()=>!1));this.model().setProperties(t,i,Fi.format({title:new z.TranslatedString(e[0].name(),e[0].title(Ri.TitleDisplayTarget.StatusLine))}))}}hideSelectedObject(){this.hideDataSources(this.model().selection().dataSources().filter((e=>!0)))}unlinkSelectedLine(){const e=(0,r.ensureNotNull)(this._model),t=e.selection().lineDataSources();e.unlinkLines(t)}selectPointMode(){return(0,r.ensureNotNull)(this._model).model().selectPointMode()}cancelRequestSelectPoint(){const e=(0,r.ensureNotNull)(this._model);e.model().cancelRequestSelectPoint(),e.model().setReplayStatus(ReplayStatus.Undefined),this.model().model().clearCurrentPosition()}requestSelectPoint(e,t){const i=(0,r.ensureNotNull)(this._model);return e.selectPointMode===K.SelectPointMode.Replay&&i.model().setReplayStatus(ReplayStatus.PointSelect),new Promise(((s,r)=>{const n=()=>!!this.isVisible()||(r("Chartwidget must be visible"),this.cancelRequestSelectPoint(),!1);if(!n())return;(0,K.resetToCursor)(!0),i.lineBeingCreated()&&i.cancelCreatingLine();let o=!1;const a={};i.model().onPointSelected().subscribe(a,((e,t)=>{o=!0,this._isVisible.unsubscribe(n),this._hideHint(),s({point:e,pane:t})}),!0),i.model().requestSelectPoint(e),this.startTrackingMode(),void 0!==t&&this._showHint(t),this._isVisible.subscribe(n),this.selectPointMode().subscribe((()=>{setTimeout((()=>{o||(this.selectPointMode().value()===K.SelectPointMode.None&&this._hideHint(),i.model().onPointSelected().unsubscribeAll(a),this._isVisible.unsubscribe(n),r("cancelled"))}))}),{once:!0})}))}onScroll(){return this._onScroll}onZoom(){return this._onZoom}images(e){window.TradingView.printing=!0;const t=this.model().selection().allSources();this.model().selectionMacro((e=>e.clearSelection())),this.model().model().recalculateAllPanes((0,vt.globalChangeEvent)());const i=(t,i)=>{t.paint(i);const s={showCollapsedStudies:Boolean(null==e?void 0:e.showCollapsedStudies),status:null==e?void 0:e.status};return t.getScreenshotData(s)},s=[];if(null!==this._maximizedPaneWidget){const e=this._paneWidgets.indexOf(this._maximizedPaneWidget);s.push(i(this._maximizedPaneWidget,N.InvalidationMask.light().invalidateForPane(e)))}else for(let e=0;e{t.forEach((t=>{e.addSourceToSelection(t)}))})),this.model().model().recalculateAllPanes((0,vt.globalChangeEvent)()), -this.model().model().lightUpdate();const n=this.mainSeriesQuotesAndMetainfo();return{panes:s,timeAxis:r,colors:{text:this.properties().childs().scalesProperties.childs().textColor.value(),bg:this.properties().childs().paneProperties.childs().background.value(),scales:this.properties().childs().scalesProperties.childs().lineColor.value()},meta:n.meta,ohlc:n.ohlc,quotes:n.quotes}}insertStudy(e,t,i,s){return new Promise((r=>{0!==t.length?window.runOrSignIn((()=>{r(this._insertStudy(e,t,i,s))}),{source:"study on study"}):r(this._insertStudy(e,t,i,s))})).catch((()=>null))}addOverlayStudy(e,t,i){const s=this.model();return this._options&&this._options.isSymbolAvailable?this._options.isSymbolAvailable(e).then((r=>{if(!r)return null;const n=s.createStudyInserter({type:"java",studyId:"Overlay@tv-basicstudies"},[]),o={allowExtendTimeScale:i};if(Ae.enabled("use_overrides_for_overlay")){const e=(0,Ei.factoryDefaults)("study_Overlay@tv-basicstudies.style");o.style=e}return n.setPropertiesState(o),n.setForceOverlay(t),n.insert((()=>Promise.resolve({inputs:{symbol:e},parentSources:[]})))})):Promise.resolve(null)}addCompareStudy(e){const t=this.model();return this._options&&this._options.isSymbolAvailable?this._options.isSymbolAvailable(e).then((i=>i?t.createStudyInserter({type:"java",studyId:"Compare@tv-basicstudies"},[]).insert((()=>Promise.resolve({inputs:{symbol:e},parentSources:[]}))):null)):Promise.resolve(null)}showIndicators(e,t){if(window.studyMarket)return window.studyMarket.visible().value()?void window.studyMarket.hide():(window.studyMarket.show(e,t),window.studyMarket)}setSaveChartService(e){this._saveChartService=e,null!==this._lineToolsSynchronizer&&this._lineToolsSynchronizer.setSaveChartService(e)}getSaveChartService(){return this._saveChartService}mainSeriesQuotesAndMetainfo(){let e,t,i;const s=this._model&&this._model.mainSeries();if(s){const r=e=>null==e?"":s.formatter().format(e,void 0,void 0,!0,!1)+"",n=e=>null==e?"":e+"";e={resolution:s.interval(),symbol:s.symbol(),values:s.valuesProvider().getValues(null)};const o=s.symbolInfo();o&&(e.symbol=o.full_name,e.description=o.description,e.exchange=o.exchange);const a=s.bars().last();null!==a&&(t=a.value.slice(1,5).map(r));const l=s.quotes();l&&(i={change:r(l.change),changePercent:n(l.change_percent),last:r(l.last_price)})}return{meta:e,ohlc:t,quotes:i}}isMultipleLayout(){return this._isMultipleLayout}updateCrossHairPositionIfNeeded(){if(this._model){const e=K.tool.value();this._model.model().setCurrentTool(e);const t=(0,U.lastMouseOrTouchEventInfo)();if(t.isTouch){const e=this._maximizedPaneWidget||this._paneWidgets[0];if(e.hasState()&&(!t.stylus&&(this._isLineToolModeExceptBrush()||(0,K.toolIsMeasure)(K.tool.value()))||this.selectPointMode().value()!==K.SelectPointMode.None)){const t=e.state(),i=.5*this._model.model().timeScale().width(),s=.5*t.defaultPriceScale().height();this._model.model().setAndSaveCurrentPosition(i,s,t)}}if(this._model&&t.isTouch){const e=this._model.model().crossHairSource();e.updateAllViews((0,vt.sourceChangeEvent)(e.id()))}}} +this.model().model().lightUpdate();const n=this.mainSeriesQuotesAndMetainfo();return{panes:s,timeAxis:r,colors:{text:this.properties().childs().scalesProperties.childs().textColor.value(),bg:this.properties().childs().paneProperties.childs().background.value(),scales:this.properties().childs().scalesProperties.childs().lineColor.value()},meta:n.meta,ohlc:n.ohlc,quotes:n.quotes}}insertStudy(e,t,i,s){return new Promise((r=>{0!==t.length?window.runOrSignIn((()=>{r(this._insertStudy(e,t,i,s))}),{source:"study on study"}):r(this._insertStudy(e,t,i,s))})).catch((()=>null))}addOverlayStudy(e,t,i){const s=this.model();return this._options&&this._options.isSymbolAvailable?this._options.isSymbolAvailable(e).then((r=>{if(!r)return null;const n=s.createStudyInserter({type:"java",studyId:"Overlay@tv-basicstudies"},[]),o={allowExtendTimeScale:i};if(Ae.enabled("use_overrides_for_overlay")){const e=(0,Vi.factoryDefaults)("study_Overlay@tv-basicstudies.style");o.style=e}return n.setPropertiesState(o),n.setForceOverlay(t),n.insert((()=>Promise.resolve({inputs:{symbol:e},parentSources:[]})))})):Promise.resolve(null)}addCompareStudy(e){const t=this.model();return this._options&&this._options.isSymbolAvailable?this._options.isSymbolAvailable(e).then((i=>i?t.createStudyInserter({type:"java",studyId:"Compare@tv-basicstudies"},[]).insert((()=>Promise.resolve({inputs:{symbol:e},parentSources:[]}))):null)):Promise.resolve(null)}showIndicators(e,t){if(window.studyMarket)return window.studyMarket.visible().value()?void window.studyMarket.hide():(window.studyMarket.show(e,t),window.studyMarket)}setSaveChartService(e){this._saveChartService=e,null!==this._lineToolsSynchronizer&&this._lineToolsSynchronizer.setSaveChartService(e)}getSaveChartService(){return this._saveChartService}mainSeriesQuotesAndMetainfo(){let e,t,i;const s=this._model&&this._model.mainSeries();if(s){const r=e=>null==e?"":s.formatter().format(e,void 0,void 0,!0,!1)+"",n=e=>null==e?"":e+"";e={resolution:s.interval(),symbol:s.symbol(),values:s.valuesProvider().getValues(null)};const o=s.symbolInfo();o&&(e.symbol=o.full_name,e.description=o.description,e.exchange=o.exchange);const a=s.bars().last();null!==a&&(t=a.value.slice(1,5).map(r));const l=s.quotes();l&&(i={change:r(l.change),changePercent:n(l.change_percent),last:r(l.last_price)})}return{meta:e,ohlc:t,quotes:i}}isMultipleLayout(){return this._isMultipleLayout}updateCrossHairPositionIfNeeded(){if(this._model){const e=K.tool.value();this._model.model().setCurrentTool(e);const t=(0,U.lastMouseOrTouchEventInfo)();if(t.isTouch){const e=this._maximizedPaneWidget||this._paneWidgets[0];if(e.hasState()&&(!t.stylus&&(this._isLineToolModeExceptBrush()||(0,K.toolIsMeasure)(K.tool.value()))||this.selectPointMode().value()!==K.SelectPointMode.None)){const t=e.state(),i=.5*this._model.model().timeScale().width(),s=.5*t.defaultPriceScale().height();this._model.model().setAndSaveCurrentPosition(i,s,t)}}if(this._model&&t.isTouch){const e=this._model.model().crossHairSource();e.updateAllViews((0,vt.sourceChangeEvent)(e.id()))}}} trackingModePaneWidget(){if(!(0,U.lastMouseOrTouchEventInfo)().isTouch)return null;for(const e of this.paneWidgets())if(e.trackingModeEnabled())return e;return null}startTrackingMode(){if((0,U.lastMouseOrTouchEventInfo)().isTouch){this.exitTrackingMode(),this.updateCrossHairPositionIfNeeded();const e=this._maximizedPaneWidget||this._paneWidgets[0],t=this.model().model().crossHairSource().currentPoint();e.startTrackingMode(t,t)}}exitTrackingMode(){(0,U.lastMouseOrTouchEventInfo)().isTouch&&this.paneWidgets().some((e=>e.trackingModeEnabled()))&&(this.paneWidgets().forEach((e=>e.exitTrackingMode())),this.model().model().clearCurrentPosition())}onToolChanged(){this.model().lineBeingCreated()&&this._cancelCreatingLine(),this.selectPointMode().value()!==K.SelectPointMode.None&&this.cancelRequestSelectPoint(),this.exitTrackingMode()}setInLoadingState(e){this._inLoadingState=e}paint(e){const t=null!=e?e:N.InvalidationMask.full();t.validationActions().forEach((e=>e())),this._paneWidgets.forEach(((e,i)=>{null!==this._maximizedPaneWidget&&this._maximizedPaneWidget!==e||e.paint(t.invalidateForPane(i))})),this._timeAxisWidget&&this._timeAxisWidget.paint(t.invalidateForTimeScale()),this._redraw.fire()}GUIResetScales(){(0,Se.trackEvent)("GUI","Reset Scales"),null!==this._model&&this._model.resetScales()}toggleMaximizePane(e){var t;if(!(this._paneWidgets.length<2)){this._maximizedPaneWidget?(this._maximizedPaneWidget.state().maximized().setValue(!1),this._maximizedPaneWidget=null,this._paneSeparators.forEach((e=>e.show()))):(this._maximizedPaneWidget=e,this._maximizedPaneWidget.state().maximized().setValue(!0),this._paneSeparators.forEach((e=>e.hide())));for(let e=this._paneWidgets.length;e--;)this._paneWidgets[e].updateControls(),this._paneWidgets[e].updatePriceAxisWidgetsStates();this._errorRenderer.updatePaneWidgets(),null===(t=this._timeAxisWidget)||void 0===t||t.updatePriceAxisStubs(),this._adjustSize(),this.updateCrossHairPositionIfNeeded()}}maximizedPaneWidget(){return this._maximizedPaneWidget}isMaximizedPane(){return null!==this._maximizedPaneWidget}toggleCollapsedPane(e){const t=e.state();t.collapsed().setValue(!t.collapsed().value()),this._paneWidgets.forEach((e=>e.updateControls())),this._adjustSize(),this.updateCrossHairPositionIfNeeded()}unsetActivePaneWidget(){this.activePaneWidget=null}setActivePaneWidget(e){this.activePaneWidget=e}onPaneWidgetDestroyed(e){this.activePaneWidget===e&&(this.activePaneWidget=null)}backgroundTopTheme(){return this._backgroundTopTheme.readonly()}backgroundBasedTheme(){return this._backgroundBasedTheme.readonly()}backgroundBottomTheme(){return this._backgroundBottomTheme.readonly()}lineToolsAndGroupsDTO(){return(0,r.ensureNotNull)(this._lineToolsSynchronizer).prepareDTO()}resetLineToolsInvalidated(e,t,i){(0,r.ensureNotNull)(this._lineToolsSynchronizer).resetInvalidated(e,t,i)}applyLineToolUpdateNotification(e,t){(0,r.ensureNotNull)(this._lineToolsSynchronizer).applyLineToolUpdateNotification(e,t)}reloadAllLineTools(){(0,r.ensureNotNull)(this._lineToolsSynchronizer).reloadAllLineTools()} -startApplyingLineToolUpdateNotification(){var e;null===(e=this._lineToolsSynchronizer)||void 0===e||e.startApplyingLineToolUpdateNotification()}endApplyingLineToolUpdateNotification(){var e;null===(e=this._lineToolsSynchronizer)||void 0===e||e.endApplyingLineToolUpdateNotification()}applyAlertIdByExternalSource(e,t){var i;null===(i=this._lineToolsSynchronizer)||void 0===i||i.applyAlertIdByExternalSource(e,t)}deleteAlertByExternalSource(e,t){var i;null===(i=this._lineToolsSynchronizer)||void 0===i||i.deleteAlertByExternalSource(e)}shouldBeSavedEvenIfHidden(){return this._model?this.model().model().shouldBeSavedEvenIfHidden():!!this._options.content.shouldBeSavedEvenIfHidden}showObjectsTreeDialog(){var e;null===(e=this._objectTreeDialogController)||void 0===e||e.show()}addCustomWidgetToLegend(e,t){this._customLegendWidgetsFactoryMap.set(e,t);for(const i of this.paneWidgets())i.addCustomWidgetToLegend(e,t)}applyIndicatorsToAllChartsAvailable(){if(!this.chartWidgetCollection().applyIndicatorsToAllChartsAvailable())return!1;for(const e of this.model().model().panes()){if(e.sourcesByGroup().all().some((e=>(0,B.isStudy)(e)&&!0)))return!0}return!1}restoreState(e,t,i){this._adjustSize();const s=(0,r.ensureNotNull)(this._model),n=(s.restoreState(this._content,t,i),s.mainSeries().properties().childs());this._symbolWV.setValue(n.symbol.value()),this._resolutionWV.setValue(n.interval.value()),this._setActions()}addCompareAsOverlay(e,t,i){const s=this.model();return(0,r.ensureDefined)(this._options.isSymbolAvailable)(e).then((r=>{if(!r)return null;const n=s.createStudyInserter({type:"java",studyId:"Overlay@tv-basicstudies"},[]);return n.setForceOverlay(!0),n.setPreferredPriceScale("as-series"),!0!==i&&n.setTargetPriceScaleMode({percentage:!0}),void 0!==t&&n.setPropertiesState({allowExtendTimeScale:t}),n.insert((async()=>({inputs:{symbol:e},parentSources:[]})))}))}scrollHelper(){return this._scrollHelper}setBroker(e){var t;this._brokerName=e,null===(t=this._lineToolsSynchronizer)||void 0===t||t.setBroker(e)}chartPainted(){return this._drawPlanned?(null===this._chartPaintedPromise&&(this._chartPaintedPromise=(0,d.createDeferredPromise)()),this._chartPaintedPromise.promise):Promise.resolve()}setDataWindowWidget(e){this._dataWindowWidget=e}removeDataWindowWidget(){this._dataWindowWidget=null}showSelectedSourcesProperties(e){const t=(0,r.ensureNotNull)(this._model).selection().dataSources();if(1===t.length)this.showSourceProperties(t[0],e);else{const i=t.filter(V.isLineTool);i.length>0&&this.showChartPropertiesForSources({sources:i,tabName:e})}}connect(){this._chartSession.isConnected().subscribe(this._onChartSessionIsConnectedChanged),this._chartSession.criticalError().subscribe(this,this._onChartSessionCriticalError),this._chartSession.connect(this._onData.bind(this))}finishInitWithoutConnect(){this._chartSession.disable(),this._init(),this._chartWidgetInitialized.fire()}reconnect(){this._chartSession.disconnect(),this._chartSession.connect()}update(){if(this.hasModel()){for(const e of this._paneWidgets)e.update() +startApplyingLineToolUpdateNotification(){var e;null===(e=this._lineToolsSynchronizer)||void 0===e||e.startApplyingLineToolUpdateNotification()}endApplyingLineToolUpdateNotification(){var e;null===(e=this._lineToolsSynchronizer)||void 0===e||e.endApplyingLineToolUpdateNotification()}applyAlertIdByExternalSource(e,t){var i;null===(i=this._lineToolsSynchronizer)||void 0===i||i.applyAlertIdByExternalSource(e,t)}deleteAlertByExternalSource(e,t){var i;null===(i=this._lineToolsSynchronizer)||void 0===i||i.deleteAlertByExternalSource(e)}shouldBeSavedEvenIfHidden(){return this._model?this.model().model().shouldBeSavedEvenIfHidden():!!this._options.content.shouldBeSavedEvenIfHidden}showObjectsTreeDialog(){var e;null===(e=this._objectTreeDialogController)||void 0===e||e.show()}addCustomWidgetToLegend(e,t){this._customLegendWidgetsFactoryMap.set(e,t);for(const i of this.paneWidgets())i.addCustomWidgetToLegend(e,t)}applyIndicatorsToAllChartsAvailable(){if(!this.chartWidgetCollection().applyIndicatorsToAllChartsAvailable())return!1;for(const e of this.model().model().panes()){if(e.sourcesByGroup().all().some((e=>(0,B.isStudy)(e)&&!0)))return!0}return!1}restoreState(e,t,i){this._adjustSize();const s=(0,r.ensureNotNull)(this._model),n=(s.restoreState(this._content,t,i),s.mainSeries().properties().childs());this._symbolWV.setValue(n.symbol.value()),this._resolutionWV.setValue(n.interval.value()),this._setActions()}addCompareAsOverlay(e,t,i){const s=this.model();return(0,r.ensureDefined)(this._options.isSymbolAvailable)(e).then((r=>{if(!r)return null;const n=s.createStudyInserter({type:"java",studyId:"Overlay@tv-basicstudies"},[]);return n.setForceOverlay(!0),n.setPreferredPriceScale("as-series"),!0!==i&&n.setTargetPriceScaleMode({percentage:!0}),void 0!==t&&n.setPropertiesState({allowExtendTimeScale:t}),n.insert((async()=>({inputs:{symbol:e},parentSources:[]})))}))}scrollHelper(){return this._scrollHelper}setBroker(e){var t;this._brokerName=e,null===(t=this._lineToolsSynchronizer)||void 0===t||t.setBroker(e)}chartPainted(){return this._drawPlanned?(null===this._chartPaintedPromise&&(this._chartPaintedPromise=(0,d.createDeferredPromise)()),this._chartPaintedPromise.promise):Promise.resolve()}setDataWindowWidget(e){this._dataWindowWidget=e}removeDataWindowWidget(){this._dataWindowWidget=null}showSelectedSourcesProperties(e){const t=(0,r.ensureNotNull)(this._model).selection().dataSources();if(1===t.length)this.showSourceProperties(t[0],e);else{const i=t.filter(E.isLineTool);i.length>0&&this.showChartPropertiesForSources({sources:i,tabName:e})}}connect(){this._chartSession.isConnected().subscribe(this._onChartSessionIsConnectedChanged),this._chartSession.criticalError().subscribe(this,this._onChartSessionCriticalError),this._chartSession.connect(this._onData.bind(this))}finishInitWithoutConnect(){this._chartSession.disable(),this._init(),this._chartWidgetInitialized.fire()}reconnect(){this._chartSession.disconnect(),this._chartSession.connect()}update(){if(this.hasModel()){for(const e of this._paneWidgets)e.update() ;this._timeAxisWidget&&this._timeAxisWidget.update()}}setPriceAxisHovered(e,t){t?this._hoveredPriceAxes.add(e):this._hoveredPriceAxes.delete(e),this._anyAxisHovered.setValue(this._hoveredPriceAxes.size>0)}anyPriceAxisHovered(){return this._anyAxisHovered.readonly()}linkingGroupIndex(){return this._linkingGroupIndex}offsetInDocument(e){const t=this._paneWidgets.find((t=>t.state()===e));if(void 0===t)return{left:NaN,top:NaN};const i=t.getElement().getBoundingClientRect();return{left:Math.round(i.left+document.body.scrollLeft),top:Math.round(i.top+document.body.scrollTop)}}_createShowDataWindowAction(){return this._showDataWindowAction=new C.Action({actionId:"Chart.DataWindow.Show",label:o.t(null,void 0,i(53831)),statName:"DataWindow",hotkeyGroup:this._hotkeys,hotkeyHash:n.Modifiers.Alt+68,icon:dataWindowSvg,onExecute:this._showOrHideDataWindowWidget.bind(this)}),this._showDataWindowAction}_clearSelectionHotkey(){return{desc:"Cancel selection",hotkey:27,handler:()=>{var e;if(this.selectPointMode().value()!==K.SelectPointMode.None)return this.selectPointMode().value()===K.SelectPointMode.Replay&&this._chartWidgetCollection.getAll().forEach((e=>{e!==this&&e.selectPointMode().value()===K.SelectPointMode.Replay&&e.cancelRequestSelectPoint()})),void this.cancelRequestSelectPoint();null===(e=this._model)||void 0===e||e.selectionMacro((e=>{this._cancelCreatingLine(),e.clearSelection()}))},isDisabled:()=>{const e=this._model;if(!e)return!0;const t=0===e.selection().allSources().length,i=null===e.crossHairSource().measurePane().value(),s=this.selectPointMode().value()===K.SelectPointMode.None;return t&&i&&s}}}_insertStudy(e,t,i,s){const n=(0,r.ensureNotNull)(this._model).createStudyInserter(e,t,i);n.setForceOverlay("java"===e.type&&"Volume@tv-basicstudies"===e.studyId&&Ae.enabled("volume_force_overlay"));const o=n.insert(((e,i,r)=>new Promise(((n,o)=>{var a;this.selectPointMode().value()!==K.SelectPointMode.None&&this.cancelRequestSelectPoint(),s?n(s(e,i,r)):!function(e){return zi.includes(e.id)}(r)?(null!=(a=i)?a:[]).some((e=>e.confirm))?((0,Se.trackEvent)("GUI","Confirmation dialogs","Inputs confirmation dialog"),ki(this,e,r,n,o)):n({inputs:{},parentSources:t}):((0,Se.trackEvent)("GUI","Confirmation dialogs","Symbol confirmation dialog"),ki(this,e,r,n,o,"symbol"))}))));return o.then((()=>{(0,K.hideAllIndicators)().value()&&(0,H.toggleHideMode)()})).catch((e=>{})),o}async _showChartProperties(e,t,i,s){if(!this._model)return null;t&&((0,c.setValue)("properties_dialog.active_tab.chart",t),i.tabName=t);const r=await _i(e,this._model,i,this._options.chartWidgetCollection,s);return(null==r?void 0:r.visible().value())?r:null}_createLineToolsSynchronizerIfNeeded(){}_updateThemedColor(){const e=this.model().model(),t=e.backgroundColorAtYPercentFromTop(.5);let i=e.backgroundTopColor().value(),s=e.backgroundColor().value();const r=(0,Xt.isColorDark)(t),n=(0,Xt.isColorDark)(i),o=(0,Xt.isColorDark)(s);this.widget().classList.toggle("chart-widget--themed-dark",r),this.widget().classList.toggle("chart-widget--themed-light",!r), -this.widget().classList.toggle("chart-widget__top--themed-dark",n),this.widget().classList.toggle("chart-widget__top--themed-light",!n),this.widget().classList.toggle("chart-widget__bottom--themed-dark",o),this.widget().classList.toggle("chart-widget__bottom--themed-light",!o),this._backgroundTopTheme.setValue(n?"dark":"light"),this._backgroundBasedTheme.setValue(r?"dark":"light"),this._backgroundBottomTheme.setValue(o?"dark":"light"),i===s&&(0,te.isStdThemedDefaultValue)("chartProperties.paneProperties.background",i,this._backgroundBasedTheme.value())&&(i=null,s=null);for(const e of this._paneWidgets)e.updateThemedColors({topColor:i,bottomColor:s})}_isLineToolModeExceptBrush(){const e=K.tool.value();return(0,E.isLineToolName)(e)&&!(0,E.isLineDrawnWithPressedButton)(e)&&this.selectPointMode().value()===K.SelectPointMode.None}_cancelCreatingLine(){const e=(0,r.ensureNotNull)(this._model).model(),t=e.lineBeingCreated();if(null!==t){const i=(0,r.ensureNotNull)(e.paneForSource(t));(0,r.ensureNotNull)(this.paneByState(i)).cancelCreatingLineTool(),t.toolname===K.tool.value()&&(0,K.resetToCursor)()}const i=e.crossHairSource().measurePane().value();if(null!==i){(0,r.ensureNotNull)(this.paneByState(i)).cancelMeasuring()}}_adjustSize(e){var t;let i=0;const r=null===this._model?null:this._model.model().priceScaleSlotsCount(),n=new Uint32Array(null===r?0:r.left),o=new Uint32Array(null===r?0:r.right),a=(0,ge.getCanvasDevicePixelRatio)(document.body),l=(e,t)=>e+t,c=(e,t)=>{t.forEach(((t,i)=>{e[i]=Math.max(e[i],t)}))},h=this._width(),d=this._height(),p=this._paneSeparators.length,_=this.isMaximizedPane()?0:zt.height()*p,m=null!==this._timeAxisWidget?this._timeAxisWidget.optimalHeight():0;let g=d-m>=61?m:0;g%2&&(g+=1);const f=Math.max(1,Math.floor((d-_-g)/this._paneWidgets.length));let v=0,S=null;for(const e of this._paneWidgets)if(!this._maximizedPaneWidget||this._maximizedPaneWidget===e){e.leftPriceAxisesContainer().updateCurrencyLabels();const t=e.leftPriceAxisesContainer().optimalWidths();e.rightPriceAxisesContainer().updateCurrencyLabels();const s=e.rightPriceAxisesContainer().optimalWidths();c(n,t),c(o,s),this._maximizedPaneWidget!==e&&e.state().collapsed().value()?v+=Math.min(f,e.collapsedHeight()):(i+=e.stretchFactor(),S=e)}let y=n.reduce(l,0),b=o.reduce(l,0),w=Math.max(h-y-b,0);if(w<=102){y=0,b=0,w=h;for(let e=0;ee+t,c=(e,t)=>{t.forEach(((t,i)=>{e[i]=Math.max(e[i],t)}))},h=this._width(),d=this._height(),p=this._paneSeparators.length,_=this.isMaximizedPane()?0:zt.height()*p,m=null!==this._timeAxisWidget?this._timeAxisWidget.optimalHeight():0;let g=d-m>=61?m:0;g%2&&(g+=1);const f=Math.max(1,Math.floor((d-_-g)/this._paneWidgets.length));let v=0,S=null;for(const e of this._paneWidgets)if(!this._maximizedPaneWidget||this._maximizedPaneWidget===e){e.leftPriceAxisesContainer().updateCurrencyLabels();const t=e.leftPriceAxisesContainer().optimalWidths();e.rightPriceAxisesContainer().updateCurrencyLabels();const s=e.rightPriceAxisesContainer().optimalWidths();c(n,t),c(o,s),this._maximizedPaneWidget!==e&&e.state().collapsed().value()?v+=Math.min(f,e.collapsedHeight()):(i+=e.stretchFactor(),S=e)}let y=n.reduce(l,0),b=o.reduce(l,0),w=Math.max(h-y-b,0);if(w<=102){y=0,b=0,w=h;for(let e=0;e0){const e=new zt(this,r-1,r);this._paneSeparators.push(e),this._timeAxisWidget?this._elMainTable.insertBefore(e.getElement(),this._timeAxisWidget.getElement()):this._elMainTable.appendChild(e.getElement())}this._timeAxisWidget?this._elMainTable.insertBefore(i.getElement(),this._timeAxisWidget.getElement()):this._elMainTable.appendChild(i.getElement())}for(let i=0;iN.InvalidationLevel.Cursor&&(null===(i=this._timeAxisWidget)||void 0===i||i.update(),this._paneWidgets.forEach((e=>{e.updatePriceAxisWidgets()})),this._applyTimeScaleInvalidations(e,t),(null===(s=this._invalidationMask)||void 0===s?void 0:s.fullInvalidation())===N.InvalidationLevel.Full&&(this._invalidationMask.merge(e),this._adjustSize(this._invalidationMask.isVisibleTimeRangeLockedOnResize()),this._applyTimeScaleInvalidations(this._invalidationMask,t),e=this._invalidationMask,this._invalidationMask=null)),this.paint(e),this._dataWindowWidget){const t=e.maxPaneInvalidation();t===N.InvalidationLevel.Full?this._dataWindowWidget.fullUpdate():t>N.InvalidationLevel.None&&this._dataWindowWidget.update()}for(let t=0;t{i.appendChild(s),s.addEventListener("mousedown",this._beginRequestActive.bind(this)),s.addEventListener("mouseup",this._endRequestActive.bind(this)),s.addEventListener("touchstart",this._beginRequestActive.bind(this)),s.addEventListener("touchmove",this._endRequestActive.bind(this)),s.addEventListener("touchend",this._endRequestActive.bind(this)),s.addEventListener("click",this._requestActive.bind(this))})),this._inited&&(null!==this._timeAxisWidget&&(this._timeAxisWidget.destroy(),this._timeAxisWidget=null),this._paneWidgets.forEach((e=>{e.destroy()})),this._paneWidgets.length=0,this._paneSeparators.forEach((e=>{e.destroy()})),this._paneSeparators.length=0,this._update(N.InvalidationMask.full(),performance.now()))}_init(){this.hasModel()&&this.model().mainSeries().clearData(),this._initColors(),this._makeDefaultGui();this._makeDefaultModel(),(()=>{this._checkObsoleteTimezone(),this._chartSession&&this._chartSession.connected()&&this.model().model().restart(),this._content&&(this._initColors(),this._updateGui(),this.update()),this._resizeHandler=()=>{this._invalidationHandler(N.InvalidationMask.full())},this._resizeHandler(),(0,r.ensureNotNull)(this._parent).appendChild((0,r.ensureNotNull)(this._mainDiv)),this._spinner&&(this._spinner.stop(),this._spinner=null),this._keydownEventListener=e=>{27===e.which&&e.preventDefault()},window.addEventListener("keydown:chart_"+this._id,this._keydownEventListener),this._activateSymbolSearchHotkeys(),this.model().timeScale().onScroll().subscribe(this,(()=>this._onScroll.fire())),this._inited=!0})()}_makeDefaultModel(){let e;if(this._content&&this._content.timeScale.points){const t=this._content.timeScale.points.items[0];e={startDate:t}}if(!(0,r.ensureNotNull)(this._metaInfoRepository).getInternalMetaInfoArray())throw new Error("Cannot create chart model: studies metainfo is absent");const t=()=>{var t,i;const s={readOnly:this.readOnly(),isSnapshot:!!this._containsData,...l(this._options,["timeScale","crossHair","chartEventsEnabled","esdEnabled","latestUpdatesEnabled","continuousContractSwitchesEnabled","futuresContractExpirationEnabled","countdownEnabled","lastPriceAnimationEnabled","currencyConversionEnabled","unitConversionEnabled","watermarkEnabled","shiftVisibleRangeOnNewBar","hideIdeas","onWidget"])},n=function(e,t,i,s,r,n,o,a,l,c,h,d){const u=new P.ChartUndoModel(e,t,i,s,r,n,o,a,l,c,h,d);return u.model().fullUpdate(),u}(this._chartSession,this._invalidationHandler,this.properties(),e,(0, r.ensureNotNull)(this._metaInfoRepository),this,this._options.undoHistory,this._options.barsMarksContainersFactory,s,this._collapsed,this._linkingGroupIndex,null!==(i=null===(t=this._saveChartService)||void 0===t?void 0:t.autoSaveEnabled())&&void 0!==i?i:new fe.WatchedValue(!0));return this._createSessions(n.model()),n};(0,Ae.enabled)("lean_chart_load")?this._model=this._model||t():this._model=t(),this._model.model().setChartSaveTime(1e3*this._chartWidgetCollection.metaInfo.lastModified.value()),this._createVolumeIfNeeded();if(this._content){let e=this._setSymbolIntervalContentOverrides;Oi&&this._initialLoading&&(e={...e,symbol:this._defSymbol,interval:this._defInterval,style:this._defStyle}),this.restoreState(this._content,this._containsData,e),this._setSymbolIntervalContentOverrides={},Oi&&this._defSymbol&&this.model().model().recalculatePriceRangeOnce()}else this._setActions();this._createLineToolsSynchronizerIfNeeded(),(()=>{const e=(0,r.ensureNotNull)(this._model);e.onTagsChanged().subscribe(this,(()=>this.onModelTagsChanged())),this._initBackgroundColor(),this._updateGui(),this._modelCreated.fire(e),this._tagsChanged.fire(),Ae.enabled("determine_first_data_request_size_using_visible_range")&&this._setFirstRequestNumbarsUsingTimeframeAndInterval(e);const t=e.mainSeries(),i=t.properties().childs();this._defTimeframe&&t.setDefaultTimeframe(this._defTimeframe),t.dataEvents().symbolNotPermitted().subscribe(null,(e=>t.setSymbolParams({symbol:e}))),this._symbolWV.setValue(i.symbol.value()),i.symbol.subscribe(this,(e=>this._symbolWV.setValue(e.value()))),this._resolutionWV.setValue(i.interval.value()),i.interval.subscribe(this,(e=>this._resolutionWV.setValue(e.value()))),i.style.unsubscribe(this,this._onChartStyleChanged),i.style.subscribe(this,this._onChartStyleChanged),t.dataEvents().completed().subscribe(this,(()=>this._addPerfMark("SeriesCompleted")),!0),t.dataEvents().barReceived().subscribe(this,(()=>this._addPerfMark("SeriesFirstDataReceived")),!0);this._options;t.dataEvents().chartTypeNotPermitted().subscribe(null,(()=>{t.setSymbolParams({interval:"D"})})),t.dataEvents().intradaySpreadNotPermitted().subscribe(null,(()=>{t.setSymbolParams({interval:"D"})})),t.dataEvents().customIntervalNotPermitted().subscribe(null,(i=>{const s=e.model().defaultResolutions(),r=s.find((e=>(0,oi.compareResolutions)(e,i)>=0)),n=null!=r?r:s[s.length-1];t.setSymbolParams({interval:n})})),t.dataEvents().intradayExchangeNotPermitted().subscribe(null,(()=>{t.setSymbolParams({interval:"D"})})),t.requestingStyleIsNotSupported.subscribe(null,(()=>{const i=t.interval(),s=e.model().defaultResolutions(),r=(0,ni.getLastUsedSingleValueBasedStyle)(),n=(0,oi.getResolutionByChartStyle)(r,i,s);t.setChartStyleWithIntervalIfNeeded(r,n)})),t.requestingStyleSupportRecovered.subscribe(null,(i=>{const s=t.interval(),r=e.model().defaultResolutions(),n=(0,oi.getResolutionByChartStyle)(i,s,r);t.setChartStyleWithIntervalIfNeeded(i,n)}))})()}_startSpinner(e){this._spinner||e&&(this._spinner=(new S).spin(e))}_handleLoginStateChanged(){0} _checkObsoleteTimezone(){const e=this.properties().childs().timezone.value();(0,mi.timezoneIsAvailable)(e)||this.properties().childs().timezone.setValue({UTC:"Etc/UTC",EST:"America/New_York",CST:"America/Chicago",PST:"America/Los_Angeles"}[e]||"exchange")}_initColors(){const e=this.properties().childs(),t=e.scalesProperties.childs();t.lineColor.listeners().subscribe(this,this._updateAndPaint),t.textColor.listeners().subscribe(this,this._updateAndPaint),e.paneProperties.childs().separatorColor.listeners().subscribe(this,this._setPaneSeparatorLineColor)}_setPaneSeparatorLineColor(){this._paneSeparators.forEach((e=>e.update())),this._updateAndPaint()}_updateAndPaint(){this.update(),this.paint()}_makeDefaultGui(){this._makeLoadingScreen(),this.hasModel()&&(this._makeTimeAxisWidget(),this._makePaneWidgetsAndSeparators()),this._adjustSize(),this._updateScalesActions(),(0,J.disableSelection)(this._elMainTable),this._updateAndPaint()}_makeLoadingScreen(){if(Ae.enabled("lean_chart_load")){if(this.screen)return;this.screen=new yi(this,(0,r.ensureNotNull)(this._parent))}else this.screen=new yi(this,(0,r.ensureNotNull)(this._mainDiv))}_makeAvailableOnTVPopup(){throw new Error("Not implemented")}_activateSymbolSearchHotkeys(){this.readOnly()||this._options.hideSymbolSearch||(0,gi.activateKeyPressHandler)()}_makeTimeAxisWidget(){if(this._timeAxisWidget)return void this._timeAxisWidget.updatePriceAxisStubs();const e=this.model();this._timeAxisWidget=new Yt(this,this._options.timeScaleWidget,this._titlesProvider.bind(this),this._menuItemsProvider.bind(this),this._backgroundBasedTheme),this._elMainTable.appendChild(this._timeAxisWidget.getElement()),this._timeAxisWidget.updatePriceAxisStubs(),this._timeAxisWidget.onLabelHovered().subscribe(this,((t,i)=>{const s=this._maximizedPaneWidget?this._maximizedPaneWidget.state():e.paneForSource(e.mainSeries()),n=(0,r.ensureNotNull)(this.paneByState((0,r.ensureNotNull)(s))).highlightedPriceAxis(),o=n.value();(i||o.owner===t.owner)&&(n.setValue({owner:t.owner,axis:i?t.axis:null}),this.model().model().lightUpdate())}))}_titlesProvider(e,t){const i=this.model(),s=(0,r.ensureNotNull)(this._maximizedPaneWidget?this._maximizedPaneWidget.state():i.paneForSource(i.mainSeries())),n="right"===e?s.rightPriceScales():s.leftPriceScales();if(n.lengthe===i.mainSeries()||(0,B.isStudy)(e)));return o.reverse(),o=(0,bi.moveToHead)(o,i.mainSeries()),o.map((e=>e.title(Ri.TitleDisplayTarget.StatusLine,!0,void 0,!1)))}_menuItemsProvider(e,t){const i=this.model(),s=(0,r.ensureNotNull)(this._maximizedPaneWidget?this._maximizedPaneWidget.state():i.paneForSource(i.mainSeries())),n="right"===e?s.visibleRightPriceScales():s.visibleLeftPriceScales();if(n.length{const i=this._model;if(null===i)return;const s=i.model();e.model!==s&&(this._lineToolsSynchronizer?this._lineToolsSynchronizer.executeSyncedAction((()=>t(s,i))):t(s,i))};K.createdLineTool.subscribe(null,(t=>{e(t,((e,i)=>{const s=(0,r.ensureNotNull)(e.paneForSource(e.mainSeries()));let n,o=null;if(void 0===t.pointPositionPercents){if(o=Hi(e,t.model,t.point.timeStamp),null===o)return;n=t.point.price}else{const i=t.pointPositionPercents.x*e.timeScale().width(),s=e.mainSeries().priceScale(),r=t.pointPositionPercents.y*s.height(),a=e.mainSeries().firstValue();if(null===a)return;o=e.timeScale().coordinateToIndex(i),n=s.coordinateToPrice(r,a)}const a={index:(0,r.ensureNotNull)(o),price:n},l=i.createLineTool({pane:s,point:a,linetool:t.linetool,properties:t.properties,linkKey:t.linkKey,ownerSource:e.mainSeries(),disableSynchronization:!0,id:t.id,sharingMode:t.sharingMode});null!==l&&!Boolean(this.model().lineBeingCreated())&&t.finalState&&l.restoreExternalPoints(t.finalState,{indexesChanged:!0,pricesChanged:!0})}))})),K.continuedLineTool.subscribe(null,(t=>{e(t,((e,i)=>{var s;const r=Hi(e,t.model,t.point.timeStamp) -;if(null===r)return;const n={index:r,price:t.point.price},o=e.lineBeingCreated();if(null===o)return;i.continueExternalLine(n,null!==(s=t.envState)&&void 0!==s?s:void 0,!!t.finalState)&&t.finalState&&o.restoreExternalPoints(t.finalState,{indexesChanged:!0,pricesChanged:!0})}))})),K.cancelledLineTool.subscribe(null,(t=>{e(t,((e,t)=>{e.cancelCreatingLine()}))})),K.beenSetLineToolLastPoint.subscribe(null,(t=>{e(t,((e,i)=>{const s=e.lineBeingCreated();if(null===s||s.linkKey().value()!==t.linkKey)return;const r=Hi(e,t.model,t.point.timeStamp);if(null===r)return;const n={index:r,price:t.point.price};s.setLastPoint(n),s.updateAllViews((0,vt.sourceChangeEvent)(s.id())),e.lightUpdate()}))})),K.startedMovingLineTool.subscribe(null,(t=>{e(t,((e,i)=>{var s;const r=t.linkKeys.map(V.lineToolByLinkKey.bind(null,e)).filter(y.notNull);if(r.length){const i=Hi(e,t.model,t.point.timeStamp);if(null===i)return;const n={index:i,price:t.point.price},o=null!==(s=t.activeItem)&&void 0!==s?s:null,a=r[0].pointToScreenPoint(n);a&&e.startMovingSources(r,{logical:n,screen:a},o,t.pointPositionPercents,null===t.envState?void 0:t.envState,!0)}}))})),K.movedLineTool.subscribe(null,(t=>{e(t,((e,i)=>{var s;const r=e.sourcesBeingMoved().filter(V.isLineTool).filter((e=>(e=>t.linkKeys.some((t=>e.linkKey().value()===t)))(e)));if(!r.length)return;const n=Hi(e,t.model,t.point.timeStamp);if(null===n)return;const o={index:n,price:t.point.price},a=r[0].pointToScreenPoint(o);a&&e.moveSources({logical:o,screen:a},t.pointPositionPercents,null!==(s=t.envState)&&void 0!==s?s:void 0,!0)}))})),K.finishedMovingLineTool.subscribe(null,(t=>{e(t,((e,i)=>{const s=e.sourcesBeingMoved().filter(V.isLineTool);if(0===s.length)return;s.forEach((i=>{const s=(e=>{for(let i=0;i{e(t,((e,i)=>{var s;const r=(0,V.lineToolByLinkKey)(e,t.linkKey);if(null!==r){const i=r.getPoint(t.pointIndex),n=i?i.index:Hi(e,t.model,t.point.timeStamp);if(null===n)return;if(r.isActualSymbol()&&r.isActualCurrency()&&r.isActualUnit()){const i={index:n,price:t.point.price};e.startChangingLinetool(r,i,t.pointIndex,null!==(s=t.envState)&&void 0!==s?s:void 0,!0)}}}))})),K.changedLineTool.subscribe(null,(t=>{e(t,((e,i)=>{const s=e.lineBeingEdited();if(null===s||s.linkKey().value()!==t.linkKey)return;let n=null;if(n=t.changes.indexesChanged?Hi(e,t.model,t.point.timeStamp):(0,r.ensureNotNull)(e.linePointBeingChanged()).index,null!==n&&s.isActualSymbol()&&s.isActualCurrency()&&s.isActualUnit()){const i={index:n,price:t.point.price};e.changeLinePoint(i,void 0,!0)}}))})),K.finishedChangingLineTool.subscribe(null,(t=>{e(t,((e,i)=>{const s=(0,V.lineToolByLinkKey)(e,t.linkKey) -;null!==s&&s.isActualSymbol()&&s.isActualCurrency()&&s.isActualUnit()&&null!==e.lineBeingEdited()&&e.endChangingLinetool(!!t.finalState,!0),null!==s&&t.finalState&&s.restoreExternalPoints(t.finalState,t.changes)}))})),K.removedLineTool.subscribe(null,(t=>{e(t,((e,i)=>{const{withUndo:s,unlink:r,linkKey:n}=t,o=(0,V.lineToolByLinkKey)(e,n);if(null!==o)r&&o.detachAlert(),s?i.removeSource(o,!1):(e.lineToolsGroupModel().removeLineTools([o]),e.removeSource(o));else if(this._lineToolsSynchronizer){const{sourceTitle:e,symbol:o,lineToolState:a}=t;i.removeUnloadedLineTool({state:a,unlink:r,sourceTitle:e,linkKey:n,symbol:o,withUndo:s})}}))})),K.finishedLineTool.subscribe(null,(t=>{e(t,((e,i)=>{const s=(0,V.lineToolByLinkKey)(e,t.linkKey);null!==s&&(0,E.isLineToolFinishRequiredWhenCreatedByApi)(s.toolname)&&s.finish()}))})),K.changedLineStyle.subscribe(null,(t=>{e(t,((e,i)=>{const s=(0,V.lineToolByLinkKey)(e,t.linkKey);null!==s&&(s.restoreExternalState(t.state),s.propertiesChanged(!0),t.alertId&&s.syncAlert(t.alertId))}))})),K.restoredLineToolState.subscribe(null,(t=>{e(t,((e,i)=>{const s=(0,V.lineToolByLinkKey)(e,t.linkKey);if(null!==s){const i={...t.state};i.indexes=t.state.points.map((i=>({index:Hi(e,t.model,i.time_t),price:i.price}))),e.restoreLineToolState(s,i,!1)}}))})),K.restoredLineTool.subscribe(null,(t=>{e(t,((e,i)=>{e.restoreSource(t.state.restorePane,t.state.paneIndex,t.state.paneState,t.state.sourceState,null)}))})),K.copiedLineTool.subscribe(null,(t=>{e(t,((e,i)=>{const s=(0,r.ensureNotNull)(e.paneForSource(e.mainSeries()));let n;const o={...t.state,intervalsVisibilities:(0,wi.mergeIntervalVisibilitiesDefaults)(t.state.intervalsVisibilities)},a=(0,V.createLineToolProperties)(t.linetool,o,e),l=e.dataSourceForId(t.id);if(l){if(!(0,V.isLineTool)(l))return void Ni.logError(`Error sync creating line tool. Object with id ${t.id} is already in use and it is not a line tool`);if(l.toolname!==t.linetool)return void Ni.logError(`Error sync creating line tool. Object with id ${t.id} is already in use and its type differs: ${l.toolname} and ${t.linetool}`)}if(l&&(l.linkKey().setValue(t.linkKey),l.share(t.sharingMode)),t.pointPositionPercents){const e={index:0,price:0};if(n=null!=l?l:i.createLineTool({pane:s,point:e,linetool:t.linetool,properties:a,linkKey:t.linkKey,disableSynchronization:!0,id:t.id}),null===n)return;n.restorePositionPercents((0,r.ensureDefined)(t.pointPositionPercents))}else{const o=t.points.map((i=>({index:(0,r.ensureNotNull)(Hi(e,t.model,i.timeStamp)),price:i.price}))),c=o[0];if(l)n=l;else if(t.withUndo)n=i.createLineTool({pane:s,point:c,linetool:t.linetool,properties:a,linkKey:t.linkKey,sharingMode:t.sharingMode,disableSynchronization:!0,id:t.id});else{const e=new w.CreateLineToolUndoCommand({model:i.model(),pane:s,lineTool:t.linetool,ownerSource:(0,r.ensureNotNull)(s.mainDataSource()),drawOnAllChartsMode:t.sharingMode,id:t.id});e.redo(),e.startCreatingLine(c,a,t.linkKey||null,t.sharingMode),n=(0,r.ensureNotNull)(e.line())}if(null===n)return -;if(e.lineBeingCreated())for(let e=1;e0){const i=Math.ceil(e.timeScale().width()/t.barCount);e.timeScale().setBarSpacing(i)}}_showOrHideDataWindowWidget(){const e=window.widgetbar,t=null==e?void 0:e.layout;if(!t)return;const i=t.getActivePage();i&&"data-window"===i.name||(t.setMinimizedState(!1),e.setPage("data-window"))}_createHint(){if(null===this._hintDefferedPromise){const e=(0,d.createDeferredPromise)();this._hintDefferedPromise=e,Promise.all([i.e(6214),i.e(962),i.e(6166)]).then(i.bind(i,5015)).then((t=>{ -e.resolve(new t.ChartEventHintRenderer(this._chartWidgetCollection.getContainer()))}))}return this._hintDefferedPromise?(0,r.ensureDefined)(this._hintDefferedPromise).promise:null}_showHint(e){if(Ae.enabled("popup_hints"))if(null!==this._activeHint)this._activeHint.show(e);else{const t=this._createHint();null!==t&&t.then((t=>{if(null!==t){if(this._activeHint=t,void 0===e)return;this._activeHint.show(e)}}))}}_hideHint(){null!==this._activeHint&&this._activeHint.hide()}}},55148:(e,t,i)=>{"use strict";i.r(t),i.d(t,{activeLinkingGroupWV:()=>gi,allInitialModelsCreated:()=>ei,allInitialSymbolsResolved:()=>Qt,allLinkingGroupsWV:()=>vi,applyIndicatorToAllChartsImpl:()=>ut,applyIndicatorsToAllChartsImpl:()=>dt,applyLineToolUpdateNotificationImpl:()=>yt,applyThemeImpl:()=>si,chartsSymbolsImpl:()=>Pt,checkProFeatureImpl:()=>ti,combinedTrackTimeLock:()=>Pi,computeContentBoxImpl:()=>Vt,copyScreenshotToClipboard:()=>Mt,createBroadcastChannel:()=>Zt,createChartStorageSubscriptionsIfRequired:()=>Ct,createClipboardHandler:()=>bt,createLeftBottomChartWidgetWV:()=>At,deserializedChartIds:()=>vt,destroyBroadcastChannel:()=>Xt,downloadScreenshot:()=>It,generateNewChartId:()=>Wt,getAllLinkingGroups:()=>fi,getAsyncStateForChartImpl:()=>gt,getChartWidgetsForIntervalLock:()=>_i,getClientSnapshot:()=>Dt,getLinkingGroupCharts:()=>Si,getSnapshot:()=>kt,getStateForChartImpl:()=>mt,getVisuallyAdjacentDefImpl:()=>Ot,handleConnectionLimitReachedChanged:()=>bi,handleDateRangeLockChange:()=>ci,handleInternalDateRangeLockChange:()=>li,handleInternalIntervalLockChange:()=>oi,handleInternalSymbolLockChange:()=>ri,handleInternalTrackTimeLockChange:()=>hi,handleIntervalLockChange:()=>ai,handleSymbolLockChange:()=>ni,handleTrackTimeLockChange:()=>di,hideChartImpl:()=>jt,isFirstChartInLayout:()=>ft,lineToolsAndGroupsDTOsImpl:()=>_t,removeChartWidgetSubscriptionsImpl:()=>Gt,resetLineToolsInvalidatedImpl:()=>St,setBrokerImpl:()=>wt,setChartLayoutWithUndoImpl:()=>ii,setLayoutImpl:()=>$t,setResolution:()=>mi,setSymbol:()=>ui,setSymbolAll:()=>pi,someOfWidgetsAreInSelectingReplayPointMode:()=>wi,syncCrosshairImpl:()=>Kt,syncScrollImpl:()=>Jt,takeScreenshot:()=>xt,takeServerScreenshot:()=>Tt,updateLayoutImpl:()=>Nt,updateLayoutPartialImpl:()=>Rt,updateLinkingGroupCharts:()=>yi});var s=i(50151),r=i(86441),n=i(59224),o=i(44352),a=i(69109),l=i(49483),c=i(36298),h=i(14483);function d(e){const t={};return{promise:new Promise(((i,s)=>{e.subscribe(t,i,!0)})),destroy:()=>{e.unsubscribeAll(t)}}}var u=i(97145),p=(i(98310),i(62591));class _ extends p.UndoCommand{constructor(e,t){super(null),this._chartModel=e,this._targetIndex=t}redo(){const e=this._chartModel.createPane(this._targetIndex,void 0,this._paneId);this._paneId=e.id()}undo(){const e=(0,s.ensureDefined)(this._paneId),t=this._chartModel.panes().find((t=>t.id()===e));void 0!==t&&this._chartModel.removePane(t)}createdPaneId(){return this._paneId}}class m extends p.UndoCommand{constructor(e,t,i,s){super(s),this._setter=e,this._oldValue=t,this._newValue=i}redo(){this._setter(this._newValue)}undo(){ +!this._inLoadingState){if(this._invalidationMask){const t=this._invalidationMask;this._invalidationMask=null,this._update(t,e);for(const i of t.timeScaleInvalidations())if(0===i.type&&!i.value.finished(e)){this.model().model().setTimeScaleAnimation(i.value);break}}null!==this._chartPaintedPromise&&(this._chartPaintedPromise.resolve(),this._chartPaintedPromise=null)}}_applyTimeScaleInvalidations(e,t){for(const i of e.timeScaleInvalidations())this._applyTimeScaleInvalidation(i,t)}_applyTimeScaleInvalidation(e,t){var i;const s=null===(i=this._model)||void 0===i?void 0:i.timeScale();if(s&&0===e.type)e.value.finished(t)||s.setRightOffset(e.value.getPosition(t))}_onChartSessionCriticalError(e,t){this._disconnected.fire(!0)}_onData(e){if("reconnect_bailout"===e.method)this._reconnectBailout.fire();else this.model().model().onData(e)}_onConnection(){this.hasModel()?(this.model().model().restart(),this.model().model().fullUpdate(),this._connected.fire()):this._requestMetadata()}_onDisconnect(){this.hasModel()&&this.model().model().disconnect(),this._model&&this._model.model().fullUpdate(),this._disconnected.fire()}async _requestMetadata(){this._addPerfMark("RequestMetadataStart");const e=(0,r.ensureNotNull)(this._metaInfoRepository);await e.requestMetaInfo(),this._addPerfMark("RequestMetadataEnd"),this._inited?this.model().model().setStudiesMetaData(e.getInternalMetaInfoArray(),e.getMigrations()):(await(0,E.initAllLineToolsFromContent)(this._content),this._init(),this._chartWidgetInitialized.fire(),Ae.enabled("charting_library_base")||Ni.logDebug("initialized"))}async _createControlBar(){const e=await Promise.all([i.e(2521),i.e(9842),i.e(9322),i.e(306),i.e(5093)]).then(i.bind(i,33283));this._controlBarNavigation=new e.ControlBarNavigation(this,(0,r.ensureNotNull)(this._mainDiv),this._options.controlBar),this._model&&this._adjustSize()}_subscribeToDrawingState(){if(this._options.readOnly)return;(0,K.init)();const e=(e,t)=>{const i=this._model;if(null===i)return;const s=i.model();e.model!==s&&(this._lineToolsSynchronizer?this._lineToolsSynchronizer.executeSyncedAction((()=>t(s,i))):t(s,i))};K.createdLineTool.subscribe(null,(t=>{e(t,((e,i)=>{const s=(0,r.ensureNotNull)(e.paneForSource(e.mainSeries()));let n,o=null;if(void 0===t.pointPositionPercents){if(o=Hi(e,t.model,t.point.timeStamp),null===o)return;n=t.point.price}else{const i=t.pointPositionPercents.x*e.timeScale().width(),s=e.mainSeries().priceScale(),r=t.pointPositionPercents.y*s.height(),a=e.mainSeries().firstValue();if(null===a)return;o=e.timeScale().coordinateToIndex(i),n=s.coordinateToPrice(r,a)}const a={index:(0,r.ensureNotNull)(o),price:n},l=i.createLineTool({pane:s,point:a,linetool:t.linetool,properties:t.properties,linkKey:t.linkKey,ownerSource:e.mainSeries(),disableSynchronization:!0,id:t.id,sharingMode:t.sharingMode});null!==l&&!Boolean(this.model().lineBeingCreated())&&t.finalState&&l.restoreExternalPoints(t.finalState,{indexesChanged:!0,pricesChanged:!0})}))})),K.continuedLineTool.subscribe(null,(t=>{e(t,((e,i)=>{var s;const r=Hi(e,t.model,t.point.timeStamp) +;if(null===r)return;const n={index:r,price:t.point.price},o=e.lineBeingCreated();if(null===o)return;i.continueExternalLine(n,null!==(s=t.envState)&&void 0!==s?s:void 0,!!t.finalState)&&t.finalState&&o.restoreExternalPoints(t.finalState,{indexesChanged:!0,pricesChanged:!0})}))})),K.cancelledLineTool.subscribe(null,(t=>{e(t,((e,t)=>{e.cancelCreatingLine()}))})),K.beenSetLineToolLastPoint.subscribe(null,(t=>{e(t,((e,i)=>{const s=e.lineBeingCreated();if(null===s||s.linkKey().value()!==t.linkKey)return;const r=Hi(e,t.model,t.point.timeStamp);if(null===r)return;const n={index:r,price:t.point.price};s.setLastPoint(n),s.updateAllViews((0,vt.sourceChangeEvent)(s.id())),e.lightUpdate()}))})),K.startedMovingLineTool.subscribe(null,(t=>{e(t,((e,i)=>{var s;const r=t.linkKeys.map(E.lineToolByLinkKey.bind(null,e)).filter(y.notNull);if(r.length){const i=Hi(e,t.model,t.point.timeStamp);if(null===i)return;const n={index:i,price:t.point.price},o=null!==(s=t.activeItem)&&void 0!==s?s:null,a=r[0].pointToScreenPoint(n);a&&e.startMovingSources(r,{logical:n,screen:a},o,t.pointPositionPercents,null===t.envState?void 0:t.envState,!0)}}))})),K.movedLineTool.subscribe(null,(t=>{e(t,((e,i)=>{var s;const r=e.sourcesBeingMoved().filter(E.isLineTool).filter((e=>(e=>t.linkKeys.some((t=>e.linkKey().value()===t)))(e)));if(!r.length)return;const n=Hi(e,t.model,t.point.timeStamp);if(null===n)return;const o={index:n,price:t.point.price},a=r[0].pointToScreenPoint(o);a&&e.moveSources({logical:o,screen:a},t.pointPositionPercents,null!==(s=t.envState)&&void 0!==s?s:void 0,!0)}))})),K.finishedMovingLineTool.subscribe(null,(t=>{e(t,((e,i)=>{const s=e.sourcesBeingMoved().filter(E.isLineTool);if(0===s.length)return;s.forEach((i=>{const s=(e=>{for(let i=0;i{e(t,((e,i)=>{var s;const r=(0,E.lineToolByLinkKey)(e,t.linkKey);if(null!==r){const i=r.getPoint(t.pointIndex),n=i?i.index:Hi(e,t.model,t.point.timeStamp);if(null===n)return;if(r.isActualSymbol()&&r.isActualCurrency()&&r.isActualUnit()){const i={index:n,price:t.point.price};e.startChangingLinetool(r,i,t.pointIndex,null!==(s=t.envState)&&void 0!==s?s:void 0,!0)}}}))})),K.changedLineTool.subscribe(null,(t=>{e(t,((e,i)=>{const s=e.lineBeingEdited();if(null===s||s.linkKey().value()!==t.linkKey)return;let n=null;if(n=t.changes.indexesChanged?Hi(e,t.model,t.point.timeStamp):(0,r.ensureNotNull)(e.linePointBeingChanged()).index,null!==n&&s.isActualSymbol()&&s.isActualCurrency()&&s.isActualUnit()){const i={index:n,price:t.point.price};e.changeLinePoint(i,void 0,!0)}}))})),K.finishedChangingLineTool.subscribe(null,(t=>{e(t,((e,i)=>{const s=(0,E.lineToolByLinkKey)(e,t.linkKey) +;null!==s&&s.isActualSymbol()&&s.isActualCurrency()&&s.isActualUnit()&&null!==e.lineBeingEdited()&&e.endChangingLinetool(!!t.finalState,!0),null!==s&&t.finalState&&s.restoreExternalPoints(t.finalState,t.changes)}))})),K.removedLineTool.subscribe(null,(t=>{e(t,((e,i)=>{const{withUndo:s,unlink:r,linkKey:n}=t,o=(0,E.lineToolByLinkKey)(e,n);if(null!==o)r&&o.detachAlert(),s?i.removeSource(o,!1):(e.lineToolsGroupModel().removeLineTools([o]),e.removeSource(o));else if(this._lineToolsSynchronizer){const{sourceTitle:e,symbol:o,lineToolState:a}=t;i.removeUnloadedLineTool({state:a,unlink:r,sourceTitle:e,linkKey:n,symbol:o,withUndo:s})}}))})),K.finishedLineTool.subscribe(null,(t=>{e(t,((e,i)=>{const s=(0,E.lineToolByLinkKey)(e,t.linkKey);null!==s&&(0,V.isLineToolFinishRequiredWhenCreatedByApi)(s.toolname)&&s.finish()}))})),K.changedLineStyle.subscribe(null,(t=>{e(t,((e,i)=>{const s=(0,E.lineToolByLinkKey)(e,t.linkKey);null!==s&&(s.restoreExternalState(t.state),s.propertiesChanged(!0),t.alertId&&s.syncAlert(t.alertId))}))})),K.restoredLineToolState.subscribe(null,(t=>{e(t,((e,i)=>{const s=(0,E.lineToolByLinkKey)(e,t.linkKey);if(null!==s){const i={...t.state};i.indexes=t.state.points.map((i=>({index:Hi(e,t.model,i.time_t),price:i.price}))),e.restoreLineToolState(s,i,!1)}}))})),K.restoredLineTool.subscribe(null,(t=>{e(t,((e,i)=>{e.restoreSource(t.state.restorePane,t.state.paneIndex,t.state.paneState,t.state.sourceState,null)}))})),K.copiedLineTool.subscribe(null,(t=>{e(t,((e,i)=>{const s=(0,r.ensureNotNull)(e.paneForSource(e.mainSeries()));let n;const o={...t.state,intervalsVisibilities:(0,wi.mergeIntervalVisibilitiesDefaults)(t.state.intervalsVisibilities)},a=(0,E.createLineToolProperties)(t.linetool,o,e),l=e.dataSourceForId(t.id);if(l){if(!(0,E.isLineTool)(l))return void Ni.logError(`Error sync creating line tool. Object with id ${t.id} is already in use and it is not a line tool`);if(l.toolname!==t.linetool)return void Ni.logError(`Error sync creating line tool. Object with id ${t.id} is already in use and its type differs: ${l.toolname} and ${t.linetool}`)}if(l&&(l.linkKey().setValue(t.linkKey),l.share(t.sharingMode)),t.pointPositionPercents){const e={index:0,price:0};if(n=null!=l?l:i.createLineTool({pane:s,point:e,linetool:t.linetool,properties:a,linkKey:t.linkKey,disableSynchronization:!0,id:t.id}),null===n)return;n.restorePositionPercents((0,r.ensureDefined)(t.pointPositionPercents))}else{const o=t.points.map((i=>({index:(0,r.ensureNotNull)(Hi(e,t.model,i.timeStamp)),price:i.price}))),c=o[0];if(l)n=l;else if(t.withUndo)n=i.createLineTool({pane:s,point:c,linetool:t.linetool,properties:a,linkKey:t.linkKey,sharingMode:t.sharingMode,disableSynchronization:!0,id:t.id});else{const e=new w.CreateLineToolUndoCommand({model:i.model(),pane:s,lineTool:t.linetool,ownerSource:(0,r.ensureNotNull)(s.mainDataSource()),drawOnAllChartsMode:t.sharingMode,id:t.id});e.redo(),e.startCreatingLine(c,a,t.linkKey||null,t.sharingMode),n=(0,r.ensureNotNull)(e.line())}if(null===n)return +;if(e.lineBeingCreated())for(let e=1;e0){const i=Math.ceil(e.timeScale().width()/t.barCount);e.timeScale().setBarSpacing(i)}}_showOrHideDataWindowWidget(){const e=window.widgetbar,t=null==e?void 0:e.layout;if(!t)return;const i=t.getActivePage();i&&"data-window"===i.name||(t.setMinimizedState(!1),e.setPage("data-window"))}_createHint(){if(null===this._hintDefferedPromise){const e=(0,d.createDeferredPromise)();this._hintDefferedPromise=e,Promise.all([i.e(6214),i.e(962),i.e(6166)]).then(i.bind(i,5015)).then((t=>{ +e.resolve(new t.ChartEventHintRenderer(this._chartWidgetCollection.getContainer()))}))}return this._hintDefferedPromise?(0,r.ensureDefined)(this._hintDefferedPromise).promise:null}_showHint(e){if(Ae.enabled("popup_hints"))if(null!==this._activeHint)this._activeHint.show(e);else{const t=this._createHint();null!==t&&t.then((t=>{if(null!==t){if(this._activeHint=t,void 0===e)return;this._activeHint.show(e)}}))}}_hideHint(){null!==this._activeHint&&this._activeHint.hide()}}},55148:(e,t,i)=>{"use strict";i.r(t),i.d(t,{activeLinkingGroupWV:()=>gi,allInitialModelsCreated:()=>ei,allInitialSymbolsResolved:()=>Qt,allLinkingGroupsWV:()=>vi,applyIndicatorToAllChartsImpl:()=>ut,applyIndicatorsToAllChartsImpl:()=>dt,applyLineToolUpdateNotificationImpl:()=>yt,applyThemeImpl:()=>si,chartsSymbolsImpl:()=>Pt,checkProFeatureImpl:()=>ti,combinedTrackTimeLock:()=>Pi,computeContentBoxImpl:()=>Et,copyScreenshotToClipboard:()=>Mt,createBroadcastChannel:()=>Zt,createChartStorageSubscriptionsIfRequired:()=>Ct,createClipboardHandler:()=>bt,createLeftBottomChartWidgetWV:()=>At,deserializedChartIds:()=>vt,destroyBroadcastChannel:()=>Xt,downloadScreenshot:()=>It,generateNewChartId:()=>Wt,getAllLinkingGroups:()=>fi,getAsyncStateForChartImpl:()=>gt,getChartWidgetsForIntervalLock:()=>_i,getClientSnapshot:()=>Dt,getLinkingGroupCharts:()=>Si,getSnapshot:()=>kt,getStateForChartImpl:()=>mt,getVisuallyAdjacentDefImpl:()=>Ot,handleConnectionLimitReachedChanged:()=>bi,handleDateRangeLockChange:()=>ci,handleInternalDateRangeLockChange:()=>li,handleInternalIntervalLockChange:()=>oi,handleInternalSymbolLockChange:()=>ri,handleInternalTrackTimeLockChange:()=>hi,handleIntervalLockChange:()=>ai,handleSymbolLockChange:()=>ni,handleTrackTimeLockChange:()=>di,hideChartImpl:()=>jt,isFirstChartInLayout:()=>ft,lineToolsAndGroupsDTOsImpl:()=>_t,removeChartWidgetSubscriptionsImpl:()=>Gt,resetLineToolsInvalidatedImpl:()=>St,setBrokerImpl:()=>wt,setChartLayoutWithUndoImpl:()=>ii,setLayoutImpl:()=>$t,setResolution:()=>mi,setSymbol:()=>ui,setSymbolAll:()=>pi,someOfWidgetsAreInSelectingReplayPointMode:()=>wi,syncCrosshairImpl:()=>Kt,syncScrollImpl:()=>Jt,takeScreenshot:()=>xt,takeServerScreenshot:()=>Tt,updateLayoutImpl:()=>Nt,updateLayoutPartialImpl:()=>Rt,updateLinkingGroupCharts:()=>yi});var s=i(50151),r=i(86441),n=i(59224),o=i(44352),a=i(69109),l=i(49483),c=i(36298),h=i(14483);function d(e){const t={};return{promise:new Promise(((i,s)=>{e.subscribe(t,i,!0)})),destroy:()=>{e.unsubscribeAll(t)}}}var u=i(97145),p=(i(98310),i(62591));class _ extends p.UndoCommand{constructor(e,t){super(null),this._chartModel=e,this._targetIndex=t}redo(){const e=this._chartModel.createPane(this._targetIndex,void 0,this._paneId);this._paneId=e.id()}undo(){const e=(0,s.ensureDefined)(this._paneId),t=this._chartModel.panes().find((t=>t.id()===e));void 0!==t&&this._chartModel.removePane(t)}createdPaneId(){return this._paneId}}class m extends p.UndoCommand{constructor(e,t,i,s){super(s),this._setter=e,this._oldValue=t,this._newValue=i}redo(){this._setter(this._newValue)}undo(){ this._setter(this._oldValue)}}class g extends m{constructor(e,t,i,s){super((e=>this._vwState.setValue(e)),t,i,s),this._vwState=e}}var f=i(94474),v=i(65446),S=i(93352);const y=(0,n.getLogger)("Clipboard");class b{constructor(e){this._e=e}write(e){return(0,v.writeImpl)(this._toRaw(e),this._e)}_toRaw(e){const t={files:[]};t.text=e.text,void 0!==e.app?t.html=this._serializeAppData(e.app,e.text):e.html&&(t.html=e.html);for(const i of e.files||[])t.files.push(i);return t}_serializeAppData(e,t){return`${t?(0,f.htmlEscape)(t.slice(0,256)):"📈"}`}}class w{constructor(e){this._e=e}async read(){this._e&&0===this._e.eventPhase&&(y.logWarn("Cannot use an already dispatched ClipboardEvent for reading"),this._e=null);const e=this._e?this._readUsingEvent(this._e):await this._readUsingApi();return this._fromRaw(e)}_readUsingEvent(e){const t=(0,s.ensure)(e.clipboardData);e.preventDefault();const i={files:[]};for(let e=0;e0&&(t.files=e.files),t}_parseAppData(e){if(-1===e.slice(0,1024).indexOf("data-tradingview-clip"))return;const t=(new DOMParser).parseFromString(e,"text/html").querySelector("[data-tradingview-clip]");return t?t.getAttribute("data-tradingview-clip")||"":void 0}_readBlobAsText(e){return new Promise(((t,i)=>{const s=new FileReader;s.onloadend=()=>{t(s.result)},s.onerror=()=>{i(s.error)},s.readAsText(e)}))}}var P=i(35749);function C(e){const t=e.target;return null!==t&&1===t.nodeType&&(0,P.isTextEditingField)(t)}function x(e){const t=e.target;if(null===t)return!1;const i=(t.ownerDocument||t).getSelection();return null!==i&&!i.isCollapsed}class T extends class{constructor(e){this._callbacks=Object.assign({},e),this._boundOnCopy=this._onCopyEv.bind(this),this._boundOnCut=this._onCutEv.bind(this),this._boundOnPaste=this._onPasteEv.bind(this)}listen(){document.addEventListener("copy",this._boundOnCopy),document.addEventListener("cut",this._boundOnCut),document.addEventListener("paste",this._boundOnPaste)}async peek(){if("granted"!==(await navigator.permissions.query({name:"clipboard-read"})).state)throw new Error("clipboard-read is not granted");return new w(null).read()}uiRequestCopy(e){ -this._callbacks.copyRequested&&this._callbacks.copyRequested(new b(null),e)}uiRequestCut(e){this._callbacks.cutRequested&&this._callbacks.cutRequested(new b(null),e)}uiRequestPaste(e){this._callbacks.pasteRequested&&this._callbacks.pasteRequested(new w(null),e)}destroy(){document.removeEventListener("copy",this._boundOnCopy),document.removeEventListener("cut",this._boundOnCut),document.removeEventListener("paste",this._boundOnPaste)}_onCopyEv(e){e.defaultPrevented||this._callbacks.copyRequested&&this._callbacks.copyRequested(new b(e))}_onCutEv(e){e.defaultPrevented||this._callbacks.cutRequested&&this._callbacks.cutRequested(new b(e))}_onPasteEv(e){e.defaultPrevented||this._callbacks.pasteRequested&&this._callbacks.pasteRequested(new w(e))}}{_onCopyEv(e){if(!C(e)&&!x(e))return super._onCopyEv(e)}_onCutEv(e){if(!C(e)&&!x(e))return super._onCutEv(e)}_onPasteEv(e){if(!C(e))return super._onPasteEv(e)}}const I=()=>i.e(4389).then(i.bind(i,82869));function M(e,t={}){return I().then((i=>i.copyToClipboardImageOfChart(e,t)))}function L(e,t={}){return I().then((i=>i.getImageOfChartSilently(e,t)))}var A=i(76422),k=i(84015),D=i(5286),V=i(27714),E=i(24377),B=i(26843),R=i(78071),N=i(74359),O=i(46501),F=i(29764),W=i(34976),H=i(76351);const z=!h.enabled("widget_logo")||!1;function U(e,t=null,i=null){let s={};if("number"==typeof e)return{relativePositions:{[e]:{l:t,t:i}},nextElementLeft:e,nextElementTop:e};const[r,...n]=e;if("v"===r){let e=null;for(const r of n){const n=U(r,t,i);s={...s,...n.relativePositions},i=n.nextElementTop,e=n.nextElementLeft}t=e}if("h"===r){let e=null;for(const r of n){const n=U(r,t,i);s={...s,...n.relativePositions},t=n.nextElementLeft,e=n.nextElementTop}i=e}return{relativePositions:s,nextElementTop:i,nextElementLeft:t}}const j=function(e){const t={};for(const i of Object.keys(e)){const s=U(e[i]).relativePositions;t[i]=s}return t}(W);function G(e,t,i,s){let r=Math.round(10*s),n=Math.round(10*s);const o=i[e];if(null!==o.l){const e=G(o.l,t,i,s);r=e.x+e.width+Math.round(5*s)}if(null!==o.t){const e=G(o.t,t,i,s);n=e.y+e.height+Math.round(5*s)}const a=t[e];return{x:r,y:n,width:a.width,height:a.height}}function q(e,t,i){var s;const r=(new DOMParser).parseFromString(H,"image/svg+xml");null===(s=null==r?void 0:r.firstElementChild)||void 0===s||s.setAttribute("color",i);const n=URL.createObjectURL(new Blob([(new XMLSerializer).serializeToString(r)],{type:"image/svg+xml"}));return new Promise((i=>{const s=new Image;s.width=e,s.height=t,s.onload=()=>{i({image:s,width:e,height:t})},s.src=n}))}function $(e,t,i,s,r){e.save(),e.drawImage(s.image,t,i,s.width,s.height),e.textBaseline="bottom";const n=(t+s.width)/r+3,o=(i+s.height)/r;(0,N.drawScaled)(e,r,r,(()=>{e.fillText("TradingView",n,o)})),e.restore()}function Y(e,t,i,s){return(0,N.drawScaled)(e,s,s,(()=>{e.fillText(i,t.x/s,t.y/s)})),e.measureText(i).width*s}function K(e,t,i,s,n,o){const a=n.map((e=>e.text)).join("");let l=i.x;const c=function(e,t,i,s){if(e.measureText(t).width*s<=i)return{text:t,elided:!1};const r=e.measureText("...").width*s,n=[] -;for(let e=0;ee.measureText(t.slice(0,o+1)).width*s+r>i));return{text:(t=t.slice(0,o)).trim(),elided:!0}}(e,a,s-l,t);if(c.elided&&!o)return null;const h=[];let d=0;for(const e of n){if(d+e.text.length>c.text.length)break;h.push(e.text),d+=e.text.length}const u=h.join("").trim().length;d=0;for(const s of n){if(d+s.text.length>u)break;s.color&&(e.save(),e.fillStyle=s.color),l+=Y(e,new r.Point(l,i.y),s.text,t),s.color&&e.restore(),d+=s.text.length}return c.elided&&(l+=Y(e,new r.Point(l,i.y),"...",t)),l}function Z(e){return e.map((e=>({...e,title:""})))}function X(e,t){const i=[{text:e.trim()}];for(const e of t)e.visible&&(""!==i[i.length-1].text&&i.push({text:" "}),e.title&&i.push({text:e.title}),i.push({text:e.value,color:e.color}));return i}class J{constructor(e,t){this._logoTextColor=null,this._snapshotData=e,t=t||{},this._options={backgroundColor:D.themes[e.theme].getThemedColor("color-bg-primary"),borderColor:D.themes[e.theme].getThemedColor("color-border"),font:O.CHART_FONT_FAMILY,fontSize:12,legendMode:"vertical",hideResolution:!1,showHeaderPublishedBy:!1,showHeaderMainSymbol:!1,...t};const i=j[e.layout],s=e.charts.map((e=>function(e){const t=e.panes[0],i=t.canvas.width+t.leftAxis.canvas.width+t.rightAxis.canvas.width;let s=0;for(const t of e.panes)s+=t.canvas.height;return void 0!==e.timeAxis&&0!==e.timeAxis.contentHeight&&(s+=e.timeAxis.canvas.height),(0,V.size)({width:i,height:s})}(e)));if(this._pixelRatio=e.hidpiRatio,this._chartsGeometry=e.charts.map(((e,t)=>G(t,s,i,this._pixelRatio))),!z){let i=e.theme;void 0!==t.backgroundColor&&(i="black"===(0,E.rgbToBlackWhiteString)((0,E.parseRgb)(t.backgroundColor),150)?B.StdTheme.Dark:B.StdTheme.Light),this._logoTextColor=D.themes[i].getThemedColor("color-text-primary")}this._headerDefaultTextColor=D.themes[e.theme].getThemedColor("color-text-primary")}async getImage(){const e=this._pixelRatio;let t=0,i=0,s=0;const n=this._headerItems();if(n.length>0){s=Math.ceil(1.4*this._options.fontSize*e)*n.length}i+=s;let o=0,a=0;for(const e of this._chartsGeometry)o=Math.max(o,e.x+e.width),a=Math.max(a,e.y+e.height);const l=i;t+=o,i+=a,t+=Math.round(10*e);const c=z?Math.round(10*e):Math.round(35*e),h=i;i+=c;const d=(0,N.createDisconnectedCanvas)(document,(0,V.size)({width:t,height:i}),1),u=(0,N.getContext2D)(d);u.font=(0,F.makeFont)(this._options.fontSize,this._options.font),u.textBaseline="top",u.fillStyle=this._options.backgroundColor,u.fillRect(0,0,t,i),n.length>0&&this._drawHeader(u,n,t,new r.Point(Math.round(10*e),Math.round(10*e)));for(let e=0;ei.e(4389).then(i.bind(i,82869));function M(e,t={}){return I().then((i=>i.copyToClipboardImageOfChart(e,t)))}function L(e,t={}){return I().then((i=>i.getImageOfChartSilently(e,t)))}var A=i(76422),k=i(84015),D=i(5286),E=i(27714),V=i(24377),B=i(26843),R=i(78071),N=i(74359),O=i(46501),F=i(29764),W=i(34976),H=i(76351);const z=!h.enabled("widget_logo")||!1;function U(e,t=null,i=null){let s={};if("number"==typeof e)return{relativePositions:{[e]:{l:t,t:i}},nextElementLeft:e,nextElementTop:e};const[r,...n]=e;if("v"===r){let e=null;for(const r of n){const n=U(r,t,i);s={...s,...n.relativePositions},i=n.nextElementTop,e=n.nextElementLeft}t=e}if("h"===r){let e=null;for(const r of n){const n=U(r,t,i);s={...s,...n.relativePositions},t=n.nextElementLeft,e=n.nextElementTop}i=e}return{relativePositions:s,nextElementTop:i,nextElementLeft:t}}const j=function(e){const t={};for(const i of Object.keys(e)){const s=U(e[i]).relativePositions;t[i]=s}return t}(W);function G(e,t,i,s){let r=Math.round(10*s),n=Math.round(10*s);const o=i[e];if(null!==o.l){const e=G(o.l,t,i,s);r=e.x+e.width+Math.round(5*s)}if(null!==o.t){const e=G(o.t,t,i,s);n=e.y+e.height+Math.round(5*s)}const a=t[e];return{x:r,y:n,width:a.width,height:a.height}}function q(e,t,i){var s;const r=(new DOMParser).parseFromString(H,"image/svg+xml");null===(s=null==r?void 0:r.firstElementChild)||void 0===s||s.setAttribute("color",i);const n=URL.createObjectURL(new Blob([(new XMLSerializer).serializeToString(r)],{type:"image/svg+xml"}));return new Promise((i=>{const s=new Image;s.width=e,s.height=t,s.onload=()=>{i({image:s,width:e,height:t})},s.src=n}))}function $(e,t,i,s,r){e.save(),e.drawImage(s.image,t,i,s.width,s.height),e.textBaseline="bottom";const n=(t+s.width)/r+3,o=(i+s.height)/r;(0,N.drawScaled)(e,r,r,(()=>{e.fillText("TradingView",n,o)})),e.restore()}function Y(e,t,i,s){return(0,N.drawScaled)(e,s,s,(()=>{e.fillText(i,t.x/s,t.y/s)})),e.measureText(i).width*s}function K(e,t,i,s,n,o){const a=n.map((e=>e.text)).join("");let l=i.x;const c=function(e,t,i,s){if(e.measureText(t).width*s<=i)return{text:t,elided:!1};const r=e.measureText("...").width*s,n=[] +;for(let e=0;ee.measureText(t.slice(0,o+1)).width*s+r>i));return{text:(t=t.slice(0,o)).trim(),elided:!0}}(e,a,s-l,t);if(c.elided&&!o)return null;const h=[];let d=0;for(const e of n){if(d+e.text.length>c.text.length)break;h.push(e.text),d+=e.text.length}const u=h.join("").trim().length;d=0;for(const s of n){if(d+s.text.length>u)break;s.color&&(e.save(),e.fillStyle=s.color),l+=Y(e,new r.Point(l,i.y),s.text,t),s.color&&e.restore(),d+=s.text.length}return c.elided&&(l+=Y(e,new r.Point(l,i.y),"...",t)),l}function Z(e){return e.map((e=>({...e,title:""})))}function X(e,t){const i=[{text:e.trim()}];for(const e of t)e.visible&&(""!==i[i.length-1].text&&i.push({text:" "}),e.title&&i.push({text:e.title}),i.push({text:e.value,color:e.color}));return i}class J{constructor(e,t){this._logoTextColor=null,this._snapshotData=e,t=t||{},this._options={backgroundColor:D.themes[e.theme].getThemedColor("color-bg-primary"),borderColor:D.themes[e.theme].getThemedColor("color-border"),font:O.CHART_FONT_FAMILY,fontSize:12,legendMode:"vertical",hideResolution:!1,showHeaderPublishedBy:!1,showHeaderMainSymbol:!1,...t};const i=j[e.layout],s=e.charts.map((e=>function(e){const t=e.panes[0],i=t.canvas.width+t.leftAxis.canvas.width+t.rightAxis.canvas.width;let s=0;for(const t of e.panes)s+=t.canvas.height;return void 0!==e.timeAxis&&0!==e.timeAxis.contentHeight&&(s+=e.timeAxis.canvas.height),(0,E.size)({width:i,height:s})}(e)));if(this._pixelRatio=e.hidpiRatio,this._chartsGeometry=e.charts.map(((e,t)=>G(t,s,i,this._pixelRatio))),!z){let i=e.theme;void 0!==t.backgroundColor&&(i="black"===(0,V.rgbToBlackWhiteString)((0,V.parseRgb)(t.backgroundColor),150)?B.StdTheme.Dark:B.StdTheme.Light),this._logoTextColor=D.themes[i].getThemedColor("color-text-primary")}this._headerDefaultTextColor=D.themes[e.theme].getThemedColor("color-text-primary")}async getImage(){const e=this._pixelRatio;let t=0,i=0,s=0;const n=this._headerItems();if(n.length>0){s=Math.ceil(1.4*this._options.fontSize*e)*n.length}i+=s;let o=0,a=0;for(const e of this._chartsGeometry)o=Math.max(o,e.x+e.width),a=Math.max(a,e.y+e.height);const l=i;t+=o,i+=a,t+=Math.round(10*e);const c=z?Math.round(10*e):Math.round(35*e),h=i;i+=c;const d=(0,N.createDisconnectedCanvas)(document,(0,E.size)({width:t,height:i}),1),u=(0,N.getContext2D)(d);u.font=(0,F.makeFont)(this._options.fontSize,this._options.font),u.textBaseline="top",u.fillStyle=this._options.backgroundColor,u.fillRect(0,0,t,i),n.length>0&&this._drawHeader(u,n,t,new r.Point(Math.round(10*e),Math.round(10*e)));for(let e=0;e0&&t.leftAxis.contentHeight>0&&(i.drawImage(t.leftAxis.canvas,s,n),s+=t.leftAxis.canvas.width),i.drawImage(t.canvas,s,n),s+=t.canvas.width,t.rightAxis.contentWidth>0&&t.rightAxis.contentHeight>0&&i.drawImage(t.rightAxis.canvas,s,n),"pane"===t.type&&(i.fillStyle=e.colors.text,this._drawLegend(t,i,new r.Point(o,l),a)),n+=t.canvas.height}if(void 0!==e.timeAxis&&0!==e.timeAxis.contentHeight){let t=0;e.timeAxis.lhsStub.contentWidth>0&&e.timeAxis.lhsStub.contentHeight>0&&(i.drawImage(e.timeAxis.lhsStub.canvas,t,n),t+=e.timeAxis.lhsStub.canvas.width),i.drawImage(e.timeAxis.canvas,t,n),t+=e.timeAxis.canvas.width,e.timeAxis.rhsStub.contentWidth>0&&e.timeAxis.rhsStub.contentHeight>0&&i.drawImage(e.timeAxis.rhsStub.canvas,t,n)}i.strokeStyle=this._options.borderColor,i.strokeRect(0,0,t.width,t.height),i.restore()}_headerItems(){var e,t,i,s;const r=[];if(this._options.showHeaderPublishedBy&&this._snapshotData.publishedBy)for(const e of this._snapshotData.publishedBy)r.push([{text:e}]);if(this._options.showHeaderMainSymbol){const n=this._snapshotData.charts[0],o=`${null===(e=n.meta)||void 0===e?void 0:e.symbol}, ${null===(t=n.meta)||void 0===t?void 0:t.resolution}`;r.push(X(o,null!==(s=null===(i=n.meta)||void 0===i?void 0:i.values)&&void 0!==s?s:[]))}return r}_drawHeader(e,t,i,s){e.save(),e.fillStyle=this._headerDefaultTextColor;const n=Math.ceil(1.4*this._options.fontSize*this._pixelRatio);t.forEach(((t,o)=>{K(e,this._pixelRatio,new r.Point(s.x,s.y+n*o),i,t,!0)})),e.restore()}_drawLegend(e,t,i,n){let o=!0;const a=Math.ceil(1.4*this._options.fontSize*this._pixelRatio);let l=i.x,c=i.y;if(e.mainSeriesText&&c+a{e.fillText(r,0,0)}))}_fillRadius(e){const t=this._data.style,i=Math.max(1,Math.floor(e));let s=Math.round(t.lollipop.width*e);return s%2!=i%2&&(s+=1),s/2}_drawBorderLine(e,t,i,s){const r=this._data.style;e.strokeStyle=r.lollipop.strokeStyle,e.lineWidth=i,(0,fe.setLineStyle)(e,ge.LINESTYLE_SOLID),(0,fe.createCircle)(e,t.x,t.y,s),e.stroke()}_drawFilledCircle(e,t,i,s){e.fillStyle=s,(0,fe.createCircle)(e,t.x,t.y,i),e.fill()}}var ye=i(18807);class be extends Se{_drawLollipop(e,t,i){var s;if(!this._imageLoaded())return void super._drawLollipop(e,t,i);const r=this._data.style,n=i.pixelRatio,o=this._fillRadius(n);let a=Math.round(r.lollipop.lineWidth*n),l=o-Math.round(1*n+a/2);if(r.lollipop.fillCircle&&(r.lollipop.backgroundColor&&this._drawFilledCircle(e,t,o,r.lollipop.backgroundColor),r.lollipop.fillStyle&&this._drawFilledCircle(e,t,l,r.lollipop.fillStyle)),null===(s=this._data.style.lollipop.image)||void 0===s?void 0:s.imageElement){const i=o-Math.round(1*n+2*a),s=2*i;e.save(),e.imageSmoothingEnabled=!0,e.imageSmoothingQuality="high",(0,fe.createCircle)(e,t.x,t.y,i),e.clip(),e.drawImage(this._data.style.lollipop.image.imageElement,t.x-i,t.y-i,s,s),e.restore()}"active"===this._data.status&&(l-=a/2,a*=1.5),this._drawBorderLine(e,t,a,l)}_drawLabel(e,t,i){this._imageLoaded()&&!this._data.style.lollipop.text.showWhenImageLoaded||super._drawLabel(e,t,i)}_imageLoaded(){return Boolean(this._data.style.lollipop.image&&this._data.style.lollipop.image.imageElement&&this._data.style.lollipop.image.imageElement.complete&&this._data.style.lollipop.image.imageElement.naturalWidth)}}const we={fillPath:new Path2D("M8.961.92a3 3 0 0 1 3.078 0l7.5 4.48A3 3 0 0 1 21 7.975V20a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V7.975A3 3 0 0 1 1.461 5.4l7.5-4.48z"), strokePath:new Path2D("M9.867 2.742c.39-.23.875-.23 1.266 0l7.5 4.406c.382.225.617.635.617 1.078V20c0 .69-.56 1.25-1.25 1.25H3c-.69 0-1.25-.56-1.25-1.25V8.226c0-.443.235-.853.617-1.078l7.5-4.406z")},Pe={fillPath:new Path2D("M8.961 22.08a3 3 0 0 0 3.078 0l7.5-4.48A3 3 0 0 0 21 15.025V3a3 3 0 0 0-3-3H3a3 3 0 0 0-3 3v12.025A3 3 0 0 0 1.461 17.6l7.5 4.48z"),strokePath:new Path2D("M9.866 20.257c.391.23.877.23 1.268 0l7.5-4.414a1.25 1.25 0 0 0 .616-1.078V3c0-.69-.56-1.25-1.25-1.25H3c-.69 0-1.25.56-1.25 1.25v11.765c0 .443.234.853.616 1.078l7.5 4.414z")},Ce={fillPath:new Path2D("M3 0h15c1.662 0 3 1.338 3 3v15c0 1.662-1.338 3-3 3H3c-1.662 0-3-1.338-3-3V3c0-1.662 1.338-3 3-3z"),strokePath:new Path2D("M3 1.75h15c.693 0 1.25.557 1.25 1.25v15c0 .693-.557 1.25-1.25 1.25H3c-.692 0-1.25-.558-1.25-1.25V3c0-.692.558-1.25 1.25-1.25z")};function xe(e,t,i,s,r){const n=i.pixelRatio;e.save(),e.translate(t.x-s.lollipop.width*n/2,t.y-s.lollipop.height*n/2),e.scale(n,n),s.lollipop.fillCircle&&s.lollipop.backgroundColor&&(e.fillStyle=s.lollipop.backgroundColor,e.fill(r.fillPath)),e.strokeStyle=s.lollipop.strokeStyle,e.lineWidth=Math.round(s.lollipop.lineWidth*n)/n,(0,fe.setLineStyle)(e,ge.LINESTYLE_SOLID),s.lollipop.fillCircle&&s.lollipop.fillStyle&&(e.fillStyle=s.lollipop.fillStyle,e.fill(r.strokePath)),e.stroke(r.strokePath),e.restore()}function Te(e,t,i,s){xe(e,t,i,s,we)}function Ie(e,t,i,s){xe(e,t,i,s,Pe)}function Me(e,t,i,s){xe(e,t,i,s,Ce)}class Le extends Se{_drawLollipop(e,t,i){const s=this._data.style;switch(s.shape){case"earningUp":Te(e,t,i,s);break;case"earningDown":Ie(e,t,i,s);break;case"earning":Me(e,t,i,s);break;default:super._drawLollipop(e,t,i)}}}const Ae={backgroundDark:(0,de.getHexColorByName)("color-cold-gray-900"),backgroundLight:(0,de.getHexColorByName)("color-white")};class ke extends class{constructor(e,t,i){this._invalidated=!1,this._renderer=new ue.CompositeRenderer,this._textWidthCache=new pe.TextWidthCache,this._stylesCache=null,this._lollipops={},this._lollipopsCounter=0,this._lastClickedId=null,this.onPaneBgChange=()=>{this._recreateStyles(this._model)},this._lastClickedId=null,this._model=e,this._source=t,this._clickHandler=i,this._recreateStyles(e),e.backgroundColor().subscribe(this.onPaneBgChange),e.mainSeries().onSymbolIntervalChanged().subscribe(this,this._onSymbolOrIntervalChanged)}destroy(){this._model.backgroundColor().unsubscribe(this.onPaneBgChange),this._model.mainSeries().onSymbolIntervalChanged().unsubscribeAll(this)}processClickOutside(e){var t;if(null===this._lastClickedId||!e)return void this.clearLastClicked();let i=null;if(function(e){return void 0!==e.touches}(e)){if(1!==e.touches.length)return;{const t=(0,s.ensureNotNull)(e.target).getBoundingClientRect(),n=e.touches[0];i=new r.Point(n.clientX-t.left,n.clientY-t.top)}}else i=new r.Point(e.offsetX,e.offsetY);const n=this._renderer.hitTest(i,{physicalHeight:0,physicalWidth:0,pixelRatio:1,cssHeight:0,cssWidth:0});null!==n&&(null===(t=n.data())||void 0===t?void 0:t.activeItem)===(0, -s.ensureDefined)(this._lollipops[this._lastClickedId]).itemIndex||this.clearLastClicked()}clearLastClicked(){const e=null!==this._lastClickedId&&this._lollipops[this._lastClickedId]||null;null!==e&&(e.active=!1),this._lastClickedId=null}getLastClickedLollipopId(){return this._lastClickedId}update(){this._invalidated=!0}afterUpdate(e,t,i,s){}getStyle(e,t){let i=t;if(e.stack&&(i+="_stack:"+e.stack),"active"===i)return this._activeStyle;if("hovered"===i)return this._hoveredStyle;if("default"===i)return this._defaultStyle;if(this._stylesCache||(this._stylesCache={}),!this._stylesCache[i]){const s=(0,ce.clone)("active"===t?this._activeStyle:"hovered"===t?this._hoveredStyle:this._defaultStyle);e.stack&&(s.lollipop.incHeight=25*e.stack),this._stylesCache[i]=s}return this._stylesCache[i]}hasTooltip(e){return!0}_getY(){let e=0;const t=this._model.panes();for(let i=t.length;i--;){const s=t[i];s.containsMainSeries()&&(e+=s.height())}return e}_showBarLine(e){return this.hasTooltip(e)&&(e.hovered||e.active)}_createRenderers(e,t){this._renderer.clear();const i=(0,V.size)({width:e,height:t});for(const e in this._lollipops)if(this._lollipops.hasOwnProperty(e)){const t=(0,s.ensureDefined)(this._lollipops[e]);if(t.visible){const e=this._getLollipopStatus(t),s=this.getStyle(t,e),n={id:t.id,centerPoint:new r.Point(t.basePoint.x,t.basePoint.y-s.lollipop.bottom-s.lollipop.height/2-(s.lollipop.incHeight||0)),style:s,status:e},o={activeItem:t.itemIndex,hideCrosshairLinesOnHover:!0,clickHandler:this._lollipopMouseClickHandler.bind(this,n,i),tapHandler:this._lollipopMouseClickHandler.bind(this,n,i)};if(this._renderer.append(this._createRendererForLollipop(n,o)),this._showBarLine(t)){const{strokeStyle:e,lineStyle:i,lineWidth:r}=s.barLine,n={color:e,linestyle:i,linewidth:r,x:t.basePoint.x,top:0,bottom:t.basePoint.y-s.lollipop.bottom-s.lollipop.height},o=new _e.VerticalLineRenderer;o.setData(n),this._renderer.insert(o,0)}}}}_recreateStyles(e){this._stylesCache=null}_createRendererForLollipop(e,t){return new Se(e,new ye.HitTestResult(ye.HitTarget.Custom,t),this._textWidthCache)}_onSymbolOrIntervalChanged(){this._lollipops={},this._lollipopsCounter=0,this._renderer.clear(),this.clearLastClicked()}_lollipopMouseClickHandler(e,t,i){i.preventDefault();const n=e.id;if(this._lastClickedId=this._lastClickedId===n?null:n,null===this._lastClickedId)return;const o={target:i.target,targetSize:t,point:new r.Point(e.centerPoint.x,e.centerPoint.y-e.style.lollipop.height/2-8),marginTop:15};this._clickHandler(o,(()=>{const e=(0,s.ensureDefined)(this._lollipops[n]);return this._createTooltipContent(e)}))}_getLollipopStatus(e){return e.active?"active":e.hovered?"hovered":"default"}}{constructor(e,t,i){super(e,t,i),this.stylesCache={},this.templatesCache={},this._itemIndexToId=new Map,this.source=t}clearCaches(){this.clearLastClicked(),this._lollipops={},this._lollipopsCounter=0}update(){this._invalidated=!0}renderer(e,t){return this._invalidated&&(this._createLollipops(t,e),this._invalidated=!1),this._renderer}getStyle(e){ -const t=e.active?"active":e.hovered?"hovered":"default";return this._generateStyle(t,e)}hasTooltip(e){return Boolean(e.items&&e.items.length)}_createTooltipContent(e){const t=e.items;return t?[{type:"common",subTitle:Array.isArray(t)?t.map((e=>({value:e}))):[{value:t}],style:{color:e.color}}]:null}_createRendererForLollipop(e,t){return new(e.style.lollipop.image?be:Le)(e,new ye.HitTestResult(ye.HitTarget.Custom,t),this._textWidthCache)}_lollipopMouseClickHandler(e,t,i){super._lollipopMouseClickHandler(e,t,i),(0,A.emit)("onTimescaleMarkClick",e.id)}_createLollipops(e,t){const i=this._model.timeScale(),s=super._getY(),n=this._model.lastHittestData(),o=this._model.hoveredSource(),a=this.source.marks(),l=new Map;Object.keys(a).forEach((e=>{var t;const c=a[e],h=c.id,d=c.index;if(null!=d){const e=h===this.getLastClickedLollipopId(),a=this._lollipops[h],u=void 0!==a?a.itemIndex:this._lollipopsCounter++;this._itemIndexToId.has(u)||this._itemIndexToId.set(u,h);const p=o===this.source&&null!==n&&n.activeItem===u,_=(null!==(t=l.get(d))&&void 0!==t?t:-1)+1;l.set(d,_),this._lollipops[h]={id:h,itemIndex:u,basePoint:new r.Point(i.indexToCoordinate(d)+1,s),hovered:p,active:e,label:c.label,color:c.color,items:c.tooltip,visible:!0,stack:_,shape:c.shape,image:this._getImageForUrl(c.imageUrl),showLabelWhenImageLoaded:c.showLabelWhenImageLoaded,textColor:c.labelFontColor}}})),super._createRenderers(e,t)}_getImageForUrl(e){if(e)return this.source.getImageElement(e)}_generateStyle(e,t){const{color:i,label:s,stack:r,shape:n,image:o,textColor:a}=t;let l=e+i+s+(this._model.dark().value()?"dark":"light");if(void 0!==r&&(l+="_stack"+r),!(l in this.stylesCache)){const c=this._model.dark().value()?Ae.backgroundDark:Ae.backgroundLight;let h,d=i;if("active"===e)h=i,d="rgba(255, 255, 255, 0.92)";else if("hovered"===e){const e=(0,E.tryParseRgba)(i);if(null!==e){const t=e[3]*(1-.85);h=(0,E.rgbaToString)((0,E.rgba)(e[0],e[1],e[2],t))}}a&&(d=a);let u=23,p=23,_=1,m=0;"earning"===n?(p=21,u=21,_=2):"earningUp"===n?(u=21,m=1,_=2):"earningDown"===n&&(u=21,m=-.5,_=.5);const g={barLine:{lineStyle:ge.LINESTYLE_DASHED,lineWidth:1,strokeStyle:i},lollipop:{width:u,height:p,bottom:_,backgroundColor:c,lineWidth:1.5,fillStyle:h,strokeStyle:i,fillCircle:!0,text:{label:s,deltaY:m,strokeStyle:d,font:(0,F.makeFont)(12,O.CHART_FONT_FAMILY,"bold"),showWhenImageLoaded:t.showLabelWhenImageLoaded},image:o},shape:n};void 0!==r&&(g.lollipop.incHeight=25*r),this.stylesCache[l]=g}return this.stylesCache[l]}}var De=i(46100),Ve=i(98517),Ee=i(12767),Be=i(36112);const Re=(0,n.getLogger)("Chart.UserDefinedImageMarks");class Ne extends Be.BarsMarksContainer{constructor(){super(...arguments),this._imageItems=new Map,this._destroyed=!1}destroy(){this._destroyed=!0,super.destroy()}getImageElement(e){return this._imageItems.has(e)||this.addImageToStore(e),this._imageItems.get(e)}addImageToStore(e){this._imageItems.has(e)||this._loadNewImage(e)}_loadNewImage(e){const t={imageElement:null};(0,Ee.getImage)(e,e).then((e=>{this._destroyed||(t.imageElement=e,this.updateAllViewsAndRepaint(), -this._model.updateSource(this))})).catch((()=>{Re.logWarn(`An error ocurred while loading image ${e}`)})),this._imageItems.set(e,t)}}class Oe extends Ne{constructor(e){super(e,new De.DefaultProperty("UserDefinedTimescaleMarks",{visible:!0})),this._requestedPointsets=new Set,(0,he.hideMarksOnBars)().subscribe(this,(()=>this._properties.childs().visible.setValue(!(0,he.hideMarksOnBars)().value()))),this._paneView=new ke(e,this,this._showTooltip.bind(this)),this._paneViews=[this._paneView]}destroy(){(0,he.hideMarksOnBars)().unsubscribeAll(this),super.destroy()}zorder(){return Ve.sortSourcesPreOrdered.TimeScaleMarks}name(){return"UserDefinedTimescaleMarks"}userEditEnabled(){return!1}clearMarks(e=0){if(1===e)return;const t=this._model.chartApi();t.isConnected().value()&&Object.keys(this._marks).forEach((e=>{const i=this._getPointsetId(e);t.removePointset(i)})),this._requestedPointsets.clear(),super.clearMarks(),this._paneView.clearCaches(),this.updateAllViewsAndRepaint()}hasContextMenu(){return!1}paneViews(){return this._properties.childs().visible.value()?this._paneViews:[]}updateAllViews(){this._paneView.update()}onClickOutside(){this._paneView.processClickOutside()}isVisible(){return this.properties().childs().visible.value()}_initialize(){this._properties.childs().visible.setValue(!0)}_plateViewData(e){return{text:e.text}}_getData(e){const t=this._model.mainSeries().symbolInfo();if(!t)return;const i=this.roundRange(this._rangeDifference(e)),r=this._model.mainSeries(),n=r.seriesSource().symbolInstanceId(),o=r.properties().childs().interval.value();window.ChartApiInstance.getTimescaleMarks(t,i.start,i.end,(t=>{const i=this._model.chartApi();for(const e of t){e.index=null;const t=e.id,r=this._getPointsetId(t.toString()),a=this._marks[t];if(a&&null!==a.index&&(a.tickmark===e.tickmark?e.index=a.index:this._requestedPointsets.has(r)&&i.isConnected().value()&&(i.removePointset(r),this._requestedPointsets.delete(r))),e.imageUrl&&this.addImageToStore(e.imageUrl),this._marks[t]=e,null===e.index&&i.isConnected().value()){this._requestedPointsets.add(r);const t=[[e.tickmark,0]];i.createPointset(r,"turnaround",(0,s.ensureNotNull)(n),o,t,(e=>this._onPointsetData(e)))}}this._loadedRange=this._rangeUnion(e,this._loadedRange),this.updateAllViewsAndRepaint()}),o)}_getPointsetId(e){return"pointsetMark_"+e}_onPointsetData(e){if("data_update"===e.method){const t=e.params.customId.split("_")[1],i=this._marks[t],s=e.params.plots;i&&1===s.length&&(i.index=s[0].value[0])}this.updateAllViews()}async _showTooltip(e,t){const r=t();if(!r)return;const n=this._model.timeScale(),o=[n.onScroll(),n.barSpacingChanged(),this._model.mainSeries().onSymbolIntervalChanged(),(0,s.ensureNotNull)(this._model.paneForSource(this)).onSizeChanged()],a=this._paneView.processClickOutside.bind(this._paneView),l=this._paneView.clearLastClicked.bind(this._paneView);(await Promise.all([i.e(3842),i.e(5649),i.e(6925),i.e(962),i.e(3179),i.e(9039)]).then(i.bind(i,70434))).showLollipopTooltip({items:r,position:e,customCloseSubscriptions:o,onClickOutside:a,onCustomClose:l})}} +s.ensureDefined)(this._lollipops[this._lastClickedId]).itemIndex||this.clearLastClicked()}clearLastClicked(){const e=null!==this._lastClickedId&&this._lollipops[this._lastClickedId]||null;null!==e&&(e.active=!1),this._lastClickedId=null}getLastClickedLollipopId(){return this._lastClickedId}update(){this._invalidated=!0}afterUpdate(e,t,i,s){}getStyle(e,t){let i=t;if(e.stack&&(i+="_stack:"+e.stack),"active"===i)return this._activeStyle;if("hovered"===i)return this._hoveredStyle;if("default"===i)return this._defaultStyle;if(this._stylesCache||(this._stylesCache={}),!this._stylesCache[i]){const s=(0,ce.clone)("active"===t?this._activeStyle:"hovered"===t?this._hoveredStyle:this._defaultStyle);e.stack&&(s.lollipop.incHeight=25*e.stack),this._stylesCache[i]=s}return this._stylesCache[i]}hasTooltip(e){return!0}_getY(){let e=0;const t=this._model.panes();for(let i=t.length;i--;){const s=t[i];s.containsMainSeries()&&(e+=s.height())}return e}_showBarLine(e){return this.hasTooltip(e)&&(e.hovered||e.active)}_createRenderers(e,t){this._renderer.clear();const i=(0,E.size)({width:e,height:t});for(const e in this._lollipops)if(this._lollipops.hasOwnProperty(e)){const t=(0,s.ensureDefined)(this._lollipops[e]);if(t.visible){const e=this._getLollipopStatus(t),s=this.getStyle(t,e),n={id:t.id,centerPoint:new r.Point(t.basePoint.x,t.basePoint.y-s.lollipop.bottom-s.lollipop.height/2-(s.lollipop.incHeight||0)),style:s,status:e},o={activeItem:t.itemIndex,hideCrosshairLinesOnHover:!0,clickHandler:this._lollipopMouseClickHandler.bind(this,n,i),tapHandler:this._lollipopMouseClickHandler.bind(this,n,i)};if(this._renderer.append(this._createRendererForLollipop(n,o)),this._showBarLine(t)){const{strokeStyle:e,lineStyle:i,lineWidth:r}=s.barLine,n={color:e,linestyle:i,linewidth:r,x:t.basePoint.x,top:0,bottom:t.basePoint.y-s.lollipop.bottom-s.lollipop.height},o=new _e.VerticalLineRenderer;o.setData(n),this._renderer.insert(o,0)}}}}_recreateStyles(e){this._stylesCache=null}_createRendererForLollipop(e,t){return new Se(e,new ye.HitTestResult(ye.HitTarget.Custom,t),this._textWidthCache)}_onSymbolOrIntervalChanged(){this._lollipops={},this._lollipopsCounter=0,this._renderer.clear(),this.clearLastClicked()}_lollipopMouseClickHandler(e,t,i){i.preventDefault();const n=e.id;if(this._lastClickedId=this._lastClickedId===n?null:n,null===this._lastClickedId)return;const o={target:i.target,targetSize:t,point:new r.Point(e.centerPoint.x,e.centerPoint.y-e.style.lollipop.height/2-8),marginTop:15};this._clickHandler(o,(()=>{const e=(0,s.ensureDefined)(this._lollipops[n]);return this._createTooltipContent(e)}))}_getLollipopStatus(e){return e.active?"active":e.hovered?"hovered":"default"}}{constructor(e,t,i){super(e,t,i),this.stylesCache={},this.templatesCache={},this._itemIndexToId=new Map,this.source=t}clearCaches(){this.clearLastClicked(),this._lollipops={},this._lollipopsCounter=0}update(){this._invalidated=!0}renderer(e,t){return this._invalidated&&(this._createLollipops(t,e),this._invalidated=!1),this._renderer}getStyle(e){ +const t=e.active?"active":e.hovered?"hovered":"default";return this._generateStyle(t,e)}hasTooltip(e){return Boolean(e.items&&e.items.length)}_createTooltipContent(e){const t=e.items;return t?[{type:"common",subTitle:Array.isArray(t)?t.map((e=>({value:e}))):[{value:t}],style:{color:e.color}}]:null}_createRendererForLollipop(e,t){return new(e.style.lollipop.image?be:Le)(e,new ye.HitTestResult(ye.HitTarget.Custom,t),this._textWidthCache)}_lollipopMouseClickHandler(e,t,i){super._lollipopMouseClickHandler(e,t,i),(0,A.emit)("onTimescaleMarkClick",e.id)}_createLollipops(e,t){const i=this._model.timeScale(),s=super._getY(),n=this._model.lastHittestData(),o=this._model.hoveredSource(),a=this.source.marks(),l=new Map;Object.keys(a).forEach((e=>{var t;const c=a[e],h=c.id,d=c.index;if(null!=d){const e=h===this.getLastClickedLollipopId(),a=this._lollipops[h],u=void 0!==a?a.itemIndex:this._lollipopsCounter++;this._itemIndexToId.has(u)||this._itemIndexToId.set(u,h);const p=o===this.source&&null!==n&&n.activeItem===u,_=(null!==(t=l.get(d))&&void 0!==t?t:-1)+1;l.set(d,_),this._lollipops[h]={id:h,itemIndex:u,basePoint:new r.Point(i.indexToCoordinate(d)+1,s),hovered:p,active:e,label:c.label,color:c.color,items:c.tooltip,visible:!0,stack:_,shape:c.shape,image:this._getImageForUrl(c.imageUrl),showLabelWhenImageLoaded:c.showLabelWhenImageLoaded,textColor:c.labelFontColor}}})),super._createRenderers(e,t)}_getImageForUrl(e){if(e)return this.source.getImageElement(e)}_generateStyle(e,t){const{color:i,label:s,stack:r,shape:n,image:o,textColor:a}=t;let l=e+i+s+(this._model.dark().value()?"dark":"light");if(void 0!==r&&(l+="_stack"+r),!(l in this.stylesCache)){const c=this._model.dark().value()?Ae.backgroundDark:Ae.backgroundLight;let h,d=i;if("active"===e)h=i,d="rgba(255, 255, 255, 0.92)";else if("hovered"===e){const e=(0,V.tryParseRgba)(i);if(null!==e){const t=e[3]*(1-.85);h=(0,V.rgbaToString)((0,V.rgba)(e[0],e[1],e[2],t))}}a&&(d=a);let u=23,p=23,_=1,m=0;"earning"===n?(p=21,u=21,_=2):"earningUp"===n?(u=21,m=1,_=2):"earningDown"===n&&(u=21,m=-.5,_=.5);const g={barLine:{lineStyle:ge.LINESTYLE_DASHED,lineWidth:1,strokeStyle:i},lollipop:{width:u,height:p,bottom:_,backgroundColor:c,lineWidth:1.5,fillStyle:h,strokeStyle:i,fillCircle:!0,text:{label:s,deltaY:m,strokeStyle:d,font:(0,F.makeFont)(12,O.CHART_FONT_FAMILY,"bold"),showWhenImageLoaded:t.showLabelWhenImageLoaded},image:o},shape:n};void 0!==r&&(g.lollipop.incHeight=25*r),this.stylesCache[l]=g}return this.stylesCache[l]}}var De=i(46100),Ee=i(98517),Ve=i(12767),Be=i(36112);const Re=(0,n.getLogger)("Chart.UserDefinedImageMarks");class Ne extends Be.BarsMarksContainer{constructor(){super(...arguments),this._imageItems=new Map,this._destroyed=!1}destroy(){this._destroyed=!0,super.destroy()}getImageElement(e){return this._imageItems.has(e)||this.addImageToStore(e),this._imageItems.get(e)}addImageToStore(e){this._imageItems.has(e)||this._loadNewImage(e)}_loadNewImage(e){const t={imageElement:null};(0,Ve.getImage)(e,e).then((e=>{this._destroyed||(t.imageElement=e,this.updateAllViewsAndRepaint(), +this._model.updateSource(this))})).catch((()=>{Re.logWarn(`An error ocurred while loading image ${e}`)})),this._imageItems.set(e,t)}}class Oe extends Ne{constructor(e){super(e,new De.DefaultProperty("UserDefinedTimescaleMarks",{visible:!0})),this._requestedPointsets=new Set,(0,he.hideMarksOnBars)().subscribe(this,(()=>this._properties.childs().visible.setValue(!(0,he.hideMarksOnBars)().value()))),this._paneView=new ke(e,this,this._showTooltip.bind(this)),this._paneViews=[this._paneView]}destroy(){(0,he.hideMarksOnBars)().unsubscribeAll(this),super.destroy()}zorder(){return Ee.sortSourcesPreOrdered.TimeScaleMarks}name(){return"UserDefinedTimescaleMarks"}userEditEnabled(){return!1}clearMarks(e=0){if(1===e)return;const t=this._model.chartApi();t.isConnected().value()&&Object.keys(this._marks).forEach((e=>{const i=this._getPointsetId(e);t.removePointset(i)})),this._requestedPointsets.clear(),super.clearMarks(),this._paneView.clearCaches(),this.updateAllViewsAndRepaint()}hasContextMenu(){return!1}paneViews(){return this._properties.childs().visible.value()?this._paneViews:[]}updateAllViews(){this._paneView.update()}onClickOutside(){this._paneView.processClickOutside()}isVisible(){return this.properties().childs().visible.value()}_initialize(){this._properties.childs().visible.setValue(!0)}_plateViewData(e){return{text:e.text}}_getData(e){const t=this._model.mainSeries().symbolInfo();if(!t)return;const i=this.roundRange(this._rangeDifference(e)),r=this._model.mainSeries(),n=r.seriesSource().symbolInstanceId(),o=r.properties().childs().interval.value();window.ChartApiInstance.getTimescaleMarks(t,i.start,i.end,(t=>{const i=this._model.chartApi();for(const e of t){e.index=null;const t=e.id,r=this._getPointsetId(t.toString()),a=this._marks[t];if(a&&null!==a.index&&(a.tickmark===e.tickmark?e.index=a.index:this._requestedPointsets.has(r)&&i.isConnected().value()&&(i.removePointset(r),this._requestedPointsets.delete(r))),e.imageUrl&&this.addImageToStore(e.imageUrl),this._marks[t]=e,null===e.index&&i.isConnected().value()){this._requestedPointsets.add(r);const t=[[e.tickmark,0]];i.createPointset(r,"turnaround",(0,s.ensureNotNull)(n),o,t,(e=>this._onPointsetData(e)))}}this._loadedRange=this._rangeUnion(e,this._loadedRange),this.updateAllViewsAndRepaint()}),o)}_getPointsetId(e){return"pointsetMark_"+e}_onPointsetData(e){if("data_update"===e.method){const t=e.params.customId.split("_")[1],i=this._marks[t],s=e.params.plots;i&&1===s.length&&(i.index=s[0].value[0])}this.updateAllViews()}async _showTooltip(e,t){const r=t();if(!r)return;const n=this._model.timeScale(),o=[n.onScroll(),n.barSpacingChanged(),this._model.mainSeries().onSymbolIntervalChanged(),(0,s.ensureNotNull)(this._model.paneForSource(this)).onSizeChanged()],a=this._paneView.processClickOutside.bind(this._paneView),l=this._paneView.clearLastClicked.bind(this._paneView);(await Promise.all([i.e(3842),i.e(5649),i.e(6925),i.e(962),i.e(3179),i.e(9039)]).then(i.bind(i,70434))).showLollipopTooltip({items:r,position:e,customCloseSubscriptions:o,onClickOutside:a,onCustomClose:l})}} function Fe(e,t){const i=Math.max(1,Math.floor(t)),s=Math.round(e.x*t)+i%2/2;let r=Math.round(e.size*t);(s+r/2)%1!=0&&(r+=1);const n=Math.min(Math.max(1,Math.round(t*e.borderWidth)),r/2);let o;const a=("up"===e.direction?-1:1)*(e.yInverted?-1:1),l=a*(Math.round(e.size*t/2)+i%2);if(void 0!==e.fixedSpaceYPosition){const i=Math.round(e.fixedSpaceYPosition.itemSpacing*t),s=e.fixedSpaceYPosition.order,n=a*(r*s+i*(s+1));o=Math.round(e.fixedSpaceYPosition.basePosition*t)+n+l}else o=Math.round(e.y*t)+l;return{x:s,y:o,size:r,borderWidth:n,tickSize:i}}function We(e,t,i,s){var r,n,o;if(e.save(),i&&!s.highlightByAuthor&&(e.globalAlpha=.4),s.mine)!function(e,t,i){const{borderColor:s,backgroundColor:r,doNotFill:n,direction:o,yInverted:a}=i,{x:l,y:c,borderWidth:h,size:d,tickSize:u}=Fe(i,t.pixelRatio);e.strokeStyle=s,e.fillStyle=r,e.lineWidth=h;const p="up"===o!==a?-1:1;let _=Math.round(d/2/Math.tan(Math.PI/6))+u%2/2;(l+_/2)%1!=0&&(_-=1);e.translate(l,c+_/2*p),e.beginPath();const m=h/2;e.moveTo(0,-p*(_-m)),e.lineTo(d/2-m,h/2),e.lineTo(-d/2+m,h/2),e.lineTo(0,-p*(_-h/2)),e.closePath(),n||e.fill();e.stroke()}(e,t,s);else{let i=!1;{const e=s.image&&(o=s.image,Boolean(o&&o.imageElement&&o.imageElement.complete&&o.imageElement.naturalWidth));i=Boolean(e&&!s.showLabelWhenImageLoaded)}!function(e,t,i,s,r){const{borderColor:n,backgroundColor:o,label:a}=i,l=t.pixelRatio,{x:c,y:h,borderWidth:d,size:u}=Fe(i,l);e.strokeStyle=n,e.fillStyle=o,e.lineWidth=d,e.beginPath();const p=u/2-d/2;e.arc(c,h,p,0,2*Math.PI,!0),e.closePath(),e.fill(),r&&function(e,t,i,s,r){if(t){const n=2*i;e.save(),e.imageSmoothingEnabled=!0,e.imageSmoothingQuality="high",(0,fe.createCircle)(e,s,r,i),e.clip(),e.drawImage(t,s-i,r-i,n,n),e.restore()}}(e,r,p,c,h);e.stroke(),!s&&a&&u/2>=7&&(e.textAlign="center",e.textBaseline="middle",e.font=a.font,e.fillStyle=a.fontColor,(0,N.drawScaled)(e,l,l,(()=>{e.fillText(a.text,c/l,h/l)})))}(e,t,s,i,null!==(n=null===(r=s.image)||void 0===r?void 0:r.imageElement)&&void 0!==n?n:void 0)}e.restore()}class He{constructor(e,t,i,s){this._canvas=null,this._clickHandler=e,this._enterHandler=t,this._leaveHandler=i,this._data=null!=s?s:null}setData(e){this._data=e}hitTest(e,t){if(null===this._data)return null;for(let i=this._data.items.length-1;i>=0;--i){const s=this._hitTestDot(this._data.items[i],e,t.pixelRatio);if(s)return s}return null}draw(e,t){this._canvas=e.canvas,null!==this._data&&this._data.items.forEach(We.bind(null,e,t,this._data.highlightByAuthor))}_hitTestDot(e,t,i){const s=new r.Point(e.x,Fe(e,i).y/i);if((0,me.pointInCircle)(t,s,Math.max(e.size/2,8))){const t=this._canvas,i=null===t?void 0:{mouseEnterHandler:()=>this._enterHandler(e,s.y,t),mouseLeaveHandler:()=>this._leaveHandler(),clickHandler:i=>this._clickHandler(e,s.y,t,i),tapHandler:i=>this._clickHandler(e,s.y,t,i)};return new ye.HitTestResult(ye.HitTarget.Regular,{activeItem:e.originalItem.id,...i})}return null}}const ze={green:{border:(0,de.getHexColorByName)("color-minty-green-700"),background:(0,de.getHexColorByName)("color-minty-green-a700")},red:{border:(0, de.getHexColorByName)("color-ripe-red-700"),background:(0,de.getHexColorByName)("color-ripe-red-500")},neutral:{border:(0,de.getHexColorByName)("color-tan-orange-700"),background:(0,de.getHexColorByName)("color-tan-orange-500")},yellow:{border:"#EAC300",background:"#FFD400"},blue:{border:"#047ACE",background:"#0496FF"}};function Ue(e){var t,i,s,r;return e.hovered||e.highlightByAuthor?null!==(i=null===(t=e.overrideBorderWidth)||void 0===t?void 0:t.hoveredWidth)&&void 0!==i?i:4:null!==(r=null===(s=e.overrideBorderWidth)||void 0===s?void 0:s.width)&&void 0!==r?r:2}class je extends class{constructor(e,t){this._tooltip=null,this._hoveredBarsMarkData=null,this._destroyed=!1,this._invalidated=!0,this._originalData=[],this._source=e,this._model=t,this._renderer=new He(this._onItemClicked.bind(this),this._showItem.bind(this),this._hideItem.bind(this)),this._createTooltipRenderer().then((e=>{this._destroyed?null==e||e.destroy():this._tooltip=e})),e.properties().childs().visible.subscribe(null,(()=>{var e;null===(e=this._tooltip)||void 0===e||e.hide(!0)}))}destroy(){var e;this._destroyed=!0,null===(e=this._tooltip)||void 0===e||e.destroy()}source(){return this._source}update(){this._invalidated=!0}renderer(e,t){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._renderer}onClickOutside(e){e.isTouch&&null!==this._tooltip&&!this._tooltip.contains(e.target)&&this._tooltip.hide(!0)}_extractBarMarksRendererItemData(e,t){var i,s;const r=null!==(i=t.overridedTheme)&&void 0!==i?i:ze[t.theme],n=this._calculateSize(e,t),o=this._calculateY(e,n,t);return null===this._hoveredBarsMarkData||this._hoveredBarsMarkData.id!==t.id||this._hoveredBarsMarkData.x===t.x&&this._hoveredBarsMarkData.y===Math.round(o)||(null===(s=this._tooltip)||void 0===s||s.hide(!0),this._hoveredBarsMarkData=null),{x:t.x,y:this._calculateY(e,n,t),direction:t.direction,borderColor:r.border,borderWidth:Ue(t),backgroundColor:r.background,size:n,doNotFill:!t.public,yInverted:t.yInverted,label:void 0===t.label?void 0:{text:t.label,fontColor:t.labelFontColor,font:(0,F.makeFont)(Math.ceil(Math.max(10,Math.min(n/2,20))),O.CHART_FONT_FAMILY,"bold")},originalItem:t}}_onItemClicked(e,t,i,s){s.isTouch&&this._showItem(e,t,i)}async _showItem(e,t,i){var r;const n=await this._tooltipProps(e);if(null===n)return;const o=this._model.timeScale().barSpacing(),a=this._calculateSize(o,e.originalItem);this._hoveredBarsMarkData={x:e.x,y:Math.round(this._calculateY(o,a,e.originalItem)),id:e.originalItem.id},null===(r=this._tooltip)||void 0===r||r.show({itemSize:a,container:(0,s.ensureNotNull)(i.parentElement),x:e.x,y:t,factoryProps:n,onClickOutside:()=>{var e;return null===(e=this._tooltip)||void 0===e?void 0:e.hide(!0)}})}_hideItem(){var e;null===(e=this._tooltip)||void 0===e||e.hide()}_calculateSize(e,t){return Math.min(553,Math.max(7,t.minSize,.8*e))}_updateImpl(){this._originalData=this._source.getPlatesViewData();const e=this._model.timeScale().barSpacing(),t=this._originalData.map(this._extractBarMarksRendererItemData.bind(this,e));this._renderer.setData({items:t, -barSpacing:e,highlightByAuthor:!1})}}{async _createTooltipRenderer(){const[{TooltipRenderer:e},{UserDefinedBarsMarksTooltip:t}]=await Promise.all([Promise.all([i.e(9789),i.e(962),i.e(8020)]).then(i.bind(i,5972)),Promise.all([i.e(9789),i.e(962),i.e(8020)]).then(i.bind(i,48080))]);return new e(t)}_calculateY(e,t,i){const s=Math.max(1.4*i.minSize,e+4),r=("up"===i.direction?-1:1)*(i.yInverted?-1:1)*(s*(i.order+.6)+.25*s);return i.y+r}_onItemClicked(e,t,i,s){var r,n;super._onItemClicked(e,t,i,s),null===(n=(r=e.originalItem).onClicked)||void 0===n||n.call(r)}_tooltipProps(e){const t=e.originalItem.text;return t?Promise.resolve({text:t}):Promise.resolve(null)}_extractBarMarksRendererItemData(e,t){return{...super._extractBarMarksRendererItemData(e,t),showLabelWhenImageLoaded:t.showLabelWhenImageLoaded,image:t.image}}}class Ge extends Ne{constructor(e){super(e,new De.DefaultProperty("UserDefinedBarsMarks",{visible:!0})),this._paneView=new je(this,e),this._paneViews=[this._paneView],(0,he.hideMarksOnBars)().subscribe(this,(()=>{this.properties().childs().visible.setValue(!(0,he.hideMarksOnBars)().value())}))}destroy(){(0,he.hideMarksOnBars)().unsubscribeAll(this),this._paneView.destroy(),super.destroy()}zorder(){return Ve.sortSourcesPreOrdered.BarMarks}name(){return"UserDefinedBarsMarks"}userEditEnabled(){return!1}clearMarks(e=0){2!==e&&(super.clearMarks(),this.updateAllViewsAndRepaint())}hasContextMenu(){return!1}paneViews(){return this._properties.childs().visible.value()?this._paneViews:[]}isVisible(){return this.properties().childs().visible.value()}onClickOutside(e){this._paneView.onClickOutside(e)}_initialize(){this.properties().childs().visible.setValue(!0)}_plateViewData(e){const t={text:e.text,onClicked:e.onClicked};"object"==typeof e.color&&(t.theme="user_defined_theme",t.overridedTheme={},t.overridedTheme.border=e.color.border,t.overridedTheme.background=e.color.background);const i=(0,ce.isNumber)(e.borderWidth)?e.borderWidth:void 0,s=(0,ce.isNumber)(e.hoveredBorderWidth)?e.hoveredBorderWidth:void 0;if(void 0===i&&void 0===s||(t.overrideBorderWidth={width:i,hoveredWidth:s}),e.showLabelWhenImageLoaded&&(t.showLabelWhenImageLoaded=!0),e.imageUrl){const i=this.getImageElement(e.imageUrl);t.image=i}return t}_getData(e){const t=this._model.mainSeries().symbolInfo();if(!t)return;const i=this.roundRange(this._rangeDifference(e)),s=this._model.mainSeries().properties().childs().interval.value();window.ChartApiInstance.getMarks(t,i.start,i.end,(t=>{for(const e of t)this._marks[e.id]=e,e.imageUrl&&this.addImageToStore(e.imageUrl);this._loadedRange=this._rangeUnion(e,this._loadedRange),this.updateAllViewsAndRepaint()}),s)}}var qe=i(45345);const $e=new c.TranslatedString("apply toolbars theme",o.t(null,void 0,i(58570)));class Ye extends p.UndoCommand{constructor(e,t,i=!0){super($e),this._prevThemeName=e,this._themeName=t,this._syncState=i}undo(){(0,D.isStdThemeName)(this._prevThemeName)&&((0,qe.setTheme)(this._prevThemeName),this._syncState&&(0,D.syncTheme)())}redo(){(0,D.isStdThemeName)(this._themeName.toLowerCase())&&((0, +barSpacing:e,highlightByAuthor:!1})}}{async _createTooltipRenderer(){const[{TooltipRenderer:e},{UserDefinedBarsMarksTooltip:t}]=await Promise.all([Promise.all([i.e(9789),i.e(962),i.e(8020)]).then(i.bind(i,5972)),Promise.all([i.e(9789),i.e(962),i.e(8020)]).then(i.bind(i,48080))]);return new e(t)}_calculateY(e,t,i){const s=Math.max(1.4*i.minSize,e+4),r=("up"===i.direction?-1:1)*(i.yInverted?-1:1)*(s*(i.order+.6)+.25*s);return i.y+r}_onItemClicked(e,t,i,s){var r,n;super._onItemClicked(e,t,i,s),null===(n=(r=e.originalItem).onClicked)||void 0===n||n.call(r)}_tooltipProps(e){const t=e.originalItem.text;return t?Promise.resolve({text:t}):Promise.resolve(null)}_extractBarMarksRendererItemData(e,t){return{...super._extractBarMarksRendererItemData(e,t),showLabelWhenImageLoaded:t.showLabelWhenImageLoaded,image:t.image}}}class Ge extends Ne{constructor(e){super(e,new De.DefaultProperty("UserDefinedBarsMarks",{visible:!0})),this._paneView=new je(this,e),this._paneViews=[this._paneView],(0,he.hideMarksOnBars)().subscribe(this,(()=>{this.properties().childs().visible.setValue(!(0,he.hideMarksOnBars)().value())}))}destroy(){(0,he.hideMarksOnBars)().unsubscribeAll(this),this._paneView.destroy(),super.destroy()}zorder(){return Ee.sortSourcesPreOrdered.BarMarks}name(){return"UserDefinedBarsMarks"}userEditEnabled(){return!1}clearMarks(e=0){2!==e&&(super.clearMarks(),this.updateAllViewsAndRepaint())}hasContextMenu(){return!1}paneViews(){return this._properties.childs().visible.value()?this._paneViews:[]}isVisible(){return this.properties().childs().visible.value()}onClickOutside(e){this._paneView.onClickOutside(e)}_initialize(){this.properties().childs().visible.setValue(!0)}_plateViewData(e){const t={text:e.text,onClicked:e.onClicked};"object"==typeof e.color&&(t.theme="user_defined_theme",t.overridedTheme={},t.overridedTheme.border=e.color.border,t.overridedTheme.background=e.color.background);const i=(0,ce.isNumber)(e.borderWidth)?e.borderWidth:void 0,s=(0,ce.isNumber)(e.hoveredBorderWidth)?e.hoveredBorderWidth:void 0;if(void 0===i&&void 0===s||(t.overrideBorderWidth={width:i,hoveredWidth:s}),e.showLabelWhenImageLoaded&&(t.showLabelWhenImageLoaded=!0),e.imageUrl){const i=this.getImageElement(e.imageUrl);t.image=i}return t}_getData(e){const t=this._model.mainSeries().symbolInfo();if(!t)return;const i=this.roundRange(this._rangeDifference(e)),s=this._model.mainSeries().properties().childs().interval.value();window.ChartApiInstance.getMarks(t,i.start,i.end,(t=>{for(const e of t)this._marks[e.id]=e,e.imageUrl&&this.addImageToStore(e.imageUrl);this._loadedRange=this._rangeUnion(e,this._loadedRange),this.updateAllViewsAndRepaint()}),s)}}var qe=i(45345);const $e=new c.TranslatedString("apply toolbars theme",o.t(null,void 0,i(58570)));class Ye extends p.UndoCommand{constructor(e,t,i=!0){super($e),this._prevThemeName=e,this._themeName=t,this._syncState=i}undo(){(0,D.isStdThemeName)(this._prevThemeName)&&((0,qe.setTheme)(this._prevThemeName),this._syncState&&(0,D.syncTheme)())}redo(){(0,D.isStdThemeName)(this._themeName.toLowerCase())&&((0, qe.setTheme)(this._themeName.toLowerCase()),this._syncState&&(0,D.syncTheme)())}}var Ke=i(97906),Ze=i(49475),Xe=i(83669),Je=(i(36274),i(94025)),Qe=i(81501);i(77825);const et=!l.CheckMobile.any(),tt=(0,n.getLogger)("ChartWidgetCollectionBase"),it=new c.TranslatedString("apply indicators to entire layout",o.t(null,void 0,i(44547))),st=new c.TranslatedString("sync time",o.t(null,void 0,i(60635))),rt=new c.TranslatedString("resize layout",o.t(null,void 0,i(13034))),nt=new c.TranslatedString("reset layout sizes",o.t(null,void 0,i(30910))),ot=new c.TranslatedString("apply chart theme",o.t(null,void 0,i(66568))),at=new c.TranslatedString("symbol lock",o.t(null,void 0,i(92831))),lt=new c.TranslatedString("interval lock",o.t(null,void 0,i(28916))),ct=new c.TranslatedString("date range lock",o.t(null,void 0,i(90621))),ht=new c.TranslatedString("track time",o.t(null,void 0,i(47122)));o.t(null,void 0,i(46669)),o.t(null,void 0,i(98478)),o.t(null,void 0,i(34004)),o.t(null,void 0,i(96260)),o.t(null,void 0,i(38641)),o.t(null,void 0,i(10160)),o.t(null,void 0,i(19149)),o.t(null,void 0,i(38660));function dt(e,t){const i=t.model().model().studyTemplate();e.undoHistory.beginUndoMacro(it);for(let s=0;se.id()===n)))}const l=t.pasteSourceFromClip(o,i,!0);if(l&&1===l.length){const e=l[0];if(r.asCompare){const i=(0,s.ensureNotNull)(t.mainSeries().priceScale());t.moveToScale(e,(0,s.ensureDefined)(o),i,n),t.setPriceScaleMode({percentage:!0},i,null)}}t.model().lightUpdate()}}e.undoHistory.endUndoMacro()}function pt(e){let t=1;for(;e.has(""+t);)t++;return""+t}function _t(e){const t=new Map,i=e.chartsCountToSave(),s=new Set;for(let r=0;r(0,s.ensureDefined)(e.content.chartId)))}function St(e,t,i){e.chartsCountToSave();i.forEach((i=>{const s=(t=>{var i,s;return null!==(s=null===(i=e.chartWidgetsDefs.find((e=>e.chartWidget.id()===t)))||void 0===i?void 0:i.chartWidget)&&void 0!==s?s:null})(i.chartId);null==s||s.resetLineToolsInvalidated(t,i.savedDto,i.sharingMode)}))}function yt(e,t,i,s){const r=e.map((e=>e.chartWidget)).filter((e=>e.hasModel())).filter((e=>e.id()===t||0!==s));try{r.forEach((e=>e.startApplyingLineToolUpdateNotification())),r.forEach((e=>e.applyLineToolUpdateNotification(i,s)))}finally{r.forEach((e=>e.endApplyingLineToolUpdateNotification()))}}function bt(e){return new T({copyRequested:(t,i)=>{e.activeChartWidget.value().model().clipboardCopy(t,i)},cutRequested:(t,i)=>{e.activeChartWidget.value().model().clipboardCut(t,i)},pasteRequested:(t,i)=>{(i?i.model().undoModel():e.activeChartWidget.value().model()).clipboardPaste(t,i)}})}function wt(e,t){0}function Pt(e){const t={};return e.chartWidgetsDefs.map((e=>e.chartWidget)).forEach((e=>t[e.id()]=function(e){var t,i,r,n,o;const a={};if(!e.hasModel()){const n=e.options().content;if(!n)return a;const o=(0,s.ensureNotNull)(n.panes.reduce(((e,t)=>{var i;return null!==(i=null!=e?e:t.sources.find((e=>"MainSeries"===e.type)))&&void 0!==i?i:null}),null));return a.resolution=null===(t=o.state)||void 0===t?void 0:t.interval,a.symbol=null===(i=o.state)||void 0===i?void 0:i.symbol,a.short_name=null===(r=o.state)||void 0===r?void 0:r.shortName,a}const l=e.model().mainSeries(),c=l.properties().childs(),h=l.symbolInfo();a.resolution=c.interval.value(),a.symbol_type=null!==h&&h.type||"",a.exchange=null!==h&&h.exchange||"",a.listed_exchange=null!==h&&h.listed_exchange||"";const d=null!==(n=null==h?void 0:h.legs)&&void 0!==n?n:[];if(null!==h&&l.isSpread()){const e=d[0];let t=h.base_name[0];t=t.split(":")[1],a.symbol=e,a.short_name=t,a.expression=h.full_name}else a.symbol=null!==h&&h.ticker||c.symbol.value(),a.short_name=c.shortName.value();const u=null!==(o=null==h?void 0:h.base_name)&&void 0!==o?o:[];return a.legs=d.map(((e,t)=>({symbol:e,pro_symbol:u[t]}))),a}(e))),t}function Ct(e,t){0}function xt(e,t){return L(t,{snapshotUrl:e}).then((e=>((0,A.emit)("onScreenshotReady",e),e)))}function Tt(e,t){const i={snapshotUrl:e};const s=(0,k.isOnMobileAppPage)("any");return(s?L:M)(t,i).then((e=>((0,A.emit)("onScreenshotReady",e),s||(0,A.emit)("onServerScreenshotCopiedToClipboard"),e)))}function It(e){return function(e){return I().then((t=>t.downloadClientScreenshot(e)))}(e)}function Mt(e){return function(e){return I().then((t=>t.copyToClipboardClientScreenshot(e)))}(e).then((()=>{(0,A.emit)("onClientScreenshotCopiedToClipboard")}))}const Lt={s:0,"2h":0,"2v":1,"2-1":1,"3s":0,"3h":0,"3v":2,4:1,6:1,8:1,"1-2":1,"3r":1,"4h":0,"4v":3,"4s":0,"5h":0,"6h":0,"7h":0,"8h":0,"1-3":1,"2-2":3,"2-3":2,"1-4":1,"5s":0,"6c":4,"8c":6,"10c5":1,"12c6":1,"12c4":3,"14c7":1,"16c8":1,"16c4":3};function At(e,t,i,s){let r=0;const n=(0,Ze.createWVFromGetterAndSubscriptions)((()=>++r),[i,s]);return(0, -Ke.combine)((t=>{var i;return null!==(i=e()[Lt[t]])&&void 0!==i?i:null}),t.weakReference(),n.ownership())}function kt(e,t,i,s){const r=Math.max(1,window.devicePixelRatio||1),n=e.getAll();let o;const a=e.maximizedChartWidget().value();if(s&&s.onlyActiveChart||a)return{layout:"s",hidpiRatio:r,theme:(0,D.getCurrentTheme)().name,charts:[e.activeChartWidget.value().images(s)],publishedBy:o};const l=[],c=ee.layouts[e.layout.value()].count,h={showCollapsedStudies:(s=s||{}).showCollapsedStudies,status:s.status};for(let e=0;e{const t=this._state.currentLayoutResizeAction.value();t&&this._applyMouseMove(t.delta,e)},this._state=e,this._splitterElement=t,this._splitter=i,(0,oe.shiftPressed)().subscribe(this._onShiftPressed)}destroy(){(0,oe.shiftPressed)().unsubscribe(this._onShiftPressed)}mouseDownEvent(e){this._mouseDownOrTouchStartEvent(e)}touchStartEvent(e){this._mouseDownOrTouchStartEvent(e)}pressedMouseMoveEvent(e){this._pressedMouseOrTouchMoveEvent(e)}touchMoveEvent(e){this._pressedMouseOrTouchMoveEvent(e)}mouseUpEvent(e){this._mouseUpOrTouchEndEvent(e)}touchEndEvent(e){this._mouseUpOrTouchEndEvent(e)}mouseEnterEvent(e){this._highlightSplitters(e.shiftKey)}mouseLeaveEvent(e){const t=Et(this._splitter.className);Array.from(this._state.parent.getElementsByClassName(t)).forEach((e=>e.classList.remove(Qe.hovered)))}mouseDoubleClickEvent(e){const t=(0,se.layoutInitialSizingState)(this._state.layoutTemplate.value().expression);this._state.undoHistory.beginUndoMacro(nt),this._state.undoHistory.pushUndoCommand(new g(this._state.sizingState,this._state.sizingState.value(),t,nt));const i=this._state.layoutTemplate.value().layoutType;this._state.undoHistory.pushUndoCommand(new m((e=>e?this._state.allLayoutSizesState.set(i,e):this._state.allLayoutSizesState.delete(i)),this._state.allLayoutSizesState.get(this._state.layoutTemplate.value().layoutType),t,nt)),this._state.undoHistory.endUndoMacro()}_highlightSplitters(e){const t=Et(this._splitter.className);Array.from(this._state.parent.getElementsByClassName(t)).forEach((e=>e.classList.remove(Qe.hovered)));(e?Array.from(this._state.parent.getElementsByClassName(t)):[this._splitterElement]).forEach((e=>e.classList.add(Qe.hovered)))}_mouseDownOrTouchStartEvent(e){ -const t=new r.Point(e.localX+this._splitterElement.offsetLeft,e.localY+this._splitterElement.offsetTop),i=(0,re.deepCopy)(this._state.sizingState.value());this._state.currentLayoutResizeAction.setValue({point:t,splitter:this._splitter,initialState:i,alignedState:this._state.layoutTemplate.value().syncSublayoutsBySplitter(this._splitter,(0,re.deepCopy)(i)),shiftState:e.shiftKey,delta:0}),this._splitterElement.classList.add(Qe["i-active"]),this._highlightSplitters(e.shiftKey)}_pressedMouseOrTouchMoveEvent(e){const t=this._state.currentLayoutResizeAction.value();if(!t)return;t.shiftState!==e.shiftKey&&(this._highlightSplitters(e.shiftKey),t.shiftState=e.shiftKey);const i=new r.Point(e.localX+this._splitterElement.offsetLeft,e.localY+this._splitterElement.offsetTop);t.delta="v"===t.splitter.orientation?i.y-t.point.y:i.x-t.point.x,this._applyMouseMove(t.delta,e.shiftKey)}_mouseUpOrTouchEndEvent(e){const t=this._state.currentLayoutResizeAction.value();if(t&&(this._splitterElement.classList.remove(Qe["i-active"]),this._state.currentLayoutResizeAction.setValue(null),t.currentState)){this._state.undoHistory.beginUndoMacro(rt),this._state.undoHistory.pushUndoCommand(new g(this._state.sizingState,t.initialState,t.currentState,rt));const e=this._state.layoutTemplate.value().layoutType;this._state.undoHistory.pushUndoCommand(new m((t=>t?this._state.allLayoutSizesState.set(e,t):this._state.allLayoutSizesState.delete(e)),this._state.allLayoutSizesState.get(this._state.layoutTemplate.value().layoutType),this._state.sizingState.value(),nt)),this._state.undoHistory.endUndoMacro(),this._state.layoutSizesChanged.setValue(!0)}}_applyMouseMove(e,t){var i;const r=(0,s.ensureNotNull)(this._state.currentLayoutResizeAction.value()),n=t?r.alignedState:r.initialState,o=null!==(i=this._state.options.padding)&&void 0!==i?i:2,a=Vt(this._state);r.currentState=this._state.layoutTemplate.value().resizeApplier(a,o,e,r.splitter,(0,re.deepCopy)(n),t),this._state.sizingState.setValue(r.currentState)}}function Rt(e,t,i,s,r){var n,o;const a=null!==(n=e.options.padding)&&void 0!==n?n:2,l=null!==(o=e.options.border)&&void 0!==o?o:0;r=null!=r?r:e.layoutTemplate.value();const c=Vt(e),h=r.sizer(c,i,s,a+l,et?e.sizingState.value():void 0);h.width=Math.max(Math.round(h.width),0),h.height=Math.max(Math.round(h.height),0),h.top=Math.round(h.top),h.left=Math.round(h.left),t.metrics=h;const d=t.container.value();if(d){d.style.width=h.width+"px",d.style.height=h.height+"px",d.style.top=h.top+"px",d.style.left=h.left+"px";const e=1===s;false;const t=Math.round(c.width),i=0===h.top&&0===h.left,r=0===h.top&&h.left+h.width===t,n=0===h.top&&h.width===t;d.classList.toggle("top-left-chart",!e&&!n&&i),d.classList.toggle("top-right-chart",!e&&!n&&r),d.classList.toggle("top-full-width-chart",e||n)}t.width.setValue(h.width),t.height.setValue(h.height)}function Nt(e){var t,i,s;let r;const n=e.layoutTemplate.value(),o=e.maximizedChartDef.value();if(r=o?[o]:e.chartWidgetsDefs.slice(0,n.count).filter((e=>!e.hiddenInLayout.value())),r.forEach(((t,i)=>Rt(e,t,i,r.length))), -et&&!e.maximizedChartDef.value()){const r=Vt(e),o=null!==(t=e.options.padding)&&void 0!==t?t:2,a=null!==(i=e.options.border)&&void 0!==i?i:0,l=n.splitters(r,o+a,e.sizingState.value()),c=null!==(s=e.splitters.value())&&void 0!==s?s:[];c.forEach(((e,t)=>{t>=l.length&&(e.splitterElement.remove(),e.mouseHandler.destroy(),e.mouseListener.destroy())}));const h=l.map(((t,i)=>{const s=i({def:t,metrics:e.layoutTemplate.value().sizer({top:0,left:0,width:256,height:256},i,s.length,0)}))).sort(((e,t)=>e.metrics.top-t.metrics.top||e.metrics.left-t.metrics.left)).map((e=>e.def));if(s.length<2)return null;let r=s.indexOf(t);return-1===r?null:(r=(r+(i?s.length-1:1))%s.length,s[r])}function Ft(e,t){return e.chartWidgetsDefs.some((e=>{var i;return(null===(i=e.chartWidget)||void 0===i?void 0:i.id())===t}))}function Wt(e){let t=1;for(;e(""+t);)t++;return""+t}function Ht(e){const t=e.activeChartWidget.value();if(t){const i=t.state();return i.chartId=Wt((t=>Ft(e,t))),i.shouldBeSavedEvenIfHidden=!1,i.panes.forEach((e=>{e.sources.forEach((e=>{"alertId"in e&&(e.alertId=void 0)}))})),{content:i}}}function zt(e,t,i){var r,n;const{toastsFactory:o,chartWidgetsDefs:a,customLegendWidgetsFactoriesMap:c}=e;let h={chartWidgetCollection:t,isActive:0===a.length,barsMarksContainersFactory:t=>function(e,t,i){const s=[];{const t=new Ge(e);s.push(t);const i=new Oe(e);s.push(i)}return s}(t,0,e.options),undoHistory:e.undoHistory,readOnly:e.readOnly,initialLoading:e.initialLoading,getToasts:o?()=>o.getChartToasts():void 0,...null!=i?i:{}};void 0!==c&&(h.customLegendWidgetFactories=new Map(c));const d=document.createElement("div");d.classList.add("chart-container"),d.style.position="absolute",d.style.overflow="hidden",e.parent.appendChild(d),l.isEdge&&(d.style.touchAction="none",d.style.msTouchAction="none"),h.className&&d.classList.add(h.className);const p={alive:new u.WatchedValue(!0),container:new u.WatchedValue(d),width:new u.WatchedValue,height:new u.WatchedValue,collapsed:new u.WatchedValue(!1),hiddenInLayout:new u.WatchedValue(!1),visible:new u.WatchedValue,rdState:new te.ResizerDetacherState,requestFullscreen:()=>{e.globalDetachable.value()&&(e.setMaximized(p),e.activeChartWidget.setValue((0,s.ensureNotNull)(p.chartWidget)))},exitFullscreen:()=>{ +Ke.combine)((t=>{var i;return null!==(i=e()[Lt[t]])&&void 0!==i?i:null}),t.weakReference(),n.ownership())}function kt(e,t,i,s){const r=Math.max(1,window.devicePixelRatio||1),n=e.getAll();let o;const a=e.maximizedChartWidget().value();if(s&&s.onlyActiveChart||a)return{layout:"s",hidpiRatio:r,theme:(0,D.getCurrentTheme)().name,charts:[e.activeChartWidget.value().images(s)],publishedBy:o};const l=[],c=ee.layouts[e.layout.value()].count,h={showCollapsedStudies:(s=s||{}).showCollapsedStudies,status:s.status};for(let e=0;e{const t=this._state.currentLayoutResizeAction.value();t&&this._applyMouseMove(t.delta,e)},this._state=e,this._splitterElement=t,this._splitter=i,(0,oe.shiftPressed)().subscribe(this._onShiftPressed)}destroy(){(0,oe.shiftPressed)().unsubscribe(this._onShiftPressed)}mouseDownEvent(e){this._mouseDownOrTouchStartEvent(e)}touchStartEvent(e){this._mouseDownOrTouchStartEvent(e)}pressedMouseMoveEvent(e){this._pressedMouseOrTouchMoveEvent(e)}touchMoveEvent(e){this._pressedMouseOrTouchMoveEvent(e)}mouseUpEvent(e){this._mouseUpOrTouchEndEvent(e)}touchEndEvent(e){this._mouseUpOrTouchEndEvent(e)}mouseEnterEvent(e){this._highlightSplitters(e.shiftKey)}mouseLeaveEvent(e){const t=Vt(this._splitter.className);Array.from(this._state.parent.getElementsByClassName(t)).forEach((e=>e.classList.remove(Qe.hovered)))}mouseDoubleClickEvent(e){const t=(0,se.layoutInitialSizingState)(this._state.layoutTemplate.value().expression);this._state.undoHistory.beginUndoMacro(nt),this._state.undoHistory.pushUndoCommand(new g(this._state.sizingState,this._state.sizingState.value(),t,nt));const i=this._state.layoutTemplate.value().layoutType;this._state.undoHistory.pushUndoCommand(new m((e=>e?this._state.allLayoutSizesState.set(i,e):this._state.allLayoutSizesState.delete(i)),this._state.allLayoutSizesState.get(this._state.layoutTemplate.value().layoutType),t,nt)),this._state.undoHistory.endUndoMacro()}_highlightSplitters(e){const t=Vt(this._splitter.className);Array.from(this._state.parent.getElementsByClassName(t)).forEach((e=>e.classList.remove(Qe.hovered)));(e?Array.from(this._state.parent.getElementsByClassName(t)):[this._splitterElement]).forEach((e=>e.classList.add(Qe.hovered)))}_mouseDownOrTouchStartEvent(e){ +const t=new r.Point(e.localX+this._splitterElement.offsetLeft,e.localY+this._splitterElement.offsetTop),i=(0,re.deepCopy)(this._state.sizingState.value());this._state.currentLayoutResizeAction.setValue({point:t,splitter:this._splitter,initialState:i,alignedState:this._state.layoutTemplate.value().syncSublayoutsBySplitter(this._splitter,(0,re.deepCopy)(i)),shiftState:e.shiftKey,delta:0}),this._splitterElement.classList.add(Qe["i-active"]),this._highlightSplitters(e.shiftKey)}_pressedMouseOrTouchMoveEvent(e){const t=this._state.currentLayoutResizeAction.value();if(!t)return;t.shiftState!==e.shiftKey&&(this._highlightSplitters(e.shiftKey),t.shiftState=e.shiftKey);const i=new r.Point(e.localX+this._splitterElement.offsetLeft,e.localY+this._splitterElement.offsetTop);t.delta="v"===t.splitter.orientation?i.y-t.point.y:i.x-t.point.x,this._applyMouseMove(t.delta,e.shiftKey)}_mouseUpOrTouchEndEvent(e){const t=this._state.currentLayoutResizeAction.value();if(t&&(this._splitterElement.classList.remove(Qe["i-active"]),this._state.currentLayoutResizeAction.setValue(null),t.currentState)){this._state.undoHistory.beginUndoMacro(rt),this._state.undoHistory.pushUndoCommand(new g(this._state.sizingState,t.initialState,t.currentState,rt));const e=this._state.layoutTemplate.value().layoutType;this._state.undoHistory.pushUndoCommand(new m((t=>t?this._state.allLayoutSizesState.set(e,t):this._state.allLayoutSizesState.delete(e)),this._state.allLayoutSizesState.get(this._state.layoutTemplate.value().layoutType),this._state.sizingState.value(),nt)),this._state.undoHistory.endUndoMacro(),this._state.layoutSizesChanged.setValue(!0)}}_applyMouseMove(e,t){var i;const r=(0,s.ensureNotNull)(this._state.currentLayoutResizeAction.value()),n=t?r.alignedState:r.initialState,o=null!==(i=this._state.options.padding)&&void 0!==i?i:2,a=Et(this._state);r.currentState=this._state.layoutTemplate.value().resizeApplier(a,o,e,r.splitter,(0,re.deepCopy)(n),t),this._state.sizingState.setValue(r.currentState)}}function Rt(e,t,i,s,r){var n,o;const a=null!==(n=e.options.padding)&&void 0!==n?n:2,l=null!==(o=e.options.border)&&void 0!==o?o:0;r=null!=r?r:e.layoutTemplate.value();const c=Et(e),h=r.sizer(c,i,s,a+l,et?e.sizingState.value():void 0);h.width=Math.max(Math.round(h.width),0),h.height=Math.max(Math.round(h.height),0),h.top=Math.round(h.top),h.left=Math.round(h.left),t.metrics=h;const d=t.container.value();if(d){d.style.width=h.width+"px",d.style.height=h.height+"px",d.style.top=h.top+"px",d.style.left=h.left+"px";const e=1===s;false;const t=Math.round(c.width),i=0===h.top&&0===h.left,r=0===h.top&&h.left+h.width===t,n=0===h.top&&h.width===t;d.classList.toggle("top-left-chart",!e&&!n&&i),d.classList.toggle("top-right-chart",!e&&!n&&r),d.classList.toggle("top-full-width-chart",e||n)}t.width.setValue(h.width),t.height.setValue(h.height)}function Nt(e){var t,i,s;let r;const n=e.layoutTemplate.value(),o=e.maximizedChartDef.value();if(r=o?[o]:e.chartWidgetsDefs.slice(0,n.count).filter((e=>!e.hiddenInLayout.value())),r.forEach(((t,i)=>Rt(e,t,i,r.length))), +et&&!e.maximizedChartDef.value()){const r=Et(e),o=null!==(t=e.options.padding)&&void 0!==t?t:2,a=null!==(i=e.options.border)&&void 0!==i?i:0,l=n.splitters(r,o+a,e.sizingState.value()),c=null!==(s=e.splitters.value())&&void 0!==s?s:[];c.forEach(((e,t)=>{t>=l.length&&(e.splitterElement.remove(),e.mouseHandler.destroy(),e.mouseListener.destroy())}));const h=l.map(((t,i)=>{const s=i({def:t,metrics:e.layoutTemplate.value().sizer({top:0,left:0,width:256,height:256},i,s.length,0)}))).sort(((e,t)=>e.metrics.top-t.metrics.top||e.metrics.left-t.metrics.left)).map((e=>e.def));if(s.length<2)return null;let r=s.indexOf(t);return-1===r?null:(r=(r+(i?s.length-1:1))%s.length,s[r])}function Ft(e,t){return e.chartWidgetsDefs.some((e=>{var i;return(null===(i=e.chartWidget)||void 0===i?void 0:i.id())===t}))}function Wt(e){let t=1;for(;e(""+t);)t++;return""+t}function Ht(e){const t=e.activeChartWidget.value();if(t){const i=t.state();return i.chartId=Wt((t=>Ft(e,t))),i.shouldBeSavedEvenIfHidden=!1,i.panes.forEach((e=>{e.sources.forEach((e=>{"alertId"in e&&(e.alertId=void 0)}))})),{content:i}}}function zt(e,t,i){var r,n;const{toastsFactory:o,chartWidgetsDefs:a,customLegendWidgetsFactoriesMap:c}=e;let h={chartWidgetCollection:t,isActive:0===a.length,barsMarksContainersFactory:t=>function(e,t,i){const s=[];{const t=new Ge(e);s.push(t);const i=new Oe(e);s.push(i)}return s}(t,0,e.options),undoHistory:e.undoHistory,readOnly:e.readOnly,initialLoading:e.initialLoading,getToasts:o?()=>o.getChartToasts():void 0,...null!=i?i:{}};void 0!==c&&(h.customLegendWidgetFactories=new Map(c));const d=document.createElement("div");d.classList.add("chart-container"),d.style.position="absolute",d.style.overflow="hidden",e.parent.appendChild(d),l.isEdge&&(d.style.touchAction="none",d.style.msTouchAction="none"),h.className&&d.classList.add(h.className);const p={alive:new u.WatchedValue(!0),container:new u.WatchedValue(d),width:new u.WatchedValue,height:new u.WatchedValue,collapsed:new u.WatchedValue(!1),hiddenInLayout:new u.WatchedValue(!1),visible:new u.WatchedValue,rdState:new te.ResizerDetacherState,requestFullscreen:()=>{e.globalDetachable.value()&&(e.setMaximized(p),e.activeChartWidget.setValue((0,s.ensureNotNull)(p.chartWidget)))},exitFullscreen:()=>{ e.activeChartWidget.value()===p.chartWidget&&e.setMaximized(null)},detachable:e.globalDetachable,fullscreenable:e.globalDetachable,fullscreen:new u.WatchedValue,chartWidget:null};p.rdState.pushOwner(p),a.push(p);const _=()=>{p.visible.setValue(!p.hiddenInLayout.value()&&e.options.resizerBridge.visible.value())};p.hiddenInLayout.subscribe((()=>{(0,s.ensureNotNull)(p.chartWidget).setVisible(!p.hiddenInLayout.value()),_()})),p.collapsed.subscribe((()=>(0,s.ensureNotNull)(p.chartWidget).setCollapsed(p.collapsed.value()))),e.options.resizerBridge.visible.subscribe(_),_(),function(e,t){let i=0,s=0;const r=t.layoutTemplate.value();for(let n=0;nFt(e,t))),g=p.chartWidget=new ie.ChartWidget(h,m,t.metaInfo.uid.value());e.saveChartService&&g.setSaveChartService(e.saveChartService),h.containsData?g.finishInitWithoutConnect():g.connect(),g.withModel(null,(()=>{const t=g.model().model();e.customSources.forEach(((e,i)=>{t.addCustomSource(i,e.factory,e.layer)}))})),e.updateWatchedValue(),e.updateActivityView();const f=null!==(n=null===(r=null==h?void 0:h.content)||void 0===r?void 0:r.linkingGroup)&&void 0!==n?n:null;g.linkingGroupIndex().setValue(f),g.linkingGroupIndex().subscribe(e.updateLinkingGroupCharts);const v=Si(e,f).value();return v.length>0&&(e.symbolLock.value()&&g.setSymbol(v[0].symbolWV().value()),e.intervalLock.value()&&g.setResolution(v[0].resolutionWV().value())),e.updateLinkingGroupCharts(),e.chartWidgetCreatedDelegate.fire(g),p}function Ut(e,t,i,s){const r={...e.widgetOptions,...e.savedChartWidgetOptions.shift()||Ht(e),...0===i||e.symbolLock.value()?void 0:{defSymbol:null}},n=zt(e,t,r),{chartWidget:o}=n;return o.modelCreated().subscribe(null,(()=>{s?s():e.checkAllPendingModelsAlreadyCreated(),e.dateRangeLock.value()&&o===e.activeChartWidget.value()&&e.subscribeToCompletedEventForDateRangeSync(o,!0)}),!0),n}function jt(e){e.hiddenInLayout.setValue(!0);const t=e.container.value();t.parentNode&&t.parentNode.removeChild(t),e.fullscreen.setValue(!1)}function Gt(e,t){e.chartWidgetsDefs.forEach((i=>{const r=(0,s.ensureNotNull)(i.chartWidget);r.onZoom().unsubscribeAll(t),r.onScroll().unsubscribeAll(t),r.withModel(null,(()=>{const t=r.lineToolsSynchronizer();null!==t&&(t.hasChanges().unsubscribe(e.recalcHasChanges),e.recalcHasChanges())}))}))}function qt(e,t){e.chartWidgetsDefs.forEach((i=>{const r=(0,s.ensureNotNull)(i.chartWidget);r.onZoom().subscribe(t,(t=>e.onZoom.fire(t))),r.onScroll().subscribe(t,(()=>e.onScroll.fire())),r.withModel(null,(()=>{const t=r.lineToolsSynchronizer();null!==t&&(t.hasChanges().subscribe(e.recalcHasChanges),e.recalcHasChanges())}))}))}async function $t(e,t,i){var r,n;try{const t=e.chartWidgetsDefs.map((e=>{var t,i,s;return null!==(s=null===(i=null===(t=e.chartWidget)||void 0===t?void 0:t.lineToolsSynchronizer())||void 0===i?void 0:i.flushPendingSavings())&&void 0!==s?s:null})).filter(ce.notNull);t.length&&await Promise.all(t) }catch(e){tt.logError(`Error flushing line tools: ${e}`)}(t=e.checkProFeature(t))in ee.layouts||(t="s"),Gt(e,i);const o=e.layoutType,a=ee.layouts[t].count;(0,A.emit)("layout_about_to_be_changed",t),(null!==(r=e.splitters.value())&&void 0!==r?r:[]).forEach(((e,t)=>{e.splitterElement.remove(),e.mouseHandler.destroy()})),e.splitters.setValue([]);const l=ee.layouts[t];e.layoutTemplate.setValue(l);const c=null!==(n=e.allLayoutSizesState.get(l.layoutType))&&void 0!==n?n:(0,se.layoutInitialSizingState)(l.expression);e.allLayoutSizesState.set(l.layoutType,c),e.sizingState.setValue(c);const h=e.maximizedChartDef.value();o!==t&&e.maximizedChartDef.value()&&e.maximizedChartDef.setValue(null),h&&e.activeChartWidget.setValue((0,s.ensureNotNull)(h.chartWidget));for(let t=0;t=a;if(r=e.maximizedChartDef.value()?e.maximizedChartDef.value()===n:t1),n.fullscreen.setValue(e.maximizedChartDef.value()===n),n.collapsed.setValue(o)}else n&&(jt(n),n.collapsed.setValue(o))}e.sizingState.setValue(c),Nt(e),e.layoutWV.setValue(t),e.setLayoutType(t),e.updateWatchedValue(),function(e){const t=e.layoutTemplate.value().count;e.inlineChartsCount.setValue(t),e.globalDetachable.setValue(t>1)}(e),e.checkAllPendingModelsAlreadyCreated(),qt(e,i),e.inlineChartsCount.value()<1&&a>0&&e.chartWidgetsDefs[a-1].rdState.bridge().attach()}function Yt(e,t,i,s,r){const n=e.actualLayoutCount();return e.chartWidgetsDefs.slice(0,n).filter((e=>e.rdState.bridge().visible.value())).map((e=>e.chartWidget)).filter((t=>t.id()!==i&&(!!t.hasModel()&&(s||e.crosshairLockRaw)))).forEach((e=>e.model().model().setExternalPosition(t,r))),!0}function Kt(e,t,i,s,r){if(Yt(e,t,i,s,r)){const i=e.crossHairSyncBroadcast;if(i){const e={type:"crosshair",payload:{point:t,envState:r,sourceUniqueId:i.uniqueId}};i.channel.postMessage(e)}}}function Zt(e){const t=new BroadcastChannel("ChartWidgetsCollection");return t.onmessage=t=>{const i=t.data,s=e();if(s.crossHairSyncBroadcast&&"crosshair"===i.type)s.crossHairSyncBroadcast.uniqueId!==i.payload.sourceUniqueId&&Yt(s,i.payload.point,null,!1,i.payload.envState)},{channel:t,uniqueId:(0,Q.randomHashN)(6)}}function Xt(e){var t;null===(t=e.crossHairSyncBroadcast)||void 0===t||t.channel.close()}function Jt(e,t,i){if(!e.combinedTrackTimeLock.value()||e.dateRangeLock.value())return;const s=e.layoutTemplate.value().count;e.undoHistory.beginUndoMacro(st),e.chartWidgetsDefs.slice(0,s).filter((e=>e.chartWidget.hasModel()&&e.chartWidget.model().model()!==i)).forEach((e=>{const i=e.chartWidget.model().model(),s=i.mainSeries().syncModel();s&&i.syncTimeWithModel(s.syncSourceTarget(),t)})),e.undoHistory.endUndoMacro()} function Qt(e){return Promise.all(e.map((e=>{const t=e.model().mainSeries();return t.symbolResolvingActive().value()?d(t.dataEvents().symbolResolved()).promise:t.symbolInfo()})))}function ei(e){return e.chartWidgetsDefs.every((e=>e.chartWidget.hasModel()))?Promise.resolve(e.chartWidgetsDefs.map((e=>e.chartWidget))):Promise.all(e.chartWidgetsDefs.map((e=>e.chartWidget.hasModel()||d(e.chartWidget.modelCreated()).promise))).then((()=>ei(e)))}function ti(e,t){var i;if((0,h.enabled)("charting_library_base"))return t;if("s"===t||e.widgetOptions.containsData||e.readOnly||isProductFeatureEnabled(ProductFeatures.MULTIPLE_CHARTS)&&(0,s.ensure)(null===(i=getProductFeatureConfig(ProductFeatures.MULTIPLE_CHARTS))||void 0===i?void 0:i.limit)>=ee.layouts[t].count)return t;return"s"}async function ii(e,t,i){if(i=ti(e,i),e.layoutWV.value()===i)return!1;const s=e.chartWidgetsDefs.map((e=>{var t,i,s;return null!==(s=null===(i=null===(t=e.chartWidget)||void 0===t?void 0:t.lineToolsSynchronizer())||void 0===i?void 0:i.flushPendingSavings())&&void 0!==s?s:null})).filter(ce.notNull);if(s.length)try{await Promise.all(s)}catch(e){tt.logError(`Error flushing line tools: ${e}`)}return e.undoHistory.pushUndoCommand(new le(t,i)),!0}async function si(e,t,i){const{theme:s,onlyActiveChart:r,restoreNonThemeDefaults:n,themeName:o,standardTheme:a,syncState:l=!0,noUndo:c}=i,h=(0,D.getCurrentTheme)().name;let d;r?d=[e.activeChartWidget.value()]:(Gt(e,t),await Promise.all(e.savedChartWidgetOptions.map(((i,s)=>new Promise((i=>{jt(Ut(e,t,s,i))}))))),d=e.chartWidgetsDefs.map((e=>e.chartWidget)),qt(e,t)),c?(a&&new Ye(h,o,l).redo(),d.forEach((e=>{e.model().model().restoreTheme(s,n,c)}))):(e.undoHistory.beginUndoMacro(ot),a&&e.undoHistory.pushUndoCommand(new Ye(h,o,l)),d.forEach((e=>{e.model().model().restoreTheme(s,n)})),e.undoHistory.endUndoMacro())}function ri(e,t){e.symbolLock.setValue(t)}function ni(e,t){const{internalSymbolLock:i,activeChartWidget:s,undoHistory:r,dateRangeLock:n,loadingContent:o,linkingGroupsCharts:l,chartWidgetsDefs:c}=e;if(t!==i.value())if(o)i.setValue(t);else{if(e.undoHistory.beginUndoMacro(at),t){const t=s.value();c.map((e=>e.chartWidget));l.forEach(((i,s)=>{const r=(t.linkingGroupIndex().value(),t);if(void 0!==r){(0,a.muteLinkingGroup)(s,!0);for(const t of i.value())t!==r&&t.symbolWV().value()!==r.symbolWV().value()&&(t.setSymbol(r.symbolWV().value()),n.value()&&e.subscribeToCompletedEventForDateRangeSync(t,!0));(0,a.muteLinkingGroup)(s,!1)}}))}r.setWatchedValue(i,t,at),r.endUndoMacro()}}function oi(e,t){e.intervalLock.setValue(t)}function ai(e,t){const{internalIntervalLock:i,activeChartWidget:s,undoHistory:r,dateRangeLock:n,loadingContent:o,chartWidgetsDefs:l,linkingGroupsCharts:c}=e;if(t!==i.value())if(o)i.setValue(t);else{if(r.beginUndoMacro(lt),t&&t){const t=s.value();l.map((e=>e.chartWidget));c.forEach(((i,s)=>{const r=(t.linkingGroupIndex().value(),t);if(void 0!==r){(0,a.muteLinkingGroup)(s,!0);for(const t of i.value())t!==r&&t.resolutionWV().value()!==r.resolutionWV().value()&&(t.setResolution(r.resolutionWV().value()), n.value()&&e.subscribeToCompletedEventForDateRangeSync(t,!0));(0,a.muteLinkingGroup)(s,!1)}}))}r.setWatchedValue(i,t,lt),r.endUndoMacro()}}function li(e,t){const i=e.activeChartWidget.value();if(i&&i.hasModel()){const s=i.model();t?(e.subscribeToEventsForDateRangeSync(s),e.syncChartsDateRangesWithActiveChartRange()):e.unsubscribeFromEventsForDateRangeSync(s)}e.dateRangeLock.setValue(t)}function ci(e,t){const{internalDateRangeLock:i,undoHistory:s,loadingContent:r}=e;r?i.setValue(t):s.setWatchedValue(i,t,ct)}function hi(e,t){e.trackTimeLock.setValue(t)}function di(e,t){const{internalTrackTimeLock:i,undoHistory:s,loadingContent:r}=e;r?i.setValue(t):s.setWatchedValue(i,t,ht)}function ui(e,t,i){e.symbolLock.value()?pi(e,t,i):e.activeChartWidget.value().setSymbol(t)}function pi(e,t,i){const s=e.activeChartWidget.value();void 0===i&&(i=s.linkingGroupIndex().value());for(const i of e.chartWidgetsDefs){const e=i.chartWidget;(e.hasModel()?e.model().mainSeries().symbolSameAsCurrent(t):e.symbolWV().value()===t)||e.setSymbol(t)}}function _i(e){return e.intervalLock.value()?e.chartWidgetsDefs.map((e=>e.chartWidget)):[e.activeChartWidget.value()]}function mi(e,t,i){if(e.flags.loadingChart||e.flags.setTimeFrameActive||e.flags.setNewResolution)return;(function(e,t,i){(0,Je.setLastUsedResolution)(t),e.flags.setNewResolution=!0;const s=e.activeChartWidget.value();void 0===i&&(i=s.linkingGroupIndex().value());if(e.intervalLock.value())for(const i of e.chartWidgetsDefs){const e=i.chartWidget;e.resolutionWV().value()!==t&&e.setResolution(t)}else s.setResolution(t);e.flags.setNewResolution=!1})(e,t,i)}function gi(e){return new u.WatchedValue(null).spawn()}function fi(e){return[null]}function vi(e){const t=new Xe.WatchedObject((e.chartWidgetsDefs,[null])),i=()=>{t.setValue((e.chartWidgetsDefs,[null]))};e.chartWidgetsDefs.forEach((e=>e.chartWidget.linkingGroupIndex().subscribe(i)));const s=e=>{e.linkingGroupIndex().subscribe(i),i()};return e.chartWidgetCreatedDelegate.subscribe(null,s),t.spawn((()=>{e.chartWidgetsDefs.forEach((e=>e.chartWidget.linkingGroupIndex().unsubscribe(i))),e.chartWidgetCreatedDelegate.unsubscribe(null,s)}))}function Si(e,t){t=null;let i=e.linkingGroupsCharts.get(t);return void 0===i&&(i=new Xe.WatchedObject([],R.compareTwoCollectionsByIds),e.linkingGroupsCharts.set(t,i)),i}function yi(e){var t;const i=new Map;for(const t of e.chartWidgetsDefs){const e=null;let s=i.get(e);void 0===s&&(s=[],i.set(e,s)),s.push(t.chartWidget)}for(const s of(0,R.join)(new Set(e.linkingGroupsCharts.keys()),new Set(i.keys())))Si(e,s).setValue(null!==(t=i.get(s))&&void 0!==t?t:[])}function bi(e){0}function wi(e,t){return new u.WatchedValue(!1).spawn()}function Pi(e,t,i){return(0,Ke.combine)(((e,t)=>e||t),t.weakReference(),wi().ownership())}},46501:(e,t,i)=>{"use strict";i.r(t),i.d(t,{CHART_FONT_FAMILY:()=>n,CHART_MONOSPACE_FONT_FAMILY:()=>o,setChartFontFamily:()=>r});const s="'Trebuchet MS', Roboto, Ubuntu, sans-serif";function r(e){n=e}let n=`-apple-system, BlinkMacSystemFont, ${s}`;const o="monospace"},66509:(e,t,i)=>{"use strict" -;var s=i(36298).TranslatedString,r=i(50151).assert,n=i(76544).Series,o=i(14483),a=i(77212).ActionBinder,l=i(56840).setValue,c=i(14787).TabNames,h=i(64358).showGoToDateDialog,d=i(68335),u=i(4741),p=i(8708).Study,_=i(52329).StudyStub,m=i(28853).isStudy,g=i(13087).LineDataSource,f=i(92249),v=f.isLineTool,S=f.isStudyLineTool,y=i(72877).STUDYPLOTDISPLAYTARGET,b=i(39347).Action,w=i(95059).ACTION_ID,P=i(88348),C=i(36274).Interval,x=i(42960),T=x.getDefaultStyle,I=x.hasVolume,M=i(5894).showSymbolInfoDialog,L=i(91280).InvalidationMask,A=i(82992).linking,k=i(54270).showChangeIntervalDialogAsync,D=i(82723).showDialog,V=i(38618),E=V.availableTimezones,B=V.timezoneIsAvailable,R=i(90995).toggleHideMode,N=i(42856).StudyMetaInfo,O=i(51768).trackEvent,F=i(38325).lastMouseOrTouchEventInfo,W=i(85804);const{viewportChangeEvent:H}=i(28558);var z=i(57898).Delegate,U=i(59224).getLogger("ChartWidget",{color:"#606"}),j=i(53180).appendEllipsis,G=i(19334).addPerfMark,q=i(49152).combineProperty,$=i(94557).ChartWidgetBase,Y=i(49483).CheckMobile.any(),K=i(17133).TIMEFRAMETYPE,Z=i(11095).addPlusButtonProperty;const X=o.enabled("show_average_close_price_line_and_label");var J=new s("change timezone",i(44352).t(null,void 0,i(20505))),Q=new s("scale price chart only",i(44352).t(null,void 0,i(99042))),ee=new s("stay in drawing mode",i(44352).t(null,void 0,i(52010))),te=(new s("hide all drawing tools",i(44352).t(null,void 0,i(54781))),new s("hide marks on bars",i(44352).t(null,void 0,i(44974)))),ie=new s("change symbol last value visibility",i(44352).t(null,void 0,i(53150))),se=(new s("change symbol previous close value visibility",i(44352).t(null,void 0,i(12707))),new s("change previous close price line visibility",i(44352).t(null,void 0,i(59883))),new s("change symbol labels visibility",i(44352).t(null,void 0,i(9402)))),re=new s("change indicators name labels visibility",i(44352).t(null,void 0,i(87027))),ne=new s("change indicators value labels visibility",i(44352).t(null,void 0,i(14922))),oe=(new s("change bid and ask labels visibility",i(44352).t(null,void 0,i(5100))),new s("change bid and ask lines visibility",i(44352).t(null,void 0,i(32311))),new s("change pre/post market price label visibility",i(44352).t(null,void 0,i(49889))),new s("change pre/post market price line visibility",i(44352).t(null,void 0,i(16750))), +;var s=i(36298).TranslatedString,r=i(50151).assert,n=i(76544).Series,o=i(14483),a=i(77212).ActionBinder,l=i(56840).setValue,c=i(14787).TabNames,h=i(64358).showGoToDateDialog,d=i(68335),u=i(4741),p=i(8708).Study,_=i(52329).StudyStub,m=i(28853).isStudy,g=i(13087).LineDataSource,f=i(92249),v=f.isLineTool,S=f.isStudyLineTool,y=i(72877).STUDYPLOTDISPLAYTARGET,b=i(39347).Action,w=i(95059).ACTION_ID,P=i(88348),C=i(36274).Interval,x=i(42960),T=x.getDefaultStyle,I=x.hasVolume,M=i(5894).showSymbolInfoDialog,L=i(91280).InvalidationMask,A=i(82992).linking,k=i(54270).showChangeIntervalDialogAsync,D=i(82723).showDialog,E=i(38618),V=E.availableTimezones,B=E.timezoneIsAvailable,R=i(90995).toggleHideMode,N=i(42856).StudyMetaInfo,O=i(51768).trackEvent,F=i(38325).lastMouseOrTouchEventInfo,W=i(85804);const{viewportChangeEvent:H}=i(28558);var z=i(57898).Delegate,U=i(59224).getLogger("ChartWidget",{color:"#606"}),j=i(53180).appendEllipsis,G=i(19334).addPerfMark,q=i(49152).combineProperty,$=i(94557).ChartWidgetBase,Y=i(49483).CheckMobile.any(),K=i(17133).TIMEFRAMETYPE,Z=i(11095).addPlusButtonProperty;const X=o.enabled("show_average_close_price_line_and_label");var J=new s("change timezone",i(44352).t(null,void 0,i(20505))),Q=new s("scale price chart only",i(44352).t(null,void 0,i(99042))),ee=new s("stay in drawing mode",i(44352).t(null,void 0,i(52010))),te=(new s("hide all drawing tools",i(44352).t(null,void 0,i(54781))),new s("hide marks on bars",i(44352).t(null,void 0,i(44974)))),ie=new s("change symbol last value visibility",i(44352).t(null,void 0,i(53150))),se=(new s("change symbol previous close value visibility",i(44352).t(null,void 0,i(12707))),new s("change previous close price line visibility",i(44352).t(null,void 0,i(59883))),new s("change symbol labels visibility",i(44352).t(null,void 0,i(9402)))),re=new s("change indicators name labels visibility",i(44352).t(null,void 0,i(87027))),ne=new s("change indicators value labels visibility",i(44352).t(null,void 0,i(14922))),oe=(new s("change bid and ask labels visibility",i(44352).t(null,void 0,i(5100))),new s("change bid and ask lines visibility",i(44352).t(null,void 0,i(32311))),new s("change pre/post market price label visibility",i(44352).t(null,void 0,i(49889))),new s("change pre/post market price line visibility",i(44352).t(null,void 0,i(16750))), new s("change high and low price lines visibility",i(44352).t(null,void 0,i(92556)))),ae=new s("change high and low price labels visibility",i(44352).t(null,void 0,i(66805))),le=new s("change average close price line visibility",i(44352).t(null,void 0,i(98866))),ce=new s("change average close price label visibility",i(44352).t(null,void 0,i(39402))),he=new s("change countdown to bar close visibility",i(44352).t(null,void 0,i(58108))),de=new s("change plus button visibility",i(44352).t(null,void 0,i(50190))),ue=new s("change price line visibility",i(44352).t(null,void 0,i(67761))),pe=new s("unlock {title}",i(44352).t(null,void 0,i(92421))),_e=new s("lock {title}",i(44352).t(null,void 0,i(50193))),me=new s("change session breaks visibility",i(44352).t(null,void 0,i(15403))),ge=i(44352).t(null,void 0,i(15241)),fe=i(44352).t(null,void 0,i(29404)),ve=i(44352).t(null,void 0,i(44302)),Se=i(44352).t(null,void 0,i(94338));e.exports.ChartWidget=class extends ${constructor(e,t,i){super(e,t,i),this._options.timeScaleWidget&&(this._options.timeScaleWidget.pressedMouseMoveScale=this._options.handleScale.axisPressedMouseMove.time);var s=this,r=this._options.content,n=this._options.readOnly;this._removeMaximizeHotkey=null,s._hotkeys=u.createGroup({desc:"Chart actions",isDisabled:function(){return!s._isActive}});var o=this._options.containsData,a=this._options.onWidget,l=this._options.onCmeWidget;l&&U.logWarn("[ChartWidget] 'onCmeWidget' option is depricated");var c=this._options.widgetCustomer,h=this._options.timezone,d=this._options.hideSymbolSearch,p=this._options.defSymbol,_=C.isValid(this._options.defInterval)?this._options.defInterval:void 0,m=parseInt(this._options.defStyle),g=x.isValidStyle(m)?m:void 0,f=this._options.defSessionId,v=void 0!==this._options.defTimeframe?"string"==typeof this._options.defTimeframe?{value:this._options.defTimeframe.toUpperCase(),type:K.PeriodBack}:{...this._options.defTimeframe,type:K.TimeRange}:void 0;this._content=r,this._initialLoading=this._options.initialLoading,this._readOnly=n,this._containsData=o,this._defSymbol=p,this._defInterval=_,this._defTimeframe=v,this._defStyle=g,this._onWidget=!!a,this._compareSymbols=this._options.compareSymbols,this._onWidget&&(l?this._widgetCustomer="cme":c&&(this._widgetCustomer=c)),this._hideSymbolSearch=d,this._frameTime=30,this._model=null,this._metaInfo={},this._drawRafId=0,this._compareDialog=this._chartWidgetCollection.getCompareDialogRenderer();var S=this._contentSeriesProperties();S&&(p=S.symbol,_=S.interval),void 0===this._options.useUserChartPreferences&&(this._options.useUserChartPreferences=!0);var y="chartproperties.mainSeriesProperties",b=this._options.useUserChartPreferences?W.defaults(y):W.factoryDefaults(y);this._properties.mainSeriesProperties.merge(b),this._properties.mainSeriesProperties.hasChild("esdBreaksStyle")&&this._properties.mainSeriesProperties.removeProperty("esdBreaksStyle"),_=_||b.interval||"D",x.isValidStyle(g)||(g=x.isValidStyle(b.style)?b.style:T(C.isRange(_))),this._properties.mainSeriesProperties.merge({visible:!0, symbol:p||DEFAULT_SYMBOL,shortName:"",timeframe:"",onWidget:this._onWidget,interval:_,currencyId:null,unitId:null,style:g,sessionId:f}),this._symbolWV.setValue(this.getSymbol()),this._resolutionWV.setValue(this.getResolution()),this._containsData&&this._properties.mainSeriesProperties.merge({showCountdown:!1}),h&&B(h)&&this._properties.timezone.setValue(h),this._tagsChanged=new z,this._timingsMeter=null,this._isActive=this._options.isActive,this._options.container.subscribe((function(e){s._setElement(e)}),{callWithLast:!0});var w=function(){s.resize()};this._options.width.subscribe(w),this._options.height.subscribe(w),this._options.visible.subscribe(this._updateTimingsMeterState.bind(this)),this._aboutToBeDestroyed=new z,this._actions=null,this._definitionsViewModel=null,this._backgroundTopColorSpawn=null,this._backgroundBottomColorSpawn=null}isInitialized(){return Boolean(this._inited)}compareSymbols(){return this._compareSymbols}async _getChartPropertyDefinitionsViewModel(){if(null===this._definitionsViewModel){const{ChartPropertyDefinitionsViewModel:e}=await Promise.all([i.e(6196),i.e(9871),i.e(5871),i.e(3986),i.e(3596)]).then(i.bind(i,73023));if(this._isDestroyed)throw new Error("Chart widget already destroyed");await new Promise((e=>this.withModel(null,e))),null===this._definitionsViewModel&&(this._definitionsViewModel=new e(this.model(),this.properties(),this._options))}return this._definitionsViewModel}_initMaximizeHotkey(e){var t=this;function i(e){e.defaultPrevented||d.modifiersFromEvent(e)===d.Modifiers.Alt&&e.stopPropagation()}function s(e){e.defaultPrevented||d.modifiersFromEvent(e)===d.Modifiers.Alt&&(e.preventDefault(),e.stopPropagation(),t.toggleFullscreen())}return e.addEventListener("mousedown",i,!0),e.addEventListener("click",s,!0),function(){e.removeEventListener("mousedown",i,!0),e.removeEventListener("click",s,!0)}}toggleFullscreen(){var e=this.getResizerDetacher();e.fullscreenable.value()&&(e.fullscreen.value()?e.exitFullscreen():e.requestFullscreen())}_beginRequestActive(){var e=this._chartWidgetCollection.activeChartWidget.value()!==this;if(this._chartWidgetCollection.activeChartWidget.setValue(this),e){const e=F();e.isTouch&&!e.stylus&&this._isLineToolModeExceptBrush()&&this.updateCrossHairPositionIfNeeded(),this._justActivated=!0}}_endRequestActive(){var e=this;this._justActivated&&setTimeout((function(){e._justActivated=!1}),0)}_requestActive(){this._beginRequestActive(),this._endRequestActive()}justActivated(){return this._justActivated}setTimezone(e){e&&B(e)?this._properties.timezone.setValue(e):console.warn("Incorrect timezone: "+JSON.stringify(e))}getTimezone(){return this._properties.timezone.value()}refreshMarks(){this.model().barsMarksSources().forEach((function(e){e.refreshData()}))}clearMarks(e){this.model().barsMarksSources().forEach((function(t){t.clearMarks(e)}))}metaInfoRepository(){return this._metaInfoRepository}_initBackgroundColor(){null===this._backgroundTopColorSpawn&&(this._backgroundTopColorSpawn=this._model.model().backgroundTopColor().spawn(), -this._backgroundTopColorSpawn.subscribe(this._onBackgroundColorChanged.bind(this))),null===this._backgroundBottomColorSpawn&&(this._backgroundBottomColorSpawn=this._model.model().backgroundColor().spawn(),this._backgroundBottomColorSpawn.subscribe(this._onBackgroundColorChanged.bind(this)))}paneWidgets(){return this._paneWidgets}paneByCanvas(e){for(var t=0;t{null!==e&&t()}))}));var t=new b({actionId:w.ChartScalesReset,label:i(44352).t(null,void 0,i(34301)),icon:i(39267),statName:"ResetChart",onExecute:this.GUIResetScales.bind(this),hotkeyGroup:this._hotkeys,hotkeyHash:u.Modifiers.Alt+82}),s=new b({actionId:w.ChartSeriesPriceScaleToggleInvertPriceScale,label:i(44352).t(null,void 0,i(53239)),statName:"Invert Scale",checkable:!0,onExecute:function(){e._model.invertPriceScale(e._model.mainSeries().priceScale())}, +this._backgroundTopColorSpawn.subscribe(this._onBackgroundColorChanged.bind(this))),null===this._backgroundBottomColorSpawn&&(this._backgroundBottomColorSpawn=this._model.model().backgroundColor().spawn(),this._backgroundBottomColorSpawn.subscribe(this._onBackgroundColorChanged.bind(this)))}paneWidgets(){return this._paneWidgets}paneByCanvas(e){for(var t=0;t{null!==e&&t()}))}));var t=new b({actionId:w.ChartScalesReset,label:i(44352).t(null,void 0,i(34301)),icon:i(39267),statName:"ResetChart",onExecute:this.GUIResetScales.bind(this),hotkeyGroup:this._hotkeys,hotkeyHash:u.Modifiers.Alt+82}),s=new b({actionId:w.ChartSeriesPriceScaleToggleInvertPriceScale,label:i(44352).t(null,void 0,i(53239)),statName:"Invert Scale",checkable:!0,onExecute:function(){e._model.invertPriceScale(e._model.mainSeries().priceScale())}, hotkeyGroup:this._hotkeys,hotkeyHash:u.Modifiers.Alt+73}),r=new b({actionId:w.ChartSeriesPriceScaleToggleAutoScale,label:i(44352).t(null,void 0,i(50834)),checkable:!0,onExecute:function(){var t=e._model.mainSeries().priceScale();e._model.togglePriceScaleAutoScaleMode(t),r.update({checked:t.isAutoScale()})}}),n=new b({actionId:w.ChartScalesToggleLockPriceToBarRatio,label:i(44352).t(null,void 0,i(18219)),checkable:!0,statName:"ToggleLockScale",onExecute:function(){e._model.togglePriceScaleLockScaleMode(e._model.mainSeries().priceScale())}}),p=new b({actionId:w.ChartSeriesPriceScaleToggleRegular,label:i(44352).t(null,{context:"scale_menu"},i(72116)),checkable:!0,statName:"ToggleRegularScale",onExecute:function(){var t=e._model.mainSeries().priceScale();e._model.setPriceScaleRegularScaleMode(t),p.update({checked:t.isRegular()})}}),_=new b({actionId:w.ChartSeriesPriceScaleTogglePercentage,label:i(44352).t(null,void 0,i(51102)),checkable:!0,statName:"TogglePercantage",onExecute:function(){e._model.togglePriceScalePercentageScaleMode(e._model.mainSeries().priceScale())},hotkeyGroup:this._hotkeys,hotkeyHash:u.Modifiers.Alt+80}),m=new b({actionId:w.ChartSeriesPriceScaleToggleIndexedTo100,label:i(44352).t(null,void 0,i(20062)),checkable:!0,statName:"ToggleIndexedTo100",onExecute:function(){e._model.togglePriceScaleIndexedTo100ScaleMode(e._model.mainSeries().priceScale())}}),g=new b({actionId:w.ChartSeriesPriceScaleToggleLogarithmic,label:i(44352).t(null,void 0,i(12285)),statName:"ToggleLogScale",checkable:!0,onExecute:function(){e._model.togglePriceScaleLogScaleMode(e._model.mainSeries().priceScale())},hotkeyGroup:this._hotkeys,hotkeyHash:u.Modifiers.Alt+76}),f=new b({actionId:w.ChartUndo,label:i(44352).t(null,void 0,i(81320)),onExecute:function(){O("GUI","Undo"),e._model.undoHistory().undo()},disabled:!0,hotkeyGroup:this._hotkeys,hotkeyHash:u.Modifiers.Mod+90}),v=new b({actionId:w.ChartRedo,label:i(44352).t(null,void 0,i(41615)),onExecute:function(){O("GUI","Redo"),e._model.undoHistory().redo()},disabled:!0,hotkeyGroup:this._hotkeys,hotkeyHash:u.Modifiers.Mod+89});e.withModel(null,(function(){e._model.undoHistory().undoStack().onChange().subscribe(e,e.updateUndoRedo),e._model.undoHistory().redoStack().onChange().subscribe(e,e.updateUndoRedo)}));var S=new b({actionId:w.ChartChangeTimeZone,label:i(44352).t(null,void 0,i(64375)),statName:"TimeZone"}),y=new b({actionId:w.ChartDialogsShowChangeSymbol,label:j(i(44352).t(null,void 0,i(28089))),statName:"ChangeSymbol",onExecute:function(){D({defaultValue:""})}});l("symboledit.dialog_last_entry","");var C={actionId:w.ChartDialogsShowChangeInterval,label:j(i(44352).t(null,void 0,i(99374))),statName:"ChangeInterval",onExecute:function(){k({initVal:A.interval.value(),selectOnInit:!0})}};!o.enabled("show_interval_dialog_on_key_press")||this.readOnly()||this._hideSymbolSearch||(C.shortcutHint=",",C.hotkeyGroup=this._hotkeys,C.hotkeyHash=188);var x,T=new b(C);if(!TradingView.onWidget()){if(this._options.addToWatchlistEnabled){const e={hotkeyGroup:this._hotkeys};x=new WatchListAction(this,e) -}0}var I=new b({actionId:w.ChartTimeScaleReset,label:i(44352).t(null,void 0,i(25333)),icon:i(39267),statName:"ResetScale",onExecute:function(){e.model().resetTimeScale()},hotkeyGroup:this._hotkeys,hotkeyHash:u.Modifiers.Mod+u.Modifiers.Alt+81}),V=new b({actionId:w.ChartRemoveAllIndicators,label:i(44352).t(null,void 0,i(13951)),statName:"RemoveAllIndicators",onExecute:this.removeAllStudies.bind(this)}),E=new b({actionId:w.ChartRemoveAllLineTools,label:i(44352).t(null,void 0,i(1434)),statName:"RemoveAllDrawingTools",onExecute:this.removeAllDrawingTools.bind(this)}),B=new b({actionId:w.ChartRemoveAllIndicatorsAndLineTools,label:i(44352).t(null,void 0,i(97305)),statName:"RemoveAllIndicatorsAndDrawingTools",onExecute:this.removeAllStudiesDrawingTools.bind(this)}),N=this.chartWidgetCollection(),F=new b({actionId:w.ChartApplyIndicatorsToAllCharts,label:i(44352).t(null,void 0,i(95910)),statName:"ApplyIndicatorsToAllCharts",onExecute:function(){N.applyIndicatorsToAllCharts(e)}}),W={actionId:w.ChartDialogsShowInsertIndicators,label:j(i(44352).t(null,void 0,i(98767))),statName:"InsertIndicator",onExecute:function(){e.showIndicators()}};this._options.indicatorsDialogShortcutEnabled&&(W.hotkeyGroup=this._hotkeys,W.hotkeyHash=191,this._hotkeys.add({handler:function(){this.showIndicators()}.bind(this),desc:"Show insert indicator dialog",hotkey:111}));var z,U=new b(W),G=new b({actionId:w.ChartDialogsShowCompareOrAddSymbol,label:j(i(44352).t(null,void 0,i(20229))),statName:"CompareOrAddSymbol",onExecute:this.toggleCompareOrAdd.bind(this)}),$=new b({actionId:w.ChartObjectTreeShow,label:j(i(44352).t(null,void 0,i(675))),statName:"ObjectsTree",onExecute:this.showObjectsTreePanelOrDialog.bind(this)}),Y=new b({actionId:w.ChartDialogsShowGeneralSettings,label:j(i(44352).t(null,void 0,i(89517))),icon:i(51983),statName:"ChartProperties",onExecute:function(){e.showGeneralChartProperties()}}),K=new b({actionId:w.ChartDialogsShowGeneralSettingsSymbolTab,label:j(i(44352).t(null,void 0,i(89517))),icon:i(51983),statName:"MainSeriesProperties",onExecute:function(){e.showGeneralChartProperties(c.symbol)}}),J=new b({actionId:w.ChartSelectedObjectToggleLocked,label:i(44352).t(null,void 0,i(1441)),statName:"ToggleLockSelectedObject",onExecute:this.toggleLockSelectedObject.bind(this)}),pe=new b({actionId:w.ChartSelectedObjectHide,label:i(44352).t(null,void 0,i(31971)),icon:i(84959),statName:"HideSelectedObject",onExecute:this.hideSelectedObject.bind(this)});o.enabled("property_pages")&&(z=new b({actionId:w.ChartSelectedObjectShowSettingsDialog,label:j(i(44352).t(null,void 0,i(89517))),icon:i(51983),statName:"EditSelectedObject",onExecute:function(){e.showSelectedSourcesProperties()}})),this.withModel(null,(function(){var t=e.model().mainSeries(),i=t.properties();i.priceAxisProperties.subscribe(e,e._updateScalesActions),t.priceScaleAboutToBeChanged().subscribe(e,(function(){i.priceAxisProperties.unsubscribeAll(e)})),t.priceScaleChanged().subscribe(e,(function(){i.priceAxisProperties.subscribe(e,e._updateScalesActions),e._updateScalesActions()}))})) +}0}var I=new b({actionId:w.ChartTimeScaleReset,label:i(44352).t(null,void 0,i(25333)),icon:i(39267),statName:"ResetScale",onExecute:function(){e.model().resetTimeScale()},hotkeyGroup:this._hotkeys,hotkeyHash:u.Modifiers.Mod+u.Modifiers.Alt+81}),E=new b({actionId:w.ChartRemoveAllIndicators,label:i(44352).t(null,void 0,i(13951)),statName:"RemoveAllIndicators",onExecute:this.removeAllStudies.bind(this)}),V=new b({actionId:w.ChartRemoveAllLineTools,label:i(44352).t(null,void 0,i(1434)),statName:"RemoveAllDrawingTools",onExecute:this.removeAllDrawingTools.bind(this)}),B=new b({actionId:w.ChartRemoveAllIndicatorsAndLineTools,label:i(44352).t(null,void 0,i(97305)),statName:"RemoveAllIndicatorsAndDrawingTools",onExecute:this.removeAllStudiesDrawingTools.bind(this)}),N=this.chartWidgetCollection(),F=new b({actionId:w.ChartApplyIndicatorsToAllCharts,label:i(44352).t(null,void 0,i(95910)),statName:"ApplyIndicatorsToAllCharts",onExecute:function(){N.applyIndicatorsToAllCharts(e)}}),W={actionId:w.ChartDialogsShowInsertIndicators,label:j(i(44352).t(null,void 0,i(98767))),statName:"InsertIndicator",onExecute:function(){e.showIndicators()}};this._options.indicatorsDialogShortcutEnabled&&(W.hotkeyGroup=this._hotkeys,W.hotkeyHash=191,this._hotkeys.add({handler:function(){this.showIndicators()}.bind(this),desc:"Show insert indicator dialog",hotkey:111}));var z,U=new b(W),G=new b({actionId:w.ChartDialogsShowCompareOrAddSymbol,label:j(i(44352).t(null,void 0,i(20229))),statName:"CompareOrAddSymbol",onExecute:this.toggleCompareOrAdd.bind(this)}),$=new b({actionId:w.ChartObjectTreeShow,label:j(i(44352).t(null,void 0,i(675))),statName:"ObjectsTree",onExecute:this.showObjectsTreePanelOrDialog.bind(this)}),Y=new b({actionId:w.ChartDialogsShowGeneralSettings,label:j(i(44352).t(null,void 0,i(89517))),icon:i(51983),statName:"ChartProperties",onExecute:function(){e.showGeneralChartProperties()}}),K=new b({actionId:w.ChartDialogsShowGeneralSettingsSymbolTab,label:j(i(44352).t(null,void 0,i(89517))),icon:i(51983),statName:"MainSeriesProperties",onExecute:function(){e.showGeneralChartProperties(c.symbol)}}),J=new b({actionId:w.ChartSelectedObjectToggleLocked,label:i(44352).t(null,void 0,i(1441)),statName:"ToggleLockSelectedObject",onExecute:this.toggleLockSelectedObject.bind(this)}),pe=new b({actionId:w.ChartSelectedObjectHide,label:i(44352).t(null,void 0,i(31971)),icon:i(84959),statName:"HideSelectedObject",onExecute:this.hideSelectedObject.bind(this)});o.enabled("property_pages")&&(z=new b({actionId:w.ChartSelectedObjectShowSettingsDialog,label:j(i(44352).t(null,void 0,i(89517))),icon:i(51983),statName:"EditSelectedObject",onExecute:function(){e.showSelectedSourcesProperties()}})),this.withModel(null,(function(){var t=e.model().mainSeries(),i=t.properties();i.priceAxisProperties.subscribe(e,e._updateScalesActions),t.priceScaleAboutToBeChanged().subscribe(e,(function(){i.priceAxisProperties.unsubscribeAll(e)})),t.priceScaleChanged().subscribe(e,(function(){i.priceAxisProperties.subscribe(e,e._updateScalesActions),e._updateScalesActions()}))})) ;var _e=new b({actionId:w.ChartPriceScaleToggleAutoScaleSeriesOnly,label:i(44352).t(null,void 0,i(37207)),checkable:!0,statName:"ScalePriceChartOnly"});_e.binder=new a(_e,this._properties.scalesProperties.scaleSeriesOnly,this.model(),Q);var me=this.model().model();this._properties.scalesProperties.scaleSeriesOnly.listeners().subscribe(null,(function(){me.recalculateAllPanes(H()),me.invalidate(L.full())}));var ye=new b({actionId:w.ChartDrawingToolbarToggleVisibility,label:i(44352).t(null,void 0,i(22903)),checkable:!0,statName:"ToggleDrawingToolbar"}),be=this._options.isDrawingToolbarVisible;be&&(be.subscribe((function(e){ye.update({checked:e})}),{callWithLast:!0}),ye.update({onExecute:function(){be.setValue(!be.value())}}));var we=new b({actionId:"",label:i(44352).t(null,void 0,i(93161)),checkable:!0,statName:"ToggleStayInDrawingMode"});we.binder=new a(we,P.properties().stayInDrawingMode,this.model(),ee),this._hotkeys.add({handler:function(){R()},desc:"Hide all drawing tools",hotkey:u.Modifiers.Mod+u.Modifiers.Alt+72});var Pe=new b({actionId:w.ChartMarksToggleVisibility,label:i(44352).t(null,void 0,i(2441)),checkable:!0,statName:"ToggleHideMarksOnBars"});Pe.binder=new a(Pe,P.hideMarksOnBars(),this.model(),te,(function(){P.hideMarksOnBars().setValue(this.value())}));const Ce=this.properties().scalesProperties;var xe=new b({actionId:w.ChartPriceScaleLabelsToggleSeriesLastValueVisibility,label:i(44352).t(null,void 0,i(52054)),checkable:!0,checked:!1,statName:"ToggleSymbolLastValue"});xe.binder=new a(xe,Ce.showSeriesLastValue,this.model(),ie);var Te=new b({actionId:w.ChartPriceScaleLabelsToggleSymbolNameLabelsVisibility,label:i(44352).t(null,void 0,i(90932)),checkable:!0,checked:!1,statName:"ToggleSymbolLabels"});Te.binding=new a(Te,Ce.showSymbolLabels,this.model(),se);const Ie=q(((e,t)=>e||!1),Ce.showStudyLastValue.weakReference(),Ce.showFundamentalLastValue.weakReference());var Me=new b({actionId:w.ChartPriceScaleLabelsToggleIndicatorsValueLabelsVisibility,label:i(44352).t(null,void 0,i(81584)),checkable:!0,checked:!1,statName:"ToggleStudiesAndFundamentalsPriceLabels"});Me.binder=new a(Me,Ie,this.model(),null,(()=>{const e=!Ie.value();this.model().beginUndoMacro(ne),this.model().setProperty(Ce.showStudyLastValue,e,null),this.model().endUndoMacro()}));const Le=q(((e,t)=>e||!1),Ce.showStudyPlotLabels.weakReference(),Ce.showFundamentalNameLabel.weakReference());var Ae=new b({actionId:w.ChartPriceScaleLabelsToggleIndicatorsNameLabelsVisibility,label:i(44352).t(null,void 0,i(31485)),checkable:!0,checked:!1,statName:"ToggleStudiesAndFundamentalsNameLabels"});Ae.binding=new a(Ae,Le,this.model(),null,(()=>{const e=!Le.value();this.model().beginUndoMacro(re),this.model().setProperty(Ce.showStudyPlotLabels,e,null),this.model().endUndoMacro()}));var ke=this.model().mainSeries().properties().highLowAvgPrice,De=new b({actionId:w.ChartPriceScaleLabelsToggleHighLowPriceLabelsVisibility,label:i(44352).t(null,void 0,i(60259)),checkable:!0,checked:!1,statName:"ToggleHighLowPriceLabels"}) -;De.binding=new a(De,ke.highLowPriceLabelsVisible,this.model(),ae);var Ve=new b({actionId:w.ChartLinesToggleHighLowLinesVisibility,label:i(44352).t(null,void 0,i(21803)),checkable:!0,checked:!1,statName:"ToggleHighLowPriceLine"});if(Ve.binding=new a(Ve,ke.highLowPriceLinesVisible,this.model(),oe),X){var Ee=new b({actionId:w.ChartPriceScaleLabelsToggleAveragePriceLabelVisibility,label:i(44352).t(null,void 0,i(8975)),checkable:!0,checked:!1,statName:"ToggleAverageClosePriceLabel"});Ee.binding=new a(Ee,ke.averageClosePriceLabelVisible,this.model(),ce);var Be=new b({actionId:w.ChartLinesToggleAverageLineVisibility,label:i(44352).t(null,void 0,i(87899)),checkable:!0,checked:!1,statName:"ToggleAverageClosePriceLine"});Be.binding=new a(Be,ke.averageClosePriceLineVisible,this.model(),le)}var Re=new b({actionId:w.ChartPriceScaleToggleCountdownToBarCloseVisibility,label:i(44352).t(null,void 0,i(94370)),checkable:!0,checked:!1,statName:"ToggleCountdown"});Re.binder=new a(Re,this.model().mainSeries().properties().showCountdown,this.model(),he);var Ne=new b({actionId:w.ChartPriceScaleToggleAddOrderPlusButtonVisibility,label:i(44352).t(null,void 0,i(97378)),checkable:!0,checked:Z.value(),statName:"ToggleAddOrderPlusButton"});Ne.binder=new a(Ne,Z,this.model(),de);var Oe=null;this._options.goToDateEnabled&&(Oe=new b({actionId:w.ChartDialogsShowGoToDate,label:j(i(44352).t(null,void 0,i(75190))),statName:"GoToDate",onExecute:function(){var t=e._chartWidgetCollection.activeChartWidget.value();h(t)},hotkeyGroup:this._hotkeys,hotkeyHash:u.Modifiers.Alt+71}));var Fe=new b({actionId:w.ChartDialogsShowSymbolInfo,label:j(i(44352).t(null,void 0,i(65986))),icon:i(37924),checkable:!1,statName:"SymbolInfo",onExecute:function(){var t=e.model().model(),i=t.mainSeries().symbol(),s=t.mainSeries().symbolInfo(),r=t.availableUnits(),n={symbolInfo:s,showUnit:t.unitConversionEnabled(),unitDescription:e=>r.description(e),dateFormatter:t.dateFormatter()};M(i,n)}}),We=new b({actionId:w.ChartPriceScaleMergeAllScalesToLeft,label:ge,statName:"MergeAllScalesToLeft",onExecute:function(){e.model().mergeAllScales("left")}}),He=new b({actionId:w.ChartPriceScaleMergeAllScalesToRight,label:fe,statName:"MergeAllScalesToRight",onExecute:function(){e.model().mergeAllScales("right")}}),ze=new b({actionId:w.ChartPriceScaleMoveToLeft,label:ve,statName:"MoveScaleToLeft",onExecute:function(){e.model().mergeAllScales("left")}}),Ue=new b({actionId:w.ChartPriceScaleMoveToRight,label:Se,statName:"MoveScaleToRight",onExecute:function(){e.model().mergeAllScales("right")}});var je=o.enabled("show_object_tree");if(this._actions={chartProperties:Y,mainSeriesPropertiesAction:K,timeScaleReset:I,chartReset:t,invertSeriesScale:s,logSeriesScale:g,autoSeriesScale:r,lockSeriesScale:n,regularSeriesScale:p,percentSeriesScale:_,indexedTo100SeriesScale:m,compareOrAdd:G,paneObjectTree:je?$:void 0,insertIndicator:U,symbolSearch:y,showSymbolInfoDialog:Fe,changeInterval:T,seriesHide:pe,studyHide:pe,lineToggleLock:J,lineHide:pe,scaleSeriesOnly:_e,drawingToolbarAction:ye,stayInDrawingModeAction:we, -hideAllMarks:Pe,applyTimeZone:S,showCountdown:Re,addPlusButton:Ne,showSeriesLastValue:xe,showHighLowPriceLabels:De,showHighLowPriceLines:Ve,showAverageClosePriceLabel:Ee,showAverageClosePriceLine:Be,showSymbolLabelsAction:Te,showStudyLastValue:Me,showStudyPlotNamesAction:Ae,undo:f,redo:v,mergeLeftScalesAction:We,mergeRightScalesAction:He,moveScaleToLeft:ze,moveScaleToRight:Ue,moveChartAction:undefined},x&&(this._actions.addToWatchlist=x),!TradingView.onWidget()&&o.enabled("text_notes")&&(this._actions.addToTextNotes=undefined),null!==Oe&&(this._actions.gotoDate=Oe),this.createSessionBreaksActions(),!this.readOnly()){var Ge=new b({actionId:w.ChartSelectedObjectRemove,label:i(44352).t(null,void 0,i(34596)),icon:i(35149),statName:"RemoveSelectedObject",onExecute:function(){var e=this._chartWidgetCollection.activeChartWidget.value();e||(e=this),e.removeSelectedSources()}.bind(this),hotkeyGroup:this._hotkeys,hotkeyHash:d.isMacKeyboard?8:46});this._hotkeys.add({handler:function(){this.removeSelectedSources()}.bind(this),desc:"Remove selected source",hotkey:d.isMacKeyboard?46:8}),this._actions.paneRemoveAllStudies=V,this._actions.paneRemoveAllDrawingTools=E,this._actions.paneRemoveAllStudiesDrawingTools=B,this._actions.applyStudiesToAllCharts=F,this._actions.studyRemove=Ge,this._actions.lineRemove=Ge,o.enabled("property_pages")&&(this._actions.format=z)}this._actions.showPriceLine=new b({actionId:w.ChartLinesToggleSeriesPriceLineVisibility,label:i(44352).t(null,void 0,i(91492)),checkable:!0,statName:"TogglePriceLine"}),this._actions.showPriceLine.binding=new a(this._actions.showPriceLine,this.model().mainSeries().properties().showPriceLine,this.model(),ue),this.readOnly()||(this._hotkeys.add({desc:"Draw Horizontal Line here",hotkey:u.Modifiers.Alt+72,handler:function(){e.activePaneWidget&&e.activePaneWidget.drawRightThere("LineToolHorzLine")}}),this._hotkeys.add({desc:"Draw Horizontal Ray here",hotkey:u.Modifiers.Alt+74,handler:function(){e.activePaneWidget&&e.activePaneWidget.drawRightThere("LineToolHorzRay")}}),this._hotkeys.add({desc:"Draw Vertical Line here",hotkey:u.Modifiers.Alt+86,handler:function(){e.activePaneWidget&&e.activePaneWidget.drawRightThere("LineToolVertLine")}}),this._hotkeys.add({desc:"Draw Cross Line here",hotkey:u.Modifiers.Alt+67,handler:function(){e.activePaneWidget&&e.activePaneWidget.drawRightThere("LineToolCrossLine")}}),this._hotkeys.add({desc:"Draw Trend Line",hotkey:u.Modifiers.Alt+84,handler:function(){e.activePaneWidget&&P.tool.setValue("LineToolTrendLine")}}),this._hotkeys.add({desc:"Draw Fib Retracement",hotkey:u.Modifiers.Alt+70,handler:function(){e.activePaneWidget&&P.tool.setValue("LineToolFibRetracement")}})),this._updateScalesActions()}options(){return this._options}executeActionById(e){if("takeScreenshot"===e)return console.warn('Action "takeScreenshot" is deprecated. Use method "takeScreenshot" instead'),void this._chartWidgetCollection.takeScreenshot();e in this._actions?this._actions[e]instanceof b&&this._actions[e].execute():console.warn("Unknown action id: "+e)} +;De.binding=new a(De,ke.highLowPriceLabelsVisible,this.model(),ae);var Ee=new b({actionId:w.ChartLinesToggleHighLowLinesVisibility,label:i(44352).t(null,void 0,i(21803)),checkable:!0,checked:!1,statName:"ToggleHighLowPriceLine"});if(Ee.binding=new a(Ee,ke.highLowPriceLinesVisible,this.model(),oe),X){var Ve=new b({actionId:w.ChartPriceScaleLabelsToggleAveragePriceLabelVisibility,label:i(44352).t(null,void 0,i(8975)),checkable:!0,checked:!1,statName:"ToggleAverageClosePriceLabel"});Ve.binding=new a(Ve,ke.averageClosePriceLabelVisible,this.model(),ce);var Be=new b({actionId:w.ChartLinesToggleAverageLineVisibility,label:i(44352).t(null,void 0,i(87899)),checkable:!0,checked:!1,statName:"ToggleAverageClosePriceLine"});Be.binding=new a(Be,ke.averageClosePriceLineVisible,this.model(),le)}var Re=new b({actionId:w.ChartPriceScaleToggleCountdownToBarCloseVisibility,label:i(44352).t(null,void 0,i(94370)),checkable:!0,checked:!1,statName:"ToggleCountdown"});Re.binder=new a(Re,this.model().mainSeries().properties().showCountdown,this.model(),he);var Ne=new b({actionId:w.ChartPriceScaleToggleAddOrderPlusButtonVisibility,label:i(44352).t(null,void 0,i(97378)),checkable:!0,checked:Z.value(),statName:"ToggleAddOrderPlusButton"});Ne.binder=new a(Ne,Z,this.model(),de);var Oe=null;this._options.goToDateEnabled&&(Oe=new b({actionId:w.ChartDialogsShowGoToDate,label:j(i(44352).t(null,void 0,i(75190))),statName:"GoToDate",onExecute:function(){var t=e._chartWidgetCollection.activeChartWidget.value();h(t)},hotkeyGroup:this._hotkeys,hotkeyHash:u.Modifiers.Alt+71}));var Fe=new b({actionId:w.ChartDialogsShowSymbolInfo,label:j(i(44352).t(null,void 0,i(65986))),icon:i(37924),checkable:!1,statName:"SymbolInfo",onExecute:function(){var t=e.model().model(),i=t.mainSeries().symbol(),s=t.mainSeries().symbolInfo(),r=t.availableUnits(),n={symbolInfo:s,showUnit:t.unitConversionEnabled(),unitDescription:e=>r.description(e),dateFormatter:t.dateFormatter()};M(i,n)}}),We=new b({actionId:w.ChartPriceScaleMergeAllScalesToLeft,label:ge,statName:"MergeAllScalesToLeft",onExecute:function(){e.model().mergeAllScales("left")}}),He=new b({actionId:w.ChartPriceScaleMergeAllScalesToRight,label:fe,statName:"MergeAllScalesToRight",onExecute:function(){e.model().mergeAllScales("right")}}),ze=new b({actionId:w.ChartPriceScaleMoveToLeft,label:ve,statName:"MoveScaleToLeft",onExecute:function(){e.model().mergeAllScales("left")}}),Ue=new b({actionId:w.ChartPriceScaleMoveToRight,label:Se,statName:"MoveScaleToRight",onExecute:function(){e.model().mergeAllScales("right")}});var je=o.enabled("show_object_tree");if(this._actions={chartProperties:Y,mainSeriesPropertiesAction:K,timeScaleReset:I,chartReset:t,invertSeriesScale:s,logSeriesScale:g,autoSeriesScale:r,lockSeriesScale:n,regularSeriesScale:p,percentSeriesScale:_,indexedTo100SeriesScale:m,compareOrAdd:G,paneObjectTree:je?$:void 0,insertIndicator:U,symbolSearch:y,showSymbolInfoDialog:Fe,changeInterval:T,seriesHide:pe,studyHide:pe,lineToggleLock:J,lineHide:pe,scaleSeriesOnly:_e,drawingToolbarAction:ye,stayInDrawingModeAction:we, +hideAllMarks:Pe,applyTimeZone:S,showCountdown:Re,addPlusButton:Ne,showSeriesLastValue:xe,showHighLowPriceLabels:De,showHighLowPriceLines:Ee,showAverageClosePriceLabel:Ve,showAverageClosePriceLine:Be,showSymbolLabelsAction:Te,showStudyLastValue:Me,showStudyPlotNamesAction:Ae,undo:f,redo:v,mergeLeftScalesAction:We,mergeRightScalesAction:He,moveScaleToLeft:ze,moveScaleToRight:Ue,moveChartAction:undefined},x&&(this._actions.addToWatchlist=x),!TradingView.onWidget()&&o.enabled("text_notes")&&(this._actions.addToTextNotes=undefined),null!==Oe&&(this._actions.gotoDate=Oe),this.createSessionBreaksActions(),!this.readOnly()){var Ge=new b({actionId:w.ChartSelectedObjectRemove,label:i(44352).t(null,void 0,i(34596)),icon:i(35149),statName:"RemoveSelectedObject",onExecute:function(){var e=this._chartWidgetCollection.activeChartWidget.value();e||(e=this),e.removeSelectedSources()}.bind(this),hotkeyGroup:this._hotkeys,hotkeyHash:d.isMacKeyboard?8:46});this._hotkeys.add({handler:function(){this.removeSelectedSources()}.bind(this),desc:"Remove selected source",hotkey:d.isMacKeyboard?46:8}),this._actions.paneRemoveAllStudies=E,this._actions.paneRemoveAllDrawingTools=V,this._actions.paneRemoveAllStudiesDrawingTools=B,this._actions.applyStudiesToAllCharts=F,this._actions.studyRemove=Ge,this._actions.lineRemove=Ge,o.enabled("property_pages")&&(this._actions.format=z)}this._actions.showPriceLine=new b({actionId:w.ChartLinesToggleSeriesPriceLineVisibility,label:i(44352).t(null,void 0,i(91492)),checkable:!0,statName:"TogglePriceLine"}),this._actions.showPriceLine.binding=new a(this._actions.showPriceLine,this.model().mainSeries().properties().showPriceLine,this.model(),ue),this.readOnly()||(this._hotkeys.add({desc:"Draw Horizontal Line here",hotkey:u.Modifiers.Alt+72,handler:function(){e.activePaneWidget&&e.activePaneWidget.drawRightThere("LineToolHorzLine")}}),this._hotkeys.add({desc:"Draw Horizontal Ray here",hotkey:u.Modifiers.Alt+74,handler:function(){e.activePaneWidget&&e.activePaneWidget.drawRightThere("LineToolHorzRay")}}),this._hotkeys.add({desc:"Draw Vertical Line here",hotkey:u.Modifiers.Alt+86,handler:function(){e.activePaneWidget&&e.activePaneWidget.drawRightThere("LineToolVertLine")}}),this._hotkeys.add({desc:"Draw Cross Line here",hotkey:u.Modifiers.Alt+67,handler:function(){e.activePaneWidget&&e.activePaneWidget.drawRightThere("LineToolCrossLine")}}),this._hotkeys.add({desc:"Draw Trend Line",hotkey:u.Modifiers.Alt+84,handler:function(){e.activePaneWidget&&P.tool.setValue("LineToolTrendLine")}}),this._hotkeys.add({desc:"Draw Fib Retracement",hotkey:u.Modifiers.Alt+70,handler:function(){e.activePaneWidget&&P.tool.setValue("LineToolFibRetracement")}})),this._updateScalesActions()}options(){return this._options}executeActionById(e){if("takeScreenshot"===e)return console.warn('Action "takeScreenshot" is deprecated. Use method "takeScreenshot" instead'),void this._chartWidgetCollection.takeScreenshot();e in this._actions?this._actions[e]instanceof b&&this._actions[e].execute():console.warn("Unknown action id: "+e)} getCheckableActionState(e){if(e in this._actions){var t=this._actions[e];if(t instanceof b&&t.isCheckable())return t.isChecked();console.warn("Action "+e+" has no state")}else console.warn("Unknown action id: "+e);return null}_updateScalesActions(){if(null!==this._actions){var e=this.model().mainSeries(),t=e.priceScale(),i=e.properties(),s=t.isLockScale(),r=i.style.value()===n.STYLE_PNF;this._actions.percentSeriesScale.update({disabled:s||r,checked:t.isPercentage()}),this._actions.logSeriesScale.update({disabled:s||r,checked:t.isLog()}),this._actions.regularSeriesScale.update({disabled:s||r,checked:t.isRegular()}),this._actions.indexedTo100SeriesScale.update({disabled:s||r,checked:t.isIndexedTo100()}),this._actions.invertSeriesScale.update({checked:t.isInverted()}),this._actions.lockSeriesScale.update({checked:t.isLockScale()}),this._actions.autoSeriesScale.update({checked:t.isAutoScale(),disabled:t.properties().autoScaleDisabled.value()})}}removeAllStudies(){this._model.removeAllStudies()}removeAllDrawingTools(){this._model.removeAllDrawingTools()}removeAllStudiesDrawingTools(){this._model.removeAllStudiesAndDrawingTools()}defaultSymbol(){return this._defSymbol}widget(){return this._mainDiv}_onBackgroundColorChanged(){for(var e=0;e0;)for(var t=this._content.panes[e].sources,i=t.length;i-- >0;)if("MainSeries"===t[i].type)return t[i].state}updateUndoRedo(){this._model&&(this.actions().undo.update({disabled:this._model.undoHistory().undoStack().isEmpty()}),this.actions().redo.update({disabled:this._model.undoHistory().redoStack().isEmpty()}))}createSessionBreaksActions(){var e=new b({actionId:w.ChartSessionBreaksToggleVisibility,label:i(44352).t(null,void 0,i(59827)),checkable:!0,statName:"ToggleSessionBreaks"});e.binder=new a(e,this._model.chartModel().sessions().properties().graphics.vertlines.sessBreaks.visible,this.model(),me),this._actions.sessionBreaks=e}updateActionForIntradayOnly(e){e&&e instanceof b&&e.update({disabled:this.model().mainSeries().isDWM()})}containsVolume(){return this.model().dataSources().some((function(e){return e instanceof p&&"Volume"===e.metaInfo().shortId}))}containsStudyByPredicate(e){return!!this._model&&this._model.dataSources().some((function(t){if(!(t instanceof p))return!1;var i=t.metaInfo();return e(i)}))}containsStudy(e){return this.containsStudyByPredicate((function(t){return t.id===e||t.fullId===e}))}isSmall(){return this._width()<550||this._height()<300}onWidget(){return this._onWidget}onCmeWidget(){return"cme"===this.widgetCustomer()}widgetCustomer(){return this._widgetCustomer}resize(){ -var e=this._height()+"px",t=this._width()+"px";this._mainDiv.style.height=e,this._mainDiv.style.width=t,this._elMainTable.style.height=e,this._elMainTable.style.width=t,this._resizeHandler&&this._mainDiv&&this._resizeHandler()}applyOverrides(e){var t={};for(var i in e)i.startsWith("mainSeriesProperties.priceAxisProperties")||(t[i]=e[i]);if(applyPropertiesOverrides(this.properties(),null,!1,t,null),this._model){applyPropertiesOverrides(this._model.model().properties(),null,!1,t),applyPropertiesOverrides(this._model.mainSeries().properties(),null,!1,t,"mainSeriesProperties"),this._model.model().sessions().applyOverrides(t);const e=this._model.chartModel().watermarkSource();null!==e&&e.applyOverrides(t)}}applyStudiesOverrides(e){N.mergeDefaultsOverrides(e),this._applyStudiesOverrides()}setActive(e){this._isActive=e,F().isTouch&&(e&&0!==this.selectPointMode().value()?this.startTrackingMode():this.exitTrackingMode()),this._paneWidgets.forEach((function(e){e.update()})),e||this.model().selectionMacro((function(e){e.clearSelection()}))}isActive(){return this._isActive}showReplayOrderConfirmationDialog(){if(!this.model().isInReplay())return Promise.resolve()}_addPerfMark(e){G("ChartWidget."+this._id+"."+e)}getResizerDetacher(){return this._options}}},3162:(e,t,i)=>{"use strict";var s=i(50151).assert,r=i(51608).createDeferredPromise,n=i(36298).TranslatedString,o=i(75531).layouts,a=i(18687).createUndoHistory,l=i(88348),c=i(4741),h=i(68335),d=i(76422),u=i(14483),p=i(97145).WatchedValue,_=i(59224).getLogger("Chart.ChartWidgetCollection"),m=i(21861).preventDefaultForContextMenu,g=i(88732),f=i(13323).GeneralChartPropertiesRenderer,v=i(42120).CompareDialogRenderer,S=i(84015).isOnMobileAppPage,y=i(41249),b=i(42960),w=i(57898).Delegate;const{isSupportedLayout:P,tryGuessingTheMostSuitableLayout:C}=i(75531);var x;const T=i(36174).randomHash;var I=i(55148),M=I.applyIndicatorsToAllChartsImpl,L=I.applyIndicatorToAllChartsImpl,A=I.lineToolsAndGroupsDTOsImpl,k=I.getStateForChartImpl,D=I.resetLineToolsInvalidatedImpl,V=I.applyLineToolUpdateNotificationImpl,E=I.createClipboardHandler,B=I.chartsSymbolsImpl,R=I.updateLayoutImpl,N=I.computeContentBoxImpl,O=(I.getVisuallyAdjacentDefImpl,I.setLayoutImpl),F=I.removeChartWidgetSubscriptionsImpl,W=I.generateNewChartId,H=I.syncCrosshairImpl,z=I.createBroadcastChannel,U=I.destroyBroadcastChannel,j=I.syncScrollImpl,G=I.allInitialModelsCreated,q=I.allInitialSymbolsResolved,$=I.applyThemeImpl,Y=I.isFirstChartInLayout,K=I.deserializedChartIds,Z=I.handleDateRangeLockChange,X=I.handleInternalDateRangeLockChange,J=I.handleTrackTimeLockChange,Q=I.handleInternalTrackTimeLockChange,ee=I.handleIntervalLockChange,te=I.handleInternalIntervalLockChange,ie=I.handleSymbolLockChange,se=I.handleInternalSymbolLockChange,re=(I.handleConnectionLimitReachedChanged,I.createLeftBottomChartWidgetWV),ne={saveChartEnabled:!0,takeScreenshotEnabled:!0,publishedChartsEnabled:!0},oe=new n("change series style",i(44352).t(null,void 0,i(53438)));i(44352).t(null,void 0,i(19149));e.exports=function(e){ -var t=this,n=Object.assign({},ne,e),ae=new p,le=n.readOnly||!1,ce=T(),he=[],de=0,ue=new p,pe=new p,_e=new p,me="s",ge=new p(null),fe=new Map,ve=new p([]),Se=new p,ye=[];const be={isConfirmationAboutReplayLocked:!1,loadingChart:!1,setTimeFrameActive:!1,setNewResolution:!1};var we=!1,Pe=!1,Ce=new p(!1),xe=new p(null),Te=new p(!1),Ie=new p(!1);Ie.subscribe((e=>ie(mt(),e)));var Me=new p(Ie.value());Me.subscribe((e=>se(mt(),e)));var Le=new p(!1);Le.subscribe((e=>ee(mt(),e)));var Ae=new p(Le.value());Ae.subscribe((e=>te(mt(),e)));var ke=new p(me),De=new p(!1);De.subscribe((e=>J(mt(),e)));var Ve=I.combinedTrackTimeLock(ke,De,he);De.subscribe((e=>J(mt(),e)));var Ee=new p(Ve.value());Ee.subscribe((e=>Q(mt(),e)));var Be=new p(!1);Be.subscribe((e=>Z(mt(),e))),ge.subscribe(Ut);var Re=new p(Be.value());Re.subscribe((e=>X(mt(),e)));var Ne=new p(TVSettings.getBool("chart.syncCrosshair",!0)),Oe=c.createGroup({desc:"Layout"}),Fe=null,We=null,He=null,ze=null;if(window.TVD){var Ue=window.TVD.crosshairSyncEnabled;Ue?(Ue.value()&&(He=z(mt)),ze=Ue.subscribe((e=>{e?He=z(mt):(U(mt()),He=null)}))):He=z(mt)}var je=Ne.value();Ne.subscribe((function(e){je=e=!!e,TVSettings.setValue("chart.syncCrosshair",e);for(var t=0;t{Ye.setValue(null===e?null:e.chartWidget)}));var Ke=n.widgetOptions||{},Ze=n.metaInfo||{},Xe={id:new p(Ze.id||null),name:new p(Ze.name),description:new p(Ze.description),username:new p(Ze.username),uid:new p(Ze.uid),lastModified:new p(Ze.lastModified)},Je=a();Je.onChange().subscribe(null,(function(e){d.emit("undo_redo_state_changed",e)}));var Qe=n.resizerBridge.container.value();Qe.addEventListener("contextmenu",m);var et,tt=r(),it=new w,st=new w,rt=new w,nt=new p(!1),ot=new p(null),at=null,lt=null;n.seriesControlBarEnabled&&(et="0px",ot.setValue(document.createElement("div")),ot.value().style.left=et,ot.value().style.right=et,ot.value().style.bottom=et,ot.value().classList.add("chart-toolbar","chart-controls-bar"),ot.value().setAttribute("data-is-chart-toolbar-component","true"),Qe.appendChild(ot.value()),Promise.all([i.e(2666),i.e(3842),i.e(4015),i.e(5145),i.e(6),i.e(5993),i.e(5649),i.e(8056),i.e(6639),i.e(6036),i.e(6106),i.e(9916),i.e(1033),i.e(4987),i.e(962),i.e(3179),i.e(5050),i.e(3291),i.e(7260)]).then(i.bind(i,33279)).then((({BottomToolbarRenderer:e})=>{var i=n.resizerBridge,s=[i.container.spawn(),i.width.spawn(),i.height.spawn()],r=i.container.value(),o=function(){var e=r.getBoundingClientRect(),t=N(mt());return t.top=e.top+t.top,t.left=e.left+t.left,t},a=new w,l=function(){a.fire()};s.forEach((function(e){e.subscribe(l)}));var c=function(){s.forEach((function(e){e.destroy()})),a.destroy()};at=new e(ot.value(),a,o,t,ChartApiInstance,Ke,n.seriesControlBar),lt=function(){null!==at&&(at.destroy(),at=null,ot.value().remove(),ot.setValue(null)),c()}})));var ct=new f(t),ht=new v(t);function dt(){nt.setValue(he.some((e=>{ -const t=e.chartWidget.lineToolsSynchronizer();return null!==t&&t.hasChanges().value()})))}function ut(e){return I.checkProFeatureImpl(mt(),e)}xe.subscribe((()=>yt()));const pt=new Map,_t=()=>I.updateLinkingGroupCharts(mt());function mt(){return{undoHistory:Je,chartWidgetsDefs:he,chartsCountToSave:gt,actualLayoutCount:ft,savedChartWidgetOptions:ye,activeChartWidget:ae,options:n,parent:Qe,toastsFactory:null,crosshairLockRaw:je,crossHairSyncBroadcast:He,setChartStorageNotificationSubscription:e=>{We=e},maximizedChartDef:$e,setMaximized:xt,layoutTemplate:_e,widthWV:Ge,heightWV:qe,checkProFeature:ut,lineToolsSynchronizerHasChanges:nt,recalcHasChanges:dt,onZoom:st,onScroll:rt,layoutType:me,layoutWV:ke,setLayoutType:e=>{me=e},isPhoneSize:Ce,viewMode:Se,updateViewMode:It,loadingContent:we,setLoadingContent:e=>{we=e},initialLoading:Pe,inlineChartsCount:pe,updateWatchedValue:Mt,checkAllPendingModelsAlreadyCreated:Tt,readOnly:le,symbolLock:Ie,internalSymbolLock:Me,intervalLock:Le,internalIntervalLock:Ae,dateRangeLock:Re,internalDateRangeLock:Re,trackTimeLock:De,internalTrackTimeLock:Ee,crosshairLock:Ne,customLegendWidgetsFactoriesMap:ti,globalDetachable:ue,saveChartService:Fe,customSources:Qt,updateActivityView:Lt,chartWidgetCreatedDelegate:it,sizingState:xe,currentLayoutResizeAction:ge,allLayoutSizesState:fe,splitters:ve,widgetOptions:Ke,bottomToolbar:ot,replayContainer:ei,layoutSizesChanged:Te,subscribeToCompletedEventForDateRangeSync:Wt,subscribeToEventsForDateRangeSync:Ht,unsubscribeFromEventsForDateRangeSync:zt,syncChartsDateRangesWithActiveChartRange:Gt,combinedTrackTimeLock:Ve,flags:be,linkingGroupsCharts:pt,updateLinkingGroupCharts:_t}}function gt(){return ft()}function ft(){return o[me].count}function vt(e,t,i,s,r){return k(mt(),e,t,i,s,r)}function St(e){return e.value()?1:0}function yt(){R(mt())}Ge.subscribe(yt),qe.subscribe(yt),this.updateLayout=yt;const bt=I.activeLinkingGroupWV(ae),wt=I.allLinkingGroupsWV(mt());function Pt(e){return e.rdState.owner.value()!==e}function Ct(e){return O(mt(),e,t)}function xt(e){$e.value()!==e&&($e.setValue(e),Ct(me))}function Tt(){he.every((e=>e.chartWidget.hasModel()))&&(Mt(),d.emit("layout_changed"))}function It(){"s"===me||$e.value()?Se.setValue(x.ForceFullscreen):Se.setValue(x.Multichart)}function Mt(){var e=Math.min(_e.value().count,he.length)-1;if(e<0)ae.deleteValue();else{var t=de;t<0&&(t=0),t>e&&(t=e),ae.setValue(he[t].chartWidget)}}function Lt(){for(var e=he.length;e--;){var t=e===de;he[e].container.value().classList.toggle("active",t),he[e].container.value().classList.toggle("inactive",!t)}}function At(e){}const kt=new w;var Dt=new w,Vt=new p,Et=new p([]),Bt=null;function Rt(e){var t=e.mainSeries().properties();t.style.subscribe(null,Nt),Nt(t.style),e.model().onSelectedSourceChanged().subscribe(null,Ot),Be.value()&&(Ht(e),Gt()),Ot(e.selection().allSources())}function Nt(e){Vt.setValue(e.value())}function Ot(){var e=Bt.model();Et.setValue(e.selection().allSources())}ae.subscribe((function(e){if(e){for(var t,i=he.length;i--;)if(he[i].chartWidget===e){t=i;break} +var e=this._height()+"px",t=this._width()+"px";this._mainDiv.style.height=e,this._mainDiv.style.width=t,this._elMainTable.style.height=e,this._elMainTable.style.width=t,this._resizeHandler&&this._mainDiv&&this._resizeHandler()}applyOverrides(e){var t={};for(var i in e)i.startsWith("mainSeriesProperties.priceAxisProperties")||(t[i]=e[i]);if(applyPropertiesOverrides(this.properties(),null,!1,t,null),this._model){applyPropertiesOverrides(this._model.model().properties(),null,!1,t),applyPropertiesOverrides(this._model.mainSeries().properties(),null,!1,t,"mainSeriesProperties"),this._model.model().sessions().applyOverrides(t);const e=this._model.chartModel().watermarkSource();null!==e&&e.applyOverrides(t)}}applyStudiesOverrides(e){N.mergeDefaultsOverrides(e),this._applyStudiesOverrides()}setActive(e){this._isActive=e,F().isTouch&&(e&&0!==this.selectPointMode().value()?this.startTrackingMode():this.exitTrackingMode()),this._paneWidgets.forEach((function(e){e.update()})),e||this.model().selectionMacro((function(e){e.clearSelection()}))}isActive(){return this._isActive}showReplayOrderConfirmationDialog(){if(!this.model().isInReplay())return Promise.resolve()}_addPerfMark(e){G("ChartWidget."+this._id+"."+e)}getResizerDetacher(){return this._options}}},3162:(e,t,i)=>{"use strict";var s=i(50151).assert,r=i(51608).createDeferredPromise,n=i(36298).TranslatedString,o=i(75531).layouts,a=i(18687).createUndoHistory,l=i(88348),c=i(4741),h=i(68335),d=i(76422),u=i(14483),p=i(97145).WatchedValue,_=i(59224).getLogger("Chart.ChartWidgetCollection"),m=i(21861).preventDefaultForContextMenu,g=i(88732),f=i(13323).GeneralChartPropertiesRenderer,v=i(42120).CompareDialogRenderer,S=i(84015).isOnMobileAppPage,y=i(41249),b=i(42960),w=i(57898).Delegate;const{isSupportedLayout:P,tryGuessingTheMostSuitableLayout:C}=i(75531);var x;const T=i(36174).randomHash;var I=i(55148),M=I.applyIndicatorsToAllChartsImpl,L=I.applyIndicatorToAllChartsImpl,A=I.lineToolsAndGroupsDTOsImpl,k=I.getStateForChartImpl,D=I.resetLineToolsInvalidatedImpl,E=I.applyLineToolUpdateNotificationImpl,V=I.createClipboardHandler,B=I.chartsSymbolsImpl,R=I.updateLayoutImpl,N=I.computeContentBoxImpl,O=(I.getVisuallyAdjacentDefImpl,I.setLayoutImpl),F=I.removeChartWidgetSubscriptionsImpl,W=I.generateNewChartId,H=I.syncCrosshairImpl,z=I.createBroadcastChannel,U=I.destroyBroadcastChannel,j=I.syncScrollImpl,G=I.allInitialModelsCreated,q=I.allInitialSymbolsResolved,$=I.applyThemeImpl,Y=I.isFirstChartInLayout,K=I.deserializedChartIds,Z=I.handleDateRangeLockChange,X=I.handleInternalDateRangeLockChange,J=I.handleTrackTimeLockChange,Q=I.handleInternalTrackTimeLockChange,ee=I.handleIntervalLockChange,te=I.handleInternalIntervalLockChange,ie=I.handleSymbolLockChange,se=I.handleInternalSymbolLockChange,re=(I.handleConnectionLimitReachedChanged,I.createLeftBottomChartWidgetWV),ne={saveChartEnabled:!0,takeScreenshotEnabled:!0,publishedChartsEnabled:!0},oe=new n("change series style",i(44352).t(null,void 0,i(53438)));i(44352).t(null,void 0,i(19149));e.exports=function(e){ +var t=this,n=Object.assign({},ne,e),ae=new p,le=n.readOnly||!1,ce=T(),he=[],de=0,ue=new p,pe=new p,_e=new p,me="s",ge=new p(null),fe=new Map,ve=new p([]),Se=new p,ye=[];const be={isConfirmationAboutReplayLocked:!1,loadingChart:!1,setTimeFrameActive:!1,setNewResolution:!1};var we=!1,Pe=!1,Ce=new p(!1),xe=new p(null),Te=new p(!1),Ie=new p(!1);Ie.subscribe((e=>ie(mt(),e)));var Me=new p(Ie.value());Me.subscribe((e=>se(mt(),e)));var Le=new p(!1);Le.subscribe((e=>ee(mt(),e)));var Ae=new p(Le.value());Ae.subscribe((e=>te(mt(),e)));var ke=new p(me),De=new p(!1);De.subscribe((e=>J(mt(),e)));var Ee=I.combinedTrackTimeLock(ke,De,he);De.subscribe((e=>J(mt(),e)));var Ve=new p(Ee.value());Ve.subscribe((e=>Q(mt(),e)));var Be=new p(!1);Be.subscribe((e=>Z(mt(),e))),ge.subscribe(Ut);var Re=new p(Be.value());Re.subscribe((e=>X(mt(),e)));var Ne=new p(TVSettings.getBool("chart.syncCrosshair",!0)),Oe=c.createGroup({desc:"Layout"}),Fe=null,We=null,He=null,ze=null;if(window.TVD){var Ue=window.TVD.crosshairSyncEnabled;Ue?(Ue.value()&&(He=z(mt)),ze=Ue.subscribe((e=>{e?He=z(mt):(U(mt()),He=null)}))):He=z(mt)}var je=Ne.value();Ne.subscribe((function(e){je=e=!!e,TVSettings.setValue("chart.syncCrosshair",e);for(var t=0;t{Ye.setValue(null===e?null:e.chartWidget)}));var Ke=n.widgetOptions||{},Ze=n.metaInfo||{},Xe={id:new p(Ze.id||null),name:new p(Ze.name),description:new p(Ze.description),username:new p(Ze.username),uid:new p(Ze.uid),lastModified:new p(Ze.lastModified)},Je=a();Je.onChange().subscribe(null,(function(e){d.emit("undo_redo_state_changed",e)}));var Qe=n.resizerBridge.container.value();Qe.addEventListener("contextmenu",m);var et,tt=r(),it=new w,st=new w,rt=new w,nt=new p(!1),ot=new p(null),at=null,lt=null;n.seriesControlBarEnabled&&(et="0px",ot.setValue(document.createElement("div")),ot.value().style.left=et,ot.value().style.right=et,ot.value().style.bottom=et,ot.value().classList.add("chart-toolbar","chart-controls-bar"),ot.value().setAttribute("data-is-chart-toolbar-component","true"),Qe.appendChild(ot.value()),Promise.all([i.e(2666),i.e(3842),i.e(4015),i.e(5145),i.e(6),i.e(5993),i.e(5649),i.e(8056),i.e(6639),i.e(6036),i.e(6106),i.e(9916),i.e(1033),i.e(4987),i.e(962),i.e(3179),i.e(5050),i.e(3291),i.e(7260)]).then(i.bind(i,33279)).then((({BottomToolbarRenderer:e})=>{var i=n.resizerBridge,s=[i.container.spawn(),i.width.spawn(),i.height.spawn()],r=i.container.value(),o=function(){var e=r.getBoundingClientRect(),t=N(mt());return t.top=e.top+t.top,t.left=e.left+t.left,t},a=new w,l=function(){a.fire()};s.forEach((function(e){e.subscribe(l)}));var c=function(){s.forEach((function(e){e.destroy()})),a.destroy()};at=new e(ot.value(),a,o,t,ChartApiInstance,Ke,n.seriesControlBar),lt=function(){null!==at&&(at.destroy(),at=null,ot.value().remove(),ot.setValue(null)),c()}})));var ct=new f(t),ht=new v(t);function dt(){nt.setValue(he.some((e=>{ +const t=e.chartWidget.lineToolsSynchronizer();return null!==t&&t.hasChanges().value()})))}function ut(e){return I.checkProFeatureImpl(mt(),e)}xe.subscribe((()=>yt()));const pt=new Map,_t=()=>I.updateLinkingGroupCharts(mt());function mt(){return{undoHistory:Je,chartWidgetsDefs:he,chartsCountToSave:gt,actualLayoutCount:ft,savedChartWidgetOptions:ye,activeChartWidget:ae,options:n,parent:Qe,toastsFactory:null,crosshairLockRaw:je,crossHairSyncBroadcast:He,setChartStorageNotificationSubscription:e=>{We=e},maximizedChartDef:$e,setMaximized:xt,layoutTemplate:_e,widthWV:Ge,heightWV:qe,checkProFeature:ut,lineToolsSynchronizerHasChanges:nt,recalcHasChanges:dt,onZoom:st,onScroll:rt,layoutType:me,layoutWV:ke,setLayoutType:e=>{me=e},isPhoneSize:Ce,viewMode:Se,updateViewMode:It,loadingContent:we,setLoadingContent:e=>{we=e},initialLoading:Pe,inlineChartsCount:pe,updateWatchedValue:Mt,checkAllPendingModelsAlreadyCreated:Tt,readOnly:le,symbolLock:Ie,internalSymbolLock:Me,intervalLock:Le,internalIntervalLock:Ae,dateRangeLock:Re,internalDateRangeLock:Re,trackTimeLock:De,internalTrackTimeLock:Ve,crosshairLock:Ne,customLegendWidgetsFactoriesMap:ti,globalDetachable:ue,saveChartService:Fe,customSources:Qt,updateActivityView:Lt,chartWidgetCreatedDelegate:it,sizingState:xe,currentLayoutResizeAction:ge,allLayoutSizesState:fe,splitters:ve,widgetOptions:Ke,bottomToolbar:ot,replayContainer:ei,layoutSizesChanged:Te,subscribeToCompletedEventForDateRangeSync:Wt,subscribeToEventsForDateRangeSync:Ht,unsubscribeFromEventsForDateRangeSync:zt,syncChartsDateRangesWithActiveChartRange:Gt,combinedTrackTimeLock:Ee,flags:be,linkingGroupsCharts:pt,updateLinkingGroupCharts:_t}}function gt(){return ft()}function ft(){return o[me].count}function vt(e,t,i,s,r){return k(mt(),e,t,i,s,r)}function St(e){return e.value()?1:0}function yt(){R(mt())}Ge.subscribe(yt),qe.subscribe(yt),this.updateLayout=yt;const bt=I.activeLinkingGroupWV(ae),wt=I.allLinkingGroupsWV(mt());function Pt(e){return e.rdState.owner.value()!==e}function Ct(e){return O(mt(),e,t)}function xt(e){$e.value()!==e&&($e.setValue(e),Ct(me))}function Tt(){he.every((e=>e.chartWidget.hasModel()))&&(Mt(),d.emit("layout_changed"))}function It(){"s"===me||$e.value()?Se.setValue(x.ForceFullscreen):Se.setValue(x.Multichart)}function Mt(){var e=Math.min(_e.value().count,he.length)-1;if(e<0)ae.deleteValue();else{var t=de;t<0&&(t=0),t>e&&(t=e),ae.setValue(he[t].chartWidget)}}function Lt(){for(var e=he.length;e--;){var t=e===de;he[e].container.value().classList.toggle("active",t),he[e].container.value().classList.toggle("inactive",!t)}}function At(e){}const kt=new w;var Dt=new w,Et=new p,Vt=new p([]),Bt=null;function Rt(e){var t=e.mainSeries().properties();t.style.subscribe(null,Nt),Nt(t.style),e.model().onSelectedSourceChanged().subscribe(null,Ot),Be.value()&&(Ht(e),Gt()),Ot(e.selection().allSources())}function Nt(e){Et.setValue(e.value())}function Ot(){var e=Bt.model();Vt.setValue(e.selection().allSources())}ae.subscribe((function(e){if(e){for(var t,i=he.length;i--;)if(he[i].chartWidget===e){t=i;break} if(!isFinite(t))throw new Error("Cannot make detached ChartWidget active");if(de!==t){$e.value()&&(Pt(he[t])||$e.setValue(he[t])),de=t,Lt();for(i=he.length;i--;)he[i].chartWidget!==e&&he[i].chartWidget.setActive(!1);di(),e.setActive(!0),l.activePointSelectionMode.setValue(e.selectPointMode().value())}!function(e){if(Bt!==e){if(Bt&&(Bt.modelCreated().unsubscribe(null,Rt),Bt.hasModel())){var t=Bt.model();Be.value()&&zt(t),t.mainSeries().properties().style.unsubscribe(null,Nt),t.model().onSelectedSourceChanged().unsubscribe(null,Ot),Bt=null}e&&(Bt=e,e.hasModel()?Rt(e.model()):e.modelCreated().subscribe(null,Rt))}}(e)}}),{callWithLast:!0});var Ft=new Map;function Wt(e,t){var i=e.id();if(!Ft.has(i)){var s=function(){const i=e.id();Ft.has(i)&&(Ft.delete(i),Gt(t?e:void 0))};e.model().mainSeries().dataEvents().completed().subscribe(null,s,!0),Ft.set(i,{cw:e,callback:s})}}function Ht(e){e.timeScale().visibleBarsStrictRangeChanged().subscribe(null,jt)}function zt(e){e.timeScale().visibleBarsStrictRangeChanged().unsubscribe(null,jt),Ft.forEach((function(e){var t=e.cw,i=e.callback;t.model().mainSeries().dataEvents().completed().unsubscribe(null,i)})),Ft.clear()}function Ut(e){Be.value()&&null===e&&Gt()}function jt(e,t){Gt()}function Gt(e){if(Be.value()&&null===ge.value()){var t=ae.value(),i=t.model().mainSeries();if(b.isTimeBasedStyle(i.style())){var s=t.model().timeScale(),r=s.visibleBarsStrictRange();if(null!==r){var n=s.points().range().value(),o=s.indexToTimePoint(r.firstBar());null===o&&i.endOfData()&&(o=s.indexToTimePoint(n.firstIndex));var a=s.indexToTimePoint(r.lastBar());if(null===a&&(a=s.indexToTimePoint(n.lastIndex)),null!==o&&null!==a){Ft.delete(t.id());var l=1e3*o,c=1e3*a;if(i.isDWM()){var h=new Date(l),d=new Date(c);y.set_hms(h,0,0,0,0),y.set_hms(d,0,0,0,0),l=h.getTime(),c=d.getTime()}for(var u=0;uhe.map((e=>e.chartWidget)),ci=re(li,ke.readonly(),kt,it);function hi(e,t){if(we=!0,Pe=Boolean(t),ye.splice(0),e){if(e.charts||(e={layout:"s",charts:[e]}),e.layoutsSizes)for(const t of Object.keys(e.layoutsSizes))fe.set(t,e.layoutsSizes[t]);var i=new Set;e.charts.forEach((function(e){e.chartId&&i.add(e.chartId)})),e.charts.forEach((function(e){if(!e.chartId){var t=W((function(e){return i.has(e)}));i.add(t),e.chartId=t}}));let t=e.layout;if(!P(t)){const e=C(t);_.logError(`Loading unsupported layout ${t}. Force migration to ${e}`),t=e}me=ut(t||"s");for(var s=0;sYe.readonly(),leftBottomChartWidget:()=>ci,activeLinkingGroup:()=>bt,allLinkingGroups:()=>wt,linkingGroupsCharts:e=>I.getLinkingGroupCharts(mt(),e).readonly(),destroy:function(){if($t.fire(),Jt(!1),null!==lt&&(lt(),lt=null),F(mt()),si.destroy(),ri.destroy(),oi.destroy(),ni.destroy(),Ve.destroy(),ai.destroy(),ge.unsubscribe(Ut),he.forEach((function(e){void 0!==e.timingsMeter&&e.timingsMeter.destroy(),e.chartWidget.linkingGroupIndex().unsubscribe(_t),e.chartWidget.destroy()})),n.resizerBridge.remove(),ve.value().forEach((e=>{e.mouseHandler.destroy(),e.mouseListener.destroy()})),window.removeEventListener("resize",yt),l.tool.unsubscribe(di),l.tool.unsubscribe(ui),tt.resolve(),Qe.remove(),Qt.clear(),ti.clear(),Oe.destroy(),We&&We.destroy(),ii&&ii.destroy(),bt.destroy(),wt.destroy(),window.TVD){const e=window.TVD.crosshairSyncEnabled;e&&e.unsubscribe(ze),U(mt())}ci.destroy()},onAboutToBeDestroyed:$t,layout:ke.readonly(),setLayout:Ct,activeChartWidget:ae,viewMode:Se,activeChartStyle:Vt.readonly(),setChartStyleToWidget:function(e,t){t||(t=ae.value()),t&&function(e,t){var i=e.model(),s=i.mainSeries().properties().style;i.setChartStyleProperty(s,t,oe)}(t,e)},selectedSources:Et.readonly(),metaInfo:Xe,state:function(e,i,s,r){for(var n=[],o=gt(),a=0;a{c.layoutsSizes[t]=e})),c},lineToolsAndGroupsDTOs:function(){return A(mt())},resetLineToolsInvalidated:function(e,t){return D(mt(),e,t)},applyLineToolUpdateNotification:V.bind(null,he),readOnly:function(){return le},onZoom:function(){return st},onScroll:function(){return rt},resizerBridge:function(){return n.resizerBridge},lock:{symbol:si,interval:ri,dateRange:ni,crosshair:ai,trackTime:oi},setSymbol:(e,t)=>I.setSymbol(mt(),e,t),setSymbolAll:(e,t)=>I.setSymbolAll(mt(),e,t),setResolution:(e,t)=>I.setResolution(mt(),e,t),setTimeFrame:function(e){be.loadingChart||be.setTimeFrameActive||(be.setTimeFrameActive=!0,Le.value()?he.forEach((function(t){t.chartWidget.loadRange(e)})):ae.value().loadRange(e),be.setTimeFrameActive=!1)},updateLayout:yt,setChartLayoutWithUndo:function(e){return I.setChartLayoutWithUndoImpl(mt(),this,e)},images:I.getSnapshot.bind(this,this,n.widgetOptions.customerReadableName,Ke.onWidget),clientSnapshot:I.getClientSnapshot.bind(this,this,n.widgetOptions.customerReadableName,Ke.onWidget),tags:function(){for(var e=[],t=0;tH(mt(),e,t,i,s),syncScroll:function(e,t){return j(mt(),e,t)},clearChartMetaInfo:function(){Xe.id.setValue(null),Xe.uid.setValue(void 0),Xe.name.setValue(void 0)},takeScreenshot:I.takeScreenshot.bind(this,n.snapshotUrl,this),takeServerScreenshot:I.takeServerScreenshot.bind(this,n.snapshotUrl,this),loadContent:hi,purgeUnusedWidgets:function(){for(var e=o[me].count;e1},applyIndicatorToAllCharts:function(e,t,i,s){L(mt(),e,t,i,s)},setActive:Jt,inlineChartsCount:pe.readonly(),revertToInline:function(){xt(null);for(var e=0;ehe.map((e=>e.chartWidget)),ci=re(li,ke.readonly(),kt,it);function hi(e,t){if(we=!0,Pe=Boolean(t),ye.splice(0),e){if(e.charts||(e={layout:"s",charts:[e]}),e.layoutsSizes)for(const t of Object.keys(e.layoutsSizes))fe.set(t,e.layoutsSizes[t]);var i=new Set;e.charts.forEach((function(e){e.chartId&&i.add(e.chartId)})),e.charts.forEach((function(e){if(!e.chartId){var t=W((function(e){return i.has(e)}));i.add(t),e.chartId=t}}));let t=e.layout;if(!P(t)){const e=C(t);_.logError(`Loading unsupported layout ${t}. Force migration to ${e}`),t=e}me=ut(t||"s");for(var s=0;sYe.readonly(),leftBottomChartWidget:()=>ci,activeLinkingGroup:()=>bt,allLinkingGroups:()=>wt,linkingGroupsCharts:e=>I.getLinkingGroupCharts(mt(),e).readonly(),destroy:function(){if($t.fire(),Jt(!1),null!==lt&&(lt(),lt=null),F(mt()),si.destroy(),ri.destroy(),oi.destroy(),ni.destroy(),Ee.destroy(),ai.destroy(),ge.unsubscribe(Ut),he.forEach((function(e){void 0!==e.timingsMeter&&e.timingsMeter.destroy(),e.chartWidget.linkingGroupIndex().unsubscribe(_t),e.chartWidget.destroy()})),n.resizerBridge.remove(),ve.value().forEach((e=>{e.mouseHandler.destroy(),e.mouseListener.destroy()})),window.removeEventListener("resize",yt),l.tool.unsubscribe(di),l.tool.unsubscribe(ui),tt.resolve(),Qe.remove(),Qt.clear(),ti.clear(),Oe.destroy(),We&&We.destroy(),ii&&ii.destroy(),bt.destroy(),wt.destroy(),window.TVD){const e=window.TVD.crosshairSyncEnabled;e&&e.unsubscribe(ze),U(mt())}ci.destroy()},onAboutToBeDestroyed:$t,layout:ke.readonly(),setLayout:Ct,activeChartWidget:ae,viewMode:Se,activeChartStyle:Et.readonly(),setChartStyleToWidget:function(e,t){t||(t=ae.value()),t&&function(e,t){var i=e.model(),s=i.mainSeries().properties().style;i.setChartStyleProperty(s,t,oe)}(t,e)},selectedSources:Vt.readonly(),metaInfo:Xe,state:function(e,i,s,r){for(var n=[],o=gt(),a=0;a{c.layoutsSizes[t]=e})),c},lineToolsAndGroupsDTOs:function(){return A(mt())},resetLineToolsInvalidated:function(e,t){return D(mt(),e,t)},applyLineToolUpdateNotification:E.bind(null,he),readOnly:function(){return le},onZoom:function(){return st},onScroll:function(){return rt},resizerBridge:function(){return n.resizerBridge},lock:{symbol:si,interval:ri,dateRange:ni,crosshair:ai,trackTime:oi},setSymbol:(e,t)=>I.setSymbol(mt(),e,t),setSymbolAll:(e,t)=>I.setSymbolAll(mt(),e,t),setResolution:(e,t)=>I.setResolution(mt(),e,t),setTimeFrame:function(e){be.loadingChart||be.setTimeFrameActive||(be.setTimeFrameActive=!0,Le.value()?he.forEach((function(t){t.chartWidget.loadRange(e)})):ae.value().loadRange(e),be.setTimeFrameActive=!1)},updateLayout:yt,setChartLayoutWithUndo:function(e){return I.setChartLayoutWithUndoImpl(mt(),this,e)},images:I.getSnapshot.bind(this,this,n.widgetOptions.customerReadableName,Ke.onWidget),clientSnapshot:I.getClientSnapshot.bind(this,this,n.widgetOptions.customerReadableName,Ke.onWidget),tags:function(){for(var e=[],t=0;tH(mt(),e,t,i,s),syncScroll:function(e,t){return j(mt(),e,t)},clearChartMetaInfo:function(){Xe.id.setValue(null),Xe.uid.setValue(void 0),Xe.name.setValue(void 0)},takeScreenshot:I.takeScreenshot.bind(this,n.snapshotUrl,this),takeServerScreenshot:I.takeServerScreenshot.bind(this,n.snapshotUrl,this),loadContent:hi,purgeUnusedWidgets:function(){for(var e=o[me].count;e1},applyIndicatorToAllCharts:function(e,t,i,s){L(mt(),e,t,i,s)},setActive:Jt,inlineChartsCount:pe.readonly(),revertToInline:function(){xt(null);for(var e=0;eyt())),yt()},destroyReplayWidget:function(){s(null!==ei,"Cannot remove replay container, container is not created"),ei.remove(),ei=null,yt()},setViewMode:function(e){Se.setValue(e)},moveActiveChartWithUndo:function(e){},activeChartCanBeMoved:function(){return!1},generalPropertiesDefinitions:function(){return ae.value().generalPropertiesDefinitions()},reconnectChartApi:function(e){undefined(e)},setBroker:function(e){0},setSaveChartService:function(e){Fe=e;for(var t=0;tTe,clientId:ce}),hi(n.content,!0),ke.subscribe((function(){Lt()})),ke.hook=function(e){return e===this.value()?e:ut(e)},le&&(ke.writeLock=!0),window.addEventListener("resize",yt);var pi=0;function _i(){0===--pi&&d.emitOnce("onChartReady")}he.forEach((function(e){if(e){pi++;var t=e.chartWidget;t.withModel(null,(function(){n.metaInfo&&t.model().model().setChartSaveTime(1e3*n.metaInfo.lastModified);var e=t.model().mainSeries();if(e.bars().size()>0||e.isFailed())_i();else{var i=e.dataEvents(),s=function(){_i(),i.barReceived().unsubscribe(null,s),i.completed().unsubscribe(null,s),i.error().unsubscribe(null,s)};i.barReceived().subscribe(null,s),i.completed().subscribe(null,s),i.error().subscribe(null,s)}}))}})),G(mt()).then(q).then((function(){window.saver&&window.is_authenticated&&n.widgetOptions.justCloned&&window.saver.saveChartSilently()})).catch(_.logError.bind(_))}},10643:(e,t,i)=>{"use strict";i.d(t,{ContextMenuManager:()=>s});var s,r=i(39347),n=i(59064);!function(e){let t=null,s=null;const o=[],a={createAction:e=>new r.Action({...e,actionId:"Chart.CustomActionId"}),createAsyncAction:e=>new r.ActionAsync("Chart.CustomActionId",e),createSeparator:()=>new r.Separator} -;async function l(e,r={},n={menuName:""},l){let h;null!==t&&(e=await t(e,a));const d=()=>{const e=o.indexOf(h);-1!==e&&o.splice(e,1),void 0!==l&&l()};if(null!==s)h=await s(e,n,d),c();else{const t=await Promise.all([i.e(3842),i.e(5649),i.e(3502),i.e(6752),i.e(8149),i.e(6639),i.e(9916),i.e(6831),i.e(962),i.e(3179),i.e(5899),i.e(1584)]).then(i.bind(i,20323));h=new t.ContextMenuRenderer(e,r,d,c)}return o.push(h),h}function c(){(0,n.globalCloseMenu)()}e.createMenu=l,e.showMenu=function(e,t,i={},s,r){return l(e,i,s,r).then((e=>e.show(t)))},e.setCustomRendererFactory=function(e){s=e},e.setCustomItemsProcessor=function(e){t=e},e.hideAll=c,e.getShown=function(){for(let e=0;e{"use strict";i.d(t,{DialogRenderer:()=>r});var s=i(97145);class r{constructor(){this._container=document.createElement("div"),this._visibility=new s.WatchedValue(!1)}visible(){return this._visibility.readonly()}_setVisibility(e){this._visibility.setValue(e)}}},14787:(e,t,i)=>{"use strict";var s;i.d(t,{TabNames:()=>s}),function(e){e.background="Background",e.coordinates="Coordinates",e.drawings="Drawings",e.events="Events",e.eventsAndAlerts="Events & Alerts",e.inputs="Inputs",e.properties="Properties",e.scales="Scales",e.legend="Legend",e.sourceCode="Source Code",e.style="Style",e.symbol="Symbol",e.timezoneSessions="Timezone/Sessions",e.trading="Trading",e.visibility="Visibility",e.text="Text"}(s||(s={}))},241:(e,t,i)=>{"use strict";i.d(t,{createFavoriteDrawingToolbar:()=>a,getFavoriteDrawingToolbarPromise:()=>o});var s=i(69774);let r=null,n=null;function o(){return n}function a(){null===n&&(n=Promise.all([i.e(5652),i.e(2666),i.e(3842),i.e(4015),i.e(6),i.e(5993),i.e(5649),i.e(2191),i.e(8056),i.e(3502),i.e(6752),i.e(8149),i.e(6639),i.e(9327),i.e(6106),i.e(9916),i.e(1109),i.e(6831),i.e(8399),i.e(962),i.e(3179),i.e(5050),i.e(1890),i.e(2020),i.e(5899),i.e(2306)]).then(i.bind(i,9629)).then((({FavoriteDrawingToolbar:e})=>(r=null!==r?r:new e({left:window.innerWidth/2,top:s.HEADER_TOOLBAR_HEIGHT_EXPANDED+61}),r))))}},31964:(e,t,i)=>{"use strict";function s(e){var t,i;return Math.max(1,(null===(i=null===(t=e.ownerDocument)||void 0===t?void 0:t.defaultView)||void 0===i?void 0:i.devicePixelRatio)||1)}i.d(t,{getCanvasDevicePixelRatio:()=>s})},10688:(e,t,i)=>{"use strict";i.d(t,{getPriceAxisNameInfo:()=>o});const s=["Z","Y","X","W","V","U","T","S"],r=["A","B","C","D","E","F","G","H"];class n{constructor(e){this.label=e}equals(e){return null!==e&&this.label===e.label}}function o(e,t){const i="left"===e?s:r;return new n(t{"use strict";i.d(t,{CHART_WIDGET_COLLECTION_SERVICE:()=>s});i(16216);const s={id:"ChartWidgetCollectionService"};var r;!function(e){e.Multichart="multichart",e.ForceFullscreen="force-fullscreen"}(r||(r={}))},91280:(e,t,i)=>{"use strict";i.d(t,{InvalidationLevel:()=>s,InvalidationMask:()=>a,defaultInvalidationLevel:()=>o});var s,r=i(50151);class n{constructor(e=o){this._paneInvalidationLevel=o, +;async function l(e,r={},n={menuName:""},l){let h;null!==t&&(e=await t(e,a,n));const d=()=>{const e=o.indexOf(h);-1!==e&&o.splice(e,1),void 0!==l&&l()};if(null!==s)h=await s(e,n,d),c();else{const t=await Promise.all([i.e(3842),i.e(5649),i.e(3502),i.e(6752),i.e(8149),i.e(6639),i.e(9916),i.e(6831),i.e(962),i.e(3179),i.e(5899),i.e(1584)]).then(i.bind(i,20323));h=new t.ContextMenuRenderer(e,r,d,c)}return o.push(h),h}function c(){(0,n.globalCloseMenu)()}e.createMenu=l,e.showMenu=function(e,t,i={},s,r){return l(e,i,s,r).then((e=>e.show(t)))},e.setCustomRendererFactory=function(e){s=e},e.setCustomItemsProcessor=function(e){t=e},e.hideAll=c,e.getShown=function(){for(let e=0;e{"use strict";i.d(t,{DialogRenderer:()=>r});var s=i(97145);class r{constructor(){this._container=document.createElement("div"),this._visibility=new s.WatchedValue(!1)}visible(){return this._visibility.readonly()}_setVisibility(e){this._visibility.setValue(e)}}},14787:(e,t,i)=>{"use strict";var s;i.d(t,{TabNames:()=>s}),function(e){e.background="Background",e.coordinates="Coordinates",e.drawings="Drawings",e.events="Events",e.eventsAndAlerts="Events & Alerts",e.inputs="Inputs",e.properties="Properties",e.scales="Scales",e.legend="Legend",e.sourceCode="Source Code",e.style="Style",e.symbol="Symbol",e.timezoneSessions="Timezone/Sessions",e.trading="Trading",e.visibility="Visibility",e.text="Text"}(s||(s={}))},241:(e,t,i)=>{"use strict";i.d(t,{createFavoriteDrawingToolbar:()=>a,getFavoriteDrawingToolbarPromise:()=>o});var s=i(69774);let r=null,n=null;function o(){return n}function a(){null===n&&(n=Promise.all([i.e(5652),i.e(2666),i.e(3842),i.e(4015),i.e(6),i.e(5993),i.e(5649),i.e(2191),i.e(8056),i.e(3502),i.e(6752),i.e(8149),i.e(6639),i.e(9327),i.e(6106),i.e(9916),i.e(1109),i.e(6831),i.e(8399),i.e(962),i.e(3179),i.e(5050),i.e(1890),i.e(2020),i.e(5899),i.e(2306)]).then(i.bind(i,9629)).then((({FavoriteDrawingToolbar:e})=>(r=null!==r?r:new e({left:window.innerWidth/2,top:s.HEADER_TOOLBAR_HEIGHT_EXPANDED+61}),r))))}},31964:(e,t,i)=>{"use strict";function s(e){var t,i;return Math.max(1,(null===(i=null===(t=e.ownerDocument)||void 0===t?void 0:t.defaultView)||void 0===i?void 0:i.devicePixelRatio)||1)}i.d(t,{getCanvasDevicePixelRatio:()=>s})},10688:(e,t,i)=>{"use strict";i.d(t,{getPriceAxisNameInfo:()=>o});const s=["Z","Y","X","W","V","U","T","S"],r=["A","B","C","D","E","F","G","H"];class n{constructor(e){this.label=e}equals(e){return null!==e&&this.label===e.label}}function o(e,t){const i="left"===e?s:r;return new n(t{"use strict";i.d(t,{CHART_WIDGET_COLLECTION_SERVICE:()=>s});i(16216);const s={id:"ChartWidgetCollectionService"};var r;!function(e){e.Multichart="multichart",e.ForceFullscreen="force-fullscreen"}(r||(r={}))},91280:(e,t,i)=>{"use strict";i.d(t,{InvalidationLevel:()=>s,InvalidationMask:()=>a,defaultInvalidationLevel:()=>o});var s,r=i(50151);class n{constructor(e=o){this._paneInvalidationLevel=o, this._leftPriceScalesInvalidationMap=new Map,this._rightPriceScalesInvalidationMap=new Map,this._legendWidgetInvalidated=!1,this._invalidationLevel=e}fullInvalidation(){return this._invalidationLevel}invalidateAll(e){this._invalidationLevel=Math.max(this._invalidationLevel,e)}invalidatePane(e){this._paneInvalidationLevel=Math.max(this._invalidationLevel,e)}invalidateLegendWidgetLayout(){this._legendWidgetInvalidated=!0}invalidatePriceScale(e,t,i){const s="left"===e?this._leftPriceScalesInvalidationMap:this._rightPriceScalesInvalidationMap,r=s.get(t)||o;s.set(t,Math.max(r,i))}invalidationLevelForPane(){return Math.max(this._paneInvalidationLevel,this._invalidationLevel)}legendWidgetLayoutInvalidated(){return this._legendWidgetInvalidated||this._invalidationLevel===s.Full}getterForPriceScaleInvalidationLevelBySide(e){const t="left"===e?this._leftPriceScalesInvalidationMap:this._rightPriceScalesInvalidationMap;return e=>Math.max(t.get(e)||o,this._invalidationLevel)}priceScaleSideMaxLevel(e){const t="left"===e?this._leftPriceScalesInvalidationMap:this._rightPriceScalesInvalidationMap;let i=this._invalidationLevel;return t.size>0&&t.forEach((e=>{e>i&&(i=e)})),i}merge(e){this._invalidationLevel=Math.max(this._invalidationLevel,e._invalidationLevel),this._paneInvalidationLevel=Math.max(this._paneInvalidationLevel,e._paneInvalidationLevel),e._leftPriceScalesInvalidationMap.forEach(((e,t)=>{const i=this._leftPriceScalesInvalidationMap.get(t)||o;this._leftPriceScalesInvalidationMap.set(t,Math.max(i,e))})),e._rightPriceScalesInvalidationMap.forEach(((e,t)=>{const i=this._rightPriceScalesInvalidationMap.get(t)||o;this._rightPriceScalesInvalidationMap.set(t,Math.max(i,e))})),this._legendWidgetInvalidated=this._legendWidgetInvalidated||e._legendWidgetInvalidated}}!function(e){e[e.None=0]="None",e[e.Cursor=1]="Cursor",e[e.Light=2]="Light",e[e.Full=3]="Full"}(s||(s={}));const o=s.None;class a{constructor(e=o){this._panesOrderChanged=!1,this._keepVisibleTimeRangeOnResize=!1,this._timeAxisInvalidationLevel=o,this._invalidatedPanes=new Map,this._additionalActions=[],this._timeScaleInvalidations=[],this._invalidationLevel=e}invalidateAll(e){this._invalidationLevel!==e&&(this._invalidationLevel=Math.max(this._invalidationLevel,e),this._invalidatedPanes.forEach((e=>{e.invalidateAll(this._invalidationLevel)})))}invalidateAllPane(e,t){this._invalidatedPanes.has(e)||this._invalidatedPanes.set(e,new n(this._invalidationLevel)),(0,r.ensureDefined)(this._invalidatedPanes.get(e)).invalidateAll(t)}invalidatePriceScale(e,t,i,s){this._invalidatedPanes.has(e)||this._invalidatedPanes.set(e,new n(this._invalidationLevel)),(0,r.ensureDefined)(this._invalidatedPanes.get(e)).invalidatePriceScale(t,i,s)}invalidateTimeScale(e){this._timeAxisInvalidationLevel=Math.max(this._timeAxisInvalidationLevel,e)}invalidatePanesOrder(){this._panesOrderChanged=!0}lockVisibleTimeRangeOnResize(){this._keepVisibleTimeRangeOnResize=!0}fullInvalidation(){return this._invalidationLevel}maxPaneInvalidation(){const e=[];return this._invalidatedPanes.forEach((t=>{ e.push(t.fullInvalidation())})),Math.max(...e,this._invalidationLevel)}invalidateForPane(e){return this._invalidatedPanes.get(e)||new n(this._invalidationLevel)}invalidateForTimeScale(){return Math.max(this._timeAxisInvalidationLevel,this._invalidationLevel)}validationActions(){return this._additionalActions}addValidationAction(e){this._additionalActions.push(e)}merge(e){this._invalidationLevel=Math.max(this._invalidationLevel,e._invalidationLevel),this._panesOrderChanged=this._panesOrderChanged||e._panesOrderChanged,this._keepVisibleTimeRangeOnResize=this._keepVisibleTimeRangeOnResize||e._keepVisibleTimeRangeOnResize,this._invalidatedPanes.forEach((e=>{e.invalidateAll(this._invalidationLevel)})),e._invalidatedPanes.forEach(((e,t)=>{this._invalidatedPanes.has(t)||this._invalidatedPanes.set(t,new n(this._invalidationLevel)),(0,r.ensureDefined)(this._invalidatedPanes.get(t)).merge(e)})),this._timeAxisInvalidationLevel=Math.max(this._timeAxisInvalidationLevel,e._timeAxisInvalidationLevel);for(let t=0;t0===e.type));if(-1!==e){const[t]=this._timeScaleInvalidations.splice(e,1);t.value.terminate()}}}},38325:(e,t,i)=>{"use strict";i.d(t,{lastMouseOrTouchEventInfo:()=>r,setLastMouseOrTouchEventInfo:()=>n});let s=(0,i(49483).supportTouch)()?{isTouch:!0,stylus:!1}:{isTouch:!1};function r(){return s}function n(e){s=e.isTouch?{isTouch:!0,stylus:e.stylus}:{isTouch:!1}}},26097:(e,t,i)=>{"use strict";i.d(t,{layoutInitialSizingState:()=>n});var s=i(3308);i(50151);function r(e){return e.map((t=>{if((0,s.default)(t))return{percent:1/e.length};{const i=t.slice(1);return{percent:1/e.length,substate:r(i)}}}))}function n(e){return r(e.slice(1))}},75531:(e,t,i)=>{"use strict";i.r(t),i.d(t,{isMultipleLayout:()=>o,isSingleLayout:()=>n,isSupportedLayout:()=>a,layouts:()=>r,tryGuessingTheMostSuitableLayout:()=>l});i(34976),i(26097);let s ;s={};const r={...{s:{title:"1 chart",count:1,layoutType:"s",sizer:(e,t)=>{if(0!==t)throw new RangeError("invalid index");return e},splitters:()=>[],resizeApplier:(e,t,i,s,r)=>r,syncSublayoutsBySplitter:(e,t)=>t,expression:["h",0]}},...s};function n(e){return"s"===e}function o(e){return!n(e)}function a(e){return n(e)||s.hasOwnProperty(e)}function l(e){return"s"}},72414:(e,t,i)=>{"use strict";i.d(t,{LineToolsGroupControllerApi:()=>o});var s=i(98517),r=i(50151),n=i(92249);class o{constructor(e,t){this._controller=e,this._model=t}createGroupFromSelection(){return this._controller.createGroupFromSelection().id}removeGroup(e){const t=(0,r.ensureDefined)(this._groupById(e));this._controller.removeGroup(t)}groups(){return this._controller.groups().map((e=>e.id))}shapesInGroup(e){const t=(0,r.ensureDefined)(this._groupById(e));return(0,s.sortSources)(t.lineTools()).map((e=>e.id()))}excludeShapeFromGroup(e,t){const i=(0,r.ensureDefined)(this._groupById(e)),s=(0,r.ensureNotNull)(this._model.dataSourceForId(t));(0,r.assert)((0,n.isLineTool)(s),"Passed shapeId is not a line tool"),this._controller.excludeLineToolFromGroup(i,s)}addShapeToGroup(e,t){const i=(0,r.ensureDefined)(this._groupById(e)),s=(0,r.ensureNotNull)(this._model.dataSourceForId(t));(0,r.assert)((0,n.isLineTool)(s),"Passed shapeId is not a line tool"),this._controller.addLineToolToGroup(i,s)}availableZOrderOperations(e){const t=(0,r.ensureDefined)(this._groupById(e));return this._controller.availableZOrderOperations(t)}bringToFront(e){const t=(0,r.ensureDefined)(this._groupById(e));this._controller.bringToFront(t)}bringForward(e){const t=(0,r.ensureDefined)(this._groupById(e));this._controller.bringForward(t)}sendBackward(e){const t=(0,r.ensureDefined)(this._groupById(e));this._controller.sendBackward(t)}sendToBack(e){const t=(0,r.ensureDefined)(this._groupById(e));this._controller.sendToBack(t)}insertAfter(e,t){const i=(0,r.ensureDefined)(this._groupById(e)),s=(0,r.ensureNotNull)(this._groupById(t)||this._model.dataSourceForId(t));this._controller.insertAfter(i,s)}insertBefore(e,t){const i=(0,r.ensureDefined)(this._groupById(e)),s=(0,r.ensureNotNull)(this._groupById(t)||this._model.dataSourceForId(t));this._controller.insertBefore(i,s)}groupVisibility(e){return(0,r.ensureDefined)(this._groupById(e)).visibility()}setGroupVisibility(e,t){const i=(0,r.ensureDefined)(this._groupById(e));this._controller.setGroupVisibility(i,t)}groupLock(e){return(0,r.ensureDefined)(this._groupById(e)).locked()}setGroupLock(e,t){const i=(0,r.ensureDefined)(this._groupById(e));this._controller.setGroupLock(i,t)}getGroupName(e){return(0,r.ensureDefined)(this._groupById(e)).name()}setGroupName(e,t){const i=(0,r.ensureDefined)(this._groupById(e));this._controller.setGroupName(i,t)}canBeGroupped(e){const t=e.map((e=>(0,r.ensureNotNull)(this._model.dataSourceForId(e))));return!t.some((e=>!(0,n.isLineTool)(e)))&&this._controller.canBeGroupped(t)}_groupById(e){return this._controller.groups().find((t=>t.id===e))}}},42184:(e,t,i)=>{"use strict";i.d(t,{MouseEventHandler:()=>h}) -;var s=i(49483),r=i(50151),n=i(1722),o=i(80007),a=i(38325);const l=s.isSafari?"click":"auxclick",c={treatVertTouchDragAsPageScroll:!1,treatHorzTouchDragAsPageScroll:!1};class h{constructor(e,t,i){this._clickCount=0,this._clickTimeoutId=null,this._clickPosition={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY},this._tapCount=0,this._tapTimeoutId=null,this._tapPosition={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY},this._longTapTimeoutId=null,this._longTapActive=!1,this._mouseMoveStartPosition=null,this._touchMoveStartPosition=null,this._touchMoveExceededManhattanDistance=!1,this._cancelClick=!1,this._cancelTap=!1,this._unsubscribeOutsideMouseEvents=null,this._unsubscribeOutsideTouchEvents=null,this._unsubscribeMobileSafariEvents=null,this._unsubscribeMousemove=null,this._unsubscribeRootMouseEvents=null,this._unsubscribeRootTouchEvents=null,this._startPinchMiddlePoint=null,this._startPinchDistance=0,this._pinchPrevented=!1,this._preventTouchDragProcess=!1,this._mousePressed=!1,this._lastTouchEventTimeStamp=0,this._activeTouchId=null,this._acceptMouseLeave=!s.CheckMobile.iOS(),this._onFirefoxOutsideMouseUp=e=>{this._mouseUpHandler(e)},this._onMobileSafariDoubleClick=e=>{if(this._firesTouchEvents(e)){const t=this._makeCompatEvent(e);if(++this._tapCount,this._tapTimeoutId&&this._tapCount>1){const{manhattanDistance:i}=this._touchMouseMoveWithDownInfo(u(e),this._tapPosition);i<30&&!this._cancelTap&&this._processTouchEvent(t,this._handler.doubleTapEvent),this._resetTapTimeout()}}else{const t=this._makeCompatEvent(e);if(++this._clickCount,this._clickTimeoutId&&this._clickCount>1){const{manhattanDistance:i}=this._touchMouseMoveWithDownInfo(u(e),this._clickPosition);i<5&&!this._cancelClick&&this._processMouseEvent(t,this._handler.mouseDoubleClickEvent),this._resetClickTimeout()}}},this._target=e,this._handler=t,this._options=(0,n.merge)((0,n.clone)(c),i||{}),this._init()}destroy(){null!==this._unsubscribeOutsideMouseEvents&&(this._unsubscribeOutsideMouseEvents(),this._unsubscribeOutsideMouseEvents=null),null!==this._unsubscribeOutsideTouchEvents&&(this._unsubscribeOutsideTouchEvents(),this._unsubscribeOutsideTouchEvents=null),null!==this._unsubscribeMousemove&&(this._unsubscribeMousemove(),this._unsubscribeMousemove=null),null!==this._unsubscribeRootMouseEvents&&(this._unsubscribeRootMouseEvents(),this._unsubscribeRootMouseEvents=null),null!==this._unsubscribeRootTouchEvents&&(this._unsubscribeRootTouchEvents(),this._unsubscribeRootTouchEvents=null),null!==this._unsubscribeMobileSafariEvents&&(this._unsubscribeMobileSafariEvents(),this._unsubscribeMobileSafariEvents=null),this._clearLongTapTimeout(),this._resetClickTimeout()}_mouseEnterHandler(e){this._unsubscribeMousemove&&this._unsubscribeMousemove();const t=this._mouseMoveHandler.bind(this);if(this._unsubscribeMousemove=()=>{this._target.removeEventListener("mousemove",t)},this._target.addEventListener("mousemove",t),this._firesTouchEvents(e))return;const i=this._makeCompatEvent(e);this._processMouseEvent(i,this._handler.mouseEnterEvent), -this._acceptMouseLeave=!0}_resetClickTimeout(){null!==this._clickTimeoutId&&clearTimeout(this._clickTimeoutId),this._clickCount=0,this._clickTimeoutId=null,this._clickPosition={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY}}_resetTapTimeout(){null!==this._tapTimeoutId&&clearTimeout(this._tapTimeoutId),this._tapCount=0,this._tapTimeoutId=null,this._tapPosition={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY}}_mouseMoveHandler(e){if(this._mousePressed||null!==this._touchMoveStartPosition)return;if(this._firesTouchEvents(e))return;const t=this._makeCompatEvent(e);this._processMouseEvent(t,this._handler.mouseMoveEvent),this._acceptMouseLeave=!0}_touchMoveHandler(e){const t=m(e.changedTouches,(0,r.ensureNotNull)(this._activeTouchId));if(null===t)return;if(this._lastTouchEventTimeStamp=_(e),null!==this._startPinchMiddlePoint)return;if(this._preventTouchDragProcess)return;this._pinchPrevented=!0;const i=this._touchMouseMoveWithDownInfo(u(t),(0,r.ensureNotNull)(this._touchMoveStartPosition)),{xOffset:s,yOffset:n,manhattanDistance:a}=i;if(this._touchMoveExceededManhattanDistance||!(a<5)){if(!this._touchMoveExceededManhattanDistance){const e=.5*s,t=n>=e&&!this._options.treatVertTouchDragAsPageScroll,i=e>n&&!this._options.treatHorzTouchDragAsPageScroll;t||i||(this._preventTouchDragProcess=!0),this._touchMoveExceededManhattanDistance=!0,this._cancelTap=!0,this._clearLongTapTimeout(),this._resetTapTimeout()}if(!this._preventTouchDragProcess){const i=this._makeCompatEvent(e,t);this._processTouchEvent(i,this._handler.touchMoveEvent),(0,o.preventDefault)(e)}}}_mouseMoveWithDownHandler(e){if(0!==e.button)return;const t=this._touchMouseMoveWithDownInfo(u(e),(0,r.ensureNotNull)(this._mouseMoveStartPosition)),{manhattanDistance:i}=t;if(i>=5&&(this._cancelClick=!0,this._resetClickTimeout()),this._cancelClick){const t=this._makeCompatEvent(e);this._processMouseEvent(t,this._handler.pressedMouseMoveEvent)}}_touchMouseMoveWithDownInfo(e,t){const i=Math.abs(t.x-e.x),s=Math.abs(t.y-e.y);return{xOffset:i,yOffset:s,manhattanDistance:i+s}}_touchEndHandler(e){let t=m(e.changedTouches,(0,r.ensureNotNull)(this._activeTouchId));if(null===t&&0===e.touches.length&&(t=e.changedTouches[0]),null===t)return;this._activeTouchId=null,this._lastTouchEventTimeStamp=_(e),this._clearLongTapTimeout(),this._touchMoveStartPosition=null,this._unsubscribeRootTouchEvents&&(this._unsubscribeRootTouchEvents(),this._unsubscribeRootTouchEvents=null);const i=this._makeCompatEvent(e,t);if(this._processTouchEvent(i,this._handler.touchEndEvent),++this._tapCount,this._tapTimeoutId&&this._tapCount>1){const{manhattanDistance:e}=this._touchMouseMoveWithDownInfo(u(t),this._tapPosition);e<30&&!this._cancelTap&&this._processTouchEvent(i,this._handler.doubleTapEvent),this._resetTapTimeout()}else this._cancelTap||(this._processTouchEvent(i,this._handler.tapEvent),this._handler.tapEvent&&(0,o.preventDefault)(e));0===this._tapCount&&(0,o.preventDefault)(e),0===e.touches.length&&this._longTapActive&&(this._longTapActive=!1,(0,o.preventDefault)(e))}_mouseUpHandler(e){ -if(0!==e.button)return;const t=this._makeCompatEvent(e);if(this._mouseMoveStartPosition=null,this._mousePressed=!1,this._unsubscribeRootMouseEvents&&(this._unsubscribeRootMouseEvents(),this._unsubscribeRootMouseEvents=null),s.isFF){this._target.ownerDocument.documentElement.removeEventListener("mouseleave",this._onFirefoxOutsideMouseUp)}if(!this._firesTouchEvents(e))if(this._processMouseEvent(t,this._handler.mouseUpEvent),++this._clickCount,this._clickTimeoutId&&this._clickCount>1){const{manhattanDistance:i}=this._touchMouseMoveWithDownInfo(u(e),this._clickPosition);i<5&&!this._cancelClick&&this._processMouseEvent(t,this._handler.mouseDoubleClickEvent),this._resetClickTimeout()}else this._cancelClick||(this._processMouseEvent(t,this._handler.mouseClickEvent),e.defaultPrevented&&--this._clickCount)}_clearLongTapTimeout(){null!==this._longTapTimeoutId&&(clearTimeout(this._longTapTimeoutId),this._longTapTimeoutId=null)}_touchStartHandler(e){if(null!==this._activeTouchId)return;const t=e.changedTouches[0];this._activeTouchId=t.identifier,this._lastTouchEventTimeStamp=_(e);const i=this._target.ownerDocument.documentElement;this._cancelTap=!1,this._touchMoveExceededManhattanDistance=!1,this._preventTouchDragProcess=!1,this._touchMoveStartPosition=u(t),this._unsubscribeRootTouchEvents&&(this._unsubscribeRootTouchEvents(),this._unsubscribeRootTouchEvents=null);{const t=this._touchMoveHandler.bind(this),s=this._touchEndHandler.bind(this);this._unsubscribeRootTouchEvents=()=>{i.removeEventListener("touchmove",t),i.removeEventListener("touchend",s)},i.addEventListener("touchmove",t,{passive:!1}),i.addEventListener("touchend",s,{passive:!1}),this._clearLongTapTimeout(),this._longTapTimeoutId=setTimeout(this._longTapHandler.bind(this,e),240)}const s=this._makeCompatEvent(e,t);this._processTouchEvent(s,this._handler.touchStartEvent),this._tapTimeoutId||(this._tapCount=0,this._tapTimeoutId=setTimeout(this._resetTapTimeout.bind(this),500),this._tapPosition=u(t))}_wheelClickHandler(e){if(1!==e.button)return;if(this._firesTouchEvents(e))return;const t=this._makeCompatEvent(e);this._processMouseEvent(t,this._handler.wheelClickEvent)}_mouseDownHandler(e){if(0!==e.button)return;const t=this._target.ownerDocument.documentElement;s.isFF&&t.addEventListener("mouseleave",this._onFirefoxOutsideMouseUp),this._cancelClick=!1,this._mouseMoveStartPosition=u(e),this._unsubscribeRootMouseEvents&&(this._unsubscribeRootMouseEvents(),this._unsubscribeRootMouseEvents=null);{const e=this._mouseMoveWithDownHandler.bind(this),i=this._mouseUpHandler.bind(this);this._unsubscribeRootMouseEvents=()=>{t.removeEventListener("mousemove",e),t.removeEventListener("mouseup",i)},t.addEventListener("mousemove",e),t.addEventListener("mouseup",i)}if(this._mousePressed=!0,this._firesTouchEvents(e))return;const i=this._makeCompatEvent(e);this._processMouseEvent(i,this._handler.mouseDownEvent),this._clickTimeoutId||(this._clickCount=0,this._clickTimeoutId=setTimeout(this._resetClickTimeout.bind(this),500),this._clickPosition=u(e))}_init(){ -this._target.addEventListener("mouseenter",this._mouseEnterHandler.bind(this)),this._target.addEventListener("touchcancel",this._clearLongTapTimeout.bind(this));{const e=this._target.ownerDocument,t=e=>!e.target||!this._target.contains(e.target),i=e=>{if(!t(e))return;const i=e.changedTouches[0];this._lastTouchEventTimeStamp=_(e),this._processTouchEvent(this._makeCompatEvent(e,i),this._handler.touchStartOutsideEvent)},s=e=>{t(e)&&!this._firesTouchEvents(e)&&this._processMouseEvent(this._makeCompatEvent(e),this._handler.mouseDownOutsideEvent)};this._unsubscribeOutsideTouchEvents=()=>{e.removeEventListener("touchstart",i)},this._unsubscribeOutsideMouseEvents=()=>{e.removeEventListener("mousedown",s)},e.addEventListener("mousedown",s),e.addEventListener("touchstart",i,{passive:!0})}s.CheckMobile.iOS()&&(this._unsubscribeMobileSafariEvents=()=>{this._target.removeEventListener("dblclick",this._onMobileSafariDoubleClick)},this._target.addEventListener("dblclick",this._onMobileSafariDoubleClick)),this._target.addEventListener("mouseleave",this._mouseLeaveHandler.bind(this)),this._target.addEventListener("contextmenu",this._contextMenuHandler.bind(this)),this._target.addEventListener("touchstart",this._touchStartHandler.bind(this),{passive:!0}),(0,o.preventScrollByWheelClick)(this._target),this._target.addEventListener("mousedown",this._mouseDownHandler.bind(this)),this._target.addEventListener(l,this._wheelClickHandler.bind(this)),this._initPinch(),this._target.addEventListener("touchmove",(()=>{}),{passive:!1})}_initPinch(){void 0===this._handler.pinchStartEvent&&void 0===this._handler.pinchEvent&&void 0===this._handler.pinchEndEvent||(this._target.addEventListener("touchstart",(e=>this._checkPinchState(e.touches)),{passive:!0}),this._target.addEventListener("touchmove",(e=>{if(2===e.touches.length&&null!==this._startPinchMiddlePoint&&void 0!==this._handler.pinchEvent){const t=e.touches[0],i=e.touches[1],s=p(t,i)/this._startPinchDistance,r=d(this._target);this._handler.pinchEvent(this._startPinchMiddlePoint,{x:t.clientX-r.left,y:t.clientY-r.top},{x:i.clientX-r.left,y:i.clientY-r.top},s),(0,o.preventDefault)(e)}}),{passive:!1}),this._target.addEventListener("touchend",(e=>{this._checkPinchState(e.touches)})))}_checkPinchState(e){1===e.length&&(this._pinchPrevented=!1),2!==e.length||this._pinchPrevented||this._longTapActive?this._stopPinch():this._startPinch(e)}_startPinch(e){if(void 0!==this._handler.pinchStartEvent){const t=d(this._target),i=e[0],s=e[1],r={x:i.clientX-t.left,y:i.clientY-t.top},n={x:s.clientX-t.left,y:s.clientY-t.top};this._startPinchMiddlePoint={x:(r.x+n.x)/2,y:(r.y+n.y)/2},this._startPinchDistance=p(i,s),this._handler.pinchStartEvent(this._startPinchMiddlePoint,r,n)}this._clearLongTapTimeout()}_stopPinch(){null!==this._startPinchMiddlePoint&&(this._startPinchMiddlePoint=null,void 0!==this._handler.pinchEndEvent&&this._handler.pinchEndEvent())}_mouseLeaveHandler(e){if(this._unsubscribeMousemove&&this._unsubscribeMousemove(),this._firesTouchEvents(e))return;if(!this._acceptMouseLeave)return -;const t=this._makeCompatEvent(e);this._processMouseEvent(t,this._handler.mouseLeaveEvent),this._acceptMouseLeave=!s.CheckMobile.iOS()}_longTapHandler(e){const t=m(e.touches,(0,r.ensureNotNull)(this._activeTouchId));if(null===t)return;const i=this._makeCompatEvent(e,t);this._processTouchEvent(i,this._handler.longTapEvent),this._processTouchEvent(i,this._handler.touchContextMenuEvent),this._cancelTap=!0,this._longTapActive=!0}_contextMenuHandler(e){if((0,o.preventDefault)(e),null!==this._touchMoveStartPosition)return;if(this._firesTouchEvents(e))return;const t=this._makeCompatEvent(e);this._processMouseEvent(t,this._handler.contextMenuEvent),this._cancelClick=!0}_firesTouchEvents(e){return e.sourceCapabilities&&void 0!==e.sourceCapabilities.firesTouchEvents?e.sourceCapabilities.firesTouchEvents:_(e){"touchstart"!==e.type&&(0,o.preventDefault)(e)}}}}function d(e){return e.getBoundingClientRect()||{left:0,top:0}}function u(e){return{x:e.pageX,y:e.pageY}}function p(e,t){const i=e.clientX-t.clientX,s=e.clientY-t.clientY;return Math.sqrt(i*i+s*s)}function _(e){return e.timeStamp||performance.now()}function m(e,t){for(let i=0;i{"use strict";i.d(t,{actualBehavior:()=>a,availableValues:()=>o,navigationButtonsVisibilityKey:()=>r,property:()=>n,restoreNavigationButtonsVisibilitySettingsValue:()=>l});var s=i(29542);const r="NavigationButtons.visibility",{property:n,availableValues:o,actualBehavior:a,restoreDefaultValue:l}=(0,s.createVisibilityController)(r)},3228:(e,t,i)=>{"use strict";i.d(t,{actualBehavior:()=>a,availableValues:()=>o,property:()=>n,restorePaneButtonsVisibilitySettingsValue:()=>l});var s=i(29542),r=i(78159);const{property:n,availableValues:o,actualBehavior:a,restoreDefaultValue:l}=(0,s.createVisibilityController)("PaneButtons.visibility",r.navigationButtonsVisibilityKey)},77212:(e,t,i)=>{"use strict";i.d(t,{ActionBinder:()=>s});class s{constructor(e,t,i,s,r=null){this._property=t,this._undoModel=i,this._undoText=s,this._action=e,this.setValue(t.value()),t.subscribe(this,this._propertyChanged),null!==r?e.update({onExecute:r.bind(this)}):e.update({onExecute:this._onActionCallback.bind(this)})}destroy(){this._property.unsubscribe(this,this._propertyChanged)}value(){return this._action.isChecked()}setValue(e){ -this._action.update({checked:Boolean(e)})}_onActionCallback(){this._undoModel.setProperty(this._property,this.value(),this._undoText)}_propertyChanged(e){this.setValue(e.value())}}},43886:(e,t,i)=>{"use strict";i.d(t,{isCustomStudy:()=>r});const s={VbPFixed:!0,PivotPointsStandard:!0,VbPVisible:!0,VbPAnchored:!0};function r(e){return e in s}},96362:(e,t,i)=>{"use strict";i.d(t,{MetaInfoHelper:()=>u});var s=i(50151),r=i(42856),n=i(72877),o=i(1722),a=i(59224),l=i(33703);function c(e){return!e.groupId&&!e.isHidden&&e.id!==l.RangeDependentStudyInputNames.FirstBar&&e.id!==l.RangeDependentStudyInputNames.LastBar}var h=i(43886);const d=(0,a.getLogger)("Platform.GUI.PropertyDialog.Indicators.MetaInfo");class u{constructor(e){this._metaInfo=e}hasUserEditableInputs(){return this._metaInfo.inputs.some(c)}getUserEditableInputs(){return this._metaInfo.inputs.filter(c)}hasUserEditableProperties(){return r.StudyMetaInfo.isScriptStrategy(this._metaInfo)}hasUserEditableStyles(){const e=this._metaInfo;return e.plots.length>0||void 0!==e.bands||void 0!==e.filledAreas||(0,h.isCustomStudy)(e.shortId)||r.StudyMetaInfo.isScriptStrategy(this._metaInfo)||Object.values(e.graphics).some((e=>void 0!==e))}getUserEditablePlots(){const e=new Set,t=this._metaInfo;return t.plots.filter((i=>{if((0,n.isColorerPlot)(i)||(0,n.isTextColorerPlot)(i)||(0,n.isDataOffsetPlot)(i)||(0,n.isOhlcColorerPlot)(i)||(0,n.isAlertConditionPlot)(i)||(0,n.isDataPlot)(i))return!1;if((0,n.isOhlcPlot)(i)){const r=i.target;if(e.has(r))return!1;e.add(r);const n=(0,s.ensureDefined)(t.ohlcPlots);return!(0,s.ensureDefined)(n[r]).isHidden}{const e=t.styles?t.styles[i.id]:void 0;return void 0===e||!e.isHidden}}))}hasUserEditableOptions(){return this.hasUserEditableInputs()||this.hasUserEditableProperties()||this.hasUserEditableStyles()}getStrategyProperties(){const e=this._metaInfo,t=e.inputs.filter(_),i={...p};for(const s of t){const t=s.internalID;i[t]=s,p.hasOwnProperty(t)||d.logWarn(`Unknown strategy input internal id ${t} in ${e.fullId}`)}return(0,o.clone)(i)}}const p={currency:void 0,backtest_fill_limits_assumption:void 0,calc_on_every_tick:void 0,calc_on_order_fills:void 0,commission_value:void 0,commission_type:void 0,initial_capital:void 0,pyramiding:void 0,slippage:void 0,default_qty_type:void 0,default_qty_value:void 0,margin_long:void 0,margin_short:void 0,use_bar_magnifier:void 0,process_orders_on_close:void 0,fill_orders_on_standard_ohlc:void 0};function _(e){return"strategy_props"===e.groupId}},68456:(e,t,i)=>{"use strict";i.d(t,{AbstractJsonStoreService:()=>r,CommonJsonStoreService:()=>n});var s=i(57898);class r{constructor(e,t,i,r,n){this._onChange=new s.Delegate,this._handleChange=()=>{this._onChange.fire(this.get())},this._crossTabEvents=e,this._jsonKeyValueStore=t,this.CROSSTAB_EVENT_NAME=i,this.JSON_STORE_KEY=r,this.defaultStoreValue=this._serialize(n),this._subscribe()}get(){const e=this._jsonKeyValueStore.getJSON(this.JSON_STORE_KEY,this.defaultStoreValue);return this._deserialize(e)}set(e,t){const i=this._serialize(e) -;this._jsonKeyValueStore.setJSON(this.JSON_STORE_KEY,i,t),this._crossTabEvents.emit(this.CROSSTAB_EVENT_NAME),this._onChange.fire(e)}getOnChange(){return this._onChange}destroy(){this._unsubscribe(),this._onChange.destroy(),delete this._onChange}_subscribe(){this._crossTabEvents.on(this.CROSSTAB_EVENT_NAME,this._handleChange),this._jsonKeyValueStore.onSync.subscribe(this,this._handleChange)}_unsubscribe(){this._crossTabEvents.off(this.CROSSTAB_EVENT_NAME,this._handleChange),this._jsonKeyValueStore.onSync.unsubscribe(this,this._handleChange)}}class n extends r{_serialize(e){return e}_deserialize(e){return e}}},75593:(e,t,i)=>{"use strict";i.d(t,{CustomStatusModel:()=>c});var s=i(97145);const r="#9598a1",n=!1,o=null,a='';class l{constructor(e){this._visible=new s.WatchedValue(n),this._tooltip=new s.WatchedValue(o),this._icon=new s.WatchedValue(a),this._color=new s.WatchedValue(r),this._tooltipContent=new s.WatchedValue(null),this._symbol=e}symbol(){return this._symbol}tooltip(){return this._tooltip}icon(){return this._icon}color(){return this._color}visible(){return this._visible}tooltipContent(){return this._tooltipContent}}class c{constructor(){this._symbolCustomStatuses=new Map}getSymbolCustomStatus(e){if(this._symbolCustomStatuses.has(e))return this._symbolCustomStatuses.get(e);const t=new l(e);return this._symbolCustomStatuses.set(e,t),t}hideAll(){for(const e of this._symbolCustomStatuses.values())e.visible().setValue(!1)}static getInstance(){return null===this._instance&&(this._instance=new c),this._instance}}c._instance=null},98425:(e,t,i)=>{"use strict";i.d(t,{restoreShowMarketOpenStatusProperty:()=>l,showMarketOpenStatusProperty:()=>a});var s=i(59680),r=i(56840);const n="Chart.ShowMarketOpenStatus";function o(){return r.getBool(n,true)}const a=(0,s.createPrimitiveProperty)(o());function l(){a.setValue(true),r.remove(n)}r.onSync.subscribe(null,(()=>a.setValue(o()))),a.subscribe(null,(()=>r.setValue(n,a.value())))},77248:(e,t,i)=>{"use strict";i.d(t,{firstReplacedByBatsExchange:()=>a,isDelay:()=>h,isEod:()=>l,isYield:()=>c,witoutRealtime:()=>d});i(50151);var s=i(79982),r=i.n(s);const n=["DJ","JSE","BELEX"],o=["NZX"];function a(e){return null}function l(e,t){return r().hasEodSymbols(e.full_name)||6===t}function c(e){var t;return Boolean(null===(t=e.typespecs)||void 0===t?void 0:t.includes("yield"))}function h(e){return void 0!==e&&e>0}function d(e){return"index"===e.type&&n.includes(e.listed_exchange)||"futures"===e.type&&o.includes(e.listed_exchange)}},31330:(e,t,i)=>{"use strict";i.d(t,{canShowSpreadActions:()=>r,globalKeypressMatches:()=>n});var s=i(14483);i(94025),i(82992);new RegExp("^quandl","i");function r(){let e=!1;return s.enabled("show_spread_operators")&&(e=!0),e}function n(e){if(e.ctrlKey)return!1;if(e.metaKey)return!1;if(!e.charCode)return!1;if(!e.which||e.which<=32)return!1;const t=e.target;return!t||!/^(input|textarea)$/i.test(t.tagName)&&"listbox"!==t.getAttribute("role")}},13702:(e,t,i)=>{"use strict" -;function s(){return Promise.all([i.e(2666),i.e(1013),i.e(4015),i.e(5145),i.e(855),i.e(6),i.e(8056),i.e(2587),i.e(2639),i.e(2109),i.e(9842),i.e(7232),i.e(962),i.e(8385),i.e(3016),i.e(9727),i.e(1754)]).then(i.bind(i,89324))}i.d(t,{loadNewSymbolSearch:()=>s})},40493:(e,t,i)=>{"use strict";i.d(t,{tradingService:()=>n});var s=i(16216);const r={id:"TradingService"};function n(){return(0,s.hasService)(r)?(0,s.service)(r):null}},96005:(e,t,i)=>{"use strict";i.d(t,{TradingViewApiBase:()=>z});var s=i(50151),r=i(82992),n=i(76422),o=i(14483),a=i(10643),l=i(75531),c=i(51768),h=i(5286),d=i(45345),u=i(57898);class p{constructor(e){this._toolbarThemeChanged=new u.Delegate,this._onWatchedThemeChanged=e=>{this._toolbarThemeChanged.fire(e)},this._opts=e,d.watchedTheme.subscribe(this._onWatchedThemeChanged)}destroy(){d.watchedTheme.unsubscribe(this._onWatchedThemeChanged)}isStdTheme(){const e=this._opts.chartWidgetCollection.getAll().every((e=>(0,h.isStdTheme)((0,h.extractThemeFromModel)(e.model()))));return Promise.resolve(e)}async setStdTheme(e,t=!0,i){await(0,h.loadTheme)(this._opts.chartWidgetCollection,{themeName:e,standardTheme:!0,syncState:t,noUndo:i})}setStdThemeForLayout(e,t=!0){(0,d.setTheme)(e),t&&(0,h.syncTheme)()}getCurrentThemeName(){return(0,h.getCurrentTheme)().name}toolbarThemeChanged(){return this._toolbarThemeChanged}}var _=i(88913),m=i(88348),g=i(97145),f=i(46100),v=i(92249),S=i(56954),y=i.t(S,2);const b=new u.Delegate;var w=i(50151).ensureNotNull,P=i(68582).isLineToolRiskReward,C=i(88913).supportedLineTools,x=i(92249).createLineToolProperties,T=i(92249).prepareLineToolPropertiesByOwnerSource,I=i(45973).lineToolEntityInfo,M=i(72414).LineToolsGroupControllerApi,L=i(47513).RemoveSourcesUndoCommand;const{isLineDrawnWithPressedButton:A,isLineToolFinishRequiredWhenCreatedByApi:k}=i(15367),D=i(81155).EnvironmentState;var V=i(75444).ChartWidgetApiBase,E=i(88348);i(51768).trackEvent;function B(e,t){return t.map((function(t){return e.dataSourceForId(t)}))}class R extends V{executeActionById(e){this._chartWidget.executeActionById(e)}getCheckableActionState(e){return this._chartWidget.getCheckableActionState(e)}setZoomEnabled(e){this._chartWidget.model().model().setZoomEnabled(e)}setScrollEnabled(e){this._chartWidget.model().model().setScrollEnabled(e)}refreshMarks(){this._chartWidget.refreshMarks()}clearMarks(e){this._chartWidget.clearMarks(e)}setEntityVisibility(e,t){console.warn("`setEntityVisibility` is deprecated. Use shape/study API instead");var i=this._chartWidget.model().model().dataSourceForId(e);if(i){var s=i.properties();s&&s.visible&&s.visible.setValue(t)}}availableZOrderOperations(e){var t=B(this._chartWidget.model().model(),e);return this._chartWidget.model().availableZOrderOperations(t)}sendToBack(e){var t=B(this._chartWidget.model().model(),e);this._chartWidget.model().sendToBack(t)}bringToFront(e){var t=B(this._chartWidget.model().model(),e);this._chartWidget.model().bringToFront(t)}insertAfter(e,t){var i=this._chartWidget.model().model(),s=B(i,e),r=i.dataSourceForId(t) -;this._chartWidget.model().insertAfter(s,r)}insertBefore(e,t){var i=this._chartWidget.model().model(),s=B(i,e),r=i.dataSourceForId(t);this._chartWidget.model().insertBefore(s,r)}bringForward(e){var t=B(this._chartWidget.model().model(),e);this._chartWidget.model().bringForward(t)}sendBackward(e){var t=B(this._chartWidget.model().model(),e);this._chartWidget.model().sendBackward(t)}showPropertiesDialog(e){var t=this._chartWidget.model().model().dataSourceForId(e);if(null===t)throw new Error("Study or shape "+e+" does not exist");this._chartWidget.showChartPropertiesForSource(t)}getAllShapes(){return this._chartWidget.model().model().allLineTools().map(I).filter((function(e){return null!==e.name}))}removeAllShapes(){this._chartWidget.removeAllDrawingTools()}removeAllStudies(){this._chartWidget.removeAllStudies()}removeEntity(e,t){var i=this._chartWidget.model().chartModel().dataSourceForId(e);i?t&&t.disableUndo?new L(this._chartWidget.model().chartModel(),[i],"").redo():this._chartWidget.model().removeSource(i,!0,!0):console.warn("Can't find a source with id: "+e)}removeEntityWithUndo(e){var t=this._chartWidget.model().chartModel().dataSourceForId(e);this._chartWidget.model().removeSource(t,!1)}createStudyTemplate(e){return this._chartWidget.model().model().studyTemplate(e.saveSymbol,e.saveInterval)}drawOnAllCharts(e){E.drawOnAllCharts.setValue(e)}applyStudyTemplate(e){this._chartWidget.model().applyStudyTemplate(e,""+1e3*Math.random())}getVisiblePriceRange(){return console.warn("`getVisiblePriceRange` is deprecated. Use Price Scale API instead"),this._chartWidget.model().mainSeries()?this._chartWidget.model().mainSeries().priceScale().priceRangeInPrice():null}scrollPosition(){return console.warn("`scrollPosition` is deprecated. Use rightOffset from Time Scale API instead"),this._chartWidget.model().timeScale().rightOffset()}defaultScrollPosition(){return console.warn("`defaultScrollPosition` is deprecated. Use defaultRightOffset from Time Scale API instead"),this._chartWidget.model().timeScale().defaultRightOffset().value()}_createTradingPrimitive(e,t){var i,s=this._chartWidget.model(),r=s.model(),n=r.paneForSource(r.mainSeries());function o(){var e=TradingView.CLOSE_PLOT,t=w(s.mainSeries().bars().last());return{index:t.index,price:t.value[e]}}return(i=t?r.createLineTool(n,o(),e):s.createLineTool({pane:n,point:o(),linetool:e}))?i._adapter:void 0}createOrderLine(e){e=e||{};return this._createTradingPrimitive("LineToolOrder",e.disableUndo)}createPositionLine(e){e=e||{};return this._createTradingPrimitive("LineToolPosition",e.disableUndo)}createExecutionShape(e){e=e||{};return this._createTradingPrimitive("LineToolExecution",e.disableUndo)}createShape(e,t){return this.createMultipointShape([e],t)}createMultipointShape(e,t){const i=Object.assign({},this._getDefaultCreateMultipointShapeOptions(),t);var s=C[i.shape]||C.flag;var r=this._chartWidget.model().model(),n=r.mainSeries();if(!r.timeScale().isEmpty()){var o=r.dataSourceForId(i.ownerStudyId)||n,a=r.paneForSource(o),l=this._convertUserPointsToDataSource(e) -;if(s.onlySelectable)throw new Error('Cannot create "'+i.shape+'" shape');if("LineToolIcon"===s.name){if(i.icon=i.icon||i.overrides&&i.overrides.icon,!i.hasOwnProperty("icon"))throw new Error("icon must be specified in options");i.overrides=i.overrides||{},i.overrides.icon=i.icon}var c,h,d=x(s.name,void 0,this._chartWidget.model().model());if(T(d,o),i.overrides)for(var u in i.overrides)d[u]?d[u].mergeAndFire(i.overrides[u]):P(s.name)&&-1!==["profitLevel","stopLevel"].indexOf(u)&&d.addProperty(u,i.overrides[u]);if(void 0!==d.text&&i.text&&d.text.setValue(i.text),d.hasChild("filled")&&i.filled&&d.filled.setValue(!0),null!==(h=i.disableUndo?(c=this._chartWidget.model().model()).createLineTool(a,l[0],s.name,d,void 0,o):(c=this._chartWidget.model()).createLineTool({pane:a,point:l[0],linetool:s.name,properties:d,ownerSource:o}))){if(P(s.name)){if(l.length>2)throw new Error("Wrong points count for "+i.shape+". Required 1 or 2");2===l.length&&(h.startChanging(1,l[1]),h.setPoint(1,l[1]),h.endChanging())}else{var p=h.pointsCount();if(p!==l.length&&-1!==p)throw new Error("Wrong points count for "+i.shape+". Required "+p);for(var _=new D(void 0,!0),m=A(s.name),g=1;g{this.setActiveChart(this._chartIndex(e))};const{chartApiInstance:t,chartWidgetCollection:i,studyMarket:s,saveChartService:o,loadChartService:a,sharingChartService:l=null,webview:c=null}=e;this._chartWidgetCollection=i,this._studyMarket=s,this._saveChartService=o,this._sharingChartService=l,this._loadChartLayoutDialog=a,this._intervalsService=null,this._alertsWidgetDialog=null,this._detailsDialogController=null,this._supportedChartStylesSpawn=r.linking.supportedChartStyles.spawn(),this._chartWidgetCollection.onAboutToBeDestroyed.subscribe(null,(()=>this.destroy()),!0),this._webview=c;const h=new F.ChartChangesWatcher(this._chartWidgetCollection,window.saver,n);this._chartChangesWatcher=h,this._chartHasChanged=(0,W.createWVFromGetterAndSubscription)((()=>h.hasChanges()),h.getOnChange());const d=i.lock;this._symbolSync=d.symbol.spawn(),this._intervalSync=d.interval.spawn(),this._dateRangeSync=d.dateRange.spawn(),this._crosshairSync=d.crosshair.spawn(),this._timeSync=d.trackTime.spawn()}destroy(){var e,t,i;this._chartHasChanged.destroy(),this._chartChangesWatcher.destroy(),this._supportedChartStylesSpawn.destroy(),null===(e=this._intervalsService)||void 0===e||e.destroy(),null===(t=this._themesApi)||void 0===t||t.destroy(),null===(i=this._widgebarApi)||void 0===i||i.destroy(),this._widgetbarApiRejectionReason="This ITradingViewApi instance has been destroyed",this._symbolSync.destroy(),this._intervalSync.destroy(),this._dateRangeSync.destroy(),this._crosshairSync.destroy(),this._timeSync.destroy(),this._isDestroyed=!0,(0,m.properties)().childs().magnet.unsubscribeAll(this),(0,m.properties)().childs().magnetMode.unsubscribeAll(this)}themes(){return null===this._themesApi&&(this._themesApi=new p({chartWidgetCollection:this._chartWidgetCollection})),this._themesApi}dialogs(){var e,t,i,s,r,n;return{Indicators:this._studyMarket,Compare:this._chartWidgetCollection.getCompareDialogRenderer(),ObjectsTree:null,ChartProperties:this._chartWidgetCollection.getChartPropertiesDialogRenderer(),ChartLayoutSaveAs:null!==(t=null===(e=this._saveChartService)||void 0===e?void 0:e.getSaveAsController())&&void 0!==t?t:null,ChartLayoutRename:null!==(s=null===(i=this._saveChartService)||void 0===i?void 0:i.getRenameController())&&void 0!==s?s:null,ChartLayoutCreate:null!==(n=null===(r=this._saveChartService)||void 0===r?void 0:r.getCreateController())&&void 0!==n?n:null,ChartLayoutLoad:this._loadChartLayoutDialog,Alerts:this._alertsWidgetDialog,Details:this._detailsDialogController, -FinancialsCharts:null,Technicals:null,Forecast:null}}webview(){return H(),this._webview}studyTemplatesDrawerApi(){H()}fontIconsSettingsDrawer(){H()}intervalsService(){H()}supportedChartTypes(){return this._supportedChartStylesSpawn}setBrokerName(e){this._chartWidgetCollection.setBroker(e)}getDrawOnAllCharts(){return(0,m.drawOnAllCharts)().value()}drawOnAllCharts(e){return(0,m.drawOnAllCharts)().setValue(e)}getDrawOnAllChartsMode(){return(0,m.drawOnAllChartsMode)().value()}drawOnAllChartsMode(e){(0,m.drawOnAllChartsMode)().setValue(e)}disableTrackingEvents(){(0,c.disableTrackingEvents)()}getSaveChartService(){return this._saveChartService}symbolSync(){return this._symbolSync}intervalSync(){return this._intervalSync}dateRangeSync(){return this._dateRangeSync}crosshairSync(){return this._crosshairSync}timeSync(){return this._timeSync}setSymbolSearchUI(e){H()}chart(e=0){if(e<0||e>=this.chartsCount())throw Error("Incorrect index: "+e);return this._getChartWidgetApi(this._chartWidgetCollection.getAll()[e])}activeChart(){return this._getChartWidgetApi(this._activeChartWidget())}setActiveChart(e){if(e>=0&&e(this._favoriteDrawingsToolbar||(this._favoriteDrawingsToolbar=new e.FavoriteDrawingsApi),this._favoriteDrawingsToolbar)))}sharingChart(){return this._sharingChartService}watchlist(){H()}setWatchlistApiPromise(e){H()}news(){H()}setNewsApiPromise(e){H()}widgetbar(){H()}setWidgetbarApiPromise(e){H()}getChartStorage(){return getChartStorage()}setDebugMode(e){o.setEnabled("charting_library_debug_mode",e)}setFeatureEnabled(e,t){"chart_crosshair_menu"!==e?o.setEnabled(e,t):O.addPlusButtonProperty.setValue(t)} -magnetEnabled(){return null===this._magnetEnabledWatchedValue&&(this._magnetEnabledWatchedValue=new g.WatchedValue((0,m.properties)().childs().magnet.value()),this._magnetEnabledWatchedValue.subscribe((e=>{(0,f.saveDefaultProperties)(!0),(0,m.properties)().childs().magnet.setValue(e),(0,f.saveDefaultProperties)(!1)})),(0,m.properties)().childs().magnet.subscribe(this,(()=>{(0,s.ensureNotNull)(this._magnetEnabledWatchedValue).setValue((0,m.properties)().childs().magnet.value())}))),this._magnetEnabledWatchedValue}magnetMode(){return null===this._magnetModeWatchedValue&&(this._magnetModeWatchedValue=new g.WatchedValue((0,m.properties)().childs().magnetMode.value()),this._magnetModeWatchedValue.subscribe((e=>{(0,f.saveDefaultProperties)(!0),(0,m.properties)().childs().magnetMode.setValue(e),(0,f.saveDefaultProperties)(!1)})),(0,m.properties)().childs().magnetMode.subscribe(this,(()=>{(0,s.ensureNotNull)(this._magnetModeWatchedValue).setValue((0,m.properties)().childs().magnetMode.value())}))),this._magnetModeWatchedValue}flushBufferedData(){b.fire()}chartWidgetCollectionState(...e){return this._chartWidgetCollection.state(...e)}chartWidgetCollectionSeriesStatuses(){return this._chartWidgetCollection.chartSeriesStatuses()}initAllLineTools(){return Promise.all(Object.keys(y).filter((e=>!y[e])).map((e=>(0,v.initLineTool)(e)))).then((()=>{}))}watermark(){{const e=N.WatermarkApi.getInstance();if(!e.ready())throw new Error("Watermark API is not initialised yet.");return e}}setContextMenuOptions(e){z.setContextMenuOptions(e)}hasChartChanges(){return this._chartHasChanged}setForceFullscreenMode(){H()}setMultichartMode(){H()}static setContextMenuOptions(e){void 0!==e.items_processor&&a.ContextMenuManager.setCustomItemsProcessor(e.items_processor),void 0!==e.renderer_factory&&a.ContextMenuManager.setCustomRendererFactory(e.renderer_factory)}_getChartWidgetApi(e){let t=this._chartWidgets.get(e);return void 0===t&&(t=new R(e,this._activateChart.bind(null,e)),this._chartWidgets.set(e,t)),t}_chartIndex(e){return this._chartWidgetCollection.getAll().indexOf(e)}_activeChartWidget(){return this._chartWidgetCollection.activeChartWidget.value()}}},75117:(e,t,i)=>{"use strict";var s=i(82992).linking,r=(i(51608).createDeferredPromise,i(76422)),n=i(10643).ContextMenuManager,o=i(88348),a=i(94025),l=i(61595).backend,c=i(59224),h=i(3615).showWarning,d=i(3615).showConfirm,u=i(88913),p=i(52092).CLOSE_POPUPS_AND_DIALOGS_COMMAND,_=i(36274).Interval,m=i(96005).TradingViewApiBase,g=i(42856).StudyMetaInfo,f=i(152).getStudyInputsInfo,v=i(70120).getStudyStylesInfo,S=i(57898).Delegate,y=i(97145).WatchedValue;e.exports=class extends m{constructor(e){const{chartWidgetCollection:t,saveChartService:i,loadChartService:r,sharingChartService:n,alertsDispatcher:o,supportTicketData:a,favoriteServices:l,chartApiInstance:c=null,studyMarket:h=null,webview:d}=e;super({chartApiInstance:c,chartWidgetCollection:t,studyMarket:h,saveChartService:i,loadChartService:r,sharingChartService:n,webview:d}),this._chartApiInstance=c,this._loadChartService=r, -this._alertsDispatcher=o,this._supportTicketData=a,this._favoriteServices=l,this._proxyWatchListChangedDelegate=null,this._lockDrawingsWatchedValue=null,this._hideDrawingsWatchedValue=null,this._hideIndicatorsWatchedValue=null,this._replayApi=null,this._getDataSourceHub=function(){return t.activeChartWidget.value().model().model()},this._alertService=this._alertsDispatcher?new undefined(this._alertsDispatcher,this._getDataSourceHub):null,this._activeChangedChangedDelegate=new S,this._chartWidgetCollection.activeChartWidget.subscribe(function(){this._activeChangedChangedDelegate.fire()}.bind(this)),this.linking=s}subscribe(e,t){r.subscribe(e,t)}unsubscribe(e,t){r.unsubscribe(e,t)}onContextMenu(e){r.subscribe("onContextMenu",(function(t){t.callback(e(t.unixtime,t.price))}))}onGrayedObjectClicked(e){r.subscribe("onGrayedObjectClicked",e)}onActiveChartChanged(){return this._activeChangedChangedDelegate}changeSymbol(e,t,i){s.interval.setValue(_.normalize(t)),s.symbol.setValue(e),i&&this.activeChart().onDataLoaded().subscribe(null,i,!0)}viewMode(){throw new Error("not implemented")}viewModeWatchedValue(){throw new Error("not implemented")}getSymbolInterval(e){var t={symbol:s.symbol.value(),interval:s.interval.value()};return e&&e(t),t}saveChart(e){if(this._saveChartService){var t=this._saveChartService.saveToJSON();return e&&e(JSON.parse(t.content))}}loadChart(e){this._chartApiInstance.disconnect(),this._chartWidgetCollection.loadContent(e.json),this._chartWidgetCollection.purgeUnusedWidgets(),e.extendedData&&(this._chartWidgetCollection.metaInfo.id.setValue(e.extendedData.uid),this._chartWidgetCollection.metaInfo.uid.setValue(e.extendedData.uid),this._chartWidgetCollection.metaInfo.name.setValue(e.extendedData.name)),this._chartApiInstance.connect(),s.symbol.setValue(this.activeChart().symbol()),r.emit("chart_loaded")}getStudiesList(){return this._chartApiInstance.allStudiesMetadata().filter((function(e){return!e.is_hidden_study})).map((function(e){return e.description}))}getStudyInputs(e){{const t=g.findStudyMetaInfoByDescription(this._chartApiInstance.allStudiesMetadata(),e);return f(t)}}getStudyStyles(e){{const t=g.findStudyMetaInfoByDescription(this._chartApiInstance.allStudiesMetadata(),e);return v(t)}}getSavedCharts(e){l.getCharts().then(e)}loadChartFromServer(e){l.loadChart(e)}saveChartToServer(e,t,i){this._saveChartService&&this._saveChartService.saveChartSilently(e,t,i)}setAutosave(e){this._saveChartService&&this._saveChartService.autoSaveEnabled().setValue(e)}removeChartFromServer(e,t){l.removeChart(e).then(t)}getIntervals(){var e=[],t=a.getCustomResolutions();return null!==this._chartApiInstance&&(e=this._chartApiInstance.defaultResolutions()),a.mergeResolutions(e,t)}closePopupsAndDialogs(){n.hideAll(),r.emit(p)}selectedLineTool(){for(var e=Object.keys(u.supportedLineTools),t=o.tool.value(),i=0;i{"use strict";i.d(t,{WatermarkApi:()=>o});var s=i(50151),r=i(63821),n=i(65632);class o{constructor(){this._widgets=null,this._provider=null,this._watermarkProperties=(0,n.watermarkProperty)();const e=(0,s.ensureDefined)(this._watermarkProperties.child("color")),t=(0,s.ensureDefined)(this._watermarkProperties.child("visibility"));this._colorWatchedValue=(0,r.convertPropertyToWatchedValue)(e),this._visibilityWatchedValue=(0,r.convertPropertyToWatchedValue)(t)}setWidgetCollection(e){this._widgets=e}setContentProvider(e){this._provider=e,this._widgets&&this._widgets.getAll().forEach((e=>{e.model().model().lightUpdate()}))}provider(){return this._provider}ready(){return null!==this._widgets}destroy(){this._colorWatchedValue.destroy(),this._visibilityWatchedValue.destroy()}visibility(){return this._visibilityWatchedValue}color(){return this._colorWatchedValue}static getInstance(){return null===this._instance&&(this._instance=new o),this._instance}}o._instance=null},11095:(e,t,i)=>{"use strict";i.d(t,{addPlusButtonProperty:()=>_,restoreAddPlusButtonSettingsValue:()=>m,showPlusButtonOnCursor:()=>d});var s=i(4741),r=i(14483),n=i(56840),o=i(59680),a=i(97145);const l="add_plus_button";function c(){const e=s.keyboardPressedKeysState.value();return void 0!==e&&(Boolean(e.modifiers&s.Modifiers.Alt&&e.modifiers&s.Modifiers.Mod)&&(void 0===e.code||e.altOrOptionCode()||e.controlOrMetaCode()))}const h=new a.WatchedValue(c());s.keyboardPressedKeysState.subscribe((()=>h.setValue(c())));const d=h.readonly();function u(){return r.enabled("chart_crosshair_menu")}function p(){return n.getBool(l,u())}const _=(0,o.createPrimitiveProperty)(p());function m(){_.setValue(u()),n.remove(l)}n.onSync.subscribe(null,(()=>_.setValue(p()))),_.subscribe(null,(()=>{n.setValue(l,_.value()),r.setEnabled("chart_crosshair_menu",!r.enabled("chart_crosshair_menu"))}))},83654:(e,t,i)=>{"use strict";i.d(t,{alignToStep:()=>n});var s=i(60521),r=i.n(s);function n(e,t){return r()(e).div(t).round(0,r().roundHalfUp).mul(t).toNumber()}},28640:(e,t,i)=>{"use strict";i.d(t,{AppliedTimeFrame:()=>r});var s=i(83669);class r{constructor(e){this._appliedTimeFrame=new s.WatchedObject(null),this._appliedTimeFrameInfo=null,this._appliedTimeFrameChangedBound=this._appliedTimeFrameChanged.bind(this),this._model=e,e.mainSeries().dataEvents().seriesTimeFrame().subscribe(this,this._onSeriesTimeFrame),this._appliedTimeFrame.subscribe(this._appliedTimeFrameChangedBound)}destroy(){this._appliedTimeFrame.unsubscribe(this._appliedTimeFrameChangedBound), -this._model.timeScale().logicalRangeChanged().unsubscribeAll(this),this._model.mainSeries().dataEvents().seriesTimeFrame().unsubscribeAll(this)}appliedTimeFrame(){return this._appliedTimeFrame}_appliedTimeFrameChanged(){this._model.timeScale().logicalRangeChanged().unsubscribe(this,this._invalidateAppliedTimeFrame)}_onSeriesTimeFrame(e,t,i,s){if(s){const e=this._model.timeScale();this._appliedTimeFrameInfo={logicalRange:e.logicalRange(),baseIndex:e.baseIndex()},e.logicalRangeChanged().subscribe(this,this._invalidateAppliedTimeFrame)}}_invalidateAppliedTimeFrame(){if(null===this._appliedTimeFrameInfo)return;const e=this._model.timeScale(),t=e.logicalRange(),i=e.baseIndex(),s=this._appliedTimeFrameInfo.logicalRange,r=this._appliedTimeFrameInfo.baseIndex;(null===t||null===s||Math.abs(i-t.left()-(r-s.left()))>=.01||Math.abs(i-t.right()-(r-s.right()))>=.01)&&this._appliedTimeFrame.setValue(null)}}},12416:(e,t,i)=>{"use strict";i.d(t,{defaultsPreferencesByWhiteList:()=>x,preferencesByWhiteList:()=>C});var s=i(1722),r=i(67980),n=i(62615),o=i(59224),a=i(74304),l=i(85804),c=i(16776),h=i(30888),d=i(93613);const u=(0,o.getLogger)("Chart.ApplyPreferencesToAllCharts"),p={color:"",style:0},_={autoScale:!1,autoScaleDisabled:!1,lockScale:!1,percentage:!1,percentageDisabled:!1,log:!1,logDisabled:!1,alignLabels:!1,isInverted:!1,indexedTo100:!1},m={backgroundType:d.ColorType.Solid,background:"",backgroundGradientStartColor:"",backgroundGradientEndColor:"",topMargin:0,bottomMargin:0,rightOffset:0,gridLinesMode:"both",horzGridProperties:(0,h.deepExtend)({},p),vertGridProperties:(0,h.deepExtend)({},p),crossHairProperties:(0,h.deepExtend)({},{color:"",style:0,transparency:0,width:0}),legendProperties:(0,h.deepExtend)({},{showStudyArguments:!1,showStudyTitles:!1,showStudyValues:!1,showSeriesTitle:!1,showSeriesOHLC:!1,showLegend:!1,showBarChange:!0,showVolume:!1,showPriceSource:!1,showBackground:!0,backgroundTransparency:0,showLogo:!0}),axisProperties:(0,h.deepExtend)({},_),separatorColor:""},g={lineColor:"",textColor:"",fontSize:0,scaleSeriesOnly:!1,showSeriesLastValue:!1,seriesLastValueMode:a.PriceAxisLastValueMode.LastValueAccordingToScale,showSeriesPrevCloseValue:!1,showStudyLastValue:!1,showSymbolLabels:!1,showStudyPlotLabels:!1,showBidAskLabels:!1,showPrePostMarketPriceLabel:!0,showFundamentalLastValue:!1,showFundamentalNameLabel:!1,showPriceScaleCrosshairLabel:!0,showTimeScaleCrosshairLabel:!0},f={...g},v={visible:!1,futureOnly:!1,breaks:(0,h.deepExtend)({},{color:"",visible:!1,style:0,width:0})},S={style:0,minTick:"",showPriceLine:!1,priceLineWidth:0,priceLineColor:"",baseLineColor:"",showPrevClosePriceLine:!1,showCountdown:!0,prevClosePriceLineWidth:0,sessionId:"regular",prevClosePriceLineColor:"",esdShowDividends:!1,esdShowSplits:!1,esdShowEarnings:!1,esdShowBreaks:!1,showContinuousContractSwitches:!1,showContinuousContractSwitchesBreaks:!1,showFuturesContractExpiration:!1,showLastNews:!1,dividendsAdjustment:!1,backAdjustment:!1,settlementAsClose:!0,statusViewStyle:(0,h.deepExtend)({},{fontSize:16,showExchange:!0,showInterval:!0, -symbolTextSource:"description"}),priceAxisProperties:(0,h.deepExtend)({},_),highLowAvgPrice:(0,h.deepExtend)({},{highLowPriceLinesVisible:!1,highLowPriceLabelsVisible:!1,averageClosePriceLabelVisible:!1,averageClosePriceLineVisible:!1,highLowPriceLinesColor:"",highLowPriceLinesWidth:0,averagePriceLineColor:"",averagePriceLineWidth:0}),candleStyle:(0,h.deepExtend)({},n.candleStylePreferencesDefault),hollowCandleStyle:(0,h.deepExtend)({},n.hollowCandlePreferencesStyleDefault),barStyle:(0,h.deepExtend)({},n.barStylePreferencesDefault),lineStyle:(0,h.deepExtend)({},n.lineStyleDefault),lineWithMarkersStyle:(0,h.deepExtend)({},n.lineStyleDefault),steplineStyle:(0,h.deepExtend)({},n.lineStyleDefault),areaStyle:(0,h.deepExtend)({},n.areaStylePreferencesDefault),hlcAreaStyle:(0,h.deepExtend)({},n.hlcAreaStylePreferencesDefault),baselineStyle:(0,h.deepExtend)({},n.baselineStylePreferencesDefault),hiloStyle:(0,h.deepExtend)({},n.hiloStylePreferencesDefault),haStyle:(0,h.deepExtend)({},n.haStylePreferencesDefault),renkoStyle:(0,h.deepExtend)({},n.renkoStylePreferencesDefault),pbStyle:(0,h.deepExtend)({},n.pbStylePreferencesDefault),kagiStyle:(0,h.deepExtend)({},n.kagiStylePreferencesDefault),pnfStyle:(0,h.deepExtend)({},n.pnfStylePreferencesDefault),rangeStyle:(0,h.deepExtend)({},n.rangeStylePreferencesDefault),columnStyle:(0,h.deepExtend)({},n.columnStylePreferencesDefault)},y={priceScaleSelectionStrategyName:"auto",timeScale:(0,h.deepExtend)({},{defaultRightOffset:0,defaultRightOffsetPercentage:5,usePercentageRightOffset:!1}),mainSeries:(0,h.deepExtend)({},S),sessions:(0,h.deepExtend)({},c.sessionsPreferencesDefault),paneProperties:(0,h.deepExtend)({},m),chartEventsSourceProperties:(0,h.deepExtend)({},v),tradingProperties:(0,h.deepExtend)({},r.tradingPreferencesDefault)},b={timezone:"",scalesProperties:(0,h.deepExtend)({},f),...y},w={scalesProperties:(0,h.deepExtend)({},g),...y};function P(e,t,i,r,n=!0){if(void 0===t[e])return u.logDebug(`We haven't had this property ${r}.${e} yet, please, remove it from whiteList`),null;if((0,s.isObject)(i[e])){const s=Object.keys(i[e]);let o="";return s.map((s=>({[s]:P(s,t[e],i[e],`${r}.${e}`,n)}))).reduce(((e,t)=>(o=Object.keys(t)[0],e[o]=t[o],e)),{})}return n?t[e].value():t[e]}function C(e,t,i=b){const s={timezone:"",priceScaleSelectionStrategyName:"auto",timeScale:{defaultRightOffset:e.timeScale().defaultRightOffset().value(),defaultRightOffsetPercentage:e.timeScale().defaultRightOffsetPercentage().value(),usePercentageRightOffset:e.timeScale().usePercentageRightOffset().value()},mainSeries:{},sessions:{},paneProperties:{},scalesProperties:{},chartEventsSourceProperties:{},tradingProperties:{}},r=["timeScale","mainSeries","sessions"],n=i.mainSeries,o=Object.keys(i),a=Object.keys(n),l=t.properties(),c=e.properties(),h=i.sessions,d=Object.keys(h),u=e.sessions().properties();return a.forEach((e=>{s.mainSeries[e]=P(e,l,n,"mainSeries")})),d.forEach((e=>{s.sessions[e]=P(e,u,h,"sessions")})),o.forEach((e=>{r.includes(e)||(s[e]=P(e,c,i,"preferences"))})),s}function x(e,t,i=w,s=!0){const r={ -timeScale:{defaultRightOffset:e.timeScale().rightOffsetDefaultValue(),defaultRightOffsetPercentage:e.timeScale().defaultRightOffsetPercentage().value(),usePercentageRightOffset:e.timeScale().usePercentageRightOffset().value()},mainSeries:{},sessions:(0,h.deepExtend)({},c.sessionsPreferencesDefault),paneProperties:{},scalesProperties:{},chartEventsSourceProperties:{},tradingProperties:{},priceScaleSelectionStrategyName:"auto"},n=["timeScale","mainSeries","sessions"],o=i.mainSeries,a=Object.keys(i),d=Object.keys(o),u=(0,l.factoryDefaults)("chartproperties.mainSeriesProperties"),p=(0,l.factoryDefaults)("chartproperties");return d.forEach((e=>{s&&"style"===e||(r.mainSeries[e]=P(e,u,o,"mainSeries",!1))})),a.forEach((e=>{n.includes(e)||(r[e]=P(e,p,i,"preferences",!1))})),r}},39875:(e,t,i)=>{"use strict";i.d(t,{autoLogButtonsVisibilityOptions:()=>n,autoLogButtonsVisibilityProperty:()=>r,restoreAutoLogButtonsVisibilitySettingsValue:()=>o});var s=i(29542);const{property:r,availableValues:n,restoreDefaultValue:o}=(0,s.createVisibilityController)("PriceAxisAutoLogButtons.visibility")},81580:(e,t,i)=>{"use strict";i.d(t,{axisLabelBackgroundColor:()=>r});var s=i(48891);const r={common:s.colorsPalette["color-tv-blue-500"],active:s.colorsPalette["color-tv-blue-800"]}},77475:(e,t,i)=>{"use strict";i.d(t,{createDwmAligner:()=>c,createTimeToBarTimeAligner:()=>d,isAlignmentEnabled:()=>h});var s=i(41249),r=i(14483),n=i(36274),o=i(98829),a=i(60156);const l=new o.SessionInfo("Etc/UTC","0000-0000:1234567");function c(e,t){if(!h()||!n.Interval.isDWM(e))return null;const i=new o.SessionInfo(t.timezone,t.session,t.session_holidays,t.corrections),r=(0,a.newBarBuilder)(e,i,l);return{timeToSessionStart:e=>r.tradingDayToSessionStart(e),timeToExchangeTradingDay:e=>{const t=s.utc_to_cal(i.timezone,e),r=i.spec.correctTradingDay(t);return s.set_hms(r,0,0,0,0,s.get_timezone("Etc/UTC")),r.getTime()}}}function h(){return!r.enabled("disable_resolution_rebuild")}function d(e,t){if(!h())return e=>e;const i=new o.SessionInfo(t.timezone,t.session,t.session_holidays,t.corrections),s=(0,a.newBarBuilder)(e,i,i,!1);return e=>s.alignTimeIfPossible(e)}},98829:(e,t,i)=>{"use strict";i.d(t,{BarBuilderBase:()=>a,SessionInfo:()=>o});var s=i(41249),r=i(60062),n=i(32923);class o{constructor(e,t,i,s){this.init(e,t,i,s),this._state={timezone:e,spec:t,holidays:i,corrections:s}}init(e,t,i,r){this.timezone=s.get_timezone(e),this.spec=new n.SessionSpec(e,t,i,r)}state(){return this._state}static fromState(e){return new o(e.timezone,e.spec,e.holidays,e.corrections)}}class a{alignTime(e){if(isNaN(e))return NaN;let t=this.indexOfBar(e);return t===r.SessionStage.POST_SESSION&&(this.moveTo(e),t=this.indexOfBar(e)),t<0?NaN:this.startOfBar(t)}}},60156:(e,t,i)=>{"use strict";i.r(t),i.d(t,{SessionInfo:()=>o.SessionInfo,alignExchangeTimeToSessionStartAndReturnUTC:()=>C,alignPeriodsBackForDataRequest:()=>y,alignPeriodsBackForVisibleRange:()=>b,getPeriodsBetweenDates:()=>P,isTradingNow:()=>x,newBarBuilder:()=>S});var s=i(41249),r=i(36274),n=i(37160),o=i(98829),a=i(60062) -;class l extends o.BarBuilderBase{constructor(e,t){super(),this._sessionStartMs=-Number.MAX_VALUE,this._sessionEndMs=-Number.MAX_VALUE,this._periodSec=e,this._session=t}alignTimeIfPossible(e){const t=this.alignTime(e);return isNaN(t)?e:t}indexOfBar(e){return e=this._sessionEndMs?a.SessionStage.POST_SESSION:(0,n.toInt)(s.time_seconds_diff(e,this._sessionStartMs)/this._periodSec)}startOfBar(e){if(e===a.SessionStage.PRE_SESSION){const e=s.get_cal_from_unix_timestamp_ms(this._session.timezone,this._sessionStartMs-1),t=this._session.spec.alignToNearestSessionEnd(e,-1);return s.cal_to_utc(this._session.timezone,t)}if(e===a.SessionStage.POST_SESSION)return this._sessionEndMs;if(e<0)throw new Error("Negative offset is not supported");return this._sessionStartMs+s.time_seconds(this._periodSec*e)}endOfBar(e){if(e<0)throw new Error("Index cannot be negative");const t=this.startOfBar(e)+1e3*this._periodSec;return t>this._sessionEndMs?this._sessionEndMs:t}isLastBar(e,t){return t>=this._sessionStartMs+s.time_seconds(this._periodSec*(e+1)-1)}moveTo(e){const t=this._session.timezone,i=s.utc_to_cal(t,e),r=this._session.spec.alignToSessionStart(i);this._sessionStartMs=s.cal_to_utc(t,i),s.add_minutes(i,r),this._sessionEndMs=s.cal_to_utc(t,i)}indexOfLastBarInSession(){return(0,n.toInt)((this._sessionEndMs-1-this._sessionStartMs)/1e3/this._periodSec)}moveNext(){this.moveTo(this._sessionEndMs)}}var c=i(54606);function h(e,t){const i=s.clone(t),r=e.businessDaysToCalendarDays(i,1);r>1&&s.add_date(i,r-1);const n=e.leftBorderOfDailyBar(i);if(null===n)throw new Error("Cannot calculate left border of daily bar");return s.cal_to_utc(s.get_timezone(e.timezone()),n)}class d extends o.BarBuilderBase{constructor(e,t,i,s,r=!1){super(),this._periodStart=-Number.MAX_VALUE,this._periodEnd=-Number.MAX_VALUE,this._periodLastBarStart=-Number.MAX_VALUE,this._periodStartDay=new c.BusinessDay(0,0,0),this._periodEndDay=new c.BusinessDay(0,0,0),this._period=i,this._sessionTgt=e,this._builder=s,this._useBusinessDays=r,this._sessionSrc=r?new o.SessionInfo("Etc/UTC","24x7"):t||e}builder(){return this._builder}alignTimeIfPossible(e){return this.tradingDayToSessionStart(e)}tradingDayToSessionStart(e){return this.moveTo(e),this.startOfBar(0)}indexOfBar(e){if(this._useBusinessDays){const t=c.BusinessDay.fromCalendar(s.get_cal_from_unix_timestamp_ms(this._sessionSrc.timezone,e));return t.before(this._periodStartDay)?a.SessionStage.PRE_SESSION:this._periodEndDay.before(t)?a.SessionStage.POST_SESSION:0}return e=this._periodEnd?a.SessionStage.POST_SESSION:0}startOfBar(e){if(e===a.SessionStage.PRE_SESSION){const e=s.get_cal_from_unix_timestamp_ms(this._sessionTgt.timezone,this._periodStart-1),t=this._sessionTgt.spec.alignToNearestSessionEnd(e,-1);return s.cal_to_utc(this._sessionTgt.timezone,t)-1}return e===a.SessionStage.POST_SESSION||e>0?this._periodEnd:e===a.SessionStage.LASTBAR_SESSION?this._periodLastBarStart:this._periodStart}moveTo(e){ -const t=s.get_cal_from_unix_timestamp_ms(this._sessionSrc.timezone,e);this._sessionSrc.spec.correctTradingDay(t);const i=s.get_year(t),r=this._indexOfPeriodInYear(t),n=r+this._period,o=this._sessionTgt.spec,a=this._sessionTgt.timezone,l=this._builder.startOfPeriod(a,r,i);this._periodStart=h(o,l);const d=s.clone(l),u=o.businessDaysToCalendarDays(d,1);u>1&&s.add_date(d,u-1),this._periodStartDay=c.BusinessDay.fromCalendar(d);const p=this._builder.startOfPeriod(a,n,i);this._periodEnd=h(o,p);const _=s.clone(p);for(s.add_date(_,-1);o.isCalWeekEnd(_);)s.add_date(_,-1);this._periodEndDay=c.BusinessDay.fromCalendar(_),s.add_date(p,-1),function(e,t){for(;e.isCalWeekEnd(t);)s.add_date(t,-1)}(this._sessionTgt.spec,p),this._periodLastBarStart=h(o,p),(this._periodLastBarStart=this._periodLastBarStart}currentRange(){return{from:this._periodStartDay,to:this._periodEndDay}}indexOfBarInYear(e){const t=s.get_cal_from_unix_timestamp_ms(this._sessionSrc.timezone,e),i=s.get_year(t),r=this._builder.indexOfPeriod(t),o=this._sessionTgt.timezone;let a=this._builder.startOfPeriod(o,r,i),l=h(this._sessionTgt.spec,a);return a=s.get_cal_from_unix_timestamp_ms(s.get_timezone("Etc/UTC"),l),i=0&&(r-=7),(0,n.toInt)((r+i)/7))}class _{indexOfPeriod(e){return s.get_day_of_year(e)-1}startOfPeriod(e,t,i){const r=s.days_per_year(i);return s.get_cal(s.get_timezone("Etc/UTC"),i,s.JANUARY,1+Math.min(t,r))}}class m extends _{constructor(e){super(),this._sessionsSpec=e}indexOfPeriod(e){return super.indexOfPeriod(e)-function(e,t){const i=p(e,t),r=s.get_cal(s.get_timezone("Etc/UTC"),s.get_year(t),s.JANUARY,1);s.add_date(r,7*i);const n=i*e.weekEndsCount()+e.holidaysFromYearStart(r),o=s.get_day_of_year(t)-s.get_day_of_year(r);return n+o-e.calendarDaysToBusinessDays(r,o)}(this._sessionsSpec,e)}startOfPeriod(e,t,i){const r=7-this._sessionsSpec.weekEndsCount(),o=Math.max(0,(0,n.toInt)(t/r)-1),a=s.get_cal(s.get_timezone("Etc/UTC"),i,s.JANUARY,1),l=s.get_days_per_year(a);if(s.add_date(a,7*o),(t-=r*o-this._sessionsSpec.holidaysFromYearStart(a))>0){const e=this._sessionsSpec.businessDaysToCalendarDays(a,t);s.add_date(a,e)}let c=s.get_day_of_year(a)-1;return is.get_days_per_year(r)?this.startOfPeriod(e,0,i+1):(s.add_date(r,a),r)}}class v{indexOfPeriod(e){return s.get_month(e)}startOfPeriod(e,t,i){if(t<0){const e=(0,n.toInt)((11-t)/12);i-=e,t+=12*e}else t>s.DECEMBER&&(i++,t=s.JANUARY);return s.get_cal(s.get_timezone("Etc/UTC"),i,t,1)}}function S(e,t,i,s=!1){const n=r.Interval.parse(e),o=n.multiplier();return n.isMinutes()?new l(60*o,t):n.isSeconds()?new l(o,t):n.isTicks()?new l(1,t):n.isRange()?new l(60*o,t):new d(t,i,o,function(e,t){switch(e){case r.ResolutionKind.Days:return new g(t);case r.ResolutionKind.Weeks:return new f(t);case r.ResolutionKind.Months:return new v}throw new Error(`Unknown dwm resolution: ${e}`)}(n.kind(),t),s)}function y(e,t,i,s,r,n,o){return w(e,t,i,s,r,n,o,0)}function b(e,t,i,s,r,n,o){return w(e,t,i,s,r,n,o,1)}function w(e,t,i,s,n,a,l,c){const h=r.Interval.parse(n+s);if(h.isMonths()){const e=new Date(l);return 0===c&&e.setUTCDate(1),function(e,t){T(e,Math.floor(t/12));let i=e.getUTCMonth()-t%12;i<0&&(T(e,1),i+=12);e.setUTCMonth(i);for(;e.getUTCMonth()!==i;)I(e,1)}(e,a*h.multiplier()),e.getTime()}const d=new o.SessionInfo("Etc/UTC",e,t,i),u=h.inMilliseconds(),p=h.isDWM();let _;_=p?864e5:60*d.spec.maxTradingDayLength()*1e3;let m=0;m=h.isWeeks()?7:7-d.spec.weekEndsCount();const g=_/u,f=m*g;let v;if(a=g&&(f=_/6048e5*g);return f%1<=Number.EPSILON*Math.ceil(f)?Math.round(f):Math.ceil(f)}function C(e,t){const i=s.clone(t);return e.alignToSessionStart(i),s.cal_to_utc(s.get_timezone(e.timezone()),i)}function x(e,t){const i=s.utc_to_cal(t.timezone,+e);let r=s.get_day_of_week(i),n=s.get_minutes_from_midnight(i);const o=t.spec.findSession(t.spec.getWeekIndex(i),r,n).getEntry();return o.isOvernight()&&n>o.startOffset()+o.length()&&r===o.dayOfWeek()-1&&(r++,n-=1440), -r===o.dayOfWeek()&&n>=o.startOffset()&&n{"use strict";i.d(t,{BusinessDay:()=>r});var s=i(41249);class r{constructor(e,t,i){this.year=e,this.month=t,this.day=i}toString(){return`${this.year}-${this.month}-${this.day}`}compareTo(e){return this.year>e.year||this.year===e.year&&this.month>e.month||this.year===e.year&&this.month===e.month&&this.day>e.day?1:this.year===e.year&&this.month===e.month&&this.day===e.day?0:-1}before(e){return-1===this.compareTo(e)}toCalendar(e){return s.get_cal(s.get_timezone("Etc/UTC"),this.year,this.month-1,this.day)}addDays(e){const t=this.toCalendar(s.get_timezone("Etc/UTC"));return s.add_date(t,e),r.fromCalendar(t)}static fromCalendar(e){return new r(s.get_year(e),s.get_month(e)+1,s.get_day_of_month(e))}}},60062:(e,t,i)=>{"use strict";var s;i.d(t,{SessionStage:()=>s}),function(e){e[e.PRE_SESSION=-1]="PRE_SESSION",e[e.POST_SESSION=-2]="POST_SESSION",e[e.LASTBAR_SESSION=-3]="LASTBAR_SESSION"}(s||(s={}))},94421:(e,t,i)=>{"use strict";i.d(t,{extrapolateBarsFrontByCount:()=>n,extrapolateBarsFrontToTime:()=>r});var s=i(60062);function r(e,t,i,s,n=!1){if(t>i){const o=r(e,i,t,s,n);return o.count=-o.count,o}return o(e,t,1,((e,t)=>t>i||0!==s&&e>s),n)}function n(e,t,i,s=!1){const r=i<0?-1:1;return o(e,t,r,((e,t)=>e>=i*r),s)}function o(e,t,i,r,n){let o=0,a=t;e.moveTo(a);let l=0,c=Number.MAX_VALUE,h=!1,d=t;const u=[];for(;!r(o,a);){if(l>15)throw new Error("Internal error 0x10 while extrapolating.");const r=e.indexOfBar(a);if(r===s.SessionStage.PRE_SESSION&&1===i)a=e.startOfBar(0),e.moveTo(a);else if(r===s.SessionStage.PRE_SESSION&&-1===i)a=e.startOfBar(s.SessionStage.PRE_SESSION),e.moveTo(a);else if(r===s.SessionStage.POST_SESSION&&1===i)a=e.startOfBar(s.SessionStage.POST_SESSION),e.moveTo(a);else{if(r===s.SessionStage.POST_SESSION&&-1===i)throw new Error("Internal error 0x12 while extrapolating.");{const p=e.startOfBar(r);if(p>t&&i>0||t>p&&i<0){if(h&&c===p)throw new Error("Internal error 0x11 while extrapolating.");h=!0,c=p,l=0,o++,d=p,n&&u.push(d)}if(0===r&&-1===i)a=p-1;else{a=e.startOfBar(r+i);const t=e.startOfBar(s.SessionStage.POST_SESSION);a>t&&(e.moveTo(t),a=e.startOfBar(0))}}}l++}return{time:d,times:u,count:o}}},32923:(e,t,i)=>{"use strict";i.d(t,{SessionSpec:()=>v});var s=i(41249),r=i(78071),n=i(54606);function o(e,t){return e.compareTo(t)}class a{constructor(e,t,i){this._dayOfWeek=e,this._start=t,this._length=i}start(){return this._start+s.minutesPerDay*this.sessionStartDaysOffset()}startOffset(){return this._start}sessionStartDaysOffset(){return this._start>=0?0:this._start%s.minutesPerDay==0?-Math.ceil(this._start/s.minutesPerDay):-Math.floor(this._start/s.minutesPerDay)}sessionEndDaysOffset(){const e=this._start+this._length;return e>=0?0:e%s.minutesPerDay==0?-Math.ceil(e/s.minutesPerDay):-Math.floor(e/s.minutesPerDay)}isOvernight(){return this._start<0}dayOfWeek(){return this._dayOfWeek} -sessionStartDayOfWeek(){let e=this._dayOfWeek-this.sessionStartDaysOffset();return es.SATURDAY&&(e=1),e}length(){return this._length}weight(){return this._dayOfWeek*s.minutesPerDay+this._start}compareTo(e){const t=this.weight(),i=t+this._length,s=e.weight(),r=s+e._length;return t<=s&&ss?1:-1}contains(e){const t=60*s.get_hours(e)+s.get_minutes(e);let i=s.get_day_of_week(e)-this._dayOfWeek;i>0&&(i-=7);const r=i*s.minutesPerDay+t;return r>=this._start&&r=48&&e<=57}class _{constructor(){this.entries=[],this.firstDayOfWeek=s.MONDAY,this.weekEndsCount=-1,this.maxTradingDayLength=0}parseSessions(e,t){var i;let s=!1;this._clear(),this.timezone=e;const{hasErrors:r,spec:n}=this._parseFirstDayOfWeek(t);if("24x7"===n.toLowerCase())for(const e of d)this.entries.push(_._createSessionEntry(e,0,0,0,0));else{let e=!1;const t=new Map;for(const i of n.split("|")){const r=i.split(":");if(1!==r.length&&2!==r.length){s=!0,u.logError(`Bad session section: ${i}`);continue}const n=1===r.length;if(n){if(e){s=!0,u.logError(`Duplicated default section: ${i}`);continue}e=!0}const o=n?h:_._parseWorkingDays(r[1]);for(const e of o)n&&t.has(e)||t.set(e,r[0])}for(const e of d){const i=t.get(e);if(void 0!==i)for(const t of i.split(",")){const{hasErrors:i,sessionEntry:r}=_._parseSessionEntry(e,t);i&&(s=i),this.entries.push(r)}}}this.entries.sort(o);const a=new Map;for(const e of this.entries){const t=e.dayOfWeek();a.set(t,e.length()+(null!==(i=a.get(t))&&void 0!==i?i:0))}return this.maxTradingDayLength=0,a.forEach((e=>{this.maxTradingDayLength=Math.max(this.maxTradingDayLength,e)})),this.weekEndsCount=7-a.size,s||r}static parseHolidaysAndCorrections(e,t,i){const r=new Map,n=new Map,o=e=>{const t=this._parseDay(e),i=t.toString(),s=n.get(i);return void 0!==s?s:(n.set(i,t),t)};if(""!==t){const e=[];for(const i of t.split(",")){if(8!==i.length)throw new Error(`bad holiday date: ${i}`);const t=o(i);r.set(t,e)}}if(""===i)return r;const l=s.get_timezone("Etc/UTC");for(const e of i.split(";")){const t=e.split(":");if(2!==t.length)throw new Error(`bad correction section: ${e}`);const i=[];if("dayoff"!==t[0])for(const e of t[0].split(","))i.push(this._parseSessionEntry(1,e).sessionEntry);for(const e of t[1].split(",")){if(8!==e.length)throw new Error(`bad correction date: ${e}`);const t=o(e),n=s.get_day_of_week(s.get_cal(l,t.year,t.month-1,t.day)),c=[];for(const e of i)c.push(new a(n,e.startOffset(),e.length()));r.set(t,c)}}return r}_clear(){this.entries=[],this.timezone="",this.firstDayOfWeek=s.MONDAY,this.weekEndsCount=-1}_parseFirstDayOfWeek(e){const t=e.split(";") -;if(t.length>2)return u.logError(`Only one \`first day\` specification expected @ session ${e}`),{hasErrors:!0,spec:e};if(1===t.length)return{hasErrors:!1,spec:e};let i=1;let r=t[0].indexOf("-")>=0?NaN:parseInt(t[0]);return isNaN(r)&&(i=0,r=parseInt(t[1])),rs.SATURDAY?(u.logError(`Unexpected day index @ session: ${e}; day index ${r}`),{hasErrors:!0,spec:e}):(this.firstDayOfWeek=r,{hasErrors:!1,spec:t[i]})}static _parseDay(e){const t=parseInt(e.substring(0,4)),i=parseInt(e.substring(4,6)),s=parseInt(e.substring(6,8));return new n.BusinessDay(t,i,s)}static _parseSessionEntry(e,t){let i=!1,s=t.split("-");2!==s.length&&(i=!0,u.logError(`Bad sessions entry: ${t}`),s=["0000","0000"]);let r=0,n=s[0];if(n.includes("F")){const e=n.split("F");n=e[0],r=""!==e[1]?parseInt(e[1]):1}let o=0,a=s[1];if(a.includes("F")){const e=a.split("F");a=e[0],o=""!==e[1]?parseInt(e[1]):1}if(!this._isCorrectSession(n)||!this._isCorrectSession(a))throw new Error(`Incorrect entry syntax: ${t}`);const l=n,c=a;return{hasErrors:i,sessionEntry:this._createSessionEntry(e,_._minutesFromHHMM(l),_._minutesFromHHMM(c),r,o)}}static _isCorrectSession(e){return 4===e.length&&p(e.charCodeAt(0))&&p(e.charCodeAt(1))&&p(e.charCodeAt(2))&&p(e.charCodeAt(3))}static _parseWorkingDays(e){const t=[];for(let i=0;i0&&(t-=r*s.minutesPerDay),n>0&&(i-=n*s.minutesPerDay);return new a(e,t,i-t)}}function m(e,t){return e.compareTo(t)<0}function g(e,t){const i=(0,r.lowerbound)(e,t,((e,t)=>-1===e.day.compareTo(t)));return i===e.length?null:e[i]}const f=621672192e5;class v{constructor(e="Etc/UTC",t="0000-0000",i="",r=""){this._entries=[],this._firstDayOfWeek=s.MONDAY,this._entriesHash=new Map,this._holidayAndCorrectionMap=new Map,this._holidaySessions=[];const n=new _;n.parseSessions(e,t),this._entries=n.entries,this._timezone=n.timezone,this._spec=t,this._firstDayOfWeek=n.firstDayOfWeek,this._weekEndsCount=n.weekEndsCount,this._maxTradingDayLength=n.maxTradingDayLength;const o=_.parseHolidaysAndCorrections(e,i,r),a=s.get_timezone(e);this._isThereCorrections=""!==i||""!==r,o.forEach(((e,t)=>{this._holidayAndCorrectionMap.set(t.toString(),e),this._holidaySessions.push({day:t,sessions:e});const i=this.getWeekIndex(t.toCalendar(a));this._entriesHash.set(i,null)})),this._holidaySessions.sort(((e,t)=>e.day.compareTo(t.day)))}entries(){return this._entries}timezone(){return this._timezone}spec(){return this._spec}firstDayOfWeek(){return this._firstDayOfWeek}addSessionEntry(e,t,i,r,n){0===i&&(i=s.minutesPerDay),r===n&&i<=t&&(r+=1),r>0&&(t-=r*s.minutesPerDay),n>0&&(i-=n*s.minutesPerDay);const o=i-t;this._entries.push(new a(e,t,o))}longestSessionLength(){let e=0,t=0;for(const t of this._holidaySessions)t.sessions.forEach((t=>{e=Math.max(e,t.length())}));return this._entries.forEach((e=>{t=Math.max(t,e.length())})),Math.max(e,t)}isWeekEnd(e){const t=(0, -r.lowerbound)(this._entries,new a(e,0,0),((e,t)=>e.dayOfWeek()this._entries.length-1||this._entries[t].dayOfWeek()!==e}isCalWeekEnd(e){const t=s.get_day_of_week(e);if(!this._isThereCorrections)return this.isWeekEnd(t);const i=n.BusinessDay.fromCalendar(e),r=this._holidayAndCorrectionMap.get(i.toString());return void 0===r?this.isWeekEnd(t):0===r.length}hasWeekEnds(){return this.weekEndsCount()>0}weekEndsCount(){return this._weekEndsCount}maxTradingDayLength(){return this._maxTradingDayLength}holidaysFromYearStart(e){if(!this._isThereCorrections)return 0;const t=s.get_timezone(this._timezone),i=new n.BusinessDay(s.get_year(e),s.JANUARY,1),r=n.BusinessDay.fromCalendar(e);let o=0;const a=this._selectHolidays(i,r);for(let e=0;et.start()%e==0&&t.length()%e==0))}indexOfSession(e,t,i){const n=this._getEntriesForWeek(e);let o=(0,r.lowerbound)(n,new a(t,i,0),m);if(o!==n.length)return new l(e,o,n);let c=e;const h=7-t+this._firstDayOfWeek-1;for(i=-(s.minutesPerDay-i+h*s.minutesPerDay);;){c++;const e=this._getEntriesForWeek(c);if(0!==e.length)return o=(0,r.lowerbound)(e,new a(this._firstDayOfWeek,i,0),m),new l(c,o,e)}}findSession(e,t,i,s=0){const r=this.indexOfSession(e,t,i),n=r.entries;let o=r.entryIndex;if(0!==s){const e=n[o].dayOfWeek(),t=s>0?1:-1;for(;;){const i=o+t;if(i<0||i>=n.length||n[i].dayOfWeek()!==e)break;o=i}}return new l(r.weekIndex,o,n)}getWeekIndex(e){if(!this._isThereCorrections)return 0;const t=s.get_day_of_week(e)-s.SUNDAY,i=s.get_timezone("Etc/UTC"),r=s.get_cal(i,s.get_year(e),s.get_month(e),s.get_day_of_month(e)-t);return Math.floor((r.getTime()+f)/1e3/86400/7)}correctTradingDay(e){const t=s.get_day_of_week(e),i=60*s.get_hours(e)+s.get_minutes(e),r=this.getWeekIndex(e),n=this.findSession(r,t,i,0),o=n.getEntry().dayOfWeek()-t+7*(n.weekIndex-r);return 0!==o&&s.add_date(e,o),e}alignToSessionStart(e,t=0){const i=s.get_day_of_week(e),r=60*s.get_hours(e)+s.get_minutes(e),n=this.getWeekIndex(e),o=this.findSession(n,i,r,t),a=o.getEntry(),l=a.dayOfWeek()-i+7*(o.weekIndex-n);0!==l&&s.add_date(e,l);const c=a.startOffset();return s.set_hms(e,c/60,c%60,0,0,s.get_timezone(this._timezone)),a.length()}businessDaysToCalendarDays(e,t){let i=this.getWeekIndex(e),r=s.get_day_of_week(e),n=0,o=0;for(;oi);)e[a].dayOfWeek()=t)return n}i++,r=s.SUNDAY}return n}calendarDaysToBusinessDays(e,t){let i=this.getWeekIndex(e),r=s.get_day_of_week(e),n=0,o=0;for(;ni);)e[a].dayOfWeek()=t)return o}i++,r=s.SUNDAY}return o}alignToNearestSessionStart(e,t){ -return this._alignToNearestSessionValue(e,t,this._entrySessionStart.bind(this))}alignToNearestSessionEnd(e,t){return this._alignToNearestSessionValue(e,t,this._entrySessionEnd.bind(this))}leftBorderOfDailyBar(e){const t=this._getEntriesForDay(e);return 0===t.length?null:(t.sort(o),this._getLeftEntryBorder(e,t[0]))}bordersOfDailyBar(e){const t=this._getEntriesForDay(e);if(0===t.length)return null;t.sort(o);const i=this._getLeftEntryBorder(e,t[0]),r=t[t.length-1],n=s.clone(e);let a=60*(r.startOffset()+r.length())-1;const l=Math.floor(a/3600);return a-=3600*l,s.set_hms(n,l,a/60,a%60,0,s.get_timezone(this._timezone)),{from:i,to:n}}getEntriesForWeekByCalendar(e){const t=this.getWeekIndex(e);return this._getEntriesForWeek(t)}_getEntriesForWeek(e){let t=this._entriesHash.get(e);if(void 0===t)return this._entries;if(null!==t)return t;const i=s.get_timezone(this._timezone);t=this._entries.slice();const r=this._weekIndexToCalendar(e),a=this._weekIndexToCalendar(e+1),l=n.BusinessDay.fromCalendar(r),c=n.BusinessDay.fromCalendar(a),h=this._selectHolidays(l,c);for(const e of h){const r=e.day.toCalendar(i),n=s.get_day_of_week(r);t=t.filter((e=>e.dayOfWeek()!==n)),t=t.concat(e.sessions)}return t.sort(o),this._entriesHash.set(e,t),t}_selectHolidays(e,t){const i=[];let s=e;for(;;){const e=g(this._holidaySessions,s);if(null===e)return i;if(!e.day.before(t))return i;i.push(e),s=e.day.addDays(1)}}_weekIndexToCalendar(e){const t=1e3*(86400*e*7+86400)-f,i=s.get_cal_from_unix_timestamp_ms(s.get_timezone("Etc/UTC"),t),r=s.get_timezone("Etc/UTC");return s.get_cal(r,s.get_year(i),s.get_month(i),s.get_day_of_month(i))}_alignToNearestSessionValue(e,t,i){const r=s.get_day_of_week(e),n=60*s.get_hours(e)+s.get_minutes(e),o=this.getWeekIndex(e);let a=this.findSession(o,r,n);if(a.getEntry().contains(e)&&o===a.weekIndex||1===t)return i(a,s.clone(e),t);const c=a.getEntry(),h=c.contains(e),d=o===a.weekIndex,u=c.sessionStartDaysOffset()-c.dayOfWeek()>=0;if(h&&(d||u))return i(a,s.clone(e),t);let p=a.entryIndex-1;if(p<0){let e=a.weekIndex,t=a.entries;for(;p<0;)e--,t=this._getEntriesForWeek(e),p+=t.length;a=new l(e,p,t)}else a=new l(a.weekIndex,p,a.entries);return i(a,s.clone(e),t)}_entrySessionStart(e,t,i){return this._entrySessionValue(e,t,i,(e=>60*e.start()))}_entrySessionEnd(e,t,i){return this._entrySessionValue(e,t,i,(e=>60*(e.start()+e.length())-1))}_entrySessionValue(e,t,i,r){let n=s.get_day_of_week(t);const o=e.getEntry();let a=o.dayOfWeek()-o.sessionStartDaysOffset();const l=this.getWeekIndex(t);let c=e.weekIndex-l,h=!1;if(a0&&i>=0||c<0&&i<0)&&s.add_date(t,7*c),!o.contains(t)){let e=a-n;h&&i<0&&(e=-(7-a+n)),s.add_date(t,e),n=s.get_day_of_week(t)}o.isOvernight()&&n===o.dayOfWeek()&&s.add_date(t,-o.sessionStartDaysOffset());let d=r(o);const u=Math.floor(d/3600);return d-=3600*u,s.set_hms(t,u,d/60,d%60,0,s.get_timezone(this._timezone)),t}_getEntriesForDay(e){const t=s.get_day_of_week(e);return this._getEntriesForWeek(this.getWeekIndex(e)).filter((e=>e.dayOfWeek()===t))}_getLeftEntryBorder(e,t){ -const i=s.clone(e),r=t.startOffset();return s.set_hms(i,r/60,r%60,0,0,s.get_timezone(this._timezone)),i}}},81049:(e,t,i)=>{"use strict";i.d(t,{barFunctionByStyle:()=>r});var s=i(13497);function r(e,t){switch(e){case 12:return(0,s.barFunction)("low","low","close");case 2:case 14:case 15:case 3:case 10:case 13:return(0,s.barFunction)(null!=t?t:"close");default:return(0,s.barFunction)("close","open")}}},36112:(e,t,i)=>{"use strict";i.d(t,{BarsMarksContainer:()=>m});var s=i(50151),r=i(59224),n=i(56840),o=i.n(n),a=i(14483),l=i(36274),c=i(1722),h=i(42960),d=i(14292),u=i(28558);const p=(0,r.getLogger)("Chart.BarsMarksContainer"),_=Math.round(new Date(2037,0,1).getTime()/1e3);class m extends d.DataSource{constructor(e,t,i){const r=e.onWidget();let n;n=r?!e.hideIdeas():!!a.enabled("bars_marks")&&o().getBool("BarsMarksContainer.visibile",!1),t.merge({visible:n}),t.childs().visible.subscribe(null,(t=>{r||e.isSnapshot()||!a.enabled("bars_marks")||o().setValue("BarsMarksContainer.visibile",!!t.value())})),super(i),this._paneViews=[],this._model=e,this._properties=t,this._requests=[],this._marks={},this._loadedRange=null,this._getDataTimeout=null,this._collectedRange=null,this._lastRange=null;const l=this._model.mainSeries();l.onSymbolIntervalChanged().subscribe(this,this.clearMarks),l.dataEvents().symbolResolved().subscribe(this,this.clearMarks),l.dataEvents().completed().subscribe(this,(()=>{var e,t;const i=l.data();if(0===i.size())return;const r=(0,s.ensureNotNull)(i.first()).index,n=(0,s.ensureNotNull)(i.last()).index,o=this.timeScale();this.getData({start:null!==(e=o.indexToTimePoint(r))&&void 0!==e?e:1/0,end:null!==(t=o.indexToTimePoint(n))&&void 0!==t?t:-1/0})})),this._initialize(),this._pinnedTooltips={}}destroy(){const e=this._model.mainSeries();e.onSymbolIntervalChanged().unsubscribeAll(this),e.dataEvents().symbolResolved().unsubscribeAll(this),e.dataEvents().completed().unsubscribeAll(this)}properties(){return this._properties}marks(){return this._marks}pinTooltip(e,t){this._pinnedTooltips[e]=t}timeScale(){return this._model.timeScale()}getIntervalInTicks(){const e=this._model.mainSeries().properties().childs().interval.value(),t=l.Interval.parse(e);if(!t.isValid())throw new TypeError("Unexpected interval");return t.isRange()?60:t.inMilliseconds()/1e3}getVisibleTickMarksRange(){var e,t;if(this.timeScale().isEmpty())return{start:0,end:0};const i=(0,s.ensureNotNull)(this.timeScale().visibleBarsStrictRange()),{firstIndex:r,lastIndex:n}=(0,s.ensureNotNull)(this.timeScale().points().range().value());if(!(i.lastBar()>r&&i.firstBar(){var r,n;const o=this._marks[s],a=o.tickmark -;a>=(null!==(r=t.start)&&void 0!==r?r:1/0)&&a<=(null!==(n=t.end)&&void 0!==n?n:-1/0)+i&&e.push(o)})),e}getPublishedPlates(){const e={};return window.is_authenticated?(this.getVisibleRangePlates().forEach((t=>{t.is_public&&(this._pinnedTooltips[t.id]||t.user__id===window.user.id)&&(e[t.id]=t)})),e):e}filterDisplayedPlates(e){const t=e.reduce(((e,t)=>{const i=this._getIndex(t.tickmark);return null!==i&&(e[i]=e[i]||[],e[i].push(t)),e}),{});return Object.keys(t).reduce(((e,i)=>{let s=t[i];return s=s.sort(((e,t)=>t.views_count-e.views_count)),s=s.slice(0,10),e.concat(s)}),[])}getPlatesViewData(){var e,t,i;const r=this._model.mainSeries();if(r.data().isEmpty())return[];const n=(0,h.isPriceSourceStyle)(r.style())?r.barFunction():null,o=this.filterDisplayedPlates(this.getVisibleRangePlates()),a={},l=null!==(e=this._model.lastHittestData())&&void 0!==e?e:this._model.lastSelectedHittestData();let c=null;null!==l&&this._model.hoveredSource()===this&&(c=null!==(t=l.activeItem)&&void 0!==t?t:null);const d=[];for(const e of o){const t=(0,s.ensureNotNull)(this._getIndex(e.tickmark)),i=this._getBar(t);if(null===i)continue;const r=this._layout(e.direction),o=this._theme(e.direction),l=c===e.id,h=this.timeScale().indexToCoordinate(t),u=this._offset(r,i,n),p=(0,s.ensureNotNull)(this.priceScale()).isInverted();let _=0;t in a||(a[t]={up:0,down:0}),_=a[t][r]++,d.push({id:e.id,x:h,y:u,yInverted:p,order:_,direction:r,theme:o,hovered:l,pinned:!0===this._pinnedTooltips[e.id],user__id:e.user__id,label:e.label,labelFontColor:e.labelFontColor||"#444",minSize:e.minSize||5,...this._plateViewData(e)})}const u=d.filter((e=>!0===e.hovered));for(let e=0;ee.hovered&&!t.hovered?1:0)),d}priceAxisViews(){return null}updateAllViews(e){for(const t of this._paneViews)t.update(e)}updateAllViewsAndRepaint(){this.updateAllViews((0,u.sourceChangeEvent)(this.id())),this._model.updateSource(this)}roundRange(e){return{start:Math.round(e.start),end:Math.round(e.end)}}refreshData(){null!==this._lastRange&&this.getData(this._lastRange)}getData(e){(0,c.isNumber)(e.start)&&(0,c.isNumber)(e.end)?(this._lastRange=e,e.end=_,this._pushGetDataStack(Object.assign({},e))):p.logError("Wrong range")}clearMarks(){this._abortAllRequests(),this._marks={},this._loadedRange=null}isUserDeletable(){return!1}isSavedInChart(e){return!1}isSpeciallyZOrderedSource(){return!0}showInObjectTree(){return!1}_plateViewData(e){return{}}_layout(e){switch(e){default:case 0:case 2:case 3:case 4:case 5:case 6:return"up";case 1:return"down"}}_theme(e){switch(e){default:case 0:return"neutral";case 1:case 5:return"green";case 2:case 6:return"red";case 3:return"yellow";case 4:return"blue"}}_offset(e,t,i){let r;switch(e){default:case"up":r=null===i?t[2]:i(t);break;case"down":r=null===i?t[3]:i(t)}return(0,s.ensureNotNull)(this.priceScale()).priceToCoordinate(r,(0,s.ensureNotNull)((0,s.ensureNotNull)(this.ownerSource()).firstValue()))}_getIndex(e){ -return this.timeScale().timePointToIndex(e)}_getBar(e){return this._model.mainSeries().data().valueAt(e)}_rangeDifference(e){return e=Object.assign({start:1/0,end:-1/0},e),this._loadedRange&&(e.startthis._loadedRange.end&&(e.start=this._loadedRange.end)),e}_rangeUnion(e,t){return e=Object.assign({start:1/0,end:-1/0},e),t&&(e.start=Math.min(t.start,e.start),e.end=Math.max(t.end,e.end)),e}_pushGetDataStack(e){(0,c.isNumber)(e.start)&&(0,c.isNumber)(e.end)?(this._getDataTimeout&&clearTimeout(this._getDataTimeout),this._collectedRange=this._rangeUnion(e,this._collectedRange),this._getDataTimeout=setTimeout((()=>{this._getData(this._collectedRange),this._getDataTimeout=this._collectedRange=null}),300)):p.logError("Wrong tickmark range")}_abortAllRequests(){this._requests.forEach((e=>{e.cancel()})),this._requests=[],this._getDataTimeout&&clearTimeout(this._getDataTimeout),this._getDataTimeout=this._collectedRange=null}}},35994:(e,t,i)=>{"use strict";var s=i(48891).getHexColorByName,r=(i(62615).RangeBarStyle,i(86094).PlotRowSearchMode),n=i(72877).STUDYPLOTDISPLAYTARGET,o=i(87095).rgbaFromInteger,a=s("color-minty-green-500"),l=s("color-ripe-red-500");function c(){this.backColorers=[]}function h(e){c.call(this),this._series=e}function d(e,t){c.call(this),this._study=e,this._plotIndex=t}c.prototype.barStyle=function(e,t,i){for(var s={},r=this.backColorers.length-1;r>=0;r--)this.backColorers[r].applyBarStyle(e,t,s,i);return this.applyBarStyle(e,t,s,i),s},c.prototype.pushBackBarColorer=function(e){this.backColorers.push(e)},c.prototype.applyBarStyle=function(e,t,i){throw new Error("This function is supposed to be reimplemented in a subclass")},inherit(h,c),h.upColor=function(e,t){switch(e.style.value()){case TradingView.Series.STYLE_LINE:return e.lineStyle.color.value();case TradingView.Series.STYLE_LINE_WITH_MARKERS:return e.lineWithMarkersStyle.color.value();case TradingView.Series.STYLE_STEPLINE:return e.steplineStyle.color.value();case TradingView.Series.STYLE_AREA:return e.areaStyle.linecolor.value();case TradingView.Series.STYLE_HLC_AREA:return e.hlcAreaStyle.closeLineColor.value();case TradingView.Series.STYLE_BARS:return e.barStyle.upColor.value();case TradingView.Series.STYLE_CANDLES:return e.candleStyle.upColor.value();case TradingView.Series.STYLE_HOLLOW_CANDLES:return e.hollowCandleStyle.upColor.value();case TradingView.Series.STYLE_HEIKEN_ASHI:return e.haStyle.upColor.value();case TradingView.Series.STYLE_BASELINE:return e.baselineStyle.topLineColor.value();case TradingView.Series.STYLE_HILO:return e.hiloStyle.color.value();case TradingView.Series.STYLE_COLUMNS:return e.columnStyle.upColor.value()}throw new Error("Unknown series style")},h.downColor=function(e,t){switch(e.style.value()){case TradingView.Series.STYLE_LINE:return e.lineStyle.color.value();case TradingView.Series.STYLE_LINE_WITH_MARKERS:return e.lineWithMarkersStyle.color.value();case TradingView.Series.STYLE_STEPLINE:return e.steplineStyle.color.value();case TradingView.Series.STYLE_AREA: -return e.areaStyle.linecolor.value();case TradingView.Series.STYLE_HLC_AREA:return e.hlcAreaStyle.closeLineColor.value();case TradingView.Series.STYLE_BARS:return e.barStyle.downColor.value();case TradingView.Series.STYLE_CANDLES:return e.candleStyle.downColor.value();case TradingView.Series.STYLE_HOLLOW_CANDLES:return e.hollowCandleStyle.downColor.value();case TradingView.Series.STYLE_HEIKEN_ASHI:return e.haStyle.downColor.value();case TradingView.Series.STYLE_BASELINE:return e.baselineStyle.bottomLineColor.value();case TradingView.Series.STYLE_HILO:return e.hiloStyle.color.value();case TradingView.Series.STYLE_COLUMNS:return e.columnStyle.downColor.value()}throw new Error("Unknown series style")},h.prototype._applyLineStyle=function(e,t,i,s,r){i.barColor=h.upColor(r)},h.prototype._applyAreaStyle=function(e,t,i,s,r){i.barColor=h.upColor(r)},h.prototype._applyHLCAreaStyle=function(e,t,i,s,r){var n,o=this.findBar(e,!1,s),c=this.findPrevBar(e,!1,s);n=this._series.data().first().index!==e?c[TradingView.CLOSE_PLOT]<=o[TradingView.CLOSE_PLOT]:o[TradingView.OPEN_PLOT]<=o[TradingView.CLOSE_PLOT],i.barColor=h.upColor(r,t),i.barBorderColor=n?a:l},h.prototype._applyBarStyle=function(e,t,i,s,r){var n=h.upColor(r),o=h.downColor(r),a=this.findBar(e,!1,s);if(r.barStyle.barColorsOnPrevClose.value()){var l=this.findPrevBar(e,!1,s);i.barColor=l[TradingView.CLOSE_PLOT]<=a[TradingView.CLOSE_PLOT]?n:o,i.barBorderColor=l[TradingView.CLOSE_PLOT]<=a[TradingView.CLOSE_PLOT]?n:o}else i.barColor=a[TradingView.OPEN_PLOT]<=a[TradingView.CLOSE_PLOT]?n:o,i.barBorderColor=a[TradingView.OPEN_PLOT]<=a[TradingView.CLOSE_PLOT]?n:o},h.prototype._applyCandleStyle=function(e,t,i,s,r){var n,o=h.upColor(r,t),a=h.downColor(r,t),l=r.candleStyle.borderUpColor?r.candleStyle.borderUpColor.value():r.candleStyle.borderColor.value(),c=r.candleStyle.borderDownColor?r.candleStyle.borderDownColor.value():r.candleStyle.borderColor.value(),d=r.candleStyle.wickUpColor?r.candleStyle.wickUpColor.value():r.candleStyle.wickColor.value(),u=r.candleStyle.wickDownColor?r.candleStyle.wickDownColor.value():r.candleStyle.wickColor.value(),p=this.findBar(e,!1,s);r.candleStyle.barColorsOnPrevClose.value()&&this._series.data().first().index!==e?n=this.findPrevBar(e,!1,s)[TradingView.CLOSE_PLOT]<=p[TradingView.CLOSE_PLOT]:n=p[TradingView.OPEN_PLOT]<=p[TradingView.CLOSE_PLOT];i.barColor=n?o:a,i.barBorderColor=n?l:c,i.barWickColor=n?d:u},h.prototype._applyHollowCandleStyle=function(e,t,i,s,r){var n,o=h.upColor(r,t),a=h.downColor(r,t),l=r.hollowCandleStyle.borderUpColor?r.hollowCandleStyle.borderUpColor.value():r.hollowCandleStyle.borderColor.value(),c=r.hollowCandleStyle.borderDownColor?r.hollowCandleStyle.borderDownColor.value():r.hollowCandleStyle.borderColor.value(),d=r.hollowCandleStyle.wickUpColor?r.hollowCandleStyle.wickUpColor.value():r.hollowCandleStyle.wickColor.value(),u=r.hollowCandleStyle.wickDownColor?r.hollowCandleStyle.wickDownColor.value():r.hollowCandleStyle.wickColor.value(),p=this.findBar(e,!1,s),_=this.findPrevBar(e,!1,s) -;n=this._series.data().first().index!==e?_[TradingView.CLOSE_PLOT]<=p[TradingView.CLOSE_PLOT]:p[TradingView.OPEN_PLOT]<=p[TradingView.CLOSE_PLOT],i.barColor=n?o:a,i.barBorderColor=n?l:c,i.barWickColor=n?d:u,i.isBarHollow=p[TradingView.OPEN_PLOT]<=p[TradingView.CLOSE_PLOT]},h.prototype._applyHAStyle=function(e,t,i,s,r){var n,o=h.upColor(r,t),a=h.downColor(r,t),l=r.haStyle.borderUpColor.value(),c=r.haStyle.borderDownColor.value(),d=r.haStyle.wickUpColor.value(),u=r.haStyle.wickDownColor.value(),p=this.findBar(e,t,s);r.haStyle.barColorsOnPrevClose.value()?n=this.findPrevBar(e,t,s)[TradingView.CLOSE_PLOT]<=p[TradingView.CLOSE_PLOT]:n=p[TradingView.OPEN_PLOT]<=p[TradingView.CLOSE_PLOT];i.barColor=n?o:a,i.barBorderColor=n?l:c,i.barWickColor=n?d:u},h.prototype._applyBaseLineStyle=function(e,t,i,s,r){var n=this.findBar(e,t,s),o=r.baselineStyle,a=this._series.priceScale(),l=Math.round(a.height()*(Math.abs(100-o.baseLevelPercentage.value())/100)),c=this._series.firstValue(),d=a.coordinateToPrice(l,c);n[TradingView.CLOSE_PLOT]>d?i.barColor=h.upColor(r,t):i.barColor=h.downColor(r,t)},h.prototype._applyHiLoStyle=function(e,t,i,s,r){i.barColor=h.upColor(r,t),i.barBorderColor=r.hiloStyle.borderColor.value()},h.prototype._applyColumnStyle=function(e,t,i,s,r){var n=h.upColor(r),o=h.downColor(r),a=this.findBar(e,!1,s);if(r.columnStyle.barColorsOnPrevClose.value()){var l=this.findPrevBar(e,!1,s);i.color=l[TradingView.CLOSE_PLOT]<=a[TradingView.CLOSE_PLOT]?n:o}else i.color=a[TradingView.OPEN_PLOT]<=a[TradingView.CLOSE_PLOT]?n:o;i.barColor=i.color},h.prototype.applyBarStyle=function(e,t,i,s){i||(i={}),i.barColor=null,i.barBorderColor=null,i.barWickColor=null,i.isBarHollow=null,i.isBarUp=null,i.upColor=null,i.downColor=null,i.isTwoColorBar=null,i.isMergedBar=null;var r=this._series.properties();switch(r.style.value()){case TradingView.Series.STYLE_LINE:case TradingView.Series.STYLE_LINE_WITH_MARKERS:case TradingView.Series.STYLE_STEPLINE:this._applyLineStyle(e,t,i,s,r);break;case TradingView.Series.STYLE_AREA:this._applyAreaStyle(e,t,i,s,r);break;case TradingView.Series.STYLE_HLC_AREA:this._applyHLCAreaStyle(e,t,i,s,r);break;case TradingView.Series.STYLE_BARS:this._applyBarStyle(e,t,i,s,r);break;case TradingView.Series.STYLE_CANDLES:this._applyCandleStyle(e,t,i,s,r);break;case TradingView.Series.STYLE_HOLLOW_CANDLES:this._applyHollowCandleStyle(e,t,i,s,r);break;case TradingView.Series.STYLE_HEIKEN_ASHI:this._applyHAStyle(e,t,i,s,r);break;case TradingView.Series.STYLE_BASELINE:this._applyBaseLineStyle(e,t,i,s,r);break;case TradingView.Series.STYLE_HILO:this._applyHiLoStyle(e,t,i,s,r);break;case TradingView.Series.STYLE_COLUMNS:this._applyColumnStyle(e,t,i,s,r)}return i},h.prototype.getSeriesBars=function(e){return e?this._series.nsBars():this._series.bars()},h.prototype._findBarFieldValue=function(e,t,i){var s=this.getSeriesBars(i).valueAt(e);if(null!==s)return s[t]},h.prototype.findBar=function(e,t,i){return i?i.value:this.getSeriesBars(t).valueAt(e)||[]},h.prototype.findPrevBar=function(e,t,i){if(i&&i.previousValue)return i.previousValue -;var s=this._series.bars().search(e-1,r.NearestLeft,TradingView.CLOSE_PLOT);return null!==s?s.value:[]},inherit(d,c),d.prototype.getBars=function(){return this._study.series().bars()},d.prototype.firstColoredBar=function(e){for(var t=e,i=0;ie+c)return i;if(s.styles[l.id].display.value()===n.None)return i;var h=a.valueAt(e-c);if(null===h)return i;var d=h[this._plotIndex+1];if(null==d)return i;if(d=Math.round(d),r.isRGB)i.barColor=o(d),i.upColor=i.barColor,i.downColor=i.barColor;else{var u=r.plots[this._plotIndex].palette,p=s.palettes[u],_=r.palettes[u].valToIndex?r.palettes[u].valToIndex[d]:d,m=p.colors[_].color.value();i.barColor=m,i.upColor=m.color,i.downColor=m.color}return i},t.SeriesBarColorer=h,t.StudyBarColorer=d},12500:(e,t,i)=>{"use strict";i.d(t,{BarsRange:()=>r});var s=i(50151);class r{constructor(e,t){(0,s.assert)(e<=t,"The last bar in the bars range should be greater than or equal to the first bar"),this._firstBar=e,this._lastBar=t}firstBar(){return this._firstBar}lastBar(){return this._lastBar}count(){return this._lastBar-this._firstBar+1}contains(e){return this._firstBar<=e&&e<=this._lastBar}equals(e){return this._firstBar===e.firstBar()&&this._lastBar===e.lastBar()}static compare(e,t){return null===e||null===t?e===t:e.equals(t)}}},73971:(e,t,i)=>{"use strict";i.d(t,{ChartModelBase:()=>cs});var s=i(12481),r=i(27788),n=i(50151),o=i(86441),a=i(24377),l=i(48891),c=i(44352),h=i(45345),d=i(5286),u=i(51768),p=i(51608),_=i(76422),m=i(11417),g=i(67980),f=i(3587),v=i(78071),S=i(92249);function y(e){return(0,S.isLineTool)(e)&&e.boundToSymbol()||!1}class b{constructor(){this._items=[],this._set=new Set,this._dataSourcesCache=null,this._customSourcesCache=null,this._lineSourcesCache=null}isEmpty(){return 0===this._items.length}add(e){if(this._items.length>0&&!y(this._items[0])&&this.clear(),y(e)){const t=(0,v.lowerbound)(this._items,e,((e,t)=>e.zorder()!(0,f.isDataSource)(e)))),this._customSourcesCache}checkLineToolSelection(){this._items.forEach((e=>(0,S.isLineTool)(e)&&e.calcIsActualSymbol())),this._items=this._items.filter((e=>!(0,S.isLineTool)(e)||e.isActualSymbol())),this._invalidateCache()}remove(e){this._items=this._items.filter((t=>t!==e)),this._set.delete(e),this._invalidateCache()}clear(){this._items=[],this._set.clear(),this._invalidateCache()}_invalidateCache(){this._customSourcesCache=null,this._dataSourcesCache=null,this._lineSourcesCache=null}}var w=i(6674),P=i(52329),C=i(76949),x=i(36274),T=i(46100),I=i(59452),M=i.n(I),L=i(29764),A=i(46501);class k{constructor(e){this._rendererOptions={borderSize:1,additionalPaddingInner:0,fontSize:NaN,font:"",color:"",paneBackgroundColor:"",paddingBottom:0,paddingInner:0,paddingOuter:0,paddingTop:0,lineSpacing:0},this._chartModel=e}options(){const e=this._rendererOptions,t=this._chartModel.properties().childs(),i=t.scalesProperties.childs().fontSize.value();return e.fontSize!==i&&(e.fontSize=i,e.font=(0,L.makeFont)(i,A.CHART_FONT_FAMILY,""),e.paddingTop=i/12*2.5,e.paddingBottom=i/12*2.5,e.paddingInner=i/12*4,e.additionalPaddingInner=i/12*4,e.paddingOuter=i/12*4,e.lineSpacing=i/12*2),e.color=t.scalesProperties.childs().textColor.value(),e.paneBackgroundColor=t.paneProperties.childs().background.value(),this._rendererOptions}}var D=i(94739),V=i(12442),E=i(61146),B=i(85804),R=i(15742),N=i(14483),O=i(42960),F=i(16776),W=i(28558);const H=new E.PriceFormatter,z="sessions";class U extends R.CustomSourceBase{constructor(e,t,i){super(e,t),this._studySource=null,this._paneViews=[],this._metaInfo=null,this._destroyed=!1,this._isStarted=!1,this._loadedGraphics=null,this._doubleClickHandler=i;const s=t.mainSeries();this._properties=new T.DefaultProperty("sessions"),(0,B.applyDefaultsOverrides)(this._properties.childs().graphics,void 0,!1,z),this._removeDuplicateProperties(),this._properties.subscribe(this,this._onPropertiesChanged),t.studyMetaInfoRepository().findById({type:"java",studyId:"Sessions@tv-basicstudies"}).then((i=>{this._destroyed||null===this._loadedGraphics&&(this._setMetaInfo(i),null!==this._metaInfo&&(this._studySource=new D.StudyDataSource(t.chartApi(),s.seriesSource(),"sessions_",this._metaInfo),this._createPaneViews(),this._studySource.dataCleared().subscribe(this,this.updateAllViews.bind(this,(0,W.sourceChangeEvent)(e))),this._studySource.dataUpdated().subscribe(this,this.updateAllViews.bind(this,(0,W.sourceChangeEvent)(e))),this._studySource.setInputs({}),this._processHibernate()))})),t.timeScale().onReset().subscribe(this,this._clearData),t.timeScale().logicalRangeChanged().subscribe(this,this.updateAllViews.bind(this,(0,W.viewportChangeEvent)())),t.mainSeries().sessionIdProxyProperty().subscribe(this,this._updateVisibleOfPreAndPostMarketBackground),t.mainSeries().properties().childs().interval.subscribe(this,this._processHibernate), -this._updateVisibleOfPreAndPostMarketBackground(t.mainSeries().properties().childs().sessionId)}applyOverrides(e){(0,B.applyPropertiesOverrides)(this._properties.childs().graphics,void 0,!1,e,z),this._model.updateSource(this)}start(){this._isStarted=!0,this._processHibernate()}restart(){this._clearData(),N.enabled("stop_study_on_restart")&&this.stop(),this.start()}isStarted(){return this._isStarted}stop(){this._isStarted=!1,null!==this._studySource&&this._studySource.stop()}isHoveredEnabled(){return!1}paneViews(e){return this._paneViews}updateAllViews(e){this._paneViews.forEach((t=>t.update(e)))}updateViewsForPane(e,t){this.updateAllViews(t)}destroy(){this._destroyed=!0,null!==this._studySource&&(this._studySource.dataCleared().unsubscribeAll(this),this._studySource.dataUpdated().unsubscribeAll(this),this._studySource.destroy(),this._studySource=null),this._model.timeScale().logicalRangeChanged().unsubscribeAll(this),this._model.timeScale().onReset().unsubscribeAll(this),this._model.mainSeries().sessionIdProxyProperty().unsubscribeAll(this),this._model.mainSeries().properties().childs().interval.unsubscribeAll(this),this._properties.unsubscribeAll(this)}series(){return this._model.mainSeries()}priceScale(){return this.series().priceScale()}graphics(){return this._loadedGraphics||(0,n.ensureNotNull)(this._studySource).graphics()}valueAt(e,t){return null}properties(){return this._properties}graphicsInfo(){return(0,n.ensureNotNull)(this._metaInfo).graphics}firstValue(e){return this._model.mainSeries().firstValue()}formatter(){return H}state(e){const t={properties:this._properties.state()};return e&&null!==this._metaInfo&&(t.data={graphics:(0,V.saveStudyGraphics)(this.graphics(),this._model.timeScale().visibleBarsStrictRange()),metaInfo:this._metaInfo}),t}restoreState(e,t){const i=e.properties;this._migrateOutOfSessionProperty(i),this._properties.mergeAndFire(i),this._removeDuplicateProperties(),this._updateVisibleOfPreAndPostMarketBackground(this._model.mainSeries().properties().childs().sessionId),void 0!==e.data&&t&&(this._loadStudyGraphics(e.data.graphics),this._setMetaInfo(e.data.metaInfo),this._createPaneViews())}restoreOldState(e,t){const i={properties:{graphics:e.state.graphics}};void 0!==e.data&&void 0!==e.metaInfo&&t&&(i.data={metaInfo:e.metaInfo,graphics:e.data.graphics}),this.restoreState(i,t)}applyPreferences(e){this._properties.mergePreferences(e)}metaInfo(){return(0,n.ensureNotNull)(this._metaInfo)}_loadStudyGraphics(e){const t=e.backgrounds;if(void 0!==t){const e=t.findIndex((e=>"inSession"===e.styleId));-1!==e&&t.splice(e,1)}this._loadedGraphics=(0,V.loadStudyGraphics)(e)}_setMetaInfo(e){const t=e.graphics.backgrounds;void 0!==t&&void 0!==t.inSession&&delete t.inSession,this._metaInfo=e}_updateVisibleOfPreAndPostMarketBackground(e){const t=!(0,O.isRegularSessionId)(e.value());this._outOfSessionVisibilityProperty().setValue(t),this._preMarketVisibilityProperty().setValue(t),this._postMarketVisibilityProperty().setValue(t)}_clearData(){null!==this._studySource&&this._studySource.clearData()} -_createPaneViews(){const e={doubleClickHandler:this._doubleClickHandler};(0,V.createGraphicsPaneViews)(this,this._model,e).then((e=>{this._paneViews=e,this._model.lightUpdate()}))}_onPropertiesChanged(){this._processHibernate(),this.updateAllViews((0,W.sourceChangeEvent)(this.id()))}_processHibernate(){if(null!==this._studySource){const e=this._canBeHibernated(),t=this._isHibernated(),i=this._studySource.isStarted();!t&&e&&i?this._studySource.stop():!t||e||i||this._studySource.start()}}_canBeHibernated(){const e=this._model.mainSeries(),t=this._preMarketVisibilityProperty().value()&&this._postMarketVisibilityProperty().value()&&this._outOfSessionVisibilityProperty().value();return e.isDWM()||!t&&!this._vertLinesVisibleProperty().value()}_isHibernated(){return this._isStarted&&(null===this._studySource||!this._studySource.isStarted())}_outOfSessionVisibilityProperty(){return this._properties.childs().graphics.childs().backgrounds.childs().outOfSession.childs().visible}_preMarketVisibilityProperty(){return this._properties.childs().graphics.childs().backgrounds.childs().preMarket.childs().visible}_postMarketVisibilityProperty(){return this._properties.childs().graphics.childs().backgrounds.childs().postMarket.childs().visible}_vertLinesVisibleProperty(){return this._properties.childs().graphics.childs().vertlines.childs().sessBreaks.childs().visible}_removeDuplicateProperties(){this._properties.hasChild("properties")&&(this._properties.removeProperty("properties"),(0,T.saveDefaultProperties)(!0),this._properties.childChanged(null),(0,T.saveDefaultProperties)(!1))}_migrateOutOfSessionProperty(e){const t=e.graphics.backgrounds;if(void 0!==t){const i=t.outOfSession;i.color===(0,n.ensureDefined)(F.sessionsPreferencesDefault.graphics.backgrounds).outOfSession.color||"postMarket"in t||(e.graphics.backgrounds={...t,postMarket:{color:i.color,transparency:i.transparency,visible:i.visible},preMarket:{color:i.color,transparency:i.transparency,visible:i.visible}})}}}var j=i(28853),G=i(57898),q=i(97145),$=i(83669),Y=i(91280),K=i(42226),Z=i(39875),X=i(59224),J=i(36174),Q=i(49535),ee=i(36298),te=i(42856),ie=i(1722),se=i(29921),re=i(80842),ne=i(98517);const oe=new Map([["price",e=>(0,re.isPriceDataSource)(e)],["trading",e=>(0,S.isTrading)(e)],["drawing",e=>(0,S.isLineTool)(e)&&!(0,S.isTrading)(e)&&!e.isPhantom()],["drawingsForAllSymbols",e=>(0,S.isLineTool)(e)&&!(0,S.isTrading)(e)&&!e.isPhantom()],["phantom",e=>(0,S.isLineTool)(e)&&e.isPhantom()],["restRowSources",e=>!(0,S.isLineTool)(e)&&!(0,S.isTrading)(e)],["legendViewSources",e=>(0,re.isPriceDataSource)(e)||(0, -S.isStudyLineTool)(e)],["leftPriceScale",(e,t)=>"left"===le(e,t)],["rightPriceScale",(e,t)=>"right"===le(e,t)],["overlayPriceScale",(e,t)=>"overlay"===le(e,t)]]),ae=new Map([["price","visibleSorted"],["trading","visibleSorted"],["drawing","visibleSorted"],["drawingsForAllSymbols","allSorted"],["phantom","visibleSorted"],["restRowSources","visibleSorted"],["legendViewSources","visibleSorted"],["leftPriceScale","visibleSorted"],["rightPriceScale","visibleSorted"],["overlayPriceScale","visibleSorted"]]);function le(e,t){const i=e.priceScale();return null===i?"overlay":t.priceScalePosition(i)}class ce{constructor(e){this._groupedSources=new Map,this._sources=null,this._pane=e}clear(){this._groupedSources.clear(),this._sources=null}destroy(){this.clear()}all(){return this._groupedSources.has("visibleSorted")||this._sortSources(),(0,n.ensureDefined)(this._groupedSources.get("visibleSorted"))}allIncludingHidden(){return this._groupedSources.has("allSorted")||this._sortSources(),(0,n.ensureDefined)(this._groupedSources.get("allSorted"))}allExceptSpecialSources(){if(!this._groupedSources.has("exceptSpecial")){const e=this.allIncludingHidden().filter((e=>!e.isSpeciallyZOrderedSource()));this._groupedSources.set("exceptSpecial",e)}return(0,n.ensureDefined)(this._groupedSources.get("exceptSpecial"))}tradingSources(){return this._getSourcesByGroupType("trading")}priceSources(){return this._getSourcesByGroupType("price")}lineSources(){return this._getSourcesByGroupType("drawing")}lineSourcesForAllSymbols(){return this._getSourcesByGroupType("drawingsForAllSymbols")}phantomSources(){return this._getSourcesByGroupType("phantom")}allExceptLineAndTradingSources(){return this._getSourcesByGroupType("restRowSources")}hitTestSources(){if(!this._groupedSources.has("hitTest")){const e=this.allExceptLineAndTradingSources().concat(this.lineSources());this._groupedSources.set("hitTest",e)}return(0,n.ensureDefined)(this._groupedSources.get("hitTest"))}generalSources(){if(!this._groupedSources.has("general")){const e=this.allExceptLineAndTradingSources().concat(this.lineSources());this._groupedSources.set("general",(0,ne.sortSources)(e))}return(0,n.ensureDefined)(this._groupedSources.get("general"))}leftPriceScalesSources(){return this._getSourcesByGroupType("leftPriceScale")}rightPriceScalesSources(){return this._getSourcesByGroupType("rightPriceScale")}overlayPriceScaleSources(){return this._getSourcesByGroupType("overlayPriceScale")}legendViewSources(){return this._getSourcesByGroupType("legendViewSources")}_getSourcesByGroupType(e){const t=(0,n.ensureDefined)(ae.get(e));return this._groupedSources.has(t)?this._groupedSources.has(e)||this._groupSources(e):(this._sortSources(),this._groupSources(e)),(0,n.ensureDefined)(this._groupedSources.get(e))}_sortSources(){null===this._sources&&(this._sources=this._pane.dataSources());const e=(0,ne.sortSources)(this._sources),t=e.filter((e=>!(0,S.isLineTool)(e)||e.isActualSymbol()&&e.isActualCurrency()&&e.isActualUnit()));this._groupedSources.set("allSorted",e), -this._groupedSources.set("visibleSorted",t)}_groupSources(e){const t=(0,n.ensureDefined)(ae.get(e)),i=oe.get(e);if(void 0!==i){const s=(0,n.ensureDefined)(this._groupedSources.get(t)).filter((e=>i(e,this._pane)));this._groupedSources.set(e,s)}}}var he=i(15367),de=i(34256),ue=i(78211),pe=i(76544),_e=i(18611),me=i(26512),ge=i(37160);class fe{constructor(e,t){if(this._base=e,this._integralDividers=t,(0,ge.isBaseDecimal)(this._base))this._fractionalDividers=[2,2.5,2];else{this._fractionalDividers=[];for(let e=this._base;1!==e;){if(e%2==0)this._fractionalDividers.push(2),e/=2;else{if(e%5!=0)throw new Error("unexpected base");this._fractionalDividers.push(2),this._fractionalDividers.push(2.5),e/=5}if(this._fractionalDividers.length>100)throw new Error("something wrong with base")}}}tickSpan(e,t,i){const s=0===this._base?0:1/this._base,r=Math.min(1e-14,(e-t)/1e3);let n=Math.pow(10,Math.max(0,Math.ceil((0,ge.log10)(e-t)))),o=0,a=this._integralDividers[0];for(;;){const e=(0,ge.greaterOrEqual)(n,s,r)&&n>s+r,t=(0,ge.greaterOrEqual)(n,i*a,r),l=(0,ge.greaterOrEqual)(n,1,r);if(!(e&&t&&l))break;n/=a,a=this._integralDividers[++o%this._integralDividers.length]}if(n<=s+r&&(n=s),n=Math.max(1,n),this._fractionalDividers.length>0&&(0,ge.equal)(n,1,r))for(o=0,a=this._fractionalDividers[0];(0,ge.greaterOrEqual)(n,i*a,r)&&n>s+r;)n/=a,a=this._fractionalDividers[++o%this._fractionalDividers.length];return n}}class ve{constructor(e,t,i,s){this._marks=null,this._priceScale=e,this._base=t,this._coordinateToLogicalFunc=i,this._logicalToCoordinateFunc=s}base(){return this._base}setBase(e){if(e<0)throw new Error("base < 0");this._base=e}tickSpan(e,t,i=0){if(ei&&(l=c);const h=o.tickSpan(e,t,r);h>i&&(l=Math.min(l,h));const d=a.tickSpan(e,t,r);return d>i&&(l=Math.min(l,d)),l>0?l:e-t}rebuildTickMarks(){this._marks=null}marks(){return null===this._marks&&(this._marks=this._rebuildTickMarksImpl()),this._marks}_fontHeight(){return this._priceScale.fontSize()}_tickMarkHeight(){return Math.ceil(2.5*this._fontHeight())}_rebuildTickMarksImpl(){const e=this._priceScale,t=[],i=e.mainSource();if(e.isEmpty()||null===i)return t;let s=i.firstValue();null===s&&(s=0);const r=e.height(),n=this._coordinateToLogicalFunc(r-1,s),o=this._coordinateToLogicalFunc(0,s),a=Math.max(n,o),l=Math.min(n,o);if(a===l)return t;let c=this.tickSpan(a,l),h=a%c;h+=h<0?c:0;const d=a>=l?1:-1;let u=null;const p=e.formatter();let _=NaN;for(let i=a-h;i>l;i-=c){i===_&&(c=this.tickSpan(a,l,c)),_=i;const r=this._logicalToCoordinateFunc(i,s);null!==u&&Math.abs(r-u){const e=this.mainSource();if(e&&e.model()){const t=e.model().paneForSource(e);t&&e.model().updatePane(t)}})),this._scalesProperties.subscribe(this,(()=>{this._marksCache=null})),this._properties.childs().lockScale.subscribe(this,this._updateResetAvailableValue),this._properties.childs().autoScale.subscribe(this,this._updateResetAvailableValue),this._updateResetAvailableValue(),this.setId((0,J.randomHash)())}id(){return this._id}setId(e){this._id=e}isLog(){return this._properties.childs().log.value()}isPercentage(){return this._properties.childs().percentage.value()}isInverted(){return this._properties.childs().isInverted.value()}isIndexedTo100(){return this._properties.childs().indexedTo100.value()}isAutoScale(){return this._properties.childs().autoScale.value()&&!this.isLockScale()}isLockScale(){return this._properties.childs().lockScale.value()}isRegular(){return!this.isPercentage()&&!this.isLog()&&!this.isIndexedTo100()}properties(){return this._properties}height(){return this.m_height}setHeight(e){this.m_height!==e&&(this.m_height=e,this._invalidateInternalHeightCache(),this._marksCache=null)}internalHeight(){if(this._internalHeightCache)return this._internalHeightCache;const e=this.height()-this.topPixelMargin()-this.bottomPixelMargin();return this._internalHeightCache=e,e} -fontSize(){return this._scalesProperties.childs().fontSize.value()}priceRange(){return this._makeSureItIsValid(),this.m_priceRange}setPriceRange(e,t,i){if(!(e instanceof de.PriceRange))throw new TypeError("incorrect price range");const s=this.m_priceRange;if(!t&&de.PriceRange.compare(s,e))return;const r=null!==this._maxPriceRange&&this._maxPriceRange.containsStrictly(e),n=null!==this._minPriceRange&&e.containsStrictly(this._minPriceRange);this.isLockScale()&&!t&&(r||n)||(this._marksCache=null,this.m_priceRange=e,i||this._priceRangeChanged.fire(s,e))}setMinPriceRange(e){this._minPriceRange=e}setMaxPriceRange(e){this._maxPriceRange=e}recalculatePriceRangeOnce(){this._recalculatePriceRangeOnce=!0}priceRangeShouldBeRecalculatedOnce(){if(!this._recalculatePriceRangeOnce||this.isLockScale())return!1;const e=this.mainSource();return null!==e&&e.priceRangeReady()}priceRangeChanged(){return this._priceRangeChanged}mode(){const e=this._properties.childs();return{autoScale:e.autoScale.value(),lockScale:e.lockScale.value(),percentage:e.percentage.value(),indexedTo100:e.indexedTo100.value(),log:e.log.value()}}setMode(e){const t={},i=this.mode(),s=this._properties.state();let r=null;void 0!==e.autoScale&&e.autoScale!==s.autoScale&&(t.autoScale=e.autoScale,this._setAutoScaleValueWithDependentProperties(e.autoScale)),void 0!==e.lockScale&&e.lockScale!==s.lockScale&&(t.lockScale=e.lockScale,this._setLockScaleValueWithDependentProperties(e.lockScale)),void 0!==e.percentage&&e.percentage!==s.percentage&&(t.percentage=e.percentage,this._setPercentageValueWithDependentProperties(e.percentage),this._invalidatedForRange.isValid=!1),void 0!==e.indexedTo100&&e.indexedTo100!==s.indexedTo100&&(t.indexedTo100=e.indexedTo100,this._setIndexedTo100ValueWithDependentProperties(e.indexedTo100),this._invalidatedForRange.isValid=!1),void 0!==e.log&&e.log!==s.log&&(t.log=e.log,this._setLogValueWithDependentProperties(e.log));const n=this._properties.childs();s.log&&!n.log.value()&&(this._canConvertPriceRangeFromLog(this.m_priceRange)?(r=this._convertPriceRangeFromLog(this.m_priceRange),null!==r&&this.setPriceRange(r)):n.autoScale.setValue(!0)),!s.log&&n.log.value()&&(r=this._convertPriceRangeToLog(this.m_priceRange),null!==r&&this.setPriceRange(r)),s.autoScale!==n.autoScale.value()&&n.autoScale.listeners().fire(n.autoScale),s.autoScaleDisabled!==n.autoScaleDisabled.value()&&n.autoScaleDisabled.listeners().fire(n.autoScaleDisabled),s.lockScale!==n.lockScale.value()&&n.lockScale.listeners().fire(n.lockScale),s.percentage!==n.percentage.value()&&(n.percentage.listeners().fire(n.percentage),this.updateFormatter()),s.indexedTo100!==n.indexedTo100.value()&&(n.indexedTo100.listeners().fire(n.indexedTo100),this.updateFormatter()),s.percentageDisabled!==n.percentageDisabled.value()&&n.percentageDisabled.listeners().fire(n.percentageDisabled),s.log!==n.log.value()&&n.log.listeners().fire(n.log),s.logDisabled!==n.logDisabled.value()&&n.logDisabled.listeners().fire(n.logDisabled), -void 0===t.log&&void 0===t.percentage&&void 0===t.lockScale&&void 0===t.autoScale&&void 0===t.indexedTo100||this._modeChanged.fire(i,this.mode())}modeChanged(){return this._modeChanged}isEmpty(){return this._makeSureItIsValid(),0===this.m_height||!this.m_priceRange||this.m_priceRange.isEmpty()}canDetachSource(e){return this.m_dataSources.some((t=>t!==e&&(0,re.isPriceDataSource)(t)&&!((0,j.isStudy)(t)&&t.isLinkedToSeries())))}updateAllViews(e){const t=this._getSourcesToUpdateViews();for(const i of t)i.updateAllViews(e)}logFormula(){return this._logFormula}state(){var e;const t=this._properties.childs();return{id:this._id,m_priceRange:this.isAutoScale()?null:(null===(e=this.priceRange())||void 0===e?void 0:e.serialize())||null,m_isAutoScale:this.isAutoScale(),m_isPercentage:t.percentage.value(),m_isIndexedTo100:t.indexedTo100.value(),m_isLog:t.log.value(),m_isLockScale:this.isLockScale(),m_isInverted:this.isInverted(),m_topMargin:this._margins.top,m_bottomMargin:this._margins.bottom,alignLabels:t.alignLabels.value(),logFormula:(0,ie.clone)(this._logFormula)}}restoreState(e){let t=e.m_priceRange;if(void 0===t)throw new TypeError("invalid state");if(void 0===e.m_isAutoScale)throw new TypeError("invalid state");void 0!==e.id&&(this._id=e.id);const i={autoScale:e.m_isAutoScale};void 0!==e.m_isPercentage&&(i.percentage=e.m_isPercentage),void 0!==e.m_isIndexedTo100&&(i.indexedTo100=e.m_isIndexedTo100),void 0!==e.m_isLog&&(i.log=e.m_isLog),void 0!==e.m_isLockScale&&(i.lockScale=e.m_isLockScale),void 0!==e.m_isInverted&&this._properties.childs().isInverted.setValue(e.m_isInverted),this.setMode(i),t?(t instanceof de.PriceRange||(t=new de.PriceRange(t)),this.setPriceRange(t,!0)):this.clearPriceRange(),e.logFormula&&(this._logFormula=e.logFormula),void 0!==e.m_topMargin&&(this._margins.top=e.m_topMargin),void 0!==e.m_bottomMargin&&(this._margins.bottom=e.m_bottomMargin),void 0!==e.alignLabels&&this._properties.childs().alignLabels.setValue(e.alignLabels),this._mainSource=null,this._scaleSeriesOnly=!1}priceToLogical(e){return this.isLog()&&e?(0,ue.toLog)(e,this._logFormula):e}logicalToPrice(e){return this.isLog()?(0,ue.fromLog)(e,this._logFormula):e}priceToCoordinate(e,t){const i=this._priceToPercentOrIndexedTo100IfNeeded(e,t);return this._logicalToCoordinate(i)}coordinateToPrice(e,t){let i=this._coordinateToLogical(e);return this.isPercentage()?i=(0,ue.fromPercent)(i,t):this.isIndexedTo100()&&(i=(0,ue.fromIndexedTo100)(i,t)),i}mainSource(){if(null!==this._mainSource)return this._mainSource;let e;for(const t of this.m_dataSources){if(t instanceof pe.Series){e=t;break}!e&&(0,re.isPriceDataSource)(t)&&(e=t)}return this._mainSource=e||null,this._correctedMarginsCache=null,this._mainSource}pricesArrayToCoordinates(e,t,i){this._makeSureItIsValid();const s=this.bottomPixelMargin(),r=(0,n.ensureNotNull)(this.priceRange()),o=r.minValue(),a=r.maxValue(),l=this.internalHeight()-1,c=this.isInverted(),h=l/(a-o);void 0===i&&(i=e.length);const d=this.isPercentage(),u=this.isIndexedTo100(),p=this.isLog(),_=this.m_height;let m,g -;for(let r=0;re?(0,ue.toLog)(e,this._logFormula):e),0===s.length)return;const h="open"in s[0],d="close"in s[0];if(null!==c)for(let e=0;ethis._currencyCache=null)),e.unitChanged().subscribe(this,(()=>this._unitCache=null)),(0,_e.isSymbolSource)(e)&&(this._seriesLikeSources.push(e),e.symbolResolved().subscribe(this,(()=>{this._currencyCache=null,this._unitCache=null,this._measureUnitIdCache=null})),e.isActingAsSymbolSource().subscribe(this._boundOnSourceIsActingAsSymbolSourceChanged),e instanceof pe.Series)){const t=e.properties();this._hasSeries||(t.childs().lockScale&&(this.setMode({lockScale:t.childs().lockScale.value()}),t.removeProperty("lockScale")),t.childs().pnfStyle.child("lockScale")&&t.childs().pnfStyle.removeProperty("lockScale")),this._hasSeries=!0}e.isSpeciallyZOrderedSource()||(this._sourcesThatAffectVisibility.push(e),e.properties().childs().visible.listeners().subscribe(this,this._onSourceVisibilityChanged))}(0,j.isStudy)(e)&&(e.onIsActualIntervalChange().subscribe(this,this._dropScaleCache),e.onHibernationStateChange().subscribe(this,this._dropScaleCache),0===this._studiesCount&&(0,Se.hideAllIndicators)().subscribe(this,this._dropScaleCache),this._studiesCount++),(0,S.isLineTool)(e)&&(0===this._drawingCount&&(0,Se.hideAllDrawings)().subscribe(this,this._dropScaleCache),this._drawingCount++),this.m_dataSources.push(e),this._mainSource=null,this._correctedMarginsCache=null,this._sourcesToUpdateViews=null,this._dropScaleCache(),this.updateFormatter(),this._initScaleProperties(),this.invalidateSourcesCache(),this._updateIsVisible()}}removeDataSource(e){const t=this.m_dataSources.indexOf(e);if((0,n.assert)(-1!==t,"Source is not attached to scale"),this.m_dataSources.splice(t,1),(0,re.isPriceDataSource)(e)){const t=this._priceDataSources.indexOf(e);if((0,n.assert)(-1!==t,"Source is not found"),this._priceDataSources.splice(t,1),(0,_e.isSymbolSource)(e)){const t=this._seriesLikeSources.indexOf(e);(0,n.assert)(-1!==t,"Source is not found"),this._seriesLikeSources.splice(t,1),e.symbolResolved().unsubscribeAll(this),e.isActingAsSymbolSource().unsubscribe(this._boundOnSourceIsActingAsSymbolSourceChanged),e instanceof pe.Series&&(this._hasSeries=!1)}e.currencyChanged().unsubscribeAll(this),e.unitChanged().unsubscribeAll(this)}this.mainSource()||this.setMode({autoScale:!0}),(0,j.isStudy)(e)&&(e.onIsActualIntervalChange().unsubscribe(this,this._dropScaleCache),e.onHibernationStateChange().unsubscribe(this,this._dropScaleCache),this._studiesCount--,0===this._studiesCount&&(0,Se.hideAllIndicators)().unsubscribe(this,this._dropScaleCache)),(0,S.isLineTool)(e)&&(this._drawingCount--,0===this._drawingCount&&(0, -Se.hideAllDrawings)().unsubscribe(this,this._dropScaleCache));const i=this._sourcesThatAffectVisibility.indexOf(e);-1!==i&&(this._sourcesThatAffectVisibility.splice(i,1),e.properties().childs().visible.listeners().unsubscribe(this,this._onSourceVisibilityChanged)),this._mainSource=null,this._correctedMarginsCache=null,this._sourcesForAutoscale=null,this._sourcesToUpdateViews=null,this.updateFormatter(),this.invalidateSourcesCache(),this._updateIsVisible(),0===this.m_dataSources.length&&this._lastSourceRemoved.fire(),this._currencyCache=null,this._unitCache=null,this._measureUnitIdCache=null}currency(e){if(null!==this._currencyCache&&e.size()===this._currencyCache.availableCurrenciesCount)return this._currencyCache.value;let t;const i=new Set,s=new Set,r=new Set,o=new Map;let a,l=0===this._seriesLikeSources.length,c=!0,h=0,d=0;const u=this._seriesLikeSources.filter(_e.isActingAsSymbolSource);for(const d of u){if(!d.isVisible())continue;const u=d.symbolInfo();if(null===u){t=null;break}const p=(0,O.symbolOriginalCurrency)(u);if(null===p){t=null;break}o.set(p,(0,n.ensureNotNull)((0,O.symbolOriginalCurrency)(u,!0)));const _=d.currency();if(null===_){t=null;break}o.set(_,(0,n.ensureNotNull)((0,O.symbolCurrency)(u,!0)));const m=(0,O.symbolBaseCurrency)(u);null!==m&&s.add(m),c=c&&p===_,r.add(_),i.add(p),void 0===a?a=_:null!==a&&a!==_&&(a=null),l||e.convertible(_)&&(0,O.symbolCurrencyConvertible)(u)||(l=!0),h+=1}if(null!==t)for(const i of this._priceDataSources){if(u.includes(i))continue;const s=i;if(!s.isCurrencySource()||!s.isVisible())continue;const c=s.currency();if(null===c){t=null;break}r.add(c),d+=1;const h=(0,n.ensureNotNull)(s.symbolSource()),p=s.currencySourceSymbolInfo();if(null===p){t=null;break}if(l||e.convertible(c)&&(0,O.symbolCurrencyConvertible)(p)||(l=!0),o.set(c,(0,n.ensureNotNull)((0,O.symbolCurrency)(p,!0))),u.includes(h)||(l=!0),void 0===a)a=c;else if(null!==a&&a!==c){a=null;break}}return void 0===t&&(t=0===h&&0===d?null:{readOnly:l,selectedCurrency:a||null,currencies:r,originalCurrencies:i,baseCurrencies:s,symbolSourceCount:h,allCurrenciesAreOriginal:c,displayedValues:o}),this._currencyCache={value:t,availableCurrenciesCount:e.size()},t}unit(e){if(null!==this._unitCache&&e.size()===this._unitCache.availableUnitsCount)return this._unitCache.value;let t;const i=new Set,s=new Set,r=new Map,o=new Map;let a,l=0===this._seriesLikeSources.length?new Set:e.allGroups(),c=!0,h=0,d=0;const u=this._seriesLikeSources.filter(_e.isActingAsSymbolSource);for(const n of u){if(!n.isVisible())continue;const d=n.symbolInfo();if(null===d){t=null;break}const u=(0,O.symbolOriginalUnit)(d,n.model().unitConversionEnabled());if(null===u){t=null;break}r.set(u,e.name(u)),o.set(u,e.description(u));const p=n.unit();if(null===p){t=null;break}if(r.set(p,e.name(p)),o.set(p,e.description(p)),c=c&&u===p,s.add(p),i.add(u),void 0===a?a=p:null!==a&&a!==p&&(a=null),l.size>0){const t=(0,me.unitConvertibleGroups)(d,p,e);l=(0,v.intersect)(l,new Set(t))}h+=1}if(null!==t)for(const i of this._priceDataSources){if(u.includes(i))continue;const c=i -;if(!c.isUnitSource()||!c.isVisible())continue;const h=c.unit();if(null===h){t=null;break}s.add(h),d+=1;const p=(0,n.ensureNotNull)(c.symbolSource()),_=p.symbolInfo();if(null===_){t=null;break}if(l.size>0){const t=(0,me.unitConvertibleGroups)(_,h,e);l=(0,v.intersect)(l,new Set(t))}if(r.set(h,e.name(h)),o.set(h,e.description(h)),u.includes(p)||(l=new Set),void 0===a)a=h;else if(null!==a&&a!==h){a=null;break}}if(void 0===t)if(0===h&&0===d)t=null;else{t={availableGroups:l,selectedUnit:a||null,units:s,originalUnits:i,symbolSourceCount:h,allUnitsAreOriginal:c,names:r,descriptions:o}}return this._unitCache={value:t,availableUnitsCount:e.size()},t}measureUnitId(e){if(null!==this._measureUnitIdCache&&e.size()===this._measureUnitIdCache.availableUnitsCount)return this._measureUnitIdCache.value;let t,i;const s=new Map,r=new Map,n=new Set;let o=0;const a=this._seriesLikeSources.filter(_e.isActingAsSymbolSource);for(const l of a){if(!l.isVisible())continue;const a=l.measureUnitId();if(null===a){t=null;break}n.add(a),s.set(a,e.name(a)),r.set(a,e.description(a)),void 0===i?i=a:null!==i&&i!==a&&(i=null),o+=1}return void 0===t&&(t=0===o?null:{selectedMeasureUnitId:i||null,measureUnitIds:n,names:s,descriptions:r,symbolSourceCount:o}),this._measureUnitIdCache={value:t,availableUnitsCount:e.size()},t}setMargins(e){if(!(0,ie.isNumber)(e.top)||!(0,ie.isNumber)(e.bottom))throw new TypeError("invalid margin");if(e.top<0||e.top>30||e.bottom<0||e.bottom>30)throw new RangeError("invalid margin");this._margins.top===e.top&&this._margins.bottom===e.bottom||(this._margins=e,this._correctedMarginsCache=null,this._invalidateInternalHeightCache(),this._marksCache=null)}topMargin(){return this._correctedMargins().top}bottomMargin(){return this._correctedMargins().bottom}invalidateMargins(){this._correctedMarginsCache=null}topPixelMargin(){return this.isInverted()?this.bottomMargin()*this.height()+this._bottomPixelMargin:this.topMargin()*this.height()+this._topPixelMargin}bottomPixelMargin(){return this.isInverted()?this.topMargin()*this.height()+this._topPixelMargin:this.bottomMargin()*this.height()+this._bottomPixelMargin}marks(){return this.isEmpty()?(this._marksCache=null,[]):(null===this._marksCache&&(this._markBuilder.rebuildTickMarks(),this._marksCache=this._markBuilder.marks(),this._onMarksChanged.fire()),this._marksCache)}onMarksChanged(){return this._onMarksChanged}priceRangeInPrice(){if(this.isEmpty())return null;const e=this.mainSource();if(null===e)return null;const t=(0,n.ensureNotNull)(e.firstValue()),i=this.height();return{from:this.coordinateToPrice(i-1,t),to:this.coordinateToPrice(0,t)}}setPriceRangeInPrice(e){if(this.isPercentage()||this.isIndexedTo100())return;const t=this.isInverted(),i=t?this.bottomMargin():this.topMargin(),s=t?this.topMargin():this.bottomMargin(),r=this.isLog();let n=r?(0,ue.toLog)(e.from,this._logFormula):e.from,o=r?(0,ue.toLog)(e.to,this._logFormula):e.to;const a=o-n;n+=s*a,o-=i*a,this.setMode({autoScale:!1}),this.setPriceRange(new de.PriceRange(n,o)),this._marksCache=null,this._onMarksChanged.fire()} -hasMainSeries(){return this._hasSeries}getStudies(){return this.dataSources().filter(j.isStudy)}lastSourceRemoved(){return this._lastSourceRemoved}sourcesForAutoscale(){return this._mainSource&&this._scaleSeriesOnly!==this._scalesProperties.childs().scaleSeriesOnly.value()&&(this._sourcesForAutoscale=null),this._sourcesForAutoscale||(this._sourcesForAutoscale=this._recalculateSourcesForAutoscale()),this._sourcesForAutoscale}recalculatePriceRange(e){this._invalidatedForRange={visibleBars:e,isValid:!1}}internalHeightChanged(){return this._internalHeightChanged}orderedSources(){if(this._cachedOrderedSoruces)return this._cachedOrderedSoruces;let e=this.m_dataSources.slice();return e=(0,ne.sortSources)(e),this._cachedOrderedSoruces=e,this._cachedOrderedSoruces}invalidateSourcesCache(){this._cachedOrderedSoruces=null,this._sourcesToUpdateViews=null}startScale(e){var t,i;this.isEmpty()||this.isPercentage()||this.isIndexedTo100()||null!==this._scaleStartPoint||null!==this._priceRangeSnapshot||(this._scaleStartPoint=this.m_height-e,this._priceRangeSnapshot=null!==(i=null===(t=this.priceRange())||void 0===t?void 0:t.clone())&&void 0!==i?i:null)}scaleTo(e){if(this.isPercentage()||this.isIndexedTo100()||null===this._scaleStartPoint)return;this.setMode({autoScale:!1}),(e=this.m_height-e)<0&&(e=0);let t=(this._scaleStartPoint+.2*(this.m_height-1))/(e+.2*(this.m_height-1));const i=(0,n.ensureNotNull)(this._priceRangeSnapshot).clone();t=Math.max(t,.1),i.scaleAroundCenter(t),this.setPriceRange(i)}endScale(){this.isPercentage()||this.isIndexedTo100()||null!==this._scaleStartPoint&&(this._scaleStartPoint=null,this._priceRangeSnapshot=null)}startTwoPointsScale(e,t){if(this.isEmpty()||this.isPercentage()||this.isIndexedTo100()||null!==this._twoPointsScaleStartPosition)return;const i=Math.min(e,t),s=Math.max(e,t);this._twoPointsScaleStartPosition={topLogical:this._coordinateToLogical(i),bottomLogical:this._coordinateToLogical(s)}}twoPointsScale(e,t){if(this.isPercentage()||this.isIndexedTo100()||null===this._twoPointsScaleStartPosition)return;this.setMode({autoScale:!1});const i=Math.min(e,t),s=Math.max(e,t),{topLogical:r,bottomLogical:n}=this._twoPointsScaleStartPosition,o=this.bottomPixelMargin(),a=this.internalHeight()-1,l=(this._invertedCoordinate(i)-o)/a,c=(n-r)/((this._invertedCoordinate(s)-o)/a-l),h=r-c*l,d=h+c;this.setPriceRange(new de.PriceRange(this.priceToLogical(h),this.priceToLogical(d)))}endTwoPointsScale(){this._twoPointsScaleStartPosition=null}startScroll(e){var t,i;this.isAutoScale()||null===this._scrollStartPoint&&null===this._priceRangeSnapshot&&(this.isEmpty()||(this._scrollStartPoint=e,this._priceRangeSnapshot=null!==(i=null===(t=this.priceRange())||void 0===t?void 0:t.clone())&&void 0!==i?i:null))}scrollTo(e){if(this.isAutoScale())return;if(null===this._scrollStartPoint||null===this._priceRangeSnapshot)return;const t=this.priceRange();if(null===t)return;let i=e-this._scrollStartPoint;this.isInverted()&&(i*=-1);const s=i*(t.length()/(this.internalHeight()-1)),r=this._priceRangeSnapshot.clone();r.shift(s), -this.setPriceRange(r,!0),this._marksCache=null}endScroll(){this.isAutoScale()||null!==this._scrollStartPoint&&(this._scrollStartPoint=null,this._priceRangeSnapshot=null)}clearPriceRange(){this.m_priceRange=null,this.recalculatePriceRangeOnce()}isVisible(){return this._isVisible}_recalculateSourcesForAutoscale(){this._mainSource&&(this._scaleSeriesOnly=this._scalesProperties.childs().scaleSeriesOnly.value());const e=this._scaleSeriesOnly&&this._hasSeries;return this.m_dataSources.filter((t=>!!(t.properties().visible.value()||t instanceof pe.Series)&&(e?t instanceof pe.Series:(0,j.isStudy)(t)?!t.isSourceHidden()&&t.isIncludedInAutoScale():t.isIncludedInAutoScale())))}_updateAutoScaleDisabledProperty(e){const t=this._properties.childs(),i=t.indexedTo100.value()||t.percentage.value()||t.lockScale.value();e?t.autoScaleDisabled.setValueSilently(i):t.autoScaleDisabled.setValue(i)}_setAutoScaleValueWithDependentProperties(e){const t=this._properties.childs();t.autoScale.setValueSilently(e),e&&(t.percentage.setValueSilently(!1),t.indexedTo100.setValueSilently(!1),t.lockScale.setValueSilently(!1),t.logDisabled.setValueSilently(!1)),this._updateAutoScaleDisabledProperty(!0)}_setLockScaleValueWithDependentProperties(e){const t=this._properties.childs();t.lockScale.setValueSilently(e),e&&(t.autoScale.setValueSilently(!1),t.percentage.setValueSilently(!1),t.indexedTo100.setValueSilently(!1),t.log.setValueSilently(!1)),t.percentageDisabled.setValueSilently(e),t.logDisabled.setValueSilently(e),this._updateAutoScaleDisabledProperty(!0)}_setPercentageValueWithDependentProperties(e){const t=this._properties.childs();t.percentage.setValueSilently(e),e&&(t.autoScale.setValueSilently(!0),t.log.setValueSilently(!1),t.lockScale.setValueSilently(!1),t.indexedTo100.setValueSilently(!1)),this._updateAutoScaleDisabledProperty(!0)}_setIndexedTo100ValueWithDependentProperties(e){const t=this._properties.childs();t.indexedTo100.setValueSilently(e),e&&(t.autoScale.setValueSilently(!0),t.log.setValueSilently(!1),t.lockScale.setValueSilently(!1),t.percentage.setValueSilently(!1)),this._updateAutoScaleDisabledProperty(!0)}_setLogValueWithDependentProperties(e){const t=this._properties.childs();t.log.setValueSilently(e),e&&(t.lockScale.setValueSilently(!1),t.percentage.setValueSilently(!1),t.indexedTo100.setValueSilently(!1)),this._updateAutoScaleDisabledProperty(!0)}_recalculatePriceRangeImpl(){const e=this._invalidatedForRange.visibleBars;if(null===e)return;let t=null;const i=this.sourcesForAutoscale(),s=this.isPercentage(),r=this.isIndexedTo100();let n=0,o=0;for(const a of i){if(!a.properties().visible.value())continue;const i=a.firstValue();if(null===i||s&&0===i)continue;const l=e.firstBar(),c=e.lastBar(),h=a.autoScaleInfo(l,c);let d=h.range;d&&(s?d=(0,ue.toPercentRange)(d,i):r&&(d=(0,ue.toIndexedTo100Range)(d,i)),t=null===t?d:t.merge(d)),void 0!==h.topPixelMargin&&(n=Math.max(n,h.topPixelMargin)),void 0!==h.bottomPixelMargin&&(o=Math.max(o,h.bottomPixelMargin))} -if((Math.abs(n-this._topPixelMargin)>0||Math.abs(o-this._bottomPixelMargin)>0)&&(this._bottomPixelMargin=o,this._topPixelMargin=n,this._marksCache=null,this._invalidateInternalHeightCache()),t){if(t.minValue()===t.maxValue()&&(t=new de.PriceRange(t.minValue()-.5,t.maxValue()+.5)),this.isLog()){const e=this._convertPriceRangeFromLog(t),i=(0,ue.logFormulaForPriceRange)(e);if(!(0,ue.logFormulasAreSame)(i,this._logFormula)){const s=this._priceRangeSnapshot?this._convertPriceRangeFromLog(this._priceRangeSnapshot):null;this._logFormula=i,t=this._convertPriceRangeToLog(e),s&&(this._priceRangeSnapshot=this._convertPriceRangeToLog(s))}}this.setPriceRange(t)}else this.m_priceRange||(this.setPriceRange(new de.PriceRange(-.5,.5)),this._logFormula=(0,ue.logFormulaForPriceRange)(null));this._invalidatedForRange.isValid=!0;const a=this.mainSource();null!==a&&this._recalculatePriceRangeOnce&&(this._recalculatePriceRangeOnce=!a.priceRangeReady())}_makeSureItIsValid(){this._invalidatedForRange.isValid||(this._invalidatedForRange.isValid=!0,this._recalculatePriceRangeImpl())}_invalidateInternalHeightCache(){this._internalHeightCache=null,this._internalHeightChanged.fire()}_coordinateToLogical(e){if(this._makeSureItIsValid(),this.isEmpty())return 0;const t=this._invertedCoordinate(e),i=(0,n.ensureNotNull)(this.priceRange()),s=i.minValue()+(i.maxValue()-i.minValue())*((t-this.bottomPixelMargin())/(this.internalHeight()-1));return this.logicalToPrice(s)}_logicalToCoordinate(e){if(this._makeSureItIsValid(),this.isEmpty())return 0;e=this.priceToLogical(e);const t=(0,n.ensureNotNull)(this.priceRange()),i=this.bottomPixelMargin()+(this.internalHeight()-1)*(e-t.minValue())/(t.maxValue()-t.minValue());return this._invertedCoordinate(i)}_convertPriceRangeFromLog(e){if(null===e)return null;const t=(0,ue.fromLog)(e.minValue(),this._logFormula),i=(0,ue.fromLog)(e.maxValue(),this._logFormula);return new de.PriceRange(t,i)}_convertPriceRangeToLog(e){if(null===e)return null;const t=(0,ue.toLog)(e.minValue(),this._logFormula),i=(0,ue.toLog)(e.maxValue(),this._logFormula);return new de.PriceRange(t,i)}_canConvertPriceRangeFromLog(e){if(null===e)return!1;const t=(0,ue.fromLog)(e.minValue(),this._logFormula),i=(0,ue.fromLog)(e.maxValue(),this._logFormula);return isFinite(t)&&isFinite(i)}_onSourceVisibilityChanged(){this._dropScaleCache(),this._updateIsVisible()}_dropScaleCache(){this._sourcesForAutoscale=null,this._currencyCache=null,this._unitCache=null,this._measureUnitIdCache=null}_updateIsVisible(){if(!be)return void this._isVisible.setValue(!0);const e=this._sourcesThatAffectVisibility.some((e=>e.isVisible()));this._isVisible.setValue(e)}_invertedCoordinate(e){return this.isInverted()?e:this.height()-1-e}_initScaleProperties(){const e=this.isLockScale(),t=this.properties().childs();e&&(t.percentage.setValue(!1),t.indexedTo100.setValue(!1),t.log.setValue(!1),t.autoScale.setValue(!1)),t.percentageDisabled.setValue(e),t.logDisabled.setValue(e),this._updateAutoScaleDisabledProperty(!1),t.percentage.value()&&(t.log.setValue(!1), -t.indexedTo100.setValue(!1)),t.indexedTo100.value()&&(t.log.setValue(!1),t.percentage.setValue(!1))}_correctedMargins(){if(null===this._correctedMarginsCache){const e=this.mainSource();this._correctedMarginsCache=null!==e?e.correctScaleMargins(this._margins):this._margins}return this._correctedMarginsCache}_getSourcesToUpdateViews(){return this._sourcesToUpdateViews||(this._sourcesToUpdateViews=this.m_dataSources.filter((e=>!(0,S.isLineTool)(e)||e.isActualSymbol()&&e.isActualCurrency()))),this._sourcesToUpdateViews}_mainSourceFormatter(){const e=this.mainSource();return(null==e?void 0:e.formatter())||Pe}_priceToPercentOrIndexedTo100IfNeeded(e,t){return this.isPercentage()?(0,ue.toPercent)(e,t):this.isIndexedTo100()?(0,ue.toIndexedTo100)(e,t):e}_onSourceIsActingAsSymbolSourceChanged(){this._dropScaleCache()}_onIsInvertedChanged(){this._marksCache=null,this._markBuilder.rebuildTickMarks()}_updateResetAvailableValue(){this._resetScaleAvailable.setValue(!this.isLockScale()&&!this.isAutoScale())}}var Te=i(29541),Ie=i(63009),Me=i(53588),Le=i(88732),Ae=i(13333);const ke=[],De=[];class Ve{constructor(e){this._studies={},this._deferreds={},this._container=e,ke.push(e),De.push(this)}add(e,t){this._deferreds[e]&&(this._deferreds[e].resolve(t),delete this._deferreds[e]),this._studies[e]=t}get(e){return this._studies[e]?Promise.resolve(this._studies[e]):(this._deferreds[e]||(this._deferreds[e]=(0,p.createDeferredPromise)()),this._deferreds[e].promise)}reset(){const e=ke.indexOf(this._container);~e&&(ke.splice(e,1),De.splice(e,1))}static instance(e){const t=ke.indexOf(e);return~t?De[t]:new Ve(e)}}var Ee=i(99366);var Be=i(4949),Re=i(2823),Ne=i(53086),Oe=i(78856),Fe=i(44010),We=i(87440),He=i(16410);new ee.TranslatedString("update {title} script",c.t(null,void 0,i(50728)));const ze=N.enabled("clear_price_scale_on_error_or_empty_bars"),Ue=(0,X.getLogger)("Chart.Pane");function je(e,t,i){e.setMargins({top:t,bottom:i})}class Ge{constructor(e,t,i,s){this.m_dataSources=[],this._sourceWatchedValuesSubscriptions=new Map,this.m_mainDataSource=null,this._cachedOrderedSources=new ce(this),this._sourcesById=new Map,this._priceSourcesById=new Map,this._sourcePropertiesChanged=new G.Delegate,this._sourcesZOrderChanged=new G.Delegate,this._tagsChanged=new G.Delegate,this._stretchFactor=1e3,this._isInInsertManyDataSourcesState=!1,this._lastLineDataSourceZOrder=null,this._rightPriceScales=[],this._leftPriceScales=[],this._lockedPriceScale=null,this._currentPriceScaleRatio=null,this._onPriceScalesChanged=new G.Delegate,this._isRecalculatingScales=!1,this._priceDataSources=[],this._symbolSources=[],this._lollipopDataSources=[],this._symbolSourceResolved=new G.Delegate,this._symbolSourceResolvingActive=new q.WatchedValue(!1),this._bulkActions={activeCounter:0},this._height=0,this._width=0,this._sizeChanged=new G.Delegate,this._dataSourcesCollectionChanged=new G.Delegate,this._symbolSourceCollectionChanged=new G.Delegate,this._priceSourcesCollectionChanged=new G.Delegate,this._maximized=new q.WatchedValue(!1),this._collapsed=new q.WatchedValue(!1), -this._resetPriceScalesAvailable=new q.WatchedValue(!1),this._destroyed=new G.Delegate,this._executionsPositionController=null,this._seriesDisplayError=null,this._onPriceScaleIsVisibleChanged=()=>{this._model.fullUpdate()},this._recalcSymbolSourceResolvingActive=()=>{for(const e of this._symbolSources)if(e.symbolResolvingActive().value())return void this._symbolSourceResolvingActive.setValue(!0);this._symbolSourceResolvingActive.setValue(!1)},this._onSymbolSourceCollectionChanged=()=>{0===this._bulkActions.activeCounter?this._symbolSourceCollectionChanged.fire():this._bulkActions.symbolSourceCollectionChanged=!0},this._onSeriesDisplayError=e=>{if(null!==e){for(const e of this._leftPriceScales)e.clearPriceRange();for(const e of this._rightPriceScales)e.clearPriceRange()}},this._updateResetPriceScalesAvailableValue=()=>{const e=e=>e.resetScaleAvailable().value(),t=this._leftPriceScales.some(e)||this._rightPriceScales.some(e);this._resetPriceScalesAvailable.setValue(t)},this._priceScaleSelectionStrategy=(0,Q.createPriceScaleSelectionStrategy)(i.properties().childs().priceScaleSelectionStrategyName.value()),this._id=null!=s?s:(0,J.randomHashN)(6),this._timeScale=e,this.m_mainDataSource=null,this._properties=t,this._model=i,i.properties().childs().priceScaleSelectionStrategyName.subscribe(null,(e=>{this._priceScaleSelectionStrategy=(0,Q.createPriceScaleSelectionStrategy)(e.value()),this._priceScaleSelectionStrategy.apply(this)})),this._timeScale.barSpacingChanged().subscribe(this,(()=>{this.m_mainDataSource===this._model.mainSeries()&&this._recalculatePriceScaleByScaleRatio(this.m_mainDataSource.priceScale())})),ze&&(this._seriesDisplayError=(0,O.getSeriesDisplayErrorWV)(this._model.mainSeries()),this._seriesDisplayError.subscribe(this._onSeriesDisplayError)),t.childs().topMargin.subscribe(this,this._updateMargins),t.childs().bottomMargin.subscribe(this,this._updateMargins),this._updateMargins()}destroy(){var e;this._properties.childs().topMargin.unsubscribeAll(this),this._properties.childs().bottomMargin.unsubscribeAll(this),this._model.properties().childs().priceScaleSelectionStrategyName.unsubscribeAll(this),this._timeScale.barSpacingChanged().unsubscribeAll(this),this._leftPriceScales.concat(this._rightPriceScales).forEach((e=>{e.modeChanged().unsubscribeAll(this),e.priceRangeChanged().unsubscribeAll(this),e.internalHeightChanged().unsubscribeAll(this),e.isVisible().unsubscribe(this._onPriceScaleIsVisibleChanged),e.resetScaleAvailable().unsubscribe(this._updateResetPriceScalesAvailableValue)}));for(const e of this.m_dataSources)this.removeSourceFromPriceScale(e),e.destroy&&e.destroy();null===(e=this._seriesDisplayError)||void 0===e||e.destroy(),this._destroyed.fire()}id(){return this._id}bulkActionMacro(e){const t=this._bulkActions;t.activeCounter+=1,e(),t.activeCounter-=1,0===t.activeCounter&&(this._dataSourcesCollectionChanged.fire(),t.symbolSourceCollectionChanged&&(this._symbolSourceCollectionChanged.fire(),t.symbolSourceCollectionChanged=!1), -t.priceSourcesCollectionChanged&&(this._priceSourcesCollectionChanged.fire(),t.priceSourcesCollectionChanged=!1))}defaultPriceScale(){var e,t;const i=null!==(t=null===(e=this.m_mainDataSource)||void 0===e?void 0:e.priceScale())&&void 0!==t?t:null;if(null!==i)return i;const s=this.properties().childs().axisProperties.state();return s.autoScale=!0,new xe(this._model.properties().childs().scalesProperties,s)}leftPriceScales(){return this._leftPriceScales}rightPriceScales(){return this._rightPriceScales}visibleLeftPriceScales(){var e;const t=this._model.priceScaleSlotsCount(),i=this._leftPriceScales.filter((e=>e.isVisible().value())),s=null===(e=this.mainDataSource())||void 0===e?void 0:e.priceScale();if(i.length>t.left&&(null==s?void 0:s.isVisible().value())){const e=(0,v.moveToHead)(i,s);return e.splice(t.left),e}return i}visibleRightPriceScales(){var e;const t=this._model.priceScaleSlotsCount(),i=this._rightPriceScales.filter((e=>e.isVisible().value())),s=null===(e=this.mainDataSource())||void 0===e?void 0:e.priceScale();if(i.length>t.right&&(null==s?void 0:s.isVisible().value())){const e=(0,v.moveToHead)(i,s);return e.splice(t.right),e}return i}clearSeries(e){const t=this._model.mainSeries();for(let i=this.m_dataSources.length-1;i>=0;i--)this.m_dataSources[i]===t&&this._removeSourceFromCollections(i,e)}sourcesByGroup(){return this._cachedOrderedSources}dataSourceForId(e){return this._sourcesById.get(e)||null}changeSourceId(e,t){(0,n.assert)(this.hasDataSource(e));const i=e.id();e.setId(t),this._sourcesById.delete(i),this._sourcesById.set(t,e),(0,re.isPriceDataSource)(e)&&(this._priceSourcesById.delete(i),this._priceSourcesById.set(t,e))}movePriceScale(e,t,i){const s=this.priceScalePosition(e);if(s!==t)this.removePriceScale(e),this._placePriceScale(e,t,i),e.invalidateMargins(),this._invalidateSourcesCache();else if(void 0!==i&&"overlay"!==s){const t="left"===s?this._leftPriceScales:this._rightPriceScales,r=t.indexOf(e);t.splice(r,1),t.splice(i,0,e)}}mainDataSource(){return this.m_mainDataSource}isEmpty(){return null===this.m_mainDataSource}recalculatePriceScale(e,t){if(!e)return;const i=e.sourcesForAutoscale();if((e.isAutoScale()||e.priceRangeShouldBeRecalculatedOnce())&&i&&i.length>0&&!this.timeScale().isEmpty()){const t=this.timeScale().visibleBarsStrictRange();e.recalculatePriceRange(t)}e.updateAllViews(t)}onSourceTagsChanged(){this._tagsChanged.fire()}insertDataSource(e,t,i){e.setZorder(i),t||(t=this.findSuitableScale(e)),this._addSourceToCollections(e);let s=!1;e===this.model().mainSeries()?(this.m_mainDataSource=this.model().mainSeries(),s=!0):null===this.m_mainDataSource&&(0,re.isPriceDataSource)(e)&&(this.m_mainDataSource=e,s=!0),t.addDataSource(e,this._isInInsertManyDataSourcesState),e.setPriceScale(t),t.invalidateMargins(),e.onTagsChanged&&e.onTagsChanged().subscribe(this,this.onSourceTagsChanged),s&&this._processMainSourceChange(),this._tagsChanged.fire(),(0,re.isPriceDataSource)(e)&&this.recalculatePriceScale(t,(0,W.sourceChangeEvent)(e.id())),this._invalidateSourcesCache()}addDataSource(e,t,i){ -let s=e.zorder();i||((0,S.isLineTool)(e)&&!e.isSpeciallyZOrderedSource()?(s=null!==this._lastLineDataSourceZOrder?this._lastLineDataSourceZOrder+1:this.newLineToolZOrder(),this._isInInsertManyDataSourcesState&&(this._lastLineDataSourceZOrder=s)):(0,j.isStudy)(e)&&!e.isSpeciallyZOrderedSource()&&(s=this.newStudyZOrder())),this.insertDataSource(e,t,s)}removeDataSource(e,t,i){const s=this.m_dataSources.indexOf(e);if(-1===s)return void Ue.logDebug("removeDataSource: invalid data source");this._removeSourceFromCollections(s,!!i),e!==this.m_mainDataSource||t||(this.m_mainDataSource=null);const r=e.priceScale();this.removeSourceFromPriceScale(e),e.onTagsChanged&&e.onTagsChanged().unsubscribe(this,this.onSourceTagsChanged),(0,re.isPriceDataSource)(e)&&!t&&this._processMainSourceChange(),this._tagsChanged.fire(),r&&(0,re.isPriceDataSource)(e)&&this.recalculatePriceScale(r,(0,W.sourceChangeEvent)(e.id())),this._invalidateSourcesCache()}hasDataSource(e){return this._sourcesById.has(e.id())}hasPriceDataSource(e){return this._priceSourcesById.has(e.id())}dataSources(){return this.m_dataSources}priceDataSources(){return this._priceDataSources}lollipopDataSources(){return this._lollipopDataSources}symbolSources(){return this._symbolSources}replaceSource(e,t,i){const s=this.m_mainDataSource===e,r=e.zorder();this.insertDataSource(t,i,r),this.removeDataSource(e,s),this._sourcesById.set(t.id(),t),(0,re.isPriceDataSource)(t)&&this._priceSourcesById.set(t.id(),t),s&&(this.m_mainDataSource=t,this._processMainSourceChange())}findSuitableScale(e,t,i){return this._priceScaleSelectionStrategy.findSuitableScale(this,e,t,i)}createNewPriceScaleIfPossible(){return this._priceScaleSelectionStrategy.createNewPriceScaleIfPossible(this)}canCreateNewPriceScale(){return this._priceScaleSelectionStrategy.canCreateNewPriceScale(this)}isOverlay(e){const t=e.priceScale();return null===t||"overlay"===this.priceScalePosition(t)}recalculate(e){this._leftPriceScales.forEach((t=>this.recalculatePriceScale(t,e))),this._rightPriceScales.forEach((t=>this.recalculatePriceScale(t,e)));for(const t of this.m_dataSources)this.isOverlay(t)&&!(0,S.isLineTool)(t)&&this.recalculatePriceScale(t.priceScale(),e);this.updateAllViews(e),this._model.updatePane(this)}updateAllViews(e){for(const t of this.m_dataSources)t.updateAllViews(e);for(const t of this.model().customSources())t.updateViewsForPane(this,e)}updateLollipopViews(e){}priceScalePosition(e){return this._leftPriceScales.includes(e)?"left":this._rightPriceScales.includes(e)?"right":"overlay"}createPriceScaleAtPosition(e,t){const i=this.properties().childs().axisProperties.state();i.autoScale=!0;const s=new xe(this.model().properties().childs().scalesProperties,i);return s.setHeight(this.height()),je(s,this._defaultTopMargin(),this._defaultBottomMargin()),this._placePriceScale(s,e,t),s}removePriceScale(e){e.modeChanged().unsubscribeAll(this),e.priceRangeChanged().unsubscribeAll(this),e.internalHeightChanged().unsubscribeAll(this),e.isVisible().unsubscribe(this._onPriceScaleIsVisibleChanged), -e.resetScaleAvailable().unsubscribe(this._updateResetPriceScalesAvailableValue),e===this._lockedPriceScale&&(this._lockedPriceScale=null,this._currentPriceScaleRatio=null);const t=this._leftPriceScales.indexOf(e);-1!==t&&(this._leftPriceScales[t].invalidateMargins(),this._leftPriceScales.splice(t,1));const i=this._rightPriceScales.indexOf(e);if(-1!==i&&(this._rightPriceScales[i].invalidateMargins(),this._rightPriceScales.splice(i,1)),null===e.mainSource()){const t=e.dataSources().length;0!==t&&Ue.logError("Invalid priceScale state: empty mainSource but non-empty data sources="+t)}this._onPriceScalesChanged.fire(),this._updateResetPriceScalesAvailableValue()}priceScaleIndex(e,t){switch(t){case"left":return this.leftPriceScales().indexOf(e);case"right":return this.rightPriceScales().indexOf(e)}}move(e,t,i){const s=e.priceScale();this.removeSourceFromPriceScale(e),t.addDataSource(e),e.setPriceScale(t),t.invalidateMargins(),this._processMainSourceChange(),this._invalidateSourcesCache(),e.isIncludedInAutoScale()&&(null!==s&&this.recalculatePriceScale(s,(0,W.sourceChangeEvent)(e.id())),this.recalculatePriceScale(t,(0,W.sourceChangeEvent)(e.id()))),this._onPriceScalesChanged.fire()}setZOrders(e){e.forEach(((e,t)=>{t.setZorder(e)})),this._invalidateSourcesCache(),0===this._bulkActions.activeCounter&&this._dataSourcesCollectionChanged.fire(),this.model().lightUpdate()}isMainPane(){return this.hasDataSource(this.model().mainSeries())}isLast(){const e=this.model().panes();return e[e.length-1]===this}newStudyZOrder(){return(0,Ie.newStudyZOrder)(this._priceDataSources)}newLineToolZOrder(e){return(0,Ie.newLineToolZOrder)(this.m_dataSources,e)}model(){return this._model}containsMainSeries(){return this._sourcesById.has(this.model().mainSeries().id())}applyPriceScaleRatio(e,t){var i;null!==this._lockedPriceScale&&this._lockedPriceScale!==e||this._currentPriceScaleRatio===t||!this.isMainPane()||null===this._lockedPriceScale&&e!==(null===(i=this.mainDataSource())||void 0===i?void 0:i.priceScale())||(this._setNewPriceRangeByScaleRatio(e,t,this._mainSourceVisiblePriceRange(e),!0,!0),null!==this._lockedPriceScale?this._tryToApplyNewPriceScaleRatio():e.isLog()||this.model().mainSeriesScaleRatioPropertyOnChanged())}sendToBack(e){const t=this.sourcesByGroup().allExceptSpecialSources();this._batchReorder(e,t[0],Ie.moveBeforeSource)}bringToFront(e){const t=this.sourcesByGroup().allExceptSpecialSources();this._batchReorder(e,t[t.length-1],Ie.moveAfterSource)}sendBackward(e){const t=this.sourcesByGroup().allIncludingHidden(),i=t.indexOf(e[0]);if(0===i)this.bringToFront(e);else{const s=t[i-1];this.insertBefore(e,s)}}bringForward(e){const t=this.sourcesByGroup().allExceptSpecialSources(),i=t.indexOf(e[e.length-1]);if(i===t.length-1)this.sendToBack(e);else{const s=t[i+1];this.insertAfter(e,s)}}insertAfter(e,t){this._batchReorder(e,t,Ie.moveAfterSource)}insertBefore(e,t){this._batchReorder(e,t,Ie.moveBeforeSource)}maximized(){return this._maximized}collapsed(){return this._collapsed}getPriceScaleById(e){const t=this.m_dataSources.find((t=>{var i -;return(null===(i=t.priceScale())||void 0===i?void 0:i.id())===e}));return void 0===t?null:t.priceScale()}priceScaleSelectionStrategy(){return this._priceScaleSelectionStrategy}setPriceScaleSelectionStrategy(e){this._priceScaleSelectionStrategy=e,e.apply(this)}findTargetPriceAxisViews(e,t,i,s){if((0,f.isDataSource)(e)&&this.model().paneForSource(e)!==this)return[];const r=e.priceScale();if(t===r)return i;if(null===r)return[];if("overlay"===this.priceScalePosition(r))return t===this.defaultPriceScale()?i:[];const n=this.priceScalePosition(t);if(n!==this.priceScalePosition(r))return[];const o="left"===n?this.leftPriceScales():this.rightPriceScales();return o.indexOf(t)1}properties(){return this._properties}setPriceAutoScale(e,t){e.setMode({autoScale:t}),this.timeScale().isEmpty()||this.recalculatePriceScale(e,(0,W.viewportChangeEvent)())}state(e,t,i,s,r,n){var o,a;const l={sources:[],mainSourceId:null===(o=this.m_mainDataSource)||void 0===o?void 0:o.id(),stretchFactor:this._stretchFactor,leftAxisesState:[],rightAxisesState:[],overlayPriceScales:{},priceScaleRatio:this._currentPriceScaleRatio},c=new Map,h=e=>{if(c.has(e))return c.get(e);let o=null;const a=i&&!e.isSavedInStudyTemplates()||!e.state||(0,S.isLineTool)(e)&&n||!e.isSavedInChart(Boolean(t))||!(o=e.state(t,r))||s&&(0,S.isLineTool)(e)&&e.isActualSymbol&&!e.isActualSymbol()||e.isPhantom()?null:o;return c.set(e,a),a};if(e){l.sources=[];for(let e=0;enull!==c.get(e),u=e=>!n||!(0,S.isLineTool)(e);l.leftAxisesState=this._leftPriceScales.map((e=>({state:e.state(),sources:e.dataSources().filter(d).filter(u).map((e=>e.id()))}))),l.rightAxisesState=this._rightPriceScales.map((e=>({state:e.state(),sources:e.dataSources().filter(d).filter(u).map((e=>e.id()))}))),l.overlayPriceScales={};for(const e of this.m_dataSources)if(this.isOverlay(e)&&e.isSavedInChart(Boolean(t))){const t=e.priceScale();l.overlayPriceScales[e.id()]=null!==(a=null==t?void 0:t.state())&&void 0!==a?a:null}return l}restoreState(e,t,i,s,r,o,a){r=r||{},e.stretchFactor&&(this._stretchFactor=e.stretchFactor),s=null!=s?s:this._model.mainSeries().id();const l={};if(e.sources){const n=e.sources.filter((e=>{var t;return!!e&&("MainSeries"===e.type||(!(null===(t=e.points)||void 0===t?void 0:t.some((e=>null===e.time_t||!isFinite(e.time_t))))||(Ue.logNormal("Dropped invalid "+e.type+". Reason: non-numeric point time"),!1)))})),c=n.findIndex(Me.isMainSeriesState);-1!==c&&this.model().mainSeries().setObsoleteZOrder(n[c].zorder),i<3&&(0,Ie.reorderDataSourcesStateZOrder)(n);const h=-1!==this.m_dataSources.indexOf(this._model.mainSeries());this.clearSeries(Boolean(a)),this.m_mainDataSource=null,h&&this._addSourceToCollections(this._model.mainSeries(),a),(()=>{const t=n.find((t=>t.id===e.mainSourceId)) -;if(void 0===t)return void Ue.logWarn("There is no main source with id "+e.mainSourceId+", total sources="+n.length);if(!window.TradingView[t.type]||!(0,he.isLineToolName)(t.type))return void Ue.logNormal("The type of main source is not line tool - fix is unnecessary");let i=null;for(const e of n)if(!window.TradingView[t.type]||!(0,he.isLineToolName)(e.type)){if(null!==i)return void Ue.logWarn("Pane contains more than 1 possibly main sources - auto fix cannot be applied");i=e}if(null===i)return void Ue.logWarn("Pane contains only line tools - possible we need to remove this pane?");const s=e.mainSourceId;let r=0;e.mainSourceId=i.id,n.forEach((e=>{e.ownerSource===s&&(e.ownerSource=null==i?void 0:i.id,r+=1)})),Ue.logNormal("Auto fix broken pane is applied, changed line tools="+r+", changed from="+s+" to="+i.id)})();for(const e of n)if("study_Sessions"===e.type){this.model().sessions().restoreOldState(e,t);break}for(const e of n)"study_Sessions"!==e.type&&(null===this._model.dataSourceForId(e.id)||"MainSeries"===e.type?(l[e.id]=e.ownerSource,(0,Me.isMainSeriesState)(e)?this._restoreMainSeries(e,t,h,r,o,a):(0,Me.isStudyState)(e)?this.restoreStudy(e,t,s,r,a,!0):(0,Me.isLineToolState)(e)?(e.state&&(e.state.zOrderVersion=2),this.restoreLineTool(e,t,void 0,a)):"ChartEventsSource"===e.type&&this._restoreSpecialSource(e,t,a)):Ue.logError("Duplicate id while restoring pane: "+e.type+","+e.id))}const c=new Set,h=(e,t)=>{e.priceScale()!==t&&(this.removeSourceFromPriceScale(e),e.setPriceScale(t),t.addDataSource(e))},d=(e,t,i)=>{if(c.has(e))return;c.add(e);const s=i.m_showSymbolLabels;void 0!==s&&e===this.model().mainSeries()&&this.model().properties().childs().scalesProperties.childs().showSymbolLabels.setValue(s),this._model.children(e,!0).forEach((e=>d(e,t,i))),h(e,t)},u=e=>{const t=(0,B.defaults)("chartproperties").paneProperties.axisProperties,i=new xe(this.model().properties().childs().scalesProperties,t);return i.restoreState(e.state),i.setHeight(this._height),e.sources.forEach((e=>{const s=this.dataSourceForId(e);s&&d(s,i,t)})),0===i.dataSources().length?null:i},p=e=>e.map(u).filter((e=>null!==e));let _;if(e.leftAxisesState)_=p(e.leftAxisesState);else{const t=u({state:e.leftAxisState,sources:e.leftAxisSources});_=null!==t?[t]:[]}let m;if(this._leftPriceScales.slice().forEach((e=>this.removePriceScale(e))),this._leftPriceScales=[],_.forEach((e=>this._placePriceScale(e,"left"))),e.rightAxisesState)m=p(e.rightAxisesState);else{const t=u({state:e.rightAxisState,sources:e.rightAxisSources});m=null!==t?[t]:[]}this._rightPriceScales.slice().forEach((e=>this.removePriceScale(e))),this._rightPriceScales=[],m.forEach((e=>this._placePriceScale(e,"right"))),this._currentPriceScaleRatio=e.priceScaleRatio||e.leftPriceScaleRatio||e.rightPriceScaleRatio||null;const g=new Map;for(const t of this.m_dataSources){if(c.has(t))continue;let i;if(e.overlayPriceScales&&e.overlayPriceScales[t.id()]){let s=e.overlayPriceScales[t.id()];g.has(null==s?void 0:s.id)?i=g.get(null==s?void 0:s.id):(s=(0,n.ensure)(s), -i=new xe(this._model.properties().childs().scalesProperties),i.setHeight(this._height),s.m_isAutoScale=!0,s.m_isLog=!1,s.m_isPercentage=!1,s.m_isLockScale=!1,i.restoreState(s),g.set(s.id,i))}else i=new xe(this._model.properties().childs().scalesProperties),i.setHeight(this._height);h(t,i)}for(const e of Object.keys(l)){const t=l[e],i=this.dataSourceForId(e);t&&i&&null===i.ownerSource()&&i.setOwnerSource(this.dataSourceForId(t))}if(e.mainSourceId&&!this.containsMainSeries()&&(this.m_mainDataSource=this.dataSourceForId(e.mainSourceId)),!this.m_mainDataSource)for(const e of this.m_dataSources)if((0,re.isPriceDataSource)(e)){this.m_mainDataSource=e;break}for(const e of this.m_dataSources)(0,S.isLineTool)(e)?(e.ownerSource()||e.setOwnerSource(this.mainDataSource()),e.isFixed()&&e.restoreFixedPoint()):(0,j.isStudy)(e)&&!e.ownerSource()&&e.isLinkedToSeries()&&e.setOwnerSource(this.model().mainSeries());this._updateMargins(),this._cachedOrderedSources.clear()}onPriceScalesChanged(){return this._onPriceScalesChanged}setPaneSize(e){let t;switch(e){case"large":t=1;break;case"medium":t=.6;break;case"small":t=.3;break;case"tiny":t=.15;break;default:throw new Error("Unknown size enum value: "+e)}this._stretchFactor=1e3*t}stretchFactor(){return this._stretchFactor}setStretchFactor(e){this._stretchFactor=e}customSources(e){return this.model().customSources(e)}createDrawingsCaches(){se.ExecutionsPositionController.recreateOrderedByBarsSourcesCache(this)}clearDrawingCaches(){se.ExecutionsPositionController.clearOrderedByBarsSourcesCache()}executionsPositionController(){return this._executionsPositionController||(this._executionsPositionController=new se.ExecutionsPositionController(this)),this._executionsPositionController}width(){return this._width}height(){return this._height}setHeight(e){if(this._height!==e){this._height=e,this._leftPriceScales.forEach((t=>t.setHeight(e))),this._rightPriceScales.forEach((t=>t.setHeight(e)));for(let t=0;t(e.paneViews(this)||[]).some((e=>{const r=e.renderer(t,i);return r&&r.doesIntersectWithBox&&r.doesIntersectWithBox(s)}))))}logicalRectToPixels(e){const t=this.defaultPriceScale(),i=this.timeScale(),s=(0,n.ensureNotNull)((0,n.ensureNotNull)(t.mainSource()).firstValue()),r=t.priceToCoordinate(e.p1.price,s),a=i.indexToCoordinate(e.p1.index),l=t.priceToCoordinate(e.p2.price,s),c=i.indexToCoordinate(e.p2.index),h=new o.Point(Math.min(a,c),Math.min(r,l)),d=new o.Point(Math.max(a,c),Math.max(r,l));return(0,o.box)(h,d)}timeScale(){return this._timeScale}restoreLineTool(e,t,i,s,r){var o,a,l,c,h,d,u,p,_,m,g;delete e.state.lastUpdateTime,e.state.intervalsVisibilities=(0,Be.mergeIntervalVisibilitiesDefaults)(e.state.intervalsVisibilities),i=void 0===i||i,Ee.LineToolElliott.migrateState(e),"LineToolGannComplex"!==(g=e).type||void 0!==g.version&&1!==g.version||(g.type="LineToolGannFixed"),Array.isArray(e.positionPercents)&&(e.positionPercents=e.positionPercents[0]);const f=e.type,v=e.id,y=e.state,b=i?e.zorder:this.newLineToolZOrder();(0,n.assert)((0,he.isLineToolName)(f),"invalid data source type:"+f+" (expected to be a Line Tool)");let w,P,C=null;if((0,Me.isStudyLineToolState)(e)){C=this._model.studyVersioning();const t=C.patchPointsBasedStudyState(e);e=t;const i=t.metaInfo;Object.assign(i,te.StudyMetaInfo.parseIdString(null==i?void 0:i.fullId));const s=C.updateMetaInfo(i)||i;P=(0,S.createStudyLineToolProperties)(f,i,s,y,C),w=(0,S.createLineTool)(f,this._model,P,s,!0)}else P=(0,S.createLineToolProperties)(f,y,this._model),t?null===(o=P.child("fixedSize"))||void 0===o||o.setValue(!1):null===(a=P.child("fixedSize"))||void 0===a||a.setValue(!0),w=(0,S.createLineTool)(f,this._model,P,null,!0);w.setId(v),w.linkKey().setValue(e.linkKey||null);const x=e.alertId;x&&w.canHasAlert()&&N.enabled("alerts")&&!this._model.readOnly()&&!this._model.isJustClonedChart()&&w.setAlert(x);let T=null!==(l=e.indexes)&&void 0!==l?l:[];if(T=T.slice(0,null!==(h=null===(c=e.points)||void 0===c?void 0:c.length)&&void 0!==h?h:T.length),w.isFixed()?void 0!==e.positionPercents?w.restorePositionPercents(e.positionPercents):w.restorePositionPercents({x:.5,y:.5}):e.points&&w.restorePoints(e.points,T,t),w instanceof Re.LineToolBarsPattern||w instanceof Ne.LineToolCallout||w instanceof Oe.LineToolTrendAngle||w instanceof Fe.LineToolGhostFeed||w instanceof We.LineToolParallelChannel)null===(u=(d=w).restoreData)||void 0===u||u.call(d,e);else if(t&&(0,Me.isStudyLineToolState)(e)&&w.restoreData){const t=e;C&&(t.graphics=C.patchPointsBasedStudyData(t.metaInfo,t.graphics)),null===(p=w.restoreData)||void 0===p||p.call(w,t)}const I=null==e.version?1:e.version,M=null==w.version?1:w.version;if(I!==M&&(null===(m=(_=w).migrateVersion)||void 0===m||m.call(_,I,M,{pane:this,model:this._model,properties:P})),void 0!==b&&w.setZorder(b),r)(0,S.prepareLineToolPropertiesByOwnerSource)(w.properties(),r),w.setOwnerSource(r);else{ -const t=e.ownerSource?this.dataSourceForId(e.ownerSource):null;w.setOwnerSource(t)}return void 0!==e.userEditEnabled&&w.setUserEditEnabled(e.userEditEnabled),void 0!==e.isSelectionEnabled&&w.setSelectionEnabled(e.isSelectionEnabled),this._addSourceToCollections(w,s),this._cachedOrderedSources.clear(),w}restoreStudy(e,t,i,s,r,n){var o;if(t&&void 0===e.data&&void 0===e.nonSeriesData&&void 0===e.indexes)return Ue.logError("Cannot restore (skipping) study without data "+e.id+", "+e.metaInfo.id),null;const a=e.id,l=e.state,c=e.zorder;i=null!=i?i:this._model.mainSeries().id();const h=(null!==(o=e.parentSources)&&void 0!==o?o:e.ownerSource?[e.ownerSource]:[]).filter((e=>e!==i));let d=(0,ie.clone)(e.metaInfo);if(Object.assign(d,te.StudyMetaInfo.parseIdString(d.id)),function(e){return"Script$TV_EARNINGS@tv-scripting"===e||"Script$TV_DIVIDENDS@tv-scripting"===e||"Script$TV_SPLITS@tv-scripting"===e||"ESD$TV_EARNINGS@tv-scripting"===e||"ESD$TV_DIVIDENDS@tv-scripting"===e||"ESD$TV_SPLITS@tv-scripting"===e||"Earnings@tv-basicstudies"===e||"Dividends@tv-basicstudies"===e||"Splits@tv-basicstudies"===e||"BarSetContinuousRollDates@tv-corestudies"===e}(d.id)&&!t)return Ue.logNormal("Skipping study "+d.id),null;let u=l;const p=this._model.studyVersioning(),_=p.patchPropsStateAndMetaInfo(u,d,{oldShowStudyLastValueProperty:t&&!(null==s?void 0:s.showStudyLastValueProperty)});u=_.propsState,d=_.metaInfo;const m=new P.StudyStub(this._model,e,d.shortDescription);let g;m.setId(a),m.setZorder(c);const f=i=>{m.setStatus({type:Ae.StudyStatusType.Undefined});const s=i||new te.StudyMetaInfo(d),r=Ve.instance(this._model),n=n=>{var o;const l=(0,C.prepareStudyPropertiesForLoadChart)(d,i,u,p),c=(0,j.createStudy)(this._model,l,n,s);if(c.setId(a),c.setOwnFirstValue(null!==(o=e.ownFirstValue)&&void 0!==o?o:null),e.customFields&&c.restoreStateCustomFields(e.customFields),t){const t=e,{data:i,nsData:s,indexes:r}=p.patchStudyData(d,t.data,t.nonSeriesData,t.indexes);c.restoreData(i,s,r)}this._model.replaceStudyStub(m,c)||(g=c),r.add(a,c)};if(h.length>0){const e=h.map((e=>r.get(e)));Promise.all(e).then(n)}else n([])};if(t)f(null);else{let e=null;0;const t=e=>{const t=p.updateMetaInfoAsync(e);t.sync?f(t.result):t.result.then(f).catch((e=>m.setFailed("error: "+e)))};e?e.then(t):t(d)}const v=null!=g?g:m;if(v){v.setZorder(c);const t=e.metaInfo.linkedToSeries?this._model.mainSeries():h.length?this.dataSourceForId(h[0]):null;v.setOwnerSource(t),this._addSourceToCollections(v,r),this._processMainSourceChange()}return this._cachedOrderedSources.clear(),v}clipboardLineToolOwnerSource(e){const t=this.dataSourceForId(e);if(null!==t){const e=t.ownerSource();if(null!==e&&null!==e.firstValue())return e}const i=this.mainDataSource();if(null!==i&&null!==i.firstValue())return i;for(const e of this.dataSources())if((0,re.isPriceDataSource)(e)&&null!==e.firstValue())return e;return null}realignLineTools(e){var t;let i=!1;for(const s of this.m_dataSources)!(0,S.isLineTool)(s)||void 0!==e&&(null===(t=null==s?void 0:s.ownerSource())||void 0===t?void 0:t.symbolSource())!==e&&(0, +;var s=i(49483),r=i(50151),n=i(1722),o=i(80007),a=i(38325);const l=s.isSafari?"click":"auxclick",c={treatVertTouchDragAsPageScroll:!1,treatHorzTouchDragAsPageScroll:!1};class h{constructor(e,t,i){this._clickCount=0,this._clickTimeoutId=null,this._clickPosition={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY},this._tapCount=0,this._tapTimeoutId=null,this._tapPosition={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY},this._longTapTimeoutId=null,this._longTapActive=!1,this._mouseMoveStartPosition=null,this._touchMoveStartPosition=null,this._touchMoveExceededManhattanDistance=!1,this._cancelClick=!1,this._cancelTap=!1,this._unsubscribeOutsideMouseEvents=null,this._unsubscribeOutsideTouchEvents=null,this._unsubscribeMobileSafariEvents=null,this._unsubscribeMousemove=null,this._unsubscribeRootMouseEvents=null,this._unsubscribeRootTouchEvents=null,this._pinchInfo=null,this._pinchPrevented=!1,this._preventTouchDragProcess=!1,this._mousePressed=!1,this._lastTouchEventTimeStamp=0,this._activeTouchId=null,this._acceptMouseLeave=!s.CheckMobile.iOS(),this._onFirefoxOutsideMouseUp=e=>{this._mouseUpHandler(e)},this._onMobileSafariDoubleClick=e=>{if(this._firesTouchEvents(e)){const t=this._makeCompatEvent(e);if(++this._tapCount,this._tapTimeoutId&&this._tapCount>1){const{manhattanDistance:i}=this._touchMouseMoveWithDownInfo(u(e),this._tapPosition);i<30&&!this._cancelTap&&this._processTouchEvent(t,this._handler.doubleTapEvent),this._resetTapTimeout()}}else{const t=this._makeCompatEvent(e);if(++this._clickCount,this._clickTimeoutId&&this._clickCount>1){const{manhattanDistance:i}=this._touchMouseMoveWithDownInfo(u(e),this._clickPosition);i<5&&!this._cancelClick&&this._processMouseEvent(t,this._handler.mouseDoubleClickEvent),this._resetClickTimeout()}}},this._target=e,this._handler=t,this._options=(0,n.merge)((0,n.clone)(c),i||{}),this._init()}destroy(){null!==this._unsubscribeOutsideMouseEvents&&(this._unsubscribeOutsideMouseEvents(),this._unsubscribeOutsideMouseEvents=null),null!==this._unsubscribeOutsideTouchEvents&&(this._unsubscribeOutsideTouchEvents(),this._unsubscribeOutsideTouchEvents=null),null!==this._unsubscribeMousemove&&(this._unsubscribeMousemove(),this._unsubscribeMousemove=null),null!==this._unsubscribeRootMouseEvents&&(this._unsubscribeRootMouseEvents(),this._unsubscribeRootMouseEvents=null),null!==this._unsubscribeRootTouchEvents&&(this._unsubscribeRootTouchEvents(),this._unsubscribeRootTouchEvents=null),null!==this._unsubscribeMobileSafariEvents&&(this._unsubscribeMobileSafariEvents(),this._unsubscribeMobileSafariEvents=null),this._clearLongTapTimeout(),this._resetClickTimeout()}_mouseEnterHandler(e){this._unsubscribeMousemove&&this._unsubscribeMousemove();const t=this._mouseMoveHandler.bind(this);if(this._unsubscribeMousemove=()=>{this._target.removeEventListener("mousemove",t)},this._target.addEventListener("mousemove",t),this._firesTouchEvents(e))return;const i=this._makeCompatEvent(e);this._processMouseEvent(i,this._handler.mouseEnterEvent),this._acceptMouseLeave=!0}_resetClickTimeout(){ +null!==this._clickTimeoutId&&clearTimeout(this._clickTimeoutId),this._clickCount=0,this._clickTimeoutId=null,this._clickPosition={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY}}_resetTapTimeout(){null!==this._tapTimeoutId&&clearTimeout(this._tapTimeoutId),this._tapCount=0,this._tapTimeoutId=null,this._tapPosition={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY}}_mouseMoveHandler(e){if(this._mousePressed||null!==this._touchMoveStartPosition)return;if(this._firesTouchEvents(e))return;const t=this._makeCompatEvent(e);this._processMouseEvent(t,this._handler.mouseMoveEvent),this._acceptMouseLeave=!0}_touchMoveHandler(e){const t=m(e.changedTouches,(0,r.ensureNotNull)(this._activeTouchId));if(null===t)return;if(this._lastTouchEventTimeStamp=_(e),null!==this._pinchInfo&&this._pinchInfo.accepted)return;if(this._preventTouchDragProcess)return;this._pinchPrevented=!0;const i=this._touchMouseMoveWithDownInfo(u(t),(0,r.ensureNotNull)(this._touchMoveStartPosition)),{xOffset:s,yOffset:n,manhattanDistance:a}=i;if(this._touchMoveExceededManhattanDistance||!(a<5)){if(!this._touchMoveExceededManhattanDistance){const e=.5*s,t=n>=e&&!this._options.treatVertTouchDragAsPageScroll,i=e>n&&!this._options.treatHorzTouchDragAsPageScroll;t||i||(this._preventTouchDragProcess=!0),this._touchMoveExceededManhattanDistance=!0,this._cancelTap=!0,this._clearLongTapTimeout(),this._resetTapTimeout()}if(!this._preventTouchDragProcess){const i=this._makeCompatEvent(e,t);this._processTouchEvent(i,this._handler.touchMoveEvent),(0,o.preventDefault)(e)}}}_mouseMoveWithDownHandler(e){if(0!==e.button)return;const t=this._touchMouseMoveWithDownInfo(u(e),(0,r.ensureNotNull)(this._mouseMoveStartPosition)),{manhattanDistance:i}=t;if(i>=5&&(this._cancelClick=!0,this._resetClickTimeout()),this._cancelClick){const t=this._makeCompatEvent(e);this._processMouseEvent(t,this._handler.pressedMouseMoveEvent)}}_touchMouseMoveWithDownInfo(e,t){const i=Math.abs(t.x-e.x),s=Math.abs(t.y-e.y);return{xOffset:i,yOffset:s,manhattanDistance:i+s}}_touchEndHandler(e){let t=m(e.changedTouches,(0,r.ensureNotNull)(this._activeTouchId));if(null===t&&0===e.touches.length&&(t=e.changedTouches[0]),null===t)return;this._activeTouchId=null,this._lastTouchEventTimeStamp=_(e),this._clearLongTapTimeout(),this._touchMoveStartPosition=null,this._unsubscribeRootTouchEvents&&(this._unsubscribeRootTouchEvents(),this._unsubscribeRootTouchEvents=null);const i=this._makeCompatEvent(e,t);if(this._processTouchEvent(i,this._handler.touchEndEvent),++this._tapCount,this._tapTimeoutId&&this._tapCount>1){const{manhattanDistance:e}=this._touchMouseMoveWithDownInfo(u(t),this._tapPosition);e<30&&!this._cancelTap&&this._processTouchEvent(i,this._handler.doubleTapEvent),this._resetTapTimeout()}else this._cancelTap||(this._processTouchEvent(i,this._handler.tapEvent),this._handler.tapEvent&&(0,o.preventDefault)(e));0===this._tapCount&&(0,o.preventDefault)(e),0===e.touches.length&&this._longTapActive&&(this._longTapActive=!1,(0,o.preventDefault)(e))}_mouseUpHandler(e){if(0!==e.button)return +;const t=this._makeCompatEvent(e);if(this._mouseMoveStartPosition=null,this._mousePressed=!1,this._unsubscribeRootMouseEvents&&(this._unsubscribeRootMouseEvents(),this._unsubscribeRootMouseEvents=null),s.isFF){this._target.ownerDocument.documentElement.removeEventListener("mouseleave",this._onFirefoxOutsideMouseUp)}if(!this._firesTouchEvents(e))if(this._processMouseEvent(t,this._handler.mouseUpEvent),++this._clickCount,this._clickTimeoutId&&this._clickCount>1){const{manhattanDistance:i}=this._touchMouseMoveWithDownInfo(u(e),this._clickPosition);i<5&&!this._cancelClick&&this._processMouseEvent(t,this._handler.mouseDoubleClickEvent),this._resetClickTimeout()}else this._cancelClick||(this._processMouseEvent(t,this._handler.mouseClickEvent),e.defaultPrevented&&--this._clickCount)}_clearLongTapTimeout(){null!==this._longTapTimeoutId&&(clearTimeout(this._longTapTimeoutId),this._longTapTimeoutId=null)}_touchStartHandler(e){if(null!==this._activeTouchId)return;const t=e.changedTouches[0];this._activeTouchId=t.identifier,this._lastTouchEventTimeStamp=_(e);const i=this._target.ownerDocument.documentElement;this._cancelTap=!1,this._touchMoveExceededManhattanDistance=!1,this._preventTouchDragProcess=!1,this._touchMoveStartPosition=u(t),this._unsubscribeRootTouchEvents&&(this._unsubscribeRootTouchEvents(),this._unsubscribeRootTouchEvents=null);{const t=this._touchMoveHandler.bind(this),s=this._touchEndHandler.bind(this);this._unsubscribeRootTouchEvents=()=>{i.removeEventListener("touchmove",t),i.removeEventListener("touchend",s)},i.addEventListener("touchmove",t,{passive:!1}),i.addEventListener("touchend",s,{passive:!1}),this._clearLongTapTimeout(),this._longTapTimeoutId=setTimeout(this._longTapHandler.bind(this,e),240)}const s=this._makeCompatEvent(e,t);this._processTouchEvent(s,this._handler.touchStartEvent),this._tapTimeoutId||(this._tapCount=0,this._tapTimeoutId=setTimeout(this._resetTapTimeout.bind(this),500),this._tapPosition=u(t))}_wheelClickHandler(e){if(1!==e.button)return;if(this._firesTouchEvents(e))return;const t=this._makeCompatEvent(e);this._processMouseEvent(t,this._handler.wheelClickEvent)}_mouseDownHandler(e){if(0!==e.button)return;const t=this._target.ownerDocument.documentElement;s.isFF&&t.addEventListener("mouseleave",this._onFirefoxOutsideMouseUp),this._cancelClick=!1,this._mouseMoveStartPosition=u(e),this._unsubscribeRootMouseEvents&&(this._unsubscribeRootMouseEvents(),this._unsubscribeRootMouseEvents=null);{const e=this._mouseMoveWithDownHandler.bind(this),i=this._mouseUpHandler.bind(this);this._unsubscribeRootMouseEvents=()=>{t.removeEventListener("mousemove",e),t.removeEventListener("mouseup",i)},t.addEventListener("mousemove",e),t.addEventListener("mouseup",i)}if(this._mousePressed=!0,this._firesTouchEvents(e))return;const i=this._makeCompatEvent(e);this._processMouseEvent(i,this._handler.mouseDownEvent),this._clickTimeoutId||(this._clickCount=0,this._clickTimeoutId=setTimeout(this._resetClickTimeout.bind(this),500),this._clickPosition=u(e))}_init(){ +this._target.addEventListener("mouseenter",this._mouseEnterHandler.bind(this)),this._target.addEventListener("touchcancel",this._clearLongTapTimeout.bind(this));{const e=this._target.ownerDocument,t=e=>!e.target||!this._target.contains(e.target),i=e=>{if(!t(e))return;const i=e.changedTouches[0];this._lastTouchEventTimeStamp=_(e),this._processTouchEvent(this._makeCompatEvent(e,i),this._handler.touchStartOutsideEvent)},s=e=>{t(e)&&!this._firesTouchEvents(e)&&this._processMouseEvent(this._makeCompatEvent(e),this._handler.mouseDownOutsideEvent)};this._unsubscribeOutsideTouchEvents=()=>{e.removeEventListener("touchstart",i)},this._unsubscribeOutsideMouseEvents=()=>{e.removeEventListener("mousedown",s)},e.addEventListener("mousedown",s),e.addEventListener("touchstart",i,{passive:!0})}s.CheckMobile.iOS()&&(this._unsubscribeMobileSafariEvents=()=>{this._target.removeEventListener("dblclick",this._onMobileSafariDoubleClick)},this._target.addEventListener("dblclick",this._onMobileSafariDoubleClick)),this._target.addEventListener("mouseleave",this._mouseLeaveHandler.bind(this)),this._target.addEventListener("contextmenu",this._contextMenuHandler.bind(this)),this._target.addEventListener("touchstart",this._touchStartHandler.bind(this),{passive:!0}),(0,o.preventScrollByWheelClick)(this._target),this._target.addEventListener("mousedown",this._mouseDownHandler.bind(this)),this._target.addEventListener(l,this._wheelClickHandler.bind(this)),this._initPinch(),this._target.addEventListener("touchmove",(()=>{}),{passive:!1})}_initPinch(){void 0===this._handler.pinchStartEvent&&void 0===this._handler.pinchEvent&&void 0===this._handler.pinchEndEvent||(this._target.addEventListener("touchstart",(e=>this._checkPinchState(e.touches)),{passive:!0}),this._target.addEventListener("touchmove",(e=>{if(null===this._pinchInfo||!this._pinchInfo.accepted)return;const t=m(e.touches,(0,r.ensureNotNull)(this._activeTouchId)),i=m(e.touches,this._pinchInfo.secondTouchId);if(t&&i&&void 0!==this._handler.pinchEvent){const{startPinchDistance:s,startPinchMiddlePoint:r}=this._pinchInfo,n=p(t,i)/s,a=d(this._target);this._handler.pinchEvent(r,{x:t.clientX-a.left,y:t.clientY-a.top},{x:i.clientX-a.left,y:i.clientY-a.top},n),(0,o.preventDefault)(e)}}),{passive:!1}),this._target.addEventListener("touchend",(e=>{this._checkPinchState(e.touches)})))}_checkPinchState(e){1===e.length&&(this._pinchPrevented=!1),2!==e.length||this._pinchPrevented||this._longTapActive?this._stopPinch():this._startPinch(e)}_startPinch(e){if(void 0!==this._handler.pinchStartEvent){const t=d(this._target);let i,s;e[0].identifier===this._activeTouchId?(i=e[0],s=e[1]):(i=e[1],s=e[0]);const r={x:i.clientX-t.left,y:i.clientY-t.top},n={x:s.clientX-t.left,y:s.clientY-t.top},o={x:(r.x+n.x)/2,y:(r.y+n.y)/2},a=this._handler.pinchStartEvent(o,r,n,{bothPointsOnTargetElement:this._target.contains(s.target)});this._pinchInfo={startPinchDistance:p(i,s),startPinchMiddlePoint:o,secondTouchId:s.identifier,accepted:a}}this._clearLongTapTimeout()}_stopPinch(){const e=this._pinchInfo;this._pinchInfo=null, +null!==e&&e.accepted&&void 0!==this._handler.pinchEndEvent&&this._handler.pinchEndEvent()}_mouseLeaveHandler(e){if(this._unsubscribeMousemove&&this._unsubscribeMousemove(),this._firesTouchEvents(e))return;if(!this._acceptMouseLeave)return;const t=this._makeCompatEvent(e);this._processMouseEvent(t,this._handler.mouseLeaveEvent),this._acceptMouseLeave=!s.CheckMobile.iOS()}_longTapHandler(e){const t=m(e.touches,(0,r.ensureNotNull)(this._activeTouchId));if(null===t)return;const i=this._makeCompatEvent(e,t);this._processTouchEvent(i,this._handler.longTapEvent),this._processTouchEvent(i,this._handler.touchContextMenuEvent),this._cancelTap=!0,this._longTapActive=!0}_contextMenuHandler(e){if((0,o.preventDefault)(e),null!==this._touchMoveStartPosition)return;if(this._firesTouchEvents(e))return;const t=this._makeCompatEvent(e);this._processMouseEvent(t,this._handler.contextMenuEvent),this._cancelClick=!0}_firesTouchEvents(e){return e.sourceCapabilities&&void 0!==e.sourceCapabilities.firesTouchEvents?e.sourceCapabilities.firesTouchEvents:_(e){"touchstart"!==e.type&&(0,o.preventDefault)(e)}}}}function d(e){return e.getBoundingClientRect()||{left:0,top:0}}function u(e){return{x:e.pageX,y:e.pageY}}function p(e,t){const i=e.clientX-t.clientX,s=e.clientY-t.clientY;return Math.sqrt(i*i+s*s)}function _(e){return e.timeStamp||performance.now()}function m(e,t){for(let i=0;i{"use strict";i.d(t,{actualBehavior:()=>a,availableValues:()=>o,navigationButtonsVisibilityKey:()=>r,property:()=>n,restoreNavigationButtonsVisibilitySettingsValue:()=>l});var s=i(29542);const r="NavigationButtons.visibility",{property:n,availableValues:o,actualBehavior:a,restoreDefaultValue:l}=(0,s.createVisibilityController)(r)},3228:(e,t,i)=>{"use strict";i.d(t,{actualBehavior:()=>a,availableValues:()=>o,property:()=>n,restorePaneButtonsVisibilitySettingsValue:()=>l});var s=i(29542),r=i(78159);const{property:n,availableValues:o,actualBehavior:a,restoreDefaultValue:l}=(0,s.createVisibilityController)("PaneButtons.visibility",r.navigationButtonsVisibilityKey)},77212:(e,t,i)=>{"use strict";i.d(t,{ActionBinder:()=>s});class s{constructor(e,t,i,s,r=null){this._property=t,this._undoModel=i,this._undoText=s,this._action=e,this.setValue(t.value()), +t.subscribe(this,this._propertyChanged),null!==r?e.update({onExecute:r.bind(this)}):e.update({onExecute:this._onActionCallback.bind(this)})}destroy(){this._property.unsubscribe(this,this._propertyChanged)}value(){return this._action.isChecked()}setValue(e){this._action.update({checked:Boolean(e)})}_onActionCallback(){this._undoModel.setProperty(this._property,this.value(),this._undoText)}_propertyChanged(e){this.setValue(e.value())}}},43886:(e,t,i)=>{"use strict";i.d(t,{isCustomStudy:()=>r});const s={VbPFixed:!0,PivotPointsStandard:!0,VbPVisible:!0,VbPAnchored:!0};function r(e){return e in s}},96362:(e,t,i)=>{"use strict";i.d(t,{MetaInfoHelper:()=>u});var s=i(50151),r=i(42856),n=i(72877),o=i(1722),a=i(59224),l=i(33703);function c(e){return!e.groupId&&!e.isHidden&&e.id!==l.RangeDependentStudyInputNames.FirstBar&&e.id!==l.RangeDependentStudyInputNames.LastBar}var h=i(43886);const d=(0,a.getLogger)("Platform.GUI.PropertyDialog.Indicators.MetaInfo");class u{constructor(e){this._metaInfo=e}hasUserEditableInputs(){return this._metaInfo.inputs.some(c)}getUserEditableInputs(){return this._metaInfo.inputs.filter(c)}hasUserEditableProperties(){return r.StudyMetaInfo.isScriptStrategy(this._metaInfo)}hasUserEditableStyles(){const e=this._metaInfo;return e.plots.length>0||void 0!==e.bands||void 0!==e.filledAreas||(0,h.isCustomStudy)(e.shortId)||r.StudyMetaInfo.isScriptStrategy(this._metaInfo)||Object.values(e.graphics).some((e=>void 0!==e))}getUserEditablePlots(){const e=new Set,t=this._metaInfo;return t.plots.filter((i=>{if((0,n.isColorerPlot)(i)||(0,n.isTextColorerPlot)(i)||(0,n.isDataOffsetPlot)(i)||(0,n.isOhlcColorerPlot)(i)||(0,n.isAlertConditionPlot)(i)||(0,n.isDataPlot)(i))return!1;if((0,n.isOhlcPlot)(i)){const r=i.target;if(e.has(r))return!1;e.add(r);const n=(0,s.ensureDefined)(t.ohlcPlots);return!(0,s.ensureDefined)(n[r]).isHidden}{const e=t.styles?t.styles[i.id]:void 0;return void 0===e||!e.isHidden}}))}hasUserEditableOptions(){return this.hasUserEditableInputs()||this.hasUserEditableProperties()||this.hasUserEditableStyles()}getStrategyProperties(){const e=this._metaInfo,t=e.inputs.filter(_),i={...p};for(const s of t){const t=s.internalID;i[t]=s,p.hasOwnProperty(t)||d.logWarn(`Unknown strategy input internal id ${t} in ${e.fullId}`)}return(0,o.clone)(i)}}const p={currency:void 0,backtest_fill_limits_assumption:void 0,calc_on_every_tick:void 0,calc_on_order_fills:void 0,commission_value:void 0,commission_type:void 0,initial_capital:void 0,pyramiding:void 0,slippage:void 0,default_qty_type:void 0,default_qty_value:void 0,margin_long:void 0,margin_short:void 0,use_bar_magnifier:void 0,process_orders_on_close:void 0,fill_orders_on_standard_ohlc:void 0};function _(e){return"strategy_props"===e.groupId}},68456:(e,t,i)=>{"use strict";i.d(t,{AbstractJsonStoreService:()=>r,CommonJsonStoreService:()=>n});var s=i(57898);class r{constructor(e,t,i,r,n){this._onChange=new s.Delegate,this._handleChange=()=>{this._onChange.fire(this.get())},this._crossTabEvents=e,this._jsonKeyValueStore=t,this.CROSSTAB_EVENT_NAME=i, +this.JSON_STORE_KEY=r,this.defaultStoreValue=this._serialize(n),this._subscribe()}get(){const e=this._jsonKeyValueStore.getJSON(this.JSON_STORE_KEY,this.defaultStoreValue);return this._deserialize(e)}set(e,t){const i=this._serialize(e);this._jsonKeyValueStore.setJSON(this.JSON_STORE_KEY,i,t),this._crossTabEvents.emit(this.CROSSTAB_EVENT_NAME),this._onChange.fire(e)}getOnChange(){return this._onChange}destroy(){this._unsubscribe(),this._onChange.destroy(),delete this._onChange}_subscribe(){this._crossTabEvents.on(this.CROSSTAB_EVENT_NAME,this._handleChange),this._jsonKeyValueStore.onSync.subscribe(this,this._handleChange)}_unsubscribe(){this._crossTabEvents.off(this.CROSSTAB_EVENT_NAME,this._handleChange),this._jsonKeyValueStore.onSync.unsubscribe(this,this._handleChange)}}class n extends r{_serialize(e){return e}_deserialize(e){return e}}},75593:(e,t,i)=>{"use strict";i.d(t,{CustomStatusModel:()=>c});var s=i(97145);const r="#9598a1",n=!1,o=null,a='';class l{constructor(e){this._visible=new s.WatchedValue(n),this._tooltip=new s.WatchedValue(o),this._icon=new s.WatchedValue(a),this._color=new s.WatchedValue(r),this._tooltipContent=new s.WatchedValue(null),this._symbol=e}symbol(){return this._symbol}tooltip(){return this._tooltip}icon(){return this._icon}color(){return this._color}visible(){return this._visible}tooltipContent(){return this._tooltipContent}}class c{constructor(){this._symbolCustomStatuses=new Map}getSymbolCustomStatus(e){if(this._symbolCustomStatuses.has(e))return this._symbolCustomStatuses.get(e);const t=new l(e);return this._symbolCustomStatuses.set(e,t),t}hideAll(){for(const e of this._symbolCustomStatuses.values())e.visible().setValue(!1)}static getInstance(){return null===this._instance&&(this._instance=new c),this._instance}}c._instance=null},98425:(e,t,i)=>{"use strict";i.d(t,{restoreShowMarketOpenStatusProperty:()=>l,showMarketOpenStatusProperty:()=>a});var s=i(59680),r=i(56840);const n="Chart.ShowMarketOpenStatus";function o(){return r.getBool(n,true)}const a=(0,s.createPrimitiveProperty)(o());function l(){a.setValue(true),r.remove(n)}r.onSync.subscribe(null,(()=>a.setValue(o()))),a.subscribe(null,(()=>r.setValue(n,a.value())))},77248:(e,t,i)=>{"use strict";i.d(t,{firstReplacedByBatsExchange:()=>a,isDelay:()=>h,isEod:()=>l,isYield:()=>c,witoutRealtime:()=>d});i(50151);var s=i(79982),r=i.n(s);const n=["DJ","JSE","BELEX"],o=["NZX"];function a(e){return null}function l(e,t){return r().hasEodSymbols(e.full_name)||6===t}function c(e){var t;return Boolean(null===(t=e.typespecs)||void 0===t?void 0:t.includes("yield"))}function h(e){return void 0!==e&&e>0}function d(e){return"index"===e.type&&n.includes(e.listed_exchange)||"futures"===e.type&&o.includes(e.listed_exchange)}},31330:(e,t,i)=>{"use strict";i.d(t,{canShowSpreadActions:()=>r,globalKeypressMatches:()=>n});var s=i(14483);i(94025),i(82992);new RegExp("^quandl","i");function r(){let e=!1;return s.enabled("show_spread_operators")&&(e=!0),e}function n(e){ +if(e.ctrlKey)return!1;if(e.metaKey)return!1;if(!e.charCode)return!1;if(!e.which||e.which<=32)return!1;const t=e.target;return!t||!/^(input|textarea)$/i.test(t.tagName)&&"listbox"!==t.getAttribute("role")}},13702:(e,t,i)=>{"use strict";function s(){return Promise.all([i.e(2666),i.e(1013),i.e(4015),i.e(5145),i.e(855),i.e(6),i.e(8056),i.e(2587),i.e(2639),i.e(2109),i.e(9842),i.e(7232),i.e(962),i.e(8385),i.e(3016),i.e(9727),i.e(1754)]).then(i.bind(i,89324))}i.d(t,{loadNewSymbolSearch:()=>s})},40493:(e,t,i)=>{"use strict";i.d(t,{tradingService:()=>n});var s=i(16216);const r={id:"TradingService"};function n(){return(0,s.hasService)(r)?(0,s.service)(r):null}},96005:(e,t,i)=>{"use strict";i.d(t,{TradingViewApiBase:()=>z});var s=i(50151),r=i(82992),n=i(76422),o=i(14483),a=i(10643),l=i(75531),c=i(51768),h=i(5286),d=i(45345),u=i(57898);class p{constructor(e){this._toolbarThemeChanged=new u.Delegate,this._onWatchedThemeChanged=e=>{this._toolbarThemeChanged.fire(e)},this._opts=e,d.watchedTheme.subscribe(this._onWatchedThemeChanged)}destroy(){d.watchedTheme.unsubscribe(this._onWatchedThemeChanged)}isStdTheme(){const e=this._opts.chartWidgetCollection.getAll().every((e=>(0,h.isStdTheme)((0,h.extractThemeFromModel)(e.model()))));return Promise.resolve(e)}async setStdTheme(e,t=!0,i){await(0,h.loadTheme)(this._opts.chartWidgetCollection,{themeName:e,standardTheme:!0,syncState:t,noUndo:i})}setStdThemeForLayout(e,t=!0){(0,d.setTheme)(e),t&&(0,h.syncTheme)()}getCurrentThemeName(){return(0,h.getCurrentTheme)().name}toolbarThemeChanged(){return this._toolbarThemeChanged}}var _=i(88913),m=i(88348),g=i(97145),f=i(46100),v=i(92249),S=i(56954),y=i.t(S,2);const b=new u.Delegate;var w=i(50151).ensureNotNull,P=i(68582).isLineToolRiskReward,C=i(88913).supportedLineTools,x=i(92249).createLineToolProperties,T=i(92249).prepareLineToolPropertiesByOwnerSource,I=i(45973).lineToolEntityInfo,M=i(72414).LineToolsGroupControllerApi,L=i(47513).RemoveSourcesUndoCommand;const{isLineDrawnWithPressedButton:A,isLineToolFinishRequiredWhenCreatedByApi:k}=i(15367),D=i(81155).EnvironmentState;var E=i(75444).ChartWidgetApiBase,V=i(88348);i(51768).trackEvent;function B(e,t){return t.map((function(t){return e.dataSourceForId(t)}))}class R extends E{executeActionById(e){this._chartWidget.executeActionById(e)}getCheckableActionState(e){return this._chartWidget.getCheckableActionState(e)}setZoomEnabled(e){this._chartWidget.model().model().setZoomEnabled(e)}setScrollEnabled(e){this._chartWidget.model().model().setScrollEnabled(e)}refreshMarks(){this._chartWidget.refreshMarks()}clearMarks(e){this._chartWidget.clearMarks(e)}setEntityVisibility(e,t){console.warn("`setEntityVisibility` is deprecated. Use shape/study API instead");var i=this._chartWidget.model().model().dataSourceForId(e);if(i){var s=i.properties();s&&s.visible&&s.visible.setValue(t)}}availableZOrderOperations(e){var t=B(this._chartWidget.model().model(),e);return this._chartWidget.model().availableZOrderOperations(t)}sendToBack(e){var t=B(this._chartWidget.model().model(),e) +;this._chartWidget.model().sendToBack(t)}bringToFront(e){var t=B(this._chartWidget.model().model(),e);this._chartWidget.model().bringToFront(t)}insertAfter(e,t){var i=this._chartWidget.model().model(),s=B(i,e),r=i.dataSourceForId(t);this._chartWidget.model().insertAfter(s,r)}insertBefore(e,t){var i=this._chartWidget.model().model(),s=B(i,e),r=i.dataSourceForId(t);this._chartWidget.model().insertBefore(s,r)}bringForward(e){var t=B(this._chartWidget.model().model(),e);this._chartWidget.model().bringForward(t)}sendBackward(e){var t=B(this._chartWidget.model().model(),e);this._chartWidget.model().sendBackward(t)}showPropertiesDialog(e){var t=this._chartWidget.model().model().dataSourceForId(e);if(null===t)throw new Error("Study or shape "+e+" does not exist");this._chartWidget.showChartPropertiesForSource(t)}getAllShapes(){return this._chartWidget.model().model().allLineTools().map(I).filter((function(e){return null!==e.name}))}removeAllShapes(){this._chartWidget.removeAllDrawingTools()}removeAllStudies(){this._chartWidget.removeAllStudies()}removeEntity(e,t){var i=this._chartWidget.model().chartModel().dataSourceForId(e);i?t&&t.disableUndo?new L(this._chartWidget.model().chartModel(),[i],"").redo():this._chartWidget.model().removeSource(i,!0,!0):console.warn("Can't find a source with id: "+e)}removeEntityWithUndo(e){var t=this._chartWidget.model().chartModel().dataSourceForId(e);this._chartWidget.model().removeSource(t,!1)}createStudyTemplate(e){return this._chartWidget.model().model().studyTemplate(e.saveSymbol,e.saveInterval)}drawOnAllCharts(e){V.drawOnAllCharts.setValue(e)}applyStudyTemplate(e){this._chartWidget.model().applyStudyTemplate(e,""+1e3*Math.random())}getVisiblePriceRange(){return console.warn("`getVisiblePriceRange` is deprecated. Use Price Scale API instead"),this._chartWidget.model().mainSeries()?this._chartWidget.model().mainSeries().priceScale().priceRangeInPrice():null}scrollPosition(){return console.warn("`scrollPosition` is deprecated. Use rightOffset from Time Scale API instead"),this._chartWidget.model().timeScale().rightOffset()}defaultScrollPosition(){return console.warn("`defaultScrollPosition` is deprecated. Use defaultRightOffset from Time Scale API instead"),this._chartWidget.model().timeScale().defaultRightOffset().value()}_createTradingPrimitive(e,t){var i,s=this._chartWidget.model(),r=s.model(),n=r.paneForSource(r.mainSeries());function o(){var e=TradingView.CLOSE_PLOT,t=w(s.mainSeries().bars().last());return{index:t.index,price:t.value[e]}}return(i=t?r.createLineTool(n,o(),e):s.createLineTool({pane:n,point:o(),linetool:e}))?i._adapter:void 0}createOrderLine(e){e=e||{};return this._createTradingPrimitive("LineToolOrder",e.disableUndo)}createPositionLine(e){e=e||{};return this._createTradingPrimitive("LineToolPosition",e.disableUndo)}createExecutionShape(e){e=e||{};return this._createTradingPrimitive("LineToolExecution",e.disableUndo)}createShape(e,t){return this.createMultipointShape([e],t)}createMultipointShape(e,t){ +const i=Object.assign({},this._getDefaultCreateMultipointShapeOptions(),t);var s=C[i.shape]||C.flag;var r=this._chartWidget.model().model(),n=r.mainSeries();if(!r.timeScale().isEmpty()){var o=r.dataSourceForId(i.ownerStudyId)||n,a=r.paneForSource(o),l=this._convertUserPointsToDataSource(e);if(s.onlySelectable)throw new Error('Cannot create "'+i.shape+'" shape');if("LineToolIcon"===s.name){if(i.icon=i.icon||i.overrides&&i.overrides.icon,!i.hasOwnProperty("icon"))throw new Error("icon must be specified in options");i.overrides=i.overrides||{},i.overrides.icon=i.icon}var c,h,d=x(s.name,void 0,this._chartWidget.model().model());if(T(d,o),i.overrides)for(var u in i.overrides)d[u]?d[u].mergeAndFire(i.overrides[u]):P(s.name)&&-1!==["profitLevel","stopLevel"].indexOf(u)&&d.addProperty(u,i.overrides[u]);if(void 0!==d.text&&i.text&&d.text.setValue(i.text),d.hasChild("filled")&&i.filled&&d.filled.setValue(!0),null!==(h=i.disableUndo?(c=this._chartWidget.model().model()).createLineTool(a,l[0],s.name,d,void 0,o):(c=this._chartWidget.model()).createLineTool({pane:a,point:l[0],linetool:s.name,properties:d,ownerSource:o}))){if(P(s.name)){if(l.length>2)throw new Error("Wrong points count for "+i.shape+". Required 1 or 2");2===l.length&&(h.startChanging(1,l[1]),h.setPoint(1,l[1]),h.endChanging())}else{var p=h.pointsCount();if(p!==l.length&&-1!==p)throw new Error("Wrong points count for "+i.shape+". Required "+p);for(var _=new D(void 0,!0),m=A(s.name),g=1;g{this.setActiveChart(this._chartIndex(e))};const{chartApiInstance:t,chartWidgetCollection:i,studyMarket:s,saveChartService:o,loadChartService:a,sharingChartService:l=null,webview:c=null}=e;this._chartWidgetCollection=i,this._studyMarket=s,this._saveChartService=o,this._sharingChartService=l,this._loadChartLayoutDialog=a,this._intervalsService=null,this._alertsWidgetDialog=null,this._detailsDialogController=null,this._supportedChartStylesSpawn=r.linking.supportedChartStyles.spawn(),this._chartWidgetCollection.onAboutToBeDestroyed.subscribe(null,(()=>this.destroy()),!0),this._webview=c;const h=new F.ChartChangesWatcher(this._chartWidgetCollection,window.saver,n);this._chartChangesWatcher=h,this._chartHasChanged=(0,W.createWVFromGetterAndSubscription)((()=>h.hasChanges()),h.getOnChange());const d=i.lock;this._symbolSync=d.symbol.spawn(),this._intervalSync=d.interval.spawn(),this._dateRangeSync=d.dateRange.spawn(),this._crosshairSync=d.crosshair.spawn(),this._timeSync=d.trackTime.spawn()}destroy(){var e,t,i;this._chartHasChanged.destroy(),this._chartChangesWatcher.destroy(),this._supportedChartStylesSpawn.destroy(),null===(e=this._intervalsService)||void 0===e||e.destroy(),null===(t=this._themesApi)||void 0===t||t.destroy(),null===(i=this._widgebarApi)||void 0===i||i.destroy(),this._widgetbarApiRejectionReason="This ITradingViewApi instance has been destroyed",this._symbolSync.destroy(),this._intervalSync.destroy(),this._dateRangeSync.destroy(),this._crosshairSync.destroy(),this._timeSync.destroy(),this._isDestroyed=!0,(0,m.properties)().childs().magnet.unsubscribeAll(this),(0,m.properties)().childs().magnetMode.unsubscribeAll(this)}themes(){return null===this._themesApi&&(this._themesApi=new p({chartWidgetCollection:this._chartWidgetCollection})),this._themesApi}dialogs(){var e,t,i,s,r,n;return{Indicators:this._studyMarket,Compare:this._chartWidgetCollection.getCompareDialogRenderer(),ObjectsTree:null,ChartProperties:this._chartWidgetCollection.getChartPropertiesDialogRenderer(),ChartLayoutSaveAs:null!==(t=null===(e=this._saveChartService)||void 0===e?void 0:e.getSaveAsController())&&void 0!==t?t:null, +ChartLayoutRename:null!==(s=null===(i=this._saveChartService)||void 0===i?void 0:i.getRenameController())&&void 0!==s?s:null,ChartLayoutCreate:null!==(n=null===(r=this._saveChartService)||void 0===r?void 0:r.getCreateController())&&void 0!==n?n:null,ChartLayoutLoad:this._loadChartLayoutDialog,Alerts:this._alertsWidgetDialog,Details:this._detailsDialogController,FinancialsCharts:null,Technicals:null,Forecast:null}}webview(){return H(),this._webview}studyTemplatesDrawerApi(){H()}fontIconsSettingsDrawer(){H()}intervalsService(){H()}supportedChartTypes(){return this._supportedChartStylesSpawn}setBrokerName(e){this._chartWidgetCollection.setBroker(e)}getDrawOnAllCharts(){return(0,m.drawOnAllCharts)().value()}drawOnAllCharts(e){return(0,m.drawOnAllCharts)().setValue(e)}getDrawOnAllChartsMode(){return(0,m.drawOnAllChartsMode)().value()}drawOnAllChartsMode(e){(0,m.drawOnAllChartsMode)().setValue(e)}disableTrackingEvents(){(0,c.disableTrackingEvents)()}getSaveChartService(){return this._saveChartService}symbolSync(){return this._symbolSync}intervalSync(){return this._intervalSync}dateRangeSync(){return this._dateRangeSync}crosshairSync(){return this._crosshairSync}timeSync(){return this._timeSync}setSymbolSearchUI(e){H()}chart(e=0){if(e<0||e>=this.chartsCount())throw Error("Incorrect index: "+e);return this._getChartWidgetApi(this._chartWidgetCollection.getAll()[e])}activeChart(){return this._getChartWidgetApi(this._activeChartWidget())}setActiveChart(e){if(e>=0&&e(this._favoriteDrawingsToolbar||(this._favoriteDrawingsToolbar=new e.FavoriteDrawingsApi),this._favoriteDrawingsToolbar)))}sharingChart(){ +return this._sharingChartService}watchlist(){H()}setWatchlistApiPromise(e){H()}news(){H()}setNewsApiPromise(e){H()}widgetbar(){H()}setWidgetbarApiPromise(e){H()}getChartStorage(){return getChartStorage()}setDebugMode(e){o.setEnabled("charting_library_debug_mode",e)}setFeatureEnabled(e,t){"chart_crosshair_menu"!==e?o.setEnabled(e,t):O.addPlusButtonProperty.setValue(t)}magnetEnabled(){return null===this._magnetEnabledWatchedValue&&(this._magnetEnabledWatchedValue=new g.WatchedValue((0,m.properties)().childs().magnet.value()),this._magnetEnabledWatchedValue.subscribe((e=>{(0,f.saveDefaultProperties)(!0),(0,m.properties)().childs().magnet.setValue(e),(0,f.saveDefaultProperties)(!1)})),(0,m.properties)().childs().magnet.subscribe(this,(()=>{(0,s.ensureNotNull)(this._magnetEnabledWatchedValue).setValue((0,m.properties)().childs().magnet.value())}))),this._magnetEnabledWatchedValue}magnetMode(){return null===this._magnetModeWatchedValue&&(this._magnetModeWatchedValue=new g.WatchedValue((0,m.properties)().childs().magnetMode.value()),this._magnetModeWatchedValue.subscribe((e=>{(0,f.saveDefaultProperties)(!0),(0,m.properties)().childs().magnetMode.setValue(e),(0,f.saveDefaultProperties)(!1)})),(0,m.properties)().childs().magnetMode.subscribe(this,(()=>{(0,s.ensureNotNull)(this._magnetModeWatchedValue).setValue((0,m.properties)().childs().magnetMode.value())}))),this._magnetModeWatchedValue}flushBufferedData(){b.fire()}chartWidgetCollectionState(...e){return this._chartWidgetCollection.state(...e)}chartWidgetCollectionSeriesStatuses(){return this._chartWidgetCollection.chartSeriesStatuses()}initAllLineTools(){return Promise.all(Object.keys(y).filter((e=>!y[e])).map((e=>(0,v.initLineTool)(e)))).then((()=>{}))}watermark(){{const e=N.WatermarkApi.getInstance();if(!e.ready())throw new Error("Watermark API is not initialised yet.");return e}}setContextMenuOptions(e){z.setContextMenuOptions(e)}hasChartChanges(){return this._chartHasChanged}setForceFullscreenMode(){H()}setMultichartMode(){H()}setDateRangeLinkingEnabled(e){this._chartWidgetCollection.lock.dateRange.setValue(e)}static setContextMenuOptions(e){void 0!==e.items_processor&&a.ContextMenuManager.setCustomItemsProcessor(e.items_processor),void 0!==e.renderer_factory&&a.ContextMenuManager.setCustomRendererFactory(e.renderer_factory)}_getChartWidgetApi(e){let t=this._chartWidgets.get(e);return void 0===t&&(t=new R(e,this._activateChart.bind(null,e)),this._chartWidgets.set(e,t)),t}_chartIndex(e){return this._chartWidgetCollection.getAll().indexOf(e)}_activeChartWidget(){return this._chartWidgetCollection.activeChartWidget.value()}}},75117:(e,t,i)=>{"use strict";var s=i(82992).linking,r=(i(51608).createDeferredPromise,i(76422)),n=i(10643).ContextMenuManager,o=i(88348),a=i(94025),l=i(61595).backend,c=i(59224),h=i(3615).showWarning,d=i(3615).showConfirm,u=i(88913),p=i(52092).CLOSE_POPUPS_AND_DIALOGS_COMMAND,_=i(36274).Interval,m=i(96005).TradingViewApiBase,g=i(42856).StudyMetaInfo,f=i(152).getStudyInputsInfo,v=i(70120).getStudyStylesInfo,S=i(57898).Delegate,y=i(97145).WatchedValue +;e.exports=class extends m{constructor(e){const{chartWidgetCollection:t,saveChartService:i,loadChartService:r,sharingChartService:n,alertsDispatcher:o,supportTicketData:a,favoriteServices:l,chartApiInstance:c=null,studyMarket:h=null,webview:d}=e;super({chartApiInstance:c,chartWidgetCollection:t,studyMarket:h,saveChartService:i,loadChartService:r,sharingChartService:n,webview:d}),this._chartApiInstance=c,this._loadChartService=r,this._alertsDispatcher=o,this._supportTicketData=a,this._favoriteServices=l,this._proxyWatchListChangedDelegate=null,this._lockDrawingsWatchedValue=null,this._hideDrawingsWatchedValue=null,this._hideIndicatorsWatchedValue=null,this._replayApi=null,this._getDataSourceHub=function(){return t.activeChartWidget.value().model().model()},this._alertService=this._alertsDispatcher?new undefined(this._alertsDispatcher,this._getDataSourceHub):null,this._activeChangedChangedDelegate=new S,this._chartWidgetCollection.activeChartWidget.subscribe(function(){this._activeChangedChangedDelegate.fire()}.bind(this)),this.linking=s}subscribe(e,t){r.subscribe(e,t)}unsubscribe(e,t){r.unsubscribe(e,t)}onContextMenu(e){r.subscribe("onContextMenu",(function(t){t.callback(e(t.unixtime,t.price))}))}onGrayedObjectClicked(e){r.subscribe("onGrayedObjectClicked",e)}onActiveChartChanged(){return this._activeChangedChangedDelegate}changeSymbol(e,t,i){s.interval.setValue(_.normalize(t)),s.symbol.setValue(e),i&&this.activeChart().onDataLoaded().subscribe(null,i,!0)}viewMode(){throw new Error("not implemented")}viewModeWatchedValue(){throw new Error("not implemented")}getSymbolInterval(e){var t={symbol:s.symbol.value(),interval:s.interval.value()};return e&&e(t),t}saveChart(e){if(this._saveChartService){var t=this._saveChartService.saveToJSON();return e&&e(JSON.parse(t.content))}}loadChart(e){this._chartApiInstance.disconnect(),this._chartWidgetCollection.loadContent(e.json),this._chartWidgetCollection.purgeUnusedWidgets(),e.extendedData&&(this._chartWidgetCollection.metaInfo.id.setValue(e.extendedData.uid),this._chartWidgetCollection.metaInfo.uid.setValue(e.extendedData.uid),this._chartWidgetCollection.metaInfo.name.setValue(e.extendedData.name)),this._chartApiInstance.connect(),s.symbol.setValue(this.activeChart().symbol()),r.emit("chart_loaded")}getStudiesList(){return this._chartApiInstance.allStudiesMetadata().filter((function(e){return!e.is_hidden_study})).map((function(e){return e.description}))}getStudyInputs(e){{const t=g.findStudyMetaInfoByDescription(this._chartApiInstance.allStudiesMetadata(),e);return f(t)}}getStudyStyles(e){{const t=g.findStudyMetaInfoByDescription(this._chartApiInstance.allStudiesMetadata(),e);return v(t)}}getSavedCharts(e){l.getCharts().then(e)}loadChartFromServer(e){l.loadChart(e)}saveChartToServer(e,t,i){this._saveChartService&&this._saveChartService.saveChartSilently(e,t,i)}setAutosave(e){this._saveChartService&&this._saveChartService.autoSaveEnabled().setValue(e)}removeChartFromServer(e,t){l.removeChart(e).then(t)}getIntervals(){var e=[],t=a.getCustomResolutions() +;return null!==this._chartApiInstance&&(e=this._chartApiInstance.defaultResolutions()),a.mergeResolutions(e,t)}closePopupsAndDialogs(){n.hideAll(),r.emit(p)}selectedLineTool(){for(var e=Object.keys(u.supportedLineTools),t=o.tool.value(),i=0;i{"use strict";i.d(t,{WatermarkApi:()=>o});var s=i(50151),r=i(63821),n=i(65632);class o{constructor(){this._widgets=null,this._provider=null,this._watermarkProperties=(0,n.watermarkProperty)();const e=(0,s.ensureDefined)(this._watermarkProperties.child("color")),t=(0,s.ensureDefined)(this._watermarkProperties.child("visibility"));this._colorWatchedValue=(0,r.convertPropertyToWatchedValue)(e),this._visibilityWatchedValue=(0,r.convertPropertyToWatchedValue)(t)}setWidgetCollection(e){this._widgets=e}setContentProvider(e){this._provider=e,this._widgets&&this._widgets.getAll().forEach((e=>{e.model().model().lightUpdate()}))}provider(){return this._provider}ready(){return null!==this._widgets}destroy(){this._colorWatchedValue.destroy(),this._visibilityWatchedValue.destroy()}visibility(){return this._visibilityWatchedValue}color(){return this._colorWatchedValue}static getInstance(){return null===this._instance&&(this._instance=new o),this._instance}}o._instance=null},11095:(e,t,i)=>{"use strict";i.d(t,{addPlusButtonProperty:()=>_,restoreAddPlusButtonSettingsValue:()=>m,showPlusButtonOnCursor:()=>d});var s=i(4741),r=i(14483),n=i(56840),o=i(59680),a=i(97145);const l="add_plus_button";function c(){const e=s.keyboardPressedKeysState.value();return void 0!==e&&(Boolean(e.modifiers&s.Modifiers.Alt&&e.modifiers&s.Modifiers.Mod)&&(void 0===e.code||e.altOrOptionCode()||e.controlOrMetaCode()))}const h=new a.WatchedValue(c());s.keyboardPressedKeysState.subscribe((()=>h.setValue(c())));const d=h.readonly();function u(){return r.enabled("chart_crosshair_menu")}function p(){return n.getBool(l,u())}const _=(0,o.createPrimitiveProperty)(p());function m(){_.setValue(u()),n.remove(l)}n.onSync.subscribe(null,(()=>_.setValue(p()))),_.subscribe(null,(()=>{n.setValue(l,_.value()),r.setEnabled("chart_crosshair_menu",!r.enabled("chart_crosshair_menu"))}))},83654:(e,t,i)=>{"use strict";i.d(t,{alignToStep:()=>n});var s=i(60521),r=i.n(s);function n(e,t){return r()(e).div(t).round(0,r().roundHalfUp).mul(t).toNumber()}},28640:(e,t,i)=>{"use strict";i.d(t,{AppliedTimeFrame:()=>r});var s=i(83669) +;class r{constructor(e){this._appliedTimeFrame=new s.WatchedObject(null),this._appliedTimeFrameInfo=null,this._appliedTimeFrameChangedBound=this._appliedTimeFrameChanged.bind(this),this._model=e,e.mainSeries().dataEvents().seriesTimeFrame().subscribe(this,this._onSeriesTimeFrame),this._appliedTimeFrame.subscribe(this._appliedTimeFrameChangedBound)}destroy(){this._appliedTimeFrame.unsubscribe(this._appliedTimeFrameChangedBound),this._model.timeScale().logicalRangeChanged().unsubscribeAll(this),this._model.mainSeries().dataEvents().seriesTimeFrame().unsubscribeAll(this)}appliedTimeFrame(){return this._appliedTimeFrame}_appliedTimeFrameChanged(){this._model.timeScale().logicalRangeChanged().unsubscribe(this,this._invalidateAppliedTimeFrame)}_onSeriesTimeFrame(e,t,i,s){if(s){const e=this._model.timeScale();this._appliedTimeFrameInfo={logicalRange:e.logicalRange(),baseIndex:e.baseIndex()},e.logicalRangeChanged().subscribe(this,this._invalidateAppliedTimeFrame)}}_invalidateAppliedTimeFrame(){if(null===this._appliedTimeFrameInfo)return;const e=this._model.timeScale(),t=e.logicalRange(),i=e.baseIndex(),s=this._appliedTimeFrameInfo.logicalRange,r=this._appliedTimeFrameInfo.baseIndex;(null===t||null===s||Math.abs(i-t.left()-(r-s.left()))>=.01||Math.abs(i-t.right()-(r-s.right()))>=.01)&&this._appliedTimeFrame.setValue(null)}}},12416:(e,t,i)=>{"use strict";i.d(t,{defaultsPreferencesByWhiteList:()=>x,preferencesByWhiteList:()=>C});var s=i(1722),r=i(67980),n=i(62615),o=i(59224),a=i(74304),l=i(85804),c=i(16776),h=i(30888),d=i(93613);const u=(0,o.getLogger)("Chart.ApplyPreferencesToAllCharts"),p={color:"",style:0},_={autoScale:!1,autoScaleDisabled:!1,lockScale:!1,percentage:!1,percentageDisabled:!1,log:!1,logDisabled:!1,alignLabels:!1,isInverted:!1,indexedTo100:!1},m={backgroundType:d.ColorType.Solid,background:"",backgroundGradientStartColor:"",backgroundGradientEndColor:"",topMargin:0,bottomMargin:0,rightOffset:0,gridLinesMode:"both",horzGridProperties:(0,h.deepExtend)({},p),vertGridProperties:(0,h.deepExtend)({},p),crossHairProperties:(0,h.deepExtend)({},{color:"",style:0,transparency:0,width:0}),legendProperties:(0,h.deepExtend)({},{showStudyArguments:!1,showStudyTitles:!1,showStudyValues:!1,showSeriesTitle:!1,showSeriesOHLC:!1,showLegend:!1,showBarChange:!0,showVolume:!1,showPriceSource:!1,showBackground:!0,backgroundTransparency:0,showLogo:!0}),axisProperties:(0,h.deepExtend)({},_),separatorColor:""},g={lineColor:"",textColor:"",fontSize:0,scaleSeriesOnly:!1,showSeriesLastValue:!1,seriesLastValueMode:a.PriceAxisLastValueMode.LastValueAccordingToScale,showSeriesPrevCloseValue:!1,showStudyLastValue:!1,showSymbolLabels:!1,showStudyPlotLabels:!1,showBidAskLabels:!1,showPrePostMarketPriceLabel:!0,showFundamentalLastValue:!1,showFundamentalNameLabel:!1,showPriceScaleCrosshairLabel:!0,showTimeScaleCrosshairLabel:!0},f={...g},v={visible:!1,futureOnly:!1,breaks:(0,h.deepExtend)({},{color:"",visible:!1,style:0,width:0})},S={style:0,minTick:"",showPriceLine:!1,priceLineWidth:0,priceLineColor:"",baseLineColor:"",showPrevClosePriceLine:!1, +showCountdown:!0,prevClosePriceLineWidth:0,sessionId:"regular",prevClosePriceLineColor:"",esdShowDividends:!1,esdShowSplits:!1,esdShowEarnings:!1,esdShowBreaks:!1,showContinuousContractSwitches:!1,showContinuousContractSwitchesBreaks:!1,showFuturesContractExpiration:!1,showLastNews:!1,dividendsAdjustment:!1,backAdjustment:!1,settlementAsClose:!0,statusViewStyle:(0,h.deepExtend)({},{fontSize:16,showExchange:!0,showInterval:!0,symbolTextSource:"description"}),priceAxisProperties:(0,h.deepExtend)({},_),highLowAvgPrice:(0,h.deepExtend)({},{highLowPriceLinesVisible:!1,highLowPriceLabelsVisible:!1,averageClosePriceLabelVisible:!1,averageClosePriceLineVisible:!1,highLowPriceLinesColor:"",highLowPriceLinesWidth:0,averagePriceLineColor:"",averagePriceLineWidth:0}),candleStyle:(0,h.deepExtend)({},n.candleStylePreferencesDefault),hollowCandleStyle:(0,h.deepExtend)({},n.hollowCandlePreferencesStyleDefault),barStyle:(0,h.deepExtend)({},n.barStylePreferencesDefault),lineStyle:(0,h.deepExtend)({},n.lineStyleDefault),lineWithMarkersStyle:(0,h.deepExtend)({},n.lineStyleDefault),steplineStyle:(0,h.deepExtend)({},n.lineStyleDefault),areaStyle:(0,h.deepExtend)({},n.areaStylePreferencesDefault),hlcAreaStyle:(0,h.deepExtend)({},n.hlcAreaStylePreferencesDefault),baselineStyle:(0,h.deepExtend)({},n.baselineStylePreferencesDefault),hiloStyle:(0,h.deepExtend)({},n.hiloStylePreferencesDefault),haStyle:(0,h.deepExtend)({},n.haStylePreferencesDefault),renkoStyle:(0,h.deepExtend)({},n.renkoStylePreferencesDefault),pbStyle:(0,h.deepExtend)({},n.pbStylePreferencesDefault),kagiStyle:(0,h.deepExtend)({},n.kagiStylePreferencesDefault),pnfStyle:(0,h.deepExtend)({},n.pnfStylePreferencesDefault),rangeStyle:(0,h.deepExtend)({},n.rangeStylePreferencesDefault),columnStyle:(0,h.deepExtend)({},n.columnStylePreferencesDefault)},y={priceScaleSelectionStrategyName:"auto",timeScale:(0,h.deepExtend)({},{defaultRightOffset:0,defaultRightOffsetPercentage:5,usePercentageRightOffset:!1}),mainSeries:(0,h.deepExtend)({},S),sessions:(0,h.deepExtend)({},c.sessionsPreferencesDefault),paneProperties:(0,h.deepExtend)({},m),chartEventsSourceProperties:(0,h.deepExtend)({},v),tradingProperties:(0,h.deepExtend)({},r.tradingPreferencesDefault)},b={timezone:"",scalesProperties:(0,h.deepExtend)({},f),...y},w={scalesProperties:(0,h.deepExtend)({},g),...y};function P(e,t,i,r,n=!0){if(void 0===t[e])return u.logDebug(`We haven't had this property ${r}.${e} yet, please, remove it from whiteList`),null;if((0,s.isObject)(i[e])){const s=Object.keys(i[e]);let o="";return s.map((s=>({[s]:P(s,t[e],i[e],`${r}.${e}`,n)}))).reduce(((e,t)=>(o=Object.keys(t)[0],e[o]=t[o],e)),{})}return n?t[e].value():t[e]}function C(e,t,i=b){const s={timezone:"",priceScaleSelectionStrategyName:"auto",timeScale:{defaultRightOffset:e.timeScale().defaultRightOffset().value(),defaultRightOffsetPercentage:e.timeScale().defaultRightOffsetPercentage().value(),usePercentageRightOffset:e.timeScale().usePercentageRightOffset().value()},mainSeries:{},sessions:{},paneProperties:{},scalesProperties:{}, +chartEventsSourceProperties:{},tradingProperties:{}},r=["timeScale","mainSeries","sessions"],n=i.mainSeries,o=Object.keys(i),a=Object.keys(n),l=t.properties(),c=e.properties(),h=i.sessions,d=Object.keys(h),u=e.sessions().properties();return a.forEach((e=>{s.mainSeries[e]=P(e,l,n,"mainSeries")})),d.forEach((e=>{s.sessions[e]=P(e,u,h,"sessions")})),o.forEach((e=>{r.includes(e)||(s[e]=P(e,c,i,"preferences"))})),s}function x(e,t,i=w,s=!0){const r={timeScale:{defaultRightOffset:e.timeScale().rightOffsetDefaultValue(),defaultRightOffsetPercentage:e.timeScale().defaultRightOffsetPercentage().value(),usePercentageRightOffset:e.timeScale().usePercentageRightOffset().value()},mainSeries:{},sessions:(0,h.deepExtend)({},c.sessionsPreferencesDefault),paneProperties:{},scalesProperties:{},chartEventsSourceProperties:{},tradingProperties:{},priceScaleSelectionStrategyName:"auto"},n=["timeScale","mainSeries","sessions"],o=i.mainSeries,a=Object.keys(i),d=Object.keys(o),u=(0,l.factoryDefaults)("chartproperties.mainSeriesProperties"),p=(0,l.factoryDefaults)("chartproperties");return d.forEach((e=>{s&&"style"===e||(r.mainSeries[e]=P(e,u,o,"mainSeries",!1))})),a.forEach((e=>{n.includes(e)||(r[e]=P(e,p,i,"preferences",!1))})),r}},39875:(e,t,i)=>{"use strict";i.d(t,{autoLogButtonsVisibilityOptions:()=>n,autoLogButtonsVisibilityProperty:()=>r,restoreAutoLogButtonsVisibilitySettingsValue:()=>o});var s=i(29542);const{property:r,availableValues:n,restoreDefaultValue:o}=(0,s.createVisibilityController)("PriceAxisAutoLogButtons.visibility")},81580:(e,t,i)=>{"use strict";i.d(t,{axisLabelBackgroundColor:()=>r});var s=i(48891);const r={common:s.colorsPalette["color-tv-blue-500"],active:s.colorsPalette["color-tv-blue-800"]}},77475:(e,t,i)=>{"use strict";i.d(t,{createDwmAligner:()=>c,createTimeToBarTimeAligner:()=>d,isAlignmentEnabled:()=>h});var s=i(41249),r=i(14483),n=i(36274),o=i(98829),a=i(60156);const l=new o.SessionInfo("Etc/UTC","0000-0000:1234567");function c(e,t){if(!h()||!n.Interval.isDWM(e))return null;const i=new o.SessionInfo(t.timezone,t.session,t.session_holidays,t.corrections),r=(0,a.newBarBuilder)(e,i,l);return{timeToSessionStart:e=>r.tradingDayToSessionStart(e),timeToExchangeTradingDay:e=>{const t=s.utc_to_cal(i.timezone,e),r=i.spec.correctTradingDay(t);return s.set_hms(r,0,0,0,0,s.get_timezone("Etc/UTC")),r.getTime()}}}function h(){return!r.enabled("disable_resolution_rebuild")}function d(e,t){if(!h())return e=>e;const i=new o.SessionInfo(t.timezone,t.session,t.session_holidays,t.corrections),s=(0,a.newBarBuilder)(e,i,i,!1);return e=>s.alignTimeIfPossible(e)}},98829:(e,t,i)=>{"use strict";i.d(t,{BarBuilderBase:()=>a,SessionInfo:()=>o});var s=i(41249),r=i(60062),n=i(32923);class o{constructor(e,t,i,s){this.init(e,t,i,s),this._state={timezone:e,spec:t,holidays:i,corrections:s}}init(e,t,i,r){this.timezone=s.get_timezone(e),this.spec=new n.SessionSpec(e,t,i,r)}state(){return this._state}static fromState(e){return new o(e.timezone,e.spec,e.holidays,e.corrections)}}class a{alignTime(e){if(isNaN(e))return NaN;let t=this.indexOfBar(e) +;return t===r.SessionStage.POST_SESSION&&(this.moveTo(e),t=this.indexOfBar(e)),t<0?NaN:this.startOfBar(t)}}},60156:(e,t,i)=>{"use strict";i.r(t),i.d(t,{SessionInfo:()=>o.SessionInfo,alignExchangeTimeToSessionStartAndReturnUTC:()=>C,alignPeriodsBackForDataRequest:()=>y,alignPeriodsBackForVisibleRange:()=>b,getPeriodsBetweenDates:()=>P,isTradingNow:()=>x,newBarBuilder:()=>S});var s=i(41249),r=i(36274),n=i(37160),o=i(98829),a=i(60062);class l extends o.BarBuilderBase{constructor(e,t){super(),this._sessionStartMs=-Number.MAX_VALUE,this._sessionEndMs=-Number.MAX_VALUE,this._periodSec=e,this._session=t}alignTimeIfPossible(e){const t=this.alignTime(e);return isNaN(t)?e:t}indexOfBar(e){return e=this._sessionEndMs?a.SessionStage.POST_SESSION:(0,n.toInt)(s.time_seconds_diff(e,this._sessionStartMs)/this._periodSec)}startOfBar(e){if(e===a.SessionStage.PRE_SESSION){const e=s.get_cal_from_unix_timestamp_ms(this._session.timezone,this._sessionStartMs-1),t=this._session.spec.alignToNearestSessionEnd(e,-1);return s.cal_to_utc(this._session.timezone,t)}if(e===a.SessionStage.POST_SESSION)return this._sessionEndMs;if(e<0)throw new Error("Negative offset is not supported");return this._sessionStartMs+s.time_seconds(this._periodSec*e)}endOfBar(e){if(e<0)throw new Error("Index cannot be negative");const t=this.startOfBar(e)+1e3*this._periodSec;return t>this._sessionEndMs?this._sessionEndMs:t}isLastBar(e,t){return t>=this._sessionStartMs+s.time_seconds(this._periodSec*(e+1)-1)}moveTo(e){const t=this._session.timezone,i=s.utc_to_cal(t,e),r=this._session.spec.alignToSessionStart(i);this._sessionStartMs=s.cal_to_utc(t,i),s.add_minutes(i,r),this._sessionEndMs=s.cal_to_utc(t,i)}indexOfLastBarInSession(){return(0,n.toInt)((this._sessionEndMs-1-this._sessionStartMs)/1e3/this._periodSec)}moveNext(){this.moveTo(this._sessionEndMs)}}var c=i(54606);function h(e,t){const i=s.clone(t),r=e.businessDaysToCalendarDays(i,1);r>1&&s.add_date(i,r-1);const n=e.leftBorderOfDailyBar(i);if(null===n)throw new Error("Cannot calculate left border of daily bar");return s.cal_to_utc(s.get_timezone(e.timezone()),n)}class d extends o.BarBuilderBase{constructor(e,t,i,s,r=!1){super(),this._periodStart=-Number.MAX_VALUE,this._periodEnd=-Number.MAX_VALUE,this._periodLastBarStart=-Number.MAX_VALUE,this._periodStartDay=new c.BusinessDay(0,0,0),this._periodEndDay=new c.BusinessDay(0,0,0),this._period=i,this._sessionTgt=e,this._builder=s,this._useBusinessDays=r,this._sessionSrc=r?new o.SessionInfo("Etc/UTC","24x7"):t||e}builder(){return this._builder}alignTimeIfPossible(e){return this.tradingDayToSessionStart(e)}tradingDayToSessionStart(e){return this.moveTo(e),this.startOfBar(0)}indexOfBar(e){if(this._useBusinessDays){const t=c.BusinessDay.fromCalendar(s.get_cal_from_unix_timestamp_ms(this._sessionSrc.timezone,e));return t.before(this._periodStartDay)?a.SessionStage.PRE_SESSION:this._periodEndDay.before(t)?a.SessionStage.POST_SESSION:0} +return e=this._periodEnd?a.SessionStage.POST_SESSION:0}startOfBar(e){if(e===a.SessionStage.PRE_SESSION){const e=s.get_cal_from_unix_timestamp_ms(this._sessionTgt.timezone,this._periodStart-1),t=this._sessionTgt.spec.alignToNearestSessionEnd(e,-1);return s.cal_to_utc(this._sessionTgt.timezone,t)-1}return e===a.SessionStage.POST_SESSION||e>0?this._periodEnd:e===a.SessionStage.LASTBAR_SESSION?this._periodLastBarStart:this._periodStart}moveTo(e){const t=s.get_cal_from_unix_timestamp_ms(this._sessionSrc.timezone,e);this._sessionSrc.spec.correctTradingDay(t);const i=s.get_year(t),r=this._indexOfPeriodInYear(t),n=r+this._period,o=this._sessionTgt.spec,a=this._sessionTgt.timezone,l=this._builder.startOfPeriod(a,r,i);this._periodStart=h(o,l);const d=s.clone(l),u=o.businessDaysToCalendarDays(d,1);u>1&&s.add_date(d,u-1),this._periodStartDay=c.BusinessDay.fromCalendar(d);const p=this._builder.startOfPeriod(a,n,i);this._periodEnd=h(o,p);const _=s.clone(p);for(s.add_date(_,-1);o.isCalWeekEnd(_);)s.add_date(_,-1);this._periodEndDay=c.BusinessDay.fromCalendar(_),s.add_date(p,-1),function(e,t){for(;e.isCalWeekEnd(t);)s.add_date(t,-1)}(this._sessionTgt.spec,p),this._periodLastBarStart=h(o,p),(this._periodLastBarStart=this._periodLastBarStart}currentRange(){return{from:this._periodStartDay,to:this._periodEndDay}}indexOfBarInYear(e){const t=s.get_cal_from_unix_timestamp_ms(this._sessionSrc.timezone,e),i=s.get_year(t),r=this._builder.indexOfPeriod(t),o=this._sessionTgt.timezone;let a=this._builder.startOfPeriod(o,r,i),l=h(this._sessionTgt.spec,a);return a=s.get_cal_from_unix_timestamp_ms(s.get_timezone("Etc/UTC"),l),i=0&&(r-=7),(0,n.toInt)((r+i)/7))}class _{indexOfPeriod(e){return s.get_day_of_year(e)-1}startOfPeriod(e,t,i){const r=s.days_per_year(i);return s.get_cal(s.get_timezone("Etc/UTC"),i,s.JANUARY,1+Math.min(t,r))}}class m extends _{constructor(e){super(),this._sessionsSpec=e}indexOfPeriod(e){return super.indexOfPeriod(e)-function(e,t){const i=p(e,t),r=s.get_cal(s.get_timezone("Etc/UTC"),s.get_year(t),s.JANUARY,1);s.add_date(r,7*i);const n=i*e.weekEndsCount()+e.holidaysFromYearStart(r),o=s.get_day_of_year(t)-s.get_day_of_year(r);return n+o-e.calendarDaysToBusinessDays(r,o)}(this._sessionsSpec,e)} +startOfPeriod(e,t,i){const r=7-this._sessionsSpec.weekEndsCount(),o=Math.max(0,(0,n.toInt)(t/r)-1),a=s.get_cal(s.get_timezone("Etc/UTC"),i,s.JANUARY,1),l=s.get_days_per_year(a);if(s.add_date(a,7*o),(t-=r*o-this._sessionsSpec.holidaysFromYearStart(a))>0){const e=this._sessionsSpec.businessDaysToCalendarDays(a,t);s.add_date(a,e)}let c=s.get_day_of_year(a)-1;return is.get_days_per_year(r)?this.startOfPeriod(e,0,i+1):(s.add_date(r,a),r)}}class v{indexOfPeriod(e){return s.get_month(e)}startOfPeriod(e,t,i){if(t<0){const e=(0,n.toInt)((11-t)/12);i-=e,t+=12*e}else t>s.DECEMBER&&(i++,t=s.JANUARY);return s.get_cal(s.get_timezone("Etc/UTC"),i,t,1)}}function S(e,t,i,s=!1){const n=r.Interval.parse(e),o=n.multiplier();return n.isMinutes()?new l(60*o,t):n.isSeconds()?new l(o,t):n.isTicks()?new l(1,t):n.isRange()?new l(60*o,t):new d(t,i,o,function(e,t){switch(e){case r.ResolutionKind.Days:return new g(t);case r.ResolutionKind.Weeks:return new f(t);case r.ResolutionKind.Months:return new v}throw new Error(`Unknown dwm resolution: ${e}`)}(n.kind(),t),s)}function y(e,t,i,s,r,n,o){return w(e,t,i,s,r,n,o,0)}function b(e,t,i,s,r,n,o){return w(e,t,i,s,r,n,o,1)}function w(e,t,i,s,n,a,l,c){const h=r.Interval.parse(n+s);if(h.isMonths()){const e=new Date(l);return 0===c&&e.setUTCDate(1),function(e,t){T(e,Math.floor(t/12));let i=e.getUTCMonth()-t%12;i<0&&(T(e,1),i+=12);e.setUTCMonth(i);for(;e.getUTCMonth()!==i;)I(e,1)}(e,a*h.multiplier()),e.getTime()}const d=new o.SessionInfo("Etc/UTC",e,t,i),u=h.inMilliseconds(),p=h.isDWM();let _;_=p?864e5:60*d.spec.maxTradingDayLength()*1e3;let m=0;m=h.isWeeks()?7:7-d.spec.weekEndsCount();const g=_/u,f=m*g;let v;if(a=g&&(f=_/6048e5*g);return f%1<=Number.EPSILON*Math.ceil(f)?Math.round(f):Math.ceil(f)}function C(e,t){const i=s.clone(t);return e.alignToSessionStart(i),s.cal_to_utc(s.get_timezone(e.timezone()),i)}function x(e,t){const i=s.utc_to_cal(t.timezone,+e);let r=s.get_day_of_week(i),n=s.get_minutes_from_midnight(i);const o=t.spec.findSession(t.spec.getWeekIndex(i),r,n).getEntry();return o.isOvernight()&&n>o.startOffset()+o.length()&&r===o.dayOfWeek()-1&&(r++,n-=1440),r===o.dayOfWeek()&&n>=o.startOffset()&&n{"use strict";i.d(t,{BusinessDay:()=>r});var s=i(41249);class r{constructor(e,t,i){this.year=e,this.month=t,this.day=i}toString(){return`${this.year}-${this.month}-${this.day}`}compareTo(e){return this.year>e.year||this.year===e.year&&this.month>e.month||this.year===e.year&&this.month===e.month&&this.day>e.day?1:this.year===e.year&&this.month===e.month&&this.day===e.day?0:-1}before(e){return-1===this.compareTo(e)}toCalendar(e){return s.get_cal(s.get_timezone("Etc/UTC"),this.year,this.month-1,this.day)}addDays(e){const t=this.toCalendar(s.get_timezone("Etc/UTC"));return s.add_date(t,e),r.fromCalendar(t)}static fromCalendar(e){return new r(s.get_year(e),s.get_month(e)+1,s.get_day_of_month(e))}}},60062:(e,t,i)=>{"use strict";var s;i.d(t,{SessionStage:()=>s}),function(e){e[e.PRE_SESSION=-1]="PRE_SESSION",e[e.POST_SESSION=-2]="POST_SESSION",e[e.LASTBAR_SESSION=-3]="LASTBAR_SESSION"}(s||(s={}))},94421:(e,t,i)=>{"use strict";i.d(t,{extrapolateBarsFrontByCount:()=>n,extrapolateBarsFrontToTime:()=>r});var s=i(60062);function r(e,t,i,s,n=!1){if(t>i){const o=r(e,i,t,s,n);return o.count=-o.count,o}return o(e,t,1,((e,t)=>t>i||0!==s&&e>s),n)}function n(e,t,i,s=!1){const r=i<0?-1:1;return o(e,t,r,((e,t)=>e>=i*r),s)}function o(e,t,i,r,n){let o=0,a=t;e.moveTo(a);let l=0,c=Number.MAX_VALUE,h=!1,d=t;const u=[];for(;!r(o,a);){if(l>15)throw new Error("Internal error 0x10 while extrapolating.");const r=e.indexOfBar(a);if(r===s.SessionStage.PRE_SESSION&&1===i)a=e.startOfBar(0),e.moveTo(a);else if(r===s.SessionStage.PRE_SESSION&&-1===i)a=e.startOfBar(s.SessionStage.PRE_SESSION),e.moveTo(a);else if(r===s.SessionStage.POST_SESSION&&1===i)a=e.startOfBar(s.SessionStage.POST_SESSION),e.moveTo(a);else{if(r===s.SessionStage.POST_SESSION&&-1===i)throw new Error("Internal error 0x12 while extrapolating.");{const p=e.startOfBar(r);if(p>t&&i>0||t>p&&i<0){if(h&&c===p)throw new Error("Internal error 0x11 while extrapolating.");h=!0,c=p,l=0,o++,d=p,n&&u.push(d)}if(0===r&&-1===i)a=p-1;else{a=e.startOfBar(r+i);const t=e.startOfBar(s.SessionStage.POST_SESSION);a>t&&(e.moveTo(t),a=e.startOfBar(0))}}}l++}return{time:d,times:u,count:o}}},32923:(e,t,i)=>{"use strict";i.d(t,{SessionSpec:()=>v});var s=i(41249),r=i(78071),n=i(54606);function o(e,t){return e.compareTo(t)}class a{constructor(e,t,i){this._dayOfWeek=e,this._start=t, +this._length=i}start(){return this._start+s.minutesPerDay*this.sessionStartDaysOffset()}startOffset(){return this._start}sessionStartDaysOffset(){return this._start>=0?0:this._start%s.minutesPerDay==0?-Math.ceil(this._start/s.minutesPerDay):-Math.floor(this._start/s.minutesPerDay)}sessionEndDaysOffset(){const e=this._start+this._length;return e>=0?0:e%s.minutesPerDay==0?-Math.ceil(e/s.minutesPerDay):-Math.floor(e/s.minutesPerDay)}isOvernight(){return this._start<0}dayOfWeek(){return this._dayOfWeek}sessionStartDayOfWeek(){let e=this._dayOfWeek-this.sessionStartDaysOffset();return es.SATURDAY&&(e=1),e}length(){return this._length}weight(){return this._dayOfWeek*s.minutesPerDay+this._start}compareTo(e){const t=this.weight(),i=t+this._length,s=e.weight(),r=s+e._length;return t<=s&&ss?1:-1}contains(e){const t=60*s.get_hours(e)+s.get_minutes(e);let i=s.get_day_of_week(e)-this._dayOfWeek;i>0&&(i-=7);const r=i*s.minutesPerDay+t;return r>=this._start&&r=48&&e<=57}class _{constructor(){this.entries=[],this.firstDayOfWeek=s.MONDAY,this.weekEndsCount=-1,this.maxTradingDayLength=0}parseSessions(e,t){var i;let s=!1;this._clear(),this.timezone=e;const{hasErrors:r,spec:n}=this._parseFirstDayOfWeek(t);if("24x7"===n.toLowerCase())for(const e of d)this.entries.push(_._createSessionEntry(e,0,0,0,0));else{let e=!1;const t=new Map;for(const i of n.split("|")){const r=i.split(":");if(1!==r.length&&2!==r.length){s=!0,u.logError(`Bad session section: ${i}`);continue}const n=1===r.length;if(n){if(e){s=!0,u.logError(`Duplicated default section: ${i}`);continue}e=!0}const o=n?h:_._parseWorkingDays(r[1]);for(const e of o)n&&t.has(e)||t.set(e,r[0])}for(const e of d){const i=t.get(e);if(void 0!==i)for(const t of i.split(",")){const{hasErrors:i,sessionEntry:r}=_._parseSessionEntry(e,t);i&&(s=i),this.entries.push(r)}}}this.entries.sort(o);const a=new Map;for(const e of this.entries){const t=e.dayOfWeek();a.set(t,e.length()+(null!==(i=a.get(t))&&void 0!==i?i:0))}return this.maxTradingDayLength=0,a.forEach((e=>{this.maxTradingDayLength=Math.max(this.maxTradingDayLength,e)})),this.weekEndsCount=7-a.size,s||r}static parseHolidaysAndCorrections(e,t,i){const r=new Map,n=new Map,o=e=>{const t=this._parseDay(e),i=t.toString(),s=n.get(i);return void 0!==s?s:(n.set(i,t),t)};if(""!==t){const e=[];for(const i of t.split(",")){if(8!==i.length)throw new Error(`bad holiday date: ${i}`);const t=o(i);r.set(t,e)}}if(""===i)return r;const l=s.get_timezone("Etc/UTC");for(const e of i.split(";")){const t=e.split(":") +;if(2!==t.length)throw new Error(`bad correction section: ${e}`);const i=[];if("dayoff"!==t[0])for(const e of t[0].split(","))i.push(this._parseSessionEntry(1,e).sessionEntry);for(const e of t[1].split(",")){if(8!==e.length)throw new Error(`bad correction date: ${e}`);const t=o(e),n=s.get_day_of_week(s.get_cal(l,t.year,t.month-1,t.day)),c=[];for(const e of i)c.push(new a(n,e.startOffset(),e.length()));r.set(t,c)}}return r}_clear(){this.entries=[],this.timezone="",this.firstDayOfWeek=s.MONDAY,this.weekEndsCount=-1}_parseFirstDayOfWeek(e){const t=e.split(";");if(t.length>2)return u.logError(`Only one \`first day\` specification expected @ session ${e}`),{hasErrors:!0,spec:e};if(1===t.length)return{hasErrors:!1,spec:e};let i=1;let r=t[0].indexOf("-")>=0?NaN:parseInt(t[0]);return isNaN(r)&&(i=0,r=parseInt(t[1])),rs.SATURDAY?(u.logError(`Unexpected day index @ session: ${e}; day index ${r}`),{hasErrors:!0,spec:e}):(this.firstDayOfWeek=r,{hasErrors:!1,spec:t[i]})}static _parseDay(e){const t=parseInt(e.substring(0,4)),i=parseInt(e.substring(4,6)),s=parseInt(e.substring(6,8));return new n.BusinessDay(t,i,s)}static _parseSessionEntry(e,t){let i=!1,s=t.split("-");2!==s.length&&(i=!0,u.logError(`Bad sessions entry: ${t}`),s=["0000","0000"]);let r=0,n=s[0];if(n.includes("F")){const e=n.split("F");n=e[0],r=""!==e[1]?parseInt(e[1]):1}let o=0,a=s[1];if(a.includes("F")){const e=a.split("F");a=e[0],o=""!==e[1]?parseInt(e[1]):1}if(!this._isCorrectSession(n)||!this._isCorrectSession(a))throw new Error(`Incorrect entry syntax: ${t}`);const l=n,c=a;return{hasErrors:i,sessionEntry:this._createSessionEntry(e,_._minutesFromHHMM(l),_._minutesFromHHMM(c),r,o)}}static _isCorrectSession(e){return 4===e.length&&p(e.charCodeAt(0))&&p(e.charCodeAt(1))&&p(e.charCodeAt(2))&&p(e.charCodeAt(3))}static _parseWorkingDays(e){const t=[];for(let i=0;i0&&(t-=r*s.minutesPerDay),n>0&&(i-=n*s.minutesPerDay);return new a(e,t,i-t)}}function m(e,t){return e.compareTo(t)<0}function g(e,t){const i=(0,r.lowerbound)(e,t,((e,t)=>-1===e.day.compareTo(t)));return i===e.length?null:e[i]}const f=621672192e5;class v{constructor(e="Etc/UTC",t="0000-0000",i="",r=""){this._entries=[],this._firstDayOfWeek=s.MONDAY,this._entriesHash=new Map,this._holidayAndCorrectionMap=new Map,this._holidaySessions=[];const n=new _;n.parseSessions(e,t),this._entries=n.entries,this._timezone=n.timezone,this._spec=t,this._firstDayOfWeek=n.firstDayOfWeek,this._weekEndsCount=n.weekEndsCount,this._maxTradingDayLength=n.maxTradingDayLength;const o=_.parseHolidaysAndCorrections(e,i,r),a=s.get_timezone(e);this._isThereCorrections=""!==i||""!==r,o.forEach(((e,t)=>{this._holidayAndCorrectionMap.set(t.toString(),e),this._holidaySessions.push({day:t,sessions:e});const i=this.getWeekIndex(t.toCalendar(a));this._entriesHash.set(i,null)})), +this._holidaySessions.sort(((e,t)=>e.day.compareTo(t.day)))}entries(){return this._entries}timezone(){return this._timezone}spec(){return this._spec}firstDayOfWeek(){return this._firstDayOfWeek}addSessionEntry(e,t,i,r,n){0===i&&(i=s.minutesPerDay),r===n&&i<=t&&(r+=1),r>0&&(t-=r*s.minutesPerDay),n>0&&(i-=n*s.minutesPerDay);const o=i-t;this._entries.push(new a(e,t,o))}longestSessionLength(){let e=0,t=0;for(const t of this._holidaySessions)t.sessions.forEach((t=>{e=Math.max(e,t.length())}));return this._entries.forEach((e=>{t=Math.max(t,e.length())})),Math.max(e,t)}isWeekEnd(e){const t=(0,r.lowerbound)(this._entries,new a(e,0,0),((e,t)=>e.dayOfWeek()this._entries.length-1||this._entries[t].dayOfWeek()!==e}isCalWeekEnd(e){const t=s.get_day_of_week(e);if(!this._isThereCorrections)return this.isWeekEnd(t);const i=n.BusinessDay.fromCalendar(e),r=this._holidayAndCorrectionMap.get(i.toString());return void 0===r?this.isWeekEnd(t):0===r.length}hasWeekEnds(){return this.weekEndsCount()>0}weekEndsCount(){return this._weekEndsCount}maxTradingDayLength(){return this._maxTradingDayLength}holidaysFromYearStart(e){if(!this._isThereCorrections)return 0;const t=s.get_timezone(this._timezone),i=new n.BusinessDay(s.get_year(e),s.JANUARY,1),r=n.BusinessDay.fromCalendar(e);let o=0;const a=this._selectHolidays(i,r);for(let e=0;et.start()%e==0&&t.length()%e==0))}indexOfSession(e,t,i){const n=this._getEntriesForWeek(e);let o=(0,r.lowerbound)(n,new a(t,i,0),m);if(o!==n.length)return new l(e,o,n);let c=e;const h=7-t+this._firstDayOfWeek-1;for(i=-(s.minutesPerDay-i+h*s.minutesPerDay);;){c++;const e=this._getEntriesForWeek(c);if(0!==e.length)return o=(0,r.lowerbound)(e,new a(this._firstDayOfWeek,i,0),m),new l(c,o,e)}}findSession(e,t,i,s=0){const r=this.indexOfSession(e,t,i),n=r.entries;let o=r.entryIndex;if(0!==s){const e=n[o].dayOfWeek(),t=s>0?1:-1;for(;;){const i=o+t;if(i<0||i>=n.length||n[i].dayOfWeek()!==e)break;o=i}}return new l(r.weekIndex,o,n)}getWeekIndex(e){if(!this._isThereCorrections)return 0;const t=s.get_day_of_week(e)-s.SUNDAY,i=s.get_timezone("Etc/UTC"),r=s.get_cal(i,s.get_year(e),s.get_month(e),s.get_day_of_month(e)-t);return Math.floor((r.getTime()+f)/1e3/86400/7)}correctTradingDay(e){const t=s.get_day_of_week(e),i=60*s.get_hours(e)+s.get_minutes(e),r=this.getWeekIndex(e),n=this.findSession(r,t,i,0),o=n.getEntry().dayOfWeek()-t+7*(n.weekIndex-r);return 0!==o&&s.add_date(e,o),e}alignToSessionStart(e,t=0){const i=s.get_day_of_week(e),r=60*s.get_hours(e)+s.get_minutes(e),n=this.getWeekIndex(e),o=this.findSession(n,i,r,t),a=o.getEntry(),l=a.dayOfWeek()-i+7*(o.weekIndex-n);0!==l&&s.add_date(e,l);const c=a.startOffset();return s.set_hms(e,c/60,c%60,0,0,s.get_timezone(this._timezone)),a.length()}businessDaysToCalendarDays(e,t){let i=this.getWeekIndex(e),r=s.get_day_of_week(e),n=0,o=0;for(;oi);)e[a].dayOfWeek()=t)return n}i++,r=s.SUNDAY}return n}calendarDaysToBusinessDays(e,t){let i=this.getWeekIndex(e),r=s.get_day_of_week(e),n=0,o=0;for(;ni);)e[a].dayOfWeek()=t)return o}i++,r=s.SUNDAY}return o}alignToNearestSessionStart(e,t){return this._alignToNearestSessionValue(e,t,this._entrySessionStart.bind(this))}alignToNearestSessionEnd(e,t){return this._alignToNearestSessionValue(e,t,this._entrySessionEnd.bind(this))}leftBorderOfDailyBar(e){const t=this._getEntriesForDay(e);return 0===t.length?null:(t.sort(o),this._getLeftEntryBorder(e,t[0]))}bordersOfDailyBar(e){const t=this._getEntriesForDay(e);if(0===t.length)return null;t.sort(o);const i=this._getLeftEntryBorder(e,t[0]),r=t[t.length-1],n=s.clone(e);let a=60*(r.startOffset()+r.length())-1;const l=Math.floor(a/3600);return a-=3600*l,s.set_hms(n,l,a/60,a%60,0,s.get_timezone(this._timezone)),{from:i,to:n}}getEntriesForWeekByCalendar(e){const t=this.getWeekIndex(e);return this._getEntriesForWeek(t)}_getEntriesForWeek(e){let t=this._entriesHash.get(e);if(void 0===t)return this._entries;if(null!==t)return t;const i=s.get_timezone(this._timezone);t=this._entries.slice();const r=this._weekIndexToCalendar(e),a=this._weekIndexToCalendar(e+1),l=n.BusinessDay.fromCalendar(r),c=n.BusinessDay.fromCalendar(a),h=this._selectHolidays(l,c);for(const e of h){const r=e.day.toCalendar(i),n=s.get_day_of_week(r);t=t.filter((e=>e.dayOfWeek()!==n)),t=t.concat(e.sessions)}return t.sort(o),this._entriesHash.set(e,t),t}_selectHolidays(e,t){const i=[];let s=e;for(;;){const e=g(this._holidaySessions,s);if(null===e)return i;if(!e.day.before(t))return i;i.push(e),s=e.day.addDays(1)}}_weekIndexToCalendar(e){const t=1e3*(86400*e*7+86400)-f,i=s.get_cal_from_unix_timestamp_ms(s.get_timezone("Etc/UTC"),t),r=s.get_timezone("Etc/UTC");return s.get_cal(r,s.get_year(i),s.get_month(i),s.get_day_of_month(i))}_alignToNearestSessionValue(e,t,i){const r=s.get_day_of_week(e),n=60*s.get_hours(e)+s.get_minutes(e),o=this.getWeekIndex(e);let a=this.findSession(o,r,n);if(a.getEntry().contains(e)&&o===a.weekIndex||1===t)return i(a,s.clone(e),t);const c=a.getEntry(),h=c.contains(e),d=o===a.weekIndex,u=c.sessionStartDaysOffset()-c.dayOfWeek()>=0;if(h&&(d||u))return i(a,s.clone(e),t);let p=a.entryIndex-1;if(p<0){let e=a.weekIndex,t=a.entries;for(;p<0;)e--,t=this._getEntriesForWeek(e),p+=t.length;a=new l(e,p,t)}else a=new l(a.weekIndex,p,a.entries);return i(a,s.clone(e),t)}_entrySessionStart(e,t,i){return this._entrySessionValue(e,t,i,(e=>60*e.start()))}_entrySessionEnd(e,t,i){return this._entrySessionValue(e,t,i,(e=>60*(e.start()+e.length())-1))}_entrySessionValue(e,t,i,r){let n=s.get_day_of_week(t);const o=e.getEntry();let a=o.dayOfWeek()-o.sessionStartDaysOffset();const l=this.getWeekIndex(t) +;let c=e.weekIndex-l,h=!1;if(a0&&i>=0||c<0&&i<0)&&s.add_date(t,7*c),!o.contains(t)){let e=a-n;h&&i<0&&(e=-(7-a+n)),s.add_date(t,e),n=s.get_day_of_week(t)}o.isOvernight()&&n===o.dayOfWeek()&&s.add_date(t,-o.sessionStartDaysOffset());let d=r(o);const u=Math.floor(d/3600);return d-=3600*u,s.set_hms(t,u,d/60,d%60,0,s.get_timezone(this._timezone)),t}_getEntriesForDay(e){const t=s.get_day_of_week(e);return this._getEntriesForWeek(this.getWeekIndex(e)).filter((e=>e.dayOfWeek()===t))}_getLeftEntryBorder(e,t){const i=s.clone(e),r=t.startOffset();return s.set_hms(i,r/60,r%60,0,0,s.get_timezone(this._timezone)),i}}},81049:(e,t,i)=>{"use strict";i.d(t,{barFunctionByStyle:()=>r});var s=i(13497);function r(e,t){switch(e){case 12:return(0,s.barFunction)("low","low","close");case 2:case 14:case 15:case 3:case 10:case 13:return(0,s.barFunction)(null!=t?t:"close");default:return(0,s.barFunction)("close","open")}}},36112:(e,t,i)=>{"use strict";i.d(t,{BarsMarksContainer:()=>m});var s=i(50151),r=i(59224),n=i(56840),o=i.n(n),a=i(14483),l=i(36274),c=i(1722),h=i(42960),d=i(14292),u=i(28558);const p=(0,r.getLogger)("Chart.BarsMarksContainer"),_=Math.round(new Date(2037,0,1).getTime()/1e3);class m extends d.DataSource{constructor(e,t,i){const r=e.onWidget();let n;n=r?!e.hideIdeas():!!a.enabled("bars_marks")&&o().getBool("BarsMarksContainer.visibile",!1),t.merge({visible:n}),t.childs().visible.subscribe(null,(t=>{r||e.isSnapshot()||!a.enabled("bars_marks")||o().setValue("BarsMarksContainer.visibile",!!t.value())})),super(i),this._paneViews=[],this._model=e,this._properties=t,this._requests=[],this._marks={},this._loadedRange=null,this._getDataTimeout=null,this._collectedRange=null,this._lastRange=null;const l=this._model.mainSeries();l.onSymbolIntervalChanged().subscribe(this,this.clearMarks),l.dataEvents().symbolResolved().subscribe(this,this.clearMarks),l.dataEvents().completed().subscribe(this,(()=>{var e,t;const i=l.data();if(0===i.size())return;const r=(0,s.ensureNotNull)(i.first()).index,n=(0,s.ensureNotNull)(i.last()).index,o=this.timeScale();this.getData({start:null!==(e=o.indexToTimePoint(r))&&void 0!==e?e:1/0,end:null!==(t=o.indexToTimePoint(n))&&void 0!==t?t:-1/0})})),this._initialize(),this._pinnedTooltips={}}destroy(){const e=this._model.mainSeries();e.onSymbolIntervalChanged().unsubscribeAll(this),e.dataEvents().symbolResolved().unsubscribeAll(this),e.dataEvents().completed().unsubscribeAll(this)}properties(){return this._properties}marks(){return this._marks}pinTooltip(e,t){this._pinnedTooltips[e]=t}timeScale(){return this._model.timeScale()}getIntervalInTicks(){const e=this._model.mainSeries().properties().childs().interval.value(),t=l.Interval.parse(e);if(!t.isValid())throw new TypeError("Unexpected interval");return t.isRange()?60:t.inMilliseconds()/1e3}getVisibleTickMarksRange(){var e,t;if(this.timeScale().isEmpty())return{start:0,end:0};const i=(0,s.ensureNotNull)(this.timeScale().visibleBarsStrictRange()),{firstIndex:r,lastIndex:n}=(0, +s.ensureNotNull)(this.timeScale().points().range().value());if(!(i.lastBar()>r&&i.firstBar(){var r,n;const o=this._marks[s],a=o.tickmark;a>=(null!==(r=t.start)&&void 0!==r?r:1/0)&&a<=(null!==(n=t.end)&&void 0!==n?n:-1/0)+i&&e.push(o)})),e}getPublishedPlates(){const e={};return window.is_authenticated?(this.getVisibleRangePlates().forEach((t=>{t.is_public&&(this._pinnedTooltips[t.id]||t.user__id===window.user.id)&&(e[t.id]=t)})),e):e}filterDisplayedPlates(e){const t=e.reduce(((e,t)=>{const i=this._getIndex(t.tickmark);return null!==i&&(e[i]=e[i]||[],e[i].push(t)),e}),{});return Object.keys(t).reduce(((e,i)=>{let s=t[i];return s=s.sort(((e,t)=>t.views_count-e.views_count)),s=s.slice(0,10),e.concat(s)}),[])}getPlatesViewData(){var e,t,i;const r=this._model.mainSeries();if(r.data().isEmpty())return[];const n=(0,h.isPriceSourceStyle)(r.style())?r.barFunction():null,o=this.filterDisplayedPlates(this.getVisibleRangePlates()),a={},l=null!==(e=this._model.lastHittestData())&&void 0!==e?e:this._model.lastSelectedHittestData();let c=null;null!==l&&this._model.hoveredSource()===this&&(c=null!==(t=l.activeItem)&&void 0!==t?t:null);const d=[];for(const e of o){const t=(0,s.ensureNotNull)(this._getIndex(e.tickmark)),i=this._getBar(t);if(null===i)continue;const r=this._layout(e.direction),o=this._theme(e.direction),l=c===e.id,h=this.timeScale().indexToCoordinate(t),u=this._offset(r,i,n),p=(0,s.ensureNotNull)(this.priceScale()).isInverted();let _=0;t in a||(a[t]={up:0,down:0}),_=a[t][r]++,d.push({id:e.id,x:h,y:u,yInverted:p,order:_,direction:r,theme:o,hovered:l,pinned:!0===this._pinnedTooltips[e.id],user__id:e.user__id,label:e.label,labelFontColor:e.labelFontColor||"#444",minSize:e.minSize||5,...this._plateViewData(e)})}const u=d.filter((e=>!0===e.hovered));for(let e=0;ee.hovered&&!t.hovered?1:0)),d}priceAxisViews(){return null}updateAllViews(e){for(const t of this._paneViews)t.update(e)}updateAllViewsAndRepaint(){this.updateAllViews((0,u.sourceChangeEvent)(this.id())),this._model.updateSource(this)}roundRange(e){return{start:Math.round(e.start),end:Math.round(e.end)}}refreshData(){null!==this._lastRange&&this.getData(this._lastRange)}getData(e){(0,c.isNumber)(e.start)&&(0,c.isNumber)(e.end)?(this._lastRange=e,e.end=_,this._pushGetDataStack(Object.assign({},e))):p.logError("Wrong range")}clearMarks(){this._abortAllRequests(),this._marks={},this._loadedRange=null}isUserDeletable(){return!1}isSavedInChart(e){return!1}isSpeciallyZOrderedSource(){return!0}showInObjectTree(){return!1}_plateViewData(e){ +return{}}_layout(e){switch(e){default:case 0:case 2:case 3:case 4:case 5:case 6:return"up";case 1:return"down"}}_theme(e){switch(e){default:case 0:return"neutral";case 1:case 5:return"green";case 2:case 6:return"red";case 3:return"yellow";case 4:return"blue"}}_offset(e,t,i){let r;switch(e){default:case"up":r=null===i?t[2]:i(t);break;case"down":r=null===i?t[3]:i(t)}return(0,s.ensureNotNull)(this.priceScale()).priceToCoordinate(r,(0,s.ensureNotNull)((0,s.ensureNotNull)(this.ownerSource()).firstValue()))}_getIndex(e){return this.timeScale().timePointToIndex(e)}_getBar(e){return this._model.mainSeries().data().valueAt(e)}_rangeDifference(e){return e=Object.assign({start:1/0,end:-1/0},e),this._loadedRange&&(e.startthis._loadedRange.end&&(e.start=this._loadedRange.end)),e}_rangeUnion(e,t){return e=Object.assign({start:1/0,end:-1/0},e),t&&(e.start=Math.min(t.start,e.start),e.end=Math.max(t.end,e.end)),e}_pushGetDataStack(e){(0,c.isNumber)(e.start)&&(0,c.isNumber)(e.end)?(this._getDataTimeout&&clearTimeout(this._getDataTimeout),this._collectedRange=this._rangeUnion(e,this._collectedRange),this._getDataTimeout=setTimeout((()=>{this._getData(this._collectedRange),this._getDataTimeout=this._collectedRange=null}),300)):p.logError("Wrong tickmark range")}_abortAllRequests(){this._requests.forEach((e=>{e.cancel()})),this._requests=[],this._getDataTimeout&&clearTimeout(this._getDataTimeout),this._getDataTimeout=this._collectedRange=null}}},35994:(e,t,i)=>{"use strict";var s=i(48891).getHexColorByName,r=(i(62615).RangeBarStyle,i(86094).PlotRowSearchMode),n=i(72877).STUDYPLOTDISPLAYTARGET,o=i(87095).rgbaFromInteger,a=s("color-minty-green-500"),l=s("color-ripe-red-500");function c(){this.backColorers=[]}function h(e){c.call(this),this._series=e}function d(e,t){c.call(this),this._study=e,this._plotIndex=t}c.prototype.barStyle=function(e,t,i){for(var s={},r=this.backColorers.length-1;r>=0;r--)this.backColorers[r].applyBarStyle(e,t,s,i);return this.applyBarStyle(e,t,s,i),s},c.prototype.pushBackBarColorer=function(e){this.backColorers.push(e)},c.prototype.applyBarStyle=function(e,t,i){throw new Error("This function is supposed to be reimplemented in a subclass")},inherit(h,c),h.upColor=function(e,t){switch(e.style.value()){case TradingView.Series.STYLE_LINE:return e.lineStyle.color.value();case TradingView.Series.STYLE_LINE_WITH_MARKERS:return e.lineWithMarkersStyle.color.value();case TradingView.Series.STYLE_STEPLINE:return e.steplineStyle.color.value();case TradingView.Series.STYLE_AREA:return e.areaStyle.linecolor.value();case TradingView.Series.STYLE_HLC_AREA:return e.hlcAreaStyle.closeLineColor.value();case TradingView.Series.STYLE_BARS:return e.barStyle.upColor.value();case TradingView.Series.STYLE_CANDLES:return e.candleStyle.upColor.value();case TradingView.Series.STYLE_HOLLOW_CANDLES:return e.hollowCandleStyle.upColor.value();case TradingView.Series.STYLE_HEIKEN_ASHI:return e.haStyle.upColor.value();case TradingView.Series.STYLE_BASELINE: +return e.baselineStyle.topLineColor.value();case TradingView.Series.STYLE_HILO:return e.hiloStyle.color.value();case TradingView.Series.STYLE_COLUMNS:return e.columnStyle.upColor.value()}throw new Error("Unknown series style")},h.downColor=function(e,t){switch(e.style.value()){case TradingView.Series.STYLE_LINE:return e.lineStyle.color.value();case TradingView.Series.STYLE_LINE_WITH_MARKERS:return e.lineWithMarkersStyle.color.value();case TradingView.Series.STYLE_STEPLINE:return e.steplineStyle.color.value();case TradingView.Series.STYLE_AREA:return e.areaStyle.linecolor.value();case TradingView.Series.STYLE_HLC_AREA:return e.hlcAreaStyle.closeLineColor.value();case TradingView.Series.STYLE_BARS:return e.barStyle.downColor.value();case TradingView.Series.STYLE_CANDLES:return e.candleStyle.downColor.value();case TradingView.Series.STYLE_HOLLOW_CANDLES:return e.hollowCandleStyle.downColor.value();case TradingView.Series.STYLE_HEIKEN_ASHI:return e.haStyle.downColor.value();case TradingView.Series.STYLE_BASELINE:return e.baselineStyle.bottomLineColor.value();case TradingView.Series.STYLE_HILO:return e.hiloStyle.color.value();case TradingView.Series.STYLE_COLUMNS:return e.columnStyle.downColor.value()}throw new Error("Unknown series style")},h.prototype._applyLineStyle=function(e,t,i,s,r){i.barColor=h.upColor(r)},h.prototype._applyAreaStyle=function(e,t,i,s,r){i.barColor=h.upColor(r)},h.prototype._applyHLCAreaStyle=function(e,t,i,s,r){var n,o=this.findBar(e,!1,s),c=this.findPrevBar(e,!1,s);n=this._series.data().first().index!==e?c[TradingView.CLOSE_PLOT]<=o[TradingView.CLOSE_PLOT]:o[TradingView.OPEN_PLOT]<=o[TradingView.CLOSE_PLOT],i.barColor=h.upColor(r,t),i.barBorderColor=n?a:l},h.prototype._applyBarStyle=function(e,t,i,s,r){var n=h.upColor(r),o=h.downColor(r),a=this.findBar(e,!1,s);if(r.barStyle.barColorsOnPrevClose.value()){var l=this.findPrevBar(e,!1,s);i.barColor=l[TradingView.CLOSE_PLOT]<=a[TradingView.CLOSE_PLOT]?n:o,i.barBorderColor=l[TradingView.CLOSE_PLOT]<=a[TradingView.CLOSE_PLOT]?n:o}else i.barColor=a[TradingView.OPEN_PLOT]<=a[TradingView.CLOSE_PLOT]?n:o,i.barBorderColor=a[TradingView.OPEN_PLOT]<=a[TradingView.CLOSE_PLOT]?n:o},h.prototype._applyCandleStyle=function(e,t,i,s,r){var n,o=h.upColor(r,t),a=h.downColor(r,t),l=r.candleStyle.borderUpColor?r.candleStyle.borderUpColor.value():r.candleStyle.borderColor.value(),c=r.candleStyle.borderDownColor?r.candleStyle.borderDownColor.value():r.candleStyle.borderColor.value(),d=r.candleStyle.wickUpColor?r.candleStyle.wickUpColor.value():r.candleStyle.wickColor.value(),u=r.candleStyle.wickDownColor?r.candleStyle.wickDownColor.value():r.candleStyle.wickColor.value(),p=this.findBar(e,!1,s);r.candleStyle.barColorsOnPrevClose.value()&&this._series.data().first().index!==e?n=this.findPrevBar(e,!1,s)[TradingView.CLOSE_PLOT]<=p[TradingView.CLOSE_PLOT]:n=p[TradingView.OPEN_PLOT]<=p[TradingView.CLOSE_PLOT];i.barColor=n?o:a,i.barBorderColor=n?l:c,i.barWickColor=n?d:u},h.prototype._applyHollowCandleStyle=function(e,t,i,s,r){ +var n,o=h.upColor(r,t),a=h.downColor(r,t),l=r.hollowCandleStyle.borderUpColor?r.hollowCandleStyle.borderUpColor.value():r.hollowCandleStyle.borderColor.value(),c=r.hollowCandleStyle.borderDownColor?r.hollowCandleStyle.borderDownColor.value():r.hollowCandleStyle.borderColor.value(),d=r.hollowCandleStyle.wickUpColor?r.hollowCandleStyle.wickUpColor.value():r.hollowCandleStyle.wickColor.value(),u=r.hollowCandleStyle.wickDownColor?r.hollowCandleStyle.wickDownColor.value():r.hollowCandleStyle.wickColor.value(),p=this.findBar(e,!1,s),_=this.findPrevBar(e,!1,s);n=this._series.data().first().index!==e?_[TradingView.CLOSE_PLOT]<=p[TradingView.CLOSE_PLOT]:p[TradingView.OPEN_PLOT]<=p[TradingView.CLOSE_PLOT],i.barColor=n?o:a,i.barBorderColor=n?l:c,i.barWickColor=n?d:u,i.isBarHollow=p[TradingView.OPEN_PLOT]<=p[TradingView.CLOSE_PLOT]},h.prototype._applyHAStyle=function(e,t,i,s,r){var n,o=h.upColor(r,t),a=h.downColor(r,t),l=r.haStyle.borderUpColor.value(),c=r.haStyle.borderDownColor.value(),d=r.haStyle.wickUpColor.value(),u=r.haStyle.wickDownColor.value(),p=this.findBar(e,t,s);r.haStyle.barColorsOnPrevClose.value()?n=this.findPrevBar(e,t,s)[TradingView.CLOSE_PLOT]<=p[TradingView.CLOSE_PLOT]:n=p[TradingView.OPEN_PLOT]<=p[TradingView.CLOSE_PLOT];i.barColor=n?o:a,i.barBorderColor=n?l:c,i.barWickColor=n?d:u},h.prototype._applyBaseLineStyle=function(e,t,i,s,r){var n=this.findBar(e,t,s),o=r.baselineStyle,a=this._series.priceScale(),l=Math.round(a.height()*(Math.abs(100-o.baseLevelPercentage.value())/100)),c=this._series.firstValue(),d=a.coordinateToPrice(l,c);n[TradingView.CLOSE_PLOT]>d?i.barColor=h.upColor(r,t):i.barColor=h.downColor(r,t)},h.prototype._applyHiLoStyle=function(e,t,i,s,r){i.barColor=h.upColor(r,t),i.barBorderColor=r.hiloStyle.borderColor.value()},h.prototype._applyColumnStyle=function(e,t,i,s,r){var n=h.upColor(r),o=h.downColor(r),a=this.findBar(e,!1,s);if(r.columnStyle.barColorsOnPrevClose.value()){var l=this.findPrevBar(e,!1,s);i.color=l[TradingView.CLOSE_PLOT]<=a[TradingView.CLOSE_PLOT]?n:o}else i.color=a[TradingView.OPEN_PLOT]<=a[TradingView.CLOSE_PLOT]?n:o;i.barColor=i.color},h.prototype.applyBarStyle=function(e,t,i,s){i||(i={}),i.barColor=null,i.barBorderColor=null,i.barWickColor=null,i.isBarHollow=null,i.isBarUp=null,i.upColor=null,i.downColor=null,i.isTwoColorBar=null,i.isMergedBar=null;var r=this._series.properties();switch(r.style.value()){case TradingView.Series.STYLE_LINE:case TradingView.Series.STYLE_LINE_WITH_MARKERS:case TradingView.Series.STYLE_STEPLINE:this._applyLineStyle(e,t,i,s,r);break;case TradingView.Series.STYLE_AREA:this._applyAreaStyle(e,t,i,s,r);break;case TradingView.Series.STYLE_HLC_AREA:this._applyHLCAreaStyle(e,t,i,s,r);break;case TradingView.Series.STYLE_BARS:this._applyBarStyle(e,t,i,s,r);break;case TradingView.Series.STYLE_CANDLES:this._applyCandleStyle(e,t,i,s,r);break;case TradingView.Series.STYLE_HOLLOW_CANDLES:this._applyHollowCandleStyle(e,t,i,s,r);break;case TradingView.Series.STYLE_HEIKEN_ASHI:this._applyHAStyle(e,t,i,s,r);break;case TradingView.Series.STYLE_BASELINE: +this._applyBaseLineStyle(e,t,i,s,r);break;case TradingView.Series.STYLE_HILO:this._applyHiLoStyle(e,t,i,s,r);break;case TradingView.Series.STYLE_COLUMNS:this._applyColumnStyle(e,t,i,s,r)}return i},h.prototype.getSeriesBars=function(e){return e?this._series.nsBars():this._series.bars()},h.prototype._findBarFieldValue=function(e,t,i){var s=this.getSeriesBars(i).valueAt(e);if(null!==s)return s[t]},h.prototype.findBar=function(e,t,i){return i?i.value:this.getSeriesBars(t).valueAt(e)||[]},h.prototype.findPrevBar=function(e,t,i){if(i&&i.previousValue)return i.previousValue;var s=this._series.bars().search(e-1,r.NearestLeft,TradingView.CLOSE_PLOT);return null!==s?s.value:[]},inherit(d,c),d.prototype.getBars=function(){return this._study.series().bars()},d.prototype.firstColoredBar=function(e){for(var t=e,i=0;ie+c)return i;if(s.styles[l.id].display.value()===n.None)return i;var h=a.valueAt(e-c);if(null===h)return i;var d=h[this._plotIndex+1];if(null==d)return i;if(d=Math.round(d),r.isRGB)i.barColor=o(d),i.upColor=i.barColor,i.downColor=i.barColor;else{var u=r.plots[this._plotIndex].palette,p=s.palettes[u],_=r.palettes[u].valToIndex?r.palettes[u].valToIndex[d]:d,m=p.colors[_].color.value();i.barColor=m,i.upColor=m.color,i.downColor=m.color}return i},t.SeriesBarColorer=h,t.StudyBarColorer=d},12500:(e,t,i)=>{"use strict";i.d(t,{BarsRange:()=>r});var s=i(50151);class r{constructor(e,t){(0,s.assert)(e<=t,"The last bar in the bars range should be greater than or equal to the first bar"),this._firstBar=e,this._lastBar=t}firstBar(){return this._firstBar}lastBar(){return this._lastBar}count(){return this._lastBar-this._firstBar+1}contains(e){return this._firstBar<=e&&e<=this._lastBar}equals(e){return this._firstBar===e.firstBar()&&this._lastBar===e.lastBar()}static compare(e,t){return null===e||null===t?e===t:e.equals(t)}}},73971:(e,t,i)=>{"use strict";i.d(t,{ChartModelBase:()=>cs});var s=i(12481),r=i(27788),n=i(50151),o=i(86441),a=i(24377),l=i(48891),c=i(44352),h=i(45345),d=i(5286),u=i(51768),p=i(51608),_=i(76422),m=i(11417),g=i(67980),f=i(3587),v=i(78071),S=i(92249);function y(e){return(0,S.isLineTool)(e)&&e.boundToSymbol()||!1}class b{constructor(){this._items=[],this._set=new Set,this._dataSourcesCache=null,this._customSourcesCache=null,this._lineSourcesCache=null}isEmpty(){return 0===this._items.length}add(e){if(this._items.length>0&&!y(this._items[0])&&this.clear(),y(e)){const t=(0, +v.lowerbound)(this._items,e,((e,t)=>e.zorder()!(0,f.isDataSource)(e)))),this._customSourcesCache}checkLineToolSelection(){this._items.forEach((e=>(0,S.isLineTool)(e)&&e.calcIsActualSymbol())),this._items=this._items.filter((e=>!(0,S.isLineTool)(e)||e.isActualSymbol())),this._invalidateCache()}remove(e){this._items=this._items.filter((t=>t!==e)),this._set.delete(e),this._invalidateCache()}clear(){this._items=[],this._set.clear(),this._invalidateCache()}_invalidateCache(){this._customSourcesCache=null,this._dataSourcesCache=null,this._lineSourcesCache=null}}var w=i(6674),P=i(52329),C=i(76949),x=i(36274),T=i(46100),I=i(59452),M=i.n(I),L=i(29764),A=i(46501);class k{constructor(e){this._rendererOptions={borderSize:1,additionalPaddingInner:0,fontSize:NaN,font:"",color:"",paneBackgroundColor:"",paddingBottom:0,paddingInner:0,paddingOuter:0,paddingTop:0,lineSpacing:0},this._chartModel=e}options(){const e=this._rendererOptions,t=this._chartModel.properties().childs(),i=t.scalesProperties.childs().fontSize.value();return e.fontSize!==i&&(e.fontSize=i,e.font=(0,L.makeFont)(i,A.CHART_FONT_FAMILY,""),e.paddingTop=i/12*2.5,e.paddingBottom=i/12*2.5,e.paddingInner=i/12*4,e.additionalPaddingInner=i/12*4,e.paddingOuter=i/12*4,e.lineSpacing=i/12*2),e.color=t.scalesProperties.childs().textColor.value(),e.paneBackgroundColor=t.paneProperties.childs().background.value(),this._rendererOptions}}var D=i(94739),E=i(12442),V=i(61146),B=i(85804),R=i(15742),N=i(14483),O=i(42960),F=i(16776),W=i(28558);const H=new V.PriceFormatter,z="sessions";class U extends R.CustomSourceBase{constructor(e,t,i){super(e,t),this._studySource=null,this._paneViews=[],this._metaInfo=null,this._destroyed=!1,this._isStarted=!1,this._loadedGraphics=null,this._doubleClickHandler=i;const s=t.mainSeries();this._properties=new T.DefaultProperty("sessions"),(0,B.applyDefaultsOverrides)(this._properties.childs().graphics,void 0,!1,z),this._removeDuplicateProperties(),this._properties.subscribe(this,this._onPropertiesChanged),t.studyMetaInfoRepository().findById({type:"java",studyId:"Sessions@tv-basicstudies"}).then((i=>{this._destroyed||null===this._loadedGraphics&&(this._setMetaInfo(i),null!==this._metaInfo&&(this._studySource=new D.StudyDataSource(t.chartApi(),s.seriesSource(),"sessions_",this._metaInfo),this._createPaneViews(),this._studySource.dataCleared().subscribe(this,this.updateAllViews.bind(this,(0,W.sourceChangeEvent)(e))), +this._studySource.dataUpdated().subscribe(this,this.updateAllViews.bind(this,(0,W.sourceChangeEvent)(e))),this._studySource.setInputs({}),this._processHibernate()))})),t.timeScale().onReset().subscribe(this,this._clearData),t.timeScale().logicalRangeChanged().subscribe(this,this.updateAllViews.bind(this,(0,W.viewportChangeEvent)())),t.mainSeries().sessionIdProxyProperty().subscribe(this,this._updateVisibleOfPreAndPostMarketBackground),t.mainSeries().properties().childs().interval.subscribe(this,this._processHibernate),this._updateVisibleOfPreAndPostMarketBackground(t.mainSeries().properties().childs().sessionId)}applyOverrides(e){(0,B.applyPropertiesOverrides)(this._properties.childs().graphics,void 0,!1,e,z),this._model.updateSource(this)}start(){this._isStarted=!0,this._processHibernate()}restart(){this._clearData(),N.enabled("stop_study_on_restart")&&this.stop(),this.start()}isStarted(){return this._isStarted}stop(){this._isStarted=!1,null!==this._studySource&&this._studySource.stop()}isHoveredEnabled(){return!1}paneViews(e){return this._paneViews}updateAllViews(e){this._paneViews.forEach((t=>t.update(e)))}updateViewsForPane(e,t){this.updateAllViews(t)}destroy(){this._destroyed=!0,null!==this._studySource&&(this._studySource.dataCleared().unsubscribeAll(this),this._studySource.dataUpdated().unsubscribeAll(this),this._studySource.destroy(),this._studySource=null),this._model.timeScale().logicalRangeChanged().unsubscribeAll(this),this._model.timeScale().onReset().unsubscribeAll(this),this._model.mainSeries().sessionIdProxyProperty().unsubscribeAll(this),this._model.mainSeries().properties().childs().interval.unsubscribeAll(this),this._properties.unsubscribeAll(this)}series(){return this._model.mainSeries()}priceScale(){return this.series().priceScale()}graphics(){return this._loadedGraphics||(0,n.ensureNotNull)(this._studySource).graphics()}valueAt(e,t){return null}properties(){return this._properties}graphicsInfo(){return(0,n.ensureNotNull)(this._metaInfo).graphics}firstValue(e){return this._model.mainSeries().firstValue()}formatter(){return H}state(e){const t={properties:this._properties.state()};return e&&null!==this._metaInfo&&(t.data={graphics:(0,E.saveStudyGraphics)(this.graphics(),this._model.timeScale().visibleBarsStrictRange()),metaInfo:this._metaInfo}),t}restoreState(e,t){const i=e.properties;this._migrateOutOfSessionProperty(i),this._properties.mergeAndFire(i),this._removeDuplicateProperties(),this._updateVisibleOfPreAndPostMarketBackground(this._model.mainSeries().properties().childs().sessionId),void 0!==e.data&&t&&(this._loadStudyGraphics(e.data.graphics),this._setMetaInfo(e.data.metaInfo),this._createPaneViews())}restoreOldState(e,t){const i={properties:{graphics:e.state.graphics}};void 0!==e.data&&void 0!==e.metaInfo&&t&&(i.data={metaInfo:e.metaInfo,graphics:e.data.graphics}),this.restoreState(i,t)}applyPreferences(e){this._properties.mergePreferences(e)}metaInfo(){return(0,n.ensureNotNull)(this._metaInfo)}_loadStudyGraphics(e){const t=e.backgrounds;if(void 0!==t){ +const e=t.findIndex((e=>"inSession"===e.styleId));-1!==e&&t.splice(e,1)}this._loadedGraphics=(0,E.loadStudyGraphics)(e)}_setMetaInfo(e){const t=e.graphics.backgrounds;void 0!==t&&void 0!==t.inSession&&delete t.inSession,this._metaInfo=e}_updateVisibleOfPreAndPostMarketBackground(e){const t=!(0,O.isRegularSessionId)(e.value());this._outOfSessionVisibilityProperty().setValue(t),this._preMarketVisibilityProperty().setValue(t),this._postMarketVisibilityProperty().setValue(t)}_clearData(){null!==this._studySource&&this._studySource.clearData()}_createPaneViews(){const e={doubleClickHandler:this._doubleClickHandler};(0,E.createGraphicsPaneViews)(this,this._model,e).then((e=>{this._paneViews=e,this._model.lightUpdate()}))}_onPropertiesChanged(){this._processHibernate(),this.updateAllViews((0,W.sourceChangeEvent)(this.id()))}_processHibernate(){if(null!==this._studySource){const e=this._canBeHibernated(),t=this._isHibernated(),i=this._studySource.isStarted();!t&&e&&i?this._studySource.stop():!t||e||i||this._studySource.start()}}_canBeHibernated(){const e=this._model.mainSeries(),t=this._preMarketVisibilityProperty().value()&&this._postMarketVisibilityProperty().value()&&this._outOfSessionVisibilityProperty().value();return e.isDWM()||!t&&!this._vertLinesVisibleProperty().value()}_isHibernated(){return this._isStarted&&(null===this._studySource||!this._studySource.isStarted())}_outOfSessionVisibilityProperty(){return this._properties.childs().graphics.childs().backgrounds.childs().outOfSession.childs().visible}_preMarketVisibilityProperty(){return this._properties.childs().graphics.childs().backgrounds.childs().preMarket.childs().visible}_postMarketVisibilityProperty(){return this._properties.childs().graphics.childs().backgrounds.childs().postMarket.childs().visible}_vertLinesVisibleProperty(){return this._properties.childs().graphics.childs().vertlines.childs().sessBreaks.childs().visible}_removeDuplicateProperties(){this._properties.hasChild("properties")&&(this._properties.removeProperty("properties"),(0,T.saveDefaultProperties)(!0),this._properties.childChanged(null),(0,T.saveDefaultProperties)(!1))}_migrateOutOfSessionProperty(e){const t=e.graphics.backgrounds;if(void 0!==t){const i=t.outOfSession;i.color===(0,n.ensureDefined)(F.sessionsPreferencesDefault.graphics.backgrounds).outOfSession.color||"postMarket"in t||(e.graphics.backgrounds={...t,postMarket:{color:i.color,transparency:i.transparency,visible:i.visible},preMarket:{color:i.color,transparency:i.transparency,visible:i.visible}})}}}var j=i(28853),G=i(57898),q=i(97145),$=i(83669),Y=i(91280),K=i(42226),Z=i(39875),X=i(59224),J=i(36174),Q=i(49535),ee=i(36298),te=i(42856),ie=i(1722),se=i(29921),re=i(80842),ne=i(98517);const oe=new Map([["price",e=>(0,re.isPriceDataSource)(e)],["trading",e=>(0,S.isTrading)(e)],["drawing",e=>(0,S.isLineTool)(e)&&!(0,S.isTrading)(e)&&!e.isPhantom()],["drawingsForAllSymbols",e=>(0,S.isLineTool)(e)&&!(0,S.isTrading)(e)&&!e.isPhantom()],["phantom",e=>(0,S.isLineTool)(e)&&e.isPhantom()],["restRowSources",e=>!(0,S.isLineTool)(e)&&!(0, +S.isTrading)(e)],["legendViewSources",e=>(0,re.isPriceDataSource)(e)||(0,S.isStudyLineTool)(e)],["leftPriceScale",(e,t)=>"left"===le(e,t)],["rightPriceScale",(e,t)=>"right"===le(e,t)],["overlayPriceScale",(e,t)=>"overlay"===le(e,t)]]),ae=new Map([["price","visibleSorted"],["trading","visibleSorted"],["drawing","visibleSorted"],["drawingsForAllSymbols","allSorted"],["phantom","visibleSorted"],["restRowSources","visibleSorted"],["legendViewSources","visibleSorted"],["leftPriceScale","visibleSorted"],["rightPriceScale","visibleSorted"],["overlayPriceScale","visibleSorted"]]);function le(e,t){const i=e.priceScale();return null===i?"overlay":t.priceScalePosition(i)}class ce{constructor(e){this._groupedSources=new Map,this._sources=null,this._pane=e}clear(){this._groupedSources.clear(),this._sources=null}destroy(){this.clear()}all(){return this._groupedSources.has("visibleSorted")||this._sortSources(),(0,n.ensureDefined)(this._groupedSources.get("visibleSorted"))}allIncludingHidden(){return this._groupedSources.has("allSorted")||this._sortSources(),(0,n.ensureDefined)(this._groupedSources.get("allSorted"))}allExceptSpecialSources(){if(!this._groupedSources.has("exceptSpecial")){const e=this.allIncludingHidden().filter((e=>!e.isSpeciallyZOrderedSource()));this._groupedSources.set("exceptSpecial",e)}return(0,n.ensureDefined)(this._groupedSources.get("exceptSpecial"))}tradingSources(){return this._getSourcesByGroupType("trading")}priceSources(){return this._getSourcesByGroupType("price")}lineSources(){return this._getSourcesByGroupType("drawing")}lineSourcesForAllSymbols(){return this._getSourcesByGroupType("drawingsForAllSymbols")}phantomSources(){return this._getSourcesByGroupType("phantom")}allExceptLineAndTradingSources(){return this._getSourcesByGroupType("restRowSources")}hitTestSources(){if(!this._groupedSources.has("hitTest")){const e=this.allExceptLineAndTradingSources().concat(this.lineSources());this._groupedSources.set("hitTest",e)}return(0,n.ensureDefined)(this._groupedSources.get("hitTest"))}generalSources(){if(!this._groupedSources.has("general")){const e=this.allExceptLineAndTradingSources().concat(this.lineSources());this._groupedSources.set("general",(0,ne.sortSources)(e))}return(0,n.ensureDefined)(this._groupedSources.get("general"))}leftPriceScalesSources(){return this._getSourcesByGroupType("leftPriceScale")}rightPriceScalesSources(){return this._getSourcesByGroupType("rightPriceScale")}overlayPriceScaleSources(){return this._getSourcesByGroupType("overlayPriceScale")}legendViewSources(){return this._getSourcesByGroupType("legendViewSources")}_getSourcesByGroupType(e){const t=(0,n.ensureDefined)(ae.get(e));return this._groupedSources.has(t)?this._groupedSources.has(e)||this._groupSources(e):(this._sortSources(),this._groupSources(e)),(0,n.ensureDefined)(this._groupedSources.get(e))}_sortSources(){null===this._sources&&(this._sources=this._pane.dataSources());const e=(0,ne.sortSources)(this._sources),t=e.filter((e=>!(0,S.isLineTool)(e)||e.isActualSymbol()&&e.isActualCurrency()&&e.isActualUnit())) +;this._groupedSources.set("allSorted",e),this._groupedSources.set("visibleSorted",t)}_groupSources(e){const t=(0,n.ensureDefined)(ae.get(e)),i=oe.get(e);if(void 0!==i){const s=(0,n.ensureDefined)(this._groupedSources.get(t)).filter((e=>i(e,this._pane)));this._groupedSources.set(e,s)}}}var he=i(15367),de=i(34256),ue=i(78211),pe=i(76544),_e=i(18611),me=i(26512),ge=i(37160);class fe{constructor(e,t){if(this._base=e,this._integralDividers=t,(0,ge.isBaseDecimal)(this._base))this._fractionalDividers=[2,2.5,2];else{this._fractionalDividers=[];for(let e=this._base;1!==e;){if(e%2==0)this._fractionalDividers.push(2),e/=2;else{if(e%5!=0)throw new Error("unexpected base");this._fractionalDividers.push(2),this._fractionalDividers.push(2.5),e/=5}if(this._fractionalDividers.length>100)throw new Error("something wrong with base")}}}tickSpan(e,t,i){const s=0===this._base?0:1/this._base,r=Math.min(1e-14,(e-t)/1e3);let n=Math.pow(10,Math.max(0,Math.ceil((0,ge.log10)(e-t)))),o=0,a=this._integralDividers[0];for(;;){const e=(0,ge.greaterOrEqual)(n,s,r)&&n>s+r,t=(0,ge.greaterOrEqual)(n,i*a,r),l=(0,ge.greaterOrEqual)(n,1,r);if(!(e&&t&&l))break;n/=a,a=this._integralDividers[++o%this._integralDividers.length]}if(n<=s+r&&(n=s),n=Math.max(1,n),this._fractionalDividers.length>0&&(0,ge.equal)(n,1,r))for(o=0,a=this._fractionalDividers[0];(0,ge.greaterOrEqual)(n,i*a,r)&&n>s+r;)n/=a,a=this._fractionalDividers[++o%this._fractionalDividers.length];return n}}class ve{constructor(e,t,i,s){this._marks=null,this._priceScale=e,this._base=t,this._coordinateToLogicalFunc=i,this._logicalToCoordinateFunc=s}base(){return this._base}setBase(e){if(e<0)throw new Error("base < 0");this._base=e}tickSpan(e,t,i=0){if(ei&&(l=c);const h=o.tickSpan(e,t,r);h>i&&(l=Math.min(l,h));const d=a.tickSpan(e,t,r);return d>i&&(l=Math.min(l,d)),l>0?l:e-t}rebuildTickMarks(){this._marks=null}marks(){return null===this._marks&&(this._marks=this._rebuildTickMarksImpl()),this._marks}_fontHeight(){return this._priceScale.fontSize()}_tickMarkHeight(){return Math.ceil(2.5*this._fontHeight())}_rebuildTickMarksImpl(){const e=this._priceScale,t=[],i=e.mainSource();if(e.isEmpty()||null===i)return t;let s=i.firstValue();null===s&&(s=0);const r=e.height(),n=this._coordinateToLogicalFunc(r-1,s),o=this._coordinateToLogicalFunc(0,s),a=Math.max(n,o),l=Math.min(n,o);if(a===l)return t;let c=this.tickSpan(a,l),h=a%c;h+=h<0?c:0;const d=a>=l?1:-1;let u=null;const p=e.formatter();let _=NaN;for(let i=a-h;i>l;i-=c){i===_&&(c=this.tickSpan(a,l,c)),_=i;const r=this._logicalToCoordinateFunc(i,s);null!==u&&Math.abs(r-u){const e=this.mainSource();if(e&&e.model()){const t=e.model().paneForSource(e);t&&e.model().updatePane(t)}})),this._scalesProperties.subscribe(this,(()=>{this._marksCache=null})),this._properties.childs().lockScale.subscribe(this,this._updateResetAvailableValue),this._properties.childs().autoScale.subscribe(this,this._updateResetAvailableValue),this._updateResetAvailableValue(),this.setId((0,J.randomHash)())}id(){return this._id}setId(e){this._id=e}isLog(){return this._properties.childs().log.value()}isPercentage(){return this._properties.childs().percentage.value()}isInverted(){return this._properties.childs().isInverted.value()}isIndexedTo100(){return this._properties.childs().indexedTo100.value()}isAutoScale(){return this._properties.childs().autoScale.value()&&!this.isLockScale()}isLockScale(){return this._properties.childs().lockScale.value()}isRegular(){return!this.isPercentage()&&!this.isLog()&&!this.isIndexedTo100()}properties(){return this._properties}height(){return this.m_height}setHeight(e){this.m_height!==e&&(this.m_height=e,this._invalidateInternalHeightCache(),this._marksCache=null)}internalHeight(){if(this._internalHeightCache)return this._internalHeightCache +;const e=this.height()-this.topPixelMargin()-this.bottomPixelMargin();return this._internalHeightCache=e,e}fontSize(){return this._scalesProperties.childs().fontSize.value()}priceRange(){return this._makeSureItIsValid(),this.m_priceRange}setPriceRange(e,t,i){if(!(e instanceof de.PriceRange))throw new TypeError("incorrect price range");const s=this.m_priceRange;if(!t&&de.PriceRange.compare(s,e))return;const r=null!==this._maxPriceRange&&this._maxPriceRange.containsStrictly(e),n=null!==this._minPriceRange&&e.containsStrictly(this._minPriceRange);this.isLockScale()&&!t&&(r||n)||(this._marksCache=null,this.m_priceRange=e,i||this._priceRangeChanged.fire(s,e))}setMinPriceRange(e){this._minPriceRange=e}setMaxPriceRange(e){this._maxPriceRange=e}recalculatePriceRangeOnce(){this._recalculatePriceRangeOnce=!0}priceRangeShouldBeRecalculatedOnce(){if(!this._recalculatePriceRangeOnce||this.isLockScale())return!1;const e=this.mainSource();return null!==e&&e.priceRangeReady()}priceRangeChanged(){return this._priceRangeChanged}mode(){const e=this._properties.childs();return{autoScale:e.autoScale.value(),lockScale:e.lockScale.value(),percentage:e.percentage.value(),indexedTo100:e.indexedTo100.value(),log:e.log.value()}}setMode(e){const t={},i=this.mode(),s=this._properties.state();let r=null;void 0!==e.autoScale&&e.autoScale!==s.autoScale&&(t.autoScale=e.autoScale,this._setAutoScaleValueWithDependentProperties(e.autoScale)),void 0!==e.lockScale&&e.lockScale!==s.lockScale&&(t.lockScale=e.lockScale,this._setLockScaleValueWithDependentProperties(e.lockScale)),void 0!==e.percentage&&e.percentage!==s.percentage&&(t.percentage=e.percentage,this._setPercentageValueWithDependentProperties(e.percentage),this._invalidatedForRange.isValid=!1),void 0!==e.indexedTo100&&e.indexedTo100!==s.indexedTo100&&(t.indexedTo100=e.indexedTo100,this._setIndexedTo100ValueWithDependentProperties(e.indexedTo100),this._invalidatedForRange.isValid=!1),void 0!==e.log&&e.log!==s.log&&(t.log=e.log,this._setLogValueWithDependentProperties(e.log));const n=this._properties.childs();s.log&&!n.log.value()&&(this._canConvertPriceRangeFromLog(this.m_priceRange)?(r=this._convertPriceRangeFromLog(this.m_priceRange),null!==r&&this.setPriceRange(r)):n.autoScale.setValue(!0)),!s.log&&n.log.value()&&(r=this._convertPriceRangeToLog(this.m_priceRange),null!==r&&this.setPriceRange(r)),s.autoScale!==n.autoScale.value()&&n.autoScale.listeners().fire(n.autoScale),s.autoScaleDisabled!==n.autoScaleDisabled.value()&&n.autoScaleDisabled.listeners().fire(n.autoScaleDisabled),s.lockScale!==n.lockScale.value()&&n.lockScale.listeners().fire(n.lockScale),s.percentage!==n.percentage.value()&&(n.percentage.listeners().fire(n.percentage),this.updateFormatter()),s.indexedTo100!==n.indexedTo100.value()&&(n.indexedTo100.listeners().fire(n.indexedTo100),this.updateFormatter()),s.percentageDisabled!==n.percentageDisabled.value()&&n.percentageDisabled.listeners().fire(n.percentageDisabled),s.log!==n.log.value()&&n.log.listeners().fire(n.log), +s.logDisabled!==n.logDisabled.value()&&n.logDisabled.listeners().fire(n.logDisabled),void 0===t.log&&void 0===t.percentage&&void 0===t.lockScale&&void 0===t.autoScale&&void 0===t.indexedTo100||this._modeChanged.fire(i,this.mode())}modeChanged(){return this._modeChanged}isEmpty(){return this._makeSureItIsValid(),0===this.m_height||!this.m_priceRange||this.m_priceRange.isEmpty()}canDetachSource(e){return this.m_dataSources.some((t=>t!==e&&(0,re.isPriceDataSource)(t)&&!((0,j.isStudy)(t)&&t.isLinkedToSeries())))}updateAllViews(e){const t=this._getSourcesToUpdateViews();for(const i of t)i.updateAllViews(e)}logFormula(){return this._logFormula}state(){var e;const t=this._properties.childs();return{id:this._id,m_priceRange:this.isAutoScale()?null:(null===(e=this.priceRange())||void 0===e?void 0:e.serialize())||null,m_isAutoScale:this.isAutoScale(),m_isPercentage:t.percentage.value(),m_isIndexedTo100:t.indexedTo100.value(),m_isLog:t.log.value(),m_isLockScale:this.isLockScale(),m_isInverted:this.isInverted(),m_topMargin:this._margins.top,m_bottomMargin:this._margins.bottom,alignLabels:t.alignLabels.value(),logFormula:(0,ie.clone)(this._logFormula)}}restoreState(e){let t=e.m_priceRange;if(void 0===t)throw new TypeError("invalid state");if(void 0===e.m_isAutoScale)throw new TypeError("invalid state");void 0!==e.id&&(this._id=e.id);const i={autoScale:e.m_isAutoScale};void 0!==e.m_isPercentage&&(i.percentage=e.m_isPercentage),void 0!==e.m_isIndexedTo100&&(i.indexedTo100=e.m_isIndexedTo100),void 0!==e.m_isLog&&(i.log=e.m_isLog),void 0!==e.m_isLockScale&&(i.lockScale=e.m_isLockScale),void 0!==e.m_isInverted&&this._properties.childs().isInverted.setValue(e.m_isInverted),this.setMode(i),t?(t instanceof de.PriceRange||(t=new de.PriceRange(t)),this.setPriceRange(t,!0)):this.clearPriceRange(),e.logFormula&&(this._logFormula=e.logFormula),void 0!==e.m_topMargin&&(this._margins.top=e.m_topMargin),void 0!==e.m_bottomMargin&&(this._margins.bottom=e.m_bottomMargin),void 0!==e.alignLabels&&this._properties.childs().alignLabels.setValue(e.alignLabels),this._mainSource=null,this._scaleSeriesOnly=!1}priceToLogical(e){return this.isLog()&&e?(0,ue.toLog)(e,this._logFormula):e}logicalToPrice(e){return this.isLog()?(0,ue.fromLog)(e,this._logFormula):e}priceToCoordinate(e,t){const i=this._priceToPercentOrIndexedTo100IfNeeded(e,t);return this._logicalToCoordinate(i)}coordinateToPrice(e,t){let i=this._coordinateToLogical(e);return this.isPercentage()?i=(0,ue.fromPercent)(i,t):this.isIndexedTo100()&&(i=(0,ue.fromIndexedTo100)(i,t)),i}mainSource(){if(null!==this._mainSource)return this._mainSource;let e;for(const t of this.m_dataSources){if(t instanceof pe.Series){e=t;break}!e&&(0,re.isPriceDataSource)(t)&&(e=t)}return this._mainSource=e||null,this._correctedMarginsCache=null,this._mainSource}pricesArrayToCoordinates(e,t,i){this._makeSureItIsValid();const s=this.bottomPixelMargin(),r=(0,n.ensureNotNull)(this.priceRange()),o=r.minValue(),a=r.maxValue(),l=this.internalHeight()-1,c=this.isInverted(),h=l/(a-o);void 0===i&&(i=e.length) +;const d=this.isPercentage(),u=this.isIndexedTo100(),p=this.isLog(),_=this.m_height;let m,g;for(let r=0;re?(0,ue.toLog)(e,this._logFormula):e),0===s.length)return;const h="open"in s[0],d="close"in s[0];if(null!==c)for(let e=0;ethis._currencyCache=null)),e.unitChanged().subscribe(this,(()=>this._unitCache=null)),(0,_e.isSymbolSource)(e)&&(this._seriesLikeSources.push(e),e.symbolResolved().subscribe(this,(()=>{this._currencyCache=null,this._unitCache=null,this._measureUnitIdCache=null})),e.isActingAsSymbolSource().subscribe(this._boundOnSourceIsActingAsSymbolSourceChanged),e instanceof pe.Series)){const t=e.properties();this._hasSeries||(t.childs().lockScale&&(this.setMode({lockScale:t.childs().lockScale.value()}),t.removeProperty("lockScale")),t.childs().pnfStyle.child("lockScale")&&t.childs().pnfStyle.removeProperty("lockScale")),this._hasSeries=!0}e.isSpeciallyZOrderedSource()||(this._sourcesThatAffectVisibility.push(e),e.properties().childs().visible.listeners().subscribe(this,this._onSourceVisibilityChanged))}(0,j.isStudy)(e)&&(e.onIsActualIntervalChange().subscribe(this,this._dropScaleCache),e.onHibernationStateChange().subscribe(this,this._dropScaleCache),0===this._studiesCount&&(0,Se.hideAllIndicators)().subscribe(this,this._dropScaleCache),this._studiesCount++),(0,S.isLineTool)(e)&&(0===this._drawingCount&&(0,Se.hideAllDrawings)().subscribe(this,this._dropScaleCache),this._drawingCount++),this.m_dataSources.push(e),this._mainSource=null,this._correctedMarginsCache=null,this._sourcesToUpdateViews=null,this._dropScaleCache(),this.updateFormatter(),this._initScaleProperties(),this.invalidateSourcesCache(),this._updateIsVisible()}}removeDataSource(e){const t=this.m_dataSources.indexOf(e);if((0,n.assert)(-1!==t,"Source is not attached to scale"),this.m_dataSources.splice(t,1),(0,re.isPriceDataSource)(e)){const t=this._priceDataSources.indexOf(e);if((0,n.assert)(-1!==t,"Source is not found"),this._priceDataSources.splice(t,1),(0,_e.isSymbolSource)(e)){const t=this._seriesLikeSources.indexOf(e);(0,n.assert)(-1!==t,"Source is not found"),this._seriesLikeSources.splice(t,1),e.symbolResolved().unsubscribeAll(this),e.isActingAsSymbolSource().unsubscribe(this._boundOnSourceIsActingAsSymbolSourceChanged),e instanceof pe.Series&&(this._hasSeries=!1)}e.currencyChanged().unsubscribeAll(this),e.unitChanged().unsubscribeAll(this)}this.mainSource()||this.setMode({autoScale:!0}),(0,j.isStudy)(e)&&(e.onIsActualIntervalChange().unsubscribe(this,this._dropScaleCache),e.onHibernationStateChange().unsubscribe(this,this._dropScaleCache),this._studiesCount--, +0===this._studiesCount&&(0,Se.hideAllIndicators)().unsubscribe(this,this._dropScaleCache)),(0,S.isLineTool)(e)&&(this._drawingCount--,0===this._drawingCount&&(0,Se.hideAllDrawings)().unsubscribe(this,this._dropScaleCache));const i=this._sourcesThatAffectVisibility.indexOf(e);-1!==i&&(this._sourcesThatAffectVisibility.splice(i,1),e.properties().childs().visible.listeners().unsubscribe(this,this._onSourceVisibilityChanged)),this._mainSource=null,this._correctedMarginsCache=null,this._sourcesForAutoscale=null,this._sourcesToUpdateViews=null,this.updateFormatter(),this.invalidateSourcesCache(),this._updateIsVisible(),0===this.m_dataSources.length&&this._lastSourceRemoved.fire(),this._currencyCache=null,this._unitCache=null,this._measureUnitIdCache=null}currency(e){if(null!==this._currencyCache&&e.size()===this._currencyCache.availableCurrenciesCount)return this._currencyCache.value;let t;const i=new Set,s=new Set,r=new Set,o=new Map;let a,l=0===this._seriesLikeSources.length,c=!0,h=0,d=0;const u=this._seriesLikeSources.filter(_e.isActingAsSymbolSource);for(const d of u){if(!d.isVisible())continue;const u=d.symbolInfo();if(null===u){t=null;break}const p=(0,O.symbolOriginalCurrency)(u);if(null===p){t=null;break}o.set(p,(0,n.ensureNotNull)((0,O.symbolOriginalCurrency)(u,!0)));const _=d.currency();if(null===_){t=null;break}o.set(_,(0,n.ensureNotNull)((0,O.symbolCurrency)(u,!0)));const m=(0,O.symbolBaseCurrency)(u);null!==m&&s.add(m),c=c&&p===_,r.add(_),i.add(p),void 0===a?a=_:null!==a&&a!==_&&(a=null),l||e.convertible(_)&&(0,O.symbolCurrencyConvertible)(u)||(l=!0),h+=1}if(null!==t)for(const i of this._priceDataSources){if(u.includes(i))continue;const s=i;if(!s.isCurrencySource()||!s.isVisible())continue;const c=s.currency();if(null===c){t=null;break}r.add(c),d+=1;const h=(0,n.ensureNotNull)(s.symbolSource()),p=s.currencySourceSymbolInfo();if(null===p){t=null;break}if(l||e.convertible(c)&&(0,O.symbolCurrencyConvertible)(p)||(l=!0),o.set(c,(0,n.ensureNotNull)((0,O.symbolCurrency)(p,!0))),u.includes(h)||(l=!0),void 0===a)a=c;else if(null!==a&&a!==c){a=null;break}}return void 0===t&&(t=0===h&&0===d?null:{readOnly:l,selectedCurrency:a||null,currencies:r,originalCurrencies:i,baseCurrencies:s,symbolSourceCount:h,allCurrenciesAreOriginal:c,displayedValues:o}),this._currencyCache={value:t,availableCurrenciesCount:e.size()},t}unit(e){if(null!==this._unitCache&&e.size()===this._unitCache.availableUnitsCount)return this._unitCache.value;let t;const i=new Set,s=new Set,r=new Map,o=new Map;let a,l=0===this._seriesLikeSources.length?new Set:e.allGroups(),c=!0,h=0,d=0;const u=this._seriesLikeSources.filter(_e.isActingAsSymbolSource);for(const n of u){if(!n.isVisible())continue;const d=n.symbolInfo();if(null===d){t=null;break}const u=(0,O.symbolOriginalUnit)(d,n.model().unitConversionEnabled());if(null===u){t=null;break}r.set(u,e.name(u)),o.set(u,e.description(u));const p=n.unit();if(null===p){t=null;break}if(r.set(p,e.name(p)),o.set(p,e.description(p)),c=c&&u===p,s.add(p),i.add(u),void 0===a?a=p:null!==a&&a!==p&&(a=null),l.size>0){ +const t=(0,me.unitConvertibleGroups)(d,p,e);l=(0,v.intersect)(l,new Set(t))}h+=1}if(null!==t)for(const i of this._priceDataSources){if(u.includes(i))continue;const c=i;if(!c.isUnitSource()||!c.isVisible())continue;const h=c.unit();if(null===h){t=null;break}s.add(h),d+=1;const p=(0,n.ensureNotNull)(c.symbolSource()),_=p.symbolInfo();if(null===_){t=null;break}if(l.size>0){const t=(0,me.unitConvertibleGroups)(_,h,e);l=(0,v.intersect)(l,new Set(t))}if(r.set(h,e.name(h)),o.set(h,e.description(h)),u.includes(p)||(l=new Set),void 0===a)a=h;else if(null!==a&&a!==h){a=null;break}}if(void 0===t)if(0===h&&0===d)t=null;else{t={availableGroups:l,selectedUnit:a||null,units:s,originalUnits:i,symbolSourceCount:h,allUnitsAreOriginal:c,names:r,descriptions:o}}return this._unitCache={value:t,availableUnitsCount:e.size()},t}measureUnitId(e){if(null!==this._measureUnitIdCache&&e.size()===this._measureUnitIdCache.availableUnitsCount)return this._measureUnitIdCache.value;let t,i;const s=new Map,r=new Map,n=new Set;let o=0;const a=this._seriesLikeSources.filter(_e.isActingAsSymbolSource);for(const l of a){if(!l.isVisible())continue;const a=l.measureUnitId();if(null===a){t=null;break}n.add(a),s.set(a,e.name(a)),r.set(a,e.description(a)),void 0===i?i=a:null!==i&&i!==a&&(i=null),o+=1}return void 0===t&&(t=0===o?null:{selectedMeasureUnitId:i||null,measureUnitIds:n,names:s,descriptions:r,symbolSourceCount:o}),this._measureUnitIdCache={value:t,availableUnitsCount:e.size()},t}setMargins(e){if(!(0,ie.isNumber)(e.top)||!(0,ie.isNumber)(e.bottom))throw new TypeError("invalid margin");if(e.top<0||e.top>30||e.bottom<0||e.bottom>30)throw new RangeError("invalid margin");this._margins.top===e.top&&this._margins.bottom===e.bottom||(this._margins=e,this._correctedMarginsCache=null,this._invalidateInternalHeightCache(),this._marksCache=null)}topMargin(){return this._correctedMargins().top}bottomMargin(){return this._correctedMargins().bottom}invalidateMargins(){this._correctedMarginsCache=null}topPixelMargin(){return this.isInverted()?this.bottomMargin()*this.height()+this._bottomPixelMargin:this.topMargin()*this.height()+this._topPixelMargin}bottomPixelMargin(){return this.isInverted()?this.topMargin()*this.height()+this._topPixelMargin:this.bottomMargin()*this.height()+this._bottomPixelMargin}marks(){return this.isEmpty()?(this._marksCache=null,[]):(null===this._marksCache&&(this._markBuilder.rebuildTickMarks(),this._marksCache=this._markBuilder.marks(),this._onMarksChanged.fire()),this._marksCache)}onMarksChanged(){return this._onMarksChanged}priceRangeInPrice(){if(this.isEmpty())return null;const e=this.mainSource();if(null===e)return null;const t=(0,n.ensureNotNull)(e.firstValue()),i=this.height();return{from:this.coordinateToPrice(i-1,t),to:this.coordinateToPrice(0,t)}}setPriceRangeInPrice(e){if(this.isPercentage()||this.isIndexedTo100())return;const t=this.isInverted(),i=t?this.bottomMargin():this.topMargin(),s=t?this.topMargin():this.bottomMargin(),r=this.isLog();let n=r?(0,ue.toLog)(e.from,this._logFormula):e.from,o=r?(0, +ue.toLog)(e.to,this._logFormula):e.to;const a=o-n;n+=s*a,o-=i*a,this.setMode({autoScale:!1}),this.setPriceRange(new de.PriceRange(n,o)),this._marksCache=null,this._onMarksChanged.fire()}hasMainSeries(){return this._hasSeries}getStudies(){return this.dataSources().filter(j.isStudy)}lastSourceRemoved(){return this._lastSourceRemoved}sourcesForAutoscale(){return this._mainSource&&this._scaleSeriesOnly!==this._scalesProperties.childs().scaleSeriesOnly.value()&&(this._sourcesForAutoscale=null),this._sourcesForAutoscale||(this._sourcesForAutoscale=this._recalculateSourcesForAutoscale()),this._sourcesForAutoscale}recalculatePriceRange(e){this._invalidatedForRange={visibleBars:e,isValid:!1}}internalHeightChanged(){return this._internalHeightChanged}orderedSources(){if(this._cachedOrderedSoruces)return this._cachedOrderedSoruces;let e=this.m_dataSources.slice();return e=(0,ne.sortSources)(e),this._cachedOrderedSoruces=e,this._cachedOrderedSoruces}invalidateSourcesCache(){this._cachedOrderedSoruces=null,this._sourcesToUpdateViews=null}startScale(e){var t,i;this.isEmpty()||this.isPercentage()||this.isIndexedTo100()||null!==this._scaleStartPoint||null!==this._priceRangeSnapshot||(this._scaleStartPoint=this.m_height-e,this._priceRangeSnapshot=null!==(i=null===(t=this.priceRange())||void 0===t?void 0:t.clone())&&void 0!==i?i:null)}scaleTo(e){if(this.isPercentage()||this.isIndexedTo100()||null===this._scaleStartPoint)return;this.setMode({autoScale:!1}),(e=this.m_height-e)<0&&(e=0);let t=(this._scaleStartPoint+.2*(this.m_height-1))/(e+.2*(this.m_height-1));const i=(0,n.ensureNotNull)(this._priceRangeSnapshot).clone();t=Math.max(t,.1),i.scaleAroundCenter(t),this.setPriceRange(i)}endScale(){this.isPercentage()||this.isIndexedTo100()||null!==this._scaleStartPoint&&(this._scaleStartPoint=null,this._priceRangeSnapshot=null)}startTwoPointsScale(e,t){if(this.isEmpty()||this.isPercentage()||this.isIndexedTo100()||null!==this._twoPointsScaleStartPosition)return;const i=Math.min(e,t),s=Math.max(e,t);this._twoPointsScaleStartPosition={topLogical:this._coordinateToLogical(i),bottomLogical:this._coordinateToLogical(s)}}twoPointsScale(e,t){if(this.isPercentage()||this.isIndexedTo100()||null===this._twoPointsScaleStartPosition)return;this.setMode({autoScale:!1});const i=Math.min(e,t),s=Math.max(e,t),{topLogical:r,bottomLogical:n}=this._twoPointsScaleStartPosition,o=this.bottomPixelMargin(),a=this.internalHeight()-1,l=(this._invertedCoordinate(i)-o)/a,c=(n-r)/((this._invertedCoordinate(s)-o)/a-l);if(!Number.isFinite(c))return;const h=r-c*l,d=h+c;this.setPriceRange(new de.PriceRange(this.priceToLogical(h),this.priceToLogical(d)))}endTwoPointsScale(){this._twoPointsScaleStartPosition=null}startScroll(e){var t,i;this.isAutoScale()||null===this._scrollStartPoint&&null===this._priceRangeSnapshot&&(this.isEmpty()||(this._scrollStartPoint=e,this._priceRangeSnapshot=null!==(i=null===(t=this.priceRange())||void 0===t?void 0:t.clone())&&void 0!==i?i:null))}scrollTo(e){if(this.isAutoScale())return +;if(null===this._scrollStartPoint||null===this._priceRangeSnapshot)return;const t=this.priceRange();if(null===t)return;let i=e-this._scrollStartPoint;this.isInverted()&&(i*=-1);const s=i*(t.length()/(this.internalHeight()-1)),r=this._priceRangeSnapshot.clone();r.shift(s),this.setPriceRange(r,!0),this._marksCache=null}endScroll(){this.isAutoScale()||null!==this._scrollStartPoint&&(this._scrollStartPoint=null,this._priceRangeSnapshot=null)}clearPriceRange(){this.m_priceRange=null,this.recalculatePriceRangeOnce()}isVisible(){return this._isVisible}_recalculateSourcesForAutoscale(){this._mainSource&&(this._scaleSeriesOnly=this._scalesProperties.childs().scaleSeriesOnly.value());const e=this._scaleSeriesOnly&&this._hasSeries;return this.m_dataSources.filter((t=>!!(t.properties().visible.value()||t instanceof pe.Series)&&(e?t instanceof pe.Series:(0,j.isStudy)(t)?!t.isSourceHidden()&&t.isIncludedInAutoScale():t.isIncludedInAutoScale())))}_updateAutoScaleDisabledProperty(e){const t=this._properties.childs(),i=t.indexedTo100.value()||t.percentage.value()||t.lockScale.value();e?t.autoScaleDisabled.setValueSilently(i):t.autoScaleDisabled.setValue(i)}_setAutoScaleValueWithDependentProperties(e){const t=this._properties.childs();t.autoScale.setValueSilently(e),e&&(t.percentage.setValueSilently(!1),t.indexedTo100.setValueSilently(!1),t.lockScale.setValueSilently(!1),t.logDisabled.setValueSilently(!1)),this._updateAutoScaleDisabledProperty(!0)}_setLockScaleValueWithDependentProperties(e){const t=this._properties.childs();t.lockScale.setValueSilently(e),e&&(t.autoScale.setValueSilently(!1),t.percentage.setValueSilently(!1),t.indexedTo100.setValueSilently(!1),t.log.setValueSilently(!1)),t.percentageDisabled.setValueSilently(e),t.logDisabled.setValueSilently(e),this._updateAutoScaleDisabledProperty(!0)}_setPercentageValueWithDependentProperties(e){const t=this._properties.childs();t.percentage.setValueSilently(e),e&&(t.autoScale.setValueSilently(!0),t.log.setValueSilently(!1),t.lockScale.setValueSilently(!1),t.indexedTo100.setValueSilently(!1)),this._updateAutoScaleDisabledProperty(!0)}_setIndexedTo100ValueWithDependentProperties(e){const t=this._properties.childs();t.indexedTo100.setValueSilently(e),e&&(t.autoScale.setValueSilently(!0),t.log.setValueSilently(!1),t.lockScale.setValueSilently(!1),t.percentage.setValueSilently(!1)),this._updateAutoScaleDisabledProperty(!0)}_setLogValueWithDependentProperties(e){const t=this._properties.childs();t.log.setValueSilently(e),e&&(t.lockScale.setValueSilently(!1),t.percentage.setValueSilently(!1),t.indexedTo100.setValueSilently(!1)),this._updateAutoScaleDisabledProperty(!0)}_recalculatePriceRangeImpl(){const e=this._invalidatedForRange.visibleBars;if(null===e)return;let t=null;const i=this.sourcesForAutoscale(),s=this.isPercentage(),r=this.isIndexedTo100();let n=0,o=0;for(const a of i){if(!a.properties().visible.value())continue;const i=a.firstValue();if(null===i||s&&0===i)continue;const l=e.firstBar(),c=e.lastBar(),h=a.autoScaleInfo(l,c);let d=h.range;d&&(s?d=(0, +ue.toPercentRange)(d,i):r&&(d=(0,ue.toIndexedTo100Range)(d,i)),t=null===t?d:t.merge(d)),void 0!==h.topPixelMargin&&(n=Math.max(n,h.topPixelMargin)),void 0!==h.bottomPixelMargin&&(o=Math.max(o,h.bottomPixelMargin))}if((Math.abs(n-this._topPixelMargin)>0||Math.abs(o-this._bottomPixelMargin)>0)&&(this._bottomPixelMargin=o,this._topPixelMargin=n,this._marksCache=null,this._invalidateInternalHeightCache()),t){if(t.minValue()===t.maxValue()&&(t=new de.PriceRange(t.minValue()-.5,t.maxValue()+.5)),this.isLog()){const e=this._convertPriceRangeFromLog(t),i=(0,ue.logFormulaForPriceRange)(e);if(!(0,ue.logFormulasAreSame)(i,this._logFormula)){const s=this._priceRangeSnapshot?this._convertPriceRangeFromLog(this._priceRangeSnapshot):null;this._logFormula=i,t=this._convertPriceRangeToLog(e),s&&(this._priceRangeSnapshot=this._convertPriceRangeToLog(s))}}this.setPriceRange(t)}else this.m_priceRange||(this.setPriceRange(new de.PriceRange(-.5,.5)),this._logFormula=(0,ue.logFormulaForPriceRange)(null));this._invalidatedForRange.isValid=!0;const a=this.mainSource();null!==a&&this._recalculatePriceRangeOnce&&(this._recalculatePriceRangeOnce=!a.priceRangeReady())}_makeSureItIsValid(){this._invalidatedForRange.isValid||(this._invalidatedForRange.isValid=!0,this._recalculatePriceRangeImpl())}_invalidateInternalHeightCache(){this._internalHeightCache=null,this._internalHeightChanged.fire()}_coordinateToLogical(e){if(this._makeSureItIsValid(),this.isEmpty())return 0;const t=this._invertedCoordinate(e),i=(0,n.ensureNotNull)(this.priceRange()),s=i.minValue()+(i.maxValue()-i.minValue())*((t-this.bottomPixelMargin())/(this.internalHeight()-1));return this.logicalToPrice(s)}_logicalToCoordinate(e){if(this._makeSureItIsValid(),this.isEmpty())return 0;e=this.priceToLogical(e);const t=(0,n.ensureNotNull)(this.priceRange()),i=this.bottomPixelMargin()+(this.internalHeight()-1)*(e-t.minValue())/(t.maxValue()-t.minValue());return this._invertedCoordinate(i)}_convertPriceRangeFromLog(e){if(null===e)return null;const t=(0,ue.fromLog)(e.minValue(),this._logFormula),i=(0,ue.fromLog)(e.maxValue(),this._logFormula);return new de.PriceRange(t,i)}_convertPriceRangeToLog(e){if(null===e)return null;const t=(0,ue.toLog)(e.minValue(),this._logFormula),i=(0,ue.toLog)(e.maxValue(),this._logFormula);return new de.PriceRange(t,i)}_canConvertPriceRangeFromLog(e){if(null===e)return!1;const t=(0,ue.fromLog)(e.minValue(),this._logFormula),i=(0,ue.fromLog)(e.maxValue(),this._logFormula);return isFinite(t)&&isFinite(i)}_onSourceVisibilityChanged(){this._dropScaleCache(),this._updateIsVisible()}_dropScaleCache(){this._sourcesForAutoscale=null,this._currencyCache=null,this._unitCache=null,this._measureUnitIdCache=null}_updateIsVisible(){if(!be)return void this._isVisible.setValue(!0);const e=this._sourcesThatAffectVisibility.some((e=>e.isVisible()));this._isVisible.setValue(e)}_invertedCoordinate(e){return this.isInverted()?e:this.height()-1-e}_initScaleProperties(){const e=this.isLockScale(),t=this.properties().childs();e&&(t.percentage.setValue(!1),t.indexedTo100.setValue(!1), +t.log.setValue(!1),t.autoScale.setValue(!1)),t.percentageDisabled.setValue(e),t.logDisabled.setValue(e),this._updateAutoScaleDisabledProperty(!1),t.percentage.value()&&(t.log.setValue(!1),t.indexedTo100.setValue(!1)),t.indexedTo100.value()&&(t.log.setValue(!1),t.percentage.setValue(!1))}_correctedMargins(){if(null===this._correctedMarginsCache){const e=this.mainSource();this._correctedMarginsCache=null!==e?e.correctScaleMargins(this._margins):this._margins}return this._correctedMarginsCache}_getSourcesToUpdateViews(){return this._sourcesToUpdateViews||(this._sourcesToUpdateViews=this.m_dataSources.filter((e=>!(0,S.isLineTool)(e)||e.isActualSymbol()&&e.isActualCurrency()))),this._sourcesToUpdateViews}_mainSourceFormatter(){const e=this.mainSource();return(null==e?void 0:e.formatter())||Pe}_priceToPercentOrIndexedTo100IfNeeded(e,t){return this.isPercentage()?(0,ue.toPercent)(e,t):this.isIndexedTo100()?(0,ue.toIndexedTo100)(e,t):e}_onSourceIsActingAsSymbolSourceChanged(){this._dropScaleCache()}_onIsInvertedChanged(){this._marksCache=null,this._markBuilder.rebuildTickMarks()}_updateResetAvailableValue(){this._resetScaleAvailable.setValue(!this.isLockScale()&&!this.isAutoScale())}}var Te=i(29541),Ie=i(63009),Me=i(53588),Le=i(88732),Ae=i(13333);const ke=[],De=[];class Ee{constructor(e){this._studies={},this._deferreds={},this._container=e,ke.push(e),De.push(this)}add(e,t){this._deferreds[e]&&(this._deferreds[e].resolve(t),delete this._deferreds[e]),this._studies[e]=t}get(e){return this._studies[e]?Promise.resolve(this._studies[e]):(this._deferreds[e]||(this._deferreds[e]=(0,p.createDeferredPromise)()),this._deferreds[e].promise)}reset(){const e=ke.indexOf(this._container);~e&&(ke.splice(e,1),De.splice(e,1))}static instance(e){const t=ke.indexOf(e);return~t?De[t]:new Ee(e)}}var Ve=i(99366);var Be=i(4949),Re=i(2823),Ne=i(53086),Oe=i(78856),Fe=i(44010),We=i(87440),He=i(16410);new ee.TranslatedString("update {title} script",c.t(null,void 0,i(50728)));const ze=N.enabled("clear_price_scale_on_error_or_empty_bars"),Ue=(0,X.getLogger)("Chart.Pane");function je(e,t,i){e.setMargins({top:t,bottom:i})}class Ge{constructor(e,t,i,s){this.m_dataSources=[],this._sourceWatchedValuesSubscriptions=new Map,this.m_mainDataSource=null,this._cachedOrderedSources=new ce(this),this._sourcesById=new Map,this._priceSourcesById=new Map,this._sourcePropertiesChanged=new G.Delegate,this._sourcesZOrderChanged=new G.Delegate,this._tagsChanged=new G.Delegate,this._stretchFactor=1e3,this._isInInsertManyDataSourcesState=!1,this._lastLineDataSourceZOrder=null,this._rightPriceScales=[],this._leftPriceScales=[],this._lockedPriceScale=null,this._currentPriceScaleRatio=null,this._onPriceScalesChanged=new G.Delegate,this._isRecalculatingScales=!1,this._priceDataSources=[],this._symbolSources=[],this._lollipopDataSources=[],this._symbolSourceResolved=new G.Delegate,this._symbolSourceResolvingActive=new q.WatchedValue(!1),this._bulkActions={activeCounter:0},this._height=0,this._width=0,this._sizeChanged=new G.Delegate, +this._dataSourcesCollectionChanged=new G.Delegate,this._symbolSourceCollectionChanged=new G.Delegate,this._priceSourcesCollectionChanged=new G.Delegate,this._maximized=new q.WatchedValue(!1),this._collapsed=new q.WatchedValue(!1),this._resetPriceScalesAvailable=new q.WatchedValue(!1),this._destroyed=new G.Delegate,this._executionsPositionController=null,this._seriesDisplayError=null,this._onPriceScaleIsVisibleChanged=()=>{this._model.fullUpdate()},this._recalcSymbolSourceResolvingActive=()=>{for(const e of this._symbolSources)if(e.symbolResolvingActive().value())return void this._symbolSourceResolvingActive.setValue(!0);this._symbolSourceResolvingActive.setValue(!1)},this._onSymbolSourceCollectionChanged=()=>{0===this._bulkActions.activeCounter?this._symbolSourceCollectionChanged.fire():this._bulkActions.symbolSourceCollectionChanged=!0},this._onSeriesDisplayError=e=>{if(null!==e){for(const e of this._leftPriceScales)e.clearPriceRange();for(const e of this._rightPriceScales)e.clearPriceRange()}},this._updateResetPriceScalesAvailableValue=()=>{const e=e=>e.resetScaleAvailable().value(),t=this._leftPriceScales.some(e)||this._rightPriceScales.some(e);this._resetPriceScalesAvailable.setValue(t)},this._priceScaleSelectionStrategy=(0,Q.createPriceScaleSelectionStrategy)(i.properties().childs().priceScaleSelectionStrategyName.value()),this._id=null!=s?s:(0,J.randomHashN)(6),this._timeScale=e,this.m_mainDataSource=null,this._properties=t,this._model=i,i.properties().childs().priceScaleSelectionStrategyName.subscribe(null,(e=>{this._priceScaleSelectionStrategy=(0,Q.createPriceScaleSelectionStrategy)(e.value()),this._priceScaleSelectionStrategy.apply(this)})),this._timeScale.barSpacingChanged().subscribe(this,(()=>{this.m_mainDataSource===this._model.mainSeries()&&this._recalculatePriceScaleByScaleRatio(this.m_mainDataSource.priceScale())})),ze&&(this._seriesDisplayError=(0,O.getSeriesDisplayErrorWV)(this._model.mainSeries()),this._seriesDisplayError.subscribe(this._onSeriesDisplayError)),t.childs().topMargin.subscribe(this,this._updateMargins),t.childs().bottomMargin.subscribe(this,this._updateMargins),this._updateMargins()}destroy(){var e;this._properties.childs().topMargin.unsubscribeAll(this),this._properties.childs().bottomMargin.unsubscribeAll(this),this._model.properties().childs().priceScaleSelectionStrategyName.unsubscribeAll(this),this._timeScale.barSpacingChanged().unsubscribeAll(this),this._leftPriceScales.concat(this._rightPriceScales).forEach((e=>{e.modeChanged().unsubscribeAll(this),e.priceRangeChanged().unsubscribeAll(this),e.internalHeightChanged().unsubscribeAll(this),e.isVisible().unsubscribe(this._onPriceScaleIsVisibleChanged),e.resetScaleAvailable().unsubscribe(this._updateResetPriceScalesAvailableValue)}));for(const e of this.m_dataSources)this.removeSourceFromPriceScale(e),e.destroy&&e.destroy();null===(e=this._seriesDisplayError)||void 0===e||e.destroy(),this._destroyed.fire()}id(){return this._id}bulkActionMacro(e){const t=this._bulkActions;t.activeCounter+=1,e(),t.activeCounter-=1, +0===t.activeCounter&&(this._dataSourcesCollectionChanged.fire(),t.symbolSourceCollectionChanged&&(this._symbolSourceCollectionChanged.fire(),t.symbolSourceCollectionChanged=!1),t.priceSourcesCollectionChanged&&(this._priceSourcesCollectionChanged.fire(),t.priceSourcesCollectionChanged=!1))}defaultPriceScale(){var e,t;const i=null!==(t=null===(e=this.m_mainDataSource)||void 0===e?void 0:e.priceScale())&&void 0!==t?t:null;if(null!==i)return i;const s=this.properties().childs().axisProperties.state();return s.autoScale=!0,new xe(this._model.properties().childs().scalesProperties,s)}leftPriceScales(){return this._leftPriceScales}rightPriceScales(){return this._rightPriceScales}visibleLeftPriceScales(){var e;const t=this._model.priceScaleSlotsCount(),i=this._leftPriceScales.filter((e=>e.isVisible().value())),s=null===(e=this.mainDataSource())||void 0===e?void 0:e.priceScale();if(i.length>t.left&&(null==s?void 0:s.isVisible().value())){const e=(0,v.moveToHead)(i,s);return e.splice(t.left),e}return i}visibleRightPriceScales(){var e;const t=this._model.priceScaleSlotsCount(),i=this._rightPriceScales.filter((e=>e.isVisible().value())),s=null===(e=this.mainDataSource())||void 0===e?void 0:e.priceScale();if(i.length>t.right&&(null==s?void 0:s.isVisible().value())){const e=(0,v.moveToHead)(i,s);return e.splice(t.right),e}return i}clearSeries(e){const t=this._model.mainSeries();for(let i=this.m_dataSources.length-1;i>=0;i--)this.m_dataSources[i]===t&&this._removeSourceFromCollections(i,e)}sourcesByGroup(){return this._cachedOrderedSources}dataSourceForId(e){return this._sourcesById.get(e)||null}changeSourceId(e,t){(0,n.assert)(this.hasDataSource(e));const i=e.id();e.setId(t),this._sourcesById.delete(i),this._sourcesById.set(t,e),(0,re.isPriceDataSource)(e)&&(this._priceSourcesById.delete(i),this._priceSourcesById.set(t,e))}movePriceScale(e,t,i){const s=this.priceScalePosition(e);if(s!==t)this.removePriceScale(e),this._placePriceScale(e,t,i),e.invalidateMargins(),this._invalidateSourcesCache();else if(void 0!==i&&"overlay"!==s){const t="left"===s?this._leftPriceScales:this._rightPriceScales,r=t.indexOf(e);t.splice(r,1),t.splice(i,0,e)}}mainDataSource(){return this.m_mainDataSource}isEmpty(){return null===this.m_mainDataSource}recalculatePriceScale(e,t){if(!e)return;const i=e.sourcesForAutoscale();if((e.isAutoScale()||e.priceRangeShouldBeRecalculatedOnce())&&i&&i.length>0&&!this.timeScale().isEmpty()){const t=this.timeScale().visibleBarsStrictRange();e.recalculatePriceRange(t)}e.updateAllViews(t)}onSourceTagsChanged(){this._tagsChanged.fire()}insertDataSource(e,t,i){e.setZorder(i),t||(t=this.findSuitableScale(e)),this._addSourceToCollections(e);let s=!1;e===this.model().mainSeries()?(this.m_mainDataSource=this.model().mainSeries(),s=!0):null===this.m_mainDataSource&&(0,re.isPriceDataSource)(e)&&(this.m_mainDataSource=e,s=!0),t.addDataSource(e,this._isInInsertManyDataSourcesState),e.setPriceScale(t),t.invalidateMargins(),e.onTagsChanged&&e.onTagsChanged().subscribe(this,this.onSourceTagsChanged),s&&this._processMainSourceChange(), +this._tagsChanged.fire(),(0,re.isPriceDataSource)(e)&&this.recalculatePriceScale(t,(0,W.sourceChangeEvent)(e.id())),this._invalidateSourcesCache()}addDataSource(e,t,i){let s=e.zorder();i||((0,S.isLineTool)(e)&&!e.isSpeciallyZOrderedSource()?(s=null!==this._lastLineDataSourceZOrder?this._lastLineDataSourceZOrder+1:this.newLineToolZOrder(),this._isInInsertManyDataSourcesState&&(this._lastLineDataSourceZOrder=s)):(0,j.isStudy)(e)&&!e.isSpeciallyZOrderedSource()&&(s=this.newStudyZOrder())),this.insertDataSource(e,t,s)}removeDataSource(e,t,i){const s=this.m_dataSources.indexOf(e);if(-1===s)return void Ue.logDebug("removeDataSource: invalid data source");this._removeSourceFromCollections(s,!!i),e!==this.m_mainDataSource||t||(this.m_mainDataSource=null);const r=e.priceScale();this.removeSourceFromPriceScale(e),e.onTagsChanged&&e.onTagsChanged().unsubscribe(this,this.onSourceTagsChanged),(0,re.isPriceDataSource)(e)&&!t&&this._processMainSourceChange(),this._tagsChanged.fire(),r&&(0,re.isPriceDataSource)(e)&&this.recalculatePriceScale(r,(0,W.sourceChangeEvent)(e.id())),this._invalidateSourcesCache()}hasDataSource(e){return this._sourcesById.has(e.id())}hasPriceDataSource(e){return this._priceSourcesById.has(e.id())}dataSources(){return this.m_dataSources}priceDataSources(){return this._priceDataSources}lollipopDataSources(){return this._lollipopDataSources}symbolSources(){return this._symbolSources}replaceSource(e,t,i){const s=this.m_mainDataSource===e,r=e.zorder();this.insertDataSource(t,i,r),this.removeDataSource(e,s),this._sourcesById.set(t.id(),t),(0,re.isPriceDataSource)(t)&&this._priceSourcesById.set(t.id(),t),s&&(this.m_mainDataSource=t,this._processMainSourceChange())}findSuitableScale(e,t,i){return this._priceScaleSelectionStrategy.findSuitableScale(this,e,t,i)}createNewPriceScaleIfPossible(){return this._priceScaleSelectionStrategy.createNewPriceScaleIfPossible(this)}canCreateNewPriceScale(){return this._priceScaleSelectionStrategy.canCreateNewPriceScale(this)}isOverlay(e){const t=e.priceScale();return null===t||"overlay"===this.priceScalePosition(t)}recalculate(e){this._leftPriceScales.forEach((t=>this.recalculatePriceScale(t,e))),this._rightPriceScales.forEach((t=>this.recalculatePriceScale(t,e)));for(const t of this.m_dataSources)this.isOverlay(t)&&!(0,S.isLineTool)(t)&&this.recalculatePriceScale(t.priceScale(),e);this.updateAllViews(e),this._model.updatePane(this)}updateAllViews(e){for(const t of this.m_dataSources)t.updateAllViews(e);for(const t of this.model().customSources())t.updateViewsForPane(this,e)}updateLollipopViews(e){}priceScalePosition(e){return this._leftPriceScales.includes(e)?"left":this._rightPriceScales.includes(e)?"right":"overlay"}createPriceScaleAtPosition(e,t){const i=this.properties().childs().axisProperties.state();i.autoScale=!0;const s=new xe(this.model().properties().childs().scalesProperties,i);return s.setHeight(this.height()),je(s,this._defaultTopMargin(),this._defaultBottomMargin()),this._placePriceScale(s,e,t),s}removePriceScale(e){e.modeChanged().unsubscribeAll(this), +e.priceRangeChanged().unsubscribeAll(this),e.internalHeightChanged().unsubscribeAll(this),e.isVisible().unsubscribe(this._onPriceScaleIsVisibleChanged),e.resetScaleAvailable().unsubscribe(this._updateResetPriceScalesAvailableValue),e===this._lockedPriceScale&&(this._lockedPriceScale=null,this._currentPriceScaleRatio=null);const t=this._leftPriceScales.indexOf(e);-1!==t&&(this._leftPriceScales[t].invalidateMargins(),this._leftPriceScales.splice(t,1));const i=this._rightPriceScales.indexOf(e);if(-1!==i&&(this._rightPriceScales[i].invalidateMargins(),this._rightPriceScales.splice(i,1)),null===e.mainSource()){const t=e.dataSources().length;0!==t&&Ue.logError("Invalid priceScale state: empty mainSource but non-empty data sources="+t)}this._onPriceScalesChanged.fire(),this._updateResetPriceScalesAvailableValue()}priceScaleIndex(e,t){switch(t){case"left":return this.leftPriceScales().indexOf(e);case"right":return this.rightPriceScales().indexOf(e)}}move(e,t,i){const s=e.priceScale();this.removeSourceFromPriceScale(e),t.addDataSource(e),e.setPriceScale(t),t.invalidateMargins(),this._processMainSourceChange(),this._invalidateSourcesCache(),e.isIncludedInAutoScale()&&(null!==s&&this.recalculatePriceScale(s,(0,W.sourceChangeEvent)(e.id())),this.recalculatePriceScale(t,(0,W.sourceChangeEvent)(e.id()))),this._onPriceScalesChanged.fire()}setZOrders(e){e.forEach(((e,t)=>{t.setZorder(e)})),this._invalidateSourcesCache(),0===this._bulkActions.activeCounter&&this._dataSourcesCollectionChanged.fire(),this.model().lightUpdate()}isMainPane(){return this.hasDataSource(this.model().mainSeries())}isLast(){const e=this.model().panes();return e[e.length-1]===this}newStudyZOrder(){return(0,Ie.newStudyZOrder)(this._priceDataSources)}newLineToolZOrder(e){return(0,Ie.newLineToolZOrder)(this.m_dataSources,e)}model(){return this._model}containsMainSeries(){return this._sourcesById.has(this.model().mainSeries().id())}applyPriceScaleRatio(e,t){var i;null!==this._lockedPriceScale&&this._lockedPriceScale!==e||this._currentPriceScaleRatio===t||!this.isMainPane()||null===this._lockedPriceScale&&e!==(null===(i=this.mainDataSource())||void 0===i?void 0:i.priceScale())||(this._setNewPriceRangeByScaleRatio(e,t,this._mainSourceVisiblePriceRange(e),!0,!0),null!==this._lockedPriceScale?this._tryToApplyNewPriceScaleRatio():e.isLog()||this.model().mainSeriesScaleRatioPropertyOnChanged())}sendToBack(e){const t=this.sourcesByGroup().allExceptSpecialSources();this._batchReorder(e,t[0],Ie.moveBeforeSource)}bringToFront(e){const t=this.sourcesByGroup().allExceptSpecialSources();this._batchReorder(e,t[t.length-1],Ie.moveAfterSource)}sendBackward(e){const t=this.sourcesByGroup().allIncludingHidden(),i=t.indexOf(e[0]);if(0===i)this.bringToFront(e);else{const s=t[i-1];this.insertBefore(e,s)}}bringForward(e){const t=this.sourcesByGroup().allExceptSpecialSources(),i=t.indexOf(e[e.length-1]);if(i===t.length-1)this.sendToBack(e);else{const s=t[i+1];this.insertAfter(e,s)}}insertAfter(e,t){this._batchReorder(e,t,Ie.moveAfterSource)}insertBefore(e,t){ +this._batchReorder(e,t,Ie.moveBeforeSource)}maximized(){return this._maximized}collapsed(){return this._collapsed}getPriceScaleById(e){const t=this.m_dataSources.find((t=>{var i;return(null===(i=t.priceScale())||void 0===i?void 0:i.id())===e}));return void 0===t?null:t.priceScale()}priceScaleSelectionStrategy(){return this._priceScaleSelectionStrategy}setPriceScaleSelectionStrategy(e){this._priceScaleSelectionStrategy=e,e.apply(this)}findTargetPriceAxisViews(e,t,i,s){if((0,f.isDataSource)(e)&&this.model().paneForSource(e)!==this)return[];const r=e.priceScale();if(t===r)return i;if(null===r)return[];if("overlay"===this.priceScalePosition(r))return t===this.defaultPriceScale()?i:[];const n=this.priceScalePosition(t);if(n!==this.priceScalePosition(r))return[];const o="left"===n?this.leftPriceScales():this.rightPriceScales();return o.indexOf(t)1}properties(){return this._properties}setPriceAutoScale(e,t){e.setMode({autoScale:t}),this.timeScale().isEmpty()||this.recalculatePriceScale(e,(0,W.viewportChangeEvent)())}state(e,t,i,s,r,n){var o,a;const l={sources:[],mainSourceId:null===(o=this.m_mainDataSource)||void 0===o?void 0:o.id(),stretchFactor:this._stretchFactor,leftAxisesState:[],rightAxisesState:[],overlayPriceScales:{},priceScaleRatio:this._currentPriceScaleRatio},c=new Map,h=e=>{if(c.has(e))return c.get(e);let o=null;const a=i&&!e.isSavedInStudyTemplates()||!e.state||(0,S.isLineTool)(e)&&n||!e.isSavedInChart(Boolean(t))||!(o=e.state(t,r))||s&&(0,S.isLineTool)(e)&&e.isActualSymbol&&!e.isActualSymbol()||e.isPhantom()?null:o;return c.set(e,a),a};if(e){l.sources=[];for(let e=0;enull!==c.get(e),u=e=>!n||!(0,S.isLineTool)(e);l.leftAxisesState=this._leftPriceScales.map((e=>({state:e.state(),sources:e.dataSources().filter(d).filter(u).map((e=>e.id()))}))),l.rightAxisesState=this._rightPriceScales.map((e=>({state:e.state(),sources:e.dataSources().filter(d).filter(u).map((e=>e.id()))}))),l.overlayPriceScales={};for(const e of this.m_dataSources)if(this.isOverlay(e)&&e.isSavedInChart(Boolean(t))){const t=e.priceScale();l.overlayPriceScales[e.id()]=null!==(a=null==t?void 0:t.state())&&void 0!==a?a:null}return l}restoreState(e,t,i,s,r,o,a){r=r||{},e.stretchFactor&&(this._stretchFactor=e.stretchFactor),s=null!=s?s:this._model.mainSeries().id();const l={};if(e.sources){const n=e.sources.filter((e=>{var t;return!!e&&("MainSeries"===e.type||(!(null===(t=e.points)||void 0===t?void 0:t.some((e=>null===e.time_t||!isFinite(e.time_t))))||(Ue.logNormal("Dropped invalid "+e.type+". Reason: non-numeric point time"),!1)))})),c=n.findIndex(Me.isMainSeriesState);-1!==c&&this.model().mainSeries().setObsoleteZOrder(n[c].zorder),i<3&&(0,Ie.reorderDataSourcesStateZOrder)(n);const h=-1!==this.m_dataSources.indexOf(this._model.mainSeries());this.clearSeries(Boolean(a)),this.m_mainDataSource=null, +h&&this._addSourceToCollections(this._model.mainSeries(),a),(()=>{const t=n.find((t=>t.id===e.mainSourceId));if(void 0===t)return void Ue.logWarn("There is no main source with id "+e.mainSourceId+", total sources="+n.length);if(!window.TradingView[t.type]||!(0,he.isLineToolName)(t.type))return void Ue.logNormal("The type of main source is not line tool - fix is unnecessary");let i=null;for(const e of n)if(!window.TradingView[t.type]||!(0,he.isLineToolName)(e.type)){if(null!==i)return void Ue.logWarn("Pane contains more than 1 possibly main sources - auto fix cannot be applied");i=e}if(null===i)return void Ue.logWarn("Pane contains only line tools - possible we need to remove this pane?");const s=e.mainSourceId;let r=0;e.mainSourceId=i.id,n.forEach((e=>{e.ownerSource===s&&(e.ownerSource=null==i?void 0:i.id,r+=1)})),Ue.logNormal("Auto fix broken pane is applied, changed line tools="+r+", changed from="+s+" to="+i.id)})();for(const e of n)if("study_Sessions"===e.type){this.model().sessions().restoreOldState(e,t);break}for(const e of n)"study_Sessions"!==e.type&&(null===this._model.dataSourceForId(e.id)||"MainSeries"===e.type?(l[e.id]=e.ownerSource,(0,Me.isMainSeriesState)(e)?this._restoreMainSeries(e,t,h,r,o,a):(0,Me.isStudyState)(e)?this.restoreStudy(e,t,s,r,a,!0):(0,Me.isLineToolState)(e)?(e.state&&(e.state.zOrderVersion=2),this.restoreLineTool(e,t,void 0,a)):"ChartEventsSource"===e.type&&this._restoreSpecialSource(e,t,a)):Ue.logError("Duplicate id while restoring pane: "+e.type+","+e.id))}const c=new Set,h=(e,t)=>{e.priceScale()!==t&&(this.removeSourceFromPriceScale(e),e.setPriceScale(t),t.addDataSource(e))},d=(e,t,i)=>{if(c.has(e))return;c.add(e);const s=i.m_showSymbolLabels;void 0!==s&&e===this.model().mainSeries()&&this.model().properties().childs().scalesProperties.childs().showSymbolLabels.setValue(s),this._model.children(e,!0).forEach((e=>d(e,t,i))),h(e,t)},u=e=>{const t=(0,B.defaults)("chartproperties").paneProperties.axisProperties,i=new xe(this.model().properties().childs().scalesProperties,t);return i.restoreState(e.state),i.setHeight(this._height),e.sources.forEach((e=>{const s=this.dataSourceForId(e);s&&d(s,i,t)})),0===i.dataSources().length?null:i},p=e=>e.map(u).filter((e=>null!==e));let _;if(e.leftAxisesState)_=p(e.leftAxisesState);else{const t=u({state:e.leftAxisState,sources:e.leftAxisSources});_=null!==t?[t]:[]}let m;if(this._leftPriceScales.slice().forEach((e=>this.removePriceScale(e))),this._leftPriceScales=[],_.forEach((e=>this._placePriceScale(e,"left"))),e.rightAxisesState)m=p(e.rightAxisesState);else{const t=u({state:e.rightAxisState,sources:e.rightAxisSources});m=null!==t?[t]:[]}this._rightPriceScales.slice().forEach((e=>this.removePriceScale(e))),this._rightPriceScales=[],m.forEach((e=>this._placePriceScale(e,"right"))),this._currentPriceScaleRatio=e.priceScaleRatio||e.leftPriceScaleRatio||e.rightPriceScaleRatio||null;const g=new Map;for(const t of this.m_dataSources){if(c.has(t))continue;let i;if(e.overlayPriceScales&&e.overlayPriceScales[t.id()]){let s=e.overlayPriceScales[t.id()] +;g.has(null==s?void 0:s.id)?i=g.get(null==s?void 0:s.id):(s=(0,n.ensure)(s),i=new xe(this._model.properties().childs().scalesProperties),i.setHeight(this._height),s.m_isAutoScale=!0,s.m_isLog=!1,s.m_isPercentage=!1,s.m_isLockScale=!1,i.restoreState(s),g.set(s.id,i))}else i=new xe(this._model.properties().childs().scalesProperties),i.setHeight(this._height);h(t,i)}for(const e of Object.keys(l)){const t=l[e],i=this.dataSourceForId(e);t&&i&&null===i.ownerSource()&&i.setOwnerSource(this.dataSourceForId(t))}if(e.mainSourceId&&!this.containsMainSeries()&&(this.m_mainDataSource=this.dataSourceForId(e.mainSourceId)),!this.m_mainDataSource)for(const e of this.m_dataSources)if((0,re.isPriceDataSource)(e)){this.m_mainDataSource=e;break}for(const e of this.m_dataSources)(0,S.isLineTool)(e)?(e.ownerSource()||e.setOwnerSource(this.mainDataSource()),e.isFixed()&&e.restoreFixedPoint()):(0,j.isStudy)(e)&&!e.ownerSource()&&e.isLinkedToSeries()&&e.setOwnerSource(this.model().mainSeries());this._updateMargins(),this._cachedOrderedSources.clear()}onPriceScalesChanged(){return this._onPriceScalesChanged}setPaneSize(e){let t;switch(e){case"large":t=1;break;case"medium":t=.6;break;case"small":t=.3;break;case"tiny":t=.15;break;default:throw new Error("Unknown size enum value: "+e)}this._stretchFactor=1e3*t}stretchFactor(){return this._stretchFactor}setStretchFactor(e){this._stretchFactor=e}customSources(e){return this.model().customSources(e)}createDrawingsCaches(){se.ExecutionsPositionController.recreateOrderedByBarsSourcesCache(this)}clearDrawingCaches(){se.ExecutionsPositionController.clearOrderedByBarsSourcesCache()}executionsPositionController(){return this._executionsPositionController||(this._executionsPositionController=new se.ExecutionsPositionController(this)),this._executionsPositionController}width(){return this._width}height(){return this._height}setHeight(e){if(this._height!==e){this._height=e,this._leftPriceScales.forEach((t=>t.setHeight(e))),this._rightPriceScales.forEach((t=>t.setHeight(e)));for(let t=0;t(e.paneViews(this)||[]).some((e=>{const r=e.renderer(t,i);return r&&r.doesIntersectWithBox&&r.doesIntersectWithBox(s)}))))}logicalRectToPixels(e){const t=this.defaultPriceScale(),i=this.timeScale(),s=(0,n.ensureNotNull)((0,n.ensureNotNull)(t.mainSource()).firstValue()),r=t.priceToCoordinate(e.p1.price,s),a=i.indexToCoordinate(e.p1.index),l=t.priceToCoordinate(e.p2.price,s),c=i.indexToCoordinate(e.p2.index),h=new o.Point(Math.min(a,c),Math.min(r,l)),d=new o.Point(Math.max(a,c),Math.max(r,l));return(0,o.box)(h,d)}timeScale(){return this._timeScale}restoreLineTool(e,t,i,s,r){var o,a,l,c,h,d,u,p,_,m,g;delete e.state.lastUpdateTime,e.state.intervalsVisibilities=(0,Be.mergeIntervalVisibilitiesDefaults)(e.state.intervalsVisibilities),i=void 0===i||i,Ve.LineToolElliott.migrateState(e),"LineToolGannComplex"!==(g=e).type||void 0!==g.version&&1!==g.version||(g.type="LineToolGannFixed"),Array.isArray(e.positionPercents)&&(e.positionPercents=e.positionPercents[0]);const f=e.type,v=e.id,y=e.state,b=i?e.zorder:this.newLineToolZOrder();(0,n.assert)((0,he.isLineToolName)(f),"invalid data source type:"+f+" (expected to be a Line Tool)");let w,P,C=null;if((0,Me.isStudyLineToolState)(e)){C=this._model.studyVersioning();const t=C.patchPointsBasedStudyState(e);e=t;const i=t.metaInfo;Object.assign(i,te.StudyMetaInfo.parseIdString(null==i?void 0:i.fullId));const s=C.updateMetaInfo(i)||i;P=(0,S.createStudyLineToolProperties)(f,i,s,y,C),w=(0,S.createLineTool)(f,this._model,P,s,!0)}else P=(0,S.createLineToolProperties)(f,y,this._model),t?null===(o=P.child("fixedSize"))||void 0===o||o.setValue(!1):null===(a=P.child("fixedSize"))||void 0===a||a.setValue(!0),w=(0,S.createLineTool)(f,this._model,P,null,!0);w.setId(v),w.linkKey().setValue(e.linkKey||null);const x=e.alertId;x&&w.canHasAlert()&&N.enabled("alerts")&&!this._model.readOnly()&&!this._model.isJustClonedChart()&&w.setAlert(x);let T=null!==(l=e.indexes)&&void 0!==l?l:[];if(T=T.slice(0,null!==(h=null===(c=e.points)||void 0===c?void 0:c.length)&&void 0!==h?h:T.length),w.isFixed()?void 0!==e.positionPercents?w.restorePositionPercents(e.positionPercents):w.restorePositionPercents({x:.5,y:.5}):e.points&&w.restorePoints(e.points,T,t),w instanceof Re.LineToolBarsPattern||w instanceof Ne.LineToolCallout||w instanceof Oe.LineToolTrendAngle||w instanceof Fe.LineToolGhostFeed||w instanceof We.LineToolParallelChannel)null===(u=(d=w).restoreData)||void 0===u||u.call(d,e);else if(t&&(0,Me.isStudyLineToolState)(e)&&w.restoreData){const t=e;C&&(t.graphics=C.patchPointsBasedStudyData(t.metaInfo,t.graphics)),null===(p=w.restoreData)||void 0===p||p.call(w,t)}const I=null==e.version?1:e.version,M=null==w.version?1:w.version;if(I!==M&&(null===(m=(_=w).migrateVersion)||void 0===m||m.call(_,I,M,{pane:this,model:this._model,properties:P})),void 0!==b&&w.setZorder(b),r)(0,S.prepareLineToolPropertiesByOwnerSource)(w.properties(),r),w.setOwnerSource(r);else{ +const t=e.ownerSource?this.dataSourceForId(e.ownerSource):null;w.setOwnerSource(t)}return void 0!==e.userEditEnabled&&w.setUserEditEnabled(e.userEditEnabled),void 0!==e.isSelectionEnabled&&w.setSelectionEnabled(e.isSelectionEnabled),this._addSourceToCollections(w,s),this._cachedOrderedSources.clear(),w}restoreStudy(e,t,i,s,r,n){var o;if(t&&void 0===e.data&&void 0===e.nonSeriesData&&void 0===e.indexes)return Ue.logError("Cannot restore (skipping) study without data "+e.id+", "+e.metaInfo.id),null;const a=e.id,l=e.state,c=e.zorder;i=null!=i?i:this._model.mainSeries().id();const h=(null!==(o=e.parentSources)&&void 0!==o?o:e.ownerSource?[e.ownerSource]:[]).filter((e=>e!==i));let d=(0,ie.clone)(e.metaInfo);if(Object.assign(d,te.StudyMetaInfo.parseIdString(d.id)),function(e){return"Script$TV_EARNINGS@tv-scripting"===e||"Script$TV_DIVIDENDS@tv-scripting"===e||"Script$TV_SPLITS@tv-scripting"===e||"ESD$TV_EARNINGS@tv-scripting"===e||"ESD$TV_DIVIDENDS@tv-scripting"===e||"ESD$TV_SPLITS@tv-scripting"===e||"Earnings@tv-basicstudies"===e||"Dividends@tv-basicstudies"===e||"Splits@tv-basicstudies"===e||"BarSetContinuousRollDates@tv-corestudies"===e}(d.id)&&!t)return Ue.logNormal("Skipping study "+d.id),null;let u=l;const p=this._model.studyVersioning(),_=p.patchPropsStateAndMetaInfo(u,d,{oldShowStudyLastValueProperty:t&&!(null==s?void 0:s.showStudyLastValueProperty)});u=_.propsState,d=_.metaInfo;const m=new P.StudyStub(this._model,e,d.shortDescription);let g;m.setId(a),m.setZorder(c);const f=i=>{m.setStatus({type:Ae.StudyStatusType.Undefined});const s=i||new te.StudyMetaInfo(d),r=Ee.instance(this._model),n=n=>{var o;const l=(0,C.prepareStudyPropertiesForLoadChart)(d,i,u,p),c=(0,j.createStudy)(this._model,l,n,s);if(c.setId(a),c.setOwnFirstValue(null!==(o=e.ownFirstValue)&&void 0!==o?o:null),e.customFields&&c.restoreStateCustomFields(e.customFields),t){const t=e,{data:i,nsData:s,indexes:r}=p.patchStudyData(d,t.data,t.nonSeriesData,t.indexes);c.restoreData(i,s,r)}this._model.replaceStudyStub(m,c)||(g=c),r.add(a,c)};if(h.length>0){const e=h.map((e=>r.get(e)));Promise.all(e).then(n)}else n([])};if(t)f(null);else{let e=null;0;const t=e=>{const t=p.updateMetaInfoAsync(e);t.sync?f(t.result):t.result.then(f).catch((e=>m.setFailed("error: "+e)))};e?e.then(t):t(d)}const v=null!=g?g:m;if(v){v.setZorder(c);const t=e.metaInfo.linkedToSeries?this._model.mainSeries():h.length?this.dataSourceForId(h[0]):null;v.setOwnerSource(t),this._addSourceToCollections(v,r),this._processMainSourceChange()}return this._cachedOrderedSources.clear(),v}clipboardLineToolOwnerSource(e){const t=this.dataSourceForId(e);if(null!==t){const e=t.ownerSource();if(null!==e&&null!==e.firstValue())return e}const i=this.mainDataSource();if(null!==i&&null!==i.firstValue())return i;for(const e of this.dataSources())if((0,re.isPriceDataSource)(e)&&null!==e.firstValue())return e;return null}realignLineTools(e){var t;let i=!1;for(const s of this.m_dataSources)!(0,S.isLineTool)(s)||void 0!==e&&(null===(t=null==s?void 0:s.ownerSource())||void 0===t?void 0:t.symbolSource())!==e&&(0, _e.isActingAsSymbolSource)(e)||(s.realign(),s.updateAllViews((0,W.sourceChangeEvent)(s.id())),i=!0);return i&&this._invalidateSourcesCache(),i}startScalePrice(e,t){e.startScale(t)}scalePriceTo(e,t){e.scaleTo(t),this.updateAllViews((0,W.viewportChangeEvent)())}endScalePrice(e){e.endScale()}startScrollPrice(e,t){e.startScroll(t)}scrollPriceTo(e,t){e.scrollTo(t),this.updateAllViews((0,W.viewportChangeEvent)())}endScrollPrice(e){e.endScroll()}resetPriceScale(e){const t=this.timeScale().visibleBarsStrictRange();e.resetScaleAvailable().value()&&e.resetScale(),e.recalculatePriceRange(t),this.updateAllViews((0,W.viewportChangeEvent)())}resetPriceScalesAvailable(){return this._resetPriceScalesAvailable.readonly()}restorePriceScaleState(e,t){e.restoreState(t),this.updateAllViews((0,W.viewportChangeEvent)())}beginInsertManyLineDataSources(){this._isInInsertManyDataSourcesState=!0,this._lastLineDataSourceZOrder=null}endInsertManyLineDataSources(){this._isInInsertManyDataSourcesState=!1,this._lastLineDataSourceZOrder=null}removeSourceFromPriceScale(e){const t=e.priceScale();if(null!==t){const i=t.dataSources();i.indexOf(e)>=0&&t.removeDataSource(e),0===i.length&&this.removePriceScale(t)}}_invalidateSourcesCache(){this._cachedOrderedSources.clear(),this._leftPriceScales.forEach((e=>e.invalidateSourcesCache())),this._rightPriceScales.forEach((e=>e.invalidateSourcesCache()))}_processMainSourceChange(){let e=!1;if(null===this.m_mainDataSource)for(const t of this.m_dataSources)if((0,re.isPriceDataSource)(t)&&!this.isOverlay(t)&&(!(0,j.isStudy)(t)||!t.isLinkedToSeries())){this.m_mainDataSource=t,e=!0;break}if(this.m_mainDataSource&&e){let e=this.m_dataSources.filter(S.isLineTool);e=(0,ne.sortSources)(e);for(const t of e)this.move(t,(0,n.ensureNotNull)(this.m_mainDataSource.priceScale()),!0)}else if(!this.m_mainDataSource||this.isOverlay(this.m_mainDataSource)&&0===this._nonOverlayPricesSourcesCount()){let e=null;if(this.m_dataSources.includes(this._model.mainSeries()))e=this._model.mainSeries();else for(const t of this.m_dataSources)if((0,re.isPriceDataSource)(t)&&this.isOverlay(t)&&t.showInObjectTree()){e=t;break}if(null!==e){const t=this.m_mainDataSource===e;this.m_mainDataSource=e;const i=this.createNewPriceScaleIfPossible();if(t&&e===this._model.mainSeries()){const t=(0,n.ensureNotNull)(e.priceScale());this._model.children(e,!0).forEach((e=>{this.removeSourceFromPriceScale(e),i.addDataSource(e),e.setPriceScale(i)})),this.removePriceScale(t)}this.move(e,i,!0),this.recalculatePriceScale(e.priceScale(),(0,W.globalChangeEvent)())}}}_addSourceToCollections(e,t){this.m_dataSources.push(e),this._sourcesById.set(e.id(),e),this._invalidateSourcesCache();const i=()=>{this._sourcePropertiesChanged.fire(e)};e.properties().subscribe(this,i),e.zOrderChanged().subscribe(this,(t=>this._sourcesZOrderChanged.fire(e,t))),(0,S.isLineTool)(e)&&(e.normalizedPointsChanged().subscribe(this,i),e.fixedPointChanged().subscribe(this,i),e.hasAlert.subscribe(i),e.sharingMode().subscribe(i),e.linkKey().subscribe(i), this._sourceWatchedValuesSubscriptions.set(e.id(),i));const s=(0,_e.isSymbolSource)(e)?e:null;(0,re.isPriceDataSource)(e)&&(this._priceSourcesById.set(e.id(),e),e.currencyChanged().subscribe(this,(()=>this._invalidateSourcesCache())),e.unitChanged().subscribe(this,(()=>this._invalidateSourcesCache())),this._priceDataSources.push(e),this._onPriceSourcesCollectionChanged(),null!==s&&(this._symbolSources.push(s),s.symbolResolved().subscribe(this,(()=>this._symbolSourceResolved.fire(e))),s.symbolResolvingActive().subscribe(this._recalcSymbolSourceResolvingActive),s.symbolHibernated().subscribe(this._onSymbolSourceCollectionChanged),this._recalcSymbolSourceResolvingActive(),this._onSymbolSourceCollectionChanged())),e.isMultiPaneAvailable()&&this.model().addMultiPaneSource(e),t||0!==this._bulkActions.activeCounter||this._dataSourcesCollectionChanged.fire()}_removeSourceFromCollections(e,t){const i=this.m_dataSources[e];i.properties().unsubscribeAll(this),i.zOrderChanged().unsubscribeAll(this),this.m_dataSources.splice(e,1),this._sourcesById.delete(i.id());const s=i.id();if((0,S.isLineTool)(i)&&(i.normalizedPointsChanged().unsubscribeAll(this),i.fixedPointChanged().unsubscribeAll(this),this._sourceWatchedValuesSubscriptions.has(s))){const e=this._sourceWatchedValuesSubscriptions.get(s);i.hasAlert.unsubscribe(e),i.linkKey().unsubscribe(e)}this._invalidateSourcesCache();const r=(0,_e.isSymbolSource)(i)?i:null;(0,re.isPriceDataSource)(i)&&(this._priceSourcesById.delete(i.id()),i.currencyChanged().unsubscribeAll(this),i.unitChanged().unsubscribeAll(this),(0,v.removeItemFromArray)(this._priceDataSources,i),this._onPriceSourcesCollectionChanged(),null!==r&&((0,v.removeItemFromArray)(this._symbolSources,r),r.symbolResolved().unsubscribeAll(this),r.symbolResolvingActive().unsubscribe(this._recalcSymbolSourceResolvingActive),r.symbolHibernated().unsubscribe(this._onSymbolSourceCollectionChanged),this._recalcSymbolSourceResolvingActive(),this._onSymbolSourceCollectionChanged())),i.isMultiPaneAvailable()&&this.model().removeMultiPaneSource(i),t||0!==this._bulkActions.activeCounter||this._dataSourcesCollectionChanged.fire()}_recalculatePriceScaleByScaleRatio(e){this.isMainPane()&&e===this._lockedPriceScale&&(null!==this._currentPriceScaleRatio?this._applyOldScaleRatioToPriceScale():this._tryToApplyNewPriceScaleRatio())}_defaultBottomMargin(){return.01*this.properties().childs().bottomMargin.value()}_defaultTopMargin(){return.01*this.properties().childs().topMargin.value()}_updateMargins(){const e=this._defaultTopMargin(),t=this._defaultBottomMargin();for(const i of this._leftPriceScales)je(i,e,t);for(const i of this._rightPriceScales)je(i,e,t);for(const i of this.m_dataSources)if(this.isOverlay(i)){const s=i.priceScale();null!==s&&(je(s,e,t),this.recalculatePriceScale(s,(0,W.viewportChangeEvent)()))}for(const e of this._leftPriceScales)this.recalculatePriceScale(e,(0,W.viewportChangeEvent)());for(const e of this._rightPriceScales)this.recalculatePriceScale(e,(0,W.viewportChangeEvent)());this.updateAllViews((0,W.viewportChangeEvent)())} _batchReorder(e,t,i){i(this.sourcesByGroup().allExceptSpecialSources(),e,t),this._invalidateSourcesCache(),this._dataSourcesCollectionChanged.fire(),this.model().fullUpdate()}_placePriceScale(e,t,i){if("overlay"===t)return void e.invalidateMargins();const s="left"===t?this._leftPriceScales:this._rightPriceScales,r=void 0===i?s.length:i;s.splice(r,0,e),e.modeChanged().subscribe(this,this._onPriceScaleModeChanged.bind(this,e)),e.internalHeightChanged().subscribe(this,this._recalculatePriceScaleByScaleRatio.bind(this,e)),e.priceRangeChanged().subscribe(this,this._recalculateTimeScaleByScaleRatio.bind(this,e)),e.priceRangeChanged().subscribe(this,this._onPriceScaleSetMinMaxPriceRange.bind(this,e)),e.isVisible().subscribe(this._onPriceScaleIsVisibleChanged),e.resetScaleAvailable().subscribe(this._updateResetPriceScalesAvailableValue),e.isLockScale()&&((0,n.assert)(null===this._lockedPriceScale),this._lockedPriceScale=e,this._currentPriceScaleRatio=null),e.invalidateMargins(),this._onPriceScalesChanged.fire(),this._updateResetPriceScalesAvailableValue()}_onPriceScaleModeChanged(e,t,i){if(i.lockScale&&(this._lockedPriceScale!==e&&null!==this._lockedPriceScale&&this._lockedPriceScale.setMode({lockScale:!1}),this._lockedPriceScale=e,this._currentPriceScaleRatio=(0,Te.scaleRatio)(this.timeScale(),e)),t.lockScale&&!i.lockScale&&(this._lockedPriceScale=null,this._currentPriceScaleRatio=null),t.percentage===i.percentage&&t.indexedTo100===i.indexedTo100)return;const s=this.timeScale().visibleBarsStrictRange();null!==s&&(e.recalculatePriceRange(s),e.updateAllViews((0,W.viewportChangeEvent)()))}_applyOldScaleRatioToPriceScale(){this._isRecalculatingScales||null===this._currentPriceScaleRatio||null===this._lockedPriceScale||(this._isRecalculatingScales=!0,this._setNewPriceRangeByScaleRatio(this._lockedPriceScale,this._currentPriceScaleRatio,this._mainSourceVisiblePriceRange(this._lockedPriceScale)),this._isRecalculatingScales=!1)}_setNewPriceRangeByScaleRatio(e,t,i,s,r){const n=(0,Te.priceRangeByScaleRatio)(e,this.timeScale().barSpacing(),t);e.setPriceRange(null!==n?n:i,s,r)}_applyOldScaleRatioToTimeScale(){this._isRecalculatingScales||null===this._currentPriceScaleRatio||(this._isRecalculatingScales=!0,this._setNewBarSpacingByScaleRatio(),this._isRecalculatingScales=!1)}_tryToApplyNewPriceScaleRatio(){const e=(0,n.ensureNotNull)(this._lockedPriceScale),t=(0,Te.scaleRatio)(this.timeScale(),e);this._currentPriceScaleRatio===t||e.isLog()||(this._currentPriceScaleRatio=t,this.model().mainSeriesScaleRatioPropertyOnChanged())}_recalculateTimeScaleByScaleRatio(e){e===this._lockedPriceScale&&(null!==this._currentPriceScaleRatio?this._applyOldScaleRatioToTimeScale():this._tryToApplyNewPriceScaleRatio())}_setNewBarSpacingByScaleRatio(){const e=this.timeScale().getValidBarSpacing((0,Te.barSpacingByScaleRatio)((0,n.ensureNotNull)(this._lockedPriceScale),this._currentPriceScaleRatio));this.timeScale().isValidBarSpacing(e)&&this.timeScale().setBarSpacing(e)}_mainSourceVisiblePriceRange(e){const t=this.timeScale().visibleBarsStrictRange() ;return null!==t?(0,n.ensureNotNull)((0,n.ensureNotNull)(e.mainSource()).priceRange(t.firstBar(),t.lastBar())):new de.PriceRange(-.5,.5)}_setMinMaxPriceRange(){const e=(0,n.ensureNotNull)(this._lockedPriceScale),t=(0,Te.priceRangeByScaleRatio)(e,this.timeScale().maxBarSpacing(),this._currentPriceScaleRatio),i=(0,Te.priceRangeByScaleRatio)(e,this.timeScale().minBarSpacing(),this._currentPriceScaleRatio);null!==t&&e.setMaxPriceRange(t),null!==i&&e.setMinPriceRange(i)}_onPriceScaleSetMinMaxPriceRange(e){e===this._lockedPriceScale&&this._setMinMaxPriceRange()}_onPriceSourcesCollectionChanged(){0===this._bulkActions.activeCounter?this._priceSourcesCollectionChanged.fire():this._bulkActions.priceSourcesCollectionChanged=!0}_nonOverlayPricesSourcesCount(){return this.m_dataSources.filter((e=>(!(0,j.isStudy)(e)||!e.isLinkedToSeries())&&((0,re.isPriceDataSource)(e)&&e.showInObjectTree()&&!this.isOverlay(e)))).length}_restoreMainSeries(e,t,i,s,r,n){const o=e.id,a=e.state;if(a&&r&&(a.style=r.style||a.style,a.interval=r.interval||a.interval,r.symbol&&r.symbol!==a.symbol&&(a.symbol=r.symbol,delete a.currencyId,delete a.unitId)),a&&["candleStyle","hollowCandleStyle","haStyle"].forEach((e=>{a[e]&&(a[e].wickUpColor=a[e].wickUpColor||a[e].wickColor,a[e].wickDownColor=a[e].wickDownColor||a[e].wickColor)})),a&&(a.statusViewStyle=a.statusViewStyle||{},!a.statusViewStyle.symbolTextSource)){const e=!!a.statusViewStyle.showSymbolAsDescription;a.statusViewStyle.symbolTextSource=e?"ticker":"description"}if(a){a.extendedHours?a.sessionId="extended":a.sessionId||(a.sessionId="regular"),delete a.extendedHours,(0,He.allChartStyles)().includes(a.style)||(a.style=2);const e=a.lineStyle.styleType;delete a.lineStyle.styleType,0===e&&(a.style=14,a.lineWithMarkersStyle=(0,ie.clone)(a.lineStyle)),1===e&&(a.style=15,a.steplineStyle=(0,ie.clone)(a.lineStyle))}if(!i){const e=this._model.mainSeries();this._model.mainPane().removeDataSource(e,!1,n),this._addSourceToCollections(e,n)}const l=this.model().mainSeries(),c=l.properties().childs();this.m_mainDataSource=l;const h=a&&a.style?a.style:void 0;if(6===h&&"ATR"===c.pnfStyle.childs().inputs.childs().style.value()?c.pnfStyle.childs().inputs.childs().style.setValueSilently("Traditional"):4===h&&"ATR"===c.renkoStyle.childs().inputs.childs().style.value()&&c.renkoStyle.childs().inputs.childs().style.setValueSilently("Traditional"),a&&!a.hasOwnProperty("showSessions")&&(a.showSessions=!1),a&&void 0===a.settlementAsClose&&(a.settlementAsClose=!1),a&&t&&(a.showCountdown=!1),a&&(t&&!("showSeriesLastValueProperty"in s)&&"showLastValue"in a&&this._model.properties().childs().scalesProperties.childs().showSeriesLastValue.setValue(a.showLastValue),delete a.showLastValue),a){const t={haStyle:(0,O.chartStyleStudyId)(8,!0),renkoStyle:(0,O.chartStyleStudyId)(4,!0),pbStyle:(0,O.chartStyleStudyId)(7,!0),kagiStyle:(0,O.chartStyleStudyId)(5,!0),pnfStyle:(0,O.chartStyleStudyId)(6,!0),rangeStyle:(0,O.chartStyleStudyId)(11,!0)},i=this._model.studyVersioning(),s=l.styleStudyInfos(),r=Object.keys(Le.SYMBOL_STRING_DATA) ;for(let n=0;nthis._right+.5?!0===t&&2:!0!==t||0}before(e){return ethis._right+.5}intersects(e){return!(this.after(e.left())||this.before(e.right()))}equals(e){return this._left===e.left()&&this._right===e.right()}static compare(e,t){return null===e||null===t?e===t:e.equals(t)}}const Ze=(0,X.getLogger)("Chart.TimePoints");function Xe(e,t){return null===e||null===t?e===t:e.firstIndex===t.firstIndex&&e.lastIndex===t.lastIndex}class Je{constructor(){this._zoffset=0,this._items=[],this._range=new $.WatchedObject(null,Xe)}clear(){this._zoffset=0,this._items=[],this._range.setValue(null)}size(){return this._items.length}range(){return this._range.readonly()}merge(e,t,i){const s=this._mergeImpl(e,t,i);return this._updateFirstAndLastIndex(),s}addTail(e,t){for(let i=t?1:0;ithis._items[this._items.length-1])return t?this._validOffsetToIndex(this._items.length-1):null;for(let i=0;io){const i=e-o;if(i<500&&null!=t)return t(l,i);return l+i*c}return null}roughIndex(e,t=null){const i=this._items;if(!i.length||i.length<2)return null ;const s=i.length-1,r=this._validOffsetToIndex(0),n=this._validOffsetToIndex(s),o=i[0],a=i[s];if(e>=o&&e<=a)return this.closestIndexLeft(e);const l=(a-o)/(n-r);if(ea){const i=e-a;let s=Math.trunc(i/l);if(s<500&&null!==t){const i=t(a,e);i.success&&(s=i.result)}return n+s}return null}closestIndexLeft(e){const t=this._items;if(!t.length)return null;if(Number.isNaN(e))return null;let i=t.length-1;if(e>=t[i])return this._validOffsetToIndex(i);let s=0;const r=t[s];if(es+1;){const r=s+i>>1,n=t[r];if(n>e)i=r;else{if(!(nthis._zoffset&&e+t>0)return Ze.logError("merge: when the first time point index is updated, we should fill the time points starting from the first one"),[];if(0===this._items.length)return this._items=i.slice(),this._zoffset=t,[{change:"rebuild",index:this._validOffsetToIndex(0)}];const s=e+this._zoffset;if(s<0){const r=Math.abs(s);if(i.lengththis._items.length){const e=o-this._items.length;for(let t=n;t{this._usePercentageRightOffset.setValue(!1),this._defaultRightOffsetOptionsUpdated()})),this._defaultRightOffsetPercentage.subscribe((e=>{if(e>=100||e<0){const t=Math.max(0,Math.min(e,99));this._defaultRightOffsetPercentage.setValue(t)}else this._usePercentageRightOffset.setValue(!0),this._defaultRightOffsetOptionsUpdated()})),this._usePercentageRightOffset.subscribe((()=>{this._defaultRightOffsetOptionsUpdated()})),this._options.preserveBarSpacing&&(this._barSpacing=this._scalesProperties.childs().barSpacing.value()||6),this._barSpacingChanged.subscribe(this,this._maxRightOffsetOnChanged),this._barSpacingChanged.subscribe(this,this._updateResetAvailableValue),this._rightOffsetChanged.subscribe(this,this._updateResetAvailableValue),this._widthChanged.subscribe(this,this._maxRightOffsetOnChanged),this._updateResetAvailableValue()}destroy(){ -this._barSpacingChanged.unsubscribeAll(this),this._barSpacingChanged.destroy(),this._widthChanged.unsubscribeAll(this),this._widthChanged.destroy()}isEmpty(){return 0===this._width||!this.canNormalize()}canNormalize(){return this._points.size()>0}update(e,t,i,s){this._visibleBarsInvalidated=!0,i.length>0&&this._points.merge(e,t,i),this._tickMarks.merge(s),this.correctOffset()}addTail(e,t,i){this._tickMarks.removeTail(t);const s=e.params,r=(0,n.ensureDefined)(this._tickMarks.maxIndex)+(i?0:1);for(let e=0;e0&&(i*=this._width/e.width)),this._tryToUpdateBarSpacing(this._barSpacing,i),this.correctOffset(),this._usePercentageRightOffset.value()&&(this._rightOffset=this.percentsToBarIndexLength(this._defaultRightOffsetPercentage.value())),this._rightOffsetChanged.fire(this._rightOffset)}marks(){if(this.isEmpty())return null;const e=this._barSpacing,t=5*((this._scalesProperties.childs().fontSize.value()||0)+4),i=Math.round(t/e),s=(0,n.ensureNotNull)(this.visibleBarsStrictRange()),r=Math.max(s.firstBar(),s.firstBar()-i),o=Math.max(s.lastBar(),s.lastBar()-i),a=this._tickMarks.build(e,t),l=[];for(const e of a){if(!(r<=e.index&&e.index<=o))continue;const t=this._tickMarks.indexToTime(e.index);null!==t&&l.push({coord:this.indexToCoordinate(e.index),label:this.formatLabel(t,e.span),span:e.span,major:e.label>=st.DAY_SPAN})}return l}visibleBarsStrictRange(){return this._visibleBarsInvalidated&&(this._visibleBarsInvalidated=!1,this._updateVisibleBars()),this._visibleBars.strictRange()}visibleBarsStrictRangeChanged(){return this._visibleBarsChanged}visibleStrictDataRange(e){const t=this.visibleBarsStrictRange();if(null===t)return null -;const i=e.search(t.firstBar(),dt.PlotRowSearchMode.NearestRight),s=e.search(t.lastBar(),dt.PlotRowSearchMode.NearestLeft);return null===i||null===s?null:new Ye.BarsRange(i.index,s.index)}visibleExtendedDataRange(e,t){const i=this.visibleBarsStrictRange();if(null===i)return null;let s=1===t?null:e.search(i.firstBar()-1,dt.PlotRowSearchMode.NearestLeft),r=0===t?null:e.search(i.lastBar()+1,dt.PlotRowSearchMode.NearestRight);return null===s&&(s=e.search(i.firstBar(),dt.PlotRowSearchMode.NearestRight)),null===r&&(r=e.search(i.lastBar(),dt.PlotRowSearchMode.NearestLeft)),null===s||null===r?null:new Ye.BarsRange(s.index,r.index)}logicalRangeChanged(){return this._logicalRangeChanged}tickMarks(){return this._tickMarks}points(){return this._points}width(){return this._width}setWidth(e,t){if(!Number.isFinite(e)||e<=0)return void mt.logWarn(`setWidth: invalid argument: ${e}`);if(this._width===e)return;if(this._visibleBarsInvalidated=!0,(t||this._options.lockVisibleTimeRangeOnResize)&&this._width){const t=this._barSpacing*e/this._width;this._tryToUpdateBarSpacing(this._barSpacing,t)}else this._width&&this.setBarSpacing(this._barSpacing);if(null!==this._leftEdgeIndex){if((0,n.ensureNotNull)(this.visibleBarsStrictRange()).firstBar()<=this._leftEdgeIndex){const t=this._width-e;this._rightOffset-=Math.round(t/this._barSpacing)+1}}const i=this._usePercentageRightOffset.value()&&this._rightOffset>0?this.barIndexLengthToPercents(this._rightOffset):-1;this._width=e,this._widthChanged.fire(e);const s=this._rightOffset;i>0?this._rightOffset=this.percentsToBarIndexLength(i):this.correctOffset(),this._rightOffset!==s&&this._rightOffsetChanged.fire(this._rightOffset),this._requestMoreData()}setLeftEdgeFix(e){this._leftEdgeIndex=e;const t=this.visibleBarsStrictRange();if(null===t)return;const i=t.firstBar()-e;if(i<0){const e=this._rightOffset-i-1;this.scrollToOffsetAnimated(e,500)}}indexToCoordinate(e){if(this.isEmpty())return 0;const t=this.baseIndex()+this._rightOffset-e;return this._width-(t+.5)*this._barSpacing}indexToUserTime(e){return this._tickMarks.indexToTime(e)}timePointToIndex(e,t){switch(t){case 0:return this._points.indexOf(e,!1);case 1:return this._points.closestIndexLeft(e);default:return this._points.indexOf(e,!0)}}indexToTimePoint(e){return this._points.valueAt(e)}timeToCoordinate(e){const t=this._points.closestIndexLeft(e);if(null===t)return null;const i=(0,n.ensureNotNull)(this._points.valueAt(t)),s=this.indexToCoordinate(t);if(s<=0||s>=this._width)return null;const r=this.barSpacing(),o=this.baseIndex(),a=s+(e-i)/((0,n.ensureNotNull)(this._points.valueAt(o))-(0,n.ensureNotNull)(this._points.valueAt(o-1)))*r+1;return a<=0||a>=this._width?null:a}barIndexesToCoordinates(e){const t=this.baseIndex();for(const i of e){const e=i.time,s=t+this._rightOffset-e,r=this._width-(s+.5)*this._barSpacing;i.time=r}}timedValuesToCoordinates(e,t,i){var s,r;const n=this.baseIndex()+this._rightOffset,o=this._width-n*this._barSpacing-.5*this._barSpacing,a=null!==(s=null==t?void 0:t.startItemIndex)&&void 0!==s?s:0;let l=a +return null!==this._logicalRange}static invalid(){return new tt(null,1)}}var it=i(21550),st=i(42609);class rt{constructor(e,t=50){this._actualSize=0,this._usageTick=1,this._oldestTick=1,this._cache=new Map,this._tick2Labels=new Map,this._format=e,this._maxSize=t}format(e){const t=this._cache.get(e.valueOf());if(void 0!==t)return t.string;if(this._actualSize===this._maxSize){const e=this._tick2Labels.get(this._oldestTick);this._tick2Labels.delete(this._oldestTick),this._cache.delete((0,n.ensureDefined)(e)),this._oldestTick++,this._actualSize--}const i=this._format(e);return this._cache.set(e.valueOf(),{string:i,tick:this._usageTick}),this._tick2Labels.set(this._usageTick,e.valueOf()),this._actualSize++,this._usageTick++,i}}var nt=i(1763);let ot;var at=i(16164),lt=i(79206),ct=i(92216),ht=i(88275),dt=i(86094);const ut={preserveBarSpacing:!1,lockVisibleTimeRangeOnResize:!1,rightBarStaysOnScroll:!0,minBarSpacing:.5},pt=N.enabled("low_density_bars"),_t=pt?1:2,mt=(0,X.getLogger)("Chart.TimeScale");class gt{constructor(e,t){this._width=0,this._widthChanged=new G.Delegate,this._rightOffset=10,this._rightOffsetChanged=new G.Delegate,this._maxRightOffsetChanged=new G.Delegate,this._defaultRightOffset=new q.WatchedValue(10),this._defaultRightOffsetPercentage=new q.WatchedValue(5),this._usePercentageRightOffset=new q.WatchedValue(!1),this._lastDefaultRightOffset=void 0,this._baseIndex=null,this._leftEdgeIndex=null,this._barSpacingChanged=new G.Delegate,this._barSpacing=6,this._visibleBars=tt.invalid(),this._visibleBarsInvalidated=!0,this._visibleBarsChanged=new G.Delegate,this._logicalRangeChanged=new G.Delegate,this._points=new Je,this._tickMarks=new it.Tickmarks,this._onScroll=new G.Delegate,this._resetDelegate=new G.Delegate,this._scrollStartPoint=null,this._scaleStartPoint=null,this._commonTransitionStartState=null,this._formattedBySpan=new Map,this._requestingMoreData=!1,this._requestedTickmarksCount=0,this._endOfData=!1,this._lockBarsAndLogicalRangeEvents=!1,this._timeout=void 0,this._prevRO=void 0,this._resetAvailable=new q.WatchedValue(!1),this._options=(0,$e.deepExtend)({},ut,t),this._model=e,this._scalesProperties=e.properties().childs().scalesProperties,this._defaultRightOffset.subscribe((()=>{this._usePercentageRightOffset.setValue(!1),this._defaultRightOffsetOptionsUpdated()})),this._defaultRightOffsetPercentage.subscribe((e=>{if(e>=100||e<0){const t=Math.max(0,Math.min(e,99));this._defaultRightOffsetPercentage.setValue(t)}else this._usePercentageRightOffset.setValue(!0),this._defaultRightOffsetOptionsUpdated()})),this._usePercentageRightOffset.subscribe((()=>{this._defaultRightOffsetOptionsUpdated()})),this._options.preserveBarSpacing&&(this._barSpacing=this._scalesProperties.childs().barSpacing.value()||6),this._barSpacingChanged.subscribe(this,this._maxRightOffsetOnChanged),this._barSpacingChanged.subscribe(this,this._updateResetAvailableValue),this._rightOffsetChanged.subscribe(this,this._updateResetAvailableValue),this._widthChanged.subscribe(this,this._maxRightOffsetOnChanged),this._updateResetAvailableValue()} +destroy(){this._barSpacingChanged.unsubscribeAll(this),this._barSpacingChanged.destroy(),this._widthChanged.unsubscribeAll(this),this._widthChanged.destroy()}isEmpty(){return 0===this._width||!this.canNormalize()}canNormalize(){return this._points.size()>0}update(e,t,i,s){this._visibleBarsInvalidated=!0,i.length>0&&this._points.merge(e,t,i),this._tickMarks.merge(s),this.correctOffset()}addTail(e,t,i){this._tickMarks.removeTail(t);const s=e.params,r=(0,n.ensureDefined)(this._tickMarks.maxIndex)+(i?0:1);for(let e=0;e0&&(i*=this._width/e.width)),this._tryToUpdateBarSpacing(this._barSpacing,i),this.correctOffset(),this._usePercentageRightOffset.value()&&(this._rightOffset=this.percentsToBarIndexLength(this._defaultRightOffsetPercentage.value())),this._rightOffsetChanged.fire(this._rightOffset)}marks(){if(this.isEmpty())return null;const e=this._barSpacing,t=5*((this._scalesProperties.childs().fontSize.value()||0)+4),i=Math.round(t/e),s=(0,n.ensureNotNull)(this.visibleBarsStrictRange()),r=Math.max(s.firstBar(),s.firstBar()-i),o=Math.max(s.lastBar(),s.lastBar()-i),a=this._tickMarks.build(e,t),l=[];for(const e of a){if(!(r<=e.index&&e.index<=o))continue;const t=this._tickMarks.indexToTime(e.index);null!==t&&l.push({coord:this.indexToCoordinate(e.index),label:this.formatLabel(t,e.span),span:e.span,major:e.label>=st.DAY_SPAN})}return l}visibleBarsStrictRange(){return this._visibleBarsInvalidated&&(this._visibleBarsInvalidated=!1,this._updateVisibleBars()),this._visibleBars.strictRange()}visibleBarsStrictRangeChanged(){return this._visibleBarsChanged}visibleStrictDataRange(e){const t=this.visibleBarsStrictRange();if(null===t)return null +;const i=e.search(t.firstBar(),dt.PlotRowSearchMode.NearestRight),s=e.search(t.lastBar(),dt.PlotRowSearchMode.NearestLeft);return null===i||null===s?null:new Ye.BarsRange(i.index,s.index)}visibleExtendedDataRange(e,t){const i=this.visibleBarsStrictRange();if(null===i)return null;let s=1===t?null:e.search(i.firstBar()-1,dt.PlotRowSearchMode.NearestLeft),r=0===t?null:e.search(i.lastBar()+1,dt.PlotRowSearchMode.NearestRight);return null===s&&(s=e.search(i.firstBar(),dt.PlotRowSearchMode.NearestRight)),null===r&&(r=e.search(i.lastBar(),dt.PlotRowSearchMode.NearestLeft)),null===s||null===r?null:new Ye.BarsRange(s.index,r.index)}logicalRangeChanged(){return this._logicalRangeChanged}tickMarks(){return this._tickMarks}points(){return this._points}width(){return this._width}setWidth(e,t){if(!Number.isFinite(e)||e<=0)return void mt.logWarn(`setWidth: invalid argument: ${e}`);if(this._width===e)return;const i=this._usePercentageRightOffset.value()&&this._rightOffset>0?this.barIndexLengthToPercents(this._rightOffset):-1;if(this._visibleBarsInvalidated=!0,(t||this._options.lockVisibleTimeRangeOnResize)&&this._width){const t=this._barSpacing*e/this._width;this._tryToUpdateBarSpacing(this._barSpacing,t)}else this._width&&this.setBarSpacing(this._barSpacing);if(null!==this._leftEdgeIndex){if((0,n.ensureNotNull)(this.visibleBarsStrictRange()).firstBar()<=this._leftEdgeIndex){const t=this._width-e;this._rightOffset-=Math.round(t/this._barSpacing)+1}}this._width=e,this._widthChanged.fire(e);const s=this._rightOffset;i>0?this._rightOffset=this.percentsToBarIndexLength(i):this.correctOffset(),this._rightOffset!==s&&this._rightOffsetChanged.fire(this._rightOffset),this._requestMoreData()}setLeftEdgeFix(e){this._leftEdgeIndex=e;const t=this.visibleBarsStrictRange();if(null===t)return;const i=t.firstBar()-e;if(i<0){const e=this._rightOffset-i-1;this.scrollToOffsetAnimated(e,500)}}indexToCoordinate(e){if(this.isEmpty())return 0;const t=this.baseIndex()+this._rightOffset-e;return this._width-(t+.5)*this._barSpacing}indexToUserTime(e){return this._tickMarks.indexToTime(e)}timePointToIndex(e,t){switch(t){case 0:return this._points.indexOf(e,!1);case 1:return this._points.closestIndexLeft(e);default:return this._points.indexOf(e,!0)}}indexToTimePoint(e){return this._points.valueAt(e)}timeToCoordinate(e){const t=this._points.closestIndexLeft(e);if(null===t)return null;const i=(0,n.ensureNotNull)(this._points.valueAt(t)),s=this.indexToCoordinate(t);if(s<=0||s>=this._width)return null;const r=this.barSpacing(),o=this.baseIndex(),a=s+(e-i)/((0,n.ensureNotNull)(this._points.valueAt(o))-(0,n.ensureNotNull)(this._points.valueAt(o-1)))*r+1;return a<=0||a>=this._width?null:a}barIndexesToCoordinates(e){const t=this.baseIndex();for(const i of e){const e=i.time,s=t+this._rightOffset-e,r=this._width-(s+.5)*this._barSpacing;i.time=r}}timedValuesToCoordinates(e,t,i){var s,r;const n=this.baseIndex()+this._rightOffset,o=this._width-n*this._barSpacing-.5*this._barSpacing,a=null!==(s=null==t?void 0:t.startItemIndex)&&void 0!==s?s:0;let l=a ;const c=null!==(r=null==t?void 0:t.endItemIndex)&&void 0!==r?r:e.length;!0===i&&(l=(0,v.upperbound)(e,Qe.UNPLOTTABLE_TIME_POINT_INDEX,((e,t)=>e{void 0!==t&&t(),this._requestMoreData()};if(e){const e=this._rightOffset,t=this.maxRightOffset();t>0&&i>t&&(i=t);const r=this._model;(0,ht.doAnimate)({from:e,to:i,duration:1e3,easing:qe.easingFunc.easeInOutQuint,onComplete:s,onStep:(e,t)=>{this._visibleBarsInvalidated=!0,this._updateRightOffset(t),this._onScroll.fire(),r.recalculateAllPanes((0,W.viewportChangeEvent)()),r.lightUpdate(),r.recalcVisibleRangeStudies()}})}else this._visibleBarsInvalidated=!0,this._updateRightOffset(i),this._onScroll.fire(),s()}scrollToFirstBar(e=(()=>{})){this._model.gotoTime(new Date("1800-01-01").getTime()).then(e),this._onScroll.fire()}scrollToOffsetAnimated(e,t){if(!isFinite(e))throw new RangeError("offset is required and must be finite number");const i=void 0===t?400:t;if(!isFinite(i)||i<=0)throw new RangeError("animationDuration (optional) must be finite positive number");const s=this._rightOffset,r=Date.now(),n=()=>{this._visibleBarsInvalidated=!0;const t=(Date.now()-r)/i;if(t>=1)return this._updateRightOffset(e),this._visibleBarsInvalidated=!0,this._model.recalculateAllPanes((0,W.viewportChangeEvent)()),void this._model.lightUpdate();const o=s+(e-s)*t;this._updateRightOffset(o),this._model.recalculateAllPanes((0,W.viewportChangeEvent)()),setTimeout(n,20)};n()}defaultRightOffset(){return this._defaultRightOffset}rightOffsetDefaultValue(){return 10}defaultRightOffsetPercentage(){return this._defaultRightOffsetPercentage}usePercentageRightOffset(){return this._usePercentageRightOffset}barSpacing(){return this._barSpacing}setBarSpacing(e){Number.isFinite(e)?(e=this.getValidBarSpacing(e),this._tryToUpdateBarSpacing(this._barSpacing,e)&&(this.correctOffset(),this._options.preserveBarSpacing&&((0,T.saveDefaultProperties)(!0),this._scalesProperties.childs().barSpacing.setValue(this._barSpacing),(0,T.saveDefaultProperties)(!1)),this._model.recalculateAllPanes((0,W.viewportChangeEvent)()),this._model.lightUpdate())):mt.logWarn(`setBarSpacing: invalid argument: ${e}`)}barSpacingChanged(){return this._barSpacingChanged}getValidBarSpacing(e){return null==e&&(e=this.barSpacing()),ethis.maxBarSpacing()?this.maxBarSpacing():e}isValidBarSpacing(e){return e>=this.minBarSpacing()&&e<=this.maxBarSpacing()}preserveBarSpacing(){return this._options.preserveBarSpacing} normalizeBarIndex(e){let t=0,i=0;const s=this.baseIndex(),r=(0,n.ensureNotNull)(this._points.range().value()).firstIndex;return es?(t=(0,n.ensureNotNull)(this._points.valueAt(s)),i=e-s):(t=(0,n.ensureNotNull)(this._points.valueAt(e)),i=0),{time_t:t,offset:i}}denormalizeTimePoint(e){const t=this._points.indexOf(e.time_t,!1);if(null!==t)return t+e.offset}rightOffset(){return this._rightOffset}rightOffsetChanged(){return this._rightOffsetChanged}minRightOffset(){var e;const t=null===(e=this.points().range().value())||void 0===e?void 0:e.firstIndex,i=this._baseIndex;if(void 0===t||null===i)return null;if(null!==this._leftEdgeIndex){const e=this.width()/this._barSpacing;return this._leftEdgeIndex-i+e-1}return t-i-1+_t}maxRightOffset(){return this.width()/this._barSpacing-_t}maxRightOffsetChanged(){return this._maxRightOffsetChanged}onReset(){return this._resetDelegate}scrollStartPoint(){return this._scrollStartPoint}baseIndex(){return this._baseIndex||0}zoom(e,t,i){if(!Number.isFinite(e)||!Number.isFinite(t))return void mt.logWarn(`zoom: invalid arguments: ${e}, ${t}, ${i}`);const s=this.rightOffset(),r=void 0!==i?!i:this._options.rightBarStaysOnScroll,n=r&&this.usePercentageRightOffset().value()&&s>=0,o=n?this.barIndexLengthToPercents(s):void 0,a=this.coordinateToIndex(e),l=this.barSpacing(),c=l+t*(l/10);this.setBarSpacing(c),r||this.setRightOffset(s-.5+(a-this.coordinateToFloatIndex(e))),n&&void 0!==o&&this.setRightOffset(this.percentsToBarIndexLength(o)),this._requestMoreData()}zoomToBarsRange(e,t){if(null!==this._leftEdgeIndex&&(e=Math.max(e,this._leftEdgeIndex)),t<=e)return;const i=this.baseIndex(),s=this._rightOffset;this._rightOffset=t-i;const r=Math.max(t-e+1,_t);this.setBarSpacing(this.width()/r),this._visibleBarsInvalidated=!0,this.correctOffset(),this._rightOffset!==s&&this._rightOffsetChanged.fire(this._rightOffset),this._requestMoreData()}coordinateToIndex(e){return Math.round(this.coordinateToFloatIndex(e))}coordinateToFloatIndex(e){const t=this._rightOffsetForCoordinate(e),i=this.baseIndex()+this.rightOffset()-t;return Math.round(1e6*i)/1e6}coordinateToVisibleIndex(e){let t=this.coordinateToIndex(e);const i=this.visibleBarsStrictRange();return null===i||i.contains(t)||(t=Math.min(Math.max(i.firstBar(),t),i.lastBar())),t}canZoomIn(){return this.barSpacing()this._options.minBarSpacing}minBarSpacing(){return this._options.minBarSpacing}maxBarSpacing(){const e=this.width();return pt?e:e/_t}minVisibleBarCount(){return _t}resetRightOffset(){this.setRightOffset(this.targetDefaultRightOffset())}reset(){this._visibleBarsInvalidated=!0,this._points.clear(),this._scrollStartPoint=null,this._scaleStartPoint=null,this._clearCommonTransitionsStartState(),this._tickMarks.reset(),this._leftEdgeIndex=null,this._resetDelegate.fire(),this.disconnect()}resetAvailable(){return this._resetAvailable.readonly()}disconnect(){this._requestingMoreData=!1,this._requestedTickmarksCount=0,this._endOfData=!1} -setBaseIndex(e){Number.isFinite(e)?(this._visibleBarsInvalidated=!0,this._baseIndex=e,this.correctOffset()):mt.logDebug(`setBaseIndex: invalid argument: ${e}`)}resetBaseIndex(){this._visibleBarsInvalidated=!0,this._baseIndex=null}setRightOffset(e){Number.isFinite(e)?(this._visibleBarsInvalidated=!0,this._updateRightOffset(e)):mt.logWarn(`setRightOffset: invalid argument: ${e}`)}correctBarSpacing(){this.isEmpty()||this.points().size()e&&(this._rightOffset=e,this._visibleBarsInvalidated=!0);const t=this.minRightOffset();null!==t&&this._rightOffset{this._prevRO!==this.rightOffset()&&(this._prevRO=this.rightOffset(),this._requestMoreData())}),100)}formatLabel(e,t){const i="24-hours"===at.timeHoursFormatProperty.value()?t.toString():`${t}_ampm`;let s=this._formattedBySpan.get(i);return void 0===s&&(s=new rt((e=>this.formatLabelImpl(e,t))),this._formattedBySpan.set(i,s)),s.format(new Date(e))} -formatLabelImpl(e,t){if(!(e&&e instanceof Date))return"incorrect time";const s=function(e,t){if(e{e.onChanged().subscribe(null,(t=>this._onChanged.fire(e.id,t)))}))}groups(){return this._groups.filter((e=>e.isActualSymbol()))}groupsForAllSymbols(){return this._groups}createGroup(e,t,i){t=t||this._generateNextName();const s=new yt.LineToolsGroup(e,t,i);this._groups.push(s),s.onChanged().subscribe(null,(e=>this._onChanged.fire(s.id,e)));const r={visibilityChanged:!1,lockedChanged:!1,titleChanged:!1,isActualIntervalChanged:!1,affectedLineTools:e.map((e=>e.id()))};return this._onChanged.fire(s.id,r),s}addGroup(e){this._groups.push(e),e.onChanged().subscribe(null,(t=>this._onChanged.fire(e.id,t))),this._onChanged.fire(e.id)}removeGroup(e){const t=this._groups.findIndex((t=>t.id===e.id));this._groups.splice(t,1),this._onChanged.fire(e.id)}groupForId(e){return this._groups.find((t=>t.id===e))||null}groupForLineTool(e){return this._groups.find((t=>t.containsLineTool(e)))||null}removeLineTools(e){const t=new Set;this._groups.forEach((i=>{const s=e.filter(i.containsLineTool.bind(i)) -;s.length&&(i.excludeLineTools(s),t.add(i.id))}));return this._groups.filter((e=>0===e.lineTools().length)).forEach((e=>this.removeGroup(e))),Array.from(t)}state(e){return{groups:(e?this._groups.filter((e=>e.isActualSymbol())):this._groups).map((e=>e.state()))}}onChanged(){return this._onChanged}fireChangedAll(){this._groups.forEach((e=>{this._onChanged.fire(e.id)}))}static fromState(e,t){const i=[];for(const s of t.groups){const t=yt.LineToolsGroup.fromState(e,s);null!==t&&i.push(t)}return new bt(i)}_generateNextName(){const e=new Set(this.groups().map((e=>e.name())));for(let t=1;;t++){const i=`Group ${t}`,s=`Group_${t}`;if(!e.has(i)&&!e.has(s))return i}}}var wt=i(99652),Pt=i(41249),Ct=i.n(Pt),xt=i(60156);let Tt=null;function It(e){return Boolean(e.symbolInfo.timezone)&&Boolean(e.symbolInfo.session)}class Mt{constructor(e,t){var i,s;this._sourceTargetBarBuilder=null,this._cache=new Map,this._source=e,this._sourceSession=xt.SessionInfo.fromState(e.session),this._target=t,this._targetSession=xt.SessionInfo.fromState(t.session),this._isResolutionTheSame=x.Interval.isEqual(e.resolution,t.resolution),this._isSessionTheSame=(i=e.symbolInfo,s=t.symbolInfo,i.timezone===s.timezone&&i.session===s.session&&i.session_holidays===s.session_holidays&&i.corrections===s.corrections),this._shouldCorrectTradingDay=x.Interval.isDWM(e.resolution)&&!this._isSessionTheSame}sourceTimeToTargetTime(e){if(this._isSessionTheSame&&this._isResolutionTheSame)return e;if(!It(this._source)||!It(this._target))return e;let t=this._cache.get(e);if(void 0===t){let i=1e3*e;if(this._shouldCorrectTradingDay){let e=Ct().utc_to_cal(this._sourceSession.timezone,i);e=this._sourceSession.spec.correctTradingDay(e);const t=new Date(e);Ct().set_hms(t,0,0,0,0,this._sourceSession.timezone),i=t.valueOf()}const s=this._sourceTargetBuilder();s.moveTo(i);const r=s.indexOfBar(i);t=s.startOfBar(Math.max(0,r))/1e3,this._cache.set(e,t)}return t}_sourceTargetBuilder(){if(null===this._sourceTargetBarBuilder){const e=this._isSessionTheSame?this._targetSession:(null===Tt&&(Tt=new xt.SessionInfo("Etc/UTC","24x7")),Tt);this._sourceTargetBarBuilder=(0,xt.newBarBuilder)(this._target.resolution,this._targetSession,e)}return this._sourceTargetBarBuilder}}var Lt=i(87095),At=i(36112),kt=i(93613);function Dt(e,t){return e.codet.code?1:0}class Vt{constructor(e){this._convertibleItems=e,this._idsToItems=new Map;for(const t of e)this._idsToItems.set(t.id,t)}convertible(e){return void 0!==this._idsToItems.get(e)}item(e){var t;return null!==(t=this._idsToItems.get(e))&&void 0!==t?t:null}size(){return this._convertibleItems.length}filterConvertible(e,t){const i=this._convertibleItems.filter(function(e,t){return i=>!e.has(i.id)&&t(i.id)}(e,t));return i.sort(Dt),i}}class Et{constructor(e){this._allGroups=new Set,this._idToName=new Map,this._idToDescription=new Map,this._groupedUnitIds=new Map,this._groupedUnits=new Map,this._groupById=new Map,this._size=0,this._units=e;for(const t in e)if(e.hasOwnProperty(t)){this._allGroups.add(t), -this._groupedUnitIds.set(t,new Set(e[t].map((e=>e.id)))),this._groupedUnits.set(t,e[t]);for(const i of e[t])this._size++,this._idToName.set(i.id,i.name),this._idToDescription.set(i.id,i.description),this._groupById.set(i.id,t)}}unitsChanged(e){return this._units!==e}size(){return this._size}name(e){return this._idToName.get(e)||e}description(e){return this._idToDescription.get(e)||e}unitGroupById(e){return this._groupById.get(e)||null}allGroups(){return new Set(this._allGroups)}unitsByGroups(e){const t=[];return e.forEach((e=>{const i=this._groupedUnits.get(e);void 0!==i&&t.push({name:e,units:i})})),t}convertible(e,t){for(const i of t){const t=this._groupedUnitIds.get(i);if(void 0!==t&&t.has(e))return!0}return!1}}var Bt=i(50335);class Rt{constructor(e){this._source=null,this._sourcePane=null,this._currentToolSupportsPhantomMode=!1,this._model=e}destroy(){this._source=null,this._sourcePane=null}source(){return this._source}onToolChanged(){this._removeSource();const e=this._model.currentTool();this._currentToolSupportsPhantomMode=(0,he.isLineToolName)(e)&&(0,S.supportsPhantomMode)(e)}onCursorPositionUpdated(){if(!this._currentToolSupportsPhantomMode)return;const e=this._model.crossHairSource();if(this._sourcePane!==e.pane&&this._removeSource(),null===e.pane||!(0,Bt.isNumber)(e.index)||!(0,Bt.isNumber)(e.price))return void this._removeSource();const t={index:e.index,price:e.price};null!==this._source?this._source.setPoint(0,t):(this._source=this._model.createLineTool(e.pane,t,this._model.currentTool(),void 0,null,0),this._sourcePane=e.pane)}_removeSource(){null!==this._source&&(this._model.removeSource(this._source),this._source=null,this._sourcePane=null)}}var Nt=i(17133),Ot=i(36147),Ft=i(18540);class Wt{constructor(){this._lastValue=null}align(e,t,i){this._lastValue=null;let s=e;if(!(0,Ft.magnetEnabled)().value())return s;const r=i.mainDataSource();if(null===r)return s;const o=r.model().mainSeries();if(r!==o)return s;const a=o.priceScale();if(a.isEmpty())return s;const l=function(e,t){const i=e.bars().valueAt(t);if(null===i)return;let s;if(null!==e.priceSource())s=[e.barFunction()(i)];else switch(e.style()){case 12:s=[i[2],i[3]];break;case 16:s=[i[2],i[4],i[3]];break;default:s=[i[1],i[2],i[3],i[4]]}return s}(o,t);if(!l)return s;const c=(0,n.ensure)(o.firstValue()),h=l.map((e=>({y:a.priceToCoordinate(e,c),price:e}))),d=a.priceToCoordinate(e,c);h.sort(((e,t)=>Math.abs(e.y-d)-Math.abs(t.y-d)));const u=h[0];return((0,Ft.magnetMode)().value()===Ot.MagnetMode.StrongMagnet||Math.abs(u.y-d)<50)&&(s=u.price,this._lastValue=s),s}lastValue(){return this._lastValue}resetLastValue(){this._lastValue=null}}var Ht=i(77475),zt=i(14292),Ut=i(68441),jt=i(59590);class Gt extends jt.BitmapCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null}setData(e){this._data=e}hitTest(e){return null}_drawImpl(e){if(null===this._data)return;const{context:t,verticalPixelRatio:i,horizontalPixelRatio:s,bitmapSize:r}=e,n=Math.max(1,Math.floor(s));t.lineWidth=n;const o=Math.ceil(r.height*i),a=Math.ceil(r.width*s);if(t.lineCap="butt", -this._data.vertLinesVisible){t.strokeStyle=this._data.vertLinesColor,(0,Ut.setLineStyle)(t,this._data.vertLineStyle);for(const e of this._data.timeMarks){const i=Math.round(e.coord*s);(0,Ut.drawVerticalLine)(t,i,0,o)}}if(this._data.horzLinesVisible){t.strokeStyle=this._data.horzLinesColor,(0,Ut.setLineStyle)(t,this._data.horzLineStyle);for(const e of this._data.priceMarks){const s=Math.round(e.coord*i);(0,Ut.drawHorizontalLine)(t,s,0,a)}}}}class qt{constructor(e){this._renderer=new Gt,this._pane=e}update(){}renderer(){const e=this._pane.defaultPriceScale(),t=this._pane.model().timeScale();if(e.isEmpty()||t.isEmpty())return null;const i=this._pane.model().properties().childs().paneProperties.childs(),s=t.marks(),r=i.gridLinesMode.value(),n={horzLinesVisible:"both"===r||"horz"===r,vertLinesVisible:"both"===r||"vert"===r,horzLinesColor:i.horzGridProperties.childs().color.value(),vertLinesColor:i.vertGridProperties.childs().color.value(),horzLineStyle:i.horzGridProperties.childs().style.value(),vertLineStyle:i.vertGridProperties.childs().style.value(),priceMarks:e.marks(),timeMarks:null!==s?s:[]};return this._renderer.setData(n),this._renderer}}class $t extends zt.DataSource{id(){return"grid"}paneViews(e){return[new qt(e)]}name(){return"Grid"}}var Yt=i(42275);class Kt extends Yt.PriceAxisView{constructor(e,t,i,s){super(),this._source=e,this._pane=t,this._priceScale=i,this._priceProvider=s,this._properties=e.model().properties().childs().scalesProperties}setHitTestData(e){this._hitTestData=e}setXCoord(e){this._xCoord=e}additionalPadding(e){return 0}_updateRendererData(e,t,i){e.visible=!1,t.visible=!1;const s=this._priceScale,r=s.mainSource(),n=null!==r?r.firstValue():null;if(!this._isVisible()||s.isEmpty()||null===n)return;const o=this._currentPrice(s);if(null===o)return;i.background=(0,Lt.resetTransparency)(this._bgColor()),i.textColor=this.generateTextColor(i.background);const a=this.additionalPadding(s.fontSize());i.additionalPaddingTop=a,i.additionalPaddingBottom=a,i.coordinate=s.priceToCoordinate(o,n),e.text=s.formatPrice(o,n),e.visible=!0,t.visible=!0,t.hitTestData=this._hitTestData,t.xCoord=this._xCoord}_currentPrice(e){return this._priceProvider(e)}}class Zt extends Kt{additionalPadding(e){return 2/12*e}_isVisible(){const e=this._source.lockedPane();return this._properties.childs().showPriceScaleCrosshairLabel.value()&&(this._source.visible||null!==e)&&(null!=e?e:this._source.pane)===this._pane}_currentPrice(e){const t=Se.crosshairLock.value();return null!==t&&1===t.type?this._pane===this._source.lockedPane()?t.price:null:super._currentPrice(e)}_bgColor(){const e=this._properties.childs();return this._source.model().dark().value()?e.crosshairLabelBgColorDark.value():e.crosshairLabelBgColorLight.value()}_updateRendererData(e,t,i){const s=t.visible;super._updateRendererData(e,t,i),this._source.isHovered()?t.backgroung=this._source.model().dark().value()?l.colorsPalette["color-cold-gray-600"]:l.colorsPalette["color-cold-gray-650"]:t.backgroung=void 0,s||(t.visible=s)}}class Xt extends Kt{_isVisible(){ -return null!==this._source.measurePane().value()}_bgColor(){return this._properties.childs().axisLineToolLabelBackgroundColorCommon.value()}}var Jt=i(43493),Qt=(i(39347),i(10643)),ei=(i(37591),i(11095));function ti(e){const t=e.priceScale();return null===t?0:t.isPercentage()||t.isIndexedTo100()?2:1}const ii=N.enabled("show_context_menu_in_crosshair_if_only_one_item");class si extends Jt.PanePriceAxisView{constructor(e,t,i,s,r){super(e,t,s),this._crossHairMenuCachedState=null,this._hasActions=!1,this._tooltipText=null,this._gaOrigin="CH menu",this._crosshairPriceAxisView=e,e.setPaneRendererLabelIcon(0),this._crosshair=t,this._scale=i,this._options=r,this._updateGaOrigin()}_updateImpl(e,t){const i=this._crosshair.y,s=this._chartModel.properties().childs().scalesProperties.childs().fontSize.value(),r=this._chartModel.timeScale().width(),n=this._crosshair.model().priceAxisRendererOptions(),a=s+2*this._crosshairPriceAxisView.additionalPadding(s)+n.paddingTop+n.paddingBottom,l=a,c=i-a/2,h=this._crosshair.pane,d=this._mainDataSourceOnPane(),u=d&&d.symbolSource(),p=!!u&&(u.isConvertedToOtherCurrency()||u.isConvertedToOtherUnit());if(this._updateGaOrigin(),null!==d){const e=ti(d),t=d.idForAlert(),i=this._chartModel.isInReplay(),s=this._crossHairMenuCachedState,r=N.enabled("chart_crosshair_menu");null!==s&&s.id===t&&s.priceScale===e&&s.isCurrencyOrUnitConverted===p&&s.isInReplay===i&&s.isMenuEnabled===r||(this._updateTooltipAndActionsAvailability(d,e,p),this._crossHairMenuCachedState={id:t,priceScale:e,isCurrencyOrUnitConverted:p,isInReplay:i,isMenuEnabled:r})}const _=null!==d&&(0,_e.isActingAsSymbolSource)(d)?d.symbol():null,m=null!==h&&(h.maximized().value()||!h.collapsed().value())&&(Boolean(_)||!1);this._crosshairPriceAxisView.setPaneLabelVisible(m);const g=this._position();if(null!==g){const e=0,t=r-l,i=Boolean(ei.showPlusButtonOnCursor.value()),s=i?this._crosshair.x:void 0,n=void 0!==s?s-l/2:"left"===g?e:t,h=void 0!==s?s+l/2:"left"===g?e+l:t+l,d=(0,o.box)(new o.Point(n,c),new o.Point(h,c+a)),u=this._tooltipText?{text:this._tooltipText,rect:{x:d.min.x,y:d.min.y,w:d.max.x-d.min.x,h:d.max.y-d.min.y}}:void 0;this._data={itemBox:d,clickHandler:this._handleClick.bind(this,g,i,d),tooltip:u},this._crosshairPriceAxisView.setHitTestData(this._data),this._crosshairPriceAxisView.setXCoord(s)}super._updateImpl(e,t)}_priceScale(){return this._scale}_updateGaOrigin(){this._gaOrigin=Boolean(ei.showPlusButtonOnCursor.value())?"CH menu cursor":"CH menu"}_updateTooltipAndActionsAvailability(e,t,i){this._tooltipText=null,this._hasActions=!1;if(!(1===t))return;this._chartModel.isInReplay();let s=0;let r=0;1!==s||ii||(this._tooltipText=""),this._crosshairPriceAxisView.setPaneRendererLabelIcon(r),this._hasActions=0!==s}_handleClick(e,t,i,s,r){(0,u.trackEvent)(this._gaOrigin,"click");const n=this._mainDataSourceOnPane(),o=null!==n&&(0,_e.isActingAsSymbolSource)(n)?n.symbol():null,a={pageX:r.pageX,pageY:r.pageY,clientX:r.clientX,clientY:r.clientY,screenX:r.screenX,screenY:r.screenY,price:this._crosshair.price,symbol:o};_.emit("onPlusClick",a)} -_getMenuItems(e){return Promise.resolve([])}_createAlertMenuItems(e){return Promise.resolve([])}_createTradingMenuItems(){return Promise.resolve([])}_createAddHorizontalLineMenuItem(){return[]}_getActionAddAlert(e){return null}_getActionAddHorizontalLine(e){return null}_getValue(e,t){const i=e.priceScale(),s=e.firstValue();if(null===i||null===s)return null;return i.isPercentage()||i.isIndexedTo100()?null:i.coordinateToPrice(t,s)}_formatValue(e,t){return t.formatter().format(e)}async _addAlert(e,t){}_addHorizontalLineTool(e,t){}_showContextMenu(e,t,i,s,r){const o="left"===r;setTimeout((()=>{const r=s.clientX-s.localX,a=s.clientY-s.localY,l=i.min.x+r,c=i.max.x+r,h=i.min.y+a,d=c-l,u=i.max.y+a-h,p=t?Se.crosshairLock.value():void 0;if(void 0!==p){const e=(0,n.ensureNotNull)(this._chartModel.timeScale().points().roughTime(this._crosshair.index));Se.crosshairLock.setValue({type:1,price:this._crosshair.price,time:e,modelId:this._chartModel.id(),paneId:(0,n.ensureNotNull)(this._crosshair.pane).id()})}Qt.ContextMenuManager.showMenu(e,{clientX:s.clientX,clientY:s.clientY,box:{x:l,w:d,y:h,h:u},attachToXBy:t?"auto":o?"left":"right",attachToYBy:"auto-strict",marginX:t?0:-d},void 0,{menuName:"CrosshairMenuView"},(()=>{void 0!==p&&Se.crosshairLock.setValue(p)}))}))}_mainDataSourceOnPane(){const e=this._crosshair.pane;return null!==e?e.mainDataSource():null}}var ri=i(79849),ni=i(38325),oi=i(18807);class ai extends jt.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){return void 0===this._data.clickHandler?null:new oi.HitTestResult(oi.HitTarget.Custom,{clickHandler:this._data.clickHandler,tapHandler:this._data.clickHandler})}_drawImpl(e){const t=this._data.vertLinesVisible,i=this._data.horzLinesVisible;if(!t&&!i)return;const{context:s,horizontalPixelRatio:r,verticalPixelRatio:n,bitmapSize:o}=e;s.lineWidth=Math.max(1,Math.floor(this._data.lineWidth*r)),s.strokeStyle=this._data.color,s.fillStyle=this._data.color,s.lineCap="butt",(0,Ut.setLineStyle)(s,this._data.lineStyle);const a=Math.round(this._data.x*r),l=Math.round(this._data.y*n),c=Math.ceil(o.width*r),h=Math.ceil(o.height*n);t&&a>=0&&(0,Ut.drawVerticalLine)(s,a,0,h),i&&l>=0&&(0,Ut.drawHorizontalLine)(s,l,0,c),this._data.drawCenter&&(s.beginPath(),s.arc(a,l,Math.round(3*r),0,2*Math.PI,!0),s.fillStyle=this._data.color,s.fill()),this._data.scissors&&function(e,t,i){const{context:s,bitmapSize:r,horizontalPixelRatio:n,verticalPixelRatio:o}=e,a=24*n,l=Math.round(t-a/2);let c=Math.round(i-a/2);if(c<0)c=0;else{const e=r.height-a;c>e&&(c=e)}s.translate(l,c),s.scale(n,o),s.fillStyle="#131722",s.fill(li),s.strokeStyle="#fff",s.lineWidth=1,s.stroke(li)}(e,a,l)}} -const li=new Path2D("m15.68 3.72-3.82 5.52-3.83-5.52-.28-.42-.42.3a2.84 2.84 0 0 0-.68 3.92l3.27 4.73-1.16 1.68a3.34 3.34 0 0 0-4.26 3.22 3.34 3.34 0 0 0 3.32 3.35 3.34 3.34 0 0 0 3.08-4.6l1-1.44 1.13 1.62a3.34 3.34 0 0 0 3.15 4.42c1.84 0 3.32-1.5 3.32-3.35a3.34 3.34 0 0 0-4.42-3.17l-1.23-1.78 3.22-4.65a2.86 2.86 0 0 0-.69-3.96l-.41-.29-.29.42ZM7.82 16.27c.47 0 .86.39.86.88 0 .48-.39.87-.86.87a.87.87 0 0 1-.86-.87c0-.5.4-.88.86-.88Zm8.36 0c.47 0 .86.39.86.88 0 .48-.4.87-.86.87a.87.87 0 0 1-.86-.87c0-.5.39-.88.86-.88Z");const ci=l.colorsPalette["color-tv-blue-500"];class hi{constructor(e,t){this._rendererData={},this._renderer=new ai(this._rendererData),this._source=e,this._pane=t}update(){}renderer(e,t){var i,s;const r=this._source.selectPointMode().value()!==Se.SelectPointMode.None,o=this._source.lockedPane(),a=(this._source.visible||null!==o)&&(this._source.areLinesVisible||r)&&!this._source.linesShouldBeHidden(),l=this._rendererData;if(!a||null===this._pane)return null;const c=this._source.paneForPointSelect(),h=this._source.isReplaySelection(),d=null!=o?o:this._source.pane,u=this._pane===d,p=h||(null!==c?d===c&&this._pane===c:u);if(l.scissors=!1,r&&(h||this._source.isOnHoveredChartWidget())&&p){const e=(0,n.ensureNotNull)(this._source.pointToSelect());l.color=this._source.lineColor()||ci,h?(l.lineWidth=2,l.scissors=u):l.lineWidth=1,l.lineStyle=ri.LINESTYLE_SOLID,l.horzLinesVisible=!0,l.vertLinesVisible=!0,l.drawCenter=!1,"time"===e?l.horzLinesVisible=!1:"price"===e&&(l.vertLinesVisible=!1)}else{const e=this._source.properties(),t=this._source.model().currentTool(),i=(0,ni.lastMouseOrTouchEventInfo)(),s=i.isTouch&&!i.stylus&&((0,he.isLineToolName)(t)||(0,Se.toolIsMeasure)(t));let r;r=s?ci:e.childs().color.value();const n=e.childs().transparency.value();!s&&n>0&&(r=(0,Lt.generateColor)(r,n)),l.color=r,l.horzLinesVisible=this._pane===d&&(this._pane.maximized().value()||!this._pane.collapsed().value()),l.vertLinesVisible=!0,l.lineWidth=e.childs().width.value(),l.lineStyle=e.childs().style.value(),l.drawCenter=s&&this._pane===d}return l.x=null!==(i=this._source.lockedX())&&void 0!==i?i:this._source.x,l.y=null!==(s=this._source.lockedY())&&void 0!==s?s:this._source.y,this._renderer}}var di=i(72739);const ui={backgroundColor:(0,Lt.generateColor)(l.colorsPalette["color-tv-blue-500"],70),borderColor:(0,Lt.generateColor)(l.colorsPalette["color-tv-blue-500"],20)};class pi{constructor(e){this._renderer=new di.RectangleRenderer,this._rectangle=null,this._crosshair=e}update(){const e=this._crosshair.selection();null!==e&&null!==this._crosshair.pane?this._rectangle=this._crosshair.pane.logicalRectToPixels(e):this._rectangle=null}renderer(e,t){if(!this._rectangle)return null;const i={backcolor:ui.backgroundColor,color:ui.borderColor,fillBackground:!0,linewidth:1,points:[this._rectangle.min,this._rectangle.max],extendLeft:!1,extendRight:!1};return this._renderer.setData(i),this._renderer}}var _i=i(38223),mi=i(57322),gi=i(2043),fi=i(98596),vi=i(99031),Si=i(80657),yi=i(19266),bi=i(73436) -;const wi=c.t(null,void 0,i(33355)),Pi=c.t(null,{context:"study"},i(32819)),Ci=new ye.PercentageFormatter,xi=new gi.TimeSpanFormatter,Ti=new fi.VolumeFormatter,Ii=(0,l.getHexColorByName)("color-tv-blue-500"),Mi=(0,l.getHexColorByName)("color-ripe-red-400"),Li={bgColorPositive:(0,Lt.generateColor)(Ii,80),bgColorNegative:(0,Lt.generateColor)(Mi,80),colorPositive:(0,l.getHexColorByName)("color-tv-blue-600"),colorNegative:(0,l.getHexColorByName)("color-ripe-red-400"),labelBgColorPositive:Ii,labelBgColorNegative:Mi};class Ai{constructor(e,t){this._pipFormatter=null,this._lastSymbolInfo=null,this._horzTrenRenderer=new vi.TrendLineRenderer,this._vertTrenRenderer=new vi.TrendLineRenderer,this._bgRenderer=new di.RectangleRenderer,this._labelRenderer=new Si.TextRenderer,this._p1=null,this._p2=null,this._label=null,this._source=e,this._pane=t}update(e){var t,i;const[s,r]=this._source.measurePoints();if(void 0===r)return this._p1=null,void(this._p2=null);const a=(0,n.ensureNotNull)(this._source.measurePane().value()),l=s.price,c=r.price,h=r.index-s.index,d=(0,_i.forceLTRStr)(""+h),u=(0,n.ensureNotNull)(a.mainDataSource()),p=(0,n.ensureNotNull)(u.formatter()),_=r.price-l;let m=null!==(i=null===(t=p.formatChange)||void 0===t?void 0:t.call(p,r.price,l))&&void 0!==i?i:p.format(_);if(Math.abs(l)>1e-8){const e=_/Math.abs(l);m+=" ("+Ci.format(100*e)+")"}const g=(0,_i.forceLTRStr)(m);this._label=g+"\n"+wi.format({count:d});const f=(0,n.ensureNotNull)(u.firstValue()),v=this._source.model().timeScale().indexToCoordinate(s.index),S=this._source.model().timeScale().indexToCoordinate(r.index),y=a.defaultPriceScale().priceToCoordinate(l,f),b=a.defaultPriceScale().priceToCoordinate(c,f);this._p1=new o.Point(v,y),this._p2=new o.Point(S,b);const w=this._source.model().timeScale().indexToUserTime(s.index),P=this._source.model().timeScale().indexToUserTime(r.index);let C=null;if(null!==w&&null!==P){const e=this._pane.model().mainSeries().symbolInfo();null!==e&&e!==this._lastSymbolInfo&&(this._pipFormatter=new mi.PipFormatter(e.pricescale,e.minmov,e.type,e.minmove2,e.typespecs),this._lastSymbolInfo=e),C=(P.valueOf()-w.valueOf())/1e3}const x=this._pipFormatter?this._pipFormatter.format(_):null,T=null!==x?" , "+x:"",I=null!==C?xi.format(C):null,M=null!==I?", "+(0,_i.startWithLTR)(I):"";this._label=(0,_i.forceLTRStr)(g+T)+"\n"+wi.format({count:d})+M;const L=this._source.measureVolume();Number.isNaN(L)||(this._label+=`\n${Pi} ${Ti.format(L)}`);const k=c=50?bi.LineEnd.Arrow:bi.LineEnd.Normal} -;this._horzTrenRenderer.setData(s)}{const e=Math.round(B.x),t=new o.Point(e,this._p1.y),i=new o.Point(e,this._p2.y),s={points:[t,i],color:D,linewidth:1,linestyle:ri.LINESTYLE_SOLID,extendleft:!1,extendright:!1,leftend:bi.LineEnd.Normal,rightend:Math.abs(t.y-i.y)>=50?bi.LineEnd.Arrow:bi.LineEnd.Normal};this._vertTrenRenderer.setData(s)}const R={x:0,y:10},N=.5*(this._p1.x+this._p2.x),O=this._p2.y,F=new o.Point(N,O),W=(H=(0,n.ensureNotNull)(this._label),{points:[F],text:H,color:"#FFFFFF",horzAlign:"center",vertAlign:"middle",font:A.CHART_FONT_FAMILY,offsetX:R.x,offsetY:R.y,bold:!1,italic:!1,fontsize:12,padding:8,highlightBorder:!1,backgroundColor:V,backgroundTransparency:10,backgroundVertInflate:5,backgroundHorzInflate:5,backgroundRoundRect:4});var H;this._labelRenderer.setData(W);const z=this._labelRenderer.measure(),U=(0,Si.calculateLabelPosition)(z,this._p1,this._p2,R,this._pane.height());this._labelRenderer.setPoints([U])}renderer(){if(null===this._p1||null===this._p2)return null;const e=new yi.CompositeRenderer;return e.append(this._bgRenderer),e.append(this._horzTrenRenderer),e.append(this._vertTrenRenderer),e.append(this._labelRenderer),e}}var ki=i(15187);class Di extends ki.MediaCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){return null}_drawImpl(e){const t=e.context;t.translate(this._data.x-this._data.width/2,this._data.y-this._data.height/2),t.strokeStyle="rgba(153,153,153,.3)",t.lineWidth=2,t.beginPath(),this._drawShackle(t),t.stroke(),t.closePath(),t.strokeStyle="rgba(153,153,153,.7)",t.lineWidth=1,t.beginPath(),t.rect(0,this._data.height-this._data.bodyHeight+.5,this._data.width,this._data.bodyHeight),t.closePath(),t.stroke(),t.translate(0,-1),t.strokeStyle="#777",t.beginPath(),this._drawShackle(t),t.stroke(),t.closePath(),t.fillStyle="rgba(255,255,255,.7)",t.beginPath(),t.rect(1,this._data.height-this._data.bodyHeight+1.5,this._data.width-2,this._data.bodyHeight-2),t.fill(),t.beginPath(),t.rect(.5,this._data.height-this._data.bodyHeight+1,this._data.width-1,this._data.bodyHeight-1),t.stroke(),t.closePath(),t.fillStyle="#777",t.fillRect(this._data.width/2-.5,this._data.height-this._data.bodyHeight/2,1,2)}_drawShackle(e){const t=(this._data.width-3)/2,i=this._data.height-this._data.bodyHeight;e.moveTo(1.5,t),e.arc(this._data.width/2,t,t,Math.PI,2*Math.PI),i>t&&(e.moveTo(1.5,t),e.lineTo(1.5,i),e.moveTo(this._data.width-1.5,t),e.lineTo(this._data.width-1.5,i))}}class Vi{constructor(e,t,i){this._horzVisible=!1,this._source=e,this._pane=t,this._axis=i||"x"}update(){}renderer(e,t){var i;const s=this._source.visible&&this._source.areLinesVisible,r=0===(null===(i=Se.crosshairLock.value())||void 0===i?void 0:i.type),o=s&&this._horzVisible,a=s||r;if("y"===this._axis&&!o||!a)return null;const l="y"===this._axis?this._pane.width()-4.5:(0,n.ensureNotNull)(this._source.lockedX())+1,c="y"===this._axis?this._source.y:this._pane.height()-5.5-1;return new Di({x:l,y:c,width:9,height:11,bodyHeight:7})}}var Ei=i(49483),Bi=i(93835),Ri=i(88546);class Ni extends Bi.DataWindowView{constructor(e){super(), -this._invalidated=!0,this._dateItem=new Bi.DataWindowItem("",c.t(null,void 0,i(76912)),""),this._timeItem=new Bi.DataWindowItem("",c.t(null,void 0,i(31976)),""),this._model=e,this._items.push(this._dateItem),this._items.push(this._timeItem)}update(){this._invalidated=!0}items(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._items}_updateImpl(){const e=this._model.mainSeries().isDWM();if(this._timeItem.setVisible(!e),this._timeItem.setValue(Ri.notAvailable),this._dateItem.setValue(Ri.notAvailable),this._model.timeScale().isEmpty())return;let t=this._model.crossHairSource().appliedIndex();if(!(0,Bt.isNumber)(t)){const e=this._model.mainSeries().data().last();if(null===e)return;t=e.index}const i=this._model.timeScale().indexToUserTime(t);null!==i&&(this._dateItem.setValue(this._model.dateFormatter().format(i)),e||this._timeItem.setValue(this._model.timeFormatter().format(i)))}}var Oi=i(34951);const Fi=l.colorsPalette["color-tv-blue-500"],Wi=c.t(null,{context:"Replay"},i(20747));class Hi extends Oi.TimeAxisView{constructor(e,t,i,s=!1){super(e),this._indexProvider=i,this._highlighted=s,this._source=t,this._properties=e.properties().childs().scalesProperties}_getText(e){if(this._source.isReplaySelection()){const t=this._model.timeScale().indexToUserTime(e);return null!==t?`${Wi}: ${this._model.dateTimeFormatter().format(t)}`:""}return super._getText(e)}_getBgColor(){if(this._source.isReplaySelection())return Fi;const e=this._properties.childs();return this._highlighted?e.axisLineToolLabelBackgroundColorCommon.value():this._model.dark().value()?e.crosshairLabelBgColorDark.value():e.crosshairLabelBgColorLight.value()}_getIndex(){return this._model.crossHairSource().visible||null!==this._source.lockedPane()?this._indexProvider():null}_isVisible(){return this._properties.childs().showTimeScaleCrosshairLabel.value()}}var zi=i(96280),Ui=i(94025);const ji={menuEnabled:!1,menuForMainSourceOnly:!1,disableTradingMenuActions:!1,disableDrawHorizLineMenuAction:!1};let Gi=0;const qi=(0,X.getLogger)("Chart.Crosshair");class $i extends zt.DataSource{constructor(e,t,i){super(),this.pane=null,this.price=NaN,this.index=NaN,this.visible=!0,this.areLinesVisible=!0,this.x=NaN,this.y=NaN,this._lockData=null,this._measurePane=new q.WatchedValue(null),this._measurePaneViewCache=new WeakMap,this._startMeasurePoint=null,this._endMeasurePoint=null,this._lastValidMeasurePoint=null,this._isOnHoveredChartWidget=!1,this._crossHairSelectPointMode=new q.WatchedValue(Se.SelectPointMode.None),this._selectionPane=null,this._selectionView=new pi(this),this._selectionStartPoint=null,this._timeLockPaneView=null,this._crosshairPaneViewCache=new WeakMap,this._pointSelectionPaneViewCache=new WeakMap,this._priceAxisViews=new Map,this._panePriceAxisViews=new Map,this._startMeasurePriceAxisViews=new Map,this._endMeasurePriceAxisViews=new Map,this._originX=NaN,this._originY=NaN,this._subscribed=!1,this._movedDelegate=new G.Delegate,this._pointSelectedDelegate=new G.Delegate,this._requestedPoint=null,this._paneForRequestedPoint=null, -this._selectLineColor=null,this._volumeCalculator=null,this._selectFromAllChartsIfOutOfData=null,this._currentMeasurePointsetAndSymbolId=null,this._model=e,this._options=Object.assign({},ji,i||{}),this._linesShouldBeHidden=this._model.readOnly(),this._dataWindowView=new Ni(e),this.setSelectionEnabled(!1);const s=e=>t=>t===(0,n.ensureNotNull)(this._measurePane.value()).defaultPriceScale()?e():null;this._currentPosPriceProvider=e=>{const t=(0,n.ensureNotNull)(this.pane);if(e===t.defaultPriceScale())return this.price;const i=(0,n.ensureNotNull)(t.defaultPriceScale().mainSource()).firstValue();if(null===i)return null;const s=t.defaultPriceScale().priceToCoordinate(this.price,i),r=(0,n.ensureNotNull)(e.mainSource()).firstValue();return null===r?null:e.coordinateToPrice(s,r)},this._startMeasurePriceProvider=s((()=>(0,n.ensureNotNull)(this._startMeasurePoint).price)),this._endMeasurePriceProvider=s((()=>(0,n.ensureNotNull)(this._lastMeasurePoint()).price)),this._properties=t;this._timeAxisView=new Hi(e,this,(()=>this.appliedIndex()),!1),this._startMeasureTimeAxisView=new Hi(e,this,(()=>(0,n.ensureNotNull)(this._startMeasurePoint).index),!0),this._endMeasureTimeAxisView=new Hi(e,this,(()=>(0,n.ensureNotNull)(this._lastMeasurePoint()).index),!0),e.readOnly()||Se.cursorTool.subscribe((e=>this.areLinesVisible="arrow"!==e),{callWithLast:!0}),this._crosshairLock=Se.crosshairLock.spawn(),this._showPlusButtonOnCursor=ei.showPlusButtonOnCursor.spawn();const r=()=>{this.updateAllViews((0,W.sourceChangeEvent)(this.id())),this._model.lightUpdate()};this._crosshairLock.subscribe(r),this._showPlusButtonOnCursor.subscribe(r)}destroy(){null!==this._volumeCalculator&&this._volumeCalculator.destroy(),this._measurePane.setValue(null),this._crosshairLock.destroy(),this._showPlusButtonOnCursor.destroy(),this._removeMeasurePointset()}name(){return"Crosshair"}moved(){return this._movedDelegate}originX(){return this._originX}originY(){return this._originY}saveOriginCoords(e,t){this._originX=e,this._originY=t}clearOriginCoords(){this._originX=NaN,this._originY=NaN}currentPoint(){return new o.Point(this.x,this.y)}model(){return this._model}appliedIndex(){var e;return null!==(e=this._getLockData().index)&&void 0!==e?e:this.index}lockedX(){var e;return null!==(e=this._getLockData().xCoord)&&void 0!==e?e:null}lockedY(){var e;return null!==(e=this._getLockData().yCoord)&&void 0!==e?e:null}lockedPane(){const e=Se.crosshairLock.value();return null===e||1!==e.type?null:this._model.id()===e.modelId?this._model.paneForId(e.paneId):this._model.mainPane()}invalidateLockPosition(){this._lockData=null}startMeasurePoint(){return this._startMeasurePoint||null}endMeasurePoint(){return this._endMeasurePoint||null}measureVolume(){if(null===this._volumeCalculator)return NaN;const[e,t]=this.measurePoints();return void 0===t?NaN:this._volumeCalculator.volume(e.index,t.index)}measurePane(){return this._measurePane.readonly()}startMeasuring(e,t){this._startMeasurePoint=e,this._measurePane.setValue(t),t.containsMainSeries()&&((0,n.assert)(null===this._volumeCalculator), -this._volumeCalculator=new zi.SeriesTimeRangeVolumeCalculator(this.model().mainSeries())),this._model.updatePane(t)}finishMeasure(e){this._endMeasurePoint=e,this._createMeasurePointset((0,n.ensureNotNull)(this._startMeasurePoint),this._endMeasurePoint)}clearMeasure(){this._removeMeasurePointset(),this._measurePane.setValue(null),delete this._startMeasurePoint,delete this._endMeasurePoint,delete this._lastValidMeasurePoint,this._model.lightUpdate(),null!==this._volumeCalculator&&(this._volumeCalculator.destroy(),this._volumeCalculator=null)}measurePoints(){const e=[(0,n.ensureNotNull)(this._startMeasurePoint)],t=this._lastMeasurePoint();return null!==t&&e.push(t),e}startSelection(e){this._selectionStartPoint=this.currentLogicalPoint(),this._selectionPane=e}clearSelection(){this._selectionStartPoint=null,this._selectionPane=null}selection(){return this._selectionStartPoint?{p1:this._selectionStartPoint,p2:this.currentLogicalPoint()}:null}currentLogicalPoint(){return{index:this.appliedIndex(),price:this.price}}selectPointMode(){return this._crossHairSelectPointMode}lineColor(){return this._selectLineColor}cancelRequestSelectPoint(){this._crossHairSelectPointMode.value()!==Se.SelectPointMode.None&&this._setSelectPointModeState(Se.SelectPointMode.None),this._selectFromAllChartsIfOutOfData=null}requestSelectPoint(e){(0,n.assert)(this._crossHairSelectPointMode.value()===Se.SelectPointMode.None,"Point already requested");const{pointType:t,pane:i,lineColor:s=null,selectFromAllChartsIfOutOfData:r,selectPointMode:o=Se.SelectPointMode.Study}=e;i&&((0,n.assert)(-1!==this._model.panes().indexOf(i),"Chartmodel doesn't contains specified pane"),this._paneForRequestedPoint=i,this._model.panesCollectionChanged().subscribe(this,this._paneCollectionChanged)),this._selectLineColor=s,this._requestedPoint=t,this._selectFromAllChartsIfOutOfData=null!=r?r:null,this._setSelectPointModeState(o)}onPointSelected(){return this._pointSelectedDelegate}trySelectCurrentPoint(){var e;const t=(0,n.ensureNotNull)(this._requestedPoint);let i=null;if(!this._model.mainSeries().bars().search(this.index,dt.PlotRowSearchMode.Exact)&&"price"!==t&&(this._selectFromAllChartsIfOutOfData&&(i=null!==(e=Math.min(...Array.from(Se.barTimesUnderCursor.values())))&&void 0!==e?e:null),null===i))return;const s=(0,n.ensureNotNull)(this.pane);if(this._paneForRequestedPoint&&this._paneForRequestedPoint!==s)return;let r,o=i;if("price"===t||null!==i||(o=this._model.timeScale().indexToTimePoint(this.index),null!==o)){if("time"!==t){const e=s.mainDataSource();if(null===e)return;const t=e.firstValue(),i=e.priceScale();if(null===t||null===i)return;r=i.coordinateToPrice(this.y,t)}this._setSelectPointModeState(Se.SelectPointMode.None),this._pointSelectedDelegate.fire({time:null!=o?o:void 0,price:r},s)}}isOnHoveredChartWidget(){return this._isOnHoveredChartWidget}setOnHoveredChartWidget(e){this._isOnHoveredChartWidget=e}isReplaySelection(){return!1}clearPosition(){this.visible=!1,this.index=NaN,this.price=NaN,this.x=NaN,this.y=NaN,this.pane=null,this.clearOriginCoords(), -this._updateVisibilityDependentPaneViews()}setPosition(e,t,i){this._subscribed||(this._model.mainSeries().onRestarted().subscribe(this,this.clearMeasure),this._subscribed=!0),this.visible=!0;const s=this._model.id(),r=this._model.mainSeries().bars().search(this.index,dt.PlotRowSearchMode.NearestRight);return r&&Se.barTimesUnderCursor.set(s,r.value[0]),this._tryToUpdateViews(e,t,i)}setLinesShouldBeHidden(e){this._linesShouldBeHidden=e}linesShouldBeHidden(){return this._linesShouldBeHidden}handleContextMenuEvent(e){this._crossHairSelectPointMode.value()!==Se.SelectPointMode.None&&this._setSelectPointModeState(Se.SelectPointMode.None)}properties(){return this._properties}priceAxisViews(e,t){var i;const s=null===this._requestedPoint||"time"!==this._requestedPoint||!this._isOnHoveredChartWidget,r=[];return(null!==(i=this.lockedPane())&&void 0!==i?i:this.pane)===e&&s&&r.push(this._createPriceAxisViewOnDemand(this._priceAxisViews,this._panePriceAxisViews,e,t,this._currentPosPriceProvider,Zt,!0)[0]),this._startMeasurePoint&&r.push(this._createPriceAxisViewOnDemand(this._startMeasurePriceAxisViews,null,e,t,this._startMeasurePriceProvider,Xt)[0]),this._lastMeasurePoint()&&r.push(this._createPriceAxisViewOnDemand(this._endMeasurePriceAxisViews,null,e,t,this._endMeasurePriceProvider,Xt)[0]),r}timeAxisViews(){const e=[],t=null===this._requestedPoint||"price"!==this._requestedPoint||!this._isOnHoveredChartWidget;return this._linesShouldBeHidden||!this.visible&&null===Se.crosshairLock.value()||!t||e.push(this._timeAxisView),this._startMeasurePoint&&e.push(this._startMeasureTimeAxisView),this._lastMeasurePoint()&&e.push(this._endMeasureTimeAxisView),e}paneViews(e){var t,i;if(void 0===e)return null;const s=[];if(this.isReplaySelection()){let t=this._pointSelectionPaneViewCache.get(e);t||(t=new CrosshairPointSelectionPaneView(this,e,this._model),this._pointSelectionPaneViewCache.set(e,t)),s.push(t)}let r=this._crosshairPaneViewCache.get(e);if(r||(r=new hi(this,e),this._crosshairPaneViewCache.set(e,r)),s.push(r),e===this._selectionPane&&s.push(this._selectionView),e===this._measurePane.value()){let t=this._measurePaneViewCache.get(e);t||(t=new Ai(this,e),this._measurePaneViewCache.set(e,t)),t.update((0,W.sourceChangeEvent)(this.id())),s.push(t)}if((ei.addPlusButtonProperty.value()||this._showPlusButtonOnCursor.value())&&1!==(null===(t=Se.crosshairLock.value())||void 0===t?void 0:t.type)){const t=e===this.pane,i=!Ei.CheckMobile.any()||window.screen.width>=320,r=Se.tool.value(),n=(0,he.isLineToolName)(r),o=null!==this._model.lineBeingEdited()||null!==this._model.lineBeingCreated()||this._model.sourcesBeingMoved().length>0||null!==this._model.customSourceBeingMoved()||(0,Se.toolIsMeasure)(r);if(t&&this._isOnHoveredChartWidget&&this._crossHairSelectPointMode.value()===Se.SelectPointMode.None&&i&&!n&&!o){const t=e.mainDataSource();if(null!==t){const i=t.priceScale();if(null!==i){const t=this._createPriceAxisViewOnDemand(this._priceAxisViews,this._panePriceAxisViews,e,i,this._currentPosPriceProvider,Zt,!0)[1];null!==t&&s.push(t)}}}} -return 0===(null===(i=Se.crosshairLock.value())||void 0===i?void 0:i.type)&&(null===this._timeLockPaneView&&(this._timeLockPaneView=new Vi(this,e)),s.push(this._timeLockPaneView)),s}dataWindowView(){return this._dataWindowView}updateAllViews(e){this._priceAxisViews.forEach((t=>{t.forEach((t=>t.update(e)))})),this._panePriceAxisViews.forEach((t=>{t.forEach((t=>t.update(e)))})),this._startMeasurePoint&&(this._startMeasurePriceAxisViews.forEach((t=>{t.forEach((t=>t.update(e)))})),this._startMeasureTimeAxisView.update(e)),this._lastMeasurePoint()&&(this._endMeasurePriceAxisViews.forEach((t=>{t.forEach((t=>t.update(e)))})),this._endMeasureTimeAxisView.update(e)),this._timeAxisView.update(e),this._selectionView.update(),this._dataWindowView.update(),this._updateVisibilityDependentPaneViews()}isMenuEnabled(){return!0}isHoveredEnabled(){return ei.addPlusButtonProperty.value()||this._showPlusButtonOnCursor.value()}isHovered(){return this._model.hoveredSource()===this}pointToSelect(){return this._requestedPoint}paneForPointSelect(){return this._paneForRequestedPoint}_lastMeasurePoint(){return this._endMeasurePoint?this._endMeasurePoint:(null!==this.pane&&this._measurePane.value()===this.pane&&(this._lastValidMeasurePoint={price:this._model.magnet().align(this.price,this.index,this.pane),index:this.index}),this._lastValidMeasurePoint||null)}_createPriceAxisViewOnDemand(e,t,i,s,r,o,a=!1){let l=e.get(i),c=null!==t?t.get(i):void 0;void 0===l&&(l=new Map,e.set(i,l),this.isMenuEnabled()&&null!==t&&(c=new Map,t.set(i,c)),a&&i.onDestroyed().subscribe(this,(()=>this._onPaneDestroyed(i))));let h=l.get(s);if(void 0===h){if(h=new o(this,i,s,r),l.set(s,h),void 0!==c){const e=new si(h,this,s,this._model,this._options);c.set(s,e)}a&&s.lastSourceRemoved().subscribe(this,(()=>this._onPriceScaleCleared(s)))}let d=null;return void 0!==c&&(d=(0,n.ensureDefined)(c.get(s))),[h,d]}_onPaneDestroyed(e){e.onDestroyed().unsubscribeAll(this),this._priceAxisViews.delete(e),this._panePriceAxisViews.delete(e),this._startMeasurePriceAxisViews.delete(e),this._endMeasurePriceAxisViews.delete(e)}_onPriceScaleCleared(e){e.lastSourceRemoved().unsubscribeAll(this),this._priceAxisViews.forEach((t=>t.delete(e))),this._panePriceAxisViews.forEach((t=>t.delete(e))),this._startMeasurePriceAxisViews.forEach((t=>t.delete(e))),this._endMeasurePriceAxisViews.forEach((t=>t.delete(e)))}_tryToUpdateViews(e,t,i){return!!this._tryToUpdateData(e,t,i)&&(this.updateAllViews((0,W.sourceChangeEvent)(this.id())),this._movedDelegate.fire({index:this.index,price:this.price}),!0)}_tryToUpdateData(e,t,i){const s=this.x,r=this.y,o=this.price,a=this.index,l=this.pane,c=this._priceScaleByPane(i);if(this.index=e,this.x=isNaN(e)?NaN:this._model.timeScale().indexToCoordinate(e),null!==c&&null!==i){this.pane=i,this.price=t;const e=(0,n.ensureNotNull)(i.mainDataSource()).firstValue();this.y=null===e?NaN:c.priceToCoordinate(t,e)}else this.pane=null,this.price=NaN,this.y=NaN;return s!==this.x||r!==this.y||a!==this.index||o!==this.price||l!==this.pane}_priceScaleByPane(e){ -return e&&!e.defaultPriceScale().isEmpty()?e.defaultPriceScale():null}_setSelectPointModeState(e){e===Se.SelectPointMode.None&&(this._requestedPoint=null,this._selectLineColor=null,this._paneForRequestedPoint&&(this._paneForRequestedPoint=null,this._model.panesCollectionChanged().unsubscribe(this,this._paneCollectionChanged))),Se.activePointSelectionMode.setValue(e),this._crossHairSelectPointMode.setValue(e),this._model.lightUpdate()}_paneCollectionChanged(e){const t=this._paneForRequestedPoint;null!==t&&-1===e.indexOf(t)&&this.cancelRequestSelectPoint()}_updateVisibilityDependentPaneViews(){var e;for(const t of this.model().panes())null===(e=this._pointSelectionPaneViewCache.get(t))||void 0===e||e.update()}_getLockData(){var e;if(null===this._lockData){const t=Se.crosshairLock.value();if(null===t)this._lockData={};else{const i=this._model.timeScale(),s=null!==(e=i.points().roughIndex(t.time))&&void 0!==e?e:void 0,r=void 0===s?void 0:i.indexToCoordinate(s);switch(t.type){case 0:this._lockData={index:s,xCoord:r};break;case 1:{let e;const i=this.lockedPane();if(null!==i){const s=i.mainDataSource();if(null!==s){const i=s.firstValue(),r=s.priceScale();null!==r&&null!==i&&(e=r.priceToCoordinate(t.price,i))}}this._lockData={index:s,xCoord:r,yCoord:e}}}}}return this._lockData}_createMeasurePointset(e,t){const i=this._normalizePoint(e),s=this._normalizePoint(t),r=[[i.time_t,i.offset],[s.time_t,s.offset]];this._removeMeasurePointset(),++Gi,this._currentMeasurePointsetAndSymbolId={measurePointsetId:Gi,symbolId:(0,n.ensureNotNull)(this._model.mainSeries().seriesSource().symbolInstanceId())};const o=(0,Ui.getServerInterval)(this._model.mainSeries().interval());this._model.chartApi().createPointset(this._currentMeasurePointsetIdWithPrefix(),"turnaround",this._currentMeasurePointsetAndSymbolId.symbolId,o,r,this._onPointsetResponse.bind(this))}_removeMeasurePointset(){null!==this._currentMeasurePointsetAndSymbolId&&this._model.chartApi().isConnected().value()&&this._model.chartApi().removePointset(this._currentMeasurePointsetIdWithPrefix()),this._currentMeasurePointsetAndSymbolId=null}_currentMeasurePointsetIdWithPrefix(){return"pointsetMeasure_"+(0,n.ensureNotNull)(this._currentMeasurePointsetAndSymbolId).measurePointsetId}_normalizePoint(e){return{...this._model.timeScale().normalizeBarIndex(e.index),price:e.price}}_onPointsetResponse(e){if("pointset_error"===e.method)return void qi.logError(`Error getting pointset: ${e.params[0]} ${e.params[1]}`);if(e.params.customId!==this._currentMeasurePointsetIdWithPrefix())return;if(null===this._startMeasurePoint||null===this._endMeasurePoint)return;const t=e.params.plots;if(2!==t.length)return;const i=t[0].value[0],s=t[1].value[0];this._startMeasurePoint.index=i,this._endMeasurePoint.index=s,this.updateAllViews((0,W.sourceChangeEvent)(this.id())),this._model.updateSource(this)}}var Yi=i(50146),Ki=i(12416),Zi=i(17236),Xi=i(39262),Ji=i(26426),Qi=i(56840);class es{constructor(e){this._priceSourceNamesById=new Map,e.forEach((e=>this._priceSourceNamesById.set(e.id,e.name)))}name(e){var t -;return null!==(t=this._priceSourceNamesById.get(e))&&void 0!==t?t:null}priceSourcesChanged(e){return e.length!==this._priceSourceNamesById.size}}var ts=i(97906),is=i(90194);const ss=new ee.TranslatedString("remove deselected empty line tools",c.t(null,void 0,i(59211))),rs=N.enabled("auto_enable_symbol_labels"),ns=(0,X.getLogger)("Chart.ChartModel");function os(e,t){const i=e.indexOf(t);return-1!==i&&(e.splice(i,1),!0)}function as(e){var t,i;for(let s=e.length;s--;){const r=e[s].dataSources();for(let e=r.length;e--;)null===(t=r[e].dataWindowView())||void 0===t||t.update();const n=e[s].priceDataSources();for(let e=n.length;e--;)null===(i=n[e].legendView())||void 0===i||i.update()}}const ls={isSnapshot:!1,readOnly:!1,watermarkEnabled:!0,shiftVisibleRangeOnNewBar:!0,currencyConversionEnabled:!1,unitConversionEnabled:!1,countdownEnabled:!0,lastPriceAnimationEnabled:!0,onWidget:!1,hideIdeas:!1};class cs{constructor(e,t,i,r,n,o,a,l,c,d,u){this._onRearrangePanes=new G.Delegate,this._lineToolsGroupModel=new bt,this._sourcesBeingMoved=[],this._activeItemBeingMoved=null,this._lineBeingEdited=null,this._linePointBeingEdited=null,this._linePointBeingChanged=null,this._customSourceBeingMovedHitTestData=null,this._customSourceBeingMoved=null,this._dataSourceCollectionChanged=new G.Delegate,this._sourceProperitesChanged=new G.Delegate,this._sourceZOrderChanged=new G.Delegate,this._symbolSourceResolved=new G.Delegate,this._symbolSourceResolvingActive=new q.WatchedValue(!1),this._adjustForDividendsAvailability=new q.WatchedValue(0),this._adjustForDividendsEnabled=new q.WatchedValue(!1),this._sessions=null,this._currentTool="",this._lineBeingCreated=null,this._paneBeingCreatedLineOn=null,this._lineCancelled=new G.Delegate,this._phantomSourceContainer=new Rt(this),this._destroyed=!1,this._isSettingsExternalPosition=!1,this._isTimeScrolling=!1,this._magnet=new Wt,this._scrollingState=null,this._modelIntervals=[],this._rendererOptionsProvider=new k(this),this._studyInserted=new G.Delegate,this._cachedStudiesMaxOffset=0,this._replayStatus=new q.WatchedValue(wt.ReplayStatus.Undefined),this._panes=[],this._tagsChanged=new G.Delegate,this._strategySources=[],this._strategySourcesChange=new G.Delegate,this._activeStrategySource=new q.WatchedValue(null),this._paneCollapsingAvailable=new q.WatchedValue(!1),this._panesCollectionChanged=new G.Delegate,this._scrollEnabled=N.enabled("chart_scroll"),this._zoomEnabled=N.enabled("chart_zoom"),this._lollipopSourcesWatcher=null,this._alertsWatcher=null,this._hoveredSource=null,this._hoveredSourceChanged=new G.Delegate,this._lastHoveredHittestData=null,this._lastSelectedHittestData=null,this._topmostCustomSources=[],this._fgCustomSources=[],this._bgCustomSources=[],this._allCustomSources=[],this._customSourcesMap=new Map,this._multiPaneSources=[],this._showLegendProperty=new(M()),this._id=(0,J.guid)(),this._chartSaveTime=null,this._availableCurrenciesList=null,this._availableCurrencies=new Vt([]),this._availablePriceSources=new es([]),this._availableUnitsObject=null,this._availableUnits=new Et({}), -this._availablePriceSourcesList=null,this._shouldBeSavedEvenIfHidden=!1,this._watchedThemeSpawn=h.watchedTheme.spawn(),this._gradientColorsCache=null,this._studiesWV=new $.WatchedObject([],v.compareTwoCollectionsByIds),this._studiesExcludeInternalWV=new $.WatchedObject([],v.compareTwoCollectionsByIds),this._resetScalesAvailable=new q.WatchedValue(!1),this._recalcVRStudiesParams={},this._recalcColorStudiesParams={},this._recalcVisibleRangeStudiesImplDebounced=(0,s.default)(this._recalcVisibleRangeStudiesImpl.bind(this,this._recalcVRStudiesParams),500),this._recalcColorStudiesImplDebounced=(0,s.default)(this._recalcColorStudiesImpl.bind(this,this._recalcColorStudiesParams),250),this._width=0,this._resetScales=new G.Delegate,this._chartThemeLoaded=new G.Delegate,this._selection=new b,this._selectedSourceChanged=new G.Delegate,this._symbolSourceCollectionChanged=new G.Delegate,this._gridSource=new $t,this._syncPointCache=new Map,this._lastAppliedGotoTimeRange=null,this._lastGotoTimeRange=null,this._clearSelection=()=>{this._lastSelectedHittestData=null,this._selection.clear()},this._removeSourceFromSelection=e=>{this._selection.remove(e)},this._addSourceToSelection=(e,t)=>{const i=this._selection.isSelected(e);i&&this._lastSelectedHittestData===t||e&&!e.isSelectionEnabled()||(this._lastSelectedHittestData=t||null,i||this._selection.add(e))},this._recalcSymbolResolvingActive=()=>{for(const e of this._panes)if(e.symbolSourceResolvingActive().value())return void this._symbolSourceResolvingActive.setValue(!0);this._symbolSourceResolvingActive.setValue(!1)},this._recalcAdjustForDividendsAvailibility=()=>{var e,t,i,s;if(this._symbolSourceResolvingActive.value())return void this._adjustForDividendsAvailability.setValue(0);const r=this.mainSeries();switch(null!==(t=null===(e=r.symbolInfo())||void 0===e?void 0:e.allowed_adjustment)&&void 0!==t?t:"none"){case"dividends":return void this._adjustForDividendsAvailability.setValue(2);case"splits":return void this._adjustForDividendsAvailability.setValue(1);case"any":return void this._adjustForDividendsAvailability.setValue(3)}for(const e of this.symbolSources().filter(_e.isActingAsSymbolSource)){if(e.symbolHibernated().value()||e===r)continue;if("any"===(null!==(s=null===(i=e.symbolInfo())||void 0===i?void 0:i.allowed_adjustment)&&void 0!==s?s:"none"))return void this._adjustForDividendsAvailability.setValue(3)}this._adjustForDividendsAvailability.setValue(0)},this._recalcAdjustForDividendsEnabled=()=>{switch(this._adjustForDividendsAvailability.value()){case 2:return void this._adjustForDividendsEnabled.setValue(!0);case 0:case 1:return void this._adjustForDividendsEnabled.setValue(!1)}this._adjustForDividendsEnabled.setValue(this.mainSeries().properties().childs().dividendsAdjustment.value())},this._recalcPaneCollapsingAvailable=e=>{let t=this._panes.filter((e=>!e.collapsed().value())).length;0===t&&e&&this._panes.length>0&&(this._panes[0].collapsed().setValue(!1),t=1),this._paneCollapsingAvailable.setValue(t>1)},this._updateResetScalesAvailableValue=()=>{ -const e=this._timeScale.resetAvailable().value()||this._panes.some((e=>e.resetPriceScalesAvailable().value()));this._resetScalesAvailable.setValue(e)},this._chartApi=e,this._invalidateHandler=t,this._undoModel=o,this._properties=i,this._options=(0,ie.merge)((0,ie.clone)(ls),l),this._hibernateWV=c,this._linkingGroupIndex=d,this._isAutoSaveEnabled=u,this._studiesMetaInfoRepository=n,this._readOnly=this._options.readOnly,this._isSnapshot=this._options.isSnapshot,this._chartSaveTime=(new Date).valueOf(),this._backgroundColor=new q.WatchedValue(this._getBackgroundColor()),this._backgroundTopColor=new q.WatchedValue(this._getBackgroundColor(!0)),this._properties.childs().paneProperties.childs().background.subscribe(this,this._updateBackgroundColor),this._properties.childs().paneProperties.childs().backgroundType.subscribe(this,this._updateBackgroundColor),this._properties.childs().paneProperties.childs().backgroundGradientStartColor.subscribe(this,this._updateBackgroundColor),this._properties.childs().paneProperties.childs().backgroundGradientEndColor.subscribe(this,this._updateBackgroundColor),this._backgroundColor.subscribe(this.recalcColorStudies.bind(this,!1)),this._backgroundTopColor.subscribe(this.recalcColorStudies.bind(this,!1)),this._backgroundCounterColor=new q.WatchedValue(this._getBackgroundCounterColor()),this._backgroundColor.subscribe((()=>this._backgroundCounterColor.setValue(this._getBackgroundCounterColor()))),this._isDark=(0,ts.combine)((e=>"white"===e),this._backgroundCounterColor.weakReference()),this._watchedThemeSpawn.subscribe(this._updateBackgroundColor.bind(this)),this._symbolSourceResolvingActive.subscribe(this._recalcAdjustForDividendsAvailibility),this.setStudiesMetaData(this._studiesMetaInfoRepository.getInternalMetaInfoArray(),this._studiesMetaInfoRepository.getMigrations()),(0,Se.init)();const p=this._readOnly?new(M())((0,B.defaults)("chartproperties.paneProperties.crossHairProperties")):this._properties.childs().paneProperties.childs().crossHairProperties;this.m_crossHairSource=new $i(this,p,this._options.crossHair),this._crossHairSelectPointMode=this.m_crossHairSource.selectPointMode().spawn(),this._crossHairSelectPointMode.subscribe((e=>{if(e!==Se.SelectPointMode.None&&this.lineBeingCreated()){const e=Se.tool.value();this.cancelCreatingLine(),Se.tool.setValue(e)}})),this._tagsChanged=new G.Delegate;const _=new T.DefaultProperty("chartproperties.mainSeriesProperties");_.addExclusion("minTick"),_.addExclusion("priceAxisProperties.lockScale"),_.addExclusion("priceAxisProperties.percentage"),_.addExclusion("priceAxisProperties.indexedTo100"),_.addExclusion("priceAxisProperties.isInverted"),_.addExclusion("priceAxisProperties.log"),_.addExclusion("priceAxisProperties.logDisabled"),_.addExclusion("priceAxisProperties.percentageDisabled"),_.addExclusion("priceAxisProperties.autoScaleDisabled"),_.merge(i.childs().mainSeriesProperties.state()),this._timeScale=new gt(this,this._options.timeScale),this._timeScale.resetAvailable().subscribe(this._updateResetScalesAvailableValue);const m={ -countdownEnabled:this._options.countdownEnabled,lastPriceAnimationEnabled:this._options.lastPriceAnimationEnabled};this.m_mainSeries=new pe.Series(this,_,m,r),this.m_mainSeries.onStyleChanged().subscribe(this._timeScale,this._timeScale.invalidateVisibleBars);const g=()=>this.fullUpdate();this.m_mainSeries.properties().childs().showCountdown.subscribe(this,(()=>{this.m_mainSeries.updateAllViews((0,W.sourceChangeEvent)(this.m_mainSeries.id())),g()})),(0,K.currencyUnitVisibilityProperty)().subscribe(this,g),(0,Z.autoLogButtonsVisibilityProperty)().subscribe(this,g),this._timeScale.visibleBarsStrictRangeChanged().subscribe(this.m_mainSeries,this.m_mainSeries.clearHighLowPriceCache),this._timeScale.visibleBarsStrictRangeChanged().subscribe(this.m_mainSeries,this.m_mainSeries.clearAveragePriceCache),this.createPane(void 0,{axisProperties:_.childs().priceAxisProperties.state(["autoScale"])}),this._adjustForDividendsAvailability.subscribe(this._recalcAdjustForDividendsEnabled),this.mainSeries().properties().childs().dividendsAdjustment.subscribe(this,this._recalcAdjustForDividendsEnabled),this._recalcAdjustForDividendsEnabled(),this._boundUpdateStudiesMaxOffset=this._updateStudiesMaxOffset.bind(this),this.mainSeries().dataEvents().seriesTimeFrame().subscribe(this,((e,t,i,s)=>{if(null!==this._lastAppliedGotoTimeRange&&null!==i&&s&&(0,Nt.areEqualTimeFrames)(this._lastAppliedGotoTimeRange.range,i)){const e=this.appliedTimeFrame().value();null!==e&&!this._lastAppliedGotoTimeRange.actual&&(0,Nt.areEqualTimeFrames)(this._lastAppliedGotoTimeRange.range,e.val)&&this.appliedTimeFrame().setValue(null),this._lastAppliedGotoTimeRange=null}})),this.mainSeries().dataEvents().completed().subscribe(this,(e=>{null===this._lastAppliedGotoTimeRange&&null!==this._lastGotoTimeRange&&(this.gotoTimeRange(this._lastGotoTimeRange.from,this._lastGotoTimeRange.to),this._lastGotoTimeRange=null)}));const f=this._panes[0];f.setStretchFactor(2*f.stretchFactor()),this._properties.listeners().subscribe(this,this.lightUpdate),this._properties.childs().timezone.subscribe(null,(()=>{this._chartApi&&this._chartApi.isConnected().value()&&this._chartApi.switchTimezone(this.timezone())})),f.addDataSource(this.m_mainSeries,f.findSuitableScale(this.m_mainSeries),!1),this._barsMarksSources=a(this);for(const e of this._barsMarksSources)e.setOwnerSource(this.m_mainSeries),f.addDataSource(e,this.m_mainSeries.priceScale(),!0);this.m_mainSeries.symbolResolved().subscribe(this,this._clearAvailablePriceSources)}setStudiesMetaData(e,t){this._studiesMetaData=e,this._studyVersioning=new w.StudyVersioning(this._studiesMetaData,t)}restart(){this._chartApi.switchTimezone(this.timezone()),this._timeScale.reset(),this.m_mainSeries.restart();for(const e of this.dataSources())e.restart&&e!==this.m_mainSeries&&e.restart();this.sessions().restart()}version(){return 3}collapsed(){return this._hibernateWV}chartSaveTime(){return this._chartSaveTime}setChartSaveTime(e){this._chartSaveTime=e}destroy(){this._phantomSourceContainer.destroy(),this._hoveredSourceChanged.destroy(), -null!==this._watermarkSource&&(this._watermarkSource.destroy(),this._watermarkSource=null),Array.from(this._customSourcesMap.keys()).forEach(this._removeCustomSource,this),(0,n.assert)(0===this._topmostCustomSources.length),(0,n.assert)(0===this._fgCustomSources.length),(0,n.assert)(0===this._bgCustomSources.length),(0,n.assert)(0===this._allCustomSources.length),(0,n.assert)(0===this._customSourcesMap.size),null!==this._lollipopSourcesWatcher&&(this._lollipopSourcesWatcher.destroy(),this._lollipopSourcesWatcher=null),null!==this._alertsWatcher&&this._alertsWatcher.destroy(),this._properties.childs().paneProperties.childs().background.unsubscribeAll(this),this._properties.childs().paneProperties.childs().backgroundType.unsubscribeAll(this),this._properties.childs().paneProperties.childs().backgroundGradientEndColor.unsubscribeAll(this),this._properties.childs().paneProperties.childs().backgroundGradientStartColor.unsubscribeAll(this),this._watchedThemeSpawn.destroy(),this._lastHoveredHittestData=null,this._lastSelectedHittestData=null,(0,K.currencyUnitVisibilityProperty)().unsubscribeAll(this),(0,Z.autoLogButtonsVisibilityProperty)().unsubscribeAll(this),this._crossHairSelectPointMode.destroy(),this.m_mainSeries.symbolResolved().unsubscribe(this,this._clearAvailablePriceSources),this._destroyed=!0}undoModel(){return this._undoModel}onData(e){switch(e.method){case"timescale_update":{const t=e.params;this._updateTimeScale({index:t.index,zoffset:t.zoffset,values:t.changes,indexDiffs:t.index_diff,baseIndex:t.baseIndex,marks:t.marks,clearFlag:t.clear});break}case"timescale_completed":{const t=Boolean(e.params[0]);this._timeScale.onTimeScaleCompleted(t);break}}}addStrategySource(e,t){1!==t&&-1===this._strategySources.indexOf(e)&&(this._strategySources.push(e),this._strategySourcesChange.fire(t),this.setActiveStrategySource(e))}removeStrategySource(e,t){if(1===t)return;const i=this._strategySources.indexOf(e);if(-1!==i){if(this._strategySources.splice(i,1)[0]===this._activeStrategySource.value()&&this.unsetActiveStrategySource(),this._strategySources.length>0){const e=this._strategySources[this._strategySources.length-1];this.setActiveStrategySource(e)}this._strategySourcesChange.fire(t)}}setActiveStrategySource(e){-1!==this._strategySources.indexOf(e)&&this._activeStrategySource.setValue(e)}unsetActiveStrategySource(){this._activeStrategySource.setValue(null)}activeStrategySource(){return this._activeStrategySource}strategySources(){return this._strategySources}strategySourcesChange(){return this._strategySourcesChange}setScrollEnabled(e){this._scrollEnabled=e}scrollEnabled(){return this._scrollEnabled}setZoomEnabled(e){this._zoomEnabled=e}zoomEnabled(){return this._zoomEnabled}zoomToViewport(e,t,i,s,r){this.setTimeViewport(e,t);let n=Math.min(i,s),o=Math.max(i,s);const a=r.defaultPriceScale();a.isPercentage()||a.setMode({autoScale:!1}),a.isLog()&&(n=a.priceToLogical(n),o=a.priceToLogical(o)),a.setPriceRange(new de.PriceRange(n,o)),this.recalculateAllPanes((0,W.viewportChangeEvent)()), -this.invalidate(this._paneInvalidationMask(r,Y.InvalidationLevel.Light))}setTimeViewport(e,t){const i=this.appliedTimeFrame().value();null!==this._lastAppliedGotoTimeRange&&null!==i&&(0,Nt.areEqualTimeFrames)(this._lastAppliedGotoTimeRange.range,i.val)&&!this._lastAppliedGotoTimeRange.actual||(this.timeScale().zoomToBarsRange(e,t),this.recalculateAllPanes((0,W.viewportChangeEvent)()),this.recalcVisibleRangeStudies(),this.lightUpdate())}onTagsChanged(){return this._tagsChanged}canZoomIn(){return this._timeScale.canZoomIn()&&this._zoomEnabled}canZoomOut(){return this._timeScale.canZoomOut()&&this._zoomEnabled}onPaneTagsChanged(){this._tagsChanged.fire()}panesCollectionChanged(){return this._panesCollectionChanged}dataSourceCollectionChanged(){return this._dataSourceCollectionChanged}symbolSourceCollectionChanged(){return this._symbolSourceCollectionChanged}symbolSourceResolved(){return this._symbolSourceResolved}symbolSourceResolvingActive(){return this._symbolSourceResolvingActive}adjustForDividendsAvailability(){return this._adjustForDividendsAvailability}adjustForDividendsEnabled(){return this._adjustForDividendsEnabled}paneCollapsingAvailable(){return this._paneCollapsingAvailable}sourcePropertiesChanged(){return this._sourceProperitesChanged}sourceZOrderChanged(){return this._sourceZOrderChanged}zoomTime(e,t,i){if(!this._zoomEnabled)return;const s=this.timeScale();if(s.isEmpty()||0===t)return;const r=s.width();e=Math.max(1,Math.min(e,r-2)),s.zoom(e,t,i),this.recalculateAllPanes((0,W.viewportChangeEvent)()),this.lightUpdate(),this.recalcVisibleRangeStudies()}lineBeingEdited(){return this._lineBeingEdited}linePointBeingEdited(){return this._linePointBeingEdited}activeItemBeingMoved(){return this._activeItemBeingMoved}linePointBeingChanged(){return this._linePointBeingChanged}updateAllPaneViews(e){for(const t of this._panes)t.updateAllViews(e)}dataSources(){const e=[this.crossHairSource()];for(const t of this._panes)for(const i of t.dataSources())e.push(i);return e}priceDataSources(){const e=[];for(const t of this._panes)for(const i of t.priceDataSources())e.push(i);return e}symbolSources(){const e=[];for(const t of this._panes)for(const i of t.symbolSources())e.push(i);return e}selection(){return this._selection}selectionMacro(e,t=!1){const i=this.selection().allSources();e({removeSourceFromSelection:this._removeSourceFromSelection,addSourceToSelection:this._addSourceToSelection,clearSelection:this._clearSelection,selection:this.selection.bind(this)});const s=(0,v.subtract)(i,this.selection().allSources()),r=(0,v.subtract)(this.selection().allSources(),i);r.concat(i).forEach((e=>e.updateAllViews((0,W.selectionChangeEvent)())));let n=[];s.forEach((e=>{if((0,S.isLineTool)(e)){const i=e.hasAlert.value()&&e.getAlertSync();i&&i.setSelected(!1),!t&&e.shouldBeRemovedOnDeselect()&&n.push(e)}})),r.forEach((e=>{const t=(0,S.isLineTool)(e)&&e.hasAlert&&e.hasAlert.value()&&e.getAlertSync();t&&t.setSelected(!0)})),n=n.filter((e=>null!==this.dataSourceForId(e.id()))),n.length>0&&this._undoModel.removeSources(n,!1,ss), -this.lightUpdate(),(s.length>0||r.length>0)&&this._selectedSourceChanged.fire()}onSelectedSourceChanged(){return this._selectedSourceChanged}checkLineToolSelection(){const e=this.selection().allSources();this._selection.checkLineToolSelection(),e.length!==this.selection().allSources().length&&this._selectedSourceChanged.fire()}lineToolsGroupModel(){return this._lineToolsGroupModel}restoreLineToolsGroups(e){this._lineToolsGroupModel=bt.fromState(this,e)}realignLineTools(e){for(const t of this._panes)(void 0===e||t.hasDataSource(e))&&t.realignLineTools(e)&&this._dataSourceCollectionChanged.fire(t)}copyToOtherCharts(e,t){const i=this.mainSeries(),s=i.syncModel(),r=this.timeScale();if(s)for(const o of e){if(!o.isSynchronizable())continue;const e=o.linkKey().value()||(0,J.randomHash)();o.linkKey().setValue(e);const a=o.state(!1),l=o.normalizedPoints(),c=o.properties().interval.value(),h=i.interval();let d;if(x.Interval.isEqual(c,h))d=l.map((e=>{const t=(0,n.ensureNotNull)(r.timePointToIndex(e.time_t))+e.offset;return{price:e.price,timeStamp:(0,n.ensureNotNull)(this.externalTimeStamp(t))}}));else{const e=s.createNewModelWithResolution(c);d=l.map((t=>({price:t.price,timeStamp:0===t.offset?t.time_t:e.projectTime(t.time_t,t.offset)})))}const u={...a,id:o.id(),linkKey:e,points:d,linetool:o.toolname,model:this,symbol:i.symbol(),withUndo:t,zOrder:o.zorder(),finalState:{points:l,interval:c},pointPositionPercents:o.isFixed()?o.calcPositionPercents():void 0,sharingMode:o.sharingMode().value()};(0,Se.copyLineTool)(u)}}isSnapshot(){return this._isSnapshot}onWidget(){return this._options.onWidget}hideIdeas(){return this._options.hideIdeas}updateSource(e){const t=this._invalidationMaskForSource(e);null!==t&&this.invalidate(t)}updateSourcePriceScale(e){const t=this._invalidationMaskForSourcePriceScale(e);null!==t&&this.invalidate(t)}updatePane(e){this.invalidate(this._paneInvalidationMask(e))}updateTimeScaleBaseIndex(e){const t=this.mainSeries().bars();t.isEmpty()||this._updateBaseIndex((0,n.ensureNotNull)(t.lastIndex()),!!(e&&e.index>0))}setInterval(e,t){const i=setInterval(e,t);return this._modelIntervals.push(i),i}clearInterval(e){clearInterval(e);const t=this._modelIntervals.indexOf(e);t>-1&&this._modelIntervals.splice(t,1)}clearIntervals(){for(let e=0;e{i.ownerSource()===e&&i.setOwnerSource(t)})),t.start(),this.recalculatePane(i,(0,W.sourceChangeEvent)(t.id())),this.fullUpdate(),!0}insertStudyStub(e){const t=this.mainSeries(),i=(0,n.ensureNotNull)(this.paneForSource(t)),s=new P.StudyStub(this,null,e),r=i.createPriceScaleAtPosition("overlay");return i.addDataSource(s,r,!1),this.recalculatePane(i,(0,W.sourceChangeEvent)(s.id())),this.fullUpdate(),s}removeStudyStub(e){const t=this.dataSourceForId(e);return null===t?(ns.logNormal("StudyStub id="+e+" is not found in chart model"),!1):(this.removeSource(t),!0)}allLineTools(){return this._getAllSources(S.isLineTool)}setHoveredSource(e,t=null){const i=this._hoveredSource!==e;if(!i&&this._lastHoveredHittestData===t)return;this._lastHoveredHittestData=t;let s=null;if(this._hoveredSource){this._hoveredSource.updateAllViews((0,W.selectionChangeEvent)()),s=new Y.InvalidationMask(Y.InvalidationLevel.Cursor);const e=this._invalidationMaskForSource(this._hoveredSource,Y.InvalidationLevel.Light);null!==e&&s.merge(e)}if(this._hoveredSource=e,e){e.updateAllViews((0,W.selectionChangeEvent)()),s||(s=new Y.InvalidationMask(Y.InvalidationLevel.Cursor));const t=this._invalidationMaskForSource(e,Y.InvalidationLevel.Light);null!==t&&s.merge(t)}s&&this.invalidate(s),i&&this._hoveredSourceChanged.fire(e)}properties(){return this._properties}chartApi(){return this._chartApi} -disconnect(){this.sessions().stop();for(const e of this.dataSources())e.disconnect&&e.disconnect();this._timeScale.disconnect()}crossHairSource(){return this.m_crossHairSource}gridSource(){return this._gridSource}publishedChartsTimelineSource(){return null}hoveredSource(){return this._hoveredSource}hoveredSourceChanged(){return this._hoveredSourceChanged}lastHittestData(){return this._lastHoveredHittestData}lastSelectedHittestData(){return this._lastSelectedHittestData}syncTimeWithModel(e,t){const i=this.mainSeries().syncModel();if(null===i)return;const s=1e3*this.createSyncPoint(e,i.syncSourceTarget()).sourceTimeToTargetTime(t/1e3),r=(0,Pt.get_timezone)(this.timezone());let n=(0,Pt.utc_to_cal)(r,s);this.mainSeries().isDWM()&&(n=i.getSession().spec.correctTradingDay(n),(0,Pt.set_hms)(n,0,0,0,0,(0,Pt.get_timezone)("Etc/UTC"))),this._gotoTimeImpl(n.getTime(),{centerIfVisible:!1})}gotoTime(e){return this._gotoTimeImpl(e,{centerIfVisible:!0})}recalculatePane(e,t){null==e||e.recalculate(t)}recalculateAllPanes(e){this._panes.forEach((t=>t.recalculate(e))),this.updateAllPaneViews(e),this.crossHairSource().updateAllViews(e)}gotoTimeRange(e,t){const i=this.timeScale(),s=i.tickMarks(),r=this.mainSeries();if(void 0===s.minIndex)return void(this._lastGotoTimeRange={from:e,to:t});let o=e,a=t;const l=r.symbolInfo();if(null!==l){let i=this.properties().childs().timezone.value();"exchange"===i&&(i=l.timezone);const s=(0,Pt.get_timezone)(i),n=(0,Pt.utc_to_cal)(s,e),c=(0,Pt.utc_to_cal)(s,t);if(r.isDWM()){const e=(0,Pt.get_timezone)("Etc/UTC");(0,Pt.set_hms)(n,0,0,0,0,e),(0,Pt.set_hms)(c,0,0,0,0,e)}o=n.getTime(),a=c.getTime()}const c=(0,n.ensureDefined)(s.maxIndex),h=(0,n.ensureDefined)(s.minIndex);if(o>=(0,n.ensureNotNull)(s.indexToTime(h)).valueOf()||r.endOfData()){const e=(e,t)=>e(0,n.ensureNotNull)(s.indexToTime(e)).valueOf(),l=(0,v.lowerboundExt)(t,o,e,s.nearestIndex(o),c);let d=o===a?l:(0,v.lowerboundExt)(t,a,e,s.nearestIndex(a),c);this._lastGotoTimeRange=null,null!==this._lastAppliedGotoTimeRange&&(this._lastAppliedGotoTimeRange.actual=!1);const u=i.baseIndex();if(l+Math.max(d-l+1,i.minVisibleBarCount())>u){const e=i.targetDefaultRightOffset();d-u=0;t--)if(this._panes[t].hasDataSource(e))return this._panes[t];return e instanceof At.BarsMarksContainer?this.paneForSource(this.mainSeries()):null} -mainPane(){for(const e of this._panes)if(e.isMainPane())return e;throw new Error("Main pane is not found")}lastPane(){return this._panes[this._panes.length-1]}removeSource(e,t){this.selectionMacro((t=>t.removeSourceFromSelection(e)),!0),this._hoveredSource===e&&(this._hoveredSource=null,this._lastHoveredHittestData=null),this._sourcesBeingMoved.includes(e)&&(this._sourcesBeingMoved=this._sourcesBeingMoved.filter((t=>t!==e)),this._sourcesBeingMoved.length||(this._activeItemBeingMoved=null)),e===this._lineBeingEdited&&(this._lineBeingEdited=null,Se.isToolEditingNow.setValue(!1)),e===this._lineBeingCreated&&(this._lineBeingCreated=null,Se.isToolCreatingNow.setValue(!1)),!t&&e.stop&&e.stop();const i=this.detachSource(e),s=this.mainSeries().priceScale();return(0,j.isStudy)(e)&&(0,_e.isActingAsSymbolSource)(e)&&e.priceScale()===s&&s.isPercentage()&&1===s.seriesLikeSources().filter(_e.isActingAsSymbolSource).length&&s.setMode({percentage:!1}),this.fullUpdate(),this._invalidateBarColorerCaches(),(0,j.isStudy)(e)&&((0,_.emit)("study_event",e.id(),"remove"),e.isChildStudy()&&e.parentSources().forEach((t=>t.unsetChild(e))),e.maxOffset().unsubscribe(this._boundUpdateStudiesMaxOffset)),!t&&e.destroy&&e.destroy(),(0,S.isLineTool)(e)&&(e.removeAlert(),(0,_.emit)("drawing_event",e.id(),"remove")),i}allStudies(e){const t=e?e=>(0,j.isStudy)(e)&&!0:j.isStudy;return this._getAllSources(t)}studiesWV(e){return e?this._studiesExcludeInternalWV.readonly():this._studiesWV.readonly()}findNonOverlayStudyWithGroupingKey(e,t){const i=void 0!==t?[t]:this._panes;for(const t of i){const i=t.dataSources().find((i=>(0,j.isStudy)(i)&&i.metaInfo().groupingKey===e&&!t.isOverlay(i)));if(void 0!==i)return{pane:t,study:i}}return null}movePaneUp(e){this.movePane(e,e-1)}movePaneDown(e){this.movePane(e,e+1)}movePane(e,t){const i=this._panes[e];this._panes.splice(e,1),this._panes.splice(t,0,i),this._panesCollectionChanged.fire(this._panes),this._onRearrangePanes.fire(),this.invalidate(Y.InvalidationMask.panesOrder())}backgroundColor(){return this._backgroundColor}backgroundTopColor(){return this._backgroundTopColor}backgroundColorAtYPercentFromTop(e){const t=this.backgroundColor().value(),i=this.backgroundTopColor().value();if(t===i)return t;if(e=Math.max(0,Math.min(100,Math.round(100*e))),null===this._gradientColorsCache||this._gradientColorsCache.topColor!==i||this._gradientColorsCache.bottomColor!==t)this._gradientColorsCache={topColor:i,bottomColor:t,colors:new Map};else{const t=this._gradientColorsCache.colors.get(e);if(void 0!==t)return t}const s=(0,Lt.gradientColorAtPercent)(i,t,e/100);return this._gradientColorsCache.colors.set(e,s),s}backgroundCounterColor(){return this._backgroundCounterColor.readonly()}dark(){return this._isDark}defaultResolutions(){return this.chartApi().defaultResolutions()}availableCurrencies(){const e=this._getAvailableCurrencies();return e.length!==this._availableCurrencies.size()&&(this._availableCurrencies=new Vt(e)),this._availableCurrencies}currencyConversionEnabled(){return this._options.currencyConversionEnabled} -availableUnits(){const e=this._getAvailableUnits();return this._availableUnits.unitsChanged(e)&&(this._availableUnits=new Et(e)),this._availableUnits}unitConversionEnabled(){return this._options.unitConversionEnabled}availablePriceSources(){const e=this._getAvailablePriceSources();return null!==e&&this._availablePriceSources.priceSourcesChanged(e)&&(this._availablePriceSources=new es(e)),this._availablePriceSources}resetDeferredStudies(){Ve.instance(this).reset()}isJustClonedChart(){return this._undoModel.isJustClonedChart()}studyTemplate(e,t,i){const s={panes:[],version:this.version()};for(const e of this.panes())s.panes.push(e.state(!0,!1,!0));const r=this.mainSeries();return e&&(s.symbol=r.symbol(),this.currencyConversionEnabled()&&i&&(s.currency=r.currency()),this.unitConversionEnabled()&&i&&(s.unit=r.unit())),t&&(s.interval=r.interval()),s}getStudyById(e){const t=this.dataSourceForId(e);return null!==t&&(0,j.isStudy)(t)?t:null}getLineToolById(e){const t=this.dataSourceForId(e);return null!==t&&(0,S.isLineTool)(t)?t:null}restoreLineToolState(e,t,i){var s;e.restorePoints(t.points,t.indexes||[]),t.state.intervalsVisibilities=(0,Be.mergeIntervalVisibilitiesDefaults)(t.state.intervalsVisibilities),e.properties().merge(t.state),e.restoreData&&e.restoreData(t),e.linkKey().setValue(t.linkKey||null),e.createServerPoints(),e.setZorder(null!==(s=t.zorder)&&void 0!==s?s:e.zorder()),this.fullUpdate();const r=e.linkKey().value();null!==r&&i&&(0,Se.restoreLineToolState)({model:this,linkKey:r,state:t})}preferences(){return(0,Ki.preferencesByWhiteList)(this,this.mainSeries())}restoreTheme(e,t,i){e.mainSourceProperties.hollowCandleStyle||(e.mainSourceProperties.hollowCandleStyle=e.mainSourceProperties.candleStyle),this._undoModel.chartLoadTheme(e,t,i)}onResetScales(){return this._resetScales}startMovingSources(e,t,i,s,r,o){this._sourcesBeingMoved=e,this._activeItemBeingMoved=i;let a=!1;if(this._sourcesBeingMoved.forEach((e=>{!a&&(0,j.isStudy)(e)&&(a=!0);const l=(0,n.ensureNotNull)(this.paneForSource(e)),c=(0,S.isLineTool)(e),h=c&&e.linkKey().value();if(!1!==h&&null!==h&&s.has(h)&&c&&e.isFixed()){const t=(0,n.ensureDefined)(s.get(h)),a={screen:this._percentPositionToPoint(t,l)};e.startMoving(a,i,r,o)}else e.startMoving(t,i,r,o);const d=this._paneInvalidationMask(l,Y.InvalidationLevel.Light);this.invalidate(d)})),!o){const s=e.filter(S.isLineTool).filter((e=>e.linkKey().value()&&e.isSynchronizable())).map((e=>e.linkKey().value()));if(s.length&&t.logical){const o=this.externalTimeStamp(t.logical.index),a={linkKeys:s,model:this,symbol:this.mainSeries().symbol(),point:{price:t.logical.price,timeStamp:o},activeItem:null!==i?i:void 0,envState:r,pointPositionPercents:new Map};e.forEach((e=>{if((0,S.isLineTool)(e)){const i=e.linkKey().value();if(i&&e.isSynchronizable()&&e.isFixed()){const s=(0,n.ensureNotNull)(this.paneForSource(e));a.pointPositionPercents.set(i,this._pointToPercentPosition((0,n.ensureDefined)(t.screen),s))}}})),(0,Se.startMovingLineTool)(a)}}Se.isToolMovingNow.setValue(!0),a&&Se.isStudyEditingNow.setValue(!0)} -moveSources(e,t,i,s){if(this._sourcesBeingMoved.filter((e=>!e.isLocked||!e.isLocked())).forEach((r=>{const o=(0,S.isLineTool)(r)?r.linkKey().value():null;if(null!==o&&t.has(o)){const e=(0,n.ensureNotNull)(this.paneForSource(r)),a=(0,n.ensureDefined)(t.get(o)),l={screen:this._percentPositionToPoint(a,e)};r.move(l,this._activeItemBeingMoved,i,s)}else r.move(e,this._activeItemBeingMoved,i,s)})),this.lightUpdate(),!s&&e.logical){const t=this._sourcesBeingMoved.filter(S.isLineTool).filter((e=>e.isSynchronizable()&&!!e.linkKey().value())).map((e=>e.linkKey().value())),s=this.externalTimeStamp(e.logical.index),r={linkKeys:t,model:this,point:{price:e.logical.price,timeStamp:s},envState:i,pointPositionPercents:new Map};this._sourcesBeingMoved.filter(S.isLineTool).forEach((t=>{if(t.linkKey().value()&&t.isSynchronizable()&&t.isFixed()){const i=(0,n.ensureNotNull)(this.paneForSource(t));r.pointPositionPercents.set(t.linkKey().value(),this._pointToPercentPosition((0,n.ensureDefined)(e.screen),i))}})),(0,Se.moveLineTool)(r)}}endMovingSources(e,t,i){const s=this._sourcesBeingMoved.map((s=>{const r=(0,n.ensureNotNull)(this.paneForSource(s)),o=s.endMoving(e,t,i),a=this._paneInvalidationMask(r,Y.InvalidationLevel.Light);return a.invalidateAll(Y.InvalidationLevel.Light),this.invalidate(a),o})),r=this._sourcesBeingMoved.filter(S.isLineTool).filter((e=>e.isSynchronizable()&&!!e.linkKey().value())).map((e=>e.linkKey().value())),o=this._sourcesBeingMoved.filter(S.isLineTool).filter((e=>e.isSynchronizable()&&!!e.linkKey)).map((e=>{const t={points:e.normalizedPoints(),interval:this.mainSeries().interval()};return e.isFixed()&&(t.pointPositionPercents=e.calcPositionPercents()),t}));r.length&&(0,Se.finishMovingLineTool)({linkKeys:r,model:this,finalStates:o,changes:s}),this._sourcesBeingMoved=[],this._activeItemBeingMoved=null,Se.isToolMovingNow.setValue(!1),Se.isStudyEditingNow.setValue(!1)}sourcesBeingMoved(){return this._sourcesBeingMoved}setMovingCustomSource(e,t){this._customSourceBeingMoved=e,this._customSourceBeingMovedHitTestData=null!==t?{beingMoved:!1,...t}:null}processingCustomSourceMove(){null!==this._customSourceBeingMovedHitTestData&&(this._customSourceBeingMovedHitTestData.beingMoved=!0)}customSourceMovingHitTestData(){return this._customSourceBeingMovedHitTestData}customSourceBeingMoved(){return null!==this._customSourceBeingMovedHitTestData&&this._customSourceBeingMovedHitTestData.beingMoved?this._customSourceBeingMoved:null}lineToolsSynchronizer(){return this._lineToolsSynchronizer}setLineToolsSynchronizer(e){this._lineToolsSynchronizer=e}width(){return this._width}setWidth(e,t){this._width=e,this._timeScale.setWidth(e,t);for(const t of this._panes)t.setWidth(e);this.recalculateAllPanes((0,W.viewportChangeEvent)()),this.recalcVisibleRangeStudies()}setPaneHeight(e,t){e.setHeight(t),this.recalculateAllPanes((0,W.viewportChangeEvent)()),this.lightUpdate()}resetScalesAvailable(){return this._resetScalesAvailable.readonly()}panes(){return this._panes}paneForId(e){return this._panes.find((t=>t.id()===e))||null}createPane(e,t,i){ -const s=this._undoModel.chartWidget();s.isMaximizedPane()&&s.toggleMaximizePane(null);const r=this._properties.childs().paneProperties;t&&r.merge(t);const n=new Ge(this._timeScale,r,this,i);return void 0!==e?this._panes.splice(e,0,n):this._panes.push(n),n.onTagsChanged().subscribe(this,cs.prototype.onPaneTagsChanged),n.dataSourcesCollectionChanged().subscribe(this,(()=>this._dataSourceCollectionChanged.fire(n))),n.symbolSourceCollectionChanged().subscribe(this,(()=>this._onSymbolSourceCollectionChanged(n))),n.priceSourcesCollectionChanged().subscribe(this,(()=>this._onPriceSourcesCollectionChanged(n))),n.sourcePropertiesChanged().subscribe(this,(e=>this._sourceProperitesChanged.fire(n,e))),n.sourceZOrderChanged().subscribe(this,(e=>this._sourceZOrderChanged.fire(n,e))),n.symbolSourceResolved().subscribe(this,(e=>this._symbolSourceResolved.fire(n,e))),n.symbolSourceResolvingActive().subscribe(this._recalcSymbolResolvingActive),n.collapsed().subscribe(this._recalcPaneCollapsingAvailable),n.resetPriceScalesAvailable().subscribe(this._updateResetScalesAvailableValue,{callWithLast:!0}),this._recalcPaneCollapsingAvailable(),this._panesCollectionChanged.fire(this._panes),this.invalidate(Y.InvalidationMask.panesOrder()),n}removePane(e){const t=this._undoModel.chartWidget();t.isMaximizedPane()&&t.toggleMaximizePane(null);const i=e;i.destroy();const s=this._panes.indexOf(i);-1!==s&&(this._panes.splice(s,1),e.dataSourcesCollectionChanged().unsubscribeAll(this),e.symbolSourceCollectionChanged().unsubscribeAll(this),e.priceSourcesCollectionChanged().unsubscribeAll(this),e.sourcePropertiesChanged().unsubscribeAll(this),e.onTagsChanged().unsubscribeAll(this),e.symbolSourceResolved().unsubscribeAll(this),i.symbolSourceResolvingActive().unsubscribe(this._recalcSymbolResolvingActive),e.collapsed().unsubscribe(this._recalcPaneCollapsingAvailable),e.resetPriceScalesAvailable().unsubscribe(this._updateResetScalesAvailableValue),this._recalcPaneCollapsingAvailable(!0)),this._updateResetScalesAvailableValue();this.crossHairSource().pane===e&&this.clearCurrentPosition(),this._panesCollectionChanged.fire(this._panes),this.invalidate(Y.InvalidationMask.panesOrder())}changePanesHeight(e,t){if(this._panes.length<2)return;(0,n.assert)(e>=0&&ee+t.stretchFactor()),0),r=this._panes.reduce(((e,t)=>e+t.height()),0),o=r-30*(this._panes.length-1);t=Math.min(o,Math.max(30,t));const a=s/r,l=i.height();i.setStretchFactor(t*a);let c=t-l,h=this._panes.length-1;for(const e of this._panes)if(e!==i){const t=Math.min(o,Math.max(30,e.height()-c/h));c-=e.height()-t,h-=1;const i=t*a;e.setStretchFactor(i)}this.fullUpdate()}clearCurrentPosition(){const e=this.crossHairSource();e.clearPosition(),(0,n.ensureNotNull)(e.dataWindowView()).update(),as(this._panes),this.invalidate(Y.InvalidationMask.cursor());const t=this._undoModel.chartWidget();t.chartWidgetCollection().syncCrosshair(null,t.id()),this._phantomSourceContainer.onCursorPositionUpdated()} -setAndSaveCurrentPosition(e,t,i,s){this.crossHairSource().saveOriginCoords(e,t),this.setCurrentPosition(e,t,i,s)}setCurrentPosition(e,t,i,s){var r,o,a,l,c,h;let d=NaN;const u=this._timeScale.coordinateToVisibleIndex(e),p=null!==(a=null===(o=null!==(r=this._lineBeingEdited)&&void 0!==r?r:this._lineBeingCreated)||void 0===o?void 0:o.priceScale())&&void 0!==a?a:i.defaultPriceScale();let _=null;!p.isEmpty()&&Number.isFinite(t)&&(_=(0,n.ensureNotNull)(i.mainDataSource()).firstValue(),null!==_&&(d=p.coordinateToPrice(t,_)));const m=this._crossHairSelectPointMode.value()!==Se.SelectPointMode.None,g=this.currentTool(),f=this.mainSeries(),v=this.crossHairSource(),S=v.index,y=v.price,b=m||Se.isStudyEditingNow.value(),w=p===this.m_mainSeries.priceScale()&&(this._lineBeingCreated||this._lineBeingEdited||(0,he.isLineToolName)(g)||(0,Se.toolIsMeasure)(g)||b);!this._isSettingsExternalPosition&&w?(d=this._magnet.align(d,u,i),null!==_&&this._setCorrectedPositionToCrosshair(u,d,i)):this._magnet.resetLastValue();let P=null;if(isNaN(d)||(P=i),this._isTimeScrolling){if(!this._isSettingsExternalPosition&&m){const e=f.bars().firstIndex(),t=f.bars().lastIndex();if(null!==e&&null!==t){const s=Math.min(Math.max(u,e),t);s!==u&&this._setCorrectedPositionToCrosshair(s,d,i)}}else v.setPosition(v.index,d,P);return}v.setOnHoveredChartWidget(!0),v.setPosition(u,d,P),(0,n.ensureNotNull)(v.dataWindowView()).update(),as(this._panes);const C=f.syncModel();if(this.crossHairSource().startMeasurePoint()||this._lineBeingCreated?this.lightUpdate():this.invalidate(Y.InvalidationMask.cursor()),this._lineBeingCreated){const e=this._lineBeingCreated.linkKey().value();if(!this._isSettingsExternalPosition){const t=this._lineBeingCreated.setLastPoint({index:u,price:d},s);if(this._lineBeingCreated.updateAllViews((0,W.sourceChangeEvent)(this._lineBeingCreated.id())),t.price===d&&t.index===u||this._setCorrectedPositionToCrosshair(t.index,t.price,i),C&&e){const i=this._timeScale.points().roughTime(t.index,C.projectTime.bind(C));(0,Se.setLineToolLastPoint)({model:this,linkKey:e,point:{timeStamp:(0,n.ensureNotNull)(i),price:t.price}})}}}if(!this._isSettingsExternalPosition&&null!==this._lineBeingEdited&&null!==this._linePointBeingEdited){const e={index:u,price:d};if(null===(l=this._linePointBeingChanged)||void 0===l?void 0:l.nonDiscreteIndex){const t=this.crossHairSource().originX();Number.isFinite(t)&&(e.index=this._timeScale.coordinateToFloatIndex(t))}this.changeLinePoint(e,s);const t=this._lineBeingEdited.alignCrossHairToAnchor(this._linePointBeingEdited)?this._lineBeingEdited.getPoint(this._linePointBeingEdited):e;null!==t&&this._setCorrectedPositionToCrosshair(t.index,t.price,i)}if(!this._isSettingsExternalPosition&&1===this._sourcesBeingMoved.length){const e=this._sourcesBeingMoved[0];if(null===(c=e.alignCrossHairToMovePoint)||void 0===c?void 0:c.call(e)){const t=null===(h=e.currentMovingPoint)||void 0===h?void 0:h.call(e);t&&t.logical&&this._setCorrectedPositionToCrosshair(t.logical.index,t.logical.price,i)}}if(!this._isSettingsExternalPosition&&b){ -const e=f.bars().firstIndex(),t=f.bars().lastIndex();if(null!==e&&null!==t){const s=Math.min(Math.max(u,e),t);s!==u&&this._setCorrectedPositionToCrosshair(s,d,i)}}(S!==u||y!==d)&&this._syncCrosshair(s)}setExternalPosition(e,t){let i;const s=this.crossHairSource();if(s.setOnHoveredChartWidget(!1),null!==e&&(0,ie.isNumber)(e.timeStamp)){const t=this.mainSeries().syncModel();if(t){const s=this.createSyncPoint(e.syncSourceTarget,t.syncSourceTarget()).sourceTimeToTargetTime(e.timeStamp);i=this._timeScale.points().roughIndex(s,t.distance.bind(t))}}if(null!==e&&null!=i&&Number.isFinite(i)){this._isSettingsExternalPosition=!0;const r=(0,n.ensureNotNull)(this.paneForSource(this.mainSeries())),o=this._timeScale.indexToCoordinate(i),a=(0,n.ensureNotNull)(r.mainDataSource()).firstValue();if(null!==a){let i=NaN;void 0!==e.price&&Number.isFinite(e.price)&&(i=this.mainSeries().priceScale().priceToCoordinate(e.price,a)),s.clearOriginCoords(),this.setCurrentPosition(o,i,r,t)}return s.setOnHoveredChartWidget(!1),void(this._isSettingsExternalPosition=!1)}s.clearPosition(),(0,n.ensureNotNull)(s.dataWindowView()).update(),as(this._panes),this.invalidate(Y.InvalidationMask.cursor())}startScaleTime(e){this._timeScale.startScale(e)}scaleTimeTo(e){this._timeScale.scaleTo(e),this.recalculateAllPanes((0,W.viewportChangeEvent)()),this.lightUpdate()}endScaleTime(){this._timeScale.endScale(),this.lightUpdate(),this.recalcVisibleRangeStudies()}resetTimeScale(){this._timeScale.restoreDefault(),this.recalculateAllPanes((0,W.viewportChangeEvent)()),this.recalcVisibleRangeStudies(),this.lightUpdate(),this._resetScales.fire()}startScalePrice(e,t,i){e.startScalePrice(t,i)}scalePriceTo(e,t,i){e.scalePriceTo(t,i),this.mainSeries().priceScale().isLockScale()?this.lightUpdate():this.invalidate(this._paneInvalidationMask(e,Y.InvalidationLevel.Light))}endScalePrice(e,t){e.endScalePrice(t),this.invalidate(this._paneInvalidationMask(e,Y.InvalidationLevel.Light))}startTwoPointsScalePrice(e,t,i,s){t.startTwoPointsScale(i,s)}twoPointsScalePriceTo(e,t,i,s){t.twoPointsScale(i,s),this.invalidate(this._paneInvalidationMask(e))}endTwoPointsScalePrice(e,t){t.endTwoPointsScale(),this.invalidate(this._paneInvalidationMask(e))}resetPriceScale(e,t){e.resetPriceScale(t),this.invalidate(this._paneInvalidationMask(e,Y.InvalidationLevel.Light))}restorePriceScaleState(e,t,i){e.restorePriceScaleState(t,i),this.invalidate(this._paneInvalidationMask(e,Y.InvalidationLevel.Light))}currentTool(){return this._currentTool}setCurrentTool(e){this._currentTool!==e&&((0,he.isLineToolName)(e)&&this.selectionMacro((e=>{e.clearSelection()})),this._currentTool=e,this._phantomSourceContainer.onToolChanged())}detachSource(e){const t=this.paneForSource(e);return!!t&&(t.removeDataSource(e),t.isEmpty()?(this._lineBeingCreated&&t===this._paneBeingCreatedLineOn&&this.cancelCreatingLine(),this.removePane(t),!0):(this.fullUpdate(),!1))}children(e,t){return this.dataSources().filter((i=>(0,j.isStudy)(i)?!t&&i.parentSources().includes(e):i.ownerSource()===e))}onRearrangePanes(){ -return this._onRearrangePanes}finishLineTool(e){const t=e.linkKey().value();(0,Se.drawOnAllCharts)().value()&&null!==t&&e.isSynchronizable()&&(0,Se.finishLineTool)({linkKey:t,model:this})}startChangingLinetool(e,t,i,s,r){this._lineBeingEdited=e,this._linePointBeingChanged=t||null,this._linePointBeingEdited=void 0===i?null:i,this._lineBeingEdited.startChanging(i,t,r),Se.isToolEditingNow.setValue(!0);const o=(0,n.ensureNotNull)(this.paneForSource(e));this._lineBeingEdited.startDragPoint&&void 0!==i&&void 0!==t&&this._lineBeingEdited.startDragPoint(i,t),r||void 0===i||void 0===t||this._lineBeingEdited.setPoint(i,t,s,r),this._lineBeingEdited.updateAllViews((0,W.sourceChangeEvent)(this._lineBeingEdited.id()));const a=this._paneInvalidationMask(o,Y.InvalidationLevel.Light);this.invalidate(a);const l=e.linkKey().value();if(l&&e.isSynchronizable()&&void 0!==i&&void 0!==t){const e=(0,n.ensureNotNull)(this.externalTimeStamp(t.index));(0,Se.startChangingLineTool)({linkKey:l,model:this,symbol:this.mainSeries().symbol(),point:{price:t.price,timeStamp:e},pointIndex:i,envState:s||null})}}createLineTool(e,t,i,s,r,a,l,c){if((0,n.assert)((0,he.isLineToolName)(i),`Cannot create unknown line tool: ${i}`),s){const e={...Zi.intervalsVisibilitiesDefaults},t=s.childs().intervalsVisibilities.state();(0,ie.merge)(e,null!=t?t:{});const r=s.state();r.intervalsVisibilities=e,s=(0,S.createLineToolProperties)(i,r,this)}const h=(0,S.createLineTool)(i,this,s,null,void 0,c);if("LineToolExecution"!==i){let e;switch(i){case"LineToolIcon":e=h.properties().childs().icon.value().toString(16).toUpperCase();break;case"LineToolEmoji":e=h.properties().childs().emoji.value();break;case"LineToolSticker":e=h.properties().childs().sticker.value()}(0,u.trackEvent)("drawings","Study_Drawing_"+i,e)}(0,S.isStudyLineTool)(h)&&(0,u.trackEvent)("studies",`Study_${h.metaInfo().id}`);const d=!h.linkKey().value()&&!r;l=(0,n.ensureDefined)(l||(0,n.ensureNotNull)(e.mainDataSource())),s||(0,S.prepareLineToolPropertiesByOwnerSource)(h.properties(),l),h.setOwnerSource(l);const p=l.priceScale();if(h.setPriceScale(p),e.addDataSource(h,p,!1),null!==h.preferredZOrder()&&e.insertAfter([h],this.mainSeries()),(0,Se.drawOnAllCharts)().value()){const e=h.isSynchronizable()?r||(0,J.randomHash)():null;h.linkKey().setValue(e)}else h.linkKey().setValue(r);let _;if(h.isFixed()){const i=(0,n.ensureNotNull)((0,n.ensureNotNull)(e.mainDataSource()).firstValue()),s=this._timeScale.indexToCoordinate(t.index),r=(0,n.ensureNotNull)(p).priceToCoordinate(t.price,i);_=h.addFixedPoint(new o.Point(s,r))}else _=h.addPoint(t);return _||(this._lineBeingCreated=h,this._paneBeingCreatedLineOn=e,Se.isToolCreatingNow.setValue(!0)),d&&h.enableCurrentIntervalVisibility(),this.fullUpdate(),h}endChangingLinetool(e,t){const i=(0,n.ensureNotNull)(this._lineBeingEdited),s=i.endChanging(!1,e,t);this._lineBeingEdited=null,Se.isToolEditingNow.setValue(!1),this._linePointBeingEdited=null,this._linePointBeingChanged=null,this.lightUpdate();const r={points:i.normalizedPoints(),interval:this.mainSeries().interval() -},o=i.linkKey().value();null!==o&&i.isSynchronizable()&&!t&&(0,Se.finishChangingLineTool)({model:this,linkKey:o,symbol:this.mainSeries().symbol(),finalState:r,changes:s})}continueCreatingLine(e,t,i,s){const r=(0,n.ensureNotNull)(this._lineBeingCreated),o=r.addPoint(e,t,i);r.updateAllViews((0,W.sourceChangeEvent)(r.id()));const a=new Y.InvalidationMask(Y.InvalidationLevel.Light);return o&&(this._paneBeingCreatedLineOn=null,this._lineBeingCreated=null,Se.isToolCreatingNow.setValue(!1)),this.invalidate(a),o}cancelCreatingLine(){if(!this._lineBeingCreated)return;const e=this._lineBeingCreated;this.removeSource(this._lineBeingCreated),this._lineBeingCreated=null,this._lineCancelled.fire(),Se.isToolCreatingNow.setValue(!1),(0,Se.drawOnAllCharts)().value()&&e.isSynchronizable()&&(0,Se.cancelLineTool)({model:this})}lineBeingCreated(){return this._lineBeingCreated}paneBeingCreatedLineOn(){return this._paneBeingCreatedLineOn}lineCancelled(){return this._lineCancelled}isPhantomLine(e){return this._phantomSourceContainer.source()===e}changeLinePoint(e,t,i){const s=(0,n.ensureNotNull)(this._lineBeingEdited),r=(0,n.ensureNotNull)(this._linePointBeingEdited);let o=e.price,a=e.index;if(s.setPoint(r,e,t,i),!i){const t=s.alignCrossHairToAnchor(r)?s.getPoint(r):e;null!==t&&(a=t.index,o=t.price)}s.updateAllViews((0,W.sourceChangeEvent)(s.id())),this.lightUpdate();const l=s.linkKey().value();if(!i&&null!==l&&s.isSynchronizable()){const e=(0,n.ensureNotNull)(this._linePointBeingChanged),i={indexesChanged:a!==e.index,pricesChanged:o!==e.price},c=s.getChangePointForSync(r);if(null!==c){const e=this.externalTimeStamp(a);null!==e&&(o=c.price,(0,Se.changeLineTool)({linkKey:l,model:this,symbol:this.mainSeries().symbol(),point:{price:o,timeStamp:e},envState:t,changes:i}))}}}changeLinePoints(e,t,i){const s=e.points(),r=e.linkKey().value();!i&&r&&e.isSynchronizable()&&t.forEach(((t,i)=>{const o=s[i],a=o.price!==t.price,l=o.index!==t.index;if(e.getChangePointForSync(i)){const e=(0,n.ensureNotNull)(this.externalTimeStamp(t.index));(0,Se.changeLineTool)({linkKey:r,model:this,symbol:this.mainSeries().symbol(),point:{price:t.price,timeStamp:e},changes:{pricesChanged:a,indexesChanged:l}})}})),e.setPoints(t),e.updateAllViews((0,W.sourceChangeEvent)(e.id())),this.lightUpdate()}startScrollTime(e){this._timeScale.startScroll(e),this._isTimeScrolling=!0,this.mainSeries().clearGotoDateResult()}scrollTimeTo(e){this._timeScale.scrollTo(e),this.recalculateAllPanes((0,W.viewportChangeEvent)()),this.lightUpdate()}endScrollTime(){this._timeScale.endScroll(),this.lightUpdate(),this.recalcVisibleRangeStudies(),this._isTimeScrolling=!1}startScrollPrice(e,t,i){e.startScrollPrice(t,i)}scrollPriceTo(e,t,i){e.scrollPriceTo(t,i),this.invalidate(this._paneInvalidationMask(e,Y.InvalidationLevel.Light))}endScrollPrice(e,t){e.endScrollPrice(t),this.invalidate(this._paneInvalidationMask(e,Y.InvalidationLevel.Light))}addCustomSource(e,t,i=g.CustomSourceLayer.Foreground){this._customSourcesMap.has(e)&&ns.logWarn(`Attempt to add the same custom source multiple time "${e}"`), -ns.logNormal(`Adding custom source "${e}"`);const s=t(e,this);switch(i){case g.CustomSourceLayer.Background:this._bgCustomSources.push(s);break;case g.CustomSourceLayer.Foreground:this._fgCustomSources.push(s);break;case g.CustomSourceLayer.Topmost:this._topmostCustomSources.push(s);break;default:throw new Error(`Unknown custom sources layer ${i}`)}this._allCustomSources.push(s),this._customSourcesMap.set(e,s),this.lightUpdate()}removeCustomSource(e){this._removeCustomSource(e),this.lightUpdate()}hasCustomSource(e){return this._customSourcesMap.has(e)}customSourceForName(e){return this._customSourcesMap.get(e)||null}customSourceName(e){let t=null;return this._customSourcesMap.forEach(((i,s)=>{i===e&&(t=s)})),t}customSources(e){switch(e){case g.CustomSourceLayer.Background:return this._bgCustomSources;case g.CustomSourceLayer.Foreground:return this._fgCustomSources;case g.CustomSourceLayer.Topmost:return this._topmostCustomSources;default:return this._allCustomSources}}addMultiPaneSource(e){this._multiPaneSources.push(e),this.lightUpdate()}removeMultiPaneSource(e){const t=this._multiPaneSources.indexOf(e);-1===t?ns.logWarn("Attempt to remove multi-pane source which does not exist in the model"):this._multiPaneSources.splice(t,1),this.lightUpdate()}multiPaneSources(e){return this._multiPaneSources.filter((t=>!e.hasDataSource(t)))}magnet(){return this._magnet}dateTimeFormatter(){return this._dateTimeFormatter}dateFormatter(){return this._dateFormatter}timeFormatter(){return this._timeFormatter}isUnmergeAvailableForSource(e){if(!this._unmergeAvailable(e))return!1;return(0,n.ensureNotNull)(this.paneForSource(e)).dataSources().filter(this._unmergeAvailable,this).length>1}isMergeDownAvailableForSource(e){if(!this._unmergeAvailable(e))return!1;const t=this.paneForSource(e),i=this.panes();return t!==i[i.length-1]}isMergeUpAvailableForSource(e){if(!this._unmergeAvailable(e))return!1;return this.paneForSource(e)!==this.panes()[0]}sessions(){return(0,n.ensureNotNull)(this._sessions)}createSessions(e){(0,n.assert)(null===this._sessions,"Sessions are already created"),this.addCustomSource("sessions",((t,i)=>(this._sessions=new U(t,i,e),this._sessions.start(),this._sessions)),g.CustomSourceLayer.Background)}createPrePostMarket(e){this.addCustomSource("prePostMarket",((t,i)=>new PrePostMarket(t,i,e)))}watermarkContentProvider(){return is.WatermarkApi.getInstance().provider()}replayStatus(){return this._replayStatus}setReplayStatus(e){this._replayStatus.setValue(e)}isInReplay(){return this.m_mainSeries.isInReplay()}theme(){const e=this.properties().childs().paneProperties.state(["horzGridProperties.style","vertGridProperties.style"]);delete e.topMargin,delete e.bottomMargin;const t=this.mainSeries().state().state;t&&(delete t.symbol,delete t.interval,delete t.currencyId,delete t.unitId);const i={mainSourceProperties:t,sessions:this.sessions().properties().state(),chartProperties:{paneProperties:e,scalesProperties:this.properties().childs().scalesProperties.state()},version:this.version()};return i.version=this.version(),i} -onChartThemeLoaded(){return this._chartThemeLoaded}chartThemeLoaded(){this._chartThemeLoaded.fire()}state(e,t,i,s){var r;const n=this.publishedChartsTimelineSource(),o=this.properties().childs(),a=o.tradingProperties.state(),l={panes:this._panes.map((r=>r.state(!0,e,!1,t,i,s))),timeScale:this._timeScale.state(e),chartProperties:{paneProperties:o.paneProperties.state(["horzGridProperties.style","vertGridProperties.style"]),scalesProperties:o.scalesProperties.state(),publishedChartsTimelineProperties:n?n.state(e):void 0,chartEventsSourceProperties:null===(r=o.chartEventsSourceProperties)||void 0===r?void 0:r.state(),tradingProperties:a,priceScaleSelectionStrategyName:o.priceScaleSelectionStrategyName.value()},sessions:this.sessions().state(e),version:this.version(),timezone:this.timezone(),shouldBeSavedEvenIfHidden:this._shouldBeSavedEvenIfHidden,linkingGroup:this._linkingGroupIndex.value()};return s||(l.lineToolsGroups=this.lineToolsGroupModel().state(t)),l}restoreState(e,t,i){var s;Ve.instance(this).reset();const r={};if(!e.panes)return void ns.logDebug("ChartModel.restoreState: invalid state");if(!Array.isArray(e.panes))return void ns.logDebug("ChartModel.restoreState: invalid state");if(e.panes.length<1)return void ns.logDebug("ChartModel.restoreState: invalid state");for(const e of this._barsMarksSources)this.detachSource(e);if(this._shouldBeSavedEvenIfHidden=void 0===e.shouldBeSavedEvenIfHidden||e.shouldBeSavedEvenIfHidden,e.chartProperties&&!e.chartProperties.timezone&&(e.chartProperties.timezone=e.timezone),e.chartProperties){const i=(0,B.factoryDefaults)("chartproperties").scalesProperties;(0,ie.merge)(i,e.chartProperties.scalesProperties),!("showLastValue"in i)||"showSeriesLastValue"in i||"showStudyLastValue"in i||(i.showSeriesLastValueProperty=i.showLastValue,i.showStudyLastValueProperty=i.showLastValue),"showSeriesLastValue"in i&&(r.showSeriesLastValueProperty=!0),"showStudyLastValue"in i&&(r.showStudyLastValueProperty=!0),(!this.isSnapshot()&&!this.readOnly()&&"showCurrency"in i||"showUnit"in i)&&((0,K.migrateShowCurrencyAndShowUnitProperties)(i.showCurrency,i.showUnit),delete i.showCurrency,delete i.showUnit);{const{paneProperties:t}=e.chartProperties;t.vertGridProperties=t.vertGridProperties||(0,ie.clone)(t.gridProperties),t.horzGridProperties=t.horzGridProperties||(0,ie.clone)(t.gridProperties),"backgroundType"in t||(t.backgroundType=kt.ColorType.Solid),"separatorColor"in t||(t.separatorColor=(0,d.getThemedColor)("color-chart-page-bg")),this._properties.childs().paneProperties.mergeAndFire(t)}this._properties.childs().scalesProperties.mergeAndFire(i),e.chartProperties.timezone&&this._properties.childs().timezone.setValue(e.chartProperties.timezone),e.chartProperties.chartEventsSourceProperties&&this._properties.hasChild("chartEventsSourceProperties")&&this._properties.childs().chartEventsSourceProperties.mergeAndFire(e.chartProperties.chartEventsSourceProperties), -e.chartProperties.tradingProperties&&this._properties.hasChild("tradingProperties")&&(void 0===e.chartProperties.tradingProperties.horizontalAlignment&&(e.chartProperties.tradingProperties.horizontalAlignment=(n=e.chartProperties.tradingProperties.lineLength)<=40?g.TradedGroupHorizontalAlignment.Right:n>=60?g.TradedGroupHorizontalAlignment.Left:g.TradedGroupHorizontalAlignment.Center),this._properties.childs().tradingProperties.mergeAndFire(e.chartProperties.tradingProperties)),this._timeScale.restoreState(e.timeScale,t),this._updateDateTimeFormatter()}var n;if(e.timeScale&&this._timeScale.restoreState(e.timeScale,t),!this.readOnly()){const t=this._getExceedingChildStudies(e.panes);if(t.length){for(let i=e.panes.length-1;i>=0;--i){const s=e.panes[i];for(let e=s.sources.length-1;e>=0;--e){const i=s.sources[e];~t.indexOf(i)&&s.sources.splice(e,1)}s.sources.length||e.panes.splice(i,1)}0}}const o=e.version||0,a=e.panes;let l="_seriesId";for(const e of a){const t=e.sources.find((e=>"MainSeries"===e.type));if(t){l=t.id;break}}this.panes()[0].restoreState(a[0],t,o,l,r,i,!0);let c=1;for(let s=1;s_&&u%100==0?{lines_limit_exceeded:!0,line_tools_count:u}:(this.panes().forEach((e=>this._dataSourceCollectionChanged.fire(e))),this._lineToolsGroupModel.fireChangedAll(),this._linkingGroupIndex.setValue(null!==(s=e.linkingGroup)&&void 0!==s?s:null),{})}shouldBeSavedEvenIfHidden(){return this._shouldBeSavedEvenIfHidden}setShouldBeSavedEvenIfHidden(e){this._shouldBeSavedEvenIfHidden=e}externalTimeStamp(e){const t=this.mainSeries().syncModel();return this.timeScale().points().roughTime(e,t&&t.projectTime.bind(t))}syncLollipopSources(){null!==this._lollipopSourcesWatcher&&this._lollipopSourcesWatcher.syncSources()}restoreChartEvents(e){null!==this._lollipopSourcesWatcher&&this._options.chartEventsEnabled&&this._lollipopSourcesWatcher.restoreChartEvents(e)}recalcVisibleRangeStudies(e){this._recalcVRStudiesParams.force=this._recalcVRStudiesParams.force||Boolean(e),this._recalcVisibleRangeStudiesImplDebounced()}recalcColorStudies(e){ -this._recalcColorStudiesParams.force=this._recalcColorStudiesParams.force||Boolean(e),this._recalcColorStudiesImplDebounced()}recalcStudyBasedLineTools(){this.dataSources().forEach((e=>{(0,S.isStudyLineTool)(e)&&e.recalcStudyIfNeeded()}))}alertsWatcher(){return this._alertsWatcher}showLegend(){return this._showLegendProperty}id(){return this._id}selectPointMode(){return this._crossHairSelectPointMode}cancelRequestSelectPoint(){this.m_crossHairSource.cancelRequestSelectPoint()}requestSelectPoint(e){return this.m_crossHairSource.requestSelectPoint(e)}onPointSelected(){return this.m_crossHairSource.onPointSelected()}recalculatePriceRangeOnce(){const e=this.mainSeries();for(const t of this._panes)for(const i of t.priceDataSources())i.symbolSource()===e&&i.disablePriceRangeReady()}invalidate(e){var t;null===(t=this._invalidateHandler)||void 0===t||t.call(this,e)}appliedTimeFrame(){return this._appliedTimeFrame.appliedTimeFrame()}barsMarksSources(){return this._barsMarksSources}createSyncPoint(e,t){return(0,Yi.getDefault2Lazy)(this._syncPointCache,e.uniqueId,t.uniqueId,(()=>new Mt(e,t)))}isAutoSaveEnabled(){return this._isAutoSaveEnabled}linkingGroupIndex(){return this._linkingGroupIndex}studyAwareDefaultRightOffset(){return this._timeScale.usePercentageRightOffset().value()?this._timeScale.percentsToBarIndexLength(this.studyAwareDefaultRightOffsetPercentage()):Math.max(this._timeScale.defaultRightOffset().value(),this._cachedStudiesMaxOffset)}studyAwareDefaultRightOffsetPercentage(){return this._timeScale.usePercentageRightOffset().value()?Math.max(this._timeScale.defaultRightOffsetPercentage().value(),this._timeScale.barIndexLengthToPercents(this._cachedStudiesMaxOffset)):this._timeScale.barIndexLengthToPercents(this.studyAwareDefaultRightOffset())}clearAllStudies(){this.dataSources().forEach((e=>{var t;return null===(t=e.clearData)||void 0===t?void 0:t.call(e)}))}setTimeScaleAnimation(e){const t=Y.InvalidationMask.light();t.setTimeScaleAnimation(e),this.invalidate(t)}stopTimeScaleAnimation(){const e=Y.InvalidationMask.light();e.stopTimeScaleAnimation(),this.invalidate(e)}lollipopSourcesOptions(){const e=this._options;return{chartEventsEnabled:!this._options.isSnapshot&&this._options.chartEventsEnabled,esdEnabled:e.esdEnabled,continuousContractSwitchesEnabled:e.continuousContractSwitchesEnabled,futuresContractExpirationEnabled:e.futuresContractExpirationEnabled,latestUpdatesEnabled:e.latestUpdatesEnabled}}_initAlertsList(){throw new Error("Not implemented")}_updateStudiesMaxOffset(){const e=Math.max(...this.allStudies().map((e=>e.maxOffset().value())));this._cachedStudiesMaxOffset=e;const t=this._timeScale.rightOffset();t<0||this._timeScale.setRightOffset(Math.max(t,e))}_updateBaseIndex(e,t){const i=this._timeScale,s=i.baseIndex(),r=i.logicalRange();if(null!==r&&t){const t=r.contains(s),n=e-s,o=t?null:i.rightOffset()-n;if(!this._options.shiftVisibleRangeOnNewBar&&t){const e=i.width()/i.barSpacing(),t=e/(e+n),s=Math.max(i.minBarSpacing(),i.barSpacing()*t);i.setBarSpacing(s)}null!==o&&i.setRightOffset(o)}i.setBaseIndex(e)} -_createLollipopSourcesWatcher(){}_updateDateTimeFormatter(){const e=St.dateFormatProperty.value(),t=void 0;if(this._dateFormatter=new vt.DateFormatter(e,t),this.mainSeries().isDWM())this._dateTimeFormatter=new vt.DateFormatter(e,t),this._timeFormatter=new lt.TimeFormatter((0,ct.getHourMinuteFormat)(at.timeHoursFormatProperty.value()));else{const i=x.Interval.parse(this.mainSeries().interval()),s=(0,ct.getTimeFormatForInterval)(i,at.timeHoursFormatProperty.value());this._dateTimeFormatter=new ft.DateTimeFormatter({dateFormat:e,withWeekday:t,timeFormat:s,dateTimeSeparator:" "}),this._timeFormatter=new lt.TimeFormatter(s)}}_invalidationMaskForSource(e,t=Y.InvalidationLevel.Light){if(e===this.crossHairSource())return Y.InvalidationMask.cursor();if(this._watermarkSource===e)return this._paneInvalidationMask((0,n.ensureNotNull)(this.paneForSource(this.mainSeries())),t);if(-1!==this._allCustomSources.indexOf(e)){const e=new Y.InvalidationMask;return e.invalidateAll(t),e}if(!(0,f.isDataSource)(e))return null;if(e.isMultiPaneEnabled())return new Y.InvalidationMask(t);const i=this.paneForSource(e);return null!==i?this._paneInvalidationMask(i,t):null}_paneInvalidationMask(e,t=Y.InvalidationLevel.Light){const i=new Y.InvalidationMask,s=this._panes.indexOf(e);return i.invalidateAllPane(s,t),i}_invalidationMaskForSourcePriceScale(e,t=Y.InvalidationLevel.Light){if(!(0,f.isDataSource)(e))return new Y.InvalidationMask(t);const i=this.paneForSource(e);if(null===i)return null;let s=e.priceScale();if(null===s)return null;const r=this._panes.indexOf(i);let n=i.priceScalePosition(s);if("overlay"===n){const e=this._panes[r].defaultPriceScale();s=e,n=i.priceScalePosition(e)}const o=i.priceScaleIndex(s,n);if(void 0===o)return null;const a=new Y.InvalidationMask;return a.invalidatePriceScale(r,n,o,t),a}_removeCustomSource(e){const t=this._customSourcesMap.get(e);if(void 0===t)return void ns.logWarn(`Attempt to remove custom source which does not exist in the model - "${e}"`);ns.logNormal(`Removing custom source "${e}"`),this.selectionMacro((e=>{e.removeSourceFromSelection(t)})),this._hoveredSource===t&&this.setHoveredSource(null),this._customSourceBeingMoved===t&&this.setMovingCustomSource(null,null);const i=os(this._bgCustomSources,t),s=os(this._fgCustomSources,t),r=os(this._topmostCustomSources,t),o=os(this._allCustomSources,t);(0,n.assert)(i||s||r,"Source should be presented in one of the layers"),(0,n.assert)(o,"Source should be presented in the array"),this._customSourcesMap.delete(e),t.destroy()}_updateShowLegendProperty(){const e=this._properties.childs().paneProperties.childs().legendProperties.childs().showLegend,t=this._showLegendProperty;if(e.value())t.setValue(!0);else{for(const e of this._panes){let i=0;for(const s of e.priceDataSources())if(s!==this.mainSeries()&&null!==s.statusView()&&(i++,i>=2))return void t.setValue(!1)}t.setValue(!0)}}_pointToPercentPosition(e,t){return{x:e.x/this._timeScale.width(),y:e.y/(0,n.ensureNotNull)((0,n.ensureNotNull)(t.mainDataSource()).priceScale()).height()}}_percentPositionToPoint(e,t){ -const i=e.x*this._timeScale.width(),s=e.y*(0,n.ensureNotNull)((0,n.ensureNotNull)(t.mainDataSource()).priceScale()).height();return new o.Point(i,s)}_recalcVisibleRangeStudiesImpl(e){var t,i,s;if(e.timerId=null,this.timeScale().isEmpty())return;const r=this.timeScale().visibleBarsStrictRange();if(null===r)return;const n=this.mainSeries().bars(),o=n.search(r.firstBar(),dt.PlotRowSearchMode.NearestRight),a=n.search(r.lastBar(),dt.PlotRowSearchMode.NearestLeft),l=n.lastIndex(),c=o?o.index:void 0,h=a?a.index:void 0,d=c===e.oldStartVisibleIndex,u=h===e.oldEndVisibleIndex;if(d&&u&&!e.force)return;e.force=!1,e.oldStartVisibleIndex=void 0!==c?c:NaN,e.oldEndVisibleIndex=void 0!==h?h:NaN;const p={first_visible_bar_time:1e3*(null!==(t=null==o?void 0:o.value[0])&&void 0!==t?t:0),last_visible_bar_time:1e3*(null!==(i=null==a?void 0:a.value[0])&&void 0!==i?i:0),subscribeRealtime:(null==a?void 0:a.index)===l},_=null!==(s=e.studies)&&void 0!==s?s:this.priceDataSources();e.studies=void 0;for(const e of _)if((0,j.isStudy)(e)){const t=e.metaInfo().inputs,i=[];for(const e of t)p.hasOwnProperty(e.id)&&i.push(e.id);const s=e.properties().childs().inputs;for(const e of i)s.childs()[e].setValueSilently(p[e]);i.length>0&&s.listeners().fire(s)}}_recalcColorStudiesImpl(e){var t;e.timerId=null;const i=this.backgroundColorAtYPercentFromTop(.5),s=this.dark().value()?l.colorsPalette["color-cold-gray-200"]:l.colorsPalette["color-cold-gray-900"],r=i===e.oldBgColor,n=s===e.oldFgColor;if(r&&n&&!e.force)return;e.force=!1,e.oldBgColor=i,e.oldFgColor=s;const o={__chart_bgcolor:i,__chart_fgcolor:s},a=null!==(t=e.studies)&&void 0!==t?t:this.priceDataSources();e.studies=void 0;for(const e of a)if((0,j.isStudy)(e)){const t=e.metaInfo().inputs,i=[];for(const e of t)o.hasOwnProperty(e.id)&&i.push(e.id);const s=e.properties().childs().inputs;for(const e of i)s.childs()[e].setValueSilently(o[e]);i.length>0&&s.listeners().fire(s)}}_getAllSources(e){const t=[];for(const i of this._panes){const s=i.sourcesByGroup().all();for(const i of s)e(i)&&t.push(i)}return t}_invalidateBarColorerCaches(){this.mainSeries().invalidateBarColorerCache()}_addAlertLabelToChart(e){throw new Error("Not implemented")}_removeAlertLabelFromChart(e){throw new Error("Not implemented")}_removeAllAlertLabelsFromChart(){throw new Error("Not implemented")}_updateTimeScale(e){var t,i,s,r;const{index:n,zoffset:o,values:a,indexDiffs:l,baseIndex:c,marks:h,clearFlag:d}=e;if(d){this._timeScale.reset();for(const e of this.dataSources())null===(t=e.clearData)||void 0===t||t.call(e)}if(l.length>0)for(const e of this.dataSources())null===(i=e.moveData)||void 0===i||i.call(e,l);const u=this._timeScale.indexToTimePoint(this._timeScale.baseIndex()),p=this._timeScale.canNormalize();this._timeScale.update(n,o,a,h);const _=this._timeScale.points().range().value();let m="ChartModel.prototype._updateTimeScale("+n+","+o+","+a.length+","+l.length+","+h.length+","+d+")" -;if(m+="TimeScale: {first:"+(null!==(s=null==_?void 0:_.firstIndex)&&void 0!==s?s:null)+",last:"+(null!==(r=null==_?void 0:_.lastIndex)&&void 0!==r?r:null)+"}",null===c){this._timeScale.resetBaseIndex();const e=this._timeScale.rightOffset();e<0?this._timeScale.setRightOffset(this.studyAwareDefaultRightOffset()):this._timeScale.setRightOffset(Math.max(e,this._cachedStudiesMaxOffset))}else if(void 0!==c){const e=this._timeScale.indexToTimePoint(c),t=null!==u&&null!==e&&e>u;this._updateBaseIndex(c,t)}if(ns.logDebug(m),!p&&p!==this._timeScale.canNormalize())for(const e of this.dataSources())!(0,S.isLineTool)(e)||e.isFixed()||e.isSourceHidden()||e.processHibernate();this.recalculateAllPanes((0,W.globalChangeEvent)()),this.lightUpdate()}_getAvailableCurrencies(){return!this.currencyConversionEnabled()||this.isSnapshot()?[]:(0,ie.isArray)(this._availableCurrenciesList)?this._availableCurrenciesList:(null!==this._availableCurrenciesList||(this._availableCurrenciesList=this.chartApi().availableCurrencies(),this._availableCurrenciesList.then((e=>{this._destroyed||(this._availableCurrenciesList=e,this.fullUpdate())})).catch((e=>{ns.logWarn(`An error occurred while getting currencies config: ${e}`)}))),[])}_getAvailableUnits(){return!this.unitConversionEnabled()||this.isSnapshot()?{}:this._availableUnitsObject instanceof Promise||null===this._availableUnitsObject?(null!==this._availableUnitsObject||(this._availableUnitsObject=this.chartApi().availableUnits(),this._availableUnitsObject.then((e=>{this._destroyed||(this._availableUnitsObject=e,this.fullUpdate())})).catch((e=>{ns.logWarn(`An error occurred while getting units config: ${e}`)}))),{}):this._availableUnitsObject}_getAvailablePriceSources(){return Array.isArray(this._availablePriceSourcesList)?this._availablePriceSourcesList:(this._availablePriceSourcesList=this.chartApi().availablePriceSources(this.m_mainSeries.getSymbolString()),this._availablePriceSourcesList.then((e=>{this._destroyed||(this._availablePriceSourcesList=e,this.fullUpdate())})).catch((e=>{ns.logWarn(`An error occurred while getting price sources config: ${e}`)})),[])}_clearAvailablePriceSources(){this._availablePriceSourcesList=null}_getBackgroundColor(e){const t=this._properties.childs().paneProperties.childs();if(t.backgroundType.value()===kt.ColorType.Gradient){const i=t.backgroundGradientStartColor.value(),s=t.backgroundGradientEndColor.value();return e?i:s}return t.background.value()}_getBackgroundCounterColor(){const e=this.backgroundColor().value();return"black"===(0,a.rgbToBlackWhiteString)((0,a.parseRgb)(e),150)?"white":"black"}_updateBackgroundColor(){this._backgroundColor.setValue(this._getBackgroundColor()),this._backgroundTopColor.setValue(this._getBackgroundColor(!0))}_syncCrosshair(e){if(!this._isSettingsExternalPosition){const t=this._undoModel.chartWidget(),i=this._undoModel.mainSeries(),s=i.syncModel(),r=this._undoModel.crossHairSource(),n=r.pane;if(null!==s&&null!==n){const o={timeStamp:this._timeScale.points().roughTime(r.index,s.projectTime.bind(s)), -syncSourceTarget:s.syncSourceTarget()};n.mainDataSource()===i&&(o.price=r.price,o.symbol=i.symbol());let a=this._lineBeingCreated||null!==this._linePointBeingEdited||Boolean(this._sourcesBeingMoved.length);a=a&&(0,Se.drawOnAllCharts)().value(),t.chartWidgetCollection().syncCrosshair(o,t.id(),a,e)}this._phantomSourceContainer.onCursorPositionUpdated()}}_gotoTimeImpl(e,t){const i=this.timeScale(),s=this.mainSeries();let r;if(void 0!==e){if(this._scrollingState&&this._scrollingState.deferred.reject(),r=(0,p.createDeferredPromise)(),!s.isDWM()){const t=s.symbolInfo();if(null!==t){let i=this.properties().childs().timezone.value();"exchange"===i&&(i=t.timezone);const r=(0,Pt.cal_to_utc)((0,Pt.get_timezone)(i),new Date(e)),n=(0,Ht.createTimeToBarTimeAligner)(s.interval(),t)(r);e=(0,Pt.utc_to_cal)((0,Pt.get_timezone)(i),n).getTime()}}this._scrollingState={targetDate:e,deferred:r,centerIfVisible:t.centerIfVisible}}else{if(!this._scrollingState)return ns.logError("scrollTo called without an argument"),Promise.reject();e=this._scrollingState.targetDate,r=this._scrollingState.deferred}if(void 0===i.tickMarks().minIndex)return r.resolve(void 0),r.promise;this.stopTimeScaleAnimation();let o=((e,t)=>{if((e=>(0,n.ensureNotNull)(i.tickMarks().indexToTime((0,n.ensureDefined)(i.tickMarks().minIndex))).valueOf()-e)(t)<0){let r=i.tickMarks().nearestIndex(t);const o=s.bars().lastIndex();if(null===o)return null;r=Math.min(r,o);let a=(0,n.ensureNotNull)(i.tickMarks().indexToTime(r)).valueOf();for(;a1&&s.push(e)),n=(n+1)%t.length}return s}}},16410:(e,t,i)=>{"use strict";i.d(t,{allChartStyles:()=>o,commonChartStyles:()=>n,japaneseChartStyles:()=>r});var s=i(14483);function r(){return s.enabled("japanese_chart_styles"),[8]}function n(){const e=[0,1,9,13,2,14,15,3,16,10];return s.enabled("chart_style_hilo")&&e.push(12),e}function o(){return n().concat(r())}},65795:(e,t,i)=>{"use strict";i.d(t,{ChartUndoModelBase:()=>Zi});var s=i(85459),r=i.n(s),n=i(16230),o=i(50151),a=i(86441),l=i(44352),c=i(61345),h=i(21866),d=i(42856),u=i(17133),p=i(36274);function _(e,t){return!!p.Interval.isEqual(e.res,t.res)&&(0,u.areEqualTimeFrames)(e.val,t.val)}var m=i(93244),g=i(69618),f=i(92249),v=i(88275),S=i(51768),y=i(39262),b=i(14483),w=i(59224),P=i(28853),C=i(36298),x=i(1722);const T=new C.TranslatedString("move all scales to left",l.t(null,void 0,i(81898))),I=new C.TranslatedString("move all scales to right",l.t(null,void 0,i(22863))),M=(0,w.getLogger)("Chart.MergeAllScales");var L=i(62591);class A extends L.UndoCommand{constructor(e,t,i,s,r,n){super(n),this._model=e,this._paneIndex=e.panes().indexOf(t),this._targetPosition=s,this._targetIndex=r,this._scaleId=i.id(),this._sourcePosition=t.priceScalePosition(i),"overlay"!==this._sourcePosition&&(this._sourceIndex=t.priceScaleIndex(i,this._sourcePosition))}redo(){const e=this._model.panes()[this._paneIndex],t=(0,o.ensureNotNull)(e.getPriceScaleById(this._scaleId));e.movePriceScale(t,this._targetPosition,this._targetIndex),this._model.fullUpdate()}undo(){const e=this._model.panes()[this._paneIndex],t=(0,o.ensureNotNull)(e.getPriceScaleById(this._scaleId));e.movePriceScale(t,this._sourcePosition,this._sourceIndex),this._model.fullUpdate()}}class k extends L.UndoCommand{constructor(e,t,i,s){super(s),this._createdIds=[],this._model=e,this._withoutShift=i,this._origStates=t.map((e=>e.state(!0)));const r=e.lineToolsGroupModel();this._origGroups=t.map((e=>{const t=r.groupForLineTool(e);return t&&t.id}))}redo(){const e=this._model.lineToolsGroupModel(),t=this._origStates.map(((t,i)=>{const s=(0,o.ensureNotNull)(this._model.dataSourceForId(t.id)),r=0===this._createdIds.length?void 0:(0,o.ensureDefined)(this._createdIds[i]),n=(0,f.cloneLineTool)(this._model,s,!this._withoutShift,r);void 0!==t.sharingMode&&n.share(t.sharingMode);const a=(0,o.ensureNotNull)(s.priceScale());(0,o.ensureNotNull)(this._model.paneForSource(s)).addDataSource(n,a,!1);const l=this._origGroups[i];if(null!==l){const t=e.groupForId(l);t&&t.addLineTools([n])}return this._model.updateSource(n),n}));0===this._createdIds.length&&(this._createdIds=t.map((e=>e.id()))),this._model.selectionMacro((e=>{e.clearSelection(),t.forEach((t=>{e.addSourceToSelection(t)}))})),this._model.setShouldBeSavedEvenIfHidden(!0)}undo(){ -const e=this._model.lineToolsGroupModel();this._createdIds.forEach((t=>{const i=(0,o.ensureNotNull)(this._model.dataSourceForId(t)),s=e.groupForLineTool(i);null!==s&&s.excludeLineTool(i),this._model.removeSource(i)}))}newIds(){return this._createdIds}}var D=i(47513),V=i(93562);class E extends L.UndoCommand{constructor(e,t,i,s=!0){super(i,s),this._newStates=[],this._model=e,this._savedStates=t.map((e=>e.state(!1)))}redo(){this._applyState(this._newStates)}undo(){0===this._newStates.length&&this.saveNewState(),this._applyState(this._savedStates)}saveNewState(){const e=this._savedStates.filter(x.notNull).map((e=>(0,o.ensureNotNull)(this._model.dataSourceForId(e.id))));this._newStates=e.map((e=>e.state(!1)))}_applyState(e){for(const t of e)if(null!==t){const e=this._model.dataSourceForId(t.id);if(null!==e)if((0,P.isStudy)(e)){const i=t.state.inputs,s=e.properties().childs().inputs.childs();for(const e in i)s[e]&&s[e].setValue(i[e])}else this._model.restoreLineToolState(e,t,!0)}}}var B=i(95529),R=i(11235),N=i(98517),O=i(14292),F=i(74007),W=i(37591);const H=new C.TranslatedString("bring {title} to front",l.t(null,void 0,i(78246))),z=new C.TranslatedString("send {title} to back",l.t(null,void 0,i(66781))),U=new C.TranslatedString("insert {title} after {targetTitle}",l.t(null,void 0,i(53146))),j=new C.TranslatedString("insert {title} before {targetTitle}",l.t(null,void 0,i(67176))),G=new C.TranslatedString("send {title} backward",l.t(null,void 0,i(16259))),q=new C.TranslatedString("bring {title} forward",l.t(null,void 0,i(56763))),$=new C.TranslatedString("send group {title} backward",l.t(null,void 0,i(4998))),Y=new C.TranslatedString("bring group {title} forward",l.t(null,void 0,i(27195)));function K(e){return new C.TranslatedString(e.name(),e.title(W.TitleDisplayTarget.StatusLine))}class Z extends L.UndoCommand{constructor(e,t,i){super(i),this._sourcesByPanes=new Map,this._originalState=new Map,this._model=e,t.forEach((t=>{const i=(0,o.ensureNotNull)(e.paneForSource(t)),s=e.panes().indexOf(i),r=this._sourcesByPanes.get(s)||[];r.push(t.id()),this._sourcesByPanes.set(s,r)})),Array.from(this._sourcesByPanes.keys()).forEach((t=>{const i=e.panes()[t],s=new Map;i.sourcesByGroup().allIncludingHidden().forEach((e=>{s.set(e.id(),e.zorder())})),this._originalState.set(t,s)}))}undo(){this._originalState.forEach(((e,t)=>{const i=this._model.panes()[t],s=new Map;e.forEach(((e,t)=>{const r=(0,o.ensureNotNull)(i.dataSourceForId(t));s.set(r,e)})),i.setZOrders(s)}))}redo(){this._sourcesByPanes.forEach(((e,t)=>{const i=this._model.panes()[t],s=e.map((e=>(0,o.ensureNotNull)(i.dataSourceForId(e))));this._paneOperation(i,s)}))}}class X extends Z{constructor(e,t){super(e,t,H.format({title:K(t[0])}))}_paneOperation(e,t){e.bringToFront(t)}}class J extends Z{constructor(e,t){super(e,t,z.format({title:K(t[0])}))}_paneOperation(e,t){e.sendToBack(t)}}class Q extends Z{constructor(e,t,i,s){super(e,t,s),this._targetSource=i}_paneOperation(e,t){e.insertAfter(t,this._targetSource)}}class ee extends Q{constructor(e,t,i){super(e,t,i,U.format({ -title:K(t[0]),targetTitle:K(i)}))}}class te extends Z{constructor(e,t,i,s){super(e,t,s),this._targetSource=i}_paneOperation(e,t){e.insertBefore(t,this._targetSource)}}class ie extends te{constructor(e,t,i){super(e,t,i,j.format({title:K(t[0]),targetTitle:K(i)}))}}function se(e,t){const i=t[0],s=e.sourcesByGroup().all().filter((e=>e.zorder()e.zorder()>i.zorder()));if(0===s.length)throw new Error("Cannot bring forward source that alreadt on back");let r=s[0];if((0,f.isLineTool)(r)){const t=e.model().lineToolsGroupModel().groupForLineTool(r);if(null!==t){const e=t.lineTools();r=e[e.length-1]}}return r}class oe extends Q{constructor(e,t,i){super(e,i,ne(t,i),q.format({title:K(i[0])}))}}function ae(e,t){return(0,o.ensureNotNull)(e.paneForSource(t.lineTools()[0]))}class le extends te{constructor(e,t){super(e,t.lineTools(),se(ae(e,t),t.lineTools()),$.format({title:t.name()}))}}class ce extends Q{constructor(e,t){super(e,t.lineTools(),ne(ae(e,t),t.lineTools()),Y.format({title:t.name()}))}}const he=new C.TranslatedString("rearrange panes",l.t(null,void 0,i(33348)));class de extends L.UndoCommand{constructor(e,t,i){super(he),this._chartModel=e,this._index=t,(0,x.isNumber)(i)?this._dstIndex=i:this._dstIndex="up"===i?t-1:t+1}redo(){this._checkIndices()&&this._chartModel.movePane(this._index,this._dstIndex)}undo(){this._checkIndices()&&this._chartModel.movePane(this._dstIndex,this._index)}_checkIndices(){const e=this._chartModel.panes().length;return this._index>=0&&this._index=0&&this._dstIndexe.id()))}redo(){const e=(0,o.ensureNotNull)(this._model.lineToolsGroupModel().groupForId(this._groupId));this._model.lineToolsGroupModel().removeGroup(e)}undo(){const e=this._lineToolsIds.map((e=>this._model.dataSourceForId(e))),t=new we.LineToolsGroup(e,this._groupName,this._groupId);this._model.lineToolsGroupModel().addGroup(t)}}const Ce=new C.TranslatedString("create line tools group",l.t(null,void 0,i(3195)));class xe extends L.UndoCommand{constructor(e,t){super(Ce),this._groupId=null,this._model=e,this._sourcesIds=t.map((e=>e.id()))}redo(){const e=this._sourcesIds.map((e=>this._model.dataSourceForId(e))),t=null===this._groupId?void 0:this._groupId;this._groupId=this._model.lineToolsGroupModel().createGroup(e,this._title,t).id}undo(){const e=(0,o.ensureNotNull)(this._model.lineToolsGroupModel().groupForId((0,o.ensureNotNull)(this._groupId)));this._model.lineToolsGroupModel().removeGroup(e)}createdGroupId(){return this._groupId}}const Te=new C.TranslatedString("add line tool(s) to group {group}",l.t(null,void 0,i(40242)));class Ie extends L.UndoCommand{constructor(e,t,i){super(Te.format({group:t.name()})),this._model=e,this._groupId=t.id,this._lineToolsIds=i.map((e=>e.id()))}redo(){const e=(0, -o.ensureNotNull)(this._model.lineToolsGroupModel().groupForId(this._groupId)),t=this._lineToolsIds.map((e=>this._model.dataSourceForId(e)));e.addLineTools(t)}undo(){const e=this._lineToolsIds.map((e=>this._model.dataSourceForId(e)));(0,o.ensureNotNull)(this._model.lineToolsGroupModel().groupForId(this._groupId)).excludeLineTools(e)}}class Me extends L.UndoCommand{constructor(e,t,i,s,r){super(i),this._targetObj=e,this._newValue=t,this._oldValue=this._targetObj.value(),this._model=s,r&&this.setCustomFlag("doesnt_affect_save",!0)}redo(){(0,_e.saveDefaultProperties)(!0),this._targetObj.setValue(this._newValue),(0,_e.saveDefaultProperties)(!1),this._model.recalculateAllPanes((0,ve.globalChangeEvent)()),this._model.lightUpdate()}undo(){(0,_e.saveDefaultProperties)(!0),this._targetObj.setValue(this._oldValue),(0,_e.saveDefaultProperties)(!1),this._model.recalculateAllPanes((0,ve.globalChangeEvent)()),this._model.lightUpdate()}}class Le extends L.UndoCommand{constructor(e,t,i,s){super(s),this._chartModel=e,this._groupId=t.id,this._oldName=t.name(),this._newName=i}redo(){(0,o.ensureNotNull)(this._chartModel.lineToolsGroupModel().groupForId(this._groupId)).setName(this._newName)}undo(){(0,o.ensureNotNull)(this._chartModel.lineToolsGroupModel().groupForId(this._groupId)).setName(this._oldName)}}var Ae=i(88348);const ke=new C.TranslatedString("create line tools group from selection",l.t(null,void 0,i(92659))),De=new C.TranslatedString("removing line tools group {name}",l.t(null,void 0,i(78811))),Ve=new C.TranslatedString("add line tool {lineTool} to group {name}",l.t(null,void 0,i(99113))),Ee=new C.TranslatedString("make group {group} visible",l.t(null,void 0,i(87927))),Be=new C.TranslatedString("make group {group} invisible",l.t(null,void 0,i(45223))),Re=new C.TranslatedString("lock group {group}",l.t(null,void 0,i(4963))),Ne=new C.TranslatedString("unlock group {group}",l.t(null,void 0,i(51114))),Oe=new C.TranslatedString("rename group {group} to {newName}",l.t(null,void 0,i(16338))),Fe=!1;class We{constructor(e){this._environment=e}createGroupFromSelection(){const e=this._environment.model();(0,o.assert)(!e.selection().isEmpty(),"Cannot create group from empty selection");const t=(0,N.sortSources)(e.selection().lineDataSources());(0,o.assert)(t.length===e.selection().allSources().length,"A group could contain line tools only");const i=t.length>1||null!==this._environment.model().lineToolsGroupModel().groupForLineTool(t[0]),s=t.reduce(((e,t)=>e.zorder()>t.zorder()?e:t),t[0]);let r=s;const n=e.lineToolsGroupModel().groupForLineTool(s);if(null!==n){const e=n.lineTools();r=e[e.length-1]}this._environment.beginUndoMacro(ke,Fe);const a=new Map,l=new Set;t.forEach((t=>{const i=this._groupForLineTool(t);if(null===i)return;const s=a.get(i)||[];s.push(t),a.set(i,s);const r=(0,o.ensureNotNull)(e.paneForSource(t));l.add(r)})),(0,o.assert)(l.size<=1,"All selected sources should be on the same pane"),a.forEach(((t,i)=>{const s=new V.ExcludeLineToolsFromGroupUndoCommand(e,i,t);this._environment.pushUndoCommand(s)}));const c=new xe(e,(0, -N.sortSources)(t));if(this._environment.pushUndoCommand(c),i){const i=new ee(e,t,r);this._environment.pushUndoCommand(i)}this._environment.endUndoMacro();const h=(0,o.ensureNotNull)(c.createdGroupId());return(0,o.ensureNotNull)(e.lineToolsGroupModel().groupForId(h))}removeGroup(e){const t=this._environment.model(),i=e.lineTools();this._environment.beginUndoMacro(De.format({name:e.name()}),Fe);const s=new Pe(t,e,null);this._environment.pushUndoCommand(s);const r=new D.RemoveSourcesUndoCommand(t,i,null);this._environment.pushUndoCommand(r);const n=t.mainSeries().symbol();i.forEach((e=>{null!==e.linkKey().value()&&(0,Ae.removeLineTool)({withUndo:!0,model:t,symbol:n,sourceTitle:new C.TranslatedString(e.name(),e.title(W.TitleDisplayTarget.DataWindow)),lineToolState:e.state(!1),linkKey:(0,o.ensureNotNull)(e.linkKey().value())})})),this._environment.endUndoMacro()}groups(){return this._environment.model().lineToolsGroupModel().groups()}excludeLineToolFromGroup(e,t){const i=this._environment.model(),s=new V.ExcludeLineToolsFromGroupUndoCommand(i,e,[t]);s.setCustomFlag("doesnt_affect_save",Fe),this._environment.pushUndoCommand(s)}addLineToolToGroup(e,t){const i=this._environment.model(),s=i.lineToolsGroupModel().groupForLineTool(t);if(s===e)return;const r=Ve.format({lineTool:new C.TranslatedString(t.name(),t.title(W.TitleDisplayTarget.StatusLine)),name:e.name()});this._environment.beginUndoMacro(r,Fe),null!==s&&this._environment.pushUndoCommand(new V.ExcludeLineToolsFromGroupUndoCommand(i,s,[t])),this._environment.pushUndoCommand(new Ie(i,e,[t])),this._environment.endUndoMacro()}bringToFront(e){const t=this._environment.model(),i=new X(t,e.lineTools());i.setCustomFlag("doesnt_affect_save",Fe),this._environment.pushUndoCommand(i),this._environment.emitEvent("changeZOrder",[e.lineTools()])}sendToBack(e){const t=this._environment.model(),i=new J(t,e.lineTools());i.setCustomFlag("doesnt_affect_save",Fe),this._environment.pushUndoCommand(i),this._environment.emitEvent("changeZOrder",[e.lineTools()])}bringForward(e){const t=this._environment.model(),i=new ce(t,e);i.setCustomFlag("doesnt_affect_save",Fe),this._environment.pushUndoCommand(i),this._environment.emitEvent("changeZOrder",[e.lineTools()])}sendBackward(e){const t=this._environment.model(),i=new le(t,e);i.setCustomFlag("doesnt_affect_save",Fe),this._environment.pushUndoCommand(i),this._environment.emitEvent("changeZOrder",[e.lineTools()])}insertAfter(e,t){const i=this._environment.model();let s;if(t instanceof we.LineToolsGroup){const e=t.lineTools();s=e[e.length-1]}else s=t;const r=new ee(i,e.lineTools(),s);this._environment.pushUndoCommand(r),this._environment.emitEvent("changeZOrder",[e.lineTools()])}insertBefore(e,t){const i=this._environment.model();let s;if(t instanceof we.LineToolsGroup){s=t.lineTools()[0]}else s=t;const r=new ie(i,e.lineTools(),s);this._environment.pushUndoCommand(r),this._environment.emitEvent("changeZOrder",[e.lineTools()])}availableZOrderOperations(e){const t=this._environment.model(),i=e.lineTools(),s=i[0],r=i[i.length-1],n=(0, -o.ensureNotNull)(t.paneForSource(i[0])).sourcesByGroup().allExceptSpecialSources(),a=n[0],l=n[n.length-1];return{bringForwardEnabled:r!==l,bringToFrontEnabled:r!==l,sendBackwardEnabled:s!==a,sendToBackEnabled:s!==a}}setGroupVisibility(e,t){const i=(t?Ee:Be).format({group:e.name()}),s=this._environment.model();this._environment.beginUndoMacro(i,Fe),e.lineTools().forEach((e=>{const i=e.properties().visible,r=new Me(i,t,null,s);this._environment.pushUndoCommand(r)})),this._environment.endUndoMacro()}setGroupLock(e,t){const i=(t?Re:Ne).format({group:e.name()}),s=this._environment.model();this._environment.beginUndoMacro(i,Fe),e.lineTools().forEach((e=>{const i=e.properties().frozen,r=new Me(i,t,null,s);this._environment.pushUndoCommand(r)})),this._environment.endUndoMacro()}setGroupName(e,t){const i=this._environment.model(),s=Oe.format({group:e.name(),newName:t}),r=new Le(i,e,t,s);r.setCustomFlag("doesnt_affect_save",Fe),this._environment.pushUndoCommand(r)}canBeGroupped(e){const t=this._environment.model();return new Set(e.map((e=>t.paneForSource(e)))).size<=1}_groupForLineTool(e){return this._environment.model().lineToolsGroupModel().groups().find((t=>t.containsLineTool(e)))||null}}var He=i(58121),ze=i(35115),Ue=i(53588),je=i(63009);const Ge=new C.TranslatedString("apply study template {template}",l.t(null,void 0,i(26065)));function qe(e){for(const t of e.panes)for(const e of t.sources)if((0,Ue.isMainSeriesState)(e))return e.id;return null}class $e extends L.UndoCommand{constructor(e,t,i){var s,r;super(Ge.format({template:i})),this._newSymbolParams={},this._model=e,this._templateContent=function(e,t){const i=(0,He.default)({},e),s=(0,o.ensureNotNull)(qe(i));for(const e of i.panes){e.mainSourceId===s&&(e.mainSourceId=t);for(const i of e.sources)if(i.id===s){i.id=t;const r=e=>{const i=e.indexOf(s);-1!==i&&e.splice(i,1,t)};if(e.leftAxisesState&&e.rightAxisesState?(e.leftAxisesState.forEach((e=>r(e.sources))),e.rightAxisesState.forEach((e=>r(e.sources)))):(r(e.leftAxisSources),r(e.rightAxisSources)),e.overlayPriceScales){const i=e.overlayPriceScales[s];i&&(delete e.overlayPriceScales[s],e.overlayPriceScales[t]=i)}}else i.ownerSource===s&&(i.ownerSource=t)}return i}(t,e.mainSeries().id()),this._initialState=e.studyTemplate(!0,!0,!0);const n=e.mainSeries();t.symbol&&(this._newSymbolParams={symbol:t.symbol,currency:null!==(s=t.currency)&&void 0!==s?s:null,unit:null!==(r=t.unit)&&void 0!==r?r:null}),t.interval&&(this._newSymbolParams.interval=t.interval,this._newSymbolParams.style=(0,me.getChartStyleByResolution)(t.interval,n.style())),this._initialSymbolParams={symbol:n.symbol(),currency:n.currency(),unit:n.unit(),interval:n.interval(),style:n.style()},this._initialState=e.studyTemplate(),this._initialGroupsState=e.lineToolsGroupModel().state()}redo(){this._model.mainSeries().setSymbolParams(this._newSymbolParams);const e=this._merge(this._templateContent).filter(f.isLineTool);this._model.lineToolsGroupModel().removeLineTools(e);const t=this._model.mainSeries().properties();(0,me.preparePriceAxisProperties)(t), -this._model.recalcVisibleRangeStudies(!0),this._model.setShouldBeSavedEvenIfHidden(!0)}undo(){this._model.mainSeries().setSymbolParams(this._initialSymbolParams),this._merge(this._initialState)}_merge(e){const t=e.version||0,i=this._model,s=i.mainSeries();(0,o.assert)(s.id()===qe(e)),s.priceScale().properties().childs().lockScale.setValue(!1);const r=i.panes(),n=[];for(let e=r.length;e--;){const t=r[e],i=t.containsMainSeries(),s=t.dataSources();for(let e=s.length;e--;){const t=s[e];(!i||(0,P.isStudy)(t)&&t.isRemovedByStudyTemplates())&&n.push(t)}}i.resetDeferredStudies();const a=(0,ze.closeSourcesSet)(i,n);for(let e=0;ee.zorder-t.zorder));for(let e=0;e-1,a=o?r[e]:i.createPane(e);o&&t<3&&(0,je.reorderDataSourcesStateZOrder)(n.sources),a.restoreState(n,!1,t),null!==a.mainDataSource()||i.removePane(a)}return i.syncLollipopSources(),s.priceScale().setMode({autoScale:!0}),i.startNotStartedStudies(),i.recalculateAllPanes((0,ve.globalChangeEvent)()),i.fullUpdate(),a}}var Ye=i(36174),Ke=i(18611);const Ze=(0,w.getLogger)("Chart.ChartUndoModel"),Xe=new C.TranslatedString("paste drawing",l.t(null,void 0,i(96916)));class Je extends L.UndoCommand{constructor(e,t,i,s,r){super(Xe),this._needCopyToOtherCharts=!1,this._sourceState=null,this._model=e,this._clipboardData=t,this._paneIndex=this._model.panes().indexOf(i||(0,o.ensureNotNull)(this._model.paneForSource(this._model.mainSeries()))),this._pasteWithData=!!s,this._keepZIndex=!!r}redo(){const e=this._model.panes()[this._paneIndex],t=(0,o.ensureNotNull)(e.clipboardLineToolOwnerSource(this._clipboardData.source.id));null===this._sourceState&&(this._sourceState=this._getSourceState(t));const i=(0,o.ensureNotNull)(e.restoreLineTool(this._sourceState,this._pasteWithData,this._keepZIndex,void 0,t));(0,o.ensureNotNull)(t.priceScale()).addDataSource(i),this._clipboardData.centeredOnChart&&i.centerPosition&&i.centerPosition(),i.restoreFixedPoint(),i.createServerPoints();const s=(0,Ke.isActingAsSymbolSource)(t)||t.metaInfo().is_price_study;this._needCopyToOtherCharts=Boolean(s&&((0,Ae.drawOnAllCharts)().value()||i.linkKey().value()&&i.isSynchronizable())),this._model.setShouldBeSavedEvenIfHidden(!0)}undo(){if(!this._sourceState)return void Ze.logError("This command was never executed - nothing to undo");const e=this.source();this._clipboardData.centeredOnChart&&(this._clipboardData.centeredOnChart=!1,this._sourceState.points=e.normalizedPoints()),this._model.removeSource(e)}source(){return(0,o.ensureNotNull)(this._model.dataSourceForId((0,o.ensureNotNull)(this._sourceState).id))}needCopyToOtherCharts(){return this._needCopyToOtherCharts}_getSourceState(e){const t=(0,x.clone)(this._clipboardData.source);delete t.state.symbol,null!=t.linkKey&&(t.linkKey=(0,Ye.randomHash)());const i=(0, -o.ensureNotNull)(e.priceScale()),s=this._model,{symbol:r,currencyId:n,unitId:l}=this._clipboardData.source.state,c=(0,o.ensureNotNull)(e.symbolSource());let h=!1;!c.symbolSameAsCurrent(r)||(null!==n?n!==(0,me.symbolCurrency)(c.symbolInfo(),void 0,!0):c.isConvertedToOtherCurrency())||(null!==l?l!==(0,me.symbolUnit)(c.symbolInfo(),this._model.unitConversionEnabled()):c.isConvertedToOtherUnit())||((0,Ke.isActingAsSymbolSource)(e)?h=!0:(0,P.isStudy)(e)&&(h=Boolean(e.metaInfo().is_price_study)));const d=e=>{const t=e.x*s.timeScale().width(),r=e.y*i.height()-40;return new a.Point(t,r)},u=(0,o.ensureNotNull)(e.firstValue());if(this._model.id()===this._clipboardData.modelId||!h)for(let e=0;e{this._symbolSource(e).setSymbolParams(e.newSymbolParams),e.showFade&&e.chartWidget.screen.show(!0)})),this._firstRedo||(0,it.muteLinkingGroup)(this._linkingGroupIndex,!1),this._firstRedo=!1}undo(){(0,it.muteLinkingGroup)(this._linkingGroupIndex,!0),this._charts.forEach((e=>{this._symbolSource(e).setSymbolParams(e.prevSymbolParams),e.showFade&&e.chartWidget.screen.show(!0)})),(0,it.muteLinkingGroup)(this._linkingGroupIndex,!1)}canMerge(e){if(!(e instanceof st)||e._linkingGroupIndex!==this._linkingGroupIndex||!this._containsMainSeriesOnly()||!e._containsMainSeriesOnly()||e._creationTime-this._creationTime>500)return!1;for(const[t]of e._charts)if(this._charts.has(t))return!1;return!0}merge(e){if(e instanceof st)for(const[t,i]of e._charts)this._charts.set(t,i)}_showFade(e,t){return e===t.model().mainSeries()}_symbolSource(e){return(0,o.ensureNotNull)(e.chartWidget.model().model().dataSourceForId(e.sourceId))}_containsMainSeriesOnly(){for(const[e,t]of this._charts)if(t.sourceId!==e.model().mainSeries().id())return!1;return!0}}const rt=new C.TranslatedString("change symbol",l.t(null,void 0,i(526)));class nt extends st{constructor(e,t,i){super(rt,e,{symbol:t,currency:null,unit:null},i),this._symbol=t}canMerge(e){return e instanceof nt&&e._symbol===this._symbol&&super.canMerge(e)}}const ot=(0,w.getLogger)("Chart.ChartUndoModel"),at=new C.TranslatedString("paste indicator",l.t(null,void 0,i(80611)));class lt extends L.UndoCommand{constructor(e,t,i){super(at), -this._sourceState=null,this._model=e,this._clipboardData=t,this._paneId=i}redo(){if(!this._sourceState){const e=(0,x.clone)(this._clipboardData.source);e.id=(0,Ye.randomHashN)(6),this._sourceState=e}let e,t;e=this._paneId?(0,o.ensureNotNull)(this._model.paneForId(this._paneId)):this._sourceState.metaInfo.is_price_study?(0,o.ensureNotNull)(this._model.paneForSource(this._model.mainSeries())):this._model.createPane();const i=!e.mainDataSource();this._sourceState.zorder=e.newStudyZOrder();const s=(0,o.ensureNotNull)(e.restoreStudy(this._sourceState,!1));i||(t=this._sourceState.metaInfo.is_price_study?t=this._model.mainSeries().priceScale():this._paneId?e.findSuitableScale(s):e.defaultPriceScale(),t!==s.priceScale()&&e.move(s,t)),(0,P.isStudy)(s)&&s.start()}undo(){if(null===this._sourceState)return void ot.logError("This command was never executed - nothing to undo");const e=(0,o.ensureNotNull)(this._model.dataSourceForId(this._sourceState.id));this._model.removeSource(e)}state(){return this._sourceState}}class ct extends L.UndoCommand{constructor(e,t,i,s,r){super(null,!1),this._model=e,this._paneA=t,this._paneB=i,this._prevStretchA=s,this._currStretchA=r}redo(){const e=this._paneA.stretchFactor()+this._paneB.stretchFactor();this._paneA.setStretchFactor(this._currStretchA),this._paneB.setStretchFactor(e-this._currStretchA),this._model.fullUpdate()}undo(){const e=this._paneA.stretchFactor()+this._paneB.stretchFactor();this._paneA.setStretchFactor(this._prevStretchA),this._paneB.setStretchFactor(e-this._prevStretchA),this._model.fullUpdate()}}var ht=i(81155);const dt=new C.TranslatedString("move",l.t(null,void 0,i(47107)));class ut extends L.UndoCommand{constructor(e,t,i,s){super(dt,!1),this._endEvent=null,this._model=e,this._sourceId=t.id(),this._itemIndex=i,this._startEvent=s}move(e){this._endEvent=e,this._move(e)}hasChanges(){return null!==this._endEvent}undo(){this._move(this._startEvent)}redo(){this._move((0,o.ensureNotNull)(this._endEvent))}_move(e){const t=(0,o.ensureNotNull)(this._model.dataSourceForId(this._sourceId));(0,o.assert)(void 0!==t.moveItem,'The method "moveItem" is not defined'),t.moveItem&&t.moveItem(new a.Point(e.localX,e.localY),this._itemIndex,new ht.EnvironmentState(e))}}class pt extends L.UndoCommand{constructor(e,t,i,s,r,n,o,a,l,c,h,d,u){super(u),this._paneState=null,this._lastInsertionStartPromise=null,this._additionalStudiesIds=[],this._chartModel=e,this._studyMetaInfo=t,this._props=s,this._addAsOverlay=r,this._parentIds=n.map((e=>e.id())),this._inputs=i,this._targetZOrder=h,this._preferredPriceScale=o,this._allowChangeCurrency=a,this._allowChangeUnit=l,this._paneSize=c,this._studyId=null!=d?d:null}redo(){const e=this._parentIds.map((e=>this._chartModel.dataSourceForId(e))),t=this._chartModel.insertStudyWithParams(this._studyMetaInfo,this._inputs,this._targetZOrder,this._props,this._addAsOverlay,e,this._preferredPriceScale,this._allowChangeCurrency,this._allowChangeUnit,this._paneSize,null===this._studyId?void 0:this._studyId),i=t.study;if(this._lastInsertionStartPromise=t.startPromise, -this._studyId=i.id(),i.childStudyByRebind().subscribe(null,(()=>(0,S.trackEvent)("SOS","Apply SOS","Rebind SOS"))),this._chartModel.setShouldBeSavedEvenIfHidden(!0),null!==this._paneState){(0,o.ensureNotNull)(this._chartModel.paneForSource(i)).restoreState(this._paneState,!1,this._chartModel.version()),this._paneState=null}}undo(){const e=(0,o.ensureNotNull)(this._chartModel.dataSourceForId((0,o.ensureNotNull)(this._studyId)));isSymbolSource(e)&&e.symbolResolved().unsubscribeAll(this);const t=(0,o.ensureNotNull)(this._chartModel.paneForSource(e)).state();this._additionalStudiesIds.forEach((e=>{const t=(0,o.ensureNotNull)(this._chartModel.dataSourceForId(e));this._chartModel.removeSource(t)})),this._additionalStudiesIds=[],this._chartModel.removeSource(e)&&(this._paneState=t)}insertedStudy(){return this._chartModel.dataSourceForId((0,o.ensureNotNull)(this._studyId))}lastInsertionStartPromise(){var e;return null!==(e=this._lastInsertionStartPromise)&&void 0!==e?e:Promise.resolve()}_createCopiesOfNewFundamentalForAllStocks(){}_createCopiesOfExistingFundamentalsForNewStock(){}}var _t=i(95367),mt=i(20585),gt=i.n(mt),ft=i(59656),vt=i(26512),St=i(67521);const yt=new C.TranslatedString("zoom",l.t(null,void 0,i(59833)));class bt extends L.UndoCommand{constructor(e,t,i,s,r,n){super(yt),this._barSpacing=null,this._rightBarsOffset=null,this._leftBarsOffset=null,this._priceMode=null,this._model=e,this._startBar=t,this._endBar=i,this._startPrice=s,this._endPrice=r,this._pane=n}redo(){const e=(0,o.ensureNotNull)(this._model.timeScale().visibleBarsStrictRange());this._leftBarsOffset=e.firstBar()-this._startBar,this._rightBarsOffset=e.lastBar()-this._endBar,this._barSpacing=this._model.timeScale().barSpacing(),this._priceMode=this._pane.defaultPriceScale().mode(),this._model.zoomToViewport(this._startBar,this._endBar,this._startPrice,this._endPrice,this._pane)}undo(){const e=this._model.timeScale(),t=this._pane.defaultPriceScale(),i=(0,o.ensureNotNull)(e.visibleBarsStrictRange());e.setBarSpacing((0,o.ensureNotNull)(this._barSpacing)),e.zoomToBarsRange(i.firstBar()+(0,o.ensureNotNull)(this._leftBarsOffset),i.lastBar()+(0,o.ensureNotNull)(this._rightBarsOffset)),t.setMode((0,o.ensureNotNull)(this._priceMode)),t.recalculatePriceRange((0,o.ensureNotNull)(e.visibleBarsStrictRange())),this._model.recalculateAllPanes((0,ve.viewportChangeEvent)()),this._model.lightUpdate()}}const wt=(0,w.getLogger)("Chart.ChartUndoModel"),Pt=new C.TranslatedString("zoom",l.t(null,void 0,i(59833)));class Ct extends L.UndoCommand{constructor(e,t,i){super(Pt),this._baseCmd=e,this._zoomStack=t,this._inOut=i}undo(){if(this._inOut){if(this._baseCmd!==this._zoomStack.head())return void wt.logDebug("zoom stack inconsistency");this._baseCmd.undo(),this._zoomStack.pop()}else this._baseCmd.redo(),this._zoomStack.push(this._baseCmd)}redo(){if(this._inOut)this._baseCmd.redo(),this._zoomStack.push(this._baseCmd);else{if(this._baseCmd!==this._zoomStack.head())return void wt.logDebug("zoom stack inconsistency");this._baseCmd.undo(),this._zoomStack.pop()}}} -const xt=new C.TranslatedString("stop syncing drawing",l.t(null,void 0,i(98784)));class Tt extends L.UndoCommand{constructor(e,t){super(xt),this._model=e,this._sourceId=t.id(),this._linkKey=t.linkKey().value()}redo(){(0,o.ensureNotNull)(this._model.dataSourceForId(this._sourceId)).linkKey().setValue(null)}undo(){(0,o.ensureNotNull)(this._model.dataSourceForId(this._sourceId)).linkKey().setValue(this._linkKey)}}const It=new C.TranslatedString("restore defaults",l.t(null,void 0,i(9608)));class Mt extends L.UndoCommand{constructor(e,t,i=It){super(i),this._chartModel=e,this._defaultProperty=t,this._state=t.state()}redo(){this._chartModel.restoreFactoryDefaults(this._defaultProperty)}undo(){this._defaultProperty.mergeAndFire(this._state),this._chartModel.mainSeries().onChartStyleChanged()}}var Lt=i(17236);class At extends Mt{redo(){this._defaultProperty.hasChild("intervalsVisibilities")&&this._defaultProperty.childs().intervalsVisibilities.mergeAndFire(Lt.intervalsVisibilitiesDefaults),super.redo()}}class kt extends At{redo(){super.redo(),this._chartModel.recalcColorStudies(!0)}undo(){super.undo(),this._chartModel.recalcColorStudies(!0)}}var Dt=i(4949),Vt=i(30888),Et=i(85804);function Bt(e){const{visible:t,...i}=e;return i}function Rt(e){const{visible:t,...i}=e;return i}function Nt(e){const{drawWick:t,drawBorder:i,drawBody:s,barColorsOnPrevClose:r,...n}=e;return n}function Ot(e){const{drawWick:t,drawBorder:i,drawBody:s,...r}=e;return r}function Ft(e){const{drawWick:t,drawBorder:i,drawBody:s,showRealLastPrice:r,inputs:n,...o}=e;return o}function Wt(e){const{barColorsOnPrevClose:t,dontDrawOpen:i,thinBars:s,...r}=e;return r}function Ht(e){const{showBorders:t,showLabels:i,drawBody:s,...r}=e;return r}function zt(e){const{linestyle:t,linewidth:i,priceSource:s,...r}=e;return r}function Ut(e){const{linestyle:t,linewidth:i,priceSource:s,...r}=e;return r}function jt(e){const{inputs:t,...i}=e;return i}function Gt(e){const{inputs:t,...i}=e;return i}function qt(e){const{inputs:t,...i}=e;return i}function $t(e){const{inputs:t,...i}=e;return i}function Yt(e){const{topLineWidth:t,bottomLineWidth:i,baseLevelPercentage:s,priceSource:r,...n}=e;return n}function Kt(e){const{thinBars:t,inputs:i,...s}=e;return s}function Zt(e){const{visible:t,style:i,symbol:s,interval:r,sessionId:n,highLowAvgPrice:o,showCountdown:a,bidAsk:l,prePostMarket:c,priceAxisProperties:h,candleStyle:d,hollowCandleStyle:u,haStyle:p,barStyle:_,hiloStyle:m,lineStyle:g,lineWithMarkersStyle:f,steplineStyle:v,areaStyle:S,renkoStyle:y,pbStyle:b,kagiStyle:w,pnfStyle:P,baselineStyle:C,rangeStyle:x,esdShowDividends:T,esdShowSplits:I,esdShowEarnings:M,esdShowBreaks:L,showContinuousContractSwitches:A,showContinuousContractSwitchesBreaks:k,showFuturesContractExpiration:D,showLastNews:V,...E}=e;return{bidAsk:Bt(l),prePostMarket:Rt(c),candleStyle:Nt(d),hollowCandleStyle:Ot(u),haStyle:Ft(p),barStyle:Wt(_),hiloStyle:Ht(m),lineStyle:zt(g),lineWithMarkersStyle:zt(f),steplineStyle:zt(v),areaStyle:Ut(S),renkoStyle:jt(y),pbStyle:Gt(b),kagiStyle:qt(w),pnfStyle:$t(P),baselineStyle:Yt(C), -rangeStyle:Kt(x),...E}}function Xt(e){const{scaleSeriesOnly:t,showSeriesLastValue:i,showStudyLastValue:s,showSymbolLabels:r,showBidAskLabels:n,showPrePostMarketPriceLabel:o,showStudyPlotLabels:a,showFundamentalNameLabel:l,showFundamentalLastValue:c,seriesLastValueMode:h,...d}=e;return d}function Jt(e){const{topMargin:t,bottomMargin:i,...s}=e;return s}const Qt=new C.TranslatedString("apply chart theme",l.t(null,void 0,i(66568)));class ei extends L.UndoCommand{constructor(e,t,i){var s,r,n;super(Qt),this._model=e,this._newSessionProps=t.sessions||(0,Et.factoryDefaults)("sessions"),["candleStyle","hollowCandleStyle","haStyle"].forEach((e=>{t.mainSourceProperties[e].wickUpColor=t.mainSourceProperties[e].wickUpColor||t.mainSourceProperties[e].wickColor,t.mainSourceProperties[e].wickDownColor=t.mainSourceProperties[e].wickDownColor||t.mainSourceProperties[e].wickColor})),t.chartProperties=null!==(s=t.chartProperties)&&void 0!==s?s:{paneProperties:{},scalesProperties:void 0},t.chartProperties.paneProperties.vertGridProperties=null!==(r=t.chartProperties.paneProperties.vertGridProperties)&&void 0!==r?r:t.chartProperties.paneProperties.gridProperties,t.chartProperties.paneProperties.horzGridProperties=null!==(n=t.chartProperties.paneProperties.horzGridProperties)&&void 0!==n?n:t.chartProperties.paneProperties.gridProperties;const o=this._model.properties().state().paneProperties.legendProperties;delete o.backgroundTransparency,t.chartProperties.paneProperties.legendProperties={...t.chartProperties.paneProperties.legendProperties,...o};const a=(0,Et.factoryDefaults)("chartproperties"),l=(0,Vt.deepExtend)({},a,t.chartProperties);this._newChartProps={paneProperties:Jt(l.paneProperties),scalesProperties:Xt(l.scalesProperties)},e.timeScale().preserveBarSpacing()&&delete this._newChartProps.scalesProperties.barSpacing;const c=(0,Et.factoryDefaults)("chartproperties.mainSeriesProperties"),h=(0,Vt.deepExtend)({},c,t.mainSourceProperties);this._newSeriesProps=i?h:Zt(h);const d=e.properties().state();this._oldChartProps={paneProperties:Jt(d.paneProperties),scalesProperties:Xt(d.scalesProperties)};const u=e.mainSeries().properties().state();this._oldSeriesProps=i?u:Zt(u),this._oldSessionProps=this._model.sessions().properties().state()}undo(){this._merge(this._oldChartProps,this._oldSeriesProps,this._oldSessionProps),this._model.mainSeries().onChartStyleChanged(),this._model.updateScales(),this._model.chartThemeLoaded()}redo(){this._merge(this._newChartProps,this._newSeriesProps,this._newSessionProps),this._model.mainSeries().onChartStyleChanged(),this._model.updateScales(),this._model.chartThemeLoaded()}_merge(e,t,i){var s,r,n,o;const a=this._model;(0,_e.saveDefaultProperties)(!0),e&&(a.properties().childs().paneProperties.mergeAndFire(e.paneProperties),a.properties().childs().scalesProperties.mergeAndFire(e.scalesProperties)),"priceAxisProperties"in t&&a.mainSeries().priceScale().setMode({autoScale:null===(s=t.priceAxisProperties)||void 0===s?void 0:s.autoScale, -percentage:null===(r=t.priceAxisProperties)||void 0===r?void 0:r.percentage,log:null===(n=t.priceAxisProperties)||void 0===n?void 0:n.log,lockScale:null===(o=t.priceAxisProperties)||void 0===o?void 0:o.lockScale}),a.mainSeries().properties().mergeAndFire(t),a.mainSeries().properties().saveDefaults(),a.mainSeries().createPaneView(),a.mainSeries().invalidateBarStylesCache(),a.recalculateAllPanes((0,ve.globalChangeEvent)()),a.fullUpdate(),a.properties().saveDefaults(),a.sessions().restoreState({properties:i},!1),(0,_e.saveDefaultProperties)(!1)}}const ti=new C.TranslatedString("change resolution",l.t(null,void 0,i(32303)));class ii extends st{constructor(e,t,i){super(ti,e,function(e,t){let i;const s=(0,me.isRangeStyle)(e.style()),r=p.Interval.isRange(t);return!s&&r?i=11:s&&!r&&(i=(0,me.getLastUsedStyle)()),{interval:t,style:i}}(e,t),i),this._resolution=t}canMerge(e){return e instanceof ii&&e._resolution===this._resolution&&super.canMerge(e)}_showFade(e,t){return!0}}var si=i(69718);class ri extends si.SetWatchedValueCommand{constructor(){super(...arguments),this._firstRedo=!0}redo(){this._firstRedo||(0,it.muteLinkingGroup)(this._newValue,!0),(0,it.muteLinkingGroup)(this._oldValue,!0),super.redo(),this._firstRedo||(0,it.muteLinkingGroup)(this._newValue,!1),(0,it.muteLinkingGroup)(this._oldValue,!1),this._firstRedo=!1}undo(){(0,it.muteLinkingGroup)(this._newValue,!0),(0,it.muteLinkingGroup)(this._oldValue,!0),super.undo(),(0,it.muteLinkingGroup)(this._newValue,!1),(0,it.muteLinkingGroup)(this._oldValue,!1)}}var ni=i(97340),oi=i(76422) -;const ai=new C.TranslatedString("send {title} backward",l.t(null,void 0,i(16259))),li=new C.TranslatedString("bring {title} forward",l.t(null,void 0,i(56763))),ci=new C.TranslatedString("insert {title} after {target}",l.t(null,void 0,i(74055))),hi=new C.TranslatedString("insert {title} before {target}",l.t(null,void 0,i(11231))),di=new C.TranslatedString("cut {title}",l.t(null,void 0,i(78755))),ui=new C.TranslatedString("cut sources",l.t(null,void 0,i(63649))),pi=new C.TranslatedString("remove {title}",l.t(null,void 0,i(39859))),_i=new C.TranslatedString("remove drawings group",l.t(null,void 0,i(70653))),mi=new C.TranslatedString("move scale",l.t(null,void 0,i(4184))),gi=new C.TranslatedString("stop syncing line tool(s)",l.t(null,void 0,i(57011))),fi=new C.TranslatedString("zoom out",l.t(null,void 0,i(9645))),vi=new C.TranslatedString("zoom in",l.t(null,void 0,i(19813))),Si=new C.TranslatedString("move drawing(s)",l.t(null,void 0,i(45356))),yi=new C.TranslatedString("load default drawing template",l.t(null,void 0,i(54597))),bi=new C.TranslatedString("apply factory defaults to selected sources",l.t(null,void 0,i(96996))),wi=new C.TranslatedString("change currency",l.t(null,void 0,i(22641))),Pi=new C.TranslatedString("change unit",l.t(null,void 0,i(39028))),Ci=new C.TranslatedString("clone line tools",l.t(null,void 0,i(5179))),xi=new C.TranslatedString("merge up",l.t(null,void 0,i(66143))),Ti=new C.TranslatedString("merge down",l.t(null,void 0,i(62153))),Ii=new C.TranslatedString("merge to pane",l.t(null,void 0,i(70746))),Mi=new C.TranslatedString("unmerge up",l.t(null,void 0,i(52540))),Li=new C.TranslatedString("unmerge down",l.t(null,void 0,i(86949))),Ai=new C.TranslatedString("unmerge to new bottom pane",l.t(null,void 0,i(20057))),ki=new C.TranslatedString("move {title} to new right scale",l.t(null,void 0,i(45544))),Di=new C.TranslatedString("move {title} to new left scale",l.t(null,void 0,i(11303))),Vi=new C.TranslatedString("make {title} no scale (Full screen)",l.t(null,void 0,i(74642))),Ei=new C.TranslatedString("scroll time",l.t(null,void 0,i(70009))),Bi=new C.TranslatedString("scale time",l.t(null,void 0,i(35962))),Ri=new C.TranslatedString("reset time scale",l.t(null,void 0,i(55064))),Ni=new C.TranslatedString("reset scales",l.t(null,void 0,i(21948))),Oi=new C.TranslatedString("create {tool}",l.t(null,void 0,i(81791))),Fi=new C.TranslatedString("change {pointIndex} point",l.t(null,void 0,i(72032))),Wi=new C.TranslatedString("paste {title}",l.t(null,void 0,i(41601))),Hi=new C.TranslatedString("insert {title}",l.t(null,void 0,i(90743))),zi=new C.TranslatedString("remove all studies",l.t(null,void 0,i(15516))),Ui=new C.TranslatedString("remove drawings",l.t(null,void 0,i(44656))),ji=new C.TranslatedString("remove all studies and drawing tools",l.t(null,void 0,i(80171))),Gi=(new C.TranslatedString("turn line tools sharing off",l.t(null,void 0,i(28068))),new C.TranslatedString("share line tools in layout",l.t(null,void 0,i(77554))),new C.TranslatedString("share line tools globally",l.t(null,void 0,i(64704))), +setBaseIndex(e){Number.isFinite(e)?(this._visibleBarsInvalidated=!0,this._baseIndex=e,this.correctOffset()):mt.logDebug(`setBaseIndex: invalid argument: ${e}`)}resetBaseIndex(){this._visibleBarsInvalidated=!0,this._baseIndex=null}setRightOffset(e){Number.isFinite(e)?(this._visibleBarsInvalidated=!0,this._updateRightOffset(e)):mt.logWarn(`setRightOffset: invalid argument: ${e}`)}correctBarSpacing(){this.isEmpty()||this.points().size()e&&(this._rightOffset=e,this._visibleBarsInvalidated=!0);const t=this.minRightOffset();null!==t&&this._rightOffset=0&&this.setRightOffset(this.percentsToBarIndexLength(s))}endScale(){null!==this._scaleStartPoint&&(this._scaleStartPoint=null,this._clearCommonTransitionsStartState(),this._requestMoreData())}startScroll(e){null===this._scrollStartPoint&&null===this._commonTransitionStartState&&(this.isEmpty()||(this._scrollStartPoint=e,this._saveCommonTransitionsStartState()))}scrollTo(e){if(this._visibleBarsInvalidated=!0,null===this._scrollStartPoint)return;const t=(this._scrollStartPoint-e)/this.barSpacing(),i=(0,n.ensureNotNull)(this._commonTransitionStartState).rightOffset+t;this._updateRightOffset(i),this._onScroll.fire()}endScroll(){if(null===this._scrollStartPoint)return clearInterval(this._timeout),void(this._prevRO=void 0);this._scrollStartPoint=null,this._clearCommonTransitionsStartState(),this._requestMoreData(),this._timeout=setInterval((()=>{this._prevRO!==this.rightOffset()&&(this._prevRO=this.rightOffset(),this._requestMoreData())}),100)}formatLabel(e,t){const i="24-hours"===at.timeHoursFormatProperty.value()?t.toString():`${t}_ampm`;let s=this._formattedBySpan.get(i);return void 0===s&&(s=new rt((e=>this.formatLabelImpl(e,t))),this._formattedBySpan.set(i,s)), +s.format(new Date(e))}formatLabelImpl(e,t){if(!(e&&e instanceof Date))return"incorrect time";const s=function(e,t){if(e=0){const e=this._defaultRightOffsetPercentage.value(),t=this._usePercentageRightOffset.value()&&this._rightOffset>=0?Math.round(this.barIndexLengthToPercents(this._rightOffset)):-1;if(this._lastDefaultRightOffset!==e&&t===this._lastDefaultRightOffset){const t=this._barSpacing*(100-e)/(100-this._lastDefaultRightOffset);this._tryToUpdateBarSpacing(this._barSpacing,t)}}this.setRightOffset(this.targetDefaultRightOffset()),this._updateResetAvailableValue(),this._lastDefaultRightOffset=this._defaultRightOffsetPercentage.value()}_updateResetAvailableValue(){this._resetAvailable.setValue(6!==this.barSpacing()||this.rightOffset()!==this.targetDefaultRightOffset())}}var ft=i(34928),vt=i(53741),St=i(83407),yt=i(35588);class bt{constructor(e){this._onChanged=new G.Delegate,this._groups=[],this._groups=e||[],this._groups.forEach((e=>{e.onChanged().subscribe(null,(t=>this._onChanged.fire(e.id,t)))}))}groups(){return this._groups.filter((e=>e.isActualSymbol()))}groupsForAllSymbols(){return this._groups}createGroup(e,t,i){t=t||this._generateNextName();const s=new yt.LineToolsGroup(e,t,i);this._groups.push(s),s.onChanged().subscribe(null,(e=>this._onChanged.fire(s.id,e)));const r={visibilityChanged:!1,lockedChanged:!1,titleChanged:!1,isActualIntervalChanged:!1,affectedLineTools:e.map((e=>e.id()))} +;return this._onChanged.fire(s.id,r),s}addGroup(e){this._groups.push(e),e.onChanged().subscribe(null,(t=>this._onChanged.fire(e.id,t))),this._onChanged.fire(e.id)}removeGroup(e){const t=this._groups.findIndex((t=>t.id===e.id));this._groups.splice(t,1),this._onChanged.fire(e.id)}groupForId(e){return this._groups.find((t=>t.id===e))||null}groupForLineTool(e){return this._groups.find((t=>t.containsLineTool(e)))||null}removeLineTools(e){const t=new Set;this._groups.forEach((i=>{const s=e.filter(i.containsLineTool.bind(i));s.length&&(i.excludeLineTools(s),t.add(i.id))}));return this._groups.filter((e=>0===e.lineTools().length)).forEach((e=>this.removeGroup(e))),Array.from(t)}state(e){return{groups:(e?this._groups.filter((e=>e.isActualSymbol())):this._groups).map((e=>e.state()))}}onChanged(){return this._onChanged}fireChangedAll(){this._groups.forEach((e=>{this._onChanged.fire(e.id)}))}static fromState(e,t){const i=[];for(const s of t.groups){const t=yt.LineToolsGroup.fromState(e,s);null!==t&&i.push(t)}return new bt(i)}_generateNextName(){const e=new Set(this.groups().map((e=>e.name())));for(let t=1;;t++){const i=`Group ${t}`,s=`Group_${t}`;if(!e.has(i)&&!e.has(s))return i}}}var wt=i(99652),Pt=i(41249),Ct=i.n(Pt),xt=i(60156);let Tt=null;function It(e){return Boolean(e.symbolInfo.timezone)&&Boolean(e.symbolInfo.session)}class Mt{constructor(e,t){var i,s;this._sourceTargetBarBuilder=null,this._cache=new Map,this._source=e,this._sourceSession=xt.SessionInfo.fromState(e.session),this._target=t,this._targetSession=xt.SessionInfo.fromState(t.session),this._isResolutionTheSame=x.Interval.isEqual(e.resolution,t.resolution),this._isSessionTheSame=(i=e.symbolInfo,s=t.symbolInfo,i.timezone===s.timezone&&i.session===s.session&&i.session_holidays===s.session_holidays&&i.corrections===s.corrections),this._shouldCorrectTradingDay=x.Interval.isDWM(e.resolution)&&!this._isSessionTheSame}sourceTimeToTargetTime(e){if(this._isSessionTheSame&&this._isResolutionTheSame)return e;if(!It(this._source)||!It(this._target))return e;let t=this._cache.get(e);if(void 0===t){let i=1e3*e;if(this._shouldCorrectTradingDay){let e=Ct().utc_to_cal(this._sourceSession.timezone,i);e=this._sourceSession.spec.correctTradingDay(e);const t=new Date(e);Ct().set_hms(t,0,0,0,0,this._sourceSession.timezone),i=t.valueOf()}const s=this._sourceTargetBuilder();s.moveTo(i);const r=s.indexOfBar(i);t=s.startOfBar(Math.max(0,r))/1e3,this._cache.set(e,t)}return t}_sourceTargetBuilder(){if(null===this._sourceTargetBarBuilder){const e=this._isSessionTheSame?this._targetSession:(null===Tt&&(Tt=new xt.SessionInfo("Etc/UTC","24x7")),Tt);this._sourceTargetBarBuilder=(0,xt.newBarBuilder)(this._target.resolution,this._targetSession,e)}return this._sourceTargetBarBuilder}}var Lt=i(87095),At=i(36112),kt=i(93613);function Dt(e,t){return e.codet.code?1:0}class Et{constructor(e){this._convertibleItems=e,this._idsToItems=new Map;for(const t of e)this._idsToItems.set(t.id,t)}convertible(e){return void 0!==this._idsToItems.get(e)}item(e){var t +;return null!==(t=this._idsToItems.get(e))&&void 0!==t?t:null}size(){return this._convertibleItems.length}filterConvertible(e,t){const i=this._convertibleItems.filter(function(e,t){return i=>!e.has(i.id)&&t(i.id)}(e,t));return i.sort(Dt),i}}class Vt{constructor(e){this._allGroups=new Set,this._idToName=new Map,this._idToDescription=new Map,this._groupedUnitIds=new Map,this._groupedUnits=new Map,this._groupById=new Map,this._size=0,this._units=e;for(const t in e)if(e.hasOwnProperty(t)){this._allGroups.add(t),this._groupedUnitIds.set(t,new Set(e[t].map((e=>e.id)))),this._groupedUnits.set(t,e[t]);for(const i of e[t])this._size++,this._idToName.set(i.id,i.name),this._idToDescription.set(i.id,i.description),this._groupById.set(i.id,t)}}unitsChanged(e){return this._units!==e}size(){return this._size}name(e){return this._idToName.get(e)||e}description(e){return this._idToDescription.get(e)||e}unitGroupById(e){return this._groupById.get(e)||null}allGroups(){return new Set(this._allGroups)}unitsByGroups(e){const t=[];return e.forEach((e=>{const i=this._groupedUnits.get(e);void 0!==i&&t.push({name:e,units:i})})),t}convertible(e,t){for(const i of t){const t=this._groupedUnitIds.get(i);if(void 0!==t&&t.has(e))return!0}return!1}}var Bt=i(50335);class Rt{constructor(e){this._source=null,this._sourcePane=null,this._currentToolSupportsPhantomMode=!1,this._model=e}destroy(){this._source=null,this._sourcePane=null}source(){return this._source}onToolChanged(){this._removeSource();const e=this._model.currentTool();this._currentToolSupportsPhantomMode=(0,he.isLineToolName)(e)&&(0,S.supportsPhantomMode)(e)}onCursorPositionUpdated(){if(!this._currentToolSupportsPhantomMode)return;const e=this._model.crossHairSource();if(this._sourcePane!==e.pane&&this._removeSource(),null===e.pane||!(0,Bt.isNumber)(e.index)||!(0,Bt.isNumber)(e.price))return void this._removeSource();const t={index:e.index,price:e.price};null!==this._source?this._source.setPoint(0,t):(this._source=this._model.createLineTool(e.pane,t,this._model.currentTool(),void 0,null,0),this._sourcePane=e.pane)}_removeSource(){null!==this._source&&(this._model.removeSource(this._source),this._source=null,this._sourcePane=null)}}var Nt=i(17133),Ot=i(36147),Ft=i(18540);class Wt{constructor(){this._lastValue=null}align(e,t,i){this._lastValue=null;let s=e;if(!(0,Ft.magnetEnabled)().value())return s;const r=i.mainDataSource();if(null===r)return s;const o=r.model().mainSeries();if(r!==o)return s;const a=o.priceScale();if(a.isEmpty())return s;const l=function(e,t){const i=e.bars().valueAt(t);if(null===i)return;let s;if(null!==e.priceSource())s=[e.barFunction()(i)];else switch(e.style()){case 12:s=[i[2],i[3]];break;case 16:s=[i[2],i[4],i[3]];break;default:s=[i[1],i[2],i[3],i[4]]}return s}(o,t);if(!l)return s;const c=(0,n.ensure)(o.firstValue()),h=l.map((e=>({y:a.priceToCoordinate(e,c),price:e}))),d=a.priceToCoordinate(e,c);h.sort(((e,t)=>Math.abs(e.y-d)-Math.abs(t.y-d)));const u=h[0];return((0,Ft.magnetMode)().value()===Ot.MagnetMode.StrongMagnet||Math.abs(u.y-d)<50)&&(s=u.price, +this._lastValue=s),s}lastValue(){return this._lastValue}resetLastValue(){this._lastValue=null}}var Ht=i(77475),zt=i(14292),Ut=i(68441),jt=i(59590);class Gt extends jt.BitmapCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null}setData(e){this._data=e}hitTest(e){return null}_drawImpl(e){if(null===this._data)return;const{context:t,verticalPixelRatio:i,horizontalPixelRatio:s,bitmapSize:r}=e,n=Math.max(1,Math.floor(s));t.lineWidth=n;const o=Math.ceil(r.height*i),a=Math.ceil(r.width*s);if(t.lineCap="butt",this._data.vertLinesVisible){t.strokeStyle=this._data.vertLinesColor,(0,Ut.setLineStyle)(t,this._data.vertLineStyle);for(const e of this._data.timeMarks){const i=Math.round(e.coord*s);(0,Ut.drawVerticalLine)(t,i,0,o)}}if(this._data.horzLinesVisible){t.strokeStyle=this._data.horzLinesColor,(0,Ut.setLineStyle)(t,this._data.horzLineStyle);for(const e of this._data.priceMarks){const s=Math.round(e.coord*i);(0,Ut.drawHorizontalLine)(t,s,0,a)}}}}class qt{constructor(e){this._renderer=new Gt,this._pane=e}update(){}renderer(){const e=this._pane.defaultPriceScale(),t=this._pane.model().timeScale();if(e.isEmpty()||t.isEmpty())return null;const i=this._pane.model().properties().childs().paneProperties.childs(),s=t.marks(),r=i.gridLinesMode.value(),n={horzLinesVisible:"both"===r||"horz"===r,vertLinesVisible:"both"===r||"vert"===r,horzLinesColor:i.horzGridProperties.childs().color.value(),vertLinesColor:i.vertGridProperties.childs().color.value(),horzLineStyle:i.horzGridProperties.childs().style.value(),vertLineStyle:i.vertGridProperties.childs().style.value(),priceMarks:e.marks(),timeMarks:null!==s?s:[]};return this._renderer.setData(n),this._renderer}}class $t extends zt.DataSource{id(){return"grid"}paneViews(e){return[new qt(e)]}name(){return"Grid"}}var Yt=i(42275);class Kt extends Yt.PriceAxisView{constructor(e,t,i,s){super(),this._source=e,this._pane=t,this._priceScale=i,this._priceProvider=s,this._properties=e.model().properties().childs().scalesProperties}setHitTestData(e){this._hitTestData=e}setXCoord(e){this._xCoord=e}additionalPadding(e){return 0}_updateRendererData(e,t,i){e.visible=!1,t.visible=!1;const s=this._priceScale,r=s.mainSource(),n=null!==r?r.firstValue():null;if(!this._isVisible()||s.isEmpty()||null===n)return;const o=this._currentPrice(s);if(null===o)return;i.background=(0,Lt.resetTransparency)(this._bgColor()),i.textColor=this.generateTextColor(i.background);const a=this.additionalPadding(s.fontSize());i.additionalPaddingTop=a,i.additionalPaddingBottom=a,i.coordinate=s.priceToCoordinate(o,n),e.text=s.formatPrice(o,n),e.visible=!0,t.visible=!0,t.hitTestData=this._hitTestData,t.xCoord=this._xCoord}_currentPrice(e){return this._priceProvider(e)}}class Zt extends Kt{additionalPadding(e){return 2/12*e}_isVisible(){const e=this._source.lockedPane();return this._properties.childs().showPriceScaleCrosshairLabel.value()&&(this._source.visible||null!==e)&&(null!=e?e:this._source.pane)===this._pane}_currentPrice(e){const t=Se.crosshairLock.value() +;return null!==t&&1===t.type?this._pane===this._source.lockedPane()?t.price:null:super._currentPrice(e)}_bgColor(){const e=this._properties.childs();return this._source.model().dark().value()?e.crosshairLabelBgColorDark.value():e.crosshairLabelBgColorLight.value()}_updateRendererData(e,t,i){const s=t.visible;super._updateRendererData(e,t,i),this._source.isHovered()?t.backgroung=this._source.model().dark().value()?l.colorsPalette["color-cold-gray-600"]:l.colorsPalette["color-cold-gray-650"]:t.backgroung=void 0,s||(t.visible=s)}}class Xt extends Kt{_isVisible(){return null!==this._source.measurePane().value()}_bgColor(){return this._properties.childs().axisLineToolLabelBackgroundColorCommon.value()}}var Jt=i(43493),Qt=(i(39347),i(10643)),ei=(i(37591),i(11095));function ti(e){const t=e.priceScale();return null===t?0:t.isPercentage()||t.isIndexedTo100()?2:1}const ii=N.enabled("show_context_menu_in_crosshair_if_only_one_item");class si extends Jt.PanePriceAxisView{constructor(e,t,i,s,r){super(e,t,s),this._crossHairMenuCachedState=null,this._hasActions=!1,this._tooltipText=null,this._gaOrigin="CH menu",this._crosshairPriceAxisView=e,e.setPaneRendererLabelIcon(0),this._crosshair=t,this._scale=i,this._options=r,this._updateGaOrigin()}_updateImpl(e,t){const i=this._crosshair.y,s=this._chartModel.properties().childs().scalesProperties.childs().fontSize.value(),r=this._chartModel.timeScale().width(),n=this._crosshair.model().priceAxisRendererOptions(),a=s+2*this._crosshairPriceAxisView.additionalPadding(s)+n.paddingTop+n.paddingBottom,l=a,c=i-a/2,h=this._crosshair.pane,d=this._mainDataSourceOnPane(),u=d&&d.symbolSource(),p=!!u&&(u.isConvertedToOtherCurrency()||u.isConvertedToOtherUnit());if(this._updateGaOrigin(),null!==d){const e=ti(d),t=d.idForAlert(),i=this._chartModel.isInReplay(),s=this._crossHairMenuCachedState,r=N.enabled("chart_crosshair_menu");null!==s&&s.id===t&&s.priceScale===e&&s.isCurrencyOrUnitConverted===p&&s.isInReplay===i&&s.isMenuEnabled===r||(this._updateTooltipAndActionsAvailability(d,e,p),this._crossHairMenuCachedState={id:t,priceScale:e,isCurrencyOrUnitConverted:p,isInReplay:i,isMenuEnabled:r})}const _=null!==d&&(0,_e.isActingAsSymbolSource)(d)?d.symbol():null,m=null!==h&&(h.maximized().value()||!h.collapsed().value())&&(Boolean(_)||!1);this._crosshairPriceAxisView.setPaneLabelVisible(m);const g=this._position();if(null!==g){const e=0,t=r-l,i=Boolean(ei.showPlusButtonOnCursor.value()),s=i?this._crosshair.x:void 0,n=void 0!==s?s-l/2:"left"===g?e:t,h=void 0!==s?s+l/2:"left"===g?e+l:t+l,d=(0,o.box)(new o.Point(n,c),new o.Point(h,c+a)),u=this._tooltipText?{text:this._tooltipText,rect:{x:d.min.x,y:d.min.y,w:d.max.x-d.min.x,h:d.max.y-d.min.y}}:void 0;this._data={itemBox:d,clickHandler:this._handleClick.bind(this,g,i,d),tooltip:u},this._crosshairPriceAxisView.setHitTestData(this._data),this._crosshairPriceAxisView.setXCoord(s)}super._updateImpl(e,t)}_priceScale(){return this._scale}_updateGaOrigin(){this._gaOrigin=Boolean(ei.showPlusButtonOnCursor.value())?"CH menu cursor":"CH menu"} +_updateTooltipAndActionsAvailability(e,t,i){this._tooltipText=null,this._hasActions=!1;if(!(1===t))return;this._chartModel.isInReplay();let s=0;let r=0;1!==s||ii||(this._tooltipText=""),this._crosshairPriceAxisView.setPaneRendererLabelIcon(r),this._hasActions=0!==s}_handleClick(e,t,i,s,r){(0,u.trackEvent)(this._gaOrigin,"click");const n=this._mainDataSourceOnPane(),o=null!==n&&(0,_e.isActingAsSymbolSource)(n)?n.symbol():null,a={pageX:r.pageX,pageY:r.pageY,clientX:r.clientX,clientY:r.clientY,screenX:r.screenX,screenY:r.screenY,price:this._crosshair.price,symbol:o};_.emit("onPlusClick",a)}_getMenuItems(e){return Promise.resolve([])}_createAlertMenuItems(e){return Promise.resolve([])}_createTradingMenuItems(){return Promise.resolve([])}_createAddHorizontalLineMenuItem(){return[]}_getActionAddAlert(e){return null}_getActionAddHorizontalLine(e){return null}_getValue(e,t){const i=e.priceScale(),s=e.firstValue();if(null===i||null===s)return null;return i.isPercentage()||i.isIndexedTo100()?null:i.coordinateToPrice(t,s)}_formatValue(e,t){return t.formatter().format(e)}async _addAlert(e,t){}_addHorizontalLineTool(e,t){}_showContextMenu(e,t,i,s,r){const o="left"===r;setTimeout((()=>{const r=s.clientX-s.localX,a=s.clientY-s.localY,l=i.min.x+r,c=i.max.x+r,h=i.min.y+a,d=c-l,u=i.max.y+a-h,p=t?Se.crosshairLock.value():void 0;if(void 0!==p){const e=(0,n.ensureNotNull)(this._chartModel.timeScale().points().roughTime(this._crosshair.index));Se.crosshairLock.setValue({type:1,price:this._crosshair.price,time:e,modelId:this._chartModel.id(),paneId:(0,n.ensureNotNull)(this._crosshair.pane).id()})}Qt.ContextMenuManager.showMenu(e,{clientX:s.clientX,clientY:s.clientY,box:{x:l,w:d,y:h,h:u},attachToXBy:t?"auto":o?"left":"right",attachToYBy:"auto-strict",marginX:t?0:-d},void 0,{menuName:"CrosshairMenuView"},(()=>{void 0!==p&&Se.crosshairLock.setValue(p)}))}))}_mainDataSourceOnPane(){const e=this._crosshair.pane;return null!==e?e.mainDataSource():null}}var ri=i(79849),ni=i(38325),oi=i(18807);class ai extends jt.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){return void 0===this._data.clickHandler?null:new oi.HitTestResult(oi.HitTarget.Custom,{clickHandler:this._data.clickHandler,tapHandler:this._data.clickHandler})}_drawImpl(e){const t=this._data.vertLinesVisible,i=this._data.horzLinesVisible;if(!t&&!i)return;const{context:s,horizontalPixelRatio:r,verticalPixelRatio:n,bitmapSize:o}=e;s.lineWidth=Math.max(1,Math.floor(this._data.lineWidth*r)),s.strokeStyle=this._data.color,s.fillStyle=this._data.color,s.lineCap="butt",(0,Ut.setLineStyle)(s,this._data.lineStyle);const a=Math.round(this._data.x*r),l=Math.round(this._data.y*n),c=Math.ceil(o.width*r),h=Math.ceil(o.height*n);t&&a>=0&&(0,Ut.drawVerticalLine)(s,a,0,h),i&&l>=0&&(0,Ut.drawHorizontalLine)(s,l,0,c),this._data.drawCenter&&(s.beginPath(),s.arc(a,l,Math.round(3*r),0,2*Math.PI,!0),s.fillStyle=this._data.color,s.fill()),this._data.scissors&&function(e,t,i){const{context:s,bitmapSize:r,horizontalPixelRatio:n,verticalPixelRatio:o}=e,a=24*n,l=Math.round(t-a/2) +;let c=Math.round(i-a/2);if(c<0)c=0;else{const e=r.height-a;c>e&&(c=e)}s.translate(l,c),s.scale(n,o),s.fillStyle="#131722",s.fill(li),s.strokeStyle="#fff",s.lineWidth=1,s.stroke(li)}(e,a,l)}}const li=new Path2D("m15.68 3.72-3.82 5.52-3.83-5.52-.28-.42-.42.3a2.84 2.84 0 0 0-.68 3.92l3.27 4.73-1.16 1.68a3.34 3.34 0 0 0-4.26 3.22 3.34 3.34 0 0 0 3.32 3.35 3.34 3.34 0 0 0 3.08-4.6l1-1.44 1.13 1.62a3.34 3.34 0 0 0 3.15 4.42c1.84 0 3.32-1.5 3.32-3.35a3.34 3.34 0 0 0-4.42-3.17l-1.23-1.78 3.22-4.65a2.86 2.86 0 0 0-.69-3.96l-.41-.29-.29.42ZM7.82 16.27c.47 0 .86.39.86.88 0 .48-.39.87-.86.87a.87.87 0 0 1-.86-.87c0-.5.4-.88.86-.88Zm8.36 0c.47 0 .86.39.86.88 0 .48-.4.87-.86.87a.87.87 0 0 1-.86-.87c0-.5.39-.88.86-.88Z");const ci=l.colorsPalette["color-tv-blue-500"];class hi{constructor(e,t){this._rendererData={},this._renderer=new ai(this._rendererData),this._source=e,this._pane=t}update(){}renderer(e,t){var i,s;const r=this._source.selectPointMode().value()!==Se.SelectPointMode.None,o=this._source.lockedPane(),a=(this._source.visible||null!==o)&&(this._source.areLinesVisible||r)&&!this._source.linesShouldBeHidden(),l=this._rendererData;if(!a||null===this._pane)return null;const c=this._source.paneForPointSelect(),h=this._source.isReplaySelection(),d=null!=o?o:this._source.pane,u=this._pane===d,p=h||(null!==c?d===c&&this._pane===c:u);if(l.scissors=!1,r&&(h||this._source.isOnHoveredChartWidget())&&p){const e=(0,n.ensureNotNull)(this._source.pointToSelect());l.color=this._source.lineColor()||ci,h?(l.lineWidth=2,l.scissors=u):l.lineWidth=1,l.lineStyle=ri.LINESTYLE_SOLID,l.horzLinesVisible=!0,l.vertLinesVisible=!0,l.drawCenter=!1,"time"===e?l.horzLinesVisible=!1:"price"===e&&(l.vertLinesVisible=!1)}else{const e=this._source.properties(),t=this._source.model().currentTool(),i=(0,ni.lastMouseOrTouchEventInfo)(),s=i.isTouch&&!i.stylus&&((0,he.isLineToolName)(t)||(0,Se.toolIsMeasure)(t));let r;r=s?ci:e.childs().color.value();const n=e.childs().transparency.value();!s&&n>0&&(r=(0,Lt.generateColor)(r,n)),l.color=r,l.horzLinesVisible=this._pane===d&&(this._pane.maximized().value()||!this._pane.collapsed().value()),l.vertLinesVisible=!0,l.lineWidth=e.childs().width.value(),l.lineStyle=e.childs().style.value(),l.drawCenter=s&&this._pane===d}return l.x=null!==(i=this._source.lockedX())&&void 0!==i?i:this._source.x,l.y=null!==(s=this._source.lockedY())&&void 0!==s?s:this._source.y,this._renderer}}var di=i(72739);const ui={backgroundColor:(0,Lt.generateColor)(l.colorsPalette["color-tv-blue-500"],70),borderColor:(0,Lt.generateColor)(l.colorsPalette["color-tv-blue-500"],20)};class pi{constructor(e){this._renderer=new di.RectangleRenderer,this._rectangle=null,this._crosshair=e}update(){const e=this._crosshair.selection();null!==e&&null!==this._crosshair.pane?this._rectangle=this._crosshair.pane.logicalRectToPixels(e):this._rectangle=null}renderer(e,t){if(!this._rectangle)return null;const i={backcolor:ui.backgroundColor,color:ui.borderColor,fillBackground:!0,linewidth:1,points:[this._rectangle.min,this._rectangle.max],extendLeft:!1,extendRight:!1} +;return this._renderer.setData(i),this._renderer}}var _i=i(38223),mi=i(57322),gi=i(2043),fi=i(98596),vi=i(99031),Si=i(80657),yi=i(19266),bi=i(73436);const wi=c.t(null,void 0,i(33355)),Pi=c.t(null,{context:"study"},i(32819)),Ci=new ye.PercentageFormatter,xi=new gi.TimeSpanFormatter,Ti=new fi.VolumeFormatter,Ii=(0,l.getHexColorByName)("color-tv-blue-500"),Mi=(0,l.getHexColorByName)("color-ripe-red-400"),Li={bgColorPositive:(0,Lt.generateColor)(Ii,80),bgColorNegative:(0,Lt.generateColor)(Mi,80),colorPositive:(0,l.getHexColorByName)("color-tv-blue-600"),colorNegative:(0,l.getHexColorByName)("color-ripe-red-400"),labelBgColorPositive:Ii,labelBgColorNegative:Mi};class Ai{constructor(e,t){this._pipFormatter=null,this._lastSymbolInfo=null,this._horzTrenRenderer=new vi.TrendLineRenderer,this._vertTrenRenderer=new vi.TrendLineRenderer,this._bgRenderer=new di.RectangleRenderer,this._labelRenderer=new Si.TextRenderer,this._p1=null,this._p2=null,this._label=null,this._source=e,this._pane=t}update(e){var t,i;const[s,r]=this._source.measurePoints();if(void 0===r)return this._p1=null,void(this._p2=null);const a=(0,n.ensureNotNull)(this._source.measurePane().value()),l=s.price,c=r.price,h=r.index-s.index,d=(0,_i.forceLTRStr)(""+h),u=(0,n.ensureNotNull)(a.mainDataSource()),p=(0,n.ensureNotNull)(u.formatter()),_=r.price-l;let m=null!==(i=null===(t=p.formatChange)||void 0===t?void 0:t.call(p,r.price,l))&&void 0!==i?i:p.format(_);if(Math.abs(l)>1e-8){const e=_/Math.abs(l);m+=" ("+Ci.format(100*e)+")"}const g=(0,_i.forceLTRStr)(m);this._label=g+"\n"+wi.format({count:d});const f=(0,n.ensureNotNull)(u.firstValue()),v=this._source.model().timeScale().indexToCoordinate(s.index),S=this._source.model().timeScale().indexToCoordinate(r.index),y=a.defaultPriceScale().priceToCoordinate(l,f),b=a.defaultPriceScale().priceToCoordinate(c,f);this._p1=new o.Point(v,y),this._p2=new o.Point(S,b);const w=this._source.model().timeScale().indexToUserTime(s.index),P=this._source.model().timeScale().indexToUserTime(r.index);let C=null;if(null!==w&&null!==P){const e=this._pane.model().mainSeries().symbolInfo();null!==e&&e!==this._lastSymbolInfo&&(this._pipFormatter=new mi.PipFormatter(e.pricescale,e.minmov,e.type,e.minmove2,e.typespecs),this._lastSymbolInfo=e),C=(P.valueOf()-w.valueOf())/1e3}const x=this._pipFormatter?this._pipFormatter.format(_):null,T=null!==x?" , "+x:"",I=null!==C?xi.format(C):null,M=null!==I?", "+(0,_i.startWithLTR)(I):"";this._label=(0,_i.forceLTRStr)(g+T)+"\n"+wi.format({count:d})+M;const L=this._source.measureVolume();Number.isNaN(L)||(this._label+=`\n${Pi} ${Ti.format(L)}`);const k=c=50?bi.LineEnd.Arrow:bi.LineEnd.Normal};this._horzTrenRenderer.setData(s)}{const e=Math.round(B.x),t=new o.Point(e,this._p1.y),i=new o.Point(e,this._p2.y),s={points:[t,i],color:D,linewidth:1,linestyle:ri.LINESTYLE_SOLID,extendleft:!1,extendright:!1,leftend:bi.LineEnd.Normal,rightend:Math.abs(t.y-i.y)>=50?bi.LineEnd.Arrow:bi.LineEnd.Normal};this._vertTrenRenderer.setData(s)}const R={x:0,y:10},N=.5*(this._p1.x+this._p2.x),O=this._p2.y,F=new o.Point(N,O),W=(H=(0,n.ensureNotNull)(this._label),{points:[F],text:H,color:"#FFFFFF",horzAlign:"center",vertAlign:"middle",font:A.CHART_FONT_FAMILY,offsetX:R.x,offsetY:R.y,bold:!1,italic:!1,fontsize:12,padding:8,highlightBorder:!1,backgroundColor:E,backgroundTransparency:10,backgroundVertInflate:5,backgroundHorzInflate:5,backgroundRoundRect:4});var H;this._labelRenderer.setData(W);const z=this._labelRenderer.measure(),U=(0,Si.calculateLabelPosition)(z,this._p1,this._p2,R,this._pane.height());this._labelRenderer.setPoints([U])}renderer(){if(null===this._p1||null===this._p2)return null;const e=new yi.CompositeRenderer;return e.append(this._bgRenderer),e.append(this._horzTrenRenderer),e.append(this._vertTrenRenderer),e.append(this._labelRenderer),e}}var ki=i(15187);class Di extends ki.MediaCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){return null}_drawImpl(e){const t=e.context;t.translate(this._data.x-this._data.width/2,this._data.y-this._data.height/2),t.strokeStyle="rgba(153,153,153,.3)",t.lineWidth=2,t.beginPath(),this._drawShackle(t),t.stroke(),t.closePath(),t.strokeStyle="rgba(153,153,153,.7)",t.lineWidth=1,t.beginPath(),t.rect(0,this._data.height-this._data.bodyHeight+.5,this._data.width,this._data.bodyHeight),t.closePath(),t.stroke(),t.translate(0,-1),t.strokeStyle="#777",t.beginPath(),this._drawShackle(t),t.stroke(),t.closePath(),t.fillStyle="rgba(255,255,255,.7)",t.beginPath(),t.rect(1,this._data.height-this._data.bodyHeight+1.5,this._data.width-2,this._data.bodyHeight-2),t.fill(),t.beginPath(),t.rect(.5,this._data.height-this._data.bodyHeight+1,this._data.width-1,this._data.bodyHeight-1),t.stroke(),t.closePath(),t.fillStyle="#777",t.fillRect(this._data.width/2-.5,this._data.height-this._data.bodyHeight/2,1,2)}_drawShackle(e){const t=(this._data.width-3)/2,i=this._data.height-this._data.bodyHeight;e.moveTo(1.5,t),e.arc(this._data.width/2,t,t,Math.PI,2*Math.PI),i>t&&(e.moveTo(1.5,t),e.lineTo(1.5,i),e.moveTo(this._data.width-1.5,t),e.lineTo(this._data.width-1.5,i))}}class Ei{constructor(e,t,i){this._horzVisible=!1,this._source=e,this._pane=t,this._axis=i||"x"}update(){}renderer(e,t){var i;const s=this._source.visible&&this._source.areLinesVisible,r=0===(null===(i=Se.crosshairLock.value())||void 0===i?void 0:i.type),o=s&&this._horzVisible,a=s||r;if("y"===this._axis&&!o||!a)return null;const l="y"===this._axis?this._pane.width()-4.5:(0,n.ensureNotNull)(this._source.lockedX())+1,c="y"===this._axis?this._source.y:this._pane.height()-5.5-1;return new Di({x:l,y:c,width:9, +height:11,bodyHeight:7})}}var Vi=i(49483),Bi=i(93835),Ri=i(88546);class Ni extends Bi.DataWindowView{constructor(e){super(),this._invalidated=!0,this._dateItem=new Bi.DataWindowItem("",c.t(null,void 0,i(76912)),""),this._timeItem=new Bi.DataWindowItem("",c.t(null,void 0,i(31976)),""),this._model=e,this._items.push(this._dateItem),this._items.push(this._timeItem)}update(){this._invalidated=!0}items(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._items}_updateImpl(){const e=this._model.mainSeries().isDWM();if(this._timeItem.setVisible(!e),this._timeItem.setValue(Ri.notAvailable),this._dateItem.setValue(Ri.notAvailable),this._model.timeScale().isEmpty())return;let t=this._model.crossHairSource().appliedIndex();if(!(0,Bt.isNumber)(t)){const e=this._model.mainSeries().data().last();if(null===e)return;t=e.index}const i=this._model.timeScale().indexToUserTime(t);null!==i&&(this._dateItem.setValue(this._model.dateFormatter().format(i)),e||this._timeItem.setValue(this._model.timeFormatter().format(i)))}}var Oi=i(34951);const Fi=l.colorsPalette["color-tv-blue-500"],Wi=c.t(null,{context:"Replay"},i(20747));class Hi extends Oi.TimeAxisView{constructor(e,t,i,s=!1){super(e),this._indexProvider=i,this._highlighted=s,this._source=t,this._properties=e.properties().childs().scalesProperties}_getText(e){if(this._source.isReplaySelection()){const t=this._model.timeScale().indexToUserTime(e);return null!==t?`${Wi}: ${this._model.dateTimeFormatter().format(t)}`:""}return super._getText(e)}_getBgColor(){if(this._source.isReplaySelection())return Fi;const e=this._properties.childs();return this._highlighted?e.axisLineToolLabelBackgroundColorCommon.value():this._model.dark().value()?e.crosshairLabelBgColorDark.value():e.crosshairLabelBgColorLight.value()}_getIndex(){return this._model.crossHairSource().visible||null!==this._source.lockedPane()?this._indexProvider():null}_isVisible(){return this._properties.childs().showTimeScaleCrosshairLabel.value()}}var zi=i(96280),Ui=i(94025);const ji={menuEnabled:!1,menuForMainSourceOnly:!1,disableTradingMenuActions:!1,disableDrawHorizLineMenuAction:!1};let Gi=0;const qi=(0,X.getLogger)("Chart.Crosshair");class $i extends zt.DataSource{constructor(e,t,i){super(),this.pane=null,this.price=NaN,this.index=NaN,this.visible=!0,this.areLinesVisible=!0,this.x=NaN,this.y=NaN,this._lockData=null,this._measurePane=new q.WatchedValue(null),this._measurePaneViewCache=new WeakMap,this._startMeasurePoint=null,this._endMeasurePoint=null,this._lastValidMeasurePoint=null,this._isOnHoveredChartWidget=!1,this._crossHairSelectPointMode=new q.WatchedValue(Se.SelectPointMode.None),this._selectionPane=null,this._selectionView=new pi(this),this._selectionStartPoint=null,this._timeLockPaneView=null,this._crosshairPaneViewCache=new WeakMap,this._pointSelectionPaneViewCache=new WeakMap,this._priceAxisViews=new Map,this._panePriceAxisViews=new Map,this._startMeasurePriceAxisViews=new Map,this._endMeasurePriceAxisViews=new Map,this._originX=NaN,this._originY=NaN,this._subscribed=!1, +this._movedDelegate=new G.Delegate,this._pointSelectedDelegate=new G.Delegate,this._requestedPoint=null,this._paneForRequestedPoint=null,this._selectLineColor=null,this._volumeCalculator=null,this._selectFromAllChartsIfOutOfData=null,this._currentMeasurePointsetAndSymbolId=null,this._model=e,this._options=Object.assign({},ji,i||{}),this._linesShouldBeHidden=this._model.readOnly(),this._dataWindowView=new Ni(e),this.setSelectionEnabled(!1);const s=e=>t=>t===(0,n.ensureNotNull)(this._measurePane.value()).defaultPriceScale()?e():null;this._currentPosPriceProvider=e=>{const t=(0,n.ensureNotNull)(this.pane);if(e===t.defaultPriceScale())return this.price;const i=(0,n.ensureNotNull)(t.defaultPriceScale().mainSource()).firstValue();if(null===i)return null;const s=t.defaultPriceScale().priceToCoordinate(this.price,i),r=(0,n.ensureNotNull)(e.mainSource()).firstValue();return null===r?null:e.coordinateToPrice(s,r)},this._startMeasurePriceProvider=s((()=>(0,n.ensureNotNull)(this._startMeasurePoint).price)),this._endMeasurePriceProvider=s((()=>(0,n.ensureNotNull)(this._lastMeasurePoint()).price)),this._properties=t;this._timeAxisView=new Hi(e,this,(()=>this.appliedIndex()),!1),this._startMeasureTimeAxisView=new Hi(e,this,(()=>(0,n.ensureNotNull)(this._startMeasurePoint).index),!0),this._endMeasureTimeAxisView=new Hi(e,this,(()=>(0,n.ensureNotNull)(this._lastMeasurePoint()).index),!0),e.readOnly()||Se.cursorTool.subscribe((e=>this.areLinesVisible="arrow"!==e),{callWithLast:!0}),this._crosshairLock=Se.crosshairLock.spawn(),this._showPlusButtonOnCursor=ei.showPlusButtonOnCursor.spawn();const r=()=>{this.updateAllViews((0,W.sourceChangeEvent)(this.id())),this._model.lightUpdate()};this._crosshairLock.subscribe(r),this._showPlusButtonOnCursor.subscribe(r)}destroy(){null!==this._volumeCalculator&&this._volumeCalculator.destroy(),this._measurePane.setValue(null),this._crosshairLock.destroy(),this._showPlusButtonOnCursor.destroy(),this._removeMeasurePointset()}name(){return"Crosshair"}moved(){return this._movedDelegate}originX(){return this._originX}originY(){return this._originY}saveOriginCoords(e,t){this._originX=e,this._originY=t}clearOriginCoords(){this._originX=NaN,this._originY=NaN}currentPoint(){return new o.Point(this.x,this.y)}model(){return this._model}appliedIndex(){var e;return null!==(e=this._getLockData().index)&&void 0!==e?e:this.index}lockedX(){var e;return null!==(e=this._getLockData().xCoord)&&void 0!==e?e:null}lockedY(){var e;return null!==(e=this._getLockData().yCoord)&&void 0!==e?e:null}lockedPane(){const e=Se.crosshairLock.value();return null===e||1!==e.type?null:this._model.id()===e.modelId?this._model.paneForId(e.paneId):this._model.mainPane()}invalidateLockPosition(){this._lockData=null}startMeasurePoint(){return this._startMeasurePoint||null}endMeasurePoint(){return this._endMeasurePoint||null}measureVolume(){if(null===this._volumeCalculator)return NaN;const[e,t]=this.measurePoints();return void 0===t?NaN:this._volumeCalculator.volume(e.index,t.index)}measurePane(){return this._measurePane.readonly()} +startMeasuring(e,t){this._startMeasurePoint=e,this._measurePane.setValue(t),t.containsMainSeries()&&((0,n.assert)(null===this._volumeCalculator),this._volumeCalculator=new zi.SeriesTimeRangeVolumeCalculator(this.model().mainSeries())),this._model.updatePane(t)}finishMeasure(e){this._endMeasurePoint=e,this._createMeasurePointset((0,n.ensureNotNull)(this._startMeasurePoint),this._endMeasurePoint)}clearMeasure(){this._removeMeasurePointset(),this._measurePane.setValue(null),delete this._startMeasurePoint,delete this._endMeasurePoint,delete this._lastValidMeasurePoint,this._model.lightUpdate(),null!==this._volumeCalculator&&(this._volumeCalculator.destroy(),this._volumeCalculator=null)}measurePoints(){const e=[(0,n.ensureNotNull)(this._startMeasurePoint)],t=this._lastMeasurePoint();return null!==t&&e.push(t),e}startSelection(e){this._selectionStartPoint=this.currentLogicalPoint(),this._selectionPane=e}clearSelection(){this._selectionStartPoint=null,this._selectionPane=null}selection(){return this._selectionStartPoint?{p1:this._selectionStartPoint,p2:this.currentLogicalPoint()}:null}currentLogicalPoint(){return{index:this.appliedIndex(),price:this.price}}selectPointMode(){return this._crossHairSelectPointMode}lineColor(){return this._selectLineColor}cancelRequestSelectPoint(){this._crossHairSelectPointMode.value()!==Se.SelectPointMode.None&&this._setSelectPointModeState(Se.SelectPointMode.None),this._selectFromAllChartsIfOutOfData=null}requestSelectPoint(e){(0,n.assert)(this._crossHairSelectPointMode.value()===Se.SelectPointMode.None,"Point already requested");const{pointType:t,pane:i,lineColor:s=null,selectFromAllChartsIfOutOfData:r,selectPointMode:o=Se.SelectPointMode.Study}=e;i&&((0,n.assert)(-1!==this._model.panes().indexOf(i),"Chartmodel doesn't contains specified pane"),this._paneForRequestedPoint=i,this._model.panesCollectionChanged().subscribe(this,this._paneCollectionChanged)),this._selectLineColor=s,this._requestedPoint=t,this._selectFromAllChartsIfOutOfData=null!=r?r:null,this._setSelectPointModeState(o)}onPointSelected(){return this._pointSelectedDelegate}trySelectCurrentPoint(){var e;const t=(0,n.ensureNotNull)(this._requestedPoint);let i=null;if(!this._model.mainSeries().bars().search(this.index,dt.PlotRowSearchMode.Exact)&&"price"!==t&&(this._selectFromAllChartsIfOutOfData&&(i=null!==(e=Math.min(...Array.from(Se.barTimesUnderCursor.values())))&&void 0!==e?e:null),null===i))return;const s=(0,n.ensureNotNull)(this.pane);if(this._paneForRequestedPoint&&this._paneForRequestedPoint!==s)return;let r,o=i;if("price"===t||null!==i||(o=this._model.timeScale().indexToTimePoint(this.index),null!==o)){if("time"!==t){const e=s.mainDataSource();if(null===e)return;const t=e.firstValue(),i=e.priceScale();if(null===t||null===i)return;r=i.coordinateToPrice(this.y,t)}this._setSelectPointModeState(Se.SelectPointMode.None),this._pointSelectedDelegate.fire({time:null!=o?o:void 0,price:r},s)}}isOnHoveredChartWidget(){return this._isOnHoveredChartWidget}setOnHoveredChartWidget(e){this._isOnHoveredChartWidget=e}isReplaySelection(){ +return!1}clearPosition(){this.visible=!1,this.index=NaN,this.price=NaN,this.x=NaN,this.y=NaN,this.pane=null,this.clearOriginCoords(),this._updateVisibilityDependentPaneViews()}setPosition(e,t,i){this._subscribed||(this._model.mainSeries().onRestarted().subscribe(this,this.clearMeasure),this._subscribed=!0),this.visible=!0;const s=this._model.id(),r=this._model.mainSeries().bars().search(this.index,dt.PlotRowSearchMode.NearestRight);return r&&Se.barTimesUnderCursor.set(s,r.value[0]),this._tryToUpdateViews(e,t,i)}setLinesShouldBeHidden(e){this._linesShouldBeHidden=e}linesShouldBeHidden(){return this._linesShouldBeHidden}handleContextMenuEvent(e){this._crossHairSelectPointMode.value()!==Se.SelectPointMode.None&&this._setSelectPointModeState(Se.SelectPointMode.None)}properties(){return this._properties}priceAxisViews(e,t){var i;const s=null===this._requestedPoint||"time"!==this._requestedPoint||!this._isOnHoveredChartWidget,r=[];return(null!==(i=this.lockedPane())&&void 0!==i?i:this.pane)===e&&s&&r.push(this._createPriceAxisViewOnDemand(this._priceAxisViews,this._panePriceAxisViews,e,t,this._currentPosPriceProvider,Zt,!0)[0]),this._startMeasurePoint&&r.push(this._createPriceAxisViewOnDemand(this._startMeasurePriceAxisViews,null,e,t,this._startMeasurePriceProvider,Xt)[0]),this._lastMeasurePoint()&&r.push(this._createPriceAxisViewOnDemand(this._endMeasurePriceAxisViews,null,e,t,this._endMeasurePriceProvider,Xt)[0]),r}timeAxisViews(){const e=[],t=null===this._requestedPoint||"price"!==this._requestedPoint||!this._isOnHoveredChartWidget;return this._linesShouldBeHidden||!this.visible&&null===Se.crosshairLock.value()||!t||e.push(this._timeAxisView),this._startMeasurePoint&&e.push(this._startMeasureTimeAxisView),this._lastMeasurePoint()&&e.push(this._endMeasureTimeAxisView),e}paneViews(e){var t,i;if(void 0===e)return null;const s=[];if(this.isReplaySelection()){let t=this._pointSelectionPaneViewCache.get(e);t||(t=new CrosshairPointSelectionPaneView(this,e,this._model),this._pointSelectionPaneViewCache.set(e,t)),s.push(t)}let r=this._crosshairPaneViewCache.get(e);if(r||(r=new hi(this,e),this._crosshairPaneViewCache.set(e,r)),s.push(r),e===this._selectionPane&&s.push(this._selectionView),e===this._measurePane.value()){let t=this._measurePaneViewCache.get(e);t||(t=new Ai(this,e),this._measurePaneViewCache.set(e,t)),t.update((0,W.sourceChangeEvent)(this.id())),s.push(t)}if((ei.addPlusButtonProperty.value()||this._showPlusButtonOnCursor.value())&&1!==(null===(t=Se.crosshairLock.value())||void 0===t?void 0:t.type)){const t=e===this.pane,i=!Vi.CheckMobile.any()||window.screen.width>=320,r=Se.tool.value(),n=(0,he.isLineToolName)(r),o=null!==this._model.lineBeingEdited()||null!==this._model.lineBeingCreated()||this._model.sourcesBeingMoved().length>0||null!==this._model.customSourceBeingMoved()||(0,Se.toolIsMeasure)(r);if(t&&this._isOnHoveredChartWidget&&this._crossHairSelectPointMode.value()===Se.SelectPointMode.None&&i&&!n&&!o){const t=e.mainDataSource();if(null!==t){const i=t.priceScale();if(null!==i){ +const t=this._createPriceAxisViewOnDemand(this._priceAxisViews,this._panePriceAxisViews,e,i,this._currentPosPriceProvider,Zt,!0)[1];null!==t&&s.push(t)}}}}return 0===(null===(i=Se.crosshairLock.value())||void 0===i?void 0:i.type)&&(null===this._timeLockPaneView&&(this._timeLockPaneView=new Ei(this,e)),s.push(this._timeLockPaneView)),s}dataWindowView(){return this._dataWindowView}updateAllViews(e){this._priceAxisViews.forEach((t=>{t.forEach((t=>t.update(e)))})),this._panePriceAxisViews.forEach((t=>{t.forEach((t=>t.update(e)))})),this._startMeasurePoint&&(this._startMeasurePriceAxisViews.forEach((t=>{t.forEach((t=>t.update(e)))})),this._startMeasureTimeAxisView.update(e)),this._lastMeasurePoint()&&(this._endMeasurePriceAxisViews.forEach((t=>{t.forEach((t=>t.update(e)))})),this._endMeasureTimeAxisView.update(e)),this._timeAxisView.update(e),this._selectionView.update(),this._dataWindowView.update(),this._updateVisibilityDependentPaneViews()}isMenuEnabled(){return!0}isHoveredEnabled(){return ei.addPlusButtonProperty.value()||this._showPlusButtonOnCursor.value()}isHovered(){return this._model.hoveredSource()===this}pointToSelect(){return this._requestedPoint}paneForPointSelect(){return this._paneForRequestedPoint}_lastMeasurePoint(){return this._endMeasurePoint?this._endMeasurePoint:(null!==this.pane&&this._measurePane.value()===this.pane&&(this._lastValidMeasurePoint={price:this._model.magnet().align(this.price,this.index,this.pane),index:this.index}),this._lastValidMeasurePoint||null)}_createPriceAxisViewOnDemand(e,t,i,s,r,o,a=!1){let l=e.get(i),c=null!==t?t.get(i):void 0;void 0===l&&(l=new Map,e.set(i,l),this.isMenuEnabled()&&null!==t&&(c=new Map,t.set(i,c)),a&&i.onDestroyed().subscribe(this,(()=>this._onPaneDestroyed(i))));let h=l.get(s);if(void 0===h){if(h=new o(this,i,s,r),l.set(s,h),void 0!==c){const e=new si(h,this,s,this._model,this._options);c.set(s,e)}a&&s.lastSourceRemoved().subscribe(this,(()=>this._onPriceScaleCleared(s)))}let d=null;return void 0!==c&&(d=(0,n.ensureDefined)(c.get(s))),[h,d]}_onPaneDestroyed(e){e.onDestroyed().unsubscribeAll(this),this._priceAxisViews.delete(e),this._panePriceAxisViews.delete(e),this._startMeasurePriceAxisViews.delete(e),this._endMeasurePriceAxisViews.delete(e)}_onPriceScaleCleared(e){e.lastSourceRemoved().unsubscribeAll(this),this._priceAxisViews.forEach((t=>t.delete(e))),this._panePriceAxisViews.forEach((t=>t.delete(e))),this._startMeasurePriceAxisViews.forEach((t=>t.delete(e))),this._endMeasurePriceAxisViews.forEach((t=>t.delete(e)))}_tryToUpdateViews(e,t,i){return!!this._tryToUpdateData(e,t,i)&&(this.updateAllViews((0,W.sourceChangeEvent)(this.id())),this._movedDelegate.fire({index:this.index,price:this.price}),!0)}_tryToUpdateData(e,t,i){const s=this.x,r=this.y,o=this.price,a=this.index,l=this.pane,c=this._priceScaleByPane(i);if(this.index=e,this.x=isNaN(e)?NaN:this._model.timeScale().indexToCoordinate(e),null!==c&&null!==i){this.pane=i,this.price=t;const e=(0,n.ensureNotNull)(i.mainDataSource()).firstValue();this.y=null===e?NaN:c.priceToCoordinate(t,e) +}else this.pane=null,this.price=NaN,this.y=NaN;return s!==this.x||r!==this.y||a!==this.index||o!==this.price||l!==this.pane}_priceScaleByPane(e){return e&&!e.defaultPriceScale().isEmpty()?e.defaultPriceScale():null}_setSelectPointModeState(e){e===Se.SelectPointMode.None&&(this._requestedPoint=null,this._selectLineColor=null,this._paneForRequestedPoint&&(this._paneForRequestedPoint=null,this._model.panesCollectionChanged().unsubscribe(this,this._paneCollectionChanged))),Se.activePointSelectionMode.setValue(e),this._crossHairSelectPointMode.setValue(e),this._model.lightUpdate()}_paneCollectionChanged(e){const t=this._paneForRequestedPoint;null!==t&&-1===e.indexOf(t)&&this.cancelRequestSelectPoint()}_updateVisibilityDependentPaneViews(){var e;for(const t of this.model().panes())null===(e=this._pointSelectionPaneViewCache.get(t))||void 0===e||e.update()}_getLockData(){var e;if(null===this._lockData){const t=Se.crosshairLock.value();if(null===t)this._lockData={};else{const i=this._model.timeScale(),s=null!==(e=i.points().roughIndex(t.time))&&void 0!==e?e:void 0,r=void 0===s?void 0:i.indexToCoordinate(s);switch(t.type){case 0:this._lockData={index:s,xCoord:r};break;case 1:{let e;const i=this.lockedPane();if(null!==i){const s=i.mainDataSource();if(null!==s){const i=s.firstValue(),r=s.priceScale();null!==r&&null!==i&&(e=r.priceToCoordinate(t.price,i))}}this._lockData={index:s,xCoord:r,yCoord:e}}}}}return this._lockData}_createMeasurePointset(e,t){const i=this._normalizePoint(e),s=this._normalizePoint(t),r=[[i.time_t,i.offset],[s.time_t,s.offset]];this._removeMeasurePointset(),++Gi,this._currentMeasurePointsetAndSymbolId={measurePointsetId:Gi,symbolId:(0,n.ensureNotNull)(this._model.mainSeries().seriesSource().symbolInstanceId())};const o=(0,Ui.getServerInterval)(this._model.mainSeries().interval());this._model.chartApi().createPointset(this._currentMeasurePointsetIdWithPrefix(),"turnaround",this._currentMeasurePointsetAndSymbolId.symbolId,o,r,this._onPointsetResponse.bind(this))}_removeMeasurePointset(){null!==this._currentMeasurePointsetAndSymbolId&&this._model.chartApi().isConnected().value()&&this._model.chartApi().removePointset(this._currentMeasurePointsetIdWithPrefix()),this._currentMeasurePointsetAndSymbolId=null}_currentMeasurePointsetIdWithPrefix(){return"pointsetMeasure_"+(0,n.ensureNotNull)(this._currentMeasurePointsetAndSymbolId).measurePointsetId}_normalizePoint(e){return{...this._model.timeScale().normalizeBarIndex(e.index),price:e.price}}_onPointsetResponse(e){if("pointset_error"===e.method)return void qi.logError(`Error getting pointset: ${e.params[0]} ${e.params[1]}`);if(e.params.customId!==this._currentMeasurePointsetIdWithPrefix())return;if(null===this._startMeasurePoint||null===this._endMeasurePoint)return;const t=e.params.plots;if(2!==t.length)return;const i=t[0].value[0],s=t[1].value[0];this._startMeasurePoint.index=i,this._endMeasurePoint.index=s,this.updateAllViews((0,W.sourceChangeEvent)(this.id())),this._model.updateSource(this)}} +var Yi=i(50146),Ki=i(12416),Zi=i(17236),Xi=i(39262),Ji=i(26426),Qi=i(56840);class es{constructor(e){this._priceSourceNamesById=new Map,e.forEach((e=>this._priceSourceNamesById.set(e.id,e.name)))}name(e){var t;return null!==(t=this._priceSourceNamesById.get(e))&&void 0!==t?t:null}priceSourcesChanged(e){return e.length!==this._priceSourceNamesById.size}}var ts=i(97906),is=i(90194);const ss=new ee.TranslatedString("remove deselected empty line tools",c.t(null,void 0,i(59211))),rs=N.enabled("auto_enable_symbol_labels"),ns=(0,X.getLogger)("Chart.ChartModel");function os(e,t){const i=e.indexOf(t);return-1!==i&&(e.splice(i,1),!0)}function as(e){var t,i;for(let s=e.length;s--;){const r=e[s].dataSources();for(let e=r.length;e--;)null===(t=r[e].dataWindowView())||void 0===t||t.update();const n=e[s].priceDataSources();for(let e=n.length;e--;)null===(i=n[e].legendView())||void 0===i||i.update()}}const ls={isSnapshot:!1,readOnly:!1,watermarkEnabled:!0,shiftVisibleRangeOnNewBar:!0,currencyConversionEnabled:!1,unitConversionEnabled:!1,countdownEnabled:!0,lastPriceAnimationEnabled:!0,onWidget:!1,hideIdeas:!1};class cs{constructor(e,t,i,r,n,o,a,l,c,d,u){this._onRearrangePanes=new G.Delegate,this._lineToolsGroupModel=new bt,this._sourcesBeingMoved=[],this._activeItemBeingMoved=null,this._lineBeingEdited=null,this._linePointBeingEdited=null,this._linePointBeingChanged=null,this._customSourceBeingMovedHitTestData=null,this._customSourceBeingMoved=null,this._dataSourceCollectionChanged=new G.Delegate,this._sourceProperitesChanged=new G.Delegate,this._sourceZOrderChanged=new G.Delegate,this._symbolSourceResolved=new G.Delegate,this._symbolSourceResolvingActive=new q.WatchedValue(!1),this._adjustForDividendsAvailability=new q.WatchedValue(0),this._adjustForDividendsEnabled=new q.WatchedValue(!1),this._sessions=null,this._currentTool="",this._lineBeingCreated=null,this._paneBeingCreatedLineOn=null,this._lineCancelled=new G.Delegate,this._phantomSourceContainer=new Rt(this),this._destroyed=!1,this._isSettingsExternalPosition=!1,this._isTimeScrolling=!1,this._magnet=new Wt,this._scrollingState=null,this._modelIntervals=[],this._rendererOptionsProvider=new k(this),this._studyInserted=new G.Delegate,this._cachedStudiesMaxOffset=0,this._replayStatus=new q.WatchedValue(wt.ReplayStatus.Undefined),this._panes=[],this._tagsChanged=new G.Delegate,this._strategySources=[],this._strategySourcesChange=new G.Delegate,this._activeStrategySource=new q.WatchedValue(null),this._paneCollapsingAvailable=new q.WatchedValue(!1),this._panesCollectionChanged=new G.Delegate,this._scrollEnabled=N.enabled("chart_scroll"),this._zoomEnabled=N.enabled("chart_zoom"),this._lollipopSourcesWatcher=null,this._alertsWatcher=null,this._hoveredSource=null,this._hoveredSourceChanged=new G.Delegate,this._lastHoveredHittestData=null,this._lastSelectedHittestData=null,this._topmostCustomSources=[],this._fgCustomSources=[],this._bgCustomSources=[],this._allCustomSources=[],this._customSourcesMap=new Map,this._multiPaneSources=[],this._showLegendProperty=new(M()),this._id=(0, +J.guid)(),this._chartSaveTime=null,this._availableCurrenciesList=null,this._availableCurrencies=new Et([]),this._availablePriceSources=new es([]),this._availableUnitsObject=null,this._availableUnits=new Vt({}),this._availablePriceSourcesList=null,this._shouldBeSavedEvenIfHidden=!1,this._watchedThemeSpawn=h.watchedTheme.spawn(),this._gradientColorsCache=null,this._studiesWV=new $.WatchedObject([],v.compareTwoCollectionsByIds),this._studiesExcludeInternalWV=new $.WatchedObject([],v.compareTwoCollectionsByIds),this._resetScalesAvailable=new q.WatchedValue(!1),this._recalcVRStudiesParams={},this._recalcColorStudiesParams={},this._recalcVisibleRangeStudiesImplDebounced=(0,s.default)(this._recalcVisibleRangeStudiesImpl.bind(this,this._recalcVRStudiesParams),500),this._recalcColorStudiesImplDebounced=(0,s.default)(this._recalcColorStudiesImpl.bind(this,this._recalcColorStudiesParams),250),this._width=0,this._resetScales=new G.Delegate,this._chartThemeLoaded=new G.Delegate,this._selection=new b,this._selectedSourceChanged=new G.Delegate,this._symbolSourceCollectionChanged=new G.Delegate,this._gridSource=new $t,this._syncPointCache=new Map,this._lastAppliedGotoTimeRange=null,this._lastGotoTimeRange=null,this._clearSelection=()=>{this._lastSelectedHittestData=null,this._selection.clear()},this._removeSourceFromSelection=e=>{this._selection.remove(e)},this._addSourceToSelection=(e,t)=>{const i=this._selection.isSelected(e);i&&this._lastSelectedHittestData===t||e&&!e.isSelectionEnabled()||(this._lastSelectedHittestData=t||null,i||this._selection.add(e))},this._recalcSymbolResolvingActive=()=>{for(const e of this._panes)if(e.symbolSourceResolvingActive().value())return void this._symbolSourceResolvingActive.setValue(!0);this._symbolSourceResolvingActive.setValue(!1)},this._recalcAdjustForDividendsAvailibility=()=>{var e,t,i,s;if(this._symbolSourceResolvingActive.value())return void this._adjustForDividendsAvailability.setValue(0);const r=this.mainSeries();switch(null!==(t=null===(e=r.symbolInfo())||void 0===e?void 0:e.allowed_adjustment)&&void 0!==t?t:"none"){case"dividends":return void this._adjustForDividendsAvailability.setValue(2);case"splits":return void this._adjustForDividendsAvailability.setValue(1);case"any":return void this._adjustForDividendsAvailability.setValue(3)}for(const e of this.symbolSources().filter(_e.isActingAsSymbolSource)){if(e.symbolHibernated().value()||e===r)continue;if("any"===(null!==(s=null===(i=e.symbolInfo())||void 0===i?void 0:i.allowed_adjustment)&&void 0!==s?s:"none"))return void this._adjustForDividendsAvailability.setValue(3)}this._adjustForDividendsAvailability.setValue(0)},this._recalcAdjustForDividendsEnabled=()=>{switch(this._adjustForDividendsAvailability.value()){case 2:return void this._adjustForDividendsEnabled.setValue(!0);case 0:case 1:return void this._adjustForDividendsEnabled.setValue(!1)}this._adjustForDividendsEnabled.setValue(this.mainSeries().properties().childs().dividendsAdjustment.value())},this._recalcPaneCollapsingAvailable=e=>{ +let t=this._panes.filter((e=>!e.collapsed().value())).length;0===t&&e&&this._panes.length>0&&(this._panes[0].collapsed().setValue(!1),t=1),this._paneCollapsingAvailable.setValue(t>1)},this._updateResetScalesAvailableValue=()=>{const e=this._timeScale.resetAvailable().value()||this._panes.some((e=>e.resetPriceScalesAvailable().value()));this._resetScalesAvailable.setValue(e)},this._chartApi=e,this._invalidateHandler=t,this._undoModel=o,this._properties=i,this._options=(0,ie.merge)((0,ie.clone)(ls),l),this._hibernateWV=c,this._linkingGroupIndex=d,this._isAutoSaveEnabled=u,this._studiesMetaInfoRepository=n,this._readOnly=this._options.readOnly,this._isSnapshot=this._options.isSnapshot,this._chartSaveTime=(new Date).valueOf(),this._backgroundColor=new q.WatchedValue(this._getBackgroundColor()),this._backgroundTopColor=new q.WatchedValue(this._getBackgroundColor(!0)),this._properties.childs().paneProperties.childs().background.subscribe(this,this._updateBackgroundColor),this._properties.childs().paneProperties.childs().backgroundType.subscribe(this,this._updateBackgroundColor),this._properties.childs().paneProperties.childs().backgroundGradientStartColor.subscribe(this,this._updateBackgroundColor),this._properties.childs().paneProperties.childs().backgroundGradientEndColor.subscribe(this,this._updateBackgroundColor),this._backgroundColor.subscribe(this.recalcColorStudies.bind(this,!1)),this._backgroundTopColor.subscribe(this.recalcColorStudies.bind(this,!1)),this._backgroundCounterColor=new q.WatchedValue(this._getBackgroundCounterColor()),this._backgroundColor.subscribe((()=>this._backgroundCounterColor.setValue(this._getBackgroundCounterColor()))),this._isDark=(0,ts.combine)((e=>"white"===e),this._backgroundCounterColor.weakReference()),this._watchedThemeSpawn.subscribe(this._updateBackgroundColor.bind(this)),this._symbolSourceResolvingActive.subscribe(this._recalcAdjustForDividendsAvailibility),this.setStudiesMetaData(this._studiesMetaInfoRepository.getInternalMetaInfoArray(),this._studiesMetaInfoRepository.getMigrations()),(0,Se.init)();const p=this._readOnly?new(M())((0,B.defaults)("chartproperties.paneProperties.crossHairProperties")):this._properties.childs().paneProperties.childs().crossHairProperties;this.m_crossHairSource=new $i(this,p,this._options.crossHair),this._crossHairSelectPointMode=this.m_crossHairSource.selectPointMode().spawn(),this._crossHairSelectPointMode.subscribe((e=>{if(e!==Se.SelectPointMode.None&&this.lineBeingCreated()){const e=Se.tool.value();this.cancelCreatingLine(),Se.tool.setValue(e)}})),this._tagsChanged=new G.Delegate;const _=new T.DefaultProperty("chartproperties.mainSeriesProperties");_.addExclusion("minTick"),_.addExclusion("priceAxisProperties.lockScale"),_.addExclusion("priceAxisProperties.percentage"),_.addExclusion("priceAxisProperties.indexedTo100"),_.addExclusion("priceAxisProperties.isInverted"),_.addExclusion("priceAxisProperties.log"),_.addExclusion("priceAxisProperties.logDisabled"),_.addExclusion("priceAxisProperties.percentageDisabled"), +_.addExclusion("priceAxisProperties.autoScaleDisabled"),_.merge(i.childs().mainSeriesProperties.state()),this._timeScale=new gt(this,this._options.timeScale),this._timeScale.resetAvailable().subscribe(this._updateResetScalesAvailableValue);const m={countdownEnabled:this._options.countdownEnabled,lastPriceAnimationEnabled:this._options.lastPriceAnimationEnabled};this.m_mainSeries=new pe.Series(this,_,m,r),this.m_mainSeries.onStyleChanged().subscribe(this._timeScale,this._timeScale.invalidateVisibleBars);const g=()=>this.fullUpdate();this.m_mainSeries.properties().childs().showCountdown.subscribe(this,(()=>{this.m_mainSeries.updateAllViews((0,W.sourceChangeEvent)(this.m_mainSeries.id())),g()})),(0,K.currencyUnitVisibilityProperty)().subscribe(this,g),(0,Z.autoLogButtonsVisibilityProperty)().subscribe(this,g),this._timeScale.visibleBarsStrictRangeChanged().subscribe(this.m_mainSeries,this.m_mainSeries.clearHighLowPriceCache),this._timeScale.visibleBarsStrictRangeChanged().subscribe(this.m_mainSeries,this.m_mainSeries.clearAveragePriceCache),this.createPane(void 0,{axisProperties:_.childs().priceAxisProperties.state(["autoScale"])}),this._adjustForDividendsAvailability.subscribe(this._recalcAdjustForDividendsEnabled),this.mainSeries().properties().childs().dividendsAdjustment.subscribe(this,this._recalcAdjustForDividendsEnabled),this._recalcAdjustForDividendsEnabled(),this._boundUpdateStudiesMaxOffset=this._updateStudiesMaxOffset.bind(this),this.mainSeries().dataEvents().seriesTimeFrame().subscribe(this,((e,t,i,s)=>{if(null!==this._lastAppliedGotoTimeRange&&null!==i&&s&&(0,Nt.areEqualTimeFrames)(this._lastAppliedGotoTimeRange.range,i)){const e=this.appliedTimeFrame().value();null!==e&&!this._lastAppliedGotoTimeRange.actual&&(0,Nt.areEqualTimeFrames)(this._lastAppliedGotoTimeRange.range,e.val)&&this.appliedTimeFrame().setValue(null),this._lastAppliedGotoTimeRange=null}})),this.mainSeries().dataEvents().completed().subscribe(this,(e=>{null===this._lastAppliedGotoTimeRange&&null!==this._lastGotoTimeRange&&(this.gotoTimeRange(this._lastGotoTimeRange.from,this._lastGotoTimeRange.to),this._lastGotoTimeRange=null)}));const f=this._panes[0];f.setStretchFactor(2*f.stretchFactor()),this._properties.listeners().subscribe(this,this.lightUpdate),this._properties.childs().timezone.subscribe(null,(()=>{this._chartApi&&this._chartApi.isConnected().value()&&this._chartApi.switchTimezone(this.timezone())})),f.addDataSource(this.m_mainSeries,f.findSuitableScale(this.m_mainSeries),!1),this._barsMarksSources=a(this);for(const e of this._barsMarksSources)e.setOwnerSource(this.m_mainSeries),f.addDataSource(e,this.m_mainSeries.priceScale(),!0);this.m_mainSeries.symbolResolved().subscribe(this,this._clearAvailablePriceSources)}setStudiesMetaData(e,t){this._studiesMetaData=e,this._studyVersioning=new w.StudyVersioning(this._studiesMetaData,t)}restart(){this._chartApi.switchTimezone(this.timezone()),this._timeScale.reset(),this.m_mainSeries.restart();for(const e of this.dataSources())e.restart&&e!==this.m_mainSeries&&e.restart() +;this.sessions().restart()}version(){return 3}collapsed(){return this._hibernateWV}chartSaveTime(){return this._chartSaveTime}setChartSaveTime(e){this._chartSaveTime=e}destroy(){this._phantomSourceContainer.destroy(),this._hoveredSourceChanged.destroy(),null!==this._watermarkSource&&(this._watermarkSource.destroy(),this._watermarkSource=null),Array.from(this._customSourcesMap.keys()).forEach(this._removeCustomSource,this),(0,n.assert)(0===this._topmostCustomSources.length),(0,n.assert)(0===this._fgCustomSources.length),(0,n.assert)(0===this._bgCustomSources.length),(0,n.assert)(0===this._allCustomSources.length),(0,n.assert)(0===this._customSourcesMap.size),null!==this._lollipopSourcesWatcher&&(this._lollipopSourcesWatcher.destroy(),this._lollipopSourcesWatcher=null),null!==this._alertsWatcher&&this._alertsWatcher.destroy(),this._properties.childs().paneProperties.childs().background.unsubscribeAll(this),this._properties.childs().paneProperties.childs().backgroundType.unsubscribeAll(this),this._properties.childs().paneProperties.childs().backgroundGradientEndColor.unsubscribeAll(this),this._properties.childs().paneProperties.childs().backgroundGradientStartColor.unsubscribeAll(this),this._watchedThemeSpawn.destroy(),this._lastHoveredHittestData=null,this._lastSelectedHittestData=null,(0,K.currencyUnitVisibilityProperty)().unsubscribeAll(this),(0,Z.autoLogButtonsVisibilityProperty)().unsubscribeAll(this),this._crossHairSelectPointMode.destroy(),this.m_mainSeries.symbolResolved().unsubscribe(this,this._clearAvailablePriceSources),this._destroyed=!0}undoModel(){return this._undoModel}onData(e){switch(e.method){case"timescale_update":{const t=e.params;this._updateTimeScale({index:t.index,zoffset:t.zoffset,values:t.changes,indexDiffs:t.index_diff,baseIndex:t.baseIndex,marks:t.marks,clearFlag:t.clear});break}case"timescale_completed":{const t=Boolean(e.params[0]);this._timeScale.onTimeScaleCompleted(t);break}}}addStrategySource(e,t){1!==t&&-1===this._strategySources.indexOf(e)&&(this._strategySources.push(e),this._strategySourcesChange.fire(t),this.setActiveStrategySource(e))}removeStrategySource(e,t){if(1===t)return;const i=this._strategySources.indexOf(e);if(-1!==i){if(this._strategySources.splice(i,1)[0]===this._activeStrategySource.value()&&this.unsetActiveStrategySource(),this._strategySources.length>0){const e=this._strategySources[this._strategySources.length-1];this.setActiveStrategySource(e)}this._strategySourcesChange.fire(t)}}setActiveStrategySource(e){-1!==this._strategySources.indexOf(e)&&this._activeStrategySource.setValue(e)}unsetActiveStrategySource(){this._activeStrategySource.setValue(null)}activeStrategySource(){return this._activeStrategySource}strategySources(){return this._strategySources}strategySourcesChange(){return this._strategySourcesChange}setScrollEnabled(e){this._scrollEnabled=e}scrollEnabled(){return this._scrollEnabled}setZoomEnabled(e){this._zoomEnabled=e}zoomEnabled(){return this._zoomEnabled}zoomToViewport(e,t,i,s,r){this.setTimeViewport(e,t);let n=Math.min(i,s),o=Math.max(i,s) +;const a=r.defaultPriceScale();a.isPercentage()||a.setMode({autoScale:!1}),a.isLog()&&(n=a.priceToLogical(n),o=a.priceToLogical(o)),a.setPriceRange(new de.PriceRange(n,o)),this.recalculateAllPanes((0,W.viewportChangeEvent)()),this.invalidate(this._paneInvalidationMask(r,Y.InvalidationLevel.Light))}setTimeViewport(e,t){const i=this.appliedTimeFrame().value();null!==this._lastAppliedGotoTimeRange&&null!==i&&(0,Nt.areEqualTimeFrames)(this._lastAppliedGotoTimeRange.range,i.val)&&!this._lastAppliedGotoTimeRange.actual||(this.timeScale().zoomToBarsRange(e,t),this.recalculateAllPanes((0,W.viewportChangeEvent)()),this.recalcVisibleRangeStudies(),this.lightUpdate())}onTagsChanged(){return this._tagsChanged}canZoomIn(){return this._timeScale.canZoomIn()&&this._zoomEnabled}canZoomOut(){return this._timeScale.canZoomOut()&&this._zoomEnabled}onPaneTagsChanged(){this._tagsChanged.fire()}panesCollectionChanged(){return this._panesCollectionChanged}dataSourceCollectionChanged(){return this._dataSourceCollectionChanged}symbolSourceCollectionChanged(){return this._symbolSourceCollectionChanged}symbolSourceResolved(){return this._symbolSourceResolved}symbolSourceResolvingActive(){return this._symbolSourceResolvingActive}adjustForDividendsAvailability(){return this._adjustForDividendsAvailability}adjustForDividendsEnabled(){return this._adjustForDividendsEnabled}paneCollapsingAvailable(){return this._paneCollapsingAvailable}sourcePropertiesChanged(){return this._sourceProperitesChanged}sourceZOrderChanged(){return this._sourceZOrderChanged}zoomTime(e,t,i){if(!this._zoomEnabled)return;const s=this.timeScale();if(s.isEmpty()||0===t)return;const r=s.width();e=Math.max(1,Math.min(e,r-2)),s.zoom(e,t,i),this.recalculateAllPanes((0,W.viewportChangeEvent)()),this.lightUpdate(),this.recalcVisibleRangeStudies()}lineBeingEdited(){return this._lineBeingEdited}linePointBeingEdited(){return this._linePointBeingEdited}activeItemBeingMoved(){return this._activeItemBeingMoved}linePointBeingChanged(){return this._linePointBeingChanged}updateAllPaneViews(e){for(const t of this._panes)t.updateAllViews(e)}dataSources(){const e=[this.crossHairSource()];for(const t of this._panes)for(const i of t.dataSources())e.push(i);return e}priceDataSources(){const e=[];for(const t of this._panes)for(const i of t.priceDataSources())e.push(i);return e}symbolSources(){const e=[];for(const t of this._panes)for(const i of t.symbolSources())e.push(i);return e}selection(){return this._selection}selectionMacro(e,t=!1){const i=this.selection().allSources();e({removeSourceFromSelection:this._removeSourceFromSelection,addSourceToSelection:this._addSourceToSelection,clearSelection:this._clearSelection,selection:this.selection.bind(this)});const s=(0,v.subtract)(i,this.selection().allSources()),r=(0,v.subtract)(this.selection().allSources(),i);r.concat(i).forEach((e=>e.updateAllViews((0,W.selectionChangeEvent)())));let n=[];s.forEach((e=>{if((0,S.isLineTool)(e)){const i=e.hasAlert.value()&&e.getAlertSync();i&&i.setSelected(!1),!t&&e.shouldBeRemovedOnDeselect()&&n.push(e)}})), +r.forEach((e=>{const t=(0,S.isLineTool)(e)&&e.hasAlert&&e.hasAlert.value()&&e.getAlertSync();t&&t.setSelected(!0)})),n=n.filter((e=>null!==this.dataSourceForId(e.id()))),n.length>0&&this._undoModel.removeSources(n,!1,ss),this.lightUpdate(),(s.length>0||r.length>0)&&this._selectedSourceChanged.fire()}onSelectedSourceChanged(){return this._selectedSourceChanged}checkLineToolSelection(){const e=this.selection().allSources();this._selection.checkLineToolSelection(),e.length!==this.selection().allSources().length&&this._selectedSourceChanged.fire()}lineToolsGroupModel(){return this._lineToolsGroupModel}restoreLineToolsGroups(e){this._lineToolsGroupModel=bt.fromState(this,e)}realignLineTools(e){for(const t of this._panes)(void 0===e||t.hasDataSource(e))&&t.realignLineTools(e)&&this._dataSourceCollectionChanged.fire(t)}copyToOtherCharts(e,t){const i=this.mainSeries(),s=i.syncModel(),r=this.timeScale();if(s)for(const o of e){if(!o.isSynchronizable())continue;const e=o.linkKey().value()||(0,J.randomHash)();o.linkKey().setValue(e);const a=o.state(!1),l=o.normalizedPoints(),c=o.properties().interval.value(),h=i.interval();let d;if(x.Interval.isEqual(c,h))d=l.map((e=>{const t=(0,n.ensureNotNull)(r.timePointToIndex(e.time_t))+e.offset;return{price:e.price,timeStamp:(0,n.ensureNotNull)(this.externalTimeStamp(t))}}));else{const e=s.createNewModelWithResolution(c);d=l.map((t=>({price:t.price,timeStamp:0===t.offset?t.time_t:e.projectTime(t.time_t,t.offset)})))}const u={...a,id:o.id(),linkKey:e,points:d,linetool:o.toolname,model:this,symbol:i.symbol(),withUndo:t,zOrder:o.zorder(),finalState:{points:l,interval:c},pointPositionPercents:o.isFixed()?o.calcPositionPercents():void 0,sharingMode:o.sharingMode().value()};(0,Se.copyLineTool)(u)}}isSnapshot(){return this._isSnapshot}onWidget(){return this._options.onWidget}hideIdeas(){return this._options.hideIdeas}updateSource(e){const t=this._invalidationMaskForSource(e);null!==t&&this.invalidate(t)}updateSourcePriceScale(e){const t=this._invalidationMaskForSourcePriceScale(e);null!==t&&this.invalidate(t)}updatePane(e){this.invalidate(this._paneInvalidationMask(e))}updateTimeScaleBaseIndex(e){const t=this.mainSeries().bars();t.isEmpty()||this._updateBaseIndex((0,n.ensureNotNull)(t.lastIndex()),!!(e&&e.index>0))}setInterval(e,t){const i=setInterval(e,t);return this._modelIntervals.push(i),i}clearInterval(e){clearInterval(e);const t=this._modelIntervals.indexOf(e);t>-1&&this._modelIntervals.splice(t,1)}clearIntervals(){for(let e=0;e{i.ownerSource()===e&&i.setOwnerSource(t)})),t.start(),this.recalculatePane(i,(0,W.sourceChangeEvent)(t.id())),this.fullUpdate(),!0}insertStudyStub(e){const t=this.mainSeries(),i=(0,n.ensureNotNull)(this.paneForSource(t)),s=new P.StudyStub(this,null,e),r=i.createPriceScaleAtPosition("overlay");return i.addDataSource(s,r,!1),this.recalculatePane(i,(0,W.sourceChangeEvent)(s.id())),this.fullUpdate(),s}removeStudyStub(e){const t=this.dataSourceForId(e);return null===t?(ns.logNormal("StudyStub id="+e+" is not found in chart model"),!1):(this.removeSource(t),!0)}allLineTools(){return this._getAllSources(S.isLineTool)}setHoveredSource(e,t=null){const i=this._hoveredSource!==e;if(!i&&this._lastHoveredHittestData===t)return;this._lastHoveredHittestData=t;let s=null;if(this._hoveredSource){this._hoveredSource.updateAllViews((0,W.selectionChangeEvent)()),s=new Y.InvalidationMask(Y.InvalidationLevel.Cursor);const e=this._invalidationMaskForSource(this._hoveredSource,Y.InvalidationLevel.Light);null!==e&&s.merge(e)}if(this._hoveredSource=e,e){e.updateAllViews((0,W.selectionChangeEvent)()),s||(s=new Y.InvalidationMask(Y.InvalidationLevel.Cursor)) +;const t=this._invalidationMaskForSource(e,Y.InvalidationLevel.Light);null!==t&&s.merge(t)}s&&this.invalidate(s),i&&this._hoveredSourceChanged.fire(e)}properties(){return this._properties}chartApi(){return this._chartApi}disconnect(){this.sessions().stop();for(const e of this.dataSources())e.disconnect&&e.disconnect();this._timeScale.disconnect()}crossHairSource(){return this.m_crossHairSource}gridSource(){return this._gridSource}publishedChartsTimelineSource(){return null}hoveredSource(){return this._hoveredSource}hoveredSourceChanged(){return this._hoveredSourceChanged}lastHittestData(){return this._lastHoveredHittestData}lastSelectedHittestData(){return this._lastSelectedHittestData}syncTimeWithModel(e,t){const i=this.mainSeries().syncModel();if(null===i)return;const s=1e3*this.createSyncPoint(e,i.syncSourceTarget()).sourceTimeToTargetTime(t/1e3),r=(0,Pt.get_timezone)(this.timezone());let n=(0,Pt.utc_to_cal)(r,s);this.mainSeries().isDWM()&&(n=i.getSession().spec.correctTradingDay(n),(0,Pt.set_hms)(n,0,0,0,0,(0,Pt.get_timezone)("Etc/UTC"))),this._gotoTimeImpl(n.getTime(),{centerIfVisible:!1})}gotoTime(e){return this._gotoTimeImpl(e,{centerIfVisible:!0})}recalculatePane(e,t){null==e||e.recalculate(t)}recalculateAllPanes(e){this._panes.forEach((t=>t.recalculate(e))),this.updateAllPaneViews(e),this.crossHairSource().updateAllViews(e)}gotoTimeRange(e,t){const i=this.timeScale(),s=i.tickMarks(),r=this.mainSeries();if(void 0===s.minIndex)return void(this._lastGotoTimeRange={from:e,to:t});let o=e,a=t;const l=r.symbolInfo();if(null!==l){let i=this.properties().childs().timezone.value();"exchange"===i&&(i=l.timezone);const s=(0,Pt.get_timezone)(i),n=(0,Pt.utc_to_cal)(s,e),c=(0,Pt.utc_to_cal)(s,t);if(r.isDWM()){const e=(0,Pt.get_timezone)("Etc/UTC");(0,Pt.set_hms)(n,0,0,0,0,e),(0,Pt.set_hms)(c,0,0,0,0,e)}o=n.getTime(),a=c.getTime()}const c=(0,n.ensureDefined)(s.maxIndex),h=(0,n.ensureDefined)(s.minIndex);if(o>=(0,n.ensureNotNull)(s.indexToTime(h)).valueOf()||r.endOfData()){const e=(e,t)=>e(0,n.ensureNotNull)(s.indexToTime(e)).valueOf(),l=(0,v.lowerboundExt)(t,o,e,s.nearestIndex(o),c);let d=o===a?l:(0,v.lowerboundExt)(t,a,e,s.nearestIndex(a),c);this._lastGotoTimeRange=null,null!==this._lastAppliedGotoTimeRange&&(this._lastAppliedGotoTimeRange.actual=!1);const u=i.baseIndex();if(l+Math.max(d-l+1,i.minVisibleBarCount())>u){const e=i.targetDefaultRightOffset();d-u=0;t--)if(this._panes[t].hasDataSource(e))return this._panes[t];return e instanceof At.BarsMarksContainer?this.paneForSource(this.mainSeries()):null}mainPane(){for(const e of this._panes)if(e.isMainPane())return e;throw new Error("Main pane is not found")}lastPane(){return this._panes[this._panes.length-1]}removeSource(e,t){this.selectionMacro((t=>t.removeSourceFromSelection(e)),!0),this._hoveredSource===e&&(this._hoveredSource=null,this._lastHoveredHittestData=null),this._sourcesBeingMoved.includes(e)&&(this._sourcesBeingMoved=this._sourcesBeingMoved.filter((t=>t!==e)),this._sourcesBeingMoved.length||(this._activeItemBeingMoved=null)),e===this._lineBeingEdited&&(this._lineBeingEdited=null,Se.isToolEditingNow.setValue(!1)),e===this._lineBeingCreated&&(this._lineBeingCreated=null,Se.isToolCreatingNow.setValue(!1)),!t&&e.stop&&e.stop();const i=this.detachSource(e),s=this.mainSeries().priceScale();return(0,j.isStudy)(e)&&(0,_e.isActingAsSymbolSource)(e)&&e.priceScale()===s&&s.isPercentage()&&1===s.seriesLikeSources().filter(_e.isActingAsSymbolSource).length&&s.setMode({percentage:!1}),this.fullUpdate(),this._invalidateBarColorerCaches(),(0,j.isStudy)(e)&&((0,_.emit)("study_event",e.id(),"remove"),e.isChildStudy()&&e.parentSources().forEach((t=>t.unsetChild(e))),e.maxOffset().unsubscribe(this._boundUpdateStudiesMaxOffset)),!t&&e.destroy&&e.destroy(),(0,S.isLineTool)(e)&&(e.removeAlert(),(0,_.emit)("drawing_event",e.id(),"remove")),i}allStudies(e){const t=e?e=>(0,j.isStudy)(e)&&!0:j.isStudy;return this._getAllSources(t)}studiesWV(e){return e?this._studiesExcludeInternalWV.readonly():this._studiesWV.readonly()}findNonOverlayStudyWithGroupingKey(e,t){const i=void 0!==t?[t]:this._panes;for(const t of i){const i=t.dataSources().find((i=>(0,j.isStudy)(i)&&i.metaInfo().groupingKey===e&&!t.isOverlay(i)));if(void 0!==i)return{pane:t,study:i}}return null}movePaneUp(e){this.movePane(e,e-1)}movePaneDown(e){this.movePane(e,e+1)}movePane(e,t){const i=this._panes[e];this._panes.splice(e,1),this._panes.splice(t,0,i),this._panesCollectionChanged.fire(this._panes),this._onRearrangePanes.fire(),this.invalidate(Y.InvalidationMask.panesOrder())}backgroundColor(){return this._backgroundColor}backgroundTopColor(){return this._backgroundTopColor}backgroundColorAtYPercentFromTop(e){const t=this.backgroundColor().value(),i=this.backgroundTopColor().value();if(t===i)return t;if(e=Math.max(0,Math.min(100,Math.round(100*e))),null===this._gradientColorsCache||this._gradientColorsCache.topColor!==i||this._gradientColorsCache.bottomColor!==t)this._gradientColorsCache={topColor:i,bottomColor:t,colors:new Map};else{const t=this._gradientColorsCache.colors.get(e);if(void 0!==t)return t}const s=(0,Lt.gradientColorAtPercent)(i,t,e/100);return this._gradientColorsCache.colors.set(e,s),s}backgroundCounterColor(){return this._backgroundCounterColor.readonly()}dark(){return this._isDark} +defaultResolutions(){return this.chartApi().defaultResolutions()}availableCurrencies(){const e=this._getAvailableCurrencies();return e.length!==this._availableCurrencies.size()&&(this._availableCurrencies=new Et(e)),this._availableCurrencies}currencyConversionEnabled(){return this._options.currencyConversionEnabled}availableUnits(){const e=this._getAvailableUnits();return this._availableUnits.unitsChanged(e)&&(this._availableUnits=new Vt(e)),this._availableUnits}unitConversionEnabled(){return this._options.unitConversionEnabled}availablePriceSources(){const e=this._getAvailablePriceSources();return null!==e&&this._availablePriceSources.priceSourcesChanged(e)&&(this._availablePriceSources=new es(e)),this._availablePriceSources}resetDeferredStudies(){Ee.instance(this).reset()}isJustClonedChart(){return this._undoModel.isJustClonedChart()}studyTemplate(e,t,i){const s={panes:[],version:this.version()};for(const e of this.panes())s.panes.push(e.state(!0,!1,!0));const r=this.mainSeries();return e&&(s.symbol=r.symbol(),this.currencyConversionEnabled()&&i&&(s.currency=r.currency()),this.unitConversionEnabled()&&i&&(s.unit=r.unit())),t&&(s.interval=r.interval()),s}getStudyById(e){const t=this.dataSourceForId(e);return null!==t&&(0,j.isStudy)(t)?t:null}getLineToolById(e){const t=this.dataSourceForId(e);return null!==t&&(0,S.isLineTool)(t)?t:null}restoreLineToolState(e,t,i){var s;e.restorePoints(t.points,t.indexes||[]),t.state.intervalsVisibilities=(0,Be.mergeIntervalVisibilitiesDefaults)(t.state.intervalsVisibilities),e.properties().merge(t.state),e.restoreData&&e.restoreData(t),e.linkKey().setValue(t.linkKey||null),e.createServerPoints(),e.setZorder(null!==(s=t.zorder)&&void 0!==s?s:e.zorder()),this.fullUpdate();const r=e.linkKey().value();null!==r&&i&&(0,Se.restoreLineToolState)({model:this,linkKey:r,state:t})}preferences(){return(0,Ki.preferencesByWhiteList)(this,this.mainSeries())}restoreTheme(e,t,i){e.mainSourceProperties.hollowCandleStyle||(e.mainSourceProperties.hollowCandleStyle=e.mainSourceProperties.candleStyle),this._undoModel.chartLoadTheme(e,t,i)}onResetScales(){return this._resetScales}startMovingSources(e,t,i,s,r,o){this._sourcesBeingMoved=e,this._activeItemBeingMoved=i;let a=!1;if(this._sourcesBeingMoved.forEach((e=>{!a&&(0,j.isStudy)(e)&&(a=!0);const l=(0,n.ensureNotNull)(this.paneForSource(e)),c=(0,S.isLineTool)(e),h=c&&e.linkKey().value();if(!1!==h&&null!==h&&s.has(h)&&c&&e.isFixed()){const t=(0,n.ensureDefined)(s.get(h)),a={screen:this._percentPositionToPoint(t,l)};e.startMoving(a,i,r,o)}else e.startMoving(t,i,r,o);const d=this._paneInvalidationMask(l,Y.InvalidationLevel.Light);this.invalidate(d)})),!o){const s=e.filter(S.isLineTool).filter((e=>e.linkKey().value()&&e.isSynchronizable())).map((e=>e.linkKey().value()));if(s.length&&t.logical){const o=this.externalTimeStamp(t.logical.index),a={linkKeys:s,model:this,symbol:this.mainSeries().symbol(),point:{price:t.logical.price,timeStamp:o},activeItem:null!==i?i:void 0,envState:r,pointPositionPercents:new Map};e.forEach((e=>{if((0,S.isLineTool)(e)){ +const i=e.linkKey().value();if(i&&e.isSynchronizable()&&e.isFixed()){const s=(0,n.ensureNotNull)(this.paneForSource(e));a.pointPositionPercents.set(i,this._pointToPercentPosition((0,n.ensureDefined)(t.screen),s))}}})),(0,Se.startMovingLineTool)(a)}}Se.isToolMovingNow.setValue(!0),a&&Se.isStudyEditingNow.setValue(!0)}moveSources(e,t,i,s){if(this._sourcesBeingMoved.filter((e=>!e.isLocked||!e.isLocked())).forEach((r=>{const o=(0,S.isLineTool)(r)?r.linkKey().value():null;if(null!==o&&t.has(o)){const e=(0,n.ensureNotNull)(this.paneForSource(r)),a=(0,n.ensureDefined)(t.get(o)),l={screen:this._percentPositionToPoint(a,e)};r.move(l,this._activeItemBeingMoved,i,s)}else r.move(e,this._activeItemBeingMoved,i,s)})),this.lightUpdate(),!s&&e.logical){const t=this._sourcesBeingMoved.filter(S.isLineTool).filter((e=>e.isSynchronizable()&&!!e.linkKey().value())).map((e=>e.linkKey().value())),s=this.externalTimeStamp(e.logical.index),r={linkKeys:t,model:this,point:{price:e.logical.price,timeStamp:s},envState:i,pointPositionPercents:new Map};this._sourcesBeingMoved.filter(S.isLineTool).forEach((t=>{if(t.linkKey().value()&&t.isSynchronizable()&&t.isFixed()){const i=(0,n.ensureNotNull)(this.paneForSource(t));r.pointPositionPercents.set(t.linkKey().value(),this._pointToPercentPosition((0,n.ensureDefined)(e.screen),i))}})),(0,Se.moveLineTool)(r)}}endMovingSources(e,t,i){const s=this._sourcesBeingMoved.map((s=>{const r=(0,n.ensureNotNull)(this.paneForSource(s)),o=s.endMoving(e,t,i),a=this._paneInvalidationMask(r,Y.InvalidationLevel.Light);return a.invalidateAll(Y.InvalidationLevel.Light),this.invalidate(a),o})),r=this._sourcesBeingMoved.filter(S.isLineTool).filter((e=>e.isSynchronizable()&&!!e.linkKey().value())).map((e=>e.linkKey().value())),o=this._sourcesBeingMoved.filter(S.isLineTool).filter((e=>e.isSynchronizable()&&!!e.linkKey)).map((e=>{const t={points:e.normalizedPoints(),interval:this.mainSeries().interval()};return e.isFixed()&&(t.pointPositionPercents=e.calcPositionPercents()),t}));r.length&&(0,Se.finishMovingLineTool)({linkKeys:r,model:this,finalStates:o,changes:s}),this._sourcesBeingMoved=[],this._activeItemBeingMoved=null,Se.isToolMovingNow.setValue(!1),Se.isStudyEditingNow.setValue(!1)}sourcesBeingMoved(){return this._sourcesBeingMoved}setMovingCustomSource(e,t){this._customSourceBeingMoved=e,this._customSourceBeingMovedHitTestData=null!==t?{beingMoved:!1,...t}:null}processingCustomSourceMove(){null!==this._customSourceBeingMovedHitTestData&&(this._customSourceBeingMovedHitTestData.beingMoved=!0)}customSourceMovingHitTestData(){return this._customSourceBeingMovedHitTestData}customSourceBeingMoved(){return null!==this._customSourceBeingMovedHitTestData&&this._customSourceBeingMovedHitTestData.beingMoved?this._customSourceBeingMoved:null}lineToolsSynchronizer(){return this._lineToolsSynchronizer}setLineToolsSynchronizer(e){this._lineToolsSynchronizer=e}width(){return this._width}setWidth(e,t){this._width=e,this._timeScale.setWidth(e,t);for(const t of this._panes)t.setWidth(e);this.recalculateAllPanes((0, +W.viewportChangeEvent)()),this.recalcVisibleRangeStudies()}setPaneHeight(e,t){e.setHeight(t),this.recalculateAllPanes((0,W.viewportChangeEvent)()),this.lightUpdate()}resetScalesAvailable(){return this._resetScalesAvailable.readonly()}panes(){return this._panes}paneForId(e){return this._panes.find((t=>t.id()===e))||null}createPane(e,t,i){const s=this._undoModel.chartWidget();s.isMaximizedPane()&&s.toggleMaximizePane(null);const r=this._properties.childs().paneProperties;t&&r.merge(t);const n=new Ge(this._timeScale,r,this,i);return void 0!==e?this._panes.splice(e,0,n):this._panes.push(n),n.onTagsChanged().subscribe(this,cs.prototype.onPaneTagsChanged),n.dataSourcesCollectionChanged().subscribe(this,(()=>this._dataSourceCollectionChanged.fire(n))),n.symbolSourceCollectionChanged().subscribe(this,(()=>this._onSymbolSourceCollectionChanged(n))),n.priceSourcesCollectionChanged().subscribe(this,(()=>this._onPriceSourcesCollectionChanged(n))),n.sourcePropertiesChanged().subscribe(this,(e=>this._sourceProperitesChanged.fire(n,e))),n.sourceZOrderChanged().subscribe(this,(e=>this._sourceZOrderChanged.fire(n,e))),n.symbolSourceResolved().subscribe(this,(e=>this._symbolSourceResolved.fire(n,e))),n.symbolSourceResolvingActive().subscribe(this._recalcSymbolResolvingActive),n.collapsed().subscribe(this._recalcPaneCollapsingAvailable),n.resetPriceScalesAvailable().subscribe(this._updateResetScalesAvailableValue,{callWithLast:!0}),this._recalcPaneCollapsingAvailable(),this._panesCollectionChanged.fire(this._panes),this.invalidate(Y.InvalidationMask.panesOrder()),n}removePane(e){const t=this._undoModel.chartWidget();t.isMaximizedPane()&&t.toggleMaximizePane(null);const i=e;i.destroy();const s=this._panes.indexOf(i);-1!==s&&(this._panes.splice(s,1),e.dataSourcesCollectionChanged().unsubscribeAll(this),e.symbolSourceCollectionChanged().unsubscribeAll(this),e.priceSourcesCollectionChanged().unsubscribeAll(this),e.sourcePropertiesChanged().unsubscribeAll(this),e.onTagsChanged().unsubscribeAll(this),e.symbolSourceResolved().unsubscribeAll(this),i.symbolSourceResolvingActive().unsubscribe(this._recalcSymbolResolvingActive),e.collapsed().unsubscribe(this._recalcPaneCollapsingAvailable),e.resetPriceScalesAvailable().unsubscribe(this._updateResetScalesAvailableValue),this._recalcPaneCollapsingAvailable(!0)),this._updateResetScalesAvailableValue();this.crossHairSource().pane===e&&this.clearCurrentPosition(),this._panesCollectionChanged.fire(this._panes),this.invalidate(Y.InvalidationMask.panesOrder())}changePanesHeight(e,t){if(this._panes.length<2)return;(0,n.assert)(e>=0&&ee+t.stretchFactor()),0),r=this._panes.reduce(((e,t)=>e+t.height()),0),o=r-30*(this._panes.length-1);t=Math.min(o,Math.max(30,t));const a=s/r,l=i.height();i.setStretchFactor(t*a);let c=t-l,h=this._panes.length-1;for(const e of this._panes)if(e!==i){const t=Math.min(o,Math.max(30,e.height()-c/h));c-=e.height()-t,h-=1;const i=t*a;e.setStretchFactor(i)}this.fullUpdate()} +clearCurrentPosition(){const e=this.crossHairSource();e.clearPosition(),(0,n.ensureNotNull)(e.dataWindowView()).update(),as(this._panes),this.invalidate(Y.InvalidationMask.cursor());const t=this._undoModel.chartWidget();t.chartWidgetCollection().syncCrosshair(null,t.id()),this._phantomSourceContainer.onCursorPositionUpdated()}setAndSaveCurrentPosition(e,t,i,s){this.crossHairSource().saveOriginCoords(e,t),this.setCurrentPosition(e,t,i,s)}setCurrentPosition(e,t,i,s){var r,o,a,l,c,h;let d=NaN;const u=this._timeScale.coordinateToVisibleIndex(e),p=null!==(a=null===(o=null!==(r=this._lineBeingEdited)&&void 0!==r?r:this._lineBeingCreated)||void 0===o?void 0:o.priceScale())&&void 0!==a?a:i.defaultPriceScale();let _=null;!p.isEmpty()&&Number.isFinite(t)&&(_=(0,n.ensureNotNull)(i.mainDataSource()).firstValue(),null!==_&&(d=p.coordinateToPrice(t,_)));const m=this._crossHairSelectPointMode.value()!==Se.SelectPointMode.None,g=this.currentTool(),f=this.mainSeries(),v=this.crossHairSource(),S=v.index,y=v.price,b=m||Se.isStudyEditingNow.value(),w=p===this.m_mainSeries.priceScale()&&(this._lineBeingCreated||this._lineBeingEdited||(0,he.isLineToolName)(g)||(0,Se.toolIsMeasure)(g)||b);!this._isSettingsExternalPosition&&w?(d=this._magnet.align(d,u,i),null!==_&&this._setCorrectedPositionToCrosshair(u,d,i)):this._magnet.resetLastValue();let P=null;if(isNaN(d)||(P=i),this._isTimeScrolling){if(!this._isSettingsExternalPosition&&m){const e=f.bars().firstIndex(),t=f.bars().lastIndex();if(null!==e&&null!==t){const s=Math.min(Math.max(u,e),t);s!==u&&this._setCorrectedPositionToCrosshair(s,d,i)}}else v.setPosition(v.index,d,P);return}v.setOnHoveredChartWidget(!0),v.setPosition(u,d,P),(0,n.ensureNotNull)(v.dataWindowView()).update(),as(this._panes);const C=f.syncModel();if(this.crossHairSource().startMeasurePoint()||this._lineBeingCreated?this.lightUpdate():this.invalidate(Y.InvalidationMask.cursor()),this._lineBeingCreated){const e=this._lineBeingCreated.linkKey().value();if(!this._isSettingsExternalPosition){const t=this._lineBeingCreated.setLastPoint({index:u,price:d},s);if(this._lineBeingCreated.updateAllViews((0,W.sourceChangeEvent)(this._lineBeingCreated.id())),t.price===d&&t.index===u||this._setCorrectedPositionToCrosshair(t.index,t.price,i),C&&e){const i=this._timeScale.points().roughTime(t.index,C.projectTime.bind(C));(0,Se.setLineToolLastPoint)({model:this,linkKey:e,point:{timeStamp:(0,n.ensureNotNull)(i),price:t.price}})}}}if(!this._isSettingsExternalPosition&&null!==this._lineBeingEdited&&null!==this._linePointBeingEdited){const e={index:u,price:d};if(null===(l=this._linePointBeingChanged)||void 0===l?void 0:l.nonDiscreteIndex){const t=this.crossHairSource().originX();Number.isFinite(t)&&(e.index=this._timeScale.coordinateToFloatIndex(t))}this.changeLinePoint(e,s);const t=this._lineBeingEdited.alignCrossHairToAnchor(this._linePointBeingEdited)?this._lineBeingEdited.getPoint(this._linePointBeingEdited):e;null!==t&&this._setCorrectedPositionToCrosshair(t.index,t.price,i)} +if(!this._isSettingsExternalPosition&&1===this._sourcesBeingMoved.length){const e=this._sourcesBeingMoved[0];if(null===(c=e.alignCrossHairToMovePoint)||void 0===c?void 0:c.call(e)){const t=null===(h=e.currentMovingPoint)||void 0===h?void 0:h.call(e);t&&t.logical&&this._setCorrectedPositionToCrosshair(t.logical.index,t.logical.price,i)}}if(!this._isSettingsExternalPosition&&b){const e=f.bars().firstIndex(),t=f.bars().lastIndex();if(null!==e&&null!==t){const s=Math.min(Math.max(u,e),t);s!==u&&this._setCorrectedPositionToCrosshair(s,d,i)}}(S!==u||y!==d)&&this._syncCrosshair(s)}setExternalPosition(e,t){let i;const s=this.crossHairSource();if(s.setOnHoveredChartWidget(!1),null!==e&&(0,ie.isNumber)(e.timeStamp)){const t=this.mainSeries().syncModel();if(t){const s=this.createSyncPoint(e.syncSourceTarget,t.syncSourceTarget()).sourceTimeToTargetTime(e.timeStamp);i=this._timeScale.points().roughIndex(s,t.distance.bind(t))}}if(null!==e&&null!=i&&Number.isFinite(i)){this._isSettingsExternalPosition=!0;const r=(0,n.ensureNotNull)(this.paneForSource(this.mainSeries())),o=this._timeScale.indexToCoordinate(i),a=(0,n.ensureNotNull)(r.mainDataSource()).firstValue();if(null!==a){let i=NaN;void 0!==e.price&&Number.isFinite(e.price)&&(i=this.mainSeries().priceScale().priceToCoordinate(e.price,a)),s.clearOriginCoords(),this.setCurrentPosition(o,i,r,t)}return s.setOnHoveredChartWidget(!1),void(this._isSettingsExternalPosition=!1)}s.clearPosition(),(0,n.ensureNotNull)(s.dataWindowView()).update(),as(this._panes),this.invalidate(Y.InvalidationMask.cursor())}startScaleTime(e){this._timeScale.startScale(e)}scaleTimeTo(e){this._timeScale.scaleTo(e),this.recalculateAllPanes((0,W.viewportChangeEvent)()),this.lightUpdate()}endScaleTime(){this._timeScale.endScale(),this.lightUpdate(),this.recalcVisibleRangeStudies()}resetTimeScale(){this._timeScale.restoreDefault(),this.recalculateAllPanes((0,W.viewportChangeEvent)()),this.recalcVisibleRangeStudies(),this.lightUpdate(),this._resetScales.fire()}startScalePrice(e,t,i){e.startScalePrice(t,i)}scalePriceTo(e,t,i){e.scalePriceTo(t,i),this.mainSeries().priceScale().isLockScale()?this.lightUpdate():this.invalidate(this._paneInvalidationMask(e,Y.InvalidationLevel.Light))}endScalePrice(e,t){e.endScalePrice(t),this.invalidate(this._paneInvalidationMask(e,Y.InvalidationLevel.Light))}startTwoPointsScalePrice(e,t,i,s){t.startTwoPointsScale(i,s)}twoPointsScalePriceTo(e,t,i,s){t.twoPointsScale(i,s),this.invalidate(this._paneInvalidationMask(e))}endTwoPointsScalePrice(e,t){t.endTwoPointsScale(),this.invalidate(this._paneInvalidationMask(e))}resetPriceScale(e,t){e.resetPriceScale(t),this.invalidate(this._paneInvalidationMask(e,Y.InvalidationLevel.Light))}restorePriceScaleState(e,t,i){e.restorePriceScaleState(t,i),this.invalidate(this._paneInvalidationMask(e,Y.InvalidationLevel.Light))}currentTool(){return this._currentTool}setCurrentTool(e){this._currentTool!==e&&((0,he.isLineToolName)(e)&&this.selectionMacro((e=>{e.clearSelection()})),this._currentTool=e,this._phantomSourceContainer.onToolChanged())} +detachSource(e){const t=this.paneForSource(e);return!!t&&(t.removeDataSource(e),t.isEmpty()?(this._lineBeingCreated&&t===this._paneBeingCreatedLineOn&&this.cancelCreatingLine(),this.removePane(t),!0):(this.fullUpdate(),!1))}children(e,t){return this.dataSources().filter((i=>(0,j.isStudy)(i)?!t&&i.parentSources().includes(e):i.ownerSource()===e))}onRearrangePanes(){return this._onRearrangePanes}finishLineTool(e){const t=e.linkKey().value();(0,Se.drawOnAllCharts)().value()&&null!==t&&e.isSynchronizable()&&(0,Se.finishLineTool)({linkKey:t,model:this})}startChangingLinetool(e,t,i,s,r){this._lineBeingEdited=e,this._linePointBeingChanged=t||null,this._linePointBeingEdited=void 0===i?null:i,this._lineBeingEdited.startChanging(i,t,r),Se.isToolEditingNow.setValue(!0);const o=(0,n.ensureNotNull)(this.paneForSource(e));this._lineBeingEdited.startDragPoint&&void 0!==i&&void 0!==t&&this._lineBeingEdited.startDragPoint(i,t),r||void 0===i||void 0===t||this._lineBeingEdited.setPoint(i,t,s,r),this._lineBeingEdited.updateAllViews((0,W.sourceChangeEvent)(this._lineBeingEdited.id()));const a=this._paneInvalidationMask(o,Y.InvalidationLevel.Light);this.invalidate(a);const l=e.linkKey().value();if(l&&e.isSynchronizable()&&void 0!==i&&void 0!==t){const e=(0,n.ensureNotNull)(this.externalTimeStamp(t.index));(0,Se.startChangingLineTool)({linkKey:l,model:this,symbol:this.mainSeries().symbol(),point:{price:t.price,timeStamp:e},pointIndex:i,envState:s||null})}}createLineTool(e,t,i,s,r,a,l,c){if((0,n.assert)((0,he.isLineToolName)(i),`Cannot create unknown line tool: ${i}`),s){const e={...Zi.intervalsVisibilitiesDefaults},t=s.childs().intervalsVisibilities.state();(0,ie.merge)(e,null!=t?t:{});const r=s.state();r.intervalsVisibilities=e,s=(0,S.createLineToolProperties)(i,r,this)}const h=(0,S.createLineTool)(i,this,s,null,void 0,c);if("LineToolExecution"!==i){let e;switch(i){case"LineToolIcon":e=h.properties().childs().icon.value().toString(16).toUpperCase();break;case"LineToolEmoji":e=h.properties().childs().emoji.value();break;case"LineToolSticker":e=h.properties().childs().sticker.value()}(0,u.trackEvent)("drawings","Study_Drawing_"+i,e)}(0,S.isStudyLineTool)(h)&&(0,u.trackEvent)("studies",`Study_${h.metaInfo().id}`);const d=!h.linkKey().value()&&!r;l=(0,n.ensureDefined)(l||(0,n.ensureNotNull)(e.mainDataSource())),s||(0,S.prepareLineToolPropertiesByOwnerSource)(h.properties(),l),h.setOwnerSource(l);const p=l.priceScale();if(h.setPriceScale(p),e.addDataSource(h,p,!1),null!==h.preferredZOrder()&&e.insertAfter([h],this.mainSeries()),(0,Se.drawOnAllCharts)().value()){const e=h.isSynchronizable()?r||(0,J.randomHash)():null;h.linkKey().setValue(e)}else h.linkKey().setValue(r);let _;if(h.isFixed()){const i=(0,n.ensureNotNull)((0,n.ensureNotNull)(e.mainDataSource()).firstValue()),s=this._timeScale.indexToCoordinate(t.index),r=(0,n.ensureNotNull)(p).priceToCoordinate(t.price,i);_=h.addFixedPoint(new o.Point(s,r))}else _=h.addPoint(t);return _||(this._lineBeingCreated=h,this._paneBeingCreatedLineOn=e,Se.isToolCreatingNow.setValue(!0)), +d&&h.enableCurrentIntervalVisibility(),this.fullUpdate(),h}endChangingLinetool(e,t){const i=(0,n.ensureNotNull)(this._lineBeingEdited),s=i.endChanging(!1,e,t);this._lineBeingEdited=null,Se.isToolEditingNow.setValue(!1),this._linePointBeingEdited=null,this._linePointBeingChanged=null,this.lightUpdate();const r={points:i.normalizedPoints(),interval:this.mainSeries().interval()},o=i.linkKey().value();null!==o&&i.isSynchronizable()&&!t&&(0,Se.finishChangingLineTool)({model:this,linkKey:o,symbol:this.mainSeries().symbol(),finalState:r,changes:s})}continueCreatingLine(e,t,i,s){const r=(0,n.ensureNotNull)(this._lineBeingCreated),o=r.addPoint(e,t,i);r.updateAllViews((0,W.sourceChangeEvent)(r.id()));const a=new Y.InvalidationMask(Y.InvalidationLevel.Light);return o&&(this._paneBeingCreatedLineOn=null,this._lineBeingCreated=null,Se.isToolCreatingNow.setValue(!1)),this.invalidate(a),o}cancelCreatingLine(){if(!this._lineBeingCreated)return;const e=this._lineBeingCreated;this.removeSource(this._lineBeingCreated),this._lineBeingCreated=null,this._lineCancelled.fire(),Se.isToolCreatingNow.setValue(!1),(0,Se.drawOnAllCharts)().value()&&e.isSynchronizable()&&(0,Se.cancelLineTool)({model:this})}lineBeingCreated(){return this._lineBeingCreated}paneBeingCreatedLineOn(){return this._paneBeingCreatedLineOn}lineCancelled(){return this._lineCancelled}isPhantomLine(e){return this._phantomSourceContainer.source()===e}changeLinePoint(e,t,i){const s=(0,n.ensureNotNull)(this._lineBeingEdited),r=(0,n.ensureNotNull)(this._linePointBeingEdited);let o=e.price,a=e.index;if(s.setPoint(r,e,t,i),!i){const t=s.alignCrossHairToAnchor(r)?s.getPoint(r):e;null!==t&&(a=t.index,o=t.price)}s.updateAllViews((0,W.sourceChangeEvent)(s.id())),this.lightUpdate();const l=s.linkKey().value();if(!i&&null!==l&&s.isSynchronizable()){const e=(0,n.ensureNotNull)(this._linePointBeingChanged),i={indexesChanged:a!==e.index,pricesChanged:o!==e.price},c=s.getChangePointForSync(r);if(null!==c){const e=this.externalTimeStamp(a);null!==e&&(o=c.price,(0,Se.changeLineTool)({linkKey:l,model:this,symbol:this.mainSeries().symbol(),point:{price:o,timeStamp:e},envState:t,changes:i}))}}}changeLinePoints(e,t,i){const s=e.points(),r=e.linkKey().value();!i&&r&&e.isSynchronizable()&&t.forEach(((t,i)=>{const o=s[i],a=o.price!==t.price,l=o.index!==t.index;if(e.getChangePointForSync(i)){const e=(0,n.ensureNotNull)(this.externalTimeStamp(t.index));(0,Se.changeLineTool)({linkKey:r,model:this,symbol:this.mainSeries().symbol(),point:{price:t.price,timeStamp:e},changes:{pricesChanged:a,indexesChanged:l}})}})),e.setPoints(t),e.updateAllViews((0,W.sourceChangeEvent)(e.id())),this.lightUpdate()}startScrollTime(e){this._timeScale.startScroll(e),this._isTimeScrolling=!0,this.mainSeries().clearGotoDateResult()}scrollTimeTo(e){this._timeScale.scrollTo(e),this.recalculateAllPanes((0,W.viewportChangeEvent)()),this.lightUpdate()}endScrollTime(){this._timeScale.endScroll(),this.lightUpdate(),this.recalcVisibleRangeStudies(),this._isTimeScrolling=!1}startScrollPrice(e,t,i){e.startScrollPrice(t,i)} +scrollPriceTo(e,t,i){e.scrollPriceTo(t,i),this.invalidate(this._paneInvalidationMask(e,Y.InvalidationLevel.Light))}endScrollPrice(e,t){e.endScrollPrice(t),this.invalidate(this._paneInvalidationMask(e,Y.InvalidationLevel.Light))}addCustomSource(e,t,i=g.CustomSourceLayer.Foreground){this._customSourcesMap.has(e)&&ns.logWarn(`Attempt to add the same custom source multiple time "${e}"`),ns.logNormal(`Adding custom source "${e}"`);const s=t(e,this);switch(i){case g.CustomSourceLayer.Background:this._bgCustomSources.push(s);break;case g.CustomSourceLayer.Foreground:this._fgCustomSources.push(s);break;case g.CustomSourceLayer.Topmost:this._topmostCustomSources.push(s);break;default:throw new Error(`Unknown custom sources layer ${i}`)}this._allCustomSources.push(s),this._customSourcesMap.set(e,s),this.lightUpdate()}removeCustomSource(e){this._removeCustomSource(e),this.lightUpdate()}hasCustomSource(e){return this._customSourcesMap.has(e)}customSourceForName(e){return this._customSourcesMap.get(e)||null}customSourceName(e){let t=null;return this._customSourcesMap.forEach(((i,s)=>{i===e&&(t=s)})),t}customSources(e){switch(e){case g.CustomSourceLayer.Background:return this._bgCustomSources;case g.CustomSourceLayer.Foreground:return this._fgCustomSources;case g.CustomSourceLayer.Topmost:return this._topmostCustomSources;default:return this._allCustomSources}}addMultiPaneSource(e){this._multiPaneSources.push(e),this.lightUpdate()}removeMultiPaneSource(e){const t=this._multiPaneSources.indexOf(e);-1===t?ns.logWarn("Attempt to remove multi-pane source which does not exist in the model"):this._multiPaneSources.splice(t,1),this.lightUpdate()}multiPaneSources(e){return this._multiPaneSources.filter((t=>!e.hasDataSource(t)))}magnet(){return this._magnet}dateTimeFormatter(){return this._dateTimeFormatter}dateFormatter(){return this._dateFormatter}timeFormatter(){return this._timeFormatter}isUnmergeAvailableForSource(e){if(!this._unmergeAvailable(e))return!1;return(0,n.ensureNotNull)(this.paneForSource(e)).dataSources().filter(this._unmergeAvailable,this).length>1}isMergeDownAvailableForSource(e){if(!this._unmergeAvailable(e))return!1;const t=this.paneForSource(e),i=this.panes();return t!==i[i.length-1]}isMergeUpAvailableForSource(e){if(!this._unmergeAvailable(e))return!1;return this.paneForSource(e)!==this.panes()[0]}sessions(){return(0,n.ensureNotNull)(this._sessions)}createSessions(e){(0,n.assert)(null===this._sessions,"Sessions are already created"),this.addCustomSource("sessions",((t,i)=>(this._sessions=new U(t,i,e),this._sessions.start(),this._sessions)),g.CustomSourceLayer.Background)}createPrePostMarket(e){this.addCustomSource("prePostMarket",((t,i)=>new PrePostMarket(t,i,e)))}watermarkContentProvider(){return is.WatermarkApi.getInstance().provider()}replayStatus(){return this._replayStatus}setReplayStatus(e){this._replayStatus.setValue(e)}isInReplay(){return this.m_mainSeries.isInReplay()}theme(){const e=this.properties().childs().paneProperties.state(["horzGridProperties.style","vertGridProperties.style"]);delete e.topMargin, +delete e.bottomMargin;const t=this.mainSeries().state().state;t&&(delete t.symbol,delete t.interval,delete t.currencyId,delete t.unitId);const i={mainSourceProperties:t,sessions:this.sessions().properties().state(),chartProperties:{paneProperties:e,scalesProperties:this.properties().childs().scalesProperties.state()},version:this.version()};return i.version=this.version(),i}onChartThemeLoaded(){return this._chartThemeLoaded}chartThemeLoaded(){this._chartThemeLoaded.fire()}state(e,t,i,s){var r;const n=this.publishedChartsTimelineSource(),o=this.properties().childs(),a=o.tradingProperties.state(),l={panes:this._panes.map((r=>r.state(!0,e,!1,t,i,s))),timeScale:this._timeScale.state(e),chartProperties:{paneProperties:o.paneProperties.state(["horzGridProperties.style","vertGridProperties.style"]),scalesProperties:o.scalesProperties.state(),publishedChartsTimelineProperties:n?n.state(e):void 0,chartEventsSourceProperties:null===(r=o.chartEventsSourceProperties)||void 0===r?void 0:r.state(),tradingProperties:a,priceScaleSelectionStrategyName:o.priceScaleSelectionStrategyName.value()},sessions:this.sessions().state(e),version:this.version(),timezone:this.timezone(),shouldBeSavedEvenIfHidden:this._shouldBeSavedEvenIfHidden,linkingGroup:this._linkingGroupIndex.value()};return s||(l.lineToolsGroups=this.lineToolsGroupModel().state(t)),l}restoreState(e,t,i){var s;Ee.instance(this).reset();const r={};if(!e.panes)return void ns.logDebug("ChartModel.restoreState: invalid state");if(!Array.isArray(e.panes))return void ns.logDebug("ChartModel.restoreState: invalid state");if(e.panes.length<1)return void ns.logDebug("ChartModel.restoreState: invalid state");for(const e of this._barsMarksSources)this.detachSource(e);if(this._shouldBeSavedEvenIfHidden=void 0===e.shouldBeSavedEvenIfHidden||e.shouldBeSavedEvenIfHidden,e.chartProperties&&!e.chartProperties.timezone&&(e.chartProperties.timezone=e.timezone),e.chartProperties){const i=(0,B.factoryDefaults)("chartproperties").scalesProperties;(0,ie.merge)(i,e.chartProperties.scalesProperties),!("showLastValue"in i)||"showSeriesLastValue"in i||"showStudyLastValue"in i||(i.showSeriesLastValueProperty=i.showLastValue,i.showStudyLastValueProperty=i.showLastValue),"showSeriesLastValue"in i&&(r.showSeriesLastValueProperty=!0),"showStudyLastValue"in i&&(r.showStudyLastValueProperty=!0),(!this.isSnapshot()&&!this.readOnly()&&"showCurrency"in i||"showUnit"in i)&&((0,K.migrateShowCurrencyAndShowUnitProperties)(i.showCurrency,i.showUnit),delete i.showCurrency,delete i.showUnit);{const{paneProperties:t}=e.chartProperties;t.vertGridProperties=t.vertGridProperties||(0,ie.clone)(t.gridProperties),t.horzGridProperties=t.horzGridProperties||(0,ie.clone)(t.gridProperties),"backgroundType"in t||(t.backgroundType=kt.ColorType.Solid),"separatorColor"in t||(t.separatorColor=(0,d.getThemedColor)("color-chart-page-bg")),this._properties.childs().paneProperties.mergeAndFire(t)}this._properties.childs().scalesProperties.mergeAndFire(i), +e.chartProperties.timezone&&this._properties.childs().timezone.setValue(e.chartProperties.timezone),e.chartProperties.chartEventsSourceProperties&&this._properties.hasChild("chartEventsSourceProperties")&&this._properties.childs().chartEventsSourceProperties.mergeAndFire(e.chartProperties.chartEventsSourceProperties),e.chartProperties.tradingProperties&&this._properties.hasChild("tradingProperties")&&(void 0===e.chartProperties.tradingProperties.horizontalAlignment&&(e.chartProperties.tradingProperties.horizontalAlignment=(n=e.chartProperties.tradingProperties.lineLength)<=40?g.TradedGroupHorizontalAlignment.Right:n>=60?g.TradedGroupHorizontalAlignment.Left:g.TradedGroupHorizontalAlignment.Center),this._properties.childs().tradingProperties.mergeAndFire(e.chartProperties.tradingProperties)),this._timeScale.restoreState(e.timeScale,t),this._updateDateTimeFormatter()}var n;if(e.timeScale&&this._timeScale.restoreState(e.timeScale,t),!this.readOnly()){const t=this._getExceedingChildStudies(e.panes);if(t.length){for(let i=e.panes.length-1;i>=0;--i){const s=e.panes[i];for(let e=s.sources.length-1;e>=0;--e){const i=s.sources[e];~t.indexOf(i)&&s.sources.splice(e,1)}s.sources.length||e.panes.splice(i,1)}0}}const o=e.version||0,a=e.panes;let l="_seriesId";for(const e of a){const t=e.sources.find((e=>"MainSeries"===e.type));if(t){l=t.id;break}}this.panes()[0].restoreState(a[0],t,o,l,r,i,!0);let c=1;for(let s=1;s_&&u%100==0?{lines_limit_exceeded:!0,line_tools_count:u}:(this.panes().forEach((e=>this._dataSourceCollectionChanged.fire(e))),this._lineToolsGroupModel.fireChangedAll(),this._linkingGroupIndex.setValue(null!==(s=e.linkingGroup)&&void 0!==s?s:null),{})}shouldBeSavedEvenIfHidden(){return this._shouldBeSavedEvenIfHidden}setShouldBeSavedEvenIfHidden(e){this._shouldBeSavedEvenIfHidden=e}externalTimeStamp(e){const t=this.mainSeries().syncModel();return this.timeScale().points().roughTime(e,t&&t.projectTime.bind(t))}syncLollipopSources(){null!==this._lollipopSourcesWatcher&&this._lollipopSourcesWatcher.syncSources()} +restoreChartEvents(e){null!==this._lollipopSourcesWatcher&&this._options.chartEventsEnabled&&this._lollipopSourcesWatcher.restoreChartEvents(e)}recalcVisibleRangeStudies(e){this._recalcVRStudiesParams.force=this._recalcVRStudiesParams.force||Boolean(e),this._recalcVisibleRangeStudiesImplDebounced()}recalcColorStudies(e){this._recalcColorStudiesParams.force=this._recalcColorStudiesParams.force||Boolean(e),this._recalcColorStudiesImplDebounced()}recalcStudyBasedLineTools(){this.dataSources().forEach((e=>{(0,S.isStudyLineTool)(e)&&e.recalcStudyIfNeeded()}))}alertsWatcher(){return this._alertsWatcher}showLegend(){return this._showLegendProperty}id(){return this._id}selectPointMode(){return this._crossHairSelectPointMode}cancelRequestSelectPoint(){this.m_crossHairSource.cancelRequestSelectPoint()}requestSelectPoint(e){return this.m_crossHairSource.requestSelectPoint(e)}onPointSelected(){return this.m_crossHairSource.onPointSelected()}recalculatePriceRangeOnce(){const e=this.mainSeries();for(const t of this._panes)for(const i of t.priceDataSources())i.symbolSource()===e&&i.disablePriceRangeReady()}invalidate(e){var t;null===(t=this._invalidateHandler)||void 0===t||t.call(this,e)}appliedTimeFrame(){return this._appliedTimeFrame.appliedTimeFrame()}barsMarksSources(){return this._barsMarksSources}createSyncPoint(e,t){return(0,Yi.getDefault2Lazy)(this._syncPointCache,e.uniqueId,t.uniqueId,(()=>new Mt(e,t)))}isAutoSaveEnabled(){return this._isAutoSaveEnabled}linkingGroupIndex(){return this._linkingGroupIndex}studyAwareDefaultRightOffset(){return this._timeScale.usePercentageRightOffset().value()?this._timeScale.percentsToBarIndexLength(this.studyAwareDefaultRightOffsetPercentage()):Math.max(this._timeScale.defaultRightOffset().value(),this._cachedStudiesMaxOffset)}studyAwareDefaultRightOffsetPercentage(){return this._timeScale.usePercentageRightOffset().value()?Math.max(this._timeScale.defaultRightOffsetPercentage().value(),this._timeScale.barIndexLengthToPercents(this._cachedStudiesMaxOffset)):this._timeScale.barIndexLengthToPercents(this.studyAwareDefaultRightOffset())}clearAllStudies(){this.dataSources().forEach((e=>{var t;return null===(t=e.clearData)||void 0===t?void 0:t.call(e)}))}setTimeScaleAnimation(e){const t=Y.InvalidationMask.light();t.setTimeScaleAnimation(e),this.invalidate(t)}stopTimeScaleAnimation(){const e=Y.InvalidationMask.light();e.stopTimeScaleAnimation(),this.invalidate(e)}lollipopSourcesOptions(){const e=this._options;return{chartEventsEnabled:!this._options.isSnapshot&&this._options.chartEventsEnabled,esdEnabled:e.esdEnabled,continuousContractSwitchesEnabled:e.continuousContractSwitchesEnabled,futuresContractExpirationEnabled:e.futuresContractExpirationEnabled,latestUpdatesEnabled:e.latestUpdatesEnabled}}_initAlertsList(){throw new Error("Not implemented")}_updateStudiesMaxOffset(){const e=Math.max(...this.allStudies().map((e=>e.maxOffset().value())));this._cachedStudiesMaxOffset=e;const t=this._timeScale.rightOffset();if(t<0)return;if(e<=t)return;const i=this._timeScale.logicalRange() +;i?this._timeScale.zoomToBarsRange(i.left(),this._timeScale.baseIndex()+Math.max(this._timeScale.rightOffset(),e)):this._timeScale.setRightOffset(Math.max(t,e))}_updateBaseIndex(e,t){const i=this._timeScale,s=i.baseIndex(),r=i.logicalRange();if(null!==r&&t){const t=r.contains(s),n=e-s,o=t?null:i.rightOffset()-n;if(!this._options.shiftVisibleRangeOnNewBar&&t){const e=i.width()/i.barSpacing(),t=e/(e+n),s=Math.max(i.minBarSpacing(),i.barSpacing()*t);i.setBarSpacing(s)}null!==o&&i.setRightOffset(o)}i.setBaseIndex(e)}_createLollipopSourcesWatcher(){}_updateDateTimeFormatter(){const e=St.dateFormatProperty.value(),t=void 0;if(this._dateFormatter=new vt.DateFormatter(e,t),this.mainSeries().isDWM())this._dateTimeFormatter=new vt.DateFormatter(e,t),this._timeFormatter=new lt.TimeFormatter((0,ct.getHourMinuteFormat)(at.timeHoursFormatProperty.value()));else{const i=x.Interval.parse(this.mainSeries().interval()),s=(0,ct.getTimeFormatForInterval)(i,at.timeHoursFormatProperty.value());this._dateTimeFormatter=new ft.DateTimeFormatter({dateFormat:e,withWeekday:t,timeFormat:s,dateTimeSeparator:" "}),this._timeFormatter=new lt.TimeFormatter(s)}}_invalidationMaskForSource(e,t=Y.InvalidationLevel.Light){if(e===this.crossHairSource())return Y.InvalidationMask.cursor();if(this._watermarkSource===e)return this._paneInvalidationMask((0,n.ensureNotNull)(this.paneForSource(this.mainSeries())),t);if(-1!==this._allCustomSources.indexOf(e)){const e=new Y.InvalidationMask;return e.invalidateAll(t),e}if(!(0,f.isDataSource)(e))return null;if(e.isMultiPaneEnabled())return new Y.InvalidationMask(t);const i=this.paneForSource(e);return null!==i?this._paneInvalidationMask(i,t):null}_paneInvalidationMask(e,t=Y.InvalidationLevel.Light){const i=new Y.InvalidationMask,s=this._panes.indexOf(e);return i.invalidateAllPane(s,t),i}_invalidationMaskForSourcePriceScale(e,t=Y.InvalidationLevel.Light){if(!(0,f.isDataSource)(e))return new Y.InvalidationMask(t);const i=this.paneForSource(e);if(null===i)return null;let s=e.priceScale();if(null===s)return null;const r=this._panes.indexOf(i);let n=i.priceScalePosition(s);if("overlay"===n){const e=this._panes[r].defaultPriceScale();s=e,n=i.priceScalePosition(e)}const o=i.priceScaleIndex(s,n);if(void 0===o)return null;const a=new Y.InvalidationMask;return a.invalidatePriceScale(r,n,o,t),a}_removeCustomSource(e){const t=this._customSourcesMap.get(e);if(void 0===t)return void ns.logWarn(`Attempt to remove custom source which does not exist in the model - "${e}"`);ns.logNormal(`Removing custom source "${e}"`),this.selectionMacro((e=>{e.removeSourceFromSelection(t)})),this._hoveredSource===t&&this.setHoveredSource(null),this._customSourceBeingMoved===t&&this.setMovingCustomSource(null,null);const i=os(this._bgCustomSources,t),s=os(this._fgCustomSources,t),r=os(this._topmostCustomSources,t),o=os(this._allCustomSources,t);(0,n.assert)(i||s||r,"Source should be presented in one of the layers"),(0,n.assert)(o,"Source should be presented in the array"),this._customSourcesMap.delete(e),t.destroy()}_updateShowLegendProperty(){ +const e=this._properties.childs().paneProperties.childs().legendProperties.childs().showLegend,t=this._showLegendProperty;if(e.value())t.setValue(!0);else{for(const e of this._panes){let i=0;for(const s of e.priceDataSources())if(s!==this.mainSeries()&&null!==s.statusView()&&(i++,i>=2))return void t.setValue(!1)}t.setValue(!0)}}_pointToPercentPosition(e,t){return{x:e.x/this._timeScale.width(),y:e.y/(0,n.ensureNotNull)((0,n.ensureNotNull)(t.mainDataSource()).priceScale()).height()}}_percentPositionToPoint(e,t){const i=e.x*this._timeScale.width(),s=e.y*(0,n.ensureNotNull)((0,n.ensureNotNull)(t.mainDataSource()).priceScale()).height();return new o.Point(i,s)}_recalcVisibleRangeStudiesImpl(e){var t,i,s;if(e.timerId=null,this.timeScale().isEmpty())return;const r=this.timeScale().visibleBarsStrictRange();if(null===r)return;const n=this.mainSeries().bars(),o=n.search(r.firstBar(),dt.PlotRowSearchMode.NearestRight),a=n.search(r.lastBar(),dt.PlotRowSearchMode.NearestLeft),l=n.lastIndex(),c=o?o.index:void 0,h=a?a.index:void 0,d=c===e.oldStartVisibleIndex,u=h===e.oldEndVisibleIndex;if(d&&u&&!e.force)return;e.force=!1,e.oldStartVisibleIndex=void 0!==c?c:NaN,e.oldEndVisibleIndex=void 0!==h?h:NaN;const p={first_visible_bar_time:1e3*(null!==(t=null==o?void 0:o.value[0])&&void 0!==t?t:0),last_visible_bar_time:1e3*(null!==(i=null==a?void 0:a.value[0])&&void 0!==i?i:0),subscribeRealtime:(null==a?void 0:a.index)===l},_=null!==(s=e.studies)&&void 0!==s?s:this.priceDataSources();e.studies=void 0;for(const e of _)if((0,j.isStudy)(e)){const t=e.metaInfo().inputs,i=[];for(const e of t)p.hasOwnProperty(e.id)&&i.push(e.id);const s=e.properties().childs().inputs;for(const e of i)s.childs()[e].setValueSilently(p[e]);i.length>0&&s.listeners().fire(s)}}_recalcColorStudiesImpl(e){var t;e.timerId=null;const i=this.backgroundColorAtYPercentFromTop(.5),s=this.dark().value()?l.colorsPalette["color-cold-gray-200"]:l.colorsPalette["color-cold-gray-900"],r=i===e.oldBgColor,n=s===e.oldFgColor;if(r&&n&&!e.force)return;e.force=!1,e.oldBgColor=i,e.oldFgColor=s;const o={__chart_bgcolor:i,__chart_fgcolor:s},a=null!==(t=e.studies)&&void 0!==t?t:this.priceDataSources();e.studies=void 0;for(const e of a)if((0,j.isStudy)(e)){const t=e.metaInfo().inputs,i=[];for(const e of t)o.hasOwnProperty(e.id)&&i.push(e.id);const s=e.properties().childs().inputs;for(const e of i)s.childs()[e].setValueSilently(o[e]);i.length>0&&s.listeners().fire(s)}}_getAllSources(e){const t=[];for(const i of this._panes){const s=i.sourcesByGroup().all();for(const i of s)e(i)&&t.push(i)}return t}_invalidateBarColorerCaches(){this.mainSeries().invalidateBarColorerCache()}_addAlertLabelToChart(e){throw new Error("Not implemented")}_removeAlertLabelFromChart(e){throw new Error("Not implemented")}_removeAllAlertLabelsFromChart(){throw new Error("Not implemented")}_updateTimeScale(e){var t,i,s,r;const{index:n,zoffset:o,values:a,indexDiffs:l,baseIndex:c,marks:h,clearFlag:d}=e;if(d){this._timeScale.reset();for(const e of this.dataSources())null===(t=e.clearData)||void 0===t||t.call(e)} +if(l.length>0)for(const e of this.dataSources())null===(i=e.moveData)||void 0===i||i.call(e,l);const u=this._timeScale.indexToTimePoint(this._timeScale.baseIndex()),p=this._timeScale.canNormalize();this._timeScale.update(n,o,a,h);const _=this._timeScale.points().range().value();let m="ChartModel.prototype._updateTimeScale("+n+","+o+","+a.length+","+l.length+","+h.length+","+d+")";if(m+="TimeScale: {first:"+(null!==(s=null==_?void 0:_.firstIndex)&&void 0!==s?s:null)+",last:"+(null!==(r=null==_?void 0:_.lastIndex)&&void 0!==r?r:null)+"}",null===c){this._timeScale.resetBaseIndex();const e=this._timeScale.rightOffset();e<0?this._timeScale.setRightOffset(this.studyAwareDefaultRightOffset()):this._timeScale.setRightOffset(Math.max(e,this._cachedStudiesMaxOffset))}else if(void 0!==c){const e=this._timeScale.indexToTimePoint(c),t=null!==u&&null!==e&&e>u;this._updateBaseIndex(c,t)}if(ns.logDebug(m),!p&&p!==this._timeScale.canNormalize())for(const e of this.dataSources())!(0,S.isLineTool)(e)||e.isFixed()||e.isSourceHidden()||e.processHibernate();this.recalculateAllPanes((0,W.globalChangeEvent)()),this.lightUpdate()}_getAvailableCurrencies(){return!this.currencyConversionEnabled()||this.isSnapshot()?[]:(0,ie.isArray)(this._availableCurrenciesList)?this._availableCurrenciesList:(null!==this._availableCurrenciesList||(this._availableCurrenciesList=this.chartApi().availableCurrencies(),this._availableCurrenciesList.then((e=>{this._destroyed||(this._availableCurrenciesList=e,this.fullUpdate())})).catch((e=>{ns.logWarn(`An error occurred while getting currencies config: ${e}`)}))),[])}_getAvailableUnits(){return!this.unitConversionEnabled()||this.isSnapshot()?{}:this._availableUnitsObject instanceof Promise||null===this._availableUnitsObject?(null!==this._availableUnitsObject||(this._availableUnitsObject=this.chartApi().availableUnits(),this._availableUnitsObject.then((e=>{this._destroyed||(this._availableUnitsObject=e,this.fullUpdate())})).catch((e=>{ns.logWarn(`An error occurred while getting units config: ${e}`)}))),{}):this._availableUnitsObject}_getAvailablePriceSources(){return Array.isArray(this._availablePriceSourcesList)?this._availablePriceSourcesList:(this._availablePriceSourcesList=this.chartApi().availablePriceSources(this.m_mainSeries.getSymbolString()),this._availablePriceSourcesList.then((e=>{this._destroyed||(this._availablePriceSourcesList=e,this.fullUpdate())})).catch((e=>{ns.logWarn(`An error occurred while getting price sources config: ${e}`)})),[])}_clearAvailablePriceSources(){this._availablePriceSourcesList=null}_getBackgroundColor(e){const t=this._properties.childs().paneProperties.childs();if(t.backgroundType.value()===kt.ColorType.Gradient){const i=t.backgroundGradientStartColor.value(),s=t.backgroundGradientEndColor.value();return e?i:s}return t.background.value()}_getBackgroundCounterColor(){const e=this.backgroundColor().value();return"black"===(0,a.rgbToBlackWhiteString)((0,a.parseRgb)(e),150)?"white":"black"}_updateBackgroundColor(){this._backgroundColor.setValue(this._getBackgroundColor()), +this._backgroundTopColor.setValue(this._getBackgroundColor(!0))}_syncCrosshair(e){if(!this._isSettingsExternalPosition){const t=this._undoModel.chartWidget(),i=this._undoModel.mainSeries(),s=i.syncModel(),r=this._undoModel.crossHairSource(),n=r.pane;if(null!==s&&null!==n){const o={timeStamp:this._timeScale.points().roughTime(r.index,s.projectTime.bind(s)),syncSourceTarget:s.syncSourceTarget()};n.mainDataSource()===i&&(o.price=r.price,o.symbol=i.symbol());let a=this._lineBeingCreated||null!==this._linePointBeingEdited||Boolean(this._sourcesBeingMoved.length);a=a&&(0,Se.drawOnAllCharts)().value(),t.chartWidgetCollection().syncCrosshair(o,t.id(),a,e)}this._phantomSourceContainer.onCursorPositionUpdated()}}_gotoTimeImpl(e,t){const i=this.timeScale(),s=this.mainSeries();let r;if(void 0!==e){if(this._scrollingState&&this._scrollingState.deferred.reject(),r=(0,p.createDeferredPromise)(),!s.isDWM()){const t=s.symbolInfo();if(null!==t){let i=this.properties().childs().timezone.value();"exchange"===i&&(i=t.timezone);const r=(0,Pt.cal_to_utc)((0,Pt.get_timezone)(i),new Date(e)),n=(0,Ht.createTimeToBarTimeAligner)(s.interval(),t)(r);e=(0,Pt.utc_to_cal)((0,Pt.get_timezone)(i),n).getTime()}}this._scrollingState={targetDate:e,deferred:r,centerIfVisible:t.centerIfVisible}}else{if(!this._scrollingState)return ns.logError("scrollTo called without an argument"),Promise.reject();e=this._scrollingState.targetDate,r=this._scrollingState.deferred}if(void 0===i.tickMarks().minIndex)return r.resolve(void 0),r.promise;this.stopTimeScaleAnimation();let o=((e,t)=>{if((e=>(0,n.ensureNotNull)(i.tickMarks().indexToTime((0,n.ensureDefined)(i.tickMarks().minIndex))).valueOf()-e)(t)<0){let r=i.tickMarks().nearestIndex(t);const o=s.bars().lastIndex();if(null===o)return null;r=Math.min(r,o);let a=(0,n.ensureNotNull)(i.tickMarks().indexToTime(r)).valueOf();for(;a1&&s.push(e)),n=(n+1)%t.length}return s}}},16410:(e,t,i)=>{"use strict";i.d(t,{allChartStyles:()=>o,commonChartStyles:()=>n,japaneseChartStyles:()=>r});var s=i(14483);function r(){return s.enabled("japanese_chart_styles"),[8]}function n(){const e=[0,1,9,13,2,14,15,3,16,10];return s.enabled("chart_style_hilo")&&e.push(12),e}function o(){return n().concat(r())}},65795:(e,t,i)=>{"use strict";i.d(t,{ChartUndoModelBase:()=>Zi});var s=i(85459),r=i.n(s),n=i(16230),o=i(50151),a=i(86441),l=i(44352),c=i(61345),h=i(21866),d=i(42856),u=i(17133),p=i(36274);function _(e,t){return!!p.Interval.isEqual(e.res,t.res)&&(0,u.areEqualTimeFrames)(e.val,t.val)}var m=i(93244),g=i(69618),f=i(92249),v=i(88275),S=i(51768),y=i(39262),b=i(14483),w=i(59224),P=i(28853),C=i(36298),x=i(1722);const T=new C.TranslatedString("move all scales to left",l.t(null,void 0,i(81898))),I=new C.TranslatedString("move all scales to right",l.t(null,void 0,i(22863))),M=(0,w.getLogger)("Chart.MergeAllScales");var L=i(62591);class A extends L.UndoCommand{constructor(e,t,i,s,r,n){super(n),this._model=e,this._paneIndex=e.panes().indexOf(t),this._targetPosition=s,this._targetIndex=r,this._scaleId=i.id(),this._sourcePosition=t.priceScalePosition(i),"overlay"!==this._sourcePosition&&(this._sourceIndex=t.priceScaleIndex(i,this._sourcePosition))}redo(){const e=this._model.panes()[this._paneIndex],t=(0,o.ensureNotNull)(e.getPriceScaleById(this._scaleId));e.movePriceScale(t,this._targetPosition,this._targetIndex),this._model.fullUpdate()}undo(){const e=this._model.panes()[this._paneIndex],t=(0,o.ensureNotNull)(e.getPriceScaleById(this._scaleId));e.movePriceScale(t,this._sourcePosition,this._sourceIndex),this._model.fullUpdate()}}class k extends L.UndoCommand{constructor(e,t,i,s){super(s),this._createdIds=[],this._model=e,this._withoutShift=i,this._origStates=t.map((e=>e.state(!0)));const r=e.lineToolsGroupModel();this._origGroups=t.map((e=>{const t=r.groupForLineTool(e);return t&&t.id}))}redo(){const e=this._model.lineToolsGroupModel(),t=this._origStates.map(((t,i)=>{const s=(0,o.ensureNotNull)(this._model.dataSourceForId(t.id)),r=0===this._createdIds.length?void 0:(0,o.ensureDefined)(this._createdIds[i]),n=(0,f.cloneLineTool)(this._model,s,!this._withoutShift,r);void 0!==t.sharingMode&&n.share(t.sharingMode);const a=(0,o.ensureNotNull)(s.priceScale());(0,o.ensureNotNull)(this._model.paneForSource(s)).addDataSource(n,a,!1) +;const l=this._origGroups[i];if(null!==l){const t=e.groupForId(l);t&&t.addLineTools([n])}return this._model.updateSource(n),n}));0===this._createdIds.length&&(this._createdIds=t.map((e=>e.id()))),this._model.selectionMacro((e=>{e.clearSelection(),t.forEach((t=>{e.addSourceToSelection(t)}))})),this._model.setShouldBeSavedEvenIfHidden(!0)}undo(){const e=this._model.lineToolsGroupModel();this._createdIds.forEach((t=>{const i=(0,o.ensureNotNull)(this._model.dataSourceForId(t)),s=e.groupForLineTool(i);null!==s&&s.excludeLineTool(i),this._model.removeSource(i)}))}newIds(){return this._createdIds}}var D=i(47513),E=i(93562);class V extends L.UndoCommand{constructor(e,t,i,s=!0){super(i,s),this._newStates=[],this._model=e,this._savedStates=t.map((e=>e.state(!1)))}redo(){this._applyState(this._newStates)}undo(){0===this._newStates.length&&this.saveNewState(),this._applyState(this._savedStates)}saveNewState(){const e=this._savedStates.filter(x.notNull).map((e=>(0,o.ensureNotNull)(this._model.dataSourceForId(e.id))));this._newStates=e.map((e=>e.state(!1)))}_applyState(e){for(const t of e)if(null!==t){const e=this._model.dataSourceForId(t.id);if(null!==e)if((0,P.isStudy)(e)){const i=t.state.inputs,s=e.properties().childs().inputs.childs();for(const e in i)s[e]&&s[e].setValue(i[e])}else this._model.restoreLineToolState(e,t,!0)}}}var B=i(95529),R=i(11235),N=i(98517),O=i(14292),F=i(74007),W=i(37591);const H=new C.TranslatedString("bring {title} to front",l.t(null,void 0,i(78246))),z=new C.TranslatedString("send {title} to back",l.t(null,void 0,i(66781))),U=new C.TranslatedString("insert {title} after {targetTitle}",l.t(null,void 0,i(53146))),j=new C.TranslatedString("insert {title} before {targetTitle}",l.t(null,void 0,i(67176))),G=new C.TranslatedString("send {title} backward",l.t(null,void 0,i(16259))),q=new C.TranslatedString("bring {title} forward",l.t(null,void 0,i(56763))),$=new C.TranslatedString("send group {title} backward",l.t(null,void 0,i(4998))),Y=new C.TranslatedString("bring group {title} forward",l.t(null,void 0,i(27195)));function K(e){return new C.TranslatedString(e.name(),e.title(W.TitleDisplayTarget.StatusLine))}class Z extends L.UndoCommand{constructor(e,t,i){super(i),this._sourcesByPanes=new Map,this._originalState=new Map,this._model=e,t.forEach((t=>{const i=(0,o.ensureNotNull)(e.paneForSource(t)),s=e.panes().indexOf(i),r=this._sourcesByPanes.get(s)||[];r.push(t.id()),this._sourcesByPanes.set(s,r)})),Array.from(this._sourcesByPanes.keys()).forEach((t=>{const i=e.panes()[t],s=new Map;i.sourcesByGroup().allIncludingHidden().forEach((e=>{s.set(e.id(),e.zorder())})),this._originalState.set(t,s)}))}undo(){this._originalState.forEach(((e,t)=>{const i=this._model.panes()[t],s=new Map;e.forEach(((e,t)=>{const r=(0,o.ensureNotNull)(i.dataSourceForId(t));s.set(r,e)})),i.setZOrders(s)}))}redo(){this._sourcesByPanes.forEach(((e,t)=>{const i=this._model.panes()[t],s=e.map((e=>(0,o.ensureNotNull)(i.dataSourceForId(e))));this._paneOperation(i,s)}))}}class X extends Z{constructor(e,t){super(e,t,H.format({title:K(t[0])}))} +_paneOperation(e,t){e.bringToFront(t)}}class J extends Z{constructor(e,t){super(e,t,z.format({title:K(t[0])}))}_paneOperation(e,t){e.sendToBack(t)}}class Q extends Z{constructor(e,t,i,s){super(e,t,s),this._targetSource=i}_paneOperation(e,t){e.insertAfter(t,this._targetSource)}}class ee extends Q{constructor(e,t,i){super(e,t,i,U.format({title:K(t[0]),targetTitle:K(i)}))}}class te extends Z{constructor(e,t,i,s){super(e,t,s),this._targetSource=i}_paneOperation(e,t){e.insertBefore(t,this._targetSource)}}class ie extends te{constructor(e,t,i){super(e,t,i,j.format({title:K(t[0]),targetTitle:K(i)}))}}function se(e,t){const i=t[0],s=e.sourcesByGroup().all().filter((e=>e.zorder()e.zorder()>i.zorder()));if(0===s.length)throw new Error("Cannot bring forward source that alreadt on back");let r=s[0];if((0,f.isLineTool)(r)){const t=e.model().lineToolsGroupModel().groupForLineTool(r);if(null!==t){const e=t.lineTools();r=e[e.length-1]}}return r}class oe extends Q{constructor(e,t,i){super(e,i,ne(t,i),q.format({title:K(i[0])}))}}function ae(e,t){return(0,o.ensureNotNull)(e.paneForSource(t.lineTools()[0]))}class le extends te{constructor(e,t){super(e,t.lineTools(),se(ae(e,t),t.lineTools()),$.format({title:t.name()}))}}class ce extends Q{constructor(e,t){super(e,t.lineTools(),ne(ae(e,t),t.lineTools()),Y.format({title:t.name()}))}}const he=new C.TranslatedString("rearrange panes",l.t(null,void 0,i(33348)));class de extends L.UndoCommand{constructor(e,t,i){super(he),this._chartModel=e,this._index=t,(0,x.isNumber)(i)?this._dstIndex=i:this._dstIndex="up"===i?t-1:t+1}redo(){this._checkIndices()&&this._chartModel.movePane(this._index,this._dstIndex)}undo(){this._checkIndices()&&this._chartModel.movePane(this._dstIndex,this._index)}_checkIndices(){const e=this._chartModel.panes().length;return this._index>=0&&this._index=0&&this._dstIndexe.id()))}redo(){const e=(0,o.ensureNotNull)(this._model.lineToolsGroupModel().groupForId(this._groupId));this._model.lineToolsGroupModel().removeGroup(e)}undo(){const e=this._lineToolsIds.map((e=>this._model.dataSourceForId(e))),t=new we.LineToolsGroup(e,this._groupName,this._groupId);this._model.lineToolsGroupModel().addGroup(t)}}const Ce=new C.TranslatedString("create line tools group",l.t(null,void 0,i(3195)));class xe extends L.UndoCommand{constructor(e,t){super(Ce),this._groupId=null,this._model=e,this._sourcesIds=t.map((e=>e.id()))}redo(){const e=this._sourcesIds.map((e=>this._model.dataSourceForId(e))),t=null===this._groupId?void 0:this._groupId;this._groupId=this._model.lineToolsGroupModel().createGroup(e,this._title,t).id}undo(){const e=(0,o.ensureNotNull)(this._model.lineToolsGroupModel().groupForId((0,o.ensureNotNull)(this._groupId))) +;this._model.lineToolsGroupModel().removeGroup(e)}createdGroupId(){return this._groupId}}const Te=new C.TranslatedString("add line tool(s) to group {group}",l.t(null,void 0,i(40242)));class Ie extends L.UndoCommand{constructor(e,t,i){super(Te.format({group:t.name()})),this._model=e,this._groupId=t.id,this._lineToolsIds=i.map((e=>e.id()))}redo(){const e=(0,o.ensureNotNull)(this._model.lineToolsGroupModel().groupForId(this._groupId)),t=this._lineToolsIds.map((e=>this._model.dataSourceForId(e)));e.addLineTools(t)}undo(){const e=this._lineToolsIds.map((e=>this._model.dataSourceForId(e)));(0,o.ensureNotNull)(this._model.lineToolsGroupModel().groupForId(this._groupId)).excludeLineTools(e)}}class Me extends L.UndoCommand{constructor(e,t,i,s,r){super(i),this._targetObj=e,this._newValue=t,this._oldValue=this._targetObj.value(),this._model=s,r&&this.setCustomFlag("doesnt_affect_save",!0)}redo(){(0,_e.saveDefaultProperties)(!0),this._targetObj.setValue(this._newValue),(0,_e.saveDefaultProperties)(!1),this._model.recalculateAllPanes((0,ve.globalChangeEvent)()),this._model.lightUpdate()}undo(){(0,_e.saveDefaultProperties)(!0),this._targetObj.setValue(this._oldValue),(0,_e.saveDefaultProperties)(!1),this._model.recalculateAllPanes((0,ve.globalChangeEvent)()),this._model.lightUpdate()}}class Le extends L.UndoCommand{constructor(e,t,i,s){super(s),this._chartModel=e,this._groupId=t.id,this._oldName=t.name(),this._newName=i}redo(){(0,o.ensureNotNull)(this._chartModel.lineToolsGroupModel().groupForId(this._groupId)).setName(this._newName)}undo(){(0,o.ensureNotNull)(this._chartModel.lineToolsGroupModel().groupForId(this._groupId)).setName(this._oldName)}}var Ae=i(88348);const ke=new C.TranslatedString("create line tools group from selection",l.t(null,void 0,i(92659))),De=new C.TranslatedString("removing line tools group {name}",l.t(null,void 0,i(78811))),Ee=new C.TranslatedString("add line tool {lineTool} to group {name}",l.t(null,void 0,i(99113))),Ve=new C.TranslatedString("make group {group} visible",l.t(null,void 0,i(87927))),Be=new C.TranslatedString("make group {group} invisible",l.t(null,void 0,i(45223))),Re=new C.TranslatedString("lock group {group}",l.t(null,void 0,i(4963))),Ne=new C.TranslatedString("unlock group {group}",l.t(null,void 0,i(51114))),Oe=new C.TranslatedString("rename group {group} to {newName}",l.t(null,void 0,i(16338))),Fe=!1;class We{constructor(e){this._environment=e}createGroupFromSelection(){const e=this._environment.model();(0,o.assert)(!e.selection().isEmpty(),"Cannot create group from empty selection");const t=(0,N.sortSources)(e.selection().lineDataSources());(0,o.assert)(t.length===e.selection().allSources().length,"A group could contain line tools only");const i=t.length>1||null!==this._environment.model().lineToolsGroupModel().groupForLineTool(t[0]),s=t.reduce(((e,t)=>e.zorder()>t.zorder()?e:t),t[0]);let r=s;const n=e.lineToolsGroupModel().groupForLineTool(s);if(null!==n){const e=n.lineTools();r=e[e.length-1]}this._environment.beginUndoMacro(ke,Fe);const a=new Map,l=new Set;t.forEach((t=>{ +const i=this._groupForLineTool(t);if(null===i)return;const s=a.get(i)||[];s.push(t),a.set(i,s);const r=(0,o.ensureNotNull)(e.paneForSource(t));l.add(r)})),(0,o.assert)(l.size<=1,"All selected sources should be on the same pane"),a.forEach(((t,i)=>{const s=new E.ExcludeLineToolsFromGroupUndoCommand(e,i,t);this._environment.pushUndoCommand(s)}));const c=new xe(e,(0,N.sortSources)(t));if(this._environment.pushUndoCommand(c),i){const i=new ee(e,t,r);this._environment.pushUndoCommand(i)}this._environment.endUndoMacro();const h=(0,o.ensureNotNull)(c.createdGroupId());return(0,o.ensureNotNull)(e.lineToolsGroupModel().groupForId(h))}removeGroup(e){const t=this._environment.model(),i=e.lineTools();this._environment.beginUndoMacro(De.format({name:e.name()}),Fe);const s=new Pe(t,e,null);this._environment.pushUndoCommand(s);const r=new D.RemoveSourcesUndoCommand(t,i,null);this._environment.pushUndoCommand(r);const n=t.mainSeries().symbol();i.forEach((e=>{null!==e.linkKey().value()&&(0,Ae.removeLineTool)({withUndo:!0,model:t,symbol:n,sourceTitle:new C.TranslatedString(e.name(),e.title(W.TitleDisplayTarget.DataWindow)),lineToolState:e.state(!1),linkKey:(0,o.ensureNotNull)(e.linkKey().value())})})),this._environment.endUndoMacro()}groups(){return this._environment.model().lineToolsGroupModel().groups()}excludeLineToolFromGroup(e,t){const i=this._environment.model(),s=new E.ExcludeLineToolsFromGroupUndoCommand(i,e,[t]);s.setCustomFlag("doesnt_affect_save",Fe),this._environment.pushUndoCommand(s)}addLineToolToGroup(e,t){const i=this._environment.model(),s=i.lineToolsGroupModel().groupForLineTool(t);if(s===e)return;const r=Ee.format({lineTool:new C.TranslatedString(t.name(),t.title(W.TitleDisplayTarget.StatusLine)),name:e.name()});this._environment.beginUndoMacro(r,Fe),null!==s&&this._environment.pushUndoCommand(new E.ExcludeLineToolsFromGroupUndoCommand(i,s,[t])),this._environment.pushUndoCommand(new Ie(i,e,[t])),this._environment.endUndoMacro()}bringToFront(e){const t=this._environment.model(),i=new X(t,e.lineTools());i.setCustomFlag("doesnt_affect_save",Fe),this._environment.pushUndoCommand(i),this._environment.emitEvent("changeZOrder",[e.lineTools()])}sendToBack(e){const t=this._environment.model(),i=new J(t,e.lineTools());i.setCustomFlag("doesnt_affect_save",Fe),this._environment.pushUndoCommand(i),this._environment.emitEvent("changeZOrder",[e.lineTools()])}bringForward(e){const t=this._environment.model(),i=new ce(t,e);i.setCustomFlag("doesnt_affect_save",Fe),this._environment.pushUndoCommand(i),this._environment.emitEvent("changeZOrder",[e.lineTools()])}sendBackward(e){const t=this._environment.model(),i=new le(t,e);i.setCustomFlag("doesnt_affect_save",Fe),this._environment.pushUndoCommand(i),this._environment.emitEvent("changeZOrder",[e.lineTools()])}insertAfter(e,t){const i=this._environment.model();let s;if(t instanceof we.LineToolsGroup){const e=t.lineTools();s=e[e.length-1]}else s=t;const r=new ee(i,e.lineTools(),s);this._environment.pushUndoCommand(r),this._environment.emitEvent("changeZOrder",[e.lineTools()])} +insertBefore(e,t){const i=this._environment.model();let s;if(t instanceof we.LineToolsGroup){s=t.lineTools()[0]}else s=t;const r=new ie(i,e.lineTools(),s);this._environment.pushUndoCommand(r),this._environment.emitEvent("changeZOrder",[e.lineTools()])}availableZOrderOperations(e){const t=this._environment.model(),i=e.lineTools(),s=i[0],r=i[i.length-1],n=(0,o.ensureNotNull)(t.paneForSource(i[0])).sourcesByGroup().allExceptSpecialSources(),a=n[0],l=n[n.length-1];return{bringForwardEnabled:r!==l,bringToFrontEnabled:r!==l,sendBackwardEnabled:s!==a,sendToBackEnabled:s!==a}}setGroupVisibility(e,t){const i=(t?Ve:Be).format({group:e.name()}),s=this._environment.model();this._environment.beginUndoMacro(i,Fe),e.lineTools().forEach((e=>{const i=e.properties().visible,r=new Me(i,t,null,s);this._environment.pushUndoCommand(r)})),this._environment.endUndoMacro()}setGroupLock(e,t){const i=(t?Re:Ne).format({group:e.name()}),s=this._environment.model();this._environment.beginUndoMacro(i,Fe),e.lineTools().forEach((e=>{const i=e.properties().frozen,r=new Me(i,t,null,s);this._environment.pushUndoCommand(r)})),this._environment.endUndoMacro()}setGroupName(e,t){const i=this._environment.model(),s=Oe.format({group:e.name(),newName:t}),r=new Le(i,e,t,s);r.setCustomFlag("doesnt_affect_save",Fe),this._environment.pushUndoCommand(r)}canBeGroupped(e){const t=this._environment.model();return new Set(e.map((e=>t.paneForSource(e)))).size<=1}_groupForLineTool(e){return this._environment.model().lineToolsGroupModel().groups().find((t=>t.containsLineTool(e)))||null}}var He=i(58121),ze=i(35115),Ue=i(53588),je=i(63009);const Ge=new C.TranslatedString("apply study template {template}",l.t(null,void 0,i(26065)));function qe(e){for(const t of e.panes)for(const e of t.sources)if((0,Ue.isMainSeriesState)(e))return e.id;return null}class $e extends L.UndoCommand{constructor(e,t,i){var s,r;super(Ge.format({template:i})),this._newSymbolParams={},this._model=e,this._templateContent=function(e,t){const i=(0,He.default)({},e),s=(0,o.ensureNotNull)(qe(i));for(const e of i.panes){e.mainSourceId===s&&(e.mainSourceId=t);for(const i of e.sources)if(i.id===s){i.id=t;const r=e=>{const i=e.indexOf(s);-1!==i&&e.splice(i,1,t)};if(e.leftAxisesState&&e.rightAxisesState?(e.leftAxisesState.forEach((e=>r(e.sources))),e.rightAxisesState.forEach((e=>r(e.sources)))):(r(e.leftAxisSources),r(e.rightAxisSources)),e.overlayPriceScales){const i=e.overlayPriceScales[s];i&&(delete e.overlayPriceScales[s],e.overlayPriceScales[t]=i)}}else i.ownerSource===s&&(i.ownerSource=t)}return i}(t,e.mainSeries().id()),this._initialState=e.studyTemplate(!0,!0,!0);const n=e.mainSeries();t.symbol&&(this._newSymbolParams={symbol:t.symbol,currency:null!==(s=t.currency)&&void 0!==s?s:null,unit:null!==(r=t.unit)&&void 0!==r?r:null}),t.interval&&(this._newSymbolParams.interval=t.interval,this._newSymbolParams.style=(0,me.getChartStyleByResolution)(t.interval,n.style())),this._initialSymbolParams={symbol:n.symbol(),currency:n.currency(),unit:n.unit(),interval:n.interval(),style:n.style()}, +this._initialState=e.studyTemplate(),this._initialGroupsState=e.lineToolsGroupModel().state()}redo(){this._model.mainSeries().setSymbolParams(this._newSymbolParams);const e=this._merge(this._templateContent).filter(f.isLineTool);this._model.lineToolsGroupModel().removeLineTools(e);const t=this._model.mainSeries().properties();(0,me.preparePriceAxisProperties)(t),this._model.recalcVisibleRangeStudies(!0),this._model.setShouldBeSavedEvenIfHidden(!0)}undo(){this._model.mainSeries().setSymbolParams(this._initialSymbolParams),this._merge(this._initialState)}_merge(e){const t=e.version||0,i=this._model,s=i.mainSeries();(0,o.assert)(s.id()===qe(e)),s.priceScale().properties().childs().lockScale.setValue(!1);const r=i.panes(),n=[];for(let e=r.length;e--;){const t=r[e],i=t.containsMainSeries(),s=t.dataSources();for(let e=s.length;e--;){const t=s[e];(!i||(0,P.isStudy)(t)&&t.isRemovedByStudyTemplates())&&n.push(t)}}i.resetDeferredStudies();const a=(0,ze.closeSourcesSet)(i,n);for(let e=0;ee.zorder-t.zorder));for(let e=0;e-1,a=o?r[e]:i.createPane(e);o&&t<3&&(0,je.reorderDataSourcesStateZOrder)(n.sources),a.restoreState(n,!1,t),null!==a.mainDataSource()||i.removePane(a)}return i.syncLollipopSources(),s.priceScale().setMode({autoScale:!0}),i.startNotStartedStudies(),i.recalculateAllPanes((0,ve.globalChangeEvent)()),i.fullUpdate(),a}}var Ye=i(36174),Ke=i(18611);const Ze=(0,w.getLogger)("Chart.ChartUndoModel"),Xe=new C.TranslatedString("paste drawing",l.t(null,void 0,i(96916)));class Je extends L.UndoCommand{constructor(e,t,i,s,r){super(Xe),this._needCopyToOtherCharts=!1,this._sourceState=null,this._model=e,this._clipboardData=t,this._paneIndex=this._model.panes().indexOf(i||(0,o.ensureNotNull)(this._model.paneForSource(this._model.mainSeries()))),this._pasteWithData=!!s,this._keepZIndex=!!r}redo(){const e=this._model.panes()[this._paneIndex],t=(0,o.ensureNotNull)(e.clipboardLineToolOwnerSource(this._clipboardData.source.id));null===this._sourceState&&(this._sourceState=this._getSourceState(t));const i=(0,o.ensureNotNull)(e.restoreLineTool(this._sourceState,this._pasteWithData,this._keepZIndex,void 0,t));(0,o.ensureNotNull)(t.priceScale()).addDataSource(i),this._clipboardData.centeredOnChart&&i.centerPosition&&i.centerPosition(),i.restoreFixedPoint(),i.createServerPoints();const s=(0,Ke.isActingAsSymbolSource)(t)||t.metaInfo().is_price_study;this._needCopyToOtherCharts=Boolean(s&&((0,Ae.drawOnAllCharts)().value()||i.linkKey().value()&&i.isSynchronizable())),this._model.setShouldBeSavedEvenIfHidden(!0)}undo(){if(!this._sourceState)return void Ze.logError("This command was never executed - nothing to undo");const e=this.source();this._clipboardData.centeredOnChart&&(this._clipboardData.centeredOnChart=!1,this._sourceState.points=e.normalizedPoints()),this._model.removeSource(e)}source(){ +return(0,o.ensureNotNull)(this._model.dataSourceForId((0,o.ensureNotNull)(this._sourceState).id))}needCopyToOtherCharts(){return this._needCopyToOtherCharts}_getSourceState(e){const t=(0,x.clone)(this._clipboardData.source);delete t.state.symbol,null!=t.linkKey&&(t.linkKey=(0,Ye.randomHash)());const i=(0,o.ensureNotNull)(e.priceScale()),s=this._model,{symbol:r,currencyId:n,unitId:l}=this._clipboardData.source.state,c=(0,o.ensureNotNull)(e.symbolSource());let h=!1;!c.symbolSameAsCurrent(r)||(null!==n?n!==(0,me.symbolCurrency)(c.symbolInfo(),void 0,!0):c.isConvertedToOtherCurrency())||(null!==l?l!==(0,me.symbolUnit)(c.symbolInfo(),this._model.unitConversionEnabled()):c.isConvertedToOtherUnit())||((0,Ke.isActingAsSymbolSource)(e)?h=!0:(0,P.isStudy)(e)&&(h=Boolean(e.metaInfo().is_price_study)));const d=e=>{const t=e.x*s.timeScale().width(),r=e.y*i.height()-40;return new a.Point(t,r)},u=(0,o.ensureNotNull)(e.firstValue());if(this._model.id()===this._clipboardData.modelId||!h)for(let e=0;e{this._symbolSource(e).setSymbolParams(e.newSymbolParams),e.showFade&&e.chartWidget.screen.show(!0)})),this._firstRedo||(0,it.muteLinkingGroup)(this._linkingGroupIndex,!1),this._firstRedo=!1}undo(){(0,it.muteLinkingGroup)(this._linkingGroupIndex,!0),this._charts.forEach((e=>{this._symbolSource(e).setSymbolParams(e.prevSymbolParams),e.showFade&&e.chartWidget.screen.show(!0)})),(0,it.muteLinkingGroup)(this._linkingGroupIndex,!1)}canMerge(e){if(!(e instanceof st)||e._linkingGroupIndex!==this._linkingGroupIndex||!this._containsMainSeriesOnly()||!e._containsMainSeriesOnly()||e._creationTime-this._creationTime>500)return!1;for(const[t]of e._charts)if(this._charts.has(t))return!1;return!0}merge(e){if(e instanceof st)for(const[t,i]of e._charts)this._charts.set(t,i)}_showFade(e,t){return e===t.model().mainSeries()}_symbolSource(e){return(0,o.ensureNotNull)(e.chartWidget.model().model().dataSourceForId(e.sourceId))}_containsMainSeriesOnly(){for(const[e,t]of this._charts)if(t.sourceId!==e.model().mainSeries().id())return!1;return!0}}const rt=new C.TranslatedString("change symbol",l.t(null,void 0,i(526)));class nt extends st{constructor(e,t,i){super(rt,e,{symbol:t, +currency:null,unit:null},i),this._symbol=t}canMerge(e){return e instanceof nt&&e._symbol===this._symbol&&super.canMerge(e)}}const ot=(0,w.getLogger)("Chart.ChartUndoModel"),at=new C.TranslatedString("paste indicator",l.t(null,void 0,i(80611)));class lt extends L.UndoCommand{constructor(e,t,i){super(at),this._sourceState=null,this._model=e,this._clipboardData=t,this._paneId=i}redo(){if(!this._sourceState){const e=(0,x.clone)(this._clipboardData.source);e.id=(0,Ye.randomHashN)(6),this._sourceState=e}let e,t;e=this._paneId?(0,o.ensureNotNull)(this._model.paneForId(this._paneId)):this._sourceState.metaInfo.is_price_study?(0,o.ensureNotNull)(this._model.paneForSource(this._model.mainSeries())):this._model.createPane();const i=!e.mainDataSource();this._sourceState.zorder=e.newStudyZOrder();const s=(0,o.ensureNotNull)(e.restoreStudy(this._sourceState,!1));i||(t=this._sourceState.metaInfo.is_price_study?t=this._model.mainSeries().priceScale():this._paneId?e.findSuitableScale(s):e.defaultPriceScale(),t!==s.priceScale()&&e.move(s,t)),(0,P.isStudy)(s)&&s.start()}undo(){if(null===this._sourceState)return void ot.logError("This command was never executed - nothing to undo");const e=(0,o.ensureNotNull)(this._model.dataSourceForId(this._sourceState.id));this._model.removeSource(e)}state(){return this._sourceState}}class ct extends L.UndoCommand{constructor(e,t,i,s,r){super(null,!1),this._model=e,this._paneA=t,this._paneB=i,this._prevStretchA=s,this._currStretchA=r}redo(){const e=this._paneA.stretchFactor()+this._paneB.stretchFactor();this._paneA.setStretchFactor(this._currStretchA),this._paneB.setStretchFactor(e-this._currStretchA),this._model.fullUpdate()}undo(){const e=this._paneA.stretchFactor()+this._paneB.stretchFactor();this._paneA.setStretchFactor(this._prevStretchA),this._paneB.setStretchFactor(e-this._prevStretchA),this._model.fullUpdate()}}var ht=i(81155);const dt=new C.TranslatedString("move",l.t(null,void 0,i(47107)));class ut extends L.UndoCommand{constructor(e,t,i,s){super(dt,!1),this._endEvent=null,this._model=e,this._sourceId=t.id(),this._itemIndex=i,this._startEvent=s}move(e){this._endEvent=e,this._move(e)}hasChanges(){return null!==this._endEvent}undo(){this._move(this._startEvent)}redo(){this._move((0,o.ensureNotNull)(this._endEvent))}_move(e){const t=(0,o.ensureNotNull)(this._model.dataSourceForId(this._sourceId));(0,o.assert)(void 0!==t.moveItem,'The method "moveItem" is not defined'),t.moveItem&&t.moveItem(new a.Point(e.localX,e.localY),this._itemIndex,new ht.EnvironmentState(e))}}class pt extends L.UndoCommand{constructor(e,t,i,s,r,n,o,a,l,c,h,d,u){super(u),this._paneState=null,this._lastInsertionStartPromise=null,this._additionalStudiesIds=[],this._chartModel=e,this._studyMetaInfo=t,this._props=s,this._addAsOverlay=r,this._parentIds=n.map((e=>e.id())),this._inputs=i,this._targetZOrder=h,this._preferredPriceScale=o,this._allowChangeCurrency=a,this._allowChangeUnit=l,this._paneSize=c,this._studyId=null!=d?d:null}redo(){ +const e=this._parentIds.map((e=>this._chartModel.dataSourceForId(e))),t=this._chartModel.insertStudyWithParams(this._studyMetaInfo,this._inputs,this._targetZOrder,this._props,this._addAsOverlay,e,this._preferredPriceScale,this._allowChangeCurrency,this._allowChangeUnit,this._paneSize,null===this._studyId?void 0:this._studyId),i=t.study;if(this._lastInsertionStartPromise=t.startPromise,this._studyId=i.id(),i.childStudyByRebind().subscribe(null,(()=>(0,S.trackEvent)("SOS","Apply SOS","Rebind SOS"))),this._chartModel.setShouldBeSavedEvenIfHidden(!0),null!==this._paneState){(0,o.ensureNotNull)(this._chartModel.paneForSource(i)).restoreState(this._paneState,!1,this._chartModel.version()),this._paneState=null}}undo(){const e=(0,o.ensureNotNull)(this._chartModel.dataSourceForId((0,o.ensureNotNull)(this._studyId)));(0,Ke.isSymbolSource)(e)&&e.symbolResolved().unsubscribeAll(this);const t=(0,o.ensureNotNull)(this._chartModel.paneForSource(e)).state();this._additionalStudiesIds.forEach((e=>{const t=(0,o.ensureNotNull)(this._chartModel.dataSourceForId(e));this._chartModel.removeSource(t)})),this._additionalStudiesIds=[],this._chartModel.removeSource(e)&&(this._paneState=t)}insertedStudy(){return this._chartModel.dataSourceForId((0,o.ensureNotNull)(this._studyId))}lastInsertionStartPromise(){var e;return null!==(e=this._lastInsertionStartPromise)&&void 0!==e?e:Promise.resolve()}_createCopiesOfNewFundamentalForAllStocks(){}_createCopiesOfExistingFundamentalsForNewStock(){}}var _t=i(95367),mt=i(20585),gt=i.n(mt),ft=i(59656),vt=i(26512),St=i(67521);const yt=new C.TranslatedString("zoom",l.t(null,void 0,i(59833)));class bt extends L.UndoCommand{constructor(e,t,i,s,r,n){super(yt),this._barSpacing=null,this._rightBarsOffset=null,this._leftBarsOffset=null,this._priceMode=null,this._model=e,this._startBar=t,this._endBar=i,this._startPrice=s,this._endPrice=r,this._pane=n}redo(){const e=(0,o.ensureNotNull)(this._model.timeScale().visibleBarsStrictRange());this._leftBarsOffset=e.firstBar()-this._startBar,this._rightBarsOffset=e.lastBar()-this._endBar,this._barSpacing=this._model.timeScale().barSpacing(),this._priceMode=this._pane.defaultPriceScale().mode(),this._model.zoomToViewport(this._startBar,this._endBar,this._startPrice,this._endPrice,this._pane)}undo(){const e=this._model.timeScale(),t=this._pane.defaultPriceScale(),i=(0,o.ensureNotNull)(e.visibleBarsStrictRange());e.setBarSpacing((0,o.ensureNotNull)(this._barSpacing)),e.zoomToBarsRange(i.firstBar()+(0,o.ensureNotNull)(this._leftBarsOffset),i.lastBar()+(0,o.ensureNotNull)(this._rightBarsOffset)),t.setMode((0,o.ensureNotNull)(this._priceMode)),t.recalculatePriceRange((0,o.ensureNotNull)(e.visibleBarsStrictRange())),this._model.recalculateAllPanes((0,ve.viewportChangeEvent)()),this._model.lightUpdate()}}const wt=(0,w.getLogger)("Chart.ChartUndoModel"),Pt=new C.TranslatedString("zoom",l.t(null,void 0,i(59833)));class Ct extends L.UndoCommand{constructor(e,t,i){super(Pt),this._baseCmd=e,this._zoomStack=t,this._inOut=i}undo(){if(this._inOut){ +if(this._baseCmd!==this._zoomStack.head())return void wt.logDebug("zoom stack inconsistency");this._baseCmd.undo(),this._zoomStack.pop()}else this._baseCmd.redo(),this._zoomStack.push(this._baseCmd)}redo(){if(this._inOut)this._baseCmd.redo(),this._zoomStack.push(this._baseCmd);else{if(this._baseCmd!==this._zoomStack.head())return void wt.logDebug("zoom stack inconsistency");this._baseCmd.undo(),this._zoomStack.pop()}}}const xt=new C.TranslatedString("stop syncing drawing",l.t(null,void 0,i(98784)));class Tt extends L.UndoCommand{constructor(e,t){super(xt),this._model=e,this._sourceId=t.id(),this._linkKey=t.linkKey().value()}redo(){(0,o.ensureNotNull)(this._model.dataSourceForId(this._sourceId)).linkKey().setValue(null)}undo(){(0,o.ensureNotNull)(this._model.dataSourceForId(this._sourceId)).linkKey().setValue(this._linkKey)}}const It=new C.TranslatedString("restore defaults",l.t(null,void 0,i(9608)));class Mt extends L.UndoCommand{constructor(e,t,i=It){super(i),this._chartModel=e,this._defaultProperty=t,this._state=t.state()}redo(){this._chartModel.restoreFactoryDefaults(this._defaultProperty)}undo(){this._defaultProperty.mergeAndFire(this._state),this._chartModel.mainSeries().onChartStyleChanged()}}var Lt=i(17236);class At extends Mt{redo(){this._defaultProperty.hasChild("intervalsVisibilities")&&this._defaultProperty.childs().intervalsVisibilities.mergeAndFire(Lt.intervalsVisibilitiesDefaults),super.redo()}}class kt extends At{redo(){super.redo(),this._chartModel.recalcColorStudies(!0)}undo(){super.undo(),this._chartModel.recalcColorStudies(!0)}}var Dt=i(4949),Et=i(30888),Vt=i(85804);function Bt(e){const{visible:t,...i}=e;return i}function Rt(e){const{visible:t,...i}=e;return i}function Nt(e){const{drawWick:t,drawBorder:i,drawBody:s,barColorsOnPrevClose:r,...n}=e;return n}function Ot(e){const{drawWick:t,drawBorder:i,drawBody:s,...r}=e;return r}function Ft(e){const{drawWick:t,drawBorder:i,drawBody:s,showRealLastPrice:r,inputs:n,...o}=e;return o}function Wt(e){const{barColorsOnPrevClose:t,dontDrawOpen:i,thinBars:s,...r}=e;return r}function Ht(e){const{showBorders:t,showLabels:i,drawBody:s,...r}=e;return r}function zt(e){const{linestyle:t,linewidth:i,priceSource:s,...r}=e;return r}function Ut(e){const{linestyle:t,linewidth:i,priceSource:s,...r}=e;return r}function jt(e){const{inputs:t,...i}=e;return i}function Gt(e){const{inputs:t,...i}=e;return i}function qt(e){const{inputs:t,...i}=e;return i}function $t(e){const{inputs:t,...i}=e;return i}function Yt(e){const{topLineWidth:t,bottomLineWidth:i,baseLevelPercentage:s,priceSource:r,...n}=e;return n}function Kt(e){const{thinBars:t,inputs:i,...s}=e;return s}function Zt(e){ +const{visible:t,style:i,symbol:s,interval:r,sessionId:n,highLowAvgPrice:o,showCountdown:a,bidAsk:l,prePostMarket:c,priceAxisProperties:h,candleStyle:d,hollowCandleStyle:u,haStyle:p,barStyle:_,hiloStyle:m,lineStyle:g,lineWithMarkersStyle:f,steplineStyle:v,areaStyle:S,renkoStyle:y,pbStyle:b,kagiStyle:w,pnfStyle:P,baselineStyle:C,rangeStyle:x,esdShowDividends:T,esdShowSplits:I,esdShowEarnings:M,esdShowBreaks:L,showContinuousContractSwitches:A,showContinuousContractSwitchesBreaks:k,showFuturesContractExpiration:D,showLastNews:E,...V}=e;return{bidAsk:Bt(l),prePostMarket:Rt(c),candleStyle:Nt(d),hollowCandleStyle:Ot(u),haStyle:Ft(p),barStyle:Wt(_),hiloStyle:Ht(m),lineStyle:zt(g),lineWithMarkersStyle:zt(f),steplineStyle:zt(v),areaStyle:Ut(S),renkoStyle:jt(y),pbStyle:Gt(b),kagiStyle:qt(w),pnfStyle:$t(P),baselineStyle:Yt(C),rangeStyle:Kt(x),...V}}function Xt(e){const{scaleSeriesOnly:t,showSeriesLastValue:i,showStudyLastValue:s,showSymbolLabels:r,showBidAskLabels:n,showPrePostMarketPriceLabel:o,showStudyPlotLabels:a,showFundamentalNameLabel:l,showFundamentalLastValue:c,seriesLastValueMode:h,...d}=e;return d}function Jt(e){const{topMargin:t,bottomMargin:i,...s}=e;return s}const Qt=new C.TranslatedString("apply chart theme",l.t(null,void 0,i(66568)));class ei extends L.UndoCommand{constructor(e,t,i){var s,r,n;super(Qt),this._model=e,this._newSessionProps=t.sessions||(0,Vt.factoryDefaults)("sessions"),["candleStyle","hollowCandleStyle","haStyle"].forEach((e=>{t.mainSourceProperties[e].wickUpColor=t.mainSourceProperties[e].wickUpColor||t.mainSourceProperties[e].wickColor,t.mainSourceProperties[e].wickDownColor=t.mainSourceProperties[e].wickDownColor||t.mainSourceProperties[e].wickColor})),t.chartProperties=null!==(s=t.chartProperties)&&void 0!==s?s:{paneProperties:{},scalesProperties:void 0},t.chartProperties.paneProperties.vertGridProperties=null!==(r=t.chartProperties.paneProperties.vertGridProperties)&&void 0!==r?r:t.chartProperties.paneProperties.gridProperties,t.chartProperties.paneProperties.horzGridProperties=null!==(n=t.chartProperties.paneProperties.horzGridProperties)&&void 0!==n?n:t.chartProperties.paneProperties.gridProperties;const o=this._model.properties().state().paneProperties.legendProperties;delete o.backgroundTransparency,t.chartProperties.paneProperties.legendProperties={...t.chartProperties.paneProperties.legendProperties,...o};const a=(0,Vt.factoryDefaults)("chartproperties"),l=(0,Et.deepExtend)({},a,t.chartProperties);this._newChartProps={paneProperties:Jt(l.paneProperties),scalesProperties:Xt(l.scalesProperties)},e.timeScale().preserveBarSpacing()&&delete this._newChartProps.scalesProperties.barSpacing;const c=(0,Vt.factoryDefaults)("chartproperties.mainSeriesProperties"),h=(0,Et.deepExtend)({},c,t.mainSourceProperties);this._newSeriesProps=i?h:Zt(h);const d=e.properties().state();this._oldChartProps={paneProperties:Jt(d.paneProperties),scalesProperties:Xt(d.scalesProperties)};const u=e.mainSeries().properties().state();this._oldSeriesProps=i?u:Zt(u), +this._oldSessionProps=this._model.sessions().properties().state()}undo(){this._merge(this._oldChartProps,this._oldSeriesProps,this._oldSessionProps),this._model.mainSeries().onChartStyleChanged(),this._model.updateScales(),this._model.chartThemeLoaded()}redo(){this._merge(this._newChartProps,this._newSeriesProps,this._newSessionProps),this._model.mainSeries().onChartStyleChanged(),this._model.updateScales(),this._model.chartThemeLoaded()}_merge(e,t,i){var s,r,n,o;const a=this._model;(0,_e.saveDefaultProperties)(!0),e&&(a.properties().childs().paneProperties.mergeAndFire(e.paneProperties),a.properties().childs().scalesProperties.mergeAndFire(e.scalesProperties)),"priceAxisProperties"in t&&a.mainSeries().priceScale().setMode({autoScale:null===(s=t.priceAxisProperties)||void 0===s?void 0:s.autoScale,percentage:null===(r=t.priceAxisProperties)||void 0===r?void 0:r.percentage,log:null===(n=t.priceAxisProperties)||void 0===n?void 0:n.log,lockScale:null===(o=t.priceAxisProperties)||void 0===o?void 0:o.lockScale}),a.mainSeries().properties().mergeAndFire(t),a.mainSeries().properties().saveDefaults(),a.mainSeries().createPaneView(),a.mainSeries().invalidateBarStylesCache(),a.recalculateAllPanes((0,ve.globalChangeEvent)()),a.fullUpdate(),a.properties().saveDefaults(),a.sessions().restoreState({properties:i},!1),(0,_e.saveDefaultProperties)(!1)}}const ti=new C.TranslatedString("change resolution",l.t(null,void 0,i(32303)));class ii extends st{constructor(e,t,i){super(ti,e,function(e,t){let i;const s=(0,me.isRangeStyle)(e.style()),r=p.Interval.isRange(t);return!s&&r?i=11:s&&!r&&(i=(0,me.getLastUsedStyle)()),{interval:t,style:i}}(e,t),i),this._resolution=t}canMerge(e){return e instanceof ii&&e._resolution===this._resolution&&super.canMerge(e)}_showFade(e,t){return!0}}var si=i(69718);class ri extends si.SetWatchedValueCommand{constructor(){super(...arguments),this._firstRedo=!0}redo(){this._firstRedo||(0,it.muteLinkingGroup)(this._newValue,!0),(0,it.muteLinkingGroup)(this._oldValue,!0),super.redo(),this._firstRedo||(0,it.muteLinkingGroup)(this._newValue,!1),(0,it.muteLinkingGroup)(this._oldValue,!1),this._firstRedo=!1}undo(){(0,it.muteLinkingGroup)(this._newValue,!0),(0,it.muteLinkingGroup)(this._oldValue,!0),super.undo(),(0,it.muteLinkingGroup)(this._newValue,!1),(0,it.muteLinkingGroup)(this._oldValue,!1)}}var ni=i(97340),oi=i(76422) +;const ai=new C.TranslatedString("send {title} backward",l.t(null,void 0,i(16259))),li=new C.TranslatedString("bring {title} forward",l.t(null,void 0,i(56763))),ci=new C.TranslatedString("insert {title} after {target}",l.t(null,void 0,i(74055))),hi=new C.TranslatedString("insert {title} before {target}",l.t(null,void 0,i(11231))),di=new C.TranslatedString("cut {title}",l.t(null,void 0,i(78755))),ui=new C.TranslatedString("cut sources",l.t(null,void 0,i(63649))),pi=new C.TranslatedString("remove {title}",l.t(null,void 0,i(39859))),_i=new C.TranslatedString("remove drawings group",l.t(null,void 0,i(70653))),mi=new C.TranslatedString("move scale",l.t(null,void 0,i(4184))),gi=new C.TranslatedString("stop syncing line tool(s)",l.t(null,void 0,i(57011))),fi=new C.TranslatedString("zoom out",l.t(null,void 0,i(9645))),vi=new C.TranslatedString("zoom in",l.t(null,void 0,i(19813))),Si=new C.TranslatedString("move drawing(s)",l.t(null,void 0,i(45356))),yi=new C.TranslatedString("load default drawing template",l.t(null,void 0,i(54597))),bi=new C.TranslatedString("apply factory defaults to selected sources",l.t(null,void 0,i(96996))),wi=new C.TranslatedString("change currency",l.t(null,void 0,i(22641))),Pi=new C.TranslatedString("change unit",l.t(null,void 0,i(39028))),Ci=new C.TranslatedString("clone line tools",l.t(null,void 0,i(5179))),xi=new C.TranslatedString("merge up",l.t(null,void 0,i(66143))),Ti=new C.TranslatedString("merge down",l.t(null,void 0,i(62153))),Ii=new C.TranslatedString("merge to pane",l.t(null,void 0,i(70746))),Mi=new C.TranslatedString("unmerge up",l.t(null,void 0,i(52540))),Li=new C.TranslatedString("unmerge down",l.t(null,void 0,i(86949))),Ai=new C.TranslatedString("unmerge to new bottom pane",l.t(null,void 0,i(20057))),ki=new C.TranslatedString("move {title} to new right scale",l.t(null,void 0,i(45544))),Di=new C.TranslatedString("move {title} to new left scale",l.t(null,void 0,i(11303))),Ei=new C.TranslatedString("make {title} no scale (Full screen)",l.t(null,void 0,i(74642))),Vi=new C.TranslatedString("scroll time",l.t(null,void 0,i(70009))),Bi=new C.TranslatedString("scale time",l.t(null,void 0,i(35962))),Ri=new C.TranslatedString("reset time scale",l.t(null,void 0,i(55064))),Ni=new C.TranslatedString("reset scales",l.t(null,void 0,i(21948))),Oi=new C.TranslatedString("create {tool}",l.t(null,void 0,i(81791))),Fi=new C.TranslatedString("change {pointIndex} point",l.t(null,void 0,i(72032))),Wi=new C.TranslatedString("paste {title}",l.t(null,void 0,i(41601))),Hi=new C.TranslatedString("insert {title}",l.t(null,void 0,i(90743))),zi=new C.TranslatedString("remove all studies",l.t(null,void 0,i(15516))),Ui=new C.TranslatedString("remove drawings",l.t(null,void 0,i(44656))),ji=new C.TranslatedString("remove all studies and drawing tools",l.t(null,void 0,i(80171))),Gi=(new C.TranslatedString("turn line tools sharing off",l.t(null,void 0,i(28068))),new C.TranslatedString("share line tools in layout",l.t(null,void 0,i(77554))),new C.TranslatedString("share line tools globally",l.t(null,void 0,i(64704))), new C.TranslatedString("change linking group",l.t(null,void 0,i(23783)))),qi=(l.t(null,void 0,i(75139)),(0,w.getLogger)("Chart.ChartUndoModel")),$i=!1;function Yi(e,t){return{bringForwardEnabled:e.bringForwardEnabled||t.bringForwardEnabled,bringToFrontEnabled:e.bringToFrontEnabled||t.bringToFrontEnabled,sendBackwardEnabled:e.sendBackwardEnabled||t.sendBackwardEnabled,sendToBackEnabled:e.sendToBackEnabled||t.sendToBackEnabled}}function Ki(){return(0,Ae.drawOnAllCharts)().value()?1:0}class Zi extends(r()){constructor(e,t,i,s,r,n,o,a,l,c,h,d){super(),this._createLineCommand=null,this._initialTimeScrollState=null,this._initialTimeScrollPos=null,this._scalePriceInfo=null,this._currentSourceMoveCommand=null,this._currentLineChangeCommand=null,this._currentCustomMoveCommand=null,this._zoomStack=new m.UndoStack,this._chartWidget=n,this.m_model=new(gt())(e,t,i,s,r,this,a,l,c,h,d),this._undoHistory=o,this._lineToolsGroupController=new We({model:this._model.bind(this),pushUndoCommand:this._pushUndoCommand.bind(this),beginUndoMacro:(e,t)=>{this._undoHistory.beginUndoMacro(e).setCustomFlag("doesnt_affect_save",!!t)},endUndoMacro:this._undoHistory.endUndoMacro.bind(this._undoHistory),emitEvent:this.emitEvent.bind(this)})}undoHistory(){return this._undoHistory}setWatchedValue(e,t,i){this._undoHistory.setWatchedValue(e,t,i)}lineToolsGroupController(){return this._lineToolsGroupController}mergeAllScales(e){!function(e,t){e.beginUndoMacro("left"===t?T:I),e.model().panes().forEach((i=>{const s="left"===t?i.rightPriceScales():i.leftPriceScales(),r=("left"===t?i.leftPriceScales():i.rightPriceScales()).concat(s),n="overlay"===i.priceScalePosition(i.defaultPriceScale())?r[0]:i.defaultPriceScale();e.movePriceScale(i,n,t,0),r.forEach((t=>{if(t===n)return;let s=t.mainSource();for(;null!==s;){e.moveToScale(s,i,n,null,!0);const r=t.mainSource();if(r===s){M.logError("Loop detected while trying to merge scales");break}s=r}}))})),e.endUndoMacro(),e.model().fullUpdate()}(this,e)}movePriceScale(e,t,i,s){const r=new A(this._model(),e,t,i,s,mi);this._pushUndoCommand(r)}createLineTool({pane:e,point:t,linetool:i,properties:s,linkKey:r,ownerSource:n,disableSynchronization:a,sharingMode:l=Ki(),id:c}){if(("LineToolRegressionTrend"===i||"LineToolAnchoredVWAP"===i)&&!this.canCreateStudy())return(0,h.showTooManyStudiesNotice)(),null;const d=Oi.format({tool:new C.TranslatedString(i,ft.lineToolsLocalizedNames[i])});this.beginUndoMacro(d,$i);const u=!a;this._createLineCommand=new F.CreateLineToolUndoCommand({model:this._model(),pane:e,lineTool:i,ownerSource:n||(0,o.ensureNotNull)(e.mainDataSource()),drawOnAllChartsMode:l,id:c});const p=this._createLineCommand.startCreatingLine(t,s,r||null,l),_=(0,o.ensureNotNull)(this._createLineCommand.line());let m=null;if(p&&(u&&this.finishLineTool(_),this._pushUndoCommand(this._createLineCommand),this._createLineCommand=null,m={points:_.normalizedPoints(),interval:this.mainSeries().interval()}),u&&void 0===r&&(0,Ae.drawOnAllCharts)().value()&&_.isSynchronizable()){const e=(0, o.ensureNotNull)(this.model().externalTimeStamp(t.index)),s={point:{price:t.price,timeStamp:e},linetool:i,properties:_.properties(),symbol:this.mainSeries().symbol(),model:this.model(),linkKey:(0,o.ensureNotNull)(_.linkKey().value()),finalState:m,id:_.id(),sharingMode:_.sharingMode().value()};_.isFixed()&&(s.pointPositionPercents=_.calcPositionPercents()),(0,Ae.createLineTool)(s)}return this.endUndoMacro(),_}continueCreatingLine(e,t,i,s){const r=(0,o.ensureNotNull)(this._createLineCommand);this.beginUndoMacro(r.text(),$i);const n=(0,o.ensureNotNull)(this._model().lineBeingCreated()),a=r.continueCreatingLine(e,t,i,s);let l=null;if(a&&(this.finishLineTool(n),this._pushUndoCommand(r),this._createLineCommand=null,l={points:n.normalizedPoints(),interval:this.mainSeries().interval()}),r.drawOnAllCharts()&&n.isSynchronizable()){const i=(0,o.ensureNotNull)(this._model().externalTimeStamp(e.index));(0,Ae.continueLineTool)({point:{price:e.price,timeStamp:i},envState:t,finalState:l,model:this._model()})}return this.endUndoMacro(),a}continueExternalLine(e,t,i){const s=(0,o.ensureNotNull)(this._createLineCommand),r=s.continueCreatingLine(e,t,i);return r&&(this._pushUndoCommand(s),this._createLineCommand=null),r}finishLineTool(e){this._model().finishLineTool(e)}pasteImageAsLineTool(e,t,i,s){return null}loadRange(e){const t=this._model(),i=t.mainSeries().getSupportedResolution(e.res),s={val:e.val,res:i},r=t.appliedTimeFrame().value();return(null===r||!_(r,s))&&(this._pushUndoCommand(new be(t,s)),!0)}unlinkLines(e){const t=this.model();this.beginUndoMacro(gi,$i);for(const i of e)null!==i.linkKey().value()&&(0,Ae.removeLineTool)({withUndo:!0,model:this.model(),symbol:i.symbol(),linkKey:(0,o.ensureNotNull)(i.linkKey().value()),sourceTitle:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,i),lineToolState:i.state(!1),unlink:!0}),this._pushUndoCommand(new Tt(t,i));this.endUndoMacro()}zoomFromViewport(){const e=new Ct((0,o.ensureDefined)(this._zoomStack.head()),this._zoomStack,!1);this._pushUndoCommand(e)}zoomToViewport(e,t,i,s,r){const n=new bt(this.m_model,e,t,i,s,r),o=new Ct(n,this._zoomStack,!0);this._pushUndoCommand(o)}zoomStack(){return this._zoomStack}hoveredSource(){return this.m_model.hoveredSource()}setProperty(e,t,i,s){if(e&&e.value()!==t){const r=new Me(e,t,i,this.m_model,s);this._pushUndoCommand(r),this.emitEvent("setProperty")}}withMacro(e,t,i){const s=this.beginUndoMacro(e,i);try{t()}finally{this.endUndoMacro()}return s}barsMarksSources(){return this.m_model.barsMarksSources()}removeAllDrawingTools(){this.beginUndoMacro(Ui,!1),this._removeAllDrawingToolsImpl(),this.endUndoMacro()}removeAllStudiesAndDrawingTools(){this.beginUndoMacro(ji),this._removeAllDrawingToolsImpl(),this._removeAllStudiesImpl(),this.endUndoMacro()}removeAllStudies(){this.beginUndoMacro(zi),this._removeAllStudiesImpl(),this.endUndoMacro()}scrollChartByBar(e){if(!this.m_model.scrollEnabled())return;const t=e*this.m_model.timeScale().barSpacing();this.startScrollTime(0),this.scrollTimeTo(t),this.endScrollTime()}canZoomIn(){ -return this.model().canZoomIn()}canZoomOut(){return this.model().canZoomOut()}zoomOut(){const e=this.timeScale().width();if(this.canZoomOut()){try{this.beginUndoMacro(fi)}catch(e){return}(0,v.doAnimate)({to:e/5,onStep:e=>{this.startScaleTime(0),this.scaleTimeTo(e),this.endScaleTime()},onComplete:()=>this.endUndoMacro()})}}zoomIn(){const e=this.timeScale().width();if(this.canZoomIn()){try{this.beginUndoMacro(vi)}catch(e){return}(0,v.doAnimate)({to:e/5,onStep:e=>{this.startScaleTime(e),this.scaleTimeTo(0),this.endScaleTime()},onComplete:()=>this.endUndoMacro()})}}startMovingSources(e,t,i,s){e.filter((e=>e.doesMovingAffectsUndo())).length&&(this._currentSourceMoveCommand=new E(this.model(),e,Si,!1),e.every(f.isLineTool)&&this._currentSourceMoveCommand.setCustomFlag("doesnt_affect_save",$i)),this.model().startMovingSources(e,t,i,new Map,s)}moveSources(e,t){this.model().moveSources(e,new Map,t)}endMovingSource(e,t){this.model().endMovingSources(e,void 0,t),null!==this._currentSourceMoveCommand&&(this._currentSourceMoveCommand.saveNewState(),this._pushUndoCommand(this._currentSourceMoveCommand)),this._currentSourceMoveCommand=null}startChangingLinetool(e,t,i,s,r){this._currentLineChangeCommand=new E(this.model(),[e],Fi.format({pointIndex:i}),!1),this._currentLineChangeCommand.setCustomFlag("doesnt_affect_save",$i),this.model().startChangingLinetool(e,t,i,s,r)}changeLinePoint(e,t){this.model().changeLinePoint(e,t)}endChangingLinetool(e){this.model().endChangingLinetool(e),null!==this._currentLineChangeCommand&&(this._currentLineChangeCommand.saveNewState(),this._pushUndoCommand(this._currentLineChangeCommand)),this._currentLineChangeCommand=null}setChartStyleProperty(e,t,i){if(e.value()!==t){const s=new Se(e,t,this.mainSeries(),i,this.model(),this.chartWidget());this._pushUndoCommand(s),this.emitEvent("setChartStyleProperty"),(0,pe.trackChartStyleChanged)(e.value())}}restorePropertiesForSource(e){(0,f.isLineTool)(e)?this._restoreLineToolFactoryDefaults(e):this._restoreStudyFactoryDefaults(e)}restoreLineToolsFactoryDefaults(e){1===e.length?this._restoreLineToolFactoryDefaults(e[0]):(this.beginUndoMacro(bi),e.forEach((e=>this._restoreLineToolFactoryDefaults(e))),this.endUndoMacro())}restoreState(e,t,i){return this.m_model.restoreState(e,t,i)}async clipboardCopy(e,t=this.selection().dataSources()){if(!(0,b.enabled)("datasource_copypaste"))return;const i=t.filter((e=>e.copiable()));if(0===i.length)return;for(const e of i)if((0,P.isStudy)(e)&&e.isChildStudy())throw new Error("Can not copy child study");const s=(0,g.clipboardDataForSources)(this._model().id(),i);return null!==s?e.write({app:JSON.stringify(s),text:s.title}):void 0}async clipboardCut(e,t=this.selection().dataSources()){if(!(0,b.enabled)("datasource_copypaste"))return;const i=t.filter((e=>e.copiable()));if(0===i.length)return;await this.clipboardCopy(e,i);const s=i.filter((e=>e.isUserDeletable()));if(0===s.length)return;const r=(1===s.length?di:ui).format({title:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,s[0])});this.beginUndoMacro(r), +return this.model().canZoomIn()}canZoomOut(){return this.model().canZoomOut()}zoomOut(){const e=this.timeScale().width();if(this.canZoomOut()){try{this.beginUndoMacro(fi)}catch(e){return}(0,v.doAnimate)({to:e/5,onStep:e=>{this.startScaleTime(0),this.scaleTimeTo(e),this.endScaleTime()},onComplete:()=>this.endUndoMacro()})}}zoomIn(){const e=this.timeScale().width();if(this.canZoomIn()){try{this.beginUndoMacro(vi)}catch(e){return}(0,v.doAnimate)({to:e/5,onStep:e=>{this.startScaleTime(e),this.scaleTimeTo(0),this.endScaleTime()},onComplete:()=>this.endUndoMacro()})}}startMovingSources(e,t,i,s){e.filter((e=>e.doesMovingAffectsUndo())).length&&(this._currentSourceMoveCommand=new V(this.model(),e,Si,!1),e.every(f.isLineTool)&&this._currentSourceMoveCommand.setCustomFlag("doesnt_affect_save",$i)),this.model().startMovingSources(e,t,i,new Map,s)}moveSources(e,t){this.model().moveSources(e,new Map,t)}endMovingSource(e,t){this.model().endMovingSources(e,void 0,t),null!==this._currentSourceMoveCommand&&(this._currentSourceMoveCommand.saveNewState(),this._pushUndoCommand(this._currentSourceMoveCommand)),this._currentSourceMoveCommand=null}startChangingLinetool(e,t,i,s,r){this._currentLineChangeCommand=new V(this.model(),[e],Fi.format({pointIndex:i}),!1),this._currentLineChangeCommand.setCustomFlag("doesnt_affect_save",$i),this.model().startChangingLinetool(e,t,i,s,r)}changeLinePoint(e,t){this.model().changeLinePoint(e,t)}endChangingLinetool(e){this.model().endChangingLinetool(e),null!==this._currentLineChangeCommand&&(this._currentLineChangeCommand.saveNewState(),this._pushUndoCommand(this._currentLineChangeCommand)),this._currentLineChangeCommand=null}setChartStyleProperty(e,t,i){if(e.value()!==t){const s=new Se(e,t,this.mainSeries(),i,this.model(),this.chartWidget());this._pushUndoCommand(s),this.emitEvent("setChartStyleProperty"),(0,pe.trackChartStyleChanged)(e.value())}}restorePropertiesForSource(e){(0,f.isLineTool)(e)?this._restoreLineToolFactoryDefaults(e):this._restoreStudyFactoryDefaults(e)}restoreLineToolsFactoryDefaults(e){1===e.length?this._restoreLineToolFactoryDefaults(e[0]):(this.beginUndoMacro(bi),e.forEach((e=>this._restoreLineToolFactoryDefaults(e))),this.endUndoMacro())}restoreState(e,t,i){return this.m_model.restoreState(e,t,i)}async clipboardCopy(e,t=this.selection().dataSources()){if(!(0,b.enabled)("datasource_copypaste"))return;const i=t.filter((e=>e.copiable()));if(0===i.length)return;for(const e of i)if((0,P.isStudy)(e)&&e.isChildStudy())throw new Error("Can not copy child study");const s=(0,g.clipboardDataForSources)(this._model().id(),i);return null!==s?e.write({app:JSON.stringify(s),text:s.title}):void 0}async clipboardCut(e,t=this.selection().dataSources()){if(!(0,b.enabled)("datasource_copypaste"))return;const i=t.filter((e=>e.copiable()));if(0===i.length)return;await this.clipboardCopy(e,i);const s=i.filter((e=>e.isUserDeletable()));if(0===s.length)return;const r=(1===s.length?di:ui).format({title:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,s[0])});this.beginUndoMacro(r), this.m_model.selectionMacro((()=>this.removeSources(s,!1,r)),!0),this.endUndoMacro()}async clipboardPaste(e,t){let i=null;if((0,b.enabled)("datasource_copypaste")&&(i=i||await e.read(),i.app)){const e=JSON.parse(i.app);if(null!==this.pasteSourceFromClip(t,e))return}await this._processSpecialLineToolsContents(e,i,t)}applyStudyTemplate(e,t){const i=new $e(this._model(),e,t);this._pushUndoCommand(i),(0,oi.emit)("load_study_template")}createStudyInserter(e,t,i){const s={createStudy:(e,t,i,s,r,n,o,a,l,c,h)=>this.checkIfFeatureAvailable(e,n)?((0,S.trackEvent)("studies","Study_"+e.id),"Compare@tv-basicstudies"===e.id&&(0,S.trackEvent)("compare","symbol:"+t.symbol),this._insertStudy(e,t,s,r,n,o,a,l,c,null,h)):(qi.logNormal("Cannot insert study "+e.id),null)};void 0!==i&&(s.createStub=()=>this.m_model.insertStudyStub(i).id(),s.removeStub=e=>this.m_model.removeStudyStub(e));const r=new ni.StudyInserter(e,this.m_model.studyMetaInfoRepository(),s);return r.setParentSources(t),r}replayStatus(){return this.m_model.replayStatus()}setReplayStatus(e){return this.m_model.setReplayStatus(e)}startCustomMoving(e,t,i){this._currentCustomMoveCommand=new ut(this.model(),e,t,i)}customMoveBeingProcessed(){return null!==this._currentCustomMoveCommand}processCustomMove(e){(0,o.ensureNotNull)(this._currentCustomMoveCommand).move(e)}endCustomMoving(){null!==this._currentCustomMoveCommand&&this._currentCustomMoveCommand.hasChanges()&&(this._pushUndoCommand(this._currentCustomMoveCommand),this._currentCustomMoveCommand=null)}panes(){return this.m_model.panes()}cloneLineTools(e,t){for(let t=0;t(0,o.ensureNotNull)(this.model().dataSourceForId(e)))).filter((e=>0!==e.sharingMode().value()));return s.length&&this._model().copyToOtherCharts(s,!0),this.endUndoMacro(),this.emitEvent("cloneLineTools"),i.newIds()}removeSource(e,t,i){this.lineBeingCreated()!==e?this.removeSources([e],t,pi.format({title:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,e)}),i):this.cancelCreatingLine()}removeSelectedSources(){const e=this._model().selection().dataSources();if(!e.length)return;const t=(e.length>1?_i:pi).format({title:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,e[0])});this.removeSources(e,!1,t)}removeSources(e,t,i,s){s||(e=e.filter((e=>e.isUserDeletable())));const r=this._model(),n=r.lineToolsGroupModel(),a=e.every(f.isLineTool)&&$i;this.beginUndoMacro(i,a),r.selectionMacro((s=>{const a=new Map;e.forEach((e=>{if((0,f.isLineTool)(e)){const t=n.groupForLineTool(e);if(null!==t){const i=a.get(t)||[];i.push(e),a.set(t,i)}null!==e.linkKey().value()&&(0,Ae.removeLineTool)({withUndo:!0,model:this.model(),linkKey:(0,o.ensureNotNull)(e.linkKey().value()),symbol:this.model().mainSeries().symbol(),lineToolState:e.state(!1),sourceTitle:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,e)})}})) ;const l=new D.RemoveSourcesUndoCommand(r,e,i),c=l.removedIds();this._pushUndoCommand(l),!t&&c.length>0&&(1===c.length?this.emitEvent("removeSource",[c[0]]):this.emitEvent("removeSources",[c]))}),!0),this.endUndoMacro()}removeUnloadedLineTool({sourceTitle:e,linkKey:t,symbol:i,state:s,withUndo:r,unlink:n}){}async scrollToLineTool(e){const t=this.timeScale().logicalRange();if(null===t)return;const i=this.timeScale().barSpacing();let s=t.left();const r=e.points().map((e=>e.index)),n=this.timeScale().points().range().value();if(null===n)return;let a=n.firstIndex;const l=n.lastIndex,h=t.length()/2;if(0===r.length||r.some((e=>t.contains(e))))return;const d=()=>{const t=e.points().map((e=>e.index)),i=t.filter((e=>e<=l)).reduce(((e,t)=>null===e?t:Math.max(e,t)),null);return null!==i?i:t.reduce(((e,t)=>Math.min(e,t)))};let u,p=d();if(a-h>p){const t=e.points().map((e=>e.time)).filter(x.notUndefined).map((e=>e.valueOf()));if(0===t.length)return;const i=t.reduce(((e,t)=>Math.min(e,t)),t[0]);await this.model().gotoTime(i),p=d();const r=(0,o.ensureNotNull)(this.timeScale().logicalRange());if(r.contains(p))return;s=r.left(),a=(0,o.ensureNotNull)(this.timeScale().points().range().value()).firstIndex}a-h>p?(u=(s-a+h)*i,this.mainSeries().setGotoDateResult({timestamp:(0,o.ensureNotNull)(this.timeScale().points().valueAt(a)),eod:!0})):u=(s-p+1+h)*i,this.startScrollTime(0),(0,v.doAnimate)({onStep:(e,t)=>this.scrollTimeTo(t),from:0,to:Math.round(u),easing:c.easingFunc.easeInOutCubic,duration:c.dur,onComplete:()=>this.endScrollTime()})}mergeSourceUp(e){const t=new R.MergeUpUndoCommand(this._model(),e,xi);this._mergeUnmergeSource(e,t)}mergeSourceDown(e){const t=new R.MergeDownUndoCommand(this._model(),e,Ti);this._mergeUnmergeSource(e,t)}mergeToPane(e,t,i){const s=this._model().panes().indexOf(t),r=new R.MergeToTargetPane(this._model(),e,s,Ii,i);this._mergeUnmergeSource(e,r)}unmergeSourceUp(e){const t=new B.UnmergeUpUndoCommand(this._model(),e,Mi);this._mergeUnmergeSource(e,t)}unmergeSourceDown(e){const t=new B.UnmergeDownUndoCommand(this._model(),e,Li);this._mergeUnmergeSource(e,t)}unmergeToNewBottomPane(e){const t=new B.UnmergeToNewBottomPane(this._model(),e,Ai);this._mergeUnmergeSource(e,t)}availableZOrderOperations(e){const t=this._model().lineToolsGroupModel(),i=e.filter(f.isLineTool),s=i.map((e=>t.groupForLineTool(e)));(0,o.assert)(new Set(s).size<=1,"Cannot move line tools from different group");const r=0===s.length?null:s[0];let n={bringForwardEnabled:!1,bringToFrontEnabled:!1,sendBackwardEnabled:!1,sendToBackEnabled:!1};const a=new Set(i);for(const t of(0,N.sortSources)(e)){if((0,f.isLineTool)(t)&&null!==r){const e=(0,N.sortSources)(r.lineTools().filter((e=>!a.has(e)||e===t)));n=Yi(n,{bringForwardEnabled:t!==e[e.length-1],bringToFrontEnabled:t!==e[e.length-1],sendBackwardEnabled:t!==e[0],sendToBackEnabled:t!==e[0]});continue}const e=(0,o.ensureNotNull)(this._model().paneForSource(t)).sourcesByGroup().allExceptSpecialSources();if(0===e.length)continue;const i=t.zorder(),s=e[0].zorder(),l=e[e.length-1].zorder();n=Yi(n,{ -bringForwardEnabled:i!==l,bringToFrontEnabled:i!==l,sendBackwardEnabled:i!==s,sendToBackEnabled:i!==s})}return n}sendToBack(e){if(!this.availableZOrderOperations(e).sendToBackEnabled)throw new Error("Send to back operation is unavailable");let t=null;const i=e[0];if((0,f.isLineTool)(i)){const s=this._model().lineToolsGroupModel().groupForLineTool(i);if(null!==s){const i=s.lineTools();t=new ie(this.model(),(0,N.sortSources)(e),i[0])}}null===t&&(t=new J(this.model(),(0,N.sortSources)(e))),this._pushUndoCommand(t),this.emitEvent("changeZOrder",[e])}bringToFront(e){if(!this.availableZOrderOperations(e).bringToFrontEnabled)throw new Error("Bring to front operation is unavailable");let t=null;const i=e[0];if((0,f.isLineTool)(i)){const s=this._model().lineToolsGroupModel().groupForLineTool(i);if(null!==s){const i=s.lineTools();t=new ee(this.model(),(0,N.sortSources)(e),i[i.length-1])}}null===t&&(t=new X(this.model(),(0,N.sortSources)(e))),this._pushUndoCommand(t),this.emitEvent("changeZOrder",[e])}sendBackward(e){if(!this.availableZOrderOperations(e).sendBackwardEnabled)throw new Error("Send backward operation is unavailable");const t=ai.format({title:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,e[0])});this._sendBackOrBringForward(t,(0,N.sortSources)(e),((e,t)=>new re(this.model(),e,t)))}bringForward(e){if(!this.availableZOrderOperations(e).bringForwardEnabled)throw new Error("Bring forward operation is unavailable");const t=li.format({title:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,e[0])});this._sendBackOrBringForward(t,(0,N.sortSources)(e),((e,t)=>new oe(this.model(),e,t)))}insertAfter(e,t){e=(0,N.sortSources)(e);const i=ci.format({title:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,e[0]),target:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,t)});this._insertAfterOrBefore(i,e,t,(()=>new ee(this.model(),e,t)))}insertBefore(e,t){e=(0,N.sortSources)(e);const i=hi.format({title:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,e[0]),target:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,t)});this._insertAfterOrBefore(i,e,t,(()=>new ie(this.model(),e,t)))}detachToRight(e,t){(0,S.trackEvent)("Chart","Move to new right scale");const i=ki.format({title:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,e)}),s=new tt.MoveToNewPriceScaleUndoCommand(this.model(),e,t,"right",i);this._pushUndoCommand(s),this.emitEvent("moveSource",[e])}detachToLeft(e,t){(0,S.trackEvent)("Chart","Move to new left scale");const i=Di.format({title:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,e)}),s=new tt.MoveToNewPriceScaleUndoCommand(this.model(),e,t,"left",i);this._pushUndoCommand(s),this.emitEvent("moveSource",[e])}detachNoScale(e,t){(0,S.trackEvent)("Chart","Make source no scale");const i=Vi.format({title:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,e)}),s=new tt.MoveToNewPriceScaleUndoCommand(this.model(),e,t,"overlay",i);this._pushUndoCommand(s), -this.emitEvent("moveSource",[e])}moveToScale(e,t,i,s,r){(0,S.trackEvent)("Chart","Move source to target scale"),this.beginUndoMacro(s);const n=new tt.MoveToExistingPriceScaleUndoCommand(this.model(),e,t,i,s),o=r?null:(0,y.sourceNewCurrencyOnPinningToPriceScale)(e,i,this._model()),a=r?null:(0,vt.sourceNewUnitOnPinningToPriceScale)(e,i,this._model());this._pushUndoCommand(n),null!==o&&this.setPriceScaleCurrency(i,o),null!==a&&this.setPriceScaleUnit(i,a),this.endUndoMacro(),this.emitEvent("moveSource",[e])}setLinkingGroupIndex(e){this._undoHistory.beginUndoMacro(Gi),this._pushUndoCommand(new ri(this.model().linkingGroupIndex(),e,Gi)),this._model().setShouldBeSavedEvenIfHidden(!0),this._undoHistory.endUndoMacro()}startScrollTime(e){const t=this.timeScale();this._initialTimeScrollState={rightOffset:t.rightOffset(),barSpacing:t.barSpacing()},this._initialTimeScrollPos=e,this.model().startScrollTime(e)}scrollTimeTo(e){null!==this._initialTimeScrollPos&&null!==this._initialTimeScrollState&&Math.abs(e-this._initialTimeScrollPos)>20&&(this._pushUndoCommand(new ue.TimeScaleChangeUndoCommand(this.model(),this._initialTimeScrollState,Ei)),this._initialTimeScrollPos=null,this._initialTimeScrollState=null),this.model().scrollTimeTo(e)}endScrollTime(){this.model().endScrollTime(),this._initialTimeScrollPos=null,this._initialTimeScrollState=null}startScaleTime(e){const t=this.timeScale(),i={rightOffset:t.rightOffset(),barSpacing:t.barSpacing()};this._pushUndoCommand(new ue.TimeScaleChangeUndoCommand(this.model(),i,Bi)),this.model().startScaleTime(e)}scaleTimeTo(e){this.model().scaleTimeTo(e)}endScaleTime(){this.model().endScaleTime()}resetTimeScale(){const e=this.timeScale(),t={rightOffset:e.rightOffset(),barSpacing:e.barSpacing()};this._pushUndoCommand(new ue.TimeScaleChangeUndoCommand(this.model(),t,Ri)),this.model().resetTimeScale()}startScalePrice(e,t,i,s){this._scalePriceInfo={priceScaleState:t.state(),tryMergeConsecutiveScales:s},this.model().startScalePrice(e,t,i)}scalePriceTo(e,t,i){this.model().scalePriceTo(e,t,i)}endScalePrice(e,t){this.model().endScalePrice(e,t);const i=(0,o.ensureNotNull)(this._scalePriceInfo);(0,n.default)(i.priceScaleState,t.state())||this._pushUndoCommand(new St.PriceScaleChangeUndoCommand(this.model(),e,t,i.priceScaleState,i.tryMergeConsecutiveScales)),this._scalePriceInfo=null}startTwoPointsScalePrice(e,t,i,s,r){this._scalePriceInfo={priceScaleState:t.state(),tryMergeConsecutiveScales:r},this.model().startTwoPointsScalePrice(e,t,i,s)}twoPointsScalePriceTo(e,t,i,s){this.model().twoPointsScalePriceTo(e,t,i,s)}endTwoPointsScalePrice(e,t){this.model().endTwoPointsScalePrice(e,t);const i=(0,o.ensureNotNull)(this._scalePriceInfo);(0,n.default)(i.priceScaleState,t.state())||this._pushUndoCommand(new St.PriceScaleChangeUndoCommand(this.model(),e,t,i.priceScaleState,i.tryMergeConsecutiveScales)),this._scalePriceInfo=null}resetPriceScale(e,t){const i=t.state();this.model().resetPriceScale(e,t),(0,n.default)(i,t.state())||this._pushUndoCommand(new St.PriceScaleChangeUndoCommand(this.m_model,e,t,i))} +bringForwardEnabled:i!==l,bringToFrontEnabled:i!==l,sendBackwardEnabled:i!==s,sendToBackEnabled:i!==s})}return n}sendToBack(e){if(!this.availableZOrderOperations(e).sendToBackEnabled)throw new Error("Send to back operation is unavailable");let t=null;const i=e[0];if((0,f.isLineTool)(i)){const s=this._model().lineToolsGroupModel().groupForLineTool(i);if(null!==s){const i=s.lineTools();t=new ie(this.model(),(0,N.sortSources)(e),i[0])}}null===t&&(t=new J(this.model(),(0,N.sortSources)(e))),this._pushUndoCommand(t),this.emitEvent("changeZOrder",[e])}bringToFront(e){if(!this.availableZOrderOperations(e).bringToFrontEnabled)throw new Error("Bring to front operation is unavailable");let t=null;const i=e[0];if((0,f.isLineTool)(i)){const s=this._model().lineToolsGroupModel().groupForLineTool(i);if(null!==s){const i=s.lineTools();t=new ee(this.model(),(0,N.sortSources)(e),i[i.length-1])}}null===t&&(t=new X(this.model(),(0,N.sortSources)(e))),this._pushUndoCommand(t),this.emitEvent("changeZOrder",[e])}sendBackward(e){if(!this.availableZOrderOperations(e).sendBackwardEnabled)throw new Error("Send backward operation is unavailable");const t=ai.format({title:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,e[0])});this._sendBackOrBringForward(t,(0,N.sortSources)(e),((e,t)=>new re(this.model(),e,t)))}bringForward(e){if(!this.availableZOrderOperations(e).bringForwardEnabled)throw new Error("Bring forward operation is unavailable");const t=li.format({title:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,e[0])});this._sendBackOrBringForward(t,(0,N.sortSources)(e),((e,t)=>new oe(this.model(),e,t)))}insertAfter(e,t){e=(0,N.sortSources)(e);const i=ci.format({title:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,e[0]),target:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,t)});this._insertAfterOrBefore(i,e,t,(()=>new ee(this.model(),e,t)))}insertBefore(e,t){e=(0,N.sortSources)(e);const i=hi.format({title:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,e[0]),target:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,t)});this._insertAfterOrBefore(i,e,t,(()=>new ie(this.model(),e,t)))}detachToRight(e,t){(0,S.trackEvent)("Chart","Move to new right scale");const i=ki.format({title:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,e)}),s=new tt.MoveToNewPriceScaleUndoCommand(this.model(),e,t,"right",i);this._pushUndoCommand(s),this.emitEvent("moveSource",[e])}detachToLeft(e,t){(0,S.trackEvent)("Chart","Move to new left scale");const i=Di.format({title:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,e)}),s=new tt.MoveToNewPriceScaleUndoCommand(this.model(),e,t,"left",i);this._pushUndoCommand(s),this.emitEvent("moveSource",[e])}detachNoScale(e,t){(0,S.trackEvent)("Chart","Make source no scale");const i=Ei.format({title:(0,O.getTranslatedStringForSource)(W.TitleDisplayTarget.StatusLine,e)}),s=new tt.MoveToNewPriceScaleUndoCommand(this.model(),e,t,"overlay",i);this._pushUndoCommand(s), +this.emitEvent("moveSource",[e])}moveToScale(e,t,i,s,r){(0,S.trackEvent)("Chart","Move source to target scale"),this.beginUndoMacro(s);const n=new tt.MoveToExistingPriceScaleUndoCommand(this.model(),e,t,i,s),o=r?null:(0,y.sourceNewCurrencyOnPinningToPriceScale)(e,i,this._model()),a=r?null:(0,vt.sourceNewUnitOnPinningToPriceScale)(e,i,this._model());this._pushUndoCommand(n),null!==o&&this.setPriceScaleCurrency(i,o),null!==a&&this.setPriceScaleUnit(i,a),this.endUndoMacro(),this.emitEvent("moveSource",[e])}setLinkingGroupIndex(e){this._undoHistory.beginUndoMacro(Gi),this._pushUndoCommand(new ri(this.model().linkingGroupIndex(),e,Gi)),this._model().setShouldBeSavedEvenIfHidden(!0),this._undoHistory.endUndoMacro()}startScrollTime(e){const t=this.timeScale();this._initialTimeScrollState={rightOffset:t.rightOffset(),barSpacing:t.barSpacing()},this._initialTimeScrollPos=e,this.model().startScrollTime(e)}scrollTimeTo(e){null!==this._initialTimeScrollPos&&null!==this._initialTimeScrollState&&Math.abs(e-this._initialTimeScrollPos)>20&&(this._pushUndoCommand(new ue.TimeScaleChangeUndoCommand(this.model(),this._initialTimeScrollState,Vi)),this._initialTimeScrollPos=null,this._initialTimeScrollState=null),this.model().scrollTimeTo(e)}endScrollTime(){this.model().endScrollTime(),this._initialTimeScrollPos=null,this._initialTimeScrollState=null}startScaleTime(e){const t=this.timeScale(),i={rightOffset:t.rightOffset(),barSpacing:t.barSpacing()};this._pushUndoCommand(new ue.TimeScaleChangeUndoCommand(this.model(),i,Bi)),this.model().startScaleTime(e)}scaleTimeTo(e){this.model().scaleTimeTo(e)}endScaleTime(){this.model().endScaleTime()}resetTimeScale(){const e=this.timeScale(),t={rightOffset:e.rightOffset(),barSpacing:e.barSpacing()};this._pushUndoCommand(new ue.TimeScaleChangeUndoCommand(this.model(),t,Ri)),this.model().resetTimeScale()}startScalePrice(e,t,i,s){this._scalePriceInfo={priceScaleState:t.state(),tryMergeConsecutiveScales:s},this.model().startScalePrice(e,t,i)}scalePriceTo(e,t,i){this.model().scalePriceTo(e,t,i)}endScalePrice(e,t){this.model().endScalePrice(e,t);const i=(0,o.ensureNotNull)(this._scalePriceInfo);(0,n.default)(i.priceScaleState,t.state())||this._pushUndoCommand(new St.PriceScaleChangeUndoCommand(this.model(),e,t,i.priceScaleState,i.tryMergeConsecutiveScales)),this._scalePriceInfo=null}startTwoPointsScalePrice(e,t,i,s,r){this._scalePriceInfo={priceScaleState:t.state(),tryMergeConsecutiveScales:r},this.model().startTwoPointsScalePrice(e,t,i,s)}twoPointsScalePriceTo(e,t,i,s){this.model().twoPointsScalePriceTo(e,t,i,s)}endTwoPointsScalePrice(e,t){this.model().endTwoPointsScalePrice(e,t);const i=(0,o.ensureNotNull)(this._scalePriceInfo);(0,n.default)(i.priceScaleState,t.state())||this._pushUndoCommand(new St.PriceScaleChangeUndoCommand(this.model(),e,t,i.priceScaleState,i.tryMergeConsecutiveScales)),this._scalePriceInfo=null}resetPriceScale(e,t){const i=t.state();this.model().resetPriceScale(e,t),(0,n.default)(i,t.state())||this._pushUndoCommand(new St.PriceScaleChangeUndoCommand(this.m_model,e,t,i))} rearrangePanes(e,t){const i=new de(this._model(),e,t);this._pushUndoCommand(i)}movePane(e,t){const i=new de(this._model(),e,t);this._pushUndoCommand(i)}readOnly(){return this.m_model.readOnly()}checkIfFeatureAvailable(e,t){let i=this.canCreateStudy();const s=t.length>0;return!this.readOnly()&&s&&(i=this.canCreateStudy(!0)),!!i||(s||(0,h.showTooManyStudiesNotice)(),!1)}pasteSourceFromClip(e,t,i){const s=t;if(!s||0===s.sources.length)return null;const r=e||(0,o.ensureNotNull)(this.model().paneForSource(this.mainSeries()));if(!s.sources.some((e=>"drawing"!==e.type||null!==r.clipboardLineToolOwnerSource(e.source.id))))return null;this.beginUndoMacro(Wi.format({title:s.title}));let n=0;const a=[],l=[];for(const t of s.sources)if("drawing"===t.type&&null!==r.clipboardLineToolOwnerSource(t.source.id)){const e=this.pasteLineTool(r,t);n<5&&((0,pe.trackDrawingPasted)(e),n+=1),l.push(e),a.push(e)}else"study"===t.type&&t.source&&t.source.metaInfo&&this.checkIfFeatureAvailable(new d.StudyMetaInfo(t.source.metaInfo),[])&&a.push(this.pasteStudy(t,i?e:void 0));return l.length&&this.selectionMacro((e=>{e.clearSelection(),l.forEach((t=>{e.addSourceToSelection(t,null)}))})),this.endUndoMacro(),a}pasteLineTool(e,t,i,s){t.source.state.intervalsVisibilities=(0,Dt.mergeIntervalVisibilitiesDefaults)(t.source.state.intervalsVisibilities),(0,Dt.makeIntervalsVisibilitiesVisibleAtInterval)(t.source.state.intervalsVisibilities,p.Interval.parse(this.model().mainSeries().interval()));const r=new Je(this.model(),t,e,i,s);this._pushUndoCommand(r);const n=r.source();return r.needCopyToOtherCharts()&&this._model().copyToOtherCharts([n],!0),this.selectionMacro((e=>{e.clearSelection(),e.addSourceToSelection(n,null)})),n}pasteStudy(e,t){const i=new lt(this.model(),e,null==t?void 0:t.id());this._pushUndoCommand(i);const s=(0,o.ensureNotNull)(i.state()).id;return(0,oi.emit)("study_event",s,"paste_study"),(0,o.ensureNotNull)(this._model().dataSourceForId(s))}setPriceScaleCurrency(e,t){const i=new Qe.SetPriceScaleCurrencyUndoCommand(e,t,this.chartWidget(),wi);this._pushUndoCommand(i)}setPriceScaleUnit(e,t){const i=new et.SetPriceScaleUnitUndoCommand(e,t,this.chartWidget(),Pi);this._pushUndoCommand(i)}setSymbol(e,t){e.symbol()!==t&&this._pushUndoCommand(new nt(e,t,this.chartWidget()))}setResolution(e,t){e===this.mainSeries()&&(t=e.getSupportedResolution(t)),p.Interval.isEqual(e.interval(),t)||this._pushUndoCommand(new ii(e,t,this.chartWidget()))}chartLoadTheme(e,t,i){const s=new ei(this.model(),e,t);i?s.redo():this._pushUndoCommand(s)}isJustClonedChart(){return this._chartWidget.isJustClonedChart()}isMultipleLayout(){return this._chartWidget.isMultipleLayout()}addPaneStretchFactorUndoCommand(e,t,i,s){const r=new ct(this.model(),e,t,i,s);this._pushUndoCommand(r)}paneForSource(e){return this.m_model.paneForSource(e)}destroy(){this.m_model.destroy()}moveSelectedToolsLeft(){return this._moveSelectedTools(2)}moveSelectedToolsUp(){return this._moveSelectedTools(0)}moveSelectedToolsRight(){return this._moveSelectedTools(3)}moveSelectedToolsDown(){ -return this._moveSelectedTools(1)}insertStudyWithoutCheck(e,t,i,s){return this._insertStudy(e,t,{},!1,[],void 0,void 0,void 0,void 0,null!=i?i:null,void 0,s)}saveLineToolState(e,t){this._pushUndoCommand(new E(this.m_model,[e],t))}resetScales(){this._model().stopTimeScaleAnimation(),this.beginUndoMacro(Ni),this.resetTimeScale();for(const e of this.m_model.panes()){for(const t of e.leftPriceScales())this.resetPriceScale(e,t);for(const t of e.rightPriceScales())this.resetPriceScale(e,t)}this.endUndoMacro(),this.m_model.recalculateAllPanes((0,ve.viewportChangeEvent)())}shareLineTools(e,t){}canCreateStudy(e){return this.model().chartApi().canCreateStudy(e)}studiesMetaData(){return this.m_model.studiesMetaData()}fullSourceId(e){return this._chartWidget.fullSourceId(e)}chartWidgetCollectionLock(){return this._chartWidget.chartWidgetCollection().lock}_isCountedStudy(e){throw new Error("Not implemented")}_mergeUnmergeSource(e,t){this.beginUndoMacro(t.text());const i=(0,o.ensureNotNull)(this._model().paneForSource(e)),s=new Set(i.sourcesByGroup().lineSources().filter((t=>t.ownerSource()===e)));this._model().lineToolsGroupModel().groups().filter((e=>{const t=e.lineTools().some((e=>s.has(e))),i=e.lineTools().some((e=>!s.has(e)));return t&&i})).forEach((e=>{this._pushUndoCommand(new V.ExcludeLineToolsFromGroupUndoCommand(this._model(),e,e.lineTools()))})),this._pushUndoCommand(t),this.endUndoMacro()}_insertStudy(e,t,i,s,r,n,a,l,c,h,d,u){const p=Hi.format({title:e.description});this.beginUndoMacro(p);const _=new pt(this.model(),e,t,i,s,r,n,a,l,c,h||null,u,p);this._pushUndoCommand(_);const m=_.insertedStudy();if(void 0!==d){const e=new _t.SetPriceScaleModeCommand(d,(0,o.ensureNotNull)(m.priceScale()),null,this.model());this._pushUndoCommand(e)}return this.endUndoMacro(),{study:m,startPromise:_.lastInsertionStartPromise()}}async _processSpecialLineToolsContents(e,t,i){0}_insertAfterOrBefore(e,t,i,s){const r=(0,o.ensureNotNull)(this._model().paneForSource(i));if(t.some((e=>(0,f.isLineTool)(e)&&this._model().paneForSource(e)!==r)))throw new Error("Cannot insert line tool after target on another pane");this.beginUndoMacro(e),t.forEach((e=>{(0,o.ensureNotNull)(this.model().paneForSource(e))!==r&&this.mergeToPane(e,r)}));const n=s();this._pushUndoCommand(n),this.emitEvent("changeZOrder",[t]),this.endUndoMacro()}_sendBackOrBringForward(e,t,i){const s=new Map;t.forEach((e=>{const t=(0,o.ensureNotNull)(this._model().paneForSource(e)),i=s.get(t)||[];i.push(e),s.set(t,i)})),this.beginUndoMacro(e),s.forEach(((e,t)=>{this._pushUndoCommand(i(t,e))})),this.endUndoMacro(),this.emitEvent("changeZOrder",[t])}_moveSelectedTools(e){const t=this.model().selection().lineDataSources();if(0===t.length)return!1;if((0,Ae.lockDrawings)().value())return!0;const i=this.timeScale().visibleBarsStrictRange();if(null===i)return!1;const s=function(e){const t=new Map;for(const i of e){const e=i.ownerSource();if(null===e)continue;let s=t.get(e);if(void 0===s){const r=e.priceScale(),n=e.priceStep(),o=e.firstValue();if(null===r||null===n||null===o)continue +return this._moveSelectedTools(1)}insertStudyWithoutCheck(e,t,i,s){return this._insertStudy(e,t,{},!1,[],void 0,void 0,void 0,void 0,null!=i?i:null,void 0,s)}saveLineToolState(e,t){this._pushUndoCommand(new V(this.m_model,[e],t))}resetScales(){this._model().stopTimeScaleAnimation(),this.beginUndoMacro(Ni),this.resetTimeScale();for(const e of this.m_model.panes()){for(const t of e.leftPriceScales())this.resetPriceScale(e,t);for(const t of e.rightPriceScales())this.resetPriceScale(e,t)}this.endUndoMacro(),this.m_model.recalculateAllPanes((0,ve.viewportChangeEvent)())}shareLineTools(e,t){}canCreateStudy(e){return this.model().chartApi().canCreateStudy(e)}studiesMetaData(){return this.m_model.studiesMetaData()}fullSourceId(e){return this._chartWidget.fullSourceId(e)}chartWidgetCollectionLock(){return this._chartWidget.chartWidgetCollection().lock}_isCountedStudy(e){throw new Error("Not implemented")}_mergeUnmergeSource(e,t){this.beginUndoMacro(t.text());const i=(0,o.ensureNotNull)(this._model().paneForSource(e)),s=new Set(i.sourcesByGroup().lineSources().filter((t=>t.ownerSource()===e)));this._model().lineToolsGroupModel().groups().filter((e=>{const t=e.lineTools().some((e=>s.has(e))),i=e.lineTools().some((e=>!s.has(e)));return t&&i})).forEach((e=>{this._pushUndoCommand(new E.ExcludeLineToolsFromGroupUndoCommand(this._model(),e,e.lineTools()))})),this._pushUndoCommand(t),this.endUndoMacro()}_insertStudy(e,t,i,s,r,n,a,l,c,h,d,u){const p=Hi.format({title:e.description});this.beginUndoMacro(p);const _=new pt(this.model(),e,t,i,s,r,n,a,l,c,h||null,u,p);this._pushUndoCommand(_);const m=_.insertedStudy();if(void 0!==d){const e=new _t.SetPriceScaleModeCommand(d,(0,o.ensureNotNull)(m.priceScale()),null,this.model());this._pushUndoCommand(e)}return this.endUndoMacro(),{study:m,startPromise:_.lastInsertionStartPromise()}}async _processSpecialLineToolsContents(e,t,i){0}_insertAfterOrBefore(e,t,i,s){const r=(0,o.ensureNotNull)(this._model().paneForSource(i));if(t.some((e=>(0,f.isLineTool)(e)&&this._model().paneForSource(e)!==r)))throw new Error("Cannot insert line tool after target on another pane");this.beginUndoMacro(e),t.forEach((e=>{(0,o.ensureNotNull)(this.model().paneForSource(e))!==r&&this.mergeToPane(e,r)}));const n=s();this._pushUndoCommand(n),this.emitEvent("changeZOrder",[t]),this.endUndoMacro()}_sendBackOrBringForward(e,t,i){const s=new Map;t.forEach((e=>{const t=(0,o.ensureNotNull)(this._model().paneForSource(e)),i=s.get(t)||[];i.push(e),s.set(t,i)})),this.beginUndoMacro(e),s.forEach(((e,t)=>{this._pushUndoCommand(i(t,e))})),this.endUndoMacro(),this.emitEvent("changeZOrder",[t])}_moveSelectedTools(e){const t=this.model().selection().lineDataSources();if(0===t.length)return!1;if((0,Ae.lockDrawings)().value())return!0;const i=this.timeScale().visibleBarsStrictRange();if(null===i)return!1;const s=function(e){const t=new Map;for(const i of e){const e=i.ownerSource();if(null===e)continue;let s=t.get(e);if(void 0===s){const r=e.priceScale(),n=e.priceStep(),o=e.firstValue();if(null===r||null===n||null===o)continue ;if(null===r.priceRange())continue;s={sources:[],priceScale:r,priceStep:n,startPrice:i.points()[0].price,firstValue:o},t.set(e,s)}s.sources.push(i)}return t}(t);if(0===s.size)return!1;this.beginUndoMacro(Si,$i);const r=i.firstBar(),n=this.timeScale().indexToCoordinate(r),o=r+(3===e?1:2===e?-1:0),l=this.timeScale().indexToCoordinate(o);return Ae.isDirectionalMovementActive.setValue(!0),s.forEach((t=>{const{startPrice:i,priceStep:s,priceScale:c,firstValue:h}=t,d=i+(0===e?s:1===e?-s:0),u=c.priceToCoordinate(i,h),p=c.priceToCoordinate(d,h),_={logical:{index:r,price:i},screen:new a.Point(n,u)},m={logical:{index:o,price:d},screen:new a.Point(l,p)};this.startMovingSources(t.sources,_,null),this.moveSources(m),this.endMovingSource(!1,!0)})),Ae.isDirectionalMovementActive.setValue(!1),this.endUndoMacro(),!0}_restoreStudyFactoryDefaults(e){const t=new kt(this.m_model,e.properties());this._pushUndoCommand(t)}_restoreLineToolFactoryDefaults(e){this.beginUndoMacro(yi,$i),this.saveLineToolState(e,yi);const t=new At(this.m_model,e.properties(),yi);this._pushUndoCommand(t),this.saveLineToolState(e,yi),this.endUndoMacro(),this.model().updateSource(e)}_removeAllDrawingToolsImpl(e){this.selectionMacro((()=>{this.lineBeingCreated()&&this.cancelCreatingLine();this.dataSources().filter(f.isLineTool).filter((e=>e.isActualSymbol()&&e.isUserDeletable())).filter((t=>!e||e===t.toolname)).forEach((e=>this.removeSource(e,!1)))}),!0)}_removeAllStudiesImpl(){const e=this.dataSources(),t=e.filter(P.isStudy).filter((e=>!e.isChildStudy()&&e.removeByRemoveAllStudies())),i=e.filter(P.isStudyStub);t.concat(i).forEach((e=>this.removeSource(e,!1)))}}},20585:(e,t,i)=>{"use strict";var s=i(50151).assert,r=i(73971).ChartModelBase,n=i(92249).isLineTool,o=i(30255).Watermark,a=i(49483).CheckMobile,l=i(91280).InvalidationMask,c=i(91280).InvalidationLevel,h=i(57898).Delegate;const{globalChangeEvent:d,sourceChangeEvent:u}=i(28558);var p=i(28853),_=p.isStudy,m=p.isFundamentalStudy,g=i(88348),f=i(90565).MainSeriesScaleRatioProperty,v=i(29541).scaleRatio,S=i(97340).StudyInserter,y=i(83407).dateFormatProperty,b=i(16164).timeHoursFormatProperty,w=i(76422),P=i(65379).StudyColorRotatorFactory,C=i(14483),x=i(28640).AppliedTimeFrame;i(99652).ReplayStatus,C.enabled("fix_left_edge");class T extends r{constructor(e,t,i,s,r,n,a,l,c,h,d){super(e,t,i,s,r,n,a,l,c,h,d);var u=this;this._mainSeriesScaleRatioProperty=new f(this),this.m_mainSeries.dataEvents().completed().subscribe(this,function(){this._scrollingState&&this.gotoTime()}.bind(this)),this.m_mainSeries.onIntervalChanged().subscribe(this,(function(){this._recalcVRStudiesParams.oldStartVisibleIndex=NaN,this._recalcVRStudiesParams.oldEndVisibleIndex=NaN})),this._readOnly||(this.m_mainSeries.properties().addChild("priceAxisProperties",this.m_mainSeries.priceScale().properties()),this._properties.paneProperties.legendProperties.showStudyTitles.listeners().subscribe(this,(function(e){e.value()||u._properties.paneProperties.legendProperties.showStudyArguments.setValue(!1)}))), this._watermarkSource=this._options.watermarkEnabled?new o(this,this.m_mainSeries):null,g.hideAllDrawings().subscribe(this,this._onDrawingsVisibilityChanged),g.hideAllIndicators().subscribe(this,this._onIndicatorsVisibilityChanged),this._properties.scalesProperties.listeners().subscribe(this,T.prototype.fullUpdate),this._studyShiftColorStartOffset=void 0,y.subscribe(this,this._updateDateTimeFormatter),b.subscribe(this,this._updateDateTimeFormatter),this.mainSeries().properties().interval.subscribe(this,this._updateDateTimeFormatter),this._updateDateTimeFormatter(),this._studyColorRotatorFactory=new P(this),this._dataSourceCollectionChanged.subscribe(this,this._updateShowLegendProperty.bind(this)),this._properties.paneProperties.legendProperties.showLegend.subscribe(this,this._updateShowLegendProperty),this._appliedTimeFrame=new x(this),this.mainSeries().onTimeFrameApplied().subscribe(this,(function(e){var t=null!==e?{res:this.mainSeries().interval(),val:e}:null;this.appliedTimeFrame().setValue(t)}))}applyPreferences(e){for(var t in e)void 0!==this._properties[t]&&"m_mainSeries"!==this._properties[t]&&this._properties[t].mergeAndFire(e[t]);void 0!==e.timeScale&&(this._timeScale.defaultRightOffset().setValue(e.timeScale.defaultRightOffset),this._timeScale.defaultRightOffsetPercentage().setValue(e.timeScale.defaultRightOffsetPercentage),this._timeScale.usePercentageRightOffset().setValue(e.timeScale.usePercentageRightOffset)),this._properties.saveDefaults(),this.m_mainSeries.applyPreferences(e.mainSeries),this.sessions().applyPreferences(e.sessions),this.recalculateAllPanes(d()),this.fullUpdate()}timezone(){return this._properties.timezone.value()}initConnection(){this._chartApi.switchTimezone(this.timezone())}updatePane(e){var t=this._paneInvalidationMask(e);this.invalidate(t)}fullUpdate(){this.invalidate(l.full())}lightUpdate(){this.invalidate(l.light())}studiesMetaData(){return this._studiesMetaData}studyVersioning(){return this._studyVersioning}startNotStartedStudies(){if(!this.m_mainSeries.isStarted())throw new Error("Cannot start studies: main series is not started");for(var e=this.dataSources(),t=0;t0),n?{left:0,right:1,totallySlots:i}:{left:1,right:0,totallySlots:i}}return{left:e,right:t,totallySlots:e+t}}setPriceAutoScale(e,t,i){e.setPriceAutoScale(t,i),this.invalidate(this._paneInvalidationMask(e,c.Light))}updateScales(e,t){this._undoModel._chartWidget._updateScalesActions()}mainSeriesScaleRatioProperty(){return this._mainSeriesScaleRatioProperty}mainSeriesScaleRatioPropertyOnChanged(){this._mainSeriesScaleRatioProperty.listeners().fire(this._mainSeriesScaleRatioProperty)}mainSeriesScaleRatio(){return v(this._timeScale,this.m_mainSeries.priceScale())}setMainSeriesScaleRatio(e){this.paneForSource(this.m_mainSeries).applyPriceScaleRatio(this.m_mainSeries.priceScale(),e)}restoreFactoryDefaults(e){e.restoreFactoryDefaults(),this.recalcVisibleRangeStudies(!0)}orderedDataSources(e){var t=[];t.push(this.m_crossHairSource);for(var i=0;ithis.removeSource(e))),Array.from(this._customSourcesMap.keys()).forEach(this._removeCustomSource,this),s(0===this._topmostCustomSources.length),s(0===this._fgCustomSources.length),s(0===this._bgCustomSources.length),s(0===this._allCustomSources.length),s(0===this._customSourcesMap.size);for(var e=0;e{"use strict";var s;i.d(t,{ColorType:()=>s}),function(e){e.Solid="solid",e.Gradient="gradient"}(s||(s={}))},42226:(e,t,i)=>{"use strict";i.d(t,{currencyUnitVisibilityOptions:()=>a,currencyUnitVisibilityProperty:()=>o,migrateShowCurrencyAndShowUnitProperties:()=>h,restoreCurrencyUnitVisibilitySettingsValue:()=>l});var s=i(29542),r=i(56840),n=i.n(r);const{property:o,availableValues:a,restoreDefaultValue:l}=(0,s.createVisibilityController)("PriceAxisCurrencyAndUnit.visibility");let c=!1;function h(e,t){c||(c=!0,void 0===n().getValue("PriceAxisCurrencyAndUnit.visibility")&&o().setValue(e||t?"alwaysOn":"alwaysOff"))}},39262:(e,t,i)=>{"use strict";i.d(t,{sourceNewCurrencyOnPinningToPriceScale:()=>r});var s=i(18611);function r(e,t,i,r){let n=null;if(i.currencyConversionEnabled()&&(0,s.isActingAsSymbolSource)(e)){const s=i.availableCurrencies(),o=t.currency(s),a=e.currency();null!==o&&null!==o.selectedCurrency&&!o.allCurrenciesAreOriginal&&o.selectedCurrency!==a&&(r&&null===a||null!==a&&s.convertible(a))&&(n=o.selectedCurrency)}return n}},15742:(e,t,i)=>{"use strict";i.d(t,{CustomSourceBase:()=>s});class s{constructor(e,t){this._id=e,this._model=t}id(){return this._id}isHoveredEnabled(){return!0}isSelectionEnabled(){return!1}priceScale(){return null}paneViews(e){return[]}labelPaneViews(e){return[]}priceAxisViews(e,t){return[]}updateViewsForPane(e,t){e.containsMainSeries()&&this.updateAllViews(t)}}},53588:(e,t,i)=>{"use strict";i.d(t,{isLineToolState:()=>o,isMainSeriesState:()=>r,isStudyLineToolState:()=>a,isStudyState:()=>n});var s=i(15367);function r(e){return"MainSeries"===e.type}function n(e){return Boolean(e.type)&&e.type.toLowerCase().startsWith("study")}function o(e){return Boolean(e.type)&&(0,s.isLineToolName)(e.type)}function a(e){return Boolean(e.type)&&(0,s.isStudyLineToolName)(e.type)}},14292:(e,t,i)=>{"use strict";i.d(t,{DataSource:()=>l,getTranslatedStringForSource:()=>a});i(14483);var s=i(36298),r=i(97145),n=i(36174),o=i(57898);function a(e,t){return new s.TranslatedString(t.name(),t.title(e))}class l{constructor(e){this.hasAlert=new r.WatchedValue(!1),this._zorder=0,this._priceScale=null,this._ownerSource=null,this._userEditEnabled=!0,this._priceScaleChanged=new o.Delegate,this._isSelectionEnabled=!0,this._instanceId=(0,n.randomHashN)(6), this._ownerSourceChanged=new o.Delegate,this._zOrderChanged=new o.Delegate,this._id=null!=e?e:(0,n.randomHashN)(6)}id(){return this._id}instanceId(){return this._instanceId}preferNoScale(){return!1}setId(e){this._id=e}zorder(){return this._zorder}setZorder(e){"number"==typeof e&&this._zorder!==e&&(this._zorder=e,this._zOrderChanged.fire(e))}preferredZOrder(){return null}isSpeciallyZOrderedSource(){return!1}title(e){return this.name()}priceScale(){return this._priceScale}setPriceScale(e){this._priceScale=e,this._priceScaleChanged.fire(e)}priceScaleChanged(){return this._priceScaleChanged}ownerSource(){return this._ownerSource}setOwnerSource(e){const t=this._ownerSource;this._ownerSource=e,this._ownerSourceChanged.fire(t,e)}ownerSourceChanged(){return this._ownerSourceChanged}zOrderChanged(){return this._zOrderChanged}isSavedInChart(e){return!0}isSavedInStudyTemplates(){return!0}isRemovedByStudyTemplates(){return!0}hasContextMenu(){return!0}showInObjectTree(){return!0}setUserEditEnabled(e){this._userEditEnabled=e}userEditEnabled(){return this._userEditEnabled}canBeHidden(){return this.userEditEnabled()}isUserDeletable(){return this.userEditEnabled()}properties(){return null}isVisible(){return this.properties().visible.value()}dataWindowView(){return null}priceAxisViews(e,t){return null}timeAxisViews(){return null}updateAllViews(e){}paneViews(e){return null}labelPaneViews(){return null}isFailed(){return!1}isLoading(){return!1}isPhantom(){return!1}isChildStudy(){return!1}hasChildren(){return!1}canHaveChildren(){return!1}onClickOutside(e){}getSourceIcon(){return null}state(e){return null}doesMovingAffectsUndo(){return!0}isMultiPaneAvailable(){return!1}isMultiPaneEnabled(){return!1}copiable(){return!1}cloneable(){return!1}movable(){return!1}isIncludedInAutoScale(){return!1}isHoveredEnabled(){return this.isSelectionEnabled()}showOnTopOnHovering(){return!0}isSelectionEnabled(){return this._isSelectionEnabled}setSelectionEnabled(e){this._isSelectionEnabled=e}firstValue(){return null}priceRange(e,t){return null}autoScaleInfo(e,t){return{range:this.priceRange(e,t)}}stateForAlert(){return null}canHasAlert(){return!1}alertCreationAvailable(){return new r.WatchedValue(this.hasStateForAlert()).readonly()}hasStateForAlert(){return!1}idForAlert(){return this._id}}},93835:(e,t,i)=>{"use strict";i.d(t,{DataWindowItem:()=>s,DataWindowView:()=>r});class s{constructor(e,t,i,s=!1){this._visible=!0,this._id=e,this._title=t,this._value=i,this._unimportant=s}id(){return this._id}title(){return this._title}setTitle(e){this._title=e}text(){return this._value}value(){return this._value}setValue(e){this._value=e}visible(){return this._visible}setVisible(e){this._visible=e}color(){return this._color}setColor(e){this._color=e}unimportant(){return this._unimportant}}class r{constructor(){this._items=[],this._header="",this._title=""}header(){return this._header}title(){return this._title}items(){return this._items}update(){}}},83407:(e,t,i)=>{"use strict";i.d(t,{dateFormatProperty:()=>l,restoreDateFormatSettingsValue:()=>c}) ;var s=i(56840),r=i(59680),n=i(15879);const o="date_format";function a(){return s.getValue(o,(0,n.defaultDateFormat)())}const l=(0,r.createPrimitiveProperty)(a());function c(){l.setValue((0,n.defaultDateFormat)()),s.remove(o)}s.onSync.subscribe(null,(()=>l.setValue(a()))),l.subscribe(null,(()=>s.setValue(o,l.value())))},46100:(e,t,i)=>{"use strict";i.r(t),i.d(t,{DefaultProperty:()=>_,createDefaultsState:()=>d,saveDefaultProperties:()=>p});var s=i(27788),r=i(58121),n=i(15736),o=i(85804),a=i(59452),l=i.n(a),c=i(57898);function h(e,t){const i=(0,s.default)(e);return t.forEach((e=>(0,n.default)(i,e.split(".")))),i}function d(e,t,i,n){const a=e?o.defaults:o.factoryDefaults,l=t.startsWith("study_")?(0,s.default)(a("study")):{};let c=(0,s.default)(a(t,n));return t.startsWith("study_")&&c.inputs&&delete c.inputs.symbol,"linetoolicon"===t&&e&&(c.icon=(0,o.defaults)(t).icon),"linetooemoji"===t&&e&&(c.emoji=(0,o.defaults)(t).emoji),"linetoolsticker"===t&&e&&(c.sticker=(0,o.defaults)(t).sticker),c=h(c,i),(0,r.default)(l,c),l}let u=!1;function p(e){u=e}class _ extends(l()){constructor(e,t,i,s){super(function(e,t,i,s){let n;return void 0===s&&(s=!0),i?n=t:(n=d(s,e,[],null),t&&(0,r.default)(n,t)),n}(e,t,i,s)),this._exclusions=[],this._restoreFactoryDefaultsEvent=new c.Delegate,this._defaultName=e,this._useUserPreferences=null==s||s,this.listeners().subscribe(this,_.prototype.onPropertyChanged),this._restoreFactoryDefaultsEvent=new c.Delegate}preferences(){return this.state(this._exclusions)}mergePreferences(e){this.mergeAndFire(h(e,this._exclusions))}addExclusion(e){this._exclusions.indexOf(e)<0&&this._exclusions.push(e)}removeExclusion(e){const t=this._exclusions.indexOf(e);-1!==t&&this._exclusions.splice(t,1)}restoreFactoryDefaults(){const e=d(!1,this._defaultName,this._exclusions,null);this.mergeAndFire(e),this._defaultName.startsWith("study_")&&!this._defaultName.startsWith("study_VbPFixed")||(0,o.saveDefaults)(this._defaultName,void 0),this._restoreFactoryDefaultsEvent.fire()}onRestoreFactoryDefaults(){return this._restoreFactoryDefaultsEvent}onPropertyChanged(){!u||this._defaultName.startsWith("study_")&&!this._defaultName.startsWith("study_VbPFixed")||this.saveDefaults()}saveDefaults(){this._useUserPreferences&&(0,o.saveDefaults)(this._defaultName,this.preferences())}clone(e){const t=new _(this._defaultName,this.state(),null==e?void 0:e.replaceByState,this._useUserPreferences);for(let e=0;e{"use strict";var s=i(67980).PlDisplay;const{getHexColorByName:r}=i(48891),{generateColor:n}=i(87095);var o=i(67980).TradedGroupHorizontalAlignment,a=i(88732),l=i(90095).LineToolPitchforkStyle,c=i(99987).LineToolBarsPatternMode,h=i(72877),d=h.LineStudyPlotStyle,u=h.STUDYPLOTDISPLAYTARGET,p=i(42609),_=i(74304).PriceAxisLastValueMode,m=i(9482).StoriesTimeLineItemType,g=i(36147).MagnetMode,f=i(73436).LineEnd,v=i(93613).ColorType,S=i(62615).RangeBarStyle,y=i(9155).StatsPosition,b=i(16776).sessionsPreferencesDefault,w=i(81580).axisLabelBackgroundColor -;const{LINESTYLE_SOLID:P,LINESTYLE_DOTTED:C,LINESTYLE_DASHED:x}=i(79849);var T=i(59224).getLogger("Chart.Defaults");const I=r("color-black"),M=r("color-white"),L=n(M,75),A=r("color-tv-blue-50"),k=r("color-tv-blue-500"),D=n(k,30),V=n(k,70),E=n(k,72),B=n(k,75),R=n(k,80),N=r("color-tv-blue-600"),O=r("color-deep-blue-200"),F=r("color-deep-blue-300"),W=r("color-deep-blue-500"),H=n(W,80),z=r("color-sky-blue-500"),U=n(z,80),j=r("color-sky-blue-700"),G=n(j,30),q=r("color-youtube"),$=r("color-ripe-red-200"),Y=r("color-ripe-red-300"),K=r("color-ripe-red-400"),Z=r("color-ripe-red-500"),X=n(Z,70),J=n(Z,80),Q=n(Z,72),ee=n(Z,95),te=r("color-ripe-red-600"),ie=r("color-grapes-purple-500"),se=n(ie,100),re=n(ie,80),ne=n(ie,30),oe=r("color-berry-pink-500"),ae=n(oe,80),le=r("color-minty-green-100"),ce=r("color-minty-green-500"),he=n(ce,80),de=n(ce,72),ue=n(ce,95),pe=r("color-iguana-green-300"),_e=r("color-iguana-green-500"),me=n(_e,80),ge=r("color-tan-orange-300"),fe=r("color-tan-orange-500"),ve=n(fe,80),Se=r("color-tan-orange-600"),ye=r("color-tan-orange-700"),be=r("color-cold-gray-150"),we=r("color-cold-gray-300"),Pe=r("color-cold-gray-400"),Ce=r("color-cold-gray-450"),xe=r("color-cold-gray-500"),Te=r("color-cold-gray-800"),Ie=n(Te,94),Me=n(Te,100),Le=r("color-cold-gray-900"),Ae=r("color-cold-gray-750"),ke=r("color-slate-gray"),De=r("color-silver-tree"),Ve=n(De,95),Ee=r("color-mandy"),Be=n(Ee,95);var Re=function(e){var t=function(e,t){return{color:e,visible:t}},i=function(e,t,i){return{coeff:e,color:t,visible:i}},r=function(e,t,i,s,r){return{coeff:e,color:t,visible:i,linestyle:void 0===s?P:s,linewidth:void 0===r?1:r}},h=function(e,t,i){return{color:e,width:i,visible:t}},T=function(e,t,i,s,r){return{color:e,visible:t,width:i,x:s,y:r}},Te=function(e,t,i,s,r,n){return{coeff1:e,coeff2:t,color:i,visible:s,linestyle:void 0===r?P:r,linewidth:void 0===n?1:n}};if(void 0===TradingView.defaultProperties){var Re;switch(window.locale){case"ar_AE":Re="Asia/Dubai";break;case"au":Re="Australia/Sydney";break;case"br":Re="America/Sao_Paulo";break;case"ca":Re="America/Toronto";break;case"de_DE":case"it":Re="Europe/Berlin";break;case"es":Re="Europe/Madrid";break;case"fa_IR":Re="Asia/Tehran";break;case"fr":case"sv_SE":Re="Europe/Paris";break;case"he_IL":case"tr":Re="Europe/Athens";break;case"hu_HU":case"pl":Re="Europe/Warsaw";break;case"id":case"th_TH":case"vi_VN":Re="Asia/Bangkok";break;case"in":Re="Asia/Kolkata";break;case"ja":case"kr":Re="Asia/Tokyo";break;case"ms_MY":Re="Asia/Singapore";break;case"ru":Re="Europe/Moscow";break;case"uk":Re="Europe/London";break;case"zh_CN":case"zh_TW":Re="Asia/Shanghai";break;default:Re="Etc/UTC"}TradingView.defaultProperties={chartproperties:{timezone:Re,priceScaleSelectionStrategyName:"auto",paneProperties:{backgroundType:v.Solid,background:M,backgroundGradientStartColor:M,backgroundGradientEndColor:M,gridLinesMode:"both",vertGridProperties:{color:Ie,style:P},horzGridProperties:{color:Ie,style:P},crossHairProperties:{color:Pe,style:x,transparency:0,width:1},topMargin:10,bottomMargin:8,axisProperties:{autoScale:!0, +;const{LINESTYLE_SOLID:P,LINESTYLE_DOTTED:C,LINESTYLE_DASHED:x}=i(79849);var T=i(59224).getLogger("Chart.Defaults");const I=r("color-black"),M=r("color-white"),L=n(M,75),A=r("color-tv-blue-50"),k=r("color-tv-blue-500"),D=n(k,30),E=n(k,70),V=n(k,72),B=n(k,75),R=n(k,80),N=r("color-tv-blue-600"),O=r("color-deep-blue-200"),F=r("color-deep-blue-300"),W=r("color-deep-blue-500"),H=n(W,80),z=r("color-sky-blue-500"),U=n(z,80),j=r("color-sky-blue-700"),G=n(j,30),q=r("color-youtube"),$=r("color-ripe-red-200"),Y=r("color-ripe-red-300"),K=r("color-ripe-red-400"),Z=r("color-ripe-red-500"),X=n(Z,70),J=n(Z,80),Q=n(Z,72),ee=n(Z,95),te=r("color-ripe-red-600"),ie=r("color-grapes-purple-500"),se=n(ie,100),re=n(ie,80),ne=n(ie,30),oe=r("color-berry-pink-500"),ae=n(oe,80),le=r("color-minty-green-100"),ce=r("color-minty-green-500"),he=n(ce,80),de=n(ce,72),ue=n(ce,95),pe=r("color-iguana-green-300"),_e=r("color-iguana-green-500"),me=n(_e,80),ge=r("color-tan-orange-300"),fe=r("color-tan-orange-500"),ve=n(fe,80),Se=r("color-tan-orange-600"),ye=r("color-tan-orange-700"),be=r("color-cold-gray-150"),we=r("color-cold-gray-300"),Pe=r("color-cold-gray-400"),Ce=r("color-cold-gray-450"),xe=r("color-cold-gray-500"),Te=r("color-cold-gray-800"),Ie=n(Te,94),Me=n(Te,100),Le=r("color-cold-gray-900"),Ae=r("color-cold-gray-750"),ke=r("color-slate-gray"),De=r("color-silver-tree"),Ee=n(De,95),Ve=r("color-mandy"),Be=n(Ve,95);var Re=function(e){var t=function(e,t){return{color:e,visible:t}},i=function(e,t,i){return{coeff:e,color:t,visible:i}},r=function(e,t,i,s,r){return{coeff:e,color:t,visible:i,linestyle:void 0===s?P:s,linewidth:void 0===r?1:r}},h=function(e,t,i){return{color:e,width:i,visible:t}},T=function(e,t,i,s,r){return{color:e,visible:t,width:i,x:s,y:r}},Te=function(e,t,i,s,r,n){return{coeff1:e,coeff2:t,color:i,visible:s,linestyle:void 0===r?P:r,linewidth:void 0===n?1:n}};if(void 0===TradingView.defaultProperties){var Re;switch(window.locale){case"ar_AE":Re="Asia/Dubai";break;case"au":Re="Australia/Sydney";break;case"br":Re="America/Sao_Paulo";break;case"ca":Re="America/Toronto";break;case"de_DE":case"it":Re="Europe/Berlin";break;case"es":Re="Europe/Madrid";break;case"fa_IR":Re="Asia/Tehran";break;case"fr":case"sv_SE":Re="Europe/Paris";break;case"he_IL":case"tr":Re="Europe/Athens";break;case"hu_HU":case"pl":Re="Europe/Warsaw";break;case"id":case"th_TH":case"vi_VN":Re="Asia/Bangkok";break;case"in":Re="Asia/Kolkata";break;case"ja":case"kr":Re="Asia/Tokyo";break;case"ms_MY":Re="Asia/Singapore";break;case"ru":Re="Europe/Moscow";break;case"uk":Re="Europe/London";break;case"zh_CN":case"zh_TW":Re="Asia/Shanghai";break;default:Re="Etc/UTC"}TradingView.defaultProperties={chartproperties:{timezone:Re,priceScaleSelectionStrategyName:"auto",paneProperties:{backgroundType:v.Solid,background:M,backgroundGradientStartColor:M,backgroundGradientEndColor:M,gridLinesMode:"both",vertGridProperties:{color:Ie,style:P},horzGridProperties:{color:Ie,style:P},crossHairProperties:{color:Pe,style:x,transparency:0,width:1},topMargin:10,bottomMargin:8,axisProperties:{autoScale:!0, autoScaleDisabled:!1,lockScale:!1,percentage:!1,percentageDisabled:!1,indexedTo100:!1,log:!1,logDisabled:!1,alignLabels:!0,isInverted:!1},legendProperties:{showStudyArguments:!0,showStudyTitles:!0,showStudyValues:!0,showSeriesTitle:!0,showSeriesOHLC:!0,showLegend:!0,showBarChange:!0,showVolume:!1,showBackground:!0,showPriceSource:!0,backgroundTransparency:50,showLogo:!0},separatorColor:be},scalesProperties:{backgroundColor:M,lineColor:Me,textColor:Le,fontSize:12,scaleSeriesOnly:!1,showSeriesLastValue:!0,seriesLastValueMode:_.LastValueAccordingToScale,showSeriesPrevCloseValue:!1,showStudyLastValue:!0,showSymbolLabels:!1,showStudyPlotLabels:!1,showBidAskLabels:!1,showPrePostMarketPriceLabel:!0,showFundamentalNameLabel:!1,showFundamentalLastValue:!0,barSpacing:p.DEFAULT_BAR_SPACING,axisHighlightColor:B,axisLineToolLabelBackgroundColorCommon:w.common,axisLineToolLabelBackgroundColorActive:w.active,showPriceScaleCrosshairLabel:!0,showTimeScaleCrosshairLabel:!0,crosshairLabelBgColorLight:Le,crosshairLabelBgColorDark:Ae},mainSeriesProperties:{style:a.STYLE_CANDLES,esdShowDividends:!0,esdShowSplits:!0,esdShowEarnings:!0,esdShowBreaks:!1,esdFlagSize:2,showContinuousContractSwitches:!0,showContinuousContractSwitchesBreaks:!1,showFuturesContractExpiration:!0,showLastNews:!0,showCountdown:!0,bidAsk:{visible:!1,lineStyle:C,lineWidth:1,bidLineColor:k,askLineColor:K},prePostMarket:{visible:!0,lineStyle:C,lineWidth:1,preMarketColor:Se,postMarketColor:k},highLowAvgPrice:{highLowPriceLinesVisible:!1,highLowPriceLabelsVisible:!1,averageClosePriceLineVisible:!1,averageClosePriceLabelVisible:!1,highLowPriceLinesColor:"",highLowPriceLinesWidth:1,averagePriceLineColor:"",averagePriceLineWidth:1},visible:!0,showPriceLine:!0,priceLineWidth:1,priceLineColor:"",baseLineColor:we,showPrevClosePriceLine:!1,prevClosePriceLineWidth:1,prevClosePriceLineColor:"#555555",minTick:"default",dividendsAdjustment:void 0,backAdjustment:!1,settlementAsClose:!0,sessionId:"regular",sessVis:!1,statusViewStyle:{fontSize:16,showExchange:!0,showInterval:!0,symbolTextSource:"description"},candleStyle:{upColor:ce,downColor:Z,drawWick:!0,drawBorder:!0,borderColor:"#378658",borderUpColor:ce,borderDownColor:Z,wickColor:"#737375",wickUpColor:ce,wickDownColor:Z,barColorsOnPrevClose:!1,drawBody:!0},hollowCandleStyle:{upColor:ce,downColor:Z,drawWick:!0,drawBorder:!0,borderColor:"#378658",borderUpColor:ce,borderDownColor:Z,wickColor:"#737375",wickUpColor:ce,wickDownColor:Z,drawBody:!0},haStyle:{upColor:ce,downColor:Z,drawWick:!0,drawBorder:!0,borderColor:"#378658",borderUpColor:ce,borderDownColor:Z,wickColor:"#737375",wickUpColor:ce,wickDownColor:Z,showRealLastPrice:!1,barColorsOnPrevClose:!1,inputs:{},inputInfo:{},drawBody:!0},barStyle:{upColor:ce,downColor:Z,barColorsOnPrevClose:!1,dontDrawOpen:!1,thinBars:!0},hiloStyle:{color:k,showBorders:!0,borderColor:k,showLabels:!0,labelColor:k,drawBody:!0},columnStyle:{upColor:n(ce,50),downColor:n(Z,50),barColorsOnPrevClose:!0,priceSource:"close"},lineStyle:{color:k,linestyle:P,linewidth:2,priceSource:"close"},lineWithMarkersStyle:{ -color:k,linestyle:P,linewidth:2,priceSource:"close"},steplineStyle:{color:k,linestyle:P,linewidth:2,priceSource:"close"},areaStyle:{color1:E,color2:k,linecolor:k,linestyle:P,linewidth:2,priceSource:"close",transparency:100},hlcAreaStyle:{highLineColor:ce,highLineStyle:P,highLineWidth:2,lowLineColor:Z,lowLineStyle:P,lowLineWidth:2,closeLineColor:Ce,closeLineStyle:P,closeLineWidth:2,highCloseFillColor:he,closeLowFillColor:J},priceAxisProperties:{autoScale:!0,autoScaleDisabled:!1,lockScale:!1,percentage:!1,percentageDisabled:!1,indexedTo100:!1,log:!1,logDisabled:!1,isInverted:!1,alignLabels:!0},renkoStyle:{upColor:ce,downColor:Z,borderUpColor:ce,borderDownColor:Z,upColorProjection:"#a9dcc3",downColorProjection:"#f5a6ae",borderUpColorProjection:"#a9dcc3",borderDownColorProjection:"#f5a6ae",wickUpColor:ce,wickDownColor:Z,inputs:{source:"close",sources:"Close",boxSize:3,style:"ATR",atrLength:14,wicks:!0},inputInfo:{source:{name:"Source"},sources:{name:"Source"},boxSize:{name:"Box size"},style:{name:"Style"},atrLength:{name:"ATR length"},wicks:{name:"Wicks"}}},pbStyle:{upColor:ce,downColor:Z,borderUpColor:ce,borderDownColor:Z,upColorProjection:"#a9dcc3",downColorProjection:"#f5a6ae",borderUpColorProjection:"#a9dcc3",borderDownColorProjection:"#f5a6ae",inputs:{source:"close",lb:3},inputInfo:{source:{name:"Source"},lb:{name:"Number of line"}}},kagiStyle:{upColor:ce,downColor:Z,upColorProjection:"#a9dcc3",downColorProjection:"#f5a6ae",inputs:{source:"close",style:"ATR",atrLength:14,reversalAmount:1},inputInfo:{source:{name:"Source"},style:{name:"Style"},atrLength:{name:"ATR length"},reversalAmount:{name:"Reversal amount"}}},pnfStyle:{upColor:ce,downColor:Z,upColorProjection:"#a9dcc3",downColorProjection:"#f5a6ae",inputs:{sources:"Close",reversalAmount:3,boxSize:1,style:"ATR",atrLength:14,oneStepBackBuilding:!1},inputInfo:{sources:{name:"Source"},boxSize:{name:"Box size"},reversalAmount:{name:"Reversal amount"},style:{name:"Style"},atrLength:{name:"ATR length"},oneStepBackBuilding:{name:"One step back building"}}},baselineStyle:{baselineColor:ke,topFillColor1:de,topFillColor2:ue,bottomFillColor1:ee,bottomFillColor2:Q,topLineColor:ce,bottomLineColor:Z,topLineWidth:2,bottomLineWidth:2,priceSource:"close",transparency:50,baseLevelPercentage:50},rangeStyle:{barStyle:S.Bars,upColor:ce,downColor:Z,upColorProjection:"#a9dcc3",downColorProjection:"#f5a6ae",thinBars:!0,candlesUpColor:ce,candlesDownColor:Z,candlesBorderUpColor:ce,candlesBorderDownColor:Z,candlesWickUpColor:ce,candlesWickDownColor:Z,inputs:{range:10,phantomBars:!1},inputInfo:{range:{name:"Range"},phantomBars:{name:"Phantom bars"}}}},chartEventsSourceProperties:{visible:!0,futureOnly:!0,breaks:{color:"#555555",visible:!1,style:x,width:1}},tradingProperties:{showPositions:!0,positionPL:{visibility:!0,display:s.Money},bracketsPL:{visibility:!0,display:s.Money},showOrders:!0,showExecutions:!0,showExecutionsLabels:!1,showReverse:!0,horizontalAlignment:o.Right,extendLeft:!0,lineLength:5,lineWidth:1,lineStyle:P}, -editorFontsList:["Verdana","Courier New","Times New Roman","Arial"],volumePaneSize:"large"},sessions:b,drawings:{magnet:!1,magnetMode:g.WeakMagnet,stayInDrawingMode:!1,drawOnAllCharts:!0,drawOnAllChartsMode:1},linetoolorder:{extendLeft:"inherit",lineLength:"inherit",lineColor:q,lineActiveBuyColor:"#4094e8",lineInactiveBuyColor:"rgba(64, 148, 232, 0.5)",lineActiveSellColor:"#e75656",lineInactiveSellColor:"rgba(231, 86, 86, 0.5)",lineStyle:"inherit",lineWidth:"inherit",bodyBorderActiveBuyColor:"#4094e8",bodyBorderInactiveBuyColor:"rgba(64, 148, 232, 0.5)",bodyBorderActiveSellColor:"#e75656",bodyBorderInactiveSellColor:"rgba(231, 86, 86, 0.5)",bodyBackgroundColor:L,bodyBackgroundTransparency:25,bodyTextInactiveLimitColor:"rgba(38, 140, 2, 0.5)",bodyTextActiveLimitColor:"#268c02",bodyTextInactiveStopColor:"rgba(231, 86, 86, 0.5)",bodyTextActiveStopColor:"#e75656",bodyTextInactiveBuyColor:"rgba(64, 148, 232, 0.5)",bodyTextActiveBuyColor:"#4094e8",bodyTextInactiveSellColor:"rgba(231, 86, 86, 0.5)",bodyTextActiveSellColor:"#e75656",bodyFontFamily:"Verdana",bodyFontSize:9,bodyFontBold:!0,bodyFontItalic:!1,quantityBorderActiveBuyColor:"#4094e8",quantityBorderInactiveBuyColor:"rgba(64, 148, 232, 0.5)",quantityBorderActiveSellColor:"#e75656",quantityBorderInactiveSellColor:"rgba(231, 86, 86, 0.5)",quantityBackgroundInactiveBuyColor:"rgba(64, 148, 232, 0.5)",quantityBackgroundActiveBuyColor:"#4094e8",quantityBackgroundInactiveSellColor:"rgba(231, 86, 86, 0.5)",quantityBackgroundActiveSellColor:"#e75656",quantityTextColor:M,quantityTextTransparency:0,quantityFontFamily:"Verdana",quantityFontSize:9,quantityFontBold:!0,quantityFontItalic:!1,cancelButtonBorderActiveBuyColor:"#4094e8",cancelButtonBorderInactiveBuyColor:"rgba(64, 148, 232, 0.5)",cancelButtonBorderActiveSellColor:"#e75656",cancelButtonBorderInactiveSellColor:"rgba(231, 86, 86, 0.5)",cancelButtonBackgroundColor:L,cancelButtonBackgroundTransparency:25,cancelButtonIconActiveBuyColor:"#4094e8",cancelButtonIconInactiveBuyColor:"rgba(64, 148, 232, 0.5)",cancelButtonIconActiveSellColor:"#e75656",cancelButtonIconInactiveSellColor:"rgba(231, 86, 86, 0.5)",tooltip:"",modifyTooltip:"",cancelTooltip:""},linetoolposition:{extendLeft:"inherit",lineLength:"inherit",lineBuyColor:"#4094e8",lineSellColor:"#e75656",lineStyle:"inherit",lineWidth:"inherit",bodyBorderBuyColor:"#4094e8",bodyBorderSellColor:"#e75656",bodyBackgroundColor:L,bodyBackgroundTransparency:25,bodyTextPositiveColor:"#268c02",bodyTextNeutralColor:"#646464",bodyTextNegativeColor:"#e75656",bodyFontFamily:"Verdana",bodyFontSize:9,bodyFontBold:!0,bodyFontItalic:!1,quantityBorderBuyColor:"#4094e8",quantityBorderSellColor:"#e75656",quantityBackgroundBuyColor:"#4094e8",quantityBackgroundSellColor:"#e75656",quantityTextColor:M,quantityTextTransparency:0,quantityFontFamily:"Verdana",quantityFontSize:9,quantityFontBold:!0,quantityFontItalic:!1,reverseButtonBorderBuyColor:"#4094e8",reverseButtonBorderSellColor:"#e75656",reverseButtonBackgroundColor:L,reverseButtonBackgroundTransparency:25,reverseButtonIconBuyColor:"#4094e8", -reverseButtonIconSellColor:"#e75656",closeButtonBorderBuyColor:"#4094e8",closeButtonBorderSellColor:"#e75656",closeButtonBackgroundColor:L,closeButtonBackgroundTransparency:25,closeButtonIconBuyColor:"#4094e8",closeButtonIconSellColor:"#e75656",tooltip:"",protectTooltip:"",closeTooltip:"",reverseTooltip:""},linetoolexecution:{direction:"buy",arrowHeight:8,arrowSpacing:1,arrowBuyColor:"#4094e8",arrowSellColor:"#e75656",text:"",textColor:I,textTransparency:0,fontFamily:"Verdana",fontSize:10,fontBold:!1,fontItalic:!1,tooltip:""},linetoolicon:{color:k,size:40,icon:61720,angle:.5*Math.PI},linetoolemoji:{size:40,emoji:"😀",angle:.5*Math.PI},linetoolsticker:{size:110,sticker:"bitcoin",angle:.5*Math.PI},linetoolimage:{transparency:0,cssWidth:0,cssHeight:0,angle:0},linetoolbezierquadro:{linecolor:k,linewidth:1,fillBackground:!1,backgroundColor:R,transparency:50,linestyle:P,extendLeft:!1,extendRight:!1,leftEnd:f.Normal,rightEnd:f.Normal},linetoolbeziercubic:{linecolor:W,linewidth:1,fillBackground:!1,backgroundColor:H,transparency:80,linestyle:P,extendLeft:!1,extendRight:!1,leftEnd:f.Normal,rightEnd:f.Normal},linetooltrendline:{linecolor:k,linewidth:2,linestyle:P,extendLeft:!1,extendRight:!1,leftEnd:f.Normal,rightEnd:f.Normal,showLabel:!1,horzLabelsAlign:"center",vertLabelsAlign:"bottom",textcolor:k,fontsize:14,bold:!1,italic:!1,alwaysShowStats:!1,showMiddlePoint:!1,showPriceLabels:!1,showPriceRange:!1,showPercentPriceRange:!1,showPipsPriceRange:!1,showBarsRange:!1,showDateTimeRange:!1,showDistance:!1,showAngle:!1,statsPosition:y.Right},linetoolinfoline:{linecolor:k,linewidth:2,linestyle:P,extendLeft:!1,extendRight:!1,leftEnd:f.Normal,rightEnd:f.Normal,showLabel:!1,horzLabelsAlign:"center",vertLabelsAlign:"bottom",textcolor:k,fontsize:14,bold:!1,italic:!1,alwaysShowStats:!0,showMiddlePoint:!1,showPriceLabels:!1,showPriceRange:!0,showPercentPriceRange:!0,showPipsPriceRange:!0,showBarsRange:!0,showDateTimeRange:!0,showDistance:!0,showAngle:!0,statsPosition:y.Center},linetooltimecycles:{linecolor:"#159980",linewidth:1,fillBackground:!0,backgroundColor:"rgba(106, 168, 79, 0.5)",transparency:50,linestyle:P},linetoolsineline:{linecolor:"#159980",linewidth:1,linestyle:P},linetooltrendangle:{linecolor:k,linewidth:2,linestyle:P,textcolor:k,fontsize:12,bold:!1,italic:!1,alwaysShowStats:!1,showMiddlePoint:!1,showPriceLabels:!1,showPriceRange:!1,showPercentPriceRange:!1,showPipsPriceRange:!1,showBarsRange:!1,extendRight:!1,extendLeft:!1,statsPosition:y.Right},linetooldisjointangle:{linecolor:ce,linewidth:2,linestyle:P,fillBackground:!0,backgroundColor:he,transparency:20,extendLeft:!1,extendRight:!1,leftEnd:f.Normal,rightEnd:f.Normal,textcolor:ce,fontsize:12,bold:!1,italic:!1,showPrices:!1,showPriceRange:!1,showDateTimeRange:!1,showBarsRange:!1},linetoolflatbottom:{linecolor:fe,linewidth:2,linestyle:P,fillBackground:!0,backgroundColor:ve,transparency:20,extendLeft:!1,extendRight:!1,leftEnd:f.Normal,rightEnd:f.Normal,textcolor:fe,fontsize:12,bold:!1,italic:!1,showPrices:!1,showPriceRange:!1,showDateTimeRange:!1,showBarsRange:!1}, -linetoolfibspiral:{counterclockwise:!1,linecolor:z,linewidth:1,linestyle:P},linetoolriskrewardshort:{linecolor:xe,linewidth:1,textcolor:M,fontsize:12,fillLabelBackground:!0,labelBackgroundColor:"#585858",fillBackground:!0,stopBackground:J,profitBackground:he,stopBackgroundTransparency:80,profitBackgroundTransparency:80,drawBorder:!1,borderColor:"#667b8b",compact:!1,riskDisplayMode:"percents",accountSize:1e3,lotSize:1,risk:25,alwaysShowStats:!1,showPriceLabels:!0},linetoolriskrewardlong:{linecolor:xe,linewidth:1,textcolor:M,fontsize:12,fillLabelBackground:!0,labelBackgroundColor:"#585858",fillBackground:!0,stopBackground:J,profitBackground:he,stopBackgroundTransparency:80,profitBackgroundTransparency:80,drawBorder:!1,borderColor:"#667b8b",compact:!1,riskDisplayMode:"percents",accountSize:1e3,lotSize:1,risk:25,alwaysShowStats:!1,showPriceLabels:!0},linetoolarrow:{linecolor:k,linewidth:2,linestyle:P,extendLeft:!1,extendRight:!1,leftEnd:f.Normal,rightEnd:f.Arrow,showLabel:!1,horzLabelsAlign:"center",vertLabelsAlign:"bottom",textcolor:k,fontsize:14,bold:!1,italic:!1,alwaysShowStats:!1,showMiddlePoint:!1,showPriceLabels:!1,showPriceRange:!1,showPercentPriceRange:!1,showPipsPriceRange:!1,showBarsRange:!1,showDateTimeRange:!1,showDistance:!1,showAngle:!1,statsPosition:y.Right},linetoolray:{linecolor:k,linewidth:2,linestyle:P,extendLeft:!1,extendRight:!0,leftEnd:f.Normal,rightEnd:f.Normal,showLabel:!1,horzLabelsAlign:"center",vertLabelsAlign:"bottom",textcolor:k,fontsize:14,bold:!1,italic:!1,alwaysShowStats:!1,showMiddlePoint:!1,showPriceLabels:!1,showPriceRange:!1,showPercentPriceRange:!1,showPipsPriceRange:!1,showBarsRange:!1,showDateTimeRange:!1,showDistance:!1,showAngle:!1,statsPosition:y.Right},linetoolextended:{linecolor:k,linewidth:2,linestyle:P,extendLeft:!0,extendRight:!0,leftEnd:f.Normal,rightEnd:f.Normal,showLabel:!1,horzLabelsAlign:"center",vertLabelsAlign:"bottom",textcolor:k,fontsize:14,bold:!1,italic:!1,alwaysShowStats:!1,showMiddlePoint:!1,showPriceLabels:!1,showPriceRange:!1,showPercentPriceRange:!1,showPipsPriceRange:!1,showBarsRange:!1,showDateTimeRange:!1,showDistance:!1,showAngle:!1,statsPosition:y.Right},linetoolhorzline:{linecolor:k,linewidth:2,linestyle:P,showPrice:!0,showLabel:!1,textcolor:k,fontsize:12,bold:!1,italic:!1,horzLabelsAlign:"center",vertLabelsAlign:"top"},linetoolhorzray:{linecolor:k,linewidth:2,linestyle:P,showPrice:!0,showLabel:!1,textcolor:k,fontsize:12,bold:!1,italic:!1,horzLabelsAlign:"center",vertLabelsAlign:"top"},linetoolvertline:{linecolor:k,linewidth:2,linestyle:P,extendLine:!0,showTime:!0,showLabel:!1,horzLabelsAlign:"right",vertLabelsAlign:"top",textcolor:k,textOrientation:"vertical",fontsize:14,bold:!1,italic:!1},linetoolcrossline:{linecolor:k,linewidth:2,linestyle:P,showPrice:!0,showTime:!0},linetoolcirclelines:{trendline:{visible:!0,color:"#808080",linewidth:1,linestyle:x},linecolor:"#80ccdb",linewidth:1,linestyle:P},linetoolfibtimezone:{horzLabelsAlign:"right",vertLabelsAlign:"bottom",baselinecolor:"#808080",linecolor:"#0055db",linewidth:1,linestyle:P,showLabels:!0, -fillBackground:!1,transparency:80,trendline:{visible:!0,color:"#808080",linewidth:1,linestyle:x},level1:r(0,xe,!0),level2:r(1,k,!0),level3:r(2,k,!0),level4:r(3,k,!0),level5:r(5,k,!0),level6:r(8,k,!0),level7:r(13,k,!0),level8:r(21,k,!0),level9:r(34,k,!0),level10:r(55,k,!0),level11:r(89,k,!0)},linetooltext:{color:k,fontsize:14,fillBackground:!1,backgroundColor:"rgba(91, 133, 191, 0.3)",backgroundTransparency:70,drawBorder:!1,borderColor:"#667b8b",bold:!1,italic:!1,fixedSize:!0,wordWrap:!1,wordWrapWidth:200},linetooltextabsolute:{color:k,fontsize:14,fillBackground:!1,backgroundColor:"rgba(155, 190, 213, 0.3)",backgroundTransparency:70,drawBorder:!1,borderColor:"#667b8b",bold:!1,italic:!1,fixedSize:!1,wordWrap:!1,wordWrapWidth:200},linetoolballoon:{color:M,backgroundColor:ne,borderColor:se,fontsize:14,transparency:30},linetoolcomment:{color:M,backgroundColor:k,borderColor:k,fontsize:16,transparency:0},linetoolbrush:{linecolor:z,linewidth:1,linestyle:P,smooth:5,fillBackground:!1,backgroundColor:z,transparency:50,leftEnd:f.Normal,rightEnd:f.Normal},linetoolhighlighter:{linecolor:J,smooth:5,transparency:80},linetoolpolyline:{linecolor:z,linewidth:1,linestyle:P,fillBackground:!0,backgroundColor:U,transparency:80,filled:!1},linetoolsignpost:{itemType:m.Emoji,emoji:"🙂",showImage:!1,plateColor:k,fontSize:12,bold:!1,italic:!1},linetoolpath:{lineColor:k,lineWidth:2,lineStyle:P,leftEnd:f.Normal,rightEnd:f.Arrow},linetoolarrowmarkleft:{color:k,arrowColor:k,fontsize:14,bold:!1,italic:!1,showLabel:!0},linetoolarrowmarkup:{color:ce,arrowColor:ce,fontsize:14,bold:!1,italic:!1,showLabel:!0},linetoolarrowmarkright:{color:k,arrowColor:k,fontsize:14,bold:!1,italic:!1,showLabel:!0},linetoolarrowmarkdown:{color:te,arrowColor:te,fontsize:14,bold:!1,italic:!1,showLabel:!0},linetoolflagmark:{flagColor:k},linetoolnote:{markerColor:k,textColor:M,backgroundColor:D,backgroundTransparency:0,borderColor:k,fontSize:14,bold:!1,italic:!1,fixedSize:!0},linetoolnoteabsolute:{markerColor:k,textColor:M,backgroundColor:D,backgroundTransparency:0,borderColor:k,fontSize:14,bold:!1,italic:!1,fixedSize:!0},linetoolpricelabel:{color:M,backgroundColor:k,borderColor:k,fontWeight:"bold",fontsize:14,transparency:0},linetoolarrowmarker:{backgroundColor:N,textColor:N,bold:!0,italic:!1,fontsize:16,showLabel:!0},linetoolrectangle:{color:ie,fillBackground:!0,backgroundColor:re,linewidth:1,transparency:50,showLabel:!1,horzLabelsAlign:"left",vertLabelsAlign:"bottom",textColor:ie,fontSize:14,bold:!1,italic:!1,extendLeft:!1,extendRight:!1},linetoolrotatedrectangle:{color:_e,fillBackground:!0,backgroundColor:me,transparency:50,linewidth:1},linetoolcircle:{color:fe,backgroundColor:ve,fillBackground:!0,linewidth:1,showLabel:!1,textColor:fe,fontSize:14,bold:!1,italic:!1},linetoolellipse:{color:Z,fillBackground:!0,backgroundColor:J,transparency:50,linewidth:1,showLabel:!1,textColor:Z,fontSize:14,bold:!1,italic:!1},linetoolarc:{color:oe,fillBackground:!0,backgroundColor:ae,transparency:80,linewidth:1},linetoolprediction:{linecolor:k,linewidth:1,sourceBackColor:k,sourceTextColor:M, -sourceStrokeColor:k,targetStrokeColor:k,targetBackColor:k,targetTextColor:M,successBackground:_e,successTextColor:M,failureBackground:Z,failureTextColor:M,intermediateBackColor:"#ead289",intermediateTextColor:"#6d4d22",transparency:10,centersColor:"#202020"},linetooltriangle:{color:ce,fillBackground:!0,backgroundColor:he,transparency:80,linewidth:1},linetoolcallout:{color:M,backgroundColor:G,transparency:50,linewidth:1,fontsize:14,bordercolor:j,bold:!1,italic:!1,wordWrap:!1,wordWrapWidth:200},linetoolparallelchannel:{linecolor:k,linewidth:2,linestyle:P,extendLeft:!1,extendRight:!1,fillBackground:!0,backgroundColor:R,transparency:20,showMidline:!0,midlinecolor:k,midlinewidth:1,midlinestyle:x},linetoolelliottimpulse:{degree:7,showWave:!0,color:"#3d85c6",linewidth:1},linetoolelliotttriangle:{degree:7,showWave:!0,color:fe,linewidth:1},linetoolelliotttriplecombo:{degree:7,showWave:!0,color:"#6aa84f",linewidth:1},linetoolelliottcorrection:{degree:7,showWave:!0,color:"#3d85c6",linewidth:1},linetoolelliottdoublecombo:{degree:7,showWave:!0,color:"#6aa84f",linewidth:1},linetoolbarspattern:{color:k,mode:c.Bars,mirrored:!1,flipped:!1},linetoolghostfeed:{averageHL:20,variance:50,candleStyle:{upColor:le,downColor:$,drawWick:!0,drawBorder:!0,borderColor:"#378658",borderUpColor:ce,borderDownColor:Z,wickColor:xe},transparency:50},study:{inputs:{},styles:{},bands:{},graphics:{},ohlcPlots:{},palettes:{},filledAreasStyle:{},filledAreas:{},visible:!0,showLegendValues:!0,showLabelsOnPriceScale:!0,precision:"default"},linetoolpitchfork:{fillBackground:!0,transparency:80,style:l.Original,median:{visible:!0,color:Z,linewidth:1,linestyle:P},extendLines:!1,level0:r(.25,ge,!1),level1:r(.382,pe,!1),level2:r(.5,ce,!0),level3:r(.618,ce,!1),level4:r(.75,z,!1),level5:r(1,k,!0),level6:r(1.5,ie,!1),level7:r(1.75,oe,!1),level8:r(2,Y,!1)},linetoolpitchfan:{fillBackground:!0,transparency:80,median:{visible:!0,color:Z,linewidth:1,linestyle:P},level0:r(.25,ge,!1),level1:r(.382,pe,!1),level2:r(.5,z,!0),level3:r(.618,ce,!1),level4:r(.75,z,!1),level5:r(1,k,!0),level6:r(1.5,ie,!1),level7:r(1.75,oe,!1),level8:r(2,Y,!1)},linetoolgannfan:{showLabels:!0,fillBackground:!0,transparency:80,level1:Te(1,8,fe,!0),level2:Te(1,4,ce,!0),level3:Te(1,3,_e,!0),level4:Te(1,2,ce,!0),level5:Te(1,1,z,!0),level6:Te(2,1,k,!0),level7:Te(3,1,ie,!0),level8:Te(4,1,oe,!0),level9:Te(8,1,Z,!0)},linetoolganncomplex:{fillBackground:!1,arcsBackground:{fillBackground:!0,transparency:80},reverse:!1,scaleRatio:"",showLabels:!0,labelsStyle:{fontSize:12,bold:!1,italic:!1},levels:[h(xe,!0,1),h(fe,!0,1),h(z,!0,1),h(_e,!0,1),h(ce,!0,1),h(xe,!0,1)],fanlines:[T(O,!1,1,8,1),T(Z,!1,1,5,1),T(xe,!1,1,4,1),T(fe,!1,1,3,1),T(z,!0,1,2,1),T(_e,!0,1,1,1),T(ce,!0,1,1,2),T(ce,!1,1,1,3),T(k,!1,1,1,4),T(F,!1,1,1,5),T(O,!1,1,1,8)],arcs:[T(fe,!0,1,1,0),T(fe,!0,1,1,1),T(fe,!0,1,1.5,0),T(z,!0,1,2,0),T(z,!0,1,2,1),T(_e,!0,1,3,0),T(_e,!0,1,3,1),T(ce,!0,1,4,0),T(ce,!0,1,4,1),T(k,!0,1,5,0),T(k,!0,1,5,1)]},linetoolgannfixed:{fillBackground:!1,arcsBackground:{fillBackground:!0,transparency:80},reverse:!1, -levels:[h(xe,!0,1),h(fe,!0,1),h(z,!0,1),h(_e,!0,1),h(ce,!0,1),h(xe,!0,1)],fanlines:[T(O,!1,1,8,1),T(Z,!1,1,5,1),T(xe,!1,1,4,1),T(fe,!1,1,3,1),T(z,!0,1,2,1),T(_e,!0,1,1,1),T(ce,!0,1,1,2),T(ce,!1,1,1,3),T(k,!1,1,1,4),T(F,!1,1,1,5),T(O,!1,1,1,8)],arcs:[T(fe,!0,1,1,0),T(fe,!0,1,1,1),T(fe,!0,1,1.5,0),T(z,!0,1,2,0),T(z,!0,1,2,1),T(_e,!0,1,3,0),T(_e,!0,1,3,1),T(ce,!0,1,4,0),T(ce,!0,1,4,1),T(k,!0,1,5,0),T(k,!0,1,5,1)]},linetoolgannsquare:{color:"rgba(21, 56, 153, 0.8)",linewidth:1,linestyle:P,showTopLabels:!0,showBottomLabels:!0,showLeftLabels:!0,showRightLabels:!0,fillHorzBackground:!0,horzTransparency:80,fillVertBackground:!0,vertTransparency:80,reverse:!1,fans:t(Pe,!1),hlevel1:i(0,xe,!0),hlevel2:i(.25,fe,!0),hlevel3:i(.382,z,!0),hlevel4:i(.5,_e,!0),hlevel5:i(.618,ce,!0),hlevel6:i(.75,k,!0),hlevel7:i(1,xe,!0),vlevel1:i(0,xe,!0),vlevel2:i(.25,fe,!0),vlevel3:i(.382,z,!0),vlevel4:i(.5,_e,!0),vlevel5:i(.618,ce,!0),vlevel6:i(.75,k,!0),vlevel7:i(1,xe,!0)},linetoolfibspeedresistancefan:{fillBackground:!0,transparency:80,grid:{color:"rgba(21, 56, 153, 0.8)",linewidth:1,linestyle:P,visible:!0},linewidth:1,linestyle:P,showTopLabels:!0,showBottomLabels:!0,showLeftLabels:!0,showRightLabels:!0,reverse:!1,hlevel1:i(0,xe,!0),hlevel2:i(.25,fe,!0),hlevel3:i(.382,z,!0),hlevel4:i(.5,_e,!0),hlevel5:i(.618,ce,!0),hlevel6:i(.75,k,!0),hlevel7:i(1,xe,!0),vlevel1:i(0,xe,!0),vlevel2:i(.25,fe,!0),vlevel3:i(.382,z,!0),vlevel4:i(.5,_e,!0),vlevel5:i(.618,ce,!0),vlevel6:i(.75,k,!0),vlevel7:i(1,xe,!0)},linetoolfibretracement:{showCoeffs:!0,showPrices:!0,fillBackground:!0,transparency:80,extendLines:!1,extendLinesLeft:!1,horzLabelsAlign:"left",vertLabelsAlign:"bottom",reverse:!1,coeffsAsPercents:!1,fibLevelsBasedOnLogScale:!1,labelFontSize:12,trendline:{visible:!0,color:xe,linewidth:1,linestyle:x},levelsStyle:{linewidth:1,linestyle:P},level1:i(0,xe,!0),level2:i(.236,Z,!0),level3:i(.382,fe,!0),level4:i(.5,_e,!0),level5:i(.618,ce,!0),level6:i(.786,z,!0),level7:i(1,xe,!0),level8:i(1.618,k,!0),level9:i(2.618,Z,!0),level10:i(3.618,ie,!0),level11:i(4.236,oe,!0),level12:i(1.272,fe,!1),level13:i(1.414,Z,!1),level16:i(2,ce,!1),level14:i(2.272,fe,!1),level15:i(2.414,_e,!1),level17:i(3,z,!1),level18:i(3.272,xe,!1),level19:i(3.414,k,!1),level20:i(4,Z,!1),level21:i(4.272,ie,!1),level22:i(4.414,oe,!1),level23:i(4.618,fe,!1),level24:i(4.764,ce,!1)},linetoolfibchannel:{showCoeffs:!0,showPrices:!0,fillBackground:!0,transparency:80,extendLeft:!1,extendRight:!1,horzLabelsAlign:"left",vertLabelsAlign:"middle",coeffsAsPercents:!1,labelFontSize:12,levelsStyle:{linewidth:1,linestyle:P},level1:i(0,xe,!0),level2:i(.236,Z,!0),level3:i(.382,fe,!0),level4:i(.5,_e,!0),level5:i(.618,ce,!0),level6:i(.786,z,!0),level7:i(1,xe,!0),level8:i(1.618,k,!0),level9:i(2.618,Z,!0),level10:i(3.618,ie,!0),level11:i(4.236,oe,!0),level12:i(1.272,fe,!1),level13:i(1.414,Z,!1),level16:i(2,ce,!1),level14:i(2.272,fe,!1),level15:i(2.414,_e,!1),level17:i(3,z,!1),level18:i(3.272,xe,!1),level19:i(3.414,k,!1),level20:i(4,Z,!1),level21:i(4.272,ie,!1),level22:i(4.414,oe,!1),level23:i(4.618,fe,!1), -level24:i(4.764,ce,!1)},linetoolprojection:{showCoeffs:!0,fillBackground:!0,transparency:80,color1:R,color2:re,linewidth:1,trendline:{visible:!0,color:Pe,linestyle:P},level1:r(1,"#808080",!0)},linetool5pointspattern:{color:k,textcolor:M,fillBackground:!0,backgroundColor:k,fontsize:12,bold:!1,italic:!1,transparency:85,linewidth:1},linetoolcypherpattern:{color:k,textcolor:M,fillBackground:!0,backgroundColor:k,fontsize:12,bold:!1,italic:!1,transparency:85,linewidth:1},linetooltrianglepattern:{color:W,textcolor:M,fillBackground:!0,backgroundColor:W,fontsize:12,bold:!1,italic:!1,transparency:85,linewidth:1},linetoolabcd:{color:ce,textcolor:M,fontsize:12,bold:!1,italic:!1,linewidth:1},linetoolthreedrivers:{color:W,textcolor:M,fillBackground:!0,backgroundColor:"rgba(149, 40, 204, 0.5)",fontsize:12,bold:!1,italic:!1,transparency:50,linewidth:1},linetoolheadandshoulders:{color:ce,textcolor:M,fillBackground:!0,backgroundColor:ce,fontsize:12,bold:!1,italic:!1,transparency:85,linewidth:1},linetoolfibwedge:{showCoeffs:!0,fillBackground:!0,transparency:80,trendline:{visible:!0,color:"#808080",linewidth:1,linestyle:P},level1:r(.236,Z,!0),level2:r(.382,fe,!0),level3:r(.5,_e,!0),level4:r(.618,ce,!0),level5:r(.786,z,!0),level6:r(1,xe,!0),level7:r(1.618,k,!1),level8:r(2.618,Z,!1),level9:r(3.618,W,!1),level10:r(4.236,oe,!1),level11:r(4.618,oe,!1)},linetoolfibcircles:{showCoeffs:!0,fillBackground:!0,transparency:80,coeffsAsPercents:!1,trendline:{visible:!0,color:xe,linewidth:1,linestyle:x},level1:r(.236,Z,!0),level2:r(.382,fe,!0),level3:r(.5,ce,!0),level4:r(.618,_e,!0),level5:r(.786,z,!0),level6:r(1,xe,!0),level7:r(1.618,k,!0),level8:r(2.618,oe,!0),level9:r(3.618,k,!0),level10:r(4.236,oe,!0),level11:r(4.618,Z,!0)},linetoolfibspeedresistancearcs:{showCoeffs:!0,fillBackground:!0,transparency:80,fullCircles:!1,trendline:{visible:!0,color:xe,linewidth:1,linestyle:x},level1:r(.236,Z,!0),level2:r(.382,fe,!0),level3:r(.5,ce,!0),level4:r(.618,_e,!0),level5:r(.786,z,!0),level6:r(1,xe,!0),level7:r(1.618,k,!0),level8:r(2.618,oe,!0),level9:r(3.618,k,!0),level10:r(4.236,oe,!0),level11:r(4.618,Z,!0)},linetooltrendbasedfibextension:{showCoeffs:!0,showPrices:!0,fillBackground:!0,transparency:80,extendLines:!1,extendLinesLeft:!1,horzLabelsAlign:"left",vertLabelsAlign:"bottom",reverse:!1,coeffsAsPercents:!1,fibLevelsBasedOnLogScale:!1,labelFontSize:12,trendline:{visible:!0,color:xe,linewidth:1,linestyle:x},levelsStyle:{linewidth:1,linestyle:P},level1:i(0,xe,!0),level2:i(.236,Z,!0),level3:i(.382,fe,!0),level4:i(.5,_e,!0),level5:i(.618,ce,!0),level6:i(.786,z,!0),level7:i(1,xe,!0),level8:i(1.618,k,!0),level9:i(2.618,Z,!0),level10:i(3.618,ie,!0),level11:i(4.236,oe,!0),level12:i(1.272,fe,!1),level13:i(1.414,Z,!1),level16:i(2,ce,!1),level14:i(2.272,fe,!1),level15:i(2.414,_e,!1),level17:i(3,z,!1),level18:i(3.272,xe,!1),level19:i(3.414,k,!1),level20:i(4,Z,!1),level21:i(4.272,ie,!1),level22:i(4.414,oe,!1),level23:i(4.618,fe,!1),level24:i(4.764,ce,!1)},linetooltrendbasedfibtime:{showCoeffs:!0,fillBackground:!0,transparency:80,horzLabelsAlign:"right", -vertLabelsAlign:"bottom",trendline:{visible:!0,color:xe,linewidth:1,linestyle:x},level1:r(0,xe,!0),level2:r(.382,Z,!0),level3:r(.5,pe,!1),level4:r(.618,_e,!0),level5:r(1,ce,!0),level6:r(1.382,z,!0),level7:r(1.618,xe,!0),level8:r(2,k,!0),level9:r(2.382,oe,!0),level10:r(2.618,ie,!0),level11:r(3,W,!0)},linetoolschiffpitchfork:{fillBackground:!0,transparency:80,style:l.Schiff,median:{visible:!0,color:Z,linewidth:1,linestyle:P},extendLines:!1,level0:r(.25,ge,!1),level1:r(.382,pe,!1),level2:r(.5,ce,!0),level3:r(.618,ce,!1),level4:r(.75,z,!1),level5:r(1,k,!0),level6:r(1.5,ie,!1),level7:r(1.75,oe,!1),level8:r(2,Y,!1)},linetoolschiffpitchfork2:{fillBackground:!0,transparency:80,style:l.Schiff2,median:{visible:!0,color:Z,linewidth:1,linestyle:P},extendLines:!1,level0:r(.25,ge,!1),level1:r(.382,pe,!1),level2:r(.5,ce,!0),level3:r(.618,ce,!1),level4:r(.75,z,!1),level5:r(1,k,!0),level6:r(1.5,ie,!1),level7:r(1.75,oe,!1),level8:r(2,Y,!1)},linetoolinsidepitchfork:{fillBackground:!0,transparency:80,style:l.Inside,median:{visible:!0,color:Z,linewidth:1,linestyle:P},extendLines:!1,level0:r(.25,ge,!1),level1:r(.382,pe,!1),level2:r(.5,ce,!0),level3:r(.618,ce,!1),level4:r(.75,z,!1),level5:r(1,k,!0),level6:r(1.5,ie,!1),level7:r(1.75,oe,!1),level8:r(2,Y,!1)},linetoolregressiontrend:{linewidth:1,linestyle:P,styles:{upLine:{display:u.All,color:V,linestyle:P,linewidth:2},downLine:{display:u.All,color:V,linestyle:P,linewidth:2},baseLine:{display:u.All,color:X,linestyle:x,linewidth:1},extendLines:!1,showPearsons:!0,transparency:70}}},Oe(TradingView.defaultProperties.chartproperties),We()}if(void 0===TradingView.defaultProperties["study_MA@tv-basicstudies"]&&(TradingView.defaultProperties["study_MA@tv-basicstudies"]={description:"Moving Average",shortDescription:"MA",inputs:{length:9,source:"close"},styles:{MovAvg:{display:u.All,color:k,linestyle:P,linewidth:1,plottype:d.Line,histogramBase:0,title:"MA"}}}),void 0===TradingView.defaultProperties["study_PivotPointsHighLow@tv-basicstudies"]&&(TradingView.defaultProperties["study_PivotPointsHighLow@tv-basicstudies"]={fontsize:10,borderColor:k,backColor:A,textColor:Le}),void 0===TradingView.defaultProperties["study_PivotPointsStandard@tv-basicstudies"]){var Ne=!0;TradingView.defaultProperties["study_PivotPointsStandard@tv-basicstudies"]={_hardCodedDefaultsVersion:1,fontsize:11,levelsStyle:{showLabels:!0,visibility:{P:Ne,"S1/R1":Ne,"S2/R2":Ne,"S3/R3":Ne,"S4/R4":Ne,"S5/R5":Ne},colors:{P:Se,"S1/R1":Se,"S2/R2":Se,"S3/R3":Se,"S4/R4":Se,"S5/R5":Se},widths:{P:1,"S1/R1":1,"S2/R2":1,"S3/R3":1,"S4/R4":1,"S5/R5":1}}}}if(void 0===TradingView.defaultProperties["study_ZigZag@tv-basicstudies"]&&(TradingView.defaultProperties["study_ZigZag@tv-basicstudies"]={color:k,linewidth:2}),void 0===TradingView.defaultProperties["study_ElliottWave@tv-basicstudies"]&&(TradingView.defaultProperties["study_ElliottWave@tv-basicstudies"]={inputs:{},level0:t(q,!1),level1:t("#008000",!1),level2:t("#0000ff",!1),level3:t("#ff00ff",!1),level4:t("#0080ff",!0),level5:t(q,!0),level6:t("#008000",!0),level7:t("#0000ff",!0), -level8:t("#ff00ff",!0)}),void 0===TradingView.defaultProperties["study_LinearRegression@tv-basicstudies"]&&(TradingView.defaultProperties["study_LinearRegression@tv-basicstudies"]={styles:{upLine:{display:u.All,color:V,linestyle:P,linewidth:1},downLine:{display:u.All,color:V,linestyle:P,linewidth:1},baseLine:{display:u.All,color:X,linestyle:P,linewidth:1},extendLines:!0,showPearsons:!0,backgroundColor:"rgba(153, 21, 21, 0.3)",transparency:70}}),void 0===TradingView.defaultProperties["study_Compare@tv-basicstudies"]&&(TradingView.defaultProperties["study_Compare@tv-basicstudies"]={minTick:"default"}),void 0===TradingView.defaultProperties["study_Overlay@tv-basicstudies"]){TradingView.defaultProperties["study_Overlay@tv-basicstudies"]={style:a.STYLE_LINE,allowExtendTimeScale:!1,showPriceLine:!1,minTick:"default",candleStyle:{upColor:"#6ba583",downColor:"#d75442",drawWick:!0,drawBorder:!0,drawBody:!0,borderColor:"#378658",borderUpColor:"#225437",borderDownColor:"#5b1a13",wickColor:"#737375",wickUpColor:"#737375",wickDownColor:"#737375",barColorsOnPrevClose:!1},hollowCandleStyle:{upColor:"#6ba583",downColor:"#d75442",drawWick:!0,drawBorder:!0,drawBody:!0,borderColor:"#378658",borderUpColor:"#225437",borderDownColor:"#5b1a13",wickColor:"#737375",wickUpColor:"#737375",wickDownColor:"#737375",barColorsOnPrevClose:!1},barStyle:{upColor:"#6ba583",downColor:"#d75442",barColorsOnPrevClose:!1,dontDrawOpen:!1,thinBars:!0},lineStyle:{color:ye,linestyle:P,linewidth:2,priceSource:"close"},lineWithMarkersStyle:{color:ye,linestyle:P,linewidth:2,priceSource:"close"},steplineStyle:{color:ye,linestyle:P,linewidth:2,priceSource:"close"},areaStyle:{color1:k,color2:k,linecolor:k,linestyle:P,linewidth:2,priceSource:"close",transparency:95},baselineStyle:{baselineColor:ke,topFillColor1:Ve,topFillColor2:Ve,bottomFillColor1:Be,bottomFillColor2:Be,topLineColor:De,bottomLineColor:Ee,topLineWidth:2,bottomLineWidth:2,priceSource:"close",transparency:50,baseLevelPercentage:50},hiloStyle:{color:k,showBorders:!0,borderColor:k,showLabels:!0,labelColor:k,drawBody:!0},columnStyle:{upColor:n(ce,50),downColor:n(Z,50),barColorsOnPrevClose:!0,priceSource:"close"},hlcAreaStyle:{highLineColor:ce,highLineStyle:P,highLineWidth:2,lowLineColor:Z,lowLineStyle:P,lowLineWidth:2,closeLineColor:Ce,closeLineStyle:P,closeLineWidth:2,highCloseFillColor:he,closeLowFillColor:J},styles:{open:{display:u.All,color:q,linestyle:P,linewidth:1,plottype:d.Line,histogramBase:0},high:{display:u.All,color:q,linestyle:P,linewidth:1,plottype:d.Line,histogramBase:0},low:{display:u.All,color:q,linestyle:P,linewidth:1,plottype:d.Line,histogramBase:0},close:{display:u.All,color:q,linestyle:P,linewidth:1,plottype:d.Line,histogramBase:0}}}}for(var Fe=e.split("."),He=TradingView.defaultProperties,ze=0;ze1?h(e[r],t.slice(1),i):(e[r]&&e[r].setValue?e[r].setValue(i):e[r]=i,!0))}function d(e){i||T.logWarn("Path `"+e+"` does not exist.")}}function Oe(e,t,i,s){window.__defaultsOverrides&&Ne(e,t,i,window.__defaultsOverrides,s)}function Fe(e,t){window.__settingsOverrides&&Ne(e,null,!1,window.__settingsOverrides,t)}function We(){var e=/^linetool.+/;Object.keys(TradingView.defaultProperties).forEach((function(t){e.test(t)&&Oe(TradingView.defaultProperties[t],null,!1,t)}))}function He(e,t){return t?function(e,t){var i=Re(e);if(!window._UNIT_TESTS){var s=TradingView.clone(TVSettings.getJSON(e,null));if(function(e){var t=new Set(["linetoolregressiontrend"]);return e.startsWith("study_")||t.has(e)}(e)&&s&&function(e){if(!e)return!1;e=e.toString();var t=new RegExp("\\d+").exec(e);return null!==t&&t[0]===e}(s.version)){var r=s.inputs,n=t.updateStudyInputs(s.id,s.version,"last",r,null);s.inputs=n,s=t.updateStudyState(s,s)}TradingView.merge(i,s),Fe(i,e)}return i}(e,t):function(e){var t=Re(e);if(!window._UNIT_TESTS){var i=TradingView.clone(TVSettings.getJSON(e,null));if(i){TradingView.merge(t,i);const s=e.split(".");Fe(t,void 0===s[1]?e:s[1])}}return t}(e)}He.create=function(e,t){if(t){var i=Re(e);TradingView.defaultProperties[e]=Object.assign(t,i)}},He.remove=function(e){TradingView.defaultProperties[e]=void 0},TradingView.saveDefaults=function(e,t){void 0===t?TVSettings.remove(e):TVSettings.setJSON(e,t)},TradingView.factoryDefaults=Re,window.applyDefaultOverridesToLinetools=We,window.applyDefaultsOverrides=Oe,window.applyPropertiesOverrides=Ne,window.defaults=He,t.applyDefaultOverridesToLinetools=We,t.applyDefaultsOverrides=Oe,t.applyPropertiesOverrides=Ne,t.defaults=He,t.factoryDefaults=Re,t.saveDefaults=TradingView.saveDefaults},88348:(e,t,i)=>{"use strict";i.r(t),i.d(t,{SelectPointMode:()=>s,activePointSelectionMode:()=>$,barTimesUnderCursor:()=>K,beenSetLineToolLastPoint:()=>E,cancelLineTool:()=>ee,cancelledLineTool:()=>V,changeLineStyle:()=>he,changeLineTool:()=>oe,changedLineStyle:()=>U,changedLineTool:()=>F,continueLineTool:()=>Q,continuedLineTool:()=>D,copiedLineTool:()=>j,copyLineTool:()=>de,createLineTool:()=>J,createdLineTool:()=>k,crosshairLock:()=>b,cursorTool:()=>T,drawOnAllCharts:()=>Pe,drawOnAllChartsMode:()=>Ce,emojiTool:()=>C,finishChangingLineTool:()=>ae,finishLineTool:()=>ce,finishMovingLineTool:()=>re,finishedChangingLineTool:()=>W,finishedLineTool:()=>z,finishedMovingLineTool:()=>N,hideAllDrawings:()=>Se,hideAllIndicators:()=>ye,hideMarksOnBars:()=>we,iconTool:()=>P,init:()=>ge,isDirectionalMovementActive:()=>A,isStudyEditingNow:()=>Y,isToolCreatingNow:()=>I,isToolEditingNow:()=>M,isToolMovingNow:()=>L,lockDrawings:()=>be,moveLineTool:()=>se,movedLineTool:()=>R,properties:()=>ve,removeLineTool:()=>le,removedLineTool:()=>H,resetToCursor:()=>m,restoreLineTool:()=>ue,restoreLineToolState:()=>pe,restoredLineTool:()=>G,restoredLineToolState:()=>q,runOnDrawingStateReady:()=>fe,setLineToolLastPoint:()=>te, -startChangingLineTool:()=>ne,startMovingLineTool:()=>ie,startedChangingLineTool:()=>O,startedMovingLineTool:()=>B,stickerTool:()=>x,tool:()=>w,toolIsCursor:()=>p,toolIsMeasure:()=>_});var s,r=i(50151),n=i(59680),o=i(46100),a=i(97145),l=i(83669),c=i(57898),h=i(56840),d=i(76422),u=i(85804);function p(e){return"cursor"===e||"arrow"===e||"dot"===e}function _(e){return"measure"===e}function m(e=!1){if(!e&&g){if(g.childs().stayInDrawingMode.value())return}w.setValue(T.value())}!function(e){e[e.None=0]="None",e[e.Replay=1]="Replay",e[e.Study=2]="Study"}(s||(s={}));let g=null,f=null,v=null,S=null,y=null;const b=new l.WatchedObject(null),w=new a.WatchedValue,P=new a.WatchedValue,C=new a.WatchedValue,x=new a.WatchedValue,T=new a.WatchedValue,I=new a.WatchedValue(!1),M=new a.WatchedValue(!1),L=new a.WatchedValue(!1),A=new a.WatchedValue(!1),k=new c.Delegate,D=new c.Delegate,V=new c.Delegate,E=new c.Delegate,B=new c.Delegate,R=new c.Delegate,N=new c.Delegate,O=new c.Delegate,F=new c.Delegate,W=new c.Delegate,H=new c.Delegate,z=new c.Delegate,U=new c.Delegate,j=new c.Delegate,G=new c.Delegate,q=new c.Delegate,$=new a.WatchedValue(s.None),Y=new a.WatchedValue(!1),K=new Map;function Z(e,t){const i=t||{value:!1};return t=>{i.value||(i.value=!0,e.fire(t),i.value=!1)}}const X={value:!1},J=Z(k,X),Q=Z(D,X),ee=Z(V,X),te=Z(E,X),ie=Z(B),se=Z(R),re=Z(N),ne=Z(O),oe=Z(F),ae=Z(W),le=Z(H),ce=Z(z),he=Z(U,X),de=Z(j,X),ue=Z(G),pe=Z(q);let _e=!1,me=[];function ge(){_e||(w.setValue(h.getValue("chart.cursorPreference","cursor")),w.subscribe((e=>p(e)&&T.setValue(e)),{callWithLast:!0}),T.subscribe((e=>{e&&h.setValue("chart.cursorPreference",e)})),g=new o.DefaultProperty("drawings"),f=(0,n.createPrimitiveProperty)(),v=(0,n.createPrimitiveProperty)(),S=(0,n.createPrimitiveProperty)(),y=(0,n.createPrimitiveProperty)(),f.setValue(!1),v.setValue(!1),S.setValue(!1),y.setValue(!1),w.subscribe((()=>{(0,d.emit)("onSelectedLineToolChanged")})),P.subscribe((()=>{(0,u.saveDefaults)("linetoolicon",{...(0,u.defaults)("linetoolicon"),icon:P.value()})})),C.subscribe((()=>{(0,u.saveDefaults)("linetoolemoji",{...(0,u.defaults)("linetoolemoji"),emoji:C.value()})})),x.subscribe((()=>{(0,u.saveDefaults)("linetoolsticker",{...(0,u.defaults)("linetoolsticker"),sticker:x.value()})})),_e=!0,me.forEach((e=>e())),me=[])}function fe(e){_e?e():me.push(e)}function ve(){return(0,r.ensureNotNull)(g)}function Se(){return(0,r.ensureNotNull)(f)}function ye(){return(0,r.ensureNotNull)(v)}function be(){return(0,r.ensureNotNull)(S)}function we(){return(0,r.ensureNotNull)(y)}function Pe(){return ve().childs().drawOnAllCharts}function Ce(){return ve().childs().drawOnAllChartsMode}},81155:(e,t,i)=>{"use strict";i.d(t,{EnvironmentState:()=>r});var s=i(49483);class r{constructor(e,t=!1){this._shift=!1,this._mod=!1,this._alt=!1,void 0!==e&&(this._shift=Boolean(e.shiftKey),this._mod=Boolean((0,s.isMac)()?e.metaKey:e.ctrlKey),this._alt=Boolean(e.altKey)),this._isApiEvent=t}shift(){return this._shift}mod(){return this._mod}alt(){return this._alt}shiftOnly(){ -return this._shift&&!this._mod&&!this._alt}modOnly(){return this._mod&&!this._shift&&!this._alt}altOnly(){return this._alt&&!this._shift&&!this._mod}modShift(){return this._shift&&this._mod&&!this._alt}isApiEvent(){return this._isApiEvent}static create(e=!1,t=!1,i=!1){return new r({shiftKey:e,ctrlKey:t,metaKey:t,altKey:i})}}},27856:(e,t,i)=>{"use strict";function s(e){return"="+JSON.stringify(r(e))}function r(e){return Object.keys(e).sort().reduce(((t,i)=>("[object Object]"===Object.prototype.toString.call(e[i])?t[i]=r(e[i]):t[i]=e[i],t)),{})}function n(e){return Boolean(e.inputs)}function o(e){return s(e)}function a(e){return"="===e[0]}function l(e){if(!a(e))return{symbol:e};try{return JSON.parse(e.slice(1))}catch(t){return{symbol:e}}}function c(e){return"string"==typeof e?e:c(e.symbol)}i.r(t),i.d(t,{decodeExtendedSymbol:()=>l,encodeExtendedSymbolOrGetSimpleSymbolString:()=>o,isEncodedExtendedSymbol:()=>a,isStudySymbol:()=>n,unwrapSimpleSymbol:()=>c})},1763:(e,t,i)=>{"use strict";i.d(t,{customFormatters:()=>s});const s={dateFormatter:null,timeFormatter:null,tickMarkFormatter:null,priceFormatterFactory:null,studyFormatterFactory:null}},15879:(e,t,i)=>{"use strict";i.d(t,{availableDateFormats:()=>f,dateFormatFunctions:()=>m,defaultDateFormat:()=>v,getDateFormatWithWeekday:()=>g});var s=i(44352),r=i(28865),n=i(61146);const o={1:()=>s.t(null,void 0,i(95425)),2:()=>s.t(null,void 0,i(35050)),3:()=>s.t(null,void 0,i(51369)),4:()=>s.t(null,void 0,i(42762)),5:()=>s.t(null,{context:"short"},i(27991)),6:()=>s.t(null,void 0,i(15224)),7:()=>s.t(null,void 0,i(6215)),8:()=>s.t(null,void 0,i(38465)),9:()=>s.t(null,void 0,i(57902)),10:()=>s.t(null,void 0,i(73546)),11:()=>s.t(null,void 0,i(71230)),12:()=>s.t(null,void 0,i(92203))},a=(e,t)=>(t?e.getMonth():e.getUTCMonth())+1,l=(e,t)=>t?e.getFullYear():e.getUTCFullYear(),c=e=>e.toLocaleDateString(window.language?(0,r.getIsoLanguageCodeFromLanguage)(window.language):void 0,{weekday:"short",timeZone:"UTC"}),h=(e,t)=>(0,n.numberToStringWithLeadingZero)(((e,t)=>t?e.getDate():e.getUTCDate())(e,t),2),d=(e,t)=>o[a(e,t)](),u=(e,t)=>(0,n.numberToStringWithLeadingZero)(a(e,t),2),p=(e,t)=>(0,n.numberToStringWithLeadingZero)(l(e,t)%100,2),_=(e,t)=>(0,n.numberToStringWithLeadingZero)(l(e,t),4),m={"dd MMM 'yy":(e,t)=>`${h(e,t)} ${d(e,t)} '${p(e,t)}`,"MMM dd, yyyy":(e,t)=>`${d(e,t)} ${h(e,t)}, ${_(e,t)}`,"MMM yyyy":(e,t)=>`${d(e,t)} ${_(e,t)}`,"MMM dd":(e,t)=>`${d(e,t)} ${h(e,t)}`,"dd MMM":(e,t)=>`${h(e,t)} ${d(e,t)}`,"yyyy-MM-dd":(e,t)=>`${_(e,t)}-${u(e,t)}-${h(e,t)}`,"yy-MM-dd":(e,t)=>`${p(e,t)}-${u(e,t)}-${h(e,t)}`,"yy/MM/dd":(e,t)=>`${p(e,t)}/${u(e,t)}/${h(e,t)}`,"yyyy/MM/dd":(e,t)=>`${_(e,t)}/${u(e,t)}/${h(e,t)}`,"dd-MM-yyyy":(e,t)=>`${h(e,t)}-${u(e,t)}-${_(e,t)}`,"dd-MM-yy":(e,t)=>`${h(e,t)}-${u(e,t)}-${p(e,t)}`,"dd/MM/yy":(e,t)=>`${h(e,t)}/${u(e,t)}/${p(e,t)}`,"dd/MM/yyyy":(e,t)=>`${h(e,t)}/${u(e,t)}/${_(e,t)}`,"MM/dd/yy":(e,t)=>`${u(e,t)}/${h(e,t)}/${p(e,t)}`,"MM/dd/yyyy":(e,t)=>`${u(e,t)}/${h(e,t)}/${_(e,t)}`};function g(e){ +color:k,linestyle:P,linewidth:2,priceSource:"close"},steplineStyle:{color:k,linestyle:P,linewidth:2,priceSource:"close"},areaStyle:{color1:V,color2:k,linecolor:k,linestyle:P,linewidth:2,priceSource:"close",transparency:100},hlcAreaStyle:{highLineColor:ce,highLineStyle:P,highLineWidth:2,lowLineColor:Z,lowLineStyle:P,lowLineWidth:2,closeLineColor:Ce,closeLineStyle:P,closeLineWidth:2,highCloseFillColor:he,closeLowFillColor:J},priceAxisProperties:{autoScale:!0,autoScaleDisabled:!1,lockScale:!1,percentage:!1,percentageDisabled:!1,indexedTo100:!1,log:!1,logDisabled:!1,isInverted:!1,alignLabels:!0},renkoStyle:{upColor:ce,downColor:Z,borderUpColor:ce,borderDownColor:Z,upColorProjection:"#a9dcc3",downColorProjection:"#f5a6ae",borderUpColorProjection:"#a9dcc3",borderDownColorProjection:"#f5a6ae",wickUpColor:ce,wickDownColor:Z,inputs:{source:"close",sources:"Close",boxSize:3,style:"ATR",atrLength:14,wicks:!0},inputInfo:{source:{name:"Source"},sources:{name:"Source"},boxSize:{name:"Box size"},style:{name:"Style"},atrLength:{name:"ATR length"},wicks:{name:"Wicks"}}},pbStyle:{upColor:ce,downColor:Z,borderUpColor:ce,borderDownColor:Z,upColorProjection:"#a9dcc3",downColorProjection:"#f5a6ae",borderUpColorProjection:"#a9dcc3",borderDownColorProjection:"#f5a6ae",inputs:{source:"close",lb:3},inputInfo:{source:{name:"Source"},lb:{name:"Number of line"}}},kagiStyle:{upColor:ce,downColor:Z,upColorProjection:"#a9dcc3",downColorProjection:"#f5a6ae",inputs:{source:"close",style:"ATR",atrLength:14,reversalAmount:1},inputInfo:{source:{name:"Source"},style:{name:"Style"},atrLength:{name:"ATR length"},reversalAmount:{name:"Reversal amount"}}},pnfStyle:{upColor:ce,downColor:Z,upColorProjection:"#a9dcc3",downColorProjection:"#f5a6ae",inputs:{sources:"Close",reversalAmount:3,boxSize:1,style:"ATR",atrLength:14,oneStepBackBuilding:!1},inputInfo:{sources:{name:"Source"},boxSize:{name:"Box size"},reversalAmount:{name:"Reversal amount"},style:{name:"Style"},atrLength:{name:"ATR length"},oneStepBackBuilding:{name:"One step back building"}}},baselineStyle:{baselineColor:ke,topFillColor1:de,topFillColor2:ue,bottomFillColor1:ee,bottomFillColor2:Q,topLineColor:ce,bottomLineColor:Z,topLineWidth:2,bottomLineWidth:2,priceSource:"close",transparency:50,baseLevelPercentage:50},rangeStyle:{barStyle:S.Bars,upColor:ce,downColor:Z,upColorProjection:"#a9dcc3",downColorProjection:"#f5a6ae",thinBars:!0,candlesUpColor:ce,candlesDownColor:Z,candlesBorderUpColor:ce,candlesBorderDownColor:Z,candlesWickUpColor:ce,candlesWickDownColor:Z,inputs:{range:10,phantomBars:!1},inputInfo:{range:{name:"Range"},phantomBars:{name:"Phantom bars"}}}},chartEventsSourceProperties:{visible:!0,futureOnly:!0,breaks:{color:"#555555",visible:!1,style:x,width:1}},tradingProperties:{showPositions:!0,positionPL:{visibility:!0,display:s.Money},bracketsPL:{visibility:!0,display:s.Money},showOrders:!0,showExecutions:!0,showExecutionsLabels:!1,showReverse:!0,horizontalAlignment:o.Right,extendLeft:!0,lineLength:5,lineWidth:1,lineStyle:P}, +editorFontsList:["Verdana","Courier New","Times New Roman","Arial"],volumePaneSize:"large"},sessions:b,drawings:{magnet:!1,magnetMode:g.WeakMagnet,stayInDrawingMode:!1,drawOnAllCharts:!0,drawOnAllChartsMode:1},linetoolorder:{extendLeft:"inherit",lineLength:"inherit",lineLengthUnit:"percentage",lineColor:q,lineActiveBuyColor:"#4094e8",lineInactiveBuyColor:"rgba(64, 148, 232, 0.5)",lineActiveSellColor:"#e75656",lineInactiveSellColor:"rgba(231, 86, 86, 0.5)",lineStyle:"inherit",lineWidth:"inherit",bodyBorderActiveBuyColor:"#4094e8",bodyBorderInactiveBuyColor:"rgba(64, 148, 232, 0.5)",bodyBorderActiveSellColor:"#e75656",bodyBorderInactiveSellColor:"rgba(231, 86, 86, 0.5)",bodyBackgroundColor:L,bodyBackgroundTransparency:25,bodyTextInactiveLimitColor:"rgba(38, 140, 2, 0.5)",bodyTextActiveLimitColor:"#268c02",bodyTextInactiveStopColor:"rgba(231, 86, 86, 0.5)",bodyTextActiveStopColor:"#e75656",bodyTextInactiveBuyColor:"rgba(64, 148, 232, 0.5)",bodyTextActiveBuyColor:"#4094e8",bodyTextInactiveSellColor:"rgba(231, 86, 86, 0.5)",bodyTextActiveSellColor:"#e75656",bodyFontFamily:"Verdana",bodyFontSize:9,bodyFontBold:!0,bodyFontItalic:!1,quantityBorderActiveBuyColor:"#4094e8",quantityBorderInactiveBuyColor:"rgba(64, 148, 232, 0.5)",quantityBorderActiveSellColor:"#e75656",quantityBorderInactiveSellColor:"rgba(231, 86, 86, 0.5)",quantityBackgroundInactiveBuyColor:"rgba(64, 148, 232, 0.5)",quantityBackgroundActiveBuyColor:"#4094e8",quantityBackgroundInactiveSellColor:"rgba(231, 86, 86, 0.5)",quantityBackgroundActiveSellColor:"#e75656",quantityTextColor:M,quantityTextTransparency:0,quantityFontFamily:"Verdana",quantityFontSize:9,quantityFontBold:!0,quantityFontItalic:!1,cancelButtonBorderActiveBuyColor:"#4094e8",cancelButtonBorderInactiveBuyColor:"rgba(64, 148, 232, 0.5)",cancelButtonBorderActiveSellColor:"#e75656",cancelButtonBorderInactiveSellColor:"rgba(231, 86, 86, 0.5)",cancelButtonBackgroundColor:L,cancelButtonBackgroundTransparency:25,cancelButtonIconActiveBuyColor:"#4094e8",cancelButtonIconInactiveBuyColor:"rgba(64, 148, 232, 0.5)",cancelButtonIconActiveSellColor:"#e75656",cancelButtonIconInactiveSellColor:"rgba(231, 86, 86, 0.5)",tooltip:"",modifyTooltip:"",cancelTooltip:""},linetoolposition:{extendLeft:"inherit",lineLength:"inherit",lineLengthUnit:"percentage",lineBuyColor:"#4094e8",lineSellColor:"#e75656",lineStyle:"inherit",lineWidth:"inherit",bodyBorderBuyColor:"#4094e8",bodyBorderSellColor:"#e75656",bodyBackgroundColor:L,bodyBackgroundTransparency:25,bodyTextPositiveColor:"#268c02",bodyTextNeutralColor:"#646464",bodyTextNegativeColor:"#e75656",bodyFontFamily:"Verdana",bodyFontSize:9,bodyFontBold:!0,bodyFontItalic:!1,quantityBorderBuyColor:"#4094e8",quantityBorderSellColor:"#e75656",quantityBackgroundBuyColor:"#4094e8",quantityBackgroundSellColor:"#e75656",quantityTextColor:M,quantityTextTransparency:0,quantityFontFamily:"Verdana",quantityFontSize:9,quantityFontBold:!0,quantityFontItalic:!1,reverseButtonBorderBuyColor:"#4094e8",reverseButtonBorderSellColor:"#e75656",reverseButtonBackgroundColor:L, +reverseButtonBackgroundTransparency:25,reverseButtonIconBuyColor:"#4094e8",reverseButtonIconSellColor:"#e75656",closeButtonBorderBuyColor:"#4094e8",closeButtonBorderSellColor:"#e75656",closeButtonBackgroundColor:L,closeButtonBackgroundTransparency:25,closeButtonIconBuyColor:"#4094e8",closeButtonIconSellColor:"#e75656",tooltip:"",protectTooltip:"",closeTooltip:"",reverseTooltip:""},linetoolexecution:{direction:"buy",arrowHeight:8,arrowSpacing:1,arrowBuyColor:"#4094e8",arrowSellColor:"#e75656",text:"",textColor:I,textTransparency:0,fontFamily:"Verdana",fontSize:10,fontBold:!1,fontItalic:!1,tooltip:""},linetoolicon:{color:k,size:40,icon:61720,angle:.5*Math.PI},linetoolemoji:{size:40,emoji:"😀",angle:.5*Math.PI},linetoolsticker:{size:110,sticker:"bitcoin",angle:.5*Math.PI},linetoolimage:{transparency:0,cssWidth:0,cssHeight:0,angle:0},linetoolbezierquadro:{linecolor:k,linewidth:1,fillBackground:!1,backgroundColor:R,transparency:50,linestyle:P,extendLeft:!1,extendRight:!1,leftEnd:f.Normal,rightEnd:f.Normal},linetoolbeziercubic:{linecolor:W,linewidth:1,fillBackground:!1,backgroundColor:H,transparency:80,linestyle:P,extendLeft:!1,extendRight:!1,leftEnd:f.Normal,rightEnd:f.Normal},linetooltrendline:{linecolor:k,linewidth:2,linestyle:P,extendLeft:!1,extendRight:!1,leftEnd:f.Normal,rightEnd:f.Normal,showLabel:!1,horzLabelsAlign:"center",vertLabelsAlign:"bottom",textcolor:k,fontsize:14,bold:!1,italic:!1,alwaysShowStats:!1,showMiddlePoint:!1,showPriceLabels:!1,showPriceRange:!1,showPercentPriceRange:!1,showPipsPriceRange:!1,showBarsRange:!1,showDateTimeRange:!1,showDistance:!1,showAngle:!1,statsPosition:y.Right},linetoolinfoline:{linecolor:k,linewidth:2,linestyle:P,extendLeft:!1,extendRight:!1,leftEnd:f.Normal,rightEnd:f.Normal,showLabel:!1,horzLabelsAlign:"center",vertLabelsAlign:"bottom",textcolor:k,fontsize:14,bold:!1,italic:!1,alwaysShowStats:!0,showMiddlePoint:!1,showPriceLabels:!1,showPriceRange:!0,showPercentPriceRange:!0,showPipsPriceRange:!0,showBarsRange:!0,showDateTimeRange:!0,showDistance:!0,showAngle:!0,statsPosition:y.Center},linetooltimecycles:{linecolor:"#159980",linewidth:1,fillBackground:!0,backgroundColor:"rgba(106, 168, 79, 0.5)",transparency:50,linestyle:P},linetoolsineline:{linecolor:"#159980",linewidth:1,linestyle:P},linetooltrendangle:{linecolor:k,linewidth:2,linestyle:P,textcolor:k,fontsize:12,bold:!1,italic:!1,alwaysShowStats:!1,showMiddlePoint:!1,showPriceLabels:!1,showPriceRange:!1,showPercentPriceRange:!1,showPipsPriceRange:!1,showBarsRange:!1,extendRight:!1,extendLeft:!1,statsPosition:y.Right},linetooldisjointangle:{linecolor:ce,linewidth:2,linestyle:P,fillBackground:!0,backgroundColor:he,transparency:20,extendLeft:!1,extendRight:!1,leftEnd:f.Normal,rightEnd:f.Normal,textcolor:ce,fontsize:12,bold:!1,italic:!1,showPrices:!1,showPriceRange:!1,showDateTimeRange:!1,showBarsRange:!1},linetoolflatbottom:{linecolor:fe,linewidth:2,linestyle:P,fillBackground:!0,backgroundColor:ve,transparency:20,extendLeft:!1,extendRight:!1,leftEnd:f.Normal,rightEnd:f.Normal,textcolor:fe,fontsize:12,bold:!1,italic:!1, +showPrices:!1,showPriceRange:!1,showDateTimeRange:!1,showBarsRange:!1},linetoolfibspiral:{counterclockwise:!1,linecolor:z,linewidth:1,linestyle:P},linetoolriskrewardshort:{linecolor:xe,linewidth:1,textcolor:M,fontsize:12,fillLabelBackground:!0,labelBackgroundColor:"#585858",fillBackground:!0,stopBackground:J,profitBackground:he,stopBackgroundTransparency:80,profitBackgroundTransparency:80,drawBorder:!1,borderColor:"#667b8b",compact:!1,riskDisplayMode:"percents",accountSize:1e3,lotSize:1,risk:25,alwaysShowStats:!1,showPriceLabels:!0},linetoolriskrewardlong:{linecolor:xe,linewidth:1,textcolor:M,fontsize:12,fillLabelBackground:!0,labelBackgroundColor:"#585858",fillBackground:!0,stopBackground:J,profitBackground:he,stopBackgroundTransparency:80,profitBackgroundTransparency:80,drawBorder:!1,borderColor:"#667b8b",compact:!1,riskDisplayMode:"percents",accountSize:1e3,lotSize:1,risk:25,alwaysShowStats:!1,showPriceLabels:!0},linetoolarrow:{linecolor:k,linewidth:2,linestyle:P,extendLeft:!1,extendRight:!1,leftEnd:f.Normal,rightEnd:f.Arrow,showLabel:!1,horzLabelsAlign:"center",vertLabelsAlign:"bottom",textcolor:k,fontsize:14,bold:!1,italic:!1,alwaysShowStats:!1,showMiddlePoint:!1,showPriceLabels:!1,showPriceRange:!1,showPercentPriceRange:!1,showPipsPriceRange:!1,showBarsRange:!1,showDateTimeRange:!1,showDistance:!1,showAngle:!1,statsPosition:y.Right},linetoolray:{linecolor:k,linewidth:2,linestyle:P,extendLeft:!1,extendRight:!0,leftEnd:f.Normal,rightEnd:f.Normal,showLabel:!1,horzLabelsAlign:"center",vertLabelsAlign:"bottom",textcolor:k,fontsize:14,bold:!1,italic:!1,alwaysShowStats:!1,showMiddlePoint:!1,showPriceLabels:!1,showPriceRange:!1,showPercentPriceRange:!1,showPipsPriceRange:!1,showBarsRange:!1,showDateTimeRange:!1,showDistance:!1,showAngle:!1,statsPosition:y.Right},linetoolextended:{linecolor:k,linewidth:2,linestyle:P,extendLeft:!0,extendRight:!0,leftEnd:f.Normal,rightEnd:f.Normal,showLabel:!1,horzLabelsAlign:"center",vertLabelsAlign:"bottom",textcolor:k,fontsize:14,bold:!1,italic:!1,alwaysShowStats:!1,showMiddlePoint:!1,showPriceLabels:!1,showPriceRange:!1,showPercentPriceRange:!1,showPipsPriceRange:!1,showBarsRange:!1,showDateTimeRange:!1,showDistance:!1,showAngle:!1,statsPosition:y.Right},linetoolhorzline:{linecolor:k,linewidth:2,linestyle:P,showPrice:!0,showLabel:!1,textcolor:k,fontsize:12,bold:!1,italic:!1,horzLabelsAlign:"center",vertLabelsAlign:"top"},linetoolhorzray:{linecolor:k,linewidth:2,linestyle:P,showPrice:!0,showLabel:!1,textcolor:k,fontsize:12,bold:!1,italic:!1,horzLabelsAlign:"center",vertLabelsAlign:"top"},linetoolvertline:{linecolor:k,linewidth:2,linestyle:P,extendLine:!0,showTime:!0,showLabel:!1,horzLabelsAlign:"right",vertLabelsAlign:"top",textcolor:k,textOrientation:"vertical",fontsize:14,bold:!1,italic:!1},linetoolcrossline:{linecolor:k,linewidth:2,linestyle:P,showPrice:!0,showTime:!0},linetoolcirclelines:{trendline:{visible:!0,color:"#808080",linewidth:1,linestyle:x},linecolor:"#80ccdb",linewidth:1,linestyle:P},linetoolfibtimezone:{horzLabelsAlign:"right",vertLabelsAlign:"bottom", +baselinecolor:"#808080",linecolor:"#0055db",linewidth:1,linestyle:P,showLabels:!0,fillBackground:!1,transparency:80,trendline:{visible:!0,color:"#808080",linewidth:1,linestyle:x},level1:r(0,xe,!0),level2:r(1,k,!0),level3:r(2,k,!0),level4:r(3,k,!0),level5:r(5,k,!0),level6:r(8,k,!0),level7:r(13,k,!0),level8:r(21,k,!0),level9:r(34,k,!0),level10:r(55,k,!0),level11:r(89,k,!0)},linetooltext:{color:k,fontsize:14,fillBackground:!1,backgroundColor:"rgba(91, 133, 191, 0.3)",backgroundTransparency:70,drawBorder:!1,borderColor:"#667b8b",bold:!1,italic:!1,fixedSize:!0,wordWrap:!1,wordWrapWidth:200},linetooltextabsolute:{color:k,fontsize:14,fillBackground:!1,backgroundColor:"rgba(155, 190, 213, 0.3)",backgroundTransparency:70,drawBorder:!1,borderColor:"#667b8b",bold:!1,italic:!1,fixedSize:!1,wordWrap:!1,wordWrapWidth:200},linetoolballoon:{color:M,backgroundColor:ne,borderColor:se,fontsize:14,transparency:30},linetoolcomment:{color:M,backgroundColor:k,borderColor:k,fontsize:16,transparency:0},linetoolbrush:{linecolor:z,linewidth:1,linestyle:P,smooth:5,fillBackground:!1,backgroundColor:z,transparency:50,leftEnd:f.Normal,rightEnd:f.Normal},linetoolhighlighter:{linecolor:J,smooth:5,transparency:80},linetoolpolyline:{linecolor:z,linewidth:1,linestyle:P,fillBackground:!0,backgroundColor:U,transparency:80,filled:!1},linetoolsignpost:{itemType:m.Emoji,emoji:"🙂",showImage:!1,plateColor:k,fontSize:12,bold:!1,italic:!1},linetoolpath:{lineColor:k,lineWidth:2,lineStyle:P,leftEnd:f.Normal,rightEnd:f.Arrow},linetoolarrowmarkleft:{color:k,arrowColor:k,fontsize:14,bold:!1,italic:!1,showLabel:!0},linetoolarrowmarkup:{color:ce,arrowColor:ce,fontsize:14,bold:!1,italic:!1,showLabel:!0},linetoolarrowmarkright:{color:k,arrowColor:k,fontsize:14,bold:!1,italic:!1,showLabel:!0},linetoolarrowmarkdown:{color:te,arrowColor:te,fontsize:14,bold:!1,italic:!1,showLabel:!0},linetoolflagmark:{flagColor:k},linetoolnote:{markerColor:k,textColor:M,backgroundColor:D,backgroundTransparency:0,borderColor:k,fontSize:14,bold:!1,italic:!1,fixedSize:!0},linetoolnoteabsolute:{markerColor:k,textColor:M,backgroundColor:D,backgroundTransparency:0,borderColor:k,fontSize:14,bold:!1,italic:!1,fixedSize:!0},linetoolpricelabel:{color:M,backgroundColor:k,borderColor:k,fontWeight:"bold",fontsize:14,transparency:0},linetoolarrowmarker:{backgroundColor:N,textColor:N,bold:!0,italic:!1,fontsize:16,showLabel:!0},linetoolrectangle:{color:ie,fillBackground:!0,backgroundColor:re,linewidth:1,transparency:50,showLabel:!1,horzLabelsAlign:"left",vertLabelsAlign:"bottom",textColor:ie,fontSize:14,bold:!1,italic:!1,extendLeft:!1,extendRight:!1},linetoolrotatedrectangle:{color:_e,fillBackground:!0,backgroundColor:me,transparency:50,linewidth:1},linetoolcircle:{color:fe,backgroundColor:ve,fillBackground:!0,linewidth:1,showLabel:!1,textColor:fe,fontSize:14,bold:!1,italic:!1},linetoolellipse:{color:Z,fillBackground:!0,backgroundColor:J,transparency:50,linewidth:1,showLabel:!1,textColor:Z,fontSize:14,bold:!1,italic:!1},linetoolarc:{color:oe,fillBackground:!0,backgroundColor:ae,transparency:80,linewidth:1 +},linetoolprediction:{linecolor:k,linewidth:1,sourceBackColor:k,sourceTextColor:M,sourceStrokeColor:k,targetStrokeColor:k,targetBackColor:k,targetTextColor:M,successBackground:_e,successTextColor:M,failureBackground:Z,failureTextColor:M,intermediateBackColor:"#ead289",intermediateTextColor:"#6d4d22",transparency:10,centersColor:"#202020"},linetooltriangle:{color:ce,fillBackground:!0,backgroundColor:he,transparency:80,linewidth:1},linetoolcallout:{color:M,backgroundColor:G,transparency:50,linewidth:1,fontsize:14,bordercolor:j,bold:!1,italic:!1,wordWrap:!1,wordWrapWidth:200},linetoolparallelchannel:{linecolor:k,linewidth:2,linestyle:P,extendLeft:!1,extendRight:!1,fillBackground:!0,backgroundColor:R,transparency:20,showMidline:!0,midlinecolor:k,midlinewidth:1,midlinestyle:x},linetoolelliottimpulse:{degree:7,showWave:!0,color:"#3d85c6",linewidth:1},linetoolelliotttriangle:{degree:7,showWave:!0,color:fe,linewidth:1},linetoolelliotttriplecombo:{degree:7,showWave:!0,color:"#6aa84f",linewidth:1},linetoolelliottcorrection:{degree:7,showWave:!0,color:"#3d85c6",linewidth:1},linetoolelliottdoublecombo:{degree:7,showWave:!0,color:"#6aa84f",linewidth:1},linetoolbarspattern:{color:k,mode:c.Bars,mirrored:!1,flipped:!1},linetoolghostfeed:{averageHL:20,variance:50,candleStyle:{upColor:le,downColor:$,drawWick:!0,drawBorder:!0,borderColor:"#378658",borderUpColor:ce,borderDownColor:Z,wickColor:xe},transparency:50},study:{inputs:{},styles:{},bands:{},graphics:{},ohlcPlots:{},palettes:{},filledAreasStyle:{},filledAreas:{},visible:!0,showLegendValues:!0,showLabelsOnPriceScale:!0,precision:"default"},linetoolpitchfork:{fillBackground:!0,transparency:80,style:l.Original,median:{visible:!0,color:Z,linewidth:1,linestyle:P},extendLines:!1,level0:r(.25,ge,!1),level1:r(.382,pe,!1),level2:r(.5,ce,!0),level3:r(.618,ce,!1),level4:r(.75,z,!1),level5:r(1,k,!0),level6:r(1.5,ie,!1),level7:r(1.75,oe,!1),level8:r(2,Y,!1)},linetoolpitchfan:{fillBackground:!0,transparency:80,median:{visible:!0,color:Z,linewidth:1,linestyle:P},level0:r(.25,ge,!1),level1:r(.382,pe,!1),level2:r(.5,z,!0),level3:r(.618,ce,!1),level4:r(.75,z,!1),level5:r(1,k,!0),level6:r(1.5,ie,!1),level7:r(1.75,oe,!1),level8:r(2,Y,!1)},linetoolgannfan:{showLabels:!0,fillBackground:!0,transparency:80,level1:Te(1,8,fe,!0),level2:Te(1,4,ce,!0),level3:Te(1,3,_e,!0),level4:Te(1,2,ce,!0),level5:Te(1,1,z,!0),level6:Te(2,1,k,!0),level7:Te(3,1,ie,!0),level8:Te(4,1,oe,!0),level9:Te(8,1,Z,!0)},linetoolganncomplex:{fillBackground:!1,arcsBackground:{fillBackground:!0,transparency:80},reverse:!1,scaleRatio:"",showLabels:!0,labelsStyle:{fontSize:12,bold:!1,italic:!1},levels:[h(xe,!0,1),h(fe,!0,1),h(z,!0,1),h(_e,!0,1),h(ce,!0,1),h(xe,!0,1)],fanlines:[T(O,!1,1,8,1),T(Z,!1,1,5,1),T(xe,!1,1,4,1),T(fe,!1,1,3,1),T(z,!0,1,2,1),T(_e,!0,1,1,1),T(ce,!0,1,1,2),T(ce,!1,1,1,3),T(k,!1,1,1,4),T(F,!1,1,1,5),T(O,!1,1,1,8)],arcs:[T(fe,!0,1,1,0),T(fe,!0,1,1,1),T(fe,!0,1,1.5,0),T(z,!0,1,2,0),T(z,!0,1,2,1),T(_e,!0,1,3,0),T(_e,!0,1,3,1),T(ce,!0,1,4,0),T(ce,!0,1,4,1),T(k,!0,1,5,0),T(k,!0,1,5,1)]},linetoolgannfixed:{fillBackground:!1, +arcsBackground:{fillBackground:!0,transparency:80},reverse:!1,levels:[h(xe,!0,1),h(fe,!0,1),h(z,!0,1),h(_e,!0,1),h(ce,!0,1),h(xe,!0,1)],fanlines:[T(O,!1,1,8,1),T(Z,!1,1,5,1),T(xe,!1,1,4,1),T(fe,!1,1,3,1),T(z,!0,1,2,1),T(_e,!0,1,1,1),T(ce,!0,1,1,2),T(ce,!1,1,1,3),T(k,!1,1,1,4),T(F,!1,1,1,5),T(O,!1,1,1,8)],arcs:[T(fe,!0,1,1,0),T(fe,!0,1,1,1),T(fe,!0,1,1.5,0),T(z,!0,1,2,0),T(z,!0,1,2,1),T(_e,!0,1,3,0),T(_e,!0,1,3,1),T(ce,!0,1,4,0),T(ce,!0,1,4,1),T(k,!0,1,5,0),T(k,!0,1,5,1)]},linetoolgannsquare:{color:"rgba(21, 56, 153, 0.8)",linewidth:1,linestyle:P,showTopLabels:!0,showBottomLabels:!0,showLeftLabels:!0,showRightLabels:!0,fillHorzBackground:!0,horzTransparency:80,fillVertBackground:!0,vertTransparency:80,reverse:!1,fans:t(Pe,!1),hlevel1:i(0,xe,!0),hlevel2:i(.25,fe,!0),hlevel3:i(.382,z,!0),hlevel4:i(.5,_e,!0),hlevel5:i(.618,ce,!0),hlevel6:i(.75,k,!0),hlevel7:i(1,xe,!0),vlevel1:i(0,xe,!0),vlevel2:i(.25,fe,!0),vlevel3:i(.382,z,!0),vlevel4:i(.5,_e,!0),vlevel5:i(.618,ce,!0),vlevel6:i(.75,k,!0),vlevel7:i(1,xe,!0)},linetoolfibspeedresistancefan:{fillBackground:!0,transparency:80,grid:{color:"rgba(21, 56, 153, 0.8)",linewidth:1,linestyle:P,visible:!0},linewidth:1,linestyle:P,showTopLabels:!0,showBottomLabels:!0,showLeftLabels:!0,showRightLabels:!0,reverse:!1,hlevel1:i(0,xe,!0),hlevel2:i(.25,fe,!0),hlevel3:i(.382,z,!0),hlevel4:i(.5,_e,!0),hlevel5:i(.618,ce,!0),hlevel6:i(.75,k,!0),hlevel7:i(1,xe,!0),vlevel1:i(0,xe,!0),vlevel2:i(.25,fe,!0),vlevel3:i(.382,z,!0),vlevel4:i(.5,_e,!0),vlevel5:i(.618,ce,!0),vlevel6:i(.75,k,!0),vlevel7:i(1,xe,!0)},linetoolfibretracement:{showCoeffs:!0,showPrices:!0,fillBackground:!0,transparency:80,extendLines:!1,extendLinesLeft:!1,horzLabelsAlign:"left",vertLabelsAlign:"bottom",reverse:!1,coeffsAsPercents:!1,fibLevelsBasedOnLogScale:!1,labelFontSize:12,trendline:{visible:!0,color:xe,linewidth:1,linestyle:x},levelsStyle:{linewidth:1,linestyle:P},level1:i(0,xe,!0),level2:i(.236,Z,!0),level3:i(.382,fe,!0),level4:i(.5,_e,!0),level5:i(.618,ce,!0),level6:i(.786,z,!0),level7:i(1,xe,!0),level8:i(1.618,k,!0),level9:i(2.618,Z,!0),level10:i(3.618,ie,!0),level11:i(4.236,oe,!0),level12:i(1.272,fe,!1),level13:i(1.414,Z,!1),level16:i(2,ce,!1),level14:i(2.272,fe,!1),level15:i(2.414,_e,!1),level17:i(3,z,!1),level18:i(3.272,xe,!1),level19:i(3.414,k,!1),level20:i(4,Z,!1),level21:i(4.272,ie,!1),level22:i(4.414,oe,!1),level23:i(4.618,fe,!1),level24:i(4.764,ce,!1)},linetoolfibchannel:{showCoeffs:!0,showPrices:!0,fillBackground:!0,transparency:80,extendLeft:!1,extendRight:!1,horzLabelsAlign:"left",vertLabelsAlign:"middle",coeffsAsPercents:!1,labelFontSize:12,levelsStyle:{linewidth:1,linestyle:P},level1:i(0,xe,!0),level2:i(.236,Z,!0),level3:i(.382,fe,!0),level4:i(.5,_e,!0),level5:i(.618,ce,!0),level6:i(.786,z,!0),level7:i(1,xe,!0),level8:i(1.618,k,!0),level9:i(2.618,Z,!0),level10:i(3.618,ie,!0),level11:i(4.236,oe,!0),level12:i(1.272,fe,!1),level13:i(1.414,Z,!1),level16:i(2,ce,!1),level14:i(2.272,fe,!1),level15:i(2.414,_e,!1),level17:i(3,z,!1),level18:i(3.272,xe,!1),level19:i(3.414,k,!1),level20:i(4,Z,!1),level21:i(4.272,ie,!1), +level22:i(4.414,oe,!1),level23:i(4.618,fe,!1),level24:i(4.764,ce,!1)},linetoolprojection:{showCoeffs:!0,fillBackground:!0,transparency:80,color1:R,color2:re,linewidth:1,trendline:{visible:!0,color:Pe,linestyle:P},level1:r(1,"#808080",!0)},linetool5pointspattern:{color:k,textcolor:M,fillBackground:!0,backgroundColor:k,fontsize:12,bold:!1,italic:!1,transparency:85,linewidth:1},linetoolcypherpattern:{color:k,textcolor:M,fillBackground:!0,backgroundColor:k,fontsize:12,bold:!1,italic:!1,transparency:85,linewidth:1},linetooltrianglepattern:{color:W,textcolor:M,fillBackground:!0,backgroundColor:W,fontsize:12,bold:!1,italic:!1,transparency:85,linewidth:1},linetoolabcd:{color:ce,textcolor:M,fontsize:12,bold:!1,italic:!1,linewidth:1},linetoolthreedrivers:{color:W,textcolor:M,fillBackground:!0,backgroundColor:"rgba(149, 40, 204, 0.5)",fontsize:12,bold:!1,italic:!1,transparency:50,linewidth:1},linetoolheadandshoulders:{color:ce,textcolor:M,fillBackground:!0,backgroundColor:ce,fontsize:12,bold:!1,italic:!1,transparency:85,linewidth:1},linetoolfibwedge:{showCoeffs:!0,fillBackground:!0,transparency:80,trendline:{visible:!0,color:"#808080",linewidth:1,linestyle:P},level1:r(.236,Z,!0),level2:r(.382,fe,!0),level3:r(.5,_e,!0),level4:r(.618,ce,!0),level5:r(.786,z,!0),level6:r(1,xe,!0),level7:r(1.618,k,!1),level8:r(2.618,Z,!1),level9:r(3.618,W,!1),level10:r(4.236,oe,!1),level11:r(4.618,oe,!1)},linetoolfibcircles:{showCoeffs:!0,fillBackground:!0,transparency:80,coeffsAsPercents:!1,trendline:{visible:!0,color:xe,linewidth:1,linestyle:x},level1:r(.236,Z,!0),level2:r(.382,fe,!0),level3:r(.5,ce,!0),level4:r(.618,_e,!0),level5:r(.786,z,!0),level6:r(1,xe,!0),level7:r(1.618,k,!0),level8:r(2.618,oe,!0),level9:r(3.618,k,!0),level10:r(4.236,oe,!0),level11:r(4.618,Z,!0)},linetoolfibspeedresistancearcs:{showCoeffs:!0,fillBackground:!0,transparency:80,fullCircles:!1,trendline:{visible:!0,color:xe,linewidth:1,linestyle:x},level1:r(.236,Z,!0),level2:r(.382,fe,!0),level3:r(.5,ce,!0),level4:r(.618,_e,!0),level5:r(.786,z,!0),level6:r(1,xe,!0),level7:r(1.618,k,!0),level8:r(2.618,oe,!0),level9:r(3.618,k,!0),level10:r(4.236,oe,!0),level11:r(4.618,Z,!0)},linetooltrendbasedfibextension:{showCoeffs:!0,showPrices:!0,fillBackground:!0,transparency:80,extendLines:!1,extendLinesLeft:!1,horzLabelsAlign:"left",vertLabelsAlign:"bottom",reverse:!1,coeffsAsPercents:!1,fibLevelsBasedOnLogScale:!1,labelFontSize:12,trendline:{visible:!0,color:xe,linewidth:1,linestyle:x},levelsStyle:{linewidth:1,linestyle:P},level1:i(0,xe,!0),level2:i(.236,Z,!0),level3:i(.382,fe,!0),level4:i(.5,_e,!0),level5:i(.618,ce,!0),level6:i(.786,z,!0),level7:i(1,xe,!0),level8:i(1.618,k,!0),level9:i(2.618,Z,!0),level10:i(3.618,ie,!0),level11:i(4.236,oe,!0),level12:i(1.272,fe,!1),level13:i(1.414,Z,!1),level16:i(2,ce,!1),level14:i(2.272,fe,!1),level15:i(2.414,_e,!1),level17:i(3,z,!1),level18:i(3.272,xe,!1),level19:i(3.414,k,!1),level20:i(4,Z,!1),level21:i(4.272,ie,!1),level22:i(4.414,oe,!1),level23:i(4.618,fe,!1),level24:i(4.764,ce,!1)},linetooltrendbasedfibtime:{showCoeffs:!0,fillBackground:!0, +transparency:80,horzLabelsAlign:"right",vertLabelsAlign:"bottom",trendline:{visible:!0,color:xe,linewidth:1,linestyle:x},level1:r(0,xe,!0),level2:r(.382,Z,!0),level3:r(.5,pe,!1),level4:r(.618,_e,!0),level5:r(1,ce,!0),level6:r(1.382,z,!0),level7:r(1.618,xe,!0),level8:r(2,k,!0),level9:r(2.382,oe,!0),level10:r(2.618,ie,!0),level11:r(3,W,!0)},linetoolschiffpitchfork:{fillBackground:!0,transparency:80,style:l.Schiff,median:{visible:!0,color:Z,linewidth:1,linestyle:P},extendLines:!1,level0:r(.25,ge,!1),level1:r(.382,pe,!1),level2:r(.5,ce,!0),level3:r(.618,ce,!1),level4:r(.75,z,!1),level5:r(1,k,!0),level6:r(1.5,ie,!1),level7:r(1.75,oe,!1),level8:r(2,Y,!1)},linetoolschiffpitchfork2:{fillBackground:!0,transparency:80,style:l.Schiff2,median:{visible:!0,color:Z,linewidth:1,linestyle:P},extendLines:!1,level0:r(.25,ge,!1),level1:r(.382,pe,!1),level2:r(.5,ce,!0),level3:r(.618,ce,!1),level4:r(.75,z,!1),level5:r(1,k,!0),level6:r(1.5,ie,!1),level7:r(1.75,oe,!1),level8:r(2,Y,!1)},linetoolinsidepitchfork:{fillBackground:!0,transparency:80,style:l.Inside,median:{visible:!0,color:Z,linewidth:1,linestyle:P},extendLines:!1,level0:r(.25,ge,!1),level1:r(.382,pe,!1),level2:r(.5,ce,!0),level3:r(.618,ce,!1),level4:r(.75,z,!1),level5:r(1,k,!0),level6:r(1.5,ie,!1),level7:r(1.75,oe,!1),level8:r(2,Y,!1)},linetoolregressiontrend:{linewidth:1,linestyle:P,styles:{upLine:{display:u.All,color:E,linestyle:P,linewidth:2},downLine:{display:u.All,color:E,linestyle:P,linewidth:2},baseLine:{display:u.All,color:X,linestyle:x,linewidth:1},extendLines:!1,showPearsons:!0,transparency:70}}},Oe(TradingView.defaultProperties.chartproperties),We()}if(void 0===TradingView.defaultProperties["study_MA@tv-basicstudies"]&&(TradingView.defaultProperties["study_MA@tv-basicstudies"]={description:"Moving Average",shortDescription:"MA",inputs:{length:9,source:"close"},styles:{MovAvg:{display:u.All,color:k,linestyle:P,linewidth:1,plottype:d.Line,histogramBase:0,title:"MA"}}}),void 0===TradingView.defaultProperties["study_PivotPointsHighLow@tv-basicstudies"]&&(TradingView.defaultProperties["study_PivotPointsHighLow@tv-basicstudies"]={fontsize:10,borderColor:k,backColor:A,textColor:Le}),void 0===TradingView.defaultProperties["study_PivotPointsStandard@tv-basicstudies"]){var Ne=!0;TradingView.defaultProperties["study_PivotPointsStandard@tv-basicstudies"]={_hardCodedDefaultsVersion:1,fontsize:11,levelsStyle:{showLabels:!0,visibility:{P:Ne,"S1/R1":Ne,"S2/R2":Ne,"S3/R3":Ne,"S4/R4":Ne,"S5/R5":Ne},colors:{P:Se,"S1/R1":Se,"S2/R2":Se,"S3/R3":Se,"S4/R4":Se,"S5/R5":Se},widths:{P:1,"S1/R1":1,"S2/R2":1,"S3/R3":1,"S4/R4":1,"S5/R5":1}}}}if(void 0===TradingView.defaultProperties["study_ZigZag@tv-basicstudies"]&&(TradingView.defaultProperties["study_ZigZag@tv-basicstudies"]={color:k,linewidth:2}),void 0===TradingView.defaultProperties["study_ElliottWave@tv-basicstudies"]&&(TradingView.defaultProperties["study_ElliottWave@tv-basicstudies"]={inputs:{},level0:t(q,!1),level1:t("#008000",!1),level2:t("#0000ff",!1),level3:t("#ff00ff",!1),level4:t("#0080ff",!0),level5:t(q,!0),level6:t("#008000",!0), +level7:t("#0000ff",!0),level8:t("#ff00ff",!0)}),void 0===TradingView.defaultProperties["study_LinearRegression@tv-basicstudies"]&&(TradingView.defaultProperties["study_LinearRegression@tv-basicstudies"]={styles:{upLine:{display:u.All,color:E,linestyle:P,linewidth:1},downLine:{display:u.All,color:E,linestyle:P,linewidth:1},baseLine:{display:u.All,color:X,linestyle:P,linewidth:1},extendLines:!0,showPearsons:!0,backgroundColor:"rgba(153, 21, 21, 0.3)",transparency:70}}),void 0===TradingView.defaultProperties["study_Compare@tv-basicstudies"]&&(TradingView.defaultProperties["study_Compare@tv-basicstudies"]={minTick:"default"}),void 0===TradingView.defaultProperties["study_Overlay@tv-basicstudies"]){TradingView.defaultProperties["study_Overlay@tv-basicstudies"]={style:a.STYLE_LINE,allowExtendTimeScale:!1,showPriceLine:!1,minTick:"default",candleStyle:{upColor:"#6ba583",downColor:"#d75442",drawWick:!0,drawBorder:!0,drawBody:!0,borderColor:"#378658",borderUpColor:"#225437",borderDownColor:"#5b1a13",wickColor:"#737375",wickUpColor:"#737375",wickDownColor:"#737375",barColorsOnPrevClose:!1},hollowCandleStyle:{upColor:"#6ba583",downColor:"#d75442",drawWick:!0,drawBorder:!0,drawBody:!0,borderColor:"#378658",borderUpColor:"#225437",borderDownColor:"#5b1a13",wickColor:"#737375",wickUpColor:"#737375",wickDownColor:"#737375",barColorsOnPrevClose:!1},barStyle:{upColor:"#6ba583",downColor:"#d75442",barColorsOnPrevClose:!1,dontDrawOpen:!1,thinBars:!0},lineStyle:{color:ye,linestyle:P,linewidth:2,priceSource:"close"},lineWithMarkersStyle:{color:ye,linestyle:P,linewidth:2,priceSource:"close"},steplineStyle:{color:ye,linestyle:P,linewidth:2,priceSource:"close"},areaStyle:{color1:k,color2:k,linecolor:k,linestyle:P,linewidth:2,priceSource:"close",transparency:95},baselineStyle:{baselineColor:ke,topFillColor1:Ee,topFillColor2:Ee,bottomFillColor1:Be,bottomFillColor2:Be,topLineColor:De,bottomLineColor:Ve,topLineWidth:2,bottomLineWidth:2,priceSource:"close",transparency:50,baseLevelPercentage:50},hiloStyle:{color:k,showBorders:!0,borderColor:k,showLabels:!0,labelColor:k,drawBody:!0},columnStyle:{upColor:n(ce,50),downColor:n(Z,50),barColorsOnPrevClose:!0,priceSource:"close"},hlcAreaStyle:{highLineColor:ce,highLineStyle:P,highLineWidth:2,lowLineColor:Z,lowLineStyle:P,lowLineWidth:2,closeLineColor:Ce,closeLineStyle:P,closeLineWidth:2,highCloseFillColor:he,closeLowFillColor:J},styles:{open:{display:u.All,color:q,linestyle:P,linewidth:1,plottype:d.Line,histogramBase:0},high:{display:u.All,color:q,linestyle:P,linewidth:1,plottype:d.Line,histogramBase:0},low:{display:u.All,color:q,linestyle:P,linewidth:1,plottype:d.Line,histogramBase:0},close:{display:u.All,color:q,linestyle:P,linewidth:1,plottype:d.Line,histogramBase:0}}}}for(var Fe=e.split("."),He=TradingView.defaultProperties,ze=0;ze1?h(e[r],t.slice(1),i):(e[r]&&e[r].setValue?e[r].setValue(i):e[r]=i,!0))}function d(e){i||T.logWarn("Path `"+e+"` does not exist.")}}function Oe(e,t,i,s){window.__defaultsOverrides&&Ne(e,t,i,window.__defaultsOverrides,s)}function Fe(e,t){window.__settingsOverrides&&Ne(e,null,!1,window.__settingsOverrides,t)}function We(){var e=/^linetool.+/;Object.keys(TradingView.defaultProperties).forEach((function(t){e.test(t)&&Oe(TradingView.defaultProperties[t],null,!1,t)}))}function He(e,t){return t?function(e,t){var i=Re(e);if(!window._UNIT_TESTS){var s=TradingView.clone(TVSettings.getJSON(e,null));if(function(e){var t=new Set(["linetoolregressiontrend"]);return e.startsWith("study_")||t.has(e)}(e)&&s&&function(e){if(!e)return!1;e=e.toString();var t=new RegExp("\\d+").exec(e);return null!==t&&t[0]===e}(s.version)){var r=s.inputs,n=t.updateStudyInputs(s.id,s.version,"last",r,null);s.inputs=n,s=t.updateStudyState(s,s)}TradingView.merge(i,s),Fe(i,e)}return i}(e,t):function(e){var t=Re(e);if(!window._UNIT_TESTS){var i=TradingView.clone(TVSettings.getJSON(e,null));if(i){TradingView.merge(t,i);const s=e.split(".");Fe(t,void 0===s[1]?e:s[1])}}return t}(e)}He.create=function(e,t){if(t){var i=Re(e);TradingView.defaultProperties[e]=Object.assign(t,i)}},He.remove=function(e){TradingView.defaultProperties[e]=void 0},TradingView.saveDefaults=function(e,t){void 0===t?TVSettings.remove(e):TVSettings.setJSON(e,t)},TradingView.factoryDefaults=Re,window.applyDefaultOverridesToLinetools=We,window.applyDefaultsOverrides=Oe,window.applyPropertiesOverrides=Ne,window.defaults=He,t.applyDefaultOverridesToLinetools=We,t.applyDefaultsOverrides=Oe,t.applyPropertiesOverrides=Ne,t.defaults=He,t.factoryDefaults=Re,t.saveDefaults=TradingView.saveDefaults},88348:(e,t,i)=>{"use strict";i.r(t),i.d(t,{SelectPointMode:()=>s,activePointSelectionMode:()=>$,barTimesUnderCursor:()=>K,beenSetLineToolLastPoint:()=>V,cancelLineTool:()=>ee,cancelledLineTool:()=>E,changeLineStyle:()=>he,changeLineTool:()=>oe,changedLineStyle:()=>U,changedLineTool:()=>F,continueLineTool:()=>Q,continuedLineTool:()=>D,copiedLineTool:()=>j,copyLineTool:()=>de,createLineTool:()=>J,createdLineTool:()=>k,crosshairLock:()=>b,cursorTool:()=>T,drawOnAllCharts:()=>Pe,drawOnAllChartsMode:()=>Ce,emojiTool:()=>C,finishChangingLineTool:()=>ae,finishLineTool:()=>ce,finishMovingLineTool:()=>re,finishedChangingLineTool:()=>W,finishedLineTool:()=>z,finishedMovingLineTool:()=>N,hideAllDrawings:()=>Se,hideAllIndicators:()=>ye,hideMarksOnBars:()=>we,iconTool:()=>P,init:()=>ge,isDirectionalMovementActive:()=>A,isStudyEditingNow:()=>Y,isToolCreatingNow:()=>I,isToolEditingNow:()=>M,isToolMovingNow:()=>L,lockDrawings:()=>be,moveLineTool:()=>se,movedLineTool:()=>R,properties:()=>ve,removeLineTool:()=>le,removedLineTool:()=>H,resetToCursor:()=>m,restoreLineTool:()=>ue,restoreLineToolState:()=>pe,restoredLineTool:()=>G,restoredLineToolState:()=>q, +runOnDrawingStateReady:()=>fe,setLineToolLastPoint:()=>te,startChangingLineTool:()=>ne,startMovingLineTool:()=>ie,startedChangingLineTool:()=>O,startedMovingLineTool:()=>B,stickerTool:()=>x,tool:()=>w,toolIsCursor:()=>p,toolIsMeasure:()=>_});var s,r=i(50151),n=i(59680),o=i(46100),a=i(97145),l=i(83669),c=i(57898),h=i(56840),d=i(76422),u=i(85804);function p(e){return"cursor"===e||"arrow"===e||"dot"===e}function _(e){return"measure"===e}function m(e=!1){if(!e&&g){if(g.childs().stayInDrawingMode.value())return}w.setValue(T.value())}!function(e){e[e.None=0]="None",e[e.Replay=1]="Replay",e[e.Study=2]="Study"}(s||(s={}));let g=null,f=null,v=null,S=null,y=null;const b=new l.WatchedObject(null),w=new a.WatchedValue,P=new a.WatchedValue,C=new a.WatchedValue,x=new a.WatchedValue,T=new a.WatchedValue,I=new a.WatchedValue(!1),M=new a.WatchedValue(!1),L=new a.WatchedValue(!1),A=new a.WatchedValue(!1),k=new c.Delegate,D=new c.Delegate,E=new c.Delegate,V=new c.Delegate,B=new c.Delegate,R=new c.Delegate,N=new c.Delegate,O=new c.Delegate,F=new c.Delegate,W=new c.Delegate,H=new c.Delegate,z=new c.Delegate,U=new c.Delegate,j=new c.Delegate,G=new c.Delegate,q=new c.Delegate,$=new a.WatchedValue(s.None),Y=new a.WatchedValue(!1),K=new Map;function Z(e,t){const i=t||{value:!1};return t=>{i.value||(i.value=!0,e.fire(t),i.value=!1)}}const X={value:!1},J=Z(k,X),Q=Z(D,X),ee=Z(E,X),te=Z(V,X),ie=Z(B),se=Z(R),re=Z(N),ne=Z(O),oe=Z(F),ae=Z(W),le=Z(H),ce=Z(z),he=Z(U,X),de=Z(j,X),ue=Z(G),pe=Z(q);let _e=!1,me=[];function ge(){_e||(w.setValue(h.getValue("chart.cursorPreference","cursor")),w.subscribe((e=>p(e)&&T.setValue(e)),{callWithLast:!0}),T.subscribe((e=>{e&&h.setValue("chart.cursorPreference",e)})),g=new o.DefaultProperty("drawings"),f=(0,n.createPrimitiveProperty)(),v=(0,n.createPrimitiveProperty)(),S=(0,n.createPrimitiveProperty)(),y=(0,n.createPrimitiveProperty)(),f.setValue(!1),v.setValue(!1),S.setValue(!1),y.setValue(!1),w.subscribe((()=>{(0,d.emit)("onSelectedLineToolChanged")})),P.subscribe((()=>{(0,u.saveDefaults)("linetoolicon",{...(0,u.defaults)("linetoolicon"),icon:P.value()})})),C.subscribe((()=>{(0,u.saveDefaults)("linetoolemoji",{...(0,u.defaults)("linetoolemoji"),emoji:C.value()})})),x.subscribe((()=>{(0,u.saveDefaults)("linetoolsticker",{...(0,u.defaults)("linetoolsticker"),sticker:x.value()})})),_e=!0,me.forEach((e=>e())),me=[])}function fe(e){_e?e():me.push(e)}function ve(){return(0,r.ensureNotNull)(g)}function Se(){return(0,r.ensureNotNull)(f)}function ye(){return(0,r.ensureNotNull)(v)}function be(){return(0,r.ensureNotNull)(S)}function we(){return(0,r.ensureNotNull)(y)}function Pe(){return ve().childs().drawOnAllCharts}function Ce(){return ve().childs().drawOnAllChartsMode}},81155:(e,t,i)=>{"use strict";i.d(t,{EnvironmentState:()=>r});var s=i(49483);class r{constructor(e,t=!1){this._shift=!1,this._mod=!1,this._alt=!1,void 0!==e&&(this._shift=Boolean(e.shiftKey),this._mod=Boolean((0,s.isMac)()?e.metaKey:e.ctrlKey),this._alt=Boolean(e.altKey)),this._isApiEvent=t}shift(){return this._shift}mod(){return this._mod}alt(){ +return this._alt}shiftOnly(){return this._shift&&!this._mod&&!this._alt}modOnly(){return this._mod&&!this._shift&&!this._alt}altOnly(){return this._alt&&!this._shift&&!this._mod}modShift(){return this._shift&&this._mod&&!this._alt}isApiEvent(){return this._isApiEvent}static create(e=!1,t=!1,i=!1){return new r({shiftKey:e,ctrlKey:t,metaKey:t,altKey:i})}}},27856:(e,t,i)=>{"use strict";function s(e){return"="+JSON.stringify(r(e))}function r(e){return Object.keys(e).sort().reduce(((t,i)=>("[object Object]"===Object.prototype.toString.call(e[i])?t[i]=r(e[i]):t[i]=e[i],t)),{})}function n(e){return Boolean(e.inputs)}function o(e){return s(e)}function a(e){return"="===e[0]}function l(e){if(!a(e))return{symbol:e};try{return JSON.parse(e.slice(1))}catch(t){return{symbol:e}}}function c(e){return"string"==typeof e?e:c(e.symbol)}i.r(t),i.d(t,{decodeExtendedSymbol:()=>l,encodeExtendedSymbolOrGetSimpleSymbolString:()=>o,isEncodedExtendedSymbol:()=>a,isStudySymbol:()=>n,unwrapSimpleSymbol:()=>c})},1763:(e,t,i)=>{"use strict";i.d(t,{customFormatters:()=>s});const s={dateFormatter:null,timeFormatter:null,tickMarkFormatter:null,priceFormatterFactory:null,studyFormatterFactory:null}},15879:(e,t,i)=>{"use strict";i.d(t,{availableDateFormats:()=>f,dateFormatFunctions:()=>m,defaultDateFormat:()=>v,getDateFormatWithWeekday:()=>g});var s=i(44352),r=i(28865),n=i(61146);const o={1:()=>s.t(null,void 0,i(95425)),2:()=>s.t(null,void 0,i(35050)),3:()=>s.t(null,void 0,i(51369)),4:()=>s.t(null,void 0,i(42762)),5:()=>s.t(null,{context:"short"},i(27991)),6:()=>s.t(null,void 0,i(15224)),7:()=>s.t(null,void 0,i(6215)),8:()=>s.t(null,void 0,i(38465)),9:()=>s.t(null,void 0,i(57902)),10:()=>s.t(null,void 0,i(73546)),11:()=>s.t(null,void 0,i(71230)),12:()=>s.t(null,void 0,i(92203))},a=(e,t)=>(t?e.getMonth():e.getUTCMonth())+1,l=(e,t)=>t?e.getFullYear():e.getUTCFullYear(),c=e=>e.toLocaleDateString(window.language?(0,r.getIsoLanguageCodeFromLanguage)(window.language):void 0,{weekday:"short",timeZone:"UTC"}),h=(e,t)=>(0,n.numberToStringWithLeadingZero)(((e,t)=>t?e.getDate():e.getUTCDate())(e,t),2),d=(e,t)=>o[a(e,t)](),u=(e,t)=>(0,n.numberToStringWithLeadingZero)(a(e,t),2),p=(e,t)=>(0,n.numberToStringWithLeadingZero)(l(e,t)%100,2),_=(e,t)=>(0,n.numberToStringWithLeadingZero)(l(e,t),4),m={"dd MMM 'yy":(e,t)=>`${h(e,t)} ${d(e,t)} '${p(e,t)}`,"MMM dd, yyyy":(e,t)=>`${d(e,t)} ${h(e,t)}, ${_(e,t)}`,"MMM yyyy":(e,t)=>`${d(e,t)} ${_(e,t)}`,"MMM dd":(e,t)=>`${d(e,t)} ${h(e,t)}`,"dd MMM":(e,t)=>`${h(e,t)} ${d(e,t)}`,"yyyy-MM-dd":(e,t)=>`${_(e,t)}-${u(e,t)}-${h(e,t)}`,"yy-MM-dd":(e,t)=>`${p(e,t)}-${u(e,t)}-${h(e,t)}`,"yy/MM/dd":(e,t)=>`${p(e,t)}/${u(e,t)}/${h(e,t)}`,"yyyy/MM/dd":(e,t)=>`${_(e,t)}/${u(e,t)}/${h(e,t)}`,"dd-MM-yyyy":(e,t)=>`${h(e,t)}-${u(e,t)}-${_(e,t)}`,"dd-MM-yy":(e,t)=>`${h(e,t)}-${u(e,t)}-${p(e,t)}`,"dd/MM/yy":(e,t)=>`${h(e,t)}/${u(e,t)}/${p(e,t)}`,"dd/MM/yyyy":(e,t)=>`${h(e,t)}/${u(e,t)}/${_(e,t)}`,"MM/dd/yy":(e,t)=>`${u(e,t)}/${h(e,t)}/${p(e,t)}`,"MM/dd/yyyy":(e,t)=>`${u(e,t)}/${h(e,t)}/${_(e,t)}`};function g(e){ return"ja"===window.language?(t,i)=>`${m[e](t,i)} (${c(t)})`:(t,i)=>`${c(t)} ${m[e](t,i)}`}const f=Object.keys(m),v=()=>-1!==["ja","ko","zh","zh_TW"].indexOf(window.language||"")?"yyyy-MM-dd":"dd MMM 'yy"},53741:(e,t,i)=>{"use strict";i.d(t,{DateFormatter:()=>n});var s=i(1763),r=i(15879);class n{constructor(e="yyyy-MM-dd",t=!1){this._dateFormatFunc=t?(0,r.getDateFormatWithWeekday)(e):r.dateFormatFunctions[e]}format(e){return s.customFormatters&&s.customFormatters.dateFormatter?s.customFormatters.dateFormatter.format(e):this._dateFormatFunc(e,!1)}formatLocal(e){return s.customFormatters.dateFormatter?s.customFormatters.dateFormatter.formatLocal?s.customFormatters.dateFormatter.formatLocal(e):s.customFormatters.dateFormatter.format(e):this._dateFormatFunc(e,!0)}}},34928:(e,t,i)=>{"use strict";i.d(t,{DateTimeFormatter:()=>o});var s=i(79206),r=i(53741);const n={dateFormat:"yyyy-MM-dd",withWeekday:!1,timeFormat:s.hourMinuteSecondFormat,dateTimeSeparator:" "};class o{constructor(e={}){const t=Object.assign({},n,e);this._dateFormatter=new r.DateFormatter(t.dateFormat,t.withWeekday),this._timeFormatter=new s.TimeFormatter(t.timeFormat),this._separator=t.dateTimeSeparator}format(e){return`${this._dateFormatter.format(e)}${this._separator}${this._timeFormatter.format(e)}`}formatLocal(e){return`${this._dateFormatter.formatLocal(e)}${this._separator}${this._timeFormatter.formatLocal(e)}`}}},10786:(e,t,i)=>{"use strict";i.d(t,{LimitedPrecisionNumericFormatter:()=>r});var s=i(1722);class r{constructor(e=1){this._precision=e}format(e){(0,s.isNumber)(e)||(e=parseFloat(e));const t=e.toFixed(this._precision),i=Math.pow(10,-this._precision);return Math.max(parseFloat(t),i)+""}parse(e){const t=parseFloat(e);return isNaN(t)?{res:!1}:{res:!0,value:t,suggest:this.format(t)}}}},87663:(e,t,i)=>{"use strict";i.d(t,{NumericFormatter:()=>n});var s=i(61146),r=i(60521);class n{constructor(e){this._precision=e}format(e){return(void 0!==this._precision?e.toFixed(this._precision):n.formatNoE(e)).replace(".",s.formatterOptions.decimalSign)}parse(e){const t=e.replace(s.formatterOptions.decimalSign,".");let i=parseFloat(t);return this._precision&&(i=+i.toFixed(this._precision)),i}static formatNoE(e){if(!Number.isFinite(e))return String(e);const t=new r.Big(e);return t.lt(1)?t.toFixed():t.toString()}}},93572:(e,t,i)=>{"use strict";i.d(t,{PercentageFormatter:()=>n});var s=i(61146),r=i(38223);class n extends s.PriceFormatter{constructor(e){super(e),this.type="percentage"}state(){const e=s.PriceFormatter.prototype.state.call(this);return e.percent=!0,e}parse(e){return e=e.replace("%",""),super.parse(e)}format(e,t,i,s,n=!0){const o=super.format(e,t,i,s,!1)+"%";return n?(0,r.forceLTRStr)(o):o}static serialize(e){return e.state()}static deserialize(e){return new n(e.priceScale)}}},57322:(e,t,i)=>{"use strict";i.d(t,{PipFormatter:()=>n});var s=i(91349),r=i(61146);class n extends r.PriceFormatter{constructor(e,t,i,r,n){t||(t=1),("forex"===i||(0,s.isCFDSymbol)(i,n))&&r?(super(r),this._isForex=!0):(super(1),this._isForex=!1),this._pipPriceScale=e, this._pipMinMove=t,this._pipMinMove2=r}format(e,t,i){let s=this._isForex?this._pipMinMove2:this._pipMinMove;return void 0===s&&(s=NaN),super.format(e*this._pipPriceScale/s,t,i)}}},61146:(e,t,i)=>{"use strict";i.d(t,{PriceFormatter:()=>m,formatterOptions:()=>c,numberToStringWithLeadingZero:()=>p});var s=i(44352),r=i(60521),n=i(1722);var o=i(38223);const a=(0,i(59224).getLogger)("Chart.PriceFormatter"),l=new RegExp(/^(-?)[0-9]+$/),c={decimalSign:".",decimalSignFractional:"'"},h=new Map;const d=new Map;function u(e,t,i,s){let r=0;if(e>0&&t>0){let t=e;for(i&&s&&(t/=s);t>1;)t/=10,r++}return r}function p(e,t){if(!(0,n.isNumber)(e))return"n/a";if(!(0,n.isInteger)(t))throw new TypeError("invalid length");if(t<0||t>24)throw new TypeError("invalid length");if(0===t)return e.toString();return("0000000000000000"+e.toString()).slice(-t)}function _(e,t){const i=function(e){const{minTick:t,price:i,variableMinTickData:s,shouldCheckForEquality:r}=e;return void 0===s?t:function(e,t,i=!1){for(let s=0;s0&&2!==l&&4!==l&&8!==l?a.logDebug("invalid minmove2"):(this._fractional=o,this._fractionalLength=u(this._priceScale,this._minMove,this._fractional,this._minMove2),this._ignoreMinMove=h)}isFractional(){return!!this._fractional}state(){return{fractional:this._fractional,fractionalLength:this._fractionalLength,minMove:this._minMove,minMove2:this._minMove2,priceScale:this._priceScale,variableMinTick:this._variableMinTick,ignoreMinMove:this._ignoreMinMove}}formatChange(e,t,i){return this._formatImpl(e-t,i,void 0,void 0,void 0,void 0,Math.min(Math.abs(e),Math.abs(t)))}format(e,t,i,s=!0,r=!0,n=!1){return this._formatImpl(e,t,i,s,r,n)}parse(e){return"+"===(e=(e=(0,o.stripLTRMarks)(e)).replace("−","-"))[0]&&(e=e.substring(1)), this._fractional?this._minMove2?this._parseAsDoubleFractional(e):this._parseAsSingleFractional(e):this._parseAsDecimal(e)}hasForexAdditionalPrecision(){return!this._fractional&&10===this._minMove2}static serialize(e){return e.state()}static deserialize(e){return new m(e.priceScale,e.minMove,e.fractional,e.minMove2,e.variableMinTick,e.ignoreMinMove)}_formatImpl(e,t,i,s=!0,r=!0,n=!1,a){const l={price:e,priceScale:this._priceScale,minMove:this._minMove,fractionalLength:this._fractionalLength,tailSize:i,cutFractionalByPrecision:n};let c,h="";return e<0?(h=!1===s?"":"−",l.price=-e):e&&!0===t&&(h="+"),void 0!==this._variableMinTickData&&(Object.assign(l,_(this._variableMinTickData,null!=a?a:l.price)),this._ignoreMinMove&&(l.minMove=1)),c=this._fractional?h+this._formatAsFractional(l.price,l.tailSize):h+this._formatAsDecimal(l),r?(0,o.forceLTRStr)(c):c}_formatAsExponential(e){const t=Math.floor(.75*Math.log10(this._priceScale)),i=e*Math.pow(10,t),s=`e-${t}`,r=Math.log10(this._priceScale)-t;return`${i.toFixed(r).replace(".",c.decimalSign)}${s}`}_formatAsDecimal(e){const{price:t,priceScale:i,minMove:s,fractionalLength:n=0,tailSize:o=0,cutFractionalByPrecision:a}=e;if(i>1e15)return this._formatAsExponential(t);let l;l=this._fractional?Math.pow(10,n):Math.pow(10,o)*i/(a?1:s);const h=1/l;let d;if(l>1)d=Math.floor(t);else{const e=Math.floor(Math.round(t/h)*h);d=0===Math.round((t-e)/h)?e:e+h}let u="";if(l>1){let e=a?new r.Big(t).mul(l).round(void 0,0).minus(new r.Big(d).mul(l)).toNumber():parseFloat((Math.round(t*l)-d*l).toFixed(n));e>=l&&(e-=l,d+=1);const i=a?new r.Big(e).round(n,0).toNumber():parseFloat(e.toFixed(n))*s;u=c.decimalSign+p(i,n+o),u=this._removeEndingZeros(u,o)}return d.toString()+u}_getFractPart(e,t,i){const s=[0,5],r=[0,2,5,7],n=[0,1,2,3,5,6,7,8];return 2===i?void 0===s[e]?-1:s[e]:4===i?void 0===r[e]?-1:r[e]:8===i&&2===t?void 0===n[e]?-1:n[e]:e}_formatAsFractional(e,t){const i=this._priceScale/this._minMove;let s=Math.floor(e),r=t?Math.floor(e*i)-s*i:Math.round(e*i)-s*i;r===i&&(r=0,s+=1);let n="";if(t){let o=(e-s-r/i)*i;o=Math.round(o*Math.pow(10,t)),n=p(o,t),n=this._removeEndingZeros(n,t)}if(!this._fractionalLength)throw new Error("_fractionalLength is not calculated");let o="";if(this._minMove2){const e=r%this._minMove2;r=(r-e)/this._minMove2;const t=p(r,this._fractionalLength),i=this._getFractPart(e,2,this._minMove2);o=t+c.decimalSignFractional+i}else r=this._getFractPart(r,1,this._priceScale),o=p(r*this._minMove,this._fractionalLength);return s.toString()+c.decimalSignFractional+o+n}_removeEndingZeros(e,t){for(let i=0;ie.HighlighterDefinitionsViewModel))}_loadPaneViews(e){i.e(1583).then(i.bind(i,75427)).then((t=>{this._setPaneViews([new t.HighlighterPaneView(this,e)])}))}}},46927:(e,t,i)=>{"use strict";i.d(t,{LineToolHorzLinePriceAxisView:()=>n});var s=i(42275),r=i(87095);class n extends s.PriceAxisView{constructor(e){super(),this._source=e}_updateRendererData(e,t,i){e.visible=!1;const s=this._source.points(),n=this._source.priceScale();if(0===s.length||null===n||n.isEmpty())return;const o=s[0];if(!isFinite(o.price))return;const a=this._source.ownerSource(),l=null!==a?a.firstValue():null;if(null===l)return;const c=(0,r.resetTransparency)(this._source.properties().linecolor.value());i.background=c,i.textColor=this.generateTextColor(c),i.coordinate=n.priceToCoordinate(o.price,l),e.text=n.formatPrice(o.price,l),e.visible=!0}}},9801:(e,t,i)=>{"use strict";i.d(t,{LineToolHorzLine:()=>l});var s=i(59452),r=i.n(s),n=i(46100),o=i(13087),a=i(46927);class l extends o.LineDataSource{constructor(e,t,s,r){super(e,t||l.createProperties(),s,r),this._priceAxisView=new a.LineToolHorzLinePriceAxisView(this),i.e(1583).then(i.bind(i,74660)).then((({HorzLinePaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}state(e){const t=super.state(e);return t.points&&0!==t.points.length&&(t.points[0].offset=0),t}pointsCount(){return 1}name(){return"Horizontal Line"}priceAxisViews(e,t){return this.isSourceHidden()||t!==this.priceScale()||!this._model.selection().isSelected(this)&&!this.properties().childs().showPrice.value()||e!==this._model.paneForSource(this)?null:[this._priceAxisView]}timeAxisViews(){return null}timeAxisPoints(){return[]}updateAllViews(e){super.updateAllViews(e),this._priceAxisView.update(e)}canHasAlert(){return!0}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}denormalizeTimePoints(){this._points=[],this._timePoint.length>0&&this._points.push({price:this._timePoint[0].price,index:0})}clearData(){const e=this._points;super.clearData(),this._points=e}static createProperties(e){const t=new n.DefaultProperty("linetoolhorzline",e);return this._configureProperties(t),t}_getAlertPlots(){return[this.points()[0].price]}_pointsForPointset(){return[]}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,55252)).then((e=>e.HorizontalLineDefinitionsViewModel))}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text||"")}static _configureProperties(e){super._configureProperties(e),e.hasChild("text")||e.addChild("text",new(r())("")), e.addExclusion("text")}}},2135:(e,t,i)=>{"use strict";i.d(t,{LineToolHorzRay:()=>l});var s=i(46100),r=i(59452),n=i.n(r),o=i(46927),a=i(13087);class l extends a.LineDataSource{constructor(e,t,s,r){super(e,null!=t?t:l.createProperties(),s,r),this._priceAxisView=new o.LineToolHorzLinePriceAxisView(this),i.e(1583).then(i.bind(i,57964)).then((({HorzRayPaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}pointsCount(){return 1}name(){return"Horizontal Ray"}priceAxisViews(e,t){return this.isSourceHidden()||t!==this.priceScale()||!this._model.selection().isSelected(this)&&!this.properties().childs().showPrice.value()||e!==this._model.paneForSource(this)?null:[this._priceAxisView]}updateAllViews(e){super.updateAllViews(e),this._priceAxisView.update(e)}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}canHasAlert(){return!0}static createProperties(e){const t=new s.DefaultProperty("linetoolhorzray",e);return this._configureProperties(t),t}_getAlertPlots(){const e=this._points[0],t={index:e.index+1,price:e.price},i=this._linePointsToAlertPlot([e,t],null,!1,!0);return null!==i?[i]:[]}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,15574))).HorizontalRayDefinitionsViewModel}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text||"")}static _configureProperties(e){super._configureProperties(e),e.hasChild("text")||e.addChild("text",new(n())("")),e.addExclusion("text")}}},93873:(e,t,i)=>{"use strict";i.d(t,{LineToolIcon:()=>a});var s=i(46100),r=i(68806),n=i(8459);const o=(0,i(59224).getLogger)("Chart.LineToolIcon");class a extends n.LineToolSvgIconBase{constructor(e,t,i,s){super(e,t||a.createProperties(),i,s),this.version=1,this._loadViews()}name(){return"Icon"}applyTemplate(e){delete e.icon,super.applyTemplate(e)}static createProperties(e){const t=new s.DefaultProperty("linetoolicon",e);return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,53284)).then((e=>e.IconsDefinitionsViewModel))}async _loadViews(){const[{getSvgContentForCharCode:e,getSvgRenderer:t},{IconPaneView:s},{svgRenderer:r}]=await Promise.all([i.e(7987).then(i.bind(i,1383)),i.e(1583).then(i.bind(i,48273)),i.e(2616).then(i.bind(i,50765))]);if(!this._isDestroyed){const i=this._properties.childs().icon.value();this._svgContent=e(i),this._onIconChanged.fire();const n=t(r,i);null===n&&o.logWarn(`Couldn't create svg renderer for icon ${i}`),this._setPaneViews([new s(this,this._model,n)])}}static _configureProperties(e){super._configureProperties(e),e.addChild("backgroundsColors",new r.LineToolColorsProperty([e.childs().color]))}}},32430:(e,t,i)=>{"use strict";i.d(t,{commonLineToolPropertiesStateKeys:()=>s});const s=["symbolStateVersion","zOrderVersion","frozen","title","symbolInfo","interval","symbol","currencyId","unitId","visible"]},48272:(e,t,i)=>{"use strict";i.d(t,{ LineToolInfoLine:()=>r});var s=i(47246);class r extends s.LineToolTrendLine{constructor(e,t,i,s){super(e,t||r.createProperties(),i,s)}pointsCount(){return 2}name(){return"Info Line"}static createProperties(e){const t=s.LineToolTrendLine.createProperties(e,"linetoolinfoline");return r._configureProperties(t),t}}},98501:(e,t,i)=>{"use strict";var s=i(53801).LevelsProperty,r=i(70309).LineToolPitchfork;class n extends r{constructor(e,t,i,s){super(e,t||n.createProperties(),i,s)}name(){return"Inside Pitchfork"}static createProperties(e){var t=new s("linetoolinsidepitchfork",e,!1,{range:[0,8]});return this._configureProperties(t),t}}t.LineToolInsidePitchfork=n},15367:(e,t,i)=>{"use strict";var s;i.r(t),i.d(t,{isImageToolName:()=>u,isLineDrawnWithPressedButton:()=>c,isLineToolDrawWithoutPoints:()=>d,isLineToolFinishRequiredWhenCreatedByApi:()=>h,isLineToolName:()=>l,isMtpPredictorToolName:()=>o,isStudyLineToolName:()=>a,isTextToolName:()=>p});var r=i(56954);const n=new Set([]);function o(e){return n.has(e)}function a(e){return"LineToolRegressionTrend"===e||"LineToolVbPFixed"===e||"LineToolFixedRangeVolumeProfile"===e||"LineToolAnchoredVolumeProfile"===e||"LineToolAnchoredVWAP"===e}function l(e){return e in(s||(s=i.t(r,2)))||a(e)}function c(e){return"LineToolBrush"===e||"LineToolHighlighter"===e}function h(e){return c(e)||"LineToolPath"===e||"LineToolPolyline"===e||"LineToolGhostFeed"===e}function d(e){return"LineToolTweet"===e||"LineToolIdea"===e||"LineToolImage"===e}function u(e){return"LineToolImage"===e}function p(e){switch(e){case"LineToolBalloon":case"LineToolComment":case"LineToolText":case"LineToolTextAbsolute":case"LineToolCallout":case"LineToolNote":case"LineToolNoteAbsolute":case"LineToolSignpost":return!0}return!1}},75149:(e,t,i)=>{"use strict";i.d(t,{LineDataSourcePointIndexProperty:()=>n});var s=i(59452),r=i.n(s);class n extends(r()){constructor(e,t){super(),this._lineSource=e,this._pointIndex=t}value(){return this._lineSource.points()[this._pointIndex].index}setValue(e){const t=this._lineSource.points()[this._pointIndex];t.index=e,this._lineSource.startChanging(this._pointIndex,t),this._setPointImpl(t),this._lineSource.model().updateSource(this._lineSource),this._listeners.fire(this);const i=this._lineSource.endChanging(!0,!1);this._lineSource.syncMultichartState(i)}_setPointImpl(e){this._lineSource.setPoint(this._pointIndex,e)}}},71243:(e,t,i)=>{"use strict";i.d(t,{LineToolPriceAxisView:()=>o});var s=i(50151),r=i(42275),n=i(87095);class o extends r.PriceAxisView{constructor(e,t){super(),this._source=e,this._data=t,this._properties=e.model().properties().childs().scalesProperties}_updateRendererData(e,t,i){e.visible=!1;const s=this._source.model();if(!s.timeScale()||s.timeScale().isEmpty())return;const r=this._source.priceScale();if(null===r||r.isEmpty())return;if(!s.selection().isSelected(this._source)&&!this._source.isForcedDrawPriceAxisLabel())return;if(null===s.timeScale().visibleBarsStrictRange())return;const o=this._source.priceAxisPoints(),a=this._data.pointIndex;if(o.length<=a)return;const l=o[a] -;if(!isFinite(l.price))return;const c=this._source.ownerSource(),h=null!==c?c.firstValue():null;if(null===h)return;let d=this._data.backgroundPropertyGetter?this._data.backgroundPropertyGetter():null;null===d&&(d=this._getBgColor()),i.background=(0,n.resetTransparency)(d),i.borderColor="#2E84A6",i.textColor=this.generateTextColor(i.background),i.coordinate=r.priceToCoordinate(l.price,h),e.text=this._formatPrice(l.price,h),e.visible=!0}_getBgColor(){return this._active?this._properties.childs().axisLineToolLabelBackgroundColorActive.value():this._properties.childs().axisLineToolLabelBackgroundColorCommon.value()}_formatPrice(e,t){return(0,s.ensureNotNull)(this._source.priceScale()).formatPrice(e,t)}}},77680:(e,t,i)=>{"use strict";i.d(t,{LineDataSourceThemedProperty:()=>r});var s=i(13637);class r extends s.ThemedDefaultProperty{template(){return(0,s.extractState)(this.state(),this._allDefaultsKeys)}}},95977:(e,t,i)=>{"use strict";i.d(t,{LineDataSourceTimeAxisView:()=>r});var s=i(34951);class r extends s.TimeAxisView{constructor(e,t){super(e.model()),this._active=!1,this._source=e,this._pointIndex=t,this._properties=e.model().properties().childs().scalesProperties}setActive(e){this._active=e}_getBgColor(){return this._active?this._properties.childs().axisLineToolLabelBackgroundColorActive.value():this._properties.childs().axisLineToolLabelBackgroundColorCommon.value()}_getIndex(){if(!this._model.selection().isSelected(this._source))return null;const e=this._source.timeAxisPoints();return e.length<=this._pointIndex?null:e[this._pointIndex].index}_isVisible(){return!0}}},13087:(e,t,i)=>{"use strict";i.d(t,{LineDataSource:()=>R});var s=i(86441),r=i(50151),n=i(76422),o=i(59224),a=i(14483),l=i(57898),c=i(22767),h=i(97145),d=i(91280),u=i(94025),p=i(4949),_=i(17236),m=i(42960),g=i(97121),f=i(36274),v=i(59452),S=i.n(v),y=i(88348),b=i(14292),w=i(38349),P=i(1722),C=i(28558),x=i(18611),T=i(75149);class I extends(S()){constructor(e,t){super(),this._lineSource=e,this._pointIndex=t,e.pointAdded().subscribe(this,(e=>{this._pointIndex===e&&this._listeners.fire(this)})),e.pointChanged().subscribe(this,(e=>{this._pointIndex===e&&this._listeners.fire(this)}))}value(){const e=this._lineSource.points()[this._pointIndex].price,t=(0,r.ensureNotNull)(this._lineSource.ownerSource()).formatter();if(t.parse){const i=t.format(e),s=t.parse(i);return s.res?s.value:e}return e}setValue(e){const t=this._lineSource.points()[this._pointIndex];t.price=parseFloat(""+e),this._lineSource.startChanging(this._pointIndex,t),this._lineSource.setPoint(this._pointIndex,t),this._lineSource.model().updateSource(this._lineSource),this._listeners.fire(this);const i=this._lineSource.endChanging(!0,!1);this._lineSource.syncMultichartState(i)}}var M=i(95977),L=i(71243),A=i(68806),k=i(59656);const D=(0,o.getLogger)("Chart.LineDataSource"),V=a.enabled("datasource_copypaste");class E{constructor(){this._states=[]}start(e){this._states.push(e)}finish(e){const t=(0,r.ensureDefined)(this._states.pop());return s=t,(i=e).length!==s.length?{indexesChanged:!0,pricesChanged:!0 -}:i.reduce(((e,t,i)=>{const r=s[i];return e.indexesChanged=e.indexesChanged||t.index!==r.index,e.pricesChanged=e.pricesChanged||t.price!==r.price,e}),{indexesChanged:!1,pricesChanged:!1});var i,s}isEmpty(){return 0===this._states.length}}let B=0;class R extends b.DataSource{constructor(e,t,i,s){if(super(s),this.version=1,this.toolname="",this.customization={forcePriceAxisLabel:!1,disableErasing:!1,disableSave:!1,showInObjectsTree:!0},this._currentPointsetAndSymbolId=null,this._pointChanged=new l.Delegate,this._pointAdded=new l.Delegate,this._priceAxisViews=[],this._timeAxisViews=[],this._timePoint=[],this._points=[],this._lastPoint=null,this._paneViews=new Map,this._normalizedPointsChanged=new l.Delegate,this._fixedPointsChanged=new l.Delegate,this._changeStatesStack=new E,this._startMovingPoint=null,this._currentMovingPoint=null,this._isActualSymbol=!1,this._isActualInterval=!1,this._isActualCurrency=!1,this._isActualUnit=!1,this._isDestroyed=!1,this._sharingMode=new h.WatchedValue(0),this._onTemplateApplying=new l.Delegate,this._onTemplateApplied=new l.Delegate,this._syncStateExclusions=[],this._definitionsViewModel=null,this._syncLineStyleMuted=!1,this._onIsActualIntervalChange=new l.Delegate,this._linkKey=new h.WatchedValue(null),this._serverUpdateTime=null,this._boundCalcIsActualSymbol=this.calcIsActualSymbol.bind(this),this._alertUndoMode=!1,this._model=e,this._properties=t,this._localAndServerAlertsMismatch=!1,this._properties.hasChild("interval")||this._properties.addChild("interval",new(S())(e.mainSeries().interval())),this.calcIsActualSymbol(),this._properties.childs().intervalsVisibilities.listeners().subscribe(this,this.calcIsActualSymbol),this._properties.subscribe(this,(()=>this.propertiesChanged())),this._createPointsProperties(),this.pointsCount()>0)for(let e=0;e{const t=!1===(0,y.hideAllDrawings)().value();e.value()?e.value()&&t&&n.emit("drawing_event",this._id,"show"):(this._model.selection().isSelected(this)&&this._model.selectionMacro((e=>{e.removeSourceFromSelection(this)})),t&&n.emit("drawing_event",this._id,"hide")),this._onSourceHiddenMayChange()})),(0,y.hideAllDrawings)().subscribe(this,this._onSourceHiddenMayChange),this._definitionsViewModel=null,this._isDestroyed=!1}destroy(){this._paneViews.forEach(((e,t)=>this._destroyPanePaneViews(t))),this.stop(),null!==this._definitionsViewModel&&(this._definitionsViewModel.destroy(),this._definitionsViewModel=null),null!==this._ownerSource&&(this._ownerSource.currencyChanged().unsubscribeAll(this),this._ownerSource.unitChanged().unsubscribeAll(this),(0,x.isSymbolSource)(this._ownerSource)&&(this._ownerSource.symbolResolved().subscribe(this,this._boundCalcIsActualSymbol),this._ownerSource.isActingAsSymbolSource().unsubscribe(this._boundCalcIsActualSymbol))),this.ownerSourceChanged().unsubscribeAll(this),(0,y.hideAllDrawings)().unsubscribeAll(this), +;if(!isFinite(l.price))return;const c=this._source.ownerSource(),h=null!==c?c.firstValue():null;if(null===h)return;let d=this._data.backgroundPropertyGetter?this._data.backgroundPropertyGetter():null;null===d&&(d=this._getBgColor()),i.background=(0,n.resetTransparency)(d),i.borderColor="#2E84A6",i.textColor=this.generateTextColor(i.background),i.coordinate=r.priceToCoordinate(l.price,h),e.text=this._formatPrice(l.price,h),e.visible=!0}_getBgColor(){return this._active?this._properties.childs().axisLineToolLabelBackgroundColorActive.value():this._properties.childs().axisLineToolLabelBackgroundColorCommon.value()}_formatPrice(e,t){return(0,s.ensureNotNull)(this._source.priceScale()).formatPrice(e,t)}}},77680:(e,t,i)=>{"use strict";i.d(t,{LineDataSourceThemedProperty:()=>r});var s=i(13637);class r extends s.ThemedDefaultProperty{template(){return(0,s.extractState)(this.state(),this._allDefaultsKeys)}}},95977:(e,t,i)=>{"use strict";i.d(t,{LineDataSourceTimeAxisView:()=>r});var s=i(34951);class r extends s.TimeAxisView{constructor(e,t){super(e.model()),this._active=!1,this._source=e,this._pointIndex=t,this._properties=e.model().properties().childs().scalesProperties}setActive(e){this._active=e}_getBgColor(){return this._active?this._properties.childs().axisLineToolLabelBackgroundColorActive.value():this._properties.childs().axisLineToolLabelBackgroundColorCommon.value()}_getIndex(){if(!this._model.selection().isSelected(this._source))return null;const e=this._source.timeAxisPoints();return e.length<=this._pointIndex?null:e[this._pointIndex].index}_isVisible(){return!0}}},13087:(e,t,i)=>{"use strict";i.d(t,{LineDataSource:()=>R});var s=i(86441),r=i(50151),n=i(76422),o=i(59224),a=i(14483),l=i(57898),c=i(22767),h=i(97145),d=i(91280),u=i(94025),p=i(4949),_=i(17236),m=i(42960),g=i(97121),f=i(36274),v=i(59452),S=i.n(v),y=i(88348),b=i(14292),w=i(38349),P=i(1722),C=i(28558),x=i(18611),T=i(75149);class I extends(S()){constructor(e,t){super(),this._lineSource=e,this._pointIndex=t,e.pointAdded().subscribe(this,(e=>{this._pointIndex===e&&this._listeners.fire(this)})),e.pointChanged().subscribe(this,(e=>{this._pointIndex===e&&this._listeners.fire(this)}))}value(){const e=this._lineSource.points()[this._pointIndex].price,t=(0,r.ensureNotNull)(this._lineSource.ownerSource()).formatter();if(t.parse){const i=t.format(e),s=t.parse(i);return s.res?s.value:e}return e}setValue(e){const t=this._lineSource.points()[this._pointIndex];t.price=parseFloat(""+e),this._lineSource.startChanging(this._pointIndex,t),this._lineSource.setPoint(this._pointIndex,t),this._lineSource.model().updateSource(this._lineSource),this._listeners.fire(this);const i=this._lineSource.endChanging(!0,!1);this._lineSource.syncMultichartState(i)}}var M=i(95977),L=i(71243),A=i(68806),k=i(59656);const D=(0,o.getLogger)("Chart.LineDataSource"),E=a.enabled("datasource_copypaste");class V{constructor(){this._states=[]}start(e){this._states.push(e)}finish(e){const t=(0,r.ensureDefined)(this._states.pop());return s=t,(i=e).length!==s.length?{indexesChanged:!0,pricesChanged:!0 +}:i.reduce(((e,t,i)=>{const r=s[i];return e.indexesChanged=e.indexesChanged||t.index!==r.index,e.pricesChanged=e.pricesChanged||t.price!==r.price,e}),{indexesChanged:!1,pricesChanged:!1});var i,s}isEmpty(){return 0===this._states.length}}let B=0;class R extends b.DataSource{constructor(e,t,i,s){if(super(s),this.version=1,this.toolname="",this.customization={forcePriceAxisLabel:!1,disableErasing:!1,disableSave:!1,showInObjectsTree:!0},this._currentPointsetAndSymbolId=null,this._pointChanged=new l.Delegate,this._pointAdded=new l.Delegate,this._priceAxisViews=[],this._timeAxisViews=[],this._timePoint=[],this._points=[],this._lastPoint=null,this._paneViews=new Map,this._normalizedPointsChanged=new l.Delegate,this._fixedPointsChanged=new l.Delegate,this._changeStatesStack=new V,this._startMovingPoint=null,this._currentMovingPoint=null,this._isActualSymbol=!1,this._isActualInterval=!1,this._isActualCurrency=!1,this._isActualUnit=!1,this._isDestroyed=!1,this._sharingMode=new h.WatchedValue(0),this._onTemplateApplying=new l.Delegate,this._onTemplateApplied=new l.Delegate,this._syncStateExclusions=[],this._definitionsViewModel=null,this._syncLineStyleMuted=!1,this._onIsActualIntervalChange=new l.Delegate,this._linkKey=new h.WatchedValue(null),this._serverUpdateTime=null,this._boundCalcIsActualSymbol=this.calcIsActualSymbol.bind(this),this._alertUndoMode=!1,this._model=e,this._properties=t,this._localAndServerAlertsMismatch=!1,this._properties.hasChild("interval")||this._properties.addChild("interval",new(S())(e.mainSeries().interval())),this.calcIsActualSymbol(),this._properties.childs().intervalsVisibilities.listeners().subscribe(this,this.calcIsActualSymbol),this._properties.subscribe(this,(()=>this.propertiesChanged())),this._createPointsProperties(),this.pointsCount()>0)for(let e=0;e{const t=!1===(0,y.hideAllDrawings)().value();e.value()?e.value()&&t&&n.emit("drawing_event",this._id,"show"):(this._model.selection().isSelected(this)&&this._model.selectionMacro((e=>{e.removeSourceFromSelection(this)})),t&&n.emit("drawing_event",this._id,"hide")),this._onSourceHiddenMayChange()})),(0,y.hideAllDrawings)().subscribe(this,this._onSourceHiddenMayChange),this._definitionsViewModel=null,this._isDestroyed=!1}destroy(){this._paneViews.forEach(((e,t)=>this._destroyPanePaneViews(t))),this.stop(),null!==this._definitionsViewModel&&(this._definitionsViewModel.destroy(),this._definitionsViewModel=null),null!==this._ownerSource&&(this._ownerSource.currencyChanged().unsubscribeAll(this),this._ownerSource.unitChanged().unsubscribeAll(this),(0,x.isSymbolSource)(this._ownerSource)&&(this._ownerSource.symbolResolved().subscribe(this,this._boundCalcIsActualSymbol),this._ownerSource.isActingAsSymbolSource().unsubscribe(this._boundCalcIsActualSymbol))),this.ownerSourceChanged().unsubscribeAll(this),(0,y.hideAllDrawings)().unsubscribeAll(this), this._isDestroyed=!0}priceScale(){return this._ownerSource?this._ownerSource.priceScale():null}createPriceAxisView(e){return new L.LineToolPriceAxisView(this,{pointIndex:e})}model(){return this._model}symbol(){return this._properties.childs().symbol.value()}linkKey(){return this._linkKey}serverUpdateTime(){return this._serverUpdateTime}setServerUpdateTime(e){this._serverUpdateTime=e}boundToSymbol(){return!0}isAvailableInFloatingWidget(){return!0}points(){const e=[];for(let t=0;t{const i=(0,r.ensureNotNull)(this.pointToScreenPoint(t)),n=i.x/this._model.timeScale().width(),o=i.y/e.height();return new s.Point(n,o)}))}widthsProperty(){var e;return null!==(e=this._properties.childs().linesWidths)&&void 0!==e?e:null}lineColorsProperty(){var e;return null!==(e=this._properties.childs().linesColors)&&void 0!==e?e:null}backgroundColorsProperty(){var e;return null!==(e=this._properties.childs().backgroundsColors)&&void 0!==e?e:null}textColorsProperty(){var e;return null!==(e=this._properties.childs().textsColors)&&void 0!==e?e:null}pointsProperty(){return this._pointsProperty}hasEditableCoordinates(){return!0}startMoving(e,t,i,s){this.isFixed()&&this.restoreFixedPoint(),this._startMovingPoint=e}move(e,t,i,s){if(i&&(i.shiftOnly()||i.modShift()))if(this.isFixed()){const t=this._alignScreenPointHorizontallyOrVertically((0,r.ensureDefined)(e.screen));this._currentMovingPoint={screen:t}}else{const t=this._alignPointHorizontallyOrVertically((0,r.ensureDefined)(e.logical)),i=(0,r.ensureNotNull)(this.pointToScreenPoint(t));this._currentMovingPoint={logical:t,screen:i}}else this._currentMovingPoint=e;this.updateAllViews((0,C.sourceChangeEvent)(this.id()))}endMoving(e,t,i){let s=!1,o=!1;if(this._currentMovingPoint&&this._startMovingPoint){if(this.isFixed()){const e=this._correctFixedPoint((0,r.ensureDefined)(this._fixedPoint));e.didCorrect&&(this._fixedPoint=e.point,this._fixedPointsChanged.fire())}else{const e=(0,r.ensureDefined)(this._currentMovingPoint.logical),t=(0, r.ensureDefined)(this._startMovingPoint.logical);s=e.index!==t.index,o=e.price!==t.price;if(this._correctPoints(this._points,i)){n.emit("drawing_event",this._id,"move"),n.emit("drawing_event",this._id,"points_changed");for(let e=0;e0&&(this._points=e)}restorePoints(e,t,i){const s=this._timePoint.length>0&&!(0,P.deepEquals)(this._timePoint,e)[0];this._timePoint=(0,c.deepCopy)(e),this._points=t,i||this.denormalizeTimePoints(),s&&this._normalizedPointsChanged.fire()}restorePositionPercents(e){this._positionPercents=e}calcIsActualSymbol(){const e=this.ownerSource();if(null===e)this._isActualSymbol=!1;else{const t=(0,r.ensureNotNull)(e.symbolSource());this._migrateSymbolProperty() ;const i=this._properties.childs().symbol,s=i.value();if(this._isActualSymbol=t.symbolSameAsCurrent(s),this._isActualSymbol){const e=t.symbol();(0,g.areEqualSymbols)(s,e)||(D.logWarn('Possible drawing "migrating" detected from "'+s+'" to "'+e+'"'),D.logWarn("Series symbolInfo: "+JSON.stringify(t.symbolInfo())),D.logWarn(`${(new Error).stack}`)),i.setValue(e)}}this.calcIsActualInterval(),this.calcIsActualCurrency(),this.calcIsActualUnit(),this._onSourceHiddenMayChange()}calcIsActualCurrency(){const e=this.ownerSource();if(null===e)return void(this._isActualCurrency=!1);let t=this._properties.childs().currencyId.value();if(null!==t){const i=e.symbolSource();0,this._isActualCurrency=t===(0,m.symbolCurrency)(i.symbolInfo(),void 0,!0)}else{const t=(0,r.ensureNotNull)(e.symbolSource()).symbolInfo();this._isActualCurrency=null!==t&&(0,m.symbolCurrency)(t)===(0,m.symbolOriginalCurrency)(t)}this._onSourceHiddenMayChange()}calcIsActualUnit(){const e=this.ownerSource();if(null===e)return void(this._isActualUnit=!1);const t=this._properties.childs().unitId.value();if(null!==t)this._isActualUnit=t===(0,r.ensureNotNull)(e.symbolSource()).unit();else{const t=(0,r.ensureNotNull)(e.symbolSource()).symbolInfo(),i=this._model.unitConversionEnabled();this._isActualUnit=null!==t&&(0,m.symbolUnit)(t,i)===(0,m.symbolOriginalUnit)(t,i)}this._onSourceHiddenMayChange()}calcIsActualInterval(){const e=this._isActualInterval,t=this._properties,i=this._model.mainSeries();this._isActualInterval=(0,p.isActualInterval)(f.Interval.parse(i.interval()),t.childs().intervalsVisibilities),!this._isActualInterval&&this._model.selection().isSelected(this)&&this._model.selectionMacro((e=>e.removeSourceFromSelection(this))),this._isActualInterval!==e&&this._onIsActualIntervalChange.fire(),this._onSourceHiddenMayChange()}paneViews(e){if(this.isSourceHidden())return null;const t=this._getPaneViews(this.isMultiPaneAvailable()?e:void 0);if(null===t)return null;if(1===t.length)return[t[0]];const i=[];for(let e=t.length-1;e>=0;--e)i.push(t[e]);return i}priceAxisViews(e,t){if(t!==this.priceScale()||this.isSourceHidden())return null;if(this._model.lineBeingEdited()===this){const e=this._model.linePointBeingEdited();if(null!==e&&e0}pointAdded(){return this._pointAdded}pointChanged(){return this._pointChanged}pointToScreenPoint(e){var t;const i=this._model.timeScale(),r=this.priceScale(),n=null===(t=this.ownerSource())||void 0===t?void 0:t.firstValue();if(!r||r.isEmpty()||i.isEmpty()||null==n)return null;const o=i.indexToCoordinate(e.index),a=r.priceToCoordinate(e.price,n);return new s.Point(o,a)}screenPointToPoint(e){var t;const i=this.priceScale(),s=null===(t=this.ownerSource())||void 0===t?void 0:t.firstValue();if(null==s||!isFinite(s)||null===i)return null;const r=this._model.timeScale().coordinateToIndex(e.x);return{price:i.coordinateToPrice(e.y,s),index:r}}calcMiddlePoint(e,t){return new s.Point((e.x+t.x)/2,(e.y+t.y)/2)}addPoint(e,t,i){const s=this._preparePoint(e,t);return this._addPointIntenal(s,t,i)}addFixedPoint(e){return this._fixedPoint=e,this.calcPositionPercents(),!0}calcPositionPercents(){const e=this.priceScale();if(!e||e.isEmpty()||void 0===this._fixedPoint)return;const t=this._fixedPoint.x/this._model.timeScale().width(),i=this._fixedPoint.y/e.height() -;return this._positionPercents={x:t,y:i},this._positionPercents}restoreFixedPoint(){this._fixedPoint=this.fixedPoint()}propertiesChanged(e){this.calcIsActualInterval(),this.updateAllViewsAndRedraw((0,C.sourceChangeEvent)(this.id())),e||this._syncLineStyleIfNeeded(),void 0===this._pendingPropertyChangedEvent&&(this._pendingPropertyChangedEvent=setTimeout((()=>{this._pendingPropertyChangedEvent=void 0,n.emit("drawing_event",this._id,"properties_changed")}),0))}state(e){var t,i;const s={type:this.toolname,id:this.id(),state:this.properties().state(null!==(t=this._propertiesStateExclusions())&&void 0!==t?t:void 0),points:(0,c.deepCopy)(this._timePoint),zorder:this.zorder(),ownerSource:null===(i=this.ownerSource())||void 0===i?void 0:i.id()};return s.isSelectionEnabled=this.isSelectionEnabled(),s.userEditEnabled=this.userEditEnabled(),this.linkKey().value()&&(s.linkKey=this.linkKey().value()),delete s.state.points,e&&(s.indexes=this._points),this.isFixed()&&(s.positionPercents=this._positionPercents||this.calcPositionPercents()),"version"in this&&1!==this.version&&(s.version=this.version),s}updateAllViews(e){this._isActualSymbol&&this._isActualCurrency&&this._isActualUnit&&this._isActualInterval&&this._properties.childs().visible.value()&&(this._updateAllPaneViews(e),this._priceAxisViews.forEach((t=>t.update(e))),this._timeAxisViews.forEach((t=>t.update(e))))}updateAllViewsAndRedraw(e){this.updateAllViews(e),this._model.updateSource(this)}tags(){return[this.toolname]}properties(){return this._properties}restoreExternalPoints(e,t){if(this._timePoint=(0,c.deepCopy)(e.points),t.indexesChanged){if(this.properties().childs().interval.setValue(e.interval),!this.isActualSymbol())return this._clearServerPoints(),void this._normalizedPointsChanged.fire();this.createServerPoints()}else{const t=Math.min(this._points.length,e.points.length);for(let i=0;i{this._pendingPropertyChangedEvent=void 0,n.emit("drawing_event",this._id,"properties_changed")}),0))}state(e){var t,i;const s={type:this.toolname,id:this.id(),state:this.properties().state(null!==(t=this._propertiesStateExclusions())&&void 0!==t?t:void 0),points:(0,c.deepCopy)(this._timePoint),zorder:this.zorder(),ownerSource:null===(i=this.ownerSource())||void 0===i?void 0:i.id()};return s.isSelectionEnabled=this.isSelectionEnabled(),s.userEditEnabled=this.userEditEnabled(),this.linkKey().value()&&(s.linkKey=this.linkKey().value()),delete s.state.points,e&&(s.indexes=this._points),this.isFixed()&&(s.positionPercents=this._positionPercents||this.calcPositionPercents()),"version"in this&&1!==this.version&&(s.version=this.version),s}updateAllViews(e){this._isActualSymbol&&this._isActualCurrency&&this._isActualUnit&&this._isActualInterval&&this._properties.childs().visible.value()&&(this._updateAllPaneViews(e),this._priceAxisViews.forEach((t=>t.update(e))),this._timeAxisViews.forEach((t=>t.update(e))))}updateAllViewsAndRedraw(e){this.updateAllViews(e),this._model.updateSource(this)}tags(){return[this.toolname]}properties(){return this._properties}restoreExternalPoints(e,t){if(this._timePoint=(0,c.deepCopy)(e.points),t.indexesChanged){if(this.properties().childs().interval.setValue(e.interval),!this.isActualSymbol())return this._clearServerPoints(),void this._normalizedPointsChanged.fire();this.createServerPoints()}else{const t=Math.min(this._points.length,e.points.length);for(let i=0;i0&&this.normalizePoints(),!this._readyToCreatePointset())return;const e=this._pointsForPointset();if(0===e.length)return;++B,this._currentPointsetAndSymbolId={pointsetId:B,symbolId:(0,r.ensureNotNull)(this._model.mainSeries().seriesSource().symbolInstanceId())};const t=(0,u.getServerInterval)(this.properties().childs().interval.value());this._model.chartApi().createPointset(this._currentPointsetIdWithPrefix(),"turnaround",this._currentPointsetAndSymbolId.symbolId,t,e,this.onData.bind(this))}finish(){}realign(){var e;this.calcIsActualSymbol(),this.isFixed()||this.isSourceHidden()||this._model.lineBeingCreated()===this||this._model.lineBeingEdited()===this||(null===(e=this._currentPointsetAndSymbolId)||void 0===e?void 0:e.symbolId)===this._model.mainSeries().seriesSource().symbolInstanceId()||this._clearServerPoints(),this.updateAllViews((0,C.sourceChangeEvent)(this.id()))}stop(){this._clearServerPoints()}restart(){this.isFixed()||(this._currentPointsetAndSymbolId=null,this.createServerPoints())}isStarted(){return null!==this._currentPointsetAndSymbolId}convertYCoordinateToPriceForMoving(e,t){var i;const s=(0,r.ensureNotNull)(this.priceScale());if(s.isEmpty())return null;const n=this.ownerSource(),o=(0,r.ensure)(null===(i=n||t)||void 0===i?void 0:i.firstValue());return s.coordinateToPrice(e,o)}syncMultichartState(e){const t={points:this._timePoint,interval:this._model.mainSeries().interval()},i=this.linkKey().value();if(null!==i&&this.isSynchronizable()){const s={model:this._model,linkKey:i,symbol:this._model.mainSeries().symbol(),finalState:t,changes:e};(0,y.finishChangingLineTool)(s)}}enableCurrentIntervalVisibility(){const e=this.properties().childs().intervalsVisibilities.state();void 0!==e&&((0,p.makeIntervalsVisibilitiesVisibleAtInterval)(e,f.Interval.parse(this._model.mainSeries().interval())),this.properties().childs().intervalsVisibilities.mergeAndFire(e))}clonePositionOffset(){return this.isFixed()?{barOffset:0,xCoordOffset:20,yCoordOffset:20}:{barOffset:0,xCoordOffset:0,yCoordOffset:-40}}sharingMode(){return this._sharingMode}share(e){this.isSynchronizable()&&this._sharingMode.setValue(e)}syncLineStyleState(){const e=this.properties().state(this._syncStateExclusions);return delete e.interval,e.intervalsVisibilities=(0,p.mergeIntervalVisibilitiesDefaults)(e.intervalsVisibilities),e}moveLineTool(e){e.forEach(((e,t)=>this._setPoint(t,e))),this.normalizePoints()}_setPoint(e,t){this._points[e].index===t.index?this._points[e].price=t.price:this._points[e]=t,this._pointChanged.fire(e)}_correctLastPoint(e){return(0,P.clone)(e)}_pointsForPointset(){ return this._timePoint.map((e=>[e.time_t,e.offset]))}_snapPoint45Degree(e,t,i){const s=this._model.timeScale(),n=s.indexToCoordinate(t.index),o=s.indexToCoordinate(e.index)-n,a=(0,r.ensureNotNull)(this.priceScale()),l=t.price,c=e.price,h=(0,r.ensureNotNull)((0,r.ensureNotNull)(this.ownerSource()).firstValue()),d=a.priceToCoordinate(l,h),u=a.priceToCoordinate(c,h)-d,p=Math.round(Math.atan2(o,u)/Math.PI*4);if(2===Math.abs(p))i||(e.price=l);else if(0===Math.abs(p)||4===Math.abs(p))i||(e.index=t.index);else{const t=Math.sqrt(o*o+u*u),i=o<0?-1:1,r=u<0?-1:1;let l=Math.max(Math.abs(u),Math.abs(o));l/=l*Math.sqrt(2)/t;const c=Math.round(s.coordinateToIndex(n+l*i)),p=Math.abs(s.indexToCoordinate(c)-n),_=a.coordinateToPrice(d+p*r,h);e.index=c,e.price=_}}normalizePoint(e){return{...this._model.timeScale().normalizeBarIndex(e.index),price:e.price}}normalizePoints(){this._timePoint=[];for(let e=0;ethis._destroyPanePaneViews(t))),this._model.lightUpdate()}_getPaneViews(e){return this._paneViews.get(e)||null}_updateAllPaneViews(e){this._paneViews.forEach((t=>{for(const i of t)i.update(e)}))}_alignPointHorizontallyOrVertically(e){const t=(0,r.ensureNotNull)(this.pointToScreenPoint(e)),i=(0,r.ensureDefined)((0,r.ensureNotNull)(this._startMovingPoint).logical),s=(0,r.ensureDefined)((0,r.ensureNotNull)(this._startMovingPoint).screen),n=Math.abs(s.x-t.x),o=Math.abs(s.y-t.y);if(n<10&&o<10)return e;return{index:n=1?{didCorrect:!0,point:e.add(s)}:{didCorrect:!1,point:e}}_currentPointsetIdWithPrefix(){return"pointset_"+(0,r.ensureNotNull)(this._currentPointsetAndSymbolId).pointsetId}_clearServerPoints(){ null!==this._currentPointsetAndSymbolId&&this._model.chartApi().isConnected().value()&&this._model.chartApi().removePointset(this._currentPointsetIdWithPrefix()),this._currentPointsetAndSymbolId=null}_createPointProperty(e){const t=this._pointsProperty.childs().points;t.addProperty(""+e,{});const i=t[e];i.addChild("price",new I(this,e)),i.addChild("bar",new T.LineDataSourcePointIndexProperty(this,e))}_createPointsProperties(){this._pointsProperty=new(S()),this._pointsProperty.addChild("points",new(S()));for(let e=0;e=2&&this._snapTo45DegreesAvailable()&&this._snapPoint45Degree(i,this.points()[this.points().length-2]),i}_addPointIntenal(e,t,i){this._points.push(e);const s=this._points.length===this.pointsCount();return s?(this._lastPoint=null,i||(this.normalizePoints(),this.createServerPoints())):this._lastPoint=e,this._pointAdded.fire(this._points.length-1),s}_onSourceHiddenMayChange(){this._model.invalidate(d.InvalidationMask.validateAction((()=>{this!==this._model.lineBeingCreated()&&(this._isDestroyed||this.processHibernate())})))}_saveAlertIdInState(){return!0}_onPointsetUpdated(e){if(0!==e.length){for(let t=0;t0}_onAlertData(e){}_propertiesStateExclusions(){return null}_syncLineStyleIfNeeded(){const e=this.linkKey().value();!this._syncLineStyleMuted&&e&&(0,y.changeLineStyle)({linkKey:e,state:this.syncLineStyleState(),model:this._model})}_muteSyncLineStyle(){this._syncLineStyleMuted=!0} @@ -579,118 +579,118 @@ t.LineToolGannFixed=i(76124).LineToolGannFixed,t.LineToolGannFan=i(21608).LineTo t.LineToolPosition=i(37619).LineToolPosition,t.LineToolOrder=i(16907).LineToolOrder,t.LineToolHighlighter=i(25007).LineToolHighlighter},59656:(e,t,i)=>{"use strict";i.d(t,{lineToolsLocalizedNames:()=>r});var s=i(44352);const r={LineTool5PointsPattern:s.t(null,void 0,i(66527)),LineToolABCD:s.t(null,void 0,i(32852)),LineToolArc:s.t(null,void 0,i(45104)),LineToolArrow:s.t(null,void 0,i(96237)),LineToolArrowMarkDown:s.t(null,void 0,i(8738)),LineToolArrowMarkLeft:s.t(null,void 0,i(35062)),LineToolArrowMarkRight:s.t(null,void 0,i(92163)),LineToolArrowMarkUp:s.t(null,void 0,i(33196)),LineToolBalloon:s.t(null,void 0,i(40664)),LineToolComment:s.t(null,void 0,i(19372)),LineToolBarsPattern:s.t(null,void 0,i(98838)),LineToolBezierCubic:s.t(null,void 0,i(59368)),LineToolBezierQuadro:s.t(null,void 0,i(17206)),LineToolBrush:s.t(null,void 0,i(30251)),LineToolCallout:s.t(null,void 0,i(64149)),LineToolCircleLines:s.t(null,void 0,i(87761)),LineToolCypherPattern:s.t(null,void 0,i(27891)),LineToolDateAndPriceRange:s.t(null,void 0,i(79859)),LineToolDateRange:s.t(null,void 0,i(60222)),LineToolDisjointAngle:s.t(null,void 0,i(3556)),LineToolElliottCorrection:s.t(null,void 0,i(91215)),LineToolElliottDoubleCombo:s.t(null,void 0,i(80983)),LineToolElliottImpulse:s.t(null,void 0,i(74118)),LineToolElliottTriangle:s.t(null,void 0,i(95840)),LineToolElliottTripleCombo:s.t(null,void 0,i(66637)),LineToolEllipse:s.t(null,void 0,i(69418)),LineToolExtended:s.t(null,void 0,i(2578)),LineToolFibChannel:s.t(null,void 0,i(82719)),LineToolFibCircles:s.t(null,void 0,i(64192)),LineToolFibRetracement:s.t(null,void 0,i(63835)),LineToolFibSpeedResistanceArcs:s.t(null,void 0,i(18072)),LineToolFibSpeedResistanceFan:s.t(null,void 0,i(20877)),LineToolFibSpiral:s.t(null,void 0,i(76783)),LineToolFibTimeZone:s.t(null,void 0,i(89037)),LineToolFibWedge:s.t(null,void 0,i(72489)),LineToolFlagMark:s.t(null,void 0,i(55678)),LineToolImage:s.t(null,void 0,i(23450)),LineToolFlatBottom:s.t(null,void 0,i(29230)),LineToolAnchoredVWAP:s.t(null,void 0,i(61704)),LineToolGannComplex:s.t(null,void 0,i(66321)),LineToolGannFixed:s.t(null,void 0,i(87107)),LineToolGannFan:s.t(null,void 0,i(68102)),LineToolGannSquare:s.t(null,void 0,i(81180)),LineToolHeadAndShoulders:s.t(null,void 0,i(42616)),LineToolHorzLine:s.t(null,void 0,i(60049)),LineToolHorzRay:s.t(null,void 0,i(76604)),LineToolIcon:s.t(null,void 0,i(26579)),LineToolEmoji:s.t(null,void 0,i(85223)),LineToolSticker:s.t(null,void 0,i(84573)),LineToolInsidePitchfork:s.t(null,void 0,i(12354)),LineToolNote:s.t(null,void 0,i(75549)),LineToolNoteAbsolute:s.t(null,void 0,i(66828)),LineToolSignpost:s.t(null,void 0,i(68161)),LineToolParallelChannel:s.t(null,void 0,i(70394)),LineToolPitchfan:s.t(null,void 0,i(22293)),LineToolPitchfork:s.t(null,void 0,i(43852)),LineToolPolyline:s.t(null,void 0,i(53047)),LineToolPath:s.t(null,void 0,i(34402)),LineToolPrediction:s.t(null,void 0,i(36972)),LineToolPriceLabel:s.t(null,void 0,i(95921)),LineToolArrowMarker:s.t(null,void 0,i(82473)),LineToolPriceRange:s.t(null,void 0,i(2032)), LineToolProjection:s.t(null,void 0,i(87086)),LineToolRay:s.t(null,void 0,i(50470)),LineToolRectangle:s.t(null,void 0,i(328)),LineToolCircle:s.t(null,void 0,i(90068)),LineToolRegressionTrend:s.t(null,void 0,i(35001)),LineToolRiskRewardLong:s.t(null,void 0,i(44604)),LineToolRiskRewardShort:s.t(null,void 0,i(37819)),LineToolFixedRangeVolumeProfile:s.t(null,{context:"study"},i(40434)),LineToolAnchoredVolumeProfile:s.t(null,{context:"study"},i(59791)),LineToolRotatedRectangle:s.t(null,void 0,i(9998)),LineToolSchiffPitchfork:s.t(null,void 0,i(18559)),LineToolSchiffPitchfork2:s.t(null,void 0,i(98114)),LineToolSineLine:s.t(null,void 0,i(69502)),LineToolText:s.t(null,{context:"tool"},i(20936)),LineToolTextAbsolute:s.t(null,void 0,i(94782)),LineToolThreeDrivers:s.t(null,void 0,i(98538)),LineToolTimeCycles:s.t(null,void 0,i(95005)),LineToolTrendAngle:s.t(null,void 0,i(94770)),LineToolTrendBasedFibExtension:s.t(null,void 0,i(15501)),LineToolTrendBasedFibTime:s.t(null,void 0,i(31196)),LineToolTrendLine:s.t(null,void 0,i(23104)),LineToolInfoLine:s.t(null,void 0,i(27677)),LineToolTriangle:s.t(null,void 0,i(29245)),LineToolTrianglePattern:s.t(null,void 0,i(12390)),LineToolVertLine:s.t(null,void 0,i(56211)),LineToolCrossLine:s.t(null,void 0,i(60997)),LineToolHighlighter:s.t(null,void 0,i(31895)),LineToolPriceNote:s.t(null,void 0,i(28625)),LineToolVbPFixed:s.t(null,void 0,i(18426))};r.LineToolGhostFeed=s.t(null,void 0,i(7914))},92249:(e,t,i)=>{"use strict";i.r(t),i.d(t,{cloneLineTool:()=>ue,createLineTool:()=>se,createLineToolProperties:()=>ne,createStudyLineToolProperties:()=>oe,getNewToolProperties:()=>Q,initAllLineToolsFromContent:()=>ie,initLineTool:()=>te,isLineTool:()=>le,isStudyLineTool:()=>ce,isTrading:()=>he,lineToolByLinkKey:()=>pe,prepareLineToolPropertiesByOwnerSource:()=>re,setNewToolProperties:()=>X,supportsPhantomMode:()=>ae,tryFindStudyLineToolNameByStudyId:()=>de,unsetNewToolProperties:()=>J});var s=i(50151),r=i(86441),n=i(4949),o=i(4063),a=i(13087),l=i(56954),c=i.t(l,2),h=i(61401),d=i(70826),u=i(42856),p=i(76949),_=i(68806),m=i(1722),g=i(46100);const f=(0,d.studyIdString)("RegressionTrend","tv-basicstudies");function v(e){return void 0!==e.startPrice&&void 0!==e.endPrice}function S(e,t,i,s){return t.styles&&(y(t.styles.baseLine),y(t.styles.downLine),y(t.styles.upLine)),t}function y(e){void 0!==e&&void 0!==e.visible&&(e.display=e.visible?15:0,delete e.visible)}class b extends o.StudyLineDataSource{constructor(e,t,r,n,o){r=null!=r?r:(0,s.ensureNotNull)(e.studyMetaInfoRepository().findByIdSync({type:"java",studyId:f}));super(e,r,"linreg_",null!=t?t:b.createProperties(e),n,o),this.version=2,this._trendData=null,i.e(1583).then(i.bind(i,5374)).then((e=>{this._setPaneViews([new e.RegressionTrendPaneView(this,this._model)])}))}formatter(){throw new Error("This method should never be called")}pointsCount(){return 2}clearData(){this._trendData=null,super.clearData()}state(e){var t;const i=super.state(e);return e?{...i,nonseriesdata:null!==(t=this._trendData)&&void 0!==t?t:void 0}:i}restoreData(e){var t;super.restoreData(e), this._trendData=null!==(t=e.nonseriesdata)&&void 0!==t?t:null}startIndex(){if(null===this._trendData||null===this._indexes)return null;const e=this._indexes[this._trendData.startIndex];return e!==h.INVALID_TIME_POINT_INDEX?e:null}endIndex(){if(null===this._trendData||null===this._indexes)return null;const e=this._indexes[this._trendData.endIndex];return e!==h.INVALID_TIME_POINT_INDEX?e:null}baseLine(){return null===this._trendData?null:this._trendData.baseLine}downLine(){return null===this._trendData?null:this._trendData.downLine}upLine(){return null===this._trendData?null:this._trendData.upLine}pearsons(){return null===this._trendData?null:this._trendData.pearsons}recalcStudyIfNeeded(){this._onStudyInputsMayChange()}cloneable(){return!1}static createProperties(e,t){const i=u.StudyMetaInfo.getStudyPropertyRootNameById(f),r=(0,s.ensureNotNull)(e.studyMetaInfoRepository().findByIdSync({type:"java",studyId:f})),n=(0,g.createDefaultsState)(!0,i,[],e.studyVersioning());return this.createRegressionTrendPropertiesFromStudyMetaInfoAndState(r,r,(0,m.merge)((0,m.clone)(n),null!=t?t:{}),e.studyVersioning())}static createRegressionTrendPropertiesFromStudyMetaInfoAndState(e,t,i,s){const r=(0,p.prepareStudyPropertiesForLoadChart)(e,t,i,s,S);return this._configureProperties(r),r}static studyId(){return f}_studyInputs(e){(0,s.assert)(2===e.length,"all the line tool points should be defined");const[t,i]=e;if(t.index===i.index)return null;const r=this._getPointTime(t.index<=i.index?t:i,!0),n=this._getPointTime(i.index>=t.index?i:t,!0);return null===r||null===n?(this._subscribeApplyInputsOnSeriesCompleted(),null):{...this.properties().childs().inputs.state(),"first bar time":1e3*r,"last bar time":1e3*n}}_onDataUpdated(e,t,i){null!==t&&(t.indexes_replace||(this._trendData=t.data),"nochange"!==i&&(this._indexes=i),super._onDataUpdated(e,t,i))}_isReady(){return null!==this._trendData&&void 0!==this._trendData.startIndex&&void 0!==this._trendData.endIndex&&v(this._trendData.upLine)&&v(this._trendData.baseLine)&&v(this._trendData.downLine)}_updateAnchorsPrice(){if(!this._trendData||(0,m.isNaN)(this._trendData.baseLine.startPrice)||(0,m.isNaN)(this._trendData.baseLine.endPrice))return;const{startPrice:e,endPrice:t}=this._trendData.baseLine;2===this._points.length&&(this._points[0].price=(0,s.ensureDefined)(e),this._points[1].price=(0,s.ensureDefined)(t),this._timePoint[0].price=(0,s.ensureDefined)(e),this._timePoint[1].price=(0,s.ensureDefined)(t))}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(6196),i.e(5871),i.e(3986),i.e(8167),i.e(607)]).then(i.bind(i,41109))).RegressionTrendDefinitionsViewModel}static _configureProperties(e){super._configureProperties(e);const t=e.childs().styles.childs(),i=[t.upLine.childs().linewidth,t.downLine.childs().linewidth,t.baseLine.childs().linewidth];e.addChild("linesWidths",new _.LineToolWidthsProperty(i))}}var w=i(58229);const P=(0,d.studyIdString)("VbPFixed","tv-basicstudies");class C extends w.LineToolVbPFixed{constructor(e,t,i,s,r){ -const n=i||e.studyMetaInfoRepository().findByIdSync({type:"java",studyId:P});super(e,t,n,s,r)}calcIsActualSymbol(){o.StudyLineDataSource.prototype.calcIsActualSymbol.apply(this)}boundToSymbol(){return!0}isSynchronizable(){return this.priceScale()===this._model.mainSeries().priceScale()}static studyId(){return P}static createProperties(e,t){const i=u.StudyMetaInfo.getStudyPropertyRootNameById(P),r=(0,s.ensureNotNull)(e.studyMetaInfoRepository().findByIdSync({type:"java",studyId:P})),n=(0,g.createDefaultsState)(!0,i,[],e.studyVersioning());return this.createPropertiesFromStudyMetaInfoAndState(r,r,(0,m.merge)((0,m.clone)(n),null!=t?t:{}),e.studyVersioning())}static createPropertiesFromStudyMetaInfoAndState(e,t,i,s){const r=(0,p.prepareStudyPropertiesForLoadChart)(e,t,i,s);return this._configureProperties(r),r}}var x=i(97145),T=(i(14483),i(59452)),I=i.n(T),M=i(34256),L=i(45802);class A extends L.StudyPriceAxisView{_showPaneLabel(){return this._visible()}_showAxisLabel(){return this._visible()}_visible(){const e=this._source.properties().childs().styles.childs()[this._data.plotIndex].childs().display.value();return this._source.properties().childs().axisLabelVisible.value()&&Boolean(4&e)}}var k=i(39871);class D extends k.StudyPlotPaneView{constructor(e,t,i,s){super(e,t,i,s),this._line=e}_updateImplFull(){return super._updateImplFull(!0),!1}_updateImplLight(){this._updateImplFull()}}var V,E=i(59224);!function(e){e.StudyLineTool="StudyLineTool"}(V||(V={}));var B=i(98098),R=(i(54358),i(28558)),N=i(3308),O=i(86094);class F extends o.StudyLineDataSource{lastValueData(e,t,i){const r={noData:!0},n=this.priceScale();if(this._model.timeScale().isEmpty()||null===this.priceScale()||null===n||n.isEmpty()||this.plots().isEmpty())return r;const o=this._model.timeScale().visibleBarsStrictRange();if(null===o)return r;const a=this._studyProps();if(!a.childs().visible.value())return r;const l=this.plots().search(o.lastBar(),O.PlotRowSearchMode.NearestLeft,1);if(null===l)return r;const c=o.contains(l.index),h=!t&&c?l:(0,s.ensureNotNull)(this.plots().last()),d=this.metaInfo().plots.findIndex((t=>t.id===e));if(d<0||!h||!(0,N.default)(h.value[d+1]))return r;const u=h.value[d+1];if(null==u)return r;const p=(0,s.ensureDefined)(a.childs().styles.child(e)),_=(0,s.ensureNotNull)(this.firstValue()),m=n.priceToCoordinate(u,_);return{...n.getFormattedValues(u,_),noData:!1,price:u,color:p.childs().color.value(),coordinate:m,floatCoordinate:m,index:h.index}}priceLabelText(e){const t=(0,s.ensureDefined)(this._metaInfo.styles);return(0,s.ensureDefined)(t[e]).title}offset(e){return 0}getMinFirstBarIndexForPlot(){return-1/0}isPlotVisibleAt(e,t){return(this._studyProps().childs().styles.childs()[e].childs().display.value()&t)===t}_studyProps(){return this.properties()}}var W=i(43493);const H=(0,E.getLogger)("Chart.AnchoredVWAP"),z=(0,d.studyIdString)("AnchoredVWAP","tv-basicstudies");function U(e,t,i,r){return"calculate_stDev"in(0,s.ensureDefined)(e.inputs)||void 0===r.inputs.find((e=>"calculate_stDev"===e.id))||((0, +const n=i||e.studyMetaInfoRepository().findByIdSync({type:"java",studyId:P});super(e,t,n,s,r)}calcIsActualSymbol(){o.StudyLineDataSource.prototype.calcIsActualSymbol.apply(this)}boundToSymbol(){return!0}isSynchronizable(){return this.priceScale()===this._model.mainSeries().priceScale()}static studyId(){return P}static createProperties(e,t){const i=u.StudyMetaInfo.getStudyPropertyRootNameById(P),r=(0,s.ensureNotNull)(e.studyMetaInfoRepository().findByIdSync({type:"java",studyId:P})),n=(0,g.createDefaultsState)(!0,i,[],e.studyVersioning());return this.createPropertiesFromStudyMetaInfoAndState(r,r,(0,m.merge)((0,m.clone)(n),null!=t?t:{}),e.studyVersioning())}static createPropertiesFromStudyMetaInfoAndState(e,t,i,s){const r=(0,p.prepareStudyPropertiesForLoadChart)(e,t,i,s);return this._configureProperties(r),r}}var x=i(97145),T=(i(14483),i(59452)),I=i.n(T),M=i(34256),L=i(45802);class A extends L.StudyPriceAxisView{_showPaneLabel(){return this._visible()}_showAxisLabel(){return this._visible()}_visible(){const e=this._source.properties().childs().styles.childs()[this._data.plotIndex].childs().display.value();return this._source.properties().childs().axisLabelVisible.value()&&Boolean(4&e)}}var k=i(39871);class D extends k.StudyPlotPaneView{constructor(e,t,i,s){super(e,t,i,s),this._line=e}_updateImplFull(){return super._updateImplFull(!0),!1}_updateImplLight(){this._updateImplFull()}}var E,V=i(59224);!function(e){e.StudyLineTool="StudyLineTool"}(E||(E={}));var B=i(98098),R=(i(54358),i(28558)),N=i(3308),O=i(86094);class F extends o.StudyLineDataSource{lastValueData(e,t,i){const r={noData:!0},n=this.priceScale();if(this._model.timeScale().isEmpty()||null===this.priceScale()||null===n||n.isEmpty()||this.plots().isEmpty())return r;const o=this._model.timeScale().visibleBarsStrictRange();if(null===o)return r;const a=this._studyProps();if(!a.childs().visible.value())return r;const l=this.plots().search(o.lastBar(),O.PlotRowSearchMode.NearestLeft,1);if(null===l)return r;const c=o.contains(l.index),h=!t&&c?l:(0,s.ensureNotNull)(this.plots().last()),d=this.metaInfo().plots.findIndex((t=>t.id===e));if(d<0||!h||!(0,N.default)(h.value[d+1]))return r;const u=h.value[d+1];if(null==u)return r;const p=(0,s.ensureDefined)(a.childs().styles.child(e)),_=(0,s.ensureNotNull)(this.firstValue()),m=n.priceToCoordinate(u,_);return{...n.getFormattedValues(u,_),noData:!1,price:u,color:p.childs().color.value(),coordinate:m,floatCoordinate:m,index:h.index}}priceLabelText(e){const t=(0,s.ensureDefined)(this._metaInfo.styles);return(0,s.ensureDefined)(t[e]).title}offset(e){return 0}getMinFirstBarIndexForPlot(){return-1/0}isPlotVisibleAt(e,t){return(this._studyProps().childs().styles.childs()[e].childs().display.value()&t)===t}_studyProps(){return this.properties()}}var W=i(43493);const H=(0,V.getLogger)("Chart.AnchoredVWAP"),z=(0,d.studyIdString)("AnchoredVWAP","tv-basicstudies");function U(e,t,i,r){return"calculate_stDev"in(0,s.ensureDefined)(e.inputs)||void 0===r.inputs.find((e=>"calculate_stDev"===e.id))||((0, s.ensureDefined)(t.inputs).calculate_stDev=!1),t.styles&&(j(t.styles.VWAP),j(t.styles.UpperBand),j(t.styles.LowerBand),j(t.styles.UpperBand_2),j(t.styles.LowerBand_2),j(t.styles.UpperBand_3),j(t.styles.LowerBand_3)),t}function j(e){void 0!==e&&void 0!==e.visible&&(e.display=e.visible?15:0,delete e.visible)}class G extends F{constructor(e,t,i,r,n){i=i||(0,s.ensureNotNull)(e.studyMetaInfoRepository().findByIdSync({type:"java",studyId:z}));const o=null!=t?t:G.createProperties(e);super(e,i,"anchoredvwap",o,r,n);const[a,l,c,h,d,u,p]=this.metaInfo().plots,_=e.mainSeries(),m=[new D(this,_,e,a.id)];l&&c&&(m.push(new k.StudyPlotPaneView(this,_,e,l.id)),m.push(new k.StudyPlotPaneView(this,_,e,c.id))),h&&d&&u&&p&&(m.push(new k.StudyPlotPaneView(this,_,e,h.id)),m.push(new k.StudyPlotPaneView(this,_,e,d.id)),m.push(new k.StudyPlotPaneView(this,_,e,u.id)),m.push(new k.StudyPlotPaneView(this,_,e,p.id))),this._properties.childs().areaBackground&&m.splice(0,0,new B.AreaBackgroundPaneView(this,e)),this._priceAxisViews=this.metaInfo().plots.map((e=>new A(this,{plotIndex:e.id}))),m.push(...this._priceAxisViews.map((e=>new W.PanePriceAxisView(e,this,this._model)))),this._anchorPriceCalculated=!1,this._onInputsReadyCallbacks=[],this._setPaneViews(m),e.properties().childs().scalesProperties.childs().showStudyLastValue.subscribe(this,this._onShowStudyLastValueChanged),o.onRestoreFactoryDefaults().subscribe(this,this._onRestoreFactoryDefaults)}destroy(){this.properties().onRestoreFactoryDefaults().unsubscribeAll(this),this.model().properties().childs().scalesProperties.childs().showStudyLastValue.unsubscribeAll(this),this._onInputsReadyCallbacks=[],super.destroy()}canHasAlert(){return!0}pointsCount(){return 1}updateAllViews(e){super.updateAllViews(e),this._priceAxisViews.forEach((t=>t.update(e)))}firstValue(){return this._model.mainSeries().firstValue()}priceRange(e,t){if(!this._isReady()||this.isSourceHidden())return null;const i=this.plots().minMaxOnRangeCached(e,t,[{name:this.metaInfo().plots[0].id,offset:0}]);if(null===i)return null;const r=(0,s.ensureNotNull)(this.priceScale());return r.isLog()?new M.PriceRange(r.priceToLogical(i.min),r.priceToLogical(i.max)):new M.PriceRange(i.min,i.max)}isIncludedInAutoScale(){return!0}restoreData(e){super.restoreData(e),void 0!==e.data&&(this._anchorPriceCalculated=!0)}properties(){return super.properties()}sourceId(){return this._studyId()}hasStateForAlert(){return!1}alertCreationAvailable(){return new x.WatchedValue(!this.hasAlert.value()&&this.hasStateForAlert()).readonly()}stateForAlert(){throw new Error("Not implemented")}inputsForAlertState(){null===this._inputs&&H.logError("Could not get inputsForAlertState if VWAP has no inputs");const{start_time:e,source:t}=this.inputs();return{start_time:e,source:t}}inputs(){return(0,s.ensureNotNull)(this._inputs)}idForAlert(){return super.idForAlert()}defaultPlotIdForAlert(){return this.metaInfo().plots[0].id}static createProperties(e,t){const i=u.StudyMetaInfo.getStudyPropertyRootNameById(z),r=(0,s.ensureNotNull)(e.studyMetaInfoRepository().findByIdSync({ type:"java",studyId:z})),n=(0,g.createDefaultsState)(!0,i,[],e.studyVersioning());return this.createPropertiesFromStudyMetaInfoAndState(r,r,(0,m.merge)((0,m.clone)(n),null!=t?t:{}),e.studyVersioning())}static studyId(){return z}static createPropertiesFromStudyMetaInfoAndState(e,t,i,s){const r=(0,p.prepareStudyPropertiesForLoadChart)(e,t,i,s,U);return this._configureProperties(r),r}_onPointsetUpdated(e){super._onPointsetUpdated(e),this._onStudyInputsMayChange()}_studyInputs(e){(0,s.assert)(1===e.length,"all the line tool points should be defined");const t=e[0],i=this._getPointTime(t,!1);return null===i?(this._subscribeApplyInputsOnSeriesCompleted(),null):{...this.properties().childs().inputs.state(["start_time"]),start_time:1e3*i}}_isReady(){return super._isReady()&&(null!==this._inputs||this._anchorPriceCalculated)&&this.model().lineBeingEdited()!==this}_onDataCleared(){super._onDataCleared(),this._anchorPriceCalculated=!1}_onInputsChanged(){if(super._onInputsChanged(),null!==this._inputs){for(const e of this._onInputsReadyCallbacks)try{e(this._inputs)}catch(e){H.logError(e.stack||e.message)}this._onInputsReadyCallbacks=[]}}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,59973))).AnchoredVWAPDefinitionsViewModel}_updateAnchorsPrice(e){if(!e&&(this._anchorPriceCalculated||!this.isActualSymbol()))return;const t=this.firstValue(),i=this.points();if(null===t||0===i.length)return;const s=i[0].index,r=this.plots().valueAt(s);if(null===r)return;const n=r[1];null!=n&&(this._points[0].price=n,this._timePoint[0].price=n,this._anchorPriceCalculated=!0)}_synchronizeAlert(e){this._onInputsReady((()=>super._synchronizeAlert(e)))}static _configureProperties(e){super._configureProperties(e),e.hasChild("axisLabelVisible")||e.addChild("axisLabelVisible",new(I())(true));const t=e.childs().styles.childs().VWAP.childs().linewidth,i=e.childs().styles.childs().VWAP.childs().color;e.addChild("linesWidths",new _.LineToolWidthsProperty([t])),e.addChild("linesColors",new _.LineToolColorsProperty([i]))}_onInputsReady(e){null!==this._inputs?e(this._inputs):this._onInputsReadyCallbacks.push(e)}_onShowStudyLastValueChanged(){this._priceAxisViews.forEach((e=>e.update((0,R.sourceChangeEvent)(this.id())))),this.model().updateSource(this)}_onRestoreFactoryDefaults(){this.properties().childs().axisLabelVisible.setValue(true)}}var q=i(87564),$=i(15367);function Y(e){for(const t of Object.keys(e))TradingView[t]=e[t]}Y(c),Y({LineToolRegressionTrend:b,LineToolVbPFixed:w.LineToolVbPFixed,LineToolFixedRangeVolumeProfile:C,LineToolAnchoredVWAP:G});const K={};Object.assign(K,c);let Z=null;function X(e,t,i){return null!==Z&&Z.tool===e&&Z.toolData===t||(Z={properties:ne(e,void 0,i),tool:e,toolData:t}),Z.properties}function J(){Z=null}function Q(e){return null!==Z&&Z.tool===e?Z.properties:null}const ee=new Map([["LineToolPriceNote",async()=>(await Promise.resolve().then(i.bind(i,32831))).LineToolPriceNote]]);async function te(e){if(K[e])return;if(!K.hasOwnProperty(e))return ;const t=(0,s.ensureDefined)(ee.get(e));K[e]=await t()}async function ie(e){if(!e)return;const t=new Set;("charts"in e?e.charts:[e]).forEach((e=>{e.panes.forEach((e=>{e.sources.forEach((e=>{(0,$.isLineToolName)(e.type)&&t.add(e.type)}))}))})),await Promise.all(Array.from(t).map((e=>te(e))))}function se(e,t,i,r,n,o){let a;if((0,s.assert)((0,$.isLineToolName)(e),"Unknown line tool: "+e),n||i||(i=Q(e)||void 0),"LineToolVbPFixed"===e)a=new w.LineToolVbPFixed(t,i,(0,s.ensureDefined)(r),n,o);else if("LineToolAnchoredVolumeProfile"===e)a=new LineToolAnchoredVolumeProfile(t,i,(0,s.ensureDefined)(r),n,o);else if("LineToolFixedRangeVolumeProfile"===e)a=new C(t,i,(0,s.ensureDefined)(r),n,o);else if("LineToolRegressionTrend"===e)a=new b(t,i,(0,s.ensureDefined)(r),n,o);else if("LineToolAnchoredVWAP"===e)a=new G(t,i,(0,s.ensureDefined)(r),n,o);else{a=new((0,s.ensureDefined)(K[e]))(t,i,n,o)}return a.toolname=e,J(),a}function re(e,t){const i=(0,s.ensureNotNull)(t.symbolSource());e.childs().symbol.setValue(i.symbol()),i.model().currencyConversionEnabled()&&e.childs().currencyId.setValue(i.currency()),i.model().unitConversionEnabled()&&e.childs().unitId.setValue(i.unit()),e.childs().symbolStateVersion.setValue(2),e.childs().zOrderVersion.setValue(2)}function ne(e,t,i){if((0,s.assert)((0,$.isLineToolName)(e),`${e} should be name of the line tool`),"LineToolVbPFixed"===e)return w.LineToolVbPFixed.createProperties(i,t);if("LineToolAnchoredVolumeProfile"===e)return LineToolAnchoredVolumeProfile.createProperties(i,t);if("LineToolFixedRangeVolumeProfile"===e)return C.createProperties(i,t);if("LineToolRegressionTrend"===e)return b.createProperties(i,t);if("LineToolAnchoredVWAP"===e)return G.createProperties(i,t);return(0,s.ensureDefined)(K[e]).createProperties(t)}function oe(e,t,i,r,n){if((0,s.assert)((0,$.isStudyLineToolName)(e),`${e} should be name of the study line tool`),"LineToolVbPFixed"===e)return w.LineToolVbPFixed.createPropertiesFromStudyMetaInfoAndState(t,i,r,n);if("LineToolAnchoredVolumeProfile"===e)return LineToolAnchoredVolumeProfile.createPropertiesFromStudyMetaInfoAndState(t,i,r,n);if("LineToolFixedRangeVolumeProfile"===e)return C.createPropertiesFromStudyMetaInfoAndState(t,i,r,n);if("LineToolRegressionTrend"===e)return b.createRegressionTrendPropertiesFromStudyMetaInfoAndState(t,i,r,n);if("LineToolAnchoredVWAP"===e)return G.createPropertiesFromStudyMetaInfoAndState(t,i,r,n);throw new Error(`Property creation is not implemented for study line tool ${e}`)}function ae(e){(0,s.assert)((0,$.isLineToolName)(e),`${e} should be name of the line tool`);const t=c[e];return void 0!==t&&Boolean(t.supportPhantomMode)}function le(e){return e instanceof a.LineDataSource}function ce(e){return e instanceof o.StudyLineDataSource}function he(e){return e instanceof q.LineToolTrading}function de(e){let t=null;return e===b.studyId()?t="LineToolRegressionTrend":e===w.LineToolVbPFixed.studyId()?t="LineToolVbPFixed":e===C.studyId()&&(t="LineToolFixedRangeVolumeProfile"),t}function ue(e,t,i,o){const a=t.toolname,l=t.properties().state() ;l.intervalsVisibilities=(0,n.mergeIntervalVisibilitiesDefaults)(null==l?void 0:l.intervalsVisibilities);const c=ne(t.toolname,l,e);c.childs().visible.setValue(!0);const h=(0,s.ensureNotNull)(t.ownerSource()),d=se(a,e,c);void 0!==o&&d.setId(o),d.setOwnerSource(h),d.toolname=a;const u=d.clonePositionOffset();if(t.isFixed()){const e=(0,s.ensureDefined)(t.fixedPoint()),n=i?e.add(new r.Point(u.xCoordOffset,u.yCoordOffset)):e;d.addFixedPoint(n)}const p=t.normalizedPoints(),_=i?function(e,t,i){const r=(0,s.ensureNotNull)(t.priceScale()),n=(0,s.ensureNotNull)(t.firstValue());return e.map((e=>{const t=e.price,s=r.priceToCoordinate(t,n)+i.yCoordOffset,o=r.coordinateToPrice(s,n);return{time_t:e.time_t,price:o,offset:e.offset+i.barOffset}}))}(p,h,u):p,m=t.points();return d.restorePoints(_,m),d.cloneData&&d.cloneData(t),d.recalculateStateByData&&d.recalculateStateByData(),d}function pe(e,t){var i;return null!==(i=e.dataSources().find((e=>le(e)&&e.linkKey().value()===t)))&&void 0!==i?i:null}},23558:(e,t,i)=>{"use strict";var s=i(13087).LineDataSource,r=i(59452),n=i(46100).DefaultProperty;class o extends s{constructor(e,t,s,r){super(e,t||o.createProperties(),s,r),this.version=o.version,i.e(1583).then(i.bind(i,34658)).then((({NotePaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}pointsCount(){return 1}name(){return"Note"}getTooltipWidth(){return o.TOOLTIP_WIDTH}getTooltipPadding(){return o.TOOLTIP_PADDING}getTooltipLineSpacing(){return o.TOOLTIP_LINESPACING}template(){var e=super.template();return e.text=this.properties().childs().text.value(),e}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text)}static createProperties(e){void 0!==e&&void 0!==e.markerColor&&void 0===e.borderColor&&(e.borderColor=e.markerColor);var t=new n("linetoolnote",e);return this._configureProperties(t),t}state(e){var t=super.state(e);return e&&(t.state.fixedSize=!1),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,77420))).NoteDefinitionsViewModel}static _configureProperties(e){super._configureProperties(e),e.hasChild("text")||e.addChild("text",new r(i(44352).t(null,void 0,i(37229)))),e.addExclusion("text")}}o.TOOLTIP_WIDTH=300,o.TOOLTIP_PADDING=10,o.TOOLTIP_LINESPACING=5,o.version=1;class a extends o{constructor(e,t){super(e,t||a.createProperties())}title(){return i(44352).t(null,void 0,i(66828))}name(){return"Anchored Note"}isFixed(){return!0}hasEditableCoordinates(){return!1}static createProperties(e){var t=new n("linetoolnoteabsolute",e);return this._configureProperties(t),t}}t.LineToolNote=o,t.LineToolNoteAbsolute=a},16907:(e,t,i)=>{"use strict";var s=i(87564).LineToolTrading,r=i(71243).LineToolPriceAxisView,n=i(47043),o=i(13087).LineDataSource,a=i(46100).DefaultProperty;const l=i(14483);var c=i(98517).sortSourcesPreOrdered.LineToolOrder;function h(e){return null==e?e="":e+="",e}class d{constructor(e){this._line=e,this._data={bodyText:"order",quantityText:"0"},this._editable=!0,this._cancellable=!0, -this._mode="",this._direction="buy",this._active=!0}setMode(e){return this._mode=e,this._line.updateAllViewsAndRedraw(),this}setDirection(e){return this._direction=e,this._line.updateAllViewsAndRedraw(),this}setActive(e){return this._active=e,this._line.updateAllViewsAndRedraw(),this}setEditable(e){return this._editable=e,this._line.updateAllViewsAndRedraw(),this}getEditable(){return this._editable}setCancellable(e){return this._cancellable=e,this._line.updateAllViewsAndRedraw(),this}getCancellable(){return this._cancellable}hasMoveCallback(){return this.isFunction(this._onMoveCallback)}hasModifyCallback(){return this.isFunction(this._onModifyCallback)}getPrice(){return this._line.points().length>0?this._line.points()[0].price:this._line._timePoint.length>0?this._line._timePoint[0].price:void 0}setPrice(e){if(this._line.points().length>0){var t=this._line.points()[0];t.price=e,this._line._points[0]=t,this._line.normalizePoints(),this._line.updateAllViewsAndRedraw()}return this._line._timePoint.length>0&&(this._line._timePoint[0].price=e),this}getText(){return this._data.bodyText}setText(e){return this._data.bodyText=e||"",this._line.updateAllViewsAndRedraw(),this}setTooltip(e){return this._line.properties().tooltip.setValue(h(e)),this}getTooltip(){return this._line.properties().tooltip.value()}setModifyTooltip(e){return this._line.properties().modifyTooltip.setValue(h(e)),this}getModifyTooltip(){return this._line.properties().modifyTooltip.value()}setCancelTooltip(e){return this._line.properties().cancelTooltip.setValue(h(e)),this}getCancelTooltip(){return this._line.properties().cancelTooltip.value()}getQuantity(){return this._data.quantityText}setQuantity(e){return this._data.quantityText=e||"",this._line.updateAllViewsAndRedraw(),this}getExtendLeft(){var e=this._line.properties().extendLeft.value();return"inherit"===e?this._line._model.properties().tradingProperties.extendLeft.value():e}setExtendLeft(e){return this._line.properties().extendLeft.setValue(e),this}getLineLength(){var e=this._line.properties().lineLength.value();return"inherit"===e?this._line._model.properties().tradingProperties.lineLength.value():e}setLineLength(e){return this._line.properties().lineLength.setValue(Math.max(0,Math.min(e,100))),this}getLineColor(){var e=this._line.properties();return"buy"===this._direction?this._active?e.lineActiveBuyColor.value():e.lineInactiveBuyColor.value():this._active?e.lineActiveSellColor.value():e.lineInactiveSellColor.value()}setLineColor(e){return"buy"===this._direction?this._active?this.setLineActiveBuyColor(e):this.setLineInactiveBuyColor(e):this._active?this.setLineActiveSellColor(e):this.setLineInactiveSellColor(e),this}setLineActiveBuyColor(e){return this._line.properties().lineActiveBuyColor.setValue(e),this}setLineInactiveBuyColor(e){return this._line.properties().lineInactiveBuyColor.setValue(e),this}setLineActiveSellColor(e){return this._line.properties().lineActiveSellColor.setValue(e),this}setLineInactiveSellColor(e){return this._line.properties().lineInactiveSellColor.setValue(e),this} -getLineStyle(){var e=this._line.properties().lineStyle.value();return"inherit"===e?this._line._model.properties().tradingProperties.lineStyle.value():e}setLineStyle(e){return this._line.properties().lineStyle.setValue(e),this}getLineWidth(){var e=this._line.properties().lineWidth.value();return"inherit"===e?this._line._model.properties().tradingProperties.lineWidth.value():e}setLineWidth(e){return this._line.properties().lineWidth.setValue(e),this}getBodyBorderColor(){var e=this._line.properties();return"buy"===this._direction?this._active?e.bodyBorderActiveBuyColor.value():e.bodyBorderInactiveBuyColor.value():this._active?e.bodyBorderActiveSellColor.value():e.bodyBorderInactiveSellColor.value()}setBodyBorderColor(e){return"buy"===this._direction?this._active?this.setBodyBorderActiveBuyColor(e):this.setBodyBorderInactiveBuyColor(e):this._active?this.setBodyBorderActiveSellColor(e):this.setBodyBorderInactiveSellColor(e),this}setBodyBorderActiveBuyColor(e){return this._line.properties().bodyBorderActiveBuyColor.setValue(e),this}setBodyBorderInactiveBuyColor(e){return this._line.properties().bodyBorderInactiveBuyColor.setValue(e),this}setBodyBorderActiveSellColor(e){return this._line.properties().bodyBorderActiveSellColor.setValue(e),this}setBodyBorderInactiveSellColor(e){return this._line.properties().bodyBorderInactiveSellColor.setValue(e),this}getBodyBackgroundColor(){return n.getColorFromProperties(this._line.properties().bodyBackgroundColor,this._line.properties().bodyBackgroundTransparency)}setBodyBackgroundColor(e){return n.setColorToProperties(e,this._line.properties().bodyBackgroundColor,this._line.properties().bodyBackgroundTransparency),this}getBodyTextColor(){var e=this._line.properties();return"limit"===this._mode?this._active?e.bodyTextActiveLimitColor.value():e.bodyTextInactiveLimitColor.value():"stop"===this._mode?this._active?e.bodyTextActiveStopColor.value():e.bodyTextInactiveStopColor.value():"buy"===this._direction?this._active?e.bodyTextActiveBuyColor.value():e.bodyTextInactiveBuyColor.value():this._active?e.bodyTextActiveSellColor.value():e.bodyTextInactiveSellColor.value()}setBodyTextColor(e){return"limit"===this._mode?this._active?this.setBodyTextActiveLimitColor(e):this.setBodyTextInactiveLimitColor(e):"stop"===this._mode?this._active?this.setBodyTextActiveStopColor(e):this.setBodyTextInactiveStopColor(e):"buy"===this._direction?this._active?this.setBodyTextActiveBuyColor(e):this.setBodyTextInactiveBuyColor(e):this._active?this.setBodyTextActiveSellColor(e):this.setBodyTextInactiveSellColor(e),this}setBodyTextInactiveLimitColor(e){return this._line.properties().bodyTextInactiveLimitColor.setValue(e),this}setBodyTextActiveLimitColor(e){return this._line.properties().bodyTextActiveLimitColor.setValue(e),this}setBodyTextInactiveStopColor(e){return this._line.properties().bodyTextInactiveStopColor.setValue(e),this}setBodyTextActiveStopColor(e){return this._line.properties().bodyTextActiveStopColor.setValue(e),this}setBodyTextInactiveBuyColor(e){ -return this._line.properties().bodyTextInactiveBuyColor.setValue(e),this}setBodyTextActiveBuyColor(e){return this._line.properties().bodyTextActiveBuyColor.setValue(e),this}setBodyTextInactiveSellColor(e){return this._line.properties().bodyTextInactiveSellColor.setValue(e),this}setBodyTextActiveSellColor(e){return this._line.properties().bodyTextActiveSellColor.setValue(e),this}getBodyFont(){return n.getFontFromProperties(this._line.properties().bodyFontFamily,this._line.properties().bodyFontSize,this._line.properties().bodyFontBold,this._line.properties().bodyFontItalic)}setBodyFont(e){return n.setFontToProperties(e,this._line.properties().bodyFontFamily,this._line.properties().bodyFontSize,this._line.properties().bodyFontBold,this._line.properties().bodyFontItalic),this}getQuantityBorderColor(){var e=this._line.properties();return"buy"===this._direction?this._active?e.quantityBorderActiveBuyColor.value():e.quantityBorderInactiveBuyColor.value():this._active?e.quantityBorderActiveSellColor.value():e.quantityBorderInactiveSellColor.value()}setQuantityBorderColor(e){return"buy"===this._direction?this._active?this.setQuantityBorderActiveBuyColor(e):this.setQuantityBorderInactiveBuyColor(e):this._active?this.setQuantityBorderActiveSellColor(e):this.setQuantityBorderInactiveSellColor(e),this}setQuantityBorderActiveBuyColor(e){return this._line.properties().quantityBorderActiveBuyColor.setValue(e),this}setQuantityBorderInactiveBuyColor(e){return this._line.properties().quantityBorderInactiveBuyColor.setValue(e),this}setQuantityBorderActiveSellColor(e){return this._line.properties().quantityBorderActiveSellColor.setValue(e),this}setQuantityBorderInactiveSellColor(e){return this._line.properties().quantityBorderInactiveSellColor.setValue(e),this}getQuantityBackgroundColor(){var e=this._line.properties();return"buy"===this._direction?this._active?e.quantityBackgroundActiveBuyColor.value():e.quantityBackgroundInactiveBuyColor.value():this._active?e.quantityBackgroundActiveSellColor.value():e.quantityBackgroundInactiveSellColor.value()}setQuantityBackgroundColor(e){return"buy"===this._direction?this._active?this.setQuantityBackgroundActiveBuyColor(e):this.setQuantityBackgroundInactiveBuyColor(e):this._active?this.setQuantityBackgroundActiveSellColor(e):this.setQuantityBackgroundInactiveSellColor(e),this}setQuantityBackgroundActiveBuyColor(e){return this._line.properties().quantityBackgroundActiveBuyColor.setValue(e),this}setQuantityBackgroundInactiveBuyColor(e){return this._line.properties().quantityBackgroundInactiveBuyColor.setValue(e),this}setQuantityBackgroundActiveSellColor(e){return this._line.properties().quantityBackgroundActiveSellColor.setValue(e),this}setQuantityBackgroundInactiveSellColor(e){return this._line.properties().quantityBackgroundInactiveSellColor.setValue(e),this}getQuantityTextColor(){return n.getColorFromProperties(this._line.properties().quantityTextColor,this._line.properties().quantityTextTransparency)}setQuantityTextColor(e){ -return n.setColorToProperties(e,this._line.properties().quantityTextColor,this._line.properties().quantityTextTransparency),this}getQuantityFont(){return n.getFontFromProperties(this._line.properties().quantityFontFamily,this._line.properties().quantityFontSize,this._line.properties().quantityFontBold,this._line.properties().quantityFontItalic)}setQuantityFont(e){return n.setFontToProperties(e,this._line.properties().quantityFontFamily,this._line.properties().quantityFontSize,this._line.properties().quantityFontBold,this._line.properties().quantityFontItalic),this}getCancelButtonBorderColor(){var e=this._line.properties();return"buy"===this._direction?this._active?e.cancelButtonBorderActiveBuyColor.value():e.cancelButtonBorderInactiveBuyColor.value():this._active?e.cancelButtonBorderActiveSellColor.value():e.cancelButtonBorderInactiveSellColor.value()}setCancelButtonBorderColor(e){return"buy"===this._direction?this._active?this.setCancelButtonBorderActiveBuyColor(e):this.setCancelButtonBorderInactiveBuyColor(e):this._active?this.setCancelButtonBorderActiveSellColor(e):this.setCancelButtonBorderInactiveSellColor(e),this}setCancelButtonBorderActiveBuyColor(e){return this._line.properties().cancelButtonBorderActiveBuyColor.setValue(e),this}setCancelButtonBorderInactiveBuyColor(e){return this._line.properties().cancelButtonBorderInactiveBuyColor.setValue(e),this}setCancelButtonBorderActiveSellColor(e){return this._line.properties().cancelButtonBorderActiveSellColor.setValue(e),this}setCancelButtonBorderInactiveSellColor(e){return this._line.properties().cancelButtonBorderInactiveSellColor.setValue(e),this}getCancelButtonBackgroundColor(){return n.getColorFromProperties(this._line.properties().cancelButtonBackgroundColor,this._line.properties().cancelButtonBackgroundTransparency)}setCancelButtonBackgroundColor(e){return n.setColorToProperties(e,this._line.properties().cancelButtonBackgroundColor,this._line.properties().cancelButtonBackgroundTransparency),this}getCancelButtonIconColor(){var e=this._line.properties();return"buy"===this._direction?this._active?e.cancelButtonIconActiveBuyColor.value():e.cancelButtonIconInactiveBuyColor.value():this._active?e.cancelButtonIconActiveSellColor.value():e.cancelButtonIconInactiveSellColor.value()}setCancelButtonIconColor(e){return"buy"===this._direction?this._active?this.setCancelButtonIconActiveBuyColor(e):this.setCancelButtonIconInactiveBuyColor(e):this._active?this.setCancelButtonIconActiveSellColor(e):this.setCancelButtonIconInactiveSellColor(e),this}setCancelButtonIconActiveBuyColor(e){return this._line.properties().cancelButtonIconActiveBuyColor.setValue(e),this}setCancelButtonIconInactiveBuyColor(e){return this._line.properties().cancelButtonIconInactiveBuyColor.setValue(e),this}setCancelButtonIconActiveSellColor(e){return this._line.properties().cancelButtonIconActiveSellColor.setValue(e),this}setCancelButtonIconInactiveSellColor(e){return this._line.properties().cancelButtonIconInactiveSellColor.setValue(e),this}block(){this._blocked=!0,this._line.updateAllViewsAndRedraw() -}unblock(){this._blocked=!1,this._line.updateAllViewsAndRedraw()}getBlocked(){return this._blocked}isFunction(e){return"function"==typeof e}onCancel(e,t){return t?this.isFunction(t)&&(this._onCancelData=e,this._onCancelCallback=t):this.isFunction(e)&&(this._onCancelCallback=e),this}callOnCancel(){this.isFunction(this._onCancelCallback)&&this._onCancelCallback.call(this,this._onCancelData)}isOnCancelCallbackPresent(){return this.isFunction(this._onCancelCallback)}onModify(e,t){return t?this.isFunction(t)&&(this._onModifyData=e,this._onModifyCallback=t):this.isFunction(e)&&(this._onModifyCallback=e),this}callOnModify(){this.isFunction(this._onModifyCallback)&&this._onModifyCallback.call(this,this._onModifyData)}onMove(e,t){return t?this.isFunction(t)&&(this._onMoveData=e,this._onMoveCallback=t):this.isFunction(e)&&(this._onMoveCallback=e),this}callOnMove(){this.isFunction(this._onMoveCallback)&&this._onMoveCallback.call(this,this._onMoveData)}onMoving(e,t){return t?this.isFunction(t)&&(this._onMovingData=e,this._onMovingCallback=t):this.isFunction(e)&&(this._onMovingCallback=e),this}callOnMoving(){this.isFunction(this._onMovingCallback)&&this._onMovingCallback.call(this,this._onMovingData)}onContextMenu(e,t){return t?this.isFunction(t)&&(this._onContextMenuData=e,this._onContextMenuCallback=t):this.isFunction(e)&&(this._onContextMenuCallback=e),this}shouldShowContextMenu(){return this.isFunction(this._onContextMenuCallback)}callOnContextMenu(){if(this.isFunction(this._onContextMenuCallback))return this._onContextMenuCallback.call(this,this._onContextMenuData)}remove(){this._line._model.removeSource(this._line),delete this._line}}class u extends s{constructor(e,t){super(e,t||u.createProperties()),this._adapter=new d(this),this.setSelectionEnabled(!0),i.e(1583).then(i.bind(i,61144)).then((({OrderPaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}zorder(){return c}isSpeciallyZOrderedSource(){return!0}setPoint(e,t,i){this._points[e]=t,this.normalizePoints()}addPoint(e,t){return this._points.push(e),this._lastPoint=null,this.normalizePoints(),this.createServerPoints(),!0}name(){return"Order"}move(e,t,i,s){var r=this._startMovingPoint&&this._currentMovingPoint&&this._startMovingPoint.logical.price!==this._currentMovingPoint.logical.price;super.move(e,t,i,s),r&&this._adapter.callOnMoving()}endMoving(e){var t=this._startMovingPoint&&this._currentMovingPoint&&this._startMovingPoint.logical.price!==this._currentMovingPoint.logical.price;super.endMoving(),!e&&t&&this._adapter.callOnMove()}createPriceAxisView(e){var t={pointIndex:e,backgroundPropertyGetter:()=>this._adapter.getLineColor()};return this._priceAxisView=new r(this,t),this._priceAxisView}paneViews(){return TradingView.printing&&!l.enabled("snapshot_trading_drawings")?null:this._model.properties().tradingProperties.showOrders.value()?o.prototype.paneViews.call(this):null}priceAxisViews(e,t){ -return TradingView.printing&&!l.enabled("snapshot_trading_drawings")?null:this._model.properties().tradingProperties.showOrders.value()?o.prototype.priceAxisViews.call(this,e,t):null}adapter(){return this._adapter}hasContextMenu(){return this._adapter.shouldShowContextMenu()}contextMenuItems(){return this._adapter.callOnContextMenu()}movable(){return Boolean(this._adapter._onMoveCallback)}static createProperties(e){var t=new a("linetoolorder",e,!1,!1);return this._configureProperties(t),t}}t.LineToolOrder=u},87440:(e,t,i)=>{"use strict";i.d(t,{LineToolParallelChannel:()=>h});var s=i(50151),r=i(86441),n=i(46100),o=i(88348),a=i(13087),l=i(1722),c=i(97145);class h extends a.LineDataSource{constructor(e,t,s,r){super(e,t||h.createProperties(),s,r),this._alertCreationAvailable=new c.WatchedValue(super.alertCreationAvailable().value()&&this._isTimePointsValid()),this._priceAxisViews.push(this.createPriceAxisView(3)),this._coordOffsetWhileMovingOrChanging=null,this._pendingPriceOffset=null,i.e(1583).then(i.bind(i,26013)).then((({ParallelChannelPaneView:e})=>{this._setPaneViews([new e(this,this._model)])})),this._normalizedPointsChanged.subscribe(this,(()=>this._alertCreationAvailable.setValue(super.alertCreationAvailable().value()&&this._isTimePointsValid())))}alertCreationAvailable(){return this._alertCreationAvailable.readonly()}paneViews(e){return null!==this._pendingPriceOffset&&this._applyPendingPriceOffset(),super.paneViews(e)}setLastPoint(e,t){t&&t.shift()&&2===this.points().length&&this._snapPoint45Degree(e,this.points()[0]);const i=(0,l.clone)(e);return super.setLastPoint(e),i}startMoving(e,t,i,s){super.startMoving(e,t,i,s),this._coordOffsetWhileMovingOrChanging=this._findPixelsHeight()}endMoving(e,t,i){return this._coordOffsetWhileMovingOrChanging=null,super.endMoving(e,t,i)}startChanging(e,t){super.startChanging(e,t),this._coordOffsetWhileMovingOrChanging=this._findPixelsHeight()}endChanging(e,t,i){return this._coordOffsetWhileMovingOrChanging=null,super.endChanging(e,t,i)}restoreExternalPoints(e,t,i){const s=i?e.points:this._timePoint.map(((t,i)=>({price:t.price,offset:e.points[i].offset,time_t:e.points[i].time_t})));if(super.restoreExternalPoints({...e,points:s},t),t.pricesChanged&&this._points.length===s.length)for(let e=0;e=4)return;this._snapPointBeforeChange(e,t,i);const a=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[0])),l=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[1])),c=(0,s.ensureNotNull)(this.pointToScreenPoint(t)),h=(0,s.ensureNotNull)(this._coordOffsetWhileMovingOrChanging),d=(0,s.ensureNotNull)(this.priceScale()),u=(0,s.ensure)(null===(n=this.ownerSource())||void 0===n?void 0:n.firstValue());switch(e){case 0:super.setPoint(e,t,i),this._points[2].price=d.coordinateToPrice(c.y+h,u);break;case 1: -super.setPoint(e,t,i);break;case 2:super.setPoint(e,t,i),this._points[0].price=d.coordinateToPrice(c.y-h,u),this._points[0].index=t.index;break;case 3:this._points[1].price=d.coordinateToPrice(c.y-h,u),this._points[1].index=t.index;break;case 4:{const e=l.subtract(a),t=(c.x-a.x)/e.x,i=a.addScaled(e,t),s=c.y-i.y;this._points[2].price=d.coordinateToPrice(a.y+s,u);break}case 5:{const e=l.subtract(a),t=(c.x-a.x)/e.x,i=a.addScaled(e,t),s=c.y-i.y;this._points[0].price=d.coordinateToPrice(a.y+s,u),this._points[1].price=d.coordinateToPrice(l.y+s,u);break}}const p=this.linkKey().value();if(p&&!r&&e<4){const e=this._points.map((e=>e.price));(0,o.changeLineStyle)({model:this._model,linkKey:p,state:{prices:e}})}}state(e){const t=super.state(e);return this._pendingPriceOffset&&(t.priceOffset=this._pendingPriceOffset),t}restoreExternalState(e){const{prices:t,...i}=e;if(t&&this.isActualSymbol())for(let e=0;ee.index<=t.index?[e,t]:[t,e],s=i(t[0],t[1]),r=i(t[2],t[3]);let n,o,a,l;t[2].pricenull!==e))}_correctLastPoint(e){if(this._points.length<2||this._points[1].index===this._points[0].index)return e;const t=(0,s.ensureNotNull)(this.pointToScreenPoint(e)),i=(0, +this._mode="",this._direction="buy",this._active=!0}setMode(e){return this._mode=e,this._line.updateAllViewsAndRedraw(),this}setDirection(e){return this._direction=e,this._line.updateAllViewsAndRedraw(),this}setActive(e){return this._active=e,this._line.updateAllViewsAndRedraw(),this}setEditable(e){return this._editable=e,this._line.updateAllViewsAndRedraw(),this}getEditable(){return this._editable}setCancellable(e){return this._cancellable=e,this._line.updateAllViewsAndRedraw(),this}getCancellable(){return this._cancellable}hasMoveCallback(){return this.isFunction(this._onMoveCallback)}hasModifyCallback(){return this.isFunction(this._onModifyCallback)}getPrice(){return this._line.points().length>0?this._line.points()[0].price:this._line._timePoint.length>0?this._line._timePoint[0].price:void 0}setPrice(e){if(this._line.points().length>0){var t=this._line.points()[0];t.price=e,this._line._points[0]=t,this._line.normalizePoints(),this._line.updateAllViewsAndRedraw()}return this._line._timePoint.length>0&&(this._line._timePoint[0].price=e),this}getText(){return this._data.bodyText}setText(e){return this._data.bodyText=e||"",this._line.updateAllViewsAndRedraw(),this}setTooltip(e){return this._line.properties().tooltip.setValue(h(e)),this}getTooltip(){return this._line.properties().tooltip.value()}setModifyTooltip(e){return this._line.properties().modifyTooltip.setValue(h(e)),this}getModifyTooltip(){return this._line.properties().modifyTooltip.value()}setCancelTooltip(e){return this._line.properties().cancelTooltip.setValue(h(e)),this}getCancelTooltip(){return this._line.properties().cancelTooltip.value()}getQuantity(){return this._data.quantityText}setQuantity(e){return this._data.quantityText=e||"",this._line.updateAllViewsAndRedraw(),this}getExtendLeft(){var e=this._line.properties().extendLeft.value();return"inherit"===e?this._line._model.properties().tradingProperties.extendLeft.value():e}setExtendLeft(e){return this._line.properties().extendLeft.setValue(e),this}getLineLength(){var e=this._line.properties().lineLength.value();return"inherit"===e?this._line._model.properties().tradingProperties.lineLength.value():e}setLineLength(e,t="percentage"){const i=t&&"pixel"===t?e:Math.max(0,Math.min(e,100));return this._line.properties().lineLength.setValue(i),this._line.properties().lineLengthUnit.setValue(t),this}getLineLengthUnit(){return this._line.properties().lineLengthUnit.value()}getLineColor(){var e=this._line.properties();return"buy"===this._direction?this._active?e.lineActiveBuyColor.value():e.lineInactiveBuyColor.value():this._active?e.lineActiveSellColor.value():e.lineInactiveSellColor.value()}setLineColor(e){return"buy"===this._direction?this._active?this.setLineActiveBuyColor(e):this.setLineInactiveBuyColor(e):this._active?this.setLineActiveSellColor(e):this.setLineInactiveSellColor(e),this}setLineActiveBuyColor(e){return this._line.properties().lineActiveBuyColor.setValue(e),this}setLineInactiveBuyColor(e){return this._line.properties().lineInactiveBuyColor.setValue(e),this}setLineActiveSellColor(e){ +return this._line.properties().lineActiveSellColor.setValue(e),this}setLineInactiveSellColor(e){return this._line.properties().lineInactiveSellColor.setValue(e),this}getLineStyle(){var e=this._line.properties().lineStyle.value();return"inherit"===e?this._line._model.properties().tradingProperties.lineStyle.value():e}setLineStyle(e){return this._line.properties().lineStyle.setValue(e),this}getLineWidth(){var e=this._line.properties().lineWidth.value();return"inherit"===e?this._line._model.properties().tradingProperties.lineWidth.value():e}setLineWidth(e){return this._line.properties().lineWidth.setValue(e),this}getBodyBorderColor(){var e=this._line.properties();return"buy"===this._direction?this._active?e.bodyBorderActiveBuyColor.value():e.bodyBorderInactiveBuyColor.value():this._active?e.bodyBorderActiveSellColor.value():e.bodyBorderInactiveSellColor.value()}setBodyBorderColor(e){return"buy"===this._direction?this._active?this.setBodyBorderActiveBuyColor(e):this.setBodyBorderInactiveBuyColor(e):this._active?this.setBodyBorderActiveSellColor(e):this.setBodyBorderInactiveSellColor(e),this}setBodyBorderActiveBuyColor(e){return this._line.properties().bodyBorderActiveBuyColor.setValue(e),this}setBodyBorderInactiveBuyColor(e){return this._line.properties().bodyBorderInactiveBuyColor.setValue(e),this}setBodyBorderActiveSellColor(e){return this._line.properties().bodyBorderActiveSellColor.setValue(e),this}setBodyBorderInactiveSellColor(e){return this._line.properties().bodyBorderInactiveSellColor.setValue(e),this}getBodyBackgroundColor(){return n.getColorFromProperties(this._line.properties().bodyBackgroundColor,this._line.properties().bodyBackgroundTransparency)}setBodyBackgroundColor(e){return n.setColorToProperties(e,this._line.properties().bodyBackgroundColor,this._line.properties().bodyBackgroundTransparency),this}getBodyTextColor(){var e=this._line.properties();return"limit"===this._mode?this._active?e.bodyTextActiveLimitColor.value():e.bodyTextInactiveLimitColor.value():"stop"===this._mode?this._active?e.bodyTextActiveStopColor.value():e.bodyTextInactiveStopColor.value():"buy"===this._direction?this._active?e.bodyTextActiveBuyColor.value():e.bodyTextInactiveBuyColor.value():this._active?e.bodyTextActiveSellColor.value():e.bodyTextInactiveSellColor.value()}setBodyTextColor(e){return"limit"===this._mode?this._active?this.setBodyTextActiveLimitColor(e):this.setBodyTextInactiveLimitColor(e):"stop"===this._mode?this._active?this.setBodyTextActiveStopColor(e):this.setBodyTextInactiveStopColor(e):"buy"===this._direction?this._active?this.setBodyTextActiveBuyColor(e):this.setBodyTextInactiveBuyColor(e):this._active?this.setBodyTextActiveSellColor(e):this.setBodyTextInactiveSellColor(e),this}setBodyTextInactiveLimitColor(e){return this._line.properties().bodyTextInactiveLimitColor.setValue(e),this}setBodyTextActiveLimitColor(e){return this._line.properties().bodyTextActiveLimitColor.setValue(e),this}setBodyTextInactiveStopColor(e){return this._line.properties().bodyTextInactiveStopColor.setValue(e),this} +setBodyTextActiveStopColor(e){return this._line.properties().bodyTextActiveStopColor.setValue(e),this}setBodyTextInactiveBuyColor(e){return this._line.properties().bodyTextInactiveBuyColor.setValue(e),this}setBodyTextActiveBuyColor(e){return this._line.properties().bodyTextActiveBuyColor.setValue(e),this}setBodyTextInactiveSellColor(e){return this._line.properties().bodyTextInactiveSellColor.setValue(e),this}setBodyTextActiveSellColor(e){return this._line.properties().bodyTextActiveSellColor.setValue(e),this}getBodyFont(){return n.getFontFromProperties(this._line.properties().bodyFontFamily,this._line.properties().bodyFontSize,this._line.properties().bodyFontBold,this._line.properties().bodyFontItalic)}setBodyFont(e){return n.setFontToProperties(e,this._line.properties().bodyFontFamily,this._line.properties().bodyFontSize,this._line.properties().bodyFontBold,this._line.properties().bodyFontItalic),this}getQuantityBorderColor(){var e=this._line.properties();return"buy"===this._direction?this._active?e.quantityBorderActiveBuyColor.value():e.quantityBorderInactiveBuyColor.value():this._active?e.quantityBorderActiveSellColor.value():e.quantityBorderInactiveSellColor.value()}setQuantityBorderColor(e){return"buy"===this._direction?this._active?this.setQuantityBorderActiveBuyColor(e):this.setQuantityBorderInactiveBuyColor(e):this._active?this.setQuantityBorderActiveSellColor(e):this.setQuantityBorderInactiveSellColor(e),this}setQuantityBorderActiveBuyColor(e){return this._line.properties().quantityBorderActiveBuyColor.setValue(e),this}setQuantityBorderInactiveBuyColor(e){return this._line.properties().quantityBorderInactiveBuyColor.setValue(e),this}setQuantityBorderActiveSellColor(e){return this._line.properties().quantityBorderActiveSellColor.setValue(e),this}setQuantityBorderInactiveSellColor(e){return this._line.properties().quantityBorderInactiveSellColor.setValue(e),this}getQuantityBackgroundColor(){var e=this._line.properties();return"buy"===this._direction?this._active?e.quantityBackgroundActiveBuyColor.value():e.quantityBackgroundInactiveBuyColor.value():this._active?e.quantityBackgroundActiveSellColor.value():e.quantityBackgroundInactiveSellColor.value()}setQuantityBackgroundColor(e){return"buy"===this._direction?this._active?this.setQuantityBackgroundActiveBuyColor(e):this.setQuantityBackgroundInactiveBuyColor(e):this._active?this.setQuantityBackgroundActiveSellColor(e):this.setQuantityBackgroundInactiveSellColor(e),this}setQuantityBackgroundActiveBuyColor(e){return this._line.properties().quantityBackgroundActiveBuyColor.setValue(e),this}setQuantityBackgroundInactiveBuyColor(e){return this._line.properties().quantityBackgroundInactiveBuyColor.setValue(e),this}setQuantityBackgroundActiveSellColor(e){return this._line.properties().quantityBackgroundActiveSellColor.setValue(e),this}setQuantityBackgroundInactiveSellColor(e){return this._line.properties().quantityBackgroundInactiveSellColor.setValue(e),this}getQuantityTextColor(){ +return n.getColorFromProperties(this._line.properties().quantityTextColor,this._line.properties().quantityTextTransparency)}setQuantityTextColor(e){return n.setColorToProperties(e,this._line.properties().quantityTextColor,this._line.properties().quantityTextTransparency),this}getQuantityFont(){return n.getFontFromProperties(this._line.properties().quantityFontFamily,this._line.properties().quantityFontSize,this._line.properties().quantityFontBold,this._line.properties().quantityFontItalic)}setQuantityFont(e){return n.setFontToProperties(e,this._line.properties().quantityFontFamily,this._line.properties().quantityFontSize,this._line.properties().quantityFontBold,this._line.properties().quantityFontItalic),this}getCancelButtonBorderColor(){var e=this._line.properties();return"buy"===this._direction?this._active?e.cancelButtonBorderActiveBuyColor.value():e.cancelButtonBorderInactiveBuyColor.value():this._active?e.cancelButtonBorderActiveSellColor.value():e.cancelButtonBorderInactiveSellColor.value()}setCancelButtonBorderColor(e){return"buy"===this._direction?this._active?this.setCancelButtonBorderActiveBuyColor(e):this.setCancelButtonBorderInactiveBuyColor(e):this._active?this.setCancelButtonBorderActiveSellColor(e):this.setCancelButtonBorderInactiveSellColor(e),this}setCancelButtonBorderActiveBuyColor(e){return this._line.properties().cancelButtonBorderActiveBuyColor.setValue(e),this}setCancelButtonBorderInactiveBuyColor(e){return this._line.properties().cancelButtonBorderInactiveBuyColor.setValue(e),this}setCancelButtonBorderActiveSellColor(e){return this._line.properties().cancelButtonBorderActiveSellColor.setValue(e),this}setCancelButtonBorderInactiveSellColor(e){return this._line.properties().cancelButtonBorderInactiveSellColor.setValue(e),this}getCancelButtonBackgroundColor(){return n.getColorFromProperties(this._line.properties().cancelButtonBackgroundColor,this._line.properties().cancelButtonBackgroundTransparency)}setCancelButtonBackgroundColor(e){return n.setColorToProperties(e,this._line.properties().cancelButtonBackgroundColor,this._line.properties().cancelButtonBackgroundTransparency),this}getCancelButtonIconColor(){var e=this._line.properties();return"buy"===this._direction?this._active?e.cancelButtonIconActiveBuyColor.value():e.cancelButtonIconInactiveBuyColor.value():this._active?e.cancelButtonIconActiveSellColor.value():e.cancelButtonIconInactiveSellColor.value()}setCancelButtonIconColor(e){return"buy"===this._direction?this._active?this.setCancelButtonIconActiveBuyColor(e):this.setCancelButtonIconInactiveBuyColor(e):this._active?this.setCancelButtonIconActiveSellColor(e):this.setCancelButtonIconInactiveSellColor(e),this}setCancelButtonIconActiveBuyColor(e){return this._line.properties().cancelButtonIconActiveBuyColor.setValue(e),this}setCancelButtonIconInactiveBuyColor(e){return this._line.properties().cancelButtonIconInactiveBuyColor.setValue(e),this}setCancelButtonIconActiveSellColor(e){return this._line.properties().cancelButtonIconActiveSellColor.setValue(e),this} +setCancelButtonIconInactiveSellColor(e){return this._line.properties().cancelButtonIconInactiveSellColor.setValue(e),this}block(){this._blocked=!0,this._line.updateAllViewsAndRedraw()}unblock(){this._blocked=!1,this._line.updateAllViewsAndRedraw()}getBlocked(){return this._blocked}isFunction(e){return"function"==typeof e}onCancel(e,t){return t?this.isFunction(t)&&(this._onCancelData=e,this._onCancelCallback=t):this.isFunction(e)&&(this._onCancelCallback=e),this}callOnCancel(){this.isFunction(this._onCancelCallback)&&this._onCancelCallback.call(this,this._onCancelData)}isOnCancelCallbackPresent(){return this.isFunction(this._onCancelCallback)}onModify(e,t){return t?this.isFunction(t)&&(this._onModifyData=e,this._onModifyCallback=t):this.isFunction(e)&&(this._onModifyCallback=e),this}callOnModify(){this.isFunction(this._onModifyCallback)&&this._onModifyCallback.call(this,this._onModifyData)}onMove(e,t){return t?this.isFunction(t)&&(this._onMoveData=e,this._onMoveCallback=t):this.isFunction(e)&&(this._onMoveCallback=e),this}callOnMove(){this.isFunction(this._onMoveCallback)&&this._onMoveCallback.call(this,this._onMoveData)}onMoving(e,t){return t?this.isFunction(t)&&(this._onMovingData=e,this._onMovingCallback=t):this.isFunction(e)&&(this._onMovingCallback=e),this}callOnMoving(){this.isFunction(this._onMovingCallback)&&this._onMovingCallback.call(this,this._onMovingData)}onContextMenu(e,t){return t?this.isFunction(t)&&(this._onContextMenuData=e,this._onContextMenuCallback=t):this.isFunction(e)&&(this._onContextMenuCallback=e),this}shouldShowContextMenu(){return this.isFunction(this._onContextMenuCallback)}callOnContextMenu(){if(this.isFunction(this._onContextMenuCallback))return this._onContextMenuCallback.call(this,this._onContextMenuData)}remove(){this._line._model.removeSource(this._line),delete this._line}}class u extends s{constructor(e,t){super(e,t||u.createProperties()),this._adapter=new d(this),this.setSelectionEnabled(!0),i.e(1583).then(i.bind(i,61144)).then((({OrderPaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}zorder(){return c}isSpeciallyZOrderedSource(){return!0}setPoint(e,t,i){this._points[e]=t,this.normalizePoints()}addPoint(e,t){return this._points.push(e),this._lastPoint=null,this.normalizePoints(),this.createServerPoints(),!0}name(){return"Order"}move(e,t,i,s){var r=this._startMovingPoint&&this._currentMovingPoint&&this._startMovingPoint.logical.price!==this._currentMovingPoint.logical.price;super.move(e,t,i,s),r&&this._adapter.callOnMoving()}endMoving(e){var t=this._startMovingPoint&&this._currentMovingPoint&&this._startMovingPoint.logical.price!==this._currentMovingPoint.logical.price;super.endMoving(),!e&&t&&this._adapter.callOnMove()}createPriceAxisView(e){var t={pointIndex:e,backgroundPropertyGetter:()=>this._adapter.getLineColor()};return this._priceAxisView=new r(this,t),this._priceAxisView}paneViews(){return TradingView.printing&&!l.enabled("snapshot_trading_drawings")?null:this._model.properties().tradingProperties.showOrders.value()?o.prototype.paneViews.call(this):null} +priceAxisViews(e,t){return TradingView.printing&&!l.enabled("snapshot_trading_drawings")?null:this._model.properties().tradingProperties.showOrders.value()?o.prototype.priceAxisViews.call(this,e,t):null}adapter(){return this._adapter}hasContextMenu(){return this._adapter.shouldShowContextMenu()}contextMenuItems(){return this._adapter.callOnContextMenu()}movable(){return Boolean(this._adapter._onMoveCallback)}static createProperties(e){var t=new a("linetoolorder",e,!1,!1);return this._configureProperties(t),t}}t.LineToolOrder=u},87440:(e,t,i)=>{"use strict";i.d(t,{LineToolParallelChannel:()=>h});var s=i(50151),r=i(86441),n=i(46100),o=i(88348),a=i(13087),l=i(1722),c=i(97145);class h extends a.LineDataSource{constructor(e,t,s,r){super(e,t||h.createProperties(),s,r),this._alertCreationAvailable=new c.WatchedValue(super.alertCreationAvailable().value()&&this._isTimePointsValid()),this._priceAxisViews.push(this.createPriceAxisView(3)),this._coordOffsetWhileMovingOrChanging=null,this._pendingPriceOffset=null,i.e(1583).then(i.bind(i,26013)).then((({ParallelChannelPaneView:e})=>{this._setPaneViews([new e(this,this._model)])})),this._normalizedPointsChanged.subscribe(this,(()=>this._alertCreationAvailable.setValue(super.alertCreationAvailable().value()&&this._isTimePointsValid())))}alertCreationAvailable(){return this._alertCreationAvailable.readonly()}paneViews(e){return null!==this._pendingPriceOffset&&this._applyPendingPriceOffset(),super.paneViews(e)}setLastPoint(e,t){t&&t.shift()&&2===this.points().length&&this._snapPoint45Degree(e,this.points()[0]);const i=(0,l.clone)(e);return super.setLastPoint(e),i}startMoving(e,t,i,s){super.startMoving(e,t,i,s),this._coordOffsetWhileMovingOrChanging=this._findPixelsHeight()}endMoving(e,t,i){return this._coordOffsetWhileMovingOrChanging=null,super.endMoving(e,t,i)}startChanging(e,t){super.startChanging(e,t),this._coordOffsetWhileMovingOrChanging=this._findPixelsHeight()}endChanging(e,t,i){return this._coordOffsetWhileMovingOrChanging=null,super.endChanging(e,t,i)}restoreExternalPoints(e,t,i){const s=i?e.points:this._timePoint.map(((t,i)=>({price:t.price,offset:e.points[i].offset,time_t:e.points[i].time_t})));if(super.restoreExternalPoints({...e,points:s},t),t.pricesChanged&&this._points.length===s.length)for(let e=0;e=4)return;this._snapPointBeforeChange(e,t,i);const a=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[0])),l=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[1])),c=(0,s.ensureNotNull)(this.pointToScreenPoint(t)),h=(0,s.ensureNotNull)(this._coordOffsetWhileMovingOrChanging),d=(0,s.ensureNotNull)(this.priceScale()),u=(0,s.ensure)(null===(n=this.ownerSource())||void 0===n?void 0:n.firstValue());switch(e){case 0:super.setPoint(e,t,i),this._points[2].price=d.coordinateToPrice(c.y+h,u) +;break;case 1:super.setPoint(e,t,i);break;case 2:super.setPoint(e,t,i),this._points[0].price=d.coordinateToPrice(c.y-h,u),this._points[0].index=t.index;break;case 3:this._points[1].price=d.coordinateToPrice(c.y-h,u),this._points[1].index=t.index;break;case 4:{const e=l.subtract(a),t=(c.x-a.x)/e.x,i=a.addScaled(e,t),s=c.y-i.y;this._points[2].price=d.coordinateToPrice(a.y+s,u);break}case 5:{const e=l.subtract(a),t=(c.x-a.x)/e.x,i=a.addScaled(e,t),s=c.y-i.y;this._points[0].price=d.coordinateToPrice(a.y+s,u),this._points[1].price=d.coordinateToPrice(l.y+s,u);break}}const p=this.linkKey().value();if(p&&!r&&e<4){const e=this._points.map((e=>e.price));(0,o.changeLineStyle)({model:this._model,linkKey:p,state:{prices:e}})}}state(e){const t=super.state(e);return this._pendingPriceOffset&&(t.priceOffset=this._pendingPriceOffset),t}restoreExternalState(e){const{prices:t,...i}=e;if(t&&this.isActualSymbol())for(let e=0;ee.index<=t.index?[e,t]:[t,e],s=i(t[0],t[1]),r=i(t[2],t[3]);let n,o,a,l;t[2].pricenull!==e))}_correctLastPoint(e){if(this._points.length<2||this._points[1].index===this._points[0].index)return e;const t=(0,s.ensureNotNull)(this.pointToScreenPoint(e)),i=(0, s.ensureNotNull)(this.pointToScreenPoint(this._points[1])),n=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[0])),o=i.subtract(n),a=(t.x-n.x)/o.x,l=n.addScaled(o,a),c=t.y-l.y,h=n.add(new r.Point(0,c));return(0,s.ensureNotNull)(this.screenPointToPoint(h))}_isTimePointsValid(){return this._timePoint.every((e=>Number.isFinite(e.price)))}_axisPoints(){const e=this.points(),t=this._points[0]?this.pointToScreenPoint(this._points[0]):null,i=this._points[1]?this.pointToScreenPoint(this._points[1]):null,n=this._points[2]?this.pointToScreenPoint(this._points[2]):null;if(t&&i&&n){const o=i.y-t.y,a=n.add(new r.Point(0,o));e.push((0,s.ensureNotNull)(this.screenPointToPoint(a)))}return e}_convertLastPointTo3rdPoint(e){const t=(0,s.ensureNotNull)(this.pointToScreenPoint(e)),i=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[1])),n=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[0])),o=i.subtract(n),a=(t.x-n.x)/o.x,l=n.addScaled(o,a),c=t.y-l.y,h=n.add(new r.Point(0,c));return(0,s.ensureNotNull)(this.screenPointToPoint(h))}_findPixelsHeight(){const e=this.pointToScreenPoint(this._points[2]),t=this.pointToScreenPoint(this._points[0]);return e&&t?e.y-t.y:null}_applyPendingPriceOffset(){const e=this._pendingPriceOffset;if(null===e||this._points.length<3)return;const t=this.priceScale(),i=(0,s.ensureNotNull)(this.ownerSource()).firstValue();if(!t||t.isEmpty()||null===i)return;const r=e+this._points[0].price,n=e+this._points[1].price,o=.5*(r+n)-e,a=.5*(r+n),l=t.priceToCoordinate(o,i),c=t.priceToCoordinate(a,i)-l,h=t.priceToCoordinate(this._points[0].price,i)+c,d=t.coordinateToPrice(h,i);this._points[2].price=d,this._timePoint[2].price=d,this._points[2].index=this._points[0].index,this._timePoint[2].time_t=this._timePoint[0].time_t,this._timePoint[2].offset=this._timePoint[0].offset,this._pendingPriceOffset=null}_snapPointBeforeChange(e,t,i){if(i&&i.shift())switch(e){case 0:case 1:this._snapPoint45Degree(t,this._points[1-e]);break;case 2:case 3:const i=(0,s.ensureNotNull)(this.getPoint(5-e));this._snapPoint45Degree(t,i)}}}},40418:(e,t,i)=>{"use strict";i.d(t,{LineToolPath:()=>c});var s=i(50151),r=i(86441),n=i(46100),o=i(45197),a=i(13087),l=i(68806);class c extends a.LineDataSource{constructor(e,t,s,r){const n=t||c.createProperties();super(e,n,s,r),this._finished=!1,i.e(1583).then(i.bind(i,62801)).then((t=>{this._setPaneViews([new t.PathPaneView(this,e)])}))}pointsCount(){return-1}name(){return"Path"}hasEditableCoordinates(){return!1}finish(){this._finished=!0,this._lastPoint=null,this.normalizePoints(),this.createServerPoints()}addPoint(e,t,i){var n;if(this._finished)return!0;const a=(0,s.ensureNotNull)(this.priceScale()),l=this._model.timeScale().indexToCoordinate(e.index),c=e.price,h=(0,s.ensure)(null===(n=this.ownerSource())||void 0===n?void 0:n.firstValue()),d=a.priceToCoordinate(c,h);if(this._points.length>0){const e=this._points[this._points.length-1],i=this._model.timeScale().indexToCoordinate(e.index),s=e.price,n=a.priceToCoordinate(s,h),c=new r.Point(l,d).subtract(new r.Point(i,n)).length() ;if(!(null==t?void 0:t.isApiEvent())&&c<(0,o.interactionTolerance)().minDistanceBetweenPoints)return this._lastPoint=null,this.normalizePoints(),this.createServerPoints(),!0}return super.addPoint(e,t,i)}static createProperties(e){const t=new n.DefaultProperty("linetoolpath",e);return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,74481)).then((e=>e.PathDefinitionsViewModel))}static _configureProperties(e){super._configureProperties(e),e.addChild("linesWidths",new l.LineToolWidthsProperty([(0,s.ensureDefined)(e.child("lineWidth"))])),e.addChild("linesColors",new l.LineToolColorsProperty([e.childs().lineColor]))}}},63596:(e,t,i)=>{"use strict";var s=i(36298).TranslatedString,r=i(13087).LineDataSource,n=i(53801).LevelsProperty,o=i(68806),a=o.LineToolWidthsProperty,l=o.LineToolColorsProperty,c=new s("erase level line",i(44352).t(null,void 0,i(12962)));class h extends r{constructor(e,t,s,r){super(e,t||h.createProperties(),s,r),i.e(1583).then(i.bind(i,87202)).then((({PitchfanLinePaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}levelsCount(){return h.LevelsCount}pointsCount(){return 3}name(){return"Pitchfan"}processErase(e,t){var i="level"+t,s=this.properties()[i].visible;e.setProperty(s,!1,c)}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,81658))).PitchBaseDefinitionsViewModel}static createProperties(e){var t=new n("linetoolpitchfan",e,!1,{range:[0,8]});return this._configureProperties(t),t}static _configureProperties(e){super._configureProperties(e);for(var t=[e.child("median").child("linewidth")],i=[e.child("median").child("color")],s=0;s<=this.LevelsCount;s++)t.push(e.child("level"+s).child("linewidth")),i.push(e.child("level"+s).child("color"));e.addChild("linesColors",new l(i)),e.addChild("linesWidths",new a(t))}}h.LevelsCount=8,t.LineToolPitchfan=h},90095:(e,t,i)=>{"use strict";var s;i.d(t,{LineToolPitchforkStyle:()=>s}),function(e){e[e.Original=0]="Original",e[e.Schiff=1]="Schiff",e[e.Inside=2]="Inside",e[e.Schiff2=3]="Schiff2"}(s||(s={}))},70309:(e,t,i)=>{"use strict";var s=i(36298).TranslatedString,r=i(13087).LineDataSource,n=i(53801).LevelsProperty,o=i(39347).Action,a=i(95059).ACTION_ID,l=i(90095).LineToolPitchforkStyle,c=null,h=i(68806),d=h.LineToolWidthsProperty,u=h.LineToolColorsProperty,p=new s("erase level line",i(44352).t(null,void 0,i(12962))),_=new s("change {title} style",i(44352).t(null,void 0,i(74428)));class m extends r{constructor(e,t,i,s){super(e,t||m.createProperties(),i,s),this._properties.style.listeners().subscribe(this,this._recreatePaneView),this._recreatePaneView()}levelsCount(){return m.LevelsCount}additionalActions(e){for(var t=[],r=[{title:i(44352).t(null,void 0,i(25595)),actionId:a.ChartLineToolPitchforkChangeTypeToOriginal},{title:i(44352).t(null,void 0,i(66276)),actionId:a.ChartLineToolPitchforkChangeTypeToModifiedSchiff},{title:i(44352).t(null,void 0,i(9114)), actionId:a.ChartLineToolPitchforkChangeTypeToInside},{title:i(44352).t(null,void 0,i(51464)),actionId:a.ChartLineToolPitchforkChangeTypeToSchiff}],n=0;n<4;n++){var l=new o({actionId:r[n].actionId,checked:this.properties().style.value()===n,checkable:!0,label:r[n].title,payload:{target:this,value:n},onExecute:function(t){var i=t.getPayload(),r=i.target;e.setProperty(r.properties().style,i.value,_.format({title:new s(r.name(),r.title())})),r.updateAllViews(),r._model.updateSource(r)}});t.push(l)}return[t[0],t[3],t[1],t[2]]}_recreatePaneView(){if(null!==c){var e=[];this._properties.style.value()===l.Original?e=[new c.PitchforkLinePaneView(this,this._model)]:this._properties.style.value()===l.Schiff?e=[new c.SchiffPitchforkLinePaneView(this,this._model)]:this._properties.style.value()===l.Schiff2?e=[new c.SchiffPitchfork2LinePaneView(this,this._model)]:this._properties.style.value()===l.Inside&&(e=[new c.InsidePitchforkLinePaneView(this,this._model)]),this._setPaneViews(e)}else i.e(1583).then(i.bind(i,95337)).then((e=>{null===c&&(c=e),this._recreatePaneView()}))}pointsCount(){return 3}name(){return"Pitchfork"}processErase(e,t){var i="level"+t,s=this.properties()[i].visible;e.setProperty(s,!1,p)}static createProperties(e){var t=new n("linetoolpitchfork",e,!1,{range:[0,8]});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,769))).PitchForkDefinitionsViewModel}static _configureProperties(e){super._configureProperties(e);for(var t=[e.child("median").child("linewidth")],i=[e.child("median").child("color")],s=0;s<=this.LevelsCount;s++)t.push(e.child("level"+s).child("linewidth")),i.push(e.child("level"+s).child("color"));e.addChild("linesColors",new u(i)),e.addChild("linesWidths",new d(t))}}m.LevelsCount=8,t.LineToolPitchfork=m},67686:(e,t,i)=>{"use strict";i.d(t,{LineToolPolyline:()=>l});var s=i(50151),r=i(86441),n=i(46100),o=i(45197),a=i(13087);class l extends a.LineDataSource{constructor(e,t,s,r){const n=t||l.createProperties();super(e,n,s,r),this._finished=!1,i.e(1583).then(i.bind(i,50253)).then((t=>{this._setPaneViews([new t.PolylinePaneView(this,e)])}))}pointsCount(){return-1}name(){return"Polyline"}hasEditableCoordinates(){return!1}finish(){this._finished=!0,this._lastPoint=null,this.normalizePoints(),this.createServerPoints()}addPoint(e,t,i){var n;if(this._finished)return!0;const a=(0,s.ensureNotNull)(this.priceScale()),l=this._model.timeScale().indexToCoordinate(e.index),c=e.price,h=(0,s.ensure)(null===(n=this.ownerSource())||void 0===n?void 0:n.firstValue()),d=a.priceToCoordinate(c,h),u=(0,o.interactionTolerance)().minDistanceBetweenPoints;if(this._points.length>0){const e=this._points[this._points.length-1],i=this._model.timeScale().indexToCoordinate(e.index),s=e.price,n=a.priceToCoordinate(s,h),o=new r.Point(l,d).subtract(new r.Point(i,n)).length();if(!(null==t?void 0:t.isApiEvent())&&oe.PolylinesDefinitionsViewModel))}static _configureProperties(e){super._configureProperties(e),e.addExclusion("filled")}}},66683:(e,t,i)=>{"use strict";i.d(t,{PositionAveragePriceAxisView:()=>r});var s=i(71243);class r extends s.LineToolPriceAxisView{_formatPrice(e,t){return this._source.formatter().format(e)}}},37619:(e,t,i)=>{"use strict";var s=i(87564).LineToolTrading,r=i(13087).LineDataSource,n=i(66683).PositionAveragePriceAxisView,o=i(47043),a=i(46100).DefaultProperty,l=i(61146).PriceFormatter;const c=i(14483);var h=i(98517).sortSourcesPreOrdered.LineToolPosition;function d(e){return null==e?e="":e+="",e}class u{constructor(e){this._line=e,this._data={bodyText:"position",quantityText:"0"},this._closeEnabled=!0,this._direction="buy",this._profitState="neutral"}setDirection(e){return this._direction=e,this._line.updateAllViewsAndRedraw(),this}setProfitState(e){return this._profitState=e,this._line.updateAllViewsAndRedraw(),this}getPrice(){return this._line.points().length>0?this._line.points()[0].price:this._line._timePoint.length>0?this._line._timePoint[0].price:void 0}setPrice(e){if(this._line.points().length>0){var t=this._line.points()[0];t.price=e,this._line._points[0]=t,this._line.normalizePoints(),this._line.updateAllViewsAndRedraw()}return this._line._timePoint.length>0&&(this._line._timePoint[0].price=e),this}getText(){return this._data.bodyText}setText(e){return this._data.bodyText=e||"",this._line.updateAllViewsAndRedraw(),this}setTooltip(e){return this._line.properties().tooltip.setValue(d(e)),this}getTooltip(){return this._line.properties().tooltip.value()}setProtectTooltip(e){return this._line.properties().protectTooltip.setValue(d(e)),this}getProtectTooltip(){return this._line.properties().protectTooltip.value()}setCloseTooltip(e){ -return this._line.properties().closeTooltip.setValue(d(e)),this}getCloseTooltip(){return this._line.properties().closeTooltip.value()}setReverseTooltip(e){return this._line.properties().reverseTooltip.setValue(d(e)),this}getReverseTooltip(){return this._line.properties().reverseTooltip.value()}getQuantity(){return this._data.quantityText}setQuantity(e){return this._data.quantityText=e||"",this._line.updateAllViewsAndRedraw(),this}getExtendLeft(){var e=this._line.properties().extendLeft.value();return"inherit"===e?this._line._model.properties().tradingProperties.extendLeft.value():e}setExtendLeft(e){return this._line.properties().extendLeft.setValue(e),this}getLineLength(){var e=this._line.properties().lineLength.value();return"inherit"===e?this._line._model.properties().tradingProperties.lineLength.value():e}setLineLength(e){return this._line.properties().lineLength.setValue(Math.max(0,Math.min(e,100))),this}getLineColor(){var e=this._line.properties();return("buy"===this._direction?e.lineBuyColor:e.lineSellColor).value()}setLineColor(e){return"buy"===this._direction?this.setLineBuyColor(e):this.setLineSellColor(e),this}setLineBuyColor(e){return this._line.properties().lineBuyColor.setValue(e),this}setLineSellColor(e){return this._line.properties().lineSellColor.setValue(e),this}getLineStyle(){var e=this._line.properties().lineStyle.value();return"inherit"===e?this._line._model.properties().tradingProperties.lineStyle.value():e}setLineStyle(e){return this._line.properties().lineStyle.setValue(e),this}getLineWidth(){var e=this._line.properties().lineWidth.value();return"inherit"===e?this._line._model.properties().tradingProperties.lineWidth.value():e}setLineWidth(e){return this._line.properties().lineWidth.setValue(e),this}getBodyBorderColor(){var e=this._line.properties();return("buy"===this._direction?e.bodyBorderBuyColor:e.bodyBorderSellColor).value()}setBodyBorderColor(e){return"buy"===this._direction?this.setBodyBorderBuyColor(e):this.setBodyBorderSellColor(e),this}setBodyBorderBuyColor(e){return this._line.properties().bodyBorderBuyColor.setValue(e),this}setBodyBorderSellColor(e){return this._line.properties().bodyBorderSellColor.setValue(e),this}getBodyBackgroundColor(){return o.getColorFromProperties(this._line.properties().bodyBackgroundColor,this._line.properties().bodyBackgroundTransparency)}setBodyBackgroundColor(e){return o.setColorToProperties(e,this._line.properties().bodyBackgroundColor,this._line.properties().bodyBackgroundTransparency),this}getBodyTextColor(){var e=this._line.properties();return("positive"===this._profitState?e.bodyTextPositiveColor:"negative"===this._profitState?e.bodyTextNegativeColor:e.bodyTextNeutralColor).value()}setBodyTextColor(e){return"positive"===this._profitState?this.setBodyTextPositiveColor(e):"negative"===this._profitState?this.setBodyTextNegativeColor(e):this.setBodyTextNeutralColor(e),this}setBodyTextPositiveColor(e){return this._line.properties().bodyTextPositiveColor.setValue(e),this}setBodyTextNegativeColor(e){ -return this._line.properties().bodyTextNegativeColor.setValue(e),this}setBodyTextNeutralColor(e){return this._line.properties().bodyTextNeutralColor.setValue(e),this}getBodyFont(){return o.getFontFromProperties(this._line.properties().bodyFontFamily,this._line.properties().bodyFontSize,this._line.properties().bodyFontBold,this._line.properties().bodyFontItalic)}setBodyFont(e){return o.setFontToProperties(e,this._line.properties().bodyFontFamily,this._line.properties().bodyFontSize,this._line.properties().bodyFontBold,this._line.properties().bodyFontItalic),this}getQuantityBorderColor(){var e=this._line.properties();return("buy"===this._direction?e.quantityBorderBuyColor:e.quantityBorderSellColor).value()}setQuantityBorderColor(e){return"buy"===this._direction?this.setQuantityBorderBuyColor(e):this.setQuantityBorderSellColor(e),this}setQuantityBorderBuyColor(e){return this._line.properties().quantityBorderBuyColor.setValue(e),this}setQuantityBorderSellColor(e){return this._line.properties().quantityBorderSellColor.setValue(e),this}getQuantityBackgroundColor(){var e=this._line.properties();return("buy"===this._direction?e.quantityBackgroundBuyColor:e.quantityBackgroundSellColor).value()}setQuantityBackgroundColor(e){return"buy"===this._direction?this.setQuantityBackgroundBuyColor(e):this.setQuantityBackgroundSellColor(e),this}setQuantityBackgroundBuyColor(e){return this._line.properties().quantityBackgroundBuyColor.setValue(e),this}setQuantityBackgroundSellColor(e){return this._line.properties().quantityBackgroundSellColor.setValue(e),this}getQuantityTextColor(){return o.getColorFromProperties(this._line.properties().quantityTextColor,this._line.properties().quantityTextTransparency)}setQuantityTextColor(e){return o.setColorToProperties(e,this._line.properties().quantityTextColor,this._line.properties().quantityTextTransparency),this}getQuantityFont(){return o.getFontFromProperties(this._line.properties().quantityFontFamily,this._line.properties().quantityFontSize,this._line.properties().quantityFontBold,this._line.properties().quantityFontItalic)}setQuantityFont(e){return o.setFontToProperties(e,this._line.properties().quantityFontFamily,this._line.properties().quantityFontSize,this._line.properties().quantityFontBold,this._line.properties().quantityFontItalic),this}getReverseButtonBorderColor(){var e=this._line.properties();return("buy"===this._direction?e.reverseButtonBorderBuyColor:e.reverseButtonBorderSellColor).value()}setReverseButtonBorderColor(e){return"buy"===this._direction?this.setReverseButtonBorderBuyColor(e):this.setReverseButtonBorderSellColor(e),this}setReverseButtonBorderBuyColor(e){return this._line.properties().reverseButtonBorderBuyColor.setValue(e),this}setReverseButtonBorderSellColor(e){return this._line.properties().reverseButtonBorderSellColor.setValue(e),this}getReverseButtonBackgroundColor(){return o.getColorFromProperties(this._line.properties().reverseButtonBackgroundColor,this._line.properties().reverseButtonBackgroundTransparency)}setReverseButtonBackgroundColor(e){ -return o.setColorToProperties(e,this._line.properties().reverseButtonBackgroundColor,this._line.properties().reverseButtonBackgroundTransparency),this}getReverseButtonIconColor(){var e=this._line.properties();return("buy"===this._direction?e.reverseButtonIconBuyColor:e.reverseButtonIconSellColor).value()}setReverseButtonIconColor(e){return"buy"===this._direction?this.setReverseButtonIconBuyColor(e):this.setReverseButtonIconSellColor(e),this}setReverseButtonIconBuyColor(e){return this._line.properties().reverseButtonIconBuyColor.setValue(e),this}setReverseButtonIconSellColor(e){return this._line.properties().reverseButtonIconSellColor.setValue(e),this}getCloseButtonBorderColor(){var e=this._line.properties();return("buy"===this._direction?e.closeButtonBorderBuyColor:e.closeButtonBorderSellColor).value()}setCloseButtonBorderColor(e){return"buy"===this._direction?this.setCloseButtonBorderBuyColor(e):this.setCloseButtonBorderSellColor(e),this}setCloseButtonBorderBuyColor(e){return this._line.properties().closeButtonBorderBuyColor.setValue(e),this}setCloseButtonBorderSellColor(e){return this._line.properties().closeButtonBorderSellColor.setValue(e),this}getCloseButtonBackgroundColor(){return o.getColorFromProperties(this._line.properties().closeButtonBackgroundColor,this._line.properties().closeButtonBackgroundTransparency)}setCloseButtonBackgroundColor(e){return o.setColorToProperties(e,this._line.properties().closeButtonBackgroundColor,this._line.properties().closeButtonBackgroundTransparency),this}getCloseButtonIconColor(){var e=this._line.properties();return("buy"===this._direction?e.closeButtonIconBuyColor:e.closeButtonIconSellColor).value()}setCloseButtonIconColor(e){return"buy"===this._direction?this.setCloseButtonIconBuyColor(e):this.setCloseButtonIconSellColor(e),this}setCloseButtonIconBuyColor(e){return this._line.properties().closeButtonIconBuyColor.setValue(e),this}setCloseButtonIconSellColor(e){return this._line.properties().closeButtonIconSellColor.setValue(e),this}block(){this._blocked=!0,this._line.updateAllViewsAndRedraw()}unblock(){this._blocked=!1,this._line.updateAllViewsAndRedraw()}isFunction(e){return"function"==typeof e}onReverse(e,t){return t?this.isFunction(t)&&(this._onReverseData=e,this._onReverseCallback=t):this.isFunction(e)&&(this._onReverseCallback=e),this}callOnReverse(){this.isFunction(this._onReverseCallback)&&this._onReverseCallback.call(this,this._onReverseData)}isOnReverseCallbackPresent(){return this.isFunction(this._onReverseCallback)}onClose(e,t){return t?this.isFunction(t)&&(this._onCloseData=e,this._onCloseCallback=t):this.isFunction(e)&&(this._onCloseCallback=e),this}setCloseEnabled(e){return this._closeEnabled===e||(this._closeEnabled=e,this._onCloseCallback&&this._line.updateAllViewsAndRedraw()),this}isCloseEnabled(){return this._closeEnabled}callOnClose(){this.isFunction(this._onCloseCallback)&&this._closeEnabled&&this._onCloseCallback.call(this,this._onCloseData)}isOnCloseCallbackPresent(){return this._closeEnabled&&this.isFunction(this._onCloseCallback)}onModify(e,t){ -return t?this.isFunction(t)&&(this._onModifyData=e,this._onModifyCallback=t):this.isFunction(e)&&(this._onModifyCallback=e),this}callOnModify(){this.isFunction(this._onModifyCallback)&&this._onModifyCallback.call(this,this._onModifyData)}onContextMenu(e,t){return t?this.isFunction(t)&&(this._onContextMenuData=e,this._onContextMenuCallback=t):this.isFunction(e)&&(this._onContextMenuCallback=e),this}shouldShowContextMenu(){return this.isFunction(this._onContextMenuCallback)}callOnContextMenu(){if(this.isFunction(this._onContextMenuCallback))return this._onContextMenuCallback.call(this,this._onContextMenuData)}remove(){this._line._model.removeSource(this._line),delete this._line}}class p extends s{constructor(e,t){super(e,t||p.createProperties()),this._adapter=new u(this),i.e(1583).then(i.t.bind(i,46258,19)).then((({PositionPaneView:e})=>{this._setPaneViews([new e(this,this._model)])}));var s=e.mainSeries().symbolInfo(),r=null!==s?s.pricescale:100,n=null!==s&&s.fractional?s.minmov:1,o=null!==s&&s.fractional,a=null!==s?s.minmove2:void 0;this._formatter=new l(r,n,o,a)}zorder(){return h}isSpeciallyZOrderedSource(){return!0}setPoint(e,t,i){this._points[e]=t,this.normalizePoints()}addPoint(e,t){return this._points.push(e),this._lastPoint=null,this.normalizePoints(),this.createServerPoints(),!0}name(){return"Position"}createPriceAxisView(e){return this._priceAxisView=new n(this,{pointIndex:e,backgroundPropertyGetter:()=>this._adapter.getLineColor()}),this._priceAxisView}paneViews(){return TradingView.printing&&!c.enabled("snapshot_trading_drawings")?null:this._model.properties().tradingProperties.showPositions.value()?r.prototype.paneViews.call(this):null}priceAxisViews(e,t){return TradingView.printing&&!c.enabled("snapshot_trading_drawings")?null:this._model.properties().tradingProperties.showPositions.value()?r.prototype.priceAxisViews.call(this,e,t):null}hasContextMenu(){return this._adapter.shouldShowContextMenu()}contextMenuItems(){return this._adapter.callOnContextMenu()}formatter(){return this._formatter}static createProperties(e){var t=new a("linetoolposition",e,!1,!1);return this._configureProperties(t),t}}t.LineToolPosition=p},21316:(e,t,i)=>{"use strict";var s,r;i.r(t),i.d(t,{AlertStatus:()=>s,Direction:()=>r}),function(e){e[e.Waiting=0]="Waiting",e[e.Success=1]="Success",e[e.Failure=2]="Failure"}(s||(s={})),function(e){e[e.Up=1]="Up",e[e.Down=2]="Down"}(r||(r={}))},30597:(e,t,i)=>{"use strict";var s=i(50151).ensureNotNull,r=i(13087).LineDataSource,n=i(46100).DefaultProperty,o=i(21316);class a extends r{constructor(e,t,s,r){super(e,t||a.createProperties(),s,r),this._predictionPaneView=null;const n=this._model.mainSeries();n.properties().interval.subscribe(this,(()=>{this.setStatus(o.AlertStatus.Waiting)})),n.dataEvents().dataUpdated().subscribe(this,this.recalculateStateByData),i.e(1583).then(i.t.bind(i,75061,19)).then((({PredictionPaneView:e})=>{this._predictionPaneView=new e(this,this._model),this._setPaneViews([this._predictionPaneView])}))}destroy(){const e=this._model.mainSeries() -;e.properties().interval.unsubscribeAll(this),e.dataEvents().dataUpdated().unsubscribeAll(this),super.destroy()}dataAndViewsReady(){return super.dataAndViewsReady()&&this._predictionPaneView&&this._predictionPaneView.iconsReady()}isSynchronizable(){return!1}status(){return this._properties.status.value()}setStatus(e){return this._properties.status.setValue(e)}pointsCount(){return 2}name(){return"Forecast"}restorePoints(e,t,i){super.restorePoints(e,t,i),this.recalculateStateByData()}recalculateStateByData(){if(!this.isSourceHidden()&&!(this._points.length<2||this._model.mainSeries().bars().isEmpty())){var e=this._points[1];if(this.status())e.index>this._model.timeScale().baseIndex()&&this.setStatus(o.AlertStatus.Waiting);else{var t=this._model.mainSeries().bars().valueAt(e.index);if(null!==t){var i=this.direction();if(i===o.Direction.Up&&t[TradingView.HIGH_PLOT]>=e.price)this.setStatus(o.AlertStatus.Success);else if(i===o.Direction.Down&&t[TradingView.LOW_PLOT]<=e.price)this.setStatus(o.AlertStatus.Success);else{var r=s(this._model.mainSeries().bars().lastIndex());e.index!==r&&this.setStatus(o.AlertStatus.Failure)}}}}}addPoint(e){var t=super.addPoint(e);return t&&this.recalculateStateByData(),t}endChanging(){super.endChanging(),this.setStatus(o.AlertStatus.Waiting),this.recalculateStateByData()}onData(e){super.onData(e),this.recalculateStateByData()}endMoving(e,t,i){super.endMoving(e,t,i),this.setStatus(o.AlertStatus.Waiting),this.recalculateStateByData()}direction(){if(this.points().length<2)return o.Direction.Up;var e=this.points()[0];return this.points()[1].price>e.price?o.Direction.Up:o.Direction.Down}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,54440))).PredictionDefinitionsViewModel}cloneable(){return!1}static createProperties(e){var t=new n("linetoolprediction",e);return this._configureProperties(t),t}static _configureProperties(e){super._configureProperties(e),e.merge({status:o.AlertStatus.Waiting})}}t.LineToolPrediction=a},27039:(e,t,i)=>{"use strict";var s=i(13087).LineDataSource,r=i(46100).DefaultProperty,n=i(68806).LineToolColorsProperty;class o extends s{constructor(e,t,s,r){super(e,t||o.createProperties(),s,r),i.e(1583).then(i.t.bind(i,86583,19)).then((({PriceLabelPaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}pointsCount(){return 1}name(){return"Price Label"}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,17265))).PriceLabelDefinitionsViewModel}static createProperties(e){var t=new r("linetoolpricelabel",e);return this._configureProperties(t),t}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new n([e.childs().borderColor])),e.addChild("textsColors",new n([e.childs().color]))}}t.LineToolPriceLabel=o},32831:(e,t,i)=>{"use strict";i.r(t),i.d(t,{LineToolPriceNote:()=>P}) -;var s=i(50151),r=i(13087),n=i(48891),o=i(24633),a=i(32430),l=i(68806),c=i(17236),h=i(13637),d=i(59452),u=i.n(d),p=i(77680);const _={intervalsVisibilities:{...c.intervalsVisibilitiesDefaults},showLabel:!1,horzLabelsAlign:"center",vertLabelsAlign:"top",fontSize:14,bold:!1,italic:!1,priceLabelFontSize:12,priceLabelBold:!1,priceLabelItalic:!1},m=(0,n.getHexColorByName)("color-tv-blue-500"),g={lineColor:m,textColor:m,priceLabelBackgroundColor:m,priceLabelBorderColor:m,priceLabelTextColor:(0,n.getHexColorByName)("color-white")},f=new Map([[o.StdTheme.Light,g],[o.StdTheme.Dark,g]]),v=(0,h.extractAllPropertiesKeys)((0,s.ensureDefined)(f.get(o.StdTheme.Light))),S=(0,h.extractAllPropertiesKeys)(_),y=[...v,...S,...a.commonLineToolPropertiesStateKeys,"text"];class b extends p.LineDataSourceThemedProperty{constructor(e,t,i,r,n){var o;super(e,t,i,r,y,n),this._textProperty=new(u())(null!==(o=null==n?void 0:n.text)&&void 0!==o?o:""),this.addChild("text",this._textProperty),this.addChild("linesColors",new l.LineToolColorsProperty([(0,s.ensureDefined)(this.child("lineColor"))])),this.addChild("backgroundsColors",new l.LineToolColorsProperty([(0,s.ensureDefined)(this.child("priceLabelBackgroundColor"))])),this.addChild("textsColors",new l.LineToolColorsProperty([(0,s.ensureDefined)(this.child("priceLabelTextColor"))]))}template(){return{...super.template(),text:this._textProperty.value()}}static create(e){return new this("linetoolpricenote",(()=>(0,h.factoryDefaultsForCurrentTheme)(_,f)),S,v,e)}}var w=i(28558);class P extends r.LineDataSource{constructor(e,t,s,r){super(e,t||P.createProperties(),s,r),this._labelMovingDelta=null,i.e(1583).then(i.bind(i,29734)).then((t=>{this._setPaneViews([new t.PriceNotePaneView(this,e)])}))}pointsCount(){return 2}name(){return"Price Note"}template(){return this._properties.template()}startMoving(e,t,i){if(1===t){if(this.isSourceHidden())return;const i=(0,s.ensureDefined)(e.logical),r=this.points()[1];this._labelMovingDelta={index:r.index-i.index,price:r.price-i.price},this.startChanging(t,i)}else this._labelMovingDelta=null,super.startMoving(e,t,i)}move(e,t,i){if(null!==this._labelMovingDelta){const t=(0,s.ensureDefined)(e.logical),r={index:t.index+this._labelMovingDelta.index,price:t.price+this._labelMovingDelta.price};this.setPoint(1,r,i),this.updateAllViews((0,w.sourceChangeEvent)(this.id()))}else super.move(e,t,i)}endMoving(e,t,i){return null!==this._labelMovingDelta?(this._labelMovingDelta=null,this.endChanging(!1,e)):super.endMoving(e,t,i)}static createProperties(e){const t=b.create(e);return this._configureProperties(t),t}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text)}async _getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,11980)).then((e=>e.PriceNoteDefinitionsViewModel))}_snapTo45DegreesAvailable(){return!0}static _addCollectedProperties(e){}}},59776:(e,t,i)=>{"use strict";i.d(t,{LineToolPriceRange:()=>m}) -;var s=i(13087),r=i(50151),n=i(24633),o=i(13637),a=i(30541),l=i(32430);const c={...a.nonThemedFactoryDefaultsBase,extendLeft:!1,extendRight:!1},h=a.themedFactoryDefaultsBase,d=(0,o.extractAllPropertiesKeys)((0,r.ensureDefined)(h.get(n.StdTheme.Light))),u=(0,o.extractAllPropertiesKeys)(c),p=[...d,...u,...l.commonLineToolPropertiesStateKeys,...a.allPropertiesStateKeysBase];class _ extends a.DateAndPriceBaseProperties{static create(e){return new this("linetoolpricerange",(()=>(0,o.factoryDefaultsForCurrentTheme)(c,h)),u,d,p,e)}}class m extends s.LineDataSource{constructor(e,t,s,r){super(e,t||m.createProperties(),s,r),i.e(1583).then(i.bind(i,61416)).then((e=>{this._setPaneViews([new e.PriceRangePaneView(this,this._model)])}))}pointsCount(){return 2}name(){return"Price Range"}template(){return this._properties.template()}static createProperties(e){const t=_.create(e);return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,83115))).GeneralDatePriceRangeDefinitionsViewModel}}},66967:(e,t,i)=>{"use strict";var s=i(53801).LevelsProperty,r=i(37122).LineToolFibWedgeBase,n=i(68806).LineToolColorsProperty;class o extends r{constructor(e,t,s,r){super(e,t||o.createProperties(),s,r),i.e(1583).then(i.t.bind(i,75219,19)).then((({ProjectionLinePaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}levelsCount(){return 1}name(){return"Projection"}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,12501))).ProjectionDefinitionsViewModel}static createProperties(e){var t=new s("linetoolprojection",e,!1,{range:[1,1]});return this._configureProperties(t),t}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new n([e.trendline.color]))}}t.LineToolProjection=o},10279:(e,t,i)=>{"use strict";i.d(t,{LineToolRay:()=>r});var s=i(47246);class r extends s.LineToolTrendLine{constructor(e,t,i,s){super(e,null!=t?t:r.createProperties(),i,s)}name(){return"Ray"}static createProperties(e){const t=s.LineToolTrendLine.createProperties(e,"linetoolray");return r._configureProperties(t),t}}},32948:(e,t,i)=>{"use strict";i.d(t,{LineToolRectangle:()=>h});var s=i(86441),r=i(46100),n=i(59452),o=i.n(n),a=i(13087),l=i(68806),c=i(50151);class h extends a.LineDataSource{constructor(e,t,s,r){const n=t||h.createProperties();super(e,n,s,r),i.e(1583).then(i.bind(i,31320)).then((({RectanglePaneView:t})=>{const i=[new t(this,e)];this._setPaneViews(i)}))}pointsCount(){return 2}textColorsProperty(){return this.properties().childs().showLabel.value()?super.textColorsProperty():null}name(){return"Rectangle"}setPoint(e,t,i){if(e<2&&super.setPoint(e,t,i),i&&i.shift()){const i=this._getAnchorPointForIndex(e);if(e>=4)return this._correctMiddlePoints(e,t,i),void this.normalizePoints();this._snapPoint45Degree(t,i)}switch(e){case 2:this._points[1].price=t.price,this._points[0].index=t.index;break;case 3:this._points[0].price=t.price, -this._points[1].index=t.index;break;case 4:this._points[0].index=t.index;break;case 5:this._points[1].index=t.index;break;case 6:this._points[0].price=t.price;break;case 7:this._points[1].price=t.price}this.normalizePoints()}getPoint(e){return e<2?super.getPoint(e):this._getAnchorPointForIndex(e)}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}static createProperties(e){const t=new r.DefaultProperty("linetoolrectangle",e);return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,3664)).then((e=>e.RectangleDefinitionsViewModel))}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text)}_snapPoint45Degree(e,t,i){const s=this._priceScale,r=this.ownerSource();if(null===s||null===r)return;const n=r.firstValue();if(null===n)return;const o=this._model.timeScale(),a=(0,c.ensureNotNull)(this.pointToScreenPoint(e)),l=(0,c.ensureNotNull)(this.pointToScreenPoint(t)),h=a.x-l.x,d=a.y-l.y,u=h<0?-1:1,p=d<0?-1:1,_=Math.max(Math.abs(h),Math.abs(d)),m=Math.round(o.coordinateToIndex(l.x+_*u)),g=Math.abs(o.indexToCoordinate(m)-l.x),f=s.coordinateToPrice(l.y+g*p,n);e.index=m,e.price=f}_correctMiddlePoints(e,t,i){e<6?this._correctRightLeftMiddlePoint(e,t,i):this._correctTopBottomMiddlePoint(e,t,i)}_correctRightLeftMiddlePoint(e,t,i){const r=(0,c.ensureNotNull)(this.pointToScreenPoint(t)),n=(0,c.ensureNotNull)(this.pointToScreenPoint(i)),o=(0,c.ensureNotNull)(this.pointToScreenPoint(this._points[0])),a=(0,c.ensureNotNull)(this.pointToScreenPoint(this._points[1]));let l=r.x-n.x;if(0===l)return;const h=o.x{"use strict";var s;i.d(t,{RiskDisplayMode:()=>s}),function(e){e.Percentage="percents",e.Money="money"}(s||(s={}))},95539:(e,t,i)=>{"use strict";var s;i.d(t,{RiskRewardPointIndex:()=>s}),function(e){e[e.Entry=0]="Entry",e[e.Close=1]="Close",e[e.ActualEntry=2]="ActualEntry",e[e.ActualClose=3]="ActualClose"}(s||(s={}))},29378:(e,t,i)=>{"use strict";i.d(t,{LineToolRiskRewardLong:()=>T,LineToolRiskRewardShort:()=>x});var s=i(50151),r=i(87663),n=i(86094),o=i(34256),a=i(13087),l=i(4895),c=i(95539),h=i(42275),d=i(87095);class u extends h.PriceAxisView{constructor(e,t){super(),this._source=e,this._data=t}_updateRendererData(e,t,i){if(e.visible=!1,!this._showAxisLabel())return;const s=this._source.priceScale();if(0===this._source.points().length||null===s||s.isEmpty())return;const r=this._source.ownerSource(),n=null!==r?r.firstValue():null;if(null===n)return;const o=this._data.priceProperty.value(),a=(0,d.resetTransparency)(this._data.colorProperty.value());i.background=a,i.textColor=this.generateTextColor(a),i.coordinate=s.priceToCoordinate(o,n),e.text=s.formatPrice(o,n),e.visible=!0}_showAxisLabel(){return this._source.properties().childs().showPriceLabels.value()}}var p=i(59452),_=i.n(p);class m extends(_()){constructor(e,t){super(),this._lineSource=e,this._pointIndex=t}value(){const e=this._lineSource.points()[this._pointIndex].price;return this._formatAndParsePrice(e)}state(){return this.value()}merge(e,t){return this.setValue(e),t?[]:null}_formatAndParsePrice(e){const t=(0,s.ensureNotNull)(this._lineSource.ownerSource()).formatter();if(t.parse){const i=t.format(e),s=t.parse(i);return s.res?s.value:e}return e}}class g extends m{constructor(e){super(e,0)}setValue(e){ -const t=this._lineSource.points()[this._pointIndex];this._lineSource.startChanging(this._pointIndex,t),t.price=parseFloat(""+e),this._lineSource.setPoint(this._pointIndex,t),this._lineSource.recalculate(),this._lineSource.model().updateSource(this._lineSource),this._listeners.fire(this),this._lineSource.endChanging(!1,!1),this._lineSource.syncPriceLevels()}}class f extends m{constructor(e){super(e,1)}value(){const e=this._lineSource.stopPrice();return this._formatAndParsePrice(e)}setValue(e){const t=Math.round(Math.abs(e-this._lineSource.entryPrice())*this._lineSource.ownerSourceBase());this._lineSource.properties().childs().stopLevel.setValue(t),this._lineSource.syncPriceLevels()}}class v extends m{constructor(e){super(e,2)}value(){const e=this._lineSource.profitPrice();return this._formatAndParsePrice(e)}setValue(e){const t=Math.round(Math.abs(e-this._lineSource.entryPrice())*this._lineSource.ownerSourceBase());this._lineSource.properties().childs().profitLevel.setValue(t),this._lineSource.syncPriceLevels()}}var S=i(1722),y=i(88348),b=i(28558);function w(e){return parseFloat(e.toFixed(2))}class P extends a.LineDataSource{constructor(e,t,n,a){super(e,t,n,a),this._syncStateExclusions=["points","entryPrice","stopPrice","targetPrice","stopLevel","profitLevel","riskSize","qty","amountTarget","amountStop"],this._riskInChange=!1,this.version=2,t.hasChild("stopLevel")||t.hasChild("profitLevel")||(t.addProperty("stopLevel",0),t.addProperty("profitLevel",0),this.ownerSourceChanged().subscribe(this,(()=>{const i=(0,s.ensureNotNull)(e.timeScale().visibleBarsStrictRange()),r=i.firstBar(),n=i.lastBar(),a=(0,s.ensureNotNull)(this.ownerSource()),l=a.priceScale();let c=(0,s.ensureNotNull)(a.priceRange(r,n));if(l&&l.isLog()){const e=l.logicalToPrice(c.minValue()),t=l.logicalToPrice(c.maxValue());c=new o.PriceRange(e,t)}if(c&&!c.isEmpty()){const e=Math.round(.2*c.length()*this.ownerSourceBase());t.merge({stopLevel:e,profitLevel:e})}}),!0));const h=t.childs();h.stopLevel.listeners().subscribe(this,this.recalculate),h.stopLevel.listeners().subscribe(null,(()=>{this.properties().childs().stopPrice.childChanged(null)})),h.profitLevel.listeners().subscribe(this,this.recalculate),h.profitLevel.listeners().subscribe(null,(()=>{this.properties().childs().targetPrice.childChanged(null)})),t.addChild("entryPrice",new g(this)),t.addChild("stopPrice",new f(this)),t.addChild("targetPrice",new v(this)),t.hasChild("riskSize")||t.addProperty("riskSize",0),t.hasChild("qty")||t.addProperty("qty",0),t.hasChild("amountTarget")||t.addProperty("amountTarget",h.accountSize.value()),t.hasChild("amountStop")||t.addProperty("amountStop",h.accountSize.value()),t.addExclusion("riskSize"),t.addExclusion("qty"),t.addExclusion("amountTarget"),t.addExclusion("amountStop"),this._riskInPercentsFormatter=new r.NumericFormatter(2),this._riskInMoneyFormatter=new r.NumericFormatter,h.risk.subscribe(this,this._recalculateRiskSize),h.accountSize.subscribe(this,this._recalculateRiskSize),h.riskDisplayMode.subscribe(this,this._recalculateRisk), -h.riskDisplayMode.subscribe(this,this._recalculateRiskSize),h.entryPrice.subscribe(this,this._recalculateRiskSize),h.stopPrice.subscribe(this,this._recalculateRiskSize),h.profitLevel.subscribe(this,this._recalculateRiskSize),h.profitLevel.subscribe(this,this.syncPriceLevels.bind(this)),h.stopLevel.subscribe(this,this._recalculateRiskSize),h.stopLevel.subscribe(this,this.syncPriceLevels.bind(this)),h.qty.subscribe(this,this._recalculateRiskSize),this.ownerSourceChanged().subscribe(null,((e,t)=>{e&&e.barsProvider().dataUpdated().unsubscribeAll(this),t&&t.barsProvider().dataUpdated().subscribe(this,this._onSeriesUpdated)})),this.pointAdded().subscribe(this,(e=>{switch(e){case c.RiskRewardPointIndex.Entry:case c.RiskRewardPointIndex.Close:this._recalculateRiskSize(),this._recalculateQty()}})),this.pointChanged().subscribe(this,(e=>{switch(e){case c.RiskRewardPointIndex.Entry:case c.RiskRewardPointIndex.Close:this._recalculateRiskSize(),this._recalculateQty()}})),h.riskDisplayMode.value()===l.RiskDisplayMode.Percentage&&h.risk.value()>100&&h.riskDisplayMode.setValueSilently(l.RiskDisplayMode.Money),h.entryPrice.subscribe(this,this._recalculateQty),h.stopPrice.subscribe(this,this._recalculateQty),h.riskSize.subscribe(this,this._recalculateQty),h.entryPrice.subscribe(this,this._recalculateAmount),h.profitLevel.subscribe(this,this._recalculateAmount),h.stopLevel.subscribe(this,this._recalculateAmount),h.accountSize.subscribe(this,this._recalculateAmount),h.riskSize.subscribe(this,this._recalculateAmount),h.qty.subscribe(this,this._recalculateAmount),this._entryPriceAxisView=new u(this,{colorProperty:h.linecolor,priceProperty:h.entryPrice}),this._stopPriceAxisView=new u(this,{colorProperty:h.stopBackground,priceProperty:h.stopPrice}),this._profitPriceAxisView=new u(this,{colorProperty:h.profitBackground,priceProperty:h.targetPrice}),i.e(1583).then(i.bind(i,56457)).then((({RiskRewardPaneView:t})=>{const i=[new t(this,e)];this._setPaneViews(i)}))}destroy(){var e;null===(e=this.ownerSource())||void 0===e||e.barsProvider().dataUpdated().unsubscribeAll(this),this.ownerSourceChanged().unsubscribeAll(this),super.destroy()}hasEditableCoordinates(){return!1}setOwnerSource(e){super.setOwnerSource(e);const t=this.ownerSource();t&&t.symbolSource().symbolInfo()&&(this._recalculateAmount(),this._recalculateRiskSize(),this._recalculateQty())}pointsCount(){return 1}priceAxisViews(e,t){return this.isSourceHidden()||t!==this.priceScale()||this._model.paneForSource(this)!==e?null:[this._entryPriceAxisView,this._stopPriceAxisView,this._profitPriceAxisView]}updateAllViews(e){this.isActualSymbol()&&this.properties().childs().visible.value()&&((0,y.hideAllDrawings)().value()&&this.userEditEnabled()||(super.updateAllViews(e),this._entryPriceAxisView.update(e),this._stopPriceAxisView.update(e),this._profitPriceAxisView.update(e)))}migrateVersion(e,t,i){if(1===e&&this._points.length>=1){const e=[];e.push(this._points[0]);let t=this._points[0];if(t={price:t.price,index:this._getClosePointIndex(t.index)},e.push(t), -this._points[1]&&e.push(this._points[1]),this._points[2]&&e.push(this._points[2]),this._points=e,this._timePoint.length>=1){const t=[],i=this._timePoint[0];t.push(i);const s={price:i.price,time_t:i.time_t,offset:this._getClosePointIndex(i.offset)};t.push(s),this._timePoint[1]&&e.push(this._points[1]),this._timePoint[2]&&e.push(this._points[2]),this._timePoint=t}}}restoreExternalState(e){if((0,S.isNumber)(e.entryPrice)){if(e=Object.assign({},e),!this.isActualSymbol()){this._timePoint[0].price=e.entryPrice,delete e.entryPrice}this.properties().merge(e)}else super.restoreExternalState(e)}addPoint(e,t,i){e.price=this._roundPrice(e.price),super.addPoint(e,void 0,!0);const s={price:e.price,index:this._getClosePointIndex(e.index)};super._addPointIntenal(s,void 0,!0);const r=this._calculateActualEntry(e,s);if(r){super._addPointIntenal(r,void 0,!0);const e=this._findClosePoint(r,s);e&&super._addPointIntenal(e,void 0,!0)}return this._lastPoint=null,this.normalizePoints(),this.createServerPoints(),!0}setPoint(e,t,i,s){if(!this.isActualSymbol())return;const r=this.properties().childs();switch(this._muteSyncLineStyle(),e){case 0:this._changeEntryPoint(t);break;case 2:r.stopPrice.setValue(this.prepareStopPrice(t.price));break;case 3:r.targetPrice.setValue(this.prepareProfitPrice(t.price));break;case 1:t.price=this._roundPrice(t.price),super.setPoint(1,t),this.recalculate()}this._unmuteSyncLineStyleWithoutApplyingChanges(),this.syncPriceLevels()}getPoint(e){switch(e){case 0:return this._points[0];case 1:return{index:this._points[1].index,price:this._points[0].price};case 2:return{index:this._points[0].index,price:this.stopPrice()};case 3:return{index:this._points[0].index,price:this.profitPrice()}}return null}setPoints(e){this._muteSyncLineStyle(),super.setPoints(e),this.recalculate(),this._unmuteSyncLineStyleWithoutApplyingChanges(),this.syncPriceLevels()}start(){super.start(),this.recalculate()}startMoving(e,t,i,r){const n=(0,s.ensureDefined)(e.logical);n.price=this._roundPrice(n.price),super.startMoving(e,t,i)}move(e,t,i,r){const n=(0,s.ensureDefined)(e.logical);n.price=this._roundPrice(n.price),super.move(e,t,i),this.recalculate(),this._entryPriceAxisView.update((0,b.sourceChangeEvent)(this.id()))}axisPoints(){if(!this._points[c.RiskRewardPointIndex.ActualEntry])return[];const e=this._points[c.RiskRewardPointIndex.ActualEntry];let t=null;if(4===this._points.length)t=this._points[c.RiskRewardPointIndex.ActualClose];else{const e=this.lastBarData();if(!e)return[];t={index:e.index,price:e.closePrice}}return[e,t]}recalculateStateByData(){this.recalculate()}recalculate(){if(0===this.points().length)return;const e=this.properties().childs(),t=e.targetPrice.value(),i=e.stopPrice.value(),s=[this._points[0],this._points[1]],r=this._calculateActualEntry(this.points()[0],this.points()[1]);if(r){s.push(r);const e=this._findClosePoint(r,this.points()[1]);e&&s.push(e)}this._points=s,t!==e.targetPrice.value()&&e.targetPrice.listeners().fire(e.targetPrice),i!==e.stopPrice.value()&&e.stopPrice.listeners().fire(e.stopPrice)}syncPriceLevels(){ -const e=this.linkKey().value();if(e){const t=this.properties().childs(),i={entryPrice:t.entryPrice.value(),stopLevel:t.stopLevel.value(),profitLevel:t.profitLevel.value()};(0,y.changeLineStyle)({linkKey:e,state:i,model:this._model})}}entryPrice(){return this.points()[0].price}lastBarData(){var e;const t=null===(e=this.ownerSource())||void 0===e?void 0:e.barsProvider();if(!t)return null;const i=t.bars().firstIndex(),r=t.bars().lastIndex();if(null===i||null===r||isNaN(i)||isNaN(r))return null;const o=this.points();if(4===o.length){const e=o[c.RiskRewardPointIndex.ActualClose];return e.indexs?(e.risk.setValue(s),e.riskSize.setValue(s)):e.riskSize.setValue(t)}_roundPrice(e){const t=this.ownerSourceBase();return Math.round(e*t)/t}_ownerSourcePointValue(){var e,t,i;return null!==(i=null===(t=null===(e=this.ownerSource())||void 0===e?void 0:e.symbolSource().symbolInfo())||void 0===t?void 0:t.pointvalue)&&void 0!==i?i:1}static _configureProperties(e){a.LineDataSource._configureProperties(e),e.addExclusion("stopLevel"),e.addExclusion("profitLevel"),e.addExclusion("stopPrice"),e.addExclusion("targetPrice"),e.addExclusion("entryPrice")}_onSeriesUpdated(e,t,i){this.isSourceHidden()||this._points.length<2||null!==i&&i.index>Math.max(this._points[0].index,this._points[1].index)||this.recalculateStateByData()}_recalculateRisk(){const e=this.properties().childs(),t=e.riskDisplayMode.value(),i=e.riskSize.value(),s=e.accountSize.value();let r=e.risk.value();r=t===l.RiskDisplayMode.Percentage?w(i/s*100):w(s/100*r),this._riskInChange=!0,e.risk.setValue(+this._riskFormatter(t).format(r)),this._riskInChange=!1}_recalculateAmount(){ -if(0===this.points().length)return;const e=this.properties().childs(),t=e.accountSize.value(),i=e.entryPrice.value(),s=e.qty.value(),r=e.stopPrice.value(),n=e.targetPrice.value(),o=this._ownerSourcePointValue();e.amountTarget.setValue(this._amountTarget(t,n,i,s,o)),e.amountStop.setValue(this._amountStop(t,r,i,s,o))}_recalculateQty(){if(0===this.points().length)return;const e=this.properties().childs(),t=e.entryPrice.value(),i=e.stopPrice.value(),s=e.riskSize.value()/(Math.abs(t-i)*this._ownerSourcePointValue());e.qty.setValue(s)}_calculateActualEntry(e,t){const i=this.ownerSource();if(!i)return null;const r=i.barsProvider().bars();if(r.isEmpty())return null;const n=(0,s.ensureNotNull)(r.firstIndex()),o=Math.max(e.index,n),a=e.price,l=(0,s.ensureNotNull)(r.lastIndex()),c=Math.min(l,t.index),h=r.rangeIterator(o,c+1);for(;h.hasNext();){const e=h.next(),t=e.value;if(null!==t&&(0,s.ensure)(t[2])>=a&&(0,s.ensure)(t[3])<=a)return{index:e.index,price:a}}return null}_riskFormatter(e){return e===l.RiskDisplayMode.Percentage?this._riskInPercentsFormatter:this._riskInMoneyFormatter}_getClosePointIndex(e){const t=this._model.timeScale(),i=Math.round(t.width()/t.barSpacing());return e+Math.max(3,Math.round(.15*i))}_findClosePoint(e,t){const i=this.ownerSource();if(!i)return null;const r=i.barsProvider().bars(),n=(0,s.ensureNotNull)(r.firstIndex()),o=Math.max(e.index,n),a=(0,s.ensureNotNull)(r.lastIndex()),l=Math.min(a,t.index),c=r.rangeIterator(o,l+1);for(;c.hasNext();){const e=c.next(),t=e.value;if(null===t)continue;const i=this._checkStopPrice(t);if(null!=i)return{index:e.index,price:i}}return null}_changeEntryPoint(e){const t=this.properties().childs(),i=t.stopPrice.value(),s=t.targetPrice.value(),r=1/this.ownerSourceBase(),n=Math.min(i,s)+r,o=Math.max(i,s)-r;e.price=Math.max(n,Math.min(o,this._roundPrice(e.price))),super.setPoint(0,e),t.stopPrice.setValue(i),t.targetPrice.setValue(s)}}var C=i(46100);class x extends P{constructor(e,t,i,s){super(e,null!=t?t:x.createProperties(),i,s)}name(){return"Risk/Reward short"}stopPrice(){return this.entryPrice()+this.properties().childs().stopLevel.value()/this.ownerSourceBase()}calculatePL(e){return this.entryPrice()-e}profitPrice(){return this.entryPrice()-this.properties().childs().profitLevel.value()/this.ownerSourceBase()}prepareStopPrice(e){e=this._roundPrice(e);const t=this.entryPrice()+1/this.ownerSourceBase();return Math.max(e,t)}prepareProfitPrice(e){e=this._roundPrice(e);const t=this.entryPrice()-1/this.ownerSourceBase();return Math.min(e,t)}static createProperties(e){const t=new C.DefaultProperty("linetoolriskrewardshort",e);return this._configureProperties(t),t}_amountTarget(e,t,i,s,r){return w(e+(i-t)*s*r)}_amountStop(e,t,i,s,r){return w(e-(t-i)*s*r)}_checkStopPrice(e){const t=this.stopPrice(),i=this.profitPrice();return(0,s.ensure)(e[2])>=t?this.stopPrice():(0,s.ensure)(e[3])<=i?this.profitPrice():null}_orderSide(){throw new Error("not supported")}}class T extends P{constructor(e,t,i,s){super(e,null!=t?t:T.createProperties(),i,s)}name(){return"Risk/Reward long"}stopPrice(){ -return this.entryPrice()-this.properties().childs().stopLevel.value()/this.ownerSourceBase()}profitPrice(){return this.entryPrice()+this.properties().childs().profitLevel.value()/this.ownerSourceBase()}calculatePL(e){return e-this.entryPrice()}prepareStopPrice(e){e=this._roundPrice(e);const t=this.entryPrice()-1/this.ownerSourceBase();return Math.min(e,t)}prepareProfitPrice(e){e=this._roundPrice(e);const t=this.entryPrice()+1/this.ownerSourceBase();return Math.max(e,t)}static createProperties(e){const t=new C.DefaultProperty("linetoolriskrewardlong",e);return this._configureProperties(t),t}_amountTarget(e,t,i,s,r){return w(e+(t-i)*s*r)}_amountStop(e,t,i,s,r){return w(e-(i-t)*s*r)}_checkStopPrice(e){const t=this.stopPrice(),i=this.profitPrice();return(0,s.ensure)(e[3])<=t?this.stopPrice():(0,s.ensure)(e[2])>=i?this.profitPrice():null}_orderSide(){throw new Error("not supported")}}},32491:(e,t,i)=>{"use strict";var s=i(86441).Point,r=i(4652).distanceToLine,n=i(13087).LineDataSource,o=i(46100).DefaultProperty,a=i(68806).LineToolColorsProperty;class l extends n{constructor(e,t,s,r){super(e,t||l.createProperties(),s,r),i.e(1583).then(i.t.bind(i,55832,19)).then((({RotatedRectanglePaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}startChanging(e,t){if(super.startChanging(e,t),0===e||1===e){var i=this._getPaneViews()[0],s=i._points[0],n=i._points[1],o=i._points[2];this._distance=r(s,n,o).distance}}setPoint(e,t,i){if(super.setPoint(e,t,i),0===e||1===e){var r=this._getPaneViews()[0];r.update();var n=r._points[0],o=r._points[1].subtract(n),a=new s(o.y,-o.x).normalized().scaled(this._distance),l=n.add(a),c=this.screenPointToPoint(l);this._points[2]=c}}endChanging(e,t){delete this._distance,super.endChanging(e,t)}pointsCount(){return 3}name(){return"Rotated Rectangle"}hasEditableCoordinates(){return!1}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,20061))).GeneralFiguresDefinitionsViewModel}_snapTo45DegreesAvailable(){return!0}static createProperties(e){var t=new o("linetoolrotatedrectangle",e);return this._configureProperties(t),t}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new a([e.color]))}}t.LineToolRotatedRectangle=l},5761:(e,t,i)=>{"use strict";var s=i(53801).LevelsProperty,r=i(70309).LineToolPitchfork;class n extends r{constructor(e,t,i,s){super(e,t||n.createProperties(),i,s)}name(){return"Modified Schiff Pitchfork"}static createProperties(e){var t=new s("linetoolschiffpitchfork",e,!1,{range:[0,8]});return this._configureProperties(t),t}}t.LineToolSchiffPitchfork=n},85806:(e,t,i)=>{"use strict";var s=i(53801).LevelsProperty,r=i(70309).LineToolPitchfork;class n extends r{constructor(e,t,i,s){super(e,t||n.createProperties(),i,s)}name(){return"Schiff Pitchfork"}static createProperties(e){var t=new s("linetoolschiffpitchfork2",e,!1,{range:[0,8]});return this._configureProperties(t),t}}t.LineToolSchiffPitchfork2=n},98624:(e,t,i)=>{"use strict";i.d(t,{LineToolSignpost:()=>g}) -;var s=i(44352),r=i(46100),n=i(13087),o=i(59452),a=i.n(o);class l extends(a()){constructor(e){super(),this._source=e,e.pointAdded().subscribe(this,(()=>this.listeners().fire(this))),e.pointChanged().subscribe(this,(()=>this.listeners().fire(this)))}value(){const e=this._source.properties().childs().position.value();return parseFloat(e.toFixed(2))}setValue(e){this._source.properties().childs().position.setValue(e),this._source.model().updateSource(this._source),this.listeners().fire(this),this._source.syncMultichartState({pricesChanged:!1,indexesChanged:!1})}}var c=i(75149);class h extends c.LineDataSourcePointIndexProperty{constructor(e,t){super(e,t),this._source=e}_setPointImpl(e){this._source.setPointAndChangeIndex(this._pointIndex,e)}}var d=i(68806),u=i(50151),p=i(85573),_=i(88348);class m extends n.LineDataSource{constructor(){super(...arguments),this._startMovingAnchorY=NaN}priceSource(){return this.ownerSource()}addPoint(e,t,i){return super.addPoint(this._updatePositionAndCorrectPoint(e),t,i)}setPoint(e,t,i){super.setPoint(e,this._updatePositionAndCorrectPoint(t,!this.isPhantom()&&!this._allowChangeAnchorHorizontally()),i),this._syncPosition()}setPointAndChangeIndex(e,t,i){super.setPoint(e,this._updatePositionAndCorrectPoint(t,!1),i),this._syncPosition()}startMoving(e,t,i,s){s||(this._startMovingAnchorY=(0,u.ensureNotNull)(this._anchorYCoordinate())),super.startMoving(e,t,i)}move(e,t,i,s){var r;const n=(0,u.ensureDefined)((0,u.ensureNotNull)(this.startMovingPoint()).logical),o=(0,u.ensureDefined)(e.logical);if(!s&&0===t){const e=this._points[0],t=o.index-n.index,i=(0,u.ensureNotNull)(this.priceScale()),s=(0,u.ensure)(null===(r=this.ownerSource())||void 0===r?void 0:r.firstValue()),a=i.priceToCoordinate(o.price,s)-i.priceToCoordinate(n.price,s),l=this._startMovingAnchorY+a,c=i.coordinateToPrice(l,s);this._updatePositionAndCorrectPoint({index:e.index+t,price:c})}super.move(e,t,i),s||this._syncPosition()}_allowChangeAnchorHorizontally(){return!1}_updatePositionAndCorrectPoint(e,t){t&&(e.index=this._points[0].index);const i=this.priceSource();if(null===i)return e;const s=i.priceScale(),r=i.firstValue();if(null===s||s.isEmpty()||null===r)return e;const n=s.height();let o=n/2,a=e.price>=s.coordinateToPrice(o,r)?1:-1;const l=this._model.mainSeries();if(i===l){const t=l.data().search(this._baseSeriesIndexForPoint(e));if(null!==t){const i=(0,p.seriesPrice)(l,t,-1),n=(0,p.seriesPrice)(l,t,1);a=e.price>=i?1:-1,o=s.priceToCoordinate(1===a?n:i,r),e.price=1===a?Math.max(n,e.price):e.price}}const c=1===(-1===a!==s.isInverted()?-1:1)?o:n-o,h=s.priceToCoordinate(e.price,r),d=Math.min(n,Math.abs(h-o)),u=Math.max(0,Math.min(100,100*d/c))*a;return this.properties().childs().position.setValue(u),e}_baseSeriesIndexForPoint(e){return e.index}_syncPosition(){const e=this.linkKey().value();if(null!==e){const t={position:this.properties().childs().position.value()};(0,_.changeLineStyle)({linkKey:e,state:t,model:this._model})}}_anchorYCoordinate(){const e=this.priceSource();if(null===e)return null;const t=e.priceScale(),i=e.firstValue() -;if(null===t||t.isEmpty()||null===i)return null;const s=this._model.mainSeries(),r=this.customEvent();if(null===r)return null;let n=null;if(e===s&&(n=(0,p.seriesBasePosition)(s,r)),null===n&&(n=(0,p.noDataBasePosition)(r,t,i)),null===n)return null;const o=r.position(),a=t.priceToCoordinate(n.price,i);return(0,p.positionToCoordinate)(o,t.height(),a,(0,p.positionVisualDirection)(o,t.isInverted()))}}class g extends m{constructor(e,t,s,r){super(e,null!=t?t:g.createProperties(),s,r),i.e(1583).then(i.bind(i,26294)).then((t=>{this._setPaneViews([new t.SignpostPaneView(this,e)])}))}pointsCount(){return 1}name(){return"Signpost"}customEvent(){return{index:()=>{var e,t;return null!==(t=null===(e=this.points()[0])||void 0===e?void 0:e.index)&&void 0!==t?t:null},position:()=>this.properties().childs().position.value()}}showInObjectTree(){return!this.isPhantom()&&super.showInObjectTree()}isPhantom(){return this._model.isPhantomLine(this)}clonePositionOffset(){return{barOffset:1,xCoordOffset:0,yCoordOffset:0}}template(){const e=super.template(),t=this.properties().childs();return e.text=t.text.value(),e.position=t.position.value(),e}shouldBeRemovedOnDeselect(){const e=this._properties.childs();if(e.showImage.value())return!1;return""===e.text.value().trim()}static createProperties(e){const t=new r.DefaultProperty("linetoolsignpost",e);return this._configureProperties(t),t.hasChild("text")||t.addChild("text",new(a())(s.t(null,void 0,i(37229)))),t.hasChild("position")||t.addChild("position",new(a())(50)),t.addExclusion("text"),t.addExclusion("position"),t.addChild("backgroundsColors",new d.LineToolColorsProperty([t.childs().plateColor])),t}_createPointProperty(e){super._createPointProperty(e);const t=this._pointsProperty.childs().points[e];t.removeProperty("price"),t.removeProperty("bar"),t.addChild("price",new l(this)),t.addChild("bar",new h(this,0))}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text),this.properties().childs().position.setValue(e.position)}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,18613)).then((e=>e.SignpostDefinitionsViewModel))}static _configureProperties(e){n.LineDataSource._configureProperties(e)}}g.supportPhantomMode=!0},94803:(e,t,i)=>{"use strict";i.d(t,{LineToolSineLine:()=>n});var s=i(46100),r=i(13087);class n extends r.LineDataSource{constructor(e,t,s,r){super(e,t||n.createProperties(),s,r),i.e(1583).then(i.bind(i,5362)).then((e=>{this._setPaneViews([new e.SineLinePaneView(this,this._model)])}))}pointsCount(){return 2}name(){return"Sine Line"}static createProperties(e){const t=new s.DefaultProperty("linetoolsineline",e);return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,15673))).CyclicAndSineLinesPatternDefinitionsViewModel}}},95366:(e,t,i)=>{"use strict";i.d(t,{LineToolSticker:()=>o});var s=i(46100),r=i(8459);const n=(0, -i(59224).getLogger)("Chart.LineToolSticker");class o extends r.LineToolSvgIconBase{constructor(e,t,i,s){super(e,t||o.createProperties(),i,s),this.version=1,this._loadViews()}name(){return"Sticker"}static createProperties(e){const t=new s.DefaultProperty("linetoolsticker",e);return o._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,85766))).LineDataSourceDefinitionsViewModel}async _loadViews(){const[{getSvgContentForSticker:e,getSvgRenderer:t},{StickerPaneView:s},{svgRenderer:r}]=await Promise.all([i.e(5598).then(i.bind(i,31235)),i.e(1583).then(i.bind(i,15378)),i.e(2616).then(i.bind(i,50765))]);if(!this._isDestroyed){const i=this._properties.childs().sticker.value();this._svgContent=e(i),this._onIconChanged.fire();const o=t(r,i);null===o&&n.logWarn(`Couldn't create svg renderer for sticker ${i}`),this._setPaneViews([new s(this,this._model,o)])}}}},4063:(e,t,i)=>{"use strict";i.d(t,{StudyLineDataSource:()=>C});var s=i(50151),r=i(1722),n=i(97034),o=i(13087),a=i(46100),l=i(42856),c=i(12442),h=i(33703),d=i(94739),u=i(75319),p=i(72007),_=i(76949),m=i(41249),g=i(77475),f=i(28558),v=i(13333),S=i(11877);class y extends S.StatusProviderBase{constructor(e){super(e.model().properties().childs().scalesProperties.childs().textColor),this._source=e}color(){return"#ff0000"}errorStatus(){const e=this._source.status();return e.type===v.StudyStatusType.Error?{error:this.sourceStatusText(),solutionId:(0,v.studyStatusSolutionId)(e),title:(0,v.studyStatusTitle)(e),studyFeature:(0,v.studyStatusFeature)(e)}:null}getSplitTitle(){return this._source.titleInParts()}text(){return this._source.translatedType()}sourceStatusText(){return(0,v.convertStudyStatusToString)(this._source.status(),!0)}}var b=i(91280),w=i(79055);class P extends w.StatusView{constructor(e){super(e.statusProvider({}))}getSplitTitle(){return this._statusProvider.getSplitTitle()}}class C extends o.LineDataSource{constructor(e,t,s,r,n,o){super(e,r,n,o),this._indexes=null,this._inputs=null,this._definitionsViewModel=null,this._pointsetPoints=null,this._loadedPlots=null,this._loadedGraphics=null,this._beingCreatedPaneView=null,this._anchorsPaneView=null,this._isLegendDisplayed=!1,this._alignerCache=null,Promise.all([i.e(1583).then(i.bind(i,99058)),i.e(1583).then(i.bind(i,44666))]).then((t=>{const{LineToolBeingCreatedPaneView:i}=t[0],{StudyLineDataSourceAnchorsPaneView:s}=t[1];this._beingCreatedPaneView=new i(this,e),this._anchorsPaneView=new s(this,this.model()),this._model.lightUpdate()})),this._metaInfo=t,this._dataSource=new d.StudyDataSource(e.chartApi(),e.mainSeries().seriesSource(),s,t),this._dataSource.dataCleared().subscribe(this,this._onDataCleared),this._dataSource.dataUpdated().subscribe(this,this._onDataUpdated),this._dataSource.studyStatusChanged().subscribe(this,this._onStudyStatusChanged),this._statusProvider=new y(this),this._statusView=new P(this), -this._showStudyArgumentsProperty=e.properties().childs().paneProperties.childs().legendProperties.childs().showStudyArguments}isDisplayedInLegend(){return this._isLegendDisplayed}titleInParts(){const e=[];if(this._showStudyArgumentsProperty.value()&&this._inputs)for(const t of this._metaInfo.inputs){if(!0===t.isHidden||"bool"===t.type)continue;const i=this._inputs[t.id];e.push(i.toString())}return[this.name(),e]}destroy(){this._dataSource.dataUpdated().unsubscribeAll(this),this._dataSource.dataCleared().unsubscribeAll(this),this._dataSource.studyStatusChanged().unsubscribeAll(this),this._dataSource.destroy(),null!==this._definitionsViewModel&&(this._definitionsViewModel.destroy(),this._definitionsViewModel=null),this._unsubscribeApplyInputsOnSeriesCompleted(),this._isDestroyed=!0,super.destroy()}stop(){super.stop(),this._isDestroyed||(this._dataSource.stop(),this.clearData())}start(){super.start(),this._isDestroyed||null===this._inputs||this._dataSource.start()}metaInfo(){return this._metaInfo}graphicsInfo(){return this._metaInfo.graphics}series(){return this._model.mainSeries()}translatedType(){return this._metaInfo.description}name(){return this._metaInfo.description}studyId(){return this._metaInfo.id}setPoint(e,t,i){super.setPoint(e,this._preparePoint(t,i))}move(e){}clearData(){this._clearAllDataExceptPointsetPoints(),this._pointsetPoints=null,this.updateAllViews((0,f.sourceChangeEvent)({sourceId:this.id(),clearData:!0})),super.clearData()}data(){return this.plots()}plots(){return this._loadedPlots||this._dataSource.plots()}graphics(){return this._loadedGraphics||this._dataSource.graphics()}valueAt(e,t){var i,s;return null!==(s=null===(i=this.ownerSource())||void 0===i?void 0:i.symbolSource().valueAt(e,t))&&void 0!==s?s:null}firstValue(){return this._model.mainSeries().firstValue()}state(e){const t=super.state(e);let i;this.metaInfo()instanceof l.StudyMetaInfo?i=this.metaInfo().state():(i=(0,r.clone)(this.metaInfo()),i.id=l.StudyMetaInfo.parseIdString(i.id+(i.version?"-"+i.version:"")).fullId);const s={...t,metaInfo:i};return e&&(s.data=this.plots().state(),s.nonseriesindexes=this._indexes,s.graphics=(0,c.saveStudyGraphics)(this.graphics(),null)),s}restoreData(e){var t;void 0!==e.data&&(this._loadedPlots=new n.PlotList((0,p.studyPlotFunctionMap)(this._metaInfo),p.studyEmptyPlotValuePredicate),this._loadedPlots.restoreState(e.data)),this._indexes=null!==(t=e.nonseriesindexes)&&void 0!==t?t:this._indexes,this._loadedGraphics=e.graphics?(0,c.loadStudyGraphics)(e.graphics):this._loadedGraphics}getPropertyDefinitionsViewModel(){return null===this._definitionsViewModel?this._getPropertyDefinitionsViewModelClass().then((e=>null===e||this._isDestroyed?null:(null===this._definitionsViewModel&&(this._definitionsViewModel=new e(this._model.undoModel(),this)),this._definitionsViewModel))):Promise.resolve(this._definitionsViewModel)}paneViews(e){let t=[];if(this.isSourceHidden())return t;if(this._isReady()&&this._changeStatesStack.isEmpty()){const i=super.paneViews(e);null!==i&&(t=t.concat(i)) -}else null!==this._beingCreatedPaneView&&t.push(this._beingCreatedPaneView);return null!==this._anchorsPaneView&&t.push(this._anchorsPaneView),t}propertiesChanged(e){super.propertiesChanged(e),this._onStudyInputsMayChange()}dataAndViewsReady(){return super.dataAndViewsReady()&&this._isReady()}endChanging(e,t){const i=super.endChanging(e,t);return i.indexesChanged?this.clearData():this._updateAnchorsPrice(!0),i}moveData(e){this._dataSource.moveData(e)}restorePoints(e,t,i){super.restorePoints(e,t,i),this._updateAnchorsPrice(!0)}realign(){super.realign(),null===this._model.mainSeries().symbolInfo()&&(this._alignerCache=null)}statusProvider(e){return this._statusProvider}statusView(){return this._statusView}legendView(){return null}dataProblemModel(){return null}dataUpdatedModeModel(){return null}marketStatusModel(){return null}onStatusChanged(){return this._dataSource.studyStatusChanged()}status(){return this._dataSource.studyStatus()}recalcStudyIfNeeded(){}static createPropertiesFromStudyMetaInfoAndState(e,t,i,s){const r=(0,_.prepareStudyPropertiesForLoadChart)(e,t,i,s);return this._configureProperties(r),r}_onStudyStatusChanged(e,t){let i;switch(t.type){case u.StudyStatusType.Error:i=!0;break;case u.StudyStatusType.Completed:i=!1;break;default:return}if(i===this._isLegendDisplayed)return;this._isLegendDisplayed=i;const s=this._model.paneForSource(this);if(s){const e=this._model.panes().indexOf(s),t=b.InvalidationMask.invalidateLegendWidgetLayout(e);this.model().invalidate(t)}}_studyId(){return this._dataSource.studyId()}_isReady(){return!0}_updateAllPaneViews(e){var t,i;super._updateAllPaneViews(e),null===(t=this._beingCreatedPaneView)||void 0===t||t.update(),null===(i=this._anchorsPaneView)||void 0===i||i.update(e)}_getPointTime(e,t){const i=e.index,s=this._model.timeScale().indexToTimePoint(i);if(null!==s)return s;if(t||void 0===e.time)return null;const r=this._model.mainSeries().symbolInfo();if(null===r)return null;let n=this._model.properties().childs().timezone.value();"exchange"===n&&(n=r.timezone);const o=(0,m.cal_to_utc)((0,m.get_timezone)(n),e.time);return this._getStartBarAligner()(o)/1e3}_updateAnchorsPrice(e){}_onPointsetUpdated(e){super._onPointsetUpdated(e),this._pointsetPoints=this._points.map((e=>({price:e.price,index:e.index,time:e.time}))),this._onStudyInputsMayChange()}_onDataCleared(){this.updateAllViews((0,f.sourceChangeEvent)({sourceId:this.id(),clearData:!0})),this._model.updateSource(this)}_onDataUpdated(e,t,i){var s;this._updateAnchorsPrice(),this.updateAllViews((0,f.sourceChangeEvent)({sourceId:this.id(),firstUpdatedTimePointIndex:null===(s=e[0])||void 0===s?void 0:s.index})),this._model.updateSource(this)}_onStudyInputsMayChange(){let e=null;if(null!==this._pointsetPoints&&this._pointsetPoints.length===this.pointsCount()&&(e=this._studyInputs(this._pointsetPoints),null===e&&(this._clearAllDataExceptPointsetPoints(),this.updateAllViews((0,f.sourceChangeEvent)(this.id())))),null!==e){const t=this.metaInfo().inputs.map((e=>e.id)),i=Object.keys(e);for(const s of i)t.includes(s)||delete e[s]} -this._areInputsEqual(this._inputs,e)||this._applyStudyInputs(e)}_preparePoint(e,t){return super._preparePoint(this._alignPointToRangeOfActualData(e),t)}_getPropertyDefinitionsViewModelClass(){return Promise.resolve(null)}_subscribeApplyInputsOnSeriesCompleted(){this._unsubscribeApplyInputsOnSeriesCompleted(),this._model.mainSeries().dataEvents().completed().subscribe(this,(()=>this._onStudyInputsMayChange()),!0)}_unsubscribeApplyInputsOnSeriesCompleted(){this._model.mainSeries().dataEvents().completed().unsubscribeAll(this)}_onInputsChanged(){0}static _createPropertiesFromStudyIdAndState(e,t){const i=l.StudyMetaInfo.getStudyPropertyRootNameById(e),s=new a.DefaultProperty(i,t);return this._configureProperties(s),s}static _configureProperties(e){super._configureProperties(e),e.removeExclusion("intervalsVisibilities")}_areInputsEqual(e,t){return null===t?null===e:null!==e&&(0,h.areStudyInputsEqual)(this._metaInfo.inputs,e,t)}_applyStudyInputs(e){const t=this._inputs;this._inputs=e,null!==e&&(this._unsubscribeApplyInputsOnSeriesCompleted(),this._dataSource.setInputs(e),null===t&&this.isStarted()&&!this._dataSource.isStarted()&&this._dataSource.start()),this._onInputsChanged()}_clearAllDataExceptPointsetPoints(){this._inputs=null,this._dataSource.clearData(),this._loadedPlots=null,this._indexes=null,this._loadedGraphics=null}_getStartBarAligner(){const e=this._model.mainSeries().interval();return null!==this._alignerCache&&this._alignerCache.resolution===this._model.mainSeries().interval()||(this._alignerCache={resolution:e,aligner:(0,g.createTimeToBarTimeAligner)(e,(0,s.ensureNotNull)(this._model.mainSeries().symbolInfo()))}),this._alignerCache.aligner}}},8459:(e,t,i)=>{"use strict";i.d(t,{LineToolSvgIconBase:()=>l});var s=i(50151),r=i(86441),n=i(25422),o=i(57898),a=i(13087);class l extends a.LineDataSource{constructor(e,t,i,s){super(e,t,i,s),this._onIconChanged=new o.Delegate,this._svgContent=null,this._changePointData=null,this._loadViews()}pointsCount(){return 1}hasEditableCoordinates(){return!1}getAnchorLimit(){return 80}getChangePointForSync(e){return null}startChanging(e,t){const i=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[0])),o=this.properties().childs(),a=o.size.value();let l;if(t)l=(0,s.ensureNotNull)(this.pointToScreenPoint(t));else{let e=new r.Point(0,Math.max(80,a)/2);const t=(0,n.rotationMatrix)(o.angle.value());e=(0,n.transformPoint)(t,e),l=i.add(e)}const c=i.subtract(l).length();this._changePointData={centerPoint:i,initialLength:c,initialSize:a},super.startChanging(e,t)}setPoint(e,t,i){const{centerPoint:r,initialLength:n,initialSize:o}=(0,s.ensureNotNull)(this._changePointData),a=(0,s.ensureNotNull)(this.pointToScreenPoint(t)),l=this.properties().childs();if(0===e||1===e){const t=a.subtract(r).normalized();let i=Math.acos(-t.x);Math.asin(t.y)>0&&(i=2*Math.PI-i),0===e&&(i+=Math.PI),l.angle.setValue(i)}else{const e=o*(r.subtract(a).length()/n);l.size.setValue(e)}}getSourceIcon(){const e=this.svgContent();return null===e?null:{type:"svgContent",content:e}}onSourceIconChanged(){ -return this._onIconChanged}svgContent(){return this._svgContent}static _configureProperties(e){super._configureProperties(e),e.addExclusion("angle")}}},79506:(e,t,i)=>{"use strict";i.d(t,{LineToolText:()=>u,LineToolTextAbsolute:()=>p});var s=i(50151),r=i(86441),n=i(44352),o=i(13087),a=i(59452),l=i.n(a),c=i(46100),h=i(68806),d=i(28558);class u extends o.LineDataSource{constructor(e,t,s,r){const n=t||u.createProperties();super(e,n,s,r),this._barSpacing=e.timeScale().barSpacing(),this._recalculatePointsOnCenter=!1,i.e(1583).then(i.bind(i,62912)).then((({TextPaneView:t})=>{const i=this._recalculatePointsOnCenter?(e,t)=>{this._recalculatePointsOnCenter&&this._recalculateCenterPosition(e,t)}:void 0;this._setPaneViews([new t(this,e,void 0,void 0,void 0,void 0,void 0,i)])}))}centerPosition(){this._recalculatePointsOnCenter=!0}setPoint(e,t,i){const r=this.properties().childs();let n;if(1===e&&r.wordWrapWidth.value()){const e=this.model().timeScale();n=this.isFixed()?(0,s.ensureDefined)(this.fixedPoint()).x:e.indexToCoordinate(this.points()[0].index);const i=e.indexToCoordinate(t.index)-n-~~(r.fontsize.value()/6);if(!isFinite(i))return;r.wordWrapWidth.setValue(Math.max(100,i))}}pointsCount(){return 1}name(){return"Text"}setPriceScale(e){super.setPriceScale(e),e&&e.priceRange()&&(this._priceDencity=e.height()/(0,s.ensureNotNull)(e.priceRange()).length(),this._isPriceDencityLog=e.isLog())}restoreSize(){const e=(0,s.ensureNotNull)(this.priceScale());this._barSpacing=this.model().timeScale().barSpacing(),this._priceDencity=e.height()/(0,s.ensureNotNull)(e.priceRange()).length(),this.redraw((0,d.sourceChangeEvent)(this.id()))}redraw(e){this.updateAllViews(e),this._model.updateSource(this)}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}state(e){const t=super.state(e);return e&&(t.state.fixedSize=!1),t}barSpacing(){return this._barSpacing}priceDencity(){return this._priceDencity}isPriceDencityLog(){return this._isPriceDencityLog}hasEditableCoordinates(){return!1}shouldBeRemovedOnDeselect(){return""===this._properties.childs().text.value().trim()}static createProperties(e){const t=new c.DefaultProperty("linetooltext",e);return this._configureProperties(t),t}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text)}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,94625)).then((e=>e.TextDefinitionsViewModel))}static _configureProperties(e){super._configureProperties(e),e.hasChild("text")||e.addChild("text",new(l())(n.t(null,void 0,i(37229)))),e.addChild("linesColors",new h.LineToolColorsProperty([e.childs().borderColor])),e.addChild("textsColors",new h.LineToolColorsProperty([e.childs().color])),e.addExclusion("text"),e.addExclusion("linesColors"),e.addExclusion("textsColors")}_recalculateCenterPosition(e,t){const i=this.isFixed()?(0,s.ensureDefined)(this.fixedPoint()):(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[0])),n=new r.Point(i.x-e/2,i.y-t/2),o=(0, -s.ensureNotNull)(this.screenPointToPoint(n));this.setPoints([o]),this.normalizePoints(),this.createServerPoints(),this.redraw((0,d.sourceChangeEvent)(this.id()))}}class p extends u{constructor(e,t){super(e,t||p.createProperties())}name(){return"Anchored Text"}hasEditableCoordinates(){return!1}isFixed(){return!0}static createProperties(e){const t=new c.DefaultProperty("linetooltextabsolute",e);return this._configureProperties(t),t}}},89299:(e,t,i)=>{"use strict";i.d(t,{LineToolThreeDrivers:()=>o});var s=i(46100),r=i(13087),n=i(68806);class o extends r.LineDataSource{constructor(e,t,s,r){const n=t||o.createProperties();super(e,n,s,r),i.e(1583).then(i.bind(i,90042)).then((t=>{this._setPaneViews([new t.LineToolThreeDrivesPaneView(this,e)])}))}pointsCount(){return 7}name(){return"Three Drives Pattern"}static createProperties(e){const t=new s.DefaultProperty("linetoolthreedrivers",e);return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,63311)).then((e=>e.PatternWithoutBackgroundDefinitionsViewModel))}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new n.LineToolColorsProperty([e.childs().color])),e.addChild("textsColors",new n.LineToolColorsProperty([e.childs().textcolor])),e.addChild("linesWidths",new n.LineToolWidthsProperty([e.childs().linewidth])),e.hasChild("backgroundsColors")&&e.removeProperty("backgroundsColors")}}},74861:(e,t,i)=>{"use strict";i.d(t,{LineToolTimeCycles:()=>o});var s=i(27788),r=i(46100),n=i(13087);class o extends n.LineDataSource{constructor(e,t,s,r){super(e,null!=t?t:o.createProperties(),s,r),i.e(1583).then(i.bind(i,65557)).then((e=>{this._setPaneViews([new e.TimeCyclesPaneView(this,this._model)])}))}pointsCount(){return 2}name(){return"Time Cycles"}setPoint(e,t){const i=(0,s.default)(t),r=this._points[0],n=this._points[1];r.price=i.price,n.price=i.price,this._points[e]=i,this.normalizePoints()}addPoint(e,t,i){const s=super.addPoint(e,t,!0);if(s){const e=this._points[0];this._points[1].price=e.price,i||(this.normalizePoints(),this.createServerPoints())}return s}static createProperties(e){const t=new r.DefaultProperty("linetooltimecycles",e);return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,81888))).TimeCyclesPatternDefinitionsViewModel}}},87564:(e,t,i)=>{"use strict";const s=i(13087).LineDataSource,r=i(83654).alignToStep;class n extends s{constructor(e,t){super(e,t),this.customization.forcePriceAxisLabel=!0,this.customization.disableErasing=!0,this.customization.showInObjectsTree=!1,this.setSelectionEnabled(!1)}isSynchronizable(){return!1}pointsCount(){return n.POINTS_COUNT}hasContextMenu(){return!1}state(){return null}startMoving(){super.startMoving.apply(this,arguments),this._cursorMoved=!1}endMoving(){super.endMoving.apply(this,arguments),this._cursorMoved=!1}_correctPoints(e,t){ -this._currentMovingPoint&&this._startMovingPoint?this._currentMovingPoint.logical.price-this._startMovingPoint.logical.price&&(this._cursorMoved=!0):this._cursorMoved=!1;for(var i=1/this.priceScale().mainSource().base(),s=0;s{"use strict";i.d(t,{LineToolTrendAngle:()=>d});var s=i(86441),r=i(50151),n=i(46100),o=i(13087),a=i(59452),l=i.n(a),c=i(28558);class h extends(l()){constructor(e){super(),this._lineSource=e}value(){return Math.round(180*this._lineSource.angle()/Math.PI)}setValue(e){const t=e*Math.PI/180,i=(0,r.ensureNotNull)(this._lineSource.pointToScreenPoint(this._lineSource.points()[0])),n=Math.cos(t),o=-Math.sin(t),a=new s.Point(n,o),l=i.addScaled(a,this._lineSource.distance()),h=(0,r.ensureNotNull)(this._lineSource.screenPointToPoint(l));this._lineSource.setPoint(1,h);const d=this._lineSource.model();d.updateSource(this._lineSource),this._lineSource.updateAllViews((0,c.sourceChangeEvent)(this._lineSource.id())),d.updateSource(this._lineSource)}notifyChanged(){this._listeners.fire(this)}}class d extends o.LineDataSource{constructor(e,t,s,r){const n=t||d.createProperties();super(e,n,s,r),this._angle=0,this._distance=0,n.addChild("angle",new h(this)),i.e(1583).then(i.bind(i,67998)).then((({TrendAnglePaneView:t})=>{const i=[new t(this,e)];this._setPaneViews(i)}))}isSynchronizable(){return!1}pointsCount(){return 2}name(){return"Trend Angle"}angle(){return this._angle}distance(){return this._distance}addPoint(e,t){const i=super.addPoint(e,t);return i&&this._calculateAngle(),i}setLastPoint(e,t){const i=super.setLastPoint(e,t);return this.points().length>1&&this._calculateAngle(),i}axisPoints(){if(this.points().length<2)return[];const e=[this.points()[0]],t=(0,r.ensureNotNull)(this.pointToScreenPoint(this.points()[0])),i=Math.cos(this._angle)*this._distance,n=-Math.sin(this._angle)*this._distance,o=t.add(new s.Point(i,n)),a=(0,r.ensureNotNull)(this.screenPointToPoint(o));return e.push(a),e}timeAxisPoints(){return this.axisPoints()}priceAxisPoints(){return this.axisPoints()}setPoint(e,t,i){super.setPoint(e,t,i),this.points().length>1&&1===e&&this._calculateAngle()}restoreData(e){var t,i;this._angle=null!==(t=e.angle)&&void 0!==t?t:0,this._distance=null!==(i=e.distance)&&void 0!==i?i:0}state(e){const t=super.state(e);return t.angle=this._angle,t.distance=this._distance,t}cloneData(e){this._angle=e.angle(),this._distance=e.distance()}canHasAlert(){return!0}static createProperties(e){e&&void 0===e.showPercentPriceRange&&(e.showPercentPriceRange=e.showPriceRange,e.showPipsPriceRange=e.showPriceRange);const t=new n.DefaultProperty("linetooltrendangle",e) -;return this._configureProperties(t),t}_snapTo45DegreesAvailable(){return!0}_getAlertPlots(){const e=this._linePointsToAlertPlot(this._points,null,this._properties.childs().extendLeft.value(),this._properties.childs().extendRight.value());return null===e?[]:[e]}_calculateAngle(){const e=(0,r.ensureNotNull)(this.pointToScreenPoint(this.points()[0]));let t=(0,r.ensureNotNull)(this.pointToScreenPoint(this.points()[1])).subtract(e);const i=t.length();i>0?(t=t.normalized(),this._angle=Math.acos(t.x),t.y>0&&(this._angle=-this._angle),this._distance=i):this._angle=0;this.properties().childs().angle.notifyChanged()}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,34935)).then((e=>e.TrendAngleDefinitionsViewModel))}}},84123:(e,t,i)=>{"use strict";i.d(t,{LineToolTrendBasedFibExtension:()=>c});var s=i(44352),r=i(36298),n=i(53801),o=i(68806),a=i(13087);const l=new r.TranslatedString("erase level line",s.t(null,void 0,i(12962)));class c extends a.LineDataSource{constructor(e,t,s,r){super(e,t||c.createProperties(),s,r),this.version=2,i.e(1583).then(i.bind(i,38058)).then((({TrendBasedFibExtensionPaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}levelsCount(){return 24}pointsCount(){return 3}name(){return"Trend-Based Fib Extension"}migrateVersion(e,t){1===e&&this.properties().childs().extendLines.setValue(!0)}processErase(e,t){const i="level"+t,s=this.properties().childs()[i].childs().visible;e.setProperty(s,!1,l)}fibLevelsBasedOnLogScale(){var e;return this.properties().childs().fibLevelsBasedOnLogScale.value()&&Boolean(null===(e=this.priceScale())||void 0===e?void 0:e.isLog())}static createProperties(e){const t=new n.LevelsProperty("linetooltrendbasedfibextension",e,!1,{range:[0,8]});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,56194))).FibDrawingsWith24LevelsDefinitionsViewModel}static _configureProperties(e){const t=e.childs();super._configureProperties(e);const i=[t.trendline.childs().color];for(let e=1;e<=24;e++){const s=t["level"+e].childs().color;i.push(s)}e.addChild("linesColors",new o.LineToolColorsProperty(i));const s=[t.trendline.childs().linewidth,t.levelsStyle.childs().linewidth];e.addChild("linesWidths",new o.LineToolWidthsProperty(s))}}},35625:(e,t,i)=>{"use strict";i.d(t,{LineToolTrendBasedFibTime:()=>c});var s=i(44352),r=i(36298),n=i(13087),o=i(53801),a=i(68806);const l=new r.TranslatedString("erase level line",s.t(null,void 0,i(12962)));class c extends n.LineDataSource{constructor(e,t,s,r){super(e,t||c.createProperties(),s,r),this.version=1,i.e(1583).then(i.bind(i,33482)).then((({TrendBasedFibTimePaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}levelsCount(){return 11}pointsCount(){return 3}name(){return"Trend-Based Fib Time"}processErase(e,t){const i="level"+t,s=this.properties().childs()[i].childs().visible;e.setProperty(s,!1,l)}static createProperties(e){ -const t=new o.LevelsProperty("linetooltrendbasedfibtime",e,!1,{range:[1,11]});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,60007))).TrendBasedFibTimeDefinitionsViewModel}static _configureProperties(e){super._configureProperties(e);const t=e.childs(),i=[t.trendline.childs().linewidth],s=[t.trendline.childs().color];for(let e=1;e<=11;e++)i.push(t["level"+e].childs().linewidth),s.push(t["level"+e].childs().color);e.addChild("linesColors",new a.LineToolColorsProperty(s)),e.addChild("linesWidths",new a.LineToolWidthsProperty(i))}}},47246:(e,t,i)=>{"use strict";i.d(t,{LineToolTrendLine:()=>l});var s=i(46100),r=i(13087),n=i(71243),o=i(59452),a=i.n(o);class l extends r.LineDataSource{constructor(e,t,s,r){super(e,t||l.createProperties(),s,r),this._trendLinePaneView=null,i.e(1583).then(i.bind(i,96310)).then((({TrendLinePaneView:e})=>{this._trendLinePaneView=new e(this,this._model),this._setPaneViews([this._trendLinePaneView])}))}dataAndViewsReady(){return super.dataAndViewsReady()&&null!==this._trendLinePaneView&&this._trendLinePaneView.iconsReady()}pointsCount(){return 2}name(){return"Trend Line"}canHasAlert(){return!0}showPriceLabels(){return this._properties.childs().showPriceLabels.value()}createPriceAxisView(e){return new n.LineToolPriceAxisView(this,{pointIndex:e,backgroundPropertyGetter:()=>this.showPriceLabels()?this._properties.childs().linecolor.value():null})}isForcedDrawPriceAxisLabel(){return this.showPriceLabels()}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}static createProperties(e,t){e&&void 0===e.showPercentPriceRange&&(e.showPercentPriceRange=e.showPriceRange,e.showPipsPriceRange=e.showPriceRange);const i=new s.DefaultProperty(null!=t?t:"linetooltrendline",e);return this._configureProperties(i),i}_getAlertPlots(){const e=this._linePointsToAlertPlot(this._points,null,this._properties.childs().extendLeft.value(),this._properties.childs().extendRight.value());return null===e?[]:[e]}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,84926))).TrendLineDefinitionsViewModel}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text||"")}_snapTo45DegreesAvailable(){return!0}static _configureProperties(e){super._configureProperties(e),e.hasChild("text")||e.addChild("text",new(a())("")),e.addExclusion("text")}}},45579:(e,t,i)=>{"use strict";i.d(t,{LineToolTrianglePattern:()=>o});var s=i(46100),r=i(13087),n=i(68806);class o extends r.LineDataSource{constructor(e,t,s,r){const n=t||o.createProperties();super(e,n,s,r),i.e(1583).then(i.bind(i,23545)).then((t=>{this._setPaneViews([new t.LineToolTrianglePatternPaneView(this,e)])}))}pointsCount(){return 4}name(){return"Triangle Pattern"}static createProperties(e){const t=new s.DefaultProperty("linetooltrianglepattern",e);return this._configureProperties(t),t} -_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,25107)).then((e=>e.PatternWithBackgroundDefinitionViewModel))}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new n.LineToolColorsProperty([e.childs().color])),e.addChild("textsColors",new n.LineToolColorsProperty([e.childs().textcolor])),e.addChild("backgroundsColors",new n.LineToolColorsProperty([e.childs().backgroundColor]))}}},38416:(e,t,i)=>{"use strict";var s=i(13087).LineDataSource,r=i(46100).DefaultProperty,n=i(68806).LineToolColorsProperty;class o extends s{constructor(e,t,s,r){super(e,t||o.createProperties(),s,r),i.e(1583).then(i.t.bind(i,97615,19)).then((({TrianglePaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}pointsCount(){return 3}name(){return"Triangle"}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,20061))).GeneralFiguresDefinitionsViewModel}static createProperties(e){var t=new r("linetooltriangle",e);return this._configureProperties(t),t}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new n([e.childs().color]))}}t.LineToolTriangle=o},26642:(e,t,i)=>{"use strict";i.d(t,{LineToolVertLineTimeAxisView:()=>r});var s=i(95977);class r extends s.LineDataSourceTimeAxisView{constructor(e){super(e,0)}_getBgColor(){return this._source.properties().linecolor.value()}_getAlwaysInViewPort(){return!1}_getIndex(){const e=this._source.points();return 0===e.length?null:e[0].index}}},54623:(e,t,i)=>{"use strict";i.d(t,{LineToolVertLine:()=>h});var s=i(50151),r=i(86441),n=i(46100),o=i(59452),a=i.n(o),l=i(13087),c=i(26642);class h extends l.LineDataSource{constructor(e,t,s,r){const n=t||h.createProperties();super(e,n,s,r),this._timeAxisView=new c.LineToolVertLineTimeAxisView(this),this._paneViewFactory=null,this.properties().childs().extendLine.subscribe(this,(()=>e.lightUpdate())),i.e(1583).then(i.bind(i,77444)).then((t=>{this._paneViewFactory=i=>new t.VertLinePaneView(this,e,i),this._model.lightUpdate()}))}destroy(){this.properties().childs().extendLine.unsubscribeAll(this),super.destroy()}pointsCount(){return 1}name(){return"Vertical Line"}timeAxisViews(){return this.isSourceHidden()?null:this.properties().childs().showTime.value()?[this._timeAxisView]:null}updateAllViews(e){super.updateAllViews(e),this._timeAxisView.update(e)}canHasAlert(){return!0}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}isMultiPaneAvailable(){return!0}isMultiPaneEnabled(){return this.properties().childs().extendLine.value()}paneViews(e){return e=(0,s.ensureDefined)(e),this.isMultiPaneEnabled()||this._model.paneForSource(this)===e?(null===this._getPaneViews(e)&&null!==this._paneViewFactory&&this._setPaneViews([this._paneViewFactory(e)],e,!0),super.paneViews(e)):null}priceAxisViews(){return null}priceAxisPoints(){return[]}pointToScreenPoint(e){const t=this._model.timeScale() -;if(t.isEmpty())return null;const i=t.indexToCoordinate(e.index);return new r.Point(i,0)}convertYCoordinateToPriceForMoving(e){return 0}static createProperties(e){null!=e&&(void 0===e.textOrientation&&(e.textOrientation="horizontal"),void 0===e.extendLine&&(e.extendLine=!1));const t=new n.DefaultProperty("linetoolvertline",e);return this._configureProperties(t),t}_getAlertPlots(){const e=this._points[0],t={index:e.index,price:e.price+1},i=this._linePointsToAlertPlot([e,t],null,!0,!0);return null===i?[]:[i]}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,71472)).then((e=>e.VerticalLineDefinitionsViewModel))}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text||"")}static _configureProperties(e){super._configureProperties(e),e.hasChild("text")||e.addChild("text",new(a())("")),e.addExclusion("text")}}},58229:(e,t,i)=>{"use strict";i.d(t,{LineToolVbPFixed:()=>f});var s=i(77973),r=i(50151),n=i(70826),o=i(42856),a=i(4063),l=i(12442),c=i(39871),h=i(28558),d=i(1722),u=i(46100),p=i(76949);const _=(0,n.studyIdString)("VbPFixed","tv-volumebyprice");function m(e,t,i,s){return t.styles&&(g(t.styles.developingPoc),g(t.styles.developingVAHigh),g(t.styles.developingVALow)),t}function g(e){void 0!==e&&void 0!==e.visible&&(e.display=e.visible?15:0,delete e.visible)}class f extends a.StudyLineDataSource{constructor(e,t,i,s,r){const n=i||e.studyMetaInfoRepository().findByIdSync({type:"java",studyId:_});super(e,n,"vbpfixed_",null!=t?t:f.createProperties(e),s,r),this._createPaneViews().then((e=>{this._setPaneViews(e),e.forEach((e=>e.update((0,h.sourceChangeEvent)({sourceId:this.id(),clearData:!0}))))})),this.clearData()}pointsCount(){return 2}boundToSymbol(){return!1}offset(e){return 0}getMinFirstBarIndexForPlot(){return-1/0}calcIsActualSymbol(){this._isActualSymbol=!0,this._isActualCurrency=!0,this._isActualUnit=!0,this.calcIsActualInterval()}cloneable(){return!1}isSynchronizable(){return!1}isPlotVisibleAt(e,t){return(this.properties().childs().styles.childs()[e].childs().display.value()&t)===t}preferredZOrder(){return 0}static createProperties(e,t){const i=o.StudyMetaInfo.getStudyPropertyRootNameById(_),s=(0,r.ensureNotNull)(e.studyMetaInfoRepository().findByIdSync({type:"java",studyId:_})),n=(0,u.createDefaultsState)(!0,i,[],e.studyVersioning());return this.createPropertiesFromStudyMetaInfoAndState(s,s,(0,d.merge)((0,d.clone)(n),null!=t?t:{}),e.studyVersioning())}static createPropertiesFromStudyMetaInfoAndState(e,t,i,s){const r=(0,p.prepareStudyPropertiesForLoadChart)(e,t,i,s,m);return this._configureProperties(r),r}static studyId(){return _}_studyInputs(e){(0,r.assert)(2===e.length,"all the line tool points should be defined");const[t,i]=e,s=Math.max(t.index,i.index),n=this._model.mainSeries().bars().lastIndex(),o=this._getPointTime(t.index<=i.index?t:i,!0),a=this._getPointTime(i.index>=t.index?i:t,!0);if(null===o||null===a)return this._subscribeApplyInputsOnSeriesCompleted(),null;return{ -...this.properties().childs().inputs.state(),first_bar_time:1e3*o,last_bar_time:1e3*a,subscribeRealtime:n===s,mapRightBoundaryToBarStartTime:!!this._needExtendToBarsEnding()||void 0}}_isReady(){return!(0,l.isStudyGraphicsEmpty)(this.graphics())}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(6196),i.e(5871),i.e(3986),i.e(8167),i.e(607)]).then(i.bind(i,56059))).StudyLineDataSourceDefinitionsViewModel}_onDataUpdated(){this._updateAnchors(),this.updateAllViews((0,h.sourceChangeEvent)(this.id())),this._model.updateSource(this)}_updateAnchors(){const e=this._calculateAnchors();if(!e)return;const[{index:t,price:i},{index:s,price:r}]=e;if(this._timePoint.length&&(this._timePoint[0].price=i,this._timePoint[1].price=r),this._points.length){const e=this.model().timeScale(),n=e.indexToTimePoint(t),o=e.indexToTimePoint(t);this._points[0]={index:t,price:i,time:(0,d.isNumber)(n)?new Date(1e3*n):void 0},this._points[1]={index:s,price:r,time:(0,d.isNumber)(o)?new Date(1e3*o):void 0}}}_calculateAnchors(){let e=null,t=null,i=null,r=null;if(this.graphics().hhists().forEach((s=>{s.forEach((s=>{const{priceLow:n,priceHigh:o,firstBarTime:a,lastBarTime:l}=s;(!e||nt)&&(t=o),(!i||ar)&&(r=l)}))})),!((0,s.default)(e)||(0,s.default)(t)||(0,s.default)(r)||(0,s.default)(i)))return[{price:t,index:i},{price:e,index:r}]}_updateAnchorsPrice(){const e=this._calculateAnchors();if(!e)return;const[{price:t},{price:i}]=e;this._timePoint.length&&(this._timePoint[0].price=t,this._timePoint[1].price=i),this._points.length&&(this._points[0].price=t,this._points[1].price=i)}async _createPaneViews(){var e;const t=this._metaInfo,s=t.graphics,r=[],n=this._needExtendToBarsEnding();if(s.hhists){const{HHistPaneView:t}=await i.e(507).then(i.bind(i,21335)),s=null===(e=this.properties().childs().graphics.childs().polygons)||void 0===e?void 0:e.childs();r.push(new t(this,this._model,void 0,null==s?void 0:s.histBoxBg,n))}if(s.horizlines){const{HorizLinePaneView:e}=await i.e(507).then(i.bind(i,13369));r.push(new e(this,this._model,void 0,n))}return t.plots.length>0&&r.push(this._createStudyPlotPaneView(t.plots[0].id,n)),t.plots.length>1&&r.push(this._createStudyPlotPaneView(t.plots[1].id,n)),t.plots.length>2&&r.push(this._createStudyPlotPaneView(t.plots[2].id,n)),r}_createStudyPlotPaneView(e,t){return new c.StudyPlotPaneView(this,this._model.mainSeries(),this._model,e,t)}_needExtendToBarsEnding(){var e;return void 0!==(null===(e=this.metaInfo().defaults.inputs)||void 0===e?void 0:e.mapRightBoundaryToBarStartTime)}}},36147:(e,t,i)=>{"use strict";var s;i.d(t,{MagnetMode:()=>s}),function(e){e[e.WeakMagnet=0]="WeakMagnet",e[e.StrongMagnet=1]="StrongMagnet"}(s||(s={}))},18540:(e,t,i)=>{"use strict";i.d(t,{magnetEnabled:()=>_,magnetMode:()=>m,setIsMagnetEnabled:()=>g,setMagnetMode:()=>f});var s=i(46100),r=i(97145),n=i(36147),o=i(88348),a=i(15367),l=i(28571);const c=new r.WatchedValue(!1),h=new r.WatchedValue(n.MagnetMode.WeakMagnet),d=(0,l.modifierPressed)(),u=(0,l.shiftPressed)();function p(){ -const e=d.value();if(u.value()&&(o.isToolEditingNow.value()||o.isToolCreatingNow.value()))return void c.setValue(!1);let t,i;if(o.activePointSelectionMode.value()===o.SelectPointMode.Replay)t=i=!1;else{const s=o.tool.value(),r=o.isStudyEditingNow.value()||o.activePointSelectionMode.value()===o.SelectPointMode.Study;t=e&&((0,a.isLineToolName)(s)||o.isToolEditingNow.value()||(0,o.toolIsMeasure)(s)||r),i=(0,o.properties)().childs().magnet.value()}h.setValue(!i&&t?n.MagnetMode.StrongMagnet:(0,o.properties)().childs().magnetMode.value()),c.setValue(t?!i:i)}function _(){return c}function m(){return h}function g(e){(0,s.saveDefaultProperties)(!0),(0,o.properties)().childs().magnet.setValue(e),(0,s.saveDefaultProperties)(!1)}function f(e){(0,s.saveDefaultProperties)(!0),(0,o.properties)().childs().magnetMode.setValue(e),(0,o.properties)().childs().magnet.setValue(!0),(0,s.saveDefaultProperties)(!1)}(0,o.runOnDrawingStateReady)((()=>{(0,o.properties)().childs().magnet.subscribe(null,p),(0,o.properties)().childs().magnetMode.subscribe(null,p),d.subscribe(p),u.subscribe(p),o.tool.subscribe(p),o.isToolEditingNow.subscribe(p),p()}))},90565:(e,t,i)=>{"use strict";i.d(t,{MainSeriesScaleRatioProperty:()=>n});var s=i(57898),r=i(19782);class n{constructor(e){this._changed=new s.Delegate,this._model=e}destroy(){this._changed.destroy()}getStepChangeValue(){return.1}getMinValue(){return 1e-7}getMaxValue(){return 99999999}value(){return this._model.mainSeriesScaleRatio()}setValue(e,t){(e!==this.value()||t)&&(this._model.setMainSeriesScaleRatio(e),this._onChanged())}state(){return null}clone(){return new n(this._model)}listeners(){return this._changed}subscribe(e,t){this._changed.subscribe(e,t)}unsubscribe(e,t){this._changed.unsubscribe(e,t)}unsubscribeAll(e){this._changed.unsubscribeAll(e)}storeStateIfUndefined(){return!0}weakReference(){return(0,r.weakReference)(this)}ownership(){return(0,r.ownership)(this)}_onChanged(){this._changed.fire(this)}}},28558:(e,t,i)=>{"use strict";i.r(t),i.d(t,{globalChangeEvent:()=>o,selectionChangeEvent:()=>h,sourceChangeEvent:()=>r,viewportChangeEvent:()=>l});var s=i(27147);function r(e){return(0,s.default)(e)?{type:"data-source-change",sourceId:e}:{type:"data-source-change",...e}}const n={type:"global-change"};function o(){return n}const a={type:"viewport-change"};function l(){return a}const c={type:"selection-change"};function h(){return c}},1115:(e,t,i)=>{"use strict";i.d(t,{ensureTimePointIndexIndex:()=>n,unpackNonSeriesData:()=>o});var s=i(30551),r=i(50151);function n(e){if(e<0)throw new Error("TimePointIndexIndex should be non-negative integer");return e}async function o(e){if(""===e)return null;const t=JSON.parse(e);if(!(0,s.isObject)(t)||"function"==typeof t)throw new Error("Non-object content in the non-series envelope");if((0,s.hasProperty)(t,"indexes_replace"))return{indexes_replace:!0};const i={indexes_replace:!1};if((0,s.hasProperty)(t,"offsets")&&(i.offsets=t.offsets),(0,s.hasProperty)(t,"isUpdate")){if("boolean"!=typeof t.isUpdate)throw new Error('Invalid type of "isUpdate" field') -;i.isUpdate=t.isUpdate}return(0,s.hasProperty)(t,"data")&&(i.data=t.data),(0,s.hasProperty)(t,"graphicsCmds")&&(i.graphicsCmds=function(e){if(!(0,s.isObject)(e))throw new Error("Graphics commands should be wrapped in an object");if((0,s.hasProperty)(e,"create"),(0,s.hasProperty)(e,"erase")){const t=e.erase;(0,r.assert)(Array.isArray(t),"Collection of erase commands should be array");for(const e of t){if(!(0,s.isObject)(e)||!(0,s.hasProperty)(e,"action"))throw new Error("Command should be an object with 'action' property");(0,r.assert)("all"===e.action||"one"===e.action,"Erase command action should be 'all' or 'one'")}}return e}(t.graphicsCmds)),i}},88546:(e,t,i)=>{"use strict";i.d(t,{notAvailable:()=>r});var s=i(44352);const r=i(14483).enabled("use_na_string_for_not_available_values")?s.t(null,void 0,i(16542)):"∅"},66103:(e,t,i)=>{"use strict";var s;i.d(t,{PaneCursorType:()=>s}),function(e){e[e.Default=0]="Default",e[e.Pointer=1]="Pointer",e[e.Eraser=2]="Eraser",e[e.Dot=3]="Dot",e[e.Grabbing=4]="Grabbing",e[e.ZoomIn=5]="ZoomIn",e[e.VerticalResize=6]="VerticalResize",e[e.HorizontalResize=7]="HorizontalResize",e[e.DiagonalNeSwResize=8]="DiagonalNeSwResize",e[e.DiagonalNwSeResize=9]="DiagonalNwSeResize"}(s||(s={}))},43493:(e,t,i)=>{"use strict";i.d(t,{PanePriceAxisView:()=>n});var s=i(34565);class r{constructor(e){this._priceAxisViewRenderer=null,this._rendererOptions=null,this._align="right",this._width=0,this._height=0,this._textWidthCache=e}setParams(e,t,i,s,r){this._priceAxisViewRenderer=e,this._rendererOptions=t,this._width=i,this._height=s,this._align=r}draw(e,t){null!==this._rendererOptions&&null!==this._priceAxisViewRenderer&&this._priceAxisViewRenderer.draw(e,this._rendererOptions,this._textWidthCache,this._width,this._height,this._align,t.pixelRatio)}hitTest(e){var t,i;return void 0===(null===(t=this._priceAxisViewRenderer)||void 0===t?void 0:t.hitTest)?null:null===(i=this._priceAxisViewRenderer)||void 0===i?void 0:i.hitTest(e,this._width,this._align)}}class n{constructor(e,t,i){this._renderer=null,this._invalidated=!0,this._priceAxisView=e,this._textWidthCache=new s.TextWidthCache(100),this._dataSource=t,this._chartModel=i,this._fontSize=-1,this._panePriceAxisViewRenderer=new r(this._textWidthCache)}update(e){this._invalidated=!0}renderer(e,t){return this._invalidated&&this._updateImpl(e,t),this._renderer}_position(){const e=this._chartModel.crossHairSource(),t=this._dataSource===e?e.pane:this._chartModel.paneForSource(this._dataSource);if(null===t)return null;const i=this._priceScale();if(null===i)return null;let s=t.priceScalePosition(i);return"overlay"===s&&(s=t.priceScalePosition(t.defaultPriceScale())),"overlay"===s?null:s}_updateImpl(e,t){this._renderer=null;const i=this._position();if(null===i)return;const s=this._chartModel.priceAxisRendererOptions();s.fontSize!==this._fontSize&&(this._fontSize=s.fontSize,this._textWidthCache.reset()),this._panePriceAxisViewRenderer.setParams(this._priceAxisView.paneRenderer(),s,t,e,i),this._renderer=this._panePriceAxisViewRenderer,this._invalidated=!1}_priceScale(){ -return this._dataSource.priceScale()}}},82386:(e,t,i)=>{"use strict";i.d(t,{AreaBackgroundItem:()=>a,AreaBackgroundItemsGroup:()=>n,AreaBackgroundRenderer:()=>l,CachedMap:()=>o});var s=i(59590),r=i(77173);class n extends r.CachedContainer{constructor(e){super(),this.color=e}}class o{constructor(){this._map=new Map,this._usedKeys=new Set,this._invalidations=0}invalidateCache(){this._invalidations+=1,50===this._invalidations&&(this._deleteUnused(),this._invalidations=0),this._usedKeys.clear(),this._map.forEach(((e,t)=>e.invalidateCache()))}get(e){const t=this._map.get(e);return void 0!==t&&this._usedKeys.add(e),t}set(e,t){this._usedKeys.add(e),this._map.set(e,t)}forEach(e){this._map.forEach(((t,i)=>{this._usedKeys.has(i)&&e(t,i)}))}delete(e){const t=this._map.get(e);void 0!==t&&t.invalidateCache(),this._usedKeys.delete(e)}_deleteUnused(){const e=[];this._map.forEach(((t,i)=>{this._usedKeys.has(i)||e.push(i)}));for(const t of e)this._map.delete(t)}}class a extends r.CachedContainer{constructor(){super(),this.points1=new r.CachedContainer,this.points2=new r.CachedContainer,this.push(this.points1),this.push(this.points2)}addPoints1Point(e,t){let i=this.points1.newItem();null!==i?(i.x=e,i.y=t):i={x:e,y:t},this.points1.push(i)}addPoints2Point(e,t){let i=this.points2.newItem();null!==i?(i.x=e,i.y=t):i={x:e,y:t},this.points2.push(i)}invalidateCache(){this.points1.invalidateCache(),this.points2.invalidateCache()}}class l extends s.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=null,this._data=null!=e?e:null}setData(e){this._data=e}hitTest(e,t){return null}_drawImpl(e){if(null===this._data)return;const{context:t,horizontalPixelRatio:i,verticalPixelRatio:s}=e,r=.25*this._data.barSpacing;this._data.colorAreas.forEach((e=>{var n,o;t.beginPath();for(let n=0;n=0;e--)t.lineTo(Math.round(o.points2.at(e).x*i),o.points2.at(e).y*s)}else{const e=o.points2.at(0).x,n=o.points2.at(0).y;t.lineTo(Math.round((a+r)*i),l*s),t.lineTo(Math.round((e+r)*i),n*s),t.lineTo(Math.round((e-r)*i),n*s),t.lineTo(Math.round((a-r)*i),l*s)}}if(t.closePath(),0===e.color.type)t.fillStyle=e.color.color;else{const i=t.createLinearGradient(0,e.color.value1*s,0,e.color.value2*s);i.addColorStop(0,null!==(n=e.color.color1)&&void 0!==n?n:"transparent"),i.addColorStop(1,null!==(o=e.color.color2)&&void 0!==o?o:"transparent"),t.fillStyle=i}t.fill()}))}}},62885:(e,t,i)=>{"use strict";i.d(t,{PaneRendererArea:()=>a});var s=i(50151),r=i(1149),n=i(45197),o=i(68441);class a extends r.PaneRendererLine{constructor(e){e.forceLineColor=!1,super(e)}_drawImpl(e){var t,i,r,a,l;const c=this._data;if(0===c.items.length)return -;let h=null!==(i=null===(t=this._data.visibleItemsRange)||void 0===t?void 0:t.startItemIndex)&&void 0!==i?i:0,d=(null!==(a=null===(r=this._data.visibleItemsRange)||void 0===r?void 0:r.endItemIndex)&&void 0!==a?a:this._data.items.length)-1;for(;h=0&&!(0,n.coordinateIsValid)(c.items[d].y);)d--;if(h>d)return;const{context:u,horizontalPixelRatio:p,verticalPixelRatio:_}=e;u.save(),u.scale(p,_),u.lineCap="round",u.strokeStyle=c.lineColor,u.lineWidth=c.lineWidth,(0,o.setLineStyle)(u,c.lineStyle),u.lineWidth=1;const m={},g=c.items;for(let e=h;e<=d;e++){const t=g[e];let i;if(i=t.style?t.style.color:c.lineColor,e{"use strict";i.d(t,{BitmapCoordinatesPaneRenderer:()=>r});var s=i(27714);class r{draw(e,t){new s.CanvasRenderingTarget2D(e,(0,s.size)({width:t.cssWidth,height:t.cssHeight}),(0,s.size)({width:t.physicalWidth,height:t.physicalHeight})).useBitmapCoordinateSpace((e=>this._drawImpl(e)))}drawBackground(e,t){new s.CanvasRenderingTarget2D(e,(0,s.size)({width:t.cssWidth,height:t.cssHeight}),(0,s.size)({width:t.physicalWidth,height:t.physicalHeight})).useBitmapCoordinateSpace((e=>this._drawBackgroundImpl(e)))}_drawBackgroundImpl(e){}}},19266:(e,t,i)=>{"use strict";i.d(t,{CompositeRenderer:()=>s});class s{constructor(){this._renderers=[],this._globalAlpha=1}setGlobalAlpha(e){this._globalAlpha=e}append(e){this._renderers.push(e)}insert(e,t){this._renderers.splice(t,0,e)}clear(){this._renderers.length=0}isEmpty(){return 0===this._renderers.length}draw(e,t){for(let i=0;i=0;s--){const r=this._renderers[s].hitTest(e,t);null!==r&&(null===i||r.target()>i.target())&&(i=r)}return i}doesIntersectWithBox(e){return this._renderers.some((t=>!!t.doesIntersectWithBox&&t.doesIntersectWithBox(e)))}}},68441:(e,t,i)=>{"use strict";i.r(t),i.d(t,{addHorizontalLineToPath:()=>a,addLineToPath:()=>y,addVerticalLineToPath:()=>c,clearRectWithGradient:()=>n,createCircle:()=>f,drawHorizontalLine:()=>l,drawLine:()=>b, -drawPoly:()=>v,drawRoundRect:()=>p,drawRoundRectWithInnerBorder:()=>_,drawVerticalLine:()=>h,fillRectInnerBorder:()=>o,fillRectWithBorder:()=>g,scaleDrawRoundRectRadii:()=>d,scaledDashPattern:()=>m,setLineStyle:()=>S});var s=i(79849),r=i(95586);function n(e,t,i,s,r,n,o){e.save(),e.globalCompositeOperation="copy";const a=e.createLinearGradient(0,0,0,r);a.addColorStop(0,n),a.addColorStop(1,o),e.fillStyle=a,e.fillRect(t,i,s,r),e.restore()}function o(e,t,i,s,r,n){e.fillRect(t+n,i,s-2*n,n),e.fillRect(t+n,i+r-n,s-2*n,n),e.fillRect(t,i,n,r),e.fillRect(t+s-n,i,n,r)}function a(e,t,i,s){const r=e.lineWidth%2?.5:0;e.moveTo(i,t+r),e.lineTo(s,t+r)}function l(e,t,i,s){e.beginPath(),a(e,t,i,s),e.stroke()}function c(e,t,i,s){const r=e.lineWidth%2?.5:0;e.moveTo(t+r,i),e.lineTo(t+r,s)}function h(e,t,i,s){e.beginPath(),c(e,t,i,s),e.stroke()}function d(e,t){return Array.isArray(e)?e.map((e=>Math.round(e*t))):Math.round(e*t)}function u(e,t){return Array.isArray(e)?e.map((e=>0===e?e:e+t)):e+t}function p(e,t,i,s,r,n,o){let a,l,c,h;if(Array.isArray(n))if(2===n.length){const e=Math.max(0,n[0]),t=Math.max(0,n[1]);a=e,l=e,c=t,h=t}else{if(4!==n.length)throw new Error("Wrong border radius - it should be like css border radius");a=Math.max(0,n[0]),l=Math.max(0,n[1]),c=Math.max(0,n[2]),h=Math.max(0,n[3])}else{const e=Math.max(0,n);a=e,l=e,c=e,h=e}o||e.beginPath(),e.moveTo(t+a,i),e.lineTo(t+s-l,i),0!==l&&e.arcTo(t+s,i,t+s,i+l,l),e.lineTo(t+s,i+r-c),0!==c&&e.arcTo(t+s,i+r,t+s-c,i+r,c),e.lineTo(t+h,i+r),0!==h&&e.arcTo(t,i+r,t,i+r-h,h),e.lineTo(t,i+a),0!==a&&e.arcTo(t,i,t+a,i,a)}function _(e,t,i,s,n,o,a=0,l=0,c="",h=r.LineStyle.Solid){if(e.save(),!l||!c||c===o)return p(e,t,i,s,n,a),e.fillStyle=o,e.fill(),void e.restore();const d=l/2;if("transparent"!==o){const d="transparent"!==c&&h!==r.LineStyle.Solid;p(e,d?t:t+l,d?i:i+l,d?s:s-2*l,d?n:n-2*l,d?a:u(a,-l)),e.fillStyle=o,e.fill()}if("transparent"!==c){p(e,t+d,i+d,s-l,n-l,u(a,-d)),e.lineWidth=l,e.strokeStyle=c,S(e,h),e.closePath(),e.stroke()}e.restore()}function m(e,t){return t=Math.max(1,t),e.map((e=>e*t))}function g(e,t,i,r,n,o,a,l){const c=o%2/2,h=t+c,d=r+c;let u,p;if(l){const{borderMode:a,borderWidth:c,color:_,dashPattern:g,lineStyle:f}=l;switch(a){case"outer":{const e=-o/2-c/2,t=-c/2;p={left:h+e,right:d-e,top:i+t,bottom:n-t};break}case"center":{const e=c%2/2;p={left:t+e,right:r+e,top:i+e,bottom:n+e};break}case"inner":{const e=-o/2+c/2,t=c/2;p={left:h+e,right:d-e,top:i+t,bottom:n-t}}}e.strokeStyle=_,e.lineWidth=c;let v=-1;g?e.setLineDash(m(g,c)):void 0!==f&&(S(e,f),f===s.LINESTYLE_SOLID&&(v=1)),u={left:p.left+v*c/2,top:p.top+v*c/2,right:p.right-v*c/2,bottom:p.bottom-v*c/2}}a&&(e.fillStyle=a.color,u||(u={left:h-o/2,right:d+o/2,top:i,bottom:n}),e.fillRect(u.left,u.top,u.right-u.left,u.bottom-u.top)),p&&e.strokeRect(p.left,p.top,p.right-p.left,p.bottom-p.top)}function f(e,t,i,s){e.beginPath(),e.arc(t,i,s,0,2*Math.PI,!1),e.closePath()}function v(e,t,i){e.beginPath(),e.moveTo(t[0].x,t[0].y);for(const i of t)e.lineTo(i.x,i.y);e.closePath(),e.stroke(),i&&e.fill()}function S(e,t){let i=[] -;t!==s.LINESTYLE_SOLID&&(i=function(e,t){return[[e.lineWidth,2*e.lineWidth],[5*e.lineWidth,6*e.lineWidth],[6*e.lineWidth,6*e.lineWidth],[e.lineWidth,4*e.lineWidth],[2*e.lineWidth,e.lineWidth]][t-1]}(e,t)),e.setLineDash(i)}function y(e,t,i,s,r){e.moveTo(t,i),e.lineTo(s,r)}function b(e,t,i,s,r){isFinite(t)&&isFinite(s)&&isFinite(i)&&isFinite(r)&&(e.beginPath(),y(e,t,i,s,r),e.stroke())}},45197:(e,t,i)=>{"use strict";i.d(t,{coordinateIsValid:()=>g,extendAndClipLineSegment:()=>h,fillScaledRadius:()=>v,getArrowPoints:()=>d,interactionTolerance:()=>m,optimalBarWidth:()=>u,optimalCandlestickWidth:()=>p,optimalHiLoWidth:()=>_,setValidLineStyle:()=>f,strokeScaledRadius:()=>S});var s=i(86441),r=i(5531),n=i(38325),o=i(1722),a=i(68441);const l={common:13,line:13,minDistanceBetweenPoints:10,series:14,curve:10,anchor:13,esd:4},c={common:3,line:3,minDistanceBetweenPoints:5,series:2,curve:3,anchor:2,esd:0};function h(e,t,i,n,o,a){if((0,s.equalPoints)(e,t))return null;const l=new s.Point(0,0),c=new s.Point(i,n);if(o){if(a){const i=(0,r.intersectLineAndBox)((0,s.lineThroughPoints)(e,t),(0,s.box)(l,c));return Array.isArray(i)?i:null}{const i=(0,r.intersectRayAndBox)(t,e,(0,s.box)(l,c));return null===i||(0,s.equalPoints)(t,i)?null:(0,s.lineSegment)(t,i)}}if(a){const i=(0,r.intersectRayAndBox)(e,t,(0,s.box)(l,c));return null===i||(0,s.equalPoints)(e,i)?null:(0,s.lineSegment)(e,i)}{const i=(0,r.intersectLineSegmentAndBox)((0,s.lineSegment)(e,t),(0,s.box)(l,c));return Array.isArray(i)?i:null}}function d(e,t,i,s,r){const n=.5*i,o=Math.sqrt(2),a=t.subtract(e),l=a.normalized();let c=5*i;s&&(c=Math.min(c,.35*a.length()));const h=1*n;if(c*o*.2<=h)return[];const d=l.scaled(c),u=t.subtract(d),p=l.transposed(),_=1*c,m=p.scaled(_),g=u.add(m),f=u.subtract(m),v=g.subtract(t).normalized().scaled(h),S=f.subtract(t).normalized().scaled(h),y=r?t:t.add(v),b=r?t:t.add(S),w=n*(o-1),P=p.scaled(w),C=Math.min(c-1*n/o,n*o*1),x=l.scaled(C),T=t.subtract(P),I=t.add(P),M=t.subtract(x);return[[g,y],[b,f],[T,M.subtract(P)],[I,M.add(P)]]}function u(e,t){return t=t||1,Math.floor(.3*e*t)}function p(e,t){if(e>=2.5&&e<=4)return Math.floor(3*t);const i=1-.2*Math.atan(Math.max(4,e)-4)/(.5*Math.PI),s=Math.floor(e*i*t),r=Math.floor(e*t),n=Math.min(s,r);return Math.max(Math.floor(t),n)}function _(e){return.4*e}function m(){return(0,n.lastMouseOrTouchEventInfo)().isTouch?l:c}function g(e){return null!=e&&!(0,o.isNaN)(e)}function f(e,t){void 0!==t&&(0,a.setLineStyle)(e,t)}function v(e,t){const i=Math.max(1,Math.floor(t))%2?.5:0;return Math.round(e*t)+i}function S(e,t,i){const s=Math.max(1,Math.floor(t))%2?.5:0;return Math.round(e*t)+(s!==i%2?.5:0)}},74997:(e,t,i)=>{"use strict";i.d(t,{HorizontalLineRenderer:()=>l});var s=i(18807),r=i(68441),n=i(45197),o=i(59590),a=i(74359);class l extends o.BitmapCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null,this._hitTest=new s.HitTestResult(s.HitTarget.Regular)}setData(e){this._data=e}setHitTest(e){this._hitTest=e}hitTest(e){if(null===this._data||!1===this._data.visible||null===this._hitTest)return null;const t=(0, -n.interactionTolerance)().line,i=Math.abs(e.y-this._data.y)<=t+this._data.linewidth/2,s=void 0===this._data.left||this._data.left-e.x<=t,r=void 0===this._data.right||e.x-this._data.right<=t;return i&&s&&r?this._hitTest:null}_drawImpl(e){if(null===this._data||!1===this._data.visible)return;const{context:t,horizontalPixelRatio:i,verticalPixelRatio:s,mediaSize:n}=e;if(this._data.y<-this._data.linewidth/2||this._data.y>n.height+this._data.linewidth/2)return;t.lineCap="butt",t.strokeStyle=this._data.color,t.lineWidth=Math.max(1,Math.floor(this._data.linewidth*i)),void 0!==this._data.linestyle&&(0,r.setLineStyle)(t,this._data.linestyle);const o=void 0!==this._data.left?Math.max(this._data.left,0):0,l=void 0!==this._data.right?Math.min(this._data.right,n.width):n.width,c=Math.round(this._data.y*s),h=Math.round(o*i),d=Math.round(l*i),u=this._data.excludeBoundaries;void 0!==u&&(0,a.addExclusionAreaByScope)(e,u),(0,r.drawHorizontalLine)(t,c,h,d)}}},73436:(e,t,i)=>{"use strict";var s;i.d(t,{LineEnd:()=>s}),function(e){e[e.Normal=0]="Normal",e[e.Arrow=1]="Arrow",e[e.Circle=2]="Circle"}(s||(s={}))},1149:(e,t,i)=>{"use strict";i.d(t,{PaneRendererLine:()=>c});var s=i(86441),r=i(4652),n=i(18807),o=i(45197),a=i(68441),l=i(59590);class c extends l.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){var t,i,a,l;const c=(0,o.interactionTolerance)().series+this._data.lineWidth/2;let h=null!==(i=null===(t=this._data.visibleItemsRange)||void 0===t?void 0:t.startItemIndex)&&void 0!==i?i:0,d=(null!==(l=null===(a=this._data.visibleItemsRange)||void 0===a?void 0:a.endItemIndex)&&void 0!==l?l:this._data.items.length)-1;for(;d-h>2;){const t=Math.round((d+h)/2);this._data.items[t].x<=e.x?h=t:d=t}h=Math.max(1,h-1),d=Math.min(this._data.items.length-1,d+1);for(let t=h;t<=d;++t){const i=this._data.items[t-1],o=this._data.items[t],a=i.x,l=o.x;if((0,r.distanceToSegment)(new s.Point(a,i.y),new s.Point(l,o.y),new s.Point(e.x,e.y)).distance<=c)return this._data.hittest?this._data.hittest:new n.HitTestResult(n.HitTarget.Regular)}return null}_drawImpl(e){const{context:t,horizontalPixelRatio:i,verticalPixelRatio:s}=e;t.scale(i,s),t.lineCap="round",t.lineJoin="round",t.strokeStyle=this._data.lineColor,t.fillStyle=this._data.lineColor,t.lineWidth=this._data.lineWidth,(0,a.setLineStyle)(t,this._data.lineStyle),(0,o.setValidLineStyle)(t,this._data.lineStyle),this._data.simpleMode?this._drawSimpleMode(t,i,s):this._drawLines(t)}_drawSimpleMode(e,t,i){var s,r,n,o;e.beginPath(),this._walkLine(e,this._data.items,!1,NaN),e.stroke();const a=this._data.lineWidth+2;if(this._data.withMarkers&&2*a=d;){const r=this._data.items[s];if(r){const s=Math.round(r.x*t)+l,n=r.y*i;e.moveTo(s,n), -e.arc(s,n,c,0,h)}}e.fill()}}_walkLine(e,t,i,s,r){var n,a,l,c;if(!t)return;const h=.25*this._data.barSpacing;let d,u,p,_,m;const g=o.coordinateIsValid,f=r?0:null!==(a=null===(n=this._data.visibleItemsRange)||void 0===n?void 0:n.startItemIndex)&&void 0!==a?a:0,v=r?t.length-1:Math.min((null!==(c=null===(l=this._data.visibleItemsRange)||void 0===l?void 0:l.endItemIndex)&&void 0!==c?c:t.length)-1,t.length-1);for(let e=f;e<=v;e++){const i=t[e];if(g(i.y)){u=i,d=e;break}}if(void 0!==d&&void 0!==u)for(let r=d;r<=v;r++){_=t[r],m=t[r+1]||{};const n=Math.round(_.x);if(g(_.y))if(p&&g(p.y))e.lineTo(n,_.y),i&&!g(m.y)&&e.lineTo(n,s);else if(m&&g(m.y))i?(r!==d&&e.lineTo(n,s),e.lineTo(n,_.y)):e.moveTo(n,_.y);else if(i){if(0===r)continue;r!==d&&e.lineTo(n-h,s),e.lineTo(n-h,_.y),e.lineTo(n+h,_.y),e.lineTo(n+h,s)}else e.moveTo(n-h,_.y),e.lineTo(n+h,_.y);p=_}}_drawLines(e){var t,i,s,r;if(!this._data.items.length)return;let n,a,l;const c=.25*this._data.barSpacing,h=o.coordinateIsValid;e.beginPath();const d=null!==(i=null===(t=this._data.visibleItemsRange)||void 0===t?void 0:t.startItemIndex)&&void 0!==i?i:0,u=(null!==(r=null===(s=this._data.visibleItemsRange)||void 0===s?void 0:s.endItemIndex)&&void 0!==r?r:this._data.items.length)-1,p=this._data.items[d];p&&e.moveTo(p.x,p.y);let _,m=e.strokeStyle,g=e.lineWidth;for(let t=d+1;t<=u;++t){let i,s,r;n=this._data.items[t-1],a=this._data.items[t],l=this._data.items[t+1],a.style&&!this._data.forceLineColor?(i=a.style.color,s=a.style.width,r=a.style.style):(i=this._data.lineColor,s=this._data.lineWidth,r=this._data.lineStyle),this._data.ignorePaletteLineWidth&&(s=this._data.lineWidth);(i!==m||s!==g||r!==_)&&(m=i,g=s,_=r,e.stroke(),e.beginPath(),e.strokeStyle=i,e.lineWidth=s,(0,o.setValidLineStyle)(e,r),e.moveTo(n.x,n.y)),f=n,S=l,h((v=a).y)&&(h(f.y)?e.lineTo(v.x,v.y):S&&h(S.y)?e.moveTo(v.x,v.y):(e.moveTo(v.x-c,v.y),e.lineTo(v.x+c,v.y)))}var f,v,S;e.stroke()}}},15187:(e,t,i)=>{"use strict";i.d(t,{MediaCoordinatesPaneRenderer:()=>r});var s=i(27714);class r{draw(e,t){new s.CanvasRenderingTarget2D(e,(0,s.size)({width:t.cssWidth,height:t.cssHeight}),(0,s.size)({width:t.physicalWidth,height:t.physicalHeight})).useMediaCoordinateSpace((e=>this._drawImpl(e)))}drawBackground(e,t){new s.CanvasRenderingTarget2D(e,(0,s.size)({width:t.cssWidth,height:t.cssHeight}),(0,s.size)({width:t.physicalWidth,height:t.physicalHeight})).useMediaCoordinateSpace((e=>this._drawBackgroundImpl(e)))}_drawBackgroundImpl(e){}}},77173:(e,t,i)=>{"use strict";i.d(t,{CachedContainer:()=>s,ObjectValuesCache:()=>r});class s{constructor(){this._items=[],this._actualLength=0,this._invalidations=0}push(e){this._items.length===this._actualLength?this._items.push(e):this._items[this._actualLength]!==e&&(this._items[this._actualLength]=e),this._actualLength+=1}newItem(){const e=this._items.length>this._actualLength?this._items[this._actualLength]:null;return null!==e&&Boolean(e.invalidateCache)&&e.invalidateCache(),e}invalidateCache(){this._invalidations+=1,3e3===this._invalidations&&(this._items.splice(this._actualLength), -this._invalidations=0),this._actualLength=0}at(e){return this._items[e]}data(){return this._items}length(){return this._actualLength}}class r extends s{constructor(){super(...arguments),this._startIndex=0}setStartIndex(e){this._startIndex=e}isValidIndex(e){return e>=this._startIndex}at(e){const t=e-this._startIndex;for(;t>=this._actualLength;)this._items.length<=t?this._items.push(this._newObject()):this._clearObject(this._items[this._actualLength]),this._actualLength+=1;return this._items[t]}}},72739:(e,t,i)=>{"use strict";i.d(t,{RectangleRenderer:()=>u});var s=i(50151),r=i(86441),n=i(34026),o=i(4652),a=i(87095),l=i(79849),c=i(18807),h=i(68441),d=i(59590);class u extends d.BitmapCoordinatesPaneRenderer{constructor(e,t,i){super(),this._data=null,this._hitTestResult=e||new c.HitTestResult(c.HitTarget.MovePoint),this._backHitTestResult=t||new c.HitTestResult(c.HitTarget.MovePointBackground),this._forceOverrideTransparency=Boolean(i)}setData(e){this._data=e}hitTest(e,t){if(null===this._data||this._data.points.length<2||this._data.nohittest)return null;const i=t.physicalWidth,s=(0,r.box)(...this._data.points),n=s.min,a=s.max,l=new r.Point(a.x,n.y),c=new r.Point(n.x,a.y),h=this._extendAndHitTestLineSegment(e,n,l,i);if(null!==h)return h;const d=this._extendAndHitTestLineSegment(e,c,a,i);if(null!==d)return d;let u=(0,o.distanceToSegment)(l,a,e);return u.distance<=3?this._hitTestResult:(u=(0,o.distanceToSegment)(n,c,e),u.distance<=3?this._hitTestResult:this._data.fillBackground?this._hitTestBackground(e,n,a,i):null)}getColor(){const e=(0,s.ensure)(this._data);return void 0===e.transparency?e.backcolor:(0,a.generateColor)(e.backcolor,e.transparency,this._forceOverrideTransparency)}_drawImpl(e){if(null===this._data||this._data.points.length<2||this._data.linewidth<=0&&!this._data.fillBackground)return;const{context:t,horizontalPixelRatio:i,verticalPixelRatio:s,bitmapSize:n}=e,{extendLeft:o,extendRight:a,linewidth:c}=this._data,d=(0,r.box)(...this._data.points),u=this._data.linewidth?Math.max(1,Math.floor(this._data.linewidth*i)):0,p=this._data.fillBackground?this.getColor():void 0,_=Math.max(1,Math.floor(i)),m=o?-c:Math.round(d.min.x*i),g=a?n.width+c:Math.round(d.max.x*i),f=Math.round(d.min.y*s),v=Math.round(d.max.y*s);(0,h.fillRectWithBorder)(t,m,f,g,v,_,void 0===p?void 0:{color:p},0===u?void 0:{color:this._data.color,lineStyle:l.LINESTYLE_SOLID,borderWidth:u,borderMode:"center"})}_extendAndHitTestLineSegment(e,t,i,s){const r=this._extendAndClipLineSegment(t,i,s);if(null!==r){if((0,o.distanceToSegment)(r[0],r[1],e).distance<=3)return this._hitTestResult}return null}_extendAndClipLineSegment(e,t,i){const n=(0,s.ensureNotNull)(this._data);if((0,r.equalPoints)(e,t)&&!n.extendLeft&&!n.extendRight)return null;const o=Math.min(e.x,t.x),a=Math.max(e.x,t.x),l=n.extendLeft?0:Math.max(o,0),c=n.extendRight?i:Math.min(a,i);return l>c||c<=0||l>=i?null:[new r.Point(l,e.y),new r.Point(c,t.y)]}_hitTestBackground(e,t,i,s){const o=this._extendAndClipLineSegment(t,i,s);return null!==o&&(0,n.pointInBox)(e,(0, -r.box)(o[0],o[1]))?this._backHitTestResult:null}}},9155:(e,t,i)=>{"use strict";var s;i.d(t,{StatsPosition:()=>s}),function(e){e[e.Left=0]="Left",e[e.Center=1]="Center",e[e.Right=2]="Right",e[e.Auto=3]="Auto"}(s||(s={}))},40621:(e,t,i)=>{"use strict";i.d(t,{PaneRendererStepLine:()=>g,StepLineDecoration:()=>s});var s,r=i(4652),n=i(86441),o=i(87095),a=i(18807),l=i(78071),c=i(45197),h=i(68441),d=i(59590);!function(e){e[e.None=0]="None",e[e.Diamonds=1]="Diamonds"}(s||(s={}));class u{initialize(e,t,i){var s,r,n,o;const{context:a,horizontalPixelRatio:l,verticalPixelRatio:c}=t,d=e.lineStyle;a.lineCap="butt",a.lineJoin="round";const u=Math.max(Math.floor(null!==(r=null===(s=i.style)||void 0===s?void 0:s.width)&&void 0!==r?r:e.lineWidth*l));void 0!==d&&(0,h.setLineStyle)(a,d);const p=u%2?.5:0;a.moveTo(Math.round(i.x*l)+p,Math.round(i.y*c)+p),a.strokeStyle=null!==(o=null===(n=i.style)||void 0===n?void 0:n.color)&&void 0!==o?o:e.lineColor,a.lineWidth=u}finishFragment(e){e.stroke()}hitTest(e,t,i,s,r){return u.hitTest(e,t,i,s,r)}applyColor(e,t){e.strokeStyle=t}applyLineWidth(e,t){e.lineWidth=t}drawItem(e,t,i){const s=e.context;s.lineTo(t.x,t.y),void 0!==i&&(s.lineTo(i.x,t.y),s.lineTo(i.x,i.y))}static hitTest(e,t,i,s,o){var a,l;const h=t.pixelRatio,d=null!==(l=null===(a=i.style)||void 0===a?void 0:a.width)&&void 0!==l?l:e.lineWidth,u=Math.max(1,Math.floor(d*h))%2?.5:0,p=(0,c.interactionTolerance)().series+d/2;let _;if(isNaN(s.y)){const e=i.x+u,t=s.x+u,a=new n.Point(e,i.y),l=new n.Point(t,i.y);_=(0,r.distanceToSegment)(a,l,o).distance}else{const t=Math.round(s.x-e.barSpacing/2*h)+u,a=new n.Point(t,i.y),l=new n.Point(t,s.y);_=Math.min((0,r.distanceToSegment)(i,a,o).distance,(0,r.distanceToSegment)(a,l,o).distance,(0,r.distanceToSegment)(l,s,o).distance)}return _<=p}}class p{constructor(){this._lineWidth=1}initialize(e,t,i){var s,r,n,o;const{context:a,horizontalPixelRatio:l}=t;this.applyColor(a,null!==(r=null===(s=i.style)||void 0===s?void 0:s.color)&&void 0!==r?r:e.lineColor),this._lineWidth=Math.max(Math.floor(null!==(o=null===(n=i.style)||void 0===n?void 0:n.width)&&void 0!==o?o:e.lineWidth*l))}finishFragment(e){e.fill()}drawItem(e,t,i,s){if(s&&void 0!==i&&!Number.isNaN(i.y)){const t=e.context;t.save(),t.translate(i.x,i.y),t.rotate(Math.PI/4);const s=this._scaleByLineWidth(this._lineWidth);t.scale(s,s),this._drawItemRotatedAndTranslated(e),t.restore()}}applyLineWidth(e,t){this._lineWidth=t}hitTest(e,t,i,s,r){var o,a;if(!s.valIsNotSameAsPrev)return!1;const l=Math.round((i.x+s.x)/2),c=new n.Point(l,s.y),h=r.subtract(c),d=Math.max(Math.floor(null!==(a=null===(o=i.style)||void 0===o?void 0:o.width)&&void 0!==a?a:e.lineWidth*t.pixelRatio));return this._hitTestTranslated(h,d)}_scaleByLineWidth(e){return Math.sqrt(e)}}class _ extends p{applyColor(e,t){e.fillStyle=t}_hitTestTranslated(e,t){return Math.abs(e.x)+Math.abs(e.y)<8*this._scaleByLineWidth(t)/2}_drawItemRotatedAndTranslated(e){(0,h.drawRoundRect)(e.context,-4,-4,8,8,2,!0)}}class m extends p{applyColor(e,t){e.fillStyle=(0,o.applyTransparency)(t,85)}_hitTestTranslated(e,t){ -return Math.abs(e.x)+Math.abs(e.y)<21*this._scaleByLineWidth(t)/2}_drawItemRotatedAndTranslated(e){(0,h.drawRoundRect)(e.context,-10.5,-10.5,21,21,5,!0)}}class g extends d.BitmapCoordinatesPaneRenderer{constructor(e,t){super(),this._data=null,this._data=null!=e?e:null,this._extendLineToLastConfirmedBar=Boolean(t)}setData(e){this._data=e}hitTest(e,t){const i=this._data;if(null===i||0===i.items.length)return null;const{items:r,items:{length:o},lastConfirmedSeriesBarCoordinate:c,visibleItemsRange:{startItemIndex:h,endItemIndex:d}={startItemIndex:0,endItemIndex:o}}=i,p=i.decoration===s.Diamonds?[new u,new m]:[new u];const _=(0,l.lowerbound)(r,e,((e,t)=>e.x<=t.x),h,d),g=Math.max(0,_-1),f=Math.min(o,_+1);for(let s=g;ss.hitTest(i,t,l,h,e))))return new a.HitTestResult(a.HitTarget.Regular)}else if(this._extendLineToLastConfirmedBar&&void 0!==c&&f===o&&l.xthis._drawDecorationItem(e,t)))}_drawDecorationItem(e,t){var i,s,r,o,a,l,c,h,d,u,p,_,m,g,f,v;if(null===this._data||0===this._data.items.length)return;const{lineWidth:S,lineColor:y,items:b}=this._data,{context:w,horizontalPixelRatio:P,verticalPixelRatio:C,bitmapSize:x}=e;let T=Math.max(Math.floor(null!==(s=null===(i=b[0].style)||void 0===i?void 0:i.width)&&void 0!==s?s:S*P)),I=T%2?.5:0;t.initialize(this._data,e,b[0]);const M=null!==(o=null===(r=this._data.visibleItemsRange)||void 0===r?void 0:r.startItemIndex)&&void 0!==o?o:0,L=null!==(l=null===(a=this._data.visibleItemsRange)||void 0===a?void 0:a.endItemIndex)&&void 0!==l?l:b.length,A=this._data.barSpacing;if(!(L<=M)){w.beginPath(),t.applyColor(w,null!==(h=null===(c=b[M].style)||void 0===c?void 0:c.color)&&void 0!==h?h:y);for(let i=M;i{"use strict";i.d(t,{TextRenderer:()=>T,calculateLabelPosition:()=>u,getTextBoundaries:()=>p,wordWrap:()=>_});var s=i(86441),r=i(50151),n=i(34026),o=i(38223),a=i(18807),l=i(68441),c=i(1722),h=i(74359),d=i(79849);function u(e,t,i,r,n){const o=.5*(t.x+i.x);let a=i.y;return t.y>i.y?(a-=e.height/2+r.y,a=Math.max(e.height/2,a)):(a+=e.height/2+r.y,a=Math.min(n-e.height/2,a)),new s.Point(o,a)}function p(e,t,i){if(e.isOutOfScreen(t,i))return null;const s=e.getPolygonPoints();return 0===s.length?null:s}function _(e,t,i){i=(0,c.isString)(i)?parseInt(i):i,e+="";const s=!(0,c.isNumber)(i)||!isFinite(i)||i<=0?e.split(/\r\n|\r|\n|$/):e.split(/[^\S\r\n]*(?:\r\n|\r|\n|$)/);if(s[s.length-1]||s.pop(),!(0,c.isNumber)(i)||!isFinite(i)||i<=0)return s;const r=[];for(let e=0;e0&&(0,h.measureText)(a.slice(0,3*--e-1).join(""),t).width>i;);if(e>0)r.push(a.slice(0,3*e-1).join("")),a.splice(0,3*e);else{const e=a[0]+(a[1]||"");if(l=1===l?1:~~(i/(0,h.measureText)(e,t).width*e.length),(0,h.measureText)(e.substring(0,l),t).width<=i)for(;(0,h.measureText)(e.substring(0,l+1),t).width<=i;)l++;else for(;l>1&&(0,h.measureText)(e.substring(0,--l),t).width>i;);l<1&&(l=1),r.push(e.substring(0,l)),a[0]=e.substring(l),a[1]=""}if((0,h.measureText)(a.join(""),t).width<=i){r.push(a.join(""));break}}}return r}function m(e,t,i){if(0===i)return e.clone();const r=(e.x-t.x)*Math.cos(i)-(e.y-t.y)*Math.sin(i)+t.x,n=(e.x-t.x)*Math.sin(i)+(e.y-t.y)*Math.cos(i)+t.y;return new s.Point(r,n)}function g(e,t){const i=Math.round(t+2*b(e)+2*S(e));return i%2?i+1:i}function f(e,t){return P(e)*t+w(e)*(t-1)+2*y(e)+2*v(e)}function v(e){return void 0!==e.boxPaddingVert?e.boxPaddingVert*x(e):void 0!==e.boxPadding?e.boxPadding*x(e):P(e)/3}function S(e){return void 0!==e.boxPaddingHorz?e.boxPaddingHorz*x(e):void 0!==e.boxPadding?e.boxPadding*x(e):P(e)/3}function y(e){return(e.backgroundVertInflate||0)*x(e)}function b(e){return(e.backgroundHorzInflate||0)*x(e)}function w(e){return(e.padding||0)*x(e)}function P(e){return Math.ceil(C(e)*x(e))}function C(e){return e.fontsize||e.fontSize||30}function x(e){const t=Math.min(1,Math.max(.2,Math.min(e.scaleX||1,e.scaleY||1)));if(1===t)return t;const i=C(e);return Math.ceil(t*i)/i}class T{constructor(e,t){this._data=null,this._internalData=null,this._boxSize=null,this._polygonPoints=null,this._linesInfo=null,this._fontInfo=null,this._hittest=t||new a.HitTestResult(a.HitTarget.MovePoint,{areaName:a.AreaName.Text}),void 0!==e&&this.setData(e)}setData(e){null!==e?(e.horzTextAlign||(e.horzTextAlign=e.horzAlign),!function(e,t){if(null===e||null===t)return null===e==(null===t) -;if(void 0===e.points!=(void 0===t.points))return!1;if(void 0!==e.points&&void 0!==t.points){if(e.points.length!==t.points.length)return!1;for(let r=0;re){const i=(0,s.box)(new s.Point(0,0),new s.Point(e,t));return this.getPolygonPoints().every((e=>!(0,n.pointInBox)(e,i)))}return!1}setPoints(e,t){(0,r.ensureNotNull)(this._data).points=e,this._hittest=t||new a.HitTestResult(a.HitTarget.MovePoint)}fontStyle(e){return null===this._data?"":this._getFontInfo().fontStyle}wordWrap(e,t,i){return _(e,i||this.fontStyle(),t)}draw(e,t){if(null===this._data||void 0===this._data.points||0===this._data.points.length)return;if(this.isOutOfScreen(t.cssWidth,t.cssHeight))return;const i=t.pixelRatio,s=this._getInternalData(),r=this._getRotationPoint().scaled(i);e.save(),e.translate(r.x,r.y),e.rotate(this._data.angle||0),e.translate(-r.x,-r.y);const n=this._getFontInfo().fontSize;e.textBaseline=s.textBaseLine,e.textAlign=s.textAlign,e.font=this.fontStyle();const{scaledLeft:o,scaledRight:a,scaledTop:c,scaledBottom:u}=function(e,t){const i=Math.round(e.boxLeft*t),s=Math.round(e.boxTop*t);return{scaledLeft:i,scaledRight:i+Math.round(e.boxWidth*t),scaledTop:s, -scaledBottom:s+Math.round(e.boxHeight*t)}}(s,i);if(this._data.backgroundColor||this._data.borderColor||this._data.highlightBorder&&this._data.wordWrapWidth){const t=this._data.borderWidth||Math.max(n/12,1),s=Math.round(t*i),r=s/2;let h=!1;if(this._data.boxShadow){e.save();const{shadowColor:t,shadowBlur:i,shadowOffsetX:s=0,shadowOffsetY:r=0}=this._data.boxShadow;e.shadowColor=t,e.shadowBlur=i,e.shadowOffsetX=s,e.shadowOffsetY=r,h=!0}if(this._data.backgroundRoundRect)this._data.backgroundColor&&((0,l.drawRoundRect)(e,o,c,a-o,u-c,this._data.backgroundRoundRect*i),e.fillStyle=this._data.backgroundColor,e.fill(),h&&(e.restore(),h=!1)),this._data.borderColor&&((0,l.drawRoundRect)(e,o-r,c-r,a-o+s,u-c+s,this._data.backgroundRoundRect*i+s),e.strokeStyle=this._data.borderColor,e.lineWidth=s,e.stroke(),h&&(e.restore(),h=!1));else if(this._data.backgroundColor&&(e.fillStyle=this._data.backgroundColor,e.fillRect(o,c,a-o,u-c),h&&(e.restore(),h=!1)),this._data.borderColor||this._data.highlightBorder){let t;this._data.borderColor?(e.strokeStyle=this._data.borderColor,t=s):(e.strokeStyle=this._data.color,(0,l.setLineStyle)(e,d.LINESTYLE_DASHED),t=Math.max(1,Math.floor(i))),e.lineWidth=t,e.beginPath(),e.moveTo(o-t/2,c-t/2),e.lineTo(o-t/2,u+t/2),e.lineTo(a+t/2,u+t/2),e.lineTo(a+t/2,c-t/2),e.lineTo(o-t/2,c-t/2),e.stroke(),h&&e.restore()}}e.fillStyle=this._data.color;const p=(o+Math.round(s.textStart*i))/i,_=.05*n;let m=(c+Math.round((s.textTop+_)*i))/i;const g=w(this._data),f=this.getLinesInfo();for(const t of f.lines)(0,h.drawScaled)(e,i,i,(()=>e.fillText(t,p,m))),m+=n+g;e.restore()}getPolygonPoints(){if(null!==this._polygonPoints)return this._polygonPoints;if(null===this._data)return[];const e=this._data.angle||0,{boxLeft:t,boxTop:i,boxWidth:r,boxHeight:n}=this._getInternalData(),o=this._getRotationPoint();return this._polygonPoints=[m(new s.Point(t,i),o,e),m(new s.Point(t+r,i),o,e),m(new s.Point(t+r,i+n),o,e),m(new s.Point(t,i+n),o,e)],this._polygonPoints}getLinesInfo(){if(null===this._linesInfo){const e=(0,r.ensureNotNull)(this._data);let t=this.wordWrap(e.text,e.wordWrapWidth);if(void 0!==e.maxHeight){const i=function(e){const t=(0,r.ensureDefined)(e.maxHeight),i=P(e),s=w(e);return Math.floor((t+s)/(i+s))}(e);t.length>i&&(t=t.slice(0,i))}this._linesInfo={linesMaxWidth:this._getLinesMaxWidth(t),lines:t}}return this._linesInfo}_getLinesMaxWidth(e){const t=this.fontStyle();if(null!==this._data&&this._data.wordWrapWidth&&!this._data.forceCalculateMaxLineWidth)return this._data.wordWrapWidth*x(this._data);let i=0;for(const s of e)i=Math.max(i,(0,h.measureText)(s,t).width);return i}_getInternalData(){if(null!==this._internalData)return this._internalData;const e=(0,r.ensureNotNull)(this._data),t=this._getBoxSize(),i=t.boxWidth,s=t.boxHeight,n=(0,r.ensureDefined)(e.points)[0];let a=n.y;switch(e.vertAlign){case"bottom":a-=s+e.offsetY;break;case"middle":a-=s/2;break;case"top":a+=e.offsetY}let l=n.x;const c=S(e),h=v(e),d=b(e)+c;let u;const p=a+(y(e)+h)+P(e)/2;let _;switch(e.horzAlign){case"left":l+=e.offsetX;break;case"center":l-=i/2;break -;case"right":l-=i+e.offsetX}switch((0,r.ensureDefined)(e.horzTextAlign)){case"left":_="start",u=l+d,(0,o.isRtl)()&&(e.forceTextAlign?_="left":(u=l+i-d,_="right"));break;case"center":_="center",u=l+i/2;break;case"right":_="end",u=l+i-d,(0,o.isRtl)()&&e.forceTextAlign&&(_="right")}return this._internalData={boxLeft:l,boxTop:a,boxWidth:i,boxHeight:s,textStart:u-l,textTop:p-a,textAlign:_,textBaseLine:"middle"},this._internalData}_getFontInfo(){if(null===this._fontInfo){const e=(0,r.ensureNotNull)(this._data),t=P(e),i=(e.bold?"bold ":"")+(e.italic?"italic ":"")+t+"px "+e.font;this._fontInfo={fontStyle:i,fontSize:t}}return this._fontInfo}_getBoxSize(){if(null===this._boxSize){const e=this.getLinesInfo(),t=(0,r.ensureNotNull)(this._data);this._boxSize={boxWidth:g(t,e.linesMaxWidth),boxHeight:f(t,e.lines.length)}}return this._boxSize}_getRotationPoint(){const{boxLeft:e,boxTop:t,boxWidth:i,boxHeight:n}=this._getInternalData(),{horzAlign:o,vertAlign:a}=(0,r.ensureNotNull)(this._data);let l,c;switch(o){case"center":l=e+i/2;break;case"left":l=e;break;case"right":l=e+i}switch(a){case"middle":c=t+n/2;break;case"top":c=t;break;case"bottom":c=t+n}return new s.Point(l,c)}}},99031:(e,t,i)=>{"use strict";i.d(t,{TrendLineRenderer:()=>p,drawArrow:()=>u});var s=i(50151),r=i(4652),n=i(73436),o=i(18807),a=i(68441),l=i(45197),c=i(74359),h=i(79849);function d(e,t,i,s,r){t.save(),t.fillStyle="#000000",t.beginPath(),t.arc(e.x*r,e.y*r,i*r,0,2*Math.PI,!1),t.fill(),s.strokeWidth&&(t.lineWidth=s.strokeWidth,t.stroke()),t.restore()}function u(e,t,i,s,r,n=!1){if(t.subtract(e).length()<1)return;const o=(0,l.getArrowPoints)(e,t,s,n,!0).slice(0,2);let a=null;for(let e=0;e1)&&i.moveTo(t.x*r,t.y*r),i.lineTo(s.x*r,s.y*r),a=s}}class p{constructor(){this._data=null,this._hittest=new o.HitTestResult(o.HitTarget.MovePoint)}setData(e){this._data=e}setHitTest(e){this._hittest=e}draw(e,t){const i=this._data;if(null===i)return;if("points"in i&&i.points.length<2)return;const s=t.pixelRatio;void 0!==i.excludeBoundaries&&(e.save(),(0,c.addExclusionArea)(e,t,i.excludeBoundaries)),e.lineCap=i.linestyle===h.LINESTYLE_SOLID?"round":"butt",e.lineJoin="round",e.strokeStyle=i.color,e.lineWidth=Math.max(1,Math.floor(i.linewidth*s)),(0,a.setLineStyle)(e,i.linestyle);const r=i.points[0],n=i.points[1];let o=[];e.beginPath(),i.overlayLineEndings?o=[r.clone(),n.clone()]:this._drawEnds(e,[r,n],i.linewidth,s);const l=this._extendAndClipLineSegment(r,n,t);null!==l&&i.linewidth>0&&(l[0].x===l[1].x?(0,a.addVerticalLineToPath)(e,Math.round(l[0].x*s),l[0].y*s,l[1].y*s):l[0].y===l[1].y?(0,a.addHorizontalLineToPath)(e,Math.round(l[0].y*s),l[0].x*s,l[1].x*s):(0,a.addLineToPath)(e,l[0].x*s,l[0].y*s,l[1].x*s,l[1].y*s)),i.overlayLineEndings&&this._drawEnds(e,o,i.linewidth,s),e.stroke(),void 0!==i.excludeBoundaries&&e.restore()}hitTest(e,t){const i=this._data;if(null===i)return null;if("points"in i&&i.points.length<2)return null;const s=(0, -l.interactionTolerance)().line,n=i.points[0],o=i.points[1],a=this._extendAndClipLineSegment(n,o,t);if(null!==a){if((0,r.distanceToSegment)(a[0],a[1],e).distance<=s)return this._hittest}return null}_extendAndClipLineSegment(e,t,i){const r=(0,s.ensureNotNull)(this._data);return(0,l.extendAndClipLineSegment)(e,t,i.cssWidth,i.cssHeight,r.extendleft,r.extendright)}_drawEnds(e,t,i,r){const o=t[0],a=t[1],l=(0,s.ensureNotNull)(this._data);switch(l.leftend){case n.LineEnd.Arrow:u(a,o,e,i,r);break;case n.LineEnd.Circle:d(o,e,i,(0,s.ensureDefined)(l.endstyle),r)}switch(l.rightend){case n.LineEnd.Arrow:u(o,a,e,i,r);break;case n.LineEnd.Circle:d(a,e,i,(0,s.ensureDefined)(l.endstyle),r)}}}},71254:(e,t,i)=>{"use strict";i.d(t,{VerticalLineRenderer:()=>l});var s=i(18807),r=i(68441),n=i(45197),o=i(74359),a=i(59590);class l extends a.BitmapCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null,this._hitTest=new s.HitTestResult(s.HitTarget.MovePoint)}setData(e){this._data=e}setHitTest(e){this._hitTest=e}hitTest(e){if(null===this._data||null===this._hitTest)return null;const t=(0,n.interactionTolerance)().line,i=Math.abs(e.x-this._data.x)<=t+this._data.linewidth/2,s=void 0===this._data.top||this._data.top-e.y<=t,r=void 0===this._data.bottom||e.y-this._data.bottom<=t;return i&&s&&r?this._hitTest:null}_drawImpl(e){if(null===this._data||this._data.linewidth<=0)return;const{context:t,horizontalPixelRatio:i,verticalPixelRatio:s,mediaSize:n}=e;if(this._data.x<-this._data.linewidth/2||this._data.x>n.width+this._data.linewidth/2)return;t.lineCap="butt",t.strokeStyle=this._data.color,t.lineWidth=Math.max(1,Math.floor(this._data.linewidth*i)),void 0!==this._data.linestyle&&(0,r.setLineStyle)(t,this._data.linestyle);const a=void 0!==this._data.top?Math.max(this._data.top,0):0,l=void 0!==this._data.bottom?Math.min(this._data.bottom,n.height):n.height,c=Math.round(this._data.x*i),h=Math.floor(a*s),d=Math.ceil(l*s),u=this._data.excludeBoundaries;void 0!==u&&(0,o.addExclusionAreaByScope)(e,u),(0,r.drawVerticalLine)(t,c,h,d)}}},98517:(e,t,i)=>{"use strict";i.d(t,{sortSources:()=>r,sortSourcesPreOrdered:()=>s});const s={LatestUpdates:10000001,BarMarks:10000002,TimeScaleMarks:10000003,ChartEventsSource:10000004,Dividends:10000005,Splits:10000006,Earnings:10000007,RollDates:10000008,FutureContractExpiration:10000009,LineToolOrder:10000010,LineToolPosition:10000011,LineToolExecution:10000012,AlertLabel:10000013};function r(e){return[...e].sort(((e,t)=>e.zorder()-t.zorder()))}},97034:(e,t,i)=>{"use strict";i.r(t),i.d(t,{PlotList:()=>u,mergeMinMax:()=>p,mergePlotRows:()=>_});var s=i(50151),r=i(78071),n=i(61401),o=i(59224),a=i(86094);const l=(0,o.getLogger)("Chart.PlotList"),c=30;function h(e){return e.index}function d(e){return e.value[0]}class u{constructor(e=null,t=null){this._items=[],this._start=0,this._end=0,this._shareRead=!1,this._minMaxCache=new Map,this._rowSearchCacheByIndex=new Map,this._rowSearchCacheByIndexWithoutEmptyValues=new Map,this._rowSearchCacheByTime=new Map,this._rowSearchCacheByTimeWithoutEmptyValues=new Map, -this._plotFunctions=e||new Map,this._emptyValuePredicate=t}clear(){this._items=[],this._start=0,this._end=0,this._shareRead=!1,this._minMaxCache.clear(),this._invalidateSearchCaches()}first(){return this.size()>0?this._items[this._start]:null}last(){return this.size()>0?this._items[this._end-1]:null}firstIndex(){return this.size()>0?this._indexAt(this._start):null}lastIndex(){return this.size()>0?this._indexAt(this._end-1):null}size(){return this._end-this._start}isEmpty(){return 0===this.size()}contains(e){return null!==this.search(e,a.PlotRowSearchMode.Exact)}valueAt(e){const t=this.search(e);return null!==t?t.value:null}add(e,t){if(this._shareRead)return l.logDebug("add: readonly collection modification attempt"),!1;const i={index:e,value:t},s=this._nonCachedSearch(e,a.PlotRowSearchMode.Exact,h);return this._invalidateSearchCaches(),null===s?(this._items.splice(this._lowerbound(e,h),0,i),this._start=0,this._end=this._items.length,!0):(this._items[s]=i,!1)}search(e,t=a.PlotRowSearchMode.Exact,i){return this._searchImpl(e,t,this._rowSearchCacheByIndex,this._rowSearchCacheByIndexWithoutEmptyValues,h,i)}searchByTime(e,t=a.PlotRowSearchMode.Exact,i){return this._searchImpl(e,t,this._rowSearchCacheByTime,this._rowSearchCacheByTimeWithoutEmptyValues,d,i)}fold(e,t){let i=t;for(let t=this._start;t=i;--t){const i=this._indexAt(t),s=this._valueAt(t);if(e(i,s))return{index:i,value:s}}return null}each(e){for(let t=this._start;tthis._start&&(t._start-=1),t}rangeIterator(e,t){const i=this._lowerbound(e,h),s=this._upperbound(t);if(i===s)return{hasNext:()=>!1,next:()=>{throw new Error("Invalid operation")}};let r=i-1;return{hasNext:()=>r(r+=1,this._items[r])}}minMaxOnRangeCached(e,t,i){if(this.isEmpty())return null;let s=null;for(const r of i){s=p(s,this._minMaxOnRangeCachedImpl(e-r.offset,t-r.offset,r.name))}return s}minMaxOnRange(e,t,i){if(this.isEmpty())return null;let s=null;for(const r of i){s=p(s,this._minMaxOnRange(e-r.offset,t-r.offset,r.name))}return s}merge(e){return this._shareRead?(l.logDebug("merge: readonly collection modification attempt"), -null):0===e.length?null:this.isEmpty()||e[e.length-1].indexthis._items[this._items.length-1].index?this._append(e):1===e.length&&e[0].index===this._items[this._items.length-1].index?(this._updateLast(e[0]),e[0]):this._merge(e)}addTail(e,t=!1){if(0===e.length)return;let i=0;t&&this._end-this._start>0&&(i=1,this._items[this._end-this._start-1].value=e[0].value);for(let t=i;tvoid 0!==e)).sort(((e,t)=>e.index-t.index)),this._invalidateSearchCaches(),this._minMaxCache.clear(),this._start=0,this._end=this._items.length}remove(e){if(this._shareRead)return l.logDebug("remove: readonly collection modification attempt"),null;const t=this._nonCachedSearch(e,a.PlotRowSearchMode.NearestRight,h);if(null===t)return null;const i=this._items.splice(t);return this._end=this._items.length,this._minMaxCache.clear(),this._invalidateSearchCaches(),i.length>0?i[0]:null}state(){const e=this._items.slice(this._start,this._end);return{start:0,end:e.length,data:e}}restoreState(e){e?(this._start=e.start,this._end=e.end,this._shareRead=!1,this._items=e.data,this._minMaxCache.clear(),this._invalidateSearchCaches()):this.clear()}_indexAt(e){return this._items[e].index}_valueAt(e){return this._items[e].value}_length(){return this._items.length}_searchImpl(e,t,i,s,r,n){const o=void 0!==n?i:s,a=void 0!==n?1e4*(t+1)+n:t;let l=o.get(e);if(void 0!==l){const e=l.get(a);if(void 0!==e)return e}const c=this._nonCachedSearch(e,t,r,n);if(null===c)return null;const h={index:this._indexAt(c),value:this._valueAt(c)};return void 0===l&&(l=new Map,o.set(e,l)),l.set(a,h),h}_nonCachedSearch(e,t,i,s){const r=this._lowerbound(e,i),n=r===this._end||e!==i(this._items[r]);if(n&&t!==a.PlotRowSearchMode.Exact)switch(t){case a.PlotRowSearchMode.NearestLeft:return this._searchNearestLeft(r,s);case a.PlotRowSearchMode.NearestRight:return this._searchNearestRight(r,s);default:throw new TypeError("Unknown search mode")}if(void 0===s||n||t===a.PlotRowSearchMode.Exact)return n?null:r;switch(t){case a.PlotRowSearchMode.NearestLeft:return this._nonEmptyNearestLeft(r,s);case a.PlotRowSearchMode.NearestRight:return this._nonEmptyNearestRight(r,s);default:throw new TypeError("Unknown search mode")}}_nonEmptyNearestRight(e,t){const i=(0,s.ensure)(this._emptyValuePredicate),r=(0,s.ensure)(t);for(;e=this._start&&i(this._valueAt(e),r);)e-=1;return et(e)t.index>e),this._start,this._end)}_plotMinMax(e,t,i){let s=null;const r=this._plotFunctions.get(i);if(void 0===r)throw new Error(`Plot "${i}" is not registered`);for(let i=e;is.max&&(s.max=e)))}return s}_invalidateCacheForRow(e){const t=Math.floor(e.index/c);this._minMaxCache.forEach((e=>e.delete(t)))}_prepend(e){return(0,s.assert)(!this._shareRead,"collection should not be readonly"),(0,s.assert)(0!==e.length,"plotRows should not be empty"),this._invalidateSearchCaches(),this._minMaxCache.clear(),this._items=e.concat(this._items),this._start=0,this._end=this._items.length,e[0]}_append(e){return(0,s.assert)(!this._shareRead,"collection should not be readonly"),(0,s.assert)(0!==e.length,"plotRows should not be empty"),this._invalidateSearchCaches(),this._minMaxCache.clear(),this._items=this._items.concat(e),this._start=0,this._end=this._items.length,e[0]}_updateLast(e){(0,s.assert)(!this.isEmpty(),"plot list should not be empty");const t=this._items[this._end-1];(0,s.assert)(t.index===e.index,"last row index should match new row index"),this._invalidateCacheForRow(e),this._invalidateSearchCaches(),this._items[this._end-1]=e}_merge(e){return(0,s.assert)(0!==e.length,"plot rows should not be empty"),this._invalidateSearchCaches(),this._minMaxCache.clear(),this._items=_(this._items,e),this._start=0,this._end=this._items.length,e[0]}_minMaxOnRangeCachedImpl(e,t,i){if(this.isEmpty())return null;let r=null;const n=(0,s.ensureNotNull)(this.firstIndex()),o=(0,s.ensureNotNull)(this.lastIndex()),a=Math.max(e,n),l=Math.min(t,o),h=Math.ceil(a/c)*c,d=Math.max(h,Math.floor(l/c)*c);r=p(r,this._minMaxOnRange(a,Math.min(h,t,l),i));let u=this._minMaxCache.get(i);void 0===u&&(u=new Map,this._minMaxCache.set(i,u));for(let e=Math.max(h+1,a);et[o].index?o++:(n++,o++,r--);return r}(e,t),s=new Array(i);let r=0,n=0;const o=e.length,a=t.length;let l=0;for(;rt[n].index?(s[l]=t[n],n++):(s[l]=t[n],r++,n++),l++;for(;r{"use strict";i.d(t,{PriceAxisView:()=>p});var s=i(86441),r=i(34026),n=i(38325),o=i(38223),a=i(74359),l=i(18807),c=i(68441);const h=new Path2D("M7.5 0.8a1 1 0 0 0 0 13.4 1 1 0 0 0 0-13.4zm0 1a1 1 0 0 1 0 11 1 1 0 0 1 0-11zm-.97-.25A3.5 3.5 0 0 0 3.5 0 3.5 3.5 0 0 0 0 3.5a3.5 3.5 0 0 0 1.75 3.03l.5-.86A2.5 2.5 0 0 1 1 3.5 2.5 2.5 0 0 1 3.5 1a2.5 2.5 0 0 1 2.17 1.25zm6.72 4.78A3.5 3.5 0 0 0 15 3.5 3.5 3.5 0 0 0 11.5 0a3.5 3.5 0 0 0-3.03 1.75l.86.5A2.5 2.5 0 0 1 11.5 1 2.5 2.5 0 0 1 14 3.5a2.5 2.5 0 0 1-1.25 2.17zM7 5h1v5H7zm3 2v1H5V7z");class d{constructor(e,t){this._bodyBox=null,this.setData(e,t)}setData(e,t){this._data=e,this._commonData=t}lastDrawnBodyBox(){return this._bodyBox}draw(e,t,i,r,n,l,h){var d,u,p,_;const m=this._data;if(!m.visible||this._isOutOfScreen(t,n))return;const g=this._commonData,f=void 0!==m.labelIcon,v=t.borderSize,S=t.paddingTop+g.additionalPaddingTop,y=t.paddingBottom+g.additionalPaddingBottom,b=t.paddingInner,w=m.ignoreAdditionalPaddingInner?0:t.additionalPaddingInner,P=t.paddingOuter,C=t.fontSize;let x=m.text,T=m.textColor||g.textColor,I=m.secondLine||"",M=g.secondLineTextColor||T,L=m.thirdLine||"";const A=g.thirdLineTextColor||T;0===I.length&&(I=L,M=A,L=""),0===x.length&&(x=I,T=M,I=L,M=A,L=""),e.save(),e.font=t.font;const k=i.yMidCorrection(e,x)*h,D=Math.ceil(i.measureText(e,x)),V=C+S+y,E=(null!==(d=m.labelIconMinWidth)&&void 0!==d?d:0)*h,B=Boolean(I),R=Boolean(L),N=B?Math.ceil(i.measureText(e,I)):0,O=R?Math.ceil(i.measureText(e,L)):0,F=v+b+P+D+w,W=N>0?v+b+P+N+w:0,H=O>0?v+b+P+O+w:0,z=Math.max(F,W,H),U=Math.max(1,Math.floor(h));let j=Math.round(V*h);j%2!=U%2&&(j+=1);const G=Math.round((C+t.lineSpacing)*h),q=Math.round(2*(C+t.lineSpacing)*h),$=Math.max(1,Math.floor(v*h)),Y=m.separatorVisible?$:0,K=m.borderVisible?$:0,Z=f?Math.max(j,E):Math.round(z*h),X=Math.round(w*h),J=Math.ceil(r*h),Q=Math.ceil(b*h),ee=Math.round((null!==(u=g.fixedCoordinate)&&void 0!==u?u:g.coordinate)*h)-Math.floor(.5*h),te=Math.floor(ee+U/2-j/2),ie=te+j,se="right"===l,re=void 0!==m.xCoord?Math.round(m.xCoord*h)+(se?1:-1)*Math.round(Z/2):se?J-Y:Y,ne=J;let oe,ae=re;const le=null!==(p=m.backgroung)&&void 0!==p?p:g.background;e.fillStyle=le;const ce=2*h;if(e.textAlign=se?"right":"left",e.textBaseline="middle",se?(ae=re-Z,oe=re-X-Q-1):(ae=re+Z,oe=re+X+Q),this._bodyBox=null,x||f){const i=R?j+q:B?j+G:j,r=null!==(_=g.borderColor)&&void 0!==_?_:le,n=void 0!==m.xCoord?ce:0;if(((t,r,o)=>{if(se){(0,c.drawRoundRectWithInnerBorder)(e,ae,te,Z,i,t,m.overridenRadius?(0,c.scaleDrawRoundRectRadii)(m.overridenRadius,h):[ce,n,n,ce],K,r,o);const a=(0, -s.point)(ae/h,te/h),l=a.add((0,s.point)(Z/h,i/h));this._bodyBox=(0,s.box)(a,l)}else{(0,c.drawRoundRectWithInnerBorder)(e,re,te,Z,i,t,m.overridenRadius?(0,c.scaleDrawRoundRectRadii)(m.overridenRadius,h):[n,ce,ce,n],K,r,o);const a=(0,s.point)(re/h,te/h),l=a.add((0,s.point)(Z/h,i/h));this._bodyBox=(0,s.box)(a,l)}})(le,r,g.borderStyle),m.separatorVisible&&(e.fillStyle=t.paneBackgroundColor,e.fillRect(se?ne-Y:0,te,Y,ie-te)),f){switch(m.labelIcon){case 0:this._drawPlusIcon(e,re,ae,te,ee,ie,U);break;case 1:this._drawClockIcon(e,re,ae,ee,U,h)}return void e.restore()}e.save(),e.translate(oe,(te+ie)/2+k),(0,a.drawScaled)(e,h,h,(()=>{e.fillStyle=T,e.fillText(x,0,0)})),e.restore()}B&&(e.fillStyle=M,e.save(),e.translate(oe,(te+ie)/2+k+G),(0,a.drawScaled)(e,h,h,(()=>{e.fillText((0,o.startWithLTR)(I),0,0)})),e.restore()),R&&(e.fillStyle=A,e.save(),e.translate(oe,(te+ie)/2+k+q),(0,a.drawScaled)(e,h,h,(()=>{e.fillText((0,o.startWithLTR)(L),0,0)})),e.restore()),e.restore()}topBottomTotalHeight(e){const t=this._lines();if(!this._data.visible||0===t)return{top:0,bottom:0,total:0};const i=e.fontSize/2+e.paddingTop+this._commonData.additionalPaddingTop,s=(t-.5)*e.fontSize+(t-1)*e.lineSpacing+e.paddingBottom+this._commonData.additionalPaddingBottom;return{top:i,bottom:s,total:i+s}}hitTest(e){return function(e,t){var i;const o=(0,n.lastMouseOrTouchEventInfo)().isTouch?10:0,a=e.hitTestData;if(void 0===a||!e.visible)return null;const{itemBox:c,clickHandler:h,tooltip:d}=a;if(c){const n=(0,s.box)(new s.Point(c.min.x-o,c.min.y-o),new s.Point(c.max.x+o,c.max.y+o));if((0,r.pointInBox)(t,n))return new l.HitTestResult(null!==(i=e.hitTarget)&&void 0!==i?i:l.HitTarget.Custom,{clickHandler:null==h?void 0:h.bind(null,t),tapHandler:null==h?void 0:h.bind(null,t),hoverModelFromAxis:a.hoverModelFromAxis,activeItem:a.activeItem,tooltip:d})}return null}(this._data,e)}_drawPlusIcon(e,t,i,s,r,n,o){e.fillStyle=this._commonData.textColor,e.strokeStyle=this._commonData.textColor,e.lineWidth=o;const a=Math.abs(t-i);let l=Math.round(.35*a);l%2!=o%2&&(l+=1);let c=Math.round(.65*a);c%2!=o%2&&(c+=1);const h=Math.floor((a-l)/2),d=Math.min(t,i),u=d+Math.floor(a/2-o/2);e.fillRect(d+h,r,l,o),e.fillRect(u,s+h,o,l),e.beginPath(),e.arc(u+o/2,r+o/2,c/2,0,2*Math.PI,!1),e.stroke()}_drawClockIcon(e,t,i,s,r,n){e.fillStyle=this._commonData.textColor,e.lineWidth=r;const o=Math.abs(t-i);let a=Math.round(.35*o);a%2!=r%2&&(a+=1);let l=Math.round(.65*o);l%2!=r%2&&(l+=1);const c=Math.min(t,i)+Math.floor(o/2-r/2);e.save(),e.translate(c+r/2-l/2,s+r/2-l/2),e.scale(n,n),e.fill(h),e.restore()}_lines(){const e=this._data;return(e.text?1:0)+(e.secondLine?1:0)+(e.thirdLine?1:0)}_isOutOfScreen(e,t){var i;const s=this._commonData,r=null!==(i=s.fixedCoordinate)&&void 0!==i?i:s.coordinate,{total:n}=this.topBottomTotalHeight(e),o=n/this._lines();return r-o/2-3>t||r+(n-o/2)+3<0}}var u=i(87095);class p{constructor(e){this._commonRendererData={coordinate:0,textColor:"#FFF",background:"#000",additionalPaddingBottom:0,additionalPaddingTop:0},this._axisRendererData={text:"",visible:!1,separatorVisible:!1, -borderVisible:!1,ignoreAdditionalPaddingInner:!1},this._paneRendererData={text:"",visible:!1,separatorVisible:!0,borderVisible:!1,ignoreAdditionalPaddingInner:!0},this._invalidated=!0,this._active=!1,this._axisRenderer=new(e||d)(this._axisRendererData,this._commonRendererData),this._paneRenderer=new(e||d)(this._paneRendererData,this._commonRendererData)}setActive(e){this._active=e}text(){return this._updateRendererDataIfNeeded(),this._axisRendererData.text}secondLineText(){return this._updateRendererDataIfNeeded(),this._axisRendererData.secondLine}thirdLineText(){return this._updateRendererDataIfNeeded(),this._axisRendererData.thirdLine}background(){return this._updateRendererDataIfNeeded(),this._commonRendererData.background}color(){return this._updateRendererDataIfNeeded(),this.generateTextColor(this.background())}generateTextColor(e){return(0,u.colorFromBackground)(e)}coordinate(){return this._updateRendererDataIfNeeded(),this._commonRendererData.coordinate}floatCoordinate(){var e;return this._updateRendererDataIfNeeded(),null!==(e=this._commonRendererData.floatCoordinate)&&void 0!==e?e:this._commonRendererData.coordinate}update(e){this._invalidated=!0}topBottomTotalHeight(e){this._updateRendererDataIfNeeded();const{top:t,bottom:i,total:s}=this._axisRenderer.topBottomTotalHeight(e),{top:r,bottom:n,total:o}=this._paneRenderer.topBottomTotalHeight(e);return{top:Math.max(t,r),bottom:Math.max(i,n),total:Math.max(s,o)}}getFixedCoordinate(){return this._commonRendererData.fixedCoordinate||0}setFixedCoordinate(e){this._commonRendererData.fixedCoordinate=e}isVisible(){return this._updateRendererDataIfNeeded(),this._axisRendererData.visible||this._paneRendererData.visible}isAxisLabelVisible(){return this._updateRendererDataIfNeeded(),this._axisRendererData.visible}isPaneLabelVisible(){return this._updateRendererDataIfNeeded(),this._paneRendererData.visible}renderer(){return this._updateRendererDataIfNeeded(),this._axisRenderer}paneRenderer(){return this._updateRendererDataIfNeeded(),this._paneRenderer}setPaneRendererLabelIcon(e){this._paneRendererData.labelIcon=e}setPaneLabelVisible(e){this._paneRendererData.visible=e,this._invalidated=!0}ignoreAlignment(){return!1}_updateRendererDataIfNeeded(){this._invalidated&&(this._commonRendererData.fixedCoordinate=void 0,this._updateRendererData(this._axisRendererData,this._paneRendererData,this._commonRendererData),this._invalidated=!1)}}},80842:(e,t,i)=>{"use strict";i.d(t,{PriceDataSource:()=>a,isPriceDataSource:()=>o});var s=i(14292),r=i(57898),n=i(18611);function o(e){return e instanceof a}class a extends s.DataSource{constructor(e,t){super(t),this._formatterChanged=new r.Delegate,this._priceStepChanged=new r.Delegate,this._currencyChanged=new r.Delegate,this._unitChanged=new r.Delegate,this._priceRangeReadyChanged=new r.Delegate,this._priceStep=null,this._priceRangeReady=!0,this._model=e}base(){return 0}model(){return this._model}currencyChanged(){return this._currencyChanged}isCurrencySource(){return!0}isDisplayedInLegend(){return!0}unitChanged(){return this._unitChanged} -isUnitSource(){return!0}priceRange(e,t){return null}isDraggable(){return!0}priceLineColor(e){return e}formatterChanged(){return this._formatterChanged}priceStep(e){return this._priceStep}priceStepChanged(){return this._priceStepChanged}isIncludedInAutoScale(){return!0}correctScaleMargins(e){return e}priceRangeReady(){return this._priceRangeReady}priceRangeReadyChanged(){return this._priceRangeReadyChanged}disablePriceRangeReady(){const e=this.priceScale();null===e||e.isAutoScale()||e.mainSource()!==this||(this._priceRangeReady=!1,e.recalculatePriceRangeOnce()),this._priceRangeReadyChanged.fire(!1)}statusView(){return null}legendView(){return null}marketStatusModel(){return null}dataUpdatedModeModel(){return null}dataProblemModel(){return null}_enablePriceRangeReady(){this._priceRangeReady=!0,this._priceRangeReadyChanged.fire(!0)}_onSourceCurrencyChanged(){(0,n.isActingAsSymbolSource)(this)||this._currencyChanged.fire()}_onSourceUnitChanged(){(0,n.isActingAsSymbolSource)(this)||this._unitChanged.fire()}_onSourcePriceRangeReadyChanged(e){(0,n.isActingAsSymbolSource)(this)||e||this.disablePriceRangeReady()}}},11527:(e,t,i)=>{"use strict";i.d(t,{PriceLineAxisView:()=>l,SeriesPriceLineAxisView:()=>c,StudyPriceLineAxisView:()=>h});var s=i(42275),r=i(50151),n=i(79849),o=i(68441);class a{constructor(e,t){this.setData(e,t)}setData(e,t){this._data=e,this._commonData=t}draw(e,t,i,s,a,l,c){var h;if(!this._data.visible)return;const d=null!==(h=this._commonData.fixedCoordinate)&&void 0!==h?h:this._commonData.coordinate;e.lineWidth=Math.max(1,Math.floor((0,r.ensureDefined)(this._data.linewidth)*c)),e.lineCap="butt",(0,o.setLineStyle)(e,void 0===this._data.linestyle?n.LINESTYLE_DOTTED:this._data.linestyle),e.strokeStyle=this._commonData.textColor,(0,o.drawHorizontalLine)(e,Math.round(d*c),0,Math.ceil(s*c))}topBottomTotalHeight(e){return{top:0,bottom:0,total:0}}}class l extends s.PriceAxisView{constructor(e){super(e||a)}ignoreAlignment(){return!0}_updateRendererData(e,t,i){if(t.visible=!1,e.visible=!1,!this._isVisible())return;const s=this._value();s.noData||(i.background="",i.textColor=this._priceLineColor(s.color),i.coordinate=s.coordinate,i.floatCoordinate=s.floatCoordinate,e.linewidth=this._lineWidth(),e.linestyle=this._lineStyle(),e.backgroundAreaVisible=this._backgroundAreaVisible(),e.backgroundAreaColor=this._backgroundAreaColor(),e.backgroundAreaHeight=this._backgroundAreaHeight(),e.visible=!0)}_lineStyle(){return n.LINESTYLE_DOTTED}_backgroundAreaVisible(){return!1}_backgroundAreaColor(){return""}_backgroundAreaHeight(){return 0}}class c extends l{constructor(e){super(),this._series=e}_value(){return this._series.lastValueData(void 0,!0)}_priceLineColor(e){return this._series.priceLineColor(e)}_lineWidth(){return this._series.properties().childs().priceLineWidth.value()}_isVisible(){const e=this._series.model().properties().childs().scalesProperties.childs().showSeriesLastValue.value();return this._series.properties().childs().showPriceLine.value()&&e}}class h extends l{constructor(e,t){super(),this._study=e,this._plotname=t -}_value(){return this._study.lastValueData(this._plotname,!0)}_lineWidth(){return this._study.properties().childs().styles.childs()[this._plotname].childs().linewidth.value()}_lineStyle(){return n.LINESTYLE_DOTTED}_priceLineColor(e){return e}_isVisible(){const e=this._study.model().properties().childs().scalesProperties.childs().showStudyLastValue.value(),t=this._study.isPlotVisibleAt(this._plotname,1);return this._study.properties().childs().styles.childs()[this._plotname].childs().trackPrice.value()&&e&&t}}},74304:(e,t,i)=>{"use strict";var s;i.d(t,{PriceAxisLastValueMode:()=>s}),function(e){e[e.LastPriceAndPercentageValue=0]="LastPriceAndPercentageValue",e[e.LastValueAccordingToScale=1]="LastValueAccordingToScale"}(s||(s={}))},78211:(e,t,i)=>{"use strict";i.d(t,{fromIndexedTo100:()=>c,fromLog:()=>p,fromPercent:()=>o,getCurrentModePriceText:()=>g,getOppositeModePriceText:()=>f,logFormulaForPriceRange:()=>_,logFormulasAreSame:()=>m,toIndexedTo100:()=>h,toIndexedTo100Range:()=>d,toLog:()=>u,toPercent:()=>a,toPercentRange:()=>l});var s=i(34256),r=i(37160);const n={logicalOffset:4,coordOffset:1e-4};function o(e,t){return t<0&&(e=-e),e/100*t+t}function a(e,t){const i=100*(e-t)/(t||1);return t<0?-i:i}function l(e,t){const i=a(e.minValue(),t),r=a(e.maxValue(),t);return new s.PriceRange(i,r)}function c(e,t){return t<0&&(e=-e),(e-=100)/100*t+t}function h(e,t){const i=100*(e-t)/t+100;return t<0?-i:i}function d(e,t){const i=h(e.minValue(),t),r=h(e.maxValue(),t);return new s.PriceRange(i,r)}function u(e,t){const i=Math.abs(e);if(i<1e-25)return 0;const s=(0,r.log10)(i+t.coordOffset)+t.logicalOffset;return e<0?-s:s}function p(e,t){const i=Math.abs(e);if(i<1e-15)return 0;const s=Math.pow(10,i-t.logicalOffset)-t.coordOffset;return e<0?-s:s}function _(e){if(null===e)return n;const t=Math.abs(e.maxValue()-e.minValue());if(t>=1||t<1e-15)return n;const i=Math.ceil(Math.abs(Math.log10(t))),s=n.logicalOffset+i;return{logicalOffset:s,coordOffset:1/Math.pow(10,s)}}function m(e,t){return e.logicalOffset===t.logicalOffset&&e.coordOffset===t.coordOffset}function g(e,t){return e.isPercentage()?t.formattedPricePercentage:e.isIndexedTo100()?t.formattedPriceIndexedTo100:t.formattedPriceAbsolute}function f(e,t){return e.isPercentage()||e.isIndexedTo100()?t.formattedPriceAbsolute:t.formattedPricePercentage}},34256:(e,t,i)=>{"use strict";i.d(t,{PriceRange:()=>n});var s=i(1722);const r=(0,i(59224).getLogger)("Chart.PriceRange");class n{constructor(e,t){if(null!==e&&"object"==typeof e){const t=e;this._minValue=t.m_minValue,this._maxValue=t.m_maxValue}else{const i=e;this._minValue=i,void 0!==t&&(this._maxValue=t)}}equals(e){return this._minValue===e._minValue&&this._maxValue===e._maxValue}clone(){return new n(this._minValue,this._maxValue)}minValue(){return this._minValue}setMinValue(e){this._minValue=e}maxValue(){return this._maxValue}setMaxValue(e){this._maxValue=e}length(){return this._maxValue-this._minValue}isEmpty(){return this._maxValue===this._minValue||this._maxValue!=this._maxValue||this._minValue!=this._minValue}serialize(){return{ -m_maxValue:this._maxValue,m_minValue:this._minValue}}state(){return{max:this._maxValue,min:this._minValue}}merge(e){return new n(Math.min(this.minValue(),e.minValue()),Math.max(this.maxValue(),e.maxValue()))}apply(e,t){this._minValue=Math.min(this._minValue,e),this._maxValue=Math.max(this._maxValue,t)}set(e,t){this._minValue=e,this._maxValue=t}scaleAroundCenter(e){if(!(0,s.isNumber)(e))return void r.logDebug("PriceRange.scaleAroundCenter: invalid coeff");if(0===this._maxValue-this._minValue)return;const t=.5*(this._maxValue+this._minValue);let i=this._maxValue-t,n=this._minValue-t;i*=e,n*=e,this._maxValue=t+i,this._minValue=t+n}shift(e){(0,s.isNumber)(e)?(this._maxValue+=e,this._minValue+=e):r.logDebug("PriceRange.shift: invalid coeff")}containsStrictly(e){return e.minValue()>this._minValue&&e.maxValue(){"use strict";i.d(t,{createPrimitiveProperty:()=>n});var s=i(59452),r=i.n(s);function n(e){return new(r())(e)}},13637:(e,t,i)=>{"use strict";i.d(t,{ThemedDefaultProperty:()=>w,extractAllPropertiesKeys:()=>v,extractState:()=>S,factoryDefaultsForCurrentTheme:()=>y});var s=i(58121),r=i(99094),n=i(16230),o=i(98279),a=i(38651),l=i(50151),c=i(56840),h=i(22767),d=i(45345),u=i(26843),p=i(59452),_=i.n(p),m=i(85804),g=i(57898);const f=(0,i(59224).getLogger)("ThemedDefaults");function v(e){const t=Object.keys(e),i=[];return t.forEach((t=>{const s=e[t];if((0,o.default)(s)){v(s).forEach((e=>i.push(`${t}.${e}`)))}else i.push(t)})),i}function S(e,t,i=""){const s={};return t.forEach((r=>{const n=r.split("."),a=n[0],l=e[a],c=""===i?a:`${i}.${a}`;if(e.hasOwnProperty(a))if(n.length>1){if(!(0,o.default)(l))return void f.logError(`path ${c} must be an object, but it is a primitive`);{const e=t.filter((e=>e.startsWith(`${a}.`))).map((e=>e.split(".").slice(1).join(".")));s[a]=S(l,e,c)}}else{if((0,o.default)(l))return void f.logError(`path ${c} must be a primitive, but it is an object`);s[a]=l}})),s}function y(e,t){var i;const r=null!==(i=d.watchedTheme.value())&&void 0!==i?i:u.StdTheme.Light,n=(0,h.deepCopy)(e);return(0,s.default)(n,(0,l.ensureDefined)(t.get(r))),n}function b(e,t){const i=(0,r.default)(e,((e,i,s)=>{if(void 0===t[s])return e;if(!(0,n.default)(i,t[s]))if((0,o.default)(i)&&(0,o.default)(t[s])){const r=b(i,t[s]);void 0!==r&&(e[s]=r)}else e[s]=i;return e}),{});return(0,a.default)(i)?void 0:i}class w extends(_()){constructor(e,t,i,r,n,o){super(function(e,t,i,r){var n;const o=t(),a=S((0,h.deepCopy)(null!==(n=c.getJSON(e,null))&&void 0!==n?n:{}),i);return(0,s.default)(o,a),(0,s.default)(o,S(null!=r?r:{},i)),o}(e,t,n,o)),this._applyingThemeInProcess=!1,this._restoreFactoryDefaultsEvent=new g.Delegate,this._defaultName=e,this._defaultsSupplier=t,this._notThemedDefaultsKeys=i,this._themedDefaultsKeys=r,this._allStateKeys=n,this._allDefaultsKeys=[...i,...r]}restoreFactoryDefaults(){const e=this._defaultsSupplier();this.mergeAndFire(e),this.saveDefaults(),this._restoreFactoryDefaultsEvent.fire()}addExclusion(){}state(){ -return S(super.state(),this._allStateKeys)}mergePreferences(e){this.mergeAndFire(S(e,this._allStateKeys))}childChanged(e){super.childChanged(e),this._applyingThemeInProcess||this.saveDefaults()}saveDefaults(){const e=this.state(),t=this._defaultsSupplier();let i=b(S(e,this._notThemedDefaultsKeys),S(t,this._notThemedDefaultsKeys));const r=S(t,this._themedDefaultsKeys),n=S(e,this._themedDefaultsKeys),o=b(n,r);(0,a.default)(o)||(i=null!=i?i:{},(0,s.default)(i,n)),(0,m.saveDefaults)(this._defaultName,i)}}},48686:(e,t,i)=>{"use strict";i.d(t,{combineProperty:()=>r});var s=i(59680);function r(e,...t){const i=()=>e(...t.map((e=>e.value()))),r=(0,s.createPrimitiveProperty)(i()),n=()=>r.setValue(i()),o={};for(const e of t)e.subscribe(o,n);return r.destroy=()=>{t.forEach((e=>e.unsubscribeAll(o))),t.forEach((e=>e.release()))},r}},63821:(e,t,i)=>{"use strict";i.d(t,{convertPropertyToWatchedValue:()=>r});var s=i(97145);function r(e){const t=new s.WatchedValue(e.value());let i=!1;e.subscribe(t,(()=>{i||(i=!0,t.setValue(e.value()),i=!1)}));const r=()=>{i||(i=!0,e.setValue(t.value()),i=!1)};return t.subscribe(r),t.spawn((()=>{e.unsubscribeAll(t),t.unsubscribe(r)}))}},49152:(e,t,i)=>{"use strict";i.d(t,{combineProperty:()=>o.combineProperty,createWVFromGetterAndSubscription:()=>s.createWVFromGetterAndSubscription,createWVFromGetterAndSubscriptions:()=>r.createWVFromGetterAndSubscriptions,createWVFromProperty:()=>n});var s=i(28986),r=i(49475);function n(e){return(0,s.createWVFromGetterAndSubscription)((()=>e.value()),e)}i(59680);var o=i(48686)},28986:(e,t,i)=>{"use strict";i.d(t,{createWVFromGetterAndSubscription:()=>r});var s=i(97145);function r(e,t){const i=new s.WatchedValue(e()),r={};t.subscribe(r,(()=>{i.setValue(e())}));return i.readonly().spawn((()=>t.unsubscribeAll(r)))}},49475:(e,t,i)=>{"use strict";i.d(t,{createWVFromGetterAndSubscriptions:()=>r});var s=i(97145);function r(e,t){const i=new s.WatchedValue(e()),r={};t.forEach((t=>t.subscribe(r,(()=>{i.setValue(e())}))));return i.readonly().spawn((()=>t.forEach((e=>e.unsubscribeAll(r)))))}},59452:(e,t,i)=>{"use strict";const{weakReference:s,ownership:r}=i(19782);var n=i(1722).isFunction,o=i(57898).Delegate;function a(e){if(this._listeners=new o,this._childs=[],this._muteChildChanges=!1,void 0!==e)if(this.isPrimitiveType(e))this._value=e;else for(var t in e)this.addProperty(t,e[t])}a.prototype.destroy=function(){this.listeners().destroy()},a.prototype.merge=function(e,t){var i=null;if(t)var s=(i=[]).length;if(void 0===e)return i;if(this.isPrimitiveType(e))return t&&this._value!==e&&i.push(this),this._value=e,i;if(Array.isArray(e))for(var r=0;rs&&i.push(this),i},a.prototype.mergeAndFire=function(e){var t=this.merge(e,!0);this._muteChildChanges=!0,t.forEach((function(e){e._muteChildChanges=!0})), -t.forEach((function(e){e._muteChildChanges=!1,e.listeners().fire(e)})),this._muteChildChanges=!1,t.length>0&&this.listeners().fire(this)},a.prototype.state=function(e){var t=n(this.value)?this.value():void 0;void 0===t&&(t={});for(var i=0;i=0},a.prototype.addChild=function(e,t){this[e]&&this[e].unsubscribe(this,this.childChanged),this[e]=t,-1===this._childs.indexOf(e)&&this._childs.push(e),t.subscribe(this,this.childChanged)},a.prototype.childChanged=function(e,t){this._muteChildChanges||this.listeners().fire(this)},a.prototype.subscribe=function(e,t){this.listeners().subscribe(e,t,!1)},a.prototype.unsubscribe=function(e,t){this.listeners().unsubscribe(e,t)},a.prototype.unsubscribeAll=function(e){this.listeners().unsubscribeAll(e)},a.prototype.childs=function(){return this},a.prototype.weakReference=function(){return s(this)},a.prototype.ownership=function(){return r(this)},e.exports=a},71625:(e,t,i)=>{"use strict";i.d(t,{QuotesProvider:()=>o});var s=i(2438),r=i(57898),n=i(36174);class o{constructor(e="full"){this._quotes=null,this._quoteSessionSymbol=null,this._quoteSessionClientId="",this._pausedQuoteSessionSymbol=null,this._quotesUpdate=new r.Delegate,this._quoteSymbolChanged=new r.Delegate,this._multiplexerType=e}setQuotesSessionSymbol(e){this._quoteSessionSymbol!==e&&(this._pausedQuoteSessionSymbol=null,this._quoteSessionClientId||(this._quoteSessionClientId="series-"+(0,n.guid)()),this._unsubscribeQuoteSession(),this._quoteSessionSymbol=e,this._quoteSymbolChanged.fire(),e&&this._subscribeQuoteSession(e))}quotesUpdate(){return this._quotesUpdate}quoteSymbolChanged(){return this._quoteSymbolChanged}quotes(){return this._quotes}isPaused(){return null!==this._pausedQuoteSessionSymbol}pause(){ -null===this._pausedQuoteSessionSymbol&&(this._pausedQuoteSessionSymbol=this._quoteSessionSymbol,this._unsubscribeQuoteSession())}resume(){null!==this._pausedQuoteSessionSymbol&&(this._subscribeQuoteSession(this._pausedQuoteSessionSymbol),this._pausedQuoteSessionSymbol=null)}destroy(){this._unsubscribeQuoteSession()}_onUpdate(e,t){this._quotes=e&&e.values||null,t&&t.values&&this._quotesUpdate.fire(e,t)}_subscribeQuoteSession(e){this._quoteSessionSymbol=e,(0,s.getQuoteSessionInstance)(this._multiplexerType).subscribe(this._quoteSessionClientId,this._quoteSessionSymbol,this._onUpdate.bind(this))}_unsubscribeQuoteSession(){this._quoteSessionSymbol&&((0,s.getQuoteSessionInstance)(this._multiplexerType).unsubscribe(this._quoteSessionClientId,this._quoteSessionSymbol),this._quoteSessionSymbol=null,this._quotes=null)}}},94025:(e,t,i)=>{"use strict";i.r(t),i.d(t,{compareResolutions:()=>k,convertResolutionsFromSettings:()=>I,getApplicableIntervalForFrequency:()=>b,getCustomResolutions:()=>D,getDefaultResolution:()=>S,getMaxResolutionValue:()=>x,getRangeResolution:()=>f,getResolutionByChartStyle:()=>y,getResolutionsFromSettings:()=>T,getServerInterval:()=>w,getTimeBasedResolution:()=>v,getTranslatedResolution:()=>V,getTranslatedResolutionModel:()=>E,intervalIsSupported:()=>W,isAvailable:()=>m,isIntervalEnabled:()=>O,isResolutionMultiplierValid:()=>P,isSecondsEnabled:()=>R,isTicksEnabled:()=>N,mergeResolutions:()=>M,normalizeIntervalString:()=>_,parseIntervalValue:()=>F,setLastUsedResolution:()=>g,sortResolutions:()=>L});var s=i(44352),r=i(36274),n=i(42960),o=i(56840),a=i(82992),l=i(15051),c=i(1722),h=i(14483);const d={[r.ResolutionKind.Ticks]:1,[r.ResolutionKind.Seconds]:60,[r.ResolutionKind.Minutes]:1440,[r.SpecialResolutionKind.Hours]:24,[r.ResolutionKind.Days]:365,[r.ResolutionKind.Weeks]:52,[r.ResolutionKind.Months]:12,[r.ResolutionKind.Range]:1e6,[r.ResolutionKind.Invalid]:NaN},u={[r.ResolutionKind.Ticks]:0,[r.ResolutionKind.Seconds]:1,[r.ResolutionKind.Minutes]:2,[r.SpecialResolutionKind.Hours]:3,[r.ResolutionKind.Days]:4,[r.ResolutionKind.Weeks]:5,[r.ResolutionKind.Months]:6,[r.ResolutionKind.Range]:7,[r.ResolutionKind.Invalid]:8},p={[r.ResolutionKind.Invalid]:"",[r.ResolutionKind.Ticks]:s.t(null,{context:"interval_short"},i(59231)),[r.ResolutionKind.Seconds]:s.t(null,{context:"interval_short"},i(2949)),[r.ResolutionKind.Minutes]:s.t(null,{context:"interval_short"},i(6791)),[r.SpecialResolutionKind.Hours]:s.t(null,{context:"interval_short"},i(13994)),[r.ResolutionKind.Days]:s.t(null,{context:"interval_short"},i(13395)),[r.ResolutionKind.Weeks]:s.t(null,{context:"interval_short"},i(85521)),[r.ResolutionKind.Months]:s.t(null,{context:"interval_short"},i(37720)),[r.ResolutionKind.Range]:s.t(null,{context:"interval_short"},i(69838))};function _(e){return r.Interval.parse(e).value()}function m(e){const t=r.Interval.parse(e);if(!R()&&t.isSeconds())return!1;if(!N()&&t.isTicks())return!1;const i=t.value(),s=a.linking.dataFrequencyResolution.value();if(void 0!==s&&k(i,s)<0)return!1;const n=a.linking.supportedResolutions.value() -;return void 0!==n?void 0!==n.find((e=>_(e)===i)):t.isSeconds()?Boolean(a.linking.seconds.value()):t.isTicks()?Boolean(a.linking.ticks.value()):t.isIntraday()?Boolean(a.linking.intraday.value()):t.isDWM()}function g(e){r.Interval.isValid(e)&&(r.Interval.isRange(e)?o.setValue("chart.lastUsedRangeResolution",e):o.setValue("chart.lastUsedTimeBasedResolution",e))}function f(e){const t=o.getValue("chart.lastUsedRangeResolution");if(void 0!==t&&r.Interval.isRange(t))return t;let i="100R";for(const t of e){const e=r.Interval.parse(t);if(e.isRange()){const t=e.value();if("100R"===t)return t;i=t}}return i}function v(e){const t=o.getValue("chart.lastUsedTimeBasedResolution");if(void 0!==t&&r.Interval.isTimeBased(t))return t;let i="1D";for(const t of e){const e=r.Interval.parse(t);if(e.isTimeBased()){const t=e.value();if("1D"===t)return t;i=t}}return i}function S(e){return e?"100R":"1D"}function y(e,t,i){const s=n.isRangeStyle(e),o=r.Interval.isRange(t);return!s&&o?v(i):s&&!o?f(i):t}function b(e,t){return k(t,e)>=0?t:e}function w(e){return r.Interval.isRange(e)?"1":e}function P(e){const{interval:t,guiResolutionKind:i}=r.Interval.parseExt(e);if(!t.isValid())return!1;const s=t.multiplier();return(i===r.SpecialResolutionKind.Hours?s/60:s)<=C(i)}function C(e){const t=d[e];return Number.isNaN(t)?1:t}function x(e){return C(r.Interval.parseExt(e).guiResolutionKind)}function T(e){const t=I(o.getJSON(e,[]));return(0,l.uniq)(t.filter(P).map(_))}function I(e){return Array.isArray(e)?e:Object.keys(e).map(r.Interval.normalize).filter(c.notNull)}function M(...e){let t=[].concat(...e);return t=(0,l.uniq)(t.filter(P).map(_)),L(t)}function L(e){return e.sort(k)}function A(e){const t=r.Interval.parse(e),i=t.multiplier()||1;return t.isMinuteHours()?[r.SpecialResolutionKind.Hours,i/60]:[t.kind(),i]}function k(e,t){if(e===t)return 0;const[i,s]=A(e),[r,n]=A(t);return i!==r?u[i]-u[r]:s-n}function D(){return[]}function V(e){const{multiplier:t,shortKind:i}=E(e);return`${t}${i}`}function E(e,t){const i=r.Interval.parse(e);let s=i.multiplier(),n=i.kind();if(!i.isValid()){if(t)return null;throw new TypeError("Can't translate invalid interval")}return i.isMinuteHours()&&(s=Math.floor(s/60),n=r.SpecialResolutionKind.Hours),{multiplier:s.toString(),shortKind:B(n),hint:`${s} ${B(n,s)}`,mayOmitMultiplier:i.isDWM()&&1===s,mayOmitShortKind:i.isMinutes()&&!i.isMinuteHours()}}function B(e,t){if(!t)return p[e];switch(e){case r.ResolutionKind.Ticks:return s.t(null,{plural:"ticks",count:t},i(99136));case r.ResolutionKind.Days:return s.t(null,{plural:"days",count:t},i(30572));case r.ResolutionKind.Weeks:return s.t(null,{plural:"weeks",count:t},i(47966));case r.ResolutionKind.Months:return s.t(null,{plural:"months",count:t},i(99062));case r.ResolutionKind.Seconds:return s.t(null,{plural:"seconds",count:t},i(71787));case r.ResolutionKind.Minutes:return s.t(null,{plural:"minutes",count:t},i(69143));case r.SpecialResolutionKind.Hours:return s.t(null,{plural:"hours",count:t},i(52254));case r.ResolutionKind.Range:return s.t(null,{plural:"ranges",count:t},i(82797));default: -return e}}function R(){return h.enabled("seconds_resolution")}function N(){return h.enabled("tick_resolution")||false}function O(e){{const t=r.Interval.parse(e);if(!R()&&t.isSeconds())return!1;if(!N()&&t.isTicks())return!1}return!0}function F(e){let t;t=h.enabled("tick_resolution")?/^[,\s]*(^[1-9][0-9]*)?\s*([hdwmst]?)\s*$/i:/^[,\s]*(^[1-9][0-9]*)?\s*([hdwms]?)\s*$/i;const i=t.exec(e)||[],s=~~i[1],r=i[2]&&i[2].toUpperCase()||null,n={qty:!s&&r?1:s,unit:r};return n.error=!s&&!r,n.intraday=!(n.error||n.unit&&"H"!==n.unit&&"S"!==n.unit&&"T"!==n.unit),n.range="R"===n.unit,n}function W(e){if(h.enabled("allow_supported_resolutions_set_only")){const t=r.Interval.normalize(e);return null!==t&&m(t)}{const t=F(e);if(t.error)return!1;if(!h.enabled("custom_resolutions")){const t=r.Interval.normalize(e),i=window.ChartApiInstance.defaultResolutions().filter(O);if(!t||-1===i.indexOf(t))return!1}const i=a.linking.dataFrequencyResolution.value();if(void 0!==i&&null!==t.unit&&b(i,t.unit)!==t.unit)return!1;if(t.intraday)return a.linking.intraday.value();{const e=a.linking.supportedResolutions.value();return!e||null!==t.unit&&!!~e.indexOf(t.unit)}}}},29541:(e,t,i)=>{"use strict";i.d(t,{barSpacingByScaleRatio:()=>o,priceRangeByScaleRatio:()=>n,scaleRatio:()=>r});var s=i(34256);function r(e,t){if(t.isLog()||e.isEmpty()||t.isEmpty())return null;const i=function(e){if(e.isEmpty())return null;const t=e.priceRange();if(null===t)return null;const i=t.length();return e.internalHeight()/i}(t);if(null===i)return null;return e.getValidBarSpacing()/Math.max(1e-10,i)}function n(e,t,i){if(e.isLog()||null===i||e.isEmpty())return null;const r=e.priceRange();if(null===r||r.isEmpty())return null;const n=e.internalHeight()/(t/i),o=r.length();if(n===o)return r;const a=(n-o)/2;return new s.PriceRange(r.minValue()-a,r.maxValue()+a)}function o(e,t){if(e.isLog()||null===t||e.isEmpty())return null;const i=e.priceRange();if(null===i)return null;const s=i.length();return e.internalHeight()/s*t}},49535:(e,t,i)=>{"use strict";i.d(t,{allPriceScaleSelectionStrategyInfo:()=>c,createPriceScaleSelectionStrategy:()=>l});var s=i(50151),r=i(44352),n=i(28853);class o{constructor(e){this._priceScalesLimit=8,this._metaInfo=e}metaInfo(){return this._metaInfo}findSuitableScale(e,t,i,s){if(void 0!==s)return this._tryToGetDesiredPriceScale(e,t,s,i);if((0,n.isStudy)(t)){const s=t.metaInfo();if("Volume"===s.shortId&&e.containsMainSeries())return e.createPriceScaleAtPosition("overlay");const r=t.desiredPriceScalePosition();if(null!==r)return this._tryToGetDesiredPriceScale(e,t,r,i);if(void 0!==i&&((0,n.isStudy)(i)||e.isMainPane())&&s.is_price_study)return this._getPriceScaleTheSameAsForSource(i,e)}let r=!1;if((0,n.isStudy)(t)){const i=t.metaInfo().groupingKey;if(void 0!==i){const t=e.model().findNonOverlayStudyWithGroupingKey(i,e);if(null!==t)return this._getPriceScaleTheSameAsForSource(t.study,t.pane)}r=Boolean(t.metaInfo().is_price_study)}else t===e.model().mainSeries()&&(r=!0);if(r){const t=this._findFirstScaleForPriceStudy(e);if(null!==t)return t} -return this.createNewPriceScaleIfPossible(e)}canCreateNewPriceScale(e){return e.leftPriceScales().length+e.rightPriceScales().lengthi&&this._priceScaleIsPrice(e.rightPriceScales()[i],t))return e.rightPriceScales()[i];if(e.leftPriceScales().length>i&&this._priceScaleIsPrice(e.leftPriceScales()[i],t))return e.leftPriceScales()[i]}return null}_targetPriceScaleIndex(e,t){if(e.mainSource()===t.mainSeries())return 0}_tryToGetDesiredPriceScale(e,t,i,r){switch(i){case"left":return this.canCreateNewPriceScale(e)?e.createPriceScaleAtPosition("left"):e.createPriceScaleAtPosition("overlay");case"right":return this.canCreateNewPriceScale(e)?e.createPriceScaleAtPosition("right"):e.createPriceScaleAtPosition("overlay");case"as-series":return void 0!==r?(0,s.ensureNotNull)(r.priceScale()):e.isMainPane()?(0,s.ensureNotNull)((0,s.ensureNotNull)(e.mainDataSource()).priceScale()):this.createNewPriceScaleIfPossible(e);case"overlay":return e.createPriceScaleAtPosition("overlay")}}}const a=[{name:"left",title:r.t(null,void 0,i(65323)),ctor:class extends o{constructor(e){super(e)}apply(e){const t=e.model();e.rightPriceScales().slice(0).forEach((i=>e.movePriceScale(i,"left",this._targetPriceScaleIndex(i,t))))}createNewPriceScaleIfPossible(e){return this.canCreateNewPriceScale(e)?e.createPriceScaleAtPosition("left"):e.createPriceScaleAtPosition("overlay")}}},{name:"right",title:r.t(null,void 0,i(14113)),ctor:class extends o{constructor(e){super(e)}apply(e){const t=e.model();e.leftPriceScales().slice(0).forEach((i=>e.movePriceScale(i,"right",this._targetPriceScaleIndex(i,t))))}createNewPriceScaleIfPossible(e){return this.canCreateNewPriceScale(e)?e.createPriceScaleAtPosition("right"):e.createPriceScaleAtPosition("overlay")}}},{name:"auto",title:r.t(null,void 0,i(86951)),ctor:class extends o{constructor(e){super(e)}apply(e){if(e.containsMainSeries()){const t=(0,s.ensureNotNull)((0,s.ensureNotNull)(e.mainDataSource()).priceScale());e.movePriceScale(t,"right",0)}const t=e.model();for(;e.leftPriceScales().length>e.rightPriceScales().length;){const i=e.leftPriceScales()[e.leftPriceScales().length-1];e.movePriceScale(i,"right",this._targetPriceScaleIndex(i,t))}for(;e.rightPriceScales().length-e.leftPriceScales().length>1;){const i=e.rightPriceScales()[e.rightPriceScales().length-1];e.movePriceScale(i,"left",this._targetPriceScaleIndex(i,t))}}createNewPriceScaleIfPossible(e){if(!this.canCreateNewPriceScale(e))return e.createPriceScaleAtPosition("overlay");const t=e.leftPriceScales().lengtht.name===e)));return new t.ctor(t)}function c(){return a}},57490:(e,t,i)=>{"use strict";i.d(t,{SelectionIndexes:()=>r});var s=i(50151);class r{constructor(e){this._baseIndex=null,this._offsetInBar=null,this._offsetInTime=null,this._barsBetweenPoints=null,this._timescale=e}indexes(){const e=this._timescale.visibleBarsStrictRange();if(null===e)return[];const t=e.firstBar(),i=e.lastBar();if(null===this._offsetInTime||null===this._barsBetweenPoints){const e=this._timescale.barSpacing();this._barsBetweenPoints=Math.floor(120/e),this._offsetInBar=i%this._barsBetweenPoints,this._offsetInTime=this._timescale.indexToTimePoint(this._offsetInBar),this._baseIndex=this._timescale.baseIndex()}const r=this._timescale.baseIndex();this._baseIndex!==r&&(this._baseIndex=r,this._offsetInBar=(0,s.ensureNotNull)(this._timescale.timePointToIndex(this._offsetInTime)));const n=(0,s.ensureNotNull)(this._offsetInBar),o=[];let a=Math.floor((t-n)/this._barsBetweenPoints);const l=Math.floor((i-n)/this._barsBetweenPoints);for(;a<=l;a++)o.push(n+a*this._barsBetweenPoints);return o}clear(){this._offsetInBar=null,this._offsetInTime=null,this._baseIndex=null,this._barsBetweenPoints=null}}},80101:(e,t,i)=>{"use strict";i.d(t,{SelectionRenderer:()=>c});var s=i(34026),r=i(48891),n=i(18807),o=i(66103),a=i(59590);const l=r.colorsPalette["color-tv-blue-600"];class c extends a.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e||null}setData(e){this._data=e}hitTest(e){if(!this._data||!this._data.visible)return null;for(let t=0;t(0,s.pointInBox)(t,e)))}_drawImpl(e){if(null===this._data||!this._data.visible)return;const{context:t,horizontalPixelRatio:i}=e;t.strokeStyle=void 0!==this._data.color?this._data.color:l,t.lineCap="butt";const s=Math.max(1,Math.floor(i));t.lineWidth=s;const r=this._data.vertOffset||0;for(let i=0;i{"use strict";i.d(t,{SeriesBase:()=>Xt}) -;var s=i(50151),r=i(49483),n=i(51768),o=i(76422),a=i(59224),l=i(80842),c=i(13497),h=i(97034),d=i(86094),u=i(34256),p=i(59452),_=i.n(p),m=i(42960),g=i(66846),f=i(61146),v=i(88732),S=i(79055),y=i(44352),b=i(14483),w=i(58557),P=i(11877),C=i(11321);function x(e){const t="QUANDL"===(e=e||{}).exchange,s={title:"",description:"",interval:"",exchange:"",provider:"",chartStyle:"",sessionDescription:"",priceSource:""};let r="";if(e.description&&t)if(2===e.description.split("/").length)r=e.description.split("/")[1];else{e.description.split("'").filter((e=>e.length)).forEach((e=>{let t=[];t=e&&("/"===e[0]||/\d+\/\(?/.test(e))?[e]:e.split("/").filter((e=>e.length)),r+=t[2===t.length?1:0]}))}else r=e.description?e.description:e.symbol;if(e.ticker?(s.title=e.ticker,s.description=T(r)):s.title=T(r),e.interval&&(s.interval=(0,C.translatedIntervalString)(e.interval)),t&&e.description){const t=/[\w_]+\/[\w_]+/.exec(e.description);t&&t[0]?s.provider=T(t[0].split("/")[0]):s.provider=T(e.description.split("/")[0])}return e.exchange&&(s.exchange=T(e.exchange)),s.chartStyle=T(function(e){return e.inputs,8===e.style?y.t(null,void 0,i(40530)):""}(e)),e.sessionDescription&&(s.sessionDescription=T(e.sessionDescription)),void 0!==e.priceSource&&(s.priceSource=T(e.priceSource)),s}function T(e){return e.replace(/'/g,"")}const I=y.t(null,void 0,i(89659)),M=b.enabled("hide_unresolved_symbols_in_legend"),L=b.enabled("symbol_info_price_source");class A extends P.StatusProviderBase{constructor(e,t,i,s){super(t),this._series=e,this._statusViewProperties=i,this._options=s||{}}text(){return function(e){const t=x(e);return(e.ticker?t.description:t.title)+(t.interval?", "+t.interval:"")+function(e,t=", "){return(e.provider?`${t}${e.provider}`:"")+(e.exchange?`${t}${e.exchange}`:"")+(e.chartStyle?`${t}${e.chartStyle}`:"")+(e.branding?`${t}${e.branding}`:"")+(e.sessionDescription?`${t}${e.sessionDescription}`:"")}(t)}(this._getTitleGenerationOptions())}getSplitTitle(){return x(this._getTitleGenerationOptions())}bold(){return!1}size(){return this._statusViewProperties.childs().fontSize.value()+"px"}errorStatus(){const e=this._series.seriesErrorMessage();return null!==e?{error:e,title:I}:null}_getTitleGenerationOptions(){var e,t,i;const s=this._series.symbolInfo(),r=this._statusViewProperties.childs(),n=this._series.symbolTextSourceProxyProperty().value();let o;if(r.showExchange.value()&&s){const i=(0,m.isEconomicSymbol)(s)&&(null!==(t=null===(e=s.source2)||void 0===e?void 0:e.description)&&void 0!==t?t:s.source);o=i||s.exchange}const a=null!==(i=L&&(null==s?void 0:s.price_source_id)?this._series.model().availablePriceSources().name(s.price_source_id):null)&&void 0!==i?i:void 0;return{description:D(n,s),exchange:o,symbol:M&&null===s?"":this._series.symbol(),interval:r.showInterval.value()&&!this._options.hideResolution?this._series.interval():void 0,style:this._series.properties().childs().style.value(),inputs:this._series.getInputsProperties().state(),boxSize:this._series.data().boxSize,reversalAmount:this._series.data().reversalAmount,ticker:k(n,s), -priceSource:a}}}function k(e,t){return"ticker-and-description"!==e?"":null!==t?t.name:void 0}function D(e,t){if(null!==t)return"ticker"===e?t.name:"long-description"===e&&void 0!==t.long_description?t.long_description:(0,w.getTranslatedSymbolDescription)({pro_name:t.pro_name||void 0,short_name:t.name||void 0,description:t.description||void 0,short_description:t.short_description||void 0,local_description:t.local_description||void 0,language:t.language||void 0})}class V extends S.StatusView{constructor(e,t,i,s){super(new A(e,t,i,s)),this._invalidated=!0,this._series=e,this._series.onRestarted().subscribe(this,this.update),this._series.dataEvents().symbolResolved().subscribe(this,this.update),this._series.dataEvents().completed().subscribe(this,this.update),this._series.boxSizeValue().subscribe(this.update.bind(this)),i.childs().symbolTextSource.listeners().subscribe(this,this.update)}getSeriesPrecision(){let e=4;const t=this._series.symbolInfo();return t&&t.pricescale&&(e=Math.round(Math.log(t.pricescale)/Math.log(10))),e}round(e){const t=this.getSeriesPrecision(),i=Math.round(e*Math.pow(10,t))/Math.pow(10,t);return i?i.toString():""}update(){this._invalidated=!0}text(){return this._updateImpl(),super.text()}color(){return this._updateImpl(),super.color()}bold(){return this._updateImpl(),super.bold()}size(){return this._updateImpl(),super.size()}getSplitTitle(){return this._updateImpl(),this._statusProvider.getSplitTitle()}_updateImpl(){this._invalidated&&(this._bold=this._statusProvider.bold(),this._size=this._statusProvider.size(),this._text=this._statusProvider.text(),this._invalidated=!1)}}var E=i(50335),B=i(93835),R=i(88348),N=i(58333),O=i(15367);const F=r.CheckMobile.any(),W=b.enabled("hide_resolution_in_legend");class H extends B.DataWindowView{constructor(e,t){super(),this._invalidated=!0,this._series=e,this._model=t,this._valuesProvider=this._createValuesProvider(e,t),this._items=this._valuesProvider.getItems().map((e=>new B.DataWindowItem(e.id,e.title,"",e.unimportant))),this.update()}update(){this._invalidated=!0}items(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._items}series(){return this._series}_updateImpl(){var e,t;const i=this._series.symbolInfo();if(i){const e=[i.name];W||e.push((0,C.translatedIntervalString)(this._series.interval())),(0,m.isEconomicSymbol)(i)&&i.source?e.push(i.source):e.push((0,r.onWidget)()||"forex"===i.type?i.exchange:i.listed_exchange),this._header=e.join(", "),this._title=i.description}else this._header=this._series.symbol();let s=this._model.crossHairSource().appliedIndex();b.enabled("use_last_visible_bar_value_in_legend")&&!(0,E.isNumber)(s)&&(s=null!==(t=null===(e=this._model.timeScale().visibleBarsStrictRange())||void 0===e?void 0:e.lastBar())&&void 0!==t?t:NaN);const n=this._valuesProvider.getValues(s);for(let e=0;ee||t||i),i.showBarChange.weakReference(),i.showSeriesOHLC.weakReference(),i.showVolume.weakReference()),this._visibilityProperty.subscribe(this,this.update)}areValuesVisible(){return this._visibilityProperty.value()}additional(){return null}marketTitle(){const e=this._series.marketStatusModel().status().value();return this._showLastPriceAndChangeOnly()&&("pre_market"===e||"post_market"===e)?`${G}:`:""}destroy(){this._backgroundColorSpawn.destroy(),this._visibilityProperty.destroy()}_createValuesProvider(e,t){return new U(e,t)}}var $=i(97145),Y=i(32923),K=i(41249);function Z(){const e=window.ChartApiInstance.serverTimeOffset();return Date.now()/1e3+e}function X(e,t,i){return e<=i?t<=i?1/0:t/1e3:Math.min(e,t)/1e3}class J{constructor(e){this._marketStatus=new $.WatchedValue(null),this._lastMarketStatus=null,this._sessionsSpec=null,this._nextSessionEdgeInternal=null,this._nextSessionEdge=new $.WatchedValue(null),this._recalcNextSessionEdgeTimerId=null, -this._futuresContractExpirationTime=null,this._quotesProvider=e,e.quotesUpdate().subscribe(this,this._update.bind(this)),e.quoteSymbolChanged().subscribe(this,this._resetStatus)}destroy(){this._quotesProvider.quotesUpdate().unsubscribeAll(this),this._quotesProvider.quoteSymbolChanged().unsubscribeAll(this),null!==this._recalcNextSessionEdgeTimerId&&clearTimeout(this._recalcNextSessionEdgeTimerId)}futuresContractExpirationTime(){return this._futuresContractExpirationTime}setSymbolInfo(e){var t,i,s,r,n;if(this._nextSessionEdgeInternal=null,null===e)return void(this._sessionsSpec=null);const o=new Y.SessionSpec(e.timezone,null!==(t=e.session_display)&&void 0!==t?t:e.session,e.session_holidays,e.corrections);let a,l;const c=null===(i=e.subsessions)||void 0===i?void 0:i.find((e=>"premarket"===e.id)),h=null===(s=e.subsessions)||void 0===s?void 0:s.find((e=>"postmarket"===e.id));void 0!==c&&(a=new Y.SessionSpec(e.timezone,null!==(r=c["session-display"])&&void 0!==r?r:c.session,e.session_holidays,c["session-correction"])),void 0!==h&&(l=new Y.SessionSpec(e.timezone,null!==(n=h["session-display"])&&void 0!==n?n:h.session,e.session_holidays,h["session-correction"])),this._sessionsSpec={general:o,preMarket:a,postMarket:l},this._recalculateNextSessionEdge()}status(){return this._marketStatus}nextSessionEdge(){return this._nextSessionEdge}_resetStatus(){this._lastMarketStatus=null,this._marketStatus.setValue(null)}_update(e){void 0!==e&&void 0!==e.values.current_session&&(this._lastMarketStatus=e.values.current_session),null!==this._lastMarketStatus?this._marketStatus.setValue(this._lastMarketStatus):this._resetStatus()}_getNextSessionEdgeInternal(){var e;if(null===this._sessionsSpec||"24x7"===this._sessionsSpec.general.spec())return null;const t=1e3*Z();if(null===this._nextSessionEdgeInternal||(null!==(e=this._nextSessionEdgeInternal.timestamp)&&void 0!==e?e:1/0)<=t/1e3){const{general:e,preMarket:i,postMarket:s}=this._sessionsSpec,r=(0,K.get_timezone)(e.timezone()),n=(0,K.utc_to_cal)(r,t),o=X((0,K.cal_to_utc)(r,e.alignToNearestSessionStart(n,1)),(0,K.cal_to_utc)(r,e.alignToNearestSessionEnd(n,1)),t),a=X(void 0!==i?(0,K.cal_to_utc)(r,i.alignToNearestSessionStart(n,1)):1/0,void 0!==i?(0,K.cal_to_utc)(r,i.alignToNearestSessionEnd(n,1)):1/0,t),l=X(void 0!==s?(0,K.cal_to_utc)(r,s.alignToNearestSessionStart(n,1)):1/0,void 0!==s?(0,K.cal_to_utc)(r,s.alignToNearestSessionEnd(n,1)):1/0,t);let c=Math.min(o,a,l);if(c===1/0){const t=Z(),i=6e4,s=new Date(Math.round(new Date(1e3*t).getTime()/i)*i).getTime()+i,n=(0,K.utc_to_cal)(r,s),o=X((0,K.cal_to_utc)(r,e.alignToNearestSessionStart(n,1)),(0,K.cal_to_utc)(r,e.alignToNearestSessionEnd(n,1)),s),h=Math.min(o,a,l);h!==1/0?(this._nextSessionEdgeInternal={timestamp:c},c=h):this._nextSessionEdgeInternal={timestamp:null}}this._nextSessionEdgeInternal=c===l?{timestamp:c,status:"post_market"}:c===a?{timestamp:c,status:"pre_market"}:{timestamp:c}}return this._nextSessionEdgeInternal}_recalculateNextSessionEdge(){const e=this._getNextSessionEdgeInternal() -;if(null===e||null===e.timestamp)return void this._nextSessionEdge.setValue(null);const t={status:e.status,remainingSeconds:Math.max(0,e.timestamp-Z())};if(null===this._recalcNextSessionEdgeTimerId){const e=Number.isFinite(t.remainingSeconds)?Math.ceil(t.remainingSeconds%60):1;this._recalcNextSessionEdgeTimerId=setTimeout((()=>this._recalculateNextSessionEdgeByTimer()),1e3*e)}this._nextSessionEdge.setValue(t)}_recalculateNextSessionEdgeByTimer(){this._recalcNextSessionEdgeTimerId=null,this._recalculateNextSessionEdge()}}var Q=i(42226),ee=i(36274),te=i(60156),ie=i(94421),se=i(36174);let re=0;class ne{constructor(e,t){this._extrapolatedData=[],this._cacheForFuture=!1,this._modelId=re++,this._builderCache=null,this._uniqueId=(0,se.randomHashN)(6),this._resolution=t,this._symbolInfo=e,this._valid=Boolean(e.timezone)&&Boolean(e.session),this._session=new te.SessionInfo(e.timezone,e.session,e.session_holidays,e.corrections)}syncSourceTarget(){return{uniqueId:this._uniqueId,resolution:this._resolution,symbolInfo:this._symbolInfo,session:this._session.state()}}getSymbolInfo(){return this._symbolInfo}getSession(){return this._session}getResolution(){return this._resolution}uniqueId(){return this._modelId}distance(e,t){if(!this.isValid())return{success:!1};if(e>t)return{success:!1};if(e===t)return{success:!0,result:0};let i=this._extrapolatedData.length,s=0!==i?this._extrapolatedData[0]:null,r=null!==s?this._extrapolatedData[i-1]:null;const n=er){const s=(0,ie.extrapolateBarsFrontToTime)(this._barBuilder(),r||1e3*e,1e3*t,2e3,!0);this._extrapolatedData=this._extrapolatedData.concat(s.times),i=this._extrapolatedData.length,this._cacheForFuture=n}if(r=this._extrapolatedData[i-1],r<1e3*t)return{success:!1};const o=this._extrapolatedData.indexOf(1e3*t);return-1===o?{success:!1}:{success:!0,result:o}}projectTime(e,t){if(!this.isValid())return e;let i=this._extrapolatedData.length,s=i>0?this._extrapolatedData[0]:null,r=null!==s?this._extrapolatedData[i-1]:null;const n=t>=0;1e3*e===s&&this._cacheForFuture===n||(this._extrapolatedData=[1e3*e],i=1,s=null,r=null);const o=Math.abs(t);if(null===s||o>=i){const s=(0,ie.extrapolateBarsFrontByCount)(this._barBuilder(),r||1e3*e,Math.sign(t)*(o-i+1),!0);this._extrapolatedData=this._extrapolatedData.concat(s.times),i=this._extrapolatedData.length,this._cacheForFuture=n}return i0?e.delay:900;return Math.round(t/60)}listedExchange(){const e=this._symbolInfo.value();return null!==e?e.listed_exchange:""}async description(){const e=this._symbolInfo.value();if(null===e)return"";return{}.description||e.listed_exchange}exchange(){const e=this._symbolInfo.value();return null!==e?e.exchange:""}proName(){const e=this._symbolInfo.value();return null!==e?e.pro_name:""}proPerm(){const e=this._symbolInfo.value();return null!==e?e.pro_perm:""}firstReplacedByBatsExchange(){const e=this._symbolInfo.value();return e&&(0,le.firstReplacedByBatsExchange)(e)}_resetStatus(){this._dataUpdatedInfoStatus.setValue(null)}_update(){const e=this._symbolInfo.value();if(null===e)return void this._dataUpdatedInfoStatus.setValue(null);const t=this._status.value();if("string"==typeof t)return void this._dataUpdatedInfoStatus.setValue(null);if(2===t||1===t)return;const i=he(e,t,this._updatePeriod.value());0!==i.length?this._dataUpdatedInfoStatus.setValue(i):this._dataUpdatedInfoStatus.setValue(null)}}i(69798);var ue=i(1722);(0,a.getLogger)("Chart.DataProblemModel");class pe{constructor(e,t){this._mainDataProblem=new oe.WatchedObject(null),this._supportPortalProblems=new oe.WatchedObject([]),this._allDataProblems=new oe.WatchedObject([]),this._pushStreamHandler=null,this._destroyed=!1,this._quotesProvider=e,this._quotesProvider.quotesUpdate().subscribe(this,this._update.bind(this)),this._resetSubscription=t,this._resetSubscription.subscribe(this,this._resetStatus),this._mainDataProblem.subscribe((()=>this._updateAllDataProblems())),this._supportPortalProblems.subscribe((()=>this._updateAllDataProblems())),this._requestSupportPortalProblems()}destroy(){this._quotesProvider.quotesUpdate().unsubscribeAll(this),this._resetSubscription.unsubscribeAll(this),this._destroyed=!0}dataProblems(){return this._allDataProblems}_resetStatus(){this._mainDataProblem.setValue(null)}_update(e){void 0===e.values||void 0===e.values.data_problem?this._resetStatus():this._mainDataProblem.setValue((0,ue.clone)(e.values.data_problem))} -_updateAllDataProblems(){const e=this._mainDataProblem.value(),t=this._supportPortalProblems.value();this._allDataProblems.setValue(null===e?t:[e,...t])}async _requestSupportPortalProblems(){0}}var _e=i(71625),me=i(87095),ge=i(42275),fe=i(74304);function ve(e){return e<10?`0${e}`:e.toString()}var Se=i(78211),ye=i(28558);const be=b.enabled("force_exchange_as_title"),we=b.enabled("chart_style_hilo_last_price"),Pe=[0,1,2,14,15,3,16,9,8,10];we&&Pe.push(12);const Ce={alwaysShowGlobalLast:!1,visibleOnHistoryOnly:!1,showCountdown:!0,showSymbolLabel:!0,useSolidBodyColor:!0};class xe extends ge.PriceAxisView{constructor(e,t,i){super(),this._previousCountdown="",this._source=e,this._model=t,this._options={...Ce,...i}}updateCountdown(){this._countdownText()!==this._previousCountdown&&(this.update((0,ye.sourceChangeEvent)(this._source.id())),this._model.updateSourcePriceScale(this._source))}_getSource(){return this._source}_getModel(){return this._model}_isCountdownEnabled(){return this._options.showCountdown}_countdownText(){const e=ee.Interval.parse(this._source.interval());if(e.isDWM()||e.isTicks()||e.isSeconds()&&1===e.multiplier())return"";const t=this._source.data().bars().last();if(null===t)return"";const i=1e3*(0,s.ensure)(t.value[0]),r=ee.Interval.parse(this._source.interval()).inMilliseconds(),n=i.valueOf()+r;let o=Math.round((n-this._currentTime())/1e3);if(o<=0)return"";o=Math.min(o,r/1e3);let a=null;o>=3600&&(a=ve(Math.floor(o/3600))),o%=3600;const l=ve(Math.floor(o/60));o%=60;const c=ve(Math.floor(o));return null!==a?`${a}:${l}:${c}`:`${l}:${c}`}_updateRendererData(e,t,i){var r;if(e.visible=!1,t.visible=!1,!this._source.isVisible())return;const n=this._source.properties().childs();if(!we&&12===n.style.value())return;const o=this._model.timeScale().visibleBarsStrictRange(),a=this._source.data().last();if(null===o||null===a)return;if(this._options.visibleOnHistoryOnly&&o.contains(a.index))return;const l=this._model.properties().childs().scalesProperties.childs();let c=l.showSeriesLastValue.value(),h=this._isCountdownEnabled()&&n.showCountdown.value()&&Pe.includes(n.style.value())&&(this._options.alwaysShowGlobalLast||o.contains(a.index)),d=this._options.showSymbolLabel&&l.showSymbolLabels.value();const u=l.seriesLastValueMode.value()===fe.PriceAxisLastValueMode.LastPriceAndPercentageValue,p=this._source.lastValueData(void 0,this._options.alwaysShowGlobalLast);if(p.noData)return;const _=8===n.style.value();if((c||h||d)&&_&&n.haStyle.childs().showRealLastPrice.value()){const e=this._source.lastValueData(void 0,!1),t=this._source.lastValueData(void 0,!0);e.noData||t.noData||e.index!==t.index||(c=!1,h=!1,d=!1)}const m=(0,me.resetTransparency)(this._source.priceLineColor(p.color));if(this._options.useSolidBodyColor?(i.background=m,i.borderColor=void 0):(i.background=this._model.backgroundColorAtYPercentFromTop((null!==(r=i.fixedCoordinate)&&void 0!==r?r:i.coordinate)/(0,s.ensureNotNull)(this._model.paneForSource(this._source)).height()),i.borderColor=m),i.coordinate=p.coordinate,i.floatCoordinate=p.floatCoordinate,c||h){ -const t=this._axisFirstLineText(p,c);e.text=t,this._options.useSolidBodyColor?(i.textColor=this.generateTextColor(i.background),e.borderVisible=!1):(e.borderVisible=!0,i.textColor=m),e.textColor=i.textColor;const s=c&&u?(0,Se.getOppositeModePriceText)(this._source.priceScale(),p):"";e.secondLine=s,i.secondLineTextColor=i.textColor;const r=h?this._countdownText():"";this._previousCountdown=r,e.thirdLine=r,i.thirdLineTextColor=(0,me.generateColor)(i.textColor,25),0===t.length&&0===s.length&&0===r.length||(e.visible=!0)}d&&(t.text=this._paneText(d),t.visible=t.text.length>0)}_paneText(e){let t="";const i=this._source.symbolInfo();return be?t=(0,m.displayedSymbolExchange)(i):e&&(t=(0,m.displayedSymbolName)(i)),t}_axisFirstLineText(e,t){return t?(0,Se.getCurrentModePriceText)(this._source.priceScale(),e):""}_currentTime(){return Date.now()+1e3*this._source.serverTimeOffset()}}var Te=i(11527);class Ie extends xe{lastPrice(){return this._getSource().data().lastProjectionPrice}_updateRendererData(e,t,i){e.visible=!1,t.visible=!1;const r=this._getModel(),n=this._getSource(),o=n.priceScale(),a=r.timeScale(),l=this.lastPrice();if(a.isEmpty()||o.isEmpty()||void 0===l)return;const c=a.visibleBarsStrictRange();if(null===c)return;const h=c.firstBar(),u=c.lastBar(),p=n.data(),_=p.search(u,d.PlotRowSearchMode.NearestLeft);if(null===_)return;const m=n.nearestIndex(h,d.PlotRowSearchMode.NearestRight);if(void 0===m)return;const g=n.model().properties().childs().scalesProperties.childs(),f=(0,s.ensureNotNull)(p.valueAt(m))[4];let v=i.background,S=g.showSeriesLastValue.value(),y=!1,b=!1,w=!1;const P=n.lastValueData(4,!1),C=n.properties().childs();if(8===C.style.value()&&C.haStyle.childs().showRealLastPrice.value()){const e=n.lastValueData(4,!0);if(e.noData||e.color===i.background||(v=(0,me.resetTransparency)(e.color)),!e.noData&&!P.noData){const t=e.index===P.index;y=t&&g.showSymbolLabels.value(),b=g.seriesLastValueMode.value()===fe.PriceAxisLastValueMode.LastPriceAndPercentageValue,S=S&&t,w=t&&this._isCountdownEnabled()&&C.showCountdown.value()}}else{const e=n.barColorer().barStyle(_.index,!0);v=(0,me.resetTransparency)(e.barColor)}if(i.background=v,i.textColor=this.generateTextColor(v),i.secondLineTextColor=i.textColor,i.thirdLineTextColor=(0,me.generateColor)(i.textColor,25),i.coordinate=o.priceToCoordinate(l,f),e.visible=S||w,!P.noData){const i=n.priceScale().isPercentage();P.formattedPriceAbsolute=o.formatPriceAbsolute(l),P.formattedPricePercentage=o.formatPricePercentage(l,f,!0),P.text=i?P.formattedPricePercentage:P.formattedPriceAbsolute,e.text=this._axisFirstLineText(P,S),e.secondLine=S&&b?i?P.formattedPriceAbsolute:P.formattedPricePercentage:"",e.thirdLine=w?this._countdownText():"",t.text=this._paneText(y)}t.visible=y}}var Me=i(43493),Le=i(38003),Ae=i(48891),ke=i(79849);const De={light:{lineStyle:ke.LINESTYLE_DOTTED,lineWidth:1,textColor:Ae.colorsPalette["color-cold-gray-900"],backgroundColor:Ae.colorsPalette["color-tv-blue-50"],lineColor:Ae.colorsPalette["color-cold-gray-500"]},dark:{lineStyle:ke.LINESTYLE_DOTTED,lineWidth:1, -textColor:Ae.colorsPalette["color-white"],backgroundColor:Ae.colorsPalette["color-tv-blue-a800"],lineColor:Ae.colorsPalette["color-cold-gray-500"]}};function Ve(e){return e?De.dark:De.light}class Ee extends Le.HorizontalLinePaneView{constructor(e,t,i){super(),this._model=e,this._isVisible=t.lineVisible,this._lineColor=t.lineColor,this._lineWidth=t.lineWidth,this._getValue=i}_updateImpl(){const e=this._lineRendererData;if(e.visible=!1,!this._isVisible.value())return;const t=this._model.mainSeries(),i=t.priceScale(),s=t.firstValue(),r=this._getValue();if(null===s||null===r)return;const n=Ve(this._model.dark().value()),o=this._lineColor.value()?this._lineColor.value():n.lineColor,a=this._lineWidth.value()?this._lineWidth.value():n.lineWidth;e.visible=!0,e.y=i.priceToCoordinate(r,s),e.linestyle=n.lineStyle,e.linewidth=a,e.color=o}}class Be extends ge.PriceAxisView{constructor(e,t,i,s){super(),this._model=e,this._label=t,this._isVisible=i,this._getValue=s}_updateRendererData(e,t,i){if(e.visible=!1,t.visible=!1,!this._isVisible.value())return;const s=this._model.mainSeries(),r=s.priceScale(),n=s.firstValue(),o=this._getValue();if(null===n||null===o)return;const a=Ve(this._model.dark().value());e.visible=!0,t.visible=!0,e.text=r.formatPriceAbsolute(o),t.text=this._label,i.coordinate=r.priceToCoordinate(o,n),i.background=a.backgroundColor,i.textColor=a.textColor}}class Re extends Te.PriceLineAxisView{constructor(e,t,i){super(),this._model=e,this._isLineVisible=t,this._getValue=i}_isVisible(){return this._isLineVisible.value()}_lineWidth(){return Ve(this._model.dark().value()).lineWidth}_lineStyle(){return Ve(this._model.dark().value()).lineStyle}_priceLineColor(e){return Ve(this._model.dark().value()).lineColor}_value(){const e=this._model.mainSeries(),t=e.priceScale(),i=e.firstValue(),s=this._getValue();if(null===i||null===s)return{noData:!0};const r=t.priceToCoordinate(s,i);return{noData:!1,floatCoordinate:r,coordinate:r,color:"",formattedPricePercentage:"",formattedPriceAbsolute:"",formattedPriceIndexedTo100:"",text:"",index:0}}}const Ne=y.t(null,void 0,i(30777)),Oe=y.t(null,void 0,i(8136));function Fe(e,t,i,s){const r=new Ee(e,i,s),n=new Be(e,i.label,i.labelVisible,s);return{paneView:r,panePriceAxisView:new Me.PanePriceAxisView(n,t,e),priceAxisView:n,priceLineAxisView:new Re(e,i.lineVisible,s)}}const We={light:{lineStyle:ke.LINESTYLE_DOTTED,lineWidth:1,textColor:(0,Ae.getHexColorByName)("color-cold-gray-900"),backgroundColor:(0,Ae.getHexColorByName)("color-tv-blue-50"),lineColor:(0,Ae.getHexColorByName)("color-cold-gray-500")},dark:{lineStyle:ke.LINESTYLE_DOTTED,lineWidth:1,textColor:(0,Ae.getHexColorByName)("color-white"),backgroundColor:(0,Ae.getHexColorByName)("color-tv-blue-a800"),lineColor:(0,Ae.getHexColorByName)("color-cold-gray-500")}};function He(e){return e?We.dark:We.light}class ze extends Le.HorizontalLinePaneView{constructor(e,t,i){super(),this._model=e,this._isVisible=t.lineVisible,this._lineColor=t.lineColor,this._lineWidth=t.lineWidth,this._getValue=i}_updateImpl(){const e=this._lineRendererData -;if(e.visible=!1,!this._isVisible.value())return;const t=this._model.mainSeries(),i=t.priceScale(),s=t.firstValue(),r=this._getValue();if(null===s||null===r)return;const n=He(this._model.dark().value()),o=this._lineColor.value()?this._lineColor.value():n.lineColor,a=this._lineWidth.value()?this._lineWidth.value():n.lineWidth;e.visible=!0,e.y=i.priceToCoordinate(r,s),e.linestyle=n.lineStyle,e.linewidth=a,e.color=o}}class Ue extends ge.PriceAxisView{constructor(e,t,i,s){super(),this._model=e,this._label=t,this._isVisible=i,this._getValue=s}_updateRendererData(e,t,i){if(e.visible=!1,t.visible=!1,!this._isVisible.value())return;const s=this._model.mainSeries(),r=s.priceScale(),n=s.firstValue(),o=this._getValue();if(null===n||null===o)return;const a=He(this._model.dark().value());e.visible=!0,t.visible=!0,e.text=r.formatPriceAbsolute(o),t.text=this._label,i.coordinate=r.priceToCoordinate(o,n),i.background=a.backgroundColor,i.textColor=a.textColor}}class je extends Te.PriceLineAxisView{constructor(e,t,i){super(),this._model=e,this._isLineVisible=t,this._getValue=i}_isVisible(){return this._isLineVisible.value()}_lineWidth(){return He(this._model.dark().value()).lineWidth}_lineStyle(){return He(this._model.dark().value()).lineStyle}_priceLineColor(e){return He(this._model.dark().value()).lineColor}_value(){const e=this._model.mainSeries(),t=e.priceScale(),i=e.firstValue(),s=this._getValue();if(null===i||null===s)return{noData:!0};const r=t.priceToCoordinate(s,i);return{noData:!1,floatCoordinate:r,coordinate:r,color:"",formattedPricePercentage:"",formattedPriceAbsolute:"",formattedPriceIndexedTo100:"",text:"",index:0}}}const Ge=y.t(null,void 0,i(22554));function qe(e,t,i,s){const r=i.childs(),n=function(e,t,i,s){const r=new ze(e,i,s),n=new Ue(e,i.label,i.labelVisible,s),o=new Me.PanePriceAxisView(n,t,e),a=new je(e,i.lineVisible,s);return{paneView:r,panePriceAxisView:o,priceAxisView:n,priceLineAxisView:a}}(e,t,{label:Ge,labelVisible:r.averageClosePriceLabelVisible,lineVisible:r.averageClosePriceLineVisible,lineColor:r.averagePriceLineColor,lineWidth:r.averagePriceLineWidth},(()=>s(0)));return{paneViews:[n.paneView],panePriceAxisViews:[n.panePriceAxisView],priceAxisViews:[n.priceAxisView],priceLineAxisViews:[n.priceLineAxisView]}}var $e=i(57898),Ye=i(97121),Ke=i(27856),Ze=i(86441);class Xe{constructor(){this._data=null}setData(e){this._data=e}data(){return this._data}draw(e,t){const i=this._data;if(null===i)return;const s=t.pixelRatio;e.save();const r=Math.max(1,Math.floor(s)),n=r%2/2,o=Math.round(i.center.x*s)+n,a=i.center.y*s;e.fillStyle=i.seriesLineColor,e.beginPath();const l=Math.max(2,1.5*i.seriesLineWidth)*s;e.arc(o,a,l,0,2*Math.PI,!1),e.fill(),e.fillStyle=i.fillColor,e.beginPath(),e.arc(o,a,i.radius*s,0,2*Math.PI,!1),e.fill(),e.lineWidth=r,e.strokeStyle=i.strokeColor,e.beginPath(),e.arc(o,a,i.radius*s+r/2,0,2*Math.PI,!1),e.stroke(),e.restore()}hitTest(e,t){return null}}function Je(e){return e}const Qe=[{start:0,end:.25,startRadius:4,endRadius:10,startFillAlpha:.25,endFillAlpha:0,startStrokeAlpha:.4,endStrokeAlpha:.8, -easing:Je},{start:.25,end:.525,startRadius:10,endRadius:14,startFillAlpha:0,endFillAlpha:0,startStrokeAlpha:.8,endStrokeAlpha:0,easing:Je},{start:.525,end:1,startRadius:14,endRadius:14,startFillAlpha:0,endFillAlpha:0,startStrokeAlpha:0,endStrokeAlpha:0,easing:Je}];function et(e,t,i,s){const r=i+(s-i)*t;return(0,me.applyTransparency)(e,(0,me.alphaToTransparency)(r))}function tt(e,t){const i=e%2600/2600;let s;for(const e of Qe)if(i>=e.start&&i<=e.end){s=e;break}if(void 0===s)throw new Error("Last price animation internal logic error");const r=s.easing((i-s.start)/(s.end-s.start));return{fillColor:et(t,r,s.startFillAlpha,s.endFillAlpha),strokeColor:et(t,r,s.startStrokeAlpha,s.endStrokeAlpha),radius:(n=r,o=s.startRadius,a=s.endRadius,o+(a-o)*n)};var n,o,a}class it{constructor(e){this._renderer=new Xe,this._invalidated=!0,this._stageInvalidated=!0,this._startTime=performance.now(),this._endTime=this._startTime-1,this._series=e}update(e){if(this._invalidated=!0,"data-source-change"===e.type&&e.sourceId===this._series.id()&&e.realtime&&this._series.seriesLoaded()){const e=performance.now(),t=this._endTime-e;if(t>0)return void(t<650&&(this._endTime+=2600));this._startTime=e,this._endTime=e+2600}}invalidateStage(){this._stageInvalidated=!0}animationActive(){return performance.now()<=this._endTime}stopAnimation(){this._endTime=this._startTime-1}renderer(e,t){return this._invalidated?(this._updateImpl(e,t),this._invalidated=!1,this._stageInvalidated=!1):this._stageInvalidated&&(this._updateRendererDataStage(),this._stageInvalidated=!1),this._renderer}_updateImpl(e,t){this._renderer.setData(null);const i=this._series.model().timeScale(),s=i.visibleBarsStrictRange(),r=this._series.firstValue(),n=this._series.lastValueData(void 0,!0,!0);if(null===s||null===r||void 0===n.index||void 0===n.price||!s.contains(n.index))return;const o=new Ze.Point(i.indexToCoordinate(n.index),this._series.priceScale().priceToCoordinate(n.price,r)),a=n.color,l=this._series.properties().childs();let c;switch(this._series.style()){case 3:c=l.areaStyle.childs().linewidth.value();break;case 10:const t=l.baselineStyle,i=Math.round(e*(Math.abs(100-t.childs().baseLevelPercentage.value())/100));c=o.y<=i?t.childs().topLineWidth.value():t.childs().bottomLineWidth.value();break;case 14:c=l.lineWithMarkersStyle.childs().linewidth.value();break;case 15:c=l.steplineStyle.childs().linewidth.value();break;default:c=l.lineStyle.childs().linewidth.value()}const h=tt(this._duration(),a);this._renderer.setData({seriesLineColor:a,seriesLineWidth:c,fillColor:h.fillColor,strokeColor:h.strokeColor,radius:h.radius,center:o})}_updateRendererDataStage(){const e=this._renderer.data();if(null!==e){const t=tt(this._duration(),e.seriesLineColor);e.fillColor=t.fillColor,e.strokeColor=t.strokeColor,e.radius=t.radius}}_duration(){return this.animationActive()?performance.now()-this._startTime:2599}}var st=i(91280),rt=i(1115),nt=i(1803);class ot{constructor(){this._created=new $e.Delegate,this._modified=new $e.Delegate,this._loading=new $e.Delegate,this._completed=new $e.Delegate, -this._error=new $e.Delegate,this._symbolError=new $e.Delegate,this._symbolResolved=new $e.Delegate,this._seriesError=new $e.Delegate,this._symbolNotPermitted=new $e.Delegate,this._symbolInvalid=new $e.Delegate,this._symbolGroupNotPermitted=new $e.Delegate,this._chartTypeNotPermitted=new $e.Delegate,this._intradaySpreadNotPermitted=new $e.Delegate,this._intradayExchangeNotPermitted=new $e.Delegate,this._customIntervalNotPermitted=new $e.Delegate,this._secondsIntervalNotPermitted=new $e.Delegate,this._tickMarksRangeChanged=new $e.Delegate,this._barReceived=new $e.Delegate,this._seriesTimeFrame=new $e.Delegate,this._dataUpdated=new $e.Delegate}destroy(){this._created.destroy(),this._modified.destroy(),this._loading.destroy(),this._completed.destroy(),this._error.destroy(),this._symbolError.destroy(),this._symbolResolved.destroy(),this._seriesError.destroy(),this._symbolInvalid.destroy(),this._symbolNotPermitted.destroy(),this._symbolGroupNotPermitted.destroy(),this._chartTypeNotPermitted.destroy(),this._intradaySpreadNotPermitted.destroy(),this._intradayExchangeNotPermitted.destroy(),this._customIntervalNotPermitted.destroy(),this._secondsIntervalNotPermitted.destroy(),this._tickMarksRangeChanged.destroy(),this._barReceived.destroy(),this._seriesTimeFrame.destroy(),this._dataUpdated.destroy()}created(){return this._created}modified(){return this._modified}loading(){return this._loading}completed(){return this._completed}error(){return this._error}symbolError(){return this._symbolError}symbolResolved(){return this._symbolResolved}seriesError(){return this._seriesError}symbolInvalid(){return this._symbolInvalid}symbolNotPermitted(){return this._symbolNotPermitted}symbolGroupNotPermitted(){return this._symbolGroupNotPermitted}chartTypeNotPermitted(){return this._chartTypeNotPermitted}intradaySpreadNotPermitted(){return this._intradaySpreadNotPermitted}intradayExchangeNotPermitted(){return this._intradayExchangeNotPermitted}customIntervalNotPermitted(){return this._customIntervalNotPermitted}secondsIntervalNotPermitted(){return this._secondsIntervalNotPermitted}tickMarksRangeChanged(){return this._tickMarksRangeChanged}barReceived(){return this._barReceived}seriesTimeFrame(){return this._seriesTimeFrame}dataUpdated(){return this._dataUpdated}fireCompleted(e){this._completed.fire(e)}fireCreated(e){this._created.fire(e)}fireModified(){this._modified.fire()}fireLoading(e){this._loading.fire(e)}fireError(){this._error.fire()}fireSymbolError(e){this._symbolError.fire(e),this.fireError()}fireSymbolResolved(e){this._symbolResolved.fire(e)}fireSeriesError(e){this._seriesError.fire(e),this.fireError()}fireSymbolInvalid(){this._symbolInvalid.fire()}fireSymbolNotPermitted(e){this._symbolNotPermitted.fire(e)}fireSymbolGroupNotPermitted(e){this._symbolGroupNotPermitted.fire(e)}fireChartTypeNotPermitted(e){this._chartTypeNotPermitted.fire(e),this.fireError()}fireIntradaySpreadNotPermitted(){this._intradaySpreadNotPermitted.fire(),this.fireError()}fireIntradayExchangeNotPermitted(){this._intradayExchangeNotPermitted.fire(), -this.fireError()}fireCustomIntervalNotPermitted(e){this._customIntervalNotPermitted.fire(e),this.fireError()}fireSecondsIntervalNotPermitted(){this._secondsIntervalNotPermitted.fire(),this.fireError()}fireTickMarksRangeChanged(e){this._tickMarksRangeChanged.fire(e)}fireBarReceived(e){this._barReceived.fire(e)}fireSeriesTimeFrame(e,t,i,s,r){this._seriesTimeFrame.fire(e,t,i,s,r)}fireDataUpdated(e,t,i){this._dataUpdated.fire(e,t,i)}}const at=(0,a.getLogger)("Chart.SeriesDataSource");var lt;!function(e){e[e.Idle=0]="Idle",e[e.AwaitingConnection=1]="AwaitingConnection",e[e.AwaitingFirstDataUpdate=2]="AwaitingFirstDataUpdate",e[e.Active=3]="Active"}(lt||(lt={}));let ct=1;let ht=1;function dt(e){return e.startDate?e.endDate||e.count?e.endDate?["from_to",e.startDate,e.endDate]:["bar_count",e.startDate,(0,s.ensure)(e.count)]:["from_to",e.startDate]:e.count||300}class ut{constructor(e,t,i,s){this._symbol=null,this._resolvedSymbolName=null,this._createSeriesOverriddenParams=0,this._instanceId=null,this._symbolInstanceId=null,this._resolution=null,this._timeFrame=null,this._data=new c.SeriesData,this._dataEvents=new ot,this._status=lt.Idle,this._turnaroundCounter=1,this._boundOnGatewayIsConnectedChanged=this._onGatewayIsConnectedChanged.bind(this),this._ongoingDataUpdate=Promise.resolve(),this._gateway=e,this._turnaroundPrefix=t,this._createSeriesParams=dt(null!=i?i:{count:300}),this._timeFrame=s||null,this._gateway.isConnected().subscribe(this._boundOnGatewayIsConnectedChanged)}destroy(){this.stop(),this._gateway.isConnected().unsubscribe(this._boundOnGatewayIsConnectedChanged)}modifySeries(e,t,i=null,r=!1,n=null){r&&(at.logNormal("Due to force flag clearing symbol & resolution to force re-requesting data."),this._symbol=null,this._resolution=null);const o=this._symbol,a=this._resolution;if(this._symbol=e,this._resolution=t,null===this._instanceId)return void(this._timeFrame=i);const l=!(0,ue.deepEquals)(o,e)[0]||null!==this._resolvedSymbolName&&this._resolvedSymbolName!==this._getSymbolNameString(e),c=null===a||!ee.Interval.isEqual(a,t);(l||c||null!==i)&&(this._timeFrame=null,(l||c)&&this._turnaroundCounter++,l&&this._resolveSymbol(),this._gateway.modifySeries(this._instanceId,this.turnaround(),(0,s.ensureNotNull)(this._symbolInstanceId),this._resolution,n,i,this._onMessage.bind(this)),this._dataEvents.fireModified())}requestMoreData(e){null!==this._instanceId&&this._gateway.requestMoreData(this._instanceId,e,this._onMessage.bind(this))}requestMoreTickmarks(e){null!==this._instanceId&&this._gateway.requestMoreTickmarks(this._instanceId,e,this._onMessage.bind(this))}isStarted(){return this._status!==lt.Idle}isActive(){return this._status===lt.Active}resolution(){return this._resolution}start(){this.isStarted()?at.logNormal("start: data source is already started, nothing to do"):((0,s.assert)(null!==this._symbol,"symbol must be set before start"),(0,s.assert)(null!==this._resolution,"resolution must be set before start"),this._gateway.isConnected().value()?this._createSeries():this._changeStatusTo(lt.AwaitingConnection))}stop(){ -this.isStarted()?(null!==this._instanceId&&(this._gateway.removeSeries(this._instanceId),this._instanceId=null),this._changeStatusTo(lt.Idle)):at.logNormal("stop: data source is already stopped, nothing to do")}instanceId(){return this._instanceId}data(){return this._data}clearData(){this.isStarted()?this._enqueueUpdate((()=>this._clearDataImpl())):this._clearDataImpl()}dataEvents(){return this._dataEvents}turnaround(){return`${this._turnaroundPrefix}${this._turnaroundCounter}`}symbolInstanceId(){return this._symbolInstanceId}symbol(){return this._symbol}moveData(e){this._enqueueUpdate((()=>this._data.moveData(e)))}setInitialRequestOptions(e){this._createSeriesOverriddenParams=dt(e)}_resolveSymbol(){null!==this._symbol&&(this._symbolInstanceId=this._gateway.resolveSymbol("sds_sym_"+ct++,(0,Ke.encodeExtendedSymbolOrGetSimpleSymbolString)(this._symbol),this._onMessage.bind(this)))}_clearDataImpl(){this._data.clear()}_changeStatusTo(e){(0,s.assert)(this._status!==e,"Source and destination status should be distinct"),at.logNormal(`Status changed from ${lt[this._status]} to ${lt[e]}`),this._status=e}_createSeries(){(0,s.assert)(this._status!==lt.Active,'Status should not be "Active" when creating a study'),this._instanceId="sds_"+ht++,this._resolveSymbol();const e=this._createSeriesOverriddenParams||this._createSeriesParams;this._createSeriesOverriddenParams&&(this._createSeriesOverriddenParams=0),this._gateway.createSeries(this._instanceId,this.turnaround(),(0,s.ensureNotNull)(this._symbolInstanceId),(0,s.ensureNotNull)(this._resolution),e,this._timeFrame,this._onMessage.bind(this)),this._timeFrame=null,this._changeStatusTo(lt.AwaitingFirstDataUpdate),this._dataEvents.fireCreated(this._instanceId)}_onGatewayIsConnectedChanged(e){e?this._onGatewayConnected():this._onGatewayDisconnected()}_onGatewayConnected(){this._status===lt.AwaitingConnection&&this._createSeries()}_onGatewayDisconnected(){this._status!==lt.Idle&&this._status!==lt.AwaitingConnection&&(this._instanceId=null,this._changeStatusTo(lt.AwaitingConnection)),this._turnaroundCounter=1}_onMessage(e){this._enqueueUpdate((()=>this._onMessageImpl(e)))}async _onMessageImpl(e){switch(e.method){case"symbol_resolved":{const[t,i]=e.params;if(t!==this._symbolInstanceId){at.logNormal(`Resolve for old symbol, expected: ${this._symbolInstanceId}, actual ${e.params[0]}`);break}this._onSymbolResolved(i);break}case"symbol_error":if(e.params[0]!==this._symbolInstanceId){at.logNormal(`Symbol error for old symbol, expected: ${this._symbolInstanceId}, actual ${e.params[0]}`);break}this._onSymbolError(e);break;case"series_timeframe":{const[t,i,s,r,n,o,a]=e.params;if(!this._checkTurnaround(t,i)){at.logNormal(`Time frame for old data, expected: ${this._symbolInstanceId} (${this.turnaround()}), actual ${t} (${i})`);break}this._onSeriesTimeFrame(s,r,n,o,a);break}case"series_error":{const[t,i]=e.params;if(!this._checkTurnaround(t,i)){at.logNormal(`Series error for old data, expected: ${this._symbolInstanceId} (${this.turnaround()}), actual ${t} (${i})`);break} -this._onSeriesError(e.params[2]);break}case"series_loading":{const[t,i]=e.params;if(!this._checkTurnaround(t,i))break;this._onSeriesLoading(e.time);break}case"series_completed":{const[t,i,s,r]=e.params;if(!this._checkTurnaround(t,s)){at.logNormal(`Series completed for old data, expected: ${this._symbolInstanceId} (${this.turnaround()}), actual ${t} (${s})`);break}this._onSeriesCompleted(i,e.time,r);break}case"data_update":if(!this._checkTurnaround(e.params.customId,e.params.turnaround)){at.logNormal(`Data update for old data, expected: ${this._symbolInstanceId} (${this.turnaround()}), actual ${e.params.customId} (${e.params.turnaround})`);break}await this._onDataUpdate(e.params.plots,e.params.nonseries,e.params.lastBar);break;case"clear_data":if(e.params.turnaround!==this.turnaround()){at.logNormal(`Clear data for old data, expected: ${this.turnaround()}, actual ${e.params.turnaround}`);break}this._clearDataImpl(),this._dataEvents.fireDataUpdated(void 0,!1,null)}}_onSeriesError(e){let t,i;if("string"==typeof e)i={error:e},t=e;else if(i=e,e.ctx){const i={};Object.entries(e.ctx).forEach((([e,t])=>{i[e]=t.toString()})),t=e.error.format(i)}else t=e.error;if(t.startsWith("study_not_auth:")){const e=t.split(":",2)[1].split("@",2)[0];if(["BarSetRenko","BarSetPriceBreak","BarSetKagi","BarSetPnF"].includes(e))this._dataEvents.fireChartTypeNotPermitted(e);else if("BarSetSpread"===e)this._dataEvents.fireIntradaySpreadNotPermitted();else if("BarSetRange"===e){const e=`${(0,s.ensureNotNull)(this._symbol).inputs.range}R`;this._dataEvents.fireCustomIntervalNotPermitted(e)}}else"resolution_not_entitled"===t?this._dataEvents.fireIntradayExchangeNotPermitted():"custom_resolution"===t?this._dataEvents.fireCustomIntervalNotPermitted((0,s.ensureNotNull)(this._resolution)):"seconds_not_entitled"===t&&this._dataEvents.fireSecondsIntervalNotPermitted();this._dataEvents.fireSeriesError(i)}_onSeriesTimeFrame(e,t,i,s,r){this._dataEvents.fireSeriesTimeFrame(e,t,i,null==s||s,r)}_onSymbolError(e){if(e.params[1]===nt.permissionDenied)switch(e.params[2]){case nt.SymbolErrorPermissionDeniedReason.Symbol:this._dataEvents.fireSymbolNotPermitted(e.params[3]);break;case nt.SymbolErrorPermissionDeniedReason.GroupPermission:this._dataEvents.fireSymbolGroupNotPermitted(e.params[3]);break;default:this._dataEvents.fireSymbolNotPermitted(e.params[2])}else e.params[1]===nt.invalidSymbol&&this._dataEvents.fireSymbolInvalid();this._dataEvents.fireSymbolError(e.params[1])}_onSymbolResolved(e){this._resolvedSymbolName=(0,m.symbolForApi)(e,this._getSymbolNameString((0,s.ensureNotNull)(this._symbol))),this._dataEvents.fireSymbolResolved(e)}_getSymbolNameString(e){return"string"==typeof e.symbol?e.symbol:e.symbol.symbol}async _onDataUpdate(e,t,i){this._onDataUnpacked(e,i,await async function(e){if(void 0===e)return{projectionPlots:[],boxSize:null};if(""===e.d||"nochange"===e.indexes)return null;const t=await(0,rt.unpackNonSeriesData)(e.d);if(null===t||t.indexes_replace)return null -;const i=e.indexes,{bars:s,price:r,boxSize:n,reversalAmount:o}=t.data,a=(s||[]).map((e=>{let t;return"factor"in e?t=e.factor:"additionalPrice"in e&&(t=e.additionalPrice),{index:i[e.time],value:[0,e.open,e.high,e.low,e.close,e.volume,t]}}));return{lastPrice:r,projectionPlots:a,reversalAmount:o,boxSize:n}}(t))}_enqueueUpdate(e){return this._ongoingDataUpdate=this._ongoingDataUpdate.then(e,e),this._ongoingDataUpdate}_onDataUnpacked(e,t,i){if(this._status===lt.Idle)return;this._status===lt.AwaitingFirstDataUpdate&&(this._changeStatusTo(lt.Active),this._clearDataImpl());const s=this._data.bars().size(),r=this._data.bars().firstIndex(),n=this._data.mergeRegularBars(e);null!==i&&(this._data.nsBars().clear(),this._data.nsBars().merge(i.projectionPlots),this._data.lastProjectionPrice=i.lastPrice,null!==i.boxSize&&(this._data.boxSize=i.boxSize),this._data.reversalAmount=i.reversalAmount);const o=null===r||null!==n&&n.indexe.value.splice(7,1))),t}class Xt extends l.PriceDataSource{constructor(e,t,i,r){super(e,"_seriesId"),this.requestingIntradayWhenNotSupported=new $e.Delegate,this.requestingStyleIsNotSupported=new $e.Delegate,this.requestingStyleSupportRecovered=new $e.Delegate,this.requestingResolutionLessThanFrequency=new $e.Delegate,this._paneView=null,this._futureBarsPaneView=null,this._projectionBarsPaneView=null,this._waterlineView=null,this._priceLineView=null,this._gotoDateView=null,this._baseHorizontalLineView=null,this._priceStep=null,this._symbolInfo=null,this._prevSymbolInfo=null,this._isPrePostMarketPricesAvailableProperty=new(_())(!1),this._isBackAdjustmentForbiddenProperty=new(_())(!0),this._isSettlementAsCloseForbiddenProperty=new(_())(!0),this._highLowPriceCache=new Map,this._averagePriceCache=new Map,this._prevClosePriceAxisView=null,this._priceScaleAboutToBeChanged=new $e.Delegate,this._onRestarted=new $e.Delegate,this._onStatusChanged=new $e.Delegate,this._extendedHoursChanged=new $e.Delegate,this._tagsChanged=new $e.Delegate,this._intervalChanged=new $e.Delegate,this._sessionIdChanged=new $e.Delegate,this._requestMoreDataAvailable=!0,this._lineStyleLastPriceCirclePaneView=new it(this),this._prevClosePriceLineView=null,this._dataPoweredBy=null,this._loading=!0,this._seriesLoaded=!1,this._status=0,this._symbolResolvingActive=new $.WatchedValue(!1),this._predictBars=0,this._syncModel=null,this._data=null,this._lastCompleteFlags=null,this._haStyle={studyId:(0,s.ensureNotNull)((0,m.chartStyleStudyId)(8,!0))},this._renkoStyle={studyId:(0,s.ensureNotNull)((0,m.chartStyleStudyId)(4,!0))},this._pbStyle={studyId:(0,s.ensureNotNull)((0,m.chartStyleStudyId)(7,!0))},this._kagiStyle={studyId:(0,s.ensureNotNull)((0,m.chartStyleStudyId)(5,!0))},this._pnfStyle={studyId:(0,s.ensureNotNull)((0,m.chartStyleStudyId)(6,!0))},this._rangeStyle={studyId:(0,s.ensureNotNull)((0,m.chartStyleStudyId)(11,!0))},this._barColorerCache=null,this._boxSizeValue=new $.WatchedValue,this._base=100,this._pointValue=1,this._formattingDeps=null,this._formatter=new f.PriceFormatter(this._base),this._ignoreMinMoveFormatter=new f.PriceFormatter(this._base),this._ignoreMinMovePriceStep=null,this._lastBarCloseTime=null,this._onSessionIdPropertyChangedBound=this._onSessionIdPropertyChanged.bind(this),this._ignoreSessionIdProxyPropertyChanges=!1,this._textSourceIsAlwaysTickerRestrictionEnabled=!1,this._lastPriceAnimationActive=!1,this._currentSession="out_of_session",this._onStyleChanged=new $e.Delegate, -this._intervalObj=null,this._obsoleteZOrder=0,this._seriesErrorMessage=null,this._seriesAlwaysFalseHibernatedVW=new $.WatchedValue(!1),this._styleToRecover=null,this._precomputedBarStyles=new WeakMap,this._doNotShowLastAvailableBar=!1,this._gotoDateResultCleared=!1,this._endOfDataPaneView=null,this._pendingTimeRange=null,this._replaySubscriber=null,this._symbolIntervalChanged=new $e.Delegate,this._isReplayResolutionAvailableForUser=null,this._onInReplayStateChanged=new $e.Delegate,this._replayExitedDueUnsupportedInterval=new $e.Delegate,this._replayExitedDueUnavailableForUserInterval=new $e.Delegate,this._onTimeFrameApplied=new $e.Delegate,this._prevRequestedInterval="",this._isActingAsSymbolSource=new $.WatchedValue(!0),this._seriesSource=new ut(e.chartApi(),"s",r);const n=this._seriesSource.dataEvents();n.symbolResolved().subscribe(this,this._onSymbolResolved),n.symbolError().subscribe(this,this._onSymbolError),n.seriesTimeFrame().subscribe(this,this._onSeriesTimeFrame),n.seriesError().subscribe(this,this._onSeriesError),n.loading().subscribe(this,this._onSeriesLoading),n.completed().subscribe(this,this._onSeriesCompleted),n.dataUpdated().subscribe(this,this._onDataUpdated),n.barReceived().subscribe(this,this._onBarReceived),this._quotesProvider=new _e.QuotesProvider,this._quotesProvider.quotesUpdate().subscribe(this,this._onQuotesUpdate);const o=t.childs();if(t.hasChild("extendedHours")){(0,s.ensureDefined)(o.extendedHours).value()&&!t.hasChild("sessionId")&&t.addChild("sessionId",new(_())("extended")),t.removeProperty("extendedHours")}t.hasChild("sessionId")||t.addChild("sessionId",new(_())(g.SubsessionId.Regular)),(0,Nt.allChartStyles)().includes(o.style.value())||o.style.setValueSilently(2);const a=o.lineStyle.childs();if(o.lineStyle.hasChild("styleType")){let e;const t=a.styleType.value();0===t&&(o.style.setValue(14),e=o.lineWithMarkersStyle.childs()),1===t&&(o.style.setValue(15),e=o.steplineStyle.childs()),e&&(e.color.setValueSilently(a.color.value()),e.linestyle.setValueSilently(a.linestyle.value()),e.linewidth.setValueSilently(a.linewidth.value()),e.priceSource.setValueSilently(a.priceSource.value())),o.lineStyle.removeProperty("styleType")}this._setProperties(t),this._sessionIdProxyProperty=new(_())(o.sessionId.value()),o.sessionId.subscribe(this,(()=>this._updateSessionIdProxyProperty())),this._sessionIdProxyProperty.subscribe(this,this._onSessionIdProxyPropertyChanged),this._symbolTextSourceProxyProperty=new(_()),this._recalcSymbolTextSourceProxyProperty(),o.statusViewStyle.childs().symbolTextSource.subscribe(this,this._recalcSymbolTextSourceProxyProperty),this._symbolTextSourceProxyProperty.subscribe(this,(()=>e.lightUpdate())),this._options=(0,ue.merge)((0,ue.clone)(Yt),i),this._prevChartStyle=o.style.value(),this._priceAxisView=new xe(this,e,{alwaysShowGlobalLast:!Ht,showCountdown:i.countdownEnabled});let l=null;Ot||Ht||(l=new xe(this,e,{visibleOnHistoryOnly:!0,showSymbolLabel:!1,showCountdown:!1,alwaysShowGlobalLast:!1,useSolidBodyColor:!1})), -this._priceLinePriceAxisView=new Te.SeriesPriceLineAxisView(this),this._priceLineAxisViews=[this._priceLinePriceAxisView];const c=new Ie(this,e,{showCountdown:i.countdownEnabled});this._priceAxisViews=[this._priceAxisView,c],null!==l&&this._priceAxisViews.push(l),this._panePriceAxisView=new Me.PanePriceAxisView(this._priceAxisView,this,e),this._historyPricePanePriceAxisView=null!==l?new Me.PanePriceAxisView(l,this,e):null,this._projectionPriceAxisView=new Me.PanePriceAxisView(c,this,e),this._labelPaneViews=[this._panePriceAxisView,this._projectionPriceAxisView],null!==this._historyPricePanePriceAxisView&&this._labelPaneViews.push(this._historyPricePanePriceAxisView),this._highLowAvgPaneViews=[],this._averagePaneViews=[],zt&&this._createAverageViews(),this._createHighLowAvgViews(),this._subscribeRestartToSessionIdChange(),o.visible.subscribe(this,this._updateLastPriceAnimationActive),this._updateLastPriceAnimationActive(),this._dataWindowView=new H(this,e),this._legendView=new q(this,e),this._statusView=new V(this,this._model.properties().childs().scalesProperties.childs().textColor,o.statusViewStyle),this._marketStatusModel=new J(this._quotesProvider),this._dataUpdatedModeModel=Ft?new de({getter:this.symbolInfo.bind(this),onChange:n.symbolResolved()},{getter:this.status.bind(this),onChange:this._onStatusChanged},{getter:()=>{var e;return null===(e=this._lastCompleteFlags)||void 0===e?void 0:e.rt_update_period},onChange:n.completed()},o.symbol.listeners()):null,this._dataProblemModel=new pe(this._quotesProvider,o.symbol.listeners()),this._symbolResolvingActive.subscribe((()=>e.realignLineTools())),this._intervalChanged.subscribe(this,(()=>e.realignLineTools()))}supportsPressedChunks(){return!0}pressedChunks(e,t){return this.data().pressedChunks(e,t)}seriesErrorMessage(){return this._seriesErrorMessage}destroy(){this._quotesProvider.quotesUpdate().unsubscribeAll(this),this._quotesProvider.destroy(),this._model.timeScale().visibleBarsStrictRangeChanged().unsubscribeAll(this),this._unsubscribeRestartToSessionIdChange(),this._replayExitedDueUnsupportedInterval.destroy(),this._replayExitedDueUnavailableForUserInterval.destroy(),this._onTimeFrameApplied.destroy()}isActingAsSymbolSource(){return this._isActingAsSymbolSource.readonly()}barColorer(){if(this._barColorerCache)return this._barColorerCache;let e=null;const t=this._model.dataSources();for(let i=t.length-1;i>=0;i--){const r=t[i];if((0,Et.isStudy)(r)&&r.hasBarColorer()&&!r.isSourceHidden()){const t=(0,s.ensureNotNull)(r.barColorer());null===e?e=t:e.pushBackBarColorer(t)}}return null===e?e=new Vt.SeriesBarColorer(this):e.pushBackBarColorer(new Vt.SeriesBarColorer(this)),this._barColorerCache=e,e}createPaneView(){this._paneView=null,this._projectionBarsPaneView=null,this._waterlineView=null,this._priceLineView=this.hasClosePrice()?new gt(this):null;const e=this._properties.childs().style.value();switch(e){case 0:this._paneView=new yt.SeriesBarsPaneView(this,this._model);break;case 1:this._paneView=new bt.SeriesCandlesPaneView(this,this._model);break;case 2:case 14: -case 15:this._paneView=new wt.SeriesLinePaneView(this,this._model);break;case 3:this._paneView=new Pt.SeriesAreaPaneView(this,this._model);break;case 16:this._paneView=new Ct.SeriesHLCAreaPaneView(this,this._model);break;case 8:this._paneView=new Lt(this,this._model);break;case 9:this._paneView=new At.SeriesHollowCandlesPaneView(this,this._model);break;case 13:this._paneView=new St.SeriesColumnsPaneView(this,this._model);break;case 10:{this._paneView=new kt.SeriesBaselinePaneView(this,this._model);const e=this._properties.childs().baselineStyle.childs();this._waterlineView=new ft.SeriesWaterlinePaneView({paneHeight:()=>this.priceScale().height(),color:()=>e.baselineColor.value(),baseLevelPercentage:()=>e.baseLevelPercentage.value()});break}case 12:this._paneView=new vt.SeriesHiLoPaneView(this,this._model)}if(null===this._paneView)throw Error("Unknown chart style assigned: "+e)}properties(){return this._properties}zorder(){return 0}quotesProvider(){return this._quotesProvider}currentSession(){return this._currentSession}syncModel(){if(!this._syncModel){const e=this.symbolInfo(),t=this.interval();if(!e||!t)return null;this._syncModel=new ne(e,t)}return this._syncModel}labelPaneViews(){return this._labelPaneViews}topPaneViews(){const e=[];if(null!==this._gotoDateView&&e.push(this._gotoDateView),this._lastPriceAnimationActive){const t=this._lineStyleLastPriceCirclePaneView;t.animationActive()&&setTimeout((()=>this._model.invalidate(st.InvalidationMask.cursor())),0),t.invalidateStage(),e.push(t)}return 0!==e.length?e:null}paneViews(){if(!this.properties().childs().visible.value())return null;const e=[(0,s.ensureNotNull)(this._baseHorizontalLineView),(0,s.ensureNotNull)(this._paneView)];return this._endOfDataPaneView&&e.push(this._endOfDataPaneView),this._futureBarsPaneView&&e.push(this._futureBarsPaneView),this._projectionBarsPaneView&&e.push(this._projectionBarsPaneView),null!==this._waterlineView&&e.push(this._waterlineView),null!==this._priceLineView&&e.push(this._priceLineView),e.push(...this._highLowAvgPaneViews),e.push(...this._averagePaneViews),e}priceAxisViews(e,t){return e.findTargetPriceAxisViews(this,t,this._priceAxisViews,this._priceLineAxisViews)}clearHighLowPriceCache(){this._highLowPriceCache.clear()}clearAveragePriceCache(){this._averagePriceCache.clear()}priceScale(){return(0,s.ensureNotNull)(this._priceScale)}setPriceScale(e){this._priceScale!==e&&(this._priceScaleAboutToBeChanged.fire(),this._priceScale=e,this._properties.removeProperty("priceAxisProperties"),this._properties.addChild("priceAxisProperties",e.properties()),this._properties.childs().priceAxisProperties.childChanged(null),(0,o.emit)("series_event","price_scale_changed"),this._priceScaleChanged.fire(e))}priceScaleChanged(){return this._priceScaleChanged}priceScaleAboutToBeChanged(){return this._priceScaleAboutToBeChanged}applyPreferences(e){const t=(0,ue.clone)(e);this.priceScale().setMode({autoScale:t.priceAxisProperties.autoScale,percentage:t.priceAxisProperties.percentage,log:t.priceAxisProperties.log, -lockScale:t.priceAxisProperties.lockScale}),this.setChartStyleWithIntervalIfNeeded(t.style);const{style:i,interval:s,...r}=t;this._properties.mergePreferences(r),this._properties.saveDefaults(),this.createPaneView(),this.invalidateBarStylesCache()}disconnect(){this._seriesSource.stop(),this._predictBars=0,this._status=0,this._model.isSnapshot()||(this._prevSymbolInfo=null,this._symbolInfo=null)}isStarted(){return this._seriesSource.isStarted()}restart(e=!0){if(5===this._status)return;this._loading=!0,this._lastCompleteFlags=null,this._onRestarted.fire(),this._setStatus(1),this._updateSymbolInfo(null,e);let t=this._properties.childs().interval.value();ee.Interval.isEqual(t,this._prevRequestedInterval)&&this._notifyIntervalChanged(t);let i=null;this._pendingTimeRange&&(i=this._pendingTimeRange,this._pendingTimeRange=null),this._onBeforeModifySeries(this.getSymbolString(),t),this._onTimeFrameApplied.fire(i),t=(0,pt.getServerInterval)(t),this._data=null,this._seriesSource.modifySeries(this._getResolvingSymbolObject(),t,i),this._seriesSource.isStarted()||this._seriesSource.start(),this._prevRequestedInterval=this.interval(),this.updateAllViews((0,ye.sourceChangeEvent)(this.id())),this._model.lightUpdate()}isSymbolInvalid(){return 4===this._status}getSymbolString(){return(0,Ke.encodeExtendedSymbolOrGetSimpleSymbolString)(this._getSymbolObject())}invalidateBarStylesCache(e){qt.logDebug("Invalidate style cache starting from "+e),this._clearStylePlot(this.bars(),e),this._clearStylePlot(this.nsBars())}isFailed(){return 12===this.status()||4===this.status()||10===this.status()}isStatusError(){return 12===this.status()}actualSymbol(){return(0,m.actualSymbol)(this.symbolInfo(),this.symbol())}proSymbol(){return(0,m.proSymbol)(this.symbolInfo(),this.symbol())}onStyleChanged(){return this._onStyleChanged}style(){return this.properties().childs().style.value()}setStyle(e){this.setSymbolParams({style:e})}isRangeBasedStyle(){return(0,m.isRangeBasedStyle)(this.style())}symbolSameAsCurrent(e){return(0,Ye.symbolSameAsCurrent)(e,this.symbolInfo())}status(){return this._status}symbol(){return this.properties().childs().symbol.value()}symbolChanged(){return this.properties().childs().symbol.listeners()}symbolInfo(){return this._symbolInfo}symbolResolved(){return this.dataEvents().symbolResolved()}symbolResolvingActive(){return this._symbolResolvingActive}symbolHibernated(){return this._seriesAlwaysFalseHibernatedVW}firstValue(){const e=this.firstBar();return null===e?null:this._barFunction(e,0)}firstBar(){const e=this.model().timeScale().visibleBarsStrictRange();if(null===e)return null;const t=e.firstBar(),i=this.data().search(t,d.PlotRowSearchMode.NearestRight);return null!==i?i.value:null}formatter(e=!0){return e?this._formatter:this._ignoreMinMoveFormatter}priceStep(e=!0){return e?this._priceStep:this._ignoreMinMovePriceStep}bars(){return this.data().bars()}nsBars(){return this.data().nsBars()}interval(){return this.properties().childs().interval.value()}setInterval(e){this.setSymbolParams({interval:e})}intervalObj(){ -const e=this.interval();if(null!==this._intervalObj&&this._intervalObj.resolutionString===e)return this._intervalObj.interval;const t=ee.Interval.parse(e);return this._intervalObj={resolutionString:e,interval:t},t}prevClose(){const e=this.priceScale();if(e.isEmpty()||this.data().isEmpty())return null;const t=this.quotes(),i=this.firstValue();if(null===t||null===i)return null;const s=t.prev_close_price;return void 0===s?null:{coordinate:e.priceToCoordinate(s,i),floatCoordinate:e.priceToCoordinate(s,i),formattedPricePercentage:e.formatPricePercentage(s,i,!0),formattedPriceAbsolute:e.formatPriceAbsolute(s),formattedPriceIndexedTo100:e.formatPriceIndexedTo100(s,i)}}priceLineColor(e){return this.properties().childs().priceLineColor.value()||e}hasClosePrice(){return Gt||12!==this.properties().childs().style.value()}lastValueData(e,t,i){var s;const r={noData:!0},n=this.priceScale();if(this.model().timeScale().isEmpty()||n.isEmpty()||this.data().isEmpty())return r;const o=this.model().timeScale().visibleBarsStrictRange(),a=this.firstValue();if(null===o||null===a)return r;let l,c;if(t){const e=this.data().bars().last();if(null===e)return r;l=e.value,c=e.index}else{const e=this.data().bars().search(o.lastBar(),d.PlotRowSearchMode.NearestLeft);if(null===e)return r;l=e.value,c=e.index}const h=null!==(s=void 0!==e?l[e]:this._barFunction(l,2))&&void 0!==s?s:NaN,u=this.barColorer().barStyle(c,!1),p=n.priceToCoordinate(h,a),_={...n.getFormattedValues(h,a,!0),noData:!1,color:u.barColor,floatCoordinate:p,coordinate:p,index:c};return i&&(_.price=h),_}isDWM(){return this.intervalObj().isDWM()}data(){var e;return null!==(e=this._data)&&void 0!==e?e:this._seriesSource.data()}clearData(){(0,s.assert)(null===this._data,"Cannot clear loaded data"),this._seriesSource.clearData()}nearestValue(e,t,i){var s;const r=this.nearestData(e,i);return null!==(s=null==r?void 0:r.value[t])&&void 0!==s?s:void 0}onSymbolIntervalChanged(){return this._symbolIntervalChanged}onIntervalChanged(){return this._intervalChanged}onStatusChanged(){return this._onStatusChanged}onRestarted(){return this._onRestarted}onExtendedHoursChanged(){return this._extendedHoursChanged}fixLastBar(e){0}requestMoreData(e){if(3!==this._status&&7!==this._status&&8!==this._status&&9!==this._status&&6!==this._status&&11!==this._status)return;if(this._model.timeScale().isEmpty())return;const t=this._model.timeScale().visibleBarsStrictRange();if(null===t)return;if(0===this.bars().size())return;const i=t.lastBar()-(0,s.ensureNotNull)(this.data().last()).index;if(this._predictBarst.update(e))),this._highLowAvgPaneViews.forEach((t=>t.update(e))),this._labelPaneViews.forEach((t=>t.update(e))),this._priceAxisViews.forEach((t=>t.update(e))),this._priceLineAxisViews.forEach((t=>t.update(e))),null===(i=this._futureBarsPaneView)||void 0===i||i.update(e),null===(s=this._projectionBarsPaneView)||void 0===s||s.update(e),null===(r=this._waterlineView)||void 0===r||r.update(e),null===(n=this._priceLineView)||void 0===n||n.update(e),null===(o=this._gotoDateView)||void 0===o||o.update(e), -null===(a=this._endOfDataPaneView)||void 0===a||a.update(e),null===(l=this._baseHorizontalLineView)||void 0===l||l.update(e);const c=this._model.activeStrategySource().value();null==c||c.updateAllViews(e),this._lineStyleLastPriceCirclePaneView.update(e)}barFunction(){return this._barFunction}precomputedBarStyle(e){return this._precomputedBarStyles.get(e)}setPrecomputedBarStyle(e,t){this._precomputedBarStyles.set(e,t)}setSymbolParams(e){const{symbol:t,currency:i,unit:r,style:n}=e;let o=e.interval;const a=this.properties().childs(),l=this._symbolInfo;let c,h,d;if(null!==l?(c=void 0!==t&&!(0,Ye.symbolSameAsCurrent)(t,l),h=void 0!==i&&!(0,Ye.currenciesAreSame)(i,l),d=void 0!==r&&!(0,Ye.unitsAreSame)(r,l,this._model.unitConversionEnabled())):(c=void 0!==t&&t!==a.symbol.value(),h=void 0!==i&&i!==a.currencyId.value(),d=void 0!==r&&r!==a.unitId.value()),void 0!==o&&!c){const e=this.getSupportedResolution(o,!1);e!==o&&(qt.logWarn(`Change interval value from ${o} to ${e} because first is not supported`),o=e)}const u=void 0!==o&&!ee.Interval.isEqual(a.interval.value(),o),p=void 0!==n&&n!==a.style.value(),_=[Kt("symbol",t,c),Kt("interval",o,u),Kt("currency",i,h),Kt("unit",r,d),Kt("style",n,p)].filter((e=>null!==e)).join("; ");qt.logInfo(`Applying series symbol params: ${_}`),void 0!==t&&a.symbol.setValue(t),void 0!==i&&a.currencyId.setValue(i),void 0!==r&&a.unitId.setValue(r),u&&a.interval.setValue((0,s.ensureDefined)(o)),p&&a.style.setValue(n);let m=!1;if(p){m=this.isNeedRestart();const e=!c&&(h||d);this.onChartStyleChanged(e)}!m&&(c||u||h||d)&&this._applySymbolParamsChanges({symbolChanged:c,currencyChanged:h,unitChanged:d,intervalChanged:u,styleChanged:p}),(c||h||d)&&this.model().checkLineToolSelection()}setSymbol(e){this.setSymbolParams({symbol:e})}currency(){return this.properties().childs().currencyId.value()||null}setCurrency(e){this.setSymbolParams({currency:e})}isConvertedToOtherCurrency(){return(0,m.isConvertedToOtherCurrency)(this.symbolInfo())}unit(){return this.properties().childs().unitId.value()||null}setUnit(e){this.setSymbolParams({unit:e})}measureUnitId(){return(0,m.measureUnitId)(this.symbolInfo())}isConvertedToOtherUnit(){return(0,m.isConvertedToOtherUnit)(this.symbolInfo(),this._model.unitConversionEnabled())}valueAt(e,t){var i,s;return null!==(s=null===(i=this.data().search(e))||void 0===i?void 0:i.value[t])&&void 0!==s?s:null}symbolSource(){return this}barsProvider(){return this}title(e){return this.symbolTitle(e)}name(){return this.symbolTitle(Rt.TitleDisplayTarget.StatusLine)}symbolTitle(e,t,i,s="exchange"){let r=this.properties().childs().symbol.value();const n=this.symbolInfo();if(null!==n){const{type:e}=n;r=(0,m.symbolTitle)(n,t,"forex"===e?"exchange":s)}return i?r:`${r}, ${(0,C.translatedIntervalString)(this.properties().childs().interval.value())}`}setObsoleteZOrder(e){this._obsoleteZOrder=e}obsoleteZOrder(){return this._obsoleteZOrder}valuesProvider(){return new U(this,this.model())}statusProvider(e){ -return new A(this,this._model.properties().childs().scalesProperties.childs().textColor,this.properties().childs().statusViewStyle,e)}open(e){const t=this.data().valueAt(e);return t&&t[1]}high(e){const t=this.data().valueAt(e);return t&&t[2]}low(e){const t=this.data().valueAt(e);return t&&t[3]}close(e){const t=this.data().valueAt(e);return t&&t[4]}moveItem(e,t,i){if(10===this.style()&&0===t){const t=this.priceScale(),i=this.properties().childs().baselineStyle,s=t.height(),r=100-e.y/s*100,n=r<0?0:Math.round(10*r)/10;i.childs().baseLevelPercentage.setValue(Math.max(Math.min(n,100),0))}}rerequestData(){this._applySymbolParamsChanges({force:!0})}switchToReplay(e,t){throw new Error("Not implemented")}switchToRealtime(){throw new Error("Not implemented")}requestMoreDataAvailable(){return this._requestMoreDataAvailable}seriesLoaded(){return this._seriesLoaded}endOfData(){var e;return void 0!==(null===(e=this._lastCompleteFlags)||void 0===e?void 0:e.data_completed)}endOfDataType(){var e,t;return null!==(t=null===(e=this._lastCompleteFlags)||void 0===e?void 0:e.data_completed)&&void 0!==t?t:null}dataPoweredBy(){return null}boxSizeValue(){return this._boxSizeValue}isUserDeletable(){return!1}changeTimeFrame(){(0,n.trackEvent)("GUI","Change timeframe")}onTagsChanged(){return this._tagsChanged}state(e){var t;const i=this.obsoleteZOrder();let s={type:"MainSeries",id:this.id(),zorder:i,haStyle:this._haStyle,renkoStyle:this._renkoStyle,pbStyle:this._pbStyle,kagiStyle:this._kagiStyle,pnfStyle:this._pnfStyle,rangeStyle:this._rangeStyle,formattingDeps:this._formattingDeps};const r=this.properties().state();if((null===(t=this._symbolInfo)||void 0===t?void 0:t.ticker)&&(r.symbol=this._symbolInfo.ticker),this._model.unitConversionEnabled()||(r.unitId=null),s.state=r,e){let e=this.bars();const t=this._model.timeScale().visibleExtendedDataRange(e,0);null!==t&&(e=e.range(t.firstBar(),t.lastBar())),s={...s,bars:Zt(e),nsBars:Zt(this.nsBars()),symbolInfo:this._symbolInfo,rtPrice:this.data().lastProjectionPrice,boxSize:this.data().boxSize,reversalAmount:this.data().reversalAmount}}return s}restoreState(e,t){if(t&&this._setStatus(5),!this._model.unitConversionEnabled()&&e.state&&delete e.state.unitId,this._properties.mergeAndFire(e.state),this._properties.hasChild("esdBreaksStyle")&&this._properties.removeProperty("esdBreaksStyle"),this._prevChartStyle=this.properties().childs().style.value(),this.createPaneView(),t){const t=e;this.restoreData(t.bars,t.nsBars,t.symbolInfo,t.rtPrice,t.boxSize,t.reversalAmount)}e.formattingDeps&&(this._formattingDeps=e.formattingDeps,this._recreatePriceFormattingDependencies())}restoreData(e,t,i,s,r,n){this._status=5,this._data=new c.SeriesData,this._data.bars().restoreState(e),this._data.nsBars().restoreState(t),this._updateSymbolInfo(i,!1),this._data.lastProjectionPrice=s,this._data.boxSize=r;const o=this.properties().childs() -;r||(6===o.style.value()?this._data.boxSize=o.pnfStyle.childs().inputs.childs().boxSize.value():4===o.style.value()&&(this._data.boxSize=o.renkoStyle.childs().inputs.childs().boxSize.value())),this._data.reversalAmount=n,n||5===o.style.value()&&(this._data.reversalAmount=o.kagiStyle.childs().inputs.childs().reversalAmount.value()),this._loading=!1}async setGotoDateResult(e,t){this._gotoDateResultCleared=!1;const s=await i.e(4079).then(i.bind(i,1539));this._gotoDateResultCleared||(this._gotoDateView=new s.GotoDateView(this,e,t),this._gotoDateView.doNotShowLastAvailableBar(this._doNotShowLastAvailableBar),this._model.updateSource(this))}clearGotoDateResult(){this._gotoDateView=null,this._gotoDateResultCleared=!0}doNotShowLastAvailableBar(e){var t;this._doNotShowLastAvailableBar=e,null===(t=this._gotoDateView)||void 0===t||t.doNotShowLastAvailableBar(e)}dataUpdated(){return this.dataEvents().dataUpdated()}getSupportedResolution(e,t=!0){if(null===this._symbolInfo||!(0,Ye.symbolSameAsCurrent)(this.symbol(),this._symbolInfo))return e;if(ee.Interval.isRange(e)&&(0,m.isCloseBasedSymbol)(this._symbolInfo)){const t=this.interval();if(!ee.Interval.isRange(t))return t;e="1D"}const i=this._symbolInfo.data_frequency;if(void 0!==i){let s=(0,pt.getApplicableIntervalForFrequency)(i,e);if(s!==e){this._model.defaultResolutions();return t&&this.requestingResolutionLessThanFrequency.fire(i,s),s}}if(ee.Interval.isIntraday(e)&&!this._symbolInfo.has_intraday)return t&&this.requestingIntradayWhenNotSupported.fire(),"D";if(this._symbolInfo.hasOwnProperty("supported_resolutions")){const t=ee.Interval.normalize(e),i=this._symbolInfo.supported_resolutions;if(null!==t&&-1===i.indexOf(t))return i[0]}return e}startedAndCompleted(){return new Promise((e=>{this.isStarted()&&e(),this.dataEvents().completed().subscribe(this,e,!0)}))}_barsState(e){const t=e.state();return t.data.forEach((e=>e.value.splice(7,1))),t}_updateBarFunction(){this._barFunction=(0,Dt.barFunctionByStyle)(this.style(),this.priceSource())}_setProperties(e){e.hasChild("timeframe")||e.merge({timeframe:""}),e.hasChild("shortName")||e.merge({shortName:""}),e.hasChild("currencyId")||e.addChild("currencyId",new(_())(null)),e.hasChild("unitId")||e.addChild("unitId",new(_())(null)),this._properties=e;const t=e.childs();t.currencyId.subscribe(this,this._onCurrencyChanged),t.unitId.subscribe(this,this._onUnitChanged),t.timeframe.subscribe(this,this.changeTimeFrame),e.subscribe(this,this._onPropertiesChanged)}_updateSessionIdProxyProperty(e){const t=this._properties.childs().sessionId.value();let i=t;if(e){const e=this.symbolInfo();null!==e&&(i=e.subsession_id||t)}this._ignoreSessionIdProxyPropertyChanges=!0,this._sessionIdProxyProperty.setValue(i),this._ignoreSessionIdProxyPropertyChanges=!1}_onSessionIdProxyPropertyChanged(){this._ignoreSessionIdProxyPropertyChanges||this._properties.childs().sessionId.setValue(this._sessionIdProxyProperty.value()),this._updateLastPriceAnimationActive()}_onSymbolResolved(e){this._seriesErrorMessage=null,this._updateSymbolInfo(e,!1), -this._model.updateSource(this),this._model.onWidget()||((0,n.trackEvent)("Symbol",e.listed_exchange,e.name),(0,n.trackEvent)("Symbol Type",e.type,e.listed_exchange));const t=e.minmov/e.pricescale,i=this.properties().childs();4===i.style.value()&&i.renkoStyle.childs().inputs.childs().boxSize.value(){e[t]=i[t].toString()})),t=t.format(e)}jt&&qt.logNormal("Error reason: "+t),this._seriesErrorMessage=t;const s="unknown_symbol"!==t?12:Ut&&this._symbolInfo?10:4;this._setStatus(s),this._seriesLoaded=!0,this._enablePriceRangeReady()}_onSeriesLoading(e){this._loading=!0,this._setStatus(2)}_onDataUpdated(e,t){t?this._requestMoreDataAvailable=!0:this._lastPriceAnimationActive&&this._seriesLoaded&&this._lineStyleLastPriceCirclePaneView.update((0,ye.sourceChangeEvent)(this.id())),this._lastBarCloseTime=e&&e.closeTime||null,this._boxSizeValue.setValue(this.data().boxSize),this._statusView.update(),this.clearAveragePriceCache(),this.clearHighLowPriceCache();const i=this.model(),r=(0,s.ensureNotNull)(i.paneForSource(this));i.recalculatePane(r,(0,ye.sourceChangeEvent)({sourceId:this.id(),realtime:!t})),i.updateSource(this)}_setStatus(e){this._status=e,this._statusView.update(),this.model().updateSource(this),this._onStatusChanged.fire()}_onBarReceived(e){this.model().recalcVisibleRangeStudies(!0)}_recreateFormatter(){var e,t,i,s;let r=null;r=null!==(t=null===(e=null===Bt.customFormatters||void 0===Bt.customFormatters?void 0:Bt.customFormatters.priceFormatterFactory)||void 0===e?void 0:e.call(Bt.customFormatters,this.symbolInfo(),this.properties().childs().minTick.value()))&&void 0!==t?t:null,null!==r?(this._formatter=r,this._ignoreMinMoveFormatter=r):(this._formatter=(0,m.createSeriesFormatter)(null!==(i=this.symbolInfo())&&void 0!==i?i:this._formattingDeps,this.properties().childs().minTick.value()),this._ignoreMinMoveFormatter=(0,m.createSeriesFormatter)(this.symbolInfo(),this.properties().childs().minTick.value(),!0)), -null===(s=this._priceScale)||void 0===s||s.updateFormatter(),this._formatterChanged.fire()}_recreatePriceStep(){const{minMove:e,priceScale:t}=(0,m.getSeriesPriceFormattingState)(this.symbolInfo()),i=e/t;this._ignoreMinMovePriceStep=1/t,this._priceStep!==i&&(this._priceStep=i,this._priceStepChanged.fire())}_recreatePriceFormattingDependencies(){this._recreateFormatter(),this._recreatePriceStep()}_onQuotesUpdate(e,t){void 0!==e.values.current_session&&e.values.current_session!==this._currentSession&&(this._currentSession=e.values.current_session,this._updateLastPriceAnimationActive())}_updateIsPrePostMarketPricesForbiddenProperty(){const e=(0,m.symbolHasPreOrPostMarket)(this._symbolInfo)&&(this.isDWM()||(0,m.isRegularSessionId)(this.sessionIdProxyProperty().value()));this._isPrePostMarketPricesAvailableProperty.setValue(e)}_updateSettlementAsCloseForbiddenProperty(){}_updateBackAdjustmentForbiddenProperty(){}_removeReplaySubscriber(){throw new Error("Not implemented")}_getSymbolForApi(){return(0,m.symbolForApi)(this.symbolInfo()||this._prevSymbolInfo,this.symbol())}_getSymbolObject(){const e=this._getExtendedSymbolObject();if(v.SYMBOL_STRING_DATA.hasOwnProperty(this.properties().childs().style.value())){return{symbol:e,type:this.styleStudyInfo(this.getStyleShortName()+"Style").studyId+"!",inputs:this.getInputsProperties().state()}}return e}_getExtendedSymbolObject(){const e={symbol:this._getSymbolForApi()},t=this.properties().childs();null!==this.currency()&&(e["currency-id"]=this.currency());const i=this.unit();return this._model.unitConversionEnabled()&&null!==i&&(e["unit-id"]=i),!this.isDWM()&&$t&&(e.session=t.sessionId.value()),e}_checkChartStyle(){const e=this.style();(0,m.isCloseBasedSymbol)(this.symbolInfo())?(0,m.isSingleValueBasedStyle)(e)||(this.requestingStyleIsNotSupported.fire(),this._styleToRecover={correctedStyle:this.style(),originalStyle:e}):null!==this._styleToRecover&&(this.requestingStyleSupportRecovered.fire(this._styleToRecover.originalStyle),this._styleToRecover=null)}_updateSymbolInfo(e,t){if(this._prevSymbolInfo=t?this._symbolInfo:null,this._symbolInfo=e,e){const t=this._properties.childs();t.shortName.setValue(e.name);const i=(0,m.extractSymbolNameFromSymbolInfo)(e,this.symbol());i&&t.symbol.setValue(i);const s=(0,m.symbolCurrency)(e),r=(0,m.symbolUnit)(e,this._model.unitConversionEnabled());"alwaysOff"===(0,Q.currencyUnitVisibilityProperty)().value()||s===t.currencyId.value()&&r===t.unitId.value()||this._model.fullUpdate(),t.currencyId.setValue(s),t.unitId.setValue(r),this._updateSessionIdProxyProperty(!0)}this._base=e?e.pricescale/e.minmov:100,this._pointValue=e&&e.pointvalue||1;const i=this._getSymbolForApi();this._quotesProvider.setQuotesSessionSymbol(i),this._marketStatusModel.setSymbolInfo(e),e&&this._recreatePriceFormattingDependencies(),this._statusView.update(),this.priceScale().updateFormatter(),this._symbolResolvingActive.setValue(!e),$t&&this._updateIsPrePostMarketPricesForbiddenProperty()}_createHighLowAvgViews(){ -const e=this.properties().childs().highLowAvgPrice,t=this._getHighLowPrice.bind(this),i=function(e,t,i,s){const r=i.childs(),n=Fe(e,t,{label:Ne,labelVisible:r.highLowPriceLabelsVisible,lineVisible:r.highLowPriceLinesVisible,lineColor:r.highLowPriceLinesColor,lineWidth:r.highLowPriceLinesWidth},(()=>s(0))),o=Fe(e,t,{label:Oe,labelVisible:r.highLowPriceLabelsVisible,lineVisible:r.highLowPriceLinesVisible,lineColor:r.highLowPriceLinesColor,lineWidth:r.highLowPriceLinesWidth},(()=>s(1)));return{paneViews:[n.paneView,o.paneView],panePriceAxisViews:[n.panePriceAxisView,o.panePriceAxisView],priceAxisViews:[n.priceAxisView,o.priceAxisView],priceLineAxisViews:[n.priceLineAxisView,o.priceLineAxisView]}}(this._model,this,e,t);this._highLowAvgPaneViews.push(...i.paneViews),this._labelPaneViews.push(...i.panePriceAxisViews),this._priceAxisViews.push(...i.priceAxisViews),this._priceLineAxisViews.push(...i.priceLineAxisViews)}_createAverageViews(){const e=this.properties().childs().highLowAvgPrice,t=this._getAveragePrice.bind(this),i=qe(this._model,this,e,t);this._averagePaneViews.push(...i.paneViews),this._labelPaneViews.push(...i.panePriceAxisViews),this._priceAxisViews.push(...i.priceAxisViews),this._priceLineAxisViews.push(...i.priceLineAxisViews)}_getHighLowPrice(e){if(!this._highLowPriceCache.has(e)){const e=this._model.timeScale().visibleBarsStrictRange();if(null===e)return null;const t=function(e,t,i){return e.minMaxOnRangeCached(t,i,[{name:"low",offset:0},{name:"high",offset:0}])}(this._model.mainSeries().bars(),e.firstBar(),e.lastBar());if(null===t)return null;this._highLowPriceCache.set(1,t.min),this._highLowPriceCache.set(0,t.max)}return this._highLowPriceCache.get(e)}_getAveragePrice(e){if(!this._averagePriceCache.has(e)){const e=this._model.timeScale().visibleBarsStrictRange();if(null===e)return null;const t=function(e,t,i){0;const s=(0,c.barFunction)("close");let r=0,n=0;for(let o=t;o<=i;o++){const t=e.valueAt(o);null!==t&&(r+=s(t),n++)}return n?r/n:null}(this._model.mainSeries().bars(),e.firstBar(),e.lastBar());if(null===t)return null;this._averagePriceCache.set(0,t)}return this._averagePriceCache.get(e)}_onSeriesCompleted(e){var t;this._loading=!1,this._seriesErrorMessage=null;let i=e.updateMode;switch("pulsed"===i&&(i="delayed"),i){case"streaming":this._setStatus(3);break;case"endofday":this._setStatus(6);break;case"delayed":this._setStatus(8);break;case"replay":this._setStatus(11)}i.match(/delayed_streaming/)&&this._setStatus(9),this._lastCompleteFlags=null!==(t=e.flags)&&void 0!==t?t:null;const r=(0,s.ensureNotNull)(this._model.paneForSource(this));r.recalculatePriceScale(this.priceScale(),(0,ye.sourceChangeEvent)(this.id()));const n=st.InvalidationMask.full();null!==this._model.appliedTimeFrame().value()&&n.lockVisibleTimeRangeOnResize(),this._model.invalidate(n),this.model().recalcVisibleRangeStudies(!0),this.model().recalcStudyBasedLineTools(),!this.priceScale().isLockScale()||this.model().timeScale().isEmpty()||this._seriesLoaded||(this.model().timeScale().correctOffset(), +return this._line.properties().closeTooltip.setValue(d(e)),this}getCloseTooltip(){return this._line.properties().closeTooltip.value()}setReverseTooltip(e){return this._line.properties().reverseTooltip.setValue(d(e)),this}getReverseTooltip(){return this._line.properties().reverseTooltip.value()}getQuantity(){return this._data.quantityText}setQuantity(e){return this._data.quantityText=e||"",this._line.updateAllViewsAndRedraw(),this}getExtendLeft(){var e=this._line.properties().extendLeft.value();return"inherit"===e?this._line._model.properties().tradingProperties.extendLeft.value():e}setExtendLeft(e){return this._line.properties().extendLeft.setValue(e),this}getLineLength(){var e=this._line.properties().lineLength.value();return"inherit"===e?this._line._model.properties().tradingProperties.lineLength.value():e}getLineLengthUnit(){return this._line.properties().lineLengthUnit.value()}setLineLength(e,t="percentage"){const i=t&&"pixel"===t?e:Math.max(0,Math.min(e,100));return this._line.properties().lineLength.setValue(i),this._line.properties().lineLengthUnit.setValue(t),this}getLineColor(){var e=this._line.properties();return("buy"===this._direction?e.lineBuyColor:e.lineSellColor).value()}setLineColor(e){return"buy"===this._direction?this.setLineBuyColor(e):this.setLineSellColor(e),this}setLineBuyColor(e){return this._line.properties().lineBuyColor.setValue(e),this}setLineSellColor(e){return this._line.properties().lineSellColor.setValue(e),this}getLineStyle(){var e=this._line.properties().lineStyle.value();return"inherit"===e?this._line._model.properties().tradingProperties.lineStyle.value():e}setLineStyle(e){return this._line.properties().lineStyle.setValue(e),this}getLineWidth(){var e=this._line.properties().lineWidth.value();return"inherit"===e?this._line._model.properties().tradingProperties.lineWidth.value():e}setLineWidth(e){return this._line.properties().lineWidth.setValue(e),this}getBodyBorderColor(){var e=this._line.properties();return("buy"===this._direction?e.bodyBorderBuyColor:e.bodyBorderSellColor).value()}setBodyBorderColor(e){return"buy"===this._direction?this.setBodyBorderBuyColor(e):this.setBodyBorderSellColor(e),this}setBodyBorderBuyColor(e){return this._line.properties().bodyBorderBuyColor.setValue(e),this}setBodyBorderSellColor(e){return this._line.properties().bodyBorderSellColor.setValue(e),this}getBodyBackgroundColor(){return o.getColorFromProperties(this._line.properties().bodyBackgroundColor,this._line.properties().bodyBackgroundTransparency)}setBodyBackgroundColor(e){return o.setColorToProperties(e,this._line.properties().bodyBackgroundColor,this._line.properties().bodyBackgroundTransparency),this}getBodyTextColor(){var e=this._line.properties();return("positive"===this._profitState?e.bodyTextPositiveColor:"negative"===this._profitState?e.bodyTextNegativeColor:e.bodyTextNeutralColor).value()}setBodyTextColor(e){return"positive"===this._profitState?this.setBodyTextPositiveColor(e):"negative"===this._profitState?this.setBodyTextNegativeColor(e):this.setBodyTextNeutralColor(e),this} +setBodyTextPositiveColor(e){return this._line.properties().bodyTextPositiveColor.setValue(e),this}setBodyTextNegativeColor(e){return this._line.properties().bodyTextNegativeColor.setValue(e),this}setBodyTextNeutralColor(e){return this._line.properties().bodyTextNeutralColor.setValue(e),this}getBodyFont(){return o.getFontFromProperties(this._line.properties().bodyFontFamily,this._line.properties().bodyFontSize,this._line.properties().bodyFontBold,this._line.properties().bodyFontItalic)}setBodyFont(e){return o.setFontToProperties(e,this._line.properties().bodyFontFamily,this._line.properties().bodyFontSize,this._line.properties().bodyFontBold,this._line.properties().bodyFontItalic),this}getQuantityBorderColor(){var e=this._line.properties();return("buy"===this._direction?e.quantityBorderBuyColor:e.quantityBorderSellColor).value()}setQuantityBorderColor(e){return"buy"===this._direction?this.setQuantityBorderBuyColor(e):this.setQuantityBorderSellColor(e),this}setQuantityBorderBuyColor(e){return this._line.properties().quantityBorderBuyColor.setValue(e),this}setQuantityBorderSellColor(e){return this._line.properties().quantityBorderSellColor.setValue(e),this}getQuantityBackgroundColor(){var e=this._line.properties();return("buy"===this._direction?e.quantityBackgroundBuyColor:e.quantityBackgroundSellColor).value()}setQuantityBackgroundColor(e){return"buy"===this._direction?this.setQuantityBackgroundBuyColor(e):this.setQuantityBackgroundSellColor(e),this}setQuantityBackgroundBuyColor(e){return this._line.properties().quantityBackgroundBuyColor.setValue(e),this}setQuantityBackgroundSellColor(e){return this._line.properties().quantityBackgroundSellColor.setValue(e),this}getQuantityTextColor(){return o.getColorFromProperties(this._line.properties().quantityTextColor,this._line.properties().quantityTextTransparency)}setQuantityTextColor(e){return o.setColorToProperties(e,this._line.properties().quantityTextColor,this._line.properties().quantityTextTransparency),this}getQuantityFont(){return o.getFontFromProperties(this._line.properties().quantityFontFamily,this._line.properties().quantityFontSize,this._line.properties().quantityFontBold,this._line.properties().quantityFontItalic)}setQuantityFont(e){return o.setFontToProperties(e,this._line.properties().quantityFontFamily,this._line.properties().quantityFontSize,this._line.properties().quantityFontBold,this._line.properties().quantityFontItalic),this}getReverseButtonBorderColor(){var e=this._line.properties();return("buy"===this._direction?e.reverseButtonBorderBuyColor:e.reverseButtonBorderSellColor).value()}setReverseButtonBorderColor(e){return"buy"===this._direction?this.setReverseButtonBorderBuyColor(e):this.setReverseButtonBorderSellColor(e),this}setReverseButtonBorderBuyColor(e){return this._line.properties().reverseButtonBorderBuyColor.setValue(e),this}setReverseButtonBorderSellColor(e){return this._line.properties().reverseButtonBorderSellColor.setValue(e),this}getReverseButtonBackgroundColor(){ +return o.getColorFromProperties(this._line.properties().reverseButtonBackgroundColor,this._line.properties().reverseButtonBackgroundTransparency)}setReverseButtonBackgroundColor(e){return o.setColorToProperties(e,this._line.properties().reverseButtonBackgroundColor,this._line.properties().reverseButtonBackgroundTransparency),this}getReverseButtonIconColor(){var e=this._line.properties();return("buy"===this._direction?e.reverseButtonIconBuyColor:e.reverseButtonIconSellColor).value()}setReverseButtonIconColor(e){return"buy"===this._direction?this.setReverseButtonIconBuyColor(e):this.setReverseButtonIconSellColor(e),this}setReverseButtonIconBuyColor(e){return this._line.properties().reverseButtonIconBuyColor.setValue(e),this}setReverseButtonIconSellColor(e){return this._line.properties().reverseButtonIconSellColor.setValue(e),this}getCloseButtonBorderColor(){var e=this._line.properties();return("buy"===this._direction?e.closeButtonBorderBuyColor:e.closeButtonBorderSellColor).value()}setCloseButtonBorderColor(e){return"buy"===this._direction?this.setCloseButtonBorderBuyColor(e):this.setCloseButtonBorderSellColor(e),this}setCloseButtonBorderBuyColor(e){return this._line.properties().closeButtonBorderBuyColor.setValue(e),this}setCloseButtonBorderSellColor(e){return this._line.properties().closeButtonBorderSellColor.setValue(e),this}getCloseButtonBackgroundColor(){return o.getColorFromProperties(this._line.properties().closeButtonBackgroundColor,this._line.properties().closeButtonBackgroundTransparency)}setCloseButtonBackgroundColor(e){return o.setColorToProperties(e,this._line.properties().closeButtonBackgroundColor,this._line.properties().closeButtonBackgroundTransparency),this}getCloseButtonIconColor(){var e=this._line.properties();return("buy"===this._direction?e.closeButtonIconBuyColor:e.closeButtonIconSellColor).value()}setCloseButtonIconColor(e){return"buy"===this._direction?this.setCloseButtonIconBuyColor(e):this.setCloseButtonIconSellColor(e),this}setCloseButtonIconBuyColor(e){return this._line.properties().closeButtonIconBuyColor.setValue(e),this}setCloseButtonIconSellColor(e){return this._line.properties().closeButtonIconSellColor.setValue(e),this}block(){this._blocked=!0,this._line.updateAllViewsAndRedraw()}unblock(){this._blocked=!1,this._line.updateAllViewsAndRedraw()}isFunction(e){return"function"==typeof e}onReverse(e,t){return t?this.isFunction(t)&&(this._onReverseData=e,this._onReverseCallback=t):this.isFunction(e)&&(this._onReverseCallback=e),this}callOnReverse(){this.isFunction(this._onReverseCallback)&&this._onReverseCallback.call(this,this._onReverseData)}isOnReverseCallbackPresent(){return this.isFunction(this._onReverseCallback)}onClose(e,t){return t?this.isFunction(t)&&(this._onCloseData=e,this._onCloseCallback=t):this.isFunction(e)&&(this._onCloseCallback=e),this}setCloseEnabled(e){return this._closeEnabled===e||(this._closeEnabled=e,this._onCloseCallback&&this._line.updateAllViewsAndRedraw()),this}isCloseEnabled(){return this._closeEnabled}callOnClose(){ +this.isFunction(this._onCloseCallback)&&this._closeEnabled&&this._onCloseCallback.call(this,this._onCloseData)}isOnCloseCallbackPresent(){return this._closeEnabled&&this.isFunction(this._onCloseCallback)}onModify(e,t){return t?this.isFunction(t)&&(this._onModifyData=e,this._onModifyCallback=t):this.isFunction(e)&&(this._onModifyCallback=e),this}callOnModify(){this.isFunction(this._onModifyCallback)&&this._onModifyCallback.call(this,this._onModifyData)}onContextMenu(e,t){return t?this.isFunction(t)&&(this._onContextMenuData=e,this._onContextMenuCallback=t):this.isFunction(e)&&(this._onContextMenuCallback=e),this}shouldShowContextMenu(){return this.isFunction(this._onContextMenuCallback)}callOnContextMenu(){if(this.isFunction(this._onContextMenuCallback))return this._onContextMenuCallback.call(this,this._onContextMenuData)}remove(){this._line._model.removeSource(this._line),delete this._line}}class p extends s{constructor(e,t){super(e,t||p.createProperties()),this._adapter=new u(this),i.e(1583).then(i.t.bind(i,46258,19)).then((({PositionPaneView:e})=>{this._setPaneViews([new e(this,this._model)])}));var s=e.mainSeries().symbolInfo(),r=null!==s?s.pricescale:100,n=null!==s&&s.fractional?s.minmov:1,o=null!==s&&s.fractional,a=null!==s?s.minmove2:void 0;this._formatter=new l(r,n,o,a)}zorder(){return h}isSpeciallyZOrderedSource(){return!0}setPoint(e,t,i){this._points[e]=t,this.normalizePoints()}addPoint(e,t){return this._points.push(e),this._lastPoint=null,this.normalizePoints(),this.createServerPoints(),!0}name(){return"Position"}createPriceAxisView(e){return this._priceAxisView=new n(this,{pointIndex:e,backgroundPropertyGetter:()=>this._adapter.getLineColor()}),this._priceAxisView}paneViews(){return TradingView.printing&&!c.enabled("snapshot_trading_drawings")?null:this._model.properties().tradingProperties.showPositions.value()?r.prototype.paneViews.call(this):null}priceAxisViews(e,t){return TradingView.printing&&!c.enabled("snapshot_trading_drawings")?null:this._model.properties().tradingProperties.showPositions.value()?r.prototype.priceAxisViews.call(this,e,t):null}hasContextMenu(){return this._adapter.shouldShowContextMenu()}contextMenuItems(){return this._adapter.callOnContextMenu()}formatter(){return this._formatter}static createProperties(e){var t=new a("linetoolposition",e,!1,!1);return this._configureProperties(t),t}}t.LineToolPosition=p},21316:(e,t,i)=>{"use strict";var s,r;i.r(t),i.d(t,{AlertStatus:()=>s,Direction:()=>r}),function(e){e[e.Waiting=0]="Waiting",e[e.Success=1]="Success",e[e.Failure=2]="Failure"}(s||(s={})),function(e){e[e.Up=1]="Up",e[e.Down=2]="Down"}(r||(r={}))},30597:(e,t,i)=>{"use strict";var s=i(50151).ensureNotNull,r=i(13087).LineDataSource,n=i(46100).DefaultProperty,o=i(21316);class a extends r{constructor(e,t,s,r){super(e,t||a.createProperties(),s,r),this._predictionPaneView=null;const n=this._model.mainSeries();n.properties().interval.subscribe(this,(()=>{this.setStatus(o.AlertStatus.Waiting)})),n.dataEvents().dataUpdated().subscribe(this,this.recalculateStateByData), +i.e(1583).then(i.t.bind(i,75061,19)).then((({PredictionPaneView:e})=>{this._predictionPaneView=new e(this,this._model),this._setPaneViews([this._predictionPaneView])}))}destroy(){const e=this._model.mainSeries();e.properties().interval.unsubscribeAll(this),e.dataEvents().dataUpdated().unsubscribeAll(this),super.destroy()}dataAndViewsReady(){return super.dataAndViewsReady()&&this._predictionPaneView&&this._predictionPaneView.iconsReady()}isSynchronizable(){return!1}status(){return this._properties.status.value()}setStatus(e){return this._properties.status.setValue(e)}pointsCount(){return 2}name(){return"Forecast"}restorePoints(e,t,i){super.restorePoints(e,t,i),this.recalculateStateByData()}recalculateStateByData(){if(!this.isSourceHidden()&&!(this._points.length<2||this._model.mainSeries().bars().isEmpty())){var e=this._points[1];if(this.status())e.index>this._model.timeScale().baseIndex()&&this.setStatus(o.AlertStatus.Waiting);else{var t=this._model.mainSeries().bars().valueAt(e.index);if(null!==t){var i=this.direction();if(i===o.Direction.Up&&t[TradingView.HIGH_PLOT]>=e.price)this.setStatus(o.AlertStatus.Success);else if(i===o.Direction.Down&&t[TradingView.LOW_PLOT]<=e.price)this.setStatus(o.AlertStatus.Success);else{var r=s(this._model.mainSeries().bars().lastIndex());e.index!==r&&this.setStatus(o.AlertStatus.Failure)}}}}}addPoint(e){var t=super.addPoint(e);return t&&this.recalculateStateByData(),t}endChanging(){super.endChanging(),this.setStatus(o.AlertStatus.Waiting),this.recalculateStateByData()}onData(e){super.onData(e),this.recalculateStateByData()}endMoving(e,t,i){super.endMoving(e,t,i),this.setStatus(o.AlertStatus.Waiting),this.recalculateStateByData()}direction(){if(this.points().length<2)return o.Direction.Up;var e=this.points()[0];return this.points()[1].price>e.price?o.Direction.Up:o.Direction.Down}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,54440))).PredictionDefinitionsViewModel}cloneable(){return!1}static createProperties(e){var t=new n("linetoolprediction",e);return this._configureProperties(t),t}static _configureProperties(e){super._configureProperties(e),e.merge({status:o.AlertStatus.Waiting})}}t.LineToolPrediction=a},27039:(e,t,i)=>{"use strict";var s=i(13087).LineDataSource,r=i(46100).DefaultProperty,n=i(68806).LineToolColorsProperty;class o extends s{constructor(e,t,s,r){super(e,t||o.createProperties(),s,r),i.e(1583).then(i.t.bind(i,86583,19)).then((({PriceLabelPaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}pointsCount(){return 1}name(){return"Price Label"}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,17265))).PriceLabelDefinitionsViewModel}static createProperties(e){var t=new r("linetoolpricelabel",e);return this._configureProperties(t),t}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new n([e.childs().borderColor])), +e.addChild("textsColors",new n([e.childs().color]))}}t.LineToolPriceLabel=o},32831:(e,t,i)=>{"use strict";i.r(t),i.d(t,{LineToolPriceNote:()=>P});var s=i(50151),r=i(13087),n=i(48891),o=i(24633),a=i(32430),l=i(68806),c=i(17236),h=i(13637),d=i(59452),u=i.n(d),p=i(77680);const _={intervalsVisibilities:{...c.intervalsVisibilitiesDefaults},showLabel:!1,horzLabelsAlign:"center",vertLabelsAlign:"top",fontSize:14,bold:!1,italic:!1,priceLabelFontSize:12,priceLabelBold:!1,priceLabelItalic:!1},m=(0,n.getHexColorByName)("color-tv-blue-500"),g={lineColor:m,textColor:m,priceLabelBackgroundColor:m,priceLabelBorderColor:m,priceLabelTextColor:(0,n.getHexColorByName)("color-white")},f=new Map([[o.StdTheme.Light,g],[o.StdTheme.Dark,g]]),v=(0,h.extractAllPropertiesKeys)((0,s.ensureDefined)(f.get(o.StdTheme.Light))),S=(0,h.extractAllPropertiesKeys)(_),y=[...v,...S,...a.commonLineToolPropertiesStateKeys,"text"];class b extends p.LineDataSourceThemedProperty{constructor(e,t,i,r,n){var o;super(e,t,i,r,y,n),this._textProperty=new(u())(null!==(o=null==n?void 0:n.text)&&void 0!==o?o:""),this.addChild("text",this._textProperty),this.addChild("linesColors",new l.LineToolColorsProperty([(0,s.ensureDefined)(this.child("lineColor"))])),this.addChild("backgroundsColors",new l.LineToolColorsProperty([(0,s.ensureDefined)(this.child("priceLabelBackgroundColor"))])),this.addChild("textsColors",new l.LineToolColorsProperty([(0,s.ensureDefined)(this.child("priceLabelTextColor"))]))}template(){return{...super.template(),text:this._textProperty.value()}}static create(e){return new this("linetoolpricenote",(()=>(0,h.factoryDefaultsForCurrentTheme)(_,f)),S,v,e)}}var w=i(28558);class P extends r.LineDataSource{constructor(e,t,s,r){super(e,t||P.createProperties(),s,r),this._labelMovingDelta=null,i.e(1583).then(i.bind(i,29734)).then((t=>{this._setPaneViews([new t.PriceNotePaneView(this,e)])}))}pointsCount(){return 2}name(){return"Price Note"}template(){return this._properties.template()}startMoving(e,t,i){if(1===t){if(this.isSourceHidden())return;const i=(0,s.ensureDefined)(e.logical),r=this.points()[1];this._labelMovingDelta={index:r.index-i.index,price:r.price-i.price},this.startChanging(t,i)}else this._labelMovingDelta=null,super.startMoving(e,t,i)}move(e,t,i){if(null!==this._labelMovingDelta){const t=(0,s.ensureDefined)(e.logical),r={index:t.index+this._labelMovingDelta.index,price:t.price+this._labelMovingDelta.price};this.setPoint(1,r,i),this.updateAllViews((0,w.sourceChangeEvent)(this.id()))}else super.move(e,t,i)}endMoving(e,t,i){return null!==this._labelMovingDelta?(this._labelMovingDelta=null,this.endChanging(!1,e)):super.endMoving(e,t,i)}static createProperties(e){const t=b.create(e);return this._configureProperties(t),t}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text)}async _getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,11980)).then((e=>e.PriceNoteDefinitionsViewModel))}_snapTo45DegreesAvailable(){return!0} +static _addCollectedProperties(e){}}},59776:(e,t,i)=>{"use strict";i.d(t,{LineToolPriceRange:()=>m});var s=i(13087),r=i(50151),n=i(24633),o=i(13637),a=i(30541),l=i(32430);const c={...a.nonThemedFactoryDefaultsBase,extendLeft:!1,extendRight:!1},h=a.themedFactoryDefaultsBase,d=(0,o.extractAllPropertiesKeys)((0,r.ensureDefined)(h.get(n.StdTheme.Light))),u=(0,o.extractAllPropertiesKeys)(c),p=[...d,...u,...l.commonLineToolPropertiesStateKeys,...a.allPropertiesStateKeysBase];class _ extends a.DateAndPriceBaseProperties{static create(e){return new this("linetoolpricerange",(()=>(0,o.factoryDefaultsForCurrentTheme)(c,h)),u,d,p,e)}}class m extends s.LineDataSource{constructor(e,t,s,r){super(e,t||m.createProperties(),s,r),i.e(1583).then(i.bind(i,61416)).then((e=>{this._setPaneViews([new e.PriceRangePaneView(this,this._model)])}))}pointsCount(){return 2}name(){return"Price Range"}template(){return this._properties.template()}static createProperties(e){const t=_.create(e);return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,83115))).GeneralDatePriceRangeDefinitionsViewModel}}},66967:(e,t,i)=>{"use strict";var s=i(53801).LevelsProperty,r=i(37122).LineToolFibWedgeBase,n=i(68806).LineToolColorsProperty;class o extends r{constructor(e,t,s,r){super(e,t||o.createProperties(),s,r),i.e(1583).then(i.t.bind(i,75219,19)).then((({ProjectionLinePaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}levelsCount(){return 1}name(){return"Projection"}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,12501))).ProjectionDefinitionsViewModel}static createProperties(e){var t=new s("linetoolprojection",e,!1,{range:[1,1]});return this._configureProperties(t),t}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new n([e.trendline.color]))}}t.LineToolProjection=o},10279:(e,t,i)=>{"use strict";i.d(t,{LineToolRay:()=>r});var s=i(47246);class r extends s.LineToolTrendLine{constructor(e,t,i,s){super(e,null!=t?t:r.createProperties(),i,s)}name(){return"Ray"}static createProperties(e){const t=s.LineToolTrendLine.createProperties(e,"linetoolray");return r._configureProperties(t),t}}},32948:(e,t,i)=>{"use strict";i.d(t,{LineToolRectangle:()=>h});var s=i(86441),r=i(46100),n=i(59452),o=i.n(n),a=i(13087),l=i(68806),c=i(50151);class h extends a.LineDataSource{constructor(e,t,s,r){const n=t||h.createProperties();super(e,n,s,r),i.e(1583).then(i.bind(i,31320)).then((({RectanglePaneView:t})=>{const i=[new t(this,e)];this._setPaneViews(i)}))}pointsCount(){return 2}textColorsProperty(){return this.properties().childs().showLabel.value()?super.textColorsProperty():null}name(){return"Rectangle"}setPoint(e,t,i){if(e<2&&super.setPoint(e,t,i),i&&i.shift()){const i=this._getAnchorPointForIndex(e);if(e>=4)return this._correctMiddlePoints(e,t,i),void this.normalizePoints();this._snapPoint45Degree(t,i)}switch(e){case 2: +this._points[1].price=t.price,this._points[0].index=t.index;break;case 3:this._points[0].price=t.price,this._points[1].index=t.index;break;case 4:this._points[0].index=t.index;break;case 5:this._points[1].index=t.index;break;case 6:this._points[0].price=t.price;break;case 7:this._points[1].price=t.price}this.normalizePoints()}getPoint(e){return e<2?super.getPoint(e):this._getAnchorPointForIndex(e)}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}static createProperties(e){const t=new r.DefaultProperty("linetoolrectangle",e);return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,3664)).then((e=>e.RectangleDefinitionsViewModel))}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text)}_snapPoint45Degree(e,t,i){const s=this._priceScale,r=this.ownerSource();if(null===s||null===r)return;const n=r.firstValue();if(null===n)return;const o=this._model.timeScale(),a=(0,c.ensureNotNull)(this.pointToScreenPoint(e)),l=(0,c.ensureNotNull)(this.pointToScreenPoint(t)),h=a.x-l.x,d=a.y-l.y,u=h<0?-1:1,p=d<0?-1:1,_=Math.max(Math.abs(h),Math.abs(d)),m=Math.round(o.coordinateToIndex(l.x+_*u)),g=Math.abs(o.indexToCoordinate(m)-l.x),f=s.coordinateToPrice(l.y+g*p,n);e.index=m,e.price=f}_correctMiddlePoints(e,t,i){e<6?this._correctRightLeftMiddlePoint(e,t,i):this._correctTopBottomMiddlePoint(e,t,i)}_correctRightLeftMiddlePoint(e,t,i){const r=(0,c.ensureNotNull)(this.pointToScreenPoint(t)),n=(0,c.ensureNotNull)(this.pointToScreenPoint(i)),o=(0,c.ensureNotNull)(this.pointToScreenPoint(this._points[0])),a=(0,c.ensureNotNull)(this.pointToScreenPoint(this._points[1]));let l=r.x-n.x;if(0===l)return;const h=o.x{"use strict";var s;i.d(t,{RiskDisplayMode:()=>s}),function(e){e.Percentage="percents",e.Money="money"}(s||(s={}))},95539:(e,t,i)=>{"use strict";var s;i.d(t,{RiskRewardPointIndex:()=>s}),function(e){e[e.Entry=0]="Entry",e[e.Close=1]="Close",e[e.ActualEntry=2]="ActualEntry",e[e.ActualClose=3]="ActualClose"}(s||(s={}))},29378:(e,t,i)=>{"use strict";i.d(t,{LineToolRiskRewardLong:()=>T,LineToolRiskRewardShort:()=>x});var s=i(50151),r=i(87663),n=i(86094),o=i(34256),a=i(13087),l=i(4895),c=i(95539),h=i(42275),d=i(87095);class u extends h.PriceAxisView{constructor(e,t){super(),this._source=e,this._data=t}_updateRendererData(e,t,i){if(e.visible=!1,!this._showAxisLabel())return;const s=this._source.priceScale();if(0===this._source.points().length||null===s||s.isEmpty())return;const r=this._source.ownerSource(),n=null!==r?r.firstValue():null;if(null===n)return;const o=this._data.priceProperty.value(),a=(0,d.resetTransparency)(this._data.colorProperty.value());i.background=a,i.textColor=this.generateTextColor(a),i.coordinate=s.priceToCoordinate(o,n),e.text=s.formatPrice(o,n),e.visible=!0}_showAxisLabel(){return this._source.properties().childs().showPriceLabels.value()}}var p=i(59452),_=i.n(p);class m extends(_()){constructor(e,t){super(),this._lineSource=e,this._pointIndex=t}value(){const e=this._lineSource.points()[this._pointIndex].price;return this._formatAndParsePrice(e)}state(){return this.value()}merge(e,t){return this.setValue(e),t?[]:null}_formatAndParsePrice(e){const t=(0,s.ensureNotNull)(this._lineSource.ownerSource()).formatter();if(t.parse){const i=t.format(e),s=t.parse(i) +;return s.res?s.value:e}return e}}class g extends m{constructor(e){super(e,0)}setValue(e){const t=this._lineSource.points()[this._pointIndex];this._lineSource.startChanging(this._pointIndex,t),t.price=parseFloat(""+e),this._lineSource.setPoint(this._pointIndex,t),this._lineSource.recalculate(),this._lineSource.model().updateSource(this._lineSource),this._listeners.fire(this),this._lineSource.endChanging(!1,!1),this._lineSource.syncPriceLevels()}}class f extends m{constructor(e){super(e,1)}value(){const e=this._lineSource.stopPrice();return this._formatAndParsePrice(e)}setValue(e){const t=Math.round(Math.abs(e-this._lineSource.entryPrice())*this._lineSource.ownerSourceBase());this._lineSource.properties().childs().stopLevel.setValue(t),this._lineSource.syncPriceLevels()}}class v extends m{constructor(e){super(e,2)}value(){const e=this._lineSource.profitPrice();return this._formatAndParsePrice(e)}setValue(e){const t=Math.round(Math.abs(e-this._lineSource.entryPrice())*this._lineSource.ownerSourceBase());this._lineSource.properties().childs().profitLevel.setValue(t),this._lineSource.syncPriceLevels()}}var S=i(1722),y=i(88348),b=i(28558);function w(e){return parseFloat(e.toFixed(2))}class P extends a.LineDataSource{constructor(e,t,n,a){super(e,t,n,a),this._syncStateExclusions=["points","entryPrice","stopPrice","targetPrice","stopLevel","profitLevel","riskSize","qty","amountTarget","amountStop"],this._riskInChange=!1,this.version=2,t.hasChild("stopLevel")||t.hasChild("profitLevel")||(t.addProperty("stopLevel",0),t.addProperty("profitLevel",0),this.ownerSourceChanged().subscribe(this,(()=>{const i=(0,s.ensureNotNull)(e.timeScale().visibleBarsStrictRange()),r=i.firstBar(),n=i.lastBar(),a=(0,s.ensureNotNull)(this.ownerSource()),l=a.priceScale();let c=(0,s.ensureNotNull)(a.priceRange(r,n));if(l&&l.isLog()){const e=l.logicalToPrice(c.minValue()),t=l.logicalToPrice(c.maxValue());c=new o.PriceRange(e,t)}if(c&&!c.isEmpty()){const e=Math.round(.2*c.length()*this.ownerSourceBase());t.merge({stopLevel:e,profitLevel:e})}}),!0));const h=t.childs();h.stopLevel.listeners().subscribe(this,this.recalculate),h.stopLevel.listeners().subscribe(null,(()=>{this.properties().childs().stopPrice.childChanged(null)})),h.profitLevel.listeners().subscribe(this,this.recalculate),h.profitLevel.listeners().subscribe(null,(()=>{this.properties().childs().targetPrice.childChanged(null)})),t.addChild("entryPrice",new g(this)),t.addChild("stopPrice",new f(this)),t.addChild("targetPrice",new v(this)),t.hasChild("riskSize")||t.addProperty("riskSize",0),t.hasChild("qty")||t.addProperty("qty",0),t.hasChild("amountTarget")||t.addProperty("amountTarget",h.accountSize.value()),t.hasChild("amountStop")||t.addProperty("amountStop",h.accountSize.value()),t.addExclusion("riskSize"),t.addExclusion("qty"),t.addExclusion("amountTarget"),t.addExclusion("amountStop"),this._riskInPercentsFormatter=new r.NumericFormatter(2),this._riskInMoneyFormatter=new r.NumericFormatter,h.risk.subscribe(this,this._recalculateRiskSize), +h.accountSize.subscribe(this,this._recalculateRiskSize),h.riskDisplayMode.subscribe(this,this._recalculateRisk),h.riskDisplayMode.subscribe(this,this._recalculateRiskSize),h.entryPrice.subscribe(this,this._recalculateRiskSize),h.stopPrice.subscribe(this,this._recalculateRiskSize),h.profitLevel.subscribe(this,this._recalculateRiskSize),h.profitLevel.subscribe(this,this.syncPriceLevels.bind(this)),h.stopLevel.subscribe(this,this._recalculateRiskSize),h.stopLevel.subscribe(this,this.syncPriceLevels.bind(this)),h.qty.subscribe(this,this._recalculateRiskSize),this.ownerSourceChanged().subscribe(null,((e,t)=>{e&&e.barsProvider().dataUpdated().unsubscribeAll(this),t&&t.barsProvider().dataUpdated().subscribe(this,this._onSeriesUpdated)})),this.pointAdded().subscribe(this,(e=>{switch(e){case c.RiskRewardPointIndex.Entry:case c.RiskRewardPointIndex.Close:this._recalculateRiskSize(),this._recalculateQty()}})),this.pointChanged().subscribe(this,(e=>{switch(e){case c.RiskRewardPointIndex.Entry:case c.RiskRewardPointIndex.Close:this._recalculateRiskSize(),this._recalculateQty()}})),h.riskDisplayMode.value()===l.RiskDisplayMode.Percentage&&h.risk.value()>100&&h.riskDisplayMode.setValueSilently(l.RiskDisplayMode.Money),h.entryPrice.subscribe(this,this._recalculateQty),h.stopPrice.subscribe(this,this._recalculateQty),h.riskSize.subscribe(this,this._recalculateQty),h.entryPrice.subscribe(this,this._recalculateAmount),h.profitLevel.subscribe(this,this._recalculateAmount),h.stopLevel.subscribe(this,this._recalculateAmount),h.accountSize.subscribe(this,this._recalculateAmount),h.riskSize.subscribe(this,this._recalculateAmount),h.qty.subscribe(this,this._recalculateAmount),this._entryPriceAxisView=new u(this,{colorProperty:h.linecolor,priceProperty:h.entryPrice}),this._stopPriceAxisView=new u(this,{colorProperty:h.stopBackground,priceProperty:h.stopPrice}),this._profitPriceAxisView=new u(this,{colorProperty:h.profitBackground,priceProperty:h.targetPrice}),i.e(1583).then(i.bind(i,56457)).then((({RiskRewardPaneView:t})=>{const i=[new t(this,e)];this._setPaneViews(i)}))}destroy(){var e;null===(e=this.ownerSource())||void 0===e||e.barsProvider().dataUpdated().unsubscribeAll(this),this.ownerSourceChanged().unsubscribeAll(this),super.destroy()}hasEditableCoordinates(){return!1}setOwnerSource(e){super.setOwnerSource(e);const t=this.ownerSource();t&&t.symbolSource().symbolInfo()&&(this._recalculateAmount(),this._recalculateRiskSize(),this._recalculateQty())}pointsCount(){return 1}priceAxisViews(e,t){return this.isSourceHidden()||t!==this.priceScale()||this._model.paneForSource(this)!==e?null:[this._entryPriceAxisView,this._stopPriceAxisView,this._profitPriceAxisView]}updateAllViews(e){this.isActualSymbol()&&this.properties().childs().visible.value()&&((0,y.hideAllDrawings)().value()&&this.userEditEnabled()||(super.updateAllViews(e),this._entryPriceAxisView.update(e),this._stopPriceAxisView.update(e),this._profitPriceAxisView.update(e)))}migrateVersion(e,t,i){if(1===e&&this._points.length>=1){const e=[];e.push(this._points[0]) +;let t=this._points[0];if(t={price:t.price,index:this._getClosePointIndex(t.index)},e.push(t),this._points[1]&&e.push(this._points[1]),this._points[2]&&e.push(this._points[2]),this._points=e,this._timePoint.length>=1){const t=[],i=this._timePoint[0];t.push(i);const s={price:i.price,time_t:i.time_t,offset:this._getClosePointIndex(i.offset)};t.push(s),this._timePoint[1]&&e.push(this._points[1]),this._timePoint[2]&&e.push(this._points[2]),this._timePoint=t}}}restoreExternalState(e){if((0,S.isNumber)(e.entryPrice)){if(e=Object.assign({},e),!this.isActualSymbol()){this._timePoint[0].price=e.entryPrice,delete e.entryPrice}this.properties().merge(e)}else super.restoreExternalState(e)}addPoint(e,t,i){e.price=this._roundPrice(e.price),super.addPoint(e,void 0,!0);const s={price:e.price,index:this._getClosePointIndex(e.index)};super._addPointIntenal(s,void 0,!0);const r=this._calculateActualEntry(e,s);if(r){super._addPointIntenal(r,void 0,!0);const e=this._findClosePoint(r,s);e&&super._addPointIntenal(e,void 0,!0)}return this._lastPoint=null,this.normalizePoints(),this.createServerPoints(),!0}setPoint(e,t,i,s){if(!this.isActualSymbol())return;const r=this.properties().childs();switch(this._muteSyncLineStyle(),e){case 0:this._changeEntryPoint(t);break;case 2:r.stopPrice.setValue(this.prepareStopPrice(t.price));break;case 3:r.targetPrice.setValue(this.prepareProfitPrice(t.price));break;case 1:t.price=this._roundPrice(t.price),super.setPoint(1,t),this.recalculate()}this._unmuteSyncLineStyleWithoutApplyingChanges(),this.syncPriceLevels()}getPoint(e){switch(e){case 0:return this._points[0];case 1:return{index:this._points[1].index,price:this._points[0].price};case 2:return{index:this._points[0].index,price:this.stopPrice()};case 3:return{index:this._points[0].index,price:this.profitPrice()}}return null}setPoints(e){this._muteSyncLineStyle(),super.setPoints(e),this.recalculate(),this._unmuteSyncLineStyleWithoutApplyingChanges(),this.syncPriceLevels()}start(){super.start(),this.recalculate()}startMoving(e,t,i,r){const n=(0,s.ensureDefined)(e.logical);n.price=this._roundPrice(n.price),super.startMoving(e,t,i)}move(e,t,i,r){const n=(0,s.ensureDefined)(e.logical);n.price=this._roundPrice(n.price),super.move(e,t,i),this.recalculate(),this._entryPriceAxisView.update((0,b.sourceChangeEvent)(this.id()))}axisPoints(){if(!this._points[c.RiskRewardPointIndex.ActualEntry])return[];const e=this._points[c.RiskRewardPointIndex.ActualEntry];let t=null;if(4===this._points.length)t=this._points[c.RiskRewardPointIndex.ActualClose];else{const e=this.lastBarData();if(!e)return[];t={index:e.index,price:e.closePrice}}return[e,t]}recalculateStateByData(){this.recalculate()}recalculate(){if(0===this.points().length)return;const e=this.properties().childs(),t=e.targetPrice.value(),i=e.stopPrice.value(),s=[this._points[0],this._points[1]],r=this._calculateActualEntry(this.points()[0],this.points()[1]);if(r){s.push(r);const e=this._findClosePoint(r,this.points()[1]);e&&s.push(e)}this._points=s, +t!==e.targetPrice.value()&&e.targetPrice.listeners().fire(e.targetPrice),i!==e.stopPrice.value()&&e.stopPrice.listeners().fire(e.stopPrice)}syncPriceLevels(){const e=this.linkKey().value();if(e){const t=this.properties().childs(),i={entryPrice:t.entryPrice.value(),stopLevel:t.stopLevel.value(),profitLevel:t.profitLevel.value()};(0,y.changeLineStyle)({linkKey:e,state:i,model:this._model})}}entryPrice(){return this.points()[0].price}lastBarData(){var e;const t=null===(e=this.ownerSource())||void 0===e?void 0:e.barsProvider();if(!t)return null;const i=t.bars().firstIndex(),r=t.bars().lastIndex();if(null===i||null===r||isNaN(i)||isNaN(r))return null;const o=this.points();if(4===o.length){const e=o[c.RiskRewardPointIndex.ActualClose];return e.indexs?(e.risk.setValue(s),e.riskSize.setValue(s)):e.riskSize.setValue(t)}_roundPrice(e){const t=this.ownerSourceBase();return Math.round(e*t)/t}_ownerSourcePointValue(){var e,t,i;return null!==(i=null===(t=null===(e=this.ownerSource())||void 0===e?void 0:e.symbolSource().symbolInfo())||void 0===t?void 0:t.pointvalue)&&void 0!==i?i:1}static _configureProperties(e){a.LineDataSource._configureProperties(e),e.addExclusion("stopLevel"),e.addExclusion("profitLevel"),e.addExclusion("stopPrice"),e.addExclusion("targetPrice"),e.addExclusion("entryPrice")}_onSeriesUpdated(e,t,i){this.isSourceHidden()||this._points.length<2||null!==i&&i.index>Math.max(this._points[0].index,this._points[1].index)||this.recalculateStateByData()}_recalculateRisk(){const e=this.properties().childs(),t=e.riskDisplayMode.value(),i=e.riskSize.value(),s=e.accountSize.value();let r=e.risk.value() +;r=t===l.RiskDisplayMode.Percentage?w(i/s*100):w(s/100*r),this._riskInChange=!0,e.risk.setValue(+this._riskFormatter(t).format(r)),this._riskInChange=!1}_recalculateAmount(){if(0===this.points().length)return;const e=this.properties().childs(),t=e.accountSize.value(),i=e.entryPrice.value(),s=e.qty.value(),r=e.stopPrice.value(),n=e.targetPrice.value(),o=this._ownerSourcePointValue();e.amountTarget.setValue(this._amountTarget(t,n,i,s,o)),e.amountStop.setValue(this._amountStop(t,r,i,s,o))}_recalculateQty(){if(0===this.points().length)return;const e=this.properties().childs(),t=e.entryPrice.value(),i=e.stopPrice.value(),s=e.riskSize.value()/(Math.abs(t-i)*this._ownerSourcePointValue());e.qty.setValue(s)}_calculateActualEntry(e,t){const i=this.ownerSource();if(!i)return null;const r=i.barsProvider().bars();if(r.isEmpty())return null;const n=(0,s.ensureNotNull)(r.firstIndex()),o=Math.max(e.index,n),a=e.price,l=(0,s.ensureNotNull)(r.lastIndex()),c=Math.min(l,t.index),h=r.rangeIterator(o,c+1);for(;h.hasNext();){const e=h.next(),t=e.value;if(null!==t&&(0,s.ensure)(t[2])>=a&&(0,s.ensure)(t[3])<=a)return{index:e.index,price:a}}return null}_riskFormatter(e){return e===l.RiskDisplayMode.Percentage?this._riskInPercentsFormatter:this._riskInMoneyFormatter}_getClosePointIndex(e){const t=this._model.timeScale(),i=Math.round(t.width()/t.barSpacing());return e+Math.max(3,Math.round(.15*i))}_findClosePoint(e,t){const i=this.ownerSource();if(!i)return null;const r=i.barsProvider().bars(),n=(0,s.ensureNotNull)(r.firstIndex()),o=Math.max(e.index,n),a=(0,s.ensureNotNull)(r.lastIndex()),l=Math.min(a,t.index),c=r.rangeIterator(o,l+1);for(;c.hasNext();){const e=c.next(),t=e.value;if(null===t)continue;const i=this._checkStopPrice(t);if(null!=i)return{index:e.index,price:i}}return null}_changeEntryPoint(e){const t=this.properties().childs(),i=t.stopPrice.value(),s=t.targetPrice.value(),r=1/this.ownerSourceBase(),n=Math.min(i,s)+r,o=Math.max(i,s)-r;e.price=Math.max(n,Math.min(o,this._roundPrice(e.price))),super.setPoint(0,e),t.stopPrice.setValue(i),t.targetPrice.setValue(s)}}var C=i(46100);class x extends P{constructor(e,t,i,s){super(e,null!=t?t:x.createProperties(),i,s)}name(){return"Risk/Reward short"}stopPrice(){return this.entryPrice()+this.properties().childs().stopLevel.value()/this.ownerSourceBase()}calculatePL(e){return this.entryPrice()-e}profitPrice(){return this.entryPrice()-this.properties().childs().profitLevel.value()/this.ownerSourceBase()}prepareStopPrice(e){e=this._roundPrice(e);const t=this.entryPrice()+1/this.ownerSourceBase();return Math.max(e,t)}prepareProfitPrice(e){e=this._roundPrice(e);const t=this.entryPrice()-1/this.ownerSourceBase();return Math.min(e,t)}static createProperties(e){const t=new C.DefaultProperty("linetoolriskrewardshort",e);return this._configureProperties(t),t}_amountTarget(e,t,i,s,r){return w(e+(i-t)*s*r)}_amountStop(e,t,i,s,r){return w(e-(t-i)*s*r)}_checkStopPrice(e){const t=this.stopPrice(),i=this.profitPrice();return(0,s.ensure)(e[2])>=t?this.stopPrice():(0,s.ensure)(e[3])<=i?this.profitPrice():null} +_orderSide(){throw new Error("not supported")}}class T extends P{constructor(e,t,i,s){super(e,null!=t?t:T.createProperties(),i,s)}name(){return"Risk/Reward long"}stopPrice(){return this.entryPrice()-this.properties().childs().stopLevel.value()/this.ownerSourceBase()}profitPrice(){return this.entryPrice()+this.properties().childs().profitLevel.value()/this.ownerSourceBase()}calculatePL(e){return e-this.entryPrice()}prepareStopPrice(e){e=this._roundPrice(e);const t=this.entryPrice()-1/this.ownerSourceBase();return Math.min(e,t)}prepareProfitPrice(e){e=this._roundPrice(e);const t=this.entryPrice()+1/this.ownerSourceBase();return Math.max(e,t)}static createProperties(e){const t=new C.DefaultProperty("linetoolriskrewardlong",e);return this._configureProperties(t),t}_amountTarget(e,t,i,s,r){return w(e+(t-i)*s*r)}_amountStop(e,t,i,s,r){return w(e-(i-t)*s*r)}_checkStopPrice(e){const t=this.stopPrice(),i=this.profitPrice();return(0,s.ensure)(e[3])<=t?this.stopPrice():(0,s.ensure)(e[2])>=i?this.profitPrice():null}_orderSide(){throw new Error("not supported")}}},32491:(e,t,i)=>{"use strict";var s=i(86441).Point,r=i(4652).distanceToLine,n=i(13087).LineDataSource,o=i(46100).DefaultProperty,a=i(68806).LineToolColorsProperty;class l extends n{constructor(e,t,s,r){super(e,t||l.createProperties(),s,r),i.e(1583).then(i.t.bind(i,55832,19)).then((({RotatedRectanglePaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}startChanging(e,t){if(super.startChanging(e,t),0===e||1===e){var i=this._getPaneViews()[0],s=i._points[0],n=i._points[1],o=i._points[2];this._distance=r(s,n,o).distance}}setPoint(e,t,i){if(super.setPoint(e,t,i),0===e||1===e){var r=this._getPaneViews()[0];r.update();var n=r._points[0],o=r._points[1].subtract(n),a=new s(o.y,-o.x).normalized().scaled(this._distance),l=n.add(a),c=this.screenPointToPoint(l);this._points[2]=c}}endChanging(e,t){delete this._distance,super.endChanging(e,t)}pointsCount(){return 3}name(){return"Rotated Rectangle"}hasEditableCoordinates(){return!1}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,20061))).GeneralFiguresDefinitionsViewModel}_snapTo45DegreesAvailable(){return!0}static createProperties(e){var t=new o("linetoolrotatedrectangle",e);return this._configureProperties(t),t}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new a([e.color]))}}t.LineToolRotatedRectangle=l},5761:(e,t,i)=>{"use strict";var s=i(53801).LevelsProperty,r=i(70309).LineToolPitchfork;class n extends r{constructor(e,t,i,s){super(e,t||n.createProperties(),i,s)}name(){return"Modified Schiff Pitchfork"}static createProperties(e){var t=new s("linetoolschiffpitchfork",e,!1,{range:[0,8]});return this._configureProperties(t),t}}t.LineToolSchiffPitchfork=n},85806:(e,t,i)=>{"use strict";var s=i(53801).LevelsProperty,r=i(70309).LineToolPitchfork;class n extends r{constructor(e,t,i,s){super(e,t||n.createProperties(),i,s)}name(){return"Schiff Pitchfork"}static createProperties(e){ +var t=new s("linetoolschiffpitchfork2",e,!1,{range:[0,8]});return this._configureProperties(t),t}}t.LineToolSchiffPitchfork2=n},98624:(e,t,i)=>{"use strict";i.d(t,{LineToolSignpost:()=>g});var s=i(44352),r=i(46100),n=i(13087),o=i(59452),a=i.n(o);class l extends(a()){constructor(e){super(),this._source=e,e.pointAdded().subscribe(this,(()=>this.listeners().fire(this))),e.pointChanged().subscribe(this,(()=>this.listeners().fire(this)))}value(){const e=this._source.properties().childs().position.value();return parseFloat(e.toFixed(2))}setValue(e){this._source.properties().childs().position.setValue(e),this._source.model().updateSource(this._source),this.listeners().fire(this),this._source.syncMultichartState({pricesChanged:!1,indexesChanged:!1})}}var c=i(75149);class h extends c.LineDataSourcePointIndexProperty{constructor(e,t){super(e,t),this._source=e}_setPointImpl(e){this._source.setPointAndChangeIndex(this._pointIndex,e)}}var d=i(68806),u=i(50151),p=i(85573),_=i(88348);class m extends n.LineDataSource{constructor(){super(...arguments),this._startMovingAnchorY=NaN}priceSource(){return this.ownerSource()}addPoint(e,t,i){return super.addPoint(this._updatePositionAndCorrectPoint(e),t,i)}setPoint(e,t,i){super.setPoint(e,this._updatePositionAndCorrectPoint(t,!this.isPhantom()&&!this._allowChangeAnchorHorizontally()),i),this._syncPosition()}setPointAndChangeIndex(e,t,i){super.setPoint(e,this._updatePositionAndCorrectPoint(t,!1),i),this._syncPosition()}startMoving(e,t,i,s){s||(this._startMovingAnchorY=(0,u.ensureNotNull)(this._anchorYCoordinate())),super.startMoving(e,t,i)}move(e,t,i,s){var r;const n=(0,u.ensureDefined)((0,u.ensureNotNull)(this.startMovingPoint()).logical),o=(0,u.ensureDefined)(e.logical);if(!s&&0===t){const e=this._points[0],t=o.index-n.index,i=(0,u.ensureNotNull)(this.priceScale()),s=(0,u.ensure)(null===(r=this.ownerSource())||void 0===r?void 0:r.firstValue()),a=i.priceToCoordinate(o.price,s)-i.priceToCoordinate(n.price,s),l=this._startMovingAnchorY+a,c=i.coordinateToPrice(l,s);this._updatePositionAndCorrectPoint({index:e.index+t,price:c})}super.move(e,t,i),s||this._syncPosition()}_allowChangeAnchorHorizontally(){return!1}_updatePositionAndCorrectPoint(e,t){t&&(e.index=this._points[0].index);const i=this.priceSource();if(null===i)return e;const s=i.priceScale(),r=i.firstValue();if(null===s||s.isEmpty()||null===r)return e;const n=s.height();let o=n/2,a=e.price>=s.coordinateToPrice(o,r)?1:-1;const l=this._model.mainSeries();if(i===l){const t=l.data().search(this._baseSeriesIndexForPoint(e));if(null!==t){const i=(0,p.seriesPrice)(l,t,-1),n=(0,p.seriesPrice)(l,t,1);a=e.price>=i?1:-1,o=s.priceToCoordinate(1===a?n:i,r),e.price=1===a?Math.max(n,e.price):e.price}}const c=1===(-1===a!==s.isInverted()?-1:1)?o:n-o,h=s.priceToCoordinate(e.price,r),d=Math.min(n,Math.abs(h-o)),u=Math.max(0,Math.min(100,100*d/c))*a;return this.properties().childs().position.setValue(u),e}_baseSeriesIndexForPoint(e){return e.index}_syncPosition(){const e=this.linkKey().value();if(null!==e){const t={ +position:this.properties().childs().position.value()};(0,_.changeLineStyle)({linkKey:e,state:t,model:this._model})}}_anchorYCoordinate(){const e=this.priceSource();if(null===e)return null;const t=e.priceScale(),i=e.firstValue();if(null===t||t.isEmpty()||null===i)return null;const s=this._model.mainSeries(),r=this.customEvent();if(null===r)return null;let n=null;if(e===s&&(n=(0,p.seriesBasePosition)(s,r)),null===n&&(n=(0,p.noDataBasePosition)(r,t,i)),null===n)return null;const o=r.position(),a=t.priceToCoordinate(n.price,i);return(0,p.positionToCoordinate)(o,t.height(),a,(0,p.positionVisualDirection)(o,t.isInverted()))}}class g extends m{constructor(e,t,s,r){super(e,null!=t?t:g.createProperties(),s,r),i.e(1583).then(i.bind(i,26294)).then((t=>{this._setPaneViews([new t.SignpostPaneView(this,e)])}))}pointsCount(){return 1}name(){return"Signpost"}customEvent(){return{index:()=>{var e,t;return null!==(t=null===(e=this.points()[0])||void 0===e?void 0:e.index)&&void 0!==t?t:null},position:()=>this.properties().childs().position.value()}}showInObjectTree(){return!this.isPhantom()&&super.showInObjectTree()}isPhantom(){return this._model.isPhantomLine(this)}clonePositionOffset(){return{barOffset:1,xCoordOffset:0,yCoordOffset:0}}template(){const e=super.template(),t=this.properties().childs();return e.text=t.text.value(),e.position=t.position.value(),e}shouldBeRemovedOnDeselect(){const e=this._properties.childs();if(e.showImage.value())return!1;return""===e.text.value().trim()}static createProperties(e){const t=new r.DefaultProperty("linetoolsignpost",e);return this._configureProperties(t),t.hasChild("text")||t.addChild("text",new(a())(s.t(null,void 0,i(37229)))),t.hasChild("position")||t.addChild("position",new(a())(50)),t.addExclusion("text"),t.addExclusion("position"),t.addChild("backgroundsColors",new d.LineToolColorsProperty([t.childs().plateColor])),t}_createPointProperty(e){super._createPointProperty(e);const t=this._pointsProperty.childs().points[e];t.removeProperty("price"),t.removeProperty("bar"),t.addChild("price",new l(this)),t.addChild("bar",new h(this,0))}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text),this.properties().childs().position.setValue(e.position)}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,18613)).then((e=>e.SignpostDefinitionsViewModel))}static _configureProperties(e){n.LineDataSource._configureProperties(e)}}g.supportPhantomMode=!0},94803:(e,t,i)=>{"use strict";i.d(t,{LineToolSineLine:()=>n});var s=i(46100),r=i(13087);class n extends r.LineDataSource{constructor(e,t,s,r){super(e,t||n.createProperties(),s,r),i.e(1583).then(i.bind(i,5362)).then((e=>{this._setPaneViews([new e.SineLinePaneView(this,this._model)])}))}pointsCount(){return 2}name(){return"Sine Line"}static createProperties(e){const t=new s.DefaultProperty("linetoolsineline",e);return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){ +return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,15673))).CyclicAndSineLinesPatternDefinitionsViewModel}}},95366:(e,t,i)=>{"use strict";i.d(t,{LineToolSticker:()=>o});var s=i(46100),r=i(8459);const n=(0,i(59224).getLogger)("Chart.LineToolSticker");class o extends r.LineToolSvgIconBase{constructor(e,t,i,s){super(e,t||o.createProperties(),i,s),this.version=1,this._loadViews()}name(){return"Sticker"}static createProperties(e){const t=new s.DefaultProperty("linetoolsticker",e);return o._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,85766))).LineDataSourceDefinitionsViewModel}async _loadViews(){const[{getSvgContentForSticker:e,getSvgRenderer:t},{StickerPaneView:s},{svgRenderer:r}]=await Promise.all([i.e(5598).then(i.bind(i,31235)),i.e(1583).then(i.bind(i,15378)),i.e(2616).then(i.bind(i,50765))]);if(!this._isDestroyed){const i=this._properties.childs().sticker.value();this._svgContent=e(i),this._onIconChanged.fire();const o=t(r,i);null===o&&n.logWarn(`Couldn't create svg renderer for sticker ${i}`),this._setPaneViews([new s(this,this._model,o)])}}}},4063:(e,t,i)=>{"use strict";i.d(t,{StudyLineDataSource:()=>C});var s=i(50151),r=i(1722),n=i(97034),o=i(13087),a=i(46100),l=i(42856),c=i(12442),h=i(33703),d=i(94739),u=i(75319),p=i(72007),_=i(76949),m=i(41249),g=i(77475),f=i(28558),v=i(13333),S=i(11877);class y extends S.StatusProviderBase{constructor(e){super(e.model().properties().childs().scalesProperties.childs().textColor),this._source=e}color(){return"#ff0000"}errorStatus(){const e=this._source.status();return e.type===v.StudyStatusType.Error?{error:this.sourceStatusText(),solutionId:(0,v.studyStatusSolutionId)(e),title:(0,v.studyStatusTitle)(e),studyFeature:(0,v.studyStatusFeature)(e)}:null}getSplitTitle(){return this._source.titleInParts()}text(){return this._source.translatedType()}sourceStatusText(){return(0,v.convertStudyStatusToString)(this._source.status(),!0)}}var b=i(91280),w=i(79055);class P extends w.StatusView{constructor(e){super(e.statusProvider({}))}getSplitTitle(){return this._statusProvider.getSplitTitle()}}class C extends o.LineDataSource{constructor(e,t,s,r,n,o){super(e,r,n,o),this._indexes=null,this._inputs=null,this._definitionsViewModel=null,this._pointsetPoints=null,this._loadedPlots=null,this._loadedGraphics=null,this._beingCreatedPaneView=null,this._anchorsPaneView=null,this._isLegendDisplayed=!1,this._alignerCache=null,Promise.all([i.e(1583).then(i.bind(i,99058)),i.e(1583).then(i.bind(i,44666))]).then((t=>{const{LineToolBeingCreatedPaneView:i}=t[0],{StudyLineDataSourceAnchorsPaneView:s}=t[1];this._beingCreatedPaneView=new i(this,e),this._anchorsPaneView=new s(this,this.model()),this._model.lightUpdate()})),this._metaInfo=t,this._dataSource=new d.StudyDataSource(e.chartApi(),e.mainSeries().seriesSource(),s,t),this._dataSource.dataCleared().subscribe(this,this._onDataCleared),this._dataSource.dataUpdated().subscribe(this,this._onDataUpdated), +this._dataSource.studyStatusChanged().subscribe(this,this._onStudyStatusChanged),this._statusProvider=new y(this),this._statusView=new P(this),this._showStudyArgumentsProperty=e.properties().childs().paneProperties.childs().legendProperties.childs().showStudyArguments}isDisplayedInLegend(){return this._isLegendDisplayed}titleInParts(){const e=[];if(this._showStudyArgumentsProperty.value()&&this._inputs)for(const t of this._metaInfo.inputs){if(!0===t.isHidden||"bool"===t.type)continue;const i=this._inputs[t.id];e.push(i.toString())}return[this.name(),e]}destroy(){this._dataSource.dataUpdated().unsubscribeAll(this),this._dataSource.dataCleared().unsubscribeAll(this),this._dataSource.studyStatusChanged().unsubscribeAll(this),this._dataSource.destroy(),null!==this._definitionsViewModel&&(this._definitionsViewModel.destroy(),this._definitionsViewModel=null),this._unsubscribeApplyInputsOnSeriesCompleted(),this._isDestroyed=!0,super.destroy()}stop(){super.stop(),this._isDestroyed||(this._dataSource.stop(),this.clearData())}start(){super.start(),this._isDestroyed||null===this._inputs||this._dataSource.start()}metaInfo(){return this._metaInfo}graphicsInfo(){return this._metaInfo.graphics}series(){return this._model.mainSeries()}translatedType(){return this._metaInfo.description}name(){return this._metaInfo.description}studyId(){return this._metaInfo.id}setPoint(e,t,i){super.setPoint(e,this._preparePoint(t,i))}move(e){}clearData(){this._clearAllDataExceptPointsetPoints(),this._pointsetPoints=null,this.updateAllViews((0,f.sourceChangeEvent)({sourceId:this.id(),clearData:!0})),super.clearData()}data(){return this.plots()}plots(){return this._loadedPlots||this._dataSource.plots()}graphics(){return this._loadedGraphics||this._dataSource.graphics()}valueAt(e,t){var i,s;return null!==(s=null===(i=this.ownerSource())||void 0===i?void 0:i.symbolSource().valueAt(e,t))&&void 0!==s?s:null}firstValue(){return this._model.mainSeries().firstValue()}state(e){const t=super.state(e);let i;this.metaInfo()instanceof l.StudyMetaInfo?i=this.metaInfo().state():(i=(0,r.clone)(this.metaInfo()),i.id=l.StudyMetaInfo.parseIdString(i.id+(i.version?"-"+i.version:"")).fullId);const s={...t,metaInfo:i};return e&&(s.data=this.plots().state(),s.nonseriesindexes=this._indexes,s.graphics=(0,c.saveStudyGraphics)(this.graphics(),null)),s}restoreData(e){var t;void 0!==e.data&&(this._loadedPlots=new n.PlotList((0,p.studyPlotFunctionMap)(this._metaInfo),p.studyEmptyPlotValuePredicate),this._loadedPlots.restoreState(e.data)),this._indexes=null!==(t=e.nonseriesindexes)&&void 0!==t?t:this._indexes,this._loadedGraphics=e.graphics?(0,c.loadStudyGraphics)(e.graphics):this._loadedGraphics}getPropertyDefinitionsViewModel(){return null===this._definitionsViewModel?this._getPropertyDefinitionsViewModelClass().then((e=>null===e||this._isDestroyed?null:(null===this._definitionsViewModel&&(this._definitionsViewModel=new e(this._model.undoModel(),this)),this._definitionsViewModel))):Promise.resolve(this._definitionsViewModel)}paneViews(e){let t=[] +;if(this.isSourceHidden())return t;if(this._isReady()&&this._changeStatesStack.isEmpty()){const i=super.paneViews(e);null!==i&&(t=t.concat(i))}else null!==this._beingCreatedPaneView&&t.push(this._beingCreatedPaneView);return null!==this._anchorsPaneView&&t.push(this._anchorsPaneView),t}propertiesChanged(e){super.propertiesChanged(e),this._onStudyInputsMayChange()}dataAndViewsReady(){return super.dataAndViewsReady()&&this._isReady()}endChanging(e,t){const i=super.endChanging(e,t);return i.indexesChanged?this.clearData():this._updateAnchorsPrice(!0),i}moveData(e){this._dataSource.moveData(e)}restorePoints(e,t,i){super.restorePoints(e,t,i),this._updateAnchorsPrice(!0)}realign(){super.realign(),null===this._model.mainSeries().symbolInfo()&&(this._alignerCache=null)}statusProvider(e){return this._statusProvider}statusView(){return this._statusView}legendView(){return null}dataProblemModel(){return null}dataUpdatedModeModel(){return null}marketStatusModel(){return null}onStatusChanged(){return this._dataSource.studyStatusChanged()}status(){return this._dataSource.studyStatus()}recalcStudyIfNeeded(){}static createPropertiesFromStudyMetaInfoAndState(e,t,i,s){const r=(0,_.prepareStudyPropertiesForLoadChart)(e,t,i,s);return this._configureProperties(r),r}_onStudyStatusChanged(e,t){let i;switch(t.type){case u.StudyStatusType.Error:i=!0;break;case u.StudyStatusType.Completed:i=!1;break;default:return}if(i===this._isLegendDisplayed)return;this._isLegendDisplayed=i;const s=this._model.paneForSource(this);if(s){const e=this._model.panes().indexOf(s),t=b.InvalidationMask.invalidateLegendWidgetLayout(e);this.model().invalidate(t)}}_studyId(){return this._dataSource.studyId()}_isReady(){return!0}_updateAllPaneViews(e){var t,i;super._updateAllPaneViews(e),null===(t=this._beingCreatedPaneView)||void 0===t||t.update(),null===(i=this._anchorsPaneView)||void 0===i||i.update(e)}_getPointTime(e,t){const i=e.index,s=this._model.timeScale().indexToTimePoint(i);if(null!==s)return s;if(t||void 0===e.time)return null;const r=this._model.mainSeries().symbolInfo();if(null===r)return null;let n=this._model.properties().childs().timezone.value();"exchange"===n&&(n=r.timezone);const o=(0,m.cal_to_utc)((0,m.get_timezone)(n),e.time);return this._getStartBarAligner()(o)/1e3}_updateAnchorsPrice(e){}_onPointsetUpdated(e){super._onPointsetUpdated(e),this._pointsetPoints=this._points.map((e=>({price:e.price,index:e.index,time:e.time}))),this._onStudyInputsMayChange()}_onDataCleared(){this.updateAllViews((0,f.sourceChangeEvent)({sourceId:this.id(),clearData:!0})),this._model.updateSource(this)}_onDataUpdated(e,t,i){var s;this._updateAnchorsPrice(),this.updateAllViews((0,f.sourceChangeEvent)({sourceId:this.id(),firstUpdatedTimePointIndex:null===(s=e[0])||void 0===s?void 0:s.index})),this._model.updateSource(this)}_onStudyInputsMayChange(){let e=null;if(null!==this._pointsetPoints&&this._pointsetPoints.length===this.pointsCount()&&(e=this._studyInputs(this._pointsetPoints),null===e&&(this._clearAllDataExceptPointsetPoints(),this.updateAllViews((0, +f.sourceChangeEvent)(this.id())))),null!==e){const t=this.metaInfo().inputs.map((e=>e.id)),i=Object.keys(e);for(const s of i)t.includes(s)||delete e[s]}this._areInputsEqual(this._inputs,e)||this._applyStudyInputs(e)}_preparePoint(e,t){return super._preparePoint(this._alignPointToRangeOfActualData(e),t)}_getPropertyDefinitionsViewModelClass(){return Promise.resolve(null)}_subscribeApplyInputsOnSeriesCompleted(){this._unsubscribeApplyInputsOnSeriesCompleted(),this._model.mainSeries().dataEvents().completed().subscribe(this,(()=>this._onStudyInputsMayChange()),!0)}_unsubscribeApplyInputsOnSeriesCompleted(){this._model.mainSeries().dataEvents().completed().unsubscribeAll(this)}_onInputsChanged(){0}static _createPropertiesFromStudyIdAndState(e,t){const i=l.StudyMetaInfo.getStudyPropertyRootNameById(e),s=new a.DefaultProperty(i,t);return this._configureProperties(s),s}static _configureProperties(e){super._configureProperties(e),e.removeExclusion("intervalsVisibilities")}_areInputsEqual(e,t){return null===t?null===e:null!==e&&(0,h.areStudyInputsEqual)(this._metaInfo.inputs,e,t)}_applyStudyInputs(e){const t=this._inputs;this._inputs=e,null!==e&&(this._unsubscribeApplyInputsOnSeriesCompleted(),this._dataSource.setInputs(e),null===t&&this.isStarted()&&!this._dataSource.isStarted()&&this._dataSource.start()),this._onInputsChanged()}_clearAllDataExceptPointsetPoints(){this._inputs=null,this._dataSource.clearData(),this._loadedPlots=null,this._indexes=null,this._loadedGraphics=null}_getStartBarAligner(){const e=this._model.mainSeries().interval();return null!==this._alignerCache&&this._alignerCache.resolution===this._model.mainSeries().interval()||(this._alignerCache={resolution:e,aligner:(0,g.createTimeToBarTimeAligner)(e,(0,s.ensureNotNull)(this._model.mainSeries().symbolInfo()))}),this._alignerCache.aligner}}},8459:(e,t,i)=>{"use strict";i.d(t,{LineToolSvgIconBase:()=>l});var s=i(50151),r=i(86441),n=i(25422),o=i(57898),a=i(13087);class l extends a.LineDataSource{constructor(e,t,i,s){super(e,t,i,s),this._onIconChanged=new o.Delegate,this._svgContent=null,this._changePointData=null,this._loadViews()}pointsCount(){return 1}hasEditableCoordinates(){return!1}getAnchorLimit(){return 80}getChangePointForSync(e){return null}startChanging(e,t){const i=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[0])),o=this.properties().childs(),a=o.size.value();let l;if(t)l=(0,s.ensureNotNull)(this.pointToScreenPoint(t));else{let e=new r.Point(0,Math.max(80,a)/2);const t=(0,n.rotationMatrix)(o.angle.value());e=(0,n.transformPoint)(t,e),l=i.add(e)}const c=i.subtract(l).length();this._changePointData={centerPoint:i,initialLength:c,initialSize:a},super.startChanging(e,t)}setPoint(e,t,i){const{centerPoint:r,initialLength:n,initialSize:o}=(0,s.ensureNotNull)(this._changePointData),a=(0,s.ensureNotNull)(this.pointToScreenPoint(t)),l=this.properties().childs();if(0===e||1===e){const t=a.subtract(r).normalized();let i=Math.acos(-t.x);Math.asin(t.y)>0&&(i=2*Math.PI-i),0===e&&(i+=Math.PI),l.angle.setValue(i)}else{const e=o*(r.subtract(a).length()/n) +;l.size.setValue(e)}}getSourceIcon(){const e=this.svgContent();return null===e?null:{type:"svgContent",content:e}}onSourceIconChanged(){return this._onIconChanged}svgContent(){return this._svgContent}static _configureProperties(e){super._configureProperties(e),e.addExclusion("angle")}}},79506:(e,t,i)=>{"use strict";i.d(t,{LineToolText:()=>u,LineToolTextAbsolute:()=>p});var s=i(50151),r=i(86441),n=i(44352),o=i(13087),a=i(59452),l=i.n(a),c=i(46100),h=i(68806),d=i(28558);class u extends o.LineDataSource{constructor(e,t,s,r){const n=t||u.createProperties();super(e,n,s,r),this._barSpacing=e.timeScale().barSpacing(),this._recalculatePointsOnCenter=!1,i.e(1583).then(i.bind(i,62912)).then((({TextPaneView:t})=>{const i=this._recalculatePointsOnCenter?(e,t)=>{this._recalculatePointsOnCenter&&this._recalculateCenterPosition(e,t)}:void 0;this._setPaneViews([new t(this,e,void 0,void 0,void 0,void 0,void 0,i)])}))}centerPosition(){this._recalculatePointsOnCenter=!0}setPoint(e,t,i){const r=this.properties().childs();let n;if(1===e&&r.wordWrapWidth.value()){const e=this.model().timeScale();n=this.isFixed()?(0,s.ensureDefined)(this.fixedPoint()).x:e.indexToCoordinate(this.points()[0].index);const i=e.indexToCoordinate(t.index)-n-~~(r.fontsize.value()/6);if(!isFinite(i))return;r.wordWrapWidth.setValue(Math.max(100,i))}}pointsCount(){return 1}name(){return"Text"}setPriceScale(e){super.setPriceScale(e),e&&e.priceRange()&&(this._priceDencity=e.height()/(0,s.ensureNotNull)(e.priceRange()).length(),this._isPriceDencityLog=e.isLog())}restoreSize(){const e=(0,s.ensureNotNull)(this.priceScale());this._barSpacing=this.model().timeScale().barSpacing(),this._priceDencity=e.height()/(0,s.ensureNotNull)(e.priceRange()).length(),this.redraw((0,d.sourceChangeEvent)(this.id()))}redraw(e){this.updateAllViews(e),this._model.updateSource(this)}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}state(e){const t=super.state(e);return e&&(t.state.fixedSize=!1),t}barSpacing(){return this._barSpacing}priceDencity(){return this._priceDencity}isPriceDencityLog(){return this._isPriceDencityLog}hasEditableCoordinates(){return!1}shouldBeRemovedOnDeselect(){return""===this._properties.childs().text.value().trim()}static createProperties(e){const t=new c.DefaultProperty("linetooltext",e);return this._configureProperties(t),t}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text)}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,94625)).then((e=>e.TextDefinitionsViewModel))}static _configureProperties(e){super._configureProperties(e),e.hasChild("text")||e.addChild("text",new(l())(n.t(null,void 0,i(37229)))),e.addChild("linesColors",new h.LineToolColorsProperty([e.childs().borderColor])),e.addChild("textsColors",new h.LineToolColorsProperty([e.childs().color])),e.addExclusion("text"),e.addExclusion("linesColors"),e.addExclusion("textsColors")}_recalculateCenterPosition(e,t){const i=this.isFixed()?(0, +s.ensureDefined)(this.fixedPoint()):(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[0])),n=new r.Point(i.x-e/2,i.y-t/2),o=(0,s.ensureNotNull)(this.screenPointToPoint(n));this.setPoints([o]),this.normalizePoints(),this.createServerPoints(),this.redraw((0,d.sourceChangeEvent)(this.id()))}}class p extends u{constructor(e,t){super(e,t||p.createProperties())}name(){return"Anchored Text"}hasEditableCoordinates(){return!1}isFixed(){return!0}static createProperties(e){const t=new c.DefaultProperty("linetooltextabsolute",e);return this._configureProperties(t),t}}},89299:(e,t,i)=>{"use strict";i.d(t,{LineToolThreeDrivers:()=>o});var s=i(46100),r=i(13087),n=i(68806);class o extends r.LineDataSource{constructor(e,t,s,r){const n=t||o.createProperties();super(e,n,s,r),i.e(1583).then(i.bind(i,90042)).then((t=>{this._setPaneViews([new t.LineToolThreeDrivesPaneView(this,e)])}))}pointsCount(){return 7}name(){return"Three Drives Pattern"}static createProperties(e){const t=new s.DefaultProperty("linetoolthreedrivers",e);return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,63311)).then((e=>e.PatternWithoutBackgroundDefinitionsViewModel))}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new n.LineToolColorsProperty([e.childs().color])),e.addChild("textsColors",new n.LineToolColorsProperty([e.childs().textcolor])),e.addChild("linesWidths",new n.LineToolWidthsProperty([e.childs().linewidth])),e.hasChild("backgroundsColors")&&e.removeProperty("backgroundsColors")}}},74861:(e,t,i)=>{"use strict";i.d(t,{LineToolTimeCycles:()=>o});var s=i(27788),r=i(46100),n=i(13087);class o extends n.LineDataSource{constructor(e,t,s,r){super(e,null!=t?t:o.createProperties(),s,r),i.e(1583).then(i.bind(i,65557)).then((e=>{this._setPaneViews([new e.TimeCyclesPaneView(this,this._model)])}))}pointsCount(){return 2}name(){return"Time Cycles"}setPoint(e,t){const i=(0,s.default)(t),r=this._points[0],n=this._points[1];r.price=i.price,n.price=i.price,this._points[e]=i,this.normalizePoints()}addPoint(e,t,i){const s=super.addPoint(e,t,!0);if(s){const e=this._points[0];this._points[1].price=e.price,i||(this.normalizePoints(),this.createServerPoints())}return s}static createProperties(e){const t=new r.DefaultProperty("linetooltimecycles",e);return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,81888))).TimeCyclesPatternDefinitionsViewModel}}},87564:(e,t,i)=>{"use strict";const s=i(13087).LineDataSource,r=i(83654).alignToStep;class n extends s{constructor(e,t){super(e,t),this.customization.forcePriceAxisLabel=!0,this.customization.disableErasing=!0,this.customization.showInObjectsTree=!1,this.setSelectionEnabled(!1)}isSynchronizable(){return!1}pointsCount(){return n.POINTS_COUNT}hasContextMenu(){return!1}state(){return null}startMoving(){super.startMoving.apply(this,arguments),this._cursorMoved=!1} +endMoving(){super.endMoving.apply(this,arguments),this._cursorMoved=!1}_correctPoints(e,t){this._currentMovingPoint&&this._startMovingPoint?this._currentMovingPoint.logical.price-this._startMovingPoint.logical.price&&(this._cursorMoved=!0):this._cursorMoved=!1;for(var i=1/this.priceScale().mainSource().base(),s=0;s{"use strict";i.d(t,{LineToolTrendAngle:()=>d});var s=i(86441),r=i(50151),n=i(46100),o=i(13087),a=i(59452),l=i.n(a),c=i(28558);class h extends(l()){constructor(e){super(),this._lineSource=e}value(){return Math.round(180*this._lineSource.angle()/Math.PI)}setValue(e){const t=e*Math.PI/180,i=(0,r.ensureNotNull)(this._lineSource.pointToScreenPoint(this._lineSource.points()[0])),n=Math.cos(t),o=-Math.sin(t),a=new s.Point(n,o),l=i.addScaled(a,this._lineSource.distance()),h=(0,r.ensureNotNull)(this._lineSource.screenPointToPoint(l));this._lineSource.setPoint(1,h);const d=this._lineSource.model();d.updateSource(this._lineSource),this._lineSource.updateAllViews((0,c.sourceChangeEvent)(this._lineSource.id())),d.updateSource(this._lineSource)}notifyChanged(){this._listeners.fire(this)}}class d extends o.LineDataSource{constructor(e,t,s,r){const n=t||d.createProperties();super(e,n,s,r),this._angle=0,this._distance=0,n.addChild("angle",new h(this)),i.e(1583).then(i.bind(i,67998)).then((({TrendAnglePaneView:t})=>{const i=[new t(this,e)];this._setPaneViews(i)}))}isSynchronizable(){return!1}pointsCount(){return 2}name(){return"Trend Angle"}angle(){return this._angle}distance(){return this._distance}addPoint(e,t){const i=super.addPoint(e,t);return i&&this._calculateAngle(),i}setLastPoint(e,t){const i=super.setLastPoint(e,t);return this.points().length>1&&this._calculateAngle(),i}axisPoints(){if(this.points().length<2)return[];const e=[this.points()[0]],t=(0,r.ensureNotNull)(this.pointToScreenPoint(this.points()[0])),i=Math.cos(this._angle)*this._distance,n=-Math.sin(this._angle)*this._distance,o=t.add(new s.Point(i,n)),a=(0,r.ensureNotNull)(this.screenPointToPoint(o));return e.push(a),e}timeAxisPoints(){return this.axisPoints()}priceAxisPoints(){return this.axisPoints()}setPoint(e,t,i){super.setPoint(e,t,i),this.points().length>1&&1===e&&this._calculateAngle()}restoreData(e){var t,i;this._angle=null!==(t=e.angle)&&void 0!==t?t:0,this._distance=null!==(i=e.distance)&&void 0!==i?i:0}state(e){const t=super.state(e);return t.angle=this._angle,t.distance=this._distance,t}cloneData(e){this._angle=e.angle(),this._distance=e.distance()}canHasAlert(){return!0}static createProperties(e){e&&void 0===e.showPercentPriceRange&&(e.showPercentPriceRange=e.showPriceRange, +e.showPipsPriceRange=e.showPriceRange);const t=new n.DefaultProperty("linetooltrendangle",e);return this._configureProperties(t),t}_snapTo45DegreesAvailable(){return!0}_getAlertPlots(){const e=this._linePointsToAlertPlot(this._points,null,this._properties.childs().extendLeft.value(),this._properties.childs().extendRight.value());return null===e?[]:[e]}_calculateAngle(){const e=(0,r.ensureNotNull)(this.pointToScreenPoint(this.points()[0]));let t=(0,r.ensureNotNull)(this.pointToScreenPoint(this.points()[1])).subtract(e);const i=t.length();i>0?(t=t.normalized(),this._angle=Math.acos(t.x),t.y>0&&(this._angle=-this._angle),this._distance=i):this._angle=0;this.properties().childs().angle.notifyChanged()}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,34935)).then((e=>e.TrendAngleDefinitionsViewModel))}}},84123:(e,t,i)=>{"use strict";i.d(t,{LineToolTrendBasedFibExtension:()=>c});var s=i(44352),r=i(36298),n=i(53801),o=i(68806),a=i(13087);const l=new r.TranslatedString("erase level line",s.t(null,void 0,i(12962)));class c extends a.LineDataSource{constructor(e,t,s,r){super(e,t||c.createProperties(),s,r),this.version=2,i.e(1583).then(i.bind(i,38058)).then((({TrendBasedFibExtensionPaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}levelsCount(){return 24}pointsCount(){return 3}name(){return"Trend-Based Fib Extension"}migrateVersion(e,t){1===e&&this.properties().childs().extendLines.setValue(!0)}processErase(e,t){const i="level"+t,s=this.properties().childs()[i].childs().visible;e.setProperty(s,!1,l)}fibLevelsBasedOnLogScale(){var e;return this.properties().childs().fibLevelsBasedOnLogScale.value()&&Boolean(null===(e=this.priceScale())||void 0===e?void 0:e.isLog())}static createProperties(e){const t=new n.LevelsProperty("linetooltrendbasedfibextension",e,!1,{range:[0,8]});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,56194))).FibDrawingsWith24LevelsDefinitionsViewModel}static _configureProperties(e){const t=e.childs();super._configureProperties(e);const i=[t.trendline.childs().color];for(let e=1;e<=24;e++){const s=t["level"+e].childs().color;i.push(s)}e.addChild("linesColors",new o.LineToolColorsProperty(i));const s=[t.trendline.childs().linewidth,t.levelsStyle.childs().linewidth];e.addChild("linesWidths",new o.LineToolWidthsProperty(s))}}},35625:(e,t,i)=>{"use strict";i.d(t,{LineToolTrendBasedFibTime:()=>c});var s=i(44352),r=i(36298),n=i(13087),o=i(53801),a=i(68806);const l=new r.TranslatedString("erase level line",s.t(null,void 0,i(12962)));class c extends n.LineDataSource{constructor(e,t,s,r){super(e,t||c.createProperties(),s,r),this.version=1,i.e(1583).then(i.bind(i,33482)).then((({TrendBasedFibTimePaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}levelsCount(){return 11}pointsCount(){return 3}name(){return"Trend-Based Fib Time"}processErase(e,t){ +const i="level"+t,s=this.properties().childs()[i].childs().visible;e.setProperty(s,!1,l)}static createProperties(e){const t=new o.LevelsProperty("linetooltrendbasedfibtime",e,!1,{range:[1,11]});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,60007))).TrendBasedFibTimeDefinitionsViewModel}static _configureProperties(e){super._configureProperties(e);const t=e.childs(),i=[t.trendline.childs().linewidth],s=[t.trendline.childs().color];for(let e=1;e<=11;e++)i.push(t["level"+e].childs().linewidth),s.push(t["level"+e].childs().color);e.addChild("linesColors",new a.LineToolColorsProperty(s)),e.addChild("linesWidths",new a.LineToolWidthsProperty(i))}}},47246:(e,t,i)=>{"use strict";i.d(t,{LineToolTrendLine:()=>l});var s=i(46100),r=i(13087),n=i(71243),o=i(59452),a=i.n(o);class l extends r.LineDataSource{constructor(e,t,s,r){super(e,t||l.createProperties(),s,r),this._trendLinePaneView=null,i.e(1583).then(i.bind(i,96310)).then((({TrendLinePaneView:e})=>{this._trendLinePaneView=new e(this,this._model),this._setPaneViews([this._trendLinePaneView])}))}dataAndViewsReady(){return super.dataAndViewsReady()&&null!==this._trendLinePaneView&&this._trendLinePaneView.iconsReady()}pointsCount(){return 2}name(){return"Trend Line"}canHasAlert(){return!0}showPriceLabels(){return this._properties.childs().showPriceLabels.value()}createPriceAxisView(e){return new n.LineToolPriceAxisView(this,{pointIndex:e,backgroundPropertyGetter:()=>this.showPriceLabels()?this._properties.childs().linecolor.value():null})}isForcedDrawPriceAxisLabel(){return this.showPriceLabels()}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}static createProperties(e,t){e&&void 0===e.showPercentPriceRange&&(e.showPercentPriceRange=e.showPriceRange,e.showPipsPriceRange=e.showPriceRange);const i=new s.DefaultProperty(null!=t?t:"linetooltrendline",e);return this._configureProperties(i),i}_getAlertPlots(){const e=this._linePointsToAlertPlot(this._points,null,this._properties.childs().extendLeft.value(),this._properties.childs().extendRight.value());return null===e?[]:[e]}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,84926))).TrendLineDefinitionsViewModel}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text||"")}_snapTo45DegreesAvailable(){return!0}static _configureProperties(e){super._configureProperties(e),e.hasChild("text")||e.addChild("text",new(a())("")),e.addExclusion("text")}}},45579:(e,t,i)=>{"use strict";i.d(t,{LineToolTrianglePattern:()=>o});var s=i(46100),r=i(13087),n=i(68806);class o extends r.LineDataSource{constructor(e,t,s,r){const n=t||o.createProperties();super(e,n,s,r),i.e(1583).then(i.bind(i,23545)).then((t=>{this._setPaneViews([new t.LineToolTrianglePatternPaneView(this,e)])}))}pointsCount(){return 4}name(){return"Triangle Pattern"}static createProperties(e){ +const t=new s.DefaultProperty("linetooltrianglepattern",e);return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,25107)).then((e=>e.PatternWithBackgroundDefinitionViewModel))}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new n.LineToolColorsProperty([e.childs().color])),e.addChild("textsColors",new n.LineToolColorsProperty([e.childs().textcolor])),e.addChild("backgroundsColors",new n.LineToolColorsProperty([e.childs().backgroundColor]))}}},38416:(e,t,i)=>{"use strict";var s=i(13087).LineDataSource,r=i(46100).DefaultProperty,n=i(68806).LineToolColorsProperty;class o extends s{constructor(e,t,s,r){super(e,t||o.createProperties(),s,r),i.e(1583).then(i.t.bind(i,97615,19)).then((({TrianglePaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}pointsCount(){return 3}name(){return"Triangle"}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,20061))).GeneralFiguresDefinitionsViewModel}static createProperties(e){var t=new r("linetooltriangle",e);return this._configureProperties(t),t}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new n([e.childs().color]))}}t.LineToolTriangle=o},26642:(e,t,i)=>{"use strict";i.d(t,{LineToolVertLineTimeAxisView:()=>r});var s=i(95977);class r extends s.LineDataSourceTimeAxisView{constructor(e){super(e,0)}_getBgColor(){return this._source.properties().linecolor.value()}_getAlwaysInViewPort(){return!1}_getIndex(){const e=this._source.points();return 0===e.length?null:e[0].index}}},54623:(e,t,i)=>{"use strict";i.d(t,{LineToolVertLine:()=>h});var s=i(50151),r=i(86441),n=i(46100),o=i(59452),a=i.n(o),l=i(13087),c=i(26642);class h extends l.LineDataSource{constructor(e,t,s,r){const n=t||h.createProperties();super(e,n,s,r),this._timeAxisView=new c.LineToolVertLineTimeAxisView(this),this._paneViewFactory=null,this.properties().childs().extendLine.subscribe(this,(()=>e.lightUpdate())),i.e(1583).then(i.bind(i,77444)).then((t=>{this._paneViewFactory=i=>new t.VertLinePaneView(this,e,i),this._model.lightUpdate()}))}destroy(){this.properties().childs().extendLine.unsubscribeAll(this),super.destroy()}pointsCount(){return 1}name(){return"Vertical Line"}timeAxisViews(){return this.isSourceHidden()?null:this.properties().childs().showTime.value()?[this._timeAxisView]:null}updateAllViews(e){super.updateAllViews(e),this._timeAxisView.update(e)}canHasAlert(){return!0}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}isMultiPaneAvailable(){return!0}isMultiPaneEnabled(){return this.properties().childs().extendLine.value()}paneViews(e){return e=(0,s.ensureDefined)(e),this.isMultiPaneEnabled()||this._model.paneForSource(this)===e?(null===this._getPaneViews(e)&&null!==this._paneViewFactory&&this._setPaneViews([this._paneViewFactory(e)],e,!0),super.paneViews(e)):null}priceAxisViews(){return null} +priceAxisPoints(){return[]}pointToScreenPoint(e){const t=this._model.timeScale();if(t.isEmpty())return null;const i=t.indexToCoordinate(e.index);return new r.Point(i,0)}convertYCoordinateToPriceForMoving(e){return 0}static createProperties(e){null!=e&&(void 0===e.textOrientation&&(e.textOrientation="horizontal"),void 0===e.extendLine&&(e.extendLine=!1));const t=new n.DefaultProperty("linetoolvertline",e);return this._configureProperties(t),t}_getAlertPlots(){const e=this._points[0],t={index:e.index,price:e.price+1},i=this._linePointsToAlertPlot([e,t],null,!0,!0);return null===i?[]:[i]}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(7201),i.e(3753),i.e(5871),i.e(8167),i.e(8537)]).then(i.bind(i,71472)).then((e=>e.VerticalLineDefinitionsViewModel))}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text||"")}static _configureProperties(e){super._configureProperties(e),e.hasChild("text")||e.addChild("text",new(a())("")),e.addExclusion("text")}}},58229:(e,t,i)=>{"use strict";i.d(t,{LineToolVbPFixed:()=>f});var s=i(77973),r=i(50151),n=i(70826),o=i(42856),a=i(4063),l=i(12442),c=i(39871),h=i(28558),d=i(1722),u=i(46100),p=i(76949);const _=(0,n.studyIdString)("VbPFixed","tv-volumebyprice");function m(e,t,i,s){return t.styles&&(g(t.styles.developingPoc),g(t.styles.developingVAHigh),g(t.styles.developingVALow)),t}function g(e){void 0!==e&&void 0!==e.visible&&(e.display=e.visible?15:0,delete e.visible)}class f extends a.StudyLineDataSource{constructor(e,t,i,s,r){const n=i||e.studyMetaInfoRepository().findByIdSync({type:"java",studyId:_});super(e,n,"vbpfixed_",null!=t?t:f.createProperties(e),s,r),this._createPaneViews().then((e=>{this._setPaneViews(e),e.forEach((e=>e.update((0,h.sourceChangeEvent)({sourceId:this.id(),clearData:!0}))))})),this.clearData()}pointsCount(){return 2}boundToSymbol(){return!1}offset(e){return 0}getMinFirstBarIndexForPlot(){return-1/0}calcIsActualSymbol(){this._isActualSymbol=!0,this._isActualCurrency=!0,this._isActualUnit=!0,this.calcIsActualInterval()}cloneable(){return!1}isSynchronizable(){return!1}isPlotVisibleAt(e,t){return(this.properties().childs().styles.childs()[e].childs().display.value()&t)===t}preferredZOrder(){return 0}static createProperties(e,t){const i=o.StudyMetaInfo.getStudyPropertyRootNameById(_),s=(0,r.ensureNotNull)(e.studyMetaInfoRepository().findByIdSync({type:"java",studyId:_})),n=(0,u.createDefaultsState)(!0,i,[],e.studyVersioning());return this.createPropertiesFromStudyMetaInfoAndState(s,s,(0,d.merge)((0,d.clone)(n),null!=t?t:{}),e.studyVersioning())}static createPropertiesFromStudyMetaInfoAndState(e,t,i,s){const r=(0,p.prepareStudyPropertiesForLoadChart)(e,t,i,s,m);return this._configureProperties(r),r}static studyId(){return _}_studyInputs(e){(0,r.assert)(2===e.length,"all the line tool points should be defined");const[t,i]=e,s=Math.max(t.index,i.index),n=this._model.mainSeries().bars().lastIndex(),o=this._getPointTime(t.index<=i.index?t:i,!0),a=this._getPointTime(i.index>=t.index?i:t,!0) +;if(null===o||null===a)return this._subscribeApplyInputsOnSeriesCompleted(),null;return{...this.properties().childs().inputs.state(),first_bar_time:1e3*o,last_bar_time:1e3*a,subscribeRealtime:n===s,mapRightBoundaryToBarStartTime:!!this._needExtendToBarsEnding()||void 0}}_isReady(){return!(0,l.isStudyGraphicsEmpty)(this.graphics())}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(7201),i.e(6196),i.e(5871),i.e(3986),i.e(8167),i.e(607)]).then(i.bind(i,56059))).StudyLineDataSourceDefinitionsViewModel}_onDataUpdated(){this._updateAnchors(),this.updateAllViews((0,h.sourceChangeEvent)(this.id())),this._model.updateSource(this)}_updateAnchors(){const e=this._calculateAnchors();if(!e)return;const[{index:t,price:i},{index:s,price:r}]=e;if(this._timePoint.length&&(this._timePoint[0].price=i,this._timePoint[1].price=r),this._points.length){const e=this.model().timeScale(),n=e.indexToTimePoint(t),o=e.indexToTimePoint(t);this._points[0]={index:t,price:i,time:(0,d.isNumber)(n)?new Date(1e3*n):void 0},this._points[1]={index:s,price:r,time:(0,d.isNumber)(o)?new Date(1e3*o):void 0}}}_calculateAnchors(){let e=null,t=null,i=null,r=null;if(this.graphics().hhists().forEach((s=>{s.forEach((s=>{const{priceLow:n,priceHigh:o,firstBarTime:a,lastBarTime:l}=s;(!e||nt)&&(t=o),(!i||ar)&&(r=l)}))})),!((0,s.default)(e)||(0,s.default)(t)||(0,s.default)(r)||(0,s.default)(i)))return[{price:t,index:i},{price:e,index:r}]}_updateAnchorsPrice(){const e=this._calculateAnchors();if(!e)return;const[{price:t},{price:i}]=e;this._timePoint.length&&(this._timePoint[0].price=t,this._timePoint[1].price=i),this._points.length&&(this._points[0].price=t,this._points[1].price=i)}async _createPaneViews(){var e;const t=this._metaInfo,s=t.graphics,r=[],n=this._needExtendToBarsEnding();if(s.hhists){const{HHistPaneView:t}=await i.e(507).then(i.bind(i,21335)),s=null===(e=this.properties().childs().graphics.childs().polygons)||void 0===e?void 0:e.childs();r.push(new t(this,this._model,void 0,null==s?void 0:s.histBoxBg,n))}if(s.horizlines){const{HorizLinePaneView:e}=await i.e(507).then(i.bind(i,13369));r.push(new e(this,this._model,void 0,n))}return t.plots.length>0&&r.push(this._createStudyPlotPaneView(t.plots[0].id,n)),t.plots.length>1&&r.push(this._createStudyPlotPaneView(t.plots[1].id,n)),t.plots.length>2&&r.push(this._createStudyPlotPaneView(t.plots[2].id,n)),r}_createStudyPlotPaneView(e,t){return new c.StudyPlotPaneView(this,this._model.mainSeries(),this._model,e,t)}_needExtendToBarsEnding(){var e;return void 0!==(null===(e=this.metaInfo().defaults.inputs)||void 0===e?void 0:e.mapRightBoundaryToBarStartTime)}}},36147:(e,t,i)=>{"use strict";var s;i.d(t,{MagnetMode:()=>s}),function(e){e[e.WeakMagnet=0]="WeakMagnet",e[e.StrongMagnet=1]="StrongMagnet"}(s||(s={}))},18540:(e,t,i)=>{"use strict";i.d(t,{magnetEnabled:()=>_,magnetMode:()=>m,setIsMagnetEnabled:()=>g,setMagnetMode:()=>f});var s=i(46100),r=i(97145),n=i(36147),o=i(88348),a=i(15367),l=i(28571) +;const c=new r.WatchedValue(!1),h=new r.WatchedValue(n.MagnetMode.WeakMagnet),d=(0,l.modifierPressed)(),u=(0,l.shiftPressed)();function p(){const e=d.value();if(u.value()&&(o.isToolEditingNow.value()||o.isToolCreatingNow.value()))return void c.setValue(!1);let t,i;if(o.activePointSelectionMode.value()===o.SelectPointMode.Replay)t=i=!1;else{const s=o.tool.value(),r=o.isStudyEditingNow.value()||o.activePointSelectionMode.value()===o.SelectPointMode.Study;t=e&&((0,a.isLineToolName)(s)||o.isToolEditingNow.value()||(0,o.toolIsMeasure)(s)||r),i=(0,o.properties)().childs().magnet.value()}h.setValue(!i&&t?n.MagnetMode.StrongMagnet:(0,o.properties)().childs().magnetMode.value()),c.setValue(t?!i:i)}function _(){return c}function m(){return h}function g(e){(0,s.saveDefaultProperties)(!0),(0,o.properties)().childs().magnet.setValue(e),(0,s.saveDefaultProperties)(!1)}function f(e){(0,s.saveDefaultProperties)(!0),(0,o.properties)().childs().magnetMode.setValue(e),(0,o.properties)().childs().magnet.setValue(!0),(0,s.saveDefaultProperties)(!1)}(0,o.runOnDrawingStateReady)((()=>{(0,o.properties)().childs().magnet.subscribe(null,p),(0,o.properties)().childs().magnetMode.subscribe(null,p),d.subscribe(p),u.subscribe(p),o.tool.subscribe(p),o.isToolEditingNow.subscribe(p),p()}))},90565:(e,t,i)=>{"use strict";i.d(t,{MainSeriesScaleRatioProperty:()=>n});var s=i(57898),r=i(19782);class n{constructor(e){this._changed=new s.Delegate,this._model=e}destroy(){this._changed.destroy()}getStepChangeValue(){return.1}getMinValue(){return 1e-7}getMaxValue(){return 99999999}value(){return this._model.mainSeriesScaleRatio()}setValue(e,t){(e!==this.value()||t)&&(this._model.setMainSeriesScaleRatio(e),this._onChanged())}state(){return null}clone(){return new n(this._model)}listeners(){return this._changed}subscribe(e,t){this._changed.subscribe(e,t)}unsubscribe(e,t){this._changed.unsubscribe(e,t)}unsubscribeAll(e){this._changed.unsubscribeAll(e)}storeStateIfUndefined(){return!0}weakReference(){return(0,r.weakReference)(this)}ownership(){return(0,r.ownership)(this)}_onChanged(){this._changed.fire(this)}}},28558:(e,t,i)=>{"use strict";i.r(t),i.d(t,{globalChangeEvent:()=>o,selectionChangeEvent:()=>h,sourceChangeEvent:()=>r,viewportChangeEvent:()=>l});var s=i(27147);function r(e){return(0,s.default)(e)?{type:"data-source-change",sourceId:e}:{type:"data-source-change",...e}}const n={type:"global-change"};function o(){return n}const a={type:"viewport-change"};function l(){return a}const c={type:"selection-change"};function h(){return c}},1115:(e,t,i)=>{"use strict";i.d(t,{ensureTimePointIndexIndex:()=>n,unpackNonSeriesData:()=>o});var s=i(30551),r=i(50151);function n(e){if(e<0)throw new Error("TimePointIndexIndex should be non-negative integer");return e}async function o(e){if(""===e)return null;const t=JSON.parse(e);if(!(0,s.isObject)(t)||"function"==typeof t)throw new Error("Non-object content in the non-series envelope");if((0,s.hasProperty)(t,"indexes_replace"))return{indexes_replace:!0};const i={indexes_replace:!1};if((0, +s.hasProperty)(t,"offsets")&&(i.offsets=t.offsets),(0,s.hasProperty)(t,"isUpdate")){if("boolean"!=typeof t.isUpdate)throw new Error('Invalid type of "isUpdate" field');i.isUpdate=t.isUpdate}return(0,s.hasProperty)(t,"data")&&(i.data=t.data),(0,s.hasProperty)(t,"graphicsCmds")&&(i.graphicsCmds=function(e){if(!(0,s.isObject)(e))throw new Error("Graphics commands should be wrapped in an object");if((0,s.hasProperty)(e,"create"),(0,s.hasProperty)(e,"erase")){const t=e.erase;(0,r.assert)(Array.isArray(t),"Collection of erase commands should be array");for(const e of t){if(!(0,s.isObject)(e)||!(0,s.hasProperty)(e,"action"))throw new Error("Command should be an object with 'action' property");(0,r.assert)("all"===e.action||"one"===e.action,"Erase command action should be 'all' or 'one'")}}return e}(t.graphicsCmds)),i}},88546:(e,t,i)=>{"use strict";i.d(t,{notAvailable:()=>r});var s=i(44352);const r=i(14483).enabled("use_na_string_for_not_available_values")?s.t(null,void 0,i(16542)):"∅"},66103:(e,t,i)=>{"use strict";var s;i.d(t,{PaneCursorType:()=>s}),function(e){e[e.Default=0]="Default",e[e.Pointer=1]="Pointer",e[e.Eraser=2]="Eraser",e[e.Dot=3]="Dot",e[e.Grabbing=4]="Grabbing",e[e.ZoomIn=5]="ZoomIn",e[e.VerticalResize=6]="VerticalResize",e[e.HorizontalResize=7]="HorizontalResize",e[e.DiagonalNeSwResize=8]="DiagonalNeSwResize",e[e.DiagonalNwSeResize=9]="DiagonalNwSeResize"}(s||(s={}))},43493:(e,t,i)=>{"use strict";i.d(t,{PanePriceAxisView:()=>n});var s=i(34565);class r{constructor(e){this._priceAxisViewRenderer=null,this._rendererOptions=null,this._align="right",this._width=0,this._height=0,this._textWidthCache=e}setParams(e,t,i,s,r){this._priceAxisViewRenderer=e,this._rendererOptions=t,this._width=i,this._height=s,this._align=r}draw(e,t){null!==this._rendererOptions&&null!==this._priceAxisViewRenderer&&this._priceAxisViewRenderer.draw(e,this._rendererOptions,this._textWidthCache,this._width,this._height,this._align,t.pixelRatio)}hitTest(e){var t,i;return void 0===(null===(t=this._priceAxisViewRenderer)||void 0===t?void 0:t.hitTest)?null:null===(i=this._priceAxisViewRenderer)||void 0===i?void 0:i.hitTest(e,this._width,this._align)}}class n{constructor(e,t,i){this._renderer=null,this._invalidated=!0,this._priceAxisView=e,this._textWidthCache=new s.TextWidthCache(100),this._dataSource=t,this._chartModel=i,this._fontSize=-1,this._panePriceAxisViewRenderer=new r(this._textWidthCache)}update(e){this._invalidated=!0}renderer(e,t){return this._invalidated&&this._updateImpl(e,t),this._renderer}_position(){const e=this._chartModel.crossHairSource(),t=this._dataSource===e?e.pane:this._chartModel.paneForSource(this._dataSource);if(null===t)return null;const i=this._priceScale();if(null===i)return null;let s=t.priceScalePosition(i);return"overlay"===s&&(s=t.priceScalePosition(t.defaultPriceScale())),"overlay"===s?null:s}_updateImpl(e,t){this._renderer=null;const i=this._position();if(null===i)return;const s=this._chartModel.priceAxisRendererOptions();s.fontSize!==this._fontSize&&(this._fontSize=s.fontSize,this._textWidthCache.reset()), +this._panePriceAxisViewRenderer.setParams(this._priceAxisView.paneRenderer(),s,t,e,i),this._renderer=this._panePriceAxisViewRenderer,this._invalidated=!1}_priceScale(){return this._dataSource.priceScale()}}},82386:(e,t,i)=>{"use strict";i.d(t,{AreaBackgroundItem:()=>a,AreaBackgroundItemsGroup:()=>n,AreaBackgroundRenderer:()=>l,CachedMap:()=>o});var s=i(59590),r=i(77173);class n extends r.CachedContainer{constructor(e){super(),this.color=e}}class o{constructor(){this._map=new Map,this._usedKeys=new Set,this._invalidations=0}invalidateCache(){this._invalidations+=1,50===this._invalidations&&(this._deleteUnused(),this._invalidations=0),this._usedKeys.clear(),this._map.forEach(((e,t)=>e.invalidateCache()))}get(e){const t=this._map.get(e);return void 0!==t&&this._usedKeys.add(e),t}set(e,t){this._usedKeys.add(e),this._map.set(e,t)}forEach(e){this._map.forEach(((t,i)=>{this._usedKeys.has(i)&&e(t,i)}))}delete(e){const t=this._map.get(e);void 0!==t&&t.invalidateCache(),this._usedKeys.delete(e)}_deleteUnused(){const e=[];this._map.forEach(((t,i)=>{this._usedKeys.has(i)||e.push(i)}));for(const t of e)this._map.delete(t)}}class a extends r.CachedContainer{constructor(){super(),this.points1=new r.CachedContainer,this.points2=new r.CachedContainer,this.push(this.points1),this.push(this.points2)}addPoints1Point(e,t){let i=this.points1.newItem();null!==i?(i.x=e,i.y=t):i={x:e,y:t},this.points1.push(i)}addPoints2Point(e,t){let i=this.points2.newItem();null!==i?(i.x=e,i.y=t):i={x:e,y:t},this.points2.push(i)}invalidateCache(){this.points1.invalidateCache(),this.points2.invalidateCache()}}class l extends s.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=null,this._data=null!=e?e:null}setData(e){this._data=e}hitTest(e,t){return null}_drawImpl(e){if(null===this._data)return;const{context:t,horizontalPixelRatio:i,verticalPixelRatio:s}=e,r=.25*this._data.barSpacing;this._data.colorAreas.forEach((e=>{var n,o;t.beginPath();for(let n=0;n=0;e--)t.lineTo(Math.round(o.points2.at(e).x*i),o.points2.at(e).y*s)}else{const e=o.points2.at(0).x,n=o.points2.at(0).y;t.lineTo(Math.round((a+r)*i),l*s),t.lineTo(Math.round((e+r)*i),n*s),t.lineTo(Math.round((e-r)*i),n*s),t.lineTo(Math.round((a-r)*i),l*s)}}if(t.closePath(),0===e.color.type)t.fillStyle=e.color.color;else{const i=t.createLinearGradient(0,e.color.value1*s,0,e.color.value2*s);i.addColorStop(0,null!==(n=e.color.color1)&&void 0!==n?n:"transparent"),i.addColorStop(1,null!==(o=e.color.color2)&&void 0!==o?o:"transparent"),t.fillStyle=i}t.fill()}))}}},62885:(e,t,i)=>{"use strict";i.d(t,{PaneRendererArea:()=>a});var s=i(50151),r=i(1149),n=i(45197),o=i(68441);class a extends r.PaneRendererLine{constructor(e){e.forceLineColor=!1,super(e)} +_drawImpl(e){var t,i,r,a,l;const c=this._data;if(0===c.items.length)return;let h=null!==(i=null===(t=this._data.visibleItemsRange)||void 0===t?void 0:t.startItemIndex)&&void 0!==i?i:0,d=(null!==(a=null===(r=this._data.visibleItemsRange)||void 0===r?void 0:r.endItemIndex)&&void 0!==a?a:this._data.items.length)-1;for(;h=0&&!(0,n.coordinateIsValid)(c.items[d].y);)d--;if(h>d)return;const{context:u,horizontalPixelRatio:p,verticalPixelRatio:_}=e;u.save(),u.scale(p,_),u.lineCap="round",u.strokeStyle=c.lineColor,u.lineWidth=c.lineWidth,(0,o.setLineStyle)(u,c.lineStyle),u.lineWidth=1;const m={},g=c.items;for(let e=h;e<=d;e++){const t=g[e];let i;if(i=t.style?t.style.color:c.lineColor,e{"use strict";i.d(t,{BitmapCoordinatesPaneRenderer:()=>r});var s=i(27714);class r{draw(e,t){new s.CanvasRenderingTarget2D(e,(0,s.size)({width:t.cssWidth,height:t.cssHeight}),(0,s.size)({width:t.physicalWidth,height:t.physicalHeight})).useBitmapCoordinateSpace((e=>this._drawImpl(e)))}drawBackground(e,t){new s.CanvasRenderingTarget2D(e,(0,s.size)({width:t.cssWidth,height:t.cssHeight}),(0,s.size)({width:t.physicalWidth,height:t.physicalHeight})).useBitmapCoordinateSpace((e=>this._drawBackgroundImpl(e)))}_drawBackgroundImpl(e){}}},19266:(e,t,i)=>{"use strict";i.d(t,{CompositeRenderer:()=>s});class s{constructor(){this._renderers=[],this._globalAlpha=1}setGlobalAlpha(e){this._globalAlpha=e}append(e){this._renderers.push(e)}insert(e,t){this._renderers.splice(t,0,e)}clear(){this._renderers.length=0}isEmpty(){return 0===this._renderers.length}draw(e,t){for(let i=0;i=0;s--){const r=this._renderers[s].hitTest(e,t);null!==r&&(null===i||r.target()>i.target())&&(i=r)}return i}doesIntersectWithBox(e){return this._renderers.some((t=>!!t.doesIntersectWithBox&&t.doesIntersectWithBox(e)))}}},68441:(e,t,i)=>{"use strict";i.r(t),i.d(t,{addHorizontalLineToPath:()=>a,addLineToPath:()=>y,addVerticalLineToPath:()=>c, +clearRectWithGradient:()=>n,createCircle:()=>f,drawHorizontalLine:()=>l,drawLine:()=>b,drawPoly:()=>v,drawRoundRect:()=>p,drawRoundRectWithInnerBorder:()=>_,drawVerticalLine:()=>h,fillRectInnerBorder:()=>o,fillRectWithBorder:()=>g,scaleDrawRoundRectRadii:()=>d,scaledDashPattern:()=>m,setLineStyle:()=>S});var s=i(79849),r=i(95586);function n(e,t,i,s,r,n,o){e.save(),e.globalCompositeOperation="copy";const a=e.createLinearGradient(0,0,0,r);a.addColorStop(0,n),a.addColorStop(1,o),e.fillStyle=a,e.fillRect(t,i,s,r),e.restore()}function o(e,t,i,s,r,n){e.fillRect(t+n,i,s-2*n,n),e.fillRect(t+n,i+r-n,s-2*n,n),e.fillRect(t,i,n,r),e.fillRect(t+s-n,i,n,r)}function a(e,t,i,s){const r=e.lineWidth%2?.5:0;e.moveTo(i,t+r),e.lineTo(s,t+r)}function l(e,t,i,s){e.beginPath(),a(e,t,i,s),e.stroke()}function c(e,t,i,s){const r=e.lineWidth%2?.5:0;e.moveTo(t+r,i),e.lineTo(t+r,s)}function h(e,t,i,s){e.beginPath(),c(e,t,i,s),e.stroke()}function d(e,t){return Array.isArray(e)?e.map((e=>Math.round(e*t))):Math.round(e*t)}function u(e,t){return Array.isArray(e)?e.map((e=>0===e?e:e+t)):e+t}function p(e,t,i,s,r,n,o){let a,l,c,h;if(Array.isArray(n))if(2===n.length){const e=Math.max(0,n[0]),t=Math.max(0,n[1]);a=e,l=e,c=t,h=t}else{if(4!==n.length)throw new Error("Wrong border radius - it should be like css border radius");a=Math.max(0,n[0]),l=Math.max(0,n[1]),c=Math.max(0,n[2]),h=Math.max(0,n[3])}else{const e=Math.max(0,n);a=e,l=e,c=e,h=e}o||e.beginPath(),e.moveTo(t+a,i),e.lineTo(t+s-l,i),0!==l&&e.arcTo(t+s,i,t+s,i+l,l),e.lineTo(t+s,i+r-c),0!==c&&e.arcTo(t+s,i+r,t+s-c,i+r,c),e.lineTo(t+h,i+r),0!==h&&e.arcTo(t,i+r,t,i+r-h,h),e.lineTo(t,i+a),0!==a&&e.arcTo(t,i,t+a,i,a)}function _(e,t,i,s,n,o,a=0,l=0,c="",h=r.LineStyle.Solid){if(e.save(),!l||!c||c===o)return p(e,t,i,s,n,a),e.fillStyle=o,e.fill(),void e.restore();const d=l/2;if("transparent"!==o){const d="transparent"!==c&&h!==r.LineStyle.Solid;p(e,d?t:t+l,d?i:i+l,d?s:s-2*l,d?n:n-2*l,d?a:u(a,-l)),e.fillStyle=o,e.fill()}if("transparent"!==c){p(e,t+d,i+d,s-l,n-l,u(a,-d)),e.lineWidth=l,e.strokeStyle=c,S(e,h),e.closePath(),e.stroke()}e.restore()}function m(e,t){return t=Math.max(1,t),e.map((e=>e*t))}function g(e,t,i,r,n,o,a,l){const c=o%2/2,h=t+c,d=r+c;let u,p;if(l){const{borderMode:a,borderWidth:c,color:_,dashPattern:g,lineStyle:f}=l;switch(a){case"outer":{const e=-o/2-c/2,t=-c/2;p={left:h+e,right:d-e,top:i+t,bottom:n-t};break}case"center":{const e=c%2/2;p={left:t+e,right:r+e,top:i+e,bottom:n+e};break}case"inner":{const e=-o/2+c/2,t=c/2;p={left:h+e,right:d-e,top:i+t,bottom:n-t}}}e.strokeStyle=_,e.lineWidth=c;let v=-1;g?e.setLineDash(m(g,c)):void 0!==f&&(S(e,f),f===s.LINESTYLE_SOLID&&(v=1)),u={left:p.left+v*c/2,top:p.top+v*c/2,right:p.right-v*c/2,bottom:p.bottom-v*c/2}}a&&(e.fillStyle=a.color,u||(u={left:h-o/2,right:d+o/2,top:i,bottom:n}),e.fillRect(u.left,u.top,u.right-u.left,u.bottom-u.top)),p&&e.strokeRect(p.left,p.top,p.right-p.left,p.bottom-p.top)}function f(e,t,i,s){e.beginPath(),e.arc(t,i,s,0,2*Math.PI,!1),e.closePath()}function v(e,t,i){e.beginPath(),e.moveTo(t[0].x,t[0].y) +;for(const i of t)e.lineTo(i.x,i.y);e.closePath(),e.stroke(),i&&e.fill()}function S(e,t){let i=[];t!==s.LINESTYLE_SOLID&&(i=function(e,t){return[[e.lineWidth,2*e.lineWidth],[5*e.lineWidth,6*e.lineWidth],[6*e.lineWidth,6*e.lineWidth],[e.lineWidth,4*e.lineWidth],[2*e.lineWidth,e.lineWidth]][t-1]}(e,t)),e.setLineDash(i)}function y(e,t,i,s,r){e.moveTo(t,i),e.lineTo(s,r)}function b(e,t,i,s,r){isFinite(t)&&isFinite(s)&&isFinite(i)&&isFinite(r)&&(e.beginPath(),y(e,t,i,s,r),e.stroke())}},45197:(e,t,i)=>{"use strict";i.d(t,{coordinateIsValid:()=>g,extendAndClipLineSegment:()=>h,fillScaledRadius:()=>v,getArrowPoints:()=>d,interactionTolerance:()=>m,optimalBarWidth:()=>u,optimalCandlestickWidth:()=>p,optimalHiLoWidth:()=>_,setValidLineStyle:()=>f,strokeScaledRadius:()=>S});var s=i(86441),r=i(5531),n=i(38325),o=i(1722),a=i(68441);const l={common:13,line:13,minDistanceBetweenPoints:10,series:14,curve:10,anchor:13,esd:4},c={common:3,line:3,minDistanceBetweenPoints:5,series:2,curve:3,anchor:2,esd:0};function h(e,t,i,n,o,a){if((0,s.equalPoints)(e,t))return null;const l=new s.Point(0,0),c=new s.Point(i,n);if(o){if(a){const i=(0,r.intersectLineAndBox)((0,s.lineThroughPoints)(e,t),(0,s.box)(l,c));return Array.isArray(i)?i:null}{const i=(0,r.intersectRayAndBox)(t,e,(0,s.box)(l,c));return null===i||(0,s.equalPoints)(t,i)?null:(0,s.lineSegment)(t,i)}}if(a){const i=(0,r.intersectRayAndBox)(e,t,(0,s.box)(l,c));return null===i||(0,s.equalPoints)(e,i)?null:(0,s.lineSegment)(e,i)}{const i=(0,r.intersectLineSegmentAndBox)((0,s.lineSegment)(e,t),(0,s.box)(l,c));return Array.isArray(i)?i:null}}function d(e,t,i,s,r){const n=.5*i,o=Math.sqrt(2),a=t.subtract(e),l=a.normalized();let c=5*i;s&&(c=Math.min(c,.35*a.length()));const h=1*n;if(c*o*.2<=h)return[];const d=l.scaled(c),u=t.subtract(d),p=l.transposed(),_=1*c,m=p.scaled(_),g=u.add(m),f=u.subtract(m),v=g.subtract(t).normalized().scaled(h),S=f.subtract(t).normalized().scaled(h),y=r?t:t.add(v),b=r?t:t.add(S),w=n*(o-1),P=p.scaled(w),C=Math.min(c-1*n/o,n*o*1),x=l.scaled(C),T=t.subtract(P),I=t.add(P),M=t.subtract(x);return[[g,y],[b,f],[T,M.subtract(P)],[I,M.add(P)]]}function u(e,t){return t=t||1,Math.floor(.3*e*t)}function p(e,t){if(e>=2.5&&e<=4)return Math.floor(3*t);const i=1-.2*Math.atan(Math.max(4,e)-4)/(.5*Math.PI),s=Math.floor(e*i*t),r=Math.floor(e*t),n=Math.min(s,r);return Math.max(Math.floor(t),n)}function _(e){return.4*e}function m(){return(0,n.lastMouseOrTouchEventInfo)().isTouch?l:c}function g(e){return null!=e&&!(0,o.isNaN)(e)}function f(e,t){void 0!==t&&(0,a.setLineStyle)(e,t)}function v(e,t){const i=Math.max(1,Math.floor(t))%2?.5:0;return Math.round(e*t)+i}function S(e,t,i){const s=Math.max(1,Math.floor(t))%2?.5:0;return Math.round(e*t)+(s!==i%2?.5:0)}},74997:(e,t,i)=>{"use strict";i.d(t,{HorizontalLineRenderer:()=>l});var s=i(18807),r=i(68441),n=i(45197),o=i(59590),a=i(74359);class l extends o.BitmapCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null,this._hitTest=new s.HitTestResult(s.HitTarget.Regular)}setData(e){this._data=e}setHitTest(e){this._hitTest=e} +hitTest(e){if(null===this._data||!1===this._data.visible||null===this._hitTest)return null;const t=(0,n.interactionTolerance)().line,i=Math.abs(e.y-this._data.y)<=t+this._data.linewidth/2,s=void 0===this._data.left||this._data.left-e.x<=t,r=void 0===this._data.right||e.x-this._data.right<=t;return i&&s&&r?this._hitTest:null}_drawImpl(e){if(null===this._data||!1===this._data.visible)return;const{context:t,horizontalPixelRatio:i,verticalPixelRatio:s,mediaSize:n}=e;if(this._data.y<-this._data.linewidth/2||this._data.y>n.height+this._data.linewidth/2)return;t.lineCap="butt",t.strokeStyle=this._data.color,t.lineWidth=Math.max(1,Math.floor(this._data.linewidth*i)),void 0!==this._data.linestyle&&(0,r.setLineStyle)(t,this._data.linestyle);const o=void 0!==this._data.left?Math.max(this._data.left,0):0,l=void 0!==this._data.right?Math.min(this._data.right,n.width):n.width,c=Math.round(this._data.y*s),h=Math.round(o*i),d=Math.round(l*i),u=this._data.excludeBoundaries;void 0!==u&&(0,a.addExclusionAreaByScope)(e,u),(0,r.drawHorizontalLine)(t,c,h,d)}}},73436:(e,t,i)=>{"use strict";var s;i.d(t,{LineEnd:()=>s}),function(e){e[e.Normal=0]="Normal",e[e.Arrow=1]="Arrow",e[e.Circle=2]="Circle"}(s||(s={}))},1149:(e,t,i)=>{"use strict";i.d(t,{PaneRendererLine:()=>c});var s=i(86441),r=i(4652),n=i(18807),o=i(45197),a=i(68441),l=i(59590);class c extends l.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){var t,i,a,l;const c=(0,o.interactionTolerance)().series+this._data.lineWidth/2;let h=null!==(i=null===(t=this._data.visibleItemsRange)||void 0===t?void 0:t.startItemIndex)&&void 0!==i?i:0,d=(null!==(l=null===(a=this._data.visibleItemsRange)||void 0===a?void 0:a.endItemIndex)&&void 0!==l?l:this._data.items.length)-1;for(;d-h>2;){const t=Math.round((d+h)/2);this._data.items[t].x<=e.x?h=t:d=t}h=Math.max(1,h-1),d=Math.min(this._data.items.length-1,d+1);for(let t=h;t<=d;++t){const i=this._data.items[t-1],o=this._data.items[t],a=i.x,l=o.x;if((0,r.distanceToSegment)(new s.Point(a,i.y),new s.Point(l,o.y),new s.Point(e.x,e.y)).distance<=c)return this._data.hittest?this._data.hittest:new n.HitTestResult(n.HitTarget.Regular)}return null}_drawImpl(e){const{context:t,horizontalPixelRatio:i,verticalPixelRatio:s}=e;t.scale(i,s),t.lineCap="round",t.lineJoin="round",t.strokeStyle=this._data.lineColor,t.fillStyle=this._data.lineColor,t.lineWidth=this._data.lineWidth,(0,a.setLineStyle)(t,this._data.lineStyle),(0,o.setValidLineStyle)(t,this._data.lineStyle),this._data.simpleMode?this._drawSimpleMode(t,i,s):this._drawLines(t)}_drawSimpleMode(e,t,i){var s,r,n,o;e.beginPath(),this._walkLine(e,this._data.items,!1,NaN),e.stroke();const a=this._data.lineWidth+2;if(this._data.withMarkers&&2*a=d;){const r=this._data.items[s];if(r){const s=Math.round(r.x*t)+l,n=r.y*i;e.moveTo(s,n),e.arc(s,n,c,0,h)}}e.fill()}}_walkLine(e,t,i,s,r){var n,a,l,c;if(!t)return;const h=.25*this._data.barSpacing;let d,u,p,_,m;const g=o.coordinateIsValid,f=r?0:null!==(a=null===(n=this._data.visibleItemsRange)||void 0===n?void 0:n.startItemIndex)&&void 0!==a?a:0,v=r?t.length-1:Math.min((null!==(c=null===(l=this._data.visibleItemsRange)||void 0===l?void 0:l.endItemIndex)&&void 0!==c?c:t.length)-1,t.length-1);for(let e=f;e<=v;e++){const i=t[e];if(g(i.y)){u=i,d=e;break}}if(void 0!==d&&void 0!==u)for(let r=d;r<=v;r++){_=t[r],m=t[r+1]||{};const n=Math.round(_.x);if(g(_.y))if(p&&g(p.y))e.lineTo(n,_.y),i&&!g(m.y)&&e.lineTo(n,s);else if(m&&g(m.y))i?(r!==d&&e.lineTo(n,s),e.lineTo(n,_.y)):e.moveTo(n,_.y);else if(i){if(0===r)continue;r!==d&&e.lineTo(n-h,s),e.lineTo(n-h,_.y),e.lineTo(n+h,_.y),e.lineTo(n+h,s)}else e.moveTo(n-h,_.y),e.lineTo(n+h,_.y);p=_}}_drawLines(e){var t,i,s,r;if(!this._data.items.length)return;let n,a,l;const c=.25*this._data.barSpacing,h=o.coordinateIsValid;e.beginPath();const d=null!==(i=null===(t=this._data.visibleItemsRange)||void 0===t?void 0:t.startItemIndex)&&void 0!==i?i:0,u=(null!==(r=null===(s=this._data.visibleItemsRange)||void 0===s?void 0:s.endItemIndex)&&void 0!==r?r:this._data.items.length)-1,p=this._data.items[d];p&&e.moveTo(p.x,p.y);let _,m=e.strokeStyle,g=e.lineWidth;for(let t=d+1;t<=u;++t){let i,s,r;n=this._data.items[t-1],a=this._data.items[t],l=this._data.items[t+1],a.style&&!this._data.forceLineColor?(i=a.style.color,s=a.style.width,r=a.style.style):(i=this._data.lineColor,s=this._data.lineWidth,r=this._data.lineStyle),this._data.ignorePaletteLineWidth&&(s=this._data.lineWidth);(i!==m||s!==g||r!==_)&&(m=i,g=s,_=r,e.stroke(),e.beginPath(),e.strokeStyle=i,e.lineWidth=s,(0,o.setValidLineStyle)(e,r),e.moveTo(n.x,n.y)),f=n,S=l,h((v=a).y)&&(h(f.y)?e.lineTo(v.x,v.y):S&&h(S.y)?e.moveTo(v.x,v.y):(e.moveTo(v.x-c,v.y),e.lineTo(v.x+c,v.y)))}var f,v,S;e.stroke()}}},15187:(e,t,i)=>{"use strict";i.d(t,{MediaCoordinatesPaneRenderer:()=>r});var s=i(27714);class r{draw(e,t){new s.CanvasRenderingTarget2D(e,(0,s.size)({width:t.cssWidth,height:t.cssHeight}),(0,s.size)({width:t.physicalWidth,height:t.physicalHeight})).useMediaCoordinateSpace((e=>this._drawImpl(e)))}drawBackground(e,t){new s.CanvasRenderingTarget2D(e,(0,s.size)({width:t.cssWidth,height:t.cssHeight}),(0,s.size)({width:t.physicalWidth,height:t.physicalHeight})).useMediaCoordinateSpace((e=>this._drawBackgroundImpl(e)))}_drawBackgroundImpl(e){}}},77173:(e,t,i)=>{"use strict";i.d(t,{CachedContainer:()=>s,ObjectValuesCache:()=>r});class s{constructor(){this._items=[],this._actualLength=0,this._invalidations=0}push(e){this._items.length===this._actualLength?this._items.push(e):this._items[this._actualLength]!==e&&(this._items[this._actualLength]=e),this._actualLength+=1}newItem(){ +const e=this._items.length>this._actualLength?this._items[this._actualLength]:null;return null!==e&&Boolean(e.invalidateCache)&&e.invalidateCache(),e}invalidateCache(){this._invalidations+=1,3e3===this._invalidations&&(this._items.splice(this._actualLength),this._invalidations=0),this._actualLength=0}at(e){return this._items[e]}data(){return this._items}length(){return this._actualLength}}class r extends s{constructor(){super(...arguments),this._startIndex=0}setStartIndex(e){this._startIndex=e}isValidIndex(e){return e>=this._startIndex}at(e){const t=e-this._startIndex;for(;t>=this._actualLength;)this._items.length<=t?this._items.push(this._newObject()):this._clearObject(this._items[this._actualLength]),this._actualLength+=1;return this._items[t]}}},72739:(e,t,i)=>{"use strict";i.d(t,{RectangleRenderer:()=>u});var s=i(50151),r=i(86441),n=i(34026),o=i(4652),a=i(87095),l=i(79849),c=i(18807),h=i(68441),d=i(59590);class u extends d.BitmapCoordinatesPaneRenderer{constructor(e,t,i){super(),this._data=null,this._hitTestResult=e||new c.HitTestResult(c.HitTarget.MovePoint),this._backHitTestResult=t||new c.HitTestResult(c.HitTarget.MovePointBackground),this._forceOverrideTransparency=Boolean(i)}setData(e){this._data=e}hitTest(e,t){if(null===this._data||this._data.points.length<2||this._data.nohittest)return null;const i=t.physicalWidth,s=(0,r.box)(...this._data.points),n=s.min,a=s.max,l=new r.Point(a.x,n.y),c=new r.Point(n.x,a.y),h=this._extendAndHitTestLineSegment(e,n,l,i);if(null!==h)return h;const d=this._extendAndHitTestLineSegment(e,c,a,i);if(null!==d)return d;let u=(0,o.distanceToSegment)(l,a,e);return u.distance<=3?this._hitTestResult:(u=(0,o.distanceToSegment)(n,c,e),u.distance<=3?this._hitTestResult:this._data.fillBackground?this._hitTestBackground(e,n,a,i):null)}getColor(){const e=(0,s.ensure)(this._data);return void 0===e.transparency?e.backcolor:(0,a.generateColor)(e.backcolor,e.transparency,this._forceOverrideTransparency)}_drawImpl(e){if(null===this._data||this._data.points.length<2||this._data.linewidth<=0&&!this._data.fillBackground)return;const{context:t,horizontalPixelRatio:i,verticalPixelRatio:s,bitmapSize:n}=e,{extendLeft:o,extendRight:a,linewidth:c}=this._data,d=(0,r.box)(...this._data.points),u=this._data.linewidth?Math.max(1,Math.floor(this._data.linewidth*i)):0,p=this._data.fillBackground?this.getColor():void 0,_=Math.max(1,Math.floor(i)),m=o?-c:Math.round(d.min.x*i),g=a?n.width+c:Math.round(d.max.x*i),f=Math.round(d.min.y*s),v=Math.round(d.max.y*s);(0,h.fillRectWithBorder)(t,m,f,g,v,_,void 0===p?void 0:{color:p},0===u?void 0:{color:this._data.color,lineStyle:l.LINESTYLE_SOLID,borderWidth:u,borderMode:"center"})}_extendAndHitTestLineSegment(e,t,i,s){const r=this._extendAndClipLineSegment(t,i,s);if(null!==r){if((0,o.distanceToSegment)(r[0],r[1],e).distance<=3)return this._hitTestResult}return null}_extendAndClipLineSegment(e,t,i){const n=(0,s.ensureNotNull)(this._data);if((0,r.equalPoints)(e,t)&&!n.extendLeft&&!n.extendRight)return null +;const o=Math.min(e.x,t.x),a=Math.max(e.x,t.x),l=n.extendLeft?0:Math.max(o,0),c=n.extendRight?i:Math.min(a,i);return l>c||c<=0||l>=i?null:[new r.Point(l,e.y),new r.Point(c,t.y)]}_hitTestBackground(e,t,i,s){const o=this._extendAndClipLineSegment(t,i,s);return null!==o&&(0,n.pointInBox)(e,(0,r.box)(o[0],o[1]))?this._backHitTestResult:null}}},9155:(e,t,i)=>{"use strict";var s;i.d(t,{StatsPosition:()=>s}),function(e){e[e.Left=0]="Left",e[e.Center=1]="Center",e[e.Right=2]="Right",e[e.Auto=3]="Auto"}(s||(s={}))},40621:(e,t,i)=>{"use strict";i.d(t,{PaneRendererStepLine:()=>g,StepLineDecoration:()=>s});var s,r=i(4652),n=i(86441),o=i(87095),a=i(18807),l=i(78071),c=i(45197),h=i(68441),d=i(59590);!function(e){e[e.None=0]="None",e[e.Diamonds=1]="Diamonds"}(s||(s={}));class u{initialize(e,t,i){var s,r,n,o;const{context:a,horizontalPixelRatio:l,verticalPixelRatio:c}=t,d=e.lineStyle;a.lineCap="butt",a.lineJoin="round";const u=Math.max(Math.floor(null!==(r=null===(s=i.style)||void 0===s?void 0:s.width)&&void 0!==r?r:e.lineWidth*l));void 0!==d&&(0,h.setLineStyle)(a,d);const p=u%2?.5:0;a.moveTo(Math.round(i.x*l)+p,Math.round(i.y*c)+p),a.strokeStyle=null!==(o=null===(n=i.style)||void 0===n?void 0:n.color)&&void 0!==o?o:e.lineColor,a.lineWidth=u}finishFragment(e){e.stroke()}hitTest(e,t,i,s,r){return u.hitTest(e,t,i,s,r)}applyColor(e,t){e.strokeStyle=t}applyLineWidth(e,t){e.lineWidth=t}drawItem(e,t,i){const s=e.context;s.lineTo(t.x,t.y),void 0!==i&&(s.lineTo(i.x,t.y),s.lineTo(i.x,i.y))}static hitTest(e,t,i,s,o){var a,l;const h=t.pixelRatio,d=null!==(l=null===(a=i.style)||void 0===a?void 0:a.width)&&void 0!==l?l:e.lineWidth,u=Math.max(1,Math.floor(d*h))%2?.5:0,p=(0,c.interactionTolerance)().series+d/2;let _;if(isNaN(s.y)){const e=i.x+u,t=s.x+u,a=new n.Point(e,i.y),l=new n.Point(t,i.y);_=(0,r.distanceToSegment)(a,l,o).distance}else{const t=Math.round(s.x-e.barSpacing/2*h)+u,a=new n.Point(t,i.y),l=new n.Point(t,s.y);_=Math.min((0,r.distanceToSegment)(i,a,o).distance,(0,r.distanceToSegment)(a,l,o).distance,(0,r.distanceToSegment)(l,s,o).distance)}return _<=p}}class p{constructor(){this._lineWidth=1}initialize(e,t,i){var s,r,n,o;const{context:a,horizontalPixelRatio:l}=t;this.applyColor(a,null!==(r=null===(s=i.style)||void 0===s?void 0:s.color)&&void 0!==r?r:e.lineColor),this._lineWidth=Math.max(Math.floor(null!==(o=null===(n=i.style)||void 0===n?void 0:n.width)&&void 0!==o?o:e.lineWidth*l))}finishFragment(e){e.fill()}drawItem(e,t,i,s){if(s&&void 0!==i&&!Number.isNaN(i.y)){const t=e.context;t.save(),t.translate(i.x,i.y),t.rotate(Math.PI/4);const s=this._scaleByLineWidth(this._lineWidth);t.scale(s,s),this._drawItemRotatedAndTranslated(e),t.restore()}}applyLineWidth(e,t){this._lineWidth=t}hitTest(e,t,i,s,r){var o,a;if(!s.valIsNotSameAsPrev)return!1;const l=Math.round((i.x+s.x)/2),c=new n.Point(l,s.y),h=r.subtract(c),d=Math.max(Math.floor(null!==(a=null===(o=i.style)||void 0===o?void 0:o.width)&&void 0!==a?a:e.lineWidth*t.pixelRatio));return this._hitTestTranslated(h,d)}_scaleByLineWidth(e){return Math.sqrt(e)}}class _ extends p{applyColor(e,t){ +e.fillStyle=t}_hitTestTranslated(e,t){return Math.abs(e.x)+Math.abs(e.y)<8*this._scaleByLineWidth(t)/2}_drawItemRotatedAndTranslated(e){(0,h.drawRoundRect)(e.context,-4,-4,8,8,2,!0)}}class m extends p{applyColor(e,t){e.fillStyle=(0,o.applyTransparency)(t,85)}_hitTestTranslated(e,t){return Math.abs(e.x)+Math.abs(e.y)<21*this._scaleByLineWidth(t)/2}_drawItemRotatedAndTranslated(e){(0,h.drawRoundRect)(e.context,-10.5,-10.5,21,21,5,!0)}}class g extends d.BitmapCoordinatesPaneRenderer{constructor(e,t){super(),this._data=null,this._data=null!=e?e:null,this._extendLineToLastConfirmedBar=Boolean(t)}setData(e){this._data=e}hitTest(e,t){const i=this._data;if(null===i||0===i.items.length)return null;const{items:r,items:{length:o},lastConfirmedSeriesBarCoordinate:c,visibleItemsRange:{startItemIndex:h,endItemIndex:d}={startItemIndex:0,endItemIndex:o}}=i,p=i.decoration===s.Diamonds?[new u,new m]:[new u];const _=(0,l.lowerbound)(r,e,((e,t)=>e.x<=t.x),h,d),g=Math.max(0,_-1),f=Math.min(o,_+1);for(let s=g;ss.hitTest(i,t,l,h,e))))return new a.HitTestResult(a.HitTarget.Regular)}else if(this._extendLineToLastConfirmedBar&&void 0!==c&&f===o&&l.xthis._drawDecorationItem(e,t)))}_drawDecorationItem(e,t){var i,s,r,o,a,l,c,h,d,u,p,_,m,g,f,v;if(null===this._data||0===this._data.items.length)return;const{lineWidth:S,lineColor:y,items:b}=this._data,{context:w,horizontalPixelRatio:P,verticalPixelRatio:C,bitmapSize:x}=e;let T=Math.max(Math.floor(null!==(s=null===(i=b[0].style)||void 0===i?void 0:i.width)&&void 0!==s?s:S*P)),I=T%2?.5:0;t.initialize(this._data,e,b[0]);const M=null!==(o=null===(r=this._data.visibleItemsRange)||void 0===r?void 0:r.startItemIndex)&&void 0!==o?o:0,L=null!==(l=null===(a=this._data.visibleItemsRange)||void 0===a?void 0:a.endItemIndex)&&void 0!==l?l:b.length,A=this._data.barSpacing;if(!(L<=M)){w.beginPath(),t.applyColor(w,null!==(h=null===(c=b[M].style)||void 0===c?void 0:c.color)&&void 0!==h?h:y);for(let i=M;i{"use strict";i.d(t,{TextRenderer:()=>T,calculateLabelPosition:()=>u,getTextBoundaries:()=>p,wordWrap:()=>_});var s=i(86441),r=i(50151),n=i(34026),o=i(38223),a=i(18807),l=i(68441),c=i(1722),h=i(74359),d=i(79849);function u(e,t,i,r,n){const o=.5*(t.x+i.x);let a=i.y;return t.y>i.y?(a-=e.height/2+r.y,a=Math.max(e.height/2,a)):(a+=e.height/2+r.y,a=Math.min(n-e.height/2,a)),new s.Point(o,a)}function p(e,t,i){if(e.isOutOfScreen(t,i))return null;const s=e.getPolygonPoints();return 0===s.length?null:s}function _(e,t,i){i=(0,c.isString)(i)?parseInt(i):i,e+="";const s=!(0,c.isNumber)(i)||!isFinite(i)||i<=0?e.split(/\r\n|\r|\n|$/):e.split(/[^\S\r\n]*(?:\r\n|\r|\n|$)/);if(s[s.length-1]||s.pop(),!(0,c.isNumber)(i)||!isFinite(i)||i<=0)return s;const r=[];for(let e=0;e0&&(0,h.measureText)(a.slice(0,3*--e-1).join(""),t).width>i;);if(e>0)r.push(a.slice(0,3*e-1).join("")),a.splice(0,3*e);else{const e=a[0]+(a[1]||"");if(l=1===l?1:~~(i/(0,h.measureText)(e,t).width*e.length),(0,h.measureText)(e.substring(0,l),t).width<=i)for(;(0,h.measureText)(e.substring(0,l+1),t).width<=i;)l++;else for(;l>1&&(0,h.measureText)(e.substring(0,--l),t).width>i;);l<1&&(l=1),r.push(e.substring(0,l)),a[0]=e.substring(l),a[1]=""}if((0,h.measureText)(a.join(""),t).width<=i){r.push(a.join(""));break}}}return r}function m(e,t,i){if(0===i)return e.clone();const r=(e.x-t.x)*Math.cos(i)-(e.y-t.y)*Math.sin(i)+t.x,n=(e.x-t.x)*Math.sin(i)+(e.y-t.y)*Math.cos(i)+t.y;return new s.Point(r,n)}function g(e,t){const i=Math.round(t+2*b(e)+2*S(e));return i%2?i+1:i}function f(e,t){return P(e)*t+w(e)*(t-1)+2*y(e)+2*v(e)}function v(e){return void 0!==e.boxPaddingVert?e.boxPaddingVert*x(e):void 0!==e.boxPadding?e.boxPadding*x(e):P(e)/3}function S(e){return void 0!==e.boxPaddingHorz?e.boxPaddingHorz*x(e):void 0!==e.boxPadding?e.boxPadding*x(e):P(e)/3}function y(e){return(e.backgroundVertInflate||0)*x(e)}function b(e){return(e.backgroundHorzInflate||0)*x(e)}function w(e){return(e.padding||0)*x(e)}function P(e){return Math.ceil(C(e)*x(e))}function C(e){return e.fontsize||e.fontSize||30}function x(e){const t=Math.min(1,Math.max(.2,Math.min(e.scaleX||1,e.scaleY||1)));if(1===t)return t;const i=C(e);return Math.ceil(t*i)/i}class T{constructor(e,t){this._data=null, +this._internalData=null,this._boxSize=null,this._polygonPoints=null,this._linesInfo=null,this._fontInfo=null,this._hittest=t||new a.HitTestResult(a.HitTarget.MovePoint,{areaName:a.AreaName.Text}),void 0!==e&&this.setData(e)}setData(e){null!==e?(e.horzTextAlign||(e.horzTextAlign=e.horzAlign),!function(e,t){if(null===e||null===t)return null===e==(null===t);if(void 0===e.points!=(void 0===t.points))return!1;if(void 0!==e.points&&void 0!==t.points){if(e.points.length!==t.points.length)return!1;for(let r=0;re){const i=(0,s.box)(new s.Point(0,0),new s.Point(e,t));return this.getPolygonPoints().every((e=>!(0,n.pointInBox)(e,i)))}return!1}setPoints(e,t){(0,r.ensureNotNull)(this._data).points=e,this._hittest=t||new a.HitTestResult(a.HitTarget.MovePoint)}fontStyle(e){return null===this._data?"":this._getFontInfo().fontStyle}wordWrap(e,t,i){return _(e,i||this.fontStyle(),t)}draw(e,t){if(null===this._data||void 0===this._data.points||0===this._data.points.length)return;if(this.isOutOfScreen(t.cssWidth,t.cssHeight))return;const i=t.pixelRatio,s=this._getInternalData(),r=this._getRotationPoint().scaled(i);e.save(),e.translate(r.x,r.y),e.rotate(this._data.angle||0),e.translate(-r.x,-r.y) +;const n=this._getFontInfo().fontSize;e.textBaseline=s.textBaseLine,e.textAlign=s.textAlign,e.font=this.fontStyle();const{scaledLeft:o,scaledRight:a,scaledTop:c,scaledBottom:u}=function(e,t){const i=Math.round(e.boxLeft*t),s=Math.round(e.boxTop*t);return{scaledLeft:i,scaledRight:i+Math.round(e.boxWidth*t),scaledTop:s,scaledBottom:s+Math.round(e.boxHeight*t)}}(s,i);if(this._data.backgroundColor||this._data.borderColor||this._data.highlightBorder&&this._data.wordWrapWidth){const t=this._data.borderWidth||Math.max(n/12,1),s=Math.round(t*i),r=s/2;let h=!1;if(this._data.boxShadow){e.save();const{shadowColor:t,shadowBlur:i,shadowOffsetX:s=0,shadowOffsetY:r=0}=this._data.boxShadow;e.shadowColor=t,e.shadowBlur=i,e.shadowOffsetX=s,e.shadowOffsetY=r,h=!0}if(this._data.backgroundRoundRect)this._data.backgroundColor&&((0,l.drawRoundRect)(e,o,c,a-o,u-c,this._data.backgroundRoundRect*i),e.fillStyle=this._data.backgroundColor,e.fill(),h&&(e.restore(),h=!1)),this._data.borderColor&&((0,l.drawRoundRect)(e,o-r,c-r,a-o+s,u-c+s,this._data.backgroundRoundRect*i+s),e.strokeStyle=this._data.borderColor,e.lineWidth=s,e.stroke(),h&&(e.restore(),h=!1));else if(this._data.backgroundColor&&(e.fillStyle=this._data.backgroundColor,e.fillRect(o,c,a-o,u-c),h&&(e.restore(),h=!1)),this._data.borderColor||this._data.highlightBorder){let t;this._data.borderColor?(e.strokeStyle=this._data.borderColor,t=s):(e.strokeStyle=this._data.color,(0,l.setLineStyle)(e,d.LINESTYLE_DASHED),t=Math.max(1,Math.floor(i))),e.lineWidth=t,e.beginPath(),e.moveTo(o-t/2,c-t/2),e.lineTo(o-t/2,u+t/2),e.lineTo(a+t/2,u+t/2),e.lineTo(a+t/2,c-t/2),e.lineTo(o-t/2,c-t/2),e.stroke(),h&&e.restore()}}e.fillStyle=this._data.color;const p=(o+Math.round(s.textStart*i))/i,_=.05*n;let m=(c+Math.round((s.textTop+_)*i))/i;const g=w(this._data),f=this.getLinesInfo();for(const t of f.lines)(0,h.drawScaled)(e,i,i,(()=>e.fillText(t,p,m))),m+=n+g;e.restore()}getPolygonPoints(){if(null!==this._polygonPoints)return this._polygonPoints;if(null===this._data)return[];const e=this._data.angle||0,{boxLeft:t,boxTop:i,boxWidth:r,boxHeight:n}=this._getInternalData(),o=this._getRotationPoint();return this._polygonPoints=[m(new s.Point(t,i),o,e),m(new s.Point(t+r,i),o,e),m(new s.Point(t+r,i+n),o,e),m(new s.Point(t,i+n),o,e)],this._polygonPoints}getLinesInfo(){if(null===this._linesInfo){const e=(0,r.ensureNotNull)(this._data);let t=this.wordWrap(e.text,e.wordWrapWidth);if(void 0!==e.maxHeight){const i=function(e){const t=(0,r.ensureDefined)(e.maxHeight),i=P(e),s=w(e);return Math.floor((t+s)/(i+s))}(e);t.length>i&&(t=t.slice(0,i))}this._linesInfo={linesMaxWidth:this._getLinesMaxWidth(t),lines:t}}return this._linesInfo}_getLinesMaxWidth(e){const t=this.fontStyle();if(null!==this._data&&this._data.wordWrapWidth&&!this._data.forceCalculateMaxLineWidth)return this._data.wordWrapWidth*x(this._data);let i=0;for(const s of e)i=Math.max(i,(0,h.measureText)(s,t).width);return i}_getInternalData(){if(null!==this._internalData)return this._internalData;const e=(0, +r.ensureNotNull)(this._data),t=this._getBoxSize(),i=t.boxWidth,s=t.boxHeight,n=(0,r.ensureDefined)(e.points)[0];let a=n.y;switch(e.vertAlign){case"bottom":a-=s+e.offsetY;break;case"middle":a-=s/2;break;case"top":a+=e.offsetY}let l=n.x;const c=S(e),h=v(e),d=b(e)+c;let u;const p=a+(y(e)+h)+P(e)/2;let _;switch(e.horzAlign){case"left":l+=e.offsetX;break;case"center":l-=i/2;break;case"right":l-=i+e.offsetX}switch((0,r.ensureDefined)(e.horzTextAlign)){case"left":_="start",u=l+d,(0,o.isRtl)()&&(e.forceTextAlign?_="left":(u=l+i-d,_="right"));break;case"center":_="center",u=l+i/2;break;case"right":_="end",u=l+i-d,(0,o.isRtl)()&&e.forceTextAlign&&(_="right")}return this._internalData={boxLeft:l,boxTop:a,boxWidth:i,boxHeight:s,textStart:u-l,textTop:p-a,textAlign:_,textBaseLine:"middle"},this._internalData}_getFontInfo(){if(null===this._fontInfo){const e=(0,r.ensureNotNull)(this._data),t=P(e),i=(e.bold?"bold ":"")+(e.italic?"italic ":"")+t+"px "+e.font;this._fontInfo={fontStyle:i,fontSize:t}}return this._fontInfo}_getBoxSize(){if(null===this._boxSize){const e=this.getLinesInfo(),t=(0,r.ensureNotNull)(this._data);this._boxSize={boxWidth:g(t,e.linesMaxWidth),boxHeight:f(t,e.lines.length)}}return this._boxSize}_getRotationPoint(){const{boxLeft:e,boxTop:t,boxWidth:i,boxHeight:n}=this._getInternalData(),{horzAlign:o,vertAlign:a}=(0,r.ensureNotNull)(this._data);let l,c;switch(o){case"center":l=e+i/2;break;case"left":l=e;break;case"right":l=e+i}switch(a){case"middle":c=t+n/2;break;case"top":c=t;break;case"bottom":c=t+n}return new s.Point(l,c)}}},99031:(e,t,i)=>{"use strict";i.d(t,{TrendLineRenderer:()=>p,drawArrow:()=>u});var s=i(50151),r=i(4652),n=i(73436),o=i(18807),a=i(68441),l=i(45197),c=i(74359),h=i(79849);function d(e,t,i,s,r){t.save(),t.fillStyle="#000000",t.beginPath(),t.arc(e.x*r,e.y*r,i*r,0,2*Math.PI,!1),t.fill(),s.strokeWidth&&(t.lineWidth=s.strokeWidth,t.stroke()),t.restore()}function u(e,t,i,s,r,n=!1){if(t.subtract(e).length()<1)return;const o=(0,l.getArrowPoints)(e,t,s,n,!0).slice(0,2);let a=null;for(let e=0;e1)&&i.moveTo(t.x*r,t.y*r),i.lineTo(s.x*r,s.y*r),a=s}}class p{constructor(){this._data=null,this._hittest=new o.HitTestResult(o.HitTarget.MovePoint)}setData(e){this._data=e}setHitTest(e){this._hittest=e}draw(e,t){const i=this._data;if(null===i)return;if("points"in i&&i.points.length<2)return;const s=t.pixelRatio;void 0!==i.excludeBoundaries&&(e.save(),(0,c.addExclusionArea)(e,t,i.excludeBoundaries)),e.lineCap=i.linestyle===h.LINESTYLE_SOLID?"round":"butt",e.lineJoin="round",e.strokeStyle=i.color,e.lineWidth=Math.max(1,Math.floor(i.linewidth*s)),(0,a.setLineStyle)(e,i.linestyle);const r=i.points[0],n=i.points[1];let o=[];e.beginPath(),i.overlayLineEndings?o=[r.clone(),n.clone()]:this._drawEnds(e,[r,n],i.linewidth,s);const l=this._extendAndClipLineSegment(r,n,t);null!==l&&i.linewidth>0&&(l[0].x===l[1].x?(0,a.addVerticalLineToPath)(e,Math.round(l[0].x*s),l[0].y*s,l[1].y*s):l[0].y===l[1].y?(0, +a.addHorizontalLineToPath)(e,Math.round(l[0].y*s),l[0].x*s,l[1].x*s):(0,a.addLineToPath)(e,l[0].x*s,l[0].y*s,l[1].x*s,l[1].y*s)),i.overlayLineEndings&&this._drawEnds(e,o,i.linewidth,s),e.stroke(),void 0!==i.excludeBoundaries&&e.restore()}hitTest(e,t){const i=this._data;if(null===i)return null;if("points"in i&&i.points.length<2)return null;const s=(0,l.interactionTolerance)().line,n=i.points[0],o=i.points[1],a=this._extendAndClipLineSegment(n,o,t);if(null!==a){if((0,r.distanceToSegment)(a[0],a[1],e).distance<=s)return this._hittest}return null}_extendAndClipLineSegment(e,t,i){const r=(0,s.ensureNotNull)(this._data);return(0,l.extendAndClipLineSegment)(e,t,i.cssWidth,i.cssHeight,r.extendleft,r.extendright)}_drawEnds(e,t,i,r){const o=t[0],a=t[1],l=(0,s.ensureNotNull)(this._data);switch(l.leftend){case n.LineEnd.Arrow:u(a,o,e,i,r);break;case n.LineEnd.Circle:d(o,e,i,(0,s.ensureDefined)(l.endstyle),r)}switch(l.rightend){case n.LineEnd.Arrow:u(o,a,e,i,r);break;case n.LineEnd.Circle:d(a,e,i,(0,s.ensureDefined)(l.endstyle),r)}}}},71254:(e,t,i)=>{"use strict";i.d(t,{VerticalLineRenderer:()=>l});var s=i(18807),r=i(68441),n=i(45197),o=i(74359),a=i(59590);class l extends a.BitmapCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null,this._hitTest=new s.HitTestResult(s.HitTarget.MovePoint)}setData(e){this._data=e}setHitTest(e){this._hitTest=e}hitTest(e){if(null===this._data||null===this._hitTest)return null;const t=(0,n.interactionTolerance)().line,i=Math.abs(e.x-this._data.x)<=t+this._data.linewidth/2,s=void 0===this._data.top||this._data.top-e.y<=t,r=void 0===this._data.bottom||e.y-this._data.bottom<=t;return i&&s&&r?this._hitTest:null}_drawImpl(e){if(null===this._data||this._data.linewidth<=0)return;const{context:t,horizontalPixelRatio:i,verticalPixelRatio:s,mediaSize:n}=e;if(this._data.x<-this._data.linewidth/2||this._data.x>n.width+this._data.linewidth/2)return;t.lineCap="butt",t.strokeStyle=this._data.color,t.lineWidth=Math.max(1,Math.floor(this._data.linewidth*i)),void 0!==this._data.linestyle&&(0,r.setLineStyle)(t,this._data.linestyle);const a=void 0!==this._data.top?Math.max(this._data.top,0):0,l=void 0!==this._data.bottom?Math.min(this._data.bottom,n.height):n.height,c=Math.round(this._data.x*i),h=Math.floor(a*s),d=Math.ceil(l*s),u=this._data.excludeBoundaries;void 0!==u&&(0,o.addExclusionAreaByScope)(e,u),(0,r.drawVerticalLine)(t,c,h,d)}}},98517:(e,t,i)=>{"use strict";i.d(t,{sortSources:()=>r,sortSourcesPreOrdered:()=>s});const s={LatestUpdates:10000001,BarMarks:10000002,TimeScaleMarks:10000003,ChartEventsSource:10000004,Dividends:10000005,Splits:10000006,Earnings:10000007,RollDates:10000008,FutureContractExpiration:10000009,LineToolOrder:10000010,LineToolPosition:10000011,LineToolExecution:10000012,AlertLabel:10000013};function r(e){return[...e].sort(((e,t)=>e.zorder()-t.zorder()))}},97034:(e,t,i)=>{"use strict";i.r(t),i.d(t,{PlotList:()=>u,mergeMinMax:()=>p,mergePlotRows:()=>_});var s=i(50151),r=i(78071),n=i(61401),o=i(59224),a=i(86094);const l=(0,o.getLogger)("Chart.PlotList"),c=30;function h(e){ +return e.index}function d(e){return e.value[0]}class u{constructor(e=null,t=null){this._items=[],this._start=0,this._end=0,this._shareRead=!1,this._minMaxCache=new Map,this._rowSearchCacheByIndex=new Map,this._rowSearchCacheByIndexWithoutEmptyValues=new Map,this._rowSearchCacheByTime=new Map,this._rowSearchCacheByTimeWithoutEmptyValues=new Map,this._plotFunctions=e||new Map,this._emptyValuePredicate=t}clear(){this._items=[],this._start=0,this._end=0,this._shareRead=!1,this._minMaxCache.clear(),this._invalidateSearchCaches()}first(){return this.size()>0?this._items[this._start]:null}last(){return this.size()>0?this._items[this._end-1]:null}firstIndex(){return this.size()>0?this._indexAt(this._start):null}lastIndex(){return this.size()>0?this._indexAt(this._end-1):null}size(){return this._end-this._start}isEmpty(){return 0===this.size()}contains(e){return null!==this.search(e,a.PlotRowSearchMode.Exact)}valueAt(e){const t=this.search(e);return null!==t?t.value:null}add(e,t){if(this._shareRead)return l.logDebug("add: readonly collection modification attempt"),!1;const i={index:e,value:t},s=this._nonCachedSearch(e,a.PlotRowSearchMode.Exact,h);return this._invalidateSearchCaches(),null===s?(this._items.splice(this._lowerbound(e,h),0,i),this._start=0,this._end=this._items.length,!0):(this._items[s]=i,!1)}search(e,t=a.PlotRowSearchMode.Exact,i){return this._searchImpl(e,t,this._rowSearchCacheByIndex,this._rowSearchCacheByIndexWithoutEmptyValues,h,i)}searchByTime(e,t=a.PlotRowSearchMode.Exact,i){return this._searchImpl(e,t,this._rowSearchCacheByTime,this._rowSearchCacheByTimeWithoutEmptyValues,d,i)}fold(e,t){let i=t;for(let t=this._start;t=i;--t){const i=this._indexAt(t),s=this._valueAt(t);if(e(i,s))return{index:i,value:s}}return null}each(e){for(let t=this._start;tthis._start&&(t._start-=1),t}rangeIterator(e,t){const i=this._lowerbound(e,h),s=this._upperbound(t);if(i===s)return{hasNext:()=>!1,next:()=>{throw new Error("Invalid operation")}};let r=i-1;return{hasNext:()=>r(r+=1,this._items[r])}}minMaxOnRangeCached(e,t,i){if(this.isEmpty())return null;let s=null;for(const r of i){ +s=p(s,this._minMaxOnRangeCachedImpl(e-r.offset,t-r.offset,r.name))}return s}minMaxOnRange(e,t,i){if(this.isEmpty())return null;let s=null;for(const r of i){s=p(s,this._minMaxOnRange(e-r.offset,t-r.offset,r.name))}return s}merge(e){return this._shareRead?(l.logDebug("merge: readonly collection modification attempt"),null):0===e.length?null:this.isEmpty()||e[e.length-1].indexthis._items[this._items.length-1].index?this._append(e):1===e.length&&e[0].index===this._items[this._items.length-1].index?(this._updateLast(e[0]),e[0]):this._merge(e)}addTail(e,t=!1){if(0===e.length)return;let i=0;t&&this._end-this._start>0&&(i=1,this._items[this._end-this._start-1].value=e[0].value);for(let t=i;tvoid 0!==e)).sort(((e,t)=>e.index-t.index)),this._invalidateSearchCaches(),this._minMaxCache.clear(),this._start=0,this._end=this._items.length}remove(e){if(this._shareRead)return l.logDebug("remove: readonly collection modification attempt"),null;const t=this._nonCachedSearch(e,a.PlotRowSearchMode.NearestRight,h);if(null===t)return null;const i=this._items.splice(t);return this._end=this._items.length,this._minMaxCache.clear(),this._invalidateSearchCaches(),i.length>0?i[0]:null}state(){const e=this._items.slice(this._start,this._end);return{start:0,end:e.length,data:e}}restoreState(e){e?(this._start=e.start,this._end=e.end,this._shareRead=!1,this._items=e.data,this._minMaxCache.clear(),this._invalidateSearchCaches()):this.clear()}_indexAt(e){return this._items[e].index}_valueAt(e){return this._items[e].value}_length(){return this._items.length}_searchImpl(e,t,i,s,r,n){const o=void 0!==n?i:s,a=void 0!==n?1e4*(t+1)+n:t;let l=o.get(e);if(void 0!==l){const e=l.get(a);if(void 0!==e)return e}const c=this._nonCachedSearch(e,t,r,n);if(null===c)return null;const h={index:this._indexAt(c),value:this._valueAt(c)};return void 0===l&&(l=new Map,o.set(e,l)),l.set(a,h),h}_nonCachedSearch(e,t,i,s){const r=this._lowerbound(e,i),n=r===this._end||e!==i(this._items[r]);if(n&&t!==a.PlotRowSearchMode.Exact)switch(t){case a.PlotRowSearchMode.NearestLeft:return this._searchNearestLeft(r,s);case a.PlotRowSearchMode.NearestRight:return this._searchNearestRight(r,s);default:throw new TypeError("Unknown search mode")}if(void 0===s||n||t===a.PlotRowSearchMode.Exact)return n?null:r;switch(t){case a.PlotRowSearchMode.NearestLeft:return this._nonEmptyNearestLeft(r,s);case a.PlotRowSearchMode.NearestRight: +return this._nonEmptyNearestRight(r,s);default:throw new TypeError("Unknown search mode")}}_nonEmptyNearestRight(e,t){const i=(0,s.ensure)(this._emptyValuePredicate),r=(0,s.ensure)(t);for(;e=this._start&&i(this._valueAt(e),r);)e-=1;return et(e)t.index>e),this._start,this._end)}_plotMinMax(e,t,i){let s=null;const r=this._plotFunctions.get(i);if(void 0===r)throw new Error(`Plot "${i}" is not registered`);for(let i=e;is.max&&(s.max=e)))}return s}_invalidateCacheForRow(e){const t=Math.floor(e.index/c);this._minMaxCache.forEach((e=>e.delete(t)))}_prepend(e){return(0,s.assert)(!this._shareRead,"collection should not be readonly"),(0,s.assert)(0!==e.length,"plotRows should not be empty"),this._invalidateSearchCaches(),this._minMaxCache.clear(),this._items=e.concat(this._items),this._start=0,this._end=this._items.length,e[0]}_append(e){return(0,s.assert)(!this._shareRead,"collection should not be readonly"),(0,s.assert)(0!==e.length,"plotRows should not be empty"),this._invalidateSearchCaches(),this._minMaxCache.clear(),this._items=this._items.concat(e),this._start=0,this._end=this._items.length,e[0]}_updateLast(e){(0,s.assert)(!this.isEmpty(),"plot list should not be empty");const t=this._items[this._end-1];(0,s.assert)(t.index===e.index,"last row index should match new row index"),this._invalidateCacheForRow(e),this._invalidateSearchCaches(),this._items[this._end-1]=e}_merge(e){return(0,s.assert)(0!==e.length,"plot rows should not be empty"),this._invalidateSearchCaches(),this._minMaxCache.clear(),this._items=_(this._items,e),this._start=0,this._end=this._items.length,e[0]}_minMaxOnRangeCachedImpl(e,t,i){if(this.isEmpty())return null;let r=null;const n=(0,s.ensureNotNull)(this.firstIndex()),o=(0,s.ensureNotNull)(this.lastIndex()),a=Math.max(e,n),l=Math.min(t,o),h=Math.ceil(a/c)*c,d=Math.max(h,Math.floor(l/c)*c);r=p(r,this._minMaxOnRange(a,Math.min(h,t,l),i));let u=this._minMaxCache.get(i);void 0===u&&(u=new Map,this._minMaxCache.set(i,u));for(let e=Math.max(h+1,a);et[o].index?o++:(n++,o++,r--);return r}(e,t),s=new Array(i);let r=0,n=0;const o=e.length,a=t.length;let l=0;for(;rt[n].index?(s[l]=t[n],n++):(s[l]=t[n],r++,n++),l++;for(;r{"use strict";i.d(t,{PriceAxisView:()=>p});var s=i(86441),r=i(34026),n=i(38325),o=i(38223),a=i(74359),l=i(18807),c=i(68441);const h=new Path2D("M7.5 0.8a1 1 0 0 0 0 13.4 1 1 0 0 0 0-13.4zm0 1a1 1 0 0 1 0 11 1 1 0 0 1 0-11zm-.97-.25A3.5 3.5 0 0 0 3.5 0 3.5 3.5 0 0 0 0 3.5a3.5 3.5 0 0 0 1.75 3.03l.5-.86A2.5 2.5 0 0 1 1 3.5 2.5 2.5 0 0 1 3.5 1a2.5 2.5 0 0 1 2.17 1.25zm6.72 4.78A3.5 3.5 0 0 0 15 3.5 3.5 3.5 0 0 0 11.5 0a3.5 3.5 0 0 0-3.03 1.75l.86.5A2.5 2.5 0 0 1 11.5 1 2.5 2.5 0 0 1 14 3.5a2.5 2.5 0 0 1-1.25 2.17zM7 5h1v5H7zm3 2v1H5V7z");class d{constructor(e,t){this._bodyBox=null,this.setData(e,t)}setData(e,t){this._data=e,this._commonData=t}lastDrawnBodyBox(){return this._bodyBox}draw(e,t,i,r,n,l,h){var d,u,p,_;const m=this._data;if(!m.visible||this._isOutOfScreen(t,n))return;const g=this._commonData,f=void 0!==m.labelIcon,v=t.borderSize,S=t.paddingTop+g.additionalPaddingTop,y=t.paddingBottom+g.additionalPaddingBottom,b=t.paddingInner,w=m.ignoreAdditionalPaddingInner?0:t.additionalPaddingInner,P=t.paddingOuter,C=t.fontSize;let x=m.text,T=m.textColor||g.textColor,I=m.secondLine||"",M=g.secondLineTextColor||T,L=m.thirdLine||"";const A=g.thirdLineTextColor||T;0===I.length&&(I=L,M=A,L=""),0===x.length&&(x=I,T=M,I=L,M=A,L=""),e.save(),e.font=t.font;const k=i.yMidCorrection(e,x)*h,D=Math.ceil(i.measureText(e,x)),E=C+S+y,V=(null!==(d=m.labelIconMinWidth)&&void 0!==d?d:0)*h,B=Boolean(I),R=Boolean(L),N=B?Math.ceil(i.measureText(e,I)):0,O=R?Math.ceil(i.measureText(e,L)):0,F=v+b+P+D+w,W=N>0?v+b+P+N+w:0,H=O>0?v+b+P+O+w:0,z=Math.max(F,W,H),U=Math.max(1,Math.floor(h));let j=Math.round(E*h);j%2!=U%2&&(j+=1);const G=Math.round((C+t.lineSpacing)*h),q=Math.round(2*(C+t.lineSpacing)*h),$=Math.max(1,Math.floor(v*h)),Y=m.separatorVisible?$:0,K=m.borderVisible?$:0,Z=f?Math.max(j,V):Math.round(z*h),X=Math.round(w*h),J=Math.ceil(r*h),Q=Math.ceil(b*h),ee=Math.round((null!==(u=g.fixedCoordinate)&&void 0!==u?u:g.coordinate)*h)-Math.floor(.5*h),te=Math.floor(ee+U/2-j/2),ie=te+j,se="right"===l,re=void 0!==m.xCoord?Math.round(m.xCoord*h)+(se?1:-1)*Math.round(Z/2):se?J-Y:Y,ne=J;let oe,ae=re;const le=null!==(p=m.backgroung)&&void 0!==p?p:g.background;e.fillStyle=le;const ce=2*h;if(e.textAlign=se?"right":"left", +e.textBaseline="middle",se?(ae=re-Z,oe=re-X-Q-1):(ae=re+Z,oe=re+X+Q),this._bodyBox=null,x||f){const i=R?j+q:B?j+G:j,r=null!==(_=g.borderColor)&&void 0!==_?_:le,n=void 0!==m.xCoord?ce:0;if(((t,r,o)=>{if(se){(0,c.drawRoundRectWithInnerBorder)(e,ae,te,Z,i,t,m.overridenRadius?(0,c.scaleDrawRoundRectRadii)(m.overridenRadius,h):[ce,n,n,ce],K,r,o);const a=(0,s.point)(ae/h,te/h),l=a.add((0,s.point)(Z/h,i/h));this._bodyBox=(0,s.box)(a,l)}else{(0,c.drawRoundRectWithInnerBorder)(e,re,te,Z,i,t,m.overridenRadius?(0,c.scaleDrawRoundRectRadii)(m.overridenRadius,h):[n,ce,ce,n],K,r,o);const a=(0,s.point)(re/h,te/h),l=a.add((0,s.point)(Z/h,i/h));this._bodyBox=(0,s.box)(a,l)}})(le,r,g.borderStyle),m.separatorVisible&&(e.fillStyle=t.paneBackgroundColor,e.fillRect(se?ne-Y:0,te,Y,ie-te)),f){switch(m.labelIcon){case 0:this._drawPlusIcon(e,re,ae,te,ee,ie,U);break;case 1:this._drawClockIcon(e,re,ae,ee,U,h)}return void e.restore()}e.save(),e.translate(oe,(te+ie)/2+k),(0,a.drawScaled)(e,h,h,(()=>{e.fillStyle=T,e.fillText(x,0,0)})),e.restore()}B&&(e.fillStyle=M,e.save(),e.translate(oe,(te+ie)/2+k+G),(0,a.drawScaled)(e,h,h,(()=>{e.fillText((0,o.startWithLTR)(I),0,0)})),e.restore()),R&&(e.fillStyle=A,e.save(),e.translate(oe,(te+ie)/2+k+q),(0,a.drawScaled)(e,h,h,(()=>{e.fillText((0,o.startWithLTR)(L),0,0)})),e.restore()),e.restore()}topBottomTotalHeight(e){const t=this._lines();if(!this._data.visible||0===t)return{top:0,bottom:0,total:0};const i=e.fontSize/2+e.paddingTop+this._commonData.additionalPaddingTop,s=(t-.5)*e.fontSize+(t-1)*e.lineSpacing+e.paddingBottom+this._commonData.additionalPaddingBottom;return{top:i,bottom:s,total:i+s}}hitTest(e){return function(e,t){var i;const o=(0,n.lastMouseOrTouchEventInfo)().isTouch?10:0,a=e.hitTestData;if(void 0===a||!e.visible)return null;const{itemBox:c,clickHandler:h,tooltip:d}=a;if(c){const n=(0,s.box)(new s.Point(c.min.x-o,c.min.y-o),new s.Point(c.max.x+o,c.max.y+o));if((0,r.pointInBox)(t,n))return new l.HitTestResult(null!==(i=e.hitTarget)&&void 0!==i?i:l.HitTarget.Custom,{clickHandler:null==h?void 0:h.bind(null,t),tapHandler:null==h?void 0:h.bind(null,t),hoverModelFromAxis:a.hoverModelFromAxis,activeItem:a.activeItem,tooltip:d})}return null}(this._data,e)}_drawPlusIcon(e,t,i,s,r,n,o){e.fillStyle=this._commonData.textColor,e.strokeStyle=this._commonData.textColor,e.lineWidth=o;const a=Math.abs(t-i);let l=Math.round(.35*a);l%2!=o%2&&(l+=1);let c=Math.round(.65*a);c%2!=o%2&&(c+=1);const h=Math.floor((a-l)/2),d=Math.min(t,i),u=d+Math.floor(a/2-o/2);e.fillRect(d+h,r,l,o),e.fillRect(u,s+h,o,l),e.beginPath(),e.arc(u+o/2,r+o/2,c/2,0,2*Math.PI,!1),e.stroke()}_drawClockIcon(e,t,i,s,r,n){e.fillStyle=this._commonData.textColor,e.lineWidth=r;const o=Math.abs(t-i);let a=Math.round(.35*o);a%2!=r%2&&(a+=1);let l=Math.round(.65*o);l%2!=r%2&&(l+=1);const c=Math.min(t,i)+Math.floor(o/2-r/2);e.save(),e.translate(c+r/2-l/2,s+r/2-l/2),e.scale(n,n),e.fill(h),e.restore()}_lines(){const e=this._data;return(e.text?1:0)+(e.secondLine?1:0)+(e.thirdLine?1:0)}_isOutOfScreen(e,t){var i +;const s=this._commonData,r=null!==(i=s.fixedCoordinate)&&void 0!==i?i:s.coordinate,{total:n}=this.topBottomTotalHeight(e),o=n/this._lines();return r-o/2-3>t||r+(n-o/2)+3<0}}var u=i(87095);class p{constructor(e){this._commonRendererData={coordinate:0,textColor:"#FFF",background:"#000",additionalPaddingBottom:0,additionalPaddingTop:0},this._axisRendererData={text:"",visible:!1,separatorVisible:!1,borderVisible:!1,ignoreAdditionalPaddingInner:!1},this._paneRendererData={text:"",visible:!1,separatorVisible:!0,borderVisible:!1,ignoreAdditionalPaddingInner:!0},this._invalidated=!0,this._active=!1,this._axisRenderer=new(e||d)(this._axisRendererData,this._commonRendererData),this._paneRenderer=new(e||d)(this._paneRendererData,this._commonRendererData)}setActive(e){this._active=e}text(){return this._updateRendererDataIfNeeded(),this._axisRendererData.text}secondLineText(){return this._updateRendererDataIfNeeded(),this._axisRendererData.secondLine}thirdLineText(){return this._updateRendererDataIfNeeded(),this._axisRendererData.thirdLine}background(){return this._updateRendererDataIfNeeded(),this._commonRendererData.background}color(){return this._updateRendererDataIfNeeded(),this.generateTextColor(this.background())}generateTextColor(e){return(0,u.colorFromBackground)(e)}coordinate(){return this._updateRendererDataIfNeeded(),this._commonRendererData.coordinate}floatCoordinate(){var e;return this._updateRendererDataIfNeeded(),null!==(e=this._commonRendererData.floatCoordinate)&&void 0!==e?e:this._commonRendererData.coordinate}update(e){this._invalidated=!0}topBottomTotalHeight(e){this._updateRendererDataIfNeeded();const{top:t,bottom:i,total:s}=this._axisRenderer.topBottomTotalHeight(e),{top:r,bottom:n,total:o}=this._paneRenderer.topBottomTotalHeight(e);return{top:Math.max(t,r),bottom:Math.max(i,n),total:Math.max(s,o)}}getFixedCoordinate(){return this._commonRendererData.fixedCoordinate||0}setFixedCoordinate(e){this._commonRendererData.fixedCoordinate=e}isVisible(){return this._updateRendererDataIfNeeded(),this._axisRendererData.visible||this._paneRendererData.visible}isAxisLabelVisible(){return this._updateRendererDataIfNeeded(),this._axisRendererData.visible}isPaneLabelVisible(){return this._updateRendererDataIfNeeded(),this._paneRendererData.visible}renderer(){return this._updateRendererDataIfNeeded(),this._axisRenderer}paneRenderer(){return this._updateRendererDataIfNeeded(),this._paneRenderer}setPaneRendererLabelIcon(e){this._paneRendererData.labelIcon=e}setPaneLabelVisible(e){this._paneRendererData.visible=e,this._invalidated=!0}ignoreAlignment(){return!1}_updateRendererDataIfNeeded(){this._invalidated&&(this._commonRendererData.fixedCoordinate=void 0,this._updateRendererData(this._axisRendererData,this._paneRendererData,this._commonRendererData),this._invalidated=!1)}}},80842:(e,t,i)=>{"use strict";i.d(t,{PriceDataSource:()=>a,isPriceDataSource:()=>o});var s=i(14292),r=i(57898),n=i(18611);function o(e){return e instanceof a}class a extends s.DataSource{constructor(e,t){super(t),this._formatterChanged=new r.Delegate, +this._priceStepChanged=new r.Delegate,this._currencyChanged=new r.Delegate,this._unitChanged=new r.Delegate,this._priceRangeReadyChanged=new r.Delegate,this._priceStep=null,this._priceRangeReady=!0,this._model=e}base(){return 0}model(){return this._model}currencyChanged(){return this._currencyChanged}isCurrencySource(){return!0}isDisplayedInLegend(){return!0}unitChanged(){return this._unitChanged}isUnitSource(){return!0}priceRange(e,t){return null}isDraggable(){return!0}priceLineColor(e){return e}formatterChanged(){return this._formatterChanged}priceStep(e){return this._priceStep}priceStepChanged(){return this._priceStepChanged}isIncludedInAutoScale(){return!0}correctScaleMargins(e){return e}priceRangeReady(){return this._priceRangeReady}priceRangeReadyChanged(){return this._priceRangeReadyChanged}disablePriceRangeReady(){const e=this.priceScale();null===e||e.isAutoScale()||e.mainSource()!==this||(this._priceRangeReady=!1,e.recalculatePriceRangeOnce()),this._priceRangeReadyChanged.fire(!1)}statusView(){return null}legendView(){return null}marketStatusModel(){return null}dataUpdatedModeModel(){return null}dataProblemModel(){return null}_enablePriceRangeReady(){this._priceRangeReady=!0,this._priceRangeReadyChanged.fire(!0)}_onSourceCurrencyChanged(){(0,n.isActingAsSymbolSource)(this)||this._currencyChanged.fire()}_onSourceUnitChanged(){(0,n.isActingAsSymbolSource)(this)||this._unitChanged.fire()}_onSourcePriceRangeReadyChanged(e){(0,n.isActingAsSymbolSource)(this)||e||this.disablePriceRangeReady()}}},11527:(e,t,i)=>{"use strict";i.d(t,{PriceLineAxisView:()=>l,SeriesPriceLineAxisView:()=>c,StudyPriceLineAxisView:()=>h});var s=i(42275),r=i(50151),n=i(79849),o=i(68441);class a{constructor(e,t){this.setData(e,t)}setData(e,t){this._data=e,this._commonData=t}draw(e,t,i,s,a,l,c){var h;if(!this._data.visible)return;const d=null!==(h=this._commonData.fixedCoordinate)&&void 0!==h?h:this._commonData.coordinate;e.lineWidth=Math.max(1,Math.floor((0,r.ensureDefined)(this._data.linewidth)*c)),e.lineCap="butt",(0,o.setLineStyle)(e,void 0===this._data.linestyle?n.LINESTYLE_DOTTED:this._data.linestyle),e.strokeStyle=this._commonData.textColor,(0,o.drawHorizontalLine)(e,Math.round(d*c),0,Math.ceil(s*c))}topBottomTotalHeight(e){return{top:0,bottom:0,total:0}}}class l extends s.PriceAxisView{constructor(e){super(e||a)}ignoreAlignment(){return!0}_updateRendererData(e,t,i){if(t.visible=!1,e.visible=!1,!this._isVisible())return;const s=this._value();s.noData||(i.background="",i.textColor=this._priceLineColor(s.color),i.coordinate=s.coordinate,i.floatCoordinate=s.floatCoordinate,e.linewidth=this._lineWidth(),e.linestyle=this._lineStyle(),e.backgroundAreaVisible=this._backgroundAreaVisible(),e.backgroundAreaColor=this._backgroundAreaColor(),e.backgroundAreaHeight=this._backgroundAreaHeight(),e.visible=!0)}_lineStyle(){return n.LINESTYLE_DOTTED}_backgroundAreaVisible(){return!1}_backgroundAreaColor(){return""}_backgroundAreaHeight(){return 0}}class c extends l{constructor(e){super(),this._series=e}_value(){ +return this._series.lastValueData(void 0,!0)}_priceLineColor(e){return this._series.priceLineColor(e)}_lineWidth(){return this._series.properties().childs().priceLineWidth.value()}_isVisible(){const e=this._series.model().properties().childs().scalesProperties.childs().showSeriesLastValue.value();return this._series.properties().childs().showPriceLine.value()&&e}}class h extends l{constructor(e,t){super(),this._study=e,this._plotname=t}_value(){return this._study.lastValueData(this._plotname,!0)}_lineWidth(){return this._study.properties().childs().styles.childs()[this._plotname].childs().linewidth.value()}_lineStyle(){return n.LINESTYLE_DOTTED}_priceLineColor(e){return e}_isVisible(){const e=this._study.model().properties().childs().scalesProperties.childs().showStudyLastValue.value(),t=this._study.isPlotVisibleAt(this._plotname,1);return this._study.properties().childs().styles.childs()[this._plotname].childs().trackPrice.value()&&e&&t}}},74304:(e,t,i)=>{"use strict";var s;i.d(t,{PriceAxisLastValueMode:()=>s}),function(e){e[e.LastPriceAndPercentageValue=0]="LastPriceAndPercentageValue",e[e.LastValueAccordingToScale=1]="LastValueAccordingToScale"}(s||(s={}))},78211:(e,t,i)=>{"use strict";i.d(t,{fromIndexedTo100:()=>c,fromLog:()=>p,fromPercent:()=>o,getCurrentModePriceText:()=>g,getOppositeModePriceText:()=>f,logFormulaForPriceRange:()=>_,logFormulasAreSame:()=>m,toIndexedTo100:()=>h,toIndexedTo100Range:()=>d,toLog:()=>u,toPercent:()=>a,toPercentRange:()=>l});var s=i(34256),r=i(37160);const n={logicalOffset:4,coordOffset:1e-4};function o(e,t){return t<0&&(e=-e),e/100*t+t}function a(e,t){const i=100*(e-t)/(t||1);return t<0?-i:i}function l(e,t){const i=a(e.minValue(),t),r=a(e.maxValue(),t);return new s.PriceRange(i,r)}function c(e,t){return t<0&&(e=-e),(e-=100)/100*t+t}function h(e,t){const i=100*(e-t)/t+100;return t<0?-i:i}function d(e,t){const i=h(e.minValue(),t),r=h(e.maxValue(),t);return new s.PriceRange(i,r)}function u(e,t){const i=Math.abs(e);if(i<1e-25)return 0;const s=(0,r.log10)(i+t.coordOffset)+t.logicalOffset;return e<0?-s:s}function p(e,t){const i=Math.abs(e);if(i<1e-15)return 0;const s=Math.pow(10,i-t.logicalOffset)-t.coordOffset;return e<0?-s:s}function _(e){if(null===e)return n;const t=Math.abs(e.maxValue()-e.minValue());if(t>=1||t<1e-15)return n;const i=Math.ceil(Math.abs(Math.log10(t))),s=n.logicalOffset+i;return{logicalOffset:s,coordOffset:1/Math.pow(10,s)}}function m(e,t){return e.logicalOffset===t.logicalOffset&&e.coordOffset===t.coordOffset}function g(e,t){return e.isPercentage()?t.formattedPricePercentage:e.isIndexedTo100()?t.formattedPriceIndexedTo100:t.formattedPriceAbsolute}function f(e,t){return e.isPercentage()||e.isIndexedTo100()?t.formattedPriceAbsolute:t.formattedPricePercentage}},34256:(e,t,i)=>{"use strict";i.d(t,{PriceRange:()=>n});var s=i(1722);const r=(0,i(59224).getLogger)("Chart.PriceRange");class n{constructor(e,t){if(null!==e&&"object"==typeof e){const t=e;this._minValue=t.m_minValue,this._maxValue=t.m_maxValue}else{const i=e;this._minValue=i,void 0!==t&&(this._maxValue=t)}} +equals(e){return this._minValue===e._minValue&&this._maxValue===e._maxValue}clone(){return new n(this._minValue,this._maxValue)}minValue(){return this._minValue}setMinValue(e){this._minValue=e}maxValue(){return this._maxValue}setMaxValue(e){this._maxValue=e}length(){return this._maxValue-this._minValue}isEmpty(){return this._maxValue===this._minValue||this._maxValue!=this._maxValue||this._minValue!=this._minValue}serialize(){return{m_maxValue:this._maxValue,m_minValue:this._minValue}}state(){return{max:this._maxValue,min:this._minValue}}merge(e){return new n(Math.min(this.minValue(),e.minValue()),Math.max(this.maxValue(),e.maxValue()))}apply(e,t){this._minValue=Math.min(this._minValue,e),this._maxValue=Math.max(this._maxValue,t)}set(e,t){this._minValue=e,this._maxValue=t}scaleAroundCenter(e){if(!(0,s.isNumber)(e))return void r.logDebug("PriceRange.scaleAroundCenter: invalid coeff");if(0===this._maxValue-this._minValue)return;const t=.5*(this._maxValue+this._minValue);let i=this._maxValue-t,n=this._minValue-t;i*=e,n*=e,this._maxValue=t+i,this._minValue=t+n}shift(e){(0,s.isNumber)(e)?(this._maxValue+=e,this._minValue+=e):r.logDebug("PriceRange.shift: invalid coeff")}containsStrictly(e){return e.minValue()>this._minValue&&e.maxValue(){"use strict";i.d(t,{createPrimitiveProperty:()=>n});var s=i(59452),r=i.n(s);function n(e){return new(r())(e)}},13637:(e,t,i)=>{"use strict";i.d(t,{ThemedDefaultProperty:()=>w,extractAllPropertiesKeys:()=>v,extractState:()=>S,factoryDefaultsForCurrentTheme:()=>y});var s=i(58121),r=i(99094),n=i(16230),o=i(98279),a=i(38651),l=i(50151),c=i(56840),h=i(22767),d=i(45345),u=i(26843),p=i(59452),_=i.n(p),m=i(85804),g=i(57898);const f=(0,i(59224).getLogger)("ThemedDefaults");function v(e){const t=Object.keys(e),i=[];return t.forEach((t=>{const s=e[t];if((0,o.default)(s)){v(s).forEach((e=>i.push(`${t}.${e}`)))}else i.push(t)})),i}function S(e,t,i=""){const s={};return t.forEach((r=>{const n=r.split("."),a=n[0],l=e[a],c=""===i?a:`${i}.${a}`;if(e.hasOwnProperty(a))if(n.length>1){if(!(0,o.default)(l))return void f.logError(`path ${c} must be an object, but it is a primitive`);{const e=t.filter((e=>e.startsWith(`${a}.`))).map((e=>e.split(".").slice(1).join(".")));s[a]=S(l,e,c)}}else{if((0,o.default)(l))return void f.logError(`path ${c} must be a primitive, but it is an object`);s[a]=l}})),s}function y(e,t){var i;const r=null!==(i=d.watchedTheme.value())&&void 0!==i?i:u.StdTheme.Light,n=(0,h.deepCopy)(e);return(0,s.default)(n,(0,l.ensureDefined)(t.get(r))),n}function b(e,t){const i=(0,r.default)(e,((e,i,s)=>{if(void 0===t[s])return e;if(!(0,n.default)(i,t[s]))if((0,o.default)(i)&&(0,o.default)(t[s])){const r=b(i,t[s]);void 0!==r&&(e[s]=r)}else e[s]=i;return e}),{});return(0,a.default)(i)?void 0:i}class w extends(_()){constructor(e,t,i,r,n,o){super(function(e,t,i,r){var n;const o=t(),a=S((0,h.deepCopy)(null!==(n=c.getJSON(e,null))&&void 0!==n?n:{}),i);return(0,s.default)(o,a),(0,s.default)(o,S(null!=r?r:{},i)), +o}(e,t,n,o)),this._applyingThemeInProcess=!1,this._restoreFactoryDefaultsEvent=new g.Delegate,this._defaultName=e,this._defaultsSupplier=t,this._notThemedDefaultsKeys=i,this._themedDefaultsKeys=r,this._allStateKeys=n,this._allDefaultsKeys=[...i,...r]}restoreFactoryDefaults(){const e=this._defaultsSupplier();this.mergeAndFire(e),this.saveDefaults(),this._restoreFactoryDefaultsEvent.fire()}addExclusion(){}state(){return S(super.state(),this._allStateKeys)}mergePreferences(e){this.mergeAndFire(S(e,this._allStateKeys))}childChanged(e){super.childChanged(e),this._applyingThemeInProcess||this.saveDefaults()}saveDefaults(){const e=this.state(),t=this._defaultsSupplier();let i=b(S(e,this._notThemedDefaultsKeys),S(t,this._notThemedDefaultsKeys));const r=S(t,this._themedDefaultsKeys),n=S(e,this._themedDefaultsKeys),o=b(n,r);(0,a.default)(o)||(i=null!=i?i:{},(0,s.default)(i,n)),(0,m.saveDefaults)(this._defaultName,i)}}},48686:(e,t,i)=>{"use strict";i.d(t,{combineProperty:()=>r});var s=i(59680);function r(e,...t){const i=()=>e(...t.map((e=>e.value()))),r=(0,s.createPrimitiveProperty)(i()),n=()=>r.setValue(i()),o={};for(const e of t)e.subscribe(o,n);return r.destroy=()=>{t.forEach((e=>e.unsubscribeAll(o))),t.forEach((e=>e.release()))},r}},63821:(e,t,i)=>{"use strict";i.d(t,{convertPropertyToWatchedValue:()=>r});var s=i(97145);function r(e){const t=new s.WatchedValue(e.value());let i=!1;e.subscribe(t,(()=>{i||(i=!0,t.setValue(e.value()),i=!1)}));const r=()=>{i||(i=!0,e.setValue(t.value()),i=!1)};return t.subscribe(r),t.spawn((()=>{e.unsubscribeAll(t),t.unsubscribe(r)}))}},49152:(e,t,i)=>{"use strict";i.d(t,{combineProperty:()=>o.combineProperty,createWVFromGetterAndSubscription:()=>s.createWVFromGetterAndSubscription,createWVFromGetterAndSubscriptions:()=>r.createWVFromGetterAndSubscriptions,createWVFromProperty:()=>n});var s=i(28986),r=i(49475);function n(e){return(0,s.createWVFromGetterAndSubscription)((()=>e.value()),e)}i(59680);var o=i(48686)},28986:(e,t,i)=>{"use strict";i.d(t,{createWVFromGetterAndSubscription:()=>r});var s=i(97145);function r(e,t){const i=new s.WatchedValue(e()),r={};t.subscribe(r,(()=>{i.setValue(e())}));return i.readonly().spawn((()=>t.unsubscribeAll(r)))}},49475:(e,t,i)=>{"use strict";i.d(t,{createWVFromGetterAndSubscriptions:()=>r});var s=i(97145);function r(e,t){const i=new s.WatchedValue(e()),r={};t.forEach((t=>t.subscribe(r,(()=>{i.setValue(e())}))));return i.readonly().spawn((()=>t.forEach((e=>e.unsubscribeAll(r)))))}},59452:(e,t,i)=>{"use strict";const{weakReference:s,ownership:r}=i(19782);var n=i(1722).isFunction,o=i(57898).Delegate;function a(e){if(this._listeners=new o,this._childs=[],this._muteChildChanges=!1,void 0!==e)if(this.isPrimitiveType(e))this._value=e;else for(var t in e)this.addProperty(t,e[t])}a.prototype.destroy=function(){this.listeners().destroy()},a.prototype.merge=function(e,t){var i=null;if(t)var s=(i=[]).length;if(void 0===e)return i;if(this.isPrimitiveType(e))return t&&this._value!==e&&i.push(this),this._value=e,i;if(Array.isArray(e))for(var r=0;rs&&i.push(this),i},a.prototype.mergeAndFire=function(e){var t=this.merge(e,!0);this._muteChildChanges=!0,t.forEach((function(e){e._muteChildChanges=!0})),t.forEach((function(e){e._muteChildChanges=!1,e.listeners().fire(e)})),this._muteChildChanges=!1,t.length>0&&this.listeners().fire(this)},a.prototype.state=function(e){var t=n(this.value)?this.value():void 0;void 0===t&&(t={});for(var i=0;i=0},a.prototype.addChild=function(e,t){this[e]&&this[e].unsubscribe(this,this.childChanged),this[e]=t,-1===this._childs.indexOf(e)&&this._childs.push(e),t.subscribe(this,this.childChanged)},a.prototype.childChanged=function(e,t){this._muteChildChanges||this.listeners().fire(this)},a.prototype.subscribe=function(e,t){this.listeners().subscribe(e,t,!1)},a.prototype.unsubscribe=function(e,t){this.listeners().unsubscribe(e,t)},a.prototype.unsubscribeAll=function(e){this.listeners().unsubscribeAll(e)},a.prototype.childs=function(){return this},a.prototype.weakReference=function(){return s(this)},a.prototype.ownership=function(){return r(this)},e.exports=a},71625:(e,t,i)=>{"use strict";i.d(t,{QuotesProvider:()=>o});var s=i(2438),r=i(57898),n=i(36174);class o{constructor(e="full"){this._quotes=null,this._quoteSessionSymbol=null,this._quoteSessionClientId="",this._pausedQuoteSessionSymbol=null,this._quotesUpdate=new r.Delegate,this._quoteSymbolChanged=new r.Delegate,this._multiplexerType=e}setQuotesSessionSymbol(e){this._quoteSessionSymbol!==e&&(this._pausedQuoteSessionSymbol=null, +this._quoteSessionClientId||(this._quoteSessionClientId="series-"+(0,n.guid)()),this._unsubscribeQuoteSession(),this._quoteSessionSymbol=e,this._quoteSymbolChanged.fire(),e&&this._subscribeQuoteSession(e))}quotesUpdate(){return this._quotesUpdate}quoteSymbolChanged(){return this._quoteSymbolChanged}quotes(){return this._quotes}isPaused(){return null!==this._pausedQuoteSessionSymbol}pause(){null===this._pausedQuoteSessionSymbol&&(this._pausedQuoteSessionSymbol=this._quoteSessionSymbol,this._unsubscribeQuoteSession())}resume(){null!==this._pausedQuoteSessionSymbol&&(this._subscribeQuoteSession(this._pausedQuoteSessionSymbol),this._pausedQuoteSessionSymbol=null)}destroy(){this._unsubscribeQuoteSession()}_onUpdate(e,t){this._quotes=e&&e.values||null,t&&t.values&&this._quotesUpdate.fire(e,t)}_subscribeQuoteSession(e){this._quoteSessionSymbol=e,(0,s.getQuoteSessionInstance)(this._multiplexerType).subscribe(this._quoteSessionClientId,this._quoteSessionSymbol,this._onUpdate.bind(this))}_unsubscribeQuoteSession(){this._quoteSessionSymbol&&((0,s.getQuoteSessionInstance)(this._multiplexerType).unsubscribe(this._quoteSessionClientId,this._quoteSessionSymbol),this._quoteSessionSymbol=null,this._quotes=null)}}},94025:(e,t,i)=>{"use strict";i.r(t),i.d(t,{compareResolutions:()=>k,convertResolutionsFromSettings:()=>I,getApplicableIntervalForFrequency:()=>b,getCustomResolutions:()=>D,getDefaultResolution:()=>S,getMaxResolutionValue:()=>x,getRangeResolution:()=>f,getResolutionByChartStyle:()=>y,getResolutionsFromSettings:()=>T,getServerInterval:()=>w,getTimeBasedResolution:()=>v,getTranslatedResolution:()=>E,getTranslatedResolutionModel:()=>V,intervalIsSupported:()=>W,isAvailable:()=>m,isIntervalEnabled:()=>O,isResolutionMultiplierValid:()=>P,isSecondsEnabled:()=>R,isTicksEnabled:()=>N,mergeResolutions:()=>M,normalizeIntervalString:()=>_,parseIntervalValue:()=>F,setLastUsedResolution:()=>g,sortResolutions:()=>L});var s=i(44352),r=i(36274),n=i(42960),o=i(56840),a=i(82992),l=i(15051),c=i(1722),h=i(14483);const d={[r.ResolutionKind.Ticks]:1,[r.ResolutionKind.Seconds]:60,[r.ResolutionKind.Minutes]:1440,[r.SpecialResolutionKind.Hours]:24,[r.ResolutionKind.Days]:365,[r.ResolutionKind.Weeks]:52,[r.ResolutionKind.Months]:12,[r.ResolutionKind.Range]:1e6,[r.ResolutionKind.Invalid]:NaN},u={[r.ResolutionKind.Ticks]:0,[r.ResolutionKind.Seconds]:1,[r.ResolutionKind.Minutes]:2,[r.SpecialResolutionKind.Hours]:3,[r.ResolutionKind.Days]:4,[r.ResolutionKind.Weeks]:5,[r.ResolutionKind.Months]:6,[r.ResolutionKind.Range]:7,[r.ResolutionKind.Invalid]:8},p={[r.ResolutionKind.Invalid]:"",[r.ResolutionKind.Ticks]:s.t(null,{context:"interval_short"},i(59231)),[r.ResolutionKind.Seconds]:s.t(null,{context:"interval_short"},i(2949)),[r.ResolutionKind.Minutes]:s.t(null,{context:"interval_short"},i(6791)),[r.SpecialResolutionKind.Hours]:s.t(null,{context:"interval_short"},i(13994)),[r.ResolutionKind.Days]:s.t(null,{context:"interval_short"},i(13395)),[r.ResolutionKind.Weeks]:s.t(null,{context:"interval_short"},i(85521)),[r.ResolutionKind.Months]:s.t(null,{ +context:"interval_short"},i(37720)),[r.ResolutionKind.Range]:s.t(null,{context:"interval_short"},i(69838))};function _(e){return r.Interval.parse(e).value()}function m(e){const t=r.Interval.parse(e);if(!R()&&t.isSeconds())return!1;if(!N()&&t.isTicks())return!1;const i=t.value(),s=a.linking.dataFrequencyResolution.value();if(void 0!==s&&k(i,s)<0)return!1;const n=a.linking.supportedResolutions.value();return void 0!==n?void 0!==n.find((e=>_(e)===i)):t.isSeconds()?Boolean(a.linking.seconds.value()):t.isTicks()?Boolean(a.linking.ticks.value()):t.isIntraday()?Boolean(a.linking.intraday.value()):t.isDWM()}function g(e){r.Interval.isValid(e)&&(r.Interval.isRange(e)?o.setValue("chart.lastUsedRangeResolution",e):o.setValue("chart.lastUsedTimeBasedResolution",e))}function f(e){const t=o.getValue("chart.lastUsedRangeResolution");if(void 0!==t&&r.Interval.isRange(t))return t;let i="100R";for(const t of e){const e=r.Interval.parse(t);if(e.isRange()){const t=e.value();if("100R"===t)return t;i=t}}return i}function v(e){const t=o.getValue("chart.lastUsedTimeBasedResolution");if(void 0!==t&&r.Interval.isTimeBased(t))return t;let i="1D";for(const t of e){const e=r.Interval.parse(t);if(e.isTimeBased()){const t=e.value();if("1D"===t)return t;i=t}}return i}function S(e){return e?"100R":"1D"}function y(e,t,i){const s=n.isRangeStyle(e),o=r.Interval.isRange(t);return!s&&o?v(i):s&&!o?f(i):t}function b(e,t){return k(t,e)>=0?t:e}function w(e){return r.Interval.isRange(e)?"1":e}function P(e){const{interval:t,guiResolutionKind:i}=r.Interval.parseExt(e);if(!t.isValid())return!1;const s=t.multiplier();return(i===r.SpecialResolutionKind.Hours?s/60:s)<=C(i)}function C(e){const t=d[e];return Number.isNaN(t)?1:t}function x(e){return C(r.Interval.parseExt(e).guiResolutionKind)}function T(e){const t=I(o.getJSON(e,[]));return(0,l.uniq)(t.filter(P).map(_))}function I(e){return Array.isArray(e)?e:Object.keys(e).map(r.Interval.normalize).filter(c.notNull)}function M(...e){let t=[].concat(...e);return t=(0,l.uniq)(t.filter(P).map(_)),L(t)}function L(e){return e.sort(k)}function A(e){const t=r.Interval.parse(e),i=t.multiplier()||1;return t.isMinuteHours()?[r.SpecialResolutionKind.Hours,i/60]:[t.kind(),i]}function k(e,t){if(e===t)return 0;const[i,s]=A(e),[r,n]=A(t);return i!==r?u[i]-u[r]:s-n}function D(){return[]}function E(e){const{multiplier:t,shortKind:i}=V(e);return`${t}${i}`}function V(e,t){const i=r.Interval.parse(e);let s=i.multiplier(),n=i.kind();if(!i.isValid()){if(t)return null;throw new TypeError("Can't translate invalid interval")}return i.isMinuteHours()&&(s=Math.floor(s/60),n=r.SpecialResolutionKind.Hours),{multiplier:s.toString(),shortKind:B(n),hint:`${s} ${B(n,s)}`,mayOmitMultiplier:i.isDWM()&&1===s,mayOmitShortKind:i.isMinutes()&&!i.isMinuteHours()}}function B(e,t){if(!t)return p[e];switch(e){case r.ResolutionKind.Ticks:return s.t(null,{plural:"ticks",count:t},i(99136));case r.ResolutionKind.Days:return s.t(null,{plural:"days",count:t},i(30572));case r.ResolutionKind.Weeks:return s.t(null,{plural:"weeks",count:t},i(47966)) +;case r.ResolutionKind.Months:return s.t(null,{plural:"months",count:t},i(99062));case r.ResolutionKind.Seconds:return s.t(null,{plural:"seconds",count:t},i(71787));case r.ResolutionKind.Minutes:return s.t(null,{plural:"minutes",count:t},i(69143));case r.SpecialResolutionKind.Hours:return s.t(null,{plural:"hours",count:t},i(52254));case r.ResolutionKind.Range:return s.t(null,{plural:"ranges",count:t},i(82797));default:return e}}function R(){return h.enabled("seconds_resolution")}function N(){return h.enabled("tick_resolution")||false}function O(e){{const t=r.Interval.parse(e);if(!R()&&t.isSeconds())return!1;if(!N()&&t.isTicks())return!1}return!0}function F(e){let t;t=h.enabled("tick_resolution")?/^[,\s]*(^[1-9][0-9]*)?\s*([hdwmst]?)\s*$/i:/^[,\s]*(^[1-9][0-9]*)?\s*([hdwms]?)\s*$/i;const i=t.exec(e)||[],s=~~i[1],r=i[2]&&i[2].toUpperCase()||null,n={qty:!s&&r?1:s,unit:r};return n.error=!s&&!r,n.intraday=!(n.error||n.unit&&"H"!==n.unit&&"S"!==n.unit&&"T"!==n.unit),n.range="R"===n.unit,n}function W(e){if(h.enabled("allow_supported_resolutions_set_only")){const t=r.Interval.normalize(e);return null!==t&&m(t)}{const t=F(e);if(t.error)return!1;if(!h.enabled("custom_resolutions")){const t=r.Interval.normalize(e),i=window.ChartApiInstance.defaultResolutions().filter(O);if(!t||-1===i.indexOf(t))return!1}const i=a.linking.dataFrequencyResolution.value();if(void 0!==i&&null!==t.unit&&b(i,t.unit)!==t.unit)return!1;if(t.intraday)return a.linking.intraday.value();{const e=a.linking.supportedResolutions.value();return!e||null!==t.unit&&!!~e.indexOf(t.unit)}}}},29541:(e,t,i)=>{"use strict";i.d(t,{barSpacingByScaleRatio:()=>o,priceRangeByScaleRatio:()=>n,scaleRatio:()=>r});var s=i(34256);function r(e,t){if(t.isLog()||e.isEmpty()||t.isEmpty())return null;const i=function(e){if(e.isEmpty())return null;const t=e.priceRange();if(null===t)return null;const i=t.length();return e.internalHeight()/i}(t);if(null===i)return null;return e.getValidBarSpacing()/Math.max(1e-10,i)}function n(e,t,i){if(e.isLog()||null===i||e.isEmpty())return null;const r=e.priceRange();if(null===r||r.isEmpty())return null;const n=e.internalHeight()/(t/i),o=r.length();if(n===o)return r;const a=(n-o)/2;return new s.PriceRange(r.minValue()-a,r.maxValue()+a)}function o(e,t){if(e.isLog()||null===t||e.isEmpty())return null;const i=e.priceRange();if(null===i)return null;const s=i.length();return e.internalHeight()/s*t}},49535:(e,t,i)=>{"use strict";i.d(t,{allPriceScaleSelectionStrategyInfo:()=>c,createPriceScaleSelectionStrategy:()=>l});var s=i(50151),r=i(44352),n=i(28853);class o{constructor(e){this._priceScalesLimit=8,this._metaInfo=e}metaInfo(){return this._metaInfo}findSuitableScale(e,t,i,s){if(void 0!==s)return this._tryToGetDesiredPriceScale(e,t,s,i);if((0,n.isStudy)(t)){const s=t.metaInfo();if("Volume"===s.shortId&&e.containsMainSeries())return e.createPriceScaleAtPosition("overlay");const r=t.desiredPriceScalePosition();if(null!==r)return this._tryToGetDesiredPriceScale(e,t,r,i);if(void 0!==i&&((0, +n.isStudy)(i)||e.isMainPane())&&s.is_price_study)return this._getPriceScaleTheSameAsForSource(i,e)}let r=!1;if((0,n.isStudy)(t)){const i=t.metaInfo().groupingKey;if(void 0!==i){const t=e.model().findNonOverlayStudyWithGroupingKey(i,e);if(null!==t)return this._getPriceScaleTheSameAsForSource(t.study,t.pane)}r=Boolean(t.metaInfo().is_price_study)}else t===e.model().mainSeries()&&(r=!0);if(r){const t=this._findFirstScaleForPriceStudy(e);if(null!==t)return t}return this.createNewPriceScaleIfPossible(e)}canCreateNewPriceScale(e){return e.leftPriceScales().length+e.rightPriceScales().lengthi&&this._priceScaleIsPrice(e.rightPriceScales()[i],t))return e.rightPriceScales()[i];if(e.leftPriceScales().length>i&&this._priceScaleIsPrice(e.leftPriceScales()[i],t))return e.leftPriceScales()[i]}return null}_targetPriceScaleIndex(e,t){if(e.mainSource()===t.mainSeries())return 0}_tryToGetDesiredPriceScale(e,t,i,r){switch(i){case"left":return this.canCreateNewPriceScale(e)?e.createPriceScaleAtPosition("left"):e.createPriceScaleAtPosition("overlay");case"right":return this.canCreateNewPriceScale(e)?e.createPriceScaleAtPosition("right"):e.createPriceScaleAtPosition("overlay");case"as-series":return void 0!==r?(0,s.ensureNotNull)(r.priceScale()):e.isMainPane()?(0,s.ensureNotNull)((0,s.ensureNotNull)(e.mainDataSource()).priceScale()):this.createNewPriceScaleIfPossible(e);case"overlay":return e.createPriceScaleAtPosition("overlay")}}}const a=[{name:"left",title:r.t(null,void 0,i(65323)),ctor:class extends o{constructor(e){super(e)}apply(e){const t=e.model();e.rightPriceScales().slice(0).forEach((i=>e.movePriceScale(i,"left",this._targetPriceScaleIndex(i,t))))}createNewPriceScaleIfPossible(e){return this.canCreateNewPriceScale(e)?e.createPriceScaleAtPosition("left"):e.createPriceScaleAtPosition("overlay")}}},{name:"right",title:r.t(null,void 0,i(14113)),ctor:class extends o{constructor(e){super(e)}apply(e){const t=e.model();e.leftPriceScales().slice(0).forEach((i=>e.movePriceScale(i,"right",this._targetPriceScaleIndex(i,t))))}createNewPriceScaleIfPossible(e){return this.canCreateNewPriceScale(e)?e.createPriceScaleAtPosition("right"):e.createPriceScaleAtPosition("overlay")}}},{name:"auto",title:r.t(null,void 0,i(86951)),ctor:class extends o{constructor(e){super(e)}apply(e){if(e.containsMainSeries()){const t=(0,s.ensureNotNull)((0,s.ensureNotNull)(e.mainDataSource()).priceScale());e.movePriceScale(t,"right",0)}const t=e.model();for(;e.leftPriceScales().length>e.rightPriceScales().length;){const i=e.leftPriceScales()[e.leftPriceScales().length-1];e.movePriceScale(i,"right",this._targetPriceScaleIndex(i,t))} +for(;e.rightPriceScales().length-e.leftPriceScales().length>1;){const i=e.rightPriceScales()[e.rightPriceScales().length-1];e.movePriceScale(i,"left",this._targetPriceScaleIndex(i,t))}}createNewPriceScaleIfPossible(e){if(!this.canCreateNewPriceScale(e))return e.createPriceScaleAtPosition("overlay");const t=e.leftPriceScales().lengtht.name===e)));return new t.ctor(t)}function c(){return a}},57490:(e,t,i)=>{"use strict";i.d(t,{SelectionIndexes:()=>r});var s=i(50151);class r{constructor(e){this._baseIndex=null,this._offsetInBar=null,this._offsetInTime=null,this._barsBetweenPoints=null,this._timescale=e}indexes(){const e=this._timescale.visibleBarsStrictRange();if(null===e)return[];const t=e.firstBar(),i=e.lastBar();if(null===this._offsetInTime||null===this._barsBetweenPoints){const e=this._timescale.barSpacing();this._barsBetweenPoints=Math.floor(120/e),this._offsetInBar=i%this._barsBetweenPoints,this._offsetInTime=this._timescale.indexToTimePoint(this._offsetInBar),this._baseIndex=this._timescale.baseIndex()}const r=this._timescale.baseIndex();this._baseIndex!==r&&(this._baseIndex=r,this._offsetInBar=(0,s.ensureNotNull)(this._timescale.timePointToIndex(this._offsetInTime)));const n=(0,s.ensureNotNull)(this._offsetInBar),o=[];let a=Math.floor((t-n)/this._barsBetweenPoints);const l=Math.floor((i-n)/this._barsBetweenPoints);for(;a<=l;a++)o.push(n+a*this._barsBetweenPoints);return o}clear(){this._offsetInBar=null,this._offsetInTime=null,this._baseIndex=null,this._barsBetweenPoints=null}}},80101:(e,t,i)=>{"use strict";i.d(t,{SelectionRenderer:()=>c});var s=i(34026),r=i(48891),n=i(18807),o=i(66103),a=i(59590);const l=r.colorsPalette["color-tv-blue-600"];class c extends a.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e||null}setData(e){this._data=e}hitTest(e){if(!this._data||!this._data.visible)return null;for(let t=0;t(0,s.pointInBox)(t,e)))}_drawImpl(e){if(null===this._data||!this._data.visible)return;const{context:t,horizontalPixelRatio:i}=e;t.strokeStyle=void 0!==this._data.color?this._data.color:l,t.lineCap="butt";const s=Math.max(1,Math.floor(i));t.lineWidth=s;const r=this._data.vertOffset||0;for(let i=0;i{"use strict";i.d(t,{SeriesBase:()=>Xt});var s=i(50151),r=i(49483),n=i(51768),o=i(76422),a=i(59224),l=i(80842),c=i(13497),h=i(97034),d=i(86094),u=i(34256),p=i(59452),_=i.n(p),m=i(42960),g=i(66846),f=i(61146),v=i(88732),S=i(79055),y=i(44352),b=i(14483),w=i(58557),P=i(11877),C=i(11321);function x(e){const t="QUANDL"===(e=e||{}).exchange,s={title:"",description:"",interval:"",exchange:"",provider:"",chartStyle:"",sessionDescription:"",priceSource:""};let r="";if(e.description&&t)if(2===e.description.split("/").length)r=e.description.split("/")[1];else{e.description.split("'").filter((e=>e.length)).forEach((e=>{let t=[];t=e&&("/"===e[0]||/\d+\/\(?/.test(e))?[e]:e.split("/").filter((e=>e.length)),r+=t[2===t.length?1:0]}))}else r=e.description?e.description:e.symbol;if(e.ticker?(s.title=e.ticker,s.description=T(r)):s.title=T(r),e.interval&&(s.interval=(0,C.translatedIntervalString)(e.interval)),t&&e.description){const t=/[\w_]+\/[\w_]+/.exec(e.description);t&&t[0]?s.provider=T(t[0].split("/")[0]):s.provider=T(e.description.split("/")[0])}return e.exchange&&(s.exchange=T(e.exchange)),s.chartStyle=T(function(e){return e.inputs,8===e.style?y.t(null,void 0,i(40530)):""}(e)),e.sessionDescription&&(s.sessionDescription=T(e.sessionDescription)),void 0!==e.priceSource&&(s.priceSource=T(e.priceSource)),s}function T(e){return e.replace(/'/g,"")}const I=y.t(null,void 0,i(89659)),M=b.enabled("hide_unresolved_symbols_in_legend"),L=b.enabled("symbol_info_price_source");class A extends P.StatusProviderBase{constructor(e,t,i,s){super(t),this._series=e,this._statusViewProperties=i,this._options=s||{}}text(){return function(e){const t=x(e);return(e.ticker?t.description:t.title)+(t.interval?", "+t.interval:"")+function(e,t=", "){return(e.provider?`${t}${e.provider}`:"")+(e.exchange?`${t}${e.exchange}`:"")+(e.chartStyle?`${t}${e.chartStyle}`:"")+(e.branding?`${t}${e.branding}`:"")+(e.sessionDescription?`${t}${e.sessionDescription}`:"")}(t)}(this._getTitleGenerationOptions())}getSplitTitle(){return x(this._getTitleGenerationOptions())}bold(){return!1}size(){return this._statusViewProperties.childs().fontSize.value()+"px"}errorStatus(){const e=this._series.seriesErrorMessage();return null!==e?{error:e,title:I}:null}_getTitleGenerationOptions(){var e,t,i;const s=this._series.symbolInfo(),r=this._statusViewProperties.childs(),n=this._series.symbolTextSourceProxyProperty().value();let o;if(r.showExchange.value()&&s){const i=(0,m.isEconomicSymbol)(s)&&(null!==(t=null===(e=s.source2)||void 0===e?void 0:e.description)&&void 0!==t?t:s.source);o=i||s.exchange}const a=null!==(i=L&&(null==s?void 0:s.price_source_id)?this._series.model().availablePriceSources().name(s.price_source_id):null)&&void 0!==i?i:void 0;return{description:D(n,s),exchange:o,symbol:M&&null===s?"":this._series.symbol(), +interval:r.showInterval.value()&&!this._options.hideResolution?this._series.interval():void 0,style:this._series.properties().childs().style.value(),inputs:this._series.getInputsProperties().state(),boxSize:this._series.data().boxSize,reversalAmount:this._series.data().reversalAmount,ticker:k(n,s),priceSource:a}}}function k(e,t){return"ticker-and-description"!==e?"":null!==t?t.name:void 0}function D(e,t){if(null!==t)return"ticker"===e?t.name:"long-description"===e&&void 0!==t.long_description?t.long_description:(0,w.getTranslatedSymbolDescription)({pro_name:t.pro_name||void 0,short_name:t.name||void 0,description:t.description||void 0,short_description:t.short_description||void 0,local_description:t.local_description||void 0,language:t.language||void 0})}class E extends S.StatusView{constructor(e,t,i,s){super(new A(e,t,i,s)),this._invalidated=!0,this._series=e,this._series.onRestarted().subscribe(this,this.update),this._series.dataEvents().symbolResolved().subscribe(this,this.update),this._series.dataEvents().completed().subscribe(this,this.update),this._series.boxSizeValue().subscribe(this.update.bind(this)),i.childs().symbolTextSource.listeners().subscribe(this,this.update)}getSeriesPrecision(){let e=4;const t=this._series.symbolInfo();return t&&t.pricescale&&(e=Math.round(Math.log(t.pricescale)/Math.log(10))),e}round(e){const t=this.getSeriesPrecision(),i=Math.round(e*Math.pow(10,t))/Math.pow(10,t);return i?i.toString():""}update(){this._invalidated=!0}text(){return this._updateImpl(),super.text()}color(){return this._updateImpl(),super.color()}bold(){return this._updateImpl(),super.bold()}size(){return this._updateImpl(),super.size()}getSplitTitle(){return this._updateImpl(),this._statusProvider.getSplitTitle()}_updateImpl(){this._invalidated&&(this._bold=this._statusProvider.bold(),this._size=this._statusProvider.size(),this._text=this._statusProvider.text(),this._invalidated=!1)}}var V=i(50335),B=i(93835),R=i(88348),N=i(58333),O=i(15367);const F=r.CheckMobile.any(),W=b.enabled("hide_resolution_in_legend");class H extends B.DataWindowView{constructor(e,t){super(),this._invalidated=!0,this._series=e,this._model=t,this._valuesProvider=this._createValuesProvider(e,t),this._items=this._valuesProvider.getItems().map((e=>new B.DataWindowItem(e.id,e.title,"",e.unimportant))),this.update()}update(){this._invalidated=!0}items(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._items}series(){return this._series}_updateImpl(){var e,t;const i=this._series.symbolInfo();if(i){const e=[i.name];W||e.push((0,C.translatedIntervalString)(this._series.interval())),(0,m.isEconomicSymbol)(i)&&i.source?e.push(i.source):e.push((0,r.onWidget)()||"forex"===i.type?i.exchange:i.listed_exchange),this._header=e.join(", "),this._title=i.description}else this._header=this._series.symbol();let s=this._model.crossHairSource().appliedIndex();b.enabled("use_last_visible_bar_value_in_legend")&&!(0, +V.isNumber)(s)&&(s=null!==(t=null===(e=this._model.timeScale().visibleBarsStrictRange())||void 0===e?void 0:e.lastBar())&&void 0!==t?t:NaN);const n=this._valuesProvider.getValues(s);for(let e=0;ee||t||i),i.showBarChange.weakReference(),i.showSeriesOHLC.weakReference(),i.showVolume.weakReference()),this._visibilityProperty.subscribe(this,this.update)}areValuesVisible(){return this._visibilityProperty.value()}additional(){return null}marketTitle(){const e=this._series.marketStatusModel().status().value();return this._showLastPriceAndChangeOnly()&&("pre_market"===e||"post_market"===e)?`${G}:`:""}destroy(){this._backgroundColorSpawn.destroy(),this._visibilityProperty.destroy()}_createValuesProvider(e,t){return new U(e,t)}}var $=i(97145),Y=i(32923),K=i(41249) +;function Z(){const e=window.ChartApiInstance.serverTimeOffset();return Date.now()/1e3+e}function X(e,t,i){return e<=i?t<=i?1/0:t/1e3:Math.min(e,t)/1e3}class J{constructor(e){this._marketStatus=new $.WatchedValue(null),this._lastMarketStatus=null,this._sessionsSpec=null,this._nextSessionEdgeInternal=null,this._nextSessionEdge=new $.WatchedValue(null),this._recalcNextSessionEdgeTimerId=null,this._futuresContractExpirationTime=null,this._quotesProvider=e,e.quotesUpdate().subscribe(this,this._update.bind(this)),e.quoteSymbolChanged().subscribe(this,this._resetStatus)}destroy(){this._quotesProvider.quotesUpdate().unsubscribeAll(this),this._quotesProvider.quoteSymbolChanged().unsubscribeAll(this),null!==this._recalcNextSessionEdgeTimerId&&clearTimeout(this._recalcNextSessionEdgeTimerId)}futuresContractExpirationTime(){return this._futuresContractExpirationTime}setSymbolInfo(e){var t,i,s,r,n;if(this._nextSessionEdgeInternal=null,null===e)return void(this._sessionsSpec=null);const o=new Y.SessionSpec(e.timezone,null!==(t=e.session_display)&&void 0!==t?t:e.session,e.session_holidays,e.corrections);let a,l;const c=null===(i=e.subsessions)||void 0===i?void 0:i.find((e=>"premarket"===e.id)),h=null===(s=e.subsessions)||void 0===s?void 0:s.find((e=>"postmarket"===e.id));void 0!==c&&(a=new Y.SessionSpec(e.timezone,null!==(r=c["session-display"])&&void 0!==r?r:c.session,e.session_holidays,c["session-correction"])),void 0!==h&&(l=new Y.SessionSpec(e.timezone,null!==(n=h["session-display"])&&void 0!==n?n:h.session,e.session_holidays,h["session-correction"])),this._sessionsSpec={general:o,preMarket:a,postMarket:l},this._recalculateNextSessionEdge()}status(){return this._marketStatus}nextSessionEdge(){return this._nextSessionEdge}_resetStatus(){this._lastMarketStatus=null,this._marketStatus.setValue(null)}_update(e){void 0!==e&&void 0!==e.values.current_session&&(this._lastMarketStatus=e.values.current_session),null!==this._lastMarketStatus?this._marketStatus.setValue(this._lastMarketStatus):this._resetStatus()}_getNextSessionEdgeInternal(){var e;if(null===this._sessionsSpec||"24x7"===this._sessionsSpec.general.spec())return null;const t=1e3*Z();if(null===this._nextSessionEdgeInternal||(null!==(e=this._nextSessionEdgeInternal.timestamp)&&void 0!==e?e:1/0)<=t/1e3){const{general:e,preMarket:i,postMarket:s}=this._sessionsSpec,r=(0,K.get_timezone)(e.timezone()),n=(0,K.utc_to_cal)(r,t),o=X((0,K.cal_to_utc)(r,e.alignToNearestSessionStart(n,1)),(0,K.cal_to_utc)(r,e.alignToNearestSessionEnd(n,1)),t),a=X(void 0!==i?(0,K.cal_to_utc)(r,i.alignToNearestSessionStart(n,1)):1/0,void 0!==i?(0,K.cal_to_utc)(r,i.alignToNearestSessionEnd(n,1)):1/0,t),l=X(void 0!==s?(0,K.cal_to_utc)(r,s.alignToNearestSessionStart(n,1)):1/0,void 0!==s?(0,K.cal_to_utc)(r,s.alignToNearestSessionEnd(n,1)):1/0,t);let c=Math.min(o,a,l);if(c===1/0){const t=Z(),i=6e4,s=new Date(Math.round(new Date(1e3*t).getTime()/i)*i).getTime()+i,n=(0,K.utc_to_cal)(r,s),o=X((0,K.cal_to_utc)(r,e.alignToNearestSessionStart(n,1)),(0, +K.cal_to_utc)(r,e.alignToNearestSessionEnd(n,1)),s),h=Math.min(o,a,l);h!==1/0?(this._nextSessionEdgeInternal={timestamp:c},c=h):this._nextSessionEdgeInternal={timestamp:null}}this._nextSessionEdgeInternal=c===l?{timestamp:c,status:"post_market"}:c===a?{timestamp:c,status:"pre_market"}:{timestamp:c}}return this._nextSessionEdgeInternal}_recalculateNextSessionEdge(){const e=this._getNextSessionEdgeInternal();if(null===e||null===e.timestamp)return void this._nextSessionEdge.setValue(null);const t={status:e.status,remainingSeconds:Math.max(0,e.timestamp-Z())};if(null===this._recalcNextSessionEdgeTimerId){const e=Number.isFinite(t.remainingSeconds)?Math.ceil(t.remainingSeconds%60):1;this._recalcNextSessionEdgeTimerId=setTimeout((()=>this._recalculateNextSessionEdgeByTimer()),1e3*e)}this._nextSessionEdge.setValue(t)}_recalculateNextSessionEdgeByTimer(){this._recalcNextSessionEdgeTimerId=null,this._recalculateNextSessionEdge()}}var Q=i(42226),ee=i(36274),te=i(60156),ie=i(94421),se=i(36174);let re=0;class ne{constructor(e,t){this._extrapolatedData=[],this._cacheForFuture=!1,this._modelId=re++,this._builderCache=null,this._uniqueId=(0,se.randomHashN)(6),this._resolution=t,this._symbolInfo=e,this._valid=Boolean(e.timezone)&&Boolean(e.session),this._session=new te.SessionInfo(e.timezone,e.session,e.session_holidays,e.corrections)}syncSourceTarget(){return{uniqueId:this._uniqueId,resolution:this._resolution,symbolInfo:this._symbolInfo,session:this._session.state()}}getSymbolInfo(){return this._symbolInfo}getSession(){return this._session}getResolution(){return this._resolution}uniqueId(){return this._modelId}distance(e,t){if(!this.isValid())return{success:!1};if(e>t)return{success:!1};if(e===t)return{success:!0,result:0};let i=this._extrapolatedData.length,s=0!==i?this._extrapolatedData[0]:null,r=null!==s?this._extrapolatedData[i-1]:null;const n=er){const s=(0,ie.extrapolateBarsFrontToTime)(this._barBuilder(),r||1e3*e,1e3*t,2e3,!0);this._extrapolatedData=this._extrapolatedData.concat(s.times),i=this._extrapolatedData.length,this._cacheForFuture=n}if(r=this._extrapolatedData[i-1],r<1e3*t)return{success:!1};const o=this._extrapolatedData.indexOf(1e3*t);return-1===o?{success:!1}:{success:!0,result:o}}projectTime(e,t){if(!this.isValid())return e;let i=this._extrapolatedData.length,s=i>0?this._extrapolatedData[0]:null,r=null!==s?this._extrapolatedData[i-1]:null;const n=t>=0;1e3*e===s&&this._cacheForFuture===n||(this._extrapolatedData=[1e3*e],i=1,s=null,r=null);const o=Math.abs(t);if(null===s||o>=i){const s=(0,ie.extrapolateBarsFrontByCount)(this._barBuilder(),r||1e3*e,Math.sign(t)*(o-i+1),!0);this._extrapolatedData=this._extrapolatedData.concat(s.times),i=this._extrapolatedData.length,this._cacheForFuture=n}return i0?e.delay:900;return Math.round(t/60)}listedExchange(){const e=this._symbolInfo.value();return null!==e?e.listed_exchange:""}async description(){const e=this._symbolInfo.value();if(null===e)return"";return{}.description||e.listed_exchange}exchange(){const e=this._symbolInfo.value();return null!==e?e.exchange:""}proName(){const e=this._symbolInfo.value();return null!==e?e.pro_name:""}proPerm(){const e=this._symbolInfo.value();return null!==e?e.pro_perm:""}firstReplacedByBatsExchange(){const e=this._symbolInfo.value();return e&&(0,le.firstReplacedByBatsExchange)(e)}_resetStatus(){this._dataUpdatedInfoStatus.setValue(null)}_update(){const e=this._symbolInfo.value();if(null===e)return void this._dataUpdatedInfoStatus.setValue(null);const t=this._status.value();if("string"==typeof t)return void this._dataUpdatedInfoStatus.setValue(null);if(2===t||1===t)return;const i=he(e,t,this._updatePeriod.value());0!==i.length?this._dataUpdatedInfoStatus.setValue(i):this._dataUpdatedInfoStatus.setValue(null)}}i(69798);var ue=i(1722);(0,a.getLogger)("Chart.DataProblemModel");class pe{constructor(e,t){this._mainDataProblem=new oe.WatchedObject(null),this._supportPortalProblems=new oe.WatchedObject([]),this._allDataProblems=new oe.WatchedObject([]),this._pushStreamHandler=null,this._destroyed=!1,this._quotesProvider=e,this._quotesProvider.quotesUpdate().subscribe(this,this._update.bind(this)),this._resetSubscription=t,this._resetSubscription.subscribe(this,this._resetStatus),this._mainDataProblem.subscribe((()=>this._updateAllDataProblems())),this._supportPortalProblems.subscribe((()=>this._updateAllDataProblems())), +this._requestSupportPortalProblems()}destroy(){this._quotesProvider.quotesUpdate().unsubscribeAll(this),this._resetSubscription.unsubscribeAll(this),this._destroyed=!0}dataProblems(){return this._allDataProblems}_resetStatus(){this._mainDataProblem.setValue(null)}_update(e){void 0===e.values||void 0===e.values.data_problem?this._resetStatus():this._mainDataProblem.setValue((0,ue.clone)(e.values.data_problem))}_updateAllDataProblems(){const e=this._mainDataProblem.value(),t=this._supportPortalProblems.value();this._allDataProblems.setValue(null===e?t:[e,...t])}async _requestSupportPortalProblems(){0}}var _e=i(71625),me=i(87095),ge=i(42275),fe=i(74304);function ve(e){return e<10?`0${e}`:e.toString()}var Se=i(78211),ye=i(28558);const be=b.enabled("force_exchange_as_title"),we=b.enabled("chart_style_hilo_last_price"),Pe=[0,1,2,14,15,3,16,9,8,10];we&&Pe.push(12);const Ce={alwaysShowGlobalLast:!1,visibleOnHistoryOnly:!1,showCountdown:!0,showSymbolLabel:!0,useSolidBodyColor:!0};class xe extends ge.PriceAxisView{constructor(e,t,i){super(),this._previousCountdown="",this._source=e,this._model=t,this._options={...Ce,...i}}updateCountdown(){this._countdownText()!==this._previousCountdown&&(this.update((0,ye.sourceChangeEvent)(this._source.id())),this._model.updateSourcePriceScale(this._source))}_getSource(){return this._source}_getModel(){return this._model}_isCountdownEnabled(){return this._options.showCountdown}_countdownText(){const e=ee.Interval.parse(this._source.interval());if(e.isDWM()||e.isTicks()||e.isSeconds()&&1===e.multiplier())return"";const t=this._source.data().bars().last();if(null===t)return"";const i=1e3*(0,s.ensure)(t.value[0]),r=ee.Interval.parse(this._source.interval()).inMilliseconds(),n=i.valueOf()+r;let o=Math.round((n-this._currentTime())/1e3);if(o<=0)return"";o=Math.min(o,r/1e3);let a=null;o>=3600&&(a=ve(Math.floor(o/3600))),o%=3600;const l=ve(Math.floor(o/60));o%=60;const c=ve(Math.floor(o));return null!==a?`${a}:${l}:${c}`:`${l}:${c}`}_updateRendererData(e,t,i){var r;if(e.visible=!1,t.visible=!1,!this._source.isVisible())return;const n=this._source.properties().childs();if(!we&&12===n.style.value())return;const o=this._model.timeScale().visibleBarsStrictRange(),a=this._source.data().last();if(null===o||null===a)return;if(this._options.visibleOnHistoryOnly&&o.contains(a.index))return;const l=this._model.properties().childs().scalesProperties.childs();let c=l.showSeriesLastValue.value(),h=this._isCountdownEnabled()&&n.showCountdown.value()&&Pe.includes(n.style.value())&&(this._options.alwaysShowGlobalLast||o.contains(a.index)),d=this._options.showSymbolLabel&&l.showSymbolLabels.value();const u=l.seriesLastValueMode.value()===fe.PriceAxisLastValueMode.LastPriceAndPercentageValue,p=this._source.lastValueData(void 0,this._options.alwaysShowGlobalLast);if(p.noData)return;const _=8===n.style.value();if((c||h||d)&&_&&n.haStyle.childs().showRealLastPrice.value()){const e=this._source.lastValueData(void 0,!1),t=this._source.lastValueData(void 0,!0);e.noData||t.noData||e.index!==t.index||(c=!1,h=!1,d=!1)} +const m=(0,me.resetTransparency)(this._source.priceLineColor(p.color));if(this._options.useSolidBodyColor?(i.background=m,i.borderColor=void 0):(i.background=this._model.backgroundColorAtYPercentFromTop((null!==(r=i.fixedCoordinate)&&void 0!==r?r:i.coordinate)/(0,s.ensureNotNull)(this._model.paneForSource(this._source)).height()),i.borderColor=m),i.coordinate=p.coordinate,i.floatCoordinate=p.floatCoordinate,c||h){const t=this._axisFirstLineText(p,c);e.text=t,this._options.useSolidBodyColor?(i.textColor=this.generateTextColor(i.background),e.borderVisible=!1):(e.borderVisible=!0,i.textColor=m),e.textColor=i.textColor;const s=c&&u?(0,Se.getOppositeModePriceText)(this._source.priceScale(),p):"";e.secondLine=s,i.secondLineTextColor=i.textColor;const r=h?this._countdownText():"";this._previousCountdown=r,e.thirdLine=r,i.thirdLineTextColor=(0,me.generateColor)(i.textColor,25),0===t.length&&0===s.length&&0===r.length||(e.visible=!0)}d&&(t.text=this._paneText(d),t.visible=t.text.length>0)}_paneText(e){let t="";const i=this._source.symbolInfo();return be?t=(0,m.displayedSymbolExchange)(i):e&&(t=(0,m.displayedSymbolName)(i)),t}_axisFirstLineText(e,t){return t?(0,Se.getCurrentModePriceText)(this._source.priceScale(),e):""}_currentTime(){return Date.now()+1e3*this._source.serverTimeOffset()}}var Te=i(11527);class Ie extends xe{lastPrice(){return this._getSource().data().lastProjectionPrice}_updateRendererData(e,t,i){e.visible=!1,t.visible=!1;const r=this._getModel(),n=this._getSource(),o=n.priceScale(),a=r.timeScale(),l=this.lastPrice();if(a.isEmpty()||o.isEmpty()||void 0===l)return;const c=a.visibleBarsStrictRange();if(null===c)return;const h=c.firstBar(),u=c.lastBar(),p=n.data(),_=p.search(u,d.PlotRowSearchMode.NearestLeft);if(null===_)return;const m=n.nearestIndex(h,d.PlotRowSearchMode.NearestRight);if(void 0===m)return;const g=n.model().properties().childs().scalesProperties.childs(),f=(0,s.ensureNotNull)(p.valueAt(m))[4];let v=i.background,S=g.showSeriesLastValue.value(),y=!1,b=!1,w=!1;const P=n.lastValueData(4,!1),C=n.properties().childs();if(8===C.style.value()&&C.haStyle.childs().showRealLastPrice.value()){const e=n.lastValueData(4,!0);if(e.noData||e.color===i.background||(v=(0,me.resetTransparency)(e.color)),!e.noData&&!P.noData){const t=e.index===P.index;y=t&&g.showSymbolLabels.value(),b=g.seriesLastValueMode.value()===fe.PriceAxisLastValueMode.LastPriceAndPercentageValue,S=S&&t,w=t&&this._isCountdownEnabled()&&C.showCountdown.value()}}else{const e=n.barColorer().barStyle(_.index,!0);v=(0,me.resetTransparency)(e.barColor)}if(i.background=v,i.textColor=this.generateTextColor(v),i.secondLineTextColor=i.textColor,i.thirdLineTextColor=(0,me.generateColor)(i.textColor,25),i.coordinate=o.priceToCoordinate(l,f),e.visible=S||w,!P.noData){const i=n.priceScale().isPercentage();P.formattedPriceAbsolute=o.formatPriceAbsolute(l),P.formattedPricePercentage=o.formatPricePercentage(l,f,!0),P.text=i?P.formattedPricePercentage:P.formattedPriceAbsolute,e.text=this._axisFirstLineText(P,S), +e.secondLine=S&&b?i?P.formattedPriceAbsolute:P.formattedPricePercentage:"",e.thirdLine=w?this._countdownText():"",t.text=this._paneText(y)}t.visible=y}}var Me=i(43493),Le=i(38003),Ae=i(48891),ke=i(79849);const De={light:{lineStyle:ke.LINESTYLE_DOTTED,lineWidth:1,textColor:Ae.colorsPalette["color-cold-gray-900"],backgroundColor:Ae.colorsPalette["color-tv-blue-50"],lineColor:Ae.colorsPalette["color-cold-gray-500"]},dark:{lineStyle:ke.LINESTYLE_DOTTED,lineWidth:1,textColor:Ae.colorsPalette["color-white"],backgroundColor:Ae.colorsPalette["color-tv-blue-a800"],lineColor:Ae.colorsPalette["color-cold-gray-500"]}};function Ee(e){return e?De.dark:De.light}class Ve extends Le.HorizontalLinePaneView{constructor(e,t,i){super(),this._model=e,this._isVisible=t.lineVisible,this._lineColor=t.lineColor,this._lineWidth=t.lineWidth,this._getValue=i}_updateImpl(){const e=this._lineRendererData;if(e.visible=!1,!this._isVisible.value())return;const t=this._model.mainSeries(),i=t.priceScale(),s=t.firstValue(),r=this._getValue();if(null===s||null===r)return;const n=Ee(this._model.dark().value()),o=this._lineColor.value()?this._lineColor.value():n.lineColor,a=this._lineWidth.value()?this._lineWidth.value():n.lineWidth;e.visible=!0,e.y=i.priceToCoordinate(r,s),e.linestyle=n.lineStyle,e.linewidth=a,e.color=o}}class Be extends ge.PriceAxisView{constructor(e,t,i,s){super(),this._model=e,this._label=t,this._isVisible=i,this._getValue=s}_updateRendererData(e,t,i){if(e.visible=!1,t.visible=!1,!this._isVisible.value())return;const s=this._model.mainSeries(),r=s.priceScale(),n=s.firstValue(),o=this._getValue();if(null===n||null===o)return;const a=Ee(this._model.dark().value());e.visible=!0,t.visible=!0,e.text=r.formatPriceAbsolute(o),t.text=this._label,i.coordinate=r.priceToCoordinate(o,n),i.background=a.backgroundColor,i.textColor=a.textColor}}class Re extends Te.PriceLineAxisView{constructor(e,t,i){super(),this._model=e,this._isLineVisible=t,this._getValue=i}_isVisible(){return this._isLineVisible.value()}_lineWidth(){return Ee(this._model.dark().value()).lineWidth}_lineStyle(){return Ee(this._model.dark().value()).lineStyle}_priceLineColor(e){return Ee(this._model.dark().value()).lineColor}_value(){const e=this._model.mainSeries(),t=e.priceScale(),i=e.firstValue(),s=this._getValue();if(null===i||null===s)return{noData:!0};const r=t.priceToCoordinate(s,i);return{noData:!1,floatCoordinate:r,coordinate:r,color:"",formattedPricePercentage:"",formattedPriceAbsolute:"",formattedPriceIndexedTo100:"",text:"",index:0}}}const Ne=y.t(null,void 0,i(30777)),Oe=y.t(null,void 0,i(8136));function Fe(e,t,i,s){const r=new Ve(e,i,s),n=new Be(e,i.label,i.labelVisible,s);return{paneView:r,panePriceAxisView:new Me.PanePriceAxisView(n,t,e),priceAxisView:n,priceLineAxisView:new Re(e,i.lineVisible,s)}}const We={light:{lineStyle:ke.LINESTYLE_DOTTED,lineWidth:1,textColor:(0,Ae.getHexColorByName)("color-cold-gray-900"),backgroundColor:(0,Ae.getHexColorByName)("color-tv-blue-50"),lineColor:(0,Ae.getHexColorByName)("color-cold-gray-500")},dark:{lineStyle:ke.LINESTYLE_DOTTED, +lineWidth:1,textColor:(0,Ae.getHexColorByName)("color-white"),backgroundColor:(0,Ae.getHexColorByName)("color-tv-blue-a800"),lineColor:(0,Ae.getHexColorByName)("color-cold-gray-500")}};function He(e){return e?We.dark:We.light}class ze extends Le.HorizontalLinePaneView{constructor(e,t,i){super(),this._model=e,this._isVisible=t.lineVisible,this._lineColor=t.lineColor,this._lineWidth=t.lineWidth,this._getValue=i}_updateImpl(){const e=this._lineRendererData;if(e.visible=!1,!this._isVisible.value())return;const t=this._model.mainSeries(),i=t.priceScale(),s=t.firstValue(),r=this._getValue();if(null===s||null===r)return;const n=He(this._model.dark().value()),o=this._lineColor.value()?this._lineColor.value():n.lineColor,a=this._lineWidth.value()?this._lineWidth.value():n.lineWidth;e.visible=!0,e.y=i.priceToCoordinate(r,s),e.linestyle=n.lineStyle,e.linewidth=a,e.color=o}}class Ue extends ge.PriceAxisView{constructor(e,t,i,s){super(),this._model=e,this._label=t,this._isVisible=i,this._getValue=s}_updateRendererData(e,t,i){if(e.visible=!1,t.visible=!1,!this._isVisible.value())return;const s=this._model.mainSeries(),r=s.priceScale(),n=s.firstValue(),o=this._getValue();if(null===n||null===o)return;const a=He(this._model.dark().value());e.visible=!0,t.visible=!0,e.text=r.formatPriceAbsolute(o),t.text=this._label,i.coordinate=r.priceToCoordinate(o,n),i.background=a.backgroundColor,i.textColor=a.textColor}}class je extends Te.PriceLineAxisView{constructor(e,t,i){super(),this._model=e,this._isLineVisible=t,this._getValue=i}_isVisible(){return this._isLineVisible.value()}_lineWidth(){return He(this._model.dark().value()).lineWidth}_lineStyle(){return He(this._model.dark().value()).lineStyle}_priceLineColor(e){return He(this._model.dark().value()).lineColor}_value(){const e=this._model.mainSeries(),t=e.priceScale(),i=e.firstValue(),s=this._getValue();if(null===i||null===s)return{noData:!0};const r=t.priceToCoordinate(s,i);return{noData:!1,floatCoordinate:r,coordinate:r,color:"",formattedPricePercentage:"",formattedPriceAbsolute:"",formattedPriceIndexedTo100:"",text:"",index:0}}}const Ge=y.t(null,void 0,i(22554));function qe(e,t,i,s){const r=i.childs(),n=function(e,t,i,s){const r=new ze(e,i,s),n=new Ue(e,i.label,i.labelVisible,s),o=new Me.PanePriceAxisView(n,t,e),a=new je(e,i.lineVisible,s);return{paneView:r,panePriceAxisView:o,priceAxisView:n,priceLineAxisView:a}}(e,t,{label:Ge,labelVisible:r.averageClosePriceLabelVisible,lineVisible:r.averageClosePriceLineVisible,lineColor:r.averagePriceLineColor,lineWidth:r.averagePriceLineWidth},(()=>s(0)));return{paneViews:[n.paneView],panePriceAxisViews:[n.panePriceAxisView],priceAxisViews:[n.priceAxisView],priceLineAxisViews:[n.priceLineAxisView]}}var $e=i(57898),Ye=i(97121),Ke=i(27856),Ze=i(86441);class Xe{constructor(){this._data=null}setData(e){this._data=e}data(){return this._data}draw(e,t){const i=this._data;if(null===i)return;const s=t.pixelRatio;e.save();const r=Math.max(1,Math.floor(s)),n=r%2/2,o=Math.round(i.center.x*s)+n,a=i.center.y*s;e.fillStyle=i.seriesLineColor,e.beginPath() +;const l=Math.max(2,1.5*i.seriesLineWidth)*s;e.arc(o,a,l,0,2*Math.PI,!1),e.fill(),e.fillStyle=i.fillColor,e.beginPath(),e.arc(o,a,i.radius*s,0,2*Math.PI,!1),e.fill(),e.lineWidth=r,e.strokeStyle=i.strokeColor,e.beginPath(),e.arc(o,a,i.radius*s+r/2,0,2*Math.PI,!1),e.stroke(),e.restore()}hitTest(e,t){return null}}function Je(e){return e}const Qe=[{start:0,end:.25,startRadius:4,endRadius:10,startFillAlpha:.25,endFillAlpha:0,startStrokeAlpha:.4,endStrokeAlpha:.8,easing:Je},{start:.25,end:.525,startRadius:10,endRadius:14,startFillAlpha:0,endFillAlpha:0,startStrokeAlpha:.8,endStrokeAlpha:0,easing:Je},{start:.525,end:1,startRadius:14,endRadius:14,startFillAlpha:0,endFillAlpha:0,startStrokeAlpha:0,endStrokeAlpha:0,easing:Je}];function et(e,t,i,s){const r=i+(s-i)*t;return(0,me.applyTransparency)(e,(0,me.alphaToTransparency)(r))}function tt(e,t){const i=e%2600/2600;let s;for(const e of Qe)if(i>=e.start&&i<=e.end){s=e;break}if(void 0===s)throw new Error("Last price animation internal logic error");const r=s.easing((i-s.start)/(s.end-s.start));return{fillColor:et(t,r,s.startFillAlpha,s.endFillAlpha),strokeColor:et(t,r,s.startStrokeAlpha,s.endStrokeAlpha),radius:(n=r,o=s.startRadius,a=s.endRadius,o+(a-o)*n)};var n,o,a}class it{constructor(e){this._renderer=new Xe,this._invalidated=!0,this._stageInvalidated=!0,this._startTime=performance.now(),this._endTime=this._startTime-1,this._series=e}update(e){if(this._invalidated=!0,"data-source-change"===e.type&&e.sourceId===this._series.id()&&e.realtime&&this._series.seriesLoaded()){const e=performance.now(),t=this._endTime-e;if(t>0)return void(t<650&&(this._endTime+=2600));this._startTime=e,this._endTime=e+2600}}invalidateStage(){this._stageInvalidated=!0}animationActive(){return performance.now()<=this._endTime}stopAnimation(){this._endTime=this._startTime-1}renderer(e,t){return this._invalidated?(this._updateImpl(e,t),this._invalidated=!1,this._stageInvalidated=!1):this._stageInvalidated&&(this._updateRendererDataStage(),this._stageInvalidated=!1),this._renderer}_updateImpl(e,t){this._renderer.setData(null);const i=this._series.model().timeScale(),s=i.visibleBarsStrictRange(),r=this._series.firstValue(),n=this._series.lastValueData(void 0,!0,!0);if(null===s||null===r||void 0===n.index||void 0===n.price||!s.contains(n.index))return;const o=new Ze.Point(i.indexToCoordinate(n.index),this._series.priceScale().priceToCoordinate(n.price,r)),a=n.color,l=this._series.properties().childs();let c;switch(this._series.style()){case 3:c=l.areaStyle.childs().linewidth.value();break;case 10:const t=l.baselineStyle,i=Math.round(e*(Math.abs(100-t.childs().baseLevelPercentage.value())/100));c=o.y<=i?t.childs().topLineWidth.value():t.childs().bottomLineWidth.value();break;case 14:c=l.lineWithMarkersStyle.childs().linewidth.value();break;case 15:c=l.steplineStyle.childs().linewidth.value();break;default:c=l.lineStyle.childs().linewidth.value()}const h=tt(this._duration(),a);this._renderer.setData({seriesLineColor:a,seriesLineWidth:c,fillColor:h.fillColor,strokeColor:h.strokeColor,radius:h.radius,center:o}) +}_updateRendererDataStage(){const e=this._renderer.data();if(null!==e){const t=tt(this._duration(),e.seriesLineColor);e.fillColor=t.fillColor,e.strokeColor=t.strokeColor,e.radius=t.radius}}_duration(){return this.animationActive()?performance.now()-this._startTime:2599}}var st=i(91280),rt=i(1115),nt=i(1803);class ot{constructor(){this._created=new $e.Delegate,this._modified=new $e.Delegate,this._loading=new $e.Delegate,this._completed=new $e.Delegate,this._error=new $e.Delegate,this._symbolError=new $e.Delegate,this._symbolResolved=new $e.Delegate,this._seriesError=new $e.Delegate,this._symbolNotPermitted=new $e.Delegate,this._symbolInvalid=new $e.Delegate,this._symbolGroupNotPermitted=new $e.Delegate,this._chartTypeNotPermitted=new $e.Delegate,this._intradaySpreadNotPermitted=new $e.Delegate,this._intradayExchangeNotPermitted=new $e.Delegate,this._customIntervalNotPermitted=new $e.Delegate,this._secondsIntervalNotPermitted=new $e.Delegate,this._tickMarksRangeChanged=new $e.Delegate,this._barReceived=new $e.Delegate,this._seriesTimeFrame=new $e.Delegate,this._dataUpdated=new $e.Delegate}destroy(){this._created.destroy(),this._modified.destroy(),this._loading.destroy(),this._completed.destroy(),this._error.destroy(),this._symbolError.destroy(),this._symbolResolved.destroy(),this._seriesError.destroy(),this._symbolInvalid.destroy(),this._symbolNotPermitted.destroy(),this._symbolGroupNotPermitted.destroy(),this._chartTypeNotPermitted.destroy(),this._intradaySpreadNotPermitted.destroy(),this._intradayExchangeNotPermitted.destroy(),this._customIntervalNotPermitted.destroy(),this._secondsIntervalNotPermitted.destroy(),this._tickMarksRangeChanged.destroy(),this._barReceived.destroy(),this._seriesTimeFrame.destroy(),this._dataUpdated.destroy()}created(){return this._created}modified(){return this._modified}loading(){return this._loading}completed(){return this._completed}error(){return this._error}symbolError(){return this._symbolError}symbolResolved(){return this._symbolResolved}seriesError(){return this._seriesError}symbolInvalid(){return this._symbolInvalid}symbolNotPermitted(){return this._symbolNotPermitted}symbolGroupNotPermitted(){return this._symbolGroupNotPermitted}chartTypeNotPermitted(){return this._chartTypeNotPermitted}intradaySpreadNotPermitted(){return this._intradaySpreadNotPermitted}intradayExchangeNotPermitted(){return this._intradayExchangeNotPermitted}customIntervalNotPermitted(){return this._customIntervalNotPermitted}secondsIntervalNotPermitted(){return this._secondsIntervalNotPermitted}tickMarksRangeChanged(){return this._tickMarksRangeChanged}barReceived(){return this._barReceived}seriesTimeFrame(){return this._seriesTimeFrame}dataUpdated(){return this._dataUpdated}fireCompleted(e){this._completed.fire(e)}fireCreated(e){this._created.fire(e)}fireModified(){this._modified.fire()}fireLoading(e){this._loading.fire(e)}fireError(){this._error.fire()}fireSymbolError(e){this._symbolError.fire(e),this.fireError()}fireSymbolResolved(e){this._symbolResolved.fire(e)}fireSeriesError(e){this._seriesError.fire(e), +this.fireError()}fireSymbolInvalid(){this._symbolInvalid.fire()}fireSymbolNotPermitted(e){this._symbolNotPermitted.fire(e)}fireSymbolGroupNotPermitted(e){this._symbolGroupNotPermitted.fire(e)}fireChartTypeNotPermitted(e){this._chartTypeNotPermitted.fire(e),this.fireError()}fireIntradaySpreadNotPermitted(){this._intradaySpreadNotPermitted.fire(),this.fireError()}fireIntradayExchangeNotPermitted(){this._intradayExchangeNotPermitted.fire(),this.fireError()}fireCustomIntervalNotPermitted(e){this._customIntervalNotPermitted.fire(e),this.fireError()}fireSecondsIntervalNotPermitted(){this._secondsIntervalNotPermitted.fire(),this.fireError()}fireTickMarksRangeChanged(e){this._tickMarksRangeChanged.fire(e)}fireBarReceived(e){this._barReceived.fire(e)}fireSeriesTimeFrame(e,t,i,s,r){this._seriesTimeFrame.fire(e,t,i,s,r)}fireDataUpdated(e,t,i){this._dataUpdated.fire(e,t,i)}}const at=(0,a.getLogger)("Chart.SeriesDataSource");var lt;!function(e){e[e.Idle=0]="Idle",e[e.AwaitingConnection=1]="AwaitingConnection",e[e.AwaitingFirstDataUpdate=2]="AwaitingFirstDataUpdate",e[e.Active=3]="Active"}(lt||(lt={}));let ct=1;let ht=1;function dt(e){return e.startDate?e.endDate||e.count?e.endDate?["from_to",e.startDate,e.endDate]:["bar_count",e.startDate,(0,s.ensure)(e.count)]:["from_to",e.startDate]:e.count||300}class ut{constructor(e,t,i,s){this._symbol=null,this._resolvedSymbolName=null,this._createSeriesOverriddenParams=0,this._instanceId=null,this._symbolInstanceId=null,this._resolution=null,this._timeFrame=null,this._data=new c.SeriesData,this._dataEvents=new ot,this._status=lt.Idle,this._turnaroundCounter=1,this._boundOnGatewayIsConnectedChanged=this._onGatewayIsConnectedChanged.bind(this),this._ongoingDataUpdate=Promise.resolve(),this._gateway=e,this._turnaroundPrefix=t,this._createSeriesParams=dt(null!=i?i:{count:300}),this._timeFrame=s||null,this._gateway.isConnected().subscribe(this._boundOnGatewayIsConnectedChanged)}destroy(){this.stop(),this._gateway.isConnected().unsubscribe(this._boundOnGatewayIsConnectedChanged)}modifySeries(e,t,i=null,r=!1,n=null){r&&(at.logNormal("Due to force flag clearing symbol & resolution to force re-requesting data."),this._symbol=null,this._resolution=null);const o=this._symbol,a=this._resolution;if(this._symbol=e,this._resolution=t,null===this._instanceId)return void(this._timeFrame=i);const l=!(0,ue.deepEquals)(o,e)[0]||null!==this._resolvedSymbolName&&this._resolvedSymbolName!==this._getSymbolNameString(e),c=null===a||!ee.Interval.isEqual(a,t);(l||c||null!==i)&&(this._timeFrame=null,(l||c)&&this._turnaroundCounter++,l&&this._resolveSymbol(),this._gateway.modifySeries(this._instanceId,this.turnaround(),(0,s.ensureNotNull)(this._symbolInstanceId),this._resolution,n,i,this._onMessage.bind(this)),this._dataEvents.fireModified())}requestMoreData(e){null!==this._instanceId&&this._gateway.requestMoreData(this._instanceId,e,this._onMessage.bind(this))}requestMoreTickmarks(e){null!==this._instanceId&&this._gateway.requestMoreTickmarks(this._instanceId,e,this._onMessage.bind(this))}isStarted(){ +return this._status!==lt.Idle}isActive(){return this._status===lt.Active}resolution(){return this._resolution}start(){this.isStarted()?at.logNormal("start: data source is already started, nothing to do"):((0,s.assert)(null!==this._symbol,"symbol must be set before start"),(0,s.assert)(null!==this._resolution,"resolution must be set before start"),this._gateway.isConnected().value()?this._createSeries():this._changeStatusTo(lt.AwaitingConnection))}stop(){this.isStarted()?(null!==this._instanceId&&(this._gateway.removeSeries(this._instanceId),this._instanceId=null),this._changeStatusTo(lt.Idle)):at.logNormal("stop: data source is already stopped, nothing to do")}instanceId(){return this._instanceId}data(){return this._data}clearData(){this.isStarted()?this._enqueueUpdate((()=>this._clearDataImpl())):this._clearDataImpl()}dataEvents(){return this._dataEvents}turnaround(){return`${this._turnaroundPrefix}${this._turnaroundCounter}`}symbolInstanceId(){return this._symbolInstanceId}symbol(){return this._symbol}moveData(e){this._enqueueUpdate((()=>this._data.moveData(e)))}setInitialRequestOptions(e){this._createSeriesOverriddenParams=dt(e)}_resolveSymbol(){null!==this._symbol&&(this._symbolInstanceId=this._gateway.resolveSymbol("sds_sym_"+ct++,(0,Ke.encodeExtendedSymbolOrGetSimpleSymbolString)(this._symbol),this._onMessage.bind(this)))}_clearDataImpl(){this._data.clear()}_changeStatusTo(e){(0,s.assert)(this._status!==e,"Source and destination status should be distinct"),at.logNormal(`Status changed from ${lt[this._status]} to ${lt[e]}`),this._status=e}_createSeries(){(0,s.assert)(this._status!==lt.Active,'Status should not be "Active" when creating a study'),this._instanceId="sds_"+ht++,this._resolveSymbol();const e=this._createSeriesOverriddenParams||this._createSeriesParams;this._createSeriesOverriddenParams&&(this._createSeriesOverriddenParams=0),this._gateway.createSeries(this._instanceId,this.turnaround(),(0,s.ensureNotNull)(this._symbolInstanceId),(0,s.ensureNotNull)(this._resolution),e,this._timeFrame,this._onMessage.bind(this)),this._timeFrame=null,this._changeStatusTo(lt.AwaitingFirstDataUpdate),this._dataEvents.fireCreated(this._instanceId)}_onGatewayIsConnectedChanged(e){e?this._onGatewayConnected():this._onGatewayDisconnected()}_onGatewayConnected(){this._status===lt.AwaitingConnection&&this._createSeries()}_onGatewayDisconnected(){this._status!==lt.Idle&&this._status!==lt.AwaitingConnection&&(this._instanceId=null,this._changeStatusTo(lt.AwaitingConnection)),this._turnaroundCounter=1}_onMessage(e){this._enqueueUpdate((()=>this._onMessageImpl(e)))}async _onMessageImpl(e){switch(e.method){case"symbol_resolved":{const[t,i]=e.params;if(t!==this._symbolInstanceId){at.logNormal(`Resolve for old symbol, expected: ${this._symbolInstanceId}, actual ${e.params[0]}`);break}this._onSymbolResolved(i);break}case"symbol_error":if(e.params[0]!==this._symbolInstanceId){at.logNormal(`Symbol error for old symbol, expected: ${this._symbolInstanceId}, actual ${e.params[0]}`);break}this._onSymbolError(e);break;case"series_timeframe": +{const[t,i,s,r,n,o,a]=e.params;if(!this._checkTurnaround(t,i)){at.logNormal(`Time frame for old data, expected: ${this._symbolInstanceId} (${this.turnaround()}), actual ${t} (${i})`);break}this._onSeriesTimeFrame(s,r,n,o,a);break}case"series_error":{const[t,i]=e.params;if(!this._checkTurnaround(t,i)){at.logNormal(`Series error for old data, expected: ${this._symbolInstanceId} (${this.turnaround()}), actual ${t} (${i})`);break}this._onSeriesError(e.params[2]);break}case"series_loading":{const[t,i]=e.params;if(!this._checkTurnaround(t,i))break;this._onSeriesLoading(e.time);break}case"series_completed":{const[t,i,s,r]=e.params;if(!this._checkTurnaround(t,s)){at.logNormal(`Series completed for old data, expected: ${this._symbolInstanceId} (${this.turnaround()}), actual ${t} (${s})`);break}this._onSeriesCompleted(i,e.time,r);break}case"data_update":if(!this._checkTurnaround(e.params.customId,e.params.turnaround)){at.logNormal(`Data update for old data, expected: ${this._symbolInstanceId} (${this.turnaround()}), actual ${e.params.customId} (${e.params.turnaround})`);break}await this._onDataUpdate(e.params.plots,e.params.nonseries,e.params.lastBar);break;case"clear_data":if(e.params.turnaround!==this.turnaround()){at.logNormal(`Clear data for old data, expected: ${this.turnaround()}, actual ${e.params.turnaround}`);break}this._clearDataImpl(),this._dataEvents.fireDataUpdated(void 0,!1,null)}}_onSeriesError(e){let t,i;if("string"==typeof e)i={error:e},t=e;else if(i=e,e.ctx){const i={};Object.entries(e.ctx).forEach((([e,t])=>{i[e]=t.toString()})),t=e.error.format(i)}else t=e.error;if(t.startsWith("study_not_auth:")){const e=t.split(":",2)[1].split("@",2)[0];if(["BarSetRenko","BarSetPriceBreak","BarSetKagi","BarSetPnF"].includes(e))this._dataEvents.fireChartTypeNotPermitted(e);else if("BarSetSpread"===e)this._dataEvents.fireIntradaySpreadNotPermitted();else if("BarSetRange"===e){const e=`${(0,s.ensureNotNull)(this._symbol).inputs.range}R`;this._dataEvents.fireCustomIntervalNotPermitted(e)}}else"resolution_not_entitled"===t?this._dataEvents.fireIntradayExchangeNotPermitted():"custom_resolution"===t?this._dataEvents.fireCustomIntervalNotPermitted((0,s.ensureNotNull)(this._resolution)):"seconds_not_entitled"===t&&this._dataEvents.fireSecondsIntervalNotPermitted();this._dataEvents.fireSeriesError(i)}_onSeriesTimeFrame(e,t,i,s,r){this._dataEvents.fireSeriesTimeFrame(e,t,i,null==s||s,r)}_onSymbolError(e){if(e.params[1]===nt.permissionDenied)switch(e.params[2]){case nt.SymbolErrorPermissionDeniedReason.Symbol:this._dataEvents.fireSymbolNotPermitted(e.params[3]);break;case nt.SymbolErrorPermissionDeniedReason.GroupPermission:this._dataEvents.fireSymbolGroupNotPermitted(e.params[3]);break;default:this._dataEvents.fireSymbolNotPermitted(e.params[2])}else e.params[1]===nt.invalidSymbol&&this._dataEvents.fireSymbolInvalid();this._dataEvents.fireSymbolError(e.params[1])}_onSymbolResolved(e){this._resolvedSymbolName=(0,m.symbolForApi)(e,this._getSymbolNameString((0,s.ensureNotNull)(this._symbol))),this._dataEvents.fireSymbolResolved(e)} +_getSymbolNameString(e){return"string"==typeof e.symbol?e.symbol:e.symbol.symbol}async _onDataUpdate(e,t,i){this._onDataUnpacked(e,i,await async function(e){if(void 0===e)return{projectionPlots:[],boxSize:null};if(""===e.d||"nochange"===e.indexes)return null;const t=await(0,rt.unpackNonSeriesData)(e.d);if(null===t||t.indexes_replace)return null;const i=e.indexes,{bars:s,price:r,boxSize:n,reversalAmount:o}=t.data,a=(s||[]).map((e=>{let t;return"factor"in e?t=e.factor:"additionalPrice"in e&&(t=e.additionalPrice),{index:i[e.time],value:[0,e.open,e.high,e.low,e.close,e.volume,t]}}));return{lastPrice:r,projectionPlots:a,reversalAmount:o,boxSize:n}}(t))}_enqueueUpdate(e){return this._ongoingDataUpdate=this._ongoingDataUpdate.then(e,e),this._ongoingDataUpdate}_onDataUnpacked(e,t,i){if(this._status===lt.Idle)return;this._status===lt.AwaitingFirstDataUpdate&&(this._changeStatusTo(lt.Active),this._clearDataImpl());const s=this._data.bars().size(),r=this._data.bars().firstIndex(),n=this._data.mergeRegularBars(e);null!==i&&(this._data.nsBars().clear(),this._data.nsBars().merge(i.projectionPlots),this._data.lastProjectionPrice=i.lastPrice,null!==i.boxSize&&(this._data.boxSize=i.boxSize),this._data.reversalAmount=i.reversalAmount);const o=null===r||null!==n&&n.indexe.value.splice(7,1))),t}class Xt extends l.PriceDataSource{constructor(e,t,i,r){super(e,"_seriesId"),this.requestingIntradayWhenNotSupported=new $e.Delegate,this.requestingStyleIsNotSupported=new $e.Delegate,this.requestingStyleSupportRecovered=new $e.Delegate,this.requestingResolutionLessThanFrequency=new $e.Delegate,this._paneView=null,this._futureBarsPaneView=null,this._projectionBarsPaneView=null,this._waterlineView=null,this._priceLineView=null,this._gotoDateView=null,this._baseHorizontalLineView=null,this._priceStep=null,this._symbolInfo=null,this._prevSymbolInfo=null,this._isPrePostMarketPricesAvailableProperty=new(_())(!1),this._isBackAdjustmentForbiddenProperty=new(_())(!0),this._isSettlementAsCloseForbiddenProperty=new(_())(!0),this._highLowPriceCache=new Map,this._averagePriceCache=new Map,this._prevClosePriceAxisView=null,this._priceScaleAboutToBeChanged=new $e.Delegate,this._onRestarted=new $e.Delegate,this._onStatusChanged=new $e.Delegate,this._extendedHoursChanged=new $e.Delegate,this._tagsChanged=new $e.Delegate,this._intervalChanged=new $e.Delegate,this._sessionIdChanged=new $e.Delegate,this._requestMoreDataAvailable=!0,this._lineStyleLastPriceCirclePaneView=new it(this),this._prevClosePriceLineView=null,this._dataPoweredBy=null,this._loading=!0,this._seriesLoaded=!1,this._status=0,this._symbolResolvingActive=new $.WatchedValue(!1),this._predictBars=0,this._syncModel=null,this._data=null,this._lastCompleteFlags=null,this._haStyle={studyId:(0,s.ensureNotNull)((0,m.chartStyleStudyId)(8,!0))},this._renkoStyle={studyId:(0,s.ensureNotNull)((0,m.chartStyleStudyId)(4,!0))},this._pbStyle={studyId:(0,s.ensureNotNull)((0,m.chartStyleStudyId)(7,!0))},this._kagiStyle={studyId:(0,s.ensureNotNull)((0,m.chartStyleStudyId)(5,!0))},this._pnfStyle={studyId:(0,s.ensureNotNull)((0,m.chartStyleStudyId)(6,!0))},this._rangeStyle={studyId:(0,s.ensureNotNull)((0,m.chartStyleStudyId)(11,!0))},this._barColorerCache=null,this._boxSizeValue=new $.WatchedValue,this._base=100,this._pointValue=1,this._formattingDeps=null,this._formatter=new f.PriceFormatter(this._base), +this._ignoreMinMoveFormatter=new f.PriceFormatter(this._base),this._ignoreMinMovePriceStep=null,this._lastBarCloseTime=null,this._onSessionIdPropertyChangedBound=this._onSessionIdPropertyChanged.bind(this),this._ignoreSessionIdProxyPropertyChanges=!1,this._textSourceIsAlwaysTickerRestrictionEnabled=!1,this._lastPriceAnimationActive=!1,this._currentSession="out_of_session",this._onStyleChanged=new $e.Delegate,this._intervalObj=null,this._obsoleteZOrder=0,this._seriesErrorMessage=null,this._seriesAlwaysFalseHibernatedVW=new $.WatchedValue(!1),this._styleToRecover=null,this._precomputedBarStyles=new WeakMap,this._doNotShowLastAvailableBar=!1,this._gotoDateResultCleared=!1,this._endOfDataPaneView=null,this._pendingTimeRange=null,this._replaySubscriber=null,this._symbolIntervalChanged=new $e.Delegate,this._isReplayResolutionAvailableForUser=null,this._onInReplayStateChanged=new $e.Delegate,this._replayExitedDueUnsupportedInterval=new $e.Delegate,this._replayExitedDueUnavailableForUserInterval=new $e.Delegate,this._onTimeFrameApplied=new $e.Delegate,this._prevRequestedInterval="",this._isActingAsSymbolSource=new $.WatchedValue(!0),this._seriesSource=new ut(e.chartApi(),"s",r);const n=this._seriesSource.dataEvents();n.symbolResolved().subscribe(this,this._onSymbolResolved),n.symbolError().subscribe(this,this._onSymbolError),n.seriesTimeFrame().subscribe(this,this._onSeriesTimeFrame),n.seriesError().subscribe(this,this._onSeriesError),n.loading().subscribe(this,this._onSeriesLoading),n.completed().subscribe(this,this._onSeriesCompleted),n.dataUpdated().subscribe(this,this._onDataUpdated),n.barReceived().subscribe(this,this._onBarReceived),this._quotesProvider=new _e.QuotesProvider,this._quotesProvider.quotesUpdate().subscribe(this,this._onQuotesUpdate);const o=t.childs();if(t.hasChild("extendedHours")){(0,s.ensureDefined)(o.extendedHours).value()&&!t.hasChild("sessionId")&&t.addChild("sessionId",new(_())("extended")),t.removeProperty("extendedHours")}t.hasChild("sessionId")||t.addChild("sessionId",new(_())(g.SubsessionId.Regular)),(0,Nt.allChartStyles)().includes(o.style.value())||o.style.setValueSilently(2);const a=o.lineStyle.childs();if(o.lineStyle.hasChild("styleType")){let e;const t=a.styleType.value();0===t&&(o.style.setValue(14),e=o.lineWithMarkersStyle.childs()),1===t&&(o.style.setValue(15),e=o.steplineStyle.childs()),e&&(e.color.setValueSilently(a.color.value()),e.linestyle.setValueSilently(a.linestyle.value()),e.linewidth.setValueSilently(a.linewidth.value()),e.priceSource.setValueSilently(a.priceSource.value())),o.lineStyle.removeProperty("styleType")}this._setProperties(t),this._sessionIdProxyProperty=new(_())(o.sessionId.value()),o.sessionId.subscribe(this,(()=>this._updateSessionIdProxyProperty())),this._sessionIdProxyProperty.subscribe(this,this._onSessionIdProxyPropertyChanged),this._symbolTextSourceProxyProperty=new(_()),this._recalcSymbolTextSourceProxyProperty(),o.statusViewStyle.childs().symbolTextSource.subscribe(this,this._recalcSymbolTextSourceProxyProperty), +this._symbolTextSourceProxyProperty.subscribe(this,(()=>e.lightUpdate())),this._options=(0,ue.merge)((0,ue.clone)(Yt),i),this._prevChartStyle=o.style.value(),this._priceAxisView=new xe(this,e,{alwaysShowGlobalLast:!Ht,showCountdown:i.countdownEnabled});let l=null;Ot||Ht||(l=new xe(this,e,{visibleOnHistoryOnly:!0,showSymbolLabel:!1,showCountdown:!1,alwaysShowGlobalLast:!1,useSolidBodyColor:!1})),this._priceLinePriceAxisView=new Te.SeriesPriceLineAxisView(this),this._priceLineAxisViews=[this._priceLinePriceAxisView];const c=new Ie(this,e,{showCountdown:i.countdownEnabled});this._priceAxisViews=[this._priceAxisView,c],null!==l&&this._priceAxisViews.push(l),this._panePriceAxisView=new Me.PanePriceAxisView(this._priceAxisView,this,e),this._historyPricePanePriceAxisView=null!==l?new Me.PanePriceAxisView(l,this,e):null,this._projectionPriceAxisView=new Me.PanePriceAxisView(c,this,e),this._labelPaneViews=[this._panePriceAxisView,this._projectionPriceAxisView],null!==this._historyPricePanePriceAxisView&&this._labelPaneViews.push(this._historyPricePanePriceAxisView),this._highLowAvgPaneViews=[],this._averagePaneViews=[],zt&&this._createAverageViews(),this._createHighLowAvgViews(),this._subscribeRestartToSessionIdChange(),o.visible.subscribe(this,this._updateLastPriceAnimationActive),this._updateLastPriceAnimationActive(),this._dataWindowView=new H(this,e),this._legendView=new q(this,e),this._statusView=new E(this,this._model.properties().childs().scalesProperties.childs().textColor,o.statusViewStyle),this._marketStatusModel=new J(this._quotesProvider),this._dataUpdatedModeModel=Ft?new de({getter:this.symbolInfo.bind(this),onChange:n.symbolResolved()},{getter:this.status.bind(this),onChange:this._onStatusChanged},{getter:()=>{var e;return null===(e=this._lastCompleteFlags)||void 0===e?void 0:e.rt_update_period},onChange:n.completed()},o.symbol.listeners()):null,this._dataProblemModel=new pe(this._quotesProvider,o.symbol.listeners()),this._symbolResolvingActive.subscribe((()=>e.realignLineTools())),this._intervalChanged.subscribe(this,(()=>e.realignLineTools()))}supportsPressedChunks(){return!0}pressedChunks(e,t){return this.data().pressedChunks(e,t)}seriesErrorMessage(){return this._seriesErrorMessage}destroy(){this._quotesProvider.quotesUpdate().unsubscribeAll(this),this._quotesProvider.destroy(),this._model.timeScale().visibleBarsStrictRangeChanged().unsubscribeAll(this),this._unsubscribeRestartToSessionIdChange(),this._replayExitedDueUnsupportedInterval.destroy(),this._replayExitedDueUnavailableForUserInterval.destroy(),this._onTimeFrameApplied.destroy()}isActingAsSymbolSource(){return this._isActingAsSymbolSource.readonly()}barColorer(){if(this._barColorerCache)return this._barColorerCache;let e=null;const t=this._model.dataSources();for(let i=t.length-1;i>=0;i--){const r=t[i];if((0,Vt.isStudy)(r)&&r.hasBarColorer()&&!r.isSourceHidden()){const t=(0,s.ensureNotNull)(r.barColorer());null===e?e=t:e.pushBackBarColorer(t)}}return null===e?e=new Et.SeriesBarColorer(this):e.pushBackBarColorer(new Et.SeriesBarColorer(this)), +this._barColorerCache=e,e}createPaneView(){this._paneView=null,this._projectionBarsPaneView=null,this._waterlineView=null,this._priceLineView=this.hasClosePrice()?new gt(this):null;const e=this._properties.childs().style.value();switch(e){case 0:this._paneView=new yt.SeriesBarsPaneView(this,this._model);break;case 1:this._paneView=new bt.SeriesCandlesPaneView(this,this._model);break;case 2:case 14:case 15:this._paneView=new wt.SeriesLinePaneView(this,this._model);break;case 3:this._paneView=new Pt.SeriesAreaPaneView(this,this._model);break;case 16:this._paneView=new Ct.SeriesHLCAreaPaneView(this,this._model);break;case 8:this._paneView=new Lt(this,this._model);break;case 9:this._paneView=new At.SeriesHollowCandlesPaneView(this,this._model);break;case 13:this._paneView=new St.SeriesColumnsPaneView(this,this._model);break;case 10:{this._paneView=new kt.SeriesBaselinePaneView(this,this._model);const e=this._properties.childs().baselineStyle.childs();this._waterlineView=new ft.SeriesWaterlinePaneView({paneHeight:()=>this.priceScale().height(),color:()=>e.baselineColor.value(),baseLevelPercentage:()=>e.baseLevelPercentage.value()});break}case 12:this._paneView=new vt.SeriesHiLoPaneView(this,this._model)}if(null===this._paneView)throw Error("Unknown chart style assigned: "+e)}properties(){return this._properties}zorder(){return 0}quotesProvider(){return this._quotesProvider}currentSession(){return this._currentSession}syncModel(){if(!this._syncModel){const e=this.symbolInfo(),t=this.interval();if(!e||!t)return null;this._syncModel=new ne(e,t)}return this._syncModel}labelPaneViews(){return this._labelPaneViews}topPaneViews(){const e=[];if(null!==this._gotoDateView&&e.push(this._gotoDateView),this._lastPriceAnimationActive){const t=this._lineStyleLastPriceCirclePaneView;t.animationActive()&&setTimeout((()=>this._model.invalidate(st.InvalidationMask.cursor())),0),t.invalidateStage(),e.push(t)}return 0!==e.length?e:null}paneViews(){if(!this.properties().childs().visible.value())return null;const e=[(0,s.ensureNotNull)(this._baseHorizontalLineView),(0,s.ensureNotNull)(this._paneView)];return this._endOfDataPaneView&&e.push(this._endOfDataPaneView),this._futureBarsPaneView&&e.push(this._futureBarsPaneView),this._projectionBarsPaneView&&e.push(this._projectionBarsPaneView),null!==this._waterlineView&&e.push(this._waterlineView),null!==this._priceLineView&&e.push(this._priceLineView),e.push(...this._highLowAvgPaneViews),e.push(...this._averagePaneViews),e}priceAxisViews(e,t){return e.findTargetPriceAxisViews(this,t,this._priceAxisViews,this._priceLineAxisViews)}clearHighLowPriceCache(){this._highLowPriceCache.clear()}clearAveragePriceCache(){this._averagePriceCache.clear()}priceScale(){return(0,s.ensureNotNull)(this._priceScale)}setPriceScale(e){this._priceScale!==e&&(this._priceScaleAboutToBeChanged.fire(),this._priceScale=e,this._properties.removeProperty("priceAxisProperties"),this._properties.addChild("priceAxisProperties",e.properties()),this._properties.childs().priceAxisProperties.childChanged(null),(0, +o.emit)("series_event","price_scale_changed"),this._priceScaleChanged.fire(e))}priceScaleChanged(){return this._priceScaleChanged}priceScaleAboutToBeChanged(){return this._priceScaleAboutToBeChanged}applyPreferences(e){const t=(0,ue.clone)(e);this.priceScale().setMode({autoScale:t.priceAxisProperties.autoScale,percentage:t.priceAxisProperties.percentage,log:t.priceAxisProperties.log,lockScale:t.priceAxisProperties.lockScale}),this.setChartStyleWithIntervalIfNeeded(t.style);const{style:i,interval:s,...r}=t;this._properties.mergePreferences(r),this._properties.saveDefaults(),this.createPaneView(),this.invalidateBarStylesCache()}disconnect(){this._seriesSource.stop(),this._predictBars=0,this._status=0,this._model.isSnapshot()||(this._prevSymbolInfo=null,this._symbolInfo=null)}isStarted(){return this._seriesSource.isStarted()}restart(e=!0){if(5===this._status)return;this._loading=!0,this._lastCompleteFlags=null,this._onRestarted.fire(),this._setStatus(1),this._updateSymbolInfo(null,e);let t=this._properties.childs().interval.value();ee.Interval.isEqual(t,this._prevRequestedInterval)&&this._notifyIntervalChanged(t);let i=null;this._pendingTimeRange&&(i=this._pendingTimeRange,this._pendingTimeRange=null),this._onBeforeModifySeries(this.getSymbolString(),t),this._onTimeFrameApplied.fire(i),t=(0,pt.getServerInterval)(t),this._data=null,this._seriesSource.modifySeries(this._getResolvingSymbolObject(),t,i),this._seriesSource.isStarted()||this._seriesSource.start(),this._prevRequestedInterval=this.interval(),this.updateAllViews((0,ye.sourceChangeEvent)(this.id())),this._model.lightUpdate()}isSymbolInvalid(){return 4===this._status}getSymbolString(){return(0,Ke.encodeExtendedSymbolOrGetSimpleSymbolString)(this._getSymbolObject())}invalidateBarStylesCache(e){qt.logDebug("Invalidate style cache starting from "+e),this._clearStylePlot(this.bars(),e),this._clearStylePlot(this.nsBars())}isFailed(){return 12===this.status()||4===this.status()||10===this.status()}isStatusError(){return 12===this.status()}actualSymbol(){return(0,m.actualSymbol)(this.symbolInfo(),this.symbol())}proSymbol(){return(0,m.proSymbol)(this.symbolInfo(),this.symbol())}onStyleChanged(){return this._onStyleChanged}style(){return this.properties().childs().style.value()}setStyle(e){this.setSymbolParams({style:e})}isRangeBasedStyle(){return(0,m.isRangeBasedStyle)(this.style())}symbolSameAsCurrent(e){return(0,Ye.symbolSameAsCurrent)(e,this.symbolInfo())}status(){return this._status}symbol(){return this.properties().childs().symbol.value()}symbolChanged(){return this.properties().childs().symbol.listeners()}symbolInfo(){return this._symbolInfo}symbolResolved(){return this.dataEvents().symbolResolved()}symbolResolvingActive(){return this._symbolResolvingActive}symbolHibernated(){return this._seriesAlwaysFalseHibernatedVW}firstValue(){const e=this.firstBar();return null===e?null:this._barFunction(e,0)}firstBar(){const e=this.model().timeScale().visibleBarsStrictRange();if(null===e)return null;const t=e.firstBar(),i=this.data().search(t,d.PlotRowSearchMode.NearestRight) +;return null!==i?i.value:null}formatter(e=!0){return e?this._formatter:this._ignoreMinMoveFormatter}priceStep(e=!0){return e?this._priceStep:this._ignoreMinMovePriceStep}bars(){return this.data().bars()}nsBars(){return this.data().nsBars()}interval(){return this.properties().childs().interval.value()}setInterval(e){this.setSymbolParams({interval:e})}intervalObj(){const e=this.interval();if(null!==this._intervalObj&&this._intervalObj.resolutionString===e)return this._intervalObj.interval;const t=ee.Interval.parse(e);return this._intervalObj={resolutionString:e,interval:t},t}prevClose(){const e=this.priceScale();if(e.isEmpty()||this.data().isEmpty())return null;const t=this.quotes(),i=this.firstValue();if(null===t||null===i)return null;const s=t.prev_close_price;return void 0===s?null:{coordinate:e.priceToCoordinate(s,i),floatCoordinate:e.priceToCoordinate(s,i),formattedPricePercentage:e.formatPricePercentage(s,i,!0),formattedPriceAbsolute:e.formatPriceAbsolute(s),formattedPriceIndexedTo100:e.formatPriceIndexedTo100(s,i)}}priceLineColor(e){return this.properties().childs().priceLineColor.value()||e}hasClosePrice(){return Gt||12!==this.properties().childs().style.value()}lastValueData(e,t,i){var s;const r={noData:!0},n=this.priceScale();if(this.model().timeScale().isEmpty()||n.isEmpty()||this.data().isEmpty())return r;const o=this.model().timeScale().visibleBarsStrictRange(),a=this.firstValue();if(null===o||null===a)return r;let l,c;if(t){const e=this.data().bars().last();if(null===e)return r;l=e.value,c=e.index}else{const e=this.data().bars().search(o.lastBar(),d.PlotRowSearchMode.NearestLeft);if(null===e)return r;l=e.value,c=e.index}const h=null!==(s=void 0!==e?l[e]:this._barFunction(l,2))&&void 0!==s?s:NaN,u=this.barColorer().barStyle(c,!1),p=n.priceToCoordinate(h,a),_={...n.getFormattedValues(h,a,!0),noData:!1,color:u.barColor,floatCoordinate:p,coordinate:p,index:c};return i&&(_.price=h),_}isDWM(){return this.intervalObj().isDWM()}data(){var e;return null!==(e=this._data)&&void 0!==e?e:this._seriesSource.data()}clearData(){(0,s.assert)(null===this._data,"Cannot clear loaded data"),this._seriesSource.clearData()}nearestValue(e,t,i){var s;const r=this.nearestData(e,i);return null!==(s=null==r?void 0:r.value[t])&&void 0!==s?s:void 0}onSymbolIntervalChanged(){return this._symbolIntervalChanged}onIntervalChanged(){return this._intervalChanged}onStatusChanged(){return this._onStatusChanged}onRestarted(){return this._onRestarted}onExtendedHoursChanged(){return this._extendedHoursChanged}fixLastBar(e){0}requestMoreData(e){if(3!==this._status&&7!==this._status&&8!==this._status&&9!==this._status&&6!==this._status&&11!==this._status)return;if(this._model.timeScale().isEmpty())return;const t=this._model.timeScale().visibleBarsStrictRange();if(null===t)return;if(0===this.bars().size())return;const i=t.lastBar()-(0,s.ensureNotNull)(this.data().last()).index;if(this._predictBarst.update(e))),this._highLowAvgPaneViews.forEach((t=>t.update(e))),this._labelPaneViews.forEach((t=>t.update(e))),this._priceAxisViews.forEach((t=>t.update(e))),this._priceLineAxisViews.forEach((t=>t.update(e))), +null===(i=this._futureBarsPaneView)||void 0===i||i.update(e),null===(s=this._projectionBarsPaneView)||void 0===s||s.update(e),null===(r=this._waterlineView)||void 0===r||r.update(e),null===(n=this._priceLineView)||void 0===n||n.update(e),null===(o=this._gotoDateView)||void 0===o||o.update(e),null===(a=this._endOfDataPaneView)||void 0===a||a.update(e),null===(l=this._baseHorizontalLineView)||void 0===l||l.update(e);const c=this._model.activeStrategySource().value();null==c||c.updateAllViews(e),this._lineStyleLastPriceCirclePaneView.update(e)}barFunction(){return this._barFunction}precomputedBarStyle(e){return this._precomputedBarStyles.get(e)}setPrecomputedBarStyle(e,t){this._precomputedBarStyles.set(e,t)}setSymbolParams(e){const{symbol:t,currency:i,unit:r,style:n}=e;let o=e.interval;const a=this.properties().childs(),l=this._symbolInfo;let c,h,d;if(null!==l?(c=void 0!==t&&!(0,Ye.symbolSameAsCurrent)(t,l),h=void 0!==i&&!(0,Ye.currenciesAreSame)(i,l),d=void 0!==r&&!(0,Ye.unitsAreSame)(r,l,this._model.unitConversionEnabled())):(c=void 0!==t&&t!==a.symbol.value(),h=void 0!==i&&i!==a.currencyId.value(),d=void 0!==r&&r!==a.unitId.value()),void 0!==o&&!c){const e=this.getSupportedResolution(o,!1);e!==o&&(qt.logWarn(`Change interval value from ${o} to ${e} because first is not supported`),o=e)}const u=void 0!==o&&!ee.Interval.isEqual(a.interval.value(),o),p=void 0!==n&&n!==a.style.value(),_=[Kt("symbol",t,c),Kt("interval",o,u),Kt("currency",i,h),Kt("unit",r,d),Kt("style",n,p)].filter((e=>null!==e)).join("; ");qt.logInfo(`Applying series symbol params: ${_}`),void 0!==t&&a.symbol.setValue(t),void 0!==i&&a.currencyId.setValue(i),void 0!==r&&a.unitId.setValue(r),u&&a.interval.setValue((0,s.ensureDefined)(o)),p&&a.style.setValue(n);let m=!1;if(p){m=this.isNeedRestart();const e=!c&&(h||d);this.onChartStyleChanged(e)}!m&&(c||u||h||d)&&this._applySymbolParamsChanges({symbolChanged:c,currencyChanged:h,unitChanged:d,intervalChanged:u,styleChanged:p}),(c||h||d)&&this.model().checkLineToolSelection()}setSymbol(e){this.setSymbolParams({symbol:e})}currency(){return this.properties().childs().currencyId.value()||null}setCurrency(e){this.setSymbolParams({currency:e})}isConvertedToOtherCurrency(){return(0,m.isConvertedToOtherCurrency)(this.symbolInfo())}unit(){return this.properties().childs().unitId.value()||null}setUnit(e){this.setSymbolParams({unit:e})}measureUnitId(){return(0,m.measureUnitId)(this.symbolInfo())}isConvertedToOtherUnit(){return(0,m.isConvertedToOtherUnit)(this.symbolInfo(),this._model.unitConversionEnabled())}valueAt(e,t){var i,s;return null!==(s=null===(i=this.data().search(e))||void 0===i?void 0:i.value[t])&&void 0!==s?s:null}symbolSource(){return this}barsProvider(){return this}title(e){return this.symbolTitle(e)}name(){return this.symbolTitle(Rt.TitleDisplayTarget.StatusLine)}symbolTitle(e,t,i,s="exchange"){let r=this.properties().childs().symbol.value();const n=this.symbolInfo();if(null!==n){const{type:e}=n;r=(0,m.symbolTitle)(n,t,"forex"===e?"exchange":s)}return i?r:`${r}, ${(0, +C.translatedIntervalString)(this.properties().childs().interval.value())}`}setObsoleteZOrder(e){this._obsoleteZOrder=e}obsoleteZOrder(){return this._obsoleteZOrder}valuesProvider(){return new U(this,this.model())}statusProvider(e){return new A(this,this._model.properties().childs().scalesProperties.childs().textColor,this.properties().childs().statusViewStyle,e)}open(e){const t=this.data().valueAt(e);return t&&t[1]}high(e){const t=this.data().valueAt(e);return t&&t[2]}low(e){const t=this.data().valueAt(e);return t&&t[3]}close(e){const t=this.data().valueAt(e);return t&&t[4]}moveItem(e,t,i){if(10===this.style()&&0===t){const t=this.priceScale(),i=this.properties().childs().baselineStyle,s=t.height(),r=100-e.y/s*100,n=r<0?0:Math.round(10*r)/10;i.childs().baseLevelPercentage.setValue(Math.max(Math.min(n,100),0))}}rerequestData(){this._applySymbolParamsChanges({force:!0})}switchToReplay(e,t){throw new Error("Not implemented")}switchToRealtime(){throw new Error("Not implemented")}requestMoreDataAvailable(){return this._requestMoreDataAvailable}seriesLoaded(){return this._seriesLoaded}endOfData(){var e;return void 0!==(null===(e=this._lastCompleteFlags)||void 0===e?void 0:e.data_completed)}endOfDataType(){var e,t;return null!==(t=null===(e=this._lastCompleteFlags)||void 0===e?void 0:e.data_completed)&&void 0!==t?t:null}dataPoweredBy(){return null}boxSizeValue(){return this._boxSizeValue}isUserDeletable(){return!1}changeTimeFrame(){(0,n.trackEvent)("GUI","Change timeframe")}onTagsChanged(){return this._tagsChanged}state(e){var t;const i=this.obsoleteZOrder();let s={type:"MainSeries",id:this.id(),zorder:i,haStyle:this._haStyle,renkoStyle:this._renkoStyle,pbStyle:this._pbStyle,kagiStyle:this._kagiStyle,pnfStyle:this._pnfStyle,rangeStyle:this._rangeStyle,formattingDeps:this._formattingDeps};const r=this.properties().state();if((null===(t=this._symbolInfo)||void 0===t?void 0:t.ticker)&&(r.symbol=this._symbolInfo.ticker),this._model.unitConversionEnabled()||(r.unitId=null),s.state=r,e){let e=this.bars();const t=this._model.timeScale().visibleExtendedDataRange(e,0);null!==t&&(e=e.range(t.firstBar(),t.lastBar())),s={...s,bars:Zt(e),nsBars:Zt(this.nsBars()),symbolInfo:this._symbolInfo,rtPrice:this.data().lastProjectionPrice,boxSize:this.data().boxSize,reversalAmount:this.data().reversalAmount}}return s}restoreState(e,t){if(t&&this._setStatus(5),!this._model.unitConversionEnabled()&&e.state&&delete e.state.unitId,this._properties.mergeAndFire(e.state),this._properties.hasChild("esdBreaksStyle")&&this._properties.removeProperty("esdBreaksStyle"),this._prevChartStyle=this.properties().childs().style.value(),this.createPaneView(),t){const t=e;this.restoreData(t.bars,t.nsBars,t.symbolInfo,t.rtPrice,t.boxSize,t.reversalAmount)}e.formattingDeps&&(this._formattingDeps=e.formattingDeps,this._recreatePriceFormattingDependencies())}restoreData(e,t,i,s,r,n){this._status=5,this._data=new c.SeriesData,this._data.bars().restoreState(e),this._data.nsBars().restoreState(t),this._updateSymbolInfo(i,!1),this._data.lastProjectionPrice=s, +this._data.boxSize=r;const o=this.properties().childs();r||(6===o.style.value()?this._data.boxSize=o.pnfStyle.childs().inputs.childs().boxSize.value():4===o.style.value()&&(this._data.boxSize=o.renkoStyle.childs().inputs.childs().boxSize.value())),this._data.reversalAmount=n,n||5===o.style.value()&&(this._data.reversalAmount=o.kagiStyle.childs().inputs.childs().reversalAmount.value()),this._loading=!1}async setGotoDateResult(e,t){this._gotoDateResultCleared=!1;const s=await i.e(4079).then(i.bind(i,1539));this._gotoDateResultCleared||(this._gotoDateView=new s.GotoDateView(this,e,t),this._gotoDateView.doNotShowLastAvailableBar(this._doNotShowLastAvailableBar),this._model.updateSource(this))}clearGotoDateResult(){this._gotoDateView=null,this._gotoDateResultCleared=!0}doNotShowLastAvailableBar(e){var t;this._doNotShowLastAvailableBar=e,null===(t=this._gotoDateView)||void 0===t||t.doNotShowLastAvailableBar(e)}dataUpdated(){return this.dataEvents().dataUpdated()}getSupportedResolution(e,t=!0){if(null===this._symbolInfo||!(0,Ye.symbolSameAsCurrent)(this.symbol(),this._symbolInfo))return e;if(ee.Interval.isRange(e)&&(0,m.isCloseBasedSymbol)(this._symbolInfo)){const t=this.interval();if(!ee.Interval.isRange(t))return t;e="1D"}const i=this._symbolInfo.data_frequency;if(void 0!==i){let s=(0,pt.getApplicableIntervalForFrequency)(i,e);if(s!==e){this._model.defaultResolutions();return t&&this.requestingResolutionLessThanFrequency.fire(i,s),s}}if(ee.Interval.isIntraday(e)&&!this._symbolInfo.has_intraday)return t&&this.requestingIntradayWhenNotSupported.fire(),"D";if(this._symbolInfo.hasOwnProperty("supported_resolutions")){const t=ee.Interval.normalize(e),i=this._symbolInfo.supported_resolutions;if(null!==t&&-1===i.indexOf(t))return i[0]}return e}startedAndCompleted(){return new Promise((e=>{this.isStarted()&&e(),this.dataEvents().completed().subscribe(this,e,!0)}))}_barsState(e){const t=e.state();return t.data.forEach((e=>e.value.splice(7,1))),t}_updateBarFunction(){this._barFunction=(0,Dt.barFunctionByStyle)(this.style(),this.priceSource())}_setProperties(e){e.hasChild("timeframe")||e.merge({timeframe:""}),e.hasChild("shortName")||e.merge({shortName:""}),e.hasChild("currencyId")||e.addChild("currencyId",new(_())(null)),e.hasChild("unitId")||e.addChild("unitId",new(_())(null)),this._properties=e;const t=e.childs();t.currencyId.subscribe(this,this._onCurrencyChanged),t.unitId.subscribe(this,this._onUnitChanged),t.timeframe.subscribe(this,this.changeTimeFrame),e.subscribe(this,this._onPropertiesChanged)}_updateSessionIdProxyProperty(e){const t=this._properties.childs().sessionId.value();let i=t;if(e){const e=this.symbolInfo();null!==e&&(i=e.subsession_id||t)}this._ignoreSessionIdProxyPropertyChanges=!0,this._sessionIdProxyProperty.setValue(i),this._ignoreSessionIdProxyPropertyChanges=!1}_onSessionIdProxyPropertyChanged(){this._ignoreSessionIdProxyPropertyChanges||this._properties.childs().sessionId.setValue(this._sessionIdProxyProperty.value()),this._updateLastPriceAnimationActive()}_onSymbolResolved(e){ +this._seriesErrorMessage=null,this._updateSymbolInfo(e,!1),this._model.updateSource(this),this._model.onWidget()||((0,n.trackEvent)("Symbol",e.listed_exchange,e.name),(0,n.trackEvent)("Symbol Type",e.type,e.listed_exchange));const t=e.minmov/e.pricescale,i=this.properties().childs();4===i.style.value()&&i.renkoStyle.childs().inputs.childs().boxSize.value(){e[t]=i[t].toString()})),t=t.format(e)}jt&&qt.logNormal("Error reason: "+t),this._seriesErrorMessage=t;const s="unknown_symbol"!==t?12:Ut&&this._symbolInfo?10:4;this._setStatus(s),this._seriesLoaded=!0,this._enablePriceRangeReady()}_onSeriesLoading(e){this._loading=!0,this._setStatus(2)}_onDataUpdated(e,t){t?this._requestMoreDataAvailable=!0:this._lastPriceAnimationActive&&this._seriesLoaded&&this._lineStyleLastPriceCirclePaneView.update((0,ye.sourceChangeEvent)(this.id())),this._lastBarCloseTime=e&&e.closeTime||null,this._boxSizeValue.setValue(this.data().boxSize),this._statusView.update(),this.clearAveragePriceCache(),this.clearHighLowPriceCache();const i=this.model(),r=(0,s.ensureNotNull)(i.paneForSource(this));i.recalculatePane(r,(0,ye.sourceChangeEvent)({sourceId:this.id(),realtime:!t})),i.updateSource(this)}_setStatus(e){this._status=e,this._statusView.update(),this.model().updateSource(this),this._onStatusChanged.fire()}_onBarReceived(e){this.model().recalcVisibleRangeStudies(!0)}_recreateFormatter(){var e,t,i,s;let r=null;r=null!==(t=null===(e=null===Bt.customFormatters||void 0===Bt.customFormatters?void 0:Bt.customFormatters.priceFormatterFactory)||void 0===e?void 0:e.call(Bt.customFormatters,this.symbolInfo(),this.properties().childs().minTick.value()))&&void 0!==t?t:null,null!==r?(this._formatter=r,this._ignoreMinMoveFormatter=r):(this._formatter=(0,m.createSeriesFormatter)(null!==(i=this.symbolInfo())&&void 0!==i?i:this._formattingDeps,this.properties().childs().minTick.value()),this._ignoreMinMoveFormatter=(0, +m.createSeriesFormatter)(this.symbolInfo(),this.properties().childs().minTick.value(),!0)),null===(s=this._priceScale)||void 0===s||s.updateFormatter(),this._formatterChanged.fire()}_recreatePriceStep(){const{minMove:e,priceScale:t}=(0,m.getSeriesPriceFormattingState)(this.symbolInfo()),i=e/t;this._ignoreMinMovePriceStep=1/t,this._priceStep!==i&&(this._priceStep=i,this._priceStepChanged.fire())}_recreatePriceFormattingDependencies(){this._recreateFormatter(),this._recreatePriceStep()}_onQuotesUpdate(e,t){void 0!==e.values.current_session&&e.values.current_session!==this._currentSession&&(this._currentSession=e.values.current_session,this._updateLastPriceAnimationActive())}_updateIsPrePostMarketPricesForbiddenProperty(){const e=(0,m.symbolHasPreOrPostMarket)(this._symbolInfo)&&(this.isDWM()||(0,m.isRegularSessionId)(this.sessionIdProxyProperty().value()));this._isPrePostMarketPricesAvailableProperty.setValue(e)}_updateSettlementAsCloseForbiddenProperty(){}_updateBackAdjustmentForbiddenProperty(){}_removeReplaySubscriber(){throw new Error("Not implemented")}_getSymbolForApi(){return(0,m.symbolForApi)(this.symbolInfo()||this._prevSymbolInfo,this.symbol())}_getSymbolObject(){const e=this._getExtendedSymbolObject();if(v.SYMBOL_STRING_DATA.hasOwnProperty(this.properties().childs().style.value())){return{symbol:e,type:this.styleStudyInfo(this.getStyleShortName()+"Style").studyId+"!",inputs:this.getInputsProperties().state()}}return e}_getExtendedSymbolObject(){const e={symbol:this._getSymbolForApi()},t=this.properties().childs();null!==this.currency()&&(e["currency-id"]=this.currency());const i=this.unit();return this._model.unitConversionEnabled()&&null!==i&&(e["unit-id"]=i),!this.isDWM()&&$t&&(e.session=t.sessionId.value()),e}_checkChartStyle(){const e=this.style();(0,m.isCloseBasedSymbol)(this.symbolInfo())?(0,m.isSingleValueBasedStyle)(e)||(this.requestingStyleIsNotSupported.fire(),this._styleToRecover={correctedStyle:this.style(),originalStyle:e}):null!==this._styleToRecover&&(this.requestingStyleSupportRecovered.fire(this._styleToRecover.originalStyle),this._styleToRecover=null)}_updateSymbolInfo(e,t){if(this._prevSymbolInfo=t?this._symbolInfo:null,this._symbolInfo=e,e){const t=this._properties.childs();t.shortName.setValue(e.name);const i=(0,m.extractSymbolNameFromSymbolInfo)(e,this.symbol());i&&t.symbol.setValue(i);const s=(0,m.symbolCurrency)(e),r=(0,m.symbolUnit)(e,this._model.unitConversionEnabled());"alwaysOff"===(0,Q.currencyUnitVisibilityProperty)().value()||s===t.currencyId.value()&&r===t.unitId.value()||this._model.fullUpdate(),t.currencyId.setValue(s),t.unitId.setValue(r),this._updateSessionIdProxyProperty(!0)}this._base=e?e.pricescale/e.minmov:100,this._pointValue=e&&e.pointvalue||1;const i=this._getSymbolForApi();this._quotesProvider.setQuotesSessionSymbol(i),this._marketStatusModel.setSymbolInfo(e),e&&this._recreatePriceFormattingDependencies(),this._statusView.update(),this.priceScale().updateFormatter(),this._symbolResolvingActive.setValue(!e),$t&&this._updateIsPrePostMarketPricesForbiddenProperty()} +_createHighLowAvgViews(){const e=this.properties().childs().highLowAvgPrice,t=this._getHighLowPrice.bind(this),i=function(e,t,i,s){const r=i.childs(),n=Fe(e,t,{label:Ne,labelVisible:r.highLowPriceLabelsVisible,lineVisible:r.highLowPriceLinesVisible,lineColor:r.highLowPriceLinesColor,lineWidth:r.highLowPriceLinesWidth},(()=>s(0))),o=Fe(e,t,{label:Oe,labelVisible:r.highLowPriceLabelsVisible,lineVisible:r.highLowPriceLinesVisible,lineColor:r.highLowPriceLinesColor,lineWidth:r.highLowPriceLinesWidth},(()=>s(1)));return{paneViews:[n.paneView,o.paneView],panePriceAxisViews:[n.panePriceAxisView,o.panePriceAxisView],priceAxisViews:[n.priceAxisView,o.priceAxisView],priceLineAxisViews:[n.priceLineAxisView,o.priceLineAxisView]}}(this._model,this,e,t);this._highLowAvgPaneViews.push(...i.paneViews),this._labelPaneViews.push(...i.panePriceAxisViews),this._priceAxisViews.push(...i.priceAxisViews),this._priceLineAxisViews.push(...i.priceLineAxisViews)}_createAverageViews(){const e=this.properties().childs().highLowAvgPrice,t=this._getAveragePrice.bind(this),i=qe(this._model,this,e,t);this._averagePaneViews.push(...i.paneViews),this._labelPaneViews.push(...i.panePriceAxisViews),this._priceAxisViews.push(...i.priceAxisViews),this._priceLineAxisViews.push(...i.priceLineAxisViews)}_getHighLowPrice(e){if(!this._highLowPriceCache.has(e)){const e=this._model.timeScale().visibleBarsStrictRange();if(null===e)return null;const t=function(e,t,i){return e.minMaxOnRangeCached(t,i,[{name:"low",offset:0},{name:"high",offset:0}])}(this._model.mainSeries().bars(),e.firstBar(),e.lastBar());if(null===t)return null;this._highLowPriceCache.set(1,t.min),this._highLowPriceCache.set(0,t.max)}return this._highLowPriceCache.get(e)}_getAveragePrice(e){if(!this._averagePriceCache.has(e)){const e=this._model.timeScale().visibleBarsStrictRange();if(null===e)return null;const t=function(e,t,i){0;const s=(0,c.barFunction)("close");let r=0,n=0;for(let o=t;o<=i;o++){const t=e.valueAt(o);null!==t&&(r+=s(t),n++)}return n?r/n:null}(this._model.mainSeries().bars(),e.firstBar(),e.lastBar());if(null===t)return null;this._averagePriceCache.set(0,t)}return this._averagePriceCache.get(e)}_onSeriesCompleted(e){var t;this._loading=!1,this._seriesErrorMessage=null;let i=e.updateMode;switch("pulsed"===i&&(i="delayed"),i){case"streaming":this._setStatus(3);break;case"endofday":this._setStatus(6);break;case"delayed":this._setStatus(8);break;case"replay":this._setStatus(11)}i.match(/delayed_streaming/)&&this._setStatus(9),this._lastCompleteFlags=null!==(t=e.flags)&&void 0!==t?t:null;const r=(0,s.ensureNotNull)(this._model.paneForSource(this));r.recalculatePriceScale(this.priceScale(),(0,ye.sourceChangeEvent)(this.id()));const n=st.InvalidationMask.full();null!==this._model.appliedTimeFrame().value()&&n.lockVisibleTimeRangeOnResize(),this._model.invalidate(n),this.model().recalcVisibleRangeStudies(!0),this.model().recalcStudyBasedLineTools(),!this.priceScale().isLockScale()||this.model().timeScale().isEmpty()||this._seriesLoaded||(this.model().timeScale().correctOffset(), this.model().timeScale().correctBarSpacing(),this.model().resetPriceScale(r,this.priceScale())),this._seriesLoaded=!0,this._enablePriceRangeReady()}_notifyIntervalChanged(e){var t,i;const s={timeframe:null!==(t=this._pendingTimeRange)&&void 0!==t?t:void 0};this._intervalChanged.fire(e,s),this._pendingTimeRange=null!==(i=s.timeframe)&&void 0!==i?i:null}_onCurrencyChanged(){this._currencyChanged.fire()}_onUnitChanged(){this._unitChanged.fire()}_applySymbolParamsChanges(e){this._lastCompleteFlags=null,this.clearGotoDateResult();const t=this.interval();this.currency(),this.unit();ee.Interval.isRange(t)&&this._properties.childs().rangeStyle.childs().inputs.childs().range.setValue(ee.Interval.parse(t).multiplier());const{symbolChanged:i,intervalChanged:s,currencyChanged:r,unitChanged:n,force:o}=e,a=$t&&s&&ee.Interval.parse(t).isDWM()!=ee.Interval.parse(t).isDWM();if(this._syncModel=null,this._prevRequestedInterval=t,5!==this._status&&(!this._seriesSource.isStarted()||i||r||n||a)&&this._updateSymbolInfo(null,!i&&(r||n)),5===this._status)return void this._model.realignLineTools();this._loading=!0,this._setStatus(1),$t&&this._updateIsPrePostMarketPricesForbiddenProperty(),this._symbolIntervalChanged.fire(),s&&this._notifyIntervalChanged(t),this._onRestarted.fire(),this._seriesLoaded=!1,this._lineStyleLastPriceCirclePaneView.stopAnimation();let l=null;this._pendingTimeRange&&(l=this._pendingTimeRange,this._pendingTimeRange=null),this._onTimeFrameApplied.fire(l),this._onBeforeModifySeries(this.getSymbolString(),t);const c=this._shouldDefineNumberOfBarsForModifySeries(e)&&this._visibleBarsCount()||null;this._data=null,this._seriesSource.modifySeries(this._getResolvingSymbolObject(),(0,pt.getServerInterval)(t),l,o,c),this._seriesSource.isStarted()||(this._predictBars=0,this._seriesSource.start()),(i||r||n)&&this.disablePriceRangeReady(),this.updateAllViews((0,ye.sourceChangeEvent)(this.id())),this._model.lightUpdate()}_isIntervalSupported(e){return!0}_onBeforeModifySeries(e,t){0}_getResolvingSymbolObject(){return this._getSymbolObject()}_onSessionIdPropertyChanged(){this._sessionIdChanged.fire(),this.isDWM()||(this.restart(),this._updateLastPriceAnimationActive())}_subscribeRestartToSessionIdChange(){this.properties().childs().sessionId.subscribe(this,this._onSessionIdPropertyChangedBound)}_unsubscribeRestartToSessionIdChange(){this.properties().childs().sessionId.unsubscribe(this,this._onSessionIdPropertyChangedBound)}_updateLastPriceAnimationActive(){if(!this._options.lastPriceAnimationEnabled)return;const e=this._lastPriceAnimationActive,t=this.properties().childs(),i=t.style.value(),s=3===i||10===i||2===i||14===i||15===i;if(!this._model.isSnapshot()&&t.visible.value()&&s){const e=this.currentSession(),t=!(0,m.isRegularSessionId)(this.sessionIdProxyProperty().value())&&!this.isDWM();this._lastPriceAnimationActive="market"===e||t&&("pre_market"===e||"post_market"===e)}else this._lastPriceAnimationActive=!1;this._lastPriceAnimationActive&&e!==this._lastPriceAnimationActive&&this.model().invalidate(st.InvalidationMask.cursor())} -_onPropertiesChanged(e){const t=this._properties.childs();e!==t.symbol&&e!==t.interval&&e!==t.timeframe&&(this._tagsChanged.fire(),this.createPaneView(),this.updateAllViews((0,ye.sourceChangeEvent)(this._id)),this.model().updateSource(this),(0,o.emit)("series_properties_changed",this._id))}_recalcSymbolTextSourceProxyProperty(){this._textSourceIsAlwaysTickerRestrictionEnabled?this._symbolTextSourceProxyProperty.setValue("ticker"):this._symbolTextSourceProxyProperty.setValue(this._properties.childs().statusViewStyle.childs().symbolTextSource.value())}_clearStylePlot(e,t){if(0===e.size())return;if(void 0===t&&e!==this.nsBars())return void(this._precomputedBarStyles=new WeakMap);const i=null!=t?t:(0,s.ensureNotNull)(e.firstIndex()),r=(0,s.ensureNotNull)(e.lastIndex())+1;e.range(i,r).each(((e,t)=>(this._precomputedBarStyles.delete(t),!1)))}_visibleBarsCount(){const e=this._model.timeScale().visibleBarsStrictRange();return null==e?void 0:e.count()}_shouldDefineNumberOfBarsForModifySeries(e){return b.enabled("request_only_visible_range_on_reset")&&e.force||!1}}},88732:(e,t,i)=>{"use strict";i.r(t),i.d(t,{SERIES_STATUS_TEXT:()=>g,STATUS_DELAYED:()=>d,STATUS_DELAYED_STREAMING:()=>u,STATUS_EOD:()=>c,STATUS_ERROR:()=>m,STATUS_INVALID_SYMBOL:()=>a,STATUS_LOADING:()=>n,STATUS_NO_BARS:()=>p,STATUS_OFFLINE:()=>s,STATUS_PULSE:()=>h,STATUS_READY:()=>o,STATUS_REPLAY:()=>_,STATUS_RESOLVING:()=>r,STATUS_SNAPSHOT:()=>l,STYLE_AREA:()=>y,STYLE_BARS:()=>f,STYLE_BASELINE:()=>I,STYLE_CANDLES:()=>v,STYLE_COLUMNS:()=>A,STYLE_HEIKEN_ASHI:()=>x,STYLE_HILO:()=>L,STYLE_HLC_AREA:()=>V,STYLE_HOLLOW_CANDLES:()=>T,STYLE_KAGI:()=>w,STYLE_LINE:()=>S,STYLE_LINE_WITH_MARKERS:()=>k,STYLE_PB:()=>C,STYLE_PNF:()=>P,STYLE_RANGE:()=>M,STYLE_RENKO:()=>b,STYLE_SHORT_NAMES:()=>E,STYLE_STEPLINE:()=>D,SYMBOL_STRING_DATA:()=>B});const s=0,r=1,n=2,o=3,a=4,l=5,c=6,h=7,d=8,u=9,p=10,_=11,m=12,g={[s]:"connecting",[r]:"loading",[n]:"loading",[o]:"realtime",[a]:"invalid",[l]:"snapshot",[c]:"endofday",[h]:"endofday",[d]:"delayed",[u]:"delayed_streaming",[p]:"forbidden",[_]:"replay",[m]:"error"},f=0,v=1,S=2,y=3,b=4,w=5,P=6,C=7,x=8,T=9,I=10,M=11,L=12,A=13,k=14,D=15,V=16,E={0:"bar",1:"candle",9:"hollowCandle",2:"line",14:"lineWithMarkers",15:"stepline",3:"area",16:"hlcArea",4:"renko",7:"pb",5:"kagi",6:"pnf",8:"ha",10:"baseline",11:"range",12:"hilo",13:"column"},B={4:{type:"BarSetRenko@tv-prostudies",basicStudyVersion:64},7:{type:"BarSetPriceBreak@tv-prostudies",basicStudyVersion:34},5:{type:"BarSetKagi@tv-prostudies",basicStudyVersion:34},6:{type:"BarSetPnF@tv-prostudies",basicStudyVersion:34},8:{type:"BarSetHeikenAshi@tv-basicstudies",basicStudyVersion:60},11:{type:"BarSetRange@tv-basicstudies",basicStudyVersion:72}}},13497:(e,t,i)=>{"use strict";i.d(t,{SeriesData:()=>p,barFunction:()=>h,seriesPlotFunctionMap:()=>c});var s,r=i(50151),n=i(97034),o=i(78071);!function(e){e[e.FromLeft=-1]="FromLeft",e[e.FromRight=1]="FromRight"}(s||(s={}));const a={open:e=>e[1],high:e=>e[2],low:e=>e[3],close:e=>e[4],hl2:e=>(e[2]+e[3])/2,hlc3:e=>(e[2]+e[3]+e[4])/3,ohlc4:e=>(e[1]+e[2]+e[3]+e[4])/4 +_onPropertiesChanged(e){const t=this._properties.childs();e!==t.symbol&&e!==t.interval&&e!==t.timeframe&&(this._tagsChanged.fire(),this.createPaneView(),this.updateAllViews((0,ye.sourceChangeEvent)(this._id)),this.model().updateSource(this),(0,o.emit)("series_properties_changed",this._id))}_recalcSymbolTextSourceProxyProperty(){this._textSourceIsAlwaysTickerRestrictionEnabled?this._symbolTextSourceProxyProperty.setValue("ticker"):this._symbolTextSourceProxyProperty.setValue(this._properties.childs().statusViewStyle.childs().symbolTextSource.value())}_clearStylePlot(e,t){if(0===e.size())return;if(void 0===t&&e!==this.nsBars())return void(this._precomputedBarStyles=new WeakMap);const i=null!=t?t:(0,s.ensureNotNull)(e.firstIndex()),r=(0,s.ensureNotNull)(e.lastIndex())+1;e.range(i,r).each(((e,t)=>(this._precomputedBarStyles.delete(t),!1)))}_visibleBarsCount(){const e=this._model.timeScale().visibleBarsStrictRange();return null==e?void 0:e.count()}_shouldDefineNumberOfBarsForModifySeries(e){return b.enabled("request_only_visible_range_on_reset")&&e.force||!1}}},88732:(e,t,i)=>{"use strict";i.r(t),i.d(t,{SERIES_STATUS_TEXT:()=>g,STATUS_DELAYED:()=>d,STATUS_DELAYED_STREAMING:()=>u,STATUS_EOD:()=>c,STATUS_ERROR:()=>m,STATUS_INVALID_SYMBOL:()=>a,STATUS_LOADING:()=>n,STATUS_NO_BARS:()=>p,STATUS_OFFLINE:()=>s,STATUS_PULSE:()=>h,STATUS_READY:()=>o,STATUS_REPLAY:()=>_,STATUS_RESOLVING:()=>r,STATUS_SNAPSHOT:()=>l,STYLE_AREA:()=>y,STYLE_BARS:()=>f,STYLE_BASELINE:()=>I,STYLE_CANDLES:()=>v,STYLE_COLUMNS:()=>A,STYLE_HEIKEN_ASHI:()=>x,STYLE_HILO:()=>L,STYLE_HLC_AREA:()=>E,STYLE_HOLLOW_CANDLES:()=>T,STYLE_KAGI:()=>w,STYLE_LINE:()=>S,STYLE_LINE_WITH_MARKERS:()=>k,STYLE_PB:()=>C,STYLE_PNF:()=>P,STYLE_RANGE:()=>M,STYLE_RENKO:()=>b,STYLE_SHORT_NAMES:()=>V,STYLE_STEPLINE:()=>D,SYMBOL_STRING_DATA:()=>B});const s=0,r=1,n=2,o=3,a=4,l=5,c=6,h=7,d=8,u=9,p=10,_=11,m=12,g={[s]:"connecting",[r]:"loading",[n]:"loading",[o]:"realtime",[a]:"invalid",[l]:"snapshot",[c]:"endofday",[h]:"endofday",[d]:"delayed",[u]:"delayed_streaming",[p]:"forbidden",[_]:"replay",[m]:"error"},f=0,v=1,S=2,y=3,b=4,w=5,P=6,C=7,x=8,T=9,I=10,M=11,L=12,A=13,k=14,D=15,E=16,V={0:"bar",1:"candle",9:"hollowCandle",2:"line",14:"lineWithMarkers",15:"stepline",3:"area",16:"hlcArea",4:"renko",7:"pb",5:"kagi",6:"pnf",8:"ha",10:"baseline",11:"range",12:"hilo",13:"column"},B={4:{type:"BarSetRenko@tv-prostudies",basicStudyVersion:64},7:{type:"BarSetPriceBreak@tv-prostudies",basicStudyVersion:34},5:{type:"BarSetKagi@tv-prostudies",basicStudyVersion:34},6:{type:"BarSetPnF@tv-prostudies",basicStudyVersion:34},8:{type:"BarSetHeikenAshi@tv-basicstudies",basicStudyVersion:60},11:{type:"BarSetRange@tv-basicstudies",basicStudyVersion:72}}},13497:(e,t,i)=>{"use strict";i.d(t,{SeriesData:()=>p,barFunction:()=>h,seriesPlotFunctionMap:()=>c});var s,r=i(50151),n=i(97034),o=i(78071);!function(e){e[e.FromLeft=-1]="FromLeft",e[e.FromRight=1]="FromRight"}(s||(s={}));const a={open:e=>e[1],high:e=>e[2],low:e=>e[3],close:e=>e[4],hl2:e=>(e[2]+e[3])/2,hlc3:e=>(e[2]+e[3]+e[4])/3,ohlc4:e=>(e[1]+e[2]+e[3]+e[4])/4 },l=["open","high","low","close","hl2","hlc3","ohlc4"];function c(){const e=new Map;return l.forEach(((t,i)=>{e.set(t,h(t))})),e}function h(e,t,i){const s=a[null!=t?t:e],r=a[e],n=a[null!=i?i:e];return(e,t)=>{switch(t){case 0:return s(e);case 2:return n(e);default:return r(e)}}}function d(e,t){return null==e[t]}const u=[{barsToMerge:10,forBarspacingLargerThen:.03},{barsToMerge:30,forBarspacingLargerThen:.01},{barsToMerge:100,forBarspacingLargerThen:.003},{barsToMerge:500,forBarspacingLargerThen:0}];class p{constructor(){this._pressedChunks={chunks:new Map,priceSource:"uninitialized"},this.m_bars=new n.PlotList(c(),d),this.m_nsBars=new n.PlotList(c(),d),this._clearPressedChunks()}bars(){return this.m_bars}nsBars(){return this.m_nsBars}pressedChunks(e,t){if(t!==this._pressedChunks.priceSource){this._pressedChunks.priceSource=t;const e=this.m_bars.first();e&&(this._clearPressedChunks(),this._rebuildPressedChunks(e))}const i=(0,r.ensureDefined)(u.find((t=>t.forBarspacingLargerThen<=e)));return(0,r.ensureDefined)(this._pressedChunks.chunks.get(i.barsToMerge))}mergeRegularBars(e){const t=this.m_bars.size(),i=this.m_bars.merge(e);return i&&"uninitialized"!==this._pressedChunks.priceSource&&(t===this.m_bars.size()&&i.index===this.m_bars.lastIndex()?this._updateLatestChunks():this._rebuildPressedChunks(i)),i}size(){return this.m_bars.size()+this.m_nsBars.size()}each(e){this.m_bars.each(e),this.m_nsBars.each(e)}clear(){this.m_bars.clear(),this.m_nsBars.clear(),this.lastProjectionPrice=void 0,this._clearPressedChunks()}isEmpty(){return this.m_bars.isEmpty()&&this.m_nsBars.isEmpty()}first(){return this.m_bars.isEmpty()?this.m_nsBars.first():this.m_bars.first()}last(){return this.m_nsBars.isEmpty()?this.m_bars.last():this.m_nsBars.last()}search(e,t){return this.nsBars().isEmpty()?this.bars().search(e,t):this.bars().isEmpty()||(0,r.ensureNotNull)(this.nsBars().firstIndex())<=e?this.nsBars().search(e,t):this.bars().search(e,t)}valueAt(e){const t=this.search(e);return null!==t?t.value:null}plotValueToTimePointIndex(e,t,i){if(i===s.FromRight){const i=(i,s)=>{const r=s[t];return null!=r&&e>=r},s=this.m_bars.findLast(i);if(null!==s)return s.index;const r=this.m_nsBars.findLast(i);return null!==r?r.index:this.m_bars.firstIndex()}if(i===s.FromLeft){const i=(i,s)=>{const r=s[t];return null!=r&&e<=r},s=this.m_bars.findFirst(i);if(null!==s)return s.index;const r=this.m_nsBars.findFirst(i);return null!==r?r.index:this.m_bars.lastIndex()}throw new Error("plotValueToTimePointIndex: unsupported search mode")}moveData(e){this.m_bars.move(e),this.m_nsBars.move(e),this.m_bars.size()>0&&this._rebuildPressedChunks((0,r.ensureNotNull)(this.m_bars.first()))}_rebuildPressedChunks(e){const t=this._pressedChunks.priceSource;if("uninitialized"===t)return;const i=e.index,s=a[t],n=(e,t,i)=>{let r=null;for(;e.hasNext();){const n=e.next(),o=s(n.value);r&&n.index-r.startTime>=i.barsToMerge&&(t.push(r),r=null),r?(r.endTime=n.index,r.high=Math.max(r.high,o),r.low=Math.min(r.low,o),r.close=o):r={startTime:n.index,endTime:n.index,open:o,high:o,low:o,close:o}} -r&&t.push(r)};u.forEach((e=>{const t=(0,r.ensureDefined)(this._pressedChunks.chunks.get(e.barsToMerge)),s=(0,o.lowerbound)(t,i,((e,t)=>e.endTime0){const i=t[0].startTime-1,s=(0,r.ensureNotNull)(this.m_bars.firstIndex()),o=this.m_bars.rangeIterator(s,i),a=[];n(o,a,e);const l=a.concat(t);this._pressedChunks.chunks.set(e.barsToMerge,l)}else{const i=(0,r.ensureNotNull)(this.m_bars.lastIndex());t.splice(s);let o=(0,r.ensureNotNull)(this.m_bars.firstIndex());t.length&&(o=t[t.length-1].endTime+1);const a=this.m_bars.rangeIterator(o,i);n(a,t,e)}}))}_updateLatestChunks(){const e=(0,r.ensureNotNull)(this.m_bars.lastIndex());u.forEach((t=>{const i=(0,r.ensureDefined)(this._pressedChunks.chunks.get(t.barsToMerge)),s=this.m_bars.rangeIterator(e,e).next(),n=s.value[4],o=i[i.length-1];o.high=Math.max(o.high,n),o.low=Math.min(o.low,n),o.close=n,o.endTime=s.index}))}_clearPressedChunks(){u.forEach((e=>this._pressedChunks.chunks.set(e.barsToMerge,[])))}}},96280:(e,t,i)=>{"use strict";i.d(t,{SeriesTimeRangeVolumeCalculator:()=>s});class s{constructor(e){this._value=null,this._series=e,this._series.dataEvents().dataUpdated().subscribe(this,this._onSeriesUpdated)}destroy(){this._series.dataEvents().dataUpdated().unsubscribeAll(this)}volume(e,t){if(null!==this._value&&this._value.from===e&&this._value.to===t)return this._value.value;let i=0;const s=this._series.data().bars(),r=s.firstIndex(),n=s.lastIndex();if(null!==r&&en&&t>n)i=NaN;else{const s=this._series.data().bars().rangeIterator(Math.min(e,t),Math.max(e,t));for(;s.hasNext();){const e=s.next().value[5];if(void 0===e){i=NaN;break}i+=e}}return this._value={from:e,to:t,value:i},i}_onSeriesUpdated(e,t){if(null===this._value)return;if(t)return void(this._value=null);const i=this._series.data().bars().lastIndex();(null===i||i<=this._value.to)&&(this._value=null)}}},42960:(e,t,i)=>{"use strict";i.r(t),i.d(t,{actualSymbol:()=>de,chartStyleStudyId:()=>W,createSeriesFormatter:()=>q,displayedSymbolExchange:()=>he,displayedSymbolName:()=>ce,extractSymbolNameFromSymbolInfo:()=>ae,getChartStyleByResolution:()=>F,getDefaultStyle:()=>O,getLastUsedRawDataStyle:()=>N,getLastUsedSingleValueBasedStyle:()=>R,getLastUsedStyle:()=>B,getSeriesDisplayErrorWV:()=>Pe,getSeriesPriceFormattingState:()=>G,getStudySymbolExchange:()=>ye,getTranslatedChartStyleName:()=>x,hasProjection:()=>U,hasVolume:()=>ve,isCloseBasedSymbol:()=>me,isConvertedToOtherCurrency:()=>X,isConvertedToOtherUnit:()=>te,isEconomicSymbol:()=>Se,isFutureContinuousSymbolWithBackajustment:()=>be,isFuturesContractSymbol:()=>we,isMeasureUnitSymbol:()=>ge,isPriceSourceStyle:()=>j,isRangeBasedStyle:()=>I,isRangeStyle:()=>M,isRawDataStyle:()=>D,isRegularSessionId:()=>_e,isRequiringRestartSeriesStyles:()=>T,isSingleValueBasedStyle:()=>k,isTimeBasedStyle:()=>L,isValidStyle:()=>A,measureUnitId:()=>fe,preparePriceAxisProperties:()=>H,proSymbol:()=>ue,setLastUsedRawDataStyle:()=>E,setLastUsedStyle:()=>V,symbolBaseCurrency:()=>Z,symbolCurrency:()=>Y,symbolCurrencyConvertible:()=>$,symbolCurrentContract:()=>se, -symbolForApi:()=>pe,symbolHasEconomicEvents:()=>oe,symbolHasPreOrPostMarket:()=>re,symbolHasSeveralSessions:()=>ne,symbolOriginalCurrency:()=>K,symbolOriginalUnit:()=>ee,symbolTitle:()=>le,symbolUnit:()=>Q,symbolUnitConvertible:()=>J,symbolUnitConvertibleGroupsIfExist:()=>ie});var s=i(44352),r=i(56840),n=i(88145),o=i(88732),a=i(36274),l=i(61146),c=i(14483),h=i(50151),d=i(98596),u=i(93572),p=i(91349),_=i(97906),m=i(28986);const g=c.enabled("pay_attention_to_ticker_not_symbol"),f=c.enabled("uppercase_instrument_names"),v=c.enabled("charting_library_single_symbol_request"),S=c.enabled("use_ticker_on_symbol_info_update"),y=c.enabled("hide_object_tree_and_price_scale_exchange_label"),b=[4,5,6,7,8],w=[4,5,6,7,11],P=[0,1,9,2,14,15,3,16,10,8,12,13],C=[2,14,15,10,3,13];function x(e){return{0:s.t(null,void 0,i(16812)),1:s.t(null,void 0,i(63528)),2:s.t(null,void 0,i(1277)),14:s.t(null,void 0,i(38397)),15:s.t(null,void 0,i(79511)),3:s.t(null,void 0,i(42097)),16:s.t(null,void 0,i(34911)),9:s.t(null,void 0,i(61582)),10:s.t(null,void 0,i(17712)),12:s.t(null,void 0,i(31994)),13:s.t(null,void 0,i(36018)),4:s.t(null,void 0,i(20801)),7:s.t(null,void 0,i(63492)),5:s.t(null,void 0,i(92901)),6:s.t(null,void 0,i(99969)),11:s.t(null,void 0,i(90357)),8:s.t(null,void 0,i(40530))}[e]}function T(e){return-1!==b.indexOf(e)}function I(e){return-1!==w.indexOf(e)}function M(e){return 11===e}function L(e){return-1!==P.indexOf(e)}function A(e){return I(e)||L(e)}function k(e){switch(e){case 3:case 10:case 2:case 14:case 15:case 13:return!0;default:return!1}}function D(e){return!o.SYMBOL_STRING_DATA[e]}function V(e,t){A(e)&&(11!==e&&r.setValue("chart.lastUsedStyle",e),D(e)&&E(e),me(t)&&k(e)&&r.setValue("chart.lastUsedSingleValueBasedStyle",e))}function E(e){r.setValue("chart.rawDataStyle",e)}function B(){const e=r.getInt("chart.lastUsedStyle");return void 0===e?1:e}function R(){const e=r.getInt("chart.lastUsedSingleValueBasedStyle");return void 0===e?14:e}function N(){return r.getInt("chart.rawDataStyle",1)}function O(e){return e?11:1}function F(e,t){const i=M(t),s=a.Interval.isRange(e);return!i&&s?O(!0):i&&!s?O(!1):t}function W(e,t){const i=o.SYMBOL_STRING_DATA[e];return void 0===i?null:t?`${i.type}-${i.basicStudyVersion}`:i.type}function H(e){const t=e.priceAxisProperties,i=t.lockScale.value(),s=6===e.style.value();(s||i)&&(t.log.setValue(!1),t.percentage.setValue(!1)),t.logDisabled.setValue(!(!s&&!i)),t.percentageDisabled.setValue(!(!s&&!i))}const z=[4,7,5,6];function U(e){return-1!==z.indexOf(e)}function j(e){return C.includes(e)}function G(e,t="default",i=!1){let s,r,n,o=100,a=1;if("default"===t)null!=e&&(({pricescale:o,minmov:a,minmove2:r,fractional:s}=e),n=e.variable_tick_size||void 0);else{let e=t.split(",");3!==e.length&&(e=["100","1","false"]),o=parseInt(e[0]),a=parseInt(e[1]),s="true"===e[2]}return i&&(a=1),{priceScale:o,minMove:a,fractional:s,minMove2:r,variableMinTick:n,ignoreMinMove:i}}function q(e,t,i=!1){if("default"===t&&null!=e){const t=e.formatter||e.format;if("volume"===t)return new d.VolumeFormatter(2) +r&&t.push(r)};u.forEach((e=>{const t=(0,r.ensureDefined)(this._pressedChunks.chunks.get(e.barsToMerge)),s=(0,o.lowerbound)(t,i,((e,t)=>e.endTime0){const i=t[0].startTime-1,s=(0,r.ensureNotNull)(this.m_bars.firstIndex()),o=this.m_bars.rangeIterator(s,i),a=[];n(o,a,e);const l=a.concat(t);this._pressedChunks.chunks.set(e.barsToMerge,l)}else{const i=(0,r.ensureNotNull)(this.m_bars.lastIndex());t.splice(s);let o=(0,r.ensureNotNull)(this.m_bars.firstIndex());t.length&&(o=t[t.length-1].endTime+1);const a=this.m_bars.rangeIterator(o,i);n(a,t,e)}}))}_updateLatestChunks(){const e=(0,r.ensureNotNull)(this.m_bars.lastIndex());u.forEach((t=>{const i=(0,r.ensureDefined)(this._pressedChunks.chunks.get(t.barsToMerge)),s=this.m_bars.rangeIterator(e,e).next(),n=s.value[4],o=i[i.length-1];o.high=Math.max(o.high,n),o.low=Math.min(o.low,n),o.close=n,o.endTime=s.index}))}_clearPressedChunks(){u.forEach((e=>this._pressedChunks.chunks.set(e.barsToMerge,[])))}}},96280:(e,t,i)=>{"use strict";i.d(t,{SeriesTimeRangeVolumeCalculator:()=>s});class s{constructor(e){this._value=null,this._series=e,this._series.dataEvents().dataUpdated().subscribe(this,this._onSeriesUpdated)}destroy(){this._series.dataEvents().dataUpdated().unsubscribeAll(this)}volume(e,t){if(null!==this._value&&this._value.from===e&&this._value.to===t)return this._value.value;let i=0;const s=this._series.data().bars(),r=s.firstIndex(),n=s.lastIndex();if(null!==r&&en&&t>n)i=NaN;else{const s=this._series.data().bars().rangeIterator(Math.min(e,t),Math.max(e,t));for(;s.hasNext();){const e=s.next().value[5];if(void 0===e){i=NaN;break}i+=e}}return this._value={from:e,to:t,value:i},i}_onSeriesUpdated(e,t){if(null===this._value)return;if(t)return void(this._value=null);const i=this._series.data().bars().lastIndex();(null===i||i<=this._value.to)&&(this._value=null)}}},42960:(e,t,i)=>{"use strict";i.r(t),i.d(t,{actualSymbol:()=>de,chartStyleStudyId:()=>W,createSeriesFormatter:()=>q,displayedSymbolExchange:()=>he,displayedSymbolName:()=>ce,extractSymbolNameFromSymbolInfo:()=>ae,getChartStyleByResolution:()=>F,getDefaultStyle:()=>O,getLastUsedRawDataStyle:()=>N,getLastUsedSingleValueBasedStyle:()=>R,getLastUsedStyle:()=>B,getSeriesDisplayErrorWV:()=>Pe,getSeriesPriceFormattingState:()=>G,getStudySymbolExchange:()=>ye,getTranslatedChartStyleName:()=>x,hasProjection:()=>U,hasVolume:()=>ve,isCloseBasedSymbol:()=>me,isConvertedToOtherCurrency:()=>X,isConvertedToOtherUnit:()=>te,isEconomicSymbol:()=>Se,isFutureContinuousSymbolWithBackajustment:()=>be,isFuturesContractSymbol:()=>we,isMeasureUnitSymbol:()=>ge,isPriceSourceStyle:()=>j,isRangeBasedStyle:()=>I,isRangeStyle:()=>M,isRawDataStyle:()=>D,isRegularSessionId:()=>_e,isRequiringRestartSeriesStyles:()=>T,isSingleValueBasedStyle:()=>k,isTimeBasedStyle:()=>L,isValidStyle:()=>A,measureUnitId:()=>fe,preparePriceAxisProperties:()=>H,proSymbol:()=>ue,setLastUsedRawDataStyle:()=>V,setLastUsedStyle:()=>E,symbolBaseCurrency:()=>Z,symbolCurrency:()=>Y,symbolCurrencyConvertible:()=>$,symbolCurrentContract:()=>se, +symbolForApi:()=>pe,symbolHasEconomicEvents:()=>oe,symbolHasPreOrPostMarket:()=>re,symbolHasSeveralSessions:()=>ne,symbolOriginalCurrency:()=>K,symbolOriginalUnit:()=>ee,symbolTitle:()=>le,symbolUnit:()=>Q,symbolUnitConvertible:()=>J,symbolUnitConvertibleGroupsIfExist:()=>ie});var s=i(44352),r=i(56840),n=i(88145),o=i(88732),a=i(36274),l=i(61146),c=i(14483),h=i(50151),d=i(98596),u=i(93572),p=i(91349),_=i(97906),m=i(28986);const g=c.enabled("pay_attention_to_ticker_not_symbol"),f=c.enabled("uppercase_instrument_names"),v=c.enabled("charting_library_single_symbol_request"),S=c.enabled("use_ticker_on_symbol_info_update"),y=c.enabled("hide_object_tree_and_price_scale_exchange_label"),b=[4,5,6,7,8],w=[4,5,6,7,11],P=[0,1,9,2,14,15,3,16,10,8,12,13],C=[2,14,15,10,3,13];function x(e){return{0:s.t(null,void 0,i(16812)),1:s.t(null,void 0,i(63528)),2:s.t(null,void 0,i(1277)),14:s.t(null,void 0,i(38397)),15:s.t(null,void 0,i(79511)),3:s.t(null,void 0,i(42097)),16:s.t(null,void 0,i(34911)),9:s.t(null,void 0,i(61582)),10:s.t(null,void 0,i(17712)),12:s.t(null,void 0,i(31994)),13:s.t(null,void 0,i(36018)),4:s.t(null,void 0,i(20801)),7:s.t(null,void 0,i(63492)),5:s.t(null,void 0,i(92901)),6:s.t(null,void 0,i(99969)),11:s.t(null,void 0,i(90357)),8:s.t(null,void 0,i(40530))}[e]}function T(e){return-1!==b.indexOf(e)}function I(e){return-1!==w.indexOf(e)}function M(e){return 11===e}function L(e){return-1!==P.indexOf(e)}function A(e){return I(e)||L(e)}function k(e){switch(e){case 3:case 10:case 2:case 14:case 15:case 13:return!0;default:return!1}}function D(e){return!o.SYMBOL_STRING_DATA[e]}function E(e,t){A(e)&&(11!==e&&r.setValue("chart.lastUsedStyle",e),D(e)&&V(e),me(t)&&k(e)&&r.setValue("chart.lastUsedSingleValueBasedStyle",e))}function V(e){r.setValue("chart.rawDataStyle",e)}function B(){const e=r.getInt("chart.lastUsedStyle");return void 0===e?1:e}function R(){const e=r.getInt("chart.lastUsedSingleValueBasedStyle");return void 0===e?14:e}function N(){return r.getInt("chart.rawDataStyle",1)}function O(e){return e?11:1}function F(e,t){const i=M(t),s=a.Interval.isRange(e);return!i&&s?O(!0):i&&!s?O(!1):t}function W(e,t){const i=o.SYMBOL_STRING_DATA[e];return void 0===i?null:t?`${i.type}-${i.basicStudyVersion}`:i.type}function H(e){const t=e.priceAxisProperties,i=t.lockScale.value(),s=6===e.style.value();(s||i)&&(t.log.setValue(!1),t.percentage.setValue(!1)),t.logDisabled.setValue(!(!s&&!i)),t.percentageDisabled.setValue(!(!s&&!i))}const z=[4,7,5,6];function U(e){return-1!==z.indexOf(e)}function j(e){return C.includes(e)}function G(e,t="default",i=!1){let s,r,n,o=100,a=1;if("default"===t)null!=e&&(({pricescale:o,minmov:a,minmove2:r,fractional:s}=e),n=e.variable_tick_size||void 0);else{let e=t.split(",");3!==e.length&&(e=["100","1","false"]),o=parseInt(e[0]),a=parseInt(e[1]),s="true"===e[2]}return i&&(a=1),{priceScale:o,minMove:a,fractional:s,minMove2:r,variableMinTick:n,ignoreMinMove:i}}function q(e,t,i=!1){if("default"===t&&null!=e){const t=e.formatter||e.format;if("volume"===t)return new d.VolumeFormatter(2) ;if("percent"===t)return new u.PercentageFormatter(e.pricescale)}const{priceScale:s,minMove:r,fractional:n,minMove2:o,variableMinTick:a}=G(e,t,i);return new l.PriceFormatter(s,r,n,o,a,i)}function $(e){return null!==e&&"spread"!==e.type}function Y(e,t,i){if(null===e)return null;const s=!t||i?e.currency_id:e.currency_code;return void 0===s||""===s?null:s}function K(e,t){const i=t?e.original_currency_code:e.original_currency_id;return null!=i?i:Y(e,t)}function Z(e){return e.base_currency_id||null}function X(e){return!(null===e||!$(e))&&(void 0!==e.original_currency_id&&e.original_currency_id!==e.currency_id)}function J(e,t){return t&&null!==e&&"spread"!==e.type}function Q(e,t){if(null===e||!t)return null;const i=e.unit_id;return void 0===i||""===i?null:i}function ee(e,t){return t?e.original_unit_id||Q(e,t):null}function te(e,t){return!(null===e||!J(e,t))&&(void 0!==e.original_unit_id&&e.original_unit_id!==e.unit_id)}function ie(e,t){return null!==e&&J(e,t)?e.unit_conversion_types||null:[]}function se(e){return"futures"===e.type&&e.front_contract||null}function re(e){return null!==e&&void 0!==e.subsessions&&e.subsessions.some((e=>"premarket"===e.id||"postmarket"===e.id))}function ne(e){return null!==e&&void 0!==e.subsessions&&e.subsessions.filter((e=>!e.private)).length>1}function oe(e){return null!==e&&("forex"===e.type||(0,p.isCFDSymbol)(e.type,e.typespecs)||(0,n.hasCryptoTypespec)(e.typespecs||[]))}function ae(e,t){let i=e&&(e.pro_name||e.full_name||e.name);return v&&t?i=t:S&&e&&e.ticker&&(i=e.ticker),f&&i&&(i=i.toUpperCase()),i}function le(e,t,i="exchange"){return t||y?e.name:`${e.name}, ${e[i]}`}function ce(e){let t=e&&(se(e)||e.name)||"";return t.length>40&&(t=t.substring(0,37)+"..."),t.trim()}function he(e){const t=e?e.exchange:"";return f?t.toUpperCase():t}function de(e,t){return null!==e?e.full_name:t}function ue(e,t){var i;return null!==(i=null==e?void 0:e.pro_name)&&void 0!==i?i:t}function pe(e,t){return g&&e?(0,h.ensureDefined)(e.ticker):de(e,t)}function _e(e){return"regular"===e||"us_regular"===e}function me(e){return"c"===(null==e?void 0:e.visible_plots_set)}function ge(e){return null!==e&&("unit"===e.measure&&null!==fe(e))}function fe(e){var t;return null!==(t=null==e?void 0:e.value_unit_id)&&void 0!==t?t:null}function ve(e){return void 0!==e.visible_plots_set&&"ohlcv"===e.visible_plots_set}function Se(e){return null!==e&&"economic"===e.type}function ye(e){return Se(e)&&e.source?e.source:e.exchange&&0!==e.exchange.length?e.exchange:void 0}function be(e){var t;return null!==e&&"futures"===e.type&&Boolean(e.has_backadjustment&&(null===(t=e.typespecs)||void 0===t?void 0:t.includes("continuous")))}function we(e){var t;return null!==e&&"futures"===e.type&&!Boolean(null===(t=e.typespecs)||void 0===t?void 0:t.includes("continuous"))}function Pe(e){return(0,_.combine)(((t,i)=>{switch(t){case 4:{const t=e.seriesErrorMessage();return null!==t&&("resolution_not_entitled"===t||"custom_resolution"===t||"seconds_not_entitled"===t||t.startsWith("study_not_auth:"))?null:"invalid_symbol"}case 1:case 2:return null;default: if(i)return"no_data"}return null}),(0,m.createWVFromGetterAndSubscription)((()=>e.status()),e.onStatusChanged()).ownership(),(0,m.createWVFromGetterAndSubscription)((()=>!e.bars().size()&&!e.isInReplay()),e.dataEvents().dataUpdated()).ownership(),(0,m.createWVFromGetterAndSubscription)((()=>({})),e.model().onChartThemeLoaded()).ownership())}},76544:(e,t,i)=>{"use strict";var s=i(59452);TradingView.DEFAULT_BAR_COUNT=300,TradingView.TIME_PLOT=0,TradingView.OPEN_PLOT=1,TradingView.HIGH_PLOT=2,TradingView.LOW_PLOT=3,TradingView.CLOSE_PLOT=4,TradingView.ADT_PLOT=6;var r=i(89379).SeriesBase,n=(i(51768).trackEvent,i(59224).getLogger("Chart.Series")),o=i(88732),a=i(25525).SeriesHorizontalBaseLinePaneView,l=i(17133).TIMEFRAMETYPE,c=i(42960).isSingleValueBasedStyle;class h extends r{constructor(e,t,i,s){t.removeProperty("currencyId"),super(e,t,i,s),this._chartApi=e._chartApi,this.createPaneView(),this._properties.addExclusion&&(this._properties.addExclusion("visible"),this._properties.addExclusion("currencyId")),this._futureBarsPaneView=null,this.properties().minTick.listeners().subscribe(this,h.prototype._recreateFormatter);var r=this;this.properties().minTick.listeners().subscribe(null,(function(){r._model.fullUpdate()})),this._priceLineView=null,this._baseHorizontalLineView=new a(this),this.bindStyleChange(),this.bindJapChartsInputs(),this._createIsDWMProperty(),this.properties().showCountdown.listeners().subscribe(this,h.prototype._onChangeShowCountdown),this._onChangeShowCountdown(this.properties().showCountdown),this._recreatePriceFormattingDependencies(),this.properties().lineStyle.priceSource.listeners().subscribe(this,this._updateBarFunction),this.properties().lineWithMarkersStyle.priceSource.listeners().subscribe(this,this._updateBarFunction),this.properties().steplineStyle.priceSource.listeners().subscribe(this,this._updateBarFunction),this.properties().areaStyle.priceSource.listeners().subscribe(this,this._updateBarFunction),this.properties().baselineStyle.priceSource.listeners().subscribe(this,this._updateBarFunction),this.properties().columnStyle.priceSource.listeners().subscribe(this,this._updateBarFunction),this._updateBarFunction()}isLoading(){return this._loading}styleStudyInfo(e){return this.styleStudyInfos()[e]}serverTimeOffset(){return this._chartApi.serverTimeOffset()}_onChangeShowCountdown(e){var t=this;e.value()?this._countdownUpdateTimer=this._model.setInterval((function(){t._priceAxisView.updateCountdown()}),500):(this._model.clearInterval(this._countdownUpdateTimer),delete this._countdownUpdateTimer)}_createIsDWMProperty(){this._isDWMProperty=new s(this.isDWM()),this._onRestarted.subscribe(this,(function(){this._isDWMProperty.setValue(this.isDWM())}))}isDWMProperty(){return this._isDWMProperty}isPulse(){return this._symbolInfo&&this._symbolInfo.resolutions.length>0}seriesSource(){return this._seriesSource}_onSeriesTimeFrame(e,t,i,s,r){var n=c(this.style())?e+.5:e,o=t ;if(void 0===r)null!==i&&i.type!==l.PeriodBack||(o+=this._model.studyAwareDefaultRightOffset());else if(r.applyDefaultRightMargin)o+=this._model.studyAwareDefaultRightOffset();else if(r.percentRightMargin){var a=t-n+1,h=Math.max(0,Math.min(.99,r.percentRightMargin/100));o+=h*a/(1-h)}this._model.setTimeViewport(n,o)}hl2(e){return(this.high(e)+this.low(e))/2}hlc3(e){return(this.high(e)+this.low(e)+this.close(e))/3}ohlc4(e){return(this.open(e)+this.high(e)+this.low(e)+this.close(e))/4}nearestData(e,t){if(TradingView.isInteger(e)){var i=this.data().search(e,t);return null!==i?i:void 0}n.logDebug("Series.nearestData: incorrect logicalPoint")}nearestIndex(e,t){var i=this.nearestData(e,t);return i?i.index:void 0}purgeSymbolInfo(){this._symbolInfo=null}bindStyleChange(){var e=this;Object.keys(h.STYLE_SHORT_NAMES).map((function(e){return h.STYLE_SHORT_NAMES[e]+"Style"})).forEach((function(t){e._properties[t].listeners().subscribe(e,h.prototype.invalidateBarStylesCache)}))}bindJapChartsInputs(){this._properties.renkoStyle.inputs.boxSize.listeners().subscribe(this,this.onInputChanged),this._properties.renkoStyle.inputs.style.listeners().subscribe(this,this.onInputChanged),this._properties.renkoStyle.inputs.atrLength.listeners().subscribe(this,this.onInputChanged),this._properties.renkoStyle.inputs.wicks.listeners().subscribe(this,this.onInputChanged),this._properties.renkoStyle.inputs.sources.listeners().subscribe(this,this.onInputChanged),this._properties.pbStyle.inputs.lb.listeners().subscribe(this,this.onInputChanged),this._properties.kagiStyle.inputs.reversalAmount.listeners().subscribe(this,this.onInputChanged),this._properties.kagiStyle.inputs.style.listeners().subscribe(this,this.onInputChanged),this._properties.kagiStyle.inputs.atrLength.listeners().subscribe(this,this.onInputChanged),this._properties.pnfStyle.inputs.boxSize.listeners().subscribe(this,this.onInputChanged),this._properties.pnfStyle.inputs.reversalAmount.listeners().subscribe(this,this.onInputChanged),this._properties.pnfStyle.inputs.sources.listeners().subscribe(this,this.onInputChanged),this._properties.pnfStyle.inputs.style.listeners().subscribe(this,this.onInputChanged),this._properties.pnfStyle.inputs.atrLength.listeners().subscribe(this,this.onInputChanged),this._properties.pnfStyle.inputs.oneStepBackBuilding.listeners().subscribe(this,this.onInputChanged),this._properties.rangeStyle.inputs.phantomBars.listeners().subscribe(this,this.onInputChanged)}createDividendsAdjustmentProperty(){throw new Error("Not implemented")}dividendsAdjustmentProperty(){return null}onInputChanged(){this.restart()}getStyleShortName(){var e=this._properties.style.value();if(h.STYLE_SHORT_NAMES.hasOwnProperty(e))return h.STYLE_SHORT_NAMES[e];throw new Error("Missed short name for style "+e)}getStyleProperties(){return this._properties[this.getStyleShortName()+"Style"]}getInputsProperties(){return this.getStyleProperties().inputs||new s}getInputsInfoProperties(){return this.getStyleProperties().inputInfo||new s}getSymbolName(){return this._symbolInfo?this._symbolInfo.name:"" @@ -702,15 +702,15 @@ const s=r?Math.min(e.high,e.low):Math.min(e.open,e.close),n=r?Math.max(e.high,e. this._model.selection().isSelected(this._source)&&this._isMarkersEnabled&&this._selectionData&&h.append(new n.SelectionRenderer(this._selectionData)),h}_createItem(e,t,i){const s={time:e,open:NaN,high:NaN,low:NaN,close:NaN,color:i.barColor,borderColor:i.barBorderColor,wickColor:i.barWickColor,hollow:i.isBarHollow};return(0,o.baseBarCandlesUpdater)(t,s)?s:null}}},18671:(e,t,i)=>{"use strict";i.d(t,{SeriesColumnsPaneView:()=>p});var s=i(50151),r=i(86441),n=i(14483),o=i(3308),a=i(18807),l=i(19266),c=i(86094),h=i(57490),d=i(80101),u=i(77243);class p{constructor(e,t){this._items=[],this._invalidated=!0,this._isMarkersEnabled=(0,n.enabled)("source_selection_markers"),this._selectionData=null,this._histogramBase=0,this._source=e,this._model=t,this._selectionIndexer=new h.SelectionIndexes(t.timeScale())}update(){this._invalidated=!0}renderer(e,t){this._invalidated&&(this._updateImpl(),this._invalidated=!1);const i={barSpacing:this._model.timeScale().barSpacing(),items:this._items,lineColor:"",histogramBase:this._histogramBase},s=new l.CompositeRenderer;return s.append(new u.PaneRendererColumns(i)),this._model.selection().isSelected(this._source)&&this._isMarkersEnabled&&this._selectionData&&s.append(new d.SelectionRenderer(this._selectionData)),s}_updateImpl(){this._items=[];const e=this._model.timeScale(),t=this._source.priceScale();if(e.isEmpty()||!t||t.isEmpty())return;const i=e.visibleBarsStrictRange();if(null===i)return;if(0===this._source.bars().size())return;const n=this._source.nearestIndex(i.firstBar(),c.PlotRowSearchMode.NearestRight),l=this._source.nearestIndex(i.lastBar(),c.PlotRowSearchMode.NearestLeft);if(void 0===n||void 0===l)return;const h=this._source.bars().range(n,l),d=this._source.barColorer(),u={},p=this._source.barFunction(),_=h.reduce(((e,t,s)=>{const n=p(s);if(!(0,o.default)(n))return e;u.value=s;let a=this._source.precomputedBarStyle(s);void 0===a&&(a=d.barStyle(t,!1,u),this._source.setPrecomputedBarStyle(s,a));const l=new r.Point(t,n);return l.style=a,l.timePointIndex=t,this._items.push(l),u.previousValue=s,i.contains(t)&&null!=e?e:n}),null);if(null!==_)if(t.pointsArrayToCoordinates(this._items,_),e.timedValuesToCoordinates(this._items),this._histogramBase=t.isInverted()?0:t.height(),this._model.selection().isSelected(this._source)){const i=this._selectionIndexer.indexes();this._selectionData={points:[],bgColors:[],visible:!0,barSpacing:e.barSpacing(),hittestResult:a.HitTarget.Regular};const n=(0,s.ensureNotNull)(this._model.paneForSource(this._source)).height();this._selectionData.hittestResult=a.HitTarget.Regular;for(let s=0;s{"use strict";i.d(t,{SeriesHiLoPaneView:()=>g});var s=i(48874),r=i(29764),n=i(78071),o=i(45197),a=i(18807),l=i(15187) ;class c extends l.MediaCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null,this._barWidth=null}setData(e){this._data=e,this._barWidth=Math.max(1,Math.round((0,o.optimalHiLoWidth)(e.barSpacing)))}hitTest(e){if(null===this._data||null===this._barWidth)return null;const t=this._data.bars,i=.5*this._data.barSpacing;if(0===t.length)return null;if(e.xt[t.length-1].time+i)return null;const s=t[(0,n.lowerbound)(t,e.x-i,((e,t)=>e.times.time+i)return null;const r=(0,o.interactionTolerance)().series+this._barWidth/2,l=Math.min(s.high,s.low),c=Math.max(s.high,s.low),h=this._data.fontSize;return l-r-h<=e.y&&e.y<=l+r||c-r<=e.y&&e.y<=c+r+h?new a.HitTestResult(a.HitTarget.Regular):null}_drawImpl(e){if(null===this._data||null===this._barWidth)return;const{font:t,fontSize:i,labelColor:s,bars:n,inverted:o,labelsPadding:a}=this._data,l=e.context;l.textAlign="center",l.fillStyle=s,l.font=(0,r.makeFont)(i,t);for(let e=0;eMath.max(1,(0,n.lowerboundExt)((e=>e+1),null,(i=>{const s=(0,r.makeFont)(i,u.CHART_FONT_FAMILY);return(0,p.measureText)(e,s).width<=t}),7,36))),((e,t)=>`${e}/${t}`))}renderer(e,t,i){const s=this._source.priceScale();if(!s||s.isEmpty())return null;const r=new h.CompositeRenderer,n=this._needLabels(),a=this._source.properties().childs().hiloStyle.childs(),l=this._model.timeScale().barSpacing();if(this._invalidated){const e=this._source.formatter();this._maxLengthLabel="",this._updateImpl({generateLabels:n,formatter:e}),this._invalidated=!1}if(this._candlesRenderer.setData({bars:this._bars,wickVisible:!1,bodyVisible:a.drawBody.value(),barSpacing:l,borderVisible:a.showBorders.value(),barWidth:(0,o.optimalHiLoWidth)(l)}),r.append(this._candlesRenderer),n){const e=this._calculateLabelFontSize();e&&e>=8&&(this._labelsRenderer.setData({bars:this._bars,barSpacing:l,font:u.CHART_FONT_FAMILY,fontSize:e,labelColor:a.labelColor.value(),inverted:s.isInverted(),labelsPadding:.4*e}),r.append(this._labelsRenderer))}return this._model.selection().isSelected(this._source)&&this._isMarkersEnabled&&this._selectionData&&r.append(new d.SelectionRenderer(this._selectionData)),r}topPixelMargin(){return this._margin()}bottomPixelMargin(){return this._margin()}_createItem(e,t,i,s){const r={time:e,open:NaN,high:NaN,low:NaN,close:NaN,color:i.barColor,borderColor:i.barBorderColor,hollow:!1,highLabel:"",lowLabel:""};if(!(0,m.baseBarCandlesUpdater)(t,r))return null;if(r.open=r.high,r.close=r.low,s.generateLabels){ const e=s.formatter.format(r.high),t=s.formatter.format(r.low);r.highLabel=e,r.lowLabel=t;const i=(e.length>t.length?e:t).replace(/\d/g,"0");i.length>this._maxLengthLabel.length&&(this._maxLengthLabel=i)}return r}_margin(){if(this._needLabels()){const e=this._calculateLabelFontSize();if(e&&e>=8)return 1.4*e}return 0}_calculateLabelFontSize(){return""===this._maxLengthLabel?null:this._calculateFontSize(this._maxLengthLabel,Math.floor(this._model.timeScale().barSpacing())-2)}_needLabels(){const e=this._source.properties().childs().hiloStyle.childs().showLabels.value(),t=this._model.timeScale().barSpacing();return e&&t>5}}},53275:(e,t,i)=>{"use strict";i.d(t,{SeriesHLCAreaPaneView:()=>g});var s=i(86441),r=i(50151),n=i(14483),o=i(82386),a=i(57490),l=i(80101),c=i(86094),h=i(45197),d=i(19266),u=i(18807),p=i(1149),_=i(77173);class m extends _.ObjectValuesCache{_newObject(){return{high:void 0,close:void 0,low:void 0}}_clearObject(e){e.high=void 0,e.close=void 0,e.low=void 0}}class g{constructor(e,t){this._isMarkersEnabled=(0,n.enabled)("source_selection_markers"),this._hlcAreaCache=new m,this._highPoints=new _.CachedContainer,this._closePoints=new _.CachedContainer,this._lowPoints=new _.CachedContainer,this._timePoints=new _.CachedContainer,this._filledAreas=new o.CachedMap,this._renderer=new d.CompositeRenderer,this._invalidated=!0,this._source=e,this._model=t,this._selectionIndexer=new a.SelectionIndexes(t.timeScale())}update(){this._invalidated=!0}renderer(e,t){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._renderer}_updateImpl(){var e,t,i,n,a,d,_,m,g;this._renderer.clear();const f=this._model.timeScale(),v=this._source.priceScale();if(f.isEmpty()||!v||v.isEmpty())return;const S=f.visibleBarsStrictRange();if(null===S)return;if(0===this._source.bars().size())return;const y=this._source.firstValue();if(null===y)return;const b=null!==(e=this._source.nearestIndex(S.firstBar()-1,c.PlotRowSearchMode.NearestLeft))&&void 0!==e?e:S.firstBar()-1,w=null!==(t=this._source.nearestIndex(S.lastBar()+1,c.PlotRowSearchMode.NearestRight))&&void 0!==t?t:S.lastBar()+1;this._hlcAreaCache.invalidateCache(),this._hlcAreaCache.setStartIndex(b),this._timePoints.invalidateCache(),this._highPoints.invalidateCache(),this._lowPoints.invalidateCache(),this._closePoints.invalidateCache(),this._filledAreas.invalidateCache();let P,C,x;this._source.bars().range(b,w).each(((e,t)=>{if(this._hlcAreaCache.isValidIndex(e)){const i=this._hlcAreaCache.at(e);i.close=t[4],i.high=t[2],i.low=t[3]}return!1}));const T=new Map,I=b+this._hlcAreaCache.length();for(let e=b;e{"use strict";i.d(t,{SeriesHollowCandlesPaneView:()=>l});var s=i(19266),r=i(45197),n=i(80101),o=i(836),a=i(57917);class l extends a.SeriesCandlesPaneView{renderer(e,t){this._invalidated&&(this._updateImpl(null),this._invalidated=!1);const i=this._source.priceScale();if(!i)return null;const a=this._source.properties().childs().hollowCandleStyle.childs(),l=this._model.timeScale().barSpacing(),c={bars:this._bars,barSpacing:l, +v.pricesArrayToCoordinates(this._highPoints.data(),y,this._highPoints.length()),v.pricesArrayToCoordinates(this._closePoints.data(),y,this._closePoints.length()),v.pricesArrayToCoordinates(this._lowPoints.data(),y,this._lowPoints.length()),f.indexesToCoordinates(this._timePoints.data(),this._timePoints.length());const M=this._source.properties().childs().hlcAreaStyle.childs(),L=M.highCloseFillColor.value(),A=M.closeLowFillColor.value(),k=null!==(d=this._filledAreas.get(L))&&void 0!==d?d:new o.AreaBackgroundItemsGroup({type:0,color:L}),D=null!==(_=k.newItem())&&void 0!==_?_:new o.AreaBackgroundItem;k.push(D),this._filledAreas.set(L,k);const E=null!==(m=this._filledAreas.get(A))&&void 0!==m?m:new o.AreaBackgroundItemsGroup({type:0,color:A}),V=null!==(g=E.newItem())&&void 0!==g?g:new o.AreaBackgroundItem;E.push(V),this._filledAreas.set(A,E);const B=[],R=[],N=[],O=this._timePoints.length();for(let e=0;e{"use strict";i.d(t,{SeriesHollowCandlesPaneView:()=>l});var s=i(19266),r=i(45197),n=i(80101),o=i(836),a=i(57917);class l extends a.SeriesCandlesPaneView{renderer(e,t){this._invalidated&&(this._updateImpl(null),this._invalidated=!1);const i=this._source.priceScale();if(!i)return null;const a=this._source.properties().childs().hollowCandleStyle.childs(),l=this._model.timeScale().barSpacing(),c={bars:this._bars,barSpacing:l, bodyVisible:a.drawBody.value(),borderVisible:a.drawBorder.value(),borderColor:a.borderColor.value(),wickColor:a.wickColor.value(),barWidth:(0,r.optimalBarWidth)(l),wickVisible:a.drawWick.value(),isPriceScaleInverted:i.isInverted()},h=new s.CompositeRenderer;return h.append(new o.PaneRendererCandles(c)),this._model.selection().isSelected(this._source)&&this._isMarkersEnabled&&this._selectionData&&h.append(new n.SelectionRenderer(this._selectionData)),h}}},41800:(e,t,i)=>{"use strict";i.d(t,{SeriesLinePaneView:()=>c});var s=i(18807),r=i(19266),n=i(1149),o=i(40621),a=i(80101),l=i(96476);class c extends l.SeriesSingleLinePaneView{renderer(e,t){this._invalidated&&(this._updateImpl(),this._invalidated=!1);const i=this._source.properties().childs(),l=i.style.value();let c,h=!1;2===l?c=i.lineStyle.childs():14===l?(c=i.lineWithMarkersStyle.childs(),h=!0):15===l&&(c=i.steplineStyle.childs());const d={barSpacing:this._model.timeScale().barSpacing(),items:this._items,lineColor:c.color.value(),lineStyle:c.linestyle.value(),withMarkers:h,lineWidth:c.linewidth.value(),simpleMode:!0,hitTestResult:s.HitTarget.Regular};let u,p;if(u=15===l?new o.PaneRendererStepLine(d):new n.PaneRendererLine(d),this._model.selection().isSelected(this._source)&&this._isMarkersEnabled&&this._selectionData){const e=new r.CompositeRenderer;e.append(u),e.append(new a.SelectionRenderer(this._selectionData)),p=e}else p=u;return p}}},4502:(e,t,i)=>{"use strict";i.d(t,{SeriesBarCandlesPaneView:()=>h,baseBarCandlesUpdater:()=>c});var s=i(86441),r=i(14483),n=i(57490),o=i(86094),a=i(18807);function l(e){return null!=e}function c(e,t){const i=e[1],s=e[2],r=e[3],n=e[4];return!!(l(i)&&l(s)&&l(r)&&l(n))&&(t.open=i,t.high=s,t.low=r,t.close=n,!0)}class h{constructor(e,t){this._bars=[],this._invalidated=!0,this._isMarkersEnabled=(0,r.enabled)("source_selection_markers"),this._selectionData=null,this._source=e,this._model=t,this._selectionIndexer=new n.SelectionIndexes(t.timeScale())}items(){return this._bars}update(){this._invalidated=!0}_updateImpl(e){const t=this._model.timeScale(),i=this._source.priceScale();if(this._bars=[],t.isEmpty()||!i||i.isEmpty())return;const r=t.visibleBarsStrictRange();if(null===r)return;if(0===this._source.bars().size())return;let n=this._source.nearestIndex(r.firstBar(),o.PlotRowSearchMode.NearestRight);const l=this._source.nearestIndex(r.lastBar(),o.PlotRowSearchMode.NearestLeft);if(void 0===n||void 0===l)return;for(;n<=l;n++){if(null!==this._source.bars().valueAt(n))break}if(n>l)return;const c=this._source.bars().range(n,l),h=this._source.barColorer(),d={};if(c.each(((t,i)=>{d.value=i;let s=this._source.precomputedBarStyle(i);void 0===s&&(s=h.barStyle(t,!1,d),this._source.setPrecomputedBarStyle(i,s));const r=this._createItem(Math.round(t),i,s,e);return!!r&&(d.previousValue=i,this._bars.push(r),!1)})),0===this._bars.length)return;const u=this._source.firstValue();if(null!==u)if(i.barPricesToCoordinates(this._bars,u),t.barIndexesToCoordinates(this._bars),this._model.selection().isSelected(this._source)){ const e=this._selectionIndexer.indexes();this._selectionData={points:[],bgColors:[],visible:!0,hittestResult:a.HitTarget.Regular,barSpacing:t.barSpacing()};const r=this._model.paneForSource(this._source);if(!r)return;const n=r.height();for(let r=0;r{"use strict";i.d(t,{SeriesHorizontalBaseLinePaneView:()=>r});var s=i(2362);class r extends s.SeriesHorizontalLinePaneView{constructor(e){super(e)}_updateImpl(){this._lineRendererData.visible=!1;const e=this._series.priceScale().mode();if(!e.percentage&&!e.indexedTo100)return;const t=this._series.firstValue();null!==t&&(this._lineRendererData.visible=!0,this._lineRendererData.y=this._series.priceScale().priceToCoordinate(t,t),this._lineRendererData.color=this._series.properties().childs().baseLineColor.value())}}},2362:(e,t,i)=>{"use strict";i.d(t,{SeriesHorizontalLinePaneView:()=>r});var s=i(38003);class r extends s.HorizontalLinePaneView{constructor(e){super(),this._series=e,this._model=e.model()}}},96476:(e,t,i)=>{"use strict";i.d(t,{SeriesSingleLinePaneView:()=>d});var s=i(3308),r=i(86441),n=i(50151),o=i(14483),a=i(57490),l=i(86094),c=i(18807),h=i(78071);class d{constructor(e,t){this._items=[],this._invalidated=!0,this._isMarkersEnabled=(0,o.enabled)("source_selection_markers"),this._selectionData=null,this._source=e,this._model=t,this._selectionIndexer=new a.SelectionIndexes(t.timeScale())}update(){this._invalidated=!0}_updateImpl(){var e,t;this._items=[];const i=this._model.timeScale(),o=this._source.priceScale();if(i.isEmpty()||!o||o.isEmpty())return;const a=i.visibleBarsStrictRange();if(null===a)return;if(0===this._source.bars().size())return;const d=null!==(e=this._source.nearestIndex(a.firstBar()-1,l.PlotRowSearchMode.NearestLeft))&&void 0!==e?e:a.firstBar()-1,u=null!==(t=this._source.nearestIndex(a.lastBar()+1,l.PlotRowSearchMode.NearestRight))&&void 0!==t?t:a.lastBar()+1,p=this._source.barFunction();let _=null;const m=this._model.timeScale().barSpacing();if(m<.1&&this._source.supportsPressedChunks()){_=this._source.firstValue();const e=this._source.pressedChunks(m,(0,n.ensureNotNull)(this._source.priceSource())),t=(0,h.lowerbound)(e,d,((e,t)=>e.startTimee.endTime{const i=new r.Point(t.startTime,e);this._items.push(i)}))}}else{_=this._source.bars().range(d,u).reduce(((e,t,i)=>{const n=p(i);if(!(0,s.default)(n))return e;const o=new r.Point(t,n);return this._items.push(o),a.contains(t)?null!=e?e:n:e}),null)}if(null!==_)if(o.pointsArrayToCoordinates(this._items,_),i.timedValuesToCoordinates(this._items), this._model.selection().isSelected(this._source)){const e=this._selectionIndexer.indexes();this._selectionData={points:[],bgColors:[],visible:!0,barSpacing:i.barSpacing(),hittestResult:c.HitTarget.Regular};const t=(0,n.ensureNotNull)(this._model.paneForSource(this._source)).height();this._selectionData.hittestResult=c.HitTarget.Regular;for(let s=0;s{"use strict";i.d(t,{RangeBarStyle:()=>g,areaStylePreferencesDefault:()=>a,barStylePreferencesDefault:()=>n,baselineStylePreferencesDefault:()=>c,candleStylePreferencesDefault:()=>s,columnStylePreferencesDefault:()=>v,haStylePreferencesDefault:()=>d,hiloStylePreferencesDefault:()=>h,hlcAreaStylePreferencesDefault:()=>l,hollowCandlePreferencesStyleDefault:()=>r,kagiStylePreferencesDefault:()=>_,lineStyleDefault:()=>o,pbStylePreferencesDefault:()=>p,pnfStylePreferencesDefault:()=>m,rangeStylePreferencesDefault:()=>f,renkoStylePreferencesDefault:()=>u});const s={upColor:"",downColor:"",drawWick:!1,drawBorder:!1,drawBody:!0,borderColor:"",borderUpColor:"",borderDownColor:"",wickColor:"",wickUpColor:"",wickDownColor:"",barColorsOnPrevClose:!1},r={upColor:"",downColor:"",drawWick:!1,drawBorder:!1,drawBody:!0,borderColor:"",borderUpColor:"",borderDownColor:"",wickColor:"",wickUpColor:"",wickDownColor:""},n={upColor:"",downColor:"",barColorsOnPrevClose:!1,dontDrawOpen:!1,thinBars:!0},o={color:"",linestyle:0,linewidth:0},a={color1:"",color2:"",linecolor:"",linestyle:0,linewidth:0,transparency:0},l={highLineColor:"",highLineStyle:0,highLineWidth:0,lowLineColor:"",lowLineStyle:0,lowLineWidth:0,closeLineColor:"",closeLineStyle:0,closeLineWidth:0,highCloseFillColor:"",closeLowFillColor:""},c={topFillColor1:"",topFillColor2:"",bottomFillColor1:"",bottomFillColor2:"",topLineColor:"",bottomLineColor:"",baselineColor:"",topLineWidth:0,bottomLineWidth:0,transparency:0,baseLevelPercentage:0},h={color:"",showBorders:!1,borderColor:"",showLabels:!1,labelColor:"",drawBody:!0},d={upColor:"",downColor:"",drawWick:!1,drawBorder:!1,drawBody:!0,borderColor:"",borderUpColor:"",borderDownColor:"",wickColor:"",wickUpColor:"",wickDownColor:"",showRealLastPrice:!1,barColorsOnPrevClose:!1,inputs:{}},u={upColor:"",downColor:"",borderUpColor:"",borderDownColor:"",upColorProjection:"",downColorProjection:"",borderUpColorProjection:"",borderDownColorProjection:"",wickUpColor:"",wickDownColor:"",inputs:{boxSize:0,style:"",atrLength:0,wicks:!1,sources:"",source:""}},p={upColor:"",downColor:"",borderUpColor:"",borderDownColor:"",upColorProjection:"",downColorProjection:"",borderUpColorProjection:"",borderDownColorProjection:"",inputs:{source:"",lb:0}},_={upColor:"",downColor:"",upColorProjection:"",downColorProjection:"",inputs:{style:"",atrLength:0, reversalAmount:0}},m={upColor:"",downColor:"",upColorProjection:"",downColorProjection:"",inputs:{reversalAmount:0,boxSize:0,style:"",atrLength:0}};var g;!function(e){e[e.Bars=0]="Bars",e[e.Candles=1]="Candles"}(g||(g={}));const f={barStyle:0,upColor:"",downColor:"",upColorProjection:"",downColorProjection:"",thinBars:!1,candlesUpColor:"",candlesDownColor:"",candlesBorderUpColor:"",candlesBorderDownColor:"",candlesWickUpColor:"",candlesWickDownColor:"",inputs:{range:0,phantomBars:!1}},v={upColor:"",downColor:"",barColorsOnPrevClose:!1}},58333:(e,t,i)=>{"use strict";i.d(t,{SeriesValuesProvider:()=>x,calculateColor:()=>C});var s=i(50151),r=i(50335),n=i(24377),o=i(44352),a=i(49483),l=(i(14483),i(87095)),c=i(38223),h=i(86094),d=i(88348),u=i(93572),p=i(98596),_=i(35994),m=i(82257),g=i(92052),f=i(15367),v=i(88546);const S=a.CheckMobile.any(),y=S&&!0,b=new u.PercentageFormatter,w=new p.VolumeFormatter(2),P=`${v.notAvailable} (${v.notAvailable}%)`;function C(e,t){const i=(0,n.parseRgb)(t),s=(0,n.parseRgb)(e);return(0,n.distanceRgb)(i,s)<70?(0,n.rgbToHexString)((0,n.invertRgb)(i)):t}class x{constructor(e,t){this._series=e,this._model=t,this._emptyValues=[{title:o.t(null,void 0,i(39280)),visible:!1,value:"",index:0,id:""},{title:o.t(null,void 0,i(30777)),visible:!1,value:"",index:1,id:""},{title:o.t(null,void 0,i(8136)),visible:!1,value:"",index:2,id:""},{title:o.t(null,void 0,i(31691)),visible:!1,value:"",index:3,id:""},{title:"",visible:!1,value:"",index:4,id:""},{title:"",visible:!1,value:"",index:5,id:""},{title:o.t(null,void 0,i(49329)),visible:!1,value:"",index:6,id:""},{title:o.t(null,{context:"study"},i(32819)),visible:!1,value:"",index:7,id:""}]}getItems(){return this._emptyValues}getValues(e){var t,i,n;const o=this._showLastPriceAndChangeOnly(),a=this._emptyValues.map((e=>({...e,visible:!o})));a[0].value=v.notAvailable,a[1].value=v.notAvailable,a[2].value=v.notAvailable,a[3].value=v.notAvailable,a[6].value=P,a[7].value=v.notAvailable,a[5].visible=!1;const d=a[4];if(d.value=v.notAvailable,d.visible=!1,this._model.timeScale().isEmpty()||0===this._series.bars().size()||this._series.priceScale().isEmpty())return a;(0,r.isNumber)(e)||(e=(0,s.ensureNotNull)(this._series.data().last()).index);const u=this._series.nearestIndex(e,h.PlotRowSearchMode.NearestLeft);if(void 0===u)return a;const p=this._series.data().valueAt(u),m=this._model.backgroundTopColor().value();if(null===p)return a;const f=p[1],S=p[2],x=p[3],T=p[4],{values:I}=this._changesData(T,u,o),M=(0,g.getPriceValueFormatterForSource)(this._series);if((0,g.shouldBeFormattedAsPercent)(this._series)||(0,g.shouldBeFormattedAsIndexedTo100)(this._series))a[6].value="";else if(void 0!==I){const e=this._series.formatter(),{currentPrice:s,prevPrice:r,change:n}=I,o=null!==(i=null===(t=e.formatChange)||void 0===t?void 0:t.call(e,s,r,!0))&&void 0!==i?i:e.format(n,!0);a[6].value=(0,c.forceLTRStr)(`${o} (${b.format(I.percentChange,!0)})`)}if(o)a[5].value=null==T?v.notAvailable:M(T),a[5].visible=!0,a[6].visible=!0;else{a[0].value=null==f?v.notAvailable:M(f), a[1].value=null==S?v.notAvailable:M(S),a[2].value=null==x?v.notAvailable:M(x),a[3].value=null==T?v.notAvailable:M(T),a[4].value=M(this._series.barFunction()(p));const e=p[5];(0,r.isNumber)(e)?a[7].value=w.format(e):a[7].visible=!1}let L=null;if(o&&!y)L=void 0===I||I.change>=0?_.SeriesBarColorer.upColor(this._series.properties()):_.SeriesBarColorer.downColor(this._series.properties());else{const e=this._series.barColorer().barStyle(u,!1);L=C(m,null!==(n=e.barBorderColor)&&void 0!==n?n:e.barColor)}L=(0,l.resetTransparency)(C(m,L));for(const e of a)e.color=L;return a}_showLastPriceAndChangeOnly(){return S&&(null===this._model.crossHairSource().pane||(0,f.isLineToolName)(d.tool.value())||null!==this._model.lineBeingEdited())}_changesData(e,t,i){var s;if(i&&!y){const t=this._series.quotes();if(null!==t){const i=null!==t.change?t.change:0;return{values:{change:i,currentPrice:e,prevPrice:e-i,percentChange:null!==t.change_percent?t.change_percent:0}}}}else{const i=this._series.data().search(t-1,h.PlotRowSearchMode.NearestLeft),r=null!==(s=null==i?void 0:i.value[4])&&void 0!==s?s:null;if(null!==r&&null!=e)return{values:{change:e-r,currentPrice:e,prevPrice:r,percentChange:(0,m.barPercentChange)(r,e)}}}return{}}}},16776:(e,t,i)=>{"use strict";i.d(t,{sessionsPreferencesDefault:()=>r});var s=i(48891);const r={graphics:{backgrounds:{outOfSession:{color:s.colorsPalette["color-tv-blue-500"],transparency:92,visible:!1},preMarket:{color:"#FF9800",transparency:92,visible:!1},postMarket:{color:s.colorsPalette["color-tv-blue-500"],transparency:92,visible:!1}},vertlines:{sessBreaks:{color:"#4985e7",style:2,visible:!1,width:1}}}}},11877:(e,t,i)=>{"use strict";i.d(t,{StatusProviderBase:()=>s});class s{constructor(e){this._colorProperty=e}size(){return"13px"}bold(){return!1}color(){return this._colorProperty.value()}}},79055:(e,t,i)=>{"use strict";i.d(t,{StatusView:()=>s});class s{constructor(e){this._text="",this._color="",this._size="13px",this._bold=!1,this._statusProvider=e}text(){return this._text}getSplitTitle(){return[this._text]}color(){return this._statusProvider.color()}bold(){return this._bold}size(){return this._size}}},9482:(e,t,i)=>{"use strict";var s;i.d(t,{StoriesTimeLineItemType:()=>s}),function(e){e[e.Image=0]="Image",e[e.Emoji=1]="Emoji"}(s||(s={}))},85573:(e,t,i)=>{"use strict";i.d(t,{getNoDataPosition:()=>d,getSeriesPosition:()=>u,noDataBasePosition:()=>c,positionToCoordinate:()=>l,positionVisualDirection:()=>a,seriesBasePosition:()=>h,seriesPrice:()=>n});var s=i(50151),r=i(86094);function n(e,t,i){const s=e.barFunction();switch(e.style()){case 3:case 10:case 2:case 14:case 15:return s(t.value);default:return t.value[-1===i?3:2]}}function o(e){return e>=0?1:-1}function a(e,t){return-1===o(e)!==t?-1:1}function l(e,t,i,s){const r=Math.min(t,Math.max(0,1===s?i:t-i));return i-s*Math.abs(r*e/100)}function c(e,t,i){const s=e.index();return null===s?null:{index:s,price:t.coordinateToPrice(t.height()/2,i)}}function h(e,t){const i=e.data().bars(),s=i.first(),a=i.last();if(null===s||null===a)return null;let l;const c=t.index() ;if(null===c){if(void 0===t.time)return null;const e=t.time(),n=s.value[0],o=a.value[0];if(eo)return null;l=i.searchByTime(e,r.PlotRowSearchMode.NearestRight,4)}else l=i.search(c);return null===l?null:{index:l.index,price:n(e,l,o(t.position()))}}function d(e,t,i){const s=c(e,t,i);if(null===s)return null;const r=a(e.position(),t.isInverted());return{index:s.index,price:s.price,poleStartY:t.height(),visualDirection:1,positionPointDirection:r,startsOnSeriesData:!1}}function u(e,t,i=!0){const r=h(e,t),n=e.priceScale(),o=(0,s.ensureNotNull)(e.firstValue());if(null===r)return d(t,n,o);let l=0;const c=e.properties().childs(),u=e.model().timeScale(),p=n.priceToCoordinate(r.price,o),_=a(t.position(),n.isInverted());if(i)switch(e.style()){case 16:l=1===_?c.hlcAreaStyle.childs().highLineWidth.value()/2:c.hlcAreaStyle.childs().lowLineWidth.value()/2;break;case 3:l=c.areaStyle.childs().linewidth.value()/2;break;case 2:l=c.lineStyle.childs().linewidth.value()/2;break;case 14:l=c.lineWithMarkersStyle.childs().linewidth.value()/2;break;case 15:l=c.steplineStyle.childs().linewidth.value()/2;break;case 10:const e=Math.abs(100-c.baselineStyle.childs().baseLevelPercentage.value());l=n.height()*e/100>p?c.baselineStyle.childs().topLineWidth.value()/2:c.baselineStyle.childs().bottomLineWidth.value()/2;break;case 1:case 9:case 8:case 12:case 4:case 7:l=3;break;case 0:l=c.barStyle.childs().thinBars.value()?3:Math.max(3,.25*u.barSpacing());break;case 11:l=c.rangeStyle.childs().thinBars.value()?3:Math.max(3,.25*u.barSpacing());break;case 5:l=Math.max(4,.25*u.barSpacing());break;case 6:l=Math.max(5,.25*u.barSpacing())}const m=p-_*l;return{index:r.index,price:r.price,poleStartY:m,visualDirection:_,positionPointDirection:_,startsOnSeriesData:!0}}},70044:(e,t,i)=>{"use strict";i.d(t,{AbstractFilledAreaPaneView:()=>p});var s=i(50151),r=i(87095),n=i(37160),o=i(82386),a=i(86094),l=i(45197),c=i(77173);function h(e){return 0===e.type?`${e.color}`:`${e.color1}:${e.color2}:${e.value1}:${e.value2}`}class d extends c.ObjectValuesCache{_newObject(){return{plot1Value:void 0,plot2Value:void 0,colorValue:void 0}}_clearObject(e){e.plot1Value=void 0,e.plot2Value=void 0,e.colorValue=void 0}}class u extends c.ObjectValuesCache{_newObject(){return{type:void 0,colorIndexOrRgba:void 0,colorIndexOrRgba1:void 0,colorIndexOrRgba2:void 0,value1:void 0,value2:void 0}}_clearObject(e){const t=e;t.type=void 0,t.colorIndexOrRgba=void 0,t.colorIndexOrRgba1=void 0,t.colorIndexOrRgba2=void 0,t.value1=void 0,t.value2=void 0}}class p{constructor(e,t,i=!1){this._isHlineFill=!1,this._bandAKey=null,this._bandBKey=null,this._colorPlotIndex=null,this._colors=new c.CachedContainer,this._areaRenderer=new o.AreaBackgroundRenderer,this._invalidated=!0,this._plIndex1=null,this._plIndex2=null,this._level1=0,this._level2=0,this._studyValuesCache=new d,this._colorValuesCache=new u,this._points1=new c.CachedContainer,this._points2=new c.CachedContainer,this._timePoints=new c.CachedContainer,this._colorAreas=new o.CachedMap,this._source=e,this._model=t,this._fillGaps=i}update(){ -this._invalidated=!0}renderer(e,t){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._areaRenderer}_correctVisibleRange(e,t){var i,s,r,n;const o=this._source.plots().plottableRange(),l=e.firstBar()+Math.min(0,t)-1,c=e.lastBar()-t+1,h=this._plotIndex1(),d=this._plotIndex2(),u=o.search(l,a.PlotRowSearchMode.NearestLeft,h),p=o.search(l,a.PlotRowSearchMode.NearestLeft,d),_=o.search(c,a.PlotRowSearchMode.NearestRight,h),m=o.search(c,a.PlotRowSearchMode.NearestRight,d),g=Math.min(null!==(i=null==u?void 0:u.index)&&void 0!==i?i:1/0,e.firstBar()-1),f=Math.min(null!==(s=null==p?void 0:p.index)&&void 0!==s?s:1/0,e.firstBar()-1),v=Math.max(null!==(r=null==_?void 0:_.index)&&void 0!==r?r:-1/0,e.lastBar()+1),S=Math.max(null!==(n=null==m?void 0:m.index)&&void 0!==n?n:-1/0,e.lastBar()+1);let y=1/0;if(null!==this._colorPlotIndex&&(null!==u||null!==p)){const e=o.search(Math.min(g,f)-1,a.PlotRowSearchMode.NearestLeft);null!==e&&(y=e.index)}return[Math.min(g,f,y),Math.max(v,S)]}_plotNames(){return this._source.metaInfo().plots.map((e=>e.id))}_plotIndex1(){return null===this._plIndex1&&(this._plIndex1=this._plotNames().indexOf(this._plotAId())+1),this._plIndex1}_plotIndex2(){return null===this._plIndex2&&(this._plIndex2=this._plotNames().indexOf(this._plotBId())+1),this._plIndex2}_updateImpl(){var e,t;if(this._areaRenderer.setData(null),!this._visible())return;const i=this._source.priceScale(),o=this._model,a=o.timeScale();if(!i||i.isEmpty()||a.isEmpty())return;if(o.mainSeries().bars().isEmpty())return;const l=this._source.firstValue();if(null===l)return;if(this._isHlineFill){const e=this._source.properties().bands[(0,s.ensureNotNull)(this._bandAKey)],t=this._source.properties().bands[(0,s.ensureNotNull)(this._bandBKey)];this._level1=i.priceToCoordinate(e.value.value(),l),this._level2=i.priceToCoordinate(t.value.value(),l)}const c=a.visibleBarsStrictRange();if(null===c)return;const h=new Map,d=e=>{let t=h.get(e);return void 0===t&&(t=i.priceToCoordinate(e,l),h.set(e,t)),t},u=(0,n.clamp)(this._transparency(),0,100),p=new Map,_=e=>{let t=p.get(e);return void 0===t&&(t=(0,r.generateColor)(e,u),p.set(e,t)),t};this._timePoints.invalidateCache(),this._points1.invalidateCache(),this._points2.invalidateCache(),this._colors.invalidateCache(),this._colorAreas.invalidateCache();const m=this._source.offset(this._plotAId()),g=this._source.offset(this._plotBId()),f=Math.min(m,g),v=Math.max(m,g),[S,y]=this._correctVisibleRange(c,v),b=null!==this._colorPlotIndex?this._colors:null,w=this._plotIndex1(),P=this._plotIndex2(),C=this._source.plots().plottableRange();if(C.isEmpty())return;let x,T;const I=(0,s.ensureNotNull)(C.firstIndex()),M=(0,s.ensureNotNull)(C.lastIndex()),L=I-Math.max(0,-f),A=M+Math.max(0,v),k=Math.max(S,L),D=Math.min(y,A),V=this._studyValuesCache,E=this._colorValuesCache;V.invalidateCache(),E.invalidateCache();const B=k-v,R=C.rangeIterator(B,D-f);let N;for(V.setStartIndex(B),E.setStartIndex(B);R.hasNext();){const e=R.next(),t=e.index,i=e.value,r=i[w],n=i[P],o=t+m,a=t+g;if(o===a&&V.isValidIndex(o)){const e=V.at(o) -;e.plot1Value=r,e.plot2Value=n}else{if(V.isValidIndex(o)){V.at(o).plot1Value=r}if(V.isValidIndex(a)){V.at(a).plot2Value=n}}if(null!==b&&void 0!==N){const e=N+f;if(V.isValidIndex(e)){const t=V.at(e),r=(0,s.ensureNotNull)(this._colorPlotIndex);if(0===r.type){const s=E.at(e);t.colorValue=s,s.type=0,s.colorIndexOrRgba=i[r.colorIndexOrRgba+1]}else{const s=E.at(e);t.colorValue=s,s.colorIndexOrRgba1=void 0===r.colorIndexOrRgba1?void 0:i[r.colorIndexOrRgba1+1],s.colorIndexOrRgba2=void 0===r.colorIndexOrRgba2?void 0:i[r.colorIndexOrRgba2+1],s.value1=void 0===r.valueIndex1?void 0:i[r.valueIndex1+1],s.value2=void 0===r.valueIndex2?void 0:i[r.valueIndex2+1]}}}N=t}const O=this._timePoints,F=this._points1,W=this._points2;let H=null;const z=B+V.length();for(let i=B;i{"use strict";i.d(t,{ +this._invalidated=!0}renderer(e,t){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._areaRenderer}_correctVisibleRange(e,t){var i,s,r,n;const o=this._source.plots().plottableRange(),l=e.firstBar()+Math.min(0,t)-1,c=e.lastBar()-t+1,h=this._plotIndex1(),d=this._plotIndex2(),u=o.search(l,a.PlotRowSearchMode.NearestLeft,h),p=o.search(l,a.PlotRowSearchMode.NearestLeft,d),_=o.search(c,a.PlotRowSearchMode.NearestRight,h),m=o.search(c,a.PlotRowSearchMode.NearestRight,d),g=Math.min(null!==(i=null==u?void 0:u.index)&&void 0!==i?i:1/0,e.firstBar()-1),f=Math.min(null!==(s=null==p?void 0:p.index)&&void 0!==s?s:1/0,e.firstBar()-1),v=Math.max(null!==(r=null==_?void 0:_.index)&&void 0!==r?r:-1/0,e.lastBar()+1),S=Math.max(null!==(n=null==m?void 0:m.index)&&void 0!==n?n:-1/0,e.lastBar()+1);let y=1/0;if(null!==this._colorPlotIndex&&(null!==u||null!==p)){const e=o.search(Math.min(g,f)-1,a.PlotRowSearchMode.NearestLeft);null!==e&&(y=e.index)}return[Math.min(g,f,y),Math.max(v,S)]}_plotNames(){return this._source.metaInfo().plots.map((e=>e.id))}_plotIndex1(){return null===this._plIndex1&&(this._plIndex1=this._plotNames().indexOf(this._plotAId())+1),this._plIndex1}_plotIndex2(){return null===this._plIndex2&&(this._plIndex2=this._plotNames().indexOf(this._plotBId())+1),this._plIndex2}_updateImpl(){var e,t;if(this._areaRenderer.setData(null),!this._visible())return;const i=this._source.priceScale(),o=this._model,a=o.timeScale();if(!i||i.isEmpty()||a.isEmpty())return;if(o.mainSeries().bars().isEmpty())return;const l=this._source.firstValue();if(null===l)return;if(this._isHlineFill){const e=this._source.properties().bands[(0,s.ensureNotNull)(this._bandAKey)],t=this._source.properties().bands[(0,s.ensureNotNull)(this._bandBKey)];this._level1=i.priceToCoordinate(e.value.value(),l),this._level2=i.priceToCoordinate(t.value.value(),l)}const c=a.visibleBarsStrictRange();if(null===c)return;const h=new Map,d=e=>{let t=h.get(e);return void 0===t&&(t=i.priceToCoordinate(e,l),h.set(e,t)),t},u=(0,n.clamp)(this._transparency(),0,100),p=new Map,_=e=>{let t=p.get(e);return void 0===t&&(t=(0,r.generateColor)(e,u),p.set(e,t)),t};this._timePoints.invalidateCache(),this._points1.invalidateCache(),this._points2.invalidateCache(),this._colors.invalidateCache(),this._colorAreas.invalidateCache();const m=this._source.offset(this._plotAId()),g=this._source.offset(this._plotBId()),f=Math.min(m,g),v=Math.max(m,g),[S,y]=this._correctVisibleRange(c,v),b=null!==this._colorPlotIndex?this._colors:null,w=this._plotIndex1(),P=this._plotIndex2(),C=this._source.plots().plottableRange();if(C.isEmpty())return;let x,T;const I=(0,s.ensureNotNull)(C.firstIndex()),M=(0,s.ensureNotNull)(C.lastIndex()),L=I-Math.max(0,-f),A=M+Math.max(0,v),k=Math.max(S,L),D=Math.min(y,A),E=this._studyValuesCache,V=this._colorValuesCache;E.invalidateCache(),V.invalidateCache();const B=k-v,R=C.rangeIterator(B,D-f);let N;for(E.setStartIndex(B),V.setStartIndex(B);R.hasNext();){const e=R.next(),t=e.index,i=e.value,r=i[w],n=i[P],o=t+m,a=t+g;if(o===a&&E.isValidIndex(o)){const e=E.at(o) +;e.plot1Value=r,e.plot2Value=n}else{if(E.isValidIndex(o)){E.at(o).plot1Value=r}if(E.isValidIndex(a)){E.at(a).plot2Value=n}}if(null!==b&&void 0!==N){const e=N+f;if(E.isValidIndex(e)){const t=E.at(e),r=(0,s.ensureNotNull)(this._colorPlotIndex);if(0===r.type){const s=V.at(e);t.colorValue=s,s.type=0,s.colorIndexOrRgba=i[r.colorIndexOrRgba+1]}else{const s=V.at(e);t.colorValue=s,s.colorIndexOrRgba1=void 0===r.colorIndexOrRgba1?void 0:i[r.colorIndexOrRgba1+1],s.colorIndexOrRgba2=void 0===r.colorIndexOrRgba2?void 0:i[r.colorIndexOrRgba2+1],s.value1=void 0===r.valueIndex1?void 0:i[r.valueIndex1+1],s.value2=void 0===r.valueIndex2?void 0:i[r.valueIndex2+1]}}}N=t}const O=this._timePoints,F=this._points1,W=this._points2;let H=null;const z=B+E.length();for(let i=B;i{"use strict";i.d(t,{ AreaBackgroundPaneView:()=>o});var s=i(50151),r=i(37160),n=i(70044);class o extends n.AbstractFilledAreaPaneView{constructor(e,t){super(e,t)}_plotAId(){return(0,s.ensureDefined)(this._source.metaInfo().area)[0].name}_plotBId(){return(0,s.ensureDefined)(this._source.metaInfo().area)[1].name}_commonColor(){return{type:0,color:this._source.properties().areaBackground.backgroundColor.value()}}_transparency(){const e=this._source.properties().areaBackground.transparency.value();return(0,r.clamp)(e,0,100)}_visible(){return this._source.properties().areaBackground.fillBackground.value()}_getColorByPlotValue(e){return this._commonColor()}}},93804:(e,t,i)=>{"use strict";i.d(t,{containsBackgroundTimePointIndexes:()=>o,dematerializeBackground:()=>l,isBackgroundInBarsRange:()=>c,materializeBackground:()=>a});var s=i(50151),r=i(61401),n=i(1115);const o=!0;function a(e,t){if(e.start>=t.length||e.stop>=t.length)return null;const i=t[e.start],n=t[e.stop];return n===r.INVALID_TIME_POINT_INDEX?null:((0,s.assert)(i===r.INVALID_TIME_POINT_INDEX||i<=n,"start should not exceed stop"),{start:i===r.INVALID_TIME_POINT_INDEX?null:i,stop:n})}function l(e,t,i){return{id:t,start:(0,n.ensureTimePointIndexIndex)(i.indexOf(null!==e.start?e.start:r.INVALID_TIME_POINT_INDEX)),stop:(0,n.ensureTimePointIndexIndex)(i.indexOf(e.stop))}}function c(e,t){if(null===e.start)return t.firstBar()<=e.stop;const i=Math.min(e.start,e.stop),s=Math.max(e.start,e.stop);return t.contains(i)||t.contains(s)||it.lastBar()}},12442:(e,t,i)=>{"use strict";i.d(t,{LiveStudyGraphics:()=>o.LiveStudyGraphics,createGraphicsPaneViews:()=>p,createGraphicsPriceAxisViews:()=>m,emptyStudyGraphics:()=>n.emptyStudyGraphics,isStudyGraphicsEmpty:()=>r.isStudyGraphicsEmpty,loadStudyGraphics:()=>n.loadStudyGraphics,saveStudyGraphics:()=>n.saveStudyGraphics});var s=i(59224),r=i(71409),n=i(12616),o=i(60393),a=i(42275),l=i(87095);class c extends a.PriceAxisView{constructor(e,t){super(),this._source=e,this._data=t}_updateRendererData(e,t,i){var s,r;e.visible=!1;const n=this._source.priceScale(),o=this._source.properties().childs(),a=o.visible.value();if(!n||n.isEmpty()||!a)return;const c=null===(r=null===(s=o.graphics.childs()[this._data.lineType])||void 0===s?void 0:s.childs()[this._data.styleId])||void 0===r?void 0:r.childs();if(!(void 0!==c&&c.visible&&c.visible.value()&&c.showPrice&&c.showPrice.value()&&this._isLabelVisibleAccordinglyToProperties()))return;const h=this._source.firstValue();if(null===h)return;const d=this._data.line.level,u=(0,l.resetTransparency)(c.color.value());i.background=u,i.textColor=this.generateTextColor(u),i.coordinate=n.priceToCoordinate(d,h),e.text=n.formatPrice(d,h,!0),e.visible=!0}_isLabelVisibleAccordinglyToProperties(){return!!this._source.model().properties().childs().scalesProperties.childs().showStudyLastValue.value()&&this._source.properties().childs().showLabelsOnPriceScale.value()}}const h=(0,s.getLogger)("Chart.StudyGraphics"),d=new Set(["dwgtablecells","tpoBlockSets","tpoLevels","tpoVolumeRows","logs"]);async function u(e,t,s,r){ switch(e){case"hhists":return new((await i.e(507).then(i.bind(i,21335))).HHistPaneView)(t,s,r);case"horizlines":return new((await i.e(507).then(i.bind(i,13369))).HorizLinePaneView)(t,s,r);case"vertlines":return new((await i.e(507).then(i.bind(i,78266))).VertLinePaneView)(t,s,r);case"polygons":return new((await i.e(507).then(i.bind(i,66999))).PolygonPaneView)(t,s,r);case"backgrounds":return new((await i.e(507).then(i.bind(i,47372))).BackgroundPaneView)(t,s,r)}return null}async function p(e,t,i){const s=[],r=Object.keys(e.graphicsInfo());r.sort(((e,t)=>_(e)-_(t)));for(const n of r){const r=await u(n,e,t,i);null!==r?s.push(r):d.has(n)||h.logWarn(`${n} is not supported by this build of graphics subsystem, skipping`)}return s}function _(e){var t;return null!==(t=r.primitivesZOrders.get(e))&&void 0!==t?t:0}function m(e){const t=Object.keys(e.graphicsInfo()),i=[];for(const s of t)switch(s){case"hlines":e.graphics().hlines().forEach(((t,r)=>{t.forEach((t=>{void 0!==t.level&&i.push(new c(e,{line:{level:t.level},styleId:r,lineType:s}))}))}));break;case"horizlines":e.graphics().horizlines().forEach(((t,r)=>{t.forEach((t=>{void 0!==t.level&&i.push(new c(e,{line:{level:t.level},styleId:r,lineType:s}))}))}))}return i}},90164:(e,t,i)=>{"use strict";i.d(t,{HHistDirection:()=>s,HHistLocation:()=>r,HHistVolumeMode:()=>n,containsHHistTimePointIndexes:()=>c,dematerializeHHist:()=>d,isHHistInBarsRange:()=>u,materializeHHist:()=>h});var s,r,n,o=i(50151),a=i(61401),l=i(1115);!function(e){e.LeftToRight="left_to_right",e.RightToLeft="right_to_left"}(s||(s={})),function(e){e.Relative="relative",e.Absolute="absolute"}(r||(r={})),function(e){e.UpDown="Up/Down",e.Total="Total",e.Delta="Delta"}(n||(n={}));const c=!0;function h(e,t){if(e.firstBarTime>=t.length||e.lastBarTime>=t.length)return null;const i=t[e.firstBarTime],s=t[e.lastBarTime];return i===a.INVALID_TIME_POINT_INDEX||s===a.INVALID_TIME_POINT_INDEX?null:((0,o.assert)(i<=s,"firstBarTime should not exceed lastBarTime"),(0,o.assert)(e.priceLow<=e.priceHigh,"priceLow should not exceed priceHigh"),{firstBarTime:i,lastBarTime:s,rate:e.rate,priceHigh:e.priceHigh,priceLow:e.priceLow})}function d(e,t,i){const s=(0,l.ensureTimePointIndexIndex)(i.indexOf(e.firstBarTime)),r=(0,l.ensureTimePointIndexIndex)(i.indexOf(e.lastBarTime));return{id:t,...e,firstBarTime:s,lastBarTime:r}}function u(e,t){const i=Math.min(e.firstBarTime,e.lastBarTime),s=Math.max(e.firstBarTime,e.lastBarTime);return t.contains(i)||t.contains(s)||it.lastBar()}},34522:(e,t,i)=>{"use strict";i.d(t,{containsHorizLineTimePointIndexes:()=>o,dematerializeHorizLine:()=>l,isHorizLineInBarsRange:()=>c,materializeHorizLine:()=>a});var s=i(50151),r=i(61401),n=i(1115);const o=!0;function a(e,t){if(e.startIndex>=t.length||e.endIndex>=t.length)return null;const i=t[e.startIndex],n=t[e.endIndex];return i===r.INVALID_TIME_POINT_INDEX||n===r.INVALID_TIME_POINT_INDEX?null:((0,s.assert)(i<=n,"startIndex should not exceed endIndex"),{startIndex:i,endIndex:n,level:e.level,extendLeft:e.extendLeft,extendRight:e.extendRight})} function l(e,t,i){const s=(0,n.ensureTimePointIndexIndex)(i.indexOf(e.startIndex)),r=(0,n.ensureTimePointIndexIndex)(i.indexOf(e.endIndex));return{id:t,...e,startIndex:s,endIndex:r}}function c(e,t){const i=Math.min(e.startIndex,e.endIndex),s=Math.max(e.startIndex,e.endIndex);if(t.contains(i)||t.contains(s)||it.lastBar())return!0;const r=e.startIndext.lastBar()&&r}},60393:(e,t,i)=>{"use strict";i.d(t,{LiveStudyGraphics:()=>u});var s=i(50151),r=i(57898),n=i(90164),o=i(34522),a=i(68696),l=i(80009),c=i(93804),h=i(71409),d=i(12616);class u{constructor(e={}){this._indexes=[],this._hhistsByTimePointIndex=new Map,this._primitivesCollection=function(e){const t={};for(const i of h.primitiveNames){t[i]=new Map;const s=e[i];if(void 0!==s)for(const e in s)if(s.hasOwnProperty(e))switch(i){case"horizlines":t[i].set(e,new p(o.materializeHorizLine,o.containsHorizLineTimePointIndexes));break;case"vertlines":t[i].set(e,new p(a.materializeVertLine,a.containsVertLineTimePointIndexes));break;case"backgrounds":t[i].set(e,new p(c.materializeBackground,c.containsBackgroundTimePointIndexes));break;case"polygons":t[i].set(e,new p(l.materializePolygon,l.containsPolygonTimePointIndexes));break;case"hhists":t[i].set(e,new p(n.materializeHHist,n.containsHHistTimePointIndexes))}}return t}(e)}horizlines(){return this._primitivesCollection.horizlines}vertlines(){return this._primitivesCollection.vertlines}lines(){return this._primitivesCollection.lines}hlines(){return this._primitivesCollection.hlines}textmarks(){return this._primitivesCollection.textmarks}shapemarks(){return this._primitivesCollection.shapemarks}backgrounds(){return this._primitivesCollection.backgrounds}polygons(){return this._primitivesCollection.polygons}trendchannels(){return this._primitivesCollection.trendchannels}hhists(){return this._primitivesCollection.hhists}dwglabels(){return this._primitivesCollection.dwglabels}dwglines(){return this._primitivesCollection.dwglines}dwgboxes(){return this._primitivesCollection.dwgboxes}dwgtables(){return this._primitivesCollection.dwgtables}dwgtablecells(){return this._primitivesCollection.dwgtablecells}dwglinefills(){return this._primitivesCollection.dwglinefills}tpos(){return this._primitivesCollection.tpos}tpoBlockSets(){return this._primitivesCollection.tpoBlockSets}tpoLevels(){return this._primitivesCollection.tpoLevels}tpoVolumeRows(){return this._primitivesCollection.tpoVolumeRows}logs(){return this._primitivesCollection.logs}observableLogs(){return this._primitivesCollection.logs}hhistsByTimePointIndex(){return this._hhistsByTimePointIndex}clear(){this._indexes=[];for(const e of h.primitiveNames)this._primitivesCollection[e].forEach((e=>e.clear()));this._hhistsByTimePointIndex=new Map}extract(){const e=e=>e.extract(),t={indexes:this._indexes,horizlines:_(this._primitivesCollection.horizlines,e),vertlines:_(this._primitivesCollection.vertlines,e),lines:_(this._primitivesCollection.lines,e), @@ -725,20 +725,20 @@ value:"",index:0,id:""},{title:n.t(null,void 0,i(30777)),visible:!1,value:"",ind return null==e||null==t?{}:{priceDirection:{basedOnCurrentBar:e>=t?0:1,basedOnPrevClose:e>=t?0:1}}}}{constructor(e,t){super(e,t);const i=t.properties().childs().paneProperties.childs().legendProperties.childs();this._showBarChange=i.showBarChange,this._showSeriesOHLC=i.showSeriesOHLC}getValues(e){const t=super.getValues(e);if(!this._showLastPriceAndChangeOnly()){const e=this._study.properties().childs(),i=e.style.value(),r=(0,s.isPriceSourceStyle)(i),n=12!==i&&16!==i,o=12!==i,a=12!==i,l=this._showSeriesOHLC.value(),c=l&&!r,h=l&&r;if(t[0].visible=c&&n,t[1].visible=c,t[2].visible=c,t[3].visible=c&&o,t[6].visible=this._showBarChange.value()&&a,t[4].visible=h,16===i){const i=e.hlcAreaStyle.childs();t[1].color=i.highLineColor.value(),t[2].color=i.lowLineColor.value(),t[3].color=i.closeLineColor.value()}}return t}}},26481:(e,t,i)=>{"use strict";i.d(t,{OverlayStatusProvider:()=>n});var s=i(6892),r=i(37591);class n extends s.StudyStatusProvider{getSplitTitle(){return this._source.titleInParts(r.TitleDisplayTarget.StatusLine,!0,void 0,!1,!1)}text(){return this._source.isActualInterval()?this._source.isFailed()?`${this._source.title(r.TitleDisplayTarget.StatusLine,!0,void 0,!1,!1)}: ${this.sourceStatusText()}`:`${this._source.title(r.TitleDisplayTarget.StatusLine,!0,void 0,!1,!1)} ${this.sourceStatusText()}`:this._source.title(r.TitleDisplayTarget.StatusLine,!0,void 0,!1,!1)}}},96759:(e,t,i)=>{"use strict";function s(e){e.lineWidth=void 0,e.lineStyle=void 0;for(let t=0;ts,createEmptyStyle:()=>r})},77243:(e,t,i)=>{"use strict";i.d(t,{PaneRendererColumns:()=>n});var s=i(59590),r=i(18807);class n extends s.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=null,this._precalculatedCache=[],this.setData(e)}setData(e){this._data=e,this._precalculatedCache=[]}hitTest(e){var t,i,s,n;if(null===this._data)return null;const o=.5*this._data.barSpacing,a=e.x-o,l=e.x+o,c=null!==(i=null===(t=this._data.visibleItemsRange)||void 0===t?void 0:t.startItemIndex)&&void 0!==i?i:0,h=(null!==(n=null===(s=this._data.visibleItemsRange)||void 0===s?void 0:s.endItemIndex)&&void 0!==n?n:this._data.items.length)-1;for(let t=c;t<=h;t++){const i=this._data.items[t],s=i.x;if(s>=a&&s<=l){const t=i.y;if(e.y>=Math.min(t,this._data.histogramBase)&&e.y<=Math.max(t,this._data.histogramBase))return new r.HitTestResult(r.HitTarget.Regular)}}return null}_drawImpl(e){var t,i,s,r;if(null===this._data||0===this._data.items.length)return;const{context:n,horizontalPixelRatio:o,verticalPixelRatio:a}=e;this._precalculatedCache.length||this._fillPrecalculatedCache(o) ;const l=Math.max(1,Math.floor(o)),c=Math.max(1,Math.floor(a)),h=Math.round(this._data.histogramBase*a)-Math.floor(l/2),d=h+l,u=this._data.lineColor,p=null!==(i=null===(t=this._data.visibleItemsRange)||void 0===t?void 0:t.startItemIndex)&&void 0!==i?i:0,_=(null!==(r=null===(s=this._data.visibleItemsRange)||void 0===s?void 0:s.endItemIndex)&&void 0!==r?r:this._data.items.length)-1;for(let e=p;e<=_;e++){const t=this._data.items[e],i=this._precalculatedCache[e-p],s=Math.round(t.y*a);let r,o;n.fillStyle=t.style?t.style.color:u,s<=h?(r=s,o=d):(r=h,o=s-Math.floor(c/2)+c),n.fillRect(i.left,r,i.right-i.left+1,o-r)}}_fillPrecalculatedCache(e){var t,i;if(null===this._data||0===this._data.items.length)return void(this._precalculatedCache=[]);const{barSpacing:s,visibleItemsRange:r,items:n}=this._data,o=Math.ceil(s*e)<=1?0:Math.max(1,Math.floor(e)),a=Math.round(s*e)-o,l=null!==(t=null==r?void 0:r.startItemIndex)&&void 0!==t?t:0,c=(null!==(i=null==r?void 0:r.endItemIndex)&&void 0!==i?i:n.length)-1,h=c-l+1;if(h<=0)return void(this._precalculatedCache=[]);this._precalculatedCache=new Array(h);for(let t=l;t<=c;t++){const i=n[t],s=Math.round(i.x*e);let r,o;if(a%2){const e=(a-1)/2;r=s-e,o=s+e}else{const e=a/2;r=s-e,o=s+e-1}this._precalculatedCache[t-l]={left:r,right:o,roundedCenter:s,center:i.x*e,time:i.timePointIndex}}for(let e=l+1;e<=c;e++){const t=this._precalculatedCache[e-l],i=this._precalculatedCache[e-l-1];t.time===i.time+1&&(t.left-i.right!==o+1&&(i.roundedCenter>i.center?i.right=t.left-o-1:t.left=i.right+o+1))}let d=Math.ceil(s*e);for(let e=l+1;e<=c;e++){const t=this._precalculatedCache[e-l];t.right0&&d<4)for(let e=l+1;e<=c;e++){const t=this._precalculatedCache[e-l];t.right-t.left+1>d&&(t.roundedCenter>t.center?t.right-=1:t.left+=1)}}}},39871:(e,t,i)=>{"use strict";i.d(t,{StudyPlotPaneView:()=>R});var s=i(50151),r=i(86441),n=i(24377),o=i(14483),a=i(37160),l=i(1722),c=i(87095),h=i(22767);function d(e,t){const i=new Map;return function(...s){const r=""+(t?t.apply(null,s):s[0]);if(!i.has(r)){const t=e.apply(this,s);return i.set(r,t),t}return i.get(r)}}var u=i(18807),p=i(62885),_=i(19266),m=i(1149),g=i(40621),f=i(57490),v=i(80101),S=i(96759),y=i(45197),b=i(59590),w=i(49483);class P extends b.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){var t,i,s,n;const o=this._data,a=o.lineWidth||o.height/2,l=o.vertOffset||0,c=(0,y.interactionTolerance)().series+a,h=null!==(i=null===(t=o.visibleItemsRange)||void 0===t?void 0:t.startItemIndex)&&void 0!==i?i:0,d=null!==(n=null===(s=o.visibleItemsRange)||void 0===s?void 0:s.endItemIndex)&&void 0!==n?n:o.items.length;for(let t=h;t{const t=(0,n.rgbToHsl)((0,n.parseRgb)(e)),i=t[0]+.05;return t[0]=i-Math.floor(i),(0,n.rgbToHexString)((0,n.hslToRgb)(t))},V=d(D);function E(e,t){if(null===e)return t;const i=e.firstIndex,s=t.firstIndex,r=e.clearData||t.clearData;return{firstIndex:r||void 0===i||void 0===s?void 0:Math.min(i,s),clearData:r}}const B=new Set([M.LineStudyPlotStyle.Line,M.LineStudyPlotStyle.Area,M.LineStudyPlotStyle.Circles,M.LineStudyPlotStyle.Cross,M.LineStudyPlotStyle.StepLine,M.LineStudyPlotStyle.StepLineWithDiamonds]);class R{constructor(e,t,i,s,r=!1){this._histogramBase=null,this._items=[],this._lastConfirmedSeriesBarCoordinate=NaN,this._selectionData=null,this._lineColor="",this._lineWidth=1,this._color1="",this._color2="",this._dataInvalidated=null,this._viewportInvalidated=!1,this._renderer=new _.CompositeRenderer,this._isMarkersEnabled=o.enabled("source_selection_markers"),this._study=e,this._series=t,this._model=i,this._plotName=s,this._plotIndex=e.metaInfo().plots.findIndex((e=>e.id===s)),this._colorProvider=(0,L.createStudyPlotColorProvider)(e.metaInfo(),e.properties(),s),this._selectionIndexer=new f.SelectionIndexes(i.timeScale()),this._extendStepLineToBarsEndings=r,this._useFirstUnplottableRow=!1}items(){return this._items}update(e){if("global-change"===e.type)return this._dataInvalidated=E(this._dataInvalidated,{}),void(this._viewportInvalidated=!0);if("data-source-change"!==e.type)this._viewportInvalidated=!0;else{if(e.sourceId===this._study.id()){const t=E(this._dataInvalidated,{firstIndex:e.firstUpdatedTimePointIndex,clearData:e.clearData});this._dataInvalidated=t}}}renderer(){return this._dataInvalidated?this._updateImplFull(this._viewportInvalidated)&&(this._dataInvalidated=null):this._viewportInvalidated&&this._updateImplLight(),this._viewportInvalidated=!1,this._renderer}_getTranspValue(){const e=this._study.properties(),t=e.styles[this._plotName];let i=0;const s=this._study.metaInfo();return"Volume@tv-basicstudies"===s.id&&s.version<=46&&"transparency"in e?(i=e.transparency.value(),i=(0,l.isNumber)(i)?i:0,i):(t.transparency&&(i=t.transparency.value(),i=(0,l.isNumber)(i)?i:0),i)}_updateImplFull(e){var t,i,n,o,l;if(this._renderer.clear(),(null===(t=this._dataInvalidated)||void 0===t?void 0:t.clearData)&&(this._items=[]), -!this._study.isPlotVisibleAt(this._plotName,1))return!1;if(!this._study.priceScale())return!1;const h=this._study.firstValue();if(null===h)return!1;const d=this._study.priceScale();if(null===d)return!1;this._histogramBase=null;const u=this._study.properties().styles[this._plotName],p=(0,s.ensureDefined)(null===(i=this._study.metaInfo().styles)||void 0===i?void 0:i[this._plotName]),_=u.plottype.value(),m=this._useFirstUnplottableRow&&(_===M.LineStudyPlotStyle.StepLine||_===M.LineStudyPlotStyle.StepLineWithDiamonds),g=this._study.plots().plottableRange(m),f=g.size();if(0===f)return!1;const v=this._study.offset(this._plotName);let y=null===(n=this._dataInvalidated)||void 0===n?void 0:n.firstIndex;const b=B.has(_);if(f!==this._items.length){const e=void 0!==y?y+v:void 0;if(void 0===e||0===this._items.length||e<(0,s.ensureDefined)(this._items[0].timePointIndex))this._items=[],g.each(((e,t)=>{const i=t[this._plotIndex+1];if(b&&null==i)return!1;const s=new r.Point(NaN,NaN);return s.origPrices=new r.Point(NaN,NaN),s.timePointIndex=e+v,this._items.push(s),!1})),y=this._items.length?(0,s.ensureDefined)(this._items[0].timePointIndex)-v:void 0;else{const e=this._items[this._items.length-1].timePointIndex,t=(0,s.ensureDefined)(e)-v,i=(0,s.ensureNotNull)(g.lastIndex())+1,n=g.rangeIterator(t+1,i);for(;n.hasNext();){const e=n.next(),t=e.value[this._plotIndex+1],i=null==t;if(b&&i)continue;const s=new r.Point(NaN,NaN);s.origPrices=new r.Point(NaN,NaN),s.timePointIndex=e.index+v,this._items.push(s)}}}let w=NaN,P=NaN;const C=new Map,x=(e,t)=>{let i=C.get(e);void 0===i&&(i=new Map,C.set(e,i));let s=i.get(t);if(void 0===s){const r=!this._plotName||"vol"!==this._plotName;s=(0,c.generateColor)(e,t,r),i.set(t,s)}return s},T=(0,S.createEmptyStyle)(),I=(0,a.clamp)(this._getTranspValue(),0,100),L=this._model.timeScale().visibleBarsStrictRange();if(null===L)return!1;const{startBar:k,endBar:D}=this._calculateStartEnd(L);if(null===k||null===D||0===this._items.length)return!1;const V=null!=y?y:(0,s.ensureNotNull)(g.firstIndex()),E=g.rangeIterator(V,(0,s.ensureNotNull)(g.lastIndex())+1),R=(0,A.lowerbound)(this._items,V+v,((e,t)=>e.timePointIndex0){const e=this._items[N-1].timePointIndex,i=new r.Point(t-1,NaN);i.origPrices=new r.Point(t-1,NaN),i.timePointIndex=e,N{const t=(0,n.rgbToHsl)((0,n.parseRgb)(e)),i=t[0]+.05;return t[0]=i-Math.floor(i),(0,n.rgbToHexString)((0,n.hslToRgb)(t))},E=d(D);function V(e,t){if(null===e)return t;const i=e.firstIndex,s=t.firstIndex,r=e.clearData||t.clearData;return{firstIndex:r||void 0===i||void 0===s?void 0:Math.min(i,s),clearData:r}}const B=new Set([M.LineStudyPlotStyle.Line,M.LineStudyPlotStyle.Area,M.LineStudyPlotStyle.Circles,M.LineStudyPlotStyle.Cross,M.LineStudyPlotStyle.StepLine,M.LineStudyPlotStyle.StepLineWithDiamonds]);class R{constructor(e,t,i,s,r=!1){this._histogramBase=null,this._items=[],this._lastConfirmedSeriesBarCoordinate=NaN,this._selectionData=null,this._lineColor="",this._lineWidth=1,this._color1="",this._color2="",this._dataInvalidated=null,this._viewportInvalidated=!1,this._renderer=new _.CompositeRenderer,this._isMarkersEnabled=o.enabled("source_selection_markers"),this._study=e,this._series=t,this._model=i,this._plotName=s,this._plotIndex=e.metaInfo().plots.findIndex((e=>e.id===s)),this._colorProvider=(0,L.createStudyPlotColorProvider)(e.metaInfo(),e.properties(),s),this._selectionIndexer=new f.SelectionIndexes(i.timeScale()),this._extendStepLineToBarsEndings=r,this._useFirstUnplottableRow=!1}items(){return this._items}update(e){if("global-change"===e.type)return this._dataInvalidated=V(this._dataInvalidated,{}),void(this._viewportInvalidated=!0);if("data-source-change"!==e.type)this._viewportInvalidated=!0;else{if(e.sourceId===this._study.id()){const t=V(this._dataInvalidated,{firstIndex:e.firstUpdatedTimePointIndex,clearData:e.clearData});this._dataInvalidated=t}}}renderer(){return this._dataInvalidated?this._updateImplFull(this._viewportInvalidated)&&(this._dataInvalidated=null):this._viewportInvalidated&&this._updateImplLight(),this._viewportInvalidated=!1,this._renderer}_getTranspValue(){const e=this._study.properties(),t=e.styles[this._plotName];let i=0;const s=this._study.metaInfo();return"Volume@tv-basicstudies"===s.id&&s.version<=46&&"transparency"in e?(i=e.transparency.value(),i=(0,l.isNumber)(i)?i:0,i):(t.transparency&&(i=t.transparency.value(),i=(0,l.isNumber)(i)?i:0),i)}_updateImplFull(e){var t,i,n,o,l;if(this._renderer.clear(),(null===(t=this._dataInvalidated)||void 0===t?void 0:t.clearData)&&(this._items=[]), +!this._study.isPlotVisibleAt(this._plotName,1))return!1;if(!this._study.priceScale())return!1;const h=this._study.firstValue();if(null===h)return!1;const d=this._study.priceScale();if(null===d)return!1;this._histogramBase=null;const u=this._study.properties().styles[this._plotName],p=(0,s.ensureDefined)(null===(i=this._study.metaInfo().styles)||void 0===i?void 0:i[this._plotName]),_=u.plottype.value(),m=this._useFirstUnplottableRow&&(_===M.LineStudyPlotStyle.StepLine||_===M.LineStudyPlotStyle.StepLineWithDiamonds),g=this._study.plots().plottableRange(m),f=g.size();if(0===f)return!1;const v=this._study.offset(this._plotName);let y=null===(n=this._dataInvalidated)||void 0===n?void 0:n.firstIndex;const b=B.has(_);if(f!==this._items.length){const e=void 0!==y?y+v:void 0;if(void 0===e||0===this._items.length||e<(0,s.ensureDefined)(this._items[0].timePointIndex))this._items=[],g.each(((e,t)=>{const i=t[this._plotIndex+1];if(b&&null==i)return!1;const s=new r.Point(NaN,NaN);return s.origPrices=new r.Point(NaN,NaN),s.timePointIndex=e+v,this._items.push(s),!1})),y=this._items.length?(0,s.ensureDefined)(this._items[0].timePointIndex)-v:void 0;else{const e=this._items[this._items.length-1].timePointIndex,t=(0,s.ensureDefined)(e)-v,i=(0,s.ensureNotNull)(g.lastIndex())+1,n=g.rangeIterator(t+1,i);for(;n.hasNext();){const e=n.next(),t=e.value[this._plotIndex+1],i=null==t;if(b&&i)continue;const s=new r.Point(NaN,NaN);s.origPrices=new r.Point(NaN,NaN),s.timePointIndex=e.index+v,this._items.push(s)}}}let w=NaN,P=NaN;const C=new Map,x=(e,t)=>{let i=C.get(e);void 0===i&&(i=new Map,C.set(e,i));let s=i.get(t);if(void 0===s){const r=!this._plotName||"vol"!==this._plotName;s=(0,c.generateColor)(e,t,r),i.set(t,s)}return s},T=(0,S.createEmptyStyle)(),I=(0,a.clamp)(this._getTranspValue(),0,100),L=this._model.timeScale().visibleBarsStrictRange();if(null===L)return!1;const{startBar:k,endBar:D}=this._calculateStartEnd(L);if(null===k||null===D||0===this._items.length)return!1;const E=null!=y?y:(0,s.ensureNotNull)(g.firstIndex()),V=g.rangeIterator(E,(0,s.ensureNotNull)(g.lastIndex())+1),R=(0,A.lowerbound)(this._items,E+v,((e,t)=>e.timePointIndex0){const e=this._items[N-1].timePointIndex,i=new r.Point(t-1,NaN);i.origPrices=new r.Point(t-1,NaN),i.timePointIndex=e,Ne.timePointIndexee.timePointIndexes+1?{startBar:null,endBar:null}:(i=Math.max(a,i),{startBar:i,endBar:s})}_createRenderer(e,t){var i,r;this._renderer.clear();const n=this._study.properties().styles.childs()[this._plotName].childs(),o=(0,s.ensureDefined)(null===(i=this._study.metaInfo().styles)||void 0===i?void 0:i[this._plotName]),d=(0,a.clamp)(this._getTranspValue(),0,100);this._lineColor=(0,c.generateColor)(n.color.value(),d), -this._lineWidth=n.linewidth.value();let u=n.color.value();const _=this._colorProvider.getDefaultPlotPointStyle();_&&(u=_.colors[0]||u,this._lineWidth=null!==(r=_.lineWidth)&&void 0!==r?r:this._lineWidth,this._lineColor=u?(0,c.generateColor)(u,d):this._lineColor),this._color2=(0,c.generateColor)(u,d);const f=this._study.metaInfo().isRGB?D(u):V(u);this._color1=(0,c.generateColor)(f,d);const S={};S.barSpacing=this._model.timeScale().barSpacing(),S.items=this._items,S.histogramBase=this._histogramBase?this._histogramBase:(0,s.ensureNotNull)(this._study.priceScale()).height(),S.lineIndex=0,S.lineStyle=n.linestyle.value(),S.lineColor=this._lineColor,S.lineWidth=this._lineWidth,S.lineWidth=(0,l.isNumber)(S.lineWidth)?S.lineWidth:1,S.color1=this._color1,S.color2=this._color2,S.bottom=S.histogramBase,S.visibleItemsRange={startItemIndex:e,endItemIndex:t},S.lastConfirmedSeriesBarCoordinate=this._lastConfirmedSeriesBarCoordinate,S.simpleMode=this._colorProvider.singleColor();const y=this._renderer,b=o.joinPoints;switch(n.plottype.value()){case M.LineStudyPlotStyle.Line:case M.LineStudyPlotStyle.LineWithBreaks:y.append(new m.PaneRendererLine(S));break;case M.LineStudyPlotStyle.Area:case M.LineStudyPlotStyle.AreaWithBreaks:y.append(new p.PaneRendererArea(S));break;case M.LineStudyPlotStyle.Histogram:y.append(new I(S));break;case M.LineStudyPlotStyle.Columns:y.append(new C.PaneRendererColumns(S));break;case M.LineStudyPlotStyle.Cross:if(y.append(new T(S)),b){const e=(0,h.deepCopy)(S);e.lineWidth=1,e.forceLineWidth=!0,y.append(new m.PaneRendererLine(e))}break;case M.LineStudyPlotStyle.Circles:if(y.append(new P(S)),b){const e=(0,h.deepCopy)(S);e.lineWidth=1,e.ignorePaletteLineWidth=!0,y.append(new m.PaneRendererLine(e))}break;case M.LineStudyPlotStyle.StepLine:case M.LineStudyPlotStyle.StepLineWithBreaks:case M.LineStudyPlotStyle.StepLineWithDiamonds:{S.decoration=n.plottype.value()===M.LineStudyPlotStyle.StepLineWithDiamonds?g.StepLineDecoration.Diamonds:g.StepLineDecoration.None,S.extendToBarsEndings=this._extendStepLineToBarsEndings;const e=new g.PaneRendererStepLine(void 0,!1);e.setData(S),y.append(e);break}default:y.append(new m.PaneRendererLine(S))}this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&this._selectionData&&y.append(new v.SelectionRenderer(this._selectionData))}_createSelection(e){const t=this._study.priceScale();if(null!==t)if(this._model.selection().isSelected(this._study)){const i=this._selectionIndexer.indexes();this._selectionData={points:[],bgColors:[],visible:!0,hittestResult:u.HitTarget.Regular,barSpacing:this._model.timeScale().barSpacing()};const n=(0,s.ensureNotNull)(this._model.paneForSource(this._study)).height(),o=this._study.offset(this._plotName);for(let s=0;s{"use strict";i.d(t,{createStudyPlotColorProvider:()=>p});var s=i(72877),r=i(50151),n=i(96759);const o=new Map([[0,"color"],[2,"textColor"],[3,"borderColor"],[4,"wickColor"],[5,"colorup"],[6,"colordown"]]);class a{constructor(e){this._plotStyle=e}getPlotPointStyle(e,t){const i=t?(0,n.clearStyle)(t):(0,n.createEmptyStyle)();return o.forEach(((e,t)=>{this._plotStyle[e]&&(i.colors[t]=this._plotStyle[e].value())})),i.lineWidth=this._plotStyle.linewidth?this._plotStyle.linewidth.value():void 0,i.lineStyle=this._plotStyle.linestyle?this._plotStyle.linestyle.value():void 0,i}isColorDefined(){return!0}singleColor(){return!0}getDefaultPlotPointStyle(){return null}}const l=[0,1,2,3,4,5,6];class c{constructor(e,t,i,s){this._palettesColors=new Map,this._defaultPlotColors=new Map,this._indexes=s;const n=t.styles[i];if(n)for(const[e,t]of o)this._defaultPlotColors.set(e,n[t]);const a=(0,r.ensureDefined)(e.palettes),l=e.plots;s.forEach(((e,i)=>{const s=l[e];if(s&&"palette"in s){const e=a[s.palette],r=t.palettes[s.palette];if(e&&r){const{valToIndex:t}=e,{colors:s}=r,n={...s};t&&Object.keys(t).forEach((e=>{const i=t[e];void 0!==i&&(n[e]=s[i])})),this._palettesColors.set(i,n)}}}))}getPlotPointStyle(e,t){const i=t?(0,n.clearStyle)(t):(0,n.createEmptyStyle)();return l.forEach((t=>{var s,n;if(this._palettesColors.has(t)){const n=e[(0,r.ensureDefined)(this._indexes.get(t))+1];if("number"==typeof n){const e=null===(s=this._palettesColors.get(t))||void 0===s?void 0:s[n];0===t&&e&&(i.lineWidth=e.width.value(),i.lineStyle=e.style.value()),i.colors[t]=null==e?void 0:e.color.value()}else i.colors[t]="transparent"}else i.colors[t]=null===(n=this._defaultPlotColors.get(t))||void 0===n?void 0:n.value()})),i}getDefaultPlotPointStyle(){var e;const t=null===(e=this._palettesColors.get(0))||void 0===e?void 0:e[0];if(void 0!==t){return{colors:[t.color.value(),void 0,void 0,void 0,void 0,void 0,void 0],lineStyle:void 0,lineWidth:t.width.value()}}return null}isColorDefined(){return!!this._palettesColors.size}singleColor(){return!1}}var h=i(87095);class d{constructor(e){this._indexes=e}getPlotPointStyle(e,t){const i=t?(0,n.clearStyle)(t):(0,n.createEmptyStyle)();return this._indexes.forEach(((t,s)=>{const r=e[t+1];if(null!=r){const e=(0,h.rgbaFromInteger)(r);i.colors[s]=e}else i.colors[s]="transparent"})),i}isColorDefined(){return!0}singleColor(){return!1}getDefaultPlotPointStyle(){return null}}const u=new Map([[0,function(e,t){const i=(0,s.isColorerPlot)(t)||(0,s.isOhlcColorerPlot)(t);return"target"in t&&t.target===e&&i}],[2,function(e,t){const i=(0,s.isTextColorerPlot)(t);return"target"in t&&t.target===e&&i}],[1,function(e,t){return(0,s.isBgColorerPlot)(t)&&t.id===e}],[3,function(e,t){const i=(0,s.isCandleBorderColorerPlot)(t);return"target"in t&&t.target===e&&i}],[4,function(e,t){const i=(0,s.isCandleWickColorerPlot)(t);return"target"in t&&t.target===e&&i}],[5,function(e,t){const i=(0,s.isUpColorerPlot)(t) -;return"target"in t&&t.target===e&&i}],[6,function(e,t){const i=(0,s.isDownColorerPlot)(t);return"target"in t&&t.target===e&&i}]]);function p(e,t,i){const{colorers:s}=function(e,t){const i=e.plots,s=i.findIndex((e=>e.id===t)),r=new Map;return i.forEach(((e,i)=>{u.forEach(((s,n)=>{s(t,e)&&r.set(n,i)}))})),{plotIndex:-1===s?null:s,colorers:r}}(e,i);if(s.size)return e.isRGB?new d(s):new c(e,t,i,s);{const e=t.ohlcPlots;if(e&&e[i])return new a(e[i]);const s=t.styles[i];return new a(s)}}},72877:(e,t,i)=>{"use strict";var s,r,n;function o(e){return"line"===e.type}function a(e){return"shapes"===e.type}function l(e){return"chars"===e.type}function c(e){return"arrows"===e.type}function h(e){return"data"===e.type}function d(e){return"dataoffset"===e.type}function u(e){return"ohlc_open"===e.type}function p(e){return"ohlc_high"===e.type}function _(e){return"ohlc_low"===e.type}function m(e){return"ohlc_close"===e.type}function g(e){return u(e)||p(e)||_(e)||m(e)}function f(e){return"colorer"===e.type&&"palette"in e}function v(e){return"colorer"===e.type&&!("palette"in e)}function S(e){return"colorer"===e.type}function y(e){return"bar_colorer"===e.type}function b(e){return"bg_colorer"===e.type}function w(e){return"text_colorer"===e.type}function P(e){return"ohlc_colorer"===e.type}function C(e){return"wick_colorer"===e.type}function x(e){return"border_colorer"===e.type}function T(e){return"up_colorer"===e.type}function I(e){return"down_colorer"===e.type}function M(e){return"alertcondition"===e.type}function L(e){return o(e)||a(e)||l(e)||c(e)}function A(e){return"Plot"!==e}function k(e){return"ohlc_bars"===e.plottype}function D(e){return"ohlc_candles"===e.plottype}function V(e){return S(e)||y(e)||b(e)||h(e)||d(e)||P(e)||M(e)||T(e)||I(e)||x(e)||C(e)||w(e)}function E(e){return S(e)||w(e)||y(e)||h(e)||d(e)||P(e)||C(e)||x(e)||T(e)||I(e)||M(e)}i.r(t),i.d(t,{LineStudyPlotStyle:()=>s,PlotSymbolSize:()=>n,STUDYPLOTDISPLAYTARGET:()=>r,isAlertConditionPlot:()=>M,isArrowsPlot:()=>c,isBarColorerPlot:()=>y,isBgColorerPlot:()=>b,isCandleBorderColorerPlot:()=>x,isCandleWickColorerPlot:()=>C,isCharsPlot:()=>l,isColorerPlot:()=>S,isDataOffsetPlot:()=>d,isDataPlot:()=>h,isDownColorerPlot:()=>I,isLinePlot:()=>o,isNonVisualPlot:()=>E,isOhlcClosePlot:()=>m,isOhlcColorerPlot:()=>P,isOhlcHighPlot:()=>p,isOhlcLowPlot:()=>_,isOhlcOpenPlot:()=>u,isOhlcPlot:()=>g,isOhlcPlotStyleBars:()=>k,isOhlcPlotStyleCandles:()=>D,isPaletteColorerPlot:()=>f,isPlotSupportDisplay:()=>L,isPlotTitleDefined:()=>A,isPlotWithTechnicalValues:()=>V,isRgbaColorerPlot:()=>v,isShapesPlot:()=>a,isTextColorerPlot:()=>w,isUpColorerPlot:()=>T}),function(e){e[e.Line=0]="Line",e[e.Histogram=1]="Histogram",e[e.Cross=3]="Cross",e[e.Area=4]="Area",e[e.Columns=5]="Columns",e[e.Circles=6]="Circles",e[e.LineWithBreaks=7]="LineWithBreaks",e[e.AreaWithBreaks=8]="AreaWithBreaks",e[e.StepLine=9]="StepLine",e[e.StepLineWithDiamonds=10]="StepLineWithDiamonds",e[e.StepLineWithBreaks=11]="StepLineWithBreaks"}(s||(s={})),function(e){e[e.None=0]="None",e[e.Pane=1]="Pane",e[e.DataWindow=2]="DataWindow", +;return"target"in t&&t.target===e&&i}],[6,function(e,t){const i=(0,s.isDownColorerPlot)(t);return"target"in t&&t.target===e&&i}]]);function p(e,t,i){const{colorers:s}=function(e,t){const i=e.plots,s=i.findIndex((e=>e.id===t)),r=new Map;return i.forEach(((e,i)=>{u.forEach(((s,n)=>{s(t,e)&&r.set(n,i)}))})),{plotIndex:-1===s?null:s,colorers:r}}(e,i);if(s.size)return e.isRGB?new d(s):new c(e,t,i,s);{const e=t.ohlcPlots;if(e&&e[i])return new a(e[i]);const s=t.styles[i];return new a(s)}}},72877:(e,t,i)=>{"use strict";var s,r,n;function o(e){return"line"===e.type}function a(e){return"shapes"===e.type}function l(e){return"chars"===e.type}function c(e){return"arrows"===e.type}function h(e){return"data"===e.type}function d(e){return"dataoffset"===e.type}function u(e){return"ohlc_open"===e.type}function p(e){return"ohlc_high"===e.type}function _(e){return"ohlc_low"===e.type}function m(e){return"ohlc_close"===e.type}function g(e){return u(e)||p(e)||_(e)||m(e)}function f(e){return"colorer"===e.type&&"palette"in e}function v(e){return"colorer"===e.type&&!("palette"in e)}function S(e){return"colorer"===e.type}function y(e){return"bar_colorer"===e.type}function b(e){return"bg_colorer"===e.type}function w(e){return"text_colorer"===e.type}function P(e){return"ohlc_colorer"===e.type}function C(e){return"wick_colorer"===e.type}function x(e){return"border_colorer"===e.type}function T(e){return"up_colorer"===e.type}function I(e){return"down_colorer"===e.type}function M(e){return"alertcondition"===e.type}function L(e){return o(e)||a(e)||l(e)||c(e)}function A(e){return"Plot"!==e}function k(e){return"ohlc_bars"===e.plottype}function D(e){return"ohlc_candles"===e.plottype}function E(e){return S(e)||y(e)||b(e)||h(e)||d(e)||P(e)||M(e)||T(e)||I(e)||x(e)||C(e)||w(e)}function V(e){return S(e)||w(e)||y(e)||h(e)||d(e)||P(e)||C(e)||x(e)||T(e)||I(e)||M(e)}i.r(t),i.d(t,{LineStudyPlotStyle:()=>s,PlotSymbolSize:()=>n,STUDYPLOTDISPLAYTARGET:()=>r,isAlertConditionPlot:()=>M,isArrowsPlot:()=>c,isBarColorerPlot:()=>y,isBgColorerPlot:()=>b,isCandleBorderColorerPlot:()=>x,isCandleWickColorerPlot:()=>C,isCharsPlot:()=>l,isColorerPlot:()=>S,isDataOffsetPlot:()=>d,isDataPlot:()=>h,isDownColorerPlot:()=>I,isLinePlot:()=>o,isNonVisualPlot:()=>V,isOhlcClosePlot:()=>m,isOhlcColorerPlot:()=>P,isOhlcHighPlot:()=>p,isOhlcLowPlot:()=>_,isOhlcOpenPlot:()=>u,isOhlcPlot:()=>g,isOhlcPlotStyleBars:()=>k,isOhlcPlotStyleCandles:()=>D,isPaletteColorerPlot:()=>f,isPlotSupportDisplay:()=>L,isPlotTitleDefined:()=>A,isPlotWithTechnicalValues:()=>E,isRgbaColorerPlot:()=>v,isShapesPlot:()=>a,isTextColorerPlot:()=>w,isUpColorerPlot:()=>T}),function(e){e[e.Line=0]="Line",e[e.Histogram=1]="Histogram",e[e.Cross=3]="Cross",e[e.Area=4]="Area",e[e.Columns=5]="Columns",e[e.Circles=6]="Circles",e[e.LineWithBreaks=7]="LineWithBreaks",e[e.AreaWithBreaks=8]="AreaWithBreaks",e[e.StepLine=9]="StepLine",e[e.StepLineWithDiamonds=10]="StepLineWithDiamonds",e[e.StepLineWithBreaks=11]="StepLineWithBreaks"}(s||(s={})),function(e){e[e.None=0]="None",e[e.Pane=1]="Pane",e[e.DataWindow=2]="DataWindow", e[e.PriceScale=4]="PriceScale",e[e.StatusLine=8]="StatusLine",e[e.All=15]="All"}(r||(r={})),function(e){e.Auto="auto",e.Tiny="tiny",e.Small="small",e.Normal="normal",e.Large="large",e.Huge="huge"}(n||(n={}))},28853:(e,t,i)=>{"use strict";i.r(t),i.d(t,{createStudy:()=>le,isESDStudy:()=>oe,isFundamentalStudy:()=>ne,isRollDatesStudy:()=>ae,isStudy:()=>ie,isStudyStrategy:()=>se,isStudyStub:()=>re,studyColorRotationMode:()=>ce,useSameColorRotationComparator:()=>de});var s=i(14483),r=i(42856),n=i(8708),o=i(50151),a=i(26426),l=i(27714),c=i(74359);class h{constructor(e,t,i,s){this._priceAxisFontSize=11,this._prices=[],this._labelWidth=0,this._pixelRatioParams=e,this._recreateCanvasAndContext((0,l.size)({width:0,height:0})),this.reset({font:t,fontSize:i,backColors:s})}destroy(){delete this._canvas,delete this._cache}canvas(){return this._canvas}reset(e){this._renderParams=e,this._prices=[],this._cache.font=e.fontSize+"px "+e.font,this._labelWidth=["P","S1","R1","S2","R2","S3","R3","S4","R4","S5","R5","/"].reduce(((e,t)=>{const i=this._cache.measureText(t).width;return Math.max(i,e)}),0)}rowHeight(){return this._priceAxisFontSize+4}labelRectByIndex(e){return{left:0,top:Math.round(this._topByIndex(e)),width:Math.round(this._labelWidth+4),height:Math.round(this._renderParams.fontSize+8)}}setPrices(e){let t=!1;const i=(e,t)=>{const i=void 0===e,s=void 0===t;return(!i&&!s||i===s)&&(0,o.ensureDefined)(e).formatted===(0,o.ensureDefined)(t).formatted};if(e.length!==this._prices.length)t=!0;else for(let s=0;s{this._cache.translate(.5,.5),this._cache.font=this._renderParams.fontSize+"px "+this._renderParams.font,this._cache.textBaseline="middle";for(let e=0;e=n||c)){this._visiblePivots.add(o[e]),this._prices=[];for(let i=0;i=t.left&&e.x<=t.left+t.width&&e.y>=t.top&&e.y<=t.top+t.height)return new I.HitTestResult(I.HitTarget.Regular);return null}_drawImpl(e){const t=this._cacheProvider(e),{horizontalPixelRatio:i,verticalPixelRatio:s,context:r}=e;this._drawRects=[];const n=e=>{const n=t.labelRectByIndex(e),o={left:Math.round(this._point.x-n.width+a), -top:Math.round(this._point.y-n.height/2),width:n.width,height:n.height};return r.drawImage(t.canvas(),Math.round(n.left*i),Math.round(n.top*s),n.width*i,n.height*s,Math.round(o.left*i),Math.round(o.top*s),o.width*i,o.height*s),this._drawRects.push(o),n.width},o=this._label.split("/");let a=0;for(let e=0;e0&&(a+=n(t+11)/2),a+=n(t)/2}}}function A(e){return"P"===e?e:"S"+e[1]+"/R"+e[1]}function k(e,t,i){const s=t;void 0===e[s]?e[s]={text:i,ids:[A(i)]}:(e[s].text+="/"+i,e[s].ids.push(A(i)))}class D{constructor(e,t){this._pivots=[],this._invalidated=!0,this._renderer=new x.CompositeRenderer,this._model=e,this._source=t,this._cacheProvider=this._source.getCache.bind(this._source)}update(e){this._invalidated=!0}renderer(e,t){return this._invalidated&&(this._updateImpl(t,e),this._invalidated=!1),this._renderer}_updateImpl(e,t){this._renderer.clear();const i=this._source.ownerSource();if(null===i)return;this._source.pricesView().prices(),this._pivots=[];const s=this._source.customData();if(!s||!s.pivots)return;const r=this._source.properties().childs();if(!r.visible.value())return;const n=s.pivots,a=this._source.indexes(),l=this._model.timeScale(),c=this._source.priceScale(),h=i.firstValue();if(!c||c.isEmpty()||l.isEmpty()||!n||!a||null===h)return;const d=(0,o.ensureNotNull)(l.visibleBarsStrictRange()),u=d.firstBar(),p=d.lastBar();for(let e=0;ep)continue;const s={},o=r.levelsStyle.childs().visibility.childs();o.P.value()&&k(s,n[e].p,"P"),o["S1/R1"].value()&&(k(s,n[e].s1,"S1"),k(s,n[e].r1,"R1")),o["S2/R2"].value()&&(k(s,n[e].s2,"S2"),k(s,n[e].r2,"R2")),o["S3/R3"].value()&&(k(s,n[e].s3,"S3"),k(s,n[e].r3,"R3")),o["S4/R4"].value()&&(k(s,n[e].s4,"S4"),k(s,n[e].r4,"R4")),o["S5/R5"].value()&&(k(s,n[e].s5,"S5"),k(s,n[e].r5,"R5"));const d=l.indexToCoordinate(t),_=l.indexToCoordinate(i);for(const t of Object.keys(s)){const i=parseFloat(t),r=c.priceToCoordinate(i,h);this._pivots.push({x1:d,x2:_,y:r,label:s[t].text,labelIds:s[t].ids,src:n[e]})}}const _=r.levelsStyle.childs().colors,m=r.levelsStyle.childs().widths,g=this._source.visiblePivots();for(let e=0;ethis.processHibernate()))}pricesView(){return this._pricesView}indexes(){return this._indexes}properties(){return this._properties}getCache(e){if(null===this._cache||null==this._cachedPixelRatioParams||(t=e,i=this._cachedPixelRatioParams,t.horizontalPixelRatio!==i.horizontalPixelRatio||t.verticalPixelRatio!==i.verticalPixelRatio)){this._cache&&this._cache.destroy();const t=this._getActualCacheParams(),i={horizontalPixelRatio:e.horizontalPixelRatio,verticalPixelRatio:e.verticalPixelRatio};this._cache=new h(i,t.font,t.fontSize,t.backColors),this._cache.setPrices((0,o.ensureNotNull)(this._pricesView).prices()),this._cachedPixelRatioParams=i,this._cache.reset(t)}var t,i;return this._cache}priceLabelText(e){return this._metaInfo.shortDescription+":"+e.toUpperCase()}updateAllViews(e){super.updateAllViews(e),this._pricesView.update()}visiblePivots(){return this._pricesView.visiblePivots()}isVisible(){if(!this.properties().childs().visible.value()||!this.isActualInterval())return!1;const e=["P","S1/R1","S2/R2","S3/R3","S4/R4","S5/R5"],t=this.properties().childs().levelsStyle.childs().visibility;for(let i=0;it)continue;const a=[],l=this.properties().childs().levelsStyle.childs().visibility.childs();l.P.value()&&a.push(r[i].p),l["S1/R1"].value()&&a.push(r[i].s1,r[i].r1),l["S2/R2"].value()&&a.push(r[i].s2,r[i].r2),l["S3/R3"].value()&&a.push(r[i].s3,r[i].r3),l["S4/R4"].value()&&a.push(r[i].s4,r[i].r4),l["S5/R5"].value()&&a.push(r[i].s5,r[i].r5);for(let e=0;e0&&(a+=n(t+11)/2),a+=n(t)/2}}}function A(e){return"P"===e?e:"S"+e[1]+"/R"+e[1]}function k(e,t,i){const s=t;void 0===e[s]?e[s]={text:i,ids:[A(i)]}:(e[s].text+="/"+i,e[s].ids.push(A(i)))}class D{constructor(e,t){this._pivots=[],this._invalidated=!0,this._renderer=new x.CompositeRenderer,this._model=e,this._source=t,this._cacheProvider=this._source.getCache.bind(this._source)}update(e){this._invalidated=!0}renderer(e,t){return this._invalidated&&(this._updateImpl(t,e),this._invalidated=!1),this._renderer}_updateImpl(e,t){this._renderer.clear();const i=this._source.ownerSource();if(null===i)return;this._source.pricesView().prices(),this._pivots=[];const s=this._source.customData();if(!s||!s.pivots)return;const r=this._source.properties().childs();if(!r.visible.value())return;const n=s.pivots,a=this._source.indexes(),l=this._model.timeScale(),c=this._source.priceScale(),h=i.firstValue();if(!c||c.isEmpty()||l.isEmpty()||!n||!a||null===h)return;const d=(0,o.ensureNotNull)(l.visibleBarsStrictRange()),u=d.firstBar(),p=d.lastBar();for(let e=0;ep)continue;const s={},o=r.levelsStyle.childs().visibility.childs();o.P.value()&&k(s,n[e].p,"P"),o["S1/R1"].value()&&(k(s,n[e].s1,"S1"),k(s,n[e].r1,"R1")),o["S2/R2"].value()&&(k(s,n[e].s2,"S2"),k(s,n[e].r2,"R2")),o["S3/R3"].value()&&(k(s,n[e].s3,"S3"),k(s,n[e].r3,"R3")),o["S4/R4"].value()&&(k(s,n[e].s4,"S4"),k(s,n[e].r4,"R4")),o["S5/R5"].value()&&(k(s,n[e].s5,"S5"),k(s,n[e].r5,"R5"));const d=l.indexToCoordinate(t),_=l.indexToCoordinate(i);for(const t of Object.keys(s)){const i=parseFloat(t),r=c.priceToCoordinate(i,h);this._pivots.push({x1:d,x2:_,y:r,label:s[t].text,labelIds:s[t].ids,src:n[e]})}}const _=r.levelsStyle.childs().colors,m=r.levelsStyle.childs().widths,g=this._source.visiblePivots();for(let e=0;ethis.processHibernate()))}pricesView(){return this._pricesView}indexes(){return this._indexes}properties(){return this._properties}getCache(e){if(null===this._cache||null==this._cachedPixelRatioParams||(t=e,i=this._cachedPixelRatioParams,t.horizontalPixelRatio!==i.horizontalPixelRatio||t.verticalPixelRatio!==i.verticalPixelRatio)){this._cache&&this._cache.destroy();const t=this._getActualCacheParams(),i={horizontalPixelRatio:e.horizontalPixelRatio,verticalPixelRatio:e.verticalPixelRatio};this._cache=new h(i,t.font,t.fontSize,t.backColors),this._cache.setPrices((0,o.ensureNotNull)(this._pricesView).prices()),this._cachedPixelRatioParams=i,this._cache.reset(t)}var t,i;return this._cache}priceLabelText(e){return this._metaInfo.shortDescription+":"+e.toUpperCase()}updateAllViews(e){super.updateAllViews(e),this._pricesView.update()}visiblePivots(){return this._pricesView.visiblePivots()}isVisible(){if(!this.properties().childs().visible.value()||!this.isActualInterval())return!1;const e=["P","S1/R1","S2/R2","S3/R3","S4/R4","S5/R5"],t=this.properties().childs().levelsStyle.childs().visibility;for(let i=0;it)continue;const a=[],l=this.properties().childs().levelsStyle.childs().visibility.childs();l.P.value()&&a.push(r[i].p),l["S1/R1"].value()&&a.push(r[i].s1,r[i].r1),l["S2/R2"].value()&&a.push(r[i].s2,r[i].r2),l["S3/R3"].value()&&a.push(r[i].s3,r[i].r3),l["S4/R4"].value()&&a.push(r[i].s4,r[i].r4),l["S5/R5"].value()&&a.push(r[i].s5,r[i].r5);for(let e=0;ethis.invalidateTitleCache()))}base(){return 1}destroy(){(0,o.ensureDefined)(this.properties().childs().styles.childs().vol_ma).childs().display.listeners().unsubscribeAll(this),super.destroy()}showOnTopOnHovering(){return!1}_titleInputs(e){const t={symbolsForDisplay:!0,skipHiddenInputs:!0,fakeInputsForDisplay:!0,asObject:!0,displayMask:e,skipOptionalEmptySymbolInputs:W};return 0!==(0,o.ensureDefined)(this.properties().childs().styles.childs().vol_ma).childs().display.value()?this.inputs(t):this.inputs({...t,skippedInputs:["length"]})}_titleInParts(e,t,i,s,r){const n=super._titleInParts(e,t,i,s,r),o=this._getVolumeUnit();return o&&(n[0]+=` · ${o}`),n}_getVolumeUnit(){const e=this.symbolSource().symbolInfo();return e?function(e){switch(e.volume_type){case"base":return e.base_currency;case"quote":return e.currency;case"tick":return F.t(null,void 0,i(30973))}}({...e,currency:e.original_currency_code||e.currency_code}):void 0}}var z=i(97145),U=i(59452),j=i.n(U),G=i(42960),q=i(97121);class $ extends n.Study{constructor(e,t,i,s){super(e,function(e){return e.hasChild("currencyId")||e.addChild("currencyId",new(j())(null)),e.hasChild("unitId")||e.addChild("unitId",new(j())(null)),e.addExclusion("currencyId"),e.addExclusion("unitId"),e}(t),i,s),this._isActingAsSymbolSource=new z.WatchedValue(!1),this._symbolHibernated=new z.WatchedValue(!1),this._symbolResolvingActive=new z.WatchedValue(!1),this._realignToolsLastParams=null,this._onIsActingAsSymbolSourceChanged=()=>{this._realignLineToolsIfParamsChanged()},this._recalculateIsActingAsSymbolSource(),this._isActingAsSymbolSource.subscribe(this._onIsActingAsSymbolSourceChanged);const r=this.properties().childs().inputs.childs().symbol;this._previousSymbolInputValue=r.value()}destroy(){this._isActingAsSymbolSource.unsubscribe(this._onIsActingAsSymbolSourceChanged),super.destroy()}isActingAsSymbolSource(){return this._isActingAsSymbolSource.readonly()}properties(){return this._properties}symbol(){return this._isActingAsSymbolSource.value()?this.properties().childs().inputs.childs().symbol.value():this.symbolSource().symbol()}symbolChanged(){return this._isActingAsSymbolSource.value()?this.properties().childs().inputs.childs().symbol.listeners():this.symbolSource().symbolChanged()}interval(){return this.model().mainSeries().interval()}style(){return this._firstSourceOrSeries().symbolSource().style()}currency(){return this._isActingAsSymbolSource.value()?this.properties().childs().currencyId.value()||null:this.symbolSource().currency()}unit(){ return this._isActingAsSymbolSource.value()?this.properties().childs().unitId.value()||null:this.symbolSource().unit()}setSymbolParams(e){this._setSymbolParamsInternal(e)}setSymbol(e){this.setSymbolParams({symbol:e})}symbolInfo(){if(!this._isActingAsSymbolSource.value())return super.symbolSource().symbolInfo();if(void 0===this._resolvedSymbols)return null;const e=this.symbol(),t=this._getSymbolForResolve(e);return this._resolvedSymbols[t]||null}symbolSource(){return this._isActingAsSymbolSource.value()?this:super.symbolSource()}symbolResolved(){return this.symbolsResolved()}symbolResolvingActive(){return this._symbolResolvingActive}symbolHibernated(){return this._symbolHibernated}isVisible(){const e=super.isVisible();return this._symbolHibernated.setValue(!e),e}symbolSameAsCurrent(e){return(0,q.symbolSameAsCurrent)(e,this.symbolInfo())}setCurrency(e){this.setSymbolParams({currency:e})}isConvertedToOtherCurrency(){return(0,G.isConvertedToOtherCurrency)(this.symbolInfo())}setUnit(e){this.setSymbolParams({unit:e})}isConvertedToOtherUnit(){return(0,G.isConvertedToOtherUnit)(this.symbolInfo(),this._model.unitConversionEnabled())}setInterval(e){}setStyle(e){}symbolTitle(e,t,i){return this.title(e,!0,{},!1,t)}measureUnitId(){return(0,G.measureUnitId)(this.symbolInfo())}bars(){return super.data()}dataUpdated(){return this._dataUpdated}_onPropertiesChanged(){this._recalculateIsActingAsSymbolSource(),super._onPropertiesChanged(),this._realignLineToolsIfParamsChanged()}async _tryChangeInputs(){var e;const t=this._resolvedSymbolsByInput[this.symbol()]||null;(0,q.symbolSameAsCurrent)(this._previousSymbolInputValue,t)||this._setSymbolParamsInternal({currency:null,unit:null}),await super._tryChangeInputs(),this._formatter=null,null===(e=this.priceScale())||void 0===e||e.updateFormatter(),this._previousSymbolInputValue=this.properties().childs().inputs.childs().symbol.value()}_getSymbolObject(e){const t={symbol:e},i=this.currency();null!==i&&(t["currency-id"]=i);const s=this.unit();return this._model.unitConversionEnabled()&&null!==s&&(t["unit-id"]=s),t}_getSymbolForApi(e){return(0,G.symbolForApi)(this._resolvedSymbolsByInput[e]||null,e)}_onSymbolResolved(e,t,i){super._onSymbolResolved(e,t,i),this._recreatePriceFormattingDependencies();const s=t===this.symbol()?(0,G.extractSymbolNameFromSymbolInfo)(i,this.symbol()):null;null!==s&&(this._previousSymbolInputValue=s);const r=(0,G.symbolCurrency)(i),n=(0,G.symbolUnit)(i,this._model.unitConversionEnabled());this._setSymbolParamsInternal({symbol:null!=s?s:void 0,currency:r,unit:n},i),this._symbolResolvingActive.setValue(!1)}_onSymbolResolvingStart(){super._onSymbolResolvingStart(),this._symbolResolvingActive.setValue(!0)}_onSymbolError(){super._onSymbolError(),this._symbolResolvingActive.setValue(!1)}_onCurrencyMayChange(){this.isActingAsSymbolSource()?super._onCurrencyMayChange():this._onCurrencyChanged()}_recalculateIsActingAsSymbolSource(){var e,t;const i=null!==(t=""!==(null===(e=this._currencySourceSymbolInputProperty)||void 0===e?void 0:e.value()))&&void 0!==t&&t ;this._isActingAsSymbolSource.setValue(i)}_setSymbolParamsInternal(e,t){const{symbol:i,currency:s,unit:r}=e,n=this.properties().childs(),o=n.inputs.childs().symbol.value(),a=n.currencyId.value(),l=n.unitId.value();if(void 0!==i&&i!==o&&n.inputs.childs().symbol.setValueSilently(i),void 0!==s&&s!==a&&n.currencyId.setValueSilently(s),void 0!==r&&r!==l&&n.unitId.setValueSilently(r),t)this._resolvedSymbolsByInput[this.symbol()]=t,this._resolvedSymbols[this._getSymbolForResolve(this.symbol())]=t,this._realignToolsLastParams=null;else{const e=this.symbolInfo();null!==e&&(n.currencyId.setValueSilently((0,G.symbolCurrency)(e)),n.unitId.setValueSilently((0,G.symbolUnit)(e,this._model.unitConversionEnabled())))}n.inputs.childs().symbol.value()!==o&&n.inputs.childs().symbol.listeners().fire(n.inputs.childs().symbol),n.currencyId.value()!==a&&n.currencyId.listeners().fire(n.currencyId),n.unitId.value()!==l&&n.unitId.listeners().fire(n.unitId),this._realignLineToolsIfParamsChanged()}_realignLineToolsIfParamsChanged(){const e=this.symbol(),t=this.interval(),i=this.currency(),s=this.unit();null!==this._realignToolsLastParams&&this._realignToolsLastParams.symbol===e&&this._realignToolsLastParams.interval===t&&this._realignToolsLastParams.currency===i&&this._realignToolsLastParams.unit===s||(this._model.realignLineTools(this),this._realignToolsLastParams={symbol:e,interval:t,currency:i,unit:s})}}class Y extends u.PriceAxisView{constructor(e,t){super(),this._source=e,this._styleId=t}_updateRendererData(e,t,i){var s;e.visible=!1;const r=this._source.priceScale(),n=this._source.properties().childs();if(!r||r.isEmpty()||!n.visible.value())return;const o=null===(s=this._source.properties().childs().graphics.childs().horizlines)||void 0===s?void 0:s.childs()[this._styleId].childs();if(!(o&&o.visible&&o.visible.value()&&this._isLabelVisibleAccordinglyToProperties()))return;const a=this._source.model().timeScale().logicalRange(),l=this._source.firstValue();if(null===l||null===a)return;const c={price:NaN,time:-1/0},h=this._source.graphics().horizlines().get(this._styleId);if(void 0===h)return;for(const e of h){if(void 0===e.level)continue;const t=a.contains(e.startIndex,!0);t===a.contains(e.endIndex,!0)&&0!==t||c.timenew Y(this,e)))}_createStudyPlotPaneView(e){return new K.StudyPlotPaneView(this,this._series,this._model,e,this._needExtendToBarsEnding())}_apiInputs(){return{...super._apiInputs(),mapRightBoundaryToBarStartTime:!!this._needExtendToBarsEnding()||void 0}}_needExtendToBarsEnding(){var e;return void 0!==(null===(e=this.metaInfo().defaults.inputs)||void 0===e?void 0:e.mapRightBoundaryToBarStartTime)}}class X extends Z{priceRange(e,t){let i=!1;this.graphics().hhists().forEach(((e,t)=>{var s;i=i||(0,o.ensureDefined)(null===(s=this.properties().childs().graphics.childs().hhists)||void 0===s?void 0:s.childs()[t]).value()}));const s=function(e,t,i,s){let r=null;return e.forEach(((e,s)=>{e.forEach((e=>{e.firstBarTime<=i&&e.lastBarTime>=t&&(null===r?r={low:{l:e.priceLow,h:e.priceHigh},high:{h:e.priceHigh}}:(e.priceLow{"use strict";i.d(t,{StudyBaseWindowView:()=>n}) +;r.push(new t(this,s,void 0,null==o?void 0:o.histBoxBg,n))}if(t.horizlines){const{HorizLinePaneView:e}=await i.e(507).then(i.bind(i,13369));r.push(new e(this,s,void 0,n))}return r}_createGraphicsPriceAxisViews(){var e;return Object.keys(null!==(e=this.metaInfo().graphics.horizlines)&&void 0!==e?e:{}).map((e=>new Y(this,e)))}_createStudyPlotPaneView(e){return new K.StudyPlotPaneView(this,this._series,this._model,e,this._needExtendToBarsEnding())}_apiInputs(){return{...super._apiInputs(),mapRightBoundaryToBarStartTime:!!this._needExtendToBarsEnding()||void 0}}_needExtendToBarsEnding(){var e;return void 0!==(null===(e=this.metaInfo().defaults.inputs)||void 0===e?void 0:e.mapRightBoundaryToBarStartTime)}}class X extends Z{priceRange(e,t){let i=!1;this.graphics().hhists().forEach(((e,t)=>{var s;i=i||(0,o.ensureDefined)(null===(s=this.properties().childs().graphics.childs().hhists)||void 0===s?void 0:s.childs()[t]).value()}));const s=function(e,t,i,s){let r=null;return e.forEach(((e,s)=>{e.forEach((e=>{e.firstBarTime<=i&&e.lastBarTime>=t&&(null===r?r={low:{l:e.priceLow,h:e.priceHigh},high:{h:e.priceHigh}}:(e.priceLow{"use strict";i.d(t,{StudyBaseWindowView:()=>n}) ;var s=i(93835),r=i(37591);class n extends s.DataWindowView{constructor(e,t){super(),this._invalidated=!0,this._study=e,this._model=t,this._valueProvider=this._createValuesProvider(e,t),this._items=this._valueProvider.getItems().map((e=>new s.DataWindowItem(e.id,e.title,""))),this.update()}update(){this._invalidated=!0}items(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._items}study(){return this._study}_updateImpl(){this._header=this._study.title(r.TitleDisplayTarget.DataWindow,!0),this._title=this._study.title(r.TitleDisplayTarget.DataWindow);const e=this._valueProvider.getValues(this._currentIndex());for(let t=0;t{"use strict";i.d(t,{StudyColorRotatorFactory:()=>h});var s=i(48891),r=i(24377),n=i(87095),o=i(28853);const a=["color-sky-blue-400","color-banana-yellow-700","color-deep-blue-500","color-grapes-purple-a700","color-iguana-green-500","color-minty-green-a700","color-ripe-red-a200","color-berry-pink-200","color-tv-blue-a100","color-tan-orange-a200","color-sky-blue-a400","color-deep-blue-a100","color-grapes-purple-400","color-iguana-green-a700","color-minty-green-200","color-ripe-red-200","color-berry-pink-a200","color-ripe-red-500","color-grapes-purple-500","color-deep-blue-400","color-tv-blue-a200","color-sky-blue-500","color-iguana-green-400","color-minty-green-400","color-banana-yellow-600","color-tan-orange-500","color-berry-pink-400","color-ripe-red-300","color-grapes-purple-300","color-deep-blue-300","color-tv-blue-300","color-sky-blue-300","color-iguana-green-300","color-minty-green-300","color-banana-yellow-400","color-tan-orange-300","color-berry-pink-300","color-tan-orange-a700"];class l{constructor(e){this._offset=0,this._offset=e}getColor(e){if(0===this._offset)return e;const t=a[(this._offset-1)%a.length],i=s.colorsPalette[t],o=(0,n.isHexColor)(e)?1:(0,r.parseRgba)(e)[3];return(0,n.generateColor)(i,(0,n.alphaToTransparency)(o))}}class c{constructor(e,t){this._offset=e,this._modelStartOffset=t}getColor(e){if((0,n.isHexColor)(e)){const t=(0,r.parseRgb)(e);return(0,r.rgbToHexString)((0,r.shiftRgb)(t,this._offset,this._modelStartOffset))}{const t=(0,r.parseRgba)(e);return(0,r.rgbaToString)((0,r.shiftRgba)(t,this._offset,this._modelStartOffset))}}}class h{constructor(e){this._chartModel=e}getColorRotator(e){const t=(0,o.studyColorRotationMode)(e);if(null===t)return null;const i=this._calcDefaultColorsOffset(e);switch(t){case"loop":return new l(i);case"shift":{const e=this._chartModel.getStudyShiftColorStartOffset();return new c(i,e)}}}_calcDefaultColorsOffset(e){let t=0;const i=(0,o.useSameColorRotationComparator)(e);return this._chartModel.dataSources().filter(o.isStudy).forEach((s=>{i(e,s.metaInfo())&&t++})),t}}},94739:(e,t,i)=>{"use strict";i.d(t,{StudyDataSource:()=>p}) ;var s=i(50151),r=i(57898),n=i(97034),o=i(1115),a=i(19171),l=i(72007),c=i(60393),h=i(75319);const d=(0,i(59224).getLogger)("Chart.StudyDataSource");var u;!function(e){e[e.Idle=0]="Idle",e[e.AwaitingConnection=1]="AwaitingConnection",e[e.AwaitingParent=2]="AwaitingParent",e[e.AwaitingFirstDataUpdate=3]="AwaitingFirstDataUpdate",e[e.Active=4]="Active"}(u||(u={}));class p{constructor(e,t,i,s){this._inputs=null,this._status=u.Idle,this._studyId=null,this._turnaroundCounter=1,this._studyStatus={type:h.StudyStatusType.Undefined},this._studyStatusChanged=new r.Delegate,this._dataCleared=new r.Delegate,this._dataUpdated=new r.Delegate,this._boundOnGatewayIsConnectedChanged=this._onGatewayIsConnectedChanged.bind(this),this._ongoingDataUpdate=Promise.resolve(),this._gateway=e,this._metaInfo=s,this._seriesSource=t,this._turnaroundPrefix=i,this._plots=new n.PlotList((0,l.studyPlotFunctionMap)(s),l.studyEmptyPlotValuePredicate),this._gateway.isConnected().subscribe(this._boundOnGatewayIsConnectedChanged),this._graphics=new c.LiveStudyGraphics(s.graphics)}destroy(){this.stop(),this._gateway.isConnected().unsubscribe(this._boundOnGatewayIsConnectedChanged)}metaInfo(){return this._metaInfo}inputs(){return this._inputs}setInputs(e){this._inputs=e,null!==this._studyId&&(this._turnaroundCounter++,this._onStudyStatusChangedTo({type:h.StudyStatusType.Undefined}),this._gateway.modifyStudy(this._studyId,this._turnaround(),e,this._onMessage.bind(this)),this._status===u.Active&&this._changeStatusTo(u.AwaitingFirstDataUpdate))}isStarted(){return this._status!==u.Idle}isActive(){return this._status===u.Active}start(){this.isStarted()?d.logNormal("start: data source is already started, nothing to do"):((0,s.assert)(null!==this._inputs,"Inputs should be defined when starting a study data source"),this._gateway.isConnected().value()?this._createStudy():this._changeStatusTo(u.AwaitingConnection))}stop(){this.isStarted()?(null!==this._studyId&&(this._gateway.removeStudy(this._studyId),this._studyId=null,this._onStudyStatusChangedTo({type:h.StudyStatusType.Undefined})),this._changeStatusTo(u.Idle)):d.logNormal("stop: data source is already stopped, nothing to do")}studyId(){return this._studyId}studyStatus(){return this._studyStatus}studyStatusChanged(){return this._studyStatusChanged}plots(){return this._plots}graphics(){return this._graphics}clearData(){this._plots.clear(),this._graphics.clear(),this._dataCleared.fire()}stopAndStealData(){(0,s.assert)(this._status===u.Active,"Couldn't steal data from non-active data source"),this.stop();const e=this._plots,t=this._graphics.extract();return this._plots=new n.PlotList((0,l.studyPlotFunctionMap)(this._metaInfo),l.studyEmptyPlotValuePredicate),{plots:e,graphics:t}}dataCleared(){return this._dataCleared}dataUpdated(){return this._dataUpdated}moveData(e){this._ongoingDataUpdate=this._ongoingDataUpdate.then((()=>{this._plots.move(e)}))}pendingUpdatesReady(){return this._ongoingDataUpdate}_changeStatusTo(e){(0,s.assert)(this._status!==e,"Source and destination status should be distinct"), d.logNormal(`Status changed from ${u[this._status]} to ${u[e]}`),this._status=e}_createStudy(){const e=this._seriesSource.instanceId();null!==e?this._createStudyUsingParentId(e):(this._changeStatusTo(u.AwaitingParent),this._seriesSource.dataEvents().completed().subscribe(this,this._onSeriesCompleted,!0))}_createStudyUsingParentId(e){(0,s.assert)(this._status!==u.Active,'Status should not be "Active" when creating a study'),(0,s.assert)(this._studyStatus.type===h.StudyStatusType.Undefined,'Study status should be "Undefined" when creating a study'),(0,s.assert)(null===this._studyId,"Study id should be empty when creating a study"),this._studyId=(0,a.makeNextStudyId)(),this._gateway.createStudy(this._studyId,this._turnaround(),e,this._metaInfo.fullId+("tv-basicstudies"===this._metaInfo.packageId?"":"!"),(0,s.ensureNotNull)(this._inputs),this._onMessage.bind(this)),this._changeStatusTo(u.AwaitingFirstDataUpdate)}_onGatewayIsConnectedChanged(e){e?this._onGatewayConnected():this._onGatewayDisconnected()}_onGatewayConnected(){this._status===u.AwaitingConnection&&this._createStudy()}_onGatewayDisconnected(){this._status!==u.Idle&&this._status!==u.AwaitingConnection&&(this._studyId=null,this._changeStatusTo(u.AwaitingConnection),this._studyStatus.type!==h.StudyStatusType.Undefined&&this._onStudyStatusChangedTo({type:h.StudyStatusType.Undefined})),this._turnaroundCounter=1}_onSeriesCompleted(){this._status===u.AwaitingParent&&this._createStudyUsingParentId((0,s.ensure)(this._seriesSource.instanceId()))}_onStudyStatusChangedTo(e){const t=this._studyStatus;this._studyStatus=e,d.logNormal(`Study status type changed from ${h.StudyStatusType[t.type]} to ${h.StudyStatusType[e.type]}`),this._studyStatusChanged.fire(t,e)}_onMessage(e){if("data_update"===e.method){const{customId:t,turnaround:i,plots:r,nonseries:n}=e.params;t===this._studyId&&this._checkTurnaround(i)&&this._onDataUpdate(r,(0,s.ensureDefined)(n))}else if("study_loading"===e.method){const[t,i,s]=e.params;t===this._studyId&&this._checkTurnaround(i)&&this._onStudyLoading(s)}else if("study_completed"===e.method){const[t,i,s]=e.params;t===this._studyId&&this._checkTurnaround(i)&&this._onStudyCompleted(s)}else if("study_error"===e.method){const[t,i,s,r,n]=e.params;t===this._studyId&&this._checkTurnaround(i)&&this._onStudyError(s,r,n)}else"clear_data"===e.method&&this._checkTurnaround(e.params.turnaround)&&this.clearData()}_onDataUpdate(e,t){const i=(0,o.unpackNonSeriesData)(t.d);return this._ongoingDataUpdate=this._ongoingDataUpdate.then((()=>i),(()=>i)).then(this._onDataUnpacked.bind(this,e,t.indexes)),this._ongoingDataUpdate}_onDataUnpacked(e,t,i){this._status!==u.Idle&&(this._status===u.AwaitingFirstDataUpdate&&(this._changeStatusTo(u.Active),this.clearData()),this._mergePlots(e),null!==i&&(i.indexes_replace?((0,s.assert)("nochange"!==t),this._graphics.replaceIndexesTo(t)):("nochange"!==t&&this._graphics.replaceIndexesTo(t),void 0!==i.graphicsCmds&&this._graphics.processCommands(i.graphicsCmds))),this._dataUpdated.fire(e,i,t))}_onStudyLoading(e){ @@ -746,8 +746,8 @@ this._onStudyStatusChangedTo({type:h.StudyStatusType.Loading,startTime:Date.now( this._inserterImpl=i,this._studyDescriptor=e}setParentSources(e){this._parentSources=e}setPaneSize(e){this._paneSize=e}setPreferredPriceScale(e){this._preferredPriceScale=e}setAllowChangeCurrency(e){this._allowChangeCurrency=e}setAllowChangeUnit(e){this._allowChangeUnit=e}setForceOverlay(e){this._forceOverlay=e}setPropertiesState(e){this._propsState=e}setTargetPriceScaleMode(e){this._targetPriceScaleMode=e}async insert(e,t){var i;const l=void 0!==(c=this._inserterImpl).createStub&&void 0!==c.removeStub?this._inserterImpl.createStub():null;var c;let h,d=!0;try{h=await this._studyMetaInfoRepository.findById(this._studyDescriptor)}catch(e){return a.logWarn(`Cannot get study ${JSON.stringify(this._studyDescriptor)}`),Promise.reject(o.InsertionErrorCode.CannotGetMetainfo)}finally{null!==l&&(d=this._inserterImpl.removeStub(l))}if(!d)return Promise.reject(o.InsertionErrorCode.StubWasRemoved);if(void 0!==t&&t.cancelled)return Promise.reject(o.InsertionErrorCode.Cancelled);if(!this._canApplyStudyToParent(h))return Promise.reject(o.InsertionErrorCode.StudyCannotBeChild);const u={...h.defaults.inputs};let p={};if(void 0!==e){const t=s.StudyMetaInfo.getStudyPropertyRootName(h),o=(0,r.clone)((0,n.defaults)(t));(0,r.merge)(u,o.inputs);const a=await e(u,h.inputs,h);p=a.inputs,this._parentSources=null!==(i=a.parentSources)&&void 0!==i?i:[]}if(void 0!==t&&t.cancelled)return Promise.reject(o.InsertionErrorCode.Cancelled);const _=this._insertStudy(h,p);return null===_?Promise.reject(o.InsertionErrorCode.Unknown):(await _.startPromise,_.study)}_insertStudy(e,t){return this._inserterImpl.createStudy(e,t,null,this._propsState,this._forceOverlay,this._parentSources,this._preferredPriceScale,this._allowChangeCurrency,this._allowChangeUnit,this._paneSize,this._targetPriceScaleMode)}_canApplyStudyToParent(e){return 0===this._parentSources.length||s.StudyMetaInfo.canBeChild(e)}}},53414:(e,t,i)=>{"use strict";i.d(t,{StudyLegendValuesProvider:()=>n});var s=i(54303),r=i(40484);class n{constructor(e,t){this._study=e,this._model=t,this._showStudyValues=t.properties().childs().paneProperties.childs().legendProperties.childs().showStudyValues,this._hhistBasedStudy=void 0!==e.metaInfo().graphics.hhists,this._valuesProvider=this._createValuesProvider(e,t)}getItems(){return this._valuesProvider.getItems()}getValues(e){const t=this._valuesProvider.getValues(e),i=this._study.properties(),s=this._showStudyValues.value()&&i.childs().showLegendValues.value(),r=e=>!!this._hhistBasedStudy||this._study.isPlotVisibleAt(e,8);for(const e of t)e.visible=e.visible&&s&&r(e.id);return t}_createValuesProvider(e,t){return this._hhistBasedStudy?new r.HHistBasedValuesProvider(e,t):new s.StudyValuesProvider(e,t)}}},99672:(e,t,i)=>{"use strict";i.d(t,{StudyStatusProviderBase:()=>l});var s=i(11877),r=i(13333),n=i(37591);const o={NONE:"Default"},a=!1;class l extends s.StatusProviderBase{constructor(e,t){super(t),this._source=e}getSplitTitle(){return this._source.titleInParts(n.TitleDisplayTarget.StatusLine,!0,o,void 0,a)}text(){ return this._source.isActualInterval()?this._source.isFailed()?`${this._source.title(n.TitleDisplayTarget.StatusLine,!0,o,void 0,a)}: ${this.sourceStatusText()}`:`${this._source.title(n.TitleDisplayTarget.StatusLine,!0,o,void 0,a)} ${this.sourceStatusText()}`:this._source.title(n.TitleDisplayTarget.StatusLine,!0,o,void 0,a)}sourceStatusText(){return(0,r.convertStudyStatusToString)(this._source.status(),!0)}errorStatus(){if(!this._source.isActualInterval()||this._source.isSymbolInvalid())return null;const e=this._source.status();return e.type===r.StudyStatusType.Error?{error:this.sourceStatusText(),solutionId:(0,r.studyStatusSolutionId)(e),title:(0,r.studyStatusTitle)(e),studyFeature:(0,r.studyStatusFeature)(e)}:null}}},6892:(e,t,i)=>{"use strict";i.d(t,{StudyStatusProvider:()=>n});var s=i(44352),r=(i(13333),i(99672));s.t(null,void 0,i(47542));class n extends r.StudyStatusProviderBase{constructor(e,t){super(e,t),this._study=e}color(){return this._study.isFailed()||this._study.metaInfo&&this._study.metaInfo().isTVScriptStub?"#ff0000":super.color()}sourceStatusText(){this._study.status();return super.sourceStatusText()}}},90830:(e,t,i)=>{"use strict";i.d(t,{StudyStatusView:()=>r});var s=i(79055);class r extends s.StatusView{constructor(e){super(e.statusProvider())}color(){return this._statusProvider.color()}getSplitTitle(){return this._statusProvider.getSplitTitle()}update(){this._text=this._statusProvider.text()}}},13333:(e,t,i)=>{"use strict";i.d(t,{StudyStatusType:()=>c,convertStudyStatusToString:()=>h,studyStatusFeature:()=>p,studyStatusSolutionId:()=>d,studyStatusTitle:()=>u});var s=i(44352);const r=new Map([["You cannot see this pivot timeframe on this resolution",s.t(null,void 0,i(17126))],["The data vendor doesn't provide volume data for this symbol.",s.t(null,void 0,i(29198))],['Histogram is too large, please increase "Row Size" input.',s.t(null,void 0,i(69085))],["Histogram is too large, please reduce 'Row Size' input.",s.t(null,void 0,i(8122))],["This script is invite-only. To request access, please contact its author.",s.t(null,void 0,i(74986))],["Volume Profile indicator available only on our upgraded plans.",s.t(null,void 0,i(61022))]]),n=s.t(null,void 0,i(16971)),o=new Map,a=new Map,l=s.t(null,void 0,i(30295));var c;function h(e,t){if(e.type===c.Loading)return t?l:"loading...";if(e.type===c.Error){const s=e.errorDescription,n=t?(i=s.error,r.get(i)||i):s.error;if(s.ctx){const e={};return Object.entries(s.ctx).forEach((([t,i])=>{e[t]=i.toString()})),n.format(e)}return n}var i;return""}function d(e){if(e.type===c.Error)return e.errorDescription.solution_id?e.errorDescription.solution_id:function(e){for(const t of Array.from(o.keys()))if(e.includes(t))return o.get(t)}(e.errorDescription.error)}function u(e){if(e.type===c.Error)return-1!==e.errorDescription.error.toLowerCase().indexOf("the data vendor doesn't provide volume data for this symbol.")?n:void 0}function p(e){const{errorDescription:{error:t}}=e;for(const[e,i]of a)if(t.startsWith(e))return i}!function(e){e[e.Undefined=0]="Undefined", e[e.Loading=1]="Loading",e[e.Completed=2]="Completed",e[e.Error=3]="Error"}(c||(c={}))},52329:(e,t,i)=>{"use strict";i.d(t,{StudyStub:()=>g});var s=i(91280),r=i(90830),n=i(80842),o=i(61146),a=i(57898),l=i(59452),c=i.n(l),h=i(99672),d=i(37591);class u extends h.StudyStatusProviderBase{text(){return this._source.isActualInterval()?`${this._source.title(d.TitleDisplayTarget.StatusLine)} ${this.sourceStatusText()}`:this._source.title(d.TitleDisplayTarget.StatusLine)}}var p=i(13333);class _{getItems(){return[]}getValues(e){return[]}}const m=new a.Delegate;class g extends n.PriceDataSource{constructor(e,t,i){super(e),this._priceStep=.01,this._status={type:p.StudyStatusType.Undefined},this._statusChanged=new a.Delegate,this._formatter=new o.PriceFormatter(100),this._origState=t,this._title=i;this._properties=new(c())({visible:!0}),this._statusView=new r.StudyStatusView(this)}barColorer(){return null}properties(){return this._properties}statusView(){return this._statusView}legendView(){return null}state(e){return this._origState}setStatus(e){const t=this.isDisplayedInLegend();if(this._status=e,this._statusChanged.fire(),this.isDisplayedInLegend()!==t){const e=this._model.paneForSource(this);if(e){const t=this._model.panes().indexOf(e),i=s.InvalidationMask.invalidateLegendWidgetLayout(t);this.model().invalidate(i)}}}formatter(){return this._formatter}name(){return this._title}title(){return this._title}titleInParts(){return[this._title]}isFailed(){return this._status.type===p.StudyStatusType.Error}isLoading(){return this._status.type===p.StudyStatusType.Loading}isDisplayedInLegend(){return this.isFailed()}setFailed(e){this.setStatus({type:p.StudyStatusType.Error,errorDescription:{error:e}}),this._model.updateSource(this)}isSymbolInvalid(){return!1}isActualInterval(){return!0}onIsActualIntervalChange(){return m}start(){}status(){return this._status}onStatusChanged(){return this._statusChanged}firstValue(){return null}currency(){return null}sessionId(){return this._model.mainSeries().sessionId()}sessionIdChanged(){return this._model.mainSeries().sessionIdChanged()}unit(){return null}symbolSource(){return this._model.mainSeries()}barsProvider(){return this._model.mainSeries()}valuesProvider(){return new _}statusProvider(e){return new u(this,this._model.properties().childs().scalesProperties.childs().textColor)}}},54303:(e,t,i)=>{"use strict";i.d(t,{StudyValuesProvider:()=>S});var s=i(50335),r=i(49483),n=i(87095),o=i(14483),a=i(86094),l=i(15367),c=i(88348),h=i(72877),d=i(41726),u=i(92052),p=i(50151),_=i(88546),m=i(37591);const g=r.CheckMobile.any(),f=o.enabled("hide_last_na_study_output"),v=o.enabled("always_show_legend_values_on_mobile");class S{constructor(e,t){this._emptyValues=[],this._colorProviders=new Map,this._study=e,this._model=t,this._studyMetaInfo=this._study.metaInfo(),this._studyProperties=this._study.properties().childs(),this._isFundamental=!1;const i=this._studyMetaInfo.plots;i&&i.forEach(((e,t)=>{if((0,h.isPlotWithTechnicalValues)(e))return;const i=e.id;this._emptyValues.push(function(e,t="",i=""){return{id:t, -index:e,title:i,value:"",visible:!1}}(t,i,this._study.guiPlotName(m.TitleDisplayTarget.StatusLine,i)));const s=(0,h.isOhlcPlot)(e)?e.target:i;this._colorProviders.set(s,(0,d.createStudyPlotColorProvider)(this._studyMetaInfo,this._study.properties(),s))}))}getItems(){return this._emptyValues}getPlotColor(e,t){var i;const r=t[e+1];if(!(0,s.isNumber)(r))return"";const n=r>0;let o;const a=this._studyMetaInfo.plots[e];let l=a.id;const c=this._studyProperties;if((0,h.isOhlcPlot)(a))l=a.target||l,o=(0,p.ensureDefined)(c.ohlcPlots.childs()[l].childs().color).value();else if((0,h.isArrowsPlot)(a)){const e=(0,p.ensureDefined)(c.styles.childs()[l]);o=n?e.childs().colorup.value():e.childs().colordown.value()}else o=(0,p.ensureDefined)(null===(i=c.styles.childs()[l])||void 0===i?void 0:i.child("color")).value();let d=o;const u=this._colorProviders.get(l),_=u&&u.getPlotPointStyle(t);return _&&((0,h.isArrowsPlot)(a)?(n&&void 0!==_.colors[5]&&(d=_.colors[5]),n||void 0===_.colors[6]||(d=_.colors[6])):void 0!==_.colors[0]&&(d=_.colors[0])),"transparent"===d&&(d=o),d}getValues(e){var t,i;const r=this._emptyValues.map((e=>({...e})));let o=null;const l=this._study.data().lastIndex(),c=this._studyProperties;if(null!==l)for(const e of r){if(0===(null===(t=c.styles.childs()[e.id])||void 0===t?void 0:t.childs().display.value()))continue;const i=this._study.nearestIndex(l,a.PlotRowSearchMode.NearestLeft,e.index+1);if(void 0===i)continue;const s=i+this._study.offset(e.id);o=null!==o?Math.max(s,o):s}(null===e||null!==o&&e>o)&&(e=o);const d=this._hideValues(),m=this._study.isVisible()&&!d?_.notAvailable:"";for(const e of r)e.value=m;if(d)return r;f&&r.length&&(r[r.length-1].value="");const g=this._study.priceScale();if(!this._study.isVisible()||null===e||null===g||g.isEmpty()||this._model.timeScale().isEmpty())return r;const v=(0,u.getPriceValueFormatterForSource)(this._study),S={};for(const t of r){const r=t.id,o=(0,p.ensureDefined)(c.styles.childs()[r]),d=o.childs().display.value();if(t.visible=0!==d,!t.visible)continue;const u=o.hasChild("plottype")?null===(i=o.child("plottype"))||void 0===i?void 0:i.value():null,_=this._isFundamental&&(u===h.LineStudyPlotStyle.StepLine||u===h.LineStudyPlotStyle.StepLineWithDiamonds),m=t.index,g=e-this._study.offset(r),f=_||null!==l&&g>l?a.PlotRowSearchMode.NearestLeft:a.PlotRowSearchMode.Exact,y=this._study.nearestIndex(g,f);if(void 0===y)continue;let b=S[r];if(void 0===b&&(b=this._study.getMinFirstBarIndexForPlot(r),Number.isFinite(b)&&(S[r]=b)),b>y)continue;const w=this._study.data().last(),P=this._study.data().valueAt(y)||(null!==w?w.value:null);if(null===P)continue;const C=P[m+1];(0,s.isNumber)(C)&&(t.value=v(C),t.color=(0,n.resetTransparency)(this.getPlotColor(m,P)))}return r}_hideValues(){return v?(0,l.isLineToolName)(c.tool.value())||null!==this._model.lineBeingEdited():g&&(null===this._model.crossHairSource().pane||(0,l.isLineToolName)(c.tool.value())||null!==this._model.lineBeingEdited())}}},76949:(e,t,i)=>{"use strict";i.d(t,{StudyBase:()=>Ft,prepareStudyProperties:()=>Vt, -prepareStudyPropertiesForLoadChart:()=>Nt});var s=i(16230),r=i(27788),n=i(50151),o=i(44352),a=i(59224),l=i(49483),c=i(21866),h=i(57898),d=i(1115),u=i(80842),p=i(34256),_=i(97034),m=i(42856),g=i(12442),f=i(86094),v=i(95586),S=i(70512),y=i(53414),b=i(72877);class w extends S.StudyBaseWindowView{constructor(e,t){super(e,t),this._showStudyValues=t.properties().childs().paneProperties.childs().legendProperties.childs().showStudyValues,this._showStudyValues.subscribe(this,this.update);const i=this._study.properties();i.childs().showLegendValues.subscribe(this,this.update);const s=this._study.metaInfo().plots,r=new Set;s.forEach((e=>{var t;if((0,b.isOhlcPlot)(e)){const t=e.target;if(r.has(t))return;r.add(t),i.childs().ohlcPlots.childs()[t].childs().display.subscribe(this,this.update)}else(0,b.isPlotSupportDisplay)(e)&&(null===(t=i.childs().styles.childs()[e.id])||void 0===t||t.childs().display.subscribe(this,this.update))}))}areValuesVisible(){return this._showStudyValues.value()}additional(){return null}destroy(){this._showStudyValues.unsubscribeAll(this);const e=this._study.properties();e.childs().showLegendValues.unsubscribeAll(this);const t=this._study.metaInfo().plots,i=new Set;t.forEach((t=>{var s;if((0,b.isOhlcPlot)(t)){const s=t.target;if(i.has(s))return;i.add(s),e.childs().ohlcPlots.childs()[s].childs().display.unsubscribe(this,this.update)}else(0,b.isPlotSupportDisplay)(t)&&(null===(s=e.childs().styles.childs()[t.id])||void 0===s||s.childs().display.unsubscribe(this,this.update))}))}_createValuesProvider(e,t){return new y.StudyLegendValuesProvider(e,t)}}var P=i(88348),C=i(90830),x=i(27856),T=i(19171),I=i(1803),M=i(6892),L=i(59452),A=i.n(L),k=i(1722),D=i(87663);i(37591);function V(e,t){return e.studyId.localeCompare(t.studyId)}function E(e){const t=new Set,i=[];return e.forEach((e=>{t.has(e.studyId)||(t.add(e.studyId),i.push(e))})),i}function B(e){const t=e.model().mainSeries();return{studyId:(0,n.ensureNotNull)(e.sourceId()),turnaround:e.turnaround(),sourceStudies:e.parentSources().filter((e=>e!==t)).map((e=>B(e)))}}var R=i(33703),N=i(14483),O=i(86441),F=i(87095),W=i(19266),H=i(59590);class z extends H.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){return null}_drawImpl(e){}_drawBackgroundImpl(e){const{context:t,horizontalPixelRatio:i,bitmapSize:s}=e,r=this._data;let n=null;const o=Math.round(this._data.barSpacing*i);for(let e=0;e0){r.items[e-1].index===a.index-1&&null!==n&&(c=n+1)}const h=l+o,d=h-c+1;t.fillRect(c,0,d,s.height),n=h}}}var U=i(41726);class j{constructor(e,t,i,s){this._items=[],this._invalidated=!0,this._isMarkersEnabled=N.enabled("source_selection_markers"),this._study=e,this._series=t,this._model=i,this._plotName=s;const r=this._study.metaInfo().plots;for(let e=0;e0;let o;const a=this._studyMetaInfo.plots[e];let l=a.id;const c=this._studyProperties;if((0,h.isOhlcPlot)(a))l=a.target||l,o=(0,p.ensureDefined)(c.ohlcPlots.childs()[l].childs().color).value();else if((0,h.isArrowsPlot)(a)){const e=(0,p.ensureDefined)(c.styles.childs()[l]);o=n?e.childs().colorup.value():e.childs().colordown.value()}else o=(0,p.ensureDefined)(null===(i=c.styles.childs()[l])||void 0===i?void 0:i.child("color")).value();let d=o;const u=this._colorProviders.get(l),_=u&&u.getPlotPointStyle(t);return _&&((0,h.isArrowsPlot)(a)?(n&&void 0!==_.colors[5]&&(d=_.colors[5]),n||void 0===_.colors[6]||(d=_.colors[6])):void 0!==_.colors[0]&&(d=_.colors[0])),"transparent"===d&&(d=o),d}getValues(e){var t,i;const r=this._emptyValues.map((e=>({...e})));let o=null;const l=this._study.data().lastIndex(),c=this._studyProperties;if(null!==l)for(const e of r){if(0===(null===(t=c.styles.childs()[e.id])||void 0===t?void 0:t.childs().display.value()))continue;const i=this._study.nearestIndex(l,a.PlotRowSearchMode.NearestLeft,e.index+1);if(void 0===i)continue;const s=i+this._study.offset(e.id);o=null!==o?Math.max(s,o):s}(null===e||null!==o&&e>o)&&(e=o);const d=this._hideValues(),m=this._study.isVisible()&&!d?_.notAvailable:"";for(const e of r)e.value=m;if(d)return r;f&&r.length&&(r[r.length-1].value="");const g=this._study.priceScale();if(!this._study.isVisible()||null===e||null===g||g.isEmpty()||this._model.timeScale().isEmpty())return r;const v=(0,u.getPriceValueFormatterForSource)(this._study),S={};for(const t of r){const r=t.id,o=(0,p.ensureDefined)(c.styles.childs()[r]),d=o.childs().display.value();if(t.visible=0!==d,!t.visible)continue;const u=o.hasChild("plottype")?null===(i=o.child("plottype"))||void 0===i?void 0:i.value():null,_=this._isFundamental&&(u===h.LineStudyPlotStyle.StepLine||u===h.LineStudyPlotStyle.StepLineWithDiamonds),m=t.index,g=e-this._study.offset(r),f=_||null!==l&&g>l?a.PlotRowSearchMode.NearestLeft:a.PlotRowSearchMode.Exact,y=this._study.nearestIndex(g,f);if(void 0===y)continue;let b=S[r];if(void 0===b&&(b=this._study.getMinFirstBarIndexForPlot(r),Number.isFinite(b)&&(S[r]=b)),b>y)continue;const w=this._study.data().last(),P=this._study.data().valueAt(y)||(null!==w?w.value:null);if(null===P)continue;const C=P[m+1];(0,s.isNumber)(C)&&(t.value=v(C),t.color=(0,n.resetTransparency)(this.getPlotColor(m,P)))}return r}_hideValues(){return v?(0,l.isLineToolName)(c.tool.value())||null!==this._model.lineBeingEdited():g&&(null===this._model.crossHairSource().pane||(0,l.isLineToolName)(c.tool.value())||null!==this._model.lineBeingEdited())}}},76949:(e,t,i)=>{"use strict";i.d(t,{StudyBase:()=>Ft,prepareStudyProperties:()=>Et, +prepareStudyPropertiesForLoadChart:()=>Nt});var s=i(16230),r=i(27788),n=i(50151),o=i(44352),a=i(59224),l=i(49483),c=i(21866),h=i(57898),d=i(1115),u=i(80842),p=i(34256),_=i(97034),m=i(42856),g=i(12442),f=i(86094),v=i(95586),S=i(70512),y=i(53414),b=i(72877);class w extends S.StudyBaseWindowView{constructor(e,t){super(e,t),this._showStudyValues=t.properties().childs().paneProperties.childs().legendProperties.childs().showStudyValues,this._showStudyValues.subscribe(this,this.update);const i=this._study.properties();i.childs().showLegendValues.subscribe(this,this.update);const s=this._study.metaInfo().plots,r=new Set;s.forEach((e=>{var t;if((0,b.isOhlcPlot)(e)){const t=e.target;if(r.has(t))return;r.add(t),i.childs().ohlcPlots.childs()[t].childs().display.subscribe(this,this.update)}else(0,b.isPlotSupportDisplay)(e)&&(null===(t=i.childs().styles.childs()[e.id])||void 0===t||t.childs().display.subscribe(this,this.update))}))}areValuesVisible(){return this._showStudyValues.value()}additional(){return null}destroy(){this._showStudyValues.unsubscribeAll(this);const e=this._study.properties();e.childs().showLegendValues.unsubscribeAll(this);const t=this._study.metaInfo().plots,i=new Set;t.forEach((t=>{var s;if((0,b.isOhlcPlot)(t)){const s=t.target;if(i.has(s))return;i.add(s),e.childs().ohlcPlots.childs()[s].childs().display.unsubscribe(this,this.update)}else(0,b.isPlotSupportDisplay)(t)&&(null===(s=e.childs().styles.childs()[t.id])||void 0===s||s.childs().display.unsubscribe(this,this.update))}))}_createValuesProvider(e,t){return new y.StudyLegendValuesProvider(e,t)}}var P=i(88348),C=i(90830),x=i(27856),T=i(19171),I=i(1803),M=i(6892),L=i(59452),A=i.n(L),k=i(1722),D=i(87663);i(37591);function E(e,t){return e.studyId.localeCompare(t.studyId)}function V(e){const t=new Set,i=[];return e.forEach((e=>{t.has(e.studyId)||(t.add(e.studyId),i.push(e))})),i}function B(e){const t=e.model().mainSeries();return{studyId:(0,n.ensureNotNull)(e.sourceId()),turnaround:e.turnaround(),sourceStudies:e.parentSources().filter((e=>e!==t)).map((e=>B(e)))}}var R=i(33703),N=i(14483),O=i(86441),F=i(87095),W=i(19266),H=i(59590);class z extends H.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){return null}_drawImpl(e){}_drawBackgroundImpl(e){const{context:t,horizontalPixelRatio:i,bitmapSize:s}=e,r=this._data;let n=null;const o=Math.round(this._data.barSpacing*i);for(let e=0;e0){r.items[e-1].index===a.index-1&&null!==n&&(c=n+1)}const h=l+o,d=h-c+1;t.fillRect(c,0,d,s.height),n=h}}}var U=i(41726);class j{constructor(e,t,i,s){this._items=[],this._invalidated=!0,this._isMarkersEnabled=N.enabled("source_selection_markers"),this._study=e,this._series=t,this._model=i,this._plotName=s;const r=this._study.metaInfo().plots;for(let e=0;e0?(i-=r,s+=r):(i+=r,s-=r);const o=this._study.getMinFirstBarIndexForPlot(this._plotName);if(o>s)return;i=Math.max(o,i);const a=this._study.data().rangeIterator(i,s);for(;a.hasNext();){const e=a.next();let i=e.index;const s=e.value;i+=r;const o=new O.Point(Math.floor(i)-.5,NaN);let l=(0,k.isNumber)(t)?t:50;l=Math.min(l,100),l=Math.max(l,0);const c=this._colorProvider.getPlotPointStyle(s);void 0!==c.colors[1]&&(o.color=(0,F.generateColor)((0,n.ensureDefined)(c.colors[1]),l)),o.index=i,this._items.push(o)}this._model.timeScale().timedValuesToCoordinates(this._items)}}var G,q,$=i(54358),Y=i(80101),K=i(76058),Z=i(37160),X=i(18807),J=i(57490),Q=i(13497),ee=i(96759),te=i(34026),ie=i(50146),se=i(29764),re=i(27714),ne=i(74359);!function(e){e.Left="left",e.Right="right",e.Center="center"}(G||(G={})),function(e){e.Top="top",e.Bottom="bottom",e.Middle="middle"}(q||(q={}));const oe=(0,ne.createDisconnectedCanvas)(document,(0,re.size)({width:0,height:0}),1);class ae{constructor(e,t,i,s,r,o="center",a=0){this._lines=e.split(/[^\S\r\n]*(?:\r\n|\r|\n)/),this._font=function(e,t,i,s){return(0,se.makeFont)(s,i,`${e?"bold ":""}${t?"italic ":""}`)}(t,i,s,r),this._fontSize=r,this._verticalPadding=~~(r/6),this._textAlign=o,this._lineSpacing=a;const l=(0,n.ensureNotNull)(oe.getContext("2d"));l.font=this._font,l.textBaseline="top";let c=0;for(let e=0;e{for(const t of this._lines)n.strokeStyle&&e.strokeText(t,o,a),e.fillText(t,o,a),a+=this._fontSize,a+=this._lineSpacing})),e.restore()}}class le extends ie.AbstractMapContainer{constructor(e){super(),this._maxSize=e,this._keysQueue=[]}get(e){const{fontSize:t,text:i,align:s,font:r,lineSpacing:n=0}=e;if(!i||!t||!s)return null;const o=(0,se.makeFont)(t,r),a=(0,ie.getDefault3)(this._map,n,s,o,new Map);let l=a.get(i);return void 0!==l||(this._size>=this._maxSize?this._deleteFirstKey():++this._size,this._keysQueue.push([o,s,n,i]),l=new ae(i,e.bold,e.italic,r,t,s,n),a.set(i,l)),l}_deleteFirstKey(){const e=this._keysQueue.shift(),[t,i,s,r]=e,o=(0,n.ensureDefined)(this._map.get(s)),a=(0,n.ensureDefined)(o.get(i)),l=(0,n.ensureDefined)(a.get(t));l.delete(r),0===l.size&&a.delete(t),0===a.size&&o.delete(i),0===o.size&&this._map.delete(s)}}var ce=i(46501);class he{constructor(e,t={skipRenderingOptimizations:!1}){this._items=[],this._barSpacing=0,this._vertOffset=0,this._textCache=t.textCache||new le(5e3),this._drawOperation=t.skipRenderingOptimizations?this._drawWithoutOptimizations.bind(this):this._drawWithOptimizations.bind(this),null!==e&&this.setData(e)}draw(e,t){this._preDrawInit(),this._drawOperation(e,t)}hitTest(e){const t=X.HitTarget.Regular;let i=null;for(const s of this._items){if(!s)continue;const r=this._calcBoundingBox(s);if(r&&(0,te.pointInBox)(e,r)){const e={tooltip:this._getTooltip(s,r)};i=new X.HitTestResult(t,e)}}return i}setData(e){this._height=void 0!==e.height?e.height:e.width,this._width=void 0!==e.width?e.width:e.height,this._color=e.color,this._borderColor=e.borderColor,this._vertOffset=e.vertOffset||0,e.text&&(this._text=e.text,this._fontSize=e.fontSize,this._lineSpacing=e.lineSpacing,this._textColor=e.textColor,this._textAlign=e.textAlign||"center"),void 0!==e.items&&void 0!==e.barSpacing&&this.setItems(e.items,e.barSpacing)}setItems(e,t){this._setBaseData(e,t)}_calcBoundingBox(e){const t=e.vertOffset,i=this._getTextCache(e);if(!i)return;const s=i.textImageWidth,r=i.textImageHeight,n=s/2,o=e.y+t+e.textVertOffset,a=t>0?0:-r,l=t>0?r:0,c=new O.Point(e.x-n,o+a),h=new O.Point(e.x+n,o+l);return(0,O.box)(c,h)}_unionBox(e,t){const i=Math.min(e.min.x,t.min.x),s=Math.max(e.max.x,t.max.x),r=Math.min(e.min.y,t.min.y),n=Math.max(e.max.y,t.max.y),o=new O.Point(i,r),a=new O.Point(s,n);return(0,O.box)(o,a)}_getTooltip(e,t){if(e.tooltip)return{content:{type:"text",data:e.tooltip},tooltipDelay:200, extendMargin:!0,rect:{x:t.min.x,y:t.min.y,w:Math.abs(t.max.x-t.min.x),h:Math.abs(t.max.y-t.min.y)}}}_setBaseData(e,t){this._items.length=0,this._barSpacing=t;for(const t of e){const e=void 0===t.width?(0,n.ensureDefined)(this._width):t.width,i=void 0===t.height?(0,n.ensureDefined)(this._height):t.height,s=void 0===t.vertOffset?this._vertOffset:t.vertOffset,r=s>0?i:-i;this._items.push({width:e,height:i,vertOffset:s,textVertOffset:r,shapeWidth:0,shapeHeight:0,stepX:0,stepY:0,...t})}}_drawItemText(e,t,i){const s=this._getTextCache(i);if(null===s)return;const r=i.x,n=i.vertOffset,o=i.y+n+i.textVertOffset;let a;a=i.style&&void 0!==i.style.textColor?i.style.textColor:this._textColor;const l={style:{fillStyle:a},location:{x:r,y:o,horzAlign:G.Center,vertAlign:n>0?q.Top:q.Bottom}};s.paintTo(e,t,l)}_drawWithOptimizations(e,t){let i,s,r=null,n=!1;for(const o of this._items)o.style&&void 0!==o.style.color?(i=o.style.color||"rgba(0, 0, 0, 0)",s=o.style.borderColor||"rgba(0, 0, 0, 0)"):(i=this._color,s=this._borderColor),(r!==i||l.isSafari)&&(r=i,n&&this._endPath(e),this._startPath(e,t,i,s)),this._drawItemShape(e,t,o),n=!0;n&&this._endPath(e);for(const i of this._items)this._drawItemText(e,t,i)}_drawWithoutOptimizations(e,t){let i,s;for(const r of this._items){const o=(0,n.ensureDefined)(r.style);i=o.color||"rgba(0, 0, 0, 0)",s=o.borderColor||"rgba(0, 0, 0, 0)",this._startPath(e,t,i,s),this._drawItemShape(e,t,r),this._endPath(e),this._drawItemText(e,t,r)}}_drawItemShape(e,t,i){(0,ne.drawScaled)(e,t.pixelRatio,t.pixelRatio,(()=>this._drawItemShapeUsingCSSPixels(e,i)))}_drawItemShapeUsingCSSPixels(e,t){}_preDrawInit(){}_startPath(e,t,i,s){}_endPath(e){}_getTextCache(e){var t,i;const s=e.text||this._text,r=e.fontSize||this._fontSize,n=null!==(t=e.lineSpacing)&&void 0!==t?t:this._lineSpacing,o=e.textAlign||this._textAlign,a=null!==(i=e.font)&&void 0!==i?i:ce.CHART_FONT_FAMILY;return this._textCache.get({text:s,bold:!1,italic:!1,font:a,fontSize:r,lineSpacing:n,align:o})}}class de extends he{_startPath(e,t,i,s){e.beginPath(),e.lineWidth=this._lineWidth(t),e.lineCap="butt",e.strokeStyle=i}_endPath(e){e.stroke()}_lineWidth(e){return Math.max(1,Math.floor(2*e.pixelRatio))}}class ue extends he{_startPath(e,t,i,s){e.beginPath(),e.lineWidth=this._lineWidth(t),e.lineCap="butt",e.fillStyle=i,e.strokeStyle=s}_endPath(e){e.fill(),e.stroke()}_lineWidth(e){return Math.max(1,Math.floor(e.pixelRatio))}}class pe extends ue{constructor(){super(...arguments),this._sign=0,this._thinArrow=!1,this._thinArrowLineWidth=0,this._headHeight=0,this._arrowWidth=0}setItems(e,t){this._setBaseData(e,t)}_drawItemShape(e,t,i){const s=t.pixelRatio,r=this._lineWidth(t)%2?.5:0,n=this._sign,o=this._arrowWidth,a=this._headHeight,l=Math.abs(i.height),c=Math.round(i.x*s)+r,h=i.vertOffset,d=Math.round((i.y+h+n*l/2)*s)+r,u=(0,Z.ceiledEven)(o*s),p=u/2,_=Math.round(l*s),m=Math.round(a*s);e.translate(c,d),this._thinArrow?(e.moveTo(0,0),e.lineTo(-p,-p*n),e.moveTo(0,0),e.lineTo(p,-p*n),e.moveTo(0,0),e.lineTo(0,-_*n),e.moveTo(-p,-_*n),e.lineTo(p,-_*n)):(e.moveTo(0,0), @@ -758,14 +758,14 @@ return e.shapeHeight/2+this._getArrowSize(e)}_calcVertOffset(e){return Math.sign if(this._colorProvider.isColorDefined()){n.style={color:x,borderColor:T,textColor:I};const e=this._colorProvider.getPlotPointStyle(i,L);this._fillItemWithPointStyle(n,e,d)}p&&-1!==u.indexOf(t)&&null!==this._selectionData&&(this._selectionData.points.push(n),this._selectionData.bgColors.push(this._model.backgroundColorAtYPercentFromTop(n.y/b))),this._items.push(n)}}this._convertItemsToCoordinates()}_fillItemWithPointStyle(e,t,i){const s=(0,n.ensureDefined)(e.style);if(void 0!==t.colors[0]){s.color=(0,F.generateColor)((0,n.ensureDefined)(t.colors[0]),i);const e=i>9?i-10:0;s.borderColor=(0,F.generateColor)(s.color,e)}void 0!==t.colors[2]&&(s.textColor=(0,F.generateColor)((0,n.ensureDefined)(t.colors[2]),i))}_updateRenderer(e){this._updateImpl();const t=this._model.timeScale(),i={},s=this._getTranspValue(),r=t.barSpacing(),n=this._calculateShapeHeight(r),o=this._study.properties().childs().styles.childs()[this._plotName].childs(),a=o.location.value(),l=this._calculateVerticalOffset(a,n+n/2);i.barSpacing=r,i.items=this._items,i.color=(0,F.generateColor)(o.color.value(),s),i.height=n,i.vertOffset=l;const c=o.plottype.value(),h=K.plotShapesData[c],d=new W.CompositeRenderer;h&&d.append(this._createRenderer(h.paneRendererClass,i)),this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&null!==this._selectionData&&(this._selectionData.vertOffset=l,d.append(new Y.SelectionRenderer(this._selectionData))),this._renderer=d}_createRenderer(e,t){const i=Se.get(e);return new((0,n.ensureDefined)(i))(t)}_getSeriesVal(e,t){const i=(0,Q.barFunction)(e),s=this._series.data().valueAt(t);return null===s?null:i(s)}_getTranspValue(){let e=0;const t=this._study.properties().childs();t.transparency&&(e=t.transparency.value(),e=(0,k.isNumber)(e)?e:50);const i=t.styles.childs()[this._plotName].childs();return i.transparency&&(e=i.transparency.value(),e=(0,k.isNumber)(e)?e:50),(0,Z.clamp)(e,0,100)}_createItem(e,t,i,s){const r=this._study.properties().childs().styles.childs()[this._plotName].childs().location.value();if((null===t||0===t)&&r!==v.MarkLocation.Absolute)return null;let o;switch(r){case v.MarkLocation.AboveBar:const a=this._getSeriesVal(i,e);if(null===a)return null;o=a;break;case v.MarkLocation.BelowBar:const l=this._getSeriesVal(s,e);if(null===l)return null;o=l;break;case v.MarkLocation.Top:o=this._topCoord;break;case v.MarkLocation.Bottom:o=this._bottomCoord;break;case v.MarkLocation.Absolute:o=(0,n.ensureNotNull)(t);break;default:throw new Error("Bad value: "+r)}return new O.Point(e,o)}_convertItemsToCoordinates(){const e=this._model.timeScale(),t=this._study.priceScale();e.timedValuesToCoordinates(this._items);const i=(0,n.ensureNotNull)(this._study.firstValue());(0,n.ensureNotNull)(t).pointsArrayToCoordinates(this._items,i)}_calculateVerticalOffset(e,t){let i=0;switch(e){case v.MarkLocation.AboveBar:case v.MarkLocation.Bottom:i=-t;break;case v.MarkLocation.BelowBar:case v.MarkLocation.Top:i=t}return(0,n.ensureNotNull)(this._study.priceScale()).isInverted()&&(i*=-1),i}_calculateShapeHeight(e,t){let i=e;switch(t){ case b.PlotSymbolSize.Tiny:i=.3*e;break;case b.PlotSymbolSize.Small:i=.6*e;break;case b.PlotSymbolSize.Normal:i=e;break;case b.PlotSymbolSize.Large:i=1.5*e;break;case b.PlotSymbolSize.Huge:i=2*e}return i}}class be extends ye{_updateRenderer(e){const t=e.childs();this._updateImpl();const i=this._model.timeScale(),s={},r=this._getTranspValue(),n=i.barSpacing();let o;o=this._plotStyleInfo.size?this._calculateShapeHeight(25,this._plotStyleInfo.size):Math.round(n/2),o=Math.max(o,1);const a=t.location.value(),l=(0,F.generateColor)(t.color.value(),r),c=r>19?r-10:0,h=this._calculateVerticalOffset(a,Math.round(1.5*o));s.barSpacing=n,s.items=this.items(),s.color=l,s.borderColor=(0,F.generateColor)(t.color.value(),c),s.height=o,s.vertOffset=h;const d=t.plottype.value(),u=K.plotShapesData[d],p=new W.CompositeRenderer,_=this._plotStyleInfo.text;if(void 0!==_&&""!==_.trim()){let e=_.trim().replace(/\\n/gm,"\n");e=(0,$.cleanButAmpersand)(e,!0),s.text=e,s.fontSize=12;const i=t.textColor?t.textColor.value():void 0;s.textColor=i?(0,F.generateColor)(i,r):l}p.append(super._createRenderer(u.paneRendererClass,s)),this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&null!==this._selectionData&&(this._selectionData.vertOffset=h,p.append(new Y.SelectionRenderer(this._selectionData))),this._renderer=p}}var we=i(87795),Pe=i.n(we),Ce=i(45197);class xe extends he{constructor(e,t){super(null,t),this._fontSizeEnsured=0,this._ch="",this._fontFamily=ce.CHART_FONT_FAMILY,this._charCache=null,null!==e&&this.setData(e)}setData(e){super.setData(e),this._fontSizeEnsured=(0,n.ensureDefined)(this._height);const t=e.char.slice(0,40);this._ch=Pe()(t)[0]||" ",this._fontFamily=e.fontFamily||ce.CHART_FONT_FAMILY}hitTest(e){const t=(0,Ce.interactionTolerance)().series+this._fontSizeEnsured/2;for(const i of this._items){if(new O.Point(i.x,i.y+i.vertOffset).subtract(e).length()<=t)return new X.HitTestResult(X.HitTarget.Regular)}return null}_drawItemShape(e,t,i){const s=i.x,r=i.vertOffset>0?1:-1,n=i.y+i.vertOffset-r*Math.round(this._fontSizeEnsured/2);let o;o=i.style&&void 0!==i.style.color?i.style.color:this._color;const a=this._textImageCache(),l=t.pixelRatio;if(this._fontSizeEnsured<=4/l){e.save();const t=Math.max(1,Math.floor(l));let r=Math.max(1,Math.floor(a.textImageWidth*l));r%2!=t%2&&(r+=r>1?-1:1);const c=Math.round(n*l)+(i.vertOffset>=0?0:-r);return e.fillStyle=o,e.fillRect(Math.round(s*l)+(l%2?.5:0)-r/2,c,r,r),void e.restore()}const c={style:{fillStyle:o},location:{x:s,y:n,horzAlign:G.Center,vertAlign:i.vertOffset>0?q.Top:q.Bottom}};a.paintTo(e,t,c)}_startPath(e,t,i,s){}_endPath(e){}_textImageCache(){return null!==this._charCache&&this._charCache.fontFamily===this._fontFamily&&this._charCache.fontSize===this._fontSizeEnsured||(this._charCache={fontSize:this._fontSizeEnsured,fontFamily:this._fontFamily,cache:new ae(this._ch,!1,!1,this._fontFamily,this._fontSizeEnsured,"center",0)}),this._charCache.cache}}class Te extends ye{constructor(){super(...arguments),this._compositeRenderer=new W.CompositeRenderer,this._charRenderer=new xe(null)} renderer(){return this._isPlotVisible()&&this._scalesReady()?(this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._compositeRenderer):null}_updateImpl(){var e,t;if(this._compositeRenderer.clear(),super._updateImpl(),0===this._items.length)return;const i=this._getTranspValue(),s=this._model.timeScale().barSpacing();let r;const o=this._study.properties().childs().styles.childs()[this._plotName].childs();r=this._plotStyleInfo.size?this._calculateShapeHeight(50,this._plotStyleInfo.size):Math.round(s);const a=o.location.value(),l=(0,F.generateColor)(o.color.value(),i),c=this._calculateVerticalOffset(a,r),h={items:this.items(),barSpacing:s,char:(0,n.ensureDefined)(null!==(t=null===(e=o.char)||void 0===e?void 0:e.value())&&void 0!==t?t:this._plotStyleInfo.char),height:r,vertOffset:c,color:l},d=this._plotStyleInfo.text;if(void 0!==d&&""!==d.trim()){let e=d.trim().replace(/\\n/gm,"\n");e=(0,$.cleanButAmpersand)(e,!0),h.text=e,h.fontSize=12;const t=o.textColor?o.textColor.value():void 0;h.textColor=t?(0,F.generateColor)(t,i):l}this._charRenderer.setData(h),this._compositeRenderer.append(this._charRenderer),this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&null!==this._selectionData&&(this._selectionData.vertOffset=c,this._compositeRenderer.append(new Y.SelectionRenderer(this._selectionData)))}}var Ie=i(24377);class Me extends O.Point{constructor(e,t,i,s){super(e,t),this.height=i,this.isUp=s,this.style={}}}function Le(e){return Math.round(e/4)}function Ae(e){return Math.round(e/2)}class ke extends H.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){const t=this._data,i=Ae(t.barSpacing),s=Math.round(i/2),r=Math.round(i),n=Le(t.barSpacing);for(const i of t.items){if(!i)continue;if(!Number.isFinite(i.x)||!Number.isFinite(i.y))continue;const t=Math.abs(i.height),o=i.isUp?-1:1,a=t+r,l=i.y-o*n,c=l-o*a,h=i.x-s,d=i.x+s;if(hthis._maxAbsValue&&(this._maxAbsValue=Math.abs(t));const r=t>0;let n;if(r){const t=this._getSeriesVal(s,e);if(null===t)return null;n=t}else{const t=this._getSeriesVal(i,e);if(null===t)return null;n=t}return new Me(e,n,t,r)}_convertItemsToCoordinates(){var e,t,i,s;const r=this._model.timeScale(),o=(0,n.ensureNotNull)(this._study.priceScale());r.timedValuesToCoordinates(this._items),o.pointsArrayToCoordinates(this._items,(0,n.ensureNotNull)(this._study.firstValue()));const a=this._study.properties().childs().styles.childs();let l=Math.abs((0,n.ensureDefined)(null!==(t=null===(e=a[this._plotName].childs().minHeight)||void 0===e?void 0:e.value())&&void 0!==t?t:this._plotStyleInfo.minHeight)),c=Math.abs((0,n.ensureDefined)(null!==(s=null===(i=a[this._plotName].childs().maxHeight)||void 0===i?void 0:i.value())&&void 0!==s?s:this._plotStyleInfo.maxHeight));if(l>c){const e=l;l=c,c=e}const h=(c-l)/this._maxAbsValue,d=this._items;for(let e=0;ethis._maxAbsValue&&(this._maxAbsValue=Math.abs(t));const r=t>0;let n;if(r){const t=this._getSeriesVal(s,e);if(null===t)return null;n=t}else{const t=this._getSeriesVal(i,e);if(null===t)return null;n=t}return new Me(e,n,t,r)}_convertItemsToCoordinates(){var e,t,i,s;const r=this._model.timeScale(),o=(0,n.ensureNotNull)(this._study.priceScale());r.timedValuesToCoordinates(this._items),o.pointsArrayToCoordinates(this._items,(0,n.ensureNotNull)(this._study.firstValue()));const a=this._study.properties().childs().styles.childs();let l=Math.abs((0,n.ensureDefined)(null!==(t=null===(e=a[this._plotName].childs().minHeight)||void 0===e?void 0:e.value())&&void 0!==t?t:this._plotStyleInfo.minHeight)),c=Math.abs((0,n.ensureDefined)(null!==(s=null===(i=a[this._plotName].childs().maxHeight)||void 0===i?void 0:i.value())&&void 0!==s?s:this._plotStyleInfo.maxHeight));if(l>c){const e=l;l=c,c=e}const h=(c-l)/this._maxAbsValue,d=this._items;for(let e=0;es)return;i=Math.max(r,i);const o=this._study.data(),a=this._study.firstValue();if(null===a)return;const l=o.rangeIterator(i,s),c=(0,n.ensureDefined)(this._study.properties().childs().ohlcPlots).childs()[this._plotName].childs(),h=new Map,d=(e,t)=>{const i=e+"@"+t;if(!h.has(i)){const s=(0,F.generateColor)(e,t);return h.set(i,s),s}return h.get(i)},u=(0,ee.createEmptyStyle)();for(;l.hasNext();){const e=l.next();let t=e.index;const i=e.value;t=Math.floor(t);let s=!0;const r=new Map;for(let e=1;e<=4;++e){const t=this._ohlcPlotIndexes.get(e);if(void 0===t){s=!1;break}const n=i[t+1];if(null==n){s=!1;break}r.set(e,n)}if(!s)continue;const o=(0,n.ensureDefined)(r.get(1)),a=(0,n.ensureDefined)(r.get(4)),h=(0,n.ensureDefined)(r.get(2)),p=(0,n.ensureDefined)(r.get(3)),_=Math.max(o,h,p,a),m=Math.min(o,h,p,a);let g=(0,n.ensureDefined)(d(c.color.value(),0));const f=this._colorProvider.getPlotPointStyle(i,u);void 0!==f.colors[0]&&(g=(0,n.ensureDefined)(f.colors[0]));const v={time:Math.round(t),open:o,high:_,low:m,close:a,color:g,wickColor:f.colors[4],borderColor:f.colors[3],hollow:null};this._bars.push(v)}if(e.barPricesToCoordinates(this._bars,a),this._model.timeScale().barIndexesToCoordinates(this._bars),this._model.selection().isSelected(this._study)){const t=this._selectionIndexer.indexes();this._selectionData={points:[],hittestResult:X.HitTarget.Regular,bgColors:[],visible:!0,barSpacing:this._model.timeScale().barSpacing()};const i=(0,n.ensureNotNull)(this._model.paneForSource(this._study)).height(),s=(0,n.ensureDefined)(this._ohlcPlotIndexes.get(4));for(let r=0;r{var e;return this._colorPlotIndex=null!==(e=this._colorPlotIndex)&&void 0!==e?e:{type:1}};for(let t=0;t{null===this._bandAKey&&i.id===e&&(this._bandAKey=s),null===this._bandBKey&&i.id===t&&(this._bandBKey=s)}))}}var tt=i(13333),it=i(4949),st=i(91280),rt=i(28558),nt=i(97145),ot=i(42960),at=i(42226),lt=i(45802),ct=i(11527),ht=i(35994),dt=i(76422),ut=i(85804),pt=i(17236),_t=i(46100),mt=i(38349),gt=i(6674),ft=i(54303),vt=i(61146),St=i(98596),yt=i(93572),bt=i(1763);const wt=(0,a.getLogger)("Chart.Study"),Pt=o.t(null,void 0,i(14177));const Ct={symbolsForDisplay:!1,symbolsForChartApi:!0,skipHiddenInputs:!1,skipFakeInputs:!1,skipBooleanInputs:N.enabled("dont_show_boolean_study_arguments"),asObject:!0,skippedGroups:[],skippedInputs:[],noExchanges:!1,noResolution:!1, -keepOptionalSymbolsEmpty:!1,skipColorInputs:!1,skipTimeInputs:!1,skipOptionalEmptySymbolInputs:!1,skipTextareaInputs:!1,priceInputsForDisplay:!1},xt=N.enabled("study_symbol_ticker_description"),Tt=N.enabled("hide_main_series_symbol_from_indicator_legend");function It(e,t){const i=e.plots[t];if(!i||!(0,b.isOhlcPlot)(i))return!1;const s=i.target,r=e.defaults.styles&&e.defaults.styles[s],n=e.defaults.ohlcPlots&&e.defaults.ohlcPlots[s],o=e.ohlcPlots&&e.ohlcPlots[s];return r&&(0,b.isOhlcPlotStyleBars)(r)||n&&(0,b.isOhlcPlotStyleBars)(n)||!!o&&(0,b.isOhlcPlotStyleBars)(o)}function Mt(e,t){const i=e.plots[t];if(!i||!(0,b.isOhlcPlot)(i))return!1;const s=i.target,r=e.defaults.styles&&e.defaults.styles[s],n=e.defaults.ohlcPlots&&e.defaults.ohlcPlots[s],o=e.ohlcPlots&&e.ohlcPlots[s];return r&&(0,b.isOhlcPlotStyleCandles)(r)||n&&(0,b.isOhlcPlotStyleCandles)(n)||!!o&&(0,b.isOhlcPlotStyleCandles)(o)}function Lt(e,t){(0,n.assert)(void 0!==e,"zOrder must be defined"),(0,n.assert)(!t.has(e),"zOrder must be unique")}function At(e,t){return e.plots.some((e=>((0,b.isColorerPlot)(e)||(0,b.isDataPlot)(e))&&e.target===t))}function kt(e,t){var i;if(t.plots)for(let s=0;s= 1");let a=(0,k.clone)((0,ut.defaults)("study"));kt(a,e);const l=m.StudyMetaInfo.getStudyPropertyRootName(e);let c=(0,k.clone)((0,ut.defaults)(l,s));c.intervalsVisibilities=(0,k.clone)(pt.intervalsVisibilitiesDefaults),"Overlay"!==e.shortId&&"Compare"!==e.shortId||(c.currencyId=null,c.unitId=null),e.isTVScript&&e.TVScriptSourceCode!==c.TVScriptSourceCode&&(c=(0,k.clone)((0,ut.factoryDefaults)(l))),(0,k.merge)(a,c),t&&((0,n.assert)(!(t instanceof A()),"propsState should not be an instance of Property"),(0,k.merge)(a,t));const h=(0,k.clone)(e.defaults),d={};gt.StudyVersioning.mergeInputsObjPart(d,null!==(r=h.inputs)&&void 0!==r?r:{}),gt.StudyVersioning.mergeInputsObjPart(d,a.inputs),a.inputs=d,delete h.inputs;const u={};if((0,k.merge)(u,h),(0,k.merge)(u,(0,ut.factoryDefaults)(l)),(0,k.merge)(u,a),a=u,null!==i){const t=i.model().studiesColorRotatorFactory().getColorRotator(e);null!==t&&("Overlay@tv-basicstudies"===e.id?a.lineStyle.color=t.getColor(a.lineStyle.color):(0,k.merge)(a,function(e,t){for(const i of Object.keys(e.styles)){const s=e.styles[i];if(s&&"color"in s){const e=s.color;s.color=t.getColor(e)}}return e}(a,t)))}return t&&(0,k.merge)(a.styles,null!==(o=t.styles)&&void 0!==o?o:{}),a}function Vt(e,t,i,s,r){return function(e,t,i,s,r,n){const o=Dt(e,t,i,s) -;return m.StudyMetaInfo.getSourceInputIds(e).forEach(((e,t)=>{const i=o.inputs[e];t=1){const e={};gt.StudyVersioning.mergeInputsObjPart(e,null!==(n=l.inputs)&&void 0!==n?n:{}),gt.StudyVersioning.mergeInputsObjPart(e,o.inputs),o.inputs=e,l&&delete l.inputs;const t={};(0,k.merge)(t,l),(0,k.merge)(t,(0,ut.factoryDefaults)(m.StudyMetaInfo.getStudyPropertyRootName(a))),(0,k.merge)(t,o),o=t}return o}(e,t,i,s,n);return Bt(t||e,r,o)}function Nt(e,t,i,s,r){return Rt(e,t,i,s,m.StudyMetaInfo.getStudyPropertyRootName(e),r)}function Ot(e,t,i){let s=0,r=0;return e.inputs.filter((e=>"source"===e.type)).forEach((e=>{(0,R.getInputValue)(i[e.id]).includes("$")&&s++,(0,R.getInputValue)(t[e.id]).includes("$")&&r++})),Math.sign(r)-Math.sign(s)}class Ft extends u.PriceDataSource{constructor(e,t,i,s){var r,o,a;super(e),this._onStart=new h.Delegate,this._onHibernationStateChange=new h.Delegate,this._symbolsResolved=new h.Delegate,this._statusChanged=new h.Delegate,this._restarting=!1,this._paneViews=[],this._legendView=null,this._priceAxisViews=[], +keepOptionalSymbolsEmpty:!1,skipColorInputs:!1,skipTimeInputs:!1,skipOptionalEmptySymbolInputs:!1,skipTextareaInputs:!1,priceInputsForDisplay:!1},xt=N.enabled("study_symbol_ticker_description"),Tt=N.enabled("hide_main_series_symbol_from_indicator_legend");function It(e,t){const i=e.plots[t];if(!i||!(0,b.isOhlcPlot)(i))return!1;const s=i.target,r=e.defaults.styles&&e.defaults.styles[s],n=e.defaults.ohlcPlots&&e.defaults.ohlcPlots[s],o=e.ohlcPlots&&e.ohlcPlots[s];return r&&(0,b.isOhlcPlotStyleBars)(r)||n&&(0,b.isOhlcPlotStyleBars)(n)||!!o&&(0,b.isOhlcPlotStyleBars)(o)}function Mt(e,t){const i=e.plots[t];if(!i||!(0,b.isOhlcPlot)(i))return!1;const s=i.target,r=e.defaults.styles&&e.defaults.styles[s],n=e.defaults.ohlcPlots&&e.defaults.ohlcPlots[s],o=e.ohlcPlots&&e.ohlcPlots[s];return r&&(0,b.isOhlcPlotStyleCandles)(r)||n&&(0,b.isOhlcPlotStyleCandles)(n)||!!o&&(0,b.isOhlcPlotStyleCandles)(o)}function Lt(e,t){(0,n.assert)(void 0!==e,"zOrder must be defined"),(0,n.assert)(!t.has(e),"zOrder must be unique")}function At(e,t){return e.plots.some((e=>((0,b.isColorerPlot)(e)||(0,b.isDataPlot)(e))&&e.target===t))}function kt(e,t){var i;if(t.plots)for(let s=0;s= 1");let a=(0,k.clone)((0,ut.defaults)("study"));kt(a,e);const l=m.StudyMetaInfo.getStudyPropertyRootName(e);let c=(0,k.clone)((0,ut.defaults)(l,s));c.intervalsVisibilities=(0,k.clone)(pt.intervalsVisibilitiesDefaults),"Overlay"!==e.shortId&&"Compare"!==e.shortId||(c.currencyId=null,c.unitId=null),e.isTVScript&&e.TVScriptSourceCode!==c.TVScriptSourceCode&&(c=(0,k.clone)((0,ut.factoryDefaults)(l))),(0,k.merge)(a,c),t&&((0,n.assert)(!(t instanceof A()),"propsState should not be an instance of Property"),(0,k.merge)(a,t));const h=(0,k.clone)(e.defaults),d={};gt.StudyVersioning.mergeInputsObjPart(d,null!==(r=h.inputs)&&void 0!==r?r:{}),gt.StudyVersioning.mergeInputsObjPart(d,a.inputs),a.inputs=d,delete h.inputs;const u={};if((0,k.merge)(u,h),(0,k.merge)(u,(0,ut.factoryDefaults)(l)),(0,k.merge)(u,a),a=u,null!==i){const t=i.model().studiesColorRotatorFactory().getColorRotator(e);null!==t&&("Overlay@tv-basicstudies"===e.id?a.lineStyle.color=t.getColor(a.lineStyle.color):(0,k.merge)(a,function(e,t){for(const i of Object.keys(e.styles)){const s=e.styles[i];if(s&&"color"in s){const e=s.color;s.color=t.getColor(e)}}return e}(a,t)))}return t&&(0,k.merge)(a.styles,null!==(o=t.styles)&&void 0!==o?o:{}),a}function Et(e,t,i,s,r){return function(e,t,i,s,r,n){const o=Dt(e,t,i,s) +;return m.StudyMetaInfo.getSourceInputIds(e).forEach(((e,t)=>{const i=o.inputs[e];t=1){const e={};gt.StudyVersioning.mergeInputsObjPart(e,null!==(n=l.inputs)&&void 0!==n?n:{}),gt.StudyVersioning.mergeInputsObjPart(e,o.inputs),o.inputs=e,l&&delete l.inputs;const t={};(0,k.merge)(t,l),(0,k.merge)(t,(0,ut.factoryDefaults)(m.StudyMetaInfo.getStudyPropertyRootName(a))),(0,k.merge)(t,o),o=t}return o}(e,t,i,s,n);return Bt(t||e,r,o)}function Nt(e,t,i,s,r){return Rt(e,t,i,s,m.StudyMetaInfo.getStudyPropertyRootName(e),r)}function Ot(e,t,i){let s=0,r=0;return e.inputs.filter((e=>"source"===e.type)).forEach((e=>{(0,R.getInputValue)(i[e.id]).includes("$")&&s++,(0,R.getInputValue)(t[e.id]).includes("$")&&r++})),Math.sign(r)-Math.sign(s)}class Ft extends u.PriceDataSource{constructor(e,t,i,s){var r,o,a;super(e),this._onStart=new h.Delegate,this._onHibernationStateChange=new h.Delegate,this._symbolsResolved=new h.Delegate,this._statusChanged=new h.Delegate,this._restarting=!1,this._paneViews=[],this._legendView=null,this._priceAxisViews=[], this._inputsAnchorsPaneView=null,this._inputsLinesPaneView=null,this._inputsTimeAxisPaneViews=[],this._inputsPriceAxisPaneViews=[],this._resolvedSymbols={},this._resolvedSymbolsByInput={},this._sources=[],this._status={type:tt.StudyStatusType.Undefined},this._wasCompletedBefore=!1,this._studyId=null,this._isSubscribedToSessionId=!1,this._titleStrCache={},this._titleInPartsCache={},this._children=[],this._numericFormatter=new D.NumericFormatter,this._priceAxisViewsBase=[],this._priceLinesAxisViews=[],this._graphicsPriceAxisViews=[],this._labelPaneViews=[],this._ownFirstValue=null,this._plotOffsets={},this._formatter=null,this._ongoingDataUpdate=Promise.resolve(),this._studyModified=!1,this._isDestroyed=!1,this._dataUpdated=new h.Delegate,this._tagsChanged=new h.Delegate,this._studyName="",this._turnaround="st0",this._currencySourceSymbolInputProperty=null,this._pendingResolveSymbols=new Map,this._onIsActualIntervalChange=new h.Delegate,this._childStudyByRebind=new h.Delegate,this._lastNonEmptyPlotRowCache={},this._startMovingPoint=null,this._processHibernateBound=this.processHibernate.bind(this,1),this._maxOffset=new nt.WatchedValue(0),this._currencySourceSymbolInfo=null,this._graphicsPriceRangeGroups=null,this._turnaroundCounter=0,this._deferredPinePatchProps=!1,this._chartApi=e.chartApi(),this._properties=t,this._metaInfo=s,this._series=this._model.mainSeries(),this._series.onIntervalChanged().subscribe(this,this._calcIsActualInterval),this._showStudyArgumentsProperty=e.properties().childs().paneProperties.childs().legendProperties.childs().showStudyArguments,e.collapsed().subscribe(this._processHibernateBound),this._sources=i,m.StudyMetaInfo.setChildStudyMetaInfoPropertiesSourceId(s,null===(r=this._sources[0])||void 0===r?void 0:r.id(),t),i.forEach((e=>{e.setChild(this)})),[this._series,...i].forEach((e=>{e.currencyChanged().subscribe(this,this._onSourceCurrencyChanged),e.unitChanged().subscribe(this,this._onSourceUnitChanged),e.priceRangeReadyChanged().subscribe(this,this._onSourcePriceRangeReadyChanged),e.formatterChanged().subscribe(this,this._onSourceFormatterChanged),e.priceStepChanged().subscribe(this,this._onSourcePriceStepChanged)})),xt&&this._model.mainSeries().properties().childs().statusViewStyle.childs().symbolTextSource.listeners().subscribe(this,(()=>{this.invalidateTitleCache(!0)}));const l=this._properties.childs();for(const e of m.StudyMetaInfo.getSourceInputIds(s))null===(o=l.inputs.childs()[e])||void 0===o||o.subscribe(this,this._onSourceInputChanged);this._properties.subscribe(this,this._onPropertiesChanged),l.visible.subscribe(this,this._visibleChanged),l.visible.subscribe(this,(()=>this.processHibernate())),l.intervalsVisibilities.subscribe(this,this._calcIsActualInterval),l.inputs.listeners().subscribe(this,this._updateMaxOffsetValue),void 0!==l.offsets&&l.offsets.listeners().subscribe(this,this._updateMaxOffsetValue),void 0!==l.offset&&l.offset.listeners().subscribe(this,this._updateMaxOffsetValue),this._initializeCurrencySource(),P.hideAllIndicators().subscribe(this,this._visibleChanged) ;for(let e=0;ethis.processHibernate()))}for(const e of Object.keys(this._metaInfo.graphics))for(const t of Object.keys(this._metaInfo.graphics[e])){const i=null===(a=l.graphics.childs()[e])||void 0===a?void 0:a.childs()[t];i&&i.childs().visible&&(0,n.ensureDefined)(i.childs().visible).subscribe(this,(()=>this.processHibernate()))}this._isActualInterval=(0,it.isActualInterval)(this._series.intervalObj(),this._properties.childs().intervalsVisibilities),this._initializeStudyInputsPaneViews(),this._handler=e=>this.onData(e),this._handler.isTVScriptStrategy=this._metaInfo.isTVScriptStrategy,this._valuesProvider=new ft.StudyValuesProvider(this,e),this._graphics=new g.LiveStudyGraphics(s.graphics)}destroy(){var e;this.parentSources().forEach((e=>{e.currencyChanged().unsubscribeAll(this),e.unitChanged().unsubscribeAll(this),e.priceRangeReadyChanged().unsubscribeAll(this),e.formatterChanged().unsubscribeAll(this),e.priceStepChanged().unsubscribeAll(this)})),this._series.properties().childs().statusViewStyle.childs().symbolTextSource.unsubscribeAll(this),this._series.onIntervalChanged().unsubscribeAll(this),this.formatterChanged().unsubscribe(this,this.invalidateTitleCache),P.hideAllIndicators().unsubscribe(this,this._visibleChanged),this._model.collapsed().unsubscribe(this._processHibernateBound),null!==this._currencySourceSymbolInputProperty&&this._currencySourceSymbolInputProperty.unsubscribeAll(this),null===(e=this._legendView)||void 0===e||e.destroy()}properties(){return this._properties}isDraggable(){return!this._metaInfo.linkedToSeries}logs(){return null}logLevelMask(){const e=this._properties.childs().inputs.childs().__log_level.value();if(!(0,k.isNumber)(e)||e<0||e>7)throw new Error(`Value of log level is unexpected, current value is ${e}, but expected values from 0 to 7`);return{error:Boolean(1&e),warning:Boolean(2&e),info:Boolean(4&e)}}setLogLevelMask(e){const t=(Number(e.error)&&1)|(Number(e.warning)&&2)|(Number(e.info)&&4);this._properties.childs().inputs.childs().__log_level.setValue(t)}lastValueData(e,t,i){const s={noData:!0},r=this.priceScale();if(this._model.timeScale().isEmpty()||null===r||r.isEmpty()||this.data().isEmpty())return s;const n=this._model.timeScale().visibleBarsStrictRange(),o=this.firstValue(!0);if(null===n||null===o)return s;if(!this._properties.childs().visible.value())return s;const a=this._properties.childs().styles,l=this._properties.childs().ohlcPlots;let c,h;if(a&&a.childs()[e]&&(c=a.childs()[e]),l&&l.childs()[e]&&(c=l.childs()[e]),!c||0===c.childs().display.value())return s;const d=this.metaInfo().plots;for(h=0;he.id()));if(h.length&&(c.parentSources=h),e){let e=this.data();const t=this._model.timeScale(),i=this._seriesDataRangeToSave(e);null!==i&&(e=e.range(i.firstBar(),i.lastBar())),c.data=e.state(),c.data.symbols=this._resolvedSymbols,c.data.graphics=(0,g.saveStudyGraphics)(this.graphics(),t.visibleBarsStrictRange()),c.data.plotOffsets=this._plotOffsets}this.ownerSource()&&(c.ownerSource=null===(i=this.ownerSource())||void 0===i?void 0:i.id());for(let e=0;e=0?e:0}}if(null===(s=c.state)||void 0===s?void 0:s.inputs){const e=c.metaInfo.inputs.find((e=>"ILScript"===e.name));e&&delete c.state.inputs[e.id]}const d=this.stateCustomFields();return d&&(c.customFields=d),c}stateCustomFields(){}restoreStateCustomFields(e){}restoreData(e){var t,i;this._invalidateLastNonEmptyPlotRowCache(),this.data().restoreState(e),this._resolvedSymbols=null!==(t=e.symbols)&&void 0!==t?t:{},this._graphics=e.graphics?(0,g.loadStudyGraphics)(e.graphics):(0,g.emptyStudyGraphics)(),this._postProcessGraphics(),this._plotOffsets=null!==(i=e.plotOffsets)&&void 0!==i?i:{},this._setStatus({type:tt.StudyStatusType.Completed},!0)}hasStateForAlert(){return!1}stateForAlert(){throw new Error("Not implemented")}idForAlert(){return super.idForAlert()}alertCreationAvailable(){return new nt.WatchedValue(!1).readonly()}hasBarColorer(){return(0,n.ensureNotNull)(this._metaInfo).plots.some(b.isBarColorerPlot)}barColorer(){const e=this._metaInfo.plots;let t=null;for(let i=0;it.update(e))),this._labelPaneViews.forEach((t=>t.update(e))),null===(t=this._dataWindowView)||void 0===t||t.update(),null===(i=this._legendView)||void 0===i||i.update(), null===(s=this._statusView)||void 0===s||s.update(),this._priceAxisViews.forEach((t=>t.update(e))),this._priceLinesAxisViews.forEach((t=>t.update(e))),null===(r=this._inputsLinesPaneView)||void 0===r||r.update(e),null===(n=this._inputsAnchorsPaneView)||void 0===n||n.update(e),this._inputsTimeAxisPaneViews.forEach((t=>t.update(e))),this._inputsPriceAxisPaneViews.forEach((t=>t.update(e)))}getStudyName(){return this._studyName}getMinFirstBarIndexForPlot(e){var t,i,s,r,n,o,a,l,c,h,d,u,p,_,m;const g=this._properties.childs(),f=this._metaInfo,v=null!==(m=null!==(u=null!==(c=null!==(o=null!==(s=null===(i=null===(t=g.styles.childs()[e])||void 0===t?void 0:t.child("showLast"))||void 0===i?void 0:i.value())&&void 0!==s?s:null===(n=null===(r=g.filledAreasStyle.childs()[e])||void 0===r?void 0:r.child("showLast"))||void 0===n?void 0:n.value())&&void 0!==o?o:null===(l=null===(a=f.styles)||void 0===a?void 0:a[e])||void 0===l?void 0:l.showLast)&&void 0!==c?c:null===(d=null===(h=g.ohlcPlots.childs()[e])||void 0===h?void 0:h.child("showLast"))||void 0===d?void 0:d.value())&&void 0!==u?u:null===(_=null===(p=f.ohlcPlots)||void 0===p?void 0:p[e])||void 0===_?void 0:_.showLast)&&void 0!==m?m:null;if(null===v)return-1/0;const S=this.data().lastIndex();return null===S?-1/0:S-v+1}guiPlotName(e,t){var i,s,r;return null!==(r=null===(s=null===(i=this._metaInfo.styles)||void 0===i?void 0:i[t])||void 0===s?void 0:s.title)&&void 0!==r?r:this.title(e)}childStudyByRebind(){return this._childStudyByRebind}isPine(){return void 0!==this._metaInfo.pine}isStandardPine(){return this.isPine()&&m.StudyMetaInfo.isStandardPine(this._metaInfo.id)}isLinkedToSeries(){return!0===this._metaInfo.linkedToSeries}defaultPlotIdForAlert(){return this._metaInfo.plots.length?this._metaInfo.plots[0].id:null}resolvedSymbolInfoBySymbol(e){return this._resolvedSymbols&&e&&this._resolvedSymbols[this._getSymbolForResolve(e)]||null}currency(){if(null!==this._currencySourceSymbolInfo)return(0,ot.symbolCurrency)(this._currencySourceSymbolInfo);const e=this.metaInfo();return Boolean(e)&&e.is_price_study?this._firstSourceOrSeries().currency():null}currencySourceSymbolInfo(){var e,t,i;return null!==(e=this._currencySourceSymbolInfo)&&void 0!==e?e:null!==(i=null===(t=this.symbolSource())||void 0===t?void 0:t.symbolInfo())&&void 0!==i?i:null}unit(){const e=this.metaInfo();return Boolean(e)&&e.is_price_study?this._firstSourceOrSeries().unit():null}dataWindowView(){return this._dataWindowView}statusView(){return this._statusView}legendView(){return this._legendView}inputsForAlertState(){return this.inputs()}sessionId(){return this._firstSourceOrSeries().sessionId()}sessionIdChanged(){return this._firstSourceOrSeries().sessionIdChanged()}getSymbolString(e){return""===e?"":(0,x.encodeExtendedSymbolOrGetSimpleSymbolString)(this._getSymbolObject(e))}onStatusChanged(){return this._statusChanged}symbolsResolved(){return this._symbolsResolved}onHibernationStateChange(){return this._onHibernationStateChange}valuesProvider(){return new y.StudyLegendValuesProvider(this,this.model())} statusProvider(e){return new M.StudyStatusProvider(this,this._model.properties().childs().scalesProperties.childs().textColor)}correctScaleMargins(e){if("Volume"===this.metaInfo().shortId){const t=this.model().paneForSource(this);return null!==t&&t.isOverlay(this)&&t.containsMainSeries()?{top:.75,bottom:0}:{top:e.top,bottom:0}}return e}canBeHiddenByGlobalFlag(){return!0}isSourceHidden(){return!this.isVisible()||this.canBeHiddenByGlobalFlag()&&P.hideAllIndicators().value()}paneViews(e){if(this.isSourceHidden()||!e.hasPriceDataSource(this))return null;const t=[];return!this._startMovingPoint&&this._wasCompletedBefore&&t.push(...this._paneViews),this._inputsLinesPaneView&&(this._startMovingPoint||this._model.selection().isSelected(this))&&t.push(this._inputsLinesPaneView),this._inputsAnchorsPaneView&&t.push(this._inputsAnchorsPaneView),t}labelPaneViews(){return this.isSourceHidden()?null:this._labelPaneViews}timeAxisViews(){return this._model.selection().isSelected(this)?this._inputsTimeAxisPaneViews:null}priceAxisViews(e,t){const i=this._properties.childs().oldShowLastValue;if(i&&!i.value())return null;let s=this._priceAxisViews.slice();return this._model.selection().isSelected(this)&&(s=s.concat(this._inputsPriceAxisPaneViews)),e.findTargetPriceAxisViews(this,t,s,this._priceLinesAxisViews)}movable(){return null!==this._inputsAnchorsPaneView}startMoving(e,t,i,s){this._startMovingPoint=e,this.stop()}move(e,t,i,s){if(void 0!==e.logical&&null!==this._startMovingPoint){if(Array.isArray(t)){const i=t;this._updateInputValue(e.logical,i[0]),this._updateInputValue(e.logical,i[1])}else this._updateInputValue(e.logical,t);this.updateAllViews((0,rt.sourceChangeEvent)(this.id()))}}endMoving(e,t){return this._startMovingPoint=null,this.start(),{indexesChanged:!1,pricesChanged:!1}}clearData(){var e;this._invalidateLastNonEmptyPlotRowCache(),this.data().clear(),this._graphics instanceof g.LiveStudyGraphics&&(null===(e=this._graphics)||void 0===e||e.clear()),this._plotOffsets={},this.hasBarColorer()&&this._model.mainSeries().invalidateBarStylesCache(),this.updateAllViews((0,rt.sourceChangeEvent)({sourceId:this.id(),clearData:!0}))}convertYCoordinateToPriceForMoving(e,t){const i=this.priceScale();if(!t||!i||i.isEmpty())return null;const s=t.firstValue();return null===s?null:i.coordinateToPrice(e,s)}processHibernate(e){const t=this.isVisible();if(!this.isStarted()&&t&&(this._sources.forEach((e=>{e.processHibernate()})),this.start(void 0,void 0,e),this._onHibernationStateChange.fire(!1)),this.isHibernationAllowed()&&this.isStarted()&&!t){for(const e of this._children)e.processHibernate();this.stop(void 0,e),this._onHibernationStateChange.fire(!0)}}isHibernationAllowed(){return!this.metaInfo().historyCalculationMayChange&&(!this.hasChildren()||!!this._model.collapsed().value()&&this._children.every((e=>e.isHibernationAllowed())))}isPlotVisibleAt(e,t){let i;const s=this.metaInfo().plots.find((t=>t.id===e));if(i=void 0!==s?(0, -b.isOhlcPlot)(s)?this._properties.childs().ohlcPlots.childs()[s.target]:this._properties.childs().styles.childs()[e]:this._properties.childs().ohlcPlots.childs()[e],void 0===i)throw new Error(`Study does not contain ${e} plot`);const r=i.childs().display.value();return null!==r&&(r&t)===t}recalculate(){const e=this._model.paneForSource(this);this._model.recalculatePane(e,(0,rt.sourceChangeEvent)(this.id())),this._model.updateSource(this)}maxOffset(){return this._maxOffset}onStart(){return this._onStart}isHibernated(){return!this.isVisible()&&!this.isStarted()}turnaround(e){if(!e)return this._turnaround;return function(e,t){let i=t.turnaround,s=[t];for(;s.length>0;){let e=[];const t=[];s.forEach((i=>{const s=E(i.sourceStudies).sort(V);if(s.length>0){e=e.concat(s);const i=s.map((e=>e.turnaround)).join("_");t.push(i)}})),t.length&&(i=t.join("_")+"_"+i),s=e}return e+"_"+i}(this._series.seriesSource().turnaround(),B(this))}canHaveChildren(){var e;return this._canHaveChildren=null!==(e=this._canHaveChildren)&&void 0!==e?e:m.StudyMetaInfo.canHaveChildren(this._metaInfo),this._canHaveChildren}setChild(e){-1===this._children.indexOf(e)&&this._children.push(e)}unsetChild(e){const t=this._children.indexOf(e);~t&&this._children.splice(t,1)}getAllChildren(){const e=this._children.slice();for(let t=0;te.id()===i)))&&void 0!==t?t:null}return this._series}priceStep(){return this._priceStep||this._firstSourceOrSeries().priceStep(!1)}_incrementTurnaround(){this._turnaround="st"+ ++this._turnaroundCounter}_checkTurnaround(e){return e===this._turnaround||e===this._model.mainSeries().seriesSource().turnaround()||e===this.turnaround(!0)}_createStudyOnServer(){if(this._isDestroyed)return;const e=this._getStudyIdWithLatestVersion();this._studyId=(0,T.makeNextStudyId)(),this._incrementTurnaround(),this._studyName=e;const t=(0,k.clone)((0,n.ensureDefined)(this._inputs));m.StudyMetaInfo.patchSoSInputs(t,(e=>{var t,i;return null!==(i=null===(t=this._sources.find((t=>t.id()===e)))||void 0===t?void 0:t.sourceId())&&void 0!==i?i:null})),this._chartApi.createStudy(this._studyId,this._turnaround,this.isChildStudy()?(0,n.ensureNotNull)(this._sources[0].sourceId()):(0,n.ensureNotNull)(this._series.seriesSource().instanceId()),this._studyName,t,this._handler,this.isChildStudy())}_stopStudyOnServer(){this._chartApi&&this._chartApi.isConnected().value()&&this.isStarted()&&(this._chartApi.removeStudy((0,n.ensureNotNull)(this._studyId),this.isChildStudy()),this._setStatus({type:tt.StudyStatusType.Undefined})),this._studyId=null}_modifyStudyOnServer(e,t){const i=(0,k.clone)((0,n.ensureDefined)(e));m.StudyMetaInfo.patchSoSInputs(i,(e=>{var t,i;return null!==(i=null===(t=this._sources.find((t=>t.id()===e)))||void 0===t?void 0:t.sourceId())&&void 0!==i?i:null})),this._chartApi.modifyStudy((0, +b.isOhlcPlot)(s)?this._properties.childs().ohlcPlots.childs()[s.target]:this._properties.childs().styles.childs()[e]:this._properties.childs().ohlcPlots.childs()[e],void 0===i)throw new Error(`Study does not contain ${e} plot`);const r=i.childs().display.value();return null!==r&&(r&t)===t}recalculate(){const e=this._model.paneForSource(this);this._model.recalculatePane(e,(0,rt.sourceChangeEvent)(this.id())),this._model.updateSource(this)}maxOffset(){return this._maxOffset}onStart(){return this._onStart}isHibernated(){return!this.isVisible()&&!this.isStarted()}turnaround(e){if(!e)return this._turnaround;return function(e,t){let i=t.turnaround,s=[t];for(;s.length>0;){let e=[];const t=[];s.forEach((i=>{const s=V(i.sourceStudies).sort(E);if(s.length>0){e=e.concat(s);const i=s.map((e=>e.turnaround)).join("_");t.push(i)}})),t.length&&(i=t.join("_")+"_"+i),s=e}return e+"_"+i}(this._series.seriesSource().turnaround(),B(this))}canHaveChildren(){var e;return this._canHaveChildren=null!==(e=this._canHaveChildren)&&void 0!==e?e:m.StudyMetaInfo.canHaveChildren(this._metaInfo),this._canHaveChildren}setChild(e){-1===this._children.indexOf(e)&&this._children.push(e)}unsetChild(e){const t=this._children.indexOf(e);~t&&this._children.splice(t,1)}getAllChildren(){const e=this._children.slice();for(let t=0;te.id()===i)))&&void 0!==t?t:null}return this._series}priceStep(){return this._priceStep||this._firstSourceOrSeries().priceStep(!1)}_incrementTurnaround(){this._turnaround="st"+ ++this._turnaroundCounter}_checkTurnaround(e){return e===this._turnaround||e===this._model.mainSeries().seriesSource().turnaround()||e===this.turnaround(!0)}_createStudyOnServer(){if(this._isDestroyed)return;const e=this._getStudyIdWithLatestVersion();this._studyId=(0,T.makeNextStudyId)(),this._incrementTurnaround(),this._studyName=e;const t=(0,k.clone)((0,n.ensureDefined)(this._inputs));m.StudyMetaInfo.patchSoSInputs(t,(e=>{var t,i;return null!==(i=null===(t=this._sources.find((t=>t.id()===e)))||void 0===t?void 0:t.sourceId())&&void 0!==i?i:null})),this._chartApi.createStudy(this._studyId,this._turnaround,this.isChildStudy()?(0,n.ensureNotNull)(this._sources[0].sourceId()):(0,n.ensureNotNull)(this._series.seriesSource().instanceId()),this._studyName,t,this._handler,this.isChildStudy())}_stopStudyOnServer(){this._chartApi&&this._chartApi.isConnected().value()&&this.isStarted()&&(this._chartApi.removeStudy((0,n.ensureNotNull)(this._studyId),this.isChildStudy()),this._setStatus({type:tt.StudyStatusType.Undefined})),this._studyId=null}_modifyStudyOnServer(e,t){const i=(0,k.clone)((0,n.ensureDefined)(e));m.StudyMetaInfo.patchSoSInputs(i,(e=>{var t,i;return null!==(i=null===(t=this._sources.find((t=>t.id()===e)))||void 0===t?void 0:t.sourceId())&&void 0!==i?i:null})),this._chartApi.modifyStudy((0, n.ensureNotNull)(this._studyId),this._turnaround,i,this._handler,t)}_transformData(e){}_updateMaxOffsetValue(){let e=-1/0;for(const t of this._metaInfo.plots)e=Math.max(this.offset(t.id),e);this._maxOffset.setValue(e)}_rightOffsetToUnixTime(e){if(this._series.bars().size()>=e){const t=(0,n.ensureNotNull)(this._series.bars().lastIndex())-e;return(0,n.ensureNotNull)(this._series.bars().valueAt(t))[0]}return null}_invalidateLastNonEmptyPlotRowCache(){this._lastNonEmptyPlotRowCache={}}_collectDepsForAlert(){throw new Error("Not implemented")}_allInputsAreValid(){for(const e of this._metaInfo.inputs)if("bar_time"===e.type){const t=e.id;if(null==this._properties.childs().inputs.childs()[t].value())return!1}return!0}async _startAfterSymbolsResolved(e,t){await Promise.all(this._sources.map((e=>!e.isStarted()||e.isRestarting()?new Promise((t=>{e.onStart().subscribe(this,t,!0)})):Promise.resolve()))),this.isStarted()&&!this._restarting||(this._restarting=!1,this._allInputsAreValid()&&(this._inputs=this._apiInputs(),this._createStudyOnServer(),this._subscribeToSessionId(),this._onStart.fire(),!0===e&&this._children&&await this._children.map((e=>e.start(!0,t)))))}async _changeInputsImpl(e,t){var s;const r=this._calcSources();let a=!0;const l=Ot(this._metaInfo,e,t);if(r.length!==this._sources.length||r[0]!==this._sources[0])a=await this._rebindToSourceOrRestorePreviousValue(null!==(s=r[0])&&void 0!==s?s:this._series,e,t),a&&(this._inputs=e);else{const s=()=>{for(const i of this._metaInfo.inputs){if("source"!==i.type)continue;const s=e[i.id].v,r=t[i.id].v;if(s!==r){(0,n.ensureDefined)(this._properties.childs().inputs.child(i.id)).setValue(r)}}};if(this.isStarted()&&this._chartApi.isConnected().value()&&l>0&&!this._chartApi.canCreateStudy(!0)){const e=window.user.pro_plan;return createGoProDialog({feature:"studyOnStudy",actions:e&&[ProPlans.ProPremium,ProPlans.ProPremiumTrial,ExpertPlans.PremiumExpert,ExpertPlans.PremiumExpert+TRIAL_SUFFIX].includes(e)?[{text:o.t(null,void 0,i(75139)),action:PredefinedAction.Close}]:void 0}),void s()}this._inputs=e;let a=!1;const c=Object.values(R.RangeDependentStudyInputNames);for(const i of Object.keys(e))if(JSON.stringify(e[i])!==JSON.stringify(t[i])&&!c.includes(i)){a=!0;break}this._incrementTurnaround(),a&&this.disablePriceRangeReady();try{await this._updateParentSources(r,l,!0),this._modifyStudyOnServer(e,l)}catch(e){wt.logError(`Error applying parent sources: ${e}`),s()}}this.invalidateTitleCache(),a&&(this._studyModified=a)}createPriceAxisView(e){return new lt.StudyPriceAxisView(this,{plotIndex:e})}createPriceLineAxisView(e){return new ct.StudyPriceLineAxisView(this,e)}_createStudyPlotPaneView(e){return new We.StudyPlotPaneView(this,this._series,this._model,e)}_createViews(){var e,t,i,s;this._priceAxisViewsBase=[],this._priceLinesAxisViews=[],this._paneViews=[],this._labelPaneViews=[];const r=new Set,o=this.metaInfo(),a=Boolean(o.usePlotsZOrder),l=new Map,c=this._properties.childs();if(c.filledAreasStyle&&o.filledAreas)for(let e=0;e{const i=c.bands.childs()[t];if(i&&i.childs().visible.value()){const t=new Ze(i,this),s=a?(0,n.ensureDefined)(e.zorder):l.size;Lt(s,l),l.set(s,{paneViews:[t]})}})),c.bandsBackground&&((0,n.assert)(!a,"'usePlotsZOrder' flag does not supported"),l.set(l.size,{paneViews:[new Qe(this)]}));const h=this._paneViews;this._createGraphicsPaneViews().then((e=>{for(let t=0;te-t));for(let e=0;e{const i=c.bands.childs()[t];if(i&&i.childs().visible.value()){const t=new Ze(i,this),s=a?(0,n.ensureDefined)(e.zorder):l.size;Lt(s,l),l.set(s,{paneViews:[t]})}})),c.bandsBackground&&((0,n.assert)(!a,"'usePlotsZOrder' flag does not supported"),l.set(l.size,{paneViews:[new Qe(this)]}));const h=this._paneViews;this._createGraphicsPaneViews().then((e=>{for(let t=0;te-t));for(let e=0;e0){const t=(0,n.ensureNotNull)(this.barColorer()).firstColoredBar(e[0].index);this._model.mainSeries().invalidateBarStylesCache(t)}null!==t&&this._postProcessGraphics();const r=this._model.paneForSource(this);this._model.recalculatePane(r,(0,rt.sourceChangeEvent)({sourceId:this.id(),firstUpdatedTimePointIndex:null!=s?s:void 0})),this._updateSources()}_updateSources(){this._model.updateSource(this),this.hasBarColorer()&&this._model.updateSource(this._model.mainSeries())}_titleInputs(e,t,i){return this.inputs(this._titleInputsOptions(e,t,i))}_titleInputsOptions(e,t,i){return{symbolsForDisplay:!0,skipHiddenInputs:!0,skipFakeInputs:!1,fakeInputsForDisplay:!0,asObject:!0,skippedGroups:[],noExchanges:t,noResolution:i,priceInputsForDisplay:!0,skipOptionalEmptySymbolInputs:Tt,displayMask:e}}_postProcessGraphics(){this._graphicsPriceAxisViews=this._createGraphicsPriceAxisViews(),this._concatPriceAxisViews()}async _createGraphicsPaneViews(){return(0,g.createGraphicsPaneViews)(this,this.model())}_createGraphicsPriceAxisViews(){return(0,g.createGraphicsPriceAxisViews)(this)}_subscribeToSessionId(){!this._isSubscribedToSessionId&&this.hasSymbolInputs()&&(this.sessionIdChanged().subscribe(this,this._onSessionIdChanged),this._isSubscribedToSessionId=!0)}_unsubscribeToSessionId(){this._isSubscribedToSessionId&&(this.sessionIdChanged().unsubscribe(this,this._onSessionIdChanged),this._isSubscribedToSessionId=!1)}_onSessionIdChanged(){ this.restart(!0)}_recreateFormatter(){this._formatter=this._tryCreateFormatter(),this._formatterChanged.fire();const e=this.priceScale();null!==e&&e.updateFormatter(),this._model.fullUpdate()}_recreatePriceStep(){var e;let t=null;const i=null!==(e=this._priceScaleByProperties())&&void 0!==e?e:this._priceScaleByMetaInfo();null!==i&&(t=1/i),this._priceStep!==t&&(this._priceStep=t,this._priceStepChanged.fire())}_recreatePriceFormattingDependencies(){this._recreateFormatter(),this._recreatePriceStep()}_title(e,t,i,s,r){const n=this._titleInParts(e,t,i,s,r);return this._joinTitlesParts(n)}_formatterByProperties(){const e=this.metaInfo().format,t=this._priceScaleByProperties();if(null!==t)switch(e.type){case"inherit":case"price":return new vt.PriceFormatter(t);case"volume":return new St.VolumeFormatter(Math.log10(t));case"percent":return new yt.PercentageFormatter(t)}return null}_formatterByMetaInfo(){var e,t;const i=this.metaInfo().format;if("inherit"===i.type)return null;const s=this.series().symbolInfo(),r=(0,k.isNumber)(i.precision)?Math.pow(10,i.precision):void 0;{const s=null!==(t=null===(e=null===bt.customFormatters||void 0===bt.customFormatters?void 0:bt.customFormatters.studyFormatterFactory)||void 0===e?void 0:e.call(bt.customFormatters,i,this.symbolSource().symbolInfo()))&&void 0!==t?t:null;if(null!==s)return s}switch(i.type){case"price":return new vt.PriceFormatter(r);case"volume":{let e=i.precision;return void 0===e&&(e=s&&(0,k.isNumber)(s.volume_precision)?s.volume_precision:0),new St.VolumeFormatter(e)}case"percent":return new yt.PercentageFormatter(r);default:return wt.logWarn(`Unsupported format type: ${i.type}`),null}}_postProcessPriceRange(e){if(e&&e.minValue()===e.maxValue()&&!this.metaInfo().is_price_study){const t=.005*e.minValue();e=new p.PriceRange(e.minValue()-t,e.maxValue()+t)}const t=this.priceScale();return t&&t.isLog()&&e?new p.PriceRange(t.priceToLogical(e.minValue()),t.priceToLogical(e.maxValue())):e}_joinTitlesParts(e){const t=e[1]?e[1].join(", "):"";return e[0]+(t.length>0?" ("+t+")":"")}_titleInParts(e,t,s,r,a){var l;const c=this.name(t);s=s||{};const h=[o.t(c,{context:"study"},i(68716))];let d=[];if(!r){const i=this._getMTFResolutionInputTitle();null!==i&&i.length>0&&h.push(i);const r=this.metaInfo(),o=this._titleInputs(e,a,!0),c=r.inputs.filter((e=>o.hasOwnProperty(e.id))).map((e=>({meta:e,value:o[e.id]})));if(c.length>0){const i={};if(this.isChildStudy())for(let s=0;s=0){const s=this.parentSourceForInput(h);if(s instanceof Ft){const r=s.metaInfo(),n=s.title(e,t,{},!0,a);if(1===r.plots.length)i[h]=n;else{const e=h.split("$")[1],t=null===(l=r.plots[parseInt(e)])||void 0===l?void 0:l.id,s=r.styles&&r.styles[t],o=s&&s.title||t;i[h]=n+": "+o}}}}d=c.map((({meta:e,value:t})=>{if("time"===e.type)return new Date(t).toISOString();let r=(0, k.isNumber)(t)?this._numericFormatter.format(t):i&&i[t.toString()]||t.toString();return s&&s[r.toString()]&&(r=s[r.toString()]),r}))}}return[h.join(" · "),d]}_getMTFResolutionInputTitle(){const e=this.metaInfo();for(let t=0;ts),(()=>s)).then(this._onDataUnpacked.bind(this,e,t.indexes,i)),this._ongoingDataUpdate}_mergeData(e){return this._invalidateLastNonEmptyPlotRowCache(),this.data().merge(e)}_getSymbolForResolve(e){return this.getSymbolString(this._getSymbolForApi(e))}_allSymbolsAreResolved(){const e=this._inputSymbols(),t=[];let i=!1;for(const s of e){const e=this._getSymbolForResolve(s);if(""!==e)if(this._resolvedSymbols[e])i=!0;else{const i=this._resolveSymbol(e,s);t.push(i)}}if(0===t.length){const e=Promise.resolve();return i?e.then((()=>this._symbolsResolved.fire())):e}return Promise.all(t).catch((e=>{this._setStatus({type:tt.StudyStatusType.Error,errorDescription:{error:Pt}});return this._inputSymbols().includes(e)&&this.stop(!0),this._model.updateSource(this),Promise.reject("Invalid symbol, "+e)})).then((()=>{this._symbolsResolved.fire(),this._recheckLineToolsActuality()}))}_getSymbolForApi(e){return e}_resolveSymbol(e,t){if(""===e)return Promise.resolve();let i=this._pendingResolveSymbols.get(e);return void 0!==i||(i=new Promise(((i,s)=>{this._onSymbolResolvingStart(),this._chartApi.resolveSymbol((0,T.makeNextSymbolId)(),e,(r=>{switch(this._pendingResolveSymbols.delete(e),r.method){case"symbol_resolved":this._setStatus({type:tt.StudyStatusType.Undefined}),this._resolvedSymbols[e]=r.params[1],this._resolvedSymbolsByInput[t]=r.params[1],this._onSymbolResolved(e,t,r.params[1]),this.invalidateTitleCache(!0),i();break;case"symbol_error":if(this._setStatus({type:tt.StudyStatusType.Error,errorDescription:{error:r.params[1]}}),this._onSymbolError(),r.params[1]===I.permissionDenied&&r.params[2]){if(r.params[2]!==I.SymbolErrorPermissionDeniedReason.Symbol)return void this._resolveSymbol(r.params[2],t).then(i);if(r.params[3])return void this._resolveSymbol(r.params[3],t).then(i)}0,s(t)}}))})),this._pendingResolveSymbols.set(e,i)),i}_recheckLineToolsActuality(){const e=this._model.paneForSource(this);null!==e&&e.sourcesByGroup().lineSourcesForAllSymbols().forEach((e=>{e.ownerSource()===this&&e.calcIsActualSymbol()}))}_getSymbolObject(e){const t={symbol:e},i=this.currency() @@ -784,16 +784,16 @@ k.isNumber)(t)?this._numericFormatter.format(t):i&&i[t.toString()]||t.toString() this._onDataUpdated(e,s,t,r&&r.index),this.priceRangeReady()||this._enablePriceRangeReady(),this._dataUpdated.fire(i,!1,r)}_processPlotOffsets(e){if(e&&e.indexes_replace)return;const t=this._plotOffsets;this._plotOffsets=e&&e.offsets||{},(0,s.default)(t,this._plotOffsets)||this.updateAllViews((0,rt.sourceChangeEvent)({sourceId:this.id(),clearData:!0})),this._updateMaxOffsetValue()}_applyPlotToPrecalculatedAutoscaleInfo(e,t,i,s){var r;const o=s.id,a=this._properties.childs().styles.childs()[o],l=(0,b.isShapesPlot)(s)||(0,b.isCharsPlot)(s);i.useMainSeriesRange=i.useMainSeriesRange||(0,b.isArrowsPlot)(s);let c=(0,b.isLinePlot)(s)||(0,b.isOhlcPlot)(s);if(l){const e=(0,n.ensureDefined)(a).childs().location.value(),t=[v.MarkLocation.Absolute,v.MarkLocation.Top,v.MarkLocation.Bottom].indexOf(e)<0;i.useMainSeriesRange=i.useMainSeriesRange||l&&t,c=c||e===v.MarkLocation.Absolute}if(!c)return i;const h={name:o,offset:this.offset(o)},d=a.childs().plottype.value();if(!this._skipHistogramBaseOnAutoScale()&&[b.LineStudyPlotStyle.Histogram,b.LineStudyPlotStyle.Columns,b.LineStudyPlotStyle.Area].indexOf(d)>=0){const s=(0,n.ensureDefined)(null===(r=this._metaInfo.styles)||void 0===r?void 0:r[o]).histogramBase,a=this.data().minMaxOnRangeCached(e,t,[h]);return(0,k.isNumber)(s)&&null!==a&&(i.baseValueMinMax=(0,_.mergeMinMax)(i.baseValueMinMax,{min:s,max:s}),i.baseValueMinMax=(0,_.mergeMinMax)(i.baseValueMinMax,a)),i}return i.fields.push(h),i}async _onSourceInputChanged(){var e;if(!this.isStarted()){const t=this._calcSources();t[0]!==this._sources[0]&&await this._rebindToSource(null!==(e=t[0])&&void 0!==e?e:this._series,this._apiInputs())}}async _rebindToSourceOrRestorePreviousValue(e,t,i){let s=!0;if(!await this._rebindToSource(e,t)){const e=this._properties.childs().inputs.state(),r=m.StudyMetaInfo.getSourceIdsByInputs(this._metaInfo.inputs,e)[0];for(const e of Object.keys(i)){const o=(0,R.getInputValue)(i[e]),a=(0,R.getInputValue)(t[e]);if(i.hasOwnProperty(e)&&o!==a&&r&&(0,k.isString)(a)&&0===a.indexOf(r)){const t=(0,n.ensureDefined)(this._properties.childs().inputs.child(e)),r=(0,R.getInputValue)(i[e]);t.setValue(r),s=!1;break}}}return s}async _rebindToSource(e,t){const i=this.isStarted()&&this._chartApi.isConnected().value();i&&e instanceof Ft&&!e.isStarted()&&await e.start(!1,!0);const s=this._firstSourceOrSeries();let r;const o=(0,k.clone)((0,n.ensureDefined)(t)),a=e instanceof Ft?[e,...this._sources]:this._sources;if(i&&m.StudyMetaInfo.patchSoSInputs(o,(e=>{var t,i;return null!==(i=null===(t=a.find((t=>t.id()===e)))||void 0===t?void 0:t.sourceId())&&void 0!==i?i:null})),!this.isChildStudy())return wt.logError("Unable to rebind study to source of this type"),!1;{let t;this._sources[0].unsetChild(this);let s=null;if(e===this._model.mainSeries())this._sources=[],this._ownerSource=null,t=this._series.seriesSource().instanceId(),s=2;else{if(!(e instanceof Ft))return wt.logError("Unable to rebind study to source of this type"),!1;this._ownerSource=e,this._sources=[e],t=e.sourceId(),e.setChild(this),null===t&&(r=e)} i&&null!==t&&(this._incrementTurnaround(),this.disablePriceRangeReady(),this._chartApi.rebindStudy((0,n.ensureNotNull)(this._studyId),this._turnaround,t,this._studyName,o,this._handler,s))}r&&(this.isStarted()&&this.stop(),r.start(!0)),s instanceof Ft&&s.processHibernate();const l=this._priceScale,c=(0,n.ensureNotNull)(e.priceScale());if(l!==c){const t=this._model.paneForSource(this),i=(0,n.ensureNotNull)(this._model.paneForSource(e));t===i&&i.move(this,c,!0)}const h=this._firstSourceOrSeries();return s.formatterChanged().unsubscribe(this,this._onSourceFormatterChanged),h.formatterChanged().subscribe(this,this._onSourceFormatterChanged),s.priceStepChanged().unsubscribe(this,this._onSourcePriceStepChanged),h.priceStepChanged().subscribe(this,this._onSourcePriceStepChanged),s.currencyChanged().unsubscribeAll(this),h.currencyChanged().subscribe(this,this._onSourceCurrencyChanged),s.unitChanged().unsubscribeAll(this),h.unitChanged().subscribe(this,this._onSourceUnitChanged),s.priceRangeReadyChanged().unsubscribeAll(this),h.priceRangeReadyChanged().subscribe(this,this._onSourcePriceRangeReadyChanged),this._recreatePriceFormattingDependencies(),!0}_buildInputs(e){(0,n.assert)(!!e,"options not set");let t={};try{t=this._prepareInputs(e)}catch(e){wt.logWarn("Failed to prepare study inputs: "+e)}if(e.asObject){const e={};return Object.keys(t).forEach((i=>{null!=t[i]&&(e[i]=t[i])})),e}{const e=[];return Object.keys(t).forEach((i=>{null!=t[i]&&e.push(t[i])})),e}}_prepareInput(e,t){const i=this._prepareInputValue(e,t);return!e.isFake||t.fakeInputsForDisplay||t.onlyAtomValues?i:{v:i,f:!0,t:e.type}}_plotsForAlert(){return[]}_dependenciesForAlerts(){throw new Error("Not implemented")}_calcIsActualInterval(){const e=this._isActualInterval;this._isActualInterval=(0,it.isActualInterval)(this._series.intervalObj(),this._properties.childs().intervalsVisibilities),e!==this._isActualInterval&&(this._onIsActualIntervalChange.fire(),this._visibleChanged(),this.processHibernate())}_visibleChanged(){this._series.invalidateBarColorerCache()}_getNonPriceParent(){const e=this._sources;for(const t of e)if(t instanceof Ft){const e=t.metaInfo();return e.is_price_study&&"Compare@tv-basicstudies"!==e.id?t._getNonPriceParent():t}return null}_updateInputValue(e,t){const i=this._properties.childs().inputs.childs();if(i[t.id])if("price"===t.type)i[t.id].setValue(e.price);else if("time"===t.type){const s=this._model.timeScale().indexToTimePoint(e.index);null!==s&&i[t.id].setValue(1e3*s)}}_initializeStudyInputsPaneViews(){}_updateCurrencySourceSymbolInfo(){var e;null!==this._currencySourceSymbolInputProperty&&(this._currencySourceSymbolInfo=null!==(e=this._resolvedSymbolsByInput[this._currencySourceSymbolInputProperty.value()])&&void 0!==e?e:null)}_initializeCurrencySource(){var e,t;const i=this.metaInfo(),s="symbolInputSymbolSource"===(null===(e=i.symbolSource)||void 0===e?void 0:e.type)&&(null===(t=i.symbolSource)||void 0===t?void 0:t.inputId),r=i.inputs.find((e=>e.id===s)),n="symbol"===(null==r?void 0:r.type);if("string"==typeof s&&n&&i.is_price_study){ const e=this._properties.childs().inputs.childs()[s];void 0!==e&&(e.subscribe(this,this._onCurrencyMayChange),this._currencySourceSymbolInputProperty=e)}}_recreatePaneViews(){this.hasBarColorer()&&this._model.mainSeries().invalidateBarStylesCache(),this._createViews(),this.recalculate(),this.updateAllViews((0,rt.sourceChangeEvent)(this.id()))}_pinePatchPropsAllowed(){return(this.isStarted()||this._metaInfo.inputs.some((e=>"symbol"===e.type)))&&!this._restarting}_pinePatchProps(){throw new Error("Not implemented")}_areStudyInputsModified(e){if(0===Object.keys(e).length)return!1;if(void 0===this._oldStudyInputs)return!0;const t=Object.keys(this._oldStudyInputs);(0,n.assert)(t.length===Object.keys(e).length,"keys quantity should be equal");for(const i of t)if((0,n.assert)(e.hasOwnProperty(i),`key '${i}' should exist in study inputs`),(0,n.ensureDefined)(this._oldStudyInputs)[i]!==e[i])return!0;return!1}_getStudyErrorText(e){return e.split(":",2)[0]}_priceScaleByProperties(){if("default"===this.properties().childs().precision.value())return null;const e=parseInt(this.properties().childs().precision.value());return isFinite(e)?Math.pow(10,e):null}_priceScaleByMetaInfo(){const e=this.metaInfo().format,t="inherit"!==e.type?e.precision:void 0,i=(0,k.isNumber)(t)?Math.pow(10,t):void 0;if("price"===e.type||"percent"===e.type)return i||100;if("volume"===e.type){if(void 0===e.precision){const e=this.series().symbolInfo();if(null!==e&&(0,k.isNumber)(e.volume_precision))return Math.pow(10,e.volume_precision)}return 1}return"inherit"===e.type||wt.logWarn("Unsupported format type: "+e.type),null}_inputSymbols(){return this.metaInfo().inputs.filter((e=>"symbol"===e.type)).map((e=>(0,n.ensureDefined)(this._properties.childs().inputs.child(e.id)).value()))}}},8561:(e,t,i)=>{"use strict";i.d(t,{StudyCompare:()=>F});var s=i(50151),r=i(42226),n=i(8708),o=i(42960),a=i(59452),l=i.n(a),c=i(14483),h=i(74304),d=i(42275),u=i(78211),p=i(87095);const _=c.enabled("force_exchange_as_title");class m extends d.PriceAxisView{constructor(e,t){super(),this._studyCompare=e,this._data=t}_updateRendererData(e,t,i){e.visible=!1,t.visible=!1;const r=this._studyCompare.priceScale(),n=this._studyCompare.lastValueData(this._data.plotIndex,!1);if(n.noData||null===r||r.isEmpty())return;const o=this._studyCompare.model(),a=o.timeScale().visibleBarsStrictRange(),l=o.mainSeries().bars().lastIndex();if(null===a||null===l)return;if(l<=a.lastBar())i.background=(0,p.resetTransparency)(n.color),i.textColor=this.generateTextColor(i.background),i.borderColor=void 0,e.borderVisible=!1,t.borderVisible=!1;else{const r=o.backgroundColorAtYPercentFromTop(n.coordinate/(0,s.ensureNotNull)(o.paneForSource(this._studyCompare)).height());i.background=r,i.textColor=(0,p.resetTransparency)(n.color),i.borderColor=i.textColor,e.borderVisible=!0,t.borderVisible=!0}i.coordinate=n.coordinate,i.floatCoordinate=n.floatCoordinate;const c=o.properties().childs().scalesProperties.childs();c.showSeriesLastValue.value()&&(e.text=(0,u.getCurrentModePriceText)(r,n), -c.seriesLastValueMode.value()!==h.PriceAxisLastValueMode.LastPriceAndPercentageValue?e.secondLine="":e.secondLine=(0,u.getOppositeModePriceText)(r,n),e.visible=!0),t.text="",c.showSymbolLabels.value()&&(t.text=this._paneText(),t.visible=t.text.length>0)}_paneText(){let e="";const t=this._studyCompare.symbolInfo();return _?e=(0,o.displayedSymbolExchange)(t):this._studyCompare.model().properties().childs().scalesProperties.childs().showSymbolLabels.value()&&(e=(0,o.displayedSymbolName)(t)),e}}i(44352);var g=i(88318),f=i(54303),v=i(88348),S=i(49483),y=i(15367),b=i(1722),w=i(37591);const P=S.CheckMobile.any();class C extends f.StudyValuesProvider{constructor(e,t){super(e,t),this._emptyValues[0].title=e.guiPlotName(w.TitleDisplayTarget.StatusLine,"")}getValues(e){return(0,b.isNumber)(e)||(this._showLastPriceAndChangeOnly()?e=this._study.data().lastIndex():(e=this._model.crossHairSource().appliedIndex(),(0,b.isNumber)(e)||(e=this._study.data().lastIndex()))),super.getValues(e)}_hideValues(){return!1}_showLastPriceAndChangeOnly(){return P&&(null===this._model.crossHairSource().pane||(0,y.isLineToolName)(v.tool.value())||null!==this._model.lineBeingEdited())}}class x extends g.StudyDataWindowView{constructor(e,t){super(e,t),this._studyCompare=e}_hideValues(){return!1}_createValuesProvider(e,t){return new C(e,t)}}class T extends x{constructor(e,t){super(e,t),this._additional=null,this._showSeriesOHLC=t.properties().childs().paneProperties.childs().legendProperties.childs().showSeriesOHLC,this._showSeriesOHLC.subscribe(this,this.update)}areValuesVisible(){return this._showSeriesOHLC.value()}destroy(){this._showSeriesOHLC.unsubscribeAll(this)}additional(){return this._additional}_updateImpl(){super._updateImpl()}}var I=i(90830),M=i(1763),L=i(6892);class A extends L.StudyStatusProvider{getSplitTitle(){return this._source.titleInParts(w.TitleDisplayTarget.StatusLine,!0,void 0,!1,!1)}text(){return this._source.isActualInterval()?this._source.isFailed()?`${this._source.title(w.TitleDisplayTarget.StatusLine,!0,void 0,!1,!1)}: ${this.sourceStatusText()}`:`${this._source.title(w.TitleDisplayTarget.StatusLine,!0,void 0,!1,!1)} ${this.sourceStatusText()}`:this._source.title(w.TitleDisplayTarget.StatusLine,!0,void 0,!1,!1)}}var k=i(97121),D=i(97145);const V=c.enabled("study_overlay_compare_legend_option"),E=c.enabled("force_exchange_as_title"),B=c.enabled("uppercase_instrument_names"),R=!c.enabled("hide_study_compare_legend_item"),N=c.enabled("hide_unresolved_symbols_in_legend"),O=c.enabled("symbol_info_price_source");class F extends n.Study{constructor(e,t,i,s){super(e,function(e){return e.hasChild("currencyId")||e.addChild("currencyId",new(l())(null)),e.hasChild("unitId")||e.addChild("unitId",new(l())(null)),e.addExclusion("currencyId"),e.addExclusion("unitId"),e}(t),i,s),this._isActingAsSymbolSource=new D.WatchedValue(!0),this._realignToolsLastParams=null,this.properties().childs().minTick.subscribe(null,(()=>this._recreatePriceFormattingDependencies())), +c.seriesLastValueMode.value()!==h.PriceAxisLastValueMode.LastPriceAndPercentageValue?e.secondLine="":e.secondLine=(0,u.getOppositeModePriceText)(r,n),e.visible=!0),t.text="",c.showSymbolLabels.value()&&(t.text=this._paneText(),t.visible=t.text.length>0)}_paneText(){let e="";const t=this._studyCompare.symbolInfo();return _?e=(0,o.displayedSymbolExchange)(t):this._studyCompare.model().properties().childs().scalesProperties.childs().showSymbolLabels.value()&&(e=(0,o.displayedSymbolName)(t)),e}}i(44352);var g=i(88318),f=i(54303),v=i(88348),S=i(49483),y=i(15367),b=i(1722),w=i(37591);const P=S.CheckMobile.any();class C extends f.StudyValuesProvider{constructor(e,t){super(e,t),this._emptyValues[0].title=e.guiPlotName(w.TitleDisplayTarget.StatusLine,"")}getValues(e){return(0,b.isNumber)(e)||(this._showLastPriceAndChangeOnly()?e=this._study.data().lastIndex():(e=this._model.crossHairSource().appliedIndex(),(0,b.isNumber)(e)||(e=this._study.data().lastIndex()))),super.getValues(e)}_hideValues(){return!1}_showLastPriceAndChangeOnly(){return P&&(null===this._model.crossHairSource().pane||(0,y.isLineToolName)(v.tool.value())||null!==this._model.lineBeingEdited())}}class x extends g.StudyDataWindowView{constructor(e,t){super(e,t),this._studyCompare=e}_hideValues(){return!1}_createValuesProvider(e,t){return new C(e,t)}}class T extends x{constructor(e,t){super(e,t),this._additional=null,this._showSeriesOHLC=t.properties().childs().paneProperties.childs().legendProperties.childs().showSeriesOHLC,this._showSeriesOHLC.subscribe(this,this.update)}areValuesVisible(){return this._showSeriesOHLC.value()}destroy(){this._showSeriesOHLC.unsubscribeAll(this)}additional(){return this._additional}_updateImpl(){super._updateImpl()}}var I=i(90830),M=i(1763),L=i(6892);class A extends L.StudyStatusProvider{getSplitTitle(){return this._source.titleInParts(w.TitleDisplayTarget.StatusLine,!0,void 0,!1,!1)}text(){return this._source.isActualInterval()?this._source.isFailed()?`${this._source.title(w.TitleDisplayTarget.StatusLine,!0,void 0,!1,!1)}: ${this.sourceStatusText()}`:`${this._source.title(w.TitleDisplayTarget.StatusLine,!0,void 0,!1,!1)} ${this.sourceStatusText()}`:this._source.title(w.TitleDisplayTarget.StatusLine,!0,void 0,!1,!1)}}var k=i(97121),D=i(97145);const E=c.enabled("study_overlay_compare_legend_option"),V=c.enabled("force_exchange_as_title"),B=c.enabled("uppercase_instrument_names"),R=!c.enabled("hide_study_compare_legend_item"),N=c.enabled("hide_unresolved_symbols_in_legend"),O=c.enabled("symbol_info_price_source");class F extends n.Study{constructor(e,t,i,s){super(e,function(e){return e.hasChild("currencyId")||e.addChild("currencyId",new(l())(null)),e.hasChild("unitId")||e.addChild("unitId",new(l())(null)),e.addExclusion("currencyId"),e.addExclusion("unitId"),e}(t),i,s),this._isActingAsSymbolSource=new D.WatchedValue(!0),this._realignToolsLastParams=null,this.properties().childs().minTick.subscribe(null,(()=>this._recreatePriceFormattingDependencies())), this.properties().childs().minTick.subscribe(null,(()=>this._model.fullUpdate())),this.properties().childs().currencyId.subscribe(this,this._onCurrencyChanged),this.properties().childs().unitId.subscribe(this,this._onUnitChanged),this._symbolResolvingActive=new D.WatchedValue(!1),this._symbolHibernated=new D.WatchedValue(!1),e.mainSeries().onIntervalChanged().subscribe(this,(()=>e.realignLineTools(this)))}destroy(){this._model.mainSeries().onIntervalChanged().unsubscribeAll(this),super.destroy()}properties(){return this._properties}isActingAsSymbolSource(){return this._isActingAsSymbolSource.readonly()}createPriceAxisView(e){return new m(this,{plotIndex:"compare"})}setSymbolParams(e){this._setSymbolCurrencyUnitInternal(e)}symbol(){return this.properties().childs().inputs.childs().symbol.value()}symbolChanged(){return this.properties().childs().inputs.childs().symbol.listeners()}setSymbol(e){this.setSymbolParams({symbol:e})}symbolInfo(){if(!this._resolvedSymbols)return null;const e=this.properties().childs().inputs.childs().symbol.value();if(!e)return null;let t;return t=this._resolvedSymbols[this._getSymbolForResolve(e)]||null,t}symbolResolved(){return this.symbolsResolved()}symbolResolvingActive(){return this._symbolResolvingActive}symbolHibernated(){return this._symbolHibernated}isVisible(){const e=super.isVisible();return this._symbolHibernated.setValue(!e),e}symbolSameAsCurrent(e){return(0,k.symbolSameAsCurrent)(e,this.symbolInfo())}currency(){return this.properties().childs().currencyId.value()||null}setCurrency(e){this.setSymbolParams({currency:e})}isConvertedToOtherCurrency(){return(0,o.isConvertedToOtherCurrency)(this.symbolInfo())}unit(){return this.properties().childs().unitId.value()||null}setUnit(e){this.setSymbolParams({unit:e})}isConvertedToOtherUnit(){return(0,o.isConvertedToOtherUnit)(this.symbolInfo(),this._model.unitConversionEnabled())}style(){return 2}setStyle(e){}interval(){return this._model.mainSeries().interval()}setInterval(e){}symbolSource(){return this}valueAt(e,t){var i,s;return null!==(s=null===(i=this.data().search(e))||void 0===i?void 0:i.value[1])&&void 0!==s?s:null}state(e,t){const i=super.state(e,t);return this._model.unitConversionEnabled()||delete i.state.unitId,e&&((0,s.ensureDefined)(i.data).symbols={___snapshot:this.symbolInfo()||void 0}),i}symbolTitle(e,t,i){return this.title(e,!0,{},!1,t)}titleInParts(e,t,i,s,r){var n;const o=this._titleInParts(e,t,i,s,r),a=[o[0],...null!==(n=o[1])&&void 0!==n?n:[]].join(", ");return[B?a.toUpperCase():a]}tags(){const e=this.symbol();return e?[e]:[]}statusView(){return R?super.statusView():null}guiPlotName(e,t){return this.properties().childs().inputs.childs().symbol.value()}canOverrideMinTick(){return!0}canBeHiddenByGlobalFlag(){return!1}valuesProvider(){return new C(this,this.model())}statusProvider(e){return new A(this,this._model.properties().childs().scalesProperties.childs().textColor)}measureUnitId(){return(0,o.measureUnitId)(this.symbolInfo())}_createViews(){this._legendView||(this._legendView=new T(this,this._model)), -this._dataWindowView||(this._dataWindowView=new x(this,this._model)),this._statusView||(this._statusView=new I.StudyStatusView(this)),super._createViews()}_showLastValueOnPriceScale(){return this._model.properties().childs().scalesProperties.childs().showSeriesLastValue.value()}_onUnitChanged(){"alwaysOff"!==(0,r.currencyUnitVisibilityProperty)().value()&&this._model.fullUpdate(),this._model.unitConversionEnabled()&&this.isStarted()&&this._tryChangeInputs(),this._unitChanged.fire()}_getSymbolObject(e){const t=super._getSymbolObject(e),i=this.currency();null!==i&&(t["currency-id"]=i);const s=this.unit();return this._model.unitConversionEnabled()&&null!==s&&(t["unit-id"]=s),t}_getSymbolForApi(e){return(0,o.symbolForApi)(this._resolvedSymbolsByInput[e]||null,e)}_onSymbolResolvingStart(){super._onSymbolResolvingStart(),this._symbolResolvingActive.setValue(!0)}_onSymbolError(){super._onSymbolError(),this._symbolResolvingActive.setValue(!1)}_onSymbolResolved(e,t,i){super._onSymbolResolved(e,t,i),this._recreatePriceFormattingDependencies();const s=t===this.symbol()?(0,o.extractSymbolNameFromSymbolInfo)(i,this.symbol()):null,r=(0,o.symbolCurrency)(i),n=(0,o.symbolUnit)(i,this._model.unitConversionEnabled());this._setSymbolCurrencyUnitInternal({symbol:null!=s?s:void 0,currency:r,unit:n},i),this._symbolResolvingActive.setValue(!1)}async _changeInputsImpl(e,t){await super._changeInputsImpl(e,t),this._realignLineToolsIfParamsChanged()}_createStudyOnServer(){super._createStudyOnServer(),this._realignLineToolsIfParamsChanged()}_tryCreateFormatter(){var e,t;const i=null!==(t=null===(e=null===M.customFormatters||void 0===M.customFormatters?void 0:M.customFormatters.priceFormatterFactory)||void 0===e?void 0:e.call(M.customFormatters,this.symbolInfo(),this.properties().childs().minTick.value()))&&void 0!==t?t:null;return null!==i?i:(0,o.createSeriesFormatter)(this.symbolInfo(),this.properties().childs().minTick.value())}_titleInParts(e,t,i,s,r){const n=this.symbolInfo();return[this._getSymbolTitlePart(n),[this._getExchangeTitlePart(n,r),this._getPriceSourceTitlePart(n)].filter((e=>null!==e))]}_skipHistogramBaseOnAutoScale(){return!0}_getSymbolTitlePart(e){var t;if(null===e)return N?"":this.properties().childs().inputs.childs().symbol.value();const i=(0,o.getStudySymbolExchange)(e);if(E&&void 0!==i)return i;if(V)switch(this._model.mainSeries().symbolTextSourceProxyProperty().value()){case"description":return e.description;case"ticker-and-description":return`${e.name}, ${e.description}`;case"long-description":return null!==(t=e.long_description)&&void 0!==t?t:e.description}return e.name}_getExchangeTitlePart(e,t){var i;return null===e||t?null:null!==(i=(0,o.getStudySymbolExchange)(e))&&void 0!==i?i:null}_getPriceSourceTitlePart(e){var t;return O&&!1!==this._model.properties().childs().paneProperties.childs().legendProperties.childs().showPriceSource.value()&&void 0!==(null==e?void 0:e.price_source_id)&&null!==(t=this._model.availablePriceSources().name(e.price_source_id))&&void 0!==t?t:null}_setSymbolCurrencyUnitInternal(e,t){ +this._dataWindowView||(this._dataWindowView=new x(this,this._model)),this._statusView||(this._statusView=new I.StudyStatusView(this)),super._createViews()}_showLastValueOnPriceScale(){return this._model.properties().childs().scalesProperties.childs().showSeriesLastValue.value()}_onUnitChanged(){"alwaysOff"!==(0,r.currencyUnitVisibilityProperty)().value()&&this._model.fullUpdate(),this._model.unitConversionEnabled()&&this.isStarted()&&this._tryChangeInputs(),this._unitChanged.fire()}_getSymbolObject(e){const t=super._getSymbolObject(e),i=this.currency();null!==i&&(t["currency-id"]=i);const s=this.unit();return this._model.unitConversionEnabled()&&null!==s&&(t["unit-id"]=s),t}_getSymbolForApi(e){return(0,o.symbolForApi)(this._resolvedSymbolsByInput[e]||null,e)}_onSymbolResolvingStart(){super._onSymbolResolvingStart(),this._symbolResolvingActive.setValue(!0)}_onSymbolError(){super._onSymbolError(),this._symbolResolvingActive.setValue(!1)}_onSymbolResolved(e,t,i){super._onSymbolResolved(e,t,i),this._recreatePriceFormattingDependencies();const s=t===this.symbol()?(0,o.extractSymbolNameFromSymbolInfo)(i,this.symbol()):null,r=(0,o.symbolCurrency)(i),n=(0,o.symbolUnit)(i,this._model.unitConversionEnabled());this._setSymbolCurrencyUnitInternal({symbol:null!=s?s:void 0,currency:r,unit:n},i),this._symbolResolvingActive.setValue(!1)}async _changeInputsImpl(e,t){await super._changeInputsImpl(e,t),this._realignLineToolsIfParamsChanged()}_createStudyOnServer(){super._createStudyOnServer(),this._realignLineToolsIfParamsChanged()}_tryCreateFormatter(){var e,t;const i=null!==(t=null===(e=null===M.customFormatters||void 0===M.customFormatters?void 0:M.customFormatters.priceFormatterFactory)||void 0===e?void 0:e.call(M.customFormatters,this.symbolInfo(),this.properties().childs().minTick.value()))&&void 0!==t?t:null;return null!==i?i:(0,o.createSeriesFormatter)(this.symbolInfo(),this.properties().childs().minTick.value())}_titleInParts(e,t,i,s,r){const n=this.symbolInfo();return[this._getSymbolTitlePart(n),[this._getExchangeTitlePart(n,r),this._getPriceSourceTitlePart(n)].filter((e=>null!==e))]}_skipHistogramBaseOnAutoScale(){return!0}_getSymbolTitlePart(e){var t;if(null===e)return N?"":this.properties().childs().inputs.childs().symbol.value();const i=(0,o.getStudySymbolExchange)(e);if(V&&void 0!==i)return i;if(E)switch(this._model.mainSeries().symbolTextSourceProxyProperty().value()){case"description":return e.description;case"ticker-and-description":return`${e.name}, ${e.description}`;case"long-description":return null!==(t=e.long_description)&&void 0!==t?t:e.description}return e.name}_getExchangeTitlePart(e,t){var i;return null===e||t?null:null!==(i=(0,o.getStudySymbolExchange)(e))&&void 0!==i?i:null}_getPriceSourceTitlePart(e){var t;return O&&!1!==this._model.properties().childs().paneProperties.childs().legendProperties.childs().showPriceSource.value()&&void 0!==(null==e?void 0:e.price_source_id)&&null!==(t=this._model.availablePriceSources().name(e.price_source_id))&&void 0!==t?t:null}_setSymbolCurrencyUnitInternal(e,t){ const{symbol:i,currency:s,unit:r}=e,n=this.properties().childs(),a=n.inputs.childs().symbol.value(),l=n.currencyId.value(),c=n.unitId.value();if(void 0!==i&&i!==a&&n.inputs.childs().symbol.setValueSilently(i),void 0!==s&&s!==l&&n.currencyId.setValueSilently(s),void 0!==r&&r!==c&&n.unitId.setValueSilently(r),t)this._resolvedSymbolsByInput[this.symbol()]=t,this._resolvedSymbols[this._getSymbolForResolve(this.symbol())]=t,this._realignToolsLastParams=null;else{const e=this.symbolInfo();null!==e&&(n.currencyId.setValueSilently((0,o.symbolCurrency)(e)),n.unitId.setValueSilently((0,o.symbolUnit)(e,this._model.unitConversionEnabled())))}n.inputs.childs().symbol.value()!==a&&n.inputs.childs().symbol.listeners().fire(n.inputs.childs().symbol),n.currencyId.value()!==l&&n.currencyId.listeners().fire(n.currencyId),n.unitId.value()!==c&&n.unitId.listeners().fire(n.unitId),this._realignLineToolsIfParamsChanged()}_realignLineToolsIfParamsChanged(){const e=this.symbol(),t=this.interval(),i=this.currency(),s=this.unit();null!==this._realignToolsLastParams&&this._realignToolsLastParams.symbol===e&&this._realignToolsLastParams.interval===t&&this._realignToolsLastParams.currency===i&&this._realignToolsLastParams.unit===s||(this._model.realignLineTools(this),this._realignToolsLastParams={symbol:e,interval:t,currency:i,unit:s})}}},47468:(e,t,i)=>{"use strict";i.d(t,{StudyOverlayBase:()=>me});var s=i(50151),r=i(49483),n=i(59224),o=i(8708),a=i(81049),l=i(42226),c=i(13497),h=i(42960),d=i(59452),u=i.n(d),p=i(27856),_=i(14483),m=i(71625),g=i(97121),f=i(94025),v=i(97034),S=i(86094),y=i(1722),b=i(34256),w=i(97145),P=i(1763),C=i(90830),x=i(11775),T=i(42275),I=i(74304),M=i(78211),L=i(87095);const A=_.enabled("force_exchange_as_title");class k extends T.PriceAxisView{constructor(e){super(),this._source=e}_updateRendererData(e,t,i){e.visible=!1,t.visible=!1;const r=this._source.lastValueData("close",!1);if(r.noData)return;const n=this._source.model(),o=this._source.priceScale();if(null===o)return;if(!n.isPriceScaleVisible(o))return;const a=n.timeScale().visibleBarsStrictRange(),l=n.mainSeries().bars().lastIndex();if(null===a||null===l)return;if(l<=a.lastBar())i.background=(0,L.resetTransparency)(r.color),i.textColor=this.generateTextColor(r.color),e.borderVisible=!1,t.borderVisible=!1;else{const o=n.backgroundColorAtYPercentFromTop(r.coordinate/(0,s.ensureNotNull)(n.paneForSource(this._source)).height());i.background=o,i.textColor=(0,L.resetTransparency)(r.color),i.borderColor=i.textColor,e.borderVisible=!0,t.borderVisible=!0}i.coordinate=r.coordinate,i.floatCoordinate=r.floatCoordinate;const c=this._source.model().properties().childs().scalesProperties.childs();c.showSeriesLastValue.value()&&(e.text=(0,M.getCurrentModePriceText)(o,r),c.seriesLastValueMode.value()!==I.PriceAxisLastValueMode.LastPriceAndPercentageValue?e.secondLine="":e.secondLine=(0,M.getOppositeModePriceText)(o,r),e.visible=!0),t.text="",c.showSymbolLabels.value()&&(t.text=this._paneText(),t.visible=t.text.length>0)}_paneText(){let e="";const t=this._source.symbolInfo() -;return A?e=(0,h.displayedSymbolExchange)(t):this._source.model().properties().childs().scalesProperties.childs().showSymbolLabels.value()&&(e=(0,h.displayedSymbolName)(t)),e}}var D=i(11527);class V extends D.PriceLineAxisView{constructor(e){super(),this._study=e}_value(){return this._study.lastValueData("",!0)}_priceLineColor(e){return e}_lineWidth(){return 1}_isVisible(){const e=this._study.model().properties().childs().scalesProperties.childs().showSeriesLastValue.value();return this._study.properties().childs().showPriceLine.value()&&e}}var E=i(79849),B=i(74997);class R{constructor(e){this._lineRenderer=new B.HorizontalLineRenderer,this._visible=!1,this._source=e}update(){if(this._visible=!1,!this._source.properties().childs().showPriceLine.value())return;const e=this._source.lastValueData("",!0);e.noData||(this._visible=!0,this._lineRenderer.setData({y:e.coordinate,color:e.color,linewidth:1,linestyle:E.LINESTYLE_DOTTED,visible:this._visible}))}renderer(){return this._visible?this._lineRenderer:null}}var N=i(93835),O=i(15367),F=i(88348),W=i(53414),H=i(37591);const z=r.CheckMobile.any();class U extends N.DataWindowView{constructor(e,t){super(),this._invalidated=!0,this._study=e,this._model=t,this._valueProvider=this._createValuesProvider(e,t),this._items=this._valueProvider.getItems().map((e=>new N.DataWindowItem(e.id,e.title,""))),this.update()}items(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._items}update(){this._invalidated=!0}study(){return this._study}_updateImpl(){var e,t;this._header=this._study.title(H.TitleDisplayTarget.DataWindow);let i;this._showLastPriceAndChangeOnly()?i=this._study.data().lastIndex():(i=this._model.crossHairSource().appliedIndex(),isNaN(i)&&(i=this._study.data().lastIndex(),_.enabled("use_last_visible_bar_value_in_legend")&&(i=null!==(t=null===(e=this._model.timeScale().visibleBarsStrictRange())||void 0===e?void 0:e.lastBar())&&void 0!==t?t:NaN)));const s=this._valueProvider.getValues(i);for(let e=0;ee||t),i.showBarChange.weakReference(),i.showSeriesOHLC.weakReference()),this._visibilityProperty.subscribe(this,this.update)}areValuesVisible(){return this._visibilityProperty.value()}additional(){return this._additional}destroy(){this._backgroundColorSpawn.destroy(),this._visibilityProperty.destroy()}_updateImpl(){super._updateImpl()} +;return A?e=(0,h.displayedSymbolExchange)(t):this._source.model().properties().childs().scalesProperties.childs().showSymbolLabels.value()&&(e=(0,h.displayedSymbolName)(t)),e}}var D=i(11527);class E extends D.PriceLineAxisView{constructor(e){super(),this._study=e}_value(){return this._study.lastValueData("",!0)}_priceLineColor(e){return e}_lineWidth(){return 1}_isVisible(){const e=this._study.model().properties().childs().scalesProperties.childs().showSeriesLastValue.value();return this._study.properties().childs().showPriceLine.value()&&e}}var V=i(79849),B=i(74997);class R{constructor(e){this._lineRenderer=new B.HorizontalLineRenderer,this._visible=!1,this._source=e}update(){if(this._visible=!1,!this._source.properties().childs().showPriceLine.value())return;const e=this._source.lastValueData("",!0);e.noData||(this._visible=!0,this._lineRenderer.setData({y:e.coordinate,color:e.color,linewidth:1,linestyle:V.LINESTYLE_DOTTED,visible:this._visible}))}renderer(){return this._visible?this._lineRenderer:null}}var N=i(93835),O=i(15367),F=i(88348),W=i(53414),H=i(37591);const z=r.CheckMobile.any();class U extends N.DataWindowView{constructor(e,t){super(),this._invalidated=!0,this._study=e,this._model=t,this._valueProvider=this._createValuesProvider(e,t),this._items=this._valueProvider.getItems().map((e=>new N.DataWindowItem(e.id,e.title,""))),this.update()}items(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._items}update(){this._invalidated=!0}study(){return this._study}_updateImpl(){var e,t;this._header=this._study.title(H.TitleDisplayTarget.DataWindow);let i;this._showLastPriceAndChangeOnly()?i=this._study.data().lastIndex():(i=this._model.crossHairSource().appliedIndex(),isNaN(i)&&(i=this._study.data().lastIndex(),_.enabled("use_last_visible_bar_value_in_legend")&&(i=null!==(t=null===(e=this._model.timeScale().visibleBarsStrictRange())||void 0===e?void 0:e.lastBar())&&void 0!==t?t:NaN)));const s=this._valueProvider.getValues(i);for(let e=0;ee||t),i.showBarChange.weakReference(),i.showSeriesOHLC.weakReference()),this._visibilityProperty.subscribe(this,this.update)}areValuesVisible(){return this._visibilityProperty.value()}additional(){return this._additional}destroy(){this._backgroundColorSpawn.destroy(),this._visibilityProperty.destroy()}_updateImpl(){super._updateImpl()} _createValuesProvider(e,t){return new j.OverlayLegendValuesProvider(e,t)}}var $=i(43493),Y=i(7138),K=i(57917),Z=i(41800),X=i(8943),J=i(53275),Q=i(28400),ee=i(11740),te=i(18671),ie=i(79586),se=i(35994),re=i(16410);const ne=_.enabled("show_symbol_logos")&&_.enabled("show_symbol_logo_in_legend")&&_.enabled("show_symbol_logo_for_compare_studies"),oe=(r.CheckMobile.any()||ne)&&!1,ae=_.enabled("uppercase_instrument_names"),le=_.enabled("study_overlay_compare_legend_option"),ce=_.enabled("secondary_series_extend_time_scale"),he=_.enabled("hide_unresolved_symbols_in_legend"),de=!_.enabled("hide_study_overlay_legend_item"),ue=_.enabled("symbol_info_price_source"),pe=(0,n.getLogger)("Chart.StudyOverlay");function _e(e,t){return null==e[t]}class me extends o.Study{constructor(e,t,i,s){super(e,function(e){e.hasChild("currencyId")||e.addChild("currencyId",new(u())(null)),e.hasChild("unitId")||e.addChild("unitId",new(u())(null)),(0,re.allChartStyles)().includes(e.childs().style.value())||e.childs().style.setValueSilently(2);const t=e.childs();if(t.lineStyle.hasChild("styleType")){const e=t.lineStyle.childs(),i=e.styleType.value();let s;0===i&&(t.style.setValueSilently(14),s=t.lineWithMarkersStyle.childs()),1===i&&(t.style.setValueSilently(15),s=t.steplineStyle.childs()),s&&(s.color.setValueSilently(e.color.value()),s.linestyle.setValueSilently(e.linestyle.value()),s.linewidth.setValueSilently(e.linewidth.value()),s.priceSource.setValueSilently(e.priceSource.value())),t.lineStyle.removeProperty("styleType")}return e.addExclusion("currencyId"),e.addExclusion("unitId"),e}(t),i,s),this._quotesProvider=new m.QuotesProvider,this._seriesSource=null,this._symbolResolvingActive=new w.WatchedValue(!1),this._symbolHibernated=new w.WatchedValue(!1),this._styleToRecover=null,this._isActingAsSymbolSource=new w.WatchedValue(!0),this._realignToolsLastParams=null,this._precomputedBarStyles=new WeakMap,this.m_data=new v.PlotList((0,c.seriesPlotFunctionMap)(),_e),oe&&this._quotesProvider.quotesUpdate().subscribe(this,this._onQuotesUpdate);const r=this.properties().childs();r.currencyId.subscribe(this,this._onCurrencyChanged),r.unitId.subscribe(this,this._onUnitChanged),r.allowExtendTimeScale.subscribe(this,this._onAllowExtendTimeScaleChanged),this._onAllowExtendTimeScaleChanged(),r.style.subscribe(this,this._onChartStyleChanged),r.lineStyle.childs().priceSource.subscribe(this,this._updateBarFunction),r.lineWithMarkersStyle.childs().priceSource.subscribe(this,this._updateBarFunction),r.steplineStyle.childs().priceSource.subscribe(this,this._updateBarFunction),r.areaStyle.childs().priceSource.subscribe(this,this._updateBarFunction),r.baselineStyle.childs().priceSource.subscribe(this,this._updateBarFunction),r.columnStyle.childs().priceSource.subscribe(this,this._updateBarFunction),this._updateBarFunction(),this._formatter=null,e.mainSeries().onIntervalChanged().subscribe(this,(()=>e.realignLineTools(this)))}destroy(){this._model.mainSeries().onIntervalChanged().unsubscribeAll(this),super.destroy()}isActingAsSymbolSource(){ return this._isActingAsSymbolSource.readonly()}precomputedBarStyle(e){return this._precomputedBarStyles.get(e)}setPrecomputedBarStyle(e,t){this._precomputedBarStyles.set(e,t)}properties(){return this._properties}barColorer(){return new se.SeriesBarColorer(this)}setSymbolParams(e){this._setSymbolParamsInternal(e)}symbol(){return this.properties().childs().inputs.childs().symbol.value()}symbolChanged(){return this.properties().childs().inputs.childs().symbol.listeners()}setSymbol(e){this.setSymbolParams({symbol:e})}symbolInfo(){if(!this._resolvedSymbols)return null;const e=this._properties.childs().inputs.childs().symbol.value();if(!e)return null;let t;return t=this._resolvedSymbols[this._getSymbolForResolve(e)]||null,t}supportsPressedChunks(){return!1}pressedChunks(e,t){throw new Error("Pressed chunks are not supported")}data(){return null===this._seriesSource?super.data():this._seriesSource.data().bars()}symbolResolved(){return this.symbolsResolved()}symbolResolvingActive(){return this._symbolResolvingActive}symbolHibernated(){return this._symbolHibernated}isVisible(){const e=super.isVisible();return this._symbolHibernated.setValue(!e),e}symbolSameAsCurrent(e){return(0,g.symbolSameAsCurrent)(e,this.symbolInfo())}priceSource(){const e=this.properties().childs();switch(e.style.value()){case 2:return e.lineStyle.childs().priceSource.value();case 14:return e.lineWithMarkersStyle.childs().priceSource.value();case 15:return e.steplineStyle.childs().priceSource.value();case 3:return e.areaStyle.childs().priceSource.value();case 10:return e.baselineStyle.childs().priceSource.value();case 13:return e.columnStyle.childs().priceSource.value()}return null}barFunction(){return this._barFunction}quotesProvider(){return this._quotesProvider}quotes(){return this._quotesProvider.quotes()}currency(){return this.properties().childs().currencyId.value()||null}setCurrency(e){this.setSymbolParams({currency:e})}isConvertedToOtherCurrency(){return(0,h.isConvertedToOtherCurrency)(this.symbolInfo())}unit(){return this.properties().childs().unitId.value()||null}setUnit(e){this.setSymbolParams({unit:e})}isConvertedToOtherUnit(){return(0,h.isConvertedToOtherUnit)(this.symbolInfo(),this._model.unitConversionEnabled())}style(){return this.properties().childs().style.value()}setStyle(e){this.setSymbolParams({style:e})}interval(){return this._model.mainSeries().interval()}setInterval(e){}valueAt(e,t){var i,s;return null!==(s=null===(i=this.data().search(e))||void 0===i?void 0:i.value[t])&&void 0!==s?s:null}symbolSource(){return this}barsProvider(){return this}state(e,t){const i=super.state(e,t);return this._model.unitConversionEnabled()||delete i.state.unitId,e&&((0,s.ensureDefined)(i.data).symbols={___snapshot:this.symbolInfo()||void 0}),i}symbolTitle(e,t,i){return this.title(e,!0,{},!1,t)}title(e,t,i,s,r){var n;const o=this._titleInParts(e,t,i,s,r),a=[o[0],...null!==(n=o[1])&&void 0!==n?n:[]].join(", ");return ae?a.toUpperCase():a}titleInParts(e,t,i,s,r){return[this.title(e,t,i,s,r)]}isStarted(){ return null===this._seriesSource?super.isStarted():this._seriesSource.isStarted()}sourceId(){return null===this._seriesSource?super.sourceId():(0,s.ensureNotNull)(this._seriesSource.instanceId())}moveData(e){null===this._seriesSource?super.moveData(e):this._seriesSource.moveData(e)}firstValue(){const e=this._model.timeScale().visibleBarsStrictRange();if(null===e)return null;const t=e.firstBar();if(0===this.data().size())return this._ownFirstValue;const i=this.data().search(t,S.PlotRowSearchMode.NearestRight,1);return this._ownFirstValue=null!==i?this._barFunction(i.value,0):null,this._ownFirstValue}lastValueData(e,t,i){const s={noData:!0},r=this.priceScale();if(this._model.timeScale().isEmpty()||null===r||r.isEmpty()||this.data().isEmpty())return s;const n=this._model.timeScale().visibleBarsStrictRange();if(null===n)return s;const o=this.properties().childs();if(!o.visible.value())return s;const a=this.nearestIndex(n.lastBar(),S.PlotRowSearchMode.NearestLeft,1);if(void 0===a)return s;const l=this.firstValue();if(null===l)return s;const c=this._lastNonEmptyPlotRow(4),h=null!==c&&n.contains(c.index),d=null!==c?c.value:null,u=t||h?d:this.data().valueAt(a);if(null===u)return s;const p=this._barFunction(u,2);if(!(0,y.isNumber)(p))return s;const _=r.priceToCoordinate(p,l);let m;switch(o.style.value()){case 0:m=u[1]<=u[4]?o.barStyle.childs().upColor.value():o.barStyle.childs().downColor.value();break;case 1:case 9:m=u[1]<=u[4]?o.candleStyle.childs().upColor.value():o.candleStyle.childs().downColor.value();break;case 13:m=u[1]<=u[4]?o.columnStyle.childs().upColor.value():o.columnStyle.childs().downColor.value();break;case 2:m=o.lineStyle.childs().color.value();break;case 14:m=o.lineWithMarkersStyle.childs().color.value();break;case 15:m=o.steplineStyle.childs().color.value();break;case 3:m=o.areaStyle.childs().color1.value();break;case 16:m=o.hlcAreaStyle.childs().closeLineColor.value();break;case 10:{const e=o.baselineStyle.childs();m=_(0,s.ensureNotNull)(this.priceScale()).height(),color:()=>e.baselineColor.value(),baseLevelPercentage:()=>e.baseLevelPercentage.value()});break}case 12:r=new ie.SeriesHiLoPaneView(this,this._model)}r&&this._paneViews.push(r),null!==i&&this._paneViews.push(i),this._paneViews.push(new R(this)),this._dataWindowView||(this._dataWindowView=new U(this,this._model)),this._legendView||(this._legendView=new q(this,this._model)),this._statusView||(this._statusView=new C.StudyStatusView(this)),this._priceAxisViews=[...this._priceAxisViewsBase],this._labelPaneViews.push(new $.PanePriceAxisView(e,this,this._model))}_createStudyOnServer(){null===this._seriesSource?super._createStudyOnServer():this._modifyStudyOnServer((0,s.ensureDefined)(this._inputs)),this._realignLineToolsIfParamsChanged()}_modifyStudyOnServer(e){null===this._seriesSource?super._modifyStudyOnServer(e,0):(this._seriesSource.modifySeries((0,p.decodeExtendedSymbol)(e.symbol),(0,f.getServerInterval)(this._series.properties().childs().interval.value())),this._seriesSource.isStarted()||this._seriesSource.start())}_stopStudyOnServer(){null===this._seriesSource?super._stopStudyOnServer():this._seriesSource.stop()}_titleInParts(e,t,i,s,r){const n=this.symbolInfo();return[this._getSymbolTitlePart(n),[this._getExchangeTitlePart(n,r),this._getPriceSourceTitlePart(n)].filter((e=>null!==e))]}_getSymbolTitlePart(e){var t;if(null===e)return he?"":this.properties().childs().inputs.childs().symbol.value();if(le)switch(this._model.mainSeries().symbolTextSourceProxyProperty().value()){case"description":return e.description;case"ticker-and-description":return`${e.name}, ${e.description}`;case"long-description":return null!==(t=e.long_description)&&void 0!==t?t:e.description}return e.name}_getExchangeTitlePart(e,t){var i;return null===e||t?null:null!==(i=(0,h.getStudySymbolExchange)(e))&&void 0!==i?i:null}_getPriceSourceTitlePart(e){var t +const t=this.symbolInfo(),i=(0,h.extractSymbolNameFromSymbolInfo)(t,e);this._quotesProvider.setQuotesSessionSymbol(i)}_createViews(){this._priceAxisViews=[];const e=new k(this);this._priceAxisViewsBase=[e];const t=new E(this);this._priceLinesAxisViews=[t],this._paneViews=[],this._labelPaneViews=[];let i=null,r=null;switch(this.properties().childs().style.value()){case 0:r=new Y.SeriesBarsPaneView(this,this._model);break;case 1:r=new K.SeriesCandlesPaneView(this,this._model);break;case 9:r=new ee.SeriesHollowCandlesPaneView(this,this._model);break;case 13:r=new te.SeriesColumnsPaneView(this,this._model);break;case 2:case 14:case 15:r=new Z.SeriesLinePaneView(this,this._model);break;case 3:r=new X.SeriesAreaPaneView(this,this._model);break;case 16:r=new J.SeriesHLCAreaPaneView(this,this._model);break;case 10:{r=new Q.SeriesBaselinePaneView(this,this._model);const e=this.properties().childs().baselineStyle.childs();i=new x.SeriesWaterlinePaneView({paneHeight:()=>(0,s.ensureNotNull)(this.priceScale()).height(),color:()=>e.baselineColor.value(),baseLevelPercentage:()=>e.baseLevelPercentage.value()});break}case 12:r=new ie.SeriesHiLoPaneView(this,this._model)}r&&this._paneViews.push(r),null!==i&&this._paneViews.push(i),this._paneViews.push(new R(this)),this._dataWindowView||(this._dataWindowView=new U(this,this._model)),this._legendView||(this._legendView=new q(this,this._model)),this._statusView||(this._statusView=new C.StudyStatusView(this)),this._priceAxisViews=[...this._priceAxisViewsBase],this._labelPaneViews.push(new $.PanePriceAxisView(e,this,this._model))}_createStudyOnServer(){null===this._seriesSource?super._createStudyOnServer():this._modifyStudyOnServer((0,s.ensureDefined)(this._inputs)),this._realignLineToolsIfParamsChanged()}_modifyStudyOnServer(e){null===this._seriesSource?super._modifyStudyOnServer(e,0):(this._seriesSource.modifySeries((0,p.decodeExtendedSymbol)(e.symbol),(0,f.getServerInterval)(this._series.properties().childs().interval.value())),this._seriesSource.isStarted()||this._seriesSource.start())}_stopStudyOnServer(){null===this._seriesSource?super._stopStudyOnServer():this._seriesSource.stop()}_titleInParts(e,t,i,s,r){const n=this.symbolInfo();return[this._getSymbolTitlePart(n),[this._getExchangeTitlePart(n,r),this._getPriceSourceTitlePart(n)].filter((e=>null!==e))]}_getSymbolTitlePart(e){var t;if(null===e)return he?"":this.properties().childs().inputs.childs().symbol.value();if(le)switch(this._model.mainSeries().symbolTextSourceProxyProperty().value()){case"description":return e.description;case"ticker-and-description":return`${e.name}, ${e.description}`;case"long-description":return null!==(t=e.long_description)&&void 0!==t?t:e.description}return e.name}_getExchangeTitlePart(e,t){var i;return null===e||t?null:null!==(i=(0,h.getStudySymbolExchange)(e))&&void 0!==i?i:null}_getPriceSourceTitlePart(e){var t ;return ue&&!1!==this._model.properties().childs().paneProperties.childs().legendProperties.childs().showPriceSource.value()&&void 0!==(null==e?void 0:e.price_source_id)&&null!==(t=this._model.availablePriceSources().name(e.price_source_id))&&void 0!==t?t:null}_onAllowExtendTimeScaleChanged(){if(!ce)return;const e=this.isStarted();e&&this.stop(!0);const t=this.properties().childs().allowExtendTimeScale.value();this.properties().childs().inputs.childs().extendTimeScale.setValue(t),e&&this.start(!0)}_setSymbolParamsInternal(e,t){const{symbol:i,currency:s,unit:r,style:n}=e,o=this.properties().childs(),a=o.inputs.childs().symbol.value(),l=o.currencyId.value(),c=o.unitId.value(),d=o.style.value();if(void 0!==i&&i!==a&&o.inputs.childs().symbol.setValueSilently(i),void 0!==s&&s!==l&&o.currencyId.setValueSilently(s),void 0!==r&&r!==c&&o.unitId.setValueSilently(r),void 0!==n&&o.style.setValueSilently(n),t)this._resolvedSymbolsByInput[this.symbol()]=t,this._resolvedSymbols[this._getSymbolForResolve(this.symbol())]=t,this._realignToolsLastParams=null;else{const e=this.symbolInfo();null!==e&&(o.currencyId.setValueSilently((0,h.symbolCurrency)(e)),o.unitId.setValueSilently((0,h.symbolUnit)(e,this._model.unitConversionEnabled())))}o.inputs.childs().symbol.value()!==a&&o.inputs.childs().symbol.listeners().fire(o.inputs.childs().symbol),o.currencyId.value()!==l&&o.currencyId.listeners().fire(o.currencyId),o.unitId.value()!==c&&o.unitId.listeners().fire(o.unitId),o.style.value()!==d&&o.style.listeners().fire(o.style),this._checkStyle(),this._realignLineToolsIfParamsChanged()}_updateBarFunction(){this._barFunction=(0,a.barFunctionByStyle)(this.style(),this.priceSource())}_onChartStyleChanged(){var e;this._updateBarFunction(),(null===(e=this._styleToRecover)||void 0===e?void 0:e.originalStyle)!==this.style()&&(this._styleToRecover=null)}_checkStyle(){const e=this.style();(0,h.isCloseBasedSymbol)(this.symbolInfo())?(0,h.isSingleValueBasedStyle)(e)||(this.setStyle(2),this._styleToRecover={correctedStyle:this.style(),originalStyle:e}):null!==this._styleToRecover&&(this.setStyle(this._styleToRecover.originalStyle),this._styleToRecover=null)}_realignLineToolsIfParamsChanged(){const e=this.symbol(),t=this.interval(),i=this.currency(),s=this.unit();null!==this._realignToolsLastParams&&this._realignToolsLastParams.symbol===e&&this._realignToolsLastParams.interval===t&&this._realignToolsLastParams.currency===i&&this._realignToolsLastParams.unit===s||(this._model.realignLineTools(this),this._realignToolsLastParams={symbol:e,interval:t,currency:i,unit:s})}}},45802:(e,t,i)=>{"use strict";i.d(t,{StudyPriceAxisView:()=>o});var s=i(50151),r=i(42275),n=i(87095);class o extends r.PriceAxisView{constructor(e,t){super(),this._model=e.model(),this._source=e,this._data=t}_updateRendererData(e,t,i){e.visible=!1,t.visible=!1;const r=this._source.model(),o=this._source.priceScale();if(null===o)return;if(!r.isPriceScaleVisible(o))return;const a=this._source.lastValueData(this._data.plotIndex,!1);if(a.noData)return ;const l=r.timeScale().visibleBarsStrictRange(),c=r.mainSeries().bars().lastIndex();if(null!==l&&null!==c){if(c<=l.lastBar()){i.background=(0,n.resetTransparency)(a.color);let s=a.color;"transparent"===s&&(s=this._model.properties().childs().scalesProperties.childs().backgroundColor.value()),i.textColor=this.generateTextColor(s),i.borderColor=void 0,e.borderVisible=!1,t.borderVisible=!1}else{const o=r.backgroundColorAtYPercentFromTop(a.coordinate/(0,s.ensureNotNull)(r.paneForSource(this._source)).height());i.background=o,i.textColor=(0,n.resetTransparency)(a.color),i.borderColor=(0,n.resetTransparency)(i.textColor),e.borderVisible=!0,t.borderVisible=!0}i.coordinate=a.coordinate,i.floatCoordinate=a.floatCoordinate,this._showAxisLabel()&&(e.text=a.text,e.visible=!0),this._updatePaneRendererData(t)}}_showPaneLabel(){return!!this._model.properties().childs().scalesProperties.childs().showStudyPlotLabels.value()&&this._source.properties().childs().showLabelsOnPriceScale.value()&&this._source.isPlotVisibleAt(this._data.plotIndex,4)}_showAxisLabel(){return!!this._model.properties().childs().scalesProperties.childs().showStudyLastValue.value()&&this._source.properties().childs().showLabelsOnPriceScale.value()&&this._source.isPlotVisibleAt(this._data.plotIndex,4)}_updatePaneRendererData(e){e.text="",this._showPaneLabel()&&(e.text=this._source.priceLabelText(this._data.plotIndex),e.visible=!0)}}},19386:(e,t,i)=>{"use strict";i.d(t,{applyOverridesToStudy:()=>c,applyOverridesToStudyDefaults:()=>h});var s=i(50151),r=i(72877);const n=(0,i(59224).getLogger)("Chart.Model.StudyPropertiesOverrider");var o,a;function l(e,t,i,s){const r=i.split(".");if(0===r.length||0===r[0].length)return;const l=function(e){const t=e.split(":");return{name:t[0],type:2===t.length?t[1]:null}}(r[0]),c=l.name,h=l.type,d=null!==h,u=!d||"band"===h,p=!d||"area"===h,_=!d||"input"===h,m=!d||"plot"===h?a.getPlotIdByTitle(e,c):null,g=u?a.getBandIndexByName(e,c):null,f=p?a.getFilledAreaIdByTitle(e,c):null,v=_?a.getInputByName(e,c):null,S=t.hasOwnProperty(c);if((null!==m?1:0)+(null!==g?1:0)+(null!==f?1:0)+(null!==v?1:0)+(S?1:0)>1)return void n.logWarn(`Study '${e.description}' has ambiguous identifier '${c}'`);const y=r[1];if(null!==m){if(1===r.length)return void n.logWarn(`Path of sub-property of '${c}' plot for study '${e.description}' must be not empty`);const i=r.slice(1);o.applyPlotProperty(e,t,m,i,s)}else if(null!==v)o.applyInputValue(t,v,s);else if(null!==g){if(void 0===y)return void n.logWarn(`Property name of '${c}' band for study '${e.description}' must be set`);o.applyBandProperty(t,g,y,s)}else if(null!==f){if(void 0===y)return void n.logWarn(`Property name of '${c}' area for study '${e.description}' must be set`);o.applyFilledAreaProperty(t,f,y,s)}else S?o.setRootProperty(t,r,s):n.logWarn(`Study '${e.description}' has no plot or input '${c}'`)}function c(e,t){const i=e.properties(),s=i.state();for(const i in t)t.hasOwnProperty(i)&&l(e.metaInfo(),s,i,t[i]);i.mergeAndFire(s)}function h(e,t,i){for(const s in e){if(!e.hasOwnProperty(s))continue ;const r=s.indexOf(".");if(-1===r)continue;const o=s.substring(0,r),c=a.getMetaInfoByDescription(t,o);if(null===c){n.logWarn(`There is no such study ${o}`);continue}const h=i(c);null!==h?l(c,h,s.substring(r+1),e[s]):n.logWarn(`Cannot apply overrides for study ${o}`)}}!function(e){const t={line:r.LineStudyPlotStyle.Line,histogram:r.LineStudyPlotStyle.Histogram,cross:r.LineStudyPlotStyle.Cross,area:r.LineStudyPlotStyle.Area,columns:r.LineStudyPlotStyle.Columns,circles:r.LineStudyPlotStyle.Circles,line_with_breaks:r.LineStudyPlotStyle.LineWithBreaks,area_with_breaks:r.LineStudyPlotStyle.AreaWithBreaks,step_line:r.LineStudyPlotStyle.StepLine,step_line_with_breaks:r.LineStudyPlotStyle.StepLineWithBreaks};e.applyPlotProperty=function(e,i,o,a,l){if(void 0===i.styles)return void n.logWarn("Study does not have styles");const c=a[0];if("color"===c){const t=function(e,t,i){if(void 0===e.plots)return null;for(const s of e.plots){if(!(0,r.isPaletteColorerPlot)(s)||void 0===t.palettes)continue;const e=t.palettes[s.palette];if(s.target===i&&void 0!==e)return e}return null}(e,i,o);return void function(e,t,i,r,o){var a;void 0!==e.styles?null===t&&!isNaN(r)&&r>0?n.logWarn(`Study plot does not have color #${r}`):((0===r||isNaN(r))&&((0,s.ensureDefined)(e.styles[i]).color=String(o),r=0),null!==t&&((0,s.ensureDefined)(null===(a=t.colors)||void 0===a?void 0:a[r]).color=String(o))):n.logWarn("Study does not have styles")}(i,t,o,a.length>1?parseInt(a[1]):NaN,l)}const h=i.styles[o];if(void 0!==h&&h.hasOwnProperty(c)){if("plottype"===c){const e=t[String(l)];if(void 0===e)return void n.logWarn(`Unsupported plot type for plot: ${l}`);l=e}h[c]=l}else n.logWarn(`Study plot does not have property '${c}'`)},e.applyBandProperty=function(e,i,s,r){if(void 0===e.bands)return void n.logWarn("Study does not have bands");const o=e.bands[i];if(void 0!==o&&o.hasOwnProperty(s)){if("plottype"===s){const e=t[String(r)];if(void 0===e)return void n.logWarn(`Unsupported plot type for band: ${r}`);r=e}o[s]=r}else n.logWarn(`Study band does not have property '${s}'`)},e.applyFilledAreaProperty=function(e,t,i,s){if(void 0===e.filledAreasStyle)return void n.logWarn("Study does not have areas");const r=e.filledAreasStyle[t];void 0!==r&&r.hasOwnProperty(i)?r[i]=s:n.logWarn(`Study area does not have property '${i}'`)},e.applyInputValue=function(e,t,i){void 0!==e.inputs&&e.inputs.hasOwnProperty(t)?e.inputs[t]=i:n.logWarn(`Study does not have input '${t}'`)},e.setRootProperty=function(e,t,i){if(0===t.length)return;let s=e;for(const e of t.slice(0,-1)){if(null==s||!s.hasOwnProperty(e))break;s=s[e]}const r=t[t.length-1];null!=s&&s.hasOwnProperty(r)?s[r]=i:n.logWarn(`Study does not have property ${t.join(".")}`)}}(o||(o={})),function(e){e.getInputByName=function(e,t){if(void 0===e.inputs)return null;t=t.toLowerCase();for(const i of e.inputs)if(i.name.toLowerCase()===t)return i.id;return null},e.getPlotIdByTitle=function(e,t){if(void 0===e.styles)return null;t=t.toLowerCase();for(const i in e.styles){const s=e.styles[i] @@ -825,28 +825,28 @@ s.isLineTool)(e)&&!e.isSpeciallyZOrderedSource()}function c(e){return(0,r.isStud o=n(e[l])):(l=M(e,i-1,s),o=n(e[l]),c=I(e,i+t,s),a=n(e[c]));if((void 0===o||o<0)&&void 0!==a&&a<=0)f(e.slice(0,c),a,r,s);else if((void 0===a||a>0)&&void 0!==o&&o>=0)v(e.slice(l+1),o,r,s);else{i+t0)&&void 0!==a&&a>=0){c=a;const e=g(c,void 0!==l?l:C(a),t);c=e.startZOrder,p=e.zOrderStep,d=i,u=d+t,h=1}if(0!==p)for(;d!==u;){const t=_(c+h*p);n(e[d],t),c=t,d+=h}else{const t=e.findIndex((e=>r(e)));-1!==t?(f(e.slice(0,t),0,n,s),v(e.slice(t+1),0,n,s)):v(e,0,n,s)}}(c,l,h,r,s,n,o)}function I(e,t,i){for(;t=0&&i(e[t]);)t--;return Math.max(0,t)}function L(e,t,i,s,r,n,o){const a=e.indexOf(i)+1;T(e,t,a,s,r,n,o)}function A(e,t,i,s,r,n,o){const a=e.indexOf(i);T(e,t,a,s,r,n,o)}function k(e,t,i){L(e,t,i,n.isSeries,c,u,p)}function D(e,t,i){A(e,t,i,n.isSeries,c,u,p)}},65106:(e,t,i)=>{"use strict";i.d(t,{getSymbolSearchCompleteOverrideFunction:()=>n,setSymbolSearchCompleteOverrideFunction:()=>r});let s=(e,t)=>{var i;return Promise.resolve({symbol:e,name:null!==(i=null==t?void 0:t.symbol)&&void 0!==i?i:e})};function r(e){s=e}function n(){return s}},60762:(e,t,i)=>{"use strict";i.d(t,{StudyMetaInfoBase:()=>u});var s=i(27147),r=i(50151),n=i(33703);const o=new Set(["CorrelationCoefficient@tv-basicstudies","Correlation - Log@tv-basicstudies-1"]),a=new Set([]),l=new Set(["line"]),c=new Map([["AnchoredVWAP@tv-basicstudies","linetoolanchoredvwap"],["RegressionTrend@tv-basicstudies","linetoolregressiontrend"],["VbPAnchored@tv-basicstudies","linetoolanchoredvp"]]),h=/^([^\$]+)\$\d+$/,d=["bool","color","time","text_area"];class u{static getSourceIdsByInputs(e,t){if(!Array.isArray(e)||!t)return[];const i=[];for(const r of e)if(u.isSourceInput(r)&&(0,s.default)(t[r.id])){const e=t[r.id];e.includes("$")&&i.push(e.split("$")[0])}return i}static isSourceInput(e){return Boolean(e.id&&(("source"===e.id||"src"===e.id)&&("text"===e.type||"source"===e.type)||"source"===e.type))}static getSourceInputIds(e){const t=[];for(const i of e.inputs)u.isSourceInput(i)&&t.push(i.id);return t}static setChildStudyMetaInfoPropertiesSourceId(e,t,i){for(const s of e.inputs){if(!u.isSourceInput(s))continue;const e=i.childs().inputs&&i.childs().inputs.childs()[s.id];if(e){const i=e.value(),s=h.exec(i);if(2===(null==s?void 0:s.length)){if("{pid}"===s[1]){const s=i.replace(/^[^\$]+/,t);e.setValue(s)}}}}}static patchSoSInputs(e,t){const i=e=>{const i=h.exec(e);if(2===(null==i?void 0:i.length)){const s=i[1],n=`${(0,r.ensureNotNull)(t(s))}`;return e.replace(/^[^\$]+/,n)}return e};for(const t in e)if(/in_[\d+]/.test(t)||"source"===t){const r=e[t];(0,s.default)(r)?e[t]=i(r):(0,n.isExtendedInput)(r)&&(0,n.isExtendedInputSource)(r)&&(r.v=i(r.v))}}static canBeChild(e){ if((0,s.default)(e))return!0;if(!e)return!1;if(e.extra&&!u.isAllowedSourceInputsCount(e.extra.sourceInputsCount)||!0===e.canNotBeChild||!1===e.canBeChild||o.has(e.id))return!1;let t=0;for(const i of e.inputs)u.isSourceInput(i)&&(t+=1);return u.isAllowedSourceInputsCount(t)}static isAllowedSourceInputsCount(e){return 1===e}static canHaveChildren(e){if(e){if(e.isTVScriptStrategy||e.TVScriptSourceCode&&isStrategy(e.TVScriptSourceCode))return!1;if(e.id&&!a.has(e.id)&&Array.isArray(e.plots))for(const t of e.plots)if(l.has(t.type))return!0}return!1}static getChildSourceInputTitles(e,t,i){var s;const r={};if(t.plots&&t.plots.length&&e.options&&e.options.length)for(const n of e.options){const e=n?+n.split("$")[1]:NaN,o=isFinite(e)&&t.plots[e];o&&l.has(o.type)&&(r[n]=t.styles&&t.styles[o.id]&&(null===(s=t.styles[o.id])||void 0===s?void 0:s.title)||o.id,i&&(r[n]=i+": "+r[n]))}return r}static canPlotBeSourceOfChildStudy(e){return l.has(e)}static getStudyPropertyRootName(e){const t=c.get(e.id);if(void 0!==t)return t;let i="study_"+e.id;return e.pine&&e.pine.version&&(i+="_"+e.pine.version.replace(".","_")),i}static getStudyPropertyRootNameById(e){const t=c.get(e);return void 0!==t?t:"study_"+e}_updateInputDisplayDefaults(){this.inputs.filter((e=>void 0===e.display)).forEach((e=>{d.includes(e.type)?e.display=n.InputDisplayFlags.None:e.display=n.InputDisplayFlags.All}))}}},42856:(e,t,i)=>{"use strict";i.d(t,{StudyMetaInfo:()=>a});var s=i(59224).getLogger("Chart.Study.MetaInfo"),r=i(19386).applyOverridesToStudyDefaults,n=i(60762).StudyMetaInfoBase,o={};class a extends n{constructor(e){super(),TradingView.merge(this,{palettes:{},inputs:[],plots:[],graphics:{},defaults:{}}),TradingView.merge(this,e);var t=e.fullId||e.id;TradingView.merge(this,a.parseIdString(t)),this._updateInputDisplayDefaults()}static versionOf(e){var t="_metainfoVersion"in e&&isNumber(e._metainfoVersion)?e._metainfoVersion:0;return t<0&&s.logError("Metainfo format version cannot be negative: "+t),t}static parseIdString(e){var t={};if(-1===e.indexOf("@"))t.shortId=e,t.packageId="tv-basicstudies",t.id=e+"@"+t.packageId,t.version=1;else{var i=e.split("@");t.shortId=i[0];var s=i[1].split("-");if(3===s.length)t.packageId=s.slice(0,2).join("-"),t.id=t.shortId+"@"+t.packageId,t.version=s[2];else if(1===s.length&&"decisionbar"===s[0])t.packageId="les-"+s[0],t.id=t.shortId+"@"+t.packageId,t.version=1;else{if(1!==s.length)throw new Error("unexpected study id:"+e);t.packageId="tv-"+s[0],t.id=t.shortId+"@"+t.packageId,t.version=1}}if(t.fullId=t.id+"-"+t.version,"tv-scripting"===t.packageId){var r=t.shortId;if(0===r.indexOf("Script$")||0===r.indexOf("StrategyScript$")){var n=r.indexOf("_");t.productId=n>=0?r.substring(0,n):t.packageId}else t.productId=t.packageId}else t.productId=t.packageId;return t}static getPackageName(e){return(/^[^@]+@([^-]+-[^-]+)/.exec(e||"")||[0,"tv-basicstudies"])[1]}static cutDollarHash(e){var t=e.indexOf("$"),i=e.indexOf("@");return-1===t?e:e.substring(0,t)+(i>=0?e.substring(i):"")}static hasUserIdSuffix(e){return/^USER;[\d\w]+;\d+$/.test(e)} static hasPubSuffix(e){return/^PUB;.+$/.test(e)}static hasStdSuffix(e){return/^STD;.+$/.test(e)}static isStandardPine(e){return/^(Strategy)?Script\$STD;.*@tv-scripting$/.test(e)}static getStudyIdWithLatestVersion(e){const t=a.cutDollarHash(e.id);let i=t;return t.indexOf("@tv-scripting")>=0?i+="-101!":t.endsWith("CP@tv-basicstudies")?i+="-"+Math.min(e.version,207):t.endsWith("CP@tv-chartpatterns")?i+="-"+Math.min(e.version,9):i+="-"+e.version,i}defaultInputs(){for(var e=[],t=0;t0?e[0].id:null}createDefaults(){if(this.defaults){var e=TradingView.clone(this.defaults);e.precision="default";var t=a.getStudyPropertyRootName(this);defaults.create(t,e)}}removeDefaults(){defaults.remove(a.getStudyPropertyRootName(this))}static findStudyMetaInfoByDescription(e,t){if(e){for(var i=0;i{"use strict";window.TradingView=window.TradingView||{},window.requireAll=function(e){return e.keys().map(e)},i(2298),i(32563).setClasses(),i(95374),i(56186).install(),i(49483),i(1722),i(42053),i(11417),i(54358),i(56696),i(56840)},62898:(e,t,i)=>{"use strict";var s=i(1836),r=i(43370),n=i(50151);function o(){return window}function a(){const e=o();return e.parent[e.urlParams.uid]}var l=i(44352),c=(i(44232),i(58005),i(85804)),h=(i(89173),i(14483));const d=o();JSON.parse(d.urlParams.disabledFeatures).forEach((e=>{h.setEnabled(e,!1)})),JSON.parse(d.urlParams.enabledFeatures).forEach((e=>{h.setEnabled(e,!0)}));var u=i(56840);const p=o(),_=a();p.__settingsOverrides=_.settingsOverrides||{};const m=_.settingsAdapter;null!=m?(u.setSettingsAdapter(m),u.sync()):h.enabled("use_localstorage_for_settings")&&u.sync();var g=i(46501);const f=o();f.urlParams.customFontFamily&&(0,g.setChartFontFamily)(f.urlParams.customFontFamily);var v=i(38881);class S extends v.ChunkLoader{_startLoading(){ -return Promise.all([i.e(2684),i.e(2666),i.e(3842),i.e(4015),i.e(6),i.e(5993),i.e(5649),i.e(8056),i.e(6752),i.e(8149),i.e(6639),i.e(6036),i.e(6106),i.e(4894),i.e(3127),i.e(6025),i.e(6949),i.e(1033),i.e(4081),i.e(962),i.e(3179),i.e(5050),i.e(3291),i.e(5516)]).then(i.bind(i,76087)).then((e=>e.getRestrictedToolSet()))}}var y=i(69774),b=i(24899);function w(e=[],t=[]){const i=document.createElement("div"),s=document.createElement("div");return i.appendChild(s),i.classList.add(b.container),s.classList.add(b.inner),e.forEach((e=>{i.classList.add(b[e])})),t.forEach((e=>{i.classList.add(b[e])})),i}class P extends v.ChunkLoader{constructor(e,t){super(),this._toolsBootloader=e,this._headerProps=t,this._headerProps.resizerBridge.negotiateHeight(y.HEADER_TOOLBAR_HEIGHT_EXPANDED),this._headerProps.resizerBridge.container.value().appendChild(w())}_startLoading(){return Promise.all([this._toolsBootloader.load(),this._loadHeaderToolbar()]).then((([e,t])=>new t(this._headerProps.resizerBridge.container.value(),{...this._headerProps,tools:e})))}_loadHeaderToolbar(){return Promise.all([i.e(3066),i.e(962),i.e(1044),i.e(3005)]).then(i.bind(i,46618)).then((e=>e.HeaderToolbarRenderer))}}var C=i(14873),x=i(9438);class T extends v.ChunkLoader{constructor(e){super(),this._opts=e,C.isDrawingToolbarVisible.value()&&(this._opts.resizerBridge.negotiateWidth(x.TOOLBAR_WIDTH_EXPANDED),this._opts.resizerBridge.container.value().appendChild(w()))}_startLoading(){return Promise.all([i.e(2427),i.e(2666),i.e(3842),i.e(4015),i.e(5993),i.e(5649),i.e(6752),i.e(3980),i.e(1109),i.e(3127),i.e(6959),i.e(962),i.e(8385),i.e(3179),i.e(769),i.e(1890),i.e(2020),i.e(2878)]).then(i.bind(i,14186)).then((e=>new e.DrawingToolbarRenderer(this._opts.resizerBridge.container.value(),{...this._opts})))}}var I=i(66501),M=i(32563),L=i(5286),A=i(45345);var k=i(58844),D=i(4741),V=i(3343);function E(e){if("number"==typeof e)return e;switch(e.toLowerCase()){case"ctrl":return V.Modifiers.Control;case"shift":return V.Modifiers.Shift;case"alt":return V.Modifiers.Alt;default:return e.toUpperCase().charCodeAt(0)}}function B(e){let t=0;for(let i=0;i{if(!U)return void this._renameActionHandler(e,t,s,r);const{newValue:n,dialogClose:o}=e,a=(await this._doLoad()).find((e=>e.name===n));o(),void 0!==a?this._hide=await(0,z.showConfirm)({title:l.t(null,void 0,i(56996)), +return Promise.all([i.e(2684),i.e(2666),i.e(3842),i.e(4015),i.e(6),i.e(5993),i.e(5649),i.e(8056),i.e(6752),i.e(8149),i.e(6639),i.e(6036),i.e(6106),i.e(4894),i.e(3127),i.e(6025),i.e(6949),i.e(1033),i.e(4081),i.e(962),i.e(3179),i.e(5050),i.e(3291),i.e(5516)]).then(i.bind(i,76087)).then((e=>e.getRestrictedToolSet()))}}var y=i(69774),b=i(24899);function w(e=[],t=[]){const i=document.createElement("div"),s=document.createElement("div");return i.appendChild(s),i.classList.add(b.container),s.classList.add(b.inner),e.forEach((e=>{i.classList.add(b[e])})),t.forEach((e=>{i.classList.add(b[e])})),i}class P extends v.ChunkLoader{constructor(e,t){super(),this._toolsBootloader=e,this._headerProps=t,this._headerProps.resizerBridge.negotiateHeight(y.HEADER_TOOLBAR_HEIGHT_EXPANDED),this._headerProps.resizerBridge.container.value().appendChild(w())}_startLoading(){return Promise.all([this._toolsBootloader.load(),this._loadHeaderToolbar()]).then((([e,t])=>new t(this._headerProps.resizerBridge.container.value(),{...this._headerProps,tools:e})))}_loadHeaderToolbar(){return Promise.all([i.e(3066),i.e(962),i.e(1044),i.e(3005)]).then(i.bind(i,46618)).then((e=>e.HeaderToolbarRenderer))}}var C=i(14873),x=i(9438);class T extends v.ChunkLoader{constructor(e){super(),this._opts=e,C.isDrawingToolbarVisible.value()&&(this._opts.resizerBridge.negotiateWidth(x.TOOLBAR_WIDTH_EXPANDED),this._opts.resizerBridge.container.value().appendChild(w()))}_startLoading(){return Promise.all([i.e(2427),i.e(2666),i.e(3842),i.e(4015),i.e(5993),i.e(5649),i.e(6752),i.e(3980),i.e(1109),i.e(3127),i.e(6959),i.e(962),i.e(8385),i.e(3179),i.e(769),i.e(1890),i.e(2020),i.e(2878)]).then(i.bind(i,14186)).then((e=>new e.DrawingToolbarRenderer(this._opts.resizerBridge.container.value(),{...this._opts})))}}var I=i(66501),M=i(32563),L=i(5286),A=i(45345);var k=i(58844),D=i(4741),E=i(3343);function V(e){if("number"==typeof e)return e;switch(e.toLowerCase()){case"ctrl":return E.Modifiers.Control;case"shift":return E.Modifiers.Shift;case"alt":return E.Modifiers.Alt;default:return e.toUpperCase().charCodeAt(0)}}function B(e){let t=0;for(let i=0;i{if(!U)return void this._renameActionHandler(e,t,s,r);const{newValue:n,dialogClose:o}=e,a=(await this._doLoad()).find((e=>e.name===n));o(),void 0!==a?this._hide=await(0,z.showConfirm)({title:l.t(null,void 0,i(56996)), text:l.t(null,void 0,i(30192)),onConfirm:({dialogClose:e})=>{e(),this._doOverwriteExistingLayout(a.id,n,t,s,r)},onCancel:({dialogClose:e})=>{e(),this._showRenameDialog(n,t,s,r)}}):this._renameActionHandler({newValue:n,dialogClose:o},t,s,r)},onClose:()=>this._visibility.setValue(!1)})}_doSaveCurrentLayout(e,t,i,s){const r=this._chartWidgetCollection.metaInfo.name.value();this._chartWidgetCollection.metaInfo.name.setValue(e),this._doSave(t,i,(()=>{this._chartWidgetCollection.metaInfo.name.setValue(r),null==s||s()}))}_doOverwriteExistingLayout(e,t,i,s,r){const n=this._chartWidgetCollection.metaInfo.name.value();this._chartWidgetCollection.metaInfo.id.setValue(e),this._chartWidgetCollection.metaInfo.name.setValue(t),this._doSave(i,s,(()=>{this._chartWidgetCollection.metaInfo.name.setValue(n),null==r||r()}))}}class G extends j{cloneChart(){this._cloneChart().then((()=>this._visibility.setValue(!0)))}show(){F((()=>this.cloneChart()),{source:"Clone chart"})}_renameDialogTitle(){return l.t(null,void 0,i(87898))}_renameDialogText(){return l.t(null,void 0,i(24435))+":"}_renameActionHandler({newValue:e,dialogClose:t}){h.enabled("saveload_storage_customization")&&this._doCloneCurrentLayout(e),t()}async _cloneChart(){let e;try{e=await H()}catch(e){return void showErrorDialog({content:l.t(null,void 0,i(56670))})}e&&(this._hide=await this._showRenameDialog(this._getInitialRenameDialogInput()))}_doCloneCurrentLayout(e){const t=this._chartWidgetCollection.metaInfo.name.value();this._chartWidgetCollection.metaInfo.uid.deleteValue(),this._chartWidgetCollection.metaInfo.id.deleteValue(),this._chartWidgetCollection.metaInfo.name.setValue(e),this._doSave(void 0,void 0,(()=>{this._chartWidgetCollection.metaInfo.name.setValue(t)}))}_getInitialRenameDialogInput(){return l.t(null,{context:"ex: AAPL chart copy"},i(16493)).format({title:this._chartWidgetCollection.metaInfo.name.value()})}}class q extends j{show(e,t,i){const s="function"==typeof e?e:void 0;this._saveNewChart(s,t,i).then((()=>this._visibility.setValue(!0)))}_renameDialogTitle(){return l.t(null,void 0,i(10520))}_renameDialogText(){return l.t(null,void 0,i(24435))+":"}_renameActionHandler({newValue:e,dialogClose:t},i,s,r){this._doSaveCurrentLayout(e,i,s,r),t()}async _saveNewChart(e,t,s){let r;try{r=await H()}catch(e){return void showErrorDialog({content:l.t(null,void 0,i(56670))})}const n=this._chartWidgetCollection.metaInfo.name.value();this._hide=await this._showRenameDialog(n,e,t,s)}}class $ extends j{show(){F((()=>this._show()),{source:"Rename chart"})}_renameDialogTitle(){return l.t(null,void 0,i(4142))}_renameDialogText(){return l.t(null,void 0,i(24435))+":"}_renameActionHandler({newValue:e,dialogClose:t}){this._doSaveCurrentLayout(e),t()}async _show(){await this._renameChart(),this._visibility.setValue(!0)}async _renameChart(){const e=this._chartWidgetCollection.metaInfo.name.value();this._hide=await this._showRenameDialog(e)}}class Y{constructor(e,t){this._autosaveTimer=null,this._watchedAutoSaveEnabled=new N.WatchedValue, this._toggleAutoSaveEnabledHandler=this._toggleAutoSaveEnabled.bind(this),this._doSave=(e,t,i,s)=>{const r=this._chartWidgetCollection;void 0!==e&&e();const n=this._chartChangesWatcher.changes();this._chartSaver.saveChartSilently((e=>{var i;i=r.metaInfo.uid.value(),"/chart/"===location.pathname&&(location.href="/chart/"+i),void 0!==t&&t(e)}),(()=>{void 0!==i&&i()}),{autoSave:Boolean(s),changes:n})},this._doLoad=()=>W.backend.getCharts(),this._chartWidgetCollection=e,this._chartSaver=t,this._createController=new q(e,this._doSave,this._doLoad),this._renameController=new $(e,this._doSave,this._doLoad),this._saveAsController=new G(e,this._doSave,this._doLoad),this._chartChangesWatcher=new I.ChartChangesWatcher(e,t,O),e.saveKeysPressed().subscribe(this,this.saveChartOrShowTitleDialog),this._chartChangesWatcher.getOnChange().subscribe(this,this._onStateChanged)}autoSaveEnabled(){return this._watchedAutoSaveEnabled}destroy(){0}getCreateController(){return this._createController}getRenameController(){return this._renameController}getSaveAsController(){return this._saveAsController}cloneChart(){this._saveAsController.cloneChart()}saveChartAs(){this._saveAsController.show()}renameChart(){this._renameController.show()}saveNewChart(e,t,i){this._createController.show(e,t,i)}saveExistentChart(e,t,i){this._doSave(e,t,i)}changes(){return this._chartChangesWatcher.changes()}hasChanges(){return 0!==this._chartChangesWatcher.changes()}saveChartOrShowTitleDialog(e,t,i){const s=window.saver.isSaveInProcess(),r=this._chartChangesWatcher.hasChanges(),n=!!this._chartWidgetCollection.metaInfo.id.value();window.is_authenticated&&(s||!r&&n)||F((()=>{null!=this._chartWidgetCollection.metaInfo.id.value()?this.saveExistentChart(e,t,i):this.saveNewChart(e,t,i)}),{source:"Save chart",sourceMeta:"Chart"})}saveToJSON(){return this._chartSaver.saveToJSON()}saveChartSilently(e,t,i){this._chartSaver.saveChartSilently(e,t,i)}setAutoSaveEnabled(e){window.is_authenticated&&window.saver.isSaveInProcess()||F((()=>{this._watchedAutoSaveEnabled.setValue(e)}),{source:"AutoSave chart"})}saveChartLineTools(e,t,i,s){return this._chartSaver.saveChartLineTools(e,t,i,s)}_autoSaveEnabledSettingHandler(e){0}_toggleAutoSaveEnabled(e){0}_enableAutoSave(){0}_disableAutoSave(){0}_onStateChanged(e){e?this._startAutosave():this._stopAutosave()}_startAutosave(){h.enabled("charts_auto_save")&&null===this._autosaveTimer&&(this._autosaveTimer=setTimeout((()=>{this._autosaveTimer=null,this._chartWidgetCollection.metaInfo.id.value()&&this._doSave(void 0,void 0,void 0,!0)}),6e4))}_stopAutosave(){null!==this._autosaveTimer&&(clearInterval(this._autosaveTimer),this._autosaveTimer=null)}}var K=i(85067),Z=i(21097),X=i(68456);class J extends X.CommonJsonStoreService{constructor(e,t){super(e,t,"FAVORITE_CHARTS_CHANGED","loadChartDialog.favorites",{})}}class Q extends K.DialogRenderer{constructor(e=null){super(),this._chartWidgetCollection=null,this._promise=null,this._dialog=null,this._subscribe=e=>{this._setVisibility(e)},this._getChartEntry=e=>({id:e.id,url:e.url,title:e.name, symbol:e.short_symbol,interval:e.interval,toolsCount:0,modified:e.modified_iso,favorite:void 0,active:()=>this._isActiveChart(e.id),openAction:()=>W.backend.loadChart(e),deleteAction:()=>W.backend.removeChart(e.image_url).then((()=>this._deleteChart(e.id))),favoriteAction:e=>Promise.resolve(this._updateFavorites(e))}),this._updateFavorites=e=>{var t;null===(t=this._favoriteChartsService)||void 0===t||t.set(e)},this._isActiveChart=e=>null!==this._chartWidgetCollection&&e===this._chartWidgetCollection.metaInfo.id.value(),this._deleteChart=e=>{this._isActiveChart(e)&&(h.enabled("saveload_storage_customization")?null!==this._chartWidgetCollection&&this._chartWidgetCollection.clearChartMetaInfo():location.href="/chart/"+location.search)},this._chartWidgetCollection=e,this._favoriteChartsService=new J(Z.TVXWindowEvents,u)}showLoadDialog(){F(this._showLoadDialog.bind(this),{source:"Load chart",sourceMeta:"Chart"})}show(){this.showLoadDialog()}hide(){var e,t;null===(e=this._dialog)||void 0===e||e.hide(),null===(t=this._dialog)||void 0===t||t.visible().unsubscribe(this._subscribe)}_showLoadDialog(){(h.enabled("saveload_requires_authentication")&&!window.is_authenticated?Promise.resolve([]):W.backend.getCharts()).then((e=>e.map(this._getChartEntry))).then((e=>{const t=this._promise=Promise.all([i.e(2666),i.e(1013),i.e(3842),i.e(4015),i.e(5145),i.e(855),i.e(5993),i.e(2587),i.e(6752),i.e(8149),i.e(1054),i.e(898),i.e(962),i.e(8385),i.e(3016),i.e(3179),i.e(5711),i.e(5009)]).then(i.bind(i,34557)).then((i=>{if(this._promise===t){this._dialog&&(this._dialog.hide(),this._dialog.visible().unsubscribe(this._subscribe));const t={charts:e,favoriteChartsService:this._favoriteChartsService,chartWidgetCollection:this._chartWidgetCollection};this._dialog=new i.LoadChartDialogRenderer(t),this._dialog.visible().subscribe(this._subscribe),this._dialog.show()}}))}))}async _changeFavoriteState(e,t,i){return Promise.resolve()}}var ee=i(51768),te=i(57898);const ie=(0,i(59224).getLogger)("Platform.StudyTemplates"),se=l.t(null,void 0,i(97065));class re{constructor(e){this._chartWidgetCollection=e.chartWidgetCollection,this._favoriteStudyTemplatesService=e.favoriteStudyTemplatesService,window.loginStateChange.subscribe(null,W.backend.invalidateStudyTemplatesList),this._list=new N.WatchedValue([]),this._onChange=new te.Delegate,this._list.subscribe((()=>this._onChange.fire()))}findRecordByName(e){return this._list.value().find((t=>t.name===e))||null}showSaveAsDialog(){const e=this._chartWidgetCollection.activeChartWidget.value().model();Promise.all([i.e(2666),i.e(1013),i.e(5145),i.e(855),i.e(6),i.e(2191),i.e(6221),i.e(3502),i.e(4215),i.e(6639),i.e(6884),i.e(3610),i.e(7149),i.e(962),i.e(3016),i.e(4717),i.e(6631)]).then(i.bind(i,13932)).then((t=>{new t.StudyTemplateSaver({controller:e,onSave:e=>{this._list.setValue(e)}}).show()}))}applyTemplate(e){const t=this.findRecordByName(e);null!==t?window.runOrSignIn((()=>{const e=this._chartWidgetCollection.activeChartWidget.value(),i=i=>{(0,ee.trackEvent)("GUI","Load Study Template"), e.model().applyStudyTemplate(JSON.parse(i.content),t.name)};void 0!==t.id?t.is_default?W.backend.getStandardStudyTemplateContentById(t.id,i):W.backend.getStudyTemplateContentById(t.id,i):W.backend.getStudyTemplateContent(t.name).then(i)}),{source:"Study templates apply"}):ie.logNormal(`Template ${e} not found in cache`)}deleteStudyTemplate(e,t){const i=this.findRecordByName(e);null!==i?this._removeTemplate(i,t):ie.logNormal(`Template ${e} not found in cache`)}list(){return this._list.value()}getOnChange(){return this._onChange}refreshStudyTemplateList(e){W.backend.getStudyTemplatesList().then((t=>{this._list.setValue(t),void 0!==e&&e()}))}invalidate(){W.backend.invalidateStudyTemplatesList()}_removeTemplate(e,t){window.runOrSignIn((()=>{(0,z.showConfirm)({text:se.format({name:e.name}),onConfirm:({dialogClose:i})=>new Promise((s=>{const r=()=>{this.refreshStudyTemplateList((()=>{const r=this.list();this._list.setValue(r.filter((t=>t!==e))),this._favoriteStudyTemplatesService&&this._favoriteStudyTemplatesService.remove(e.name),s(),i(),null==t||t()}))};W.backend.invalidateStudyTemplatesList(),void 0!==e.id?W.backend.removeStudyTemplateById(e.id,r):W.backend.removeStudyTemplate(e.name).then(r)}))})}),{source:"Study templates delete"})}}var ne=i(35423),oe=i(82992),ae=i(61146),le=i(1763);class ce{constructor(e,t){this._visibility=new N.WatchedValue(!1),this._dialogPromise=null,this._dialog=null,this._chartWidgetCollection=e,this._options=t}visible(){return this._visibility.readonly()}show(e,t,i){var s;const r=Array.isArray(e)?e:[],n=Array.isArray(e)?void 0:e,o=void 0;null===this._dialog&&this._requestDialog(null!=r?r:[],o,t,i,n),null===(s=this._dialog)||void 0===s||s.open(null!=r?r:[],o,t,i,n)}hide(){var e;null===(e=this._dialog)||void 0===e||e.hide()}getDialog(){return this._dialog}resetAllPages(){var e;null===(e=this._dialog)||void 0===e||e.resetAllStudies()}_requestDialog(e,t,s,r,n){if(null===this._dialogPromise){let o;o=Promise.all([i.e(2666),i.e(1013),i.e(5145),i.e(855),i.e(2191),i.e(2587),i.e(6752),i.e(7350),i.e(6494),i.e(962),i.e(3016),i.e(6456)]).then(i.bind(i,57979)).then((e=>new e.IndicatorsLibraryContainer(this._chartWidgetCollection,this._options))),this._dialogPromise=o.then((i=>{this._dialog=i,this._dialog.visible().subscribe((e=>{this._visibility.setValue(e)})),this._dialog.open(e,t,s,r,n)}))}return this._dialogPromise}}var he=i(51608),de=i(30888),ue=i(36174),pe=i(63821),_e=i(78159),me=i(3228),ge=i(83407),fe=i(16164),ve=i(41249),Se=i(38618),ye=i(96429);const be=/^Etc\/GMT([+-])(\d{1,2}):?(\d\d)?$/,we=new Map;function Pe(e){if(we.has(e))return we.get(e);const t=be.test(e);return we.set(e,t),t}const Ce=new Map;function xe(e){if(Ce.has(e))return Ce.get(e);const t=function(e){const t=e.match(be);if(!t)return 0;const i="+"===t[1]?-1:1;return 60*(60*parseInt(t[2],10)+parseInt(t[3]||"0",10))*i}(e),i={time:[1924992e3+t],offset:[t]};return Ce.set(e,i),i}let Te=null;const Ie=new Map;class Me{constructor(){this._customTimezones=new Map}addTimezones(e){e.forEach((e=>{const{id:t,...i}=e;this._addTimezone(t,i)})), -this.updateChartTimezones()}listTimezoneIds(){return[...this._customTimezones.keys()]}listTimezones(){return[...this._customTimezones.entries()].map((([e,t])=>({id:e,...t})))}getTimezoneInfo(e){if(!this.timezoneIsAvailable(e))throw new Error("Provided timezone alias is not within the list of supported timezones.");return(0,n.ensure)(this._customTimezones.get(e))}getAllTimezoneInfo(){return this.listTimezones()}getAliasTimezone(e){return this.getTimezoneInfo(e).alias}timezoneIsAvailable(e){return this._customTimezones.has(e)}updateChartTimezones(){(0,Se.updateAvailableTimezones)(this.getAllTimezoneInfo())}getTimezoneData(e){if(Ie.has(e))return Ie.get(e);let t=null;if(Pe(e))t=xe(e);else if(this.timezoneIsAvailable(e)){const i=this.getAliasTimezone(e);ye.tzData[i]&&(t=ye.tzData[i]),!t&&Pe(i)&&(t=xe(i))}return t&&Ie.set(e,t),t}static instance(){return null===Te&&(Te=new Me),Te}_addTimezone(e,t){try{if((0,n.ensure)(e,"Custom timezone ID"),(0,n.ensure)(t.alias,"Custom timezone alias"),(0,n.ensure)(t.title,"Custom timezone title"),(0,Se.timezoneIsAvailable)(e)&&!this.timezoneIsAvailable(e))throw new Error("Custom timezone id already exists.");if(!(0,Se.timezoneIsSupported)(t.alias)&&!Pe(t.alias))throw new Error("Custom timezone alias is not a supported timezone.");if(e.length<1)throw new Error("Custom timezone id is empty");if(t.title.length<1)throw new Error("Custom timezone title is empty");this._customTimezones.set(e,t)}catch(e){console.warn(`Unable to add custom timezone. ${e}`)}}}(0,ve.setCustomTimezones)(Me);var Le=i(42226),Ae=i(36274),ke=i(31940);class De{constructor(e){this._document=e,this.isFullscreen=new N.WatchedValue;const t=()=>{const e=["fullscreenElement","webkitFullscreenElement","mozFullscreenElement","mozFullScreenElement","msFullscreenElement"];for(let t=0;t{this.isVisible.setValue(!e[r])},i(),e.addEventListener(t,i,!1);break}}this.destroy=()=>{i&&(e.removeEventListener(t,i,!1),i=null)}}}var Ee=i(84015),Be=i(49483);function Re(e,t){let i=0;for(const{min:s,max:r}of t){if(e0&&t.push({min:e,max:s})}return t.sort(((e,t)=>e.min-t.min||e.max-t.max)),t}function Oe(e,t){if(e.length!==t.length)return!1;for(let i=e.length;i--;){if(e[i].min!==t[i].min)return!1;if(e[i].max!==t[i].max)return!1}return!0}const Fe=h.enabled("no_min_chart_width");function We(e){const t=h.enabled("side_toolbar_in_fullscreen_mode"),i=h.enabled("header_in_fullscreen_mode");return"center"===e||"left"===e&&t||"top"===e&&i}var He=i(2438),ze=i(98310),Ue=i(16216),je=(i(26665),i(3162)),Ge=i.n(je),qe=i(241),$e=i(88348),Ye=i(15367),Ke=i(68335);var Ze=i(2269),Xe=i.n(Ze),Je=i(42856),Qe=i(75117),et=i.n(Qe),tt=(i(24172),i(46544),i(78136)),it=i(88732),st=i(74649),rt=i(97906),nt=i(27714),ot=i(12481),at=i(86441),lt=i(34026),ct=i(48891),ht=i(15742),dt=i(18807),ut=i(61345),pt=i(87095),_t=i(88275),mt=i(74359),gt=i(68441),ft=i(34565),vt=i(66103),St=i(70893),yt=i(50946);i(77275);const bt=new Map([["logo-old-style",yt],["tradingview-old-style",St]]),wt=h.enabled("adaptive_logo"),Pt=h.enabled("small_no_display"),Ct=h.enabled("38914"),xt="site_branding",Tt="widget_branding",It="widget_referral_branding",Mt="widget_custom_branding",Lt="widget_custom_no_powered_branding",At="fundamental_branding",kt="fundamental_custom_branding",Dt="fundamental_custom_no_powered_branding",Vt="library_branding",Et="library_custom_branding",Bt="library_custom_no_powered_branding",Rt=navigator.userAgent.toLowerCase().indexOf("chrome")>-1&&-1===navigator.userAgent.toLowerCase().indexOf("edge"),Nt=window.urlParams||{};window.initData;Nt.no_referral_id&&enable(Nt.referral_id||"","aggressive");const Ot=l.t(null,void 0,i(26619)),Ft=Ct?l.t(null,void 0,i(5607)):l.t(null,void 0,i(68111)),Wt=(l.t(null,void 0,i(82128)),l.t(null,void 0,i(88841)),l.t(null,void 0,i(99769)),(0,Be.onWidget)(),{brandCircleSize:32,textAsImageWidthCompensation:0,leftOffset:0,bottomOffset:-23,logoLeftOffset:1,maximizedWidthsCompensation:0,logoTextOffset:6});class Ht extends ht.CustomSourceBase{constructor(e,t,i){super(e,t),this._canvasWidth=0,this._paneHeight=0,this._left=13,this._bottom=36,this._layout=xt,this._needToShow=!0,this._showBranding=!1,this._customLogoSrc="",this._customLogoLink="",this._cubicBezier=new ut.CubicBezier(.4,.01,.22,1),this._openAnimation=null,this._closeAnimation=null,this._powBy=null,this._custom=null,this._destroyed=!1,this._mainSeries=this._model.mainSeries(),this._visible=i,this._showForPro=!t.onWidget();const s=()=>this._model.updateSource(this);this._visible.subscribe(s),this._dark=t.dark().spawn(),this._dark.subscribe(s),this._checkLayout(),this._layout!==Mt&&this._layout!==kt||(this._left=8,this._bottom=5);const r=()=>{this._needToShow?this._showBranding=!0:this._showBranding=!1};this._resizeHandlerDelayed=(0,ot.default)(r,200),r(),window.addEventListener("resize",this._resizeHandlerDelayed),this._monitorCanvas=(0,mt.createDisconnectedBoundCanvas)(document,(0,nt.size)({width:0,height:0})), -this._monitorCanvas.subscribeSuggestedBitmapSizeChanged((()=>{this._init()})),this._model.isSnapshot()?this._init():(this._mainSeries.dataEvents().symbolResolved().subscribe(this,this._init),null!==this._mainSeries.symbolInfo()&&this._init()),this._renderer={draw:this.draw.bind(this),hitTest:this.hitTest.bind(this)},t.onWidget()||window.loginStateChange.subscribe(this,this._init)}destroy(){window.removeEventListener("resize",this._resizeHandlerDelayed),this._mainSeries.dataEvents().symbolResolved().unsubscribeAll(this),this._powBy&&this._powBy.destroy(),this._model.onWidget()||window.loginStateChange.unsubscribeAll(this),this._visible.release(),this._dark.destroy(),this._destroyed=!0}paneViews(e){if(window.TradingView.printing&&this._layout!==Lt&&this._layout!==Dt)return[];if(!this._visible.value())return[];if(this._layout===xt&&!this._showForPro&&window.user&&window.user.is_pro)return[];const t=h.enabled("move_logo_to_main_pane");let i=!1;if(e.maximized().value())i=!0;else if(t)i=this._model.mainPane().collapsed().value()?e===this._model.panes().find((e=>!e.collapsed().value())):e.isMainPane();else if(this._model.lastPane().collapsed().value()){const t=this._model.panes();for(let s=t.length-1;s>=0;--s){const r=t[s];if(!r.collapsed().value()){i=r===e;break}}}else i=e.isLast();return i?[{renderer:this.renderer.bind(this)}]:[]}labelPaneViews(e){return[]}priceAxisViews(e,t){return[]}updateAllViews(){}updateViewsForPane(e){}priceScale(){return null}renderer(e,t){return this._paneHeight=e,this._canvasWidth=t,this._renderer}hasContextMenu(){return!1}onClickOutside(){this._hasAnimation()&&this._startCloseAnimation()}hitTest(e){if(!this._showBranding||h.enabled("logo_without_link"))return null;if(this._powBy&&this._layout!==Lt&&this._layout!==Dt&&(this._powBy.hitTest(e)||this._custom&&this._custom.hitTest(e))){const e=!0;return new dt.HitTestResult(dt.HitTarget.Custom,{hideCrosshairLinesOnHover:!0,cursorType:e?vt.PaneCursorType.Pointer:vt.PaneCursorType.Default,clickHandler:()=>{this._openLink()},tapHandler:()=>{this._hasAnimation()?this._toggleOpenAnimatedOrOpenLink():this._openLink()},mouseEnterHandler:()=>{this._hasAnimation()&&this._startOpenAnimation()},mouseLeaveHandler:()=>{this._hasAnimation()&&this._startCloseAnimation()}})}return null}tvUrl(){let e=new URL("https://www.tradingview.com/");if(this._customLogoLink)return this._customLogoLink;if(this._layout===Vt||this._layout===Et){let t;switch(!0){case h.enabled("charting_library"):t="library";break;case h.enabled("trading_terminal"):t="trading-terminal"}e.searchParams.append("utm_source",window.location.origin),e.searchParams.append("utm_medium","library"),t&&e.searchParams.append("utm_campaign",t)}return e.toString()}draw(e,t){if(!this._showBranding)return;let i=0;Nt.utm=!0,(0,mt.drawScaled)(e,t.pixelRatio,t.pixelRatio,(()=>{if(this._powBy&&this._powBy.show){i=this._powBy.height,e.save();const s=new at.Point(this._left,this._paneHeight-this._bottom-i);this._powBy.draw(s,e,t,this._canvasWidth),e.restore()}if(this._custom&&this._custom.show){e.save() -;const s=new at.Point(this._left,this._paneHeight-this._bottom-i-this._custom.height);this._custom.draw(s,e,t),e.restore()}}))}_init(){this._checkLayout();const e=this._mainSeries.symbolInfo();this._powBy&&this._powBy.destroy(),this._powBy=new Xt(this._layout,(null==e?void 0:e.name)||"",this._model,(()=>this._model.fullUpdate())),this._custom=new Jt(this._layout,this._customLogoSrc,(()=>this._model.fullUpdate())),this._openAnimation=null,this._closeAnimation=null,this._model.lightUpdate()}_checkLayout(){if(h.enabled("widget"))0;else{{const e=JSON.parse(Nt.logo)||{};e.image?(this._customLogoSrc=e.image,this._customLogoLink=e.link,this._needToShow=h.enabled("widget_logo"),h.enabled("link_to_tradingview")?this._layout=Et:this._layout=Bt):(this._layout=Vt,this._needToShow=h.enabled("widget_logo"))}}}_startOpenAnimation(){null===this._openAnimation&&(null!==this._closeAnimation&&(this._closeAnimation.stop(),this._closeAnimation=null),this._openAnimation=(0,_t.doAnimate)({from:this._currentStateForAnimation(),to:this._openedStateForAnimation(),duration:200,easing:this._cubicBezier.easingFunc,onStep:this._animatedDrawStep.bind(this)}))}_startCloseAnimation(){null===this._closeAnimation&&(null!==this._openAnimation&&(this._openAnimation.stop(),this._openAnimation=null),this._closeAnimation=(0,_t.doAnimate)({from:this._currentStateForAnimation(),to:this._closedStateForAnimation(),duration:200,easing:this._cubicBezier.easingFunc,onStep:this._animatedDrawStep.bind(this)}))}_currentStateForAnimation(){return(0,n.ensureNotNull)(this._powBy).width}_closedStateForAnimation(){return(0,n.ensureNotNull)(this._powBy).minimizedAnimationWidth()}_openedStateForAnimation(){return(0,n.ensureNotNull)(this._powBy).maximizedAnimationWidth()}_animatedDrawStep(e,t){(0,n.ensureNotNull)(this._powBy).animatedDrawStep(e,t),this._model.lightUpdate()}_hasAnimation(){return null!==this._powBy&&this._powBy.hasAnimation()}_openGoPro(){0}_openLink(){if(this._layout===xt)return this._openGoPro(),!1;h.enabled("widget");return(0,n.ensureNotNull)(window.open(this.tvUrl(),"_blank")).opener=null,!0}_toggleOpenAnimatedOrOpenLink(){null!==this._openAnimation&&this._openAnimation.completed()?this._openLink()||this._startCloseAnimation():this._startOpenAnimation()}}function zt(e){return!Pt||e>480}function Ut(e){return!wt||e>500}const jt={customBrandingTradingViewText:ct.colorsPalette["color-brand"],customBrandingText:ct.colorsPalette["color-cold-gray-850"],background:ct.colorsPalette["color-cold-gray-900"],shadow:ct.colorsPalette["color-cold-gray-700"],text:ct.colorsPalette["color-white"],staticTextBackground:(0,pt.generateColor)(ct.colorsPalette["color-cold-gray-800"],20),logo:ct.colorsPalette["color-white"]},Gt={customBrandingTradingViewText:ct.colorsPalette["color-brand"],customBrandingText:ct.colorsPalette["color-cold-gray-850"],background:ct.colorsPalette["color-white"],shadow:ct.colorsPalette["color-cold-gray-150"],text:ct.colorsPalette["color-cold-gray-900"],staticTextBackground:(0,pt.generateColor)(ct.colorsPalette["color-white"],20), -logo:ct.colorsPalette["color-cold-gray-900"]};function qt(e,t){return new Promise((i=>{const s=e.replace(/fill="#[\da-f]{6}"/gi,`fill="${t}"`),r=new Image;r.onload=()=>{r.onload=null,i(r)},r.src=URL.createObjectURL(new Blob([s],{type:"image/svg+xml"}))}))}let $t={},Yt={};function Kt(e,t,i){const s=Yt,r=e+t,o=s[r];if(void 0!==o)return o;const a=(0,n.ensureDefined)(bt.get("logo-old-style")),l=(0,n.ensureDefined)(bt.get("tradingview-old-style")),c=qt(a,t),h=qt(l,t);return Promise.all([c,h]).then((([e,t])=>{const n={logoImage:e,textImage:t};s[r]=n,i(n)})),null}class Zt{constructor(){this._topLeftPoint=null}hitTest(e){const t=this._getHitTestBox();if(t)return(0,lt.pointInBox)(e,t)}_getHitTestBox(){const e=this._topLeftPoint;if(e){const{x:t,y:i}=e;return(0,at.box)(e,new at.Point(t+this.width,i+this.height))}}}class Xt extends Zt{constructor(e,t,i,s){super(),this.show=!0,this._needDisplayImage=!1,this._animatedWidth=Wt.brandCircleSize,this._font=`px ${g.CHART_FONT_FAMILY}`,this._txt="TradingView",this._textWidth=0,this._maximizedAnimationTextWidth=0,this._textWidthCache=new ft.TextWidthCache,this._pixelRatio=1,this._onLogoImageReady=e=>{this._requestRepaint()},this._model=i,this._layout=e,this._symbol=t,this._showAnimatedBranding=h.enabled("show_animated_logo")||this._layout===Tt,this._alwaysMaximized=h.enabled("logo_always_maximized")||!1,this._fontSize=this._showAnimatedBranding||this._layout===It?11:14,this._showAnimatedBranding||this._layout!==Mt&&this._layout!==kt||(this._fontSize=12),this.width=Wt.brandCircleSize,this.height=this._fontSize+2,this._requestRepaint=s,this._init(),this._checkFontLoaded(),this._recalculateMetrics()}destroy(){this._model.properties().childs().paneProperties.childs().background.unsubscribeAll(this),this._model.onChartThemeLoaded().unsubscribeAll(this)}hasAnimation(){return this._showAnimatedBranding&&!this._alwaysMaximized}minimizedAnimationWidth(){return Wt.brandCircleSize}maximizedAnimationWidth(){return Wt.brandCircleSize+Wt.logoTextOffset+this._maximizedAnimationTextWidth}animatedDrawStep(e,t){this._animatedWidth=t}draw(e,t,i,s){const{brandCircleSize:r,logoLeftOffset:n,leftOffset:o,bottomOffset:a}=Wt;this._needDisplayImage&&zt(s)&&(e=new at.Point(e.x+o,e.y-a)),this._topLeftPoint=e,t.translate(e.x,e.y),i.pixelRatio!==this._pixelRatio&&(this._textWidthCache.reset(),this._pixelRatio=i.pixelRatio);const l=this._colors;if(this._showAnimatedBranding){const e=this._getLogoImage(l.logo);this._needDisplayImage&&e&&this._drawLogo(t,e,this._animatedWidth,this._animatedWidth-r,this._animatedWidth>r)}else if(this._layout===Mt||this._layout===kt){t.font=this._fontSize+this._font;const e=t.measureText(this._txt).width+2;this.width=e+t.measureText("TradingView").width+2,t.save(),t.globalAlpha=.7,t.fillStyle=this._colors.customBrandingText,t.fillText(this._txt,0,12),t.fillStyle=this._colors.customBrandingTradingViewText,t.fillText("TradingView",e,12),t.restore()}else if(zt(s)&&this._layout===It){const e=this._getLogoImage(l.logo),i=this.maximizedAnimationWidth();e&&this._drawLogo(t,e,i,i,!0) -}else if(zt(s)){const e=this._getLogoImage(l.logo);if(this._needDisplayImage&&e){t.save(),this._drawBgCircle(t,r/2);const i=new at.Point(Math.round((r-e.logoImage.width)/2)-1+n,Math.floor((r-e.logoImage.height)/2)+1);this._drawLogoImage(t,i,e.logoImage);const o=Ut(s);o&&(t.translate(r+5,Math.round(this._fontSize*("px EuclidCircular"===this._font?.1:0))),this._drawTextStroke(t),this._drawTextFill(t)),t.restore(),this.width=r,o&&(this.width+=this._maximizedAnimationTextWidth)}else{const e=Ut(s);e&&(t.save(),t.translate(Rt?-.5:0,-.5),this._drawTextStroke(t),this._drawTextFill(t),t.restore()),e&&(this.width=this._maximizedAnimationTextWidth)}}else this.width=0}_drawLogo(e,t,i,s,r){const{brandCircleSize:n,logoLeftOffset:o,logoTextOffset:a}=Wt;e.save(),this._drawFillRectWithRoundedCorner(e,-.5,0,i,n,n/2);const l=new at.Point(Math.round((n-t.logoImage.width)/2)-1+o,Math.floor((n-t.logoImage.height)/2)+1);if(this._drawLogoImage(e,l,t.logoImage),r){const i=new at.Point(l.x+t.logoImage.width+a,l.y);this._drawImageCropWidth(e,i,t.textImage,s),this.width=t.logoImage.width+Math.min(t.textImage.width,s)}e.restore()}_init(){Yt={},$t={},this._checkLayout(),this.show&&(this._updateColors(),this.height=this._needDisplayImage?Wt.brandCircleSize:this._fontSize+2,this._model.properties().childs().paneProperties.childs().background.subscribe(this,this._updateColors),this._model.onChartThemeLoaded().subscribe(this,this._updateColors))}_checkFontLoaded(){if(!this._showAnimatedBranding&&document.fonts&&document.fonts.check&&document.fonts.load){document.fonts.check(`${this._fontSize}px EuclidCircular`)?this._font="px EuclidCircular":document.fonts.load(`${this._fontSize}px EuclidCircular`,this._txt).then((()=>{this._font="px EuclidCircular",this._recalculateMetrics(),this._requestRepaint()}))}}_recalculateMetrics(){const e=(0,mt.createDisconnectedBoundCanvas)(document,(0,nt.size)({width:0,height:0})),t=(0,mt.getPretransformedContext2D)(e,!0);t.font=this._fontSize+this._font;const i=this._needDisplayImage?Kt(this._model.dark().value()?"dark":"light",this._colors.logo,(()=>this._recalculateMetrics())):null;this._textWidth=i?i.textImage.width+Wt.textAsImageWidthCompensation:Math.ceil(t.measureText(this._txt).width)+2+8;let s=this._textWidth;s%2==0&&(s+=1),this._maximizedAnimationTextWidth=s,this._textWidthCache.reset(),this._alwaysMaximized&&(this._animatedWidth=this.maximizedAnimationWidth())}_updateColors(){this._colors=this._model.dark().value()?jt:Gt}_getLogoImage(e){return Kt(this._model.dark().value()?"dark":"light",e,this._onLogoImageReady)}_checkLayout(){switch(this._layout){case Tt:case It:case Mt:case At:case kt:case Et:case Vt:case xt:this.show=!0;break;case Lt:case Dt:case Bt:this.show=!1}switch(this._layout){case Vt:this._needDisplayImage=!0,this._txt=Ot;break;case Et:this._txt=Ft}}_drawTextStroke(e){e.save(),e.textBaseline="middle",e.textAlign="start",e.font=this._fontSize+this._font,e.strokeStyle=this._colors.staticTextBackground,e.lineWidth=4,e.lineJoin="round", -e.strokeText(this._txt,0,Wt.brandCircleSize/2+this._textWidthCache.yMidCorrection(e,this._txt)),e.restore()}_drawTextFill(e){e.save(),e.textBaseline="middle",e.textAlign="start",e.font=this._fontSize+this._font,e.fillStyle=this._colors.text,e.fillText(this._txt,0,Wt.brandCircleSize/2+this._textWidthCache.yMidCorrection(e,this._txt)),e.restore()}_drawImageCropWidth(e,t,i,s){e.save(),e.beginPath(),e.rect(t.x,t.y,s,this.height),e.clip(),e.drawImage(i,t.x,t.y),e.restore()}_drawBgCircle(e,t){const i=2*Math.PI;e.save(),e.beginPath(),e.fillStyle=this._colors.shadow,e.arc(t,t,t+1,0,i),e.fill(),e.closePath(),e.restore(),e.save(),e.beginPath(),e.fillStyle=this._colors.background,e.arc(t,t,t,0,i,!1),e.fill(),e.closePath(),e.restore()}_drawFillRectWithRoundedCorner(e,t,i,s,r,n){e.save(),(0,gt.drawRoundRect)(e,t-1,i-1,s+2,r+2,n),e.fillStyle=this._colors.shadow,e.fill(),e.closePath(),e.restore(),e.save(),(0,gt.drawRoundRect)(e,t,i,s,r,n),e.fillStyle=this._colors.background,e.fill(),e.closePath(),e.restore()}_drawLogoImage(e,t,i){e.drawImage(i,t.x,t.y)}}class Jt extends Zt{constructor(e,t,i){super(),this.show=!1,this.width=0,this.height=0,this._ready=!1,this._layout=e,this._src=t,this._onReadyCallback=i,this._checkLayout();const s=new Image;this._img=s,this.show&&(s.addEventListener("load",(()=>{this.width=Math.round(s.width),this.height=Math.round(s.height),this._ready=!0,this._onReadyCallback&&this._onReadyCallback()})),s.crossOrigin="anonymous",s.src=this._src)}draw(e,t,i){this._topLeftPoint=e,this._ready&&(t.translate(e.x,e.y),t.drawImage(this._img,-.5,-.5,this.width,this.height))}_checkLayout(){switch(this._layout){case Mt:case Lt:case kt:case Dt:case Et:case Bt:this.show=!0;break;case xt:case Tt:case It:case At:case Vt:this.show=!1}}}var Qt=i(97304),ei=i(65106);class ti{constructor(e,t){this._headerToolbar=e,this._dropdownId=t}applyOptions(e){this._headerToolbar.updateDropdown(this._dropdownId,e)}remove(){this._headerToolbar.removeDropdown(this._dropdownId)}}var ii=i(90194),si=i(75593);class ri{constructor(e){this._symbolModel=e}getVisible(){return this._symbolModel.visible().value()}setVisible(e){return this._symbolModel.visible().setValue(e),this}getIcon(){return this._symbolModel.icon().value()}setIcon(e){return this._symbolModel.icon().setValue(e),this}getColor(){return this._symbolModel.color().value()}setColor(e){return this._symbolModel.color().setValue(e),this}getTooltip(){return this._symbolModel.tooltip().value()}setTooltip(e){return this._symbolModel.tooltip().setValue(e),this}getDropDownContent(){return this._symbolModel.tooltipContent().value()}setDropDownContent(e){return this._symbolModel.tooltipContent().setValue(e),this}}class ni{symbol(e){return new ri(this._model().getSymbolCustomStatus(e))}hideAll(){this._model().hideAll()}static getInstance(){return null===this._instance&&(this._instance=new ni),this._instance}_model(){return si.CustomStatusModel.getInstance()}}ni._instance=null;var oi,ai=i(39347),li=i(16838);(0,M.setClasses)();const ci=o(),hi=a(),di=new class{constructor(e,t){ -this._updateDocumentHeight=e=>{"visual"===this._viewportType&&this._window.document.documentElement.style.setProperty("height",`${e}px`,"important")},this._window=e,this._fullscreenApi=new De(e.document),this._viewportType=Be.CheckMobile.iOS()&&!(0,Ee.isOnMobileAppPage)("any")&&this._window.visualViewport?"visual":"quirks","visual"===this._viewportType?this._viewport=(0,n.ensure)(this._window.visualViewport):this._viewport=this._window;const i=this._layoutSizeSensor=this._window.document.createElement("div");i.id="layout-size-sensor",i.style.position="fixed",i.style.top="0",i.style.left="0",i.style.right="0",i.style.bottom="0",i.style.pointerEvents="none",i.style.visibility="hidden",this._initFullscreen()}allocate(){this.free();const e=this._window.document,t=e.createElement("div");t.classList.add("js-rootresizer__contents"),t.style.position="relative",t.style.width="100%",t.style.height="100%",e.body.insertAdjacentElement("afterbegin",t),e.body.insertAdjacentElement("afterbegin",this._layoutSizeSensor),this._visibilityApi=new Ve(this._window.document);const i={alive:new N.WatchedValue(!0),fullscreenable:new N.WatchedValue(!0),container:new N.WatchedValue(t),width:new N.WatchedValue,height:new N.WatchedValue,availWidth:new N.WatchedValue,availHeight:new N.WatchedValue,visible:this._visibilityApi.isVisible,fullscreen:this._fullscreenApi.isFullscreen,remove:()=>{i.alive.setValue(!1)},attach:()=>{i.alive.setValue(!1),this._window.close()},requestFullscreen:()=>{this._requestFullscreen()},exitFullscreen:()=>{this._exitFullscreen()}};return i.alive.subscribe((e=>{e||i!==this._area||this.free()})),this._area=i,this._resizeHandler=()=>{const e=this._width(i)||800,t=this._height(i)||600;i.availHeight.setValue(t),i.availWidth.setValue(e),i.height.setValue(t),i.width.setValue(e)},this._area.height.subscribe(this._updateDocumentHeight,{callWithLast:!0}),this._resizeHandler(),this._viewport.addEventListener("resize",this._resizeHandler),new ke.ResizerDetacherState(i).bridge()}free(){if(this._resizeHandler&&(this._viewport.removeEventListener("resize",this._resizeHandler),this._resizeHandler=void 0),this._visibilityApi&&(this._visibilityApi.destroy(),this._visibilityApi=void 0),this._area){const e=this._area;this._area=void 0,e.height.unsubscribe(this._updateDocumentHeight),e.alive.setValue(!1);const t=e.container.value(),i=null==t?void 0:t.parentElement;i&&(i.removeChild(t),i.removeChild(this._layoutSizeSensor))}}_height(e){if("visual"===this._viewportType)return this._layoutSizeSensor.clientHeight;return e.container.value().clientHeight}_width(e){return e.container.value().clientWidth}_requestFullscreen(){this._fullscreenApi.enter()}_exitFullscreen(){this._fullscreenApi.exit()}_initFullscreen(){this._fullscreenApi.isFullscreen.subscribe((e=>{this._resizeHandler&&this._resizeHandler()}))}}(window),ui=new class{constructor(e){this._processVisibility=e=>{const t=e.container.value();return this.affectsLayout(e.name)?(t&&t.classList.toggle("js-hidden",!1),!0):(t&&t.classList.toggle("js-hidden",!0),!1)},this._setWidth=(e,t,i)=>{ +this.updateChartTimezones()}listTimezoneIds(){return[...this._customTimezones.keys()]}listTimezones(){return[...this._customTimezones.entries()].map((([e,t])=>({id:e,...t})))}getTimezoneInfo(e){if(!this.timezoneIsAvailable(e))throw new Error("Provided timezone alias is not within the list of supported timezones.");return(0,n.ensure)(this._customTimezones.get(e))}getAllTimezoneInfo(){return this.listTimezones()}getAliasTimezone(e){return this.getTimezoneInfo(e).alias}timezoneIsAvailable(e){return this._customTimezones.has(e)}updateChartTimezones(){(0,Se.updateAvailableTimezones)(this.getAllTimezoneInfo())}getTimezoneData(e){if(Ie.has(e))return Ie.get(e);let t=null;if(Pe(e))t=xe(e);else if(this.timezoneIsAvailable(e)){const i=this.getAliasTimezone(e);ye.tzData[i]&&(t=ye.tzData[i]),!t&&Pe(i)&&(t=xe(i))}return t&&Ie.set(e,t),t}static instance(){return null===Te&&(Te=new Me),Te}_addTimezone(e,t){try{if((0,n.ensure)(e,"Custom timezone ID"),(0,n.ensure)(t.alias,"Custom timezone alias"),(0,n.ensure)(t.title,"Custom timezone title"),(0,Se.timezoneIsAvailable)(e)&&!this.timezoneIsAvailable(e))throw new Error("Custom timezone id already exists.");if(!(0,Se.timezoneIsSupported)(t.alias)&&!Pe(t.alias))throw new Error("Custom timezone alias is not a supported timezone.");if(e.length<1)throw new Error("Custom timezone id is empty");if(t.title.length<1)throw new Error("Custom timezone title is empty");this._customTimezones.set(e,t)}catch(e){console.warn(`Unable to add custom timezone. ${e}`)}}}(0,ve.setCustomTimezones)(Me);var Le=i(42226),Ae=i(36274),ke=i(31940);class De{constructor(e){this._document=e,this.isFullscreen=new N.WatchedValue;const t=()=>{const e=["fullscreenElement","webkitFullscreenElement","mozFullscreenElement","mozFullScreenElement","msFullscreenElement"];for(let t=0;t{this.isVisible.setValue(!e[r])},i(),e.addEventListener(t,i,!1);break}}this.destroy=()=>{i&&(e.removeEventListener(t,i,!1),i=null)}}}var Ve=i(84015),Be=i(49483);function Re(e,t){let i=0;for(const{min:s,max:r}of t){if(e0&&t.push({min:e,max:s})}return t.sort(((e,t)=>e.min-t.min||e.max-t.max)),t}function Oe(e,t){if(e.length!==t.length)return!1;for(let i=e.length;i--;){if(e[i].min!==t[i].min)return!1;if(e[i].max!==t[i].max)return!1}return!0}const Fe=h.enabled("no_min_chart_width"),We=h.enabled("bypass_chart_height_check");function He(e){const t=h.enabled("side_toolbar_in_fullscreen_mode"),i=h.enabled("header_in_fullscreen_mode");return"center"===e||"left"===e&&t||"top"===e&&i}var ze=i(2438),Ue=i(98310),je=i(16216),Ge=(i(26665),i(3162)),qe=i.n(Ge),$e=i(241),Ye=i(88348),Ke=i(15367),Ze=i(68335);var Xe=i(2269),Je=i.n(Xe),Qe=i(42856),et=i(75117),tt=i.n(et),it=(i(24172),i(46544),i(78136)),st=i(88732),rt=i(74649),nt=i(97906),ot=i(27714),at=i(12481),lt=i(86441),ct=i(34026),ht=i(48891),dt=i(15742),ut=i(18807),pt=i(61345),_t=i(87095),mt=i(88275),gt=i(74359),ft=i(68441),vt=i(34565),St=i(66103),yt=i(70893),bt=i(50946);i(77275);const wt=new Map([["logo-old-style",bt],["tradingview-old-style",yt]]),Pt=h.enabled("adaptive_logo"),Ct=h.enabled("small_no_display"),xt=h.enabled("38914"),Tt="site_branding",It="widget_branding",Mt="widget_referral_branding",Lt="widget_custom_branding",At="widget_custom_no_powered_branding",kt="fundamental_branding",Dt="fundamental_custom_branding",Et="fundamental_custom_no_powered_branding",Vt="library_branding",Bt="library_custom_branding",Rt="library_custom_no_powered_branding",Nt=navigator.userAgent.toLowerCase().indexOf("chrome")>-1&&-1===navigator.userAgent.toLowerCase().indexOf("edge"),Ot=window.urlParams||{};window.initData;Ot.no_referral_id&&enable(Ot.referral_id||"","aggressive");const Ft=l.t(null,void 0,i(26619)),Wt=xt?l.t(null,void 0,i(5607)):l.t(null,void 0,i(68111)),Ht=(l.t(null,void 0,i(82128)),l.t(null,void 0,i(88841)),l.t(null,void 0,i(99769)),(0,Be.onWidget)(),{brandCircleSize:32,textAsImageWidthCompensation:0,leftOffset:0,bottomOffset:-23,logoLeftOffset:1,maximizedWidthsCompensation:0,logoTextOffset:6});class zt extends dt.CustomSourceBase{constructor(e,t,i){super(e,t),this._canvasWidth=0,this._paneHeight=0,this._left=13,this._bottom=36,this._layout=Tt,this._needToShow=!0,this._showBranding=!1,this._customLogoSrc="",this._customLogoLink="",this._cubicBezier=new pt.CubicBezier(.4,.01,.22,1),this._openAnimation=null,this._closeAnimation=null,this._powBy=null,this._custom=null,this._destroyed=!1,this._mainSeries=this._model.mainSeries(),this._visible=i,this._showForPro=!t.onWidget();const s=()=>this._model.updateSource(this);this._visible.subscribe(s),this._dark=t.dark().spawn(),this._dark.subscribe(s),this._checkLayout(),this._layout!==Lt&&this._layout!==Dt||(this._left=8,this._bottom=5);const r=()=>{this._needToShow?this._showBranding=!0:this._showBranding=!1};this._resizeHandlerDelayed=(0,at.default)(r,200),r(),window.addEventListener("resize",this._resizeHandlerDelayed),this._monitorCanvas=(0,gt.createDisconnectedBoundCanvas)(document,(0,ot.size)({width:0,height:0})), +this._monitorCanvas.subscribeSuggestedBitmapSizeChanged((()=>{this._init()})),this._model.isSnapshot()?this._init():(this._mainSeries.dataEvents().symbolResolved().subscribe(this,this._init),null!==this._mainSeries.symbolInfo()&&this._init()),this._renderer={draw:this.draw.bind(this),hitTest:this.hitTest.bind(this)},t.onWidget()||window.loginStateChange.subscribe(this,this._init)}destroy(){window.removeEventListener("resize",this._resizeHandlerDelayed),this._mainSeries.dataEvents().symbolResolved().unsubscribeAll(this),this._powBy&&this._powBy.destroy(),this._model.onWidget()||window.loginStateChange.unsubscribeAll(this),this._visible.release(),this._dark.destroy(),this._destroyed=!0}paneViews(e){if(window.TradingView.printing&&this._layout!==At&&this._layout!==Et)return[];if(!this._visible.value())return[];if(this._layout===Tt&&!this._showForPro&&window.user&&window.user.is_pro)return[];const t=h.enabled("move_logo_to_main_pane");let i=!1;if(e.maximized().value())i=!0;else if(t)i=this._model.mainPane().collapsed().value()?e===this._model.panes().find((e=>!e.collapsed().value())):e.isMainPane();else if(this._model.lastPane().collapsed().value()){const t=this._model.panes();for(let s=t.length-1;s>=0;--s){const r=t[s];if(!r.collapsed().value()){i=r===e;break}}}else i=e.isLast();return i?[{renderer:this.renderer.bind(this)}]:[]}labelPaneViews(e){return[]}priceAxisViews(e,t){return[]}updateAllViews(){}updateViewsForPane(e){}priceScale(){return null}renderer(e,t){return this._paneHeight=e,this._canvasWidth=t,this._renderer}hasContextMenu(){return!1}onClickOutside(){this._hasAnimation()&&this._startCloseAnimation()}hitTest(e){if(!this._showBranding||h.enabled("logo_without_link"))return null;if(this._powBy&&this._layout!==At&&this._layout!==Et&&(this._powBy.hitTest(e)||this._custom&&this._custom.hitTest(e))){const e=!0;return new ut.HitTestResult(ut.HitTarget.Custom,{hideCrosshairLinesOnHover:!0,cursorType:e?St.PaneCursorType.Pointer:St.PaneCursorType.Default,clickHandler:()=>{this._openLink()},tapHandler:()=>{this._hasAnimation()?this._toggleOpenAnimatedOrOpenLink():this._openLink()},mouseEnterHandler:()=>{this._hasAnimation()&&this._startOpenAnimation()},mouseLeaveHandler:()=>{this._hasAnimation()&&this._startCloseAnimation()}})}return null}tvUrl(){let e=new URL("https://www.tradingview.com/");if(this._customLogoLink)return this._customLogoLink;if(this._layout===Vt||this._layout===Bt){let t;switch(!0){case h.enabled("charting_library"):t="library";break;case h.enabled("trading_terminal"):t="trading-terminal"}e.searchParams.append("utm_source",window.location.origin),e.searchParams.append("utm_medium","library"),t&&e.searchParams.append("utm_campaign",t)}return e.toString()}draw(e,t){if(!this._showBranding)return;let i=0;Ot.utm=!0,(0,gt.drawScaled)(e,t.pixelRatio,t.pixelRatio,(()=>{if(this._powBy&&this._powBy.show){i=this._powBy.height,e.save();const s=new lt.Point(this._left,this._paneHeight-this._bottom-i);this._powBy.draw(s,e,t,this._canvasWidth),e.restore()}if(this._custom&&this._custom.show){e.save() +;const s=new lt.Point(this._left,this._paneHeight-this._bottom-i-this._custom.height);this._custom.draw(s,e,t),e.restore()}}))}_init(){this._checkLayout();const e=this._mainSeries.symbolInfo();this._powBy&&this._powBy.destroy(),this._powBy=new Jt(this._layout,(null==e?void 0:e.name)||"",this._model,(()=>this._model.fullUpdate())),this._custom=new Qt(this._layout,this._customLogoSrc,(()=>this._model.fullUpdate())),this._openAnimation=null,this._closeAnimation=null,this._model.lightUpdate()}_checkLayout(){if(h.enabled("widget"))0;else{{const e=JSON.parse(Ot.logo)||{};e.image?(this._customLogoSrc=e.image,this._customLogoLink=e.link,this._needToShow=h.enabled("widget_logo"),h.enabled("link_to_tradingview")?this._layout=Bt:this._layout=Rt):(this._layout=Vt,this._needToShow=h.enabled("widget_logo"))}}}_startOpenAnimation(){null===this._openAnimation&&(null!==this._closeAnimation&&(this._closeAnimation.stop(),this._closeAnimation=null),this._openAnimation=(0,mt.doAnimate)({from:this._currentStateForAnimation(),to:this._openedStateForAnimation(),duration:200,easing:this._cubicBezier.easingFunc,onStep:this._animatedDrawStep.bind(this)}))}_startCloseAnimation(){null===this._closeAnimation&&(null!==this._openAnimation&&(this._openAnimation.stop(),this._openAnimation=null),this._closeAnimation=(0,mt.doAnimate)({from:this._currentStateForAnimation(),to:this._closedStateForAnimation(),duration:200,easing:this._cubicBezier.easingFunc,onStep:this._animatedDrawStep.bind(this)}))}_currentStateForAnimation(){return(0,n.ensureNotNull)(this._powBy).width}_closedStateForAnimation(){return(0,n.ensureNotNull)(this._powBy).minimizedAnimationWidth()}_openedStateForAnimation(){return(0,n.ensureNotNull)(this._powBy).maximizedAnimationWidth()}_animatedDrawStep(e,t){(0,n.ensureNotNull)(this._powBy).animatedDrawStep(e,t),this._model.lightUpdate()}_hasAnimation(){return null!==this._powBy&&this._powBy.hasAnimation()}_openGoPro(){0}_openLink(){if(this._layout===Tt)return this._openGoPro(),!1;h.enabled("widget");return(0,n.ensureNotNull)(window.open(this.tvUrl(),"_blank")).opener=null,!0}_toggleOpenAnimatedOrOpenLink(){null!==this._openAnimation&&this._openAnimation.completed()?this._openLink()||this._startCloseAnimation():this._startOpenAnimation()}}function Ut(e){return!Ct||e>480}function jt(e){return!Pt||e>500}const Gt={customBrandingTradingViewText:ht.colorsPalette["color-brand"],customBrandingText:ht.colorsPalette["color-cold-gray-850"],background:ht.colorsPalette["color-cold-gray-900"],shadow:ht.colorsPalette["color-cold-gray-700"],text:ht.colorsPalette["color-white"],staticTextBackground:(0,_t.generateColor)(ht.colorsPalette["color-cold-gray-800"],20),logo:ht.colorsPalette["color-white"]},qt={customBrandingTradingViewText:ht.colorsPalette["color-brand"],customBrandingText:ht.colorsPalette["color-cold-gray-850"],background:ht.colorsPalette["color-white"],shadow:ht.colorsPalette["color-cold-gray-150"],text:ht.colorsPalette["color-cold-gray-900"],staticTextBackground:(0,_t.generateColor)(ht.colorsPalette["color-white"],20), +logo:ht.colorsPalette["color-cold-gray-900"]};function $t(e,t){return new Promise((i=>{const s=e.replace(/fill="#[\da-f]{6}"/gi,`fill="${t}"`),r=new Image;r.onload=()=>{r.onload=null,i(r)},r.src=URL.createObjectURL(new Blob([s],{type:"image/svg+xml"}))}))}let Yt={},Kt={};function Zt(e,t,i){const s=Kt,r=e+t,o=s[r];if(void 0!==o)return o;const a=(0,n.ensureDefined)(wt.get("logo-old-style")),l=(0,n.ensureDefined)(wt.get("tradingview-old-style")),c=$t(a,t),h=$t(l,t);return Promise.all([c,h]).then((([e,t])=>{const n={logoImage:e,textImage:t};s[r]=n,i(n)})),null}class Xt{constructor(){this._topLeftPoint=null}hitTest(e){const t=this._getHitTestBox();if(t)return(0,ct.pointInBox)(e,t)}_getHitTestBox(){const e=this._topLeftPoint;if(e){const{x:t,y:i}=e;return(0,lt.box)(e,new lt.Point(t+this.width,i+this.height))}}}class Jt extends Xt{constructor(e,t,i,s){super(),this.show=!0,this._needDisplayImage=!1,this._animatedWidth=Ht.brandCircleSize,this._font=`px ${g.CHART_FONT_FAMILY}`,this._txt="TradingView",this._textWidth=0,this._maximizedAnimationTextWidth=0,this._textWidthCache=new vt.TextWidthCache,this._pixelRatio=1,this._onLogoImageReady=e=>{this._requestRepaint()},this._model=i,this._layout=e,this._symbol=t,this._showAnimatedBranding=h.enabled("show_animated_logo")||this._layout===It,this._alwaysMaximized=h.enabled("logo_always_maximized")||!1,this._fontSize=this._showAnimatedBranding||this._layout===Mt?11:14,this._showAnimatedBranding||this._layout!==Lt&&this._layout!==Dt||(this._fontSize=12),this.width=Ht.brandCircleSize,this.height=this._fontSize+2,this._requestRepaint=s,this._init(),this._checkFontLoaded(),this._recalculateMetrics()}destroy(){this._model.properties().childs().paneProperties.childs().background.unsubscribeAll(this),this._model.onChartThemeLoaded().unsubscribeAll(this)}hasAnimation(){return this._showAnimatedBranding&&!this._alwaysMaximized}minimizedAnimationWidth(){return Ht.brandCircleSize}maximizedAnimationWidth(){return Ht.brandCircleSize+Ht.logoTextOffset+this._maximizedAnimationTextWidth}animatedDrawStep(e,t){this._animatedWidth=t}draw(e,t,i,s){const{brandCircleSize:r,logoLeftOffset:n,leftOffset:o,bottomOffset:a}=Ht;this._needDisplayImage&&Ut(s)&&(e=new lt.Point(e.x+o,e.y-a)),this._topLeftPoint=e,t.translate(e.x,e.y),i.pixelRatio!==this._pixelRatio&&(this._textWidthCache.reset(),this._pixelRatio=i.pixelRatio);const l=this._colors;if(this._showAnimatedBranding){const e=this._getLogoImage(l.logo);this._needDisplayImage&&e&&this._drawLogo(t,e,this._animatedWidth,this._animatedWidth-r,this._animatedWidth>r)}else if(this._layout===Lt||this._layout===Dt){t.font=this._fontSize+this._font;const e=t.measureText(this._txt).width+2;this.width=e+t.measureText("TradingView").width+2,t.save(),t.globalAlpha=.7,t.fillStyle=this._colors.customBrandingText,t.fillText(this._txt,0,12),t.fillStyle=this._colors.customBrandingTradingViewText,t.fillText("TradingView",e,12),t.restore()}else if(Ut(s)&&this._layout===Mt){const e=this._getLogoImage(l.logo),i=this.maximizedAnimationWidth();e&&this._drawLogo(t,e,i,i,!0) +}else if(Ut(s)){const e=this._getLogoImage(l.logo);if(this._needDisplayImage&&e){t.save(),this._drawBgCircle(t,r/2);const i=new lt.Point(Math.round((r-e.logoImage.width)/2)-1+n,Math.floor((r-e.logoImage.height)/2)+1);this._drawLogoImage(t,i,e.logoImage);const o=jt(s);o&&(t.translate(r+5,Math.round(this._fontSize*("px EuclidCircular"===this._font?.1:0))),this._drawTextStroke(t),this._drawTextFill(t)),t.restore(),this.width=r,o&&(this.width+=this._maximizedAnimationTextWidth)}else{const e=jt(s);e&&(t.save(),t.translate(Nt?-.5:0,-.5),this._drawTextStroke(t),this._drawTextFill(t),t.restore()),e&&(this.width=this._maximizedAnimationTextWidth)}}else this.width=0}_drawLogo(e,t,i,s,r){const{brandCircleSize:n,logoLeftOffset:o,logoTextOffset:a}=Ht;e.save(),this._drawFillRectWithRoundedCorner(e,-.5,0,i,n,n/2);const l=new lt.Point(Math.round((n-t.logoImage.width)/2)-1+o,Math.floor((n-t.logoImage.height)/2)+1);if(this._drawLogoImage(e,l,t.logoImage),r){const i=new lt.Point(l.x+t.logoImage.width+a,l.y);this._drawImageCropWidth(e,i,t.textImage,s),this.width=t.logoImage.width+Math.min(t.textImage.width,s)}e.restore()}_init(){Kt={},Yt={},this._checkLayout(),this.show&&(this._updateColors(),this.height=this._needDisplayImage?Ht.brandCircleSize:this._fontSize+2,this._model.properties().childs().paneProperties.childs().background.subscribe(this,this._updateColors),this._model.onChartThemeLoaded().subscribe(this,this._updateColors))}_checkFontLoaded(){if(!this._showAnimatedBranding&&document.fonts&&document.fonts.check&&document.fonts.load){document.fonts.check(`${this._fontSize}px EuclidCircular`)?this._font="px EuclidCircular":document.fonts.load(`${this._fontSize}px EuclidCircular`,this._txt).then((()=>{this._font="px EuclidCircular",this._recalculateMetrics(),this._requestRepaint()}))}}_recalculateMetrics(){const e=(0,gt.createDisconnectedBoundCanvas)(document,(0,ot.size)({width:0,height:0})),t=(0,gt.getPretransformedContext2D)(e,!0);t.font=this._fontSize+this._font;const i=this._needDisplayImage?Zt(this._model.dark().value()?"dark":"light",this._colors.logo,(()=>this._recalculateMetrics())):null;this._textWidth=i?i.textImage.width+Ht.textAsImageWidthCompensation:Math.ceil(t.measureText(this._txt).width)+2+8;let s=this._textWidth;s%2==0&&(s+=1),this._maximizedAnimationTextWidth=s,this._textWidthCache.reset(),this._alwaysMaximized&&(this._animatedWidth=this.maximizedAnimationWidth())}_updateColors(){this._colors=this._model.dark().value()?Gt:qt}_getLogoImage(e){return Zt(this._model.dark().value()?"dark":"light",e,this._onLogoImageReady)}_checkLayout(){switch(this._layout){case It:case Mt:case Lt:case kt:case Dt:case Bt:case Vt:case Tt:this.show=!0;break;case At:case Et:case Rt:this.show=!1}switch(this._layout){case Vt:this._needDisplayImage=!0,this._txt=Ft;break;case Bt:this._txt=Wt}}_drawTextStroke(e){e.save(),e.textBaseline="middle",e.textAlign="start",e.font=this._fontSize+this._font,e.strokeStyle=this._colors.staticTextBackground,e.lineWidth=4,e.lineJoin="round", +e.strokeText(this._txt,0,Ht.brandCircleSize/2+this._textWidthCache.yMidCorrection(e,this._txt)),e.restore()}_drawTextFill(e){e.save(),e.textBaseline="middle",e.textAlign="start",e.font=this._fontSize+this._font,e.fillStyle=this._colors.text,e.fillText(this._txt,0,Ht.brandCircleSize/2+this._textWidthCache.yMidCorrection(e,this._txt)),e.restore()}_drawImageCropWidth(e,t,i,s){e.save(),e.beginPath(),e.rect(t.x,t.y,s,this.height),e.clip(),e.drawImage(i,t.x,t.y),e.restore()}_drawBgCircle(e,t){const i=2*Math.PI;e.save(),e.beginPath(),e.fillStyle=this._colors.shadow,e.arc(t,t,t+1,0,i),e.fill(),e.closePath(),e.restore(),e.save(),e.beginPath(),e.fillStyle=this._colors.background,e.arc(t,t,t,0,i,!1),e.fill(),e.closePath(),e.restore()}_drawFillRectWithRoundedCorner(e,t,i,s,r,n){e.save(),(0,ft.drawRoundRect)(e,t-1,i-1,s+2,r+2,n),e.fillStyle=this._colors.shadow,e.fill(),e.closePath(),e.restore(),e.save(),(0,ft.drawRoundRect)(e,t,i,s,r,n),e.fillStyle=this._colors.background,e.fill(),e.closePath(),e.restore()}_drawLogoImage(e,t,i){e.drawImage(i,t.x,t.y)}}class Qt extends Xt{constructor(e,t,i){super(),this.show=!1,this.width=0,this.height=0,this._ready=!1,this._layout=e,this._src=t,this._onReadyCallback=i,this._checkLayout();const s=new Image;this._img=s,this.show&&(s.addEventListener("load",(()=>{this.width=Math.round(s.width),this.height=Math.round(s.height),this._ready=!0,this._onReadyCallback&&this._onReadyCallback()})),s.crossOrigin="anonymous",s.src=this._src)}draw(e,t,i){this._topLeftPoint=e,this._ready&&(t.translate(e.x,e.y),t.drawImage(this._img,-.5,-.5,this.width,this.height))}_checkLayout(){switch(this._layout){case Lt:case At:case Dt:case Et:case Bt:case Rt:this.show=!0;break;case Tt:case It:case Mt:case kt:case Vt:this.show=!1}}}var ei=i(97304),ti=i(65106);class ii{constructor(e,t){this._headerToolbar=e,this._dropdownId=t}applyOptions(e){this._headerToolbar.updateDropdown(this._dropdownId,e)}remove(){this._headerToolbar.removeDropdown(this._dropdownId)}}var si=i(90194),ri=i(75593);class ni{constructor(e){this._symbolModel=e}getVisible(){return this._symbolModel.visible().value()}setVisible(e){return this._symbolModel.visible().setValue(e),this}getIcon(){return this._symbolModel.icon().value()}setIcon(e){return this._symbolModel.icon().setValue(e),this}getColor(){return this._symbolModel.color().value()}setColor(e){return this._symbolModel.color().setValue(e),this}getTooltip(){return this._symbolModel.tooltip().value()}setTooltip(e){return this._symbolModel.tooltip().setValue(e),this}getDropDownContent(){return this._symbolModel.tooltipContent().value()}setDropDownContent(e){return this._symbolModel.tooltipContent().setValue(e),this}}class oi{symbol(e){return new ni(this._model().getSymbolCustomStatus(e))}hideAll(){this._model().hideAll()}static getInstance(){return null===this._instance&&(this._instance=new oi),this._instance}_model(){return ri.CustomStatusModel.getInstance()}}oi._instance=null;var ai,li=i(39347),ci=i(16838);(0,M.setClasses)();const hi=o(),di=a(),ui=new class{constructor(e,t){ +this._updateDocumentHeight=e=>{"visual"===this._viewportType&&this._window.document.documentElement.style.setProperty("height",`${e}px`,"important")},this._window=e,this._fullscreenApi=new De(e.document),this._viewportType=Be.CheckMobile.iOS()&&!(0,Ve.isOnMobileAppPage)("any")&&this._window.visualViewport?"visual":"quirks","visual"===this._viewportType?this._viewport=(0,n.ensure)(this._window.visualViewport):this._viewport=this._window;const i=this._layoutSizeSensor=this._window.document.createElement("div");i.id="layout-size-sensor",i.style.position="fixed",i.style.top="0",i.style.left="0",i.style.right="0",i.style.bottom="0",i.style.pointerEvents="none",i.style.visibility="hidden",this._initFullscreen()}allocate(){this.free();const e=this._window.document,t=e.createElement("div");t.classList.add("js-rootresizer__contents"),t.style.position="relative",t.style.width="100%",t.style.height="100%",e.body.insertAdjacentElement("afterbegin",t),e.body.insertAdjacentElement("afterbegin",this._layoutSizeSensor),this._visibilityApi=new Ee(this._window.document);const i={alive:new N.WatchedValue(!0),fullscreenable:new N.WatchedValue(!0),container:new N.WatchedValue(t),width:new N.WatchedValue,height:new N.WatchedValue,availWidth:new N.WatchedValue,availHeight:new N.WatchedValue,visible:this._visibilityApi.isVisible,fullscreen:this._fullscreenApi.isFullscreen,remove:()=>{i.alive.setValue(!1)},attach:()=>{i.alive.setValue(!1),this._window.close()},requestFullscreen:()=>{this._requestFullscreen()},exitFullscreen:()=>{this._exitFullscreen()}};return i.alive.subscribe((e=>{e||i!==this._area||this.free()})),this._area=i,this._resizeHandler=()=>{const e=this._width(i)||800,t=this._height(i)||600;i.availHeight.setValue(t),i.availWidth.setValue(e),i.height.setValue(t),i.width.setValue(e)},this._area.height.subscribe(this._updateDocumentHeight,{callWithLast:!0}),this._resizeHandler(),this._viewport.addEventListener("resize",this._resizeHandler),new ke.ResizerDetacherState(i).bridge()}free(){if(this._resizeHandler&&(this._viewport.removeEventListener("resize",this._resizeHandler),this._resizeHandler=void 0),this._visibilityApi&&(this._visibilityApi.destroy(),this._visibilityApi=void 0),this._area){const e=this._area;this._area=void 0,e.height.unsubscribe(this._updateDocumentHeight),e.alive.setValue(!1);const t=e.container.value(),i=null==t?void 0:t.parentElement;i&&(i.removeChild(t),i.removeChild(this._layoutSizeSensor))}}_height(e){if("visual"===this._viewportType)return this._layoutSizeSensor.clientHeight;return e.container.value().clientHeight}_width(e){return e.container.value().clientWidth}_requestFullscreen(){this._fullscreenApi.enter()}_exitFullscreen(){this._fullscreenApi.exit()}_initFullscreen(){this._fullscreenApi.isFullscreen.subscribe((e=>{this._resizeHandler&&this._resizeHandler()}))}}(window),pi=new class{constructor(e){this._processVisibility=e=>{const t=e.container.value();return this.affectsLayout(e.name)?(t&&t.classList.toggle("js-hidden",!1),!0):(t&&t.classList.toggle("js-hidden",!0),!1)},this._setWidth=(e,t,i)=>{ let s=i;this._fullscreenArea!==e.name&&(e.availWidth.setValue(i),e.canNegotiate.width&&(s=Re(i,e.negotiations.width))),t||(s=0);const r=e.container.value();return r&&t&&(r.style.width=s+"px"),e.width.setValue(s),s},this._setHeight=(e,t,i)=>{let s=i;this._fullscreenArea!==e.name&&(e.availHeight.setValue(i),e.canNegotiate.height&&(s=Re(i,e.negotiations.height))),t||(s=0);const r=e.container.value();return r&&t&&(r.style.height=s+"px"),e.height.setValue(s),s};const t=e.container.value();if(!t)throw new Error("bridge.container.value() must be an element");this._container=t,this._availableAreas=["left","tradingpanel","right","top","bottom","center","topleft","extratop"],this._areas={},this._bridge=e,this._width=e.width,this._height=e.height,this._width.subscribe((()=>this.recalculate())),this._height.subscribe((()=>this.recalculate())),this._bridge.visible.subscribe((()=>this._updateVisibility())),this._bridge.fullscreen.subscribe((()=>this._onParentFullscreenChange())),this.recalculate()}allocate(e){const t=e&&e.areaName;if(-1===this._availableAreas.indexOf(t))throw new Error("unknown options.areaName");this.free(t);const i=this._createDOM(t),s={name:t,canNegotiate:{width:"left"===t||"right"===t||"tradingpanel"===t||"topleft"===t,height:"top"===t||"bottom"===t||"topleft"===t||"extratop"===t},negotiations:{width:[],height:[]},remove:()=>{for(const e in this._areas)this._areas[e]===s&&this.free(e)},negotiateWidth:e=>{if(!s.canNegotiate.width)return;const t=Ne(e);Oe(s.negotiations.width,t)||(s.negotiations.width=t,this.recalculate())},negotiateHeight:e=>{if(!s.canNegotiate.height)return;const t=Ne(e);Oe(s.negotiations.height,t)||(s.negotiations.height=t,this.recalculate())},requestFullscreen:()=>{this._fullscreenArea||("right"!==t&&"center"!==t||(this._fullscreenArea=t),"center"===t&&this._bridge.requestFullscreen(),this._updateFullscreen())},exitFullscreen:()=>{t===this._fullscreenArea&&(this._fullscreenArea=void 0,"center"===t&&this._bridge.exitFullscreen(),this._updateFullscreen())},width:new N.WatchedValue,height:new N.WatchedValue,availWidth:new N.WatchedValue,availHeight:new N.WatchedValue,alive:new N.WatchedValue(!0),container:new N.WatchedValue(i),visible:new N.WatchedValue(!0),fullscreen:new N.WatchedValue(!1),fullscreenable:new N.WatchedValue("right"===t||"center"===t),rdState:new ke.ResizerDetacherState};return s.rdState.pushOwner(s),this._areas[t]=s,s.rdState.owner.subscribe((e=>{const i=s.container.value();if(e!==s)i&&(i.innerHTML="",i.parentElement&&i.parentElement.removeChild(i));else{let e=null;for(let i=this._availableAreas.indexOf(t);i--;){const t=this._availableAreas[i];if(this.affectsLayout(t)){e=this._areas[t].container.value();break}}i&&(e&&i.parentElement?i.insertAdjacentElement("afterend",e):this._container.appendChild(i))}this.recalculate()}),{callWithLast:!0}),s.rdState.bridge()}free(e){const t=this._areas[e];if(!t)return;this._areas[e]=void 0;const i=t.container.value();i&&i.parentElement&&i.parentElement.removeChild(i),t.alive.setValue(!1)}recalculate(){const e={};this._recalcSingleRunToken=e -;const t=this._areas.topleft,i=this._areas.left,s=this._areas.tradingpanel,r=this._areas.right,n=this._areas.top,o=this._areas.bottom,a=this._areas.center,l=this._areas.extratop,c=this._width.value(),h=this._height.value();let d=0,u=0,p=0,_=0,m=0,g=0,f=0,v=0;if(e===this._recalcSingleRunToken&&l){const e=this._processVisibility(l);v=this._setHeight(l,e,h),this._setWidth(l,e,c)}if(e===this._recalcSingleRunToken&&t){const e=this._processVisibility(t);f=this._setHeight(t,e,h),g=this._setWidth(t,e,c);const i=t.container.value();e&&i&&(i.style.top=v+"px")}let S=0;if(e===this._recalcSingleRunToken&&n){const e=this._processVisibility(n),t=n.container.value();e&&t&&(t.style.left=g+"px",t.style.top=v+"px");const i=c-g;this._setWidth(n,e,i),d=this._setHeight(n,e,h),d&&(S=1)}if(e===this._recalcSingleRunToken&&i){const e=this._processVisibility(i),t=Math.max(f,d);p=this._setWidth(i,e,c),p&&(p+=4),p&&1===S&&(S=4);const s=i.container.value();e&&s&&(s.style.top=t+v+S+"px"),this._setHeight(i,e,h-t-v)}if(e===this._recalcSingleRunToken&&s){const e=this._processVisibility(s);let t=c-p;Fe||(t-=300),m=this._setWidth(s,e,t),m&&1===S&&(S=4),this._setHeight(s,e,h-v-d-S)}if(e===this._recalcSingleRunToken&&r){const e=this._processVisibility(r);let t=c-p-m;Fe||(t-=300),_=this._setWidth(r,e,t),_&&1===S&&(S=4),this._setHeight(r,e,h-v-d-S);const i=r.container.value();e&&i&&(i.style.top=d+v+S+"px",i.classList.toggle("no-border-top-left-radius",Boolean(m)))}const y=m+_;let b=0;const w=c-p-m-_-(y?4:0);if(e===this._recalcSingleRunToken&&o){const e=this._processVisibility(o),t=o.container.value();e&&t&&(t.style.left=p+"px",t.classList.toggle("no-border-top-left-radius",!p),t.classList.toggle("no-border-top-right-radius",!y)),this._setWidth(o,e,w);const i=h-v;b=Math.min(300,i-0),u=this._setHeight(o,e,i)+4}const P=Boolean(d&&(p||y));if(this._container.classList.toggle("layout-with-border-radius",P),e===this._recalcSingleRunToken&&a){const e=this._processVisibility(a),t=a.container.value();e&&t&&(t.style.left=p+"px",t.style.top=d+v+S+"px",t.classList.toggle("no-border-bottom-left-radius",!u||!p),t.classList.toggle("no-border-bottom-right-radius",!y||!u),t.classList.toggle("no-border-top-left-radius",Boolean(!p&&y)),t.classList.toggle("no-border-top-right-radius",Boolean(p&&!y))),this._setWidth(a,e,w);const i=h-d-u-v-S;this._setHeight(a,e,Math.max(i,b))}if(e===this._recalcSingleRunToken&&s&&this.affectsLayout("tradingpanel")){const e=s.container.value();e&&(e.style.right=_+"px",e.style.top=v+d+S+"px",e.style.borderTopLeftRadius=P?"4px":"0px")}e===this._recalcSingleRunToken&&this._updateVisibility()}affectsLayout(e){const t=this._areas[e];if(!t)return!1;if(t.rdState.owner.value()!==t)return!1;if(this._fullscreenArea&&this._fullscreenArea!==e)return We(e);if(this._width.value()<=567||this._height.value()<=445){if(!["center","top","left","topleft","extratop"].includes(e))return!1}return!0}_updateVisibility(){const e=this._bridge.visible.value();for(let t=0;t{ci.ChartApiInstance.start()})),"function"==typeof gi){const e=gi(st);e&&e.then?e.then((e=>{if(!Array.isArray(e))return console.warn("custom_indicators_getter should be a function that returns a Promise object which result is an array of custom indicators"),void fi.resolve();const t=ci.JSServer;t.studyLibrary.push.apply(t.studyLibrary,e),fi.resolve(),console.log("{0} custom indicators loaded.".format(e.length))})).catch((e=>{console.warn("Error loading custom indicators "+e),fi.resolve()})):(console.warn("custom_indicators_getter should be a function that returns a Promise object"),fi.resolve())}else fi.resolve();ci.widgetReady=e=>{O.subscribe("onChartReady",e,null)};const xi=null===(oi=_i.theme)||void 0===oi?void 0:oi.toLowerCase();function Ti(e){ci.__defaultsOverrides=ci.__defaultsOverrides||{},(0,de.deepExtend)(ci.__defaultsOverrides,e),void 0!==TradingView.defaultProperties&&void 0!==TradingView.defaultProperties.chartproperties&&((0,c.applyDefaultsOverrides)(TradingView.defaultProperties.chartproperties),(0,c.applyDefaultOverridesToLinetools)())}!function(e){if(!e)return;L.themes[e]&&(0,A.setTheme)(e)}(xi),ci.applyStudiesOverrides=e=>{var t,i;e&&(ci.chartWidgetCollection?null===(i=(t=ci.chartWidgetCollection).applyStudiesOverrides)||void 0===i||i.call(t,e):Je.StudyMetaInfo.mergeDefaultsOverrides(e))},ci.applyOverrides=e=>{Ti(e),ci.chartWidgetCollection&&ci.chartWidgetCollection.applyOverrides(e)}, -ci.doWhenApiIsReady=e=>{ci.tradingViewApi?e():vi.promise.then(e)},ci.applyTradingCustomization=e=>{for(const t in e.order)TradingView.defaultProperties.linetoolorder[t]=e.order[t];for(const t in e.position)TradingView.defaultProperties.linetoolposition[t]=e.position[t]},ci.changeTheme=(e,t)=>{const i=L.themes[e.toLowerCase()];return i?ci.tradingViewApi.themes().setStdTheme(i.name,!0,t&&t.disableUndo):Promise.resolve()},ci.getTheme=()=>ci.tradingViewApi.themes().getCurrentThemeName(),ci.is_authenticated=!1;JSON.parse(ci.urlParams.brokerConfig);l.t(null,void 0,i(65911)),l.t(null,void 0,i(68111)),l.t(null,void 0,i(5607));let Ii=null;const Mi=(0,he.createDeferredPromise)();let Li;const Ai=()=>{if(h.setEnabled("charting_library_debug_mode","true"===_i.debug),h.setEnabled("chart_property_page_trading",!1),h.enabled("remove_library_container_border")){const e=document.querySelector("#library-container");null!==e&&(e.style.border="0px",e.style.padding="1px")}h.enabled("no_min_chart_width")&&(document.body.style.minWidth="0px"),null!=_i.studiesOverrides&&Je.StudyMetaInfo.mergeDefaultsOverrides(JSON.parse(_i.studiesOverrides)),(0,n.assert)(void 0===TradingView.defaultProperties,"Default properties are inited before applying overrides"),Ti(JSON.parse(_i.overrides));const e=_i.numeric_formatting?JSON.parse(_i.numeric_formatting):void 0;e&&"string"==typeof e.decimal_sign&&(ae.formatterOptions.decimalSign=e.decimal_sign[0]),ci.ChartApiInstance=new(Xe())(hi.datafeed);const t=hi.customFormatters;t&&(t.timeFormatter&&(le.customFormatters.timeFormatter=t.timeFormatter),t.dateFormatter&&(le.customFormatters.dateFormatter=t.dateFormatter),t.tickMarkFormatter&&(le.customFormatters.tickMarkFormatter=t.tickMarkFormatter),t.priceFormatterFactory&&(le.customFormatters.priceFormatterFactory=t.priceFormatterFactory),t.studyFormatterFactory&&(le.customFormatters.studyFormatterFactory=t.studyFormatterFactory)),hi.customTimezones&&Me.instance().addTimezones(hi.customTimezones),ci.ChartApiInstance.setStudiesAccessController(ci.ChartApiInstance.createStudiesAccessController(_i.studiesAccess));const s=_i.chartContent?JSON.parse(_i.chartContent).json:void 0,o=_i.chartContentExtendedData?JSON.parse(_i.chartContentExtendedData):s?s.extendedData:void 0,a=_i.interval||"D",c=function(e){const t=/(\d+)(\w+)/;return e.map((e=>{const s=(0,n.ensureNotNull)(t.exec(e.text)),r=s[2].toLowerCase(),o=parseInt(s[1]),a="y"===r?12*o+"M":o+r,c=Ae.Interval.parse(e.resolution);return{text:e.title||o+l.t(r,{context:"dates",count:o},i(673)),description:e.description||"",value:{value:a.toUpperCase(),type:"period-back"},targetResolution:c.value(),requiresIntraday:c.isIntraday()}}))}(JSON.parse(_i.timeFrames)),d={resizerBridge:Ci,padding:h.enabled("border_around_the_chart")?2:0,content:s,widgetOptions:{addToWatchlistEnabled:!1,hideIdeas:!0,addVolume:(0,n.ensureDefined)(ci.ChartApiInstance.studiesAccessController).isToolEnabled("Volume"),muteSessionErrors:!0,timezone:_i.timezone,defSymbol:s?"":_i.symbol,defInterval:s?"":a, -compareSymbols:_i.compareSymbols&&JSON.parse(_i.compareSymbols),defTimeframe:(p=hi.timeframe,p?"string"==typeof p?p:{...p,type:"time-range"}:p),paneContextMenuEnabled:h.enabled("pane_context_menu"),paneContextMenu:{mainSeriesTrade:pi},priceScaleContextMenuEnabled:h.enabled("scales_context_menu"),currencyConversionEnabled:h.enabled("pricescale_currency"),unitConversionEnabled:h.enabled("pricescale_unit"),legendWidgetEnabled:h.enabled("legend_widget"),legendWidget:{contextMenu:{settings:h.enabled("show_chart_property_page"),showOpenMarketStatus:h.enabled("display_market_status")}},sourceStatusesWidget:{errorSolution:!1},marketStatusWidgetEnabled:h.enabled("display_market_status"),chartWarningWidget:{subscriptionFullInfo:!1},timeScaleWidget:{contextMenuEnabled:h.enabled("scales_context_menu"),timezoneMenuEnabled:h.enabled("timezone_menu"),priceAxisLabelsOptions:{showLabels:h.enabled("main_series_scale_menu")}},timeScale:{preserveBarSpacing:!1,lockVisibleTimeRangeOnResize:h.enabled("lock_visible_time_range_on_resize"),rightBarStaysOnScroll:h.enabled("right_bar_stays_on_scroll"),minBarSpacing:_i.time_scale&&JSON.parse(_i.time_scale).min_bar_spacing},goToDateEnabled:h.enabled("go_to_date"),crossHair:{menuEnabled:h.enabled("chart_crosshair_menu")},handleScale:{mouseWheel:h.enabled("mouse_wheel_scale"),pinch:h.enabled("pinch_scale"),axisPressedMouseMove:{time:h.enabled("axis_pressed_mouse_move_scale"),price:h.enabled("axis_pressed_mouse_move_scale")}},handleScroll:{mouseWheel:h.enabled("mouse_wheel_scroll"),pressedMouseMove:h.enabled("pressed_mouse_move_scroll"),horzTouchDrag:h.enabled("horz_touch_drag_scroll"),vertTouchDrag:h.enabled("vert_touch_drag_scroll")},shiftVisibleRangeOnNewBar:h.enabled("shift_visible_range_on_new_bar"),croppedTickMarks:h.enabled("cropped_tick_marks"),countdownEnabled:h.enabled("countdown"),indicatorsDialogShortcutEnabled:h.enabled("insert_indicator_dialog_shortcut")},seriesControlBarEnabled:h.enabled("timeframes_toolbar"),seriesControlBar:{timeFramesWidgetEnabled:!0,timeFramesWidget:{goToDateEnabled:h.enabled("go_to_date"),availableTimeFrames:(e,t)=>{if(!e)return[];if(t!==it.STATUS_DELAYED&&t!==it.STATUS_DELAYED_STREAMING&&t!==it.STATUS_EOD&&t!==it.STATUS_READY)return[];return c.filter((t=>!(t.requiresIntraday&&!e.has_intraday)&&!(e.supported_resolutions&&!e.supported_resolutions.includes(t.targetResolution))))}},timeWidgetEnabled:!0,timeWidget:{timezoneMenuEnabled:h.enabled("timezone_menu")},adjustForDividendsButtonEnabled:!1,sessionIdButtonEnabled:h.enabled("pre_post_market_sessions"),backAdjustmentButtonEnabled:!1,settlementAsCloseButtonEnabled:!1,percentageScaleButtonEnabled:!0,logScaleButtonEnabled:!0,autoScaleButtonEnabled:!0,fullscreenButtonEnabled:!0,mobileChangeLayoutEnabled:!1},globalEvents:!0,snapshotUrl:_i.snapshotUrl,mobileForceChartMaximizeEnabled:!1,saveChartEnabled:h.enabled("save_shortcut")};var p;Si&&((0,qe.createFavoriteDrawingToolbar)(),d.widgetOptions.isDrawingToolbarVisible=C.isDrawingToolbarVisible),o&&(d.metaInfo={id:o.uid,name:o.name,description:o.description,uid:o.uid, -username:""}),hi.additionalSymbolInfoFields&&(0,Qt.setAdditionalSymbolInfoFields)(hi.additionalSymbolInfoFields);const _=hi.symbolSearchComplete;_&&(0,ei.setSymbolSearchCompleteOverrideFunction)(_);const m=ci.chartWidgetCollection=new(Ge())(d);let g=!1;m.onAboutToBeDestroyed.subscribe(null,(()=>{g=!0}),!0),function(e){e.addCustomSource("branding",((t,i)=>{const s=(0,rt.combine)(((e,t)=>{const s=null!=e?e:t;return null!==s&&s.hasModel()&&s.model().model()===i}),e.maximizedChartWidget().weakReference(),e.leftBottomChartWidget().weakReference());return new Ht(t,i,s.ownership())}))}(m),ci.studyMarket=new ce(m),Ue.registerService(ze.CHART_WIDGET_COLLECTION_SERVICE,m),m.activeChartWidget.subscribe((e=>{O.emit("activeChartChanged",m.getAll().indexOf(e))})),ci.saver=new R.ChartSaver(m);const f=new Y(m,ci.saver),v=new Q(m);ci.chartWidget=m.activeChartWidget.value(),ci.pro=new TradingView.Pro;const y=function(e){if(!wi)return null;const t=new I.ChartChangesWatcher(e.chartWidgetCollection,ci.saver,O),i=JSON.parse(_i.favorites);let s,r;i.intervals=i.intervals.map((e=>{let t=""+e;return t.match(/1[DWMYdwmy]/)&&(t=t.slice(1)),t})),h.enabled("study_templates")&&(s=new ne.FavoriteStudyTemplateService(Z.TVXWindowEvents,u),Li=new re({chartWidgetCollection:e.chartWidgetCollection,favoriteStudyTemplatesService:s}));const n=_i.header_widget_buttons_mode;"fullsize"===n&&(r=["full"]);"compact"===n&&(r=["small"]);return new P(new S,{chartSaver:ci.saver,chartApiInstance:ci.ChartApiInstance,chartWidgetCollection:e.chartWidgetCollection,defaultFavoriteStyles:i.chartTypes,defaultFavoriteIntervals:i.intervals,resizerBridge:wi,studyMarket:ci.studyMarket,studyTemplates:Li,favoriteStudyTemplatesService:s,allowedModes:r,saveChartService:e.saveChartService,loadChartService:e.loadChartService,chartChangesWatcher:t,onClick:Ei,snapshotUrl:e.snapshotUrl})}({chartWidgetCollection:m,saveChartService:f,loadChartService:v,snapshotUrl:_i.snapshotUrl});null!==y?y.load().then((e=>{Ii=e.getComponent(),Mi.resolve()})):(Mi.promise.catch((()=>{})),Mi.reject("header widget is not loaded"));const b=function(e){if(Pi){const t=_i.toolbarbg&&/^[0-9a-f]+$/i.test(_i.toolbarbg)?String(_i.toolbarbg):void 0;if(t){const e=document.createElement("style");e.textContent="body,.chart-controls-bar,#footer-chart-panel{background-color:#"+t+" !important}",document.head.appendChild(e)}return new T({bgColor:t,chartWidgetCollection:e,drawingsAccess:_i.drawingsAccess?JSON.parse(_i.drawingsAccess):void 0,resizerBridge:Pi,onClick:Ei})}return null}(m),w=null;ci.tradingViewApi=new(et())({chartWidgetCollection:m,chartApiInstance:ci.ChartApiInstance,saveChartService:f,loadChartService:v,studyMarket:null});if(oe.linking.bindToChartWidgetCollection(m),isNaN(_i.studyCountLimit)||(TradingView.STUDY_COUNT_LIMIT=Math.max(2,+(0,n.ensureDefined)(_i.studyCountLimit))),!isNaN(_i.ssreqdelay)){const e=Math.max(0,+(0,n.ensureDefined)(_i.ssreqdelay));(0,tt.setSearchRequestDelay)(e)}ci.ChartApiInstance.connect(),(async()=>{ -const{default:e}=await Promise.all([i.e(5652),i.e(2666),i.e(3842),i.e(4015),i.e(6),i.e(5993),i.e(5649),i.e(2191),i.e(8056),i.e(3502),i.e(6752),i.e(8149),i.e(6639),i.e(9327),i.e(6106),i.e(9916),i.e(1109),i.e(6831),i.e(8399),i.e(962),i.e(3179),i.e(5050),i.e(1890),i.e(2020),i.e(5899),i.e(2306)]).then(i.t.bind(i,26916,23));g||(ci.lineToolPropertiesToolbar=new e(m))})();const x=document.querySelector(".tv-content");null!==x&&x.addEventListener("contextmenu",(e=>{e.target instanceof Element&&"input"!==e.target.tagName.toLowerCase()&&"textarea"!==e.target.tagName.toLowerCase()&&e.preventDefault()})),vi.resolve(),m.undoHistory.undoStack().onChange().subscribe(null,(0,r.default)((e=>{e&&!e.customFlag("doesnt_affect_save")&&O.emit("onAutoSaveNeeded")}),1e3*(Number(_i.autoSaveDelay)||5),{leading:!1,trailing:!0}));let M=!1;function A(){b&&b.load(mi.signal),w&&w.load(mi.signal).then((e=>{ci.footerWidget=e.getComponent()}))}ci.chartWidget.withModel(null,(()=>{ci.ChartApiInstance.on("realtime_tick",(e=>{O.emit("onTick",e)}));if(!L.savedThemeName()&&xi){const e=L.getStdTheme(xi);e&&e.content&&void 0===s&&m.applyTheme({theme:e.content,onlyActiveChart:!1,restoreNonThemeDefaults:!1,themeName:xi,standardTheme:!0,syncState:!0,noUndo:!0}).then((()=>ci.applyOverrides(ci.__defaultsOverrides)))}if(h.enabled("charting_library_debug_mode")&&O.subscribeToAll(((...e)=>{console.log('Event "{0}", arguments: {1}'.format(e[0],JSON.stringify(e.slice(1))))})),M)return;M=!0,function(e,t=!1){if(!h.enabled("popup_hints"))return;const s=e.getContainer();let r=null,o=null;function a(e,t){if(r)r.show(e,d.bind(null,t));else{const n=$e.tool.value();Promise.all([i.e(6214),i.e(962),i.e(6166)]).then(i.bind(i,5015)).then((i=>{r=new i.ChartEventHintRenderer(s),n===$e.tool.value()&&r.show(e,d.bind(null,t))}))}}function c(e){return!Boolean(u.getBool(e))}function d(e){u.setValue(e,!0,{forceFlush:!0}),(0,n.ensureNotNull)(r).destroy(),null!==o&&o(),r=null}$e.tool.subscribe((function(){if(!c("hint.touchPainting"))return;const e=$e.tool.value(),t=(0,Ye.isLineToolDrawWithoutPoints)(e),s=Be.CheckMobile.any();!(0,Ye.isStudyLineToolName)(e)||"LineToolRegressionTrend"===e||t||s?(0,Ye.isLineToolName)(e)&&!(0,Ye.isLineDrawnWithPressedButton)(e)&&!t&&s?a(l.t(null,void 0,i(67861)),"hint.touchPainting"):r&&r.hide():a(l.t(null,void 0,i(32234)),"hint.touchPainting")})),$e.createdLineTool.subscribe(null,(function(){const e=$e.tool.value();"LineToolPath"===e&&c("hint.finishBuildPathByDblClick")?a(l.t(null,void 0,i(5828)),"hint.finishBuildPathByDblClick"):"LineToolPolyline"===e&&c("hint.finishBuildPolylineByDblClick")&&a(l.t(null,void 0,i(63898)),"hint.finishBuildPolylineByDblClick")})),$e.finishedLineTool.subscribe(null,(function(){if(r){const e=$e.tool.value();"LineToolPath"===e?d("hint.finishBuildPathByDblClick"):"LineToolPolyline"===e&&d("hint.finishBuildPolylineByDblClick")}})),e.layoutSizesChanged().subscribe((function(){c("hint.startResizingChartInLayout")&&a(l.t(null,void 0,i(35273)),"hint.startResizingChartInLayout")})), -t||Be.CheckMobile.any()||!c("hint.startFocusedZoom")||(o=function(e,t){let i=!1;const s=r=>{r?(i&&t(r),e.onZoom().unsubscribe(null,s)):i||(t(r),i=!0)};return e.onZoom().subscribe(null,s),()=>e.onZoom().unsubscribe(null,s)}(e,(function(e){if(c("hint.startFocusedZoom"))if(e)r&&(o=null,d("hint.startFocusedZoom"));else{const e=Ke.isMacKeyboard?"⌘":"Ctrl";a(l.t(null,void 0,i(35963)).format({key:e}),"hint.startFocusedZoom")}})))}(m),function(e,t){const s=l.t(null,void 0,i(78104)).format({emoji:"👍"}),r=l.t(null,void 0,i(12011)).format({emoji:"👍"}),o=l.t(null,void 0,i(79393)).format({emoji:"👍"});O.on("onServerScreenshotCopiedToClipboard",(()=>h(s)),null),O.on("onClientScreenshotCopiedToClipboard",(()=>h(r)),null),O.on("onServerScreenshotEmbedCodeCopiedToClipboard",(()=>h(o)),null);let a=null;const c=e.getContainer();function h(e){a?a.show(e):Promise.all([i.e(2109),i.e(3896),i.e(962),i.e(92)]).then(i.bind(i,60441)).then((i=>{a||(a=new i.ChartScreenshotHintRenderer((0,n.ensureNotNull)(c),{bottomPadding:t.seriesControlBarEnabled}),a.show(e))}))}}(m,{seriesControlBarEnabled:h.enabled("timeframes_toolbar")});ii.WatermarkApi.getInstance().setWidgetCollection(ci.chartWidgetCollection)})),m.getAll().some((e=>e.isInitialized()))?A():function(e,t){const i=e.getAll(),s=()=>{t(),i.forEach((e=>{e.chartWidgetInitialized().unsubscribe(null,s)}))};i.forEach((e=>{e.chartWidgetInitialized().subscribe(null,s,!0)}))}(m,A),O.subscribe("chart_load_requested",(e=>{ci.tradingViewApi.loadChart({json:JSON.parse(e.content),extendedData:e})}),null)};window.addEventListener("unload",(()=>{mi.abort(),ci.widgetbar&&(ci.widgetbar.destroy(),ci.widgetbar=null),ci.chartWidgetCollection&&(ci.chartWidgetCollection.destroy(),ci.chartWidgetCollection=null),ci.ChartApiInstance&&ci.ChartApiInstance.disconnect(),(0,He.destroyQuoteSessions)(),ci.ChartApiInstance&&(ci.ChartApiInstance.destroy(),ci.ChartApiInstance=null)})),h.enabled("saveload_storage_customization")&&(hi.saveLoadAdapter?k.setCustomAdapter(hi.saveLoadAdapter):ci.urlParams.chartsStorageUrl&&ci.urlParams.clientId?k.initialize(ci.urlParams.clientId,ci.urlParams.userId,ci.urlParams.chartsStorageUrl,ci.urlParams.chartsStorageVer||"1.0"):(h.setEnabled("saveload_storage_customization",!1),h.setEnabled("header_saveload",!1)));const ki=(0,he.createDeferredPromise)();function Di(){ki.resolve()}hi.loadLastChart&&h.enabled("saveload_storage_customization")?k.getCharts().then((e=>{if(0===e.length)return void Di();const t=e.sort(((e,t)=>t.modified_iso-e.modified_iso))[0];k.getChartContent(t).then((e=>{const t=e,i=JSON.parse(t.content);i.extendedData=e,_i.chartContent=JSON.stringify({json:i}),Di()})).catch(Di)})).catch(Di):Di();const Vi=(0,he.createDeferredPromise)();function Ei(){const e=TradingView.bottomWidgetBar;e&&e.turnOffMaximize()}Promise.all([Vi.promise,ki.promise,ci.loadedCustomCss]).then((()=>{const e=document.querySelector(".loading-indicator");if(e&&(e.style.display="none"),setTimeout(Ai,0),h.enabled("14851")&&Math.random()<=.02){t=window,i=document,s="script",r="ga",t.GoogleAnalyticsObject=r, -t.ga=t.ga||function(){(t.ga.q=t.ga.q||[]).push(arguments)},t.ga.l=Number(new Date),o=i.createElement(s),a=i.getElementsByTagName(s)[0],o.async=1,o.src="//www.google-analytics.com/analytics.js",a.parentNode.insertBefore(o,a);const e=(0,n.ensureNotNull)(document.URL.match(new RegExp("(:?.*://)([^/]+)/.*")))[2];ci.ga("create","UA-112911840-1","auto"),ci.ga("set","anonymizeIp",!0),ci.ga("set",{hostname:e,page:e,referrer:e}),ci.ga("send","pageview")}var t,i,s,r,o,a})),(()=>{let e=!0;hi.datafeed.onReady((t=>{e&&console.warn("`onReady` should return result asynchronously. Use `setTimeout` with 0 interval to execute the callback function."),ci.configurationData=t,Vi.resolve()})),e=!1})(),ci.createShortcutAction=(()=>{const e=D.createGroup({desc:"API"});return(t,i)=>{var s;e.add({hotkey:(s=t,"number"==typeof s?s:"string"==typeof s?B(s.split("+")):Array.isArray(s)?B(s):0),handler:i})}})(),ci.initializationFinished=()=>{ci.chartWidgetCollection.undoHistory.clearStack()},ci.headerReady=()=>Mi.promise,ci.createButton=e=>{if(null===Ii)throw new Error("Cannot create button: header widget is not ready or is not loaded - use `headerReady` to wait until header is ready");return(e=e||{}).align=e.align||"left",e.useTradingViewStyle=e.useTradingViewStyle||!1,Ii.addButton((0,ue.randomHash)(),e)},ci.createDropdown=e=>{if(void 0===e)throw new Error("Cannot create dropdown without any parameters. Please refer to the documentation");void 0===e.align&&(e.align="left");const t=(0,ue.randomHash)();return Ii?(Ii.addDropdown(t,e),Promise.resolve(new ti(Ii,t))):Mi.promise.then((()=>((0,n.ensureNotNull)(Ii).addDropdown(t,e),new ti((0,n.ensureNotNull)(Ii),t))))},ci.getAllFeatures=()=>{const e=h.getAllFeatures();return Object.keys(e).forEach((t=>{isNaN(parseFloat(t))||delete e[t]})),e},ci.getNavigationButtonsVisibility=(0,s.default)((()=>(0,pe.convertPropertyToWatchedValue)((0,_e.property)()))),ci.getPaneButtonsVisibility=(0,s.default)((()=>(0,pe.convertPropertyToWatchedValue)((0,me.property)()))),ci.getDateFormat=(0,s.default)((()=>(0,pe.convertPropertyToWatchedValue)(ge.dateFormatProperty))),ci.getTimeHoursFormat=(0,s.default)((()=>(0,pe.convertPropertyToWatchedValue)(fe.timeHoursFormatProperty))),ci.getCurrencyAndUnitVisibility=(0,s.default)((()=>(0,pe.convertPropertyToWatchedValue)((0,Le.currencyUnitVisibilityProperty)()))),ci.customSymbolStatus=()=>ni.getInstance(),new ai.Action({actionId:"TVActionId",onExecute:()=>{window.dispatchEvent(new CustomEvent("keyboard-navigation-activation",{bubbles:!0}));const[e]=Array.from(document.querySelectorAll('button:not([disabled], [aria-disabled], [tabindex="-1"]), input:not([disabled], [aria-disabled], [tabindex="-1"]), [tabindex]:not([disabled], [aria-disabled], [tabindex="-1"])')).filter((0,li.createScopedVisibleElementFilter)(document.documentElement)).sort(li.navigationOrderComparator);void 0!==e&&e.focus()},hotkeyHash:D.Modifiers.Alt+90,hotkeyGroup:(0,D.createGroup)({desc:"Global shortcuts"}),disabled:!li.PLATFORM_ACCESSIBILITY_ENABLED})},54358:(e,t,i)=>{e=i.nmd(e), +;const t=this._areas.topleft,i=this._areas.left,s=this._areas.tradingpanel,r=this._areas.right,n=this._areas.top,o=this._areas.bottom,a=this._areas.center,l=this._areas.extratop,c=this._width.value(),h=this._height.value();let d=0,u=0,p=0,_=0,m=0,g=0,f=0,v=0;if(e===this._recalcSingleRunToken&&l){const e=this._processVisibility(l);v=this._setHeight(l,e,h),this._setWidth(l,e,c)}if(e===this._recalcSingleRunToken&&t){const e=this._processVisibility(t);f=this._setHeight(t,e,h),g=this._setWidth(t,e,c);const i=t.container.value();e&&i&&(i.style.top=v+"px")}let S=0;if(e===this._recalcSingleRunToken&&n){const e=this._processVisibility(n),t=n.container.value();e&&t&&(t.style.left=g+"px",t.style.top=v+"px");const i=c-g;this._setWidth(n,e,i),d=this._setHeight(n,e,h),d&&(S=1)}if(e===this._recalcSingleRunToken&&i){const e=this._processVisibility(i),t=Math.max(f,d);p=this._setWidth(i,e,c),p&&(p+=4),p&&1===S&&(S=4);const s=i.container.value();e&&s&&(s.style.top=t+v+S+"px"),this._setHeight(i,e,h-t-v)}if(e===this._recalcSingleRunToken&&s){const e=this._processVisibility(s);let t=c-p;Fe||(t-=300),m=this._setWidth(s,e,t),m&&1===S&&(S=4),this._setHeight(s,e,h-v-d-S)}if(e===this._recalcSingleRunToken&&r){const e=this._processVisibility(r);let t=c-p-m;Fe||(t-=300),_=this._setWidth(r,e,t),_&&1===S&&(S=4),this._setHeight(r,e,h-v-d-S);const i=r.container.value();e&&i&&(i.style.top=d+v+S+"px",i.classList.toggle("no-border-top-left-radius",Boolean(m)))}const y=m+_;let b=0;const w=c-p-m-_-(y?4:0);if(e===this._recalcSingleRunToken&&o){const e=this._processVisibility(o),t=o.container.value();e&&t&&(t.style.left=p+"px",t.classList.toggle("no-border-top-left-radius",!p),t.classList.toggle("no-border-top-right-radius",!y)),this._setWidth(o,e,w);const i=h-v;b=Math.min(300,i-0),u=this._setHeight(o,e,i)+4}const P=Boolean(d&&(p||y));if(this._container.classList.toggle("layout-with-border-radius",P),e===this._recalcSingleRunToken&&a){const e=this._processVisibility(a),t=a.container.value();e&&t&&(t.style.left=p+"px",t.style.top=d+v+S+"px",t.classList.toggle("no-border-bottom-left-radius",!u||!p),t.classList.toggle("no-border-bottom-right-radius",!y||!u),t.classList.toggle("no-border-top-left-radius",Boolean(!p&&y)),t.classList.toggle("no-border-top-right-radius",Boolean(p&&!y))),this._setWidth(a,e,w);const i=h-d-u-v-S;this._setHeight(a,e,Math.max(i,b))}if(e===this._recalcSingleRunToken&&s&&this.affectsLayout("tradingpanel")){const e=s.container.value();e&&(e.style.right=_+"px",e.style.top=v+d+S+"px",e.style.borderTopLeftRadius=P?"4px":"0px")}e===this._recalcSingleRunToken&&this._updateVisibility()}affectsLayout(e){const t=this._areas[e];if(!t)return!1;if(t.rdState.owner.value()!==t)return!1;if(this._fullscreenArea&&this._fullscreenArea!==e)return He(e);if(this._width.value()<=567||this._height.value()<=445&&!We){if(!["center","top","left","topleft","extratop"].includes(e))return!1}return!0}_updateVisibility(){const e=this._bridge.visible.value();for(let t=0;t{hi.ChartApiInstance.start()})),"function"==typeof fi){const e=fi(rt);e&&e.then?e.then((e=>{if(!Array.isArray(e))return console.warn("custom_indicators_getter should be a function that returns a Promise object which result is an array of custom indicators"),void vi.resolve();const t=hi.JSServer;t.studyLibrary.push.apply(t.studyLibrary,e),vi.resolve(),console.log("{0} custom indicators loaded.".format(e.length))})).catch((e=>{console.warn("Error loading custom indicators "+e),vi.resolve()})):(console.warn("custom_indicators_getter should be a function that returns a Promise object"),vi.resolve())}else vi.resolve();hi.widgetReady=e=>{O.subscribe("onChartReady",e,null)};const Ti=null===(ai=mi.theme)||void 0===ai?void 0:ai.toLowerCase();function Ii(e){hi.__defaultsOverrides=hi.__defaultsOverrides||{},(0,de.deepExtend)(hi.__defaultsOverrides,e),void 0!==TradingView.defaultProperties&&void 0!==TradingView.defaultProperties.chartproperties&&((0,c.applyDefaultsOverrides)(TradingView.defaultProperties.chartproperties),(0,c.applyDefaultOverridesToLinetools)())}!function(e){if(!e)return;L.themes[e]&&(0,A.setTheme)(e)}(Ti),hi.applyStudiesOverrides=e=>{var t,i;e&&(hi.chartWidgetCollection?null===(i=(t=hi.chartWidgetCollection).applyStudiesOverrides)||void 0===i||i.call(t,e):Qe.StudyMetaInfo.mergeDefaultsOverrides(e))},hi.applyOverrides=e=>{Ii(e),hi.chartWidgetCollection&&hi.chartWidgetCollection.applyOverrides(e)}, +hi.doWhenApiIsReady=e=>{hi.tradingViewApi?e():Si.promise.then(e)},hi.applyTradingCustomization=e=>{for(const t in e.order)TradingView.defaultProperties.linetoolorder[t]=e.order[t];for(const t in e.position)TradingView.defaultProperties.linetoolposition[t]=e.position[t]},hi.changeTheme=(e,t)=>{const i=L.themes[e.toLowerCase()];return i?hi.tradingViewApi.themes().setStdTheme(i.name,!0,t&&t.disableUndo):Promise.resolve()},hi.getTheme=()=>hi.tradingViewApi.themes().getCurrentThemeName(),hi.is_authenticated=!1;JSON.parse(hi.urlParams.brokerConfig);l.t(null,void 0,i(65911)),l.t(null,void 0,i(68111)),l.t(null,void 0,i(5607));let Mi=null;const Li=(0,he.createDeferredPromise)();let Ai;const ki=()=>{if(h.setEnabled("charting_library_debug_mode","true"===mi.debug),h.setEnabled("chart_property_page_trading",!1),h.enabled("remove_library_container_border")){const e=document.querySelector("#library-container");null!==e&&(e.style.border="0px",e.style.padding="1px")}h.enabled("no_min_chart_width")&&(document.body.style.minWidth="0px"),null!=mi.studiesOverrides&&Qe.StudyMetaInfo.mergeDefaultsOverrides(JSON.parse(mi.studiesOverrides)),(0,n.assert)(void 0===TradingView.defaultProperties,"Default properties are inited before applying overrides"),Ii(JSON.parse(mi.overrides));const e=mi.numeric_formatting?JSON.parse(mi.numeric_formatting):void 0;e&&"string"==typeof e.decimal_sign&&(ae.formatterOptions.decimalSign=e.decimal_sign[0]),hi.ChartApiInstance=new(Je())(di.datafeed);const t=di.customFormatters;t&&(t.timeFormatter&&(le.customFormatters.timeFormatter=t.timeFormatter),t.dateFormatter&&(le.customFormatters.dateFormatter=t.dateFormatter),t.tickMarkFormatter&&(le.customFormatters.tickMarkFormatter=t.tickMarkFormatter),t.priceFormatterFactory&&(le.customFormatters.priceFormatterFactory=t.priceFormatterFactory),t.studyFormatterFactory&&(le.customFormatters.studyFormatterFactory=t.studyFormatterFactory)),di.customTimezones&&Me.instance().addTimezones(di.customTimezones),hi.ChartApiInstance.setStudiesAccessController(hi.ChartApiInstance.createStudiesAccessController(mi.studiesAccess));const s=mi.chartContent?JSON.parse(mi.chartContent).json:void 0,o=mi.chartContentExtendedData?JSON.parse(mi.chartContentExtendedData):s?s.extendedData:void 0,a=mi.interval||"D",c=function(e){const t=/(\d+)(\w+)/;return e.map((e=>{const s=(0,n.ensureNotNull)(t.exec(e.text)),r=s[2].toLowerCase(),o=parseInt(s[1]),a="y"===r?12*o+"M":o+r,c=Ae.Interval.parse(e.resolution);return{text:e.title||o+l.t(r,{context:"dates",count:o},i(673)),description:e.description||"",value:{value:a.toUpperCase(),type:"period-back"},targetResolution:c.value(),requiresIntraday:c.isIntraday()}}))}(JSON.parse(mi.timeFrames)),d={resizerBridge:xi,padding:h.enabled("border_around_the_chart")?2:0,content:s,widgetOptions:{addToWatchlistEnabled:!1,hideIdeas:!0,addVolume:(0,n.ensureDefined)(hi.ChartApiInstance.studiesAccessController).isToolEnabled("Volume"),muteSessionErrors:!0,timezone:mi.timezone,defSymbol:s?"":mi.symbol,defInterval:s?"":a, +compareSymbols:mi.compareSymbols&&JSON.parse(mi.compareSymbols),defTimeframe:(p=di.timeframe,p?"string"==typeof p?p:{...p,type:"time-range"}:p),paneContextMenuEnabled:h.enabled("pane_context_menu"),paneContextMenu:{mainSeriesTrade:_i},priceScaleContextMenuEnabled:h.enabled("scales_context_menu"),currencyConversionEnabled:h.enabled("pricescale_currency"),unitConversionEnabled:h.enabled("pricescale_unit"),legendWidgetEnabled:h.enabled("legend_widget"),legendWidget:{contextMenu:{settings:h.enabled("show_chart_property_page"),showOpenMarketStatus:h.enabled("display_market_status")}},sourceStatusesWidget:{errorSolution:!1},marketStatusWidgetEnabled:h.enabled("display_market_status"),chartWarningWidget:{subscriptionFullInfo:!1},timeScaleWidget:{contextMenuEnabled:h.enabled("scales_context_menu"),timezoneMenuEnabled:h.enabled("timezone_menu"),priceAxisLabelsOptions:{showLabels:h.enabled("main_series_scale_menu")}},timeScale:{preserveBarSpacing:!1,lockVisibleTimeRangeOnResize:h.enabled("lock_visible_time_range_on_resize"),rightBarStaysOnScroll:h.enabled("right_bar_stays_on_scroll"),minBarSpacing:mi.time_scale&&JSON.parse(mi.time_scale).min_bar_spacing},goToDateEnabled:h.enabled("go_to_date"),crossHair:{menuEnabled:h.enabled("chart_crosshair_menu")},handleScale:{mouseWheel:h.enabled("mouse_wheel_scale"),pinch:h.enabled("pinch_scale"),axisPressedMouseMove:{time:h.enabled("axis_pressed_mouse_move_scale"),price:h.enabled("axis_pressed_mouse_move_scale")}},handleScroll:{mouseWheel:h.enabled("mouse_wheel_scroll"),pressedMouseMove:h.enabled("pressed_mouse_move_scroll"),horzTouchDrag:h.enabled("horz_touch_drag_scroll"),vertTouchDrag:h.enabled("vert_touch_drag_scroll")},shiftVisibleRangeOnNewBar:h.enabled("shift_visible_range_on_new_bar"),croppedTickMarks:h.enabled("cropped_tick_marks"),countdownEnabled:h.enabled("countdown"),indicatorsDialogShortcutEnabled:h.enabled("insert_indicator_dialog_shortcut")},seriesControlBarEnabled:h.enabled("timeframes_toolbar"),seriesControlBar:{timeFramesWidgetEnabled:!0,timeFramesWidget:{goToDateEnabled:h.enabled("go_to_date"),availableTimeFrames:(e,t)=>{if(!e)return[];if(t!==st.STATUS_DELAYED&&t!==st.STATUS_DELAYED_STREAMING&&t!==st.STATUS_EOD&&t!==st.STATUS_READY)return[];return c.filter((t=>!(t.requiresIntraday&&!e.has_intraday)&&!(e.supported_resolutions&&!e.supported_resolutions.includes(t.targetResolution))))}},timeWidgetEnabled:!0,timeWidget:{timezoneMenuEnabled:h.enabled("timezone_menu")},adjustForDividendsButtonEnabled:!1,sessionIdButtonEnabled:h.enabled("pre_post_market_sessions"),backAdjustmentButtonEnabled:!1,settlementAsCloseButtonEnabled:!1,percentageScaleButtonEnabled:!0,logScaleButtonEnabled:!0,autoScaleButtonEnabled:!0,fullscreenButtonEnabled:!0,mobileChangeLayoutEnabled:!1},globalEvents:!0,snapshotUrl:mi.snapshotUrl,mobileForceChartMaximizeEnabled:!1,saveChartEnabled:h.enabled("save_shortcut")};var p;yi&&((0,$e.createFavoriteDrawingToolbar)(),d.widgetOptions.isDrawingToolbarVisible=C.isDrawingToolbarVisible),o&&(d.metaInfo={id:o.uid,name:o.name,description:o.description,uid:o.uid, +username:""}),di.additionalSymbolInfoFields&&(0,ei.setAdditionalSymbolInfoFields)(di.additionalSymbolInfoFields);const _=di.symbolSearchComplete;_&&(0,ti.setSymbolSearchCompleteOverrideFunction)(_);const m=hi.chartWidgetCollection=new(qe())(d);let g=!1;m.onAboutToBeDestroyed.subscribe(null,(()=>{g=!0}),!0),function(e){e.addCustomSource("branding",((t,i)=>{const s=(0,nt.combine)(((e,t)=>{const s=null!=e?e:t;return null!==s&&s.hasModel()&&s.model().model()===i}),e.maximizedChartWidget().weakReference(),e.leftBottomChartWidget().weakReference());return new zt(t,i,s.ownership())}))}(m),hi.studyMarket=new ce(m),je.registerService(Ue.CHART_WIDGET_COLLECTION_SERVICE,m),m.activeChartWidget.subscribe((e=>{O.emit("activeChartChanged",m.getAll().indexOf(e))})),hi.saver=new R.ChartSaver(m);const f=new Y(m,hi.saver),v=new Q(m);hi.chartWidget=m.activeChartWidget.value(),hi.pro=new TradingView.Pro;const y=function(e){if(!Pi)return null;const t=new I.ChartChangesWatcher(e.chartWidgetCollection,hi.saver,O),i=JSON.parse(mi.favorites);let s,r;i.intervals=i.intervals.map((e=>{let t=""+e;return t.match(/1[DWMYdwmy]/)&&(t=t.slice(1)),t})),h.enabled("study_templates")&&(s=new ne.FavoriteStudyTemplateService(Z.TVXWindowEvents,u),Ai=new re({chartWidgetCollection:e.chartWidgetCollection,favoriteStudyTemplatesService:s}));const n=mi.header_widget_buttons_mode;"fullsize"===n&&(r=["full"]);"compact"===n&&(r=["small"]);return new P(new S,{chartSaver:hi.saver,chartApiInstance:hi.ChartApiInstance,chartWidgetCollection:e.chartWidgetCollection,defaultFavoriteStyles:i.chartTypes,defaultFavoriteIntervals:i.intervals,resizerBridge:Pi,studyMarket:hi.studyMarket,studyTemplates:Ai,favoriteStudyTemplatesService:s,allowedModes:r,saveChartService:e.saveChartService,loadChartService:e.loadChartService,chartChangesWatcher:t,onClick:Bi,snapshotUrl:e.snapshotUrl})}({chartWidgetCollection:m,saveChartService:f,loadChartService:v,snapshotUrl:mi.snapshotUrl});null!==y?y.load().then((e=>{Mi=e.getComponent(),Li.resolve()})):(Li.promise.catch((()=>{})),Li.reject("header widget is not loaded"));const b=function(e){if(Ci){const t=mi.toolbarbg&&/^[0-9a-f]+$/i.test(mi.toolbarbg)?String(mi.toolbarbg):void 0;if(t){const e=document.createElement("style");e.textContent="body,.chart-controls-bar,#footer-chart-panel{background-color:#"+t+" !important}",document.head.appendChild(e)}return new T({bgColor:t,chartWidgetCollection:e,drawingsAccess:mi.drawingsAccess?JSON.parse(mi.drawingsAccess):void 0,resizerBridge:Ci,onClick:Bi})}return null}(m),w=null;hi.tradingViewApi=new(tt())({chartWidgetCollection:m,chartApiInstance:hi.ChartApiInstance,saveChartService:f,loadChartService:v,studyMarket:null});if(oe.linking.bindToChartWidgetCollection(m),isNaN(mi.studyCountLimit)||(TradingView.STUDY_COUNT_LIMIT=Math.max(2,+(0,n.ensureDefined)(mi.studyCountLimit))),!isNaN(mi.ssreqdelay)){const e=Math.max(0,+(0,n.ensureDefined)(mi.ssreqdelay));(0,it.setSearchRequestDelay)(e)}hi.ChartApiInstance.connect(),(async()=>{ +const{default:e}=await Promise.all([i.e(5652),i.e(2666),i.e(3842),i.e(4015),i.e(6),i.e(5993),i.e(5649),i.e(2191),i.e(8056),i.e(3502),i.e(6752),i.e(8149),i.e(6639),i.e(9327),i.e(6106),i.e(9916),i.e(1109),i.e(6831),i.e(8399),i.e(962),i.e(3179),i.e(5050),i.e(1890),i.e(2020),i.e(5899),i.e(2306)]).then(i.t.bind(i,26916,23));g||(hi.lineToolPropertiesToolbar=new e(m))})();const x=document.querySelector(".tv-content");null!==x&&x.addEventListener("contextmenu",(e=>{e.target instanceof Element&&"input"!==e.target.tagName.toLowerCase()&&"textarea"!==e.target.tagName.toLowerCase()&&e.preventDefault()})),Si.resolve(),m.undoHistory.undoStack().onChange().subscribe(null,(0,r.default)((e=>{e&&!e.customFlag("doesnt_affect_save")&&O.emit("onAutoSaveNeeded")}),1e3*(Number(mi.autoSaveDelay)||5),{leading:!1,trailing:!0}));let M=!1;function A(){b&&b.load(gi.signal),w&&w.load(gi.signal).then((e=>{hi.footerWidget=e.getComponent()}))}hi.chartWidget.withModel(null,(()=>{hi.ChartApiInstance.on("realtime_tick",(e=>{O.emit("onTick",e)}));if(!L.savedThemeName()&&Ti){const e=L.getStdTheme(Ti);e&&e.content&&void 0===s&&m.applyTheme({theme:e.content,onlyActiveChart:!1,restoreNonThemeDefaults:!1,themeName:Ti,standardTheme:!0,syncState:!0,noUndo:!0}).then((()=>hi.applyOverrides(hi.__defaultsOverrides)))}if(h.enabled("charting_library_debug_mode")&&O.subscribeToAll(((...e)=>{console.log('Event "{0}", arguments: {1}'.format(e[0],JSON.stringify(e.slice(1))))})),M)return;M=!0,function(e,t=!1){if(!h.enabled("popup_hints"))return;const s=e.getContainer();let r=null,o=null;function a(e,t){if(r)r.show(e,d.bind(null,t));else{const n=Ye.tool.value();Promise.all([i.e(6214),i.e(962),i.e(6166)]).then(i.bind(i,5015)).then((i=>{r=new i.ChartEventHintRenderer(s),n===Ye.tool.value()&&r.show(e,d.bind(null,t))}))}}function c(e){return!Boolean(u.getBool(e))}function d(e){u.setValue(e,!0,{forceFlush:!0}),(0,n.ensureNotNull)(r).destroy(),null!==o&&o(),r=null}Ye.tool.subscribe((function(){if(!c("hint.touchPainting"))return;const e=Ye.tool.value(),t=(0,Ke.isLineToolDrawWithoutPoints)(e),s=Be.CheckMobile.any();!(0,Ke.isStudyLineToolName)(e)||"LineToolRegressionTrend"===e||t||s?(0,Ke.isLineToolName)(e)&&!(0,Ke.isLineDrawnWithPressedButton)(e)&&!t&&s?a(l.t(null,void 0,i(67861)),"hint.touchPainting"):r&&r.hide():a(l.t(null,void 0,i(32234)),"hint.touchPainting")})),Ye.createdLineTool.subscribe(null,(function(){const e=Ye.tool.value();"LineToolPath"===e&&c("hint.finishBuildPathByDblClick")?a(l.t(null,void 0,i(5828)),"hint.finishBuildPathByDblClick"):"LineToolPolyline"===e&&c("hint.finishBuildPolylineByDblClick")&&a(l.t(null,void 0,i(63898)),"hint.finishBuildPolylineByDblClick")})),Ye.finishedLineTool.subscribe(null,(function(){if(r){const e=Ye.tool.value();"LineToolPath"===e?d("hint.finishBuildPathByDblClick"):"LineToolPolyline"===e&&d("hint.finishBuildPolylineByDblClick")}})),e.layoutSizesChanged().subscribe((function(){c("hint.startResizingChartInLayout")&&a(l.t(null,void 0,i(35273)),"hint.startResizingChartInLayout")})), +t||Be.CheckMobile.any()||!c("hint.startFocusedZoom")||(o=function(e,t){let i=!1;const s=r=>{r?(i&&t(r),e.onZoom().unsubscribe(null,s)):i||(t(r),i=!0)};return e.onZoom().subscribe(null,s),()=>e.onZoom().unsubscribe(null,s)}(e,(function(e){if(c("hint.startFocusedZoom"))if(e)r&&(o=null,d("hint.startFocusedZoom"));else{const e=Ze.isMacKeyboard?"⌘":"Ctrl";a(l.t(null,void 0,i(35963)).format({key:e}),"hint.startFocusedZoom")}})))}(m),function(e,t){const s=l.t(null,void 0,i(78104)).format({emoji:"👍"}),r=l.t(null,void 0,i(12011)).format({emoji:"👍"}),o=l.t(null,void 0,i(79393)).format({emoji:"👍"});O.on("onServerScreenshotCopiedToClipboard",(()=>h(s)),null),O.on("onClientScreenshotCopiedToClipboard",(()=>h(r)),null),O.on("onServerScreenshotEmbedCodeCopiedToClipboard",(()=>h(o)),null);let a=null;const c=e.getContainer();function h(e){a?a.show(e):Promise.all([i.e(2109),i.e(3896),i.e(962),i.e(92)]).then(i.bind(i,60441)).then((i=>{a||(a=new i.ChartScreenshotHintRenderer((0,n.ensureNotNull)(c),{bottomPadding:t.seriesControlBarEnabled}),a.show(e))}))}}(m,{seriesControlBarEnabled:h.enabled("timeframes_toolbar")});si.WatermarkApi.getInstance().setWidgetCollection(hi.chartWidgetCollection)})),m.getAll().some((e=>e.isInitialized()))?A():function(e,t){const i=e.getAll(),s=()=>{t(),i.forEach((e=>{e.chartWidgetInitialized().unsubscribe(null,s)}))};i.forEach((e=>{e.chartWidgetInitialized().subscribe(null,s,!0)}))}(m,A),O.subscribe("chart_load_requested",(e=>{hi.tradingViewApi.loadChart({json:JSON.parse(e.content),extendedData:e})}),null)};window.addEventListener("unload",(()=>{gi.abort(),hi.widgetbar&&(hi.widgetbar.destroy(),hi.widgetbar=null),hi.chartWidgetCollection&&(hi.chartWidgetCollection.destroy(),hi.chartWidgetCollection=null),hi.ChartApiInstance&&hi.ChartApiInstance.disconnect(),(0,ze.destroyQuoteSessions)(),hi.ChartApiInstance&&(hi.ChartApiInstance.destroy(),hi.ChartApiInstance=null)})),h.enabled("saveload_storage_customization")&&(di.saveLoadAdapter?k.setCustomAdapter(di.saveLoadAdapter):hi.urlParams.chartsStorageUrl&&hi.urlParams.clientId?k.initialize(hi.urlParams.clientId,hi.urlParams.userId,hi.urlParams.chartsStorageUrl,hi.urlParams.chartsStorageVer||"1.0"):(h.setEnabled("saveload_storage_customization",!1),h.setEnabled("header_saveload",!1)));const Di=(0,he.createDeferredPromise)();function Ei(){Di.resolve()}di.loadLastChart&&h.enabled("saveload_storage_customization")?k.getCharts().then((e=>{if(0===e.length)return void Ei();const t=e.sort(((e,t)=>t.modified_iso-e.modified_iso))[0];k.getChartContent(t).then((e=>{const t=e,i=JSON.parse(t.content);i.extendedData=e,mi.chartContent=JSON.stringify({json:i}),Ei()})).catch(Ei)})).catch(Ei):Ei();const Vi=(0,he.createDeferredPromise)();function Bi(){const e=TradingView.bottomWidgetBar;e&&e.turnOffMaximize()}Promise.all([Vi.promise,Di.promise,hi.loadedCustomCss]).then((()=>{const e=document.querySelector(".loading-indicator");if(e&&(e.style.display="none"),setTimeout(ki,0),h.enabled("14851")&&Math.random()<=.02){t=window,i=document,s="script",r="ga",t.GoogleAnalyticsObject=r, +t.ga=t.ga||function(){(t.ga.q=t.ga.q||[]).push(arguments)},t.ga.l=Number(new Date),o=i.createElement(s),a=i.getElementsByTagName(s)[0],o.async=1,o.src="//www.google-analytics.com/analytics.js",a.parentNode.insertBefore(o,a);const e=(0,n.ensureNotNull)(document.URL.match(new RegExp("(:?.*://)([^/]+)/.*")))[2];hi.ga("create","UA-112911840-1","auto"),hi.ga("set","anonymizeIp",!0),hi.ga("set",{hostname:e,page:e,referrer:e}),hi.ga("send","pageview")}var t,i,s,r,o,a})),(()=>{let e=!0;di.datafeed.onReady((t=>{e&&console.warn("`onReady` should return result asynchronously. Use `setTimeout` with 0 interval to execute the callback function."),hi.configurationData=t,Vi.resolve()})),e=!1})(),hi.createShortcutAction=(()=>{const e=D.createGroup({desc:"API"});return(t,i)=>{var s;e.add({hotkey:(s=t,"number"==typeof s?s:"string"==typeof s?B(s.split("+")):Array.isArray(s)?B(s):0),handler:i})}})(),hi.initializationFinished=()=>{hi.chartWidgetCollection.undoHistory.clearStack()},hi.headerReady=()=>Li.promise,hi.createButton=e=>{if(null===Mi)throw new Error("Cannot create button: header widget is not ready or is not loaded - use `headerReady` to wait until header is ready");return(e=e||{}).align=e.align||"left",e.useTradingViewStyle=e.useTradingViewStyle||!1,Mi.addButton((0,ue.randomHash)(),e)},hi.createDropdown=e=>{if(void 0===e)throw new Error("Cannot create dropdown without any parameters. Please refer to the documentation");void 0===e.align&&(e.align="left");const t=(0,ue.randomHash)();return Mi?(Mi.addDropdown(t,e),Promise.resolve(new ii(Mi,t))):Li.promise.then((()=>((0,n.ensureNotNull)(Mi).addDropdown(t,e),new ii((0,n.ensureNotNull)(Mi),t))))},hi.getAllFeatures=()=>{const e=h.getAllFeatures();return Object.keys(e).forEach((t=>{isNaN(parseFloat(t))||delete e[t]})),e},hi.getNavigationButtonsVisibility=(0,s.default)((()=>(0,pe.convertPropertyToWatchedValue)((0,_e.property)()))),hi.getPaneButtonsVisibility=(0,s.default)((()=>(0,pe.convertPropertyToWatchedValue)((0,me.property)()))),hi.getDateFormat=(0,s.default)((()=>(0,pe.convertPropertyToWatchedValue)(ge.dateFormatProperty))),hi.getTimeHoursFormat=(0,s.default)((()=>(0,pe.convertPropertyToWatchedValue)(fe.timeHoursFormatProperty))),hi.getCurrencyAndUnitVisibility=(0,s.default)((()=>(0,pe.convertPropertyToWatchedValue)((0,Le.currencyUnitVisibilityProperty)()))),hi.customSymbolStatus=()=>oi.getInstance(),new li.Action({actionId:"TVActionId",onExecute:()=>{window.dispatchEvent(new CustomEvent("keyboard-navigation-activation",{bubbles:!0}));const[e]=Array.from(document.querySelectorAll('button:not([disabled], [aria-disabled], [tabindex="-1"]), input:not([disabled], [aria-disabled], [tabindex="-1"]), [tabindex]:not([disabled], [aria-disabled], [tabindex="-1"])')).filter((0,ci.createScopedVisibleElementFilter)(document.documentElement)).sort(ci.navigationOrderComparator);void 0!==e&&e.focus()},hotkeyHash:D.Modifiers.Alt+90,hotkeyGroup:(0,D.createGroup)({desc:"Global shortcuts"}),disabled:!ci.PLATFORM_ACCESSIBILITY_ENABLED})},54358:(e,t,i)=>{e=i.nmd(e), TradingView.cleanButAmpersand=function(e,t){var i=t?["&"]:["&"];return TradingView.clean(e,t,i)},TradingView.strip_tags=function(e){return e&&e.replace?e.replace(/(<([^>]+)>)/gi,""):e},TradingView.encodeSpread=function(e){return encodeURIComponent(e)},TradingView.clean=function(e,t,i){var s=[["&","&"],["<","<"],[">",">"],['"',"""],["'","'"],["'","'"]],r=e;if(!e||!e.replace)return r;for(var n=0;n{"use strict";i.r(t);var s=i(21097),r=i(51768),n=i(76422),o=i(38780);function a(e,t=!1){"loading"!==document.readyState?t?setTimeout((()=>e()),1):e():document.addEventListener("DOMContentLoaded",(()=>e()))}new Promise((e=>{a(e)}));function l(e,t="x"){let i=!1;return"x"!==t&&"both"!==t||(i=i||e.offsetWidth{document.addEventListener("mouseenter",(e=>{const t=e.target;if(t instanceof HTMLElement&&t.matches(".apply-overflow-tooltip")){let e="x";if(t.matches(".apply-overflow-tooltip--direction_both")?e="both":t.matches(".apply-overflow-tooltip--direction_y")&&(e="y"),t.matches(".apply-overflow-tooltip--check-children-recursively")){if(!c(t,e))return}else if(t.matches(".apply-overflow-tooltip--check-children")){let i=!1;const s=t.children;for(let t=0;t(t.nodeType===Node.TEXT_NODE&&e.push(t.textContent||""),e)),[]).join("").trim()),(0,o.showOnElement)(t,{text:s});const r=()=>{(0,o.hide)(),["mouseleave","mousedown"].forEach((e=>t.removeEventListener(e,r)))};["mouseleave","mousedown"].forEach((e=>t.addEventListener(e,r)))}}),!0)}));var h=i(57898),d=i(11417);var u=i(30888);let p;function _(e){window.iframeAuthWidget&&!1===window.user.profile_data_filled&&(window.iframeAuthWidget.preventClose=!0);const t=window.user.available_offers||{};window.TVSettings&&window.TVSettings.sync(window.user.settings),window.is_authenticated?(e||(initOfferLoginStateChangeButton(),onGoPro()&&window.location.reload()),!1===window.user.profile_data_filled&&((0,r.trackEvent)("Conversion","First login"),delete window.user.profile_data_filled)):(Object.keys(t).forEach((e=>{const i=e;t[i].available_for_anons||delete t[i]})),window.user={username:"Guest",following:"0",followers:"0",ignore_list:[],available_offers:t},d.TVLocalStorage.removeItem("trial_availiable"))} p=window.loginStateChange?window.loginStateChange:window.loginStateChange=new h.Delegate,p.subscribe(null,_),s.TVXWindowEvents.on("loginStateChange",(e=>{const t=JSON.parse(e);window.user=t.user,window.is_authenticated=!!t.is_authenticated,p.fire()})),s.TVXWindowEvents.on("signOut",(()=>{!function(){if(window.initData.lfs){const e=document.getElementsByClassName("js-admin-warning")[0];document.body.removeChild(e)}let e=!0;[/^\/chart\//,/^\/share-your-love\//].forEach((t=>{t.test(window.location.pathname)&&(e=!1)})),e&&window.location.reload()}()})),(()=>{const e="user-obj-changed",t={};window.crossTabSyncUserAttr=t=>{const i={};t instanceof Array?t.forEach((e=>{i[e]=window.user[e]})):i[t]=window.user[t],s.TVXWindowEvents.emit(e,JSON.stringify(i))},s.TVXWindowEvents.on(e,(e=>{const i=JSON.parse(e);let s;for(s in i)if(i.hasOwnProperty(s)){window.user[s]=i[s];(t[s]||[]).forEach((e=>{e.fire(i[s])}))}}))})(),window.TradingView.changeLoginState=e=>{window.is_authenticated=!!e,s.TVXWindowEvents.emit("loginStateChange",JSON.stringify({is_authenticated:window.is_authenticated,user:window.user})),p.fire()},window.loginUser=function(e,t){window.TVDialogs&&window.TVDialogs.signModal&&window.TVDialogs.signModal.close(),window.user=(0,u.deepExtend)({},e),window.TradingView.changeLoginState(!0),"function"==typeof t&&window.TVDialogs&&window.TVDialogs.signModal?n.subscribe("GLOBAL_EVENT_SIGN_IN_SUCCESS",t,null):"function"==typeof t&&t()},window.loginRequiredDelegate=new h.Delegate,window.runOrSignIn=(e,t)=>{t||(t={}),e()},window.onLoginStateChange=_,window.TradingView.setTrialAvailiable=e=>{d.TVLocalStorage.setItem("trial_availiable",e?"1":"0")},window.TradingView.notificationsChanged=new h.Delegate},87095:(e,t,i)=>{"use strict";i.r(t),i.d(t,{alphaToTransparency:()=>o,applyAlpha:()=>n,applyTransparency:()=>l,colorFromBackground:()=>u,colorToInteger:()=>f,generateColor:()=>r,getLuminance:()=>h,gradientColorAtPercent:()=>p,isColorDark:()=>_,isHexColor:()=>d,resetTransparency:()=>c,rgbaFromInteger:()=>m,rgbaToInteger:()=>g,transparencyToAlpha:()=>a});var s=i(24377);function r(e,t,i){if(t=t||0,!d(e))return i?(0,s.rgbaToString)((0,s.rgba)((0,s.parseRgb)(e),(0,s.normalizeAlphaComponent)(a(t)))):e;const[r,n,o]=(0,s.parseRgb)(e),l=(0,s.normalizeAlphaComponent)(a(t));return(0,s.rgbaToString)([r,n,o,l])}function n(e,t){return r(e,o(t),!0)}function o(e){return 100*(1-e)}function a(e){if(e<0||e>100)throw new Error("invalid transparency");return 1-e/100}function l(e,t){if("transparent"===e)return e;const i=(0,s.parseRgba)(e),r=i[3];return(0,s.rgbaToString)((0,s.rgba)(i[0],i[1],i[2],a(t)*r))}function c(e){return"transparent"===e||d(e)?e:(0,s.rgbaToString)((0,s.rgba)((0,s.parseRgb)(e),(0,s.normalizeAlphaComponent)(1)))}function h(e){const t=(0,s.parseRgb)(e).map((e=>(e/=255)<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)));return Number((.2126*t[0]+.7152*t[1]+.0722*t[2]).toFixed(3))}function d(e){return 0===e.indexOf("#")}function u(e){return"black"===(0,s.rgbToBlackWhiteString)((0,s.parseRgb)(e),150)?"#ffffff":"#000000"}function p(e,t,i){ const[r,n,o,a]=(0,s.parseRgba)(e),[l,c,h,d]=(0,s.parseRgba)(t),u=(0,s.rgba)(Math.round(r+i*(l-r)),Math.round(n+i*(c-n)),Math.round(o+i*(h-o)),a+i*(d-a));return(0,s.rgbaToString)(u)}function _(e){return h(c(e))<.5}function m(e){const t=(e=Math.round(e))%256;e-=t;const i=(e/=256)%256;e-=i;const s=(e/=256)%256;e-=s;return`rgba(${t},${i},${s},${(e/=256)/255})`}function g(e){const t=Math.round(255*e[3]);return e[0]+256*e[1]+65536*e[2]+16777216*t}function f(e){const t=(0,s.tryParseRgba)(e);return null===t?0:g(t)}},88275:(e,t,i)=>{"use strict";i.d(t,{doAnimate:()=>n});const s={from:0,duration:250,easing:i(61345).easingFunc.easeOutCubic};class r{constructor(e){this._doing=!0,this._completed=!1,this._options={...s,...e};const t=performance.now();window.requestAnimationFrame((e=>{this._animation(t,this._options.from,e)}))}stop(){this._doing=!1}completed(){return this._completed}_animation(e,t,i){if(!this._doing)return void this._finishAnimation();const s=(i=!i||i<1e12?performance.now():i)-e,r=s>=this._options.duration||t===this._options.to,n=(o=this._options.from,a=this._options.to,l=this._options.easing(s/this._options.duration),o*(1-l)+a*l);var o,a,l;const c=r?this._options.to:n,h=c-t;this._options.onStep(h,c),r?this._finishAnimation():window.requestAnimationFrame((t=>{this._animation(e,c,t)}))}_finishAnimation(){this._options.onComplete&&this._options.onComplete(),this._completed=!0}}function n(e){return new r(e)}},69798:(e,t,i)=>{"use strict";i.d(t,{fetch:()=>s});(0,i(59224).getLogger)("Fetch");function s(e,t,i={}){return window.fetch(e,t)}},59224:(e,t,i)=>{"use strict";i.r(t),i.d(t,{LOGLEVEL:()=>s.LOGLEVEL,getLogHistory:()=>s.getLogHistory,getLogLevel:()=>s.getLogLevel,getLogger:()=>s.getLogger,getRawLogHistory:()=>s.getRawLogHistory,isHighRateEnabled:()=>s.isHighRateEnabled,loggingOff:()=>s.loggingOff,loggingOn:()=>s.loggingOn,serializeLogHistoryEntry:()=>s.serializeLogHistoryEntry,setLogLevel:()=>s.setLogLevel});var s=i(44441)},29764:(e,t,i)=>{"use strict";function s(e,t,i,s){return`${s?s+" ":""}${i?i+" ":""}${e}px ${t}`}i.d(t,{makeFont:()=>s,parseFont:()=>n});const r=/(bold )?(italic )?(\d+)(px|pt) (.*)$/;function n(e){const t=r.exec(e);return null===t?null:{family:t[5],size:parseInt(t[3])*("pt"===t[4]?.75:1),bold:Boolean(t[1]),italic:Boolean(t[2])}}},2298:()=>{"use strict";(()=>{if(window.matchMedia("").addEventListener)return;const e=window.matchMedia;window.matchMedia=(...t)=>{const i=e(...t);return i.addEventListener=(e,t)=>i.addListener(t),i.removeEventListener=(e,t)=>i.removeListener(t),i}})()},2663:(e,t,i)=>{"use strict";i.d(t,{visitObject:()=>n});var s=i(1722);function r(e,t,i){return(0,s.isArray)(e)?function(e,t,i){return e.map((e=>{const s=r(e,t,i),n=t(s);return void 0!==n?n:s}))}(e,t,i):(0,s.isObject)(e)&&((0,s.isHashObject)(e)||i&&i.visitInstances)?function(e,t,i){const s={};return Object.keys(e).forEach((n=>{const o=r(e[n],t,i),a=t(o);s[n]=void 0!==a?a:o})),s}(e,t,i):e}function n(e,t,i){const s=r(e,t,i),n=t(s);return void 0!==n?n:s}},52157:(e,t,i)=>{"use strict";function s(e){ diff --git a/charting_library/bundles/lt-pane-views.f9c2f48c51585106118a.js b/charting_library/bundles/lt-pane-views.9222abe1a9c6cc59d449.js similarity index 65% rename from charting_library/bundles/lt-pane-views.f9c2f48c51585106118a.js rename to charting_library/bundles/lt-pane-views.9222abe1a9c6cc59d449.js index b9147967..66b8e0d4 100644 --- a/charting_library/bundles/lt-pane-views.f9c2f48c51585106118a.js +++ b/charting_library/bundles/lt-pane-views.9222abe1a9c6cc59d449.js @@ -46,44 +46,44 @@ const r=s.vertLabelsAlign.value(),l=s.horzLabelsAlign.value();let c=0,p=0;"left" return Boolean(this._source.isLocked&&this._source.isLocked())}addAnchors(e,t){let i=this._points;this._model.lineBeingCreated()===this._source&&(i=i.slice(0,-1));const n=i.map(((e,t)=>{const i=this._source.points()[t],n=e;return n.snappingPrice=null==i?void 0:i.price,n.snappingIndex=null==i?void 0:i.index,n}));e.append(this.createLineAnchor({...null!=t?t:{},points:n},0))}createLineAnchor(e,t){var i;if(this.isLocked()){const i=this._getSelectionRenderer(t);return i.setData({bgColors:this._lineAnchorColors(e.points),points:e.points,visible:this.areAnchorsVisible(),hittestResult:o.HitTarget.Regular,barSpacing:this._model.timeScale().barSpacing()}),i}const n=(0,s.lastMouseOrTouchEventInfo)().isTouch,r=this._getLineAnchorRenderer(t);return r.setData({...e,color:this.anchorColor(),backgroundColors:this._lineAnchorColors(e.points),currentPoint:this.currentPoint(),linePointBeingEdited:this.isBeingEdited()?this._model.linePointBeingEdited():null,hittestResult:null!==(i=e.hittestResult)&&void 0!==i?i:o.HitTarget.ChangePoint,radius:this._anchorRadius(),strokeWidth:n?c.TouchStrokeWidth:c.RegularStrokeWidth,selected:this.isSelectedSource(),selectedStrokeWidth:n?c.TouchSelectedStrokeWidth:c.RegularSelectedStrokeWidth,visible:this.areAnchorsVisible()}),r}_anchorRadius(){return(0,s.lastMouseOrTouchEventInfo)().isTouch?c.TouchAnchorRadius:c.RegularAnchorRadius}_lineAnchorColors(e){const t=(0,r.ensureNotNull)(this._model.paneForSource(this._source)).height();return e.map((e=>this._model.backgroundColorAtYPercentFromTop(e.y/t)))}_updateImpl(e,t){this._points=[];if(this._model.timeScale().isEmpty())return;if(!this._validatePriceScale())return;const i=this._source.points();for(let e=0;e{"use strict";i.r(t),i.d(t,{LineToolBeingCreatedPaneView:()=>c});var n=i(48891),r=i(79191),s=i(79849),o=i(73436),a=i(19266),l=i(71254),d=i(99031);const h=n.colorsPalette["color-cold-gray-500"];class c extends r.LineSourcePaneView{ constructor(){super(...arguments),this._lineRenderer1=new l.VerticalLineRenderer,this._lineRenderer2=new l.VerticalLineRenderer,this._medianRenderer=new d.TrendLineRenderer,this._renderer=null}renderer(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._renderer}_updateImpl(){super._updateImpl(),this._renderer=null;const e=this._getPoints();if(e.length<1)return;this._renderer=new a.CompositeRenderer;const[t,i]=e;this._lineRenderer1.setData({x:t.x,color:h,linewidth:1,linestyle:s.LINESTYLE_SOLID}),this._renderer.append(this._lineRenderer1),e.length>1&&(this._lineRenderer2.setData({x:i.x,color:h,linewidth:1,linestyle:s.LINESTYLE_SOLID}),this._medianRenderer.setData({points:[t,i],color:h,linewidth:1,linestyle:s.LINESTYLE_SOLID,extendleft:!1,extendright:!1,leftend:o.LineEnd.Normal,rightend:o.LineEnd.Normal}),this._renderer.append(this._lineRenderer2),this._renderer.append(this._medianRenderer))}}},134:(e,t,i)=>{"use strict";i.r(t),i.d(t,{LineToolPaneViewFibWithLabels:()=>d});var n=i(86441),r=i(79191),s=i(80657),o=i(87663),a=i(93572),l=i(46501);class d extends r.LineSourcePaneView{constructor(e,t){super(e,t),this._labelsRenderers={};for(let t=0;tthis._model.timeScale().width()&&!h||r.x<0&&!c);let b,P,L=a;switch(L){case"left":P=i.y,h?b=T?0:r.x:(b=i.x,L="right");break;case"right":P=r.y,c?b=T?this._model.timeScale().width():i.x:(b=r.x,L="left");break;default:b=(i.x+r.x)/2,P=(i.y+r.y)/2}const S=m["level"+t].coeff.value();let C="";if(w){C+=null!==(f=null===(g=m.coeffsAsPercents)||void 0===g?void 0:g.value())&&void 0!==f&&f?this._percentageFormatter.format(100*S,!1,2):this._numericFormatter.format(S)}return R&&(C+="("+x.formatPrice(s,y)+")"),v.setData({points:[new n.Point(b,P)],text:C,color:o,vertAlign:d,horzAlign:L,offsetX:4,offsetY:0,font:l.CHART_FONT_FAMILY,fontSize:m.labelFontSize?m.labelFontSize.value():12}),v}}},34658:(e,t,i)=>{"use strict";i.r(t),i.d(t,{NotePaneView:()=>m});var n=i(50151),r=i(79191),s=i(19266),o=i(80101),a=i(18807),l=i(46501),d=i(80657),h=i(87095),c=i(38223),u=i(74359),p=i(57352),_=i(27714),g=i(86441),f=i(34026);class v{constructor(e){this._data=null,this._sourceCanvas=null,this._translate=new g.Point(0,0),this._renderParams=e}destroy(){var e;null===(e=this._sourceCanvas)||void 0===e||e.remove()}renderParams(){return this._renderParams}update(e){var t,i;t=this._data, i=e,(null===t||t.markerColor!==i.markerColor||t.borderColor!==i.borderColor||t.width!==i.width||t.height!==i.height)&&this._createSource(e.width,e.height,e.markerColor),this._data=e}drawOn(e){const t=(0,n.ensureNotNull)(this._data),i=new g.Point(Math.round(t.point.x),Math.round(t.point.y)).add(this._translate);e.drawImage((0,n.ensureNotNull)(this._sourceCanvas),Math.round(i.x*this._renderParams.pixelRatio),Math.round(i.y*this._renderParams.pixelRatio),Math.round(t.width*this._renderParams.pixelRatio),Math.round(t.height*this._renderParams.pixelRatio))}hasPoint(e){const t=(0,n.ensureNotNull)(this._data),i=t.point.add(this._translate),r=new g.Point(t.point.x-this._translate.x,t.point.y);return(0,f.pointInBox)(e,(0,g.box)(i,r))}_createSource(e,t,i){this._sourceCanvas=(0,u.createDisconnectedCanvas)(document,(0,_.size)({width:e,height:t}),this._renderParams.pixelRatio),this._translate=new g.Point(-e/2,.5-t),this._translate.x%1==0&&(this._translate=new g.Point(this._translate.x+.5,this._translate.y));const r=(0,n.ensureNotNull)(this._sourceCanvas.getContext("2d")),{pixelRatio:s}=this._renderParams;(0,u.drawScaled)(r,s,s,(()=>{const n=.6*e;r.fillStyle=i,r.beginPath(),r.moveTo(e/2,t),r.quadraticCurveTo(e,e/1.15,e,e/2),r.arc(e/2,e/2,e/2,0,Math.PI,!0),r.quadraticCurveTo(0,e/1.15,e/2,t),r.fill(),r.globalCompositeOperation="destination-out",r.beginPath(),r.moveTo((e-n)/2,e/2),r.arc(e/2,e/2,n/2,0,2*Math.PI),r.fill()}))}}class x{constructor(){this._source=null,this._data=null}setData(e){this._data=e,this._source&&this._source.update(e)}draw(e,t){var i;if(null===this._data)return;null!==this._source&&(0,p.areEqualPaneRenderParams)(this._source.renderParams(),t)||(null===(i=this._source)||void 0===i||i.destroy(),this._source=new v(t),this._source.update(this._data));this._source.drawOn(e),this._data.tooltipVisible&&this._drawTooltipOn(e,t)}hitTest(e){return null!==this._data&&null!==this._source&&this._source.hasPoint(e)?new a.HitTestResult(a.HitTarget.MovePoint):null}_drawTooltipOn(e,t){e.save(),e.translate(.5,.5);const i=(0,n.ensureNotNull)(this._data),r=String(i.text).replace(/^\s+|\s+$/g,"");e.font=(i.bold?"bold ":"")+(i.italic?"italic ":"")+i.fontSize+"px "+i.font;const s=i.tooltipWidth-2*i.tooltipPadding,o=(0,d.wordWrap)(r,e.font,s),a=i.point,l=i.tooltipLineSpacing;let p=i.tooltipWidth,_=o.length*i.fontSize+2*i.tooltipPadding;o.length>1&&(_+=(o.length-1)*l);let g=Math.round(a.x-p/2),f=Math.round(a.y-i.height-_-8);const v=a.x<20||a.x+20>i.vpWidth;let x=v?null:"top",m=v?0:Math.round(a.x);f<10?f=a.y+13:x="bottom",g<10?g+=Math.abs(g-10):g+p+10>i.vpWidth&&(g-=g+p+10-i.vpWidth),e.fillStyle=(0,h.generateColor)(i.backgroundColor,i.backgroundTransparency),e.strokeStyle=i.borderColor,e.lineWidth=1,e.beginPath();const w=Math.round(g*t.pixelRatio),R=Math.round(f*t.pixelRatio);m=Math.round(m*t.pixelRatio),_=Math.round(_*t.pixelRatio),p=Math.round(p*t.pixelRatio);const y=Math.round(7*t.pixelRatio);e.moveTo(w,R),v||"top"!==x||(e.lineTo(m-y,R),e.lineTo(m,R-y),e.lineTo(m+y,R)),e.lineTo(w+p,R),e.lineTo(w+p,R+_), -v||"bottom"!==x||(e.lineTo(m+y,R+_),e.lineTo(m,R+_+y),e.lineTo(m-y,R+_)),e.lineTo(w,R+_),e.closePath(),e.fill(),e.stroke(),e.textBaseline="middle",e.fillStyle=i.textColor,e.textAlign=(0,c.isRtl)()?"right":"left";const T=(0,u.calcTextHorizontalShift)(e,s),b=g+i.tooltipPadding+T;let P=f+i.tooltipPadding+i.fontSize/2;(0,u.drawScaled)(e,t.pixelRatio,t.pixelRatio,(()=>{for(let t=0;t{"use strict";i.r(t),i.d(t,{OrderPaneView:()=>v});var n=i(86441),r=i(79191),s=i(19266),o=i(44352),a=i(82161),l=i(68441),d=i(15187),h=i(18807),c=i(53180),u=i(47043);const p=o.t(null,void 0,i(33241)),_=o.t(null,void 0,i(16075));class g extends d.MediaCoordinatesPaneRenderer{constructor(e){super(),this._data=null,this._cache={},this._data=null,this._adapter=e}setData(e){this._data=e}hitTest(e,t){if(null===this._data||0===this._data.points.length)return null;const i=this._cache;if(e.yi.bottom)return null;if(this._adapter.getBlocked()&&e.x>=i.left&&e.x=i.left&&e.x=i.bodyRight&&e.x=i.quantityRight&&e.x0){const t=this._points[0].y,i=e-3.5-1,r=this._adapter.hasMoveCallback()?h.HitTarget.MovePoint:h.HitTarget.Regular,s=[new n.Point(i,t)];this._selectionData={barSpacing:this._model.timeScale().barSpacing(),points:s,bgColors:this._lineAnchorColors(s),hittestResult:r,visible:!0}}this._orderRenderer.setData({points:this._points}),this._selectionRenderer.setData(this._selectionData)}}},26013:(e,t,i)=>{"use strict";i.r(t),i.d(t,{ParallelChannelPaneView:()=>d});var n=i(86441),r=i(66103),s=i(19266),o=i(28621),a=i(33295);const l=[r.PaneCursorType.Default,r.PaneCursorType.Default,r.PaneCursorType.Default,r.PaneCursorType.Default,r.PaneCursorType.VerticalResize,r.PaneCursorType.VerticalResize];class d extends a.AlertableLineSourcePaneView{constructor(){super(...arguments),this._channelRenderer=new o.ParallelChannelRenderer,this._renderer=null}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){super._updateImpl(),this._renderer=null;const e=this._source.priceScale();if(!e||e.isEmpty())return;if(0===this._source.points().length)return;let t=null,i=null;if(3===this._points.length){const e=this._points[0],r=this._points[1],s=this._points[2].y-this._points[0].y;t=e.add((0, -n.point)(0,s)),i=r.add((0,n.point)(0,s))}if(this._points.length<=1)return;const r=this._source.properties(),o={points:this._points.length>2&&null!==t&&null!==i?[this._points[0],this._points[1],t,i]:[this._points[0],this._points[1]],color:r.childs().linecolor.value(),linewidth:r.childs().linewidth.value(),linestyle:r.childs().linestyle.value(),extendleft:r.childs().extendLeft.value(),extendright:r.childs().extendRight.value(),fillBackground:r.childs().fillBackground.value(),backcolor:r.childs().backgroundColor.value(),transparency:r.childs().transparency.value(),showMidline:r.childs().showMidline.value(),midlinewidth:r.childs().midlinewidth.value(),midlinestyle:r.childs().midlinestyle.value(),midcolor:r.childs().midlinecolor.value(),hittestOnBackground:!0};this._channelRenderer.setData(o);const a=new s.CompositeRenderer;a.append(this._channelRenderer);const d=[];if(this._points[0]&&d.push(this._points[0]),this._points[1]&&d.push(this._points[1]),t&&i){const e=t;e.data=2,d.push(e);const n=i;n.data=3,d.push(n);const r=t.add(i).scaled(.5);r.data=4,r.square=!0,d.push(r);const s=d[0].add(d[1]).scaled(.5);s.data=5,s.square=!0,d.push(s)}const h=3===this._points.length&&!t;if(this._model.lineBeingCreated()!==this._source||h||(d.pop(),d.pop()),a.append(this.createLineAnchor({points:d,pointsCursorType:l},0)),this._points.length>=2){const e=this._points;this._addAlertRenderer(a,[e[0],e[1]])}this._renderer=a}}},62801:(e,t,i)=>{"use strict";i.r(t),i.d(t,{PathPaneView:()=>o});var n=i(79797),r=i(19266),s=i(79191);class o extends s.LineSourcePaneView{constructor(e,t){super(e,t),this._polygonRenderer=new n.PolygonRenderer,this._renderer=new r.CompositeRenderer}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){super._updateImpl(),this._renderer.clear();const e=this._source.properties().childs(),t={points:this._points,color:e.lineColor.value(),linewidth:e.lineWidth.value(),linestyle:e.lineStyle.value(),leftend:e.leftEnd.value(),rightend:e.rightEnd.value(),filled:!1,backcolor:"",fillBackground:!1,transparency:0};this._polygonRenderer.setData(t),this._renderer.append(this._polygonRenderer),this.addAnchors(this._renderer)}}},87202:(e,t,i)=>{"use strict";i.r(t),i.d(t,{PitchfanLinePaneView:()=>d});var n=i(18807),r=i(14146),s=i(19266),o=i(73436),a=i(99031),l=i(79191);class d extends l.LineSourcePaneView{constructor(){super(...arguments),this._medianRenderer=new a.TrendLineRenderer,this._sideRenderer=new a.TrendLineRenderer,this._renderer=null,this._medianPoint=null}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){if(super._updateImpl(),this._renderer=null,0===this._points.length)return;if(3===this._points.length?(this._medianPoint=this._points[1].add(this._points[2]).scaled(.5),this._medianPoint.data=3):2===this._points.length?(this._medianPoint=this._points[1].clone(),this._medianPoint.data=3):(this._medianPoint=this._points[0].clone(),this._medianPoint.data=3),this._points.length<2)return;if(!this._medianPoint)return -;const e=new s.CompositeRenderer,t=this._source.properties().childs(),i=t.median.childs(),l={points:[this._points[0],this._medianPoint],color:i.color.value(),linewidth:i.linewidth.value(),linestyle:i.linestyle.value(),extendleft:!1,extendright:!0,leftend:o.LineEnd.Normal,rightend:o.LineEnd.Normal};if(this._medianRenderer.setData(l),e.append(this._medianRenderer),this._points.length<3)return this.addAnchors(e),void(this._renderer=e);const d={points:[this._points[1],this._points[2]],color:i.color.value(),linewidth:i.linewidth.value(),linestyle:i.linestyle.value(),extendleft:!1,extendright:!1,leftend:o.LineEnd.Normal,rightend:o.LineEnd.Normal};this._sideRenderer.setData(d),e.append(this._sideRenderer);let h=0;const c=this._points[2].subtract(this._points[1]).scaled(.5),u=t.fillBackground.value(),p=t.transparency.value();for(let t=0;t<=8;t++){const i="level"+t,s=this._source.properties().child(i);if(s.childs().visible.value()){const i=this._medianPoint.addScaled(c,s.childs().coeff.value()),l=this._medianPoint.addScaled(c,-s.childs().coeff.value());if(u){{const t={p1:this._points[0],p2:i,p3:this._points[0],p4:this._medianPoint.addScaled(c,h),color:s.childs().color.value(),transparency:p,hittestOnBackground:!0,extendLeft:!1},n=new r.ChannelRenderer;n.setData(t),e.append(n)}{const t={p1:this._points[0],p2:l,p3:this._points[0],p4:this._medianPoint.addScaled(c,-h),color:s.childs().color.value(),transparency:p,hittestOnBackground:!0,extendLeft:!1},i=new r.ChannelRenderer;i.setData(t),e.append(i)}}h=s.childs().coeff.value();{const r={points:[this._points[0],i],color:s.childs().color.value(),linewidth:s.childs().linewidth.value(),linestyle:s.childs().linestyle.value(),extendleft:!1,extendright:!0,leftend:o.LineEnd.Normal,rightend:o.LineEnd.Normal},l=new a.TrendLineRenderer;l.setData(r),l.setHitTest(new n.HitTestResult(n.HitTarget.MovePoint,void 0,t)),e.append(l)}{const i={points:[this._points[0],l],color:s.childs().color.value(),linewidth:s.childs().linewidth.value(),linestyle:s.childs().linestyle.value(),extendleft:!1,extendright:!0,leftend:o.LineEnd.Normal,rightend:o.LineEnd.Normal},r=new a.TrendLineRenderer;r.setData(i),r.setHitTest(new n.HitTestResult(n.HitTarget.MovePoint,void 0,t)),e.append(r)}}}this.addAnchors(e),this._renderer=e}}},95337:(e,t,i)=>{"use strict";i.r(t),i.d(t,{InsidePitchforkLinePaneView:()=>p,PitchforkLinePaneView:()=>h,SchiffPitchfork2LinePaneView:()=>u,SchiffPitchforkLinePaneView:()=>c});var n=i(86441),r=i(18807),s=i(14146),o=i(19266),a=i(73436),l=i(99031),d=i(79191);class h extends d.LineSourcePaneView{constructor(){super(...arguments),this._medianRenderer=new l.TrendLineRenderer,this._sideRenderer=new l.TrendLineRenderer,this._renderer=null,this._medianPoint=null}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){super._updateImpl(),this._renderer=null,0!==this._points.length&&(3===this._points.length?(this._medianPoint=this._points[1].add(this._points[2]).scaled(.5),this._medianPoint.data=3):2===this._points.length?(this._medianPoint=this._points[1].clone(), -this._medianPoint.data=3):(this._medianPoint=this._points[0].clone(),this._medianPoint.data=3),this._updateRenderer())}_updateRenderer(){if(this._points.length<2)return;if(!this._medianPoint)return;const e=this._source.properties(),t=e.childs().median.childs(),i=new o.CompositeRenderer,n={points:[this._points[0],this._medianPoint],color:t.color.value(),linewidth:t.linewidth.value(),linestyle:t.linestyle.value(),extendleft:e.childs().extendLines.value(),extendright:!0,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal};if(this._medianRenderer.setData(n),i.append(this._medianRenderer),this._points.length<3)return this.addAnchors(i),void(this._renderer=i);const d={points:[this._points[1],this._points[2]],color:t.color.value(),linewidth:t.linewidth.value(),linestyle:t.linestyle.value(),extendleft:!1,extendright:!1,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal};this._sideRenderer.setData(d),i.append(this._sideRenderer);const h=this._points[2].subtract(this._points[1]).scaled(.5),c=this._medianPoint.subtract(this._points[0]);let u=0;const p=e.childs().fillBackground.value(),_=e.childs().transparency.value();for(let t=0;t<=8;t++){const n="level"+t,o=e.childs()[n];if(o.childs().visible.value()){const n=this._medianPoint.addScaled(h,o.childs().coeff.value()),d=n.add(c),g=this._medianPoint.addScaled(h,-o.childs().coeff.value()),f=g.add(c);if(p){{const t=this._medianPoint.addScaled(h,u),r={p1:n,p2:d,p3:t,p4:t.add(c),color:o.childs().color.value(),transparency:_,hittestOnBackground:!0,extendLeft:e.childs().extendLines.value()},a=new s.ChannelRenderer;a.setData(r),i.append(a)}{const t=this._medianPoint.addScaled(h,-u),n={p1:g,p2:f,p3:t,p4:t.add(c),color:o.childs().color.value(),transparency:_,hittestOnBackground:!0,extendLeft:e.childs().extendLines.value()},r=new s.ChannelRenderer;r.setData(n),i.append(r)}}u=o.childs().coeff.value();const v={points:[n,d],color:o.childs().color.value(),linewidth:o.childs().linewidth.value(),linestyle:o.childs().linestyle.value(),extendleft:e.childs().extendLines.value(),extendright:!0,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal},x=new l.TrendLineRenderer;x.setData(v),x.setHitTest(new r.HitTestResult(r.HitTarget.MovePoint,void 0,t)),i.append(x);const m={points:[g,f],color:o.childs().color.value(),linewidth:o.childs().linewidth.value(),linestyle:o.childs().linestyle.value(),extendleft:e.childs().extendLines.value(),extendright:!0,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal},w=new l.TrendLineRenderer;w.setData(m),w.setHitTest(new r.HitTestResult(r.HitTarget.MovePoint,void 0,t)),i.append(w)}}this.addAnchors(i),this._renderer=i}}class c extends h{constructor(){super(...arguments),this._modifiedBase=null,this._backSideRenderer=new l.TrendLineRenderer}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateRenderer(){if(this._points.length<2)return;this._calcMofifiedBase();const e=this._source.properties(),t=new o.CompositeRenderer,i=e.childs().median.childs();{const e={points:[this._points[0],this._points[1]],color:i.color.value(), -linewidth:i.linewidth.value(),linestyle:i.linestyle.value(),extendleft:!1,extendright:!1,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal};if(this._backSideRenderer.setData(e),t.append(this._backSideRenderer),!this._medianPoint||!this._modifiedBase)return this.addAnchors(t),void(this._renderer=t)}{const n={points:[this._modifiedBase,this._medianPoint],color:i.color.value(),linewidth:i.linewidth.value(),linestyle:i.linestyle.value(),extendleft:e.childs().extendLines.value(),extendright:!0,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal};if(this._medianRenderer.setData(n),t.append(this._medianRenderer),this._points.length<3)return this.addAnchors(t),void(this._renderer=t)}{const e={points:[this._points[1],this._points[2]],color:i.color.value(),linewidth:i.linewidth.value(),linestyle:i.linestyle.value(),extendleft:!1,extendright:!1,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal};this._sideRenderer.setData(e),t.append(this._sideRenderer)}{const i=this._points[2].subtract(this._points[1]).scaled(.5),n=this._medianPoint.subtract(this._modifiedBase);let o=0;const d=e.childs().fillBackground.value(),h=e.childs().transparency.value();for(let c=0;c<=8;c++){const u="level"+c,p=e.child(u);if(p.childs().visible.value()){const u=this._medianPoint.addScaled(i,p.childs().coeff.value()),_=u.add(n),g=this._medianPoint.addScaled(i,-p.childs().coeff.value()),f=g.add(n);if(d){const r=this._medianPoint.addScaled(i,o);{const i={p1:u,p2:_,p3:r,p4:r.add(n),color:p.childs().color.value(),transparency:h,hittestOnBackground:!0,extendLeft:e.childs().extendLines.value()},o=new s.ChannelRenderer;o.setData(i),t.append(o)}{const r=this._medianPoint.addScaled(i,-o),a={p1:g,p2:f,p3:r,p4:r.add(n),color:p.childs().color.value(),transparency:h,hittestOnBackground:!0,extendLeft:e.childs().extendLines.value()},l=new s.ChannelRenderer;l.setData(a),t.append(l)}}o=p.childs().coeff.value();const v={points:[u,_],color:p.childs().color.value(),linewidth:p.childs().linewidth.value(),linestyle:p.childs().linestyle.value(),extendleft:e.childs().extendLines.value(),extendright:!0,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal},x=new l.TrendLineRenderer;x.setData(v),x.setHitTest(new r.HitTestResult(r.HitTarget.MovePoint,void 0,c)),t.append(x);const m={points:[g,f],color:p.childs().color.value(),linewidth:p.childs().linewidth.value(),linestyle:p.childs().linestyle.value(),extendleft:e.childs().extendLines.value(),extendright:!0,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal},w=new l.TrendLineRenderer;w.setData(m),w.setHitTest(new r.HitTestResult(r.HitTarget.MovePoint,void 0,c)),t.append(w)}}}this.addAnchors(t),this._renderer=t}_calcMofifiedBase(){this._points.length>1&&(this._modifiedBase=this._points[0].add(this._points[1]).scaled(.5))}}class u extends c{_calcMofifiedBase(){if(this._points.length>2){const e=this._points[0].x,t=.5*(this._points[0].y+this._points[1].y),i=new n.Point(e,t);this._modifiedBase=i}}}class p extends h{constructor(){super(...arguments),this._backSideRenderer=new l.TrendLineRenderer,this._centerRenderer=new l.TrendLineRenderer, -this._modifiedBase=null}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateRenderer(){if(this._points.length>1&&(this._modifiedBase=this._points[0].add(this._points[1]).scaled(.5)),this._points.length<2)return;const e=new o.CompositeRenderer;if(!this._medianPoint||!this._modifiedBase)return void this.addAnchors(e);const t=this._source.properties(),i=t.childs().median.childs();if(3===this._points.length){const t={points:[this._modifiedBase,this._points[2]],color:i.color.value(),linewidth:i.linewidth.value(),linestyle:i.linestyle.value(),extendleft:!1,extendright:!1,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal};this._medianRenderer.setData(t),e.append(this._medianRenderer)}{const t={points:[this._points[0],this._points[1]],color:i.color.value(),linewidth:i.linewidth.value(),linestyle:i.linestyle.value(),extendleft:!1,extendright:!1,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal};if(this._backSideRenderer.setData(t),e.append(this._backSideRenderer),this._points.length<3)return this.addAnchors(e),void(this._renderer=e)}{const t={points:[this._points[1],this._points[2]],color:i.color.value(),linewidth:i.linewidth.value(),linestyle:i.linestyle.value(),extendleft:!1,extendright:!1,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal};this._sideRenderer.setData(t),e.append(this._sideRenderer)}{const n=this._points[2].subtract(this._points[1]).scaled(.5),o=this._points[2].subtract(this._modifiedBase);let d=0;const h=t.childs().fillBackground.value(),c=t.childs().transparency.value(),u={points:[this._medianPoint,this._medianPoint.add(o)],color:i.color.value(),linewidth:i.linewidth.value(),linestyle:i.linestyle.value(),extendleft:t.childs().extendLines.value(),extendright:!0,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal};this._centerRenderer.setData(u),e.append(this._centerRenderer);for(let i=0;i<=8;i++){const u="level"+i,p=t.child(u).childs();if(p.visible.value()){const u=this._medianPoint.addScaled(n,p.coeff.value()),_=u.add(o),g=this._medianPoint.addScaled(n,-p.coeff.value()),f=g.add(o);if(h){{const i=this._medianPoint.addScaled(n,d),r={p1:u,p2:_,p3:i,p4:i.add(o),color:p.color.value(),transparency:c,hittestOnBackground:!0,extendLeft:t.childs().extendLines.value()},a=new s.ChannelRenderer;a.setData(r),e.append(a)}{const i=this._medianPoint.addScaled(n,-d),r={p1:g,p2:f,p3:i,p4:i.add(o),color:p.color.value(),transparency:c,hittestOnBackground:!0,extendLeft:t.childs().extendLines.value()},a=new s.ChannelRenderer;a.setData(r),e.append(a)}}d=p.coeff.value();const v={points:[u,_],color:p.color.value(),linewidth:p.linewidth.value(),linestyle:p.linestyle.value(),extendleft:t.childs().extendLines.value(),extendright:!0,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal},x=new l.TrendLineRenderer;x.setData(v),x.setHitTest(new r.HitTestResult(r.HitTarget.MovePoint,void 0,i)),e.append(x);const m={points:[g,f],color:p.color.value(),linewidth:p.linewidth.value(),linestyle:p.linestyle.value(),extendleft:t.childs().extendLines.value(),extendright:!0,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal -},w=new l.TrendLineRenderer;w.setData(m),w.setHitTest(new r.HitTestResult(r.HitTarget.MovePoint,void 0,i)),e.append(w)}}}this.addAnchors(e),this._renderer=e}}},50253:(e,t,i)=>{"use strict";i.r(t),i.d(t,{PolylinePaneView:()=>o});var n=i(79797),r=i(19266),s=i(79191);class o extends s.LineSourcePaneView{constructor(e,t){super(e,t),this._polygonRenderer=new n.PolygonRenderer,this._renderer=new r.CompositeRenderer}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){super._updateImpl(),this._renderer.clear();const e=this._source.properties().childs(),t={points:this._points,color:e.linecolor.value(),linewidth:e.linewidth.value(),linestyle:e.linestyle.value(),filled:e.filled.value(),backcolor:e.backgroundColor.value(),fillBackground:e.fillBackground.value(),transparency:e.transparency.value()};this._polygonRenderer.setData(t),this._renderer.append(this._polygonRenderer),this.addAnchors(this._renderer)}}},46258:(e,t,i)=>{"use strict";var n=i(79191).LineSourcePaneView,r=i(47043),s=i(18807).HitTestResult,o=i(18807).HitTarget,a=i(82161).splitThousands,l=i(38223),d=i(53180).appendEllipsis,h=i(15187).MediaCoordinatesPaneRenderer;const{setLineStyle:c,drawLine:u,drawPoly:p}=i(68441),{LINESTYLE_SOLID:_}=i(79849);class g extends h{constructor(e,t){super(),this._data=null,this._cache=e,this._adapter=t}setData(e){this._data=e}_height(){return Math.max(20,1+Math.max(r.fontHeight(this._adapter.getBodyFont()),r.fontHeight(this._adapter.getQuantityFont())))}_bodyWidth(e){if(0===this._adapter.getText().length)return 0;e.save(),e.font=this._adapter.getBodyFont();var t=e.measureText(this._adapter.getText()).width;return e.restore(),Math.round(10+t)}_getQuantity(){var e=this._adapter.getQuantity();return isNaN(e)?e:a(this._adapter.getQuantity()," ")}_quantityWidth(e){if(0===this._getQuantity().length)return 0;e.save(),e.font=this._adapter.getQuantityFont();var t=e.measureText(this._getQuantity()).width;return e.restore(),Math.round(Math.max(this._height(),10+t))}_reverseButtonWidth(){return this._adapter.isOnReverseCallbackPresent()?this._height():0}_closeButtonWidth(){return this._adapter.isOnCloseCallbackPresent()?this._height():0}_drawLines(e,t,i,n,r){e.save(),e.strokeStyle=this._adapter.getLineColor(),e.lineStyle=this._adapter.getLineStyle(),e.lineWidth=this._adapter.getLineWidth(),u(e,i,n,r,n),this._adapter.getExtendLeft()&&u(e,0,n,t,n),e.restore()}_drawBody(e,t,i){e.strokeStyle=this._adapter.getBodyBorderColor(),e.fillStyle=this._adapter.getBodyBackgroundColor();var n=this._bodyWidth(e),r=this._height();e.fillRect(t+.5,i+.5,n-1,r-1),e.strokeRect(t,i,n,r)}_drawBodyText(e,t,i){e.save(),e.textAlign="center",e.textBaseline="middle",e.font=this._adapter.getBodyFont(),e.fillStyle=this._adapter.getBodyTextColor();var n=t+this._bodyWidth(e)/2,r=i+this._height()/2;e.fillText(this._adapter.getText(),n,r),e.restore()}_drawQuantity(e,t,i){e.strokeStyle=this._adapter.getQuantityBorderColor(),e.fillStyle=this._adapter.getQuantityBackgroundColor();var n=this._quantityWidth(e),r=this._height() -;e.fillRect(t+.5,i+.5,n-1,r-1),e.strokeRect(t,i,n,r)}_drawQuantityText(e,t,i){e.save(),e.textAlign="center",e.textBaseline="middle",e.font=this._adapter.getQuantityFont(),e.fillStyle=this._adapter.getQuantityTextColor();var n=t+this._quantityWidth(e)/2,r=i+this._height()/2;e.fillText(l.startWithLTR(this._getQuantity()+""),n,r),e.restore()}_drawReverseButton(e,t,i){e.save(),e.strokeStyle=this._adapter.getReverseButtonBorderColor(),e.fillStyle=this._adapter.getReverseButtonBackgroundColor();var n=this._reverseButtonWidth(),r=this._height();e.fillRect(t+.5,i+.5,n-1,r-1),e.strokeRect(t,i,n,r),e.strokeStyle=this._adapter.getReverseButtonIconColor();var s=function(e,t){c(e,_),u(e,0,0,0,t),u(e,-1,1,1,1),u(e,-2,2,2,2)},o=t+Math.round((this._reverseButtonWidth()-6)/2),a=i+5;e.save(),e.translate(o,a),s(e,10),e.translate(6,10),e.rotate(Math.PI),s(e,10),e.restore(),this._adapter._blocked&&(e.fillStyle="rgba(140, 140, 140, 0.75)",e.fillRect(t+.5,i+.5,n-1,r-1)),e.restore()}_drawCloseButton(e,t,i){e.save(),e.strokeStyle=this._adapter.getCloseButtonBorderColor(),e.fillStyle=this._adapter.getCloseButtonBackgroundColor();var n=this._closeButtonWidth(),r=this._height();e.fillRect(t+.5,i+.5,n-1,r-1),e.strokeRect(t,i,n,r);var s=t+n,o=i+r;e.strokeStyle=this._adapter.getCloseButtonIconColor();var a=(this._closeButtonWidth()-8)/2,l=(this._height()-8)/2;p(e,[{x:t+a,y:i+l},{x:s-a,y:o-l}],!0),p(e,[{x:s-a,y:i+l},{x:t+a,y:o-l}],!0),this._adapter._blocked&&(e.fillStyle="rgba(140, 140, 140, 0.75)",e.fillRect(t+.5,i+.5,n-1,r-1)),e.restore()}_drawImpl(e){if(null!==this._data&&this._data.points&&!(this._data.points.length<1)){var t=e.context,i=this._data.width,n=this._bodyWidth(t),r=this._quantityWidth(t),s=this._reverseButtonWidth(t),o=n+r+s+this._closeButtonWidth(),a=i-o,l=Math.max(this._adapter.getLineLength()/100*i,1),d=Math.round(i-Math.min(a,l)),h=d-o,c=Math.round(this._data.points[0].y),u=Math.round(c-(this._height()+1)/2);this._cache.bodyRight=h+n,this._cache.quantityRight=this._cache.bodyRight+r,this._cache.reverseButtonRight=this._cache.quantityRight+s,this._cache.top=u,this._cache.bottom=u+this._height(),this._cache.left=h,this._cache.right=d,this._drawLines(t,h,d,c,i),0!==n&&(this._drawBody(t,h,u),this._drawBodyText(t,h,u)),0!==r&&(this._drawQuantity(t,this._cache.bodyRight,u),this._drawQuantityText(t,this._cache.bodyRight,u)),0!==s&&this._drawReverseButton(t,this._cache.quantityRight,u),0!==this._closeButtonWidth()&&this._drawCloseButton(t,this._cache.reverseButtonRight,u)}}hitTest(e){return null===this._data||0===this._data.points.length||e.ythis._cache.bottom||e.x=this._cache.bodyRight&&e.x=this._cache.quantityRight&&e.x=this._cache.reverseButtonRight&&e.x{"use strict";var n=i(86441).Point,r=i(79191).LineSourcePaneView,s=i(36274).Interval,o=i(18807).HitTestResult,a=i(18807).HitTarget,l=i(19266).CompositeRenderer,d=i(12767).getImage,h=i(37160),c=i(93572).PercentageFormatter,u=i(53741).DateFormatter,p=i(79206).TimeFormatter,_=i(79206).hourMinuteFormat,g=i(79206).hourMinuteSecondFormat,f=i(2043).TimeSpanFormatter,v=i(87095),x=i(21316),m=i(74359).calcTextHorizontalShift,w=i(38223).isRtl,R=i(68441).drawRoundRect,y=i(29764).makeFont,T=i(15187).MediaCoordinatesPaneRenderer,b=i(38223),P=b.forceLTRStr,L=b.startWithLTR,S=i(46501).CHART_FONT_FAMILY;class C extends T{constructor(){super(),this._data=null,this._font=S,this._targetFontSize1=14,this._targetFontSize2=11,this._sourceFontSize1=12,this._sourceFontSize2=10,this._arrowOffset=6,this._arrowWidth=5,this._arrowHeight=5,this._radius=3,this._sourceWidth=void 0,this._sourceHeight=void 0,this._sourceRectLeftOffset=void 0,this._targetWidth=void 0,this._targetHeight=void 0,this._targetRectLeftOffset=void 0}setData(e){this._data=e}drawBalloon(e,t,i,r,s,o){var a=o||20;if(e.beginPath(),"down"===s){var l=new n(t.x-a,t.y-this._arrowOffset-this._arrowHeight-r);return e.moveTo(l.x+this._radius,l.y),e.lineTo(l.x+i-this._radius,l.y),e.arcTo(l.x+i,l.y,l.x+i,l.y+this._radius,this._radius),e.lineTo(l.x+i,l.y+r-this._radius),e.arcTo(l.x+i,l.y+r,l.x+i-this._radius,l.y+r,this._radius),e.lineTo(l.x+a+this._arrowWidth,l.y+r),e.lineTo(l.x+a,l.y+r+this._arrowHeight),e.lineTo(l.x+a-this._arrowWidth,l.y+r),e.lineTo(l.x+this._radius,l.y+r), -e.arcTo(l.x,l.y+r,l.x,l.y+r-this._radius,this._radius),e.lineTo(l.x,l.y+this._radius),e.arcTo(l.x,l.y,l.x+this._radius,l.y,this._radius),l}var d=new n(t.x-a,t.y+this._arrowOffset+this._arrowHeight+r);return e.moveTo(d.x+this._radius,d.y),e.lineTo(d.x+i-this._radius,d.y),e.arcTo(d.x+i,d.y,d.x+i,d.y-this._radius,this._radius),e.lineTo(d.x+i,d.y-r+this._radius),e.arcTo(d.x+i,d.y-r,d.x+i-this._radius,d.y-r,this._radius),e.lineTo(d.x+a+this._arrowWidth,d.y-r),e.lineTo(d.x+a,d.y-r-this._arrowHeight),e.lineTo(d.x+a-this._arrowWidth,d.y-r),e.lineTo(d.x+this._radius,d.y-r),e.arcTo(d.x,d.y-r,d.x,d.y-r+this._radius,this._radius),e.lineTo(d.x,d.y-this._radius),e.arcTo(d.x,d.y,d.x+this._radius,d.y,this._radius),new n(d.x,d.y-r)}drawTargetLabel(e){e.save(),e.translate(.5,.5);var t=y(this._targetFontSize1,this._font,"normal"),n=y(this._targetFontSize2,this._font,"normal"),r=this._data.targetLine1,s=this._data.targetLine2,o=this._data.targetLine3,a=this._data.targetLine4;e.font=t;var l=e.measureText(r).width,d=e.measureText(s).width,h=e.measureText(" ").width;e.font=n;var c=e.measureText(o).width,u=e.measureText(a).width,p=e.measureText(" ").width,_=this._data.clockWhite&&this._data.clockWhite.width||0;this._targetWidth=Math.max(l+d+h,c+u+_+2*p)+8+4,this._targetHeight=this._targetFontSize1+this._targetFontSize2+9+4;var g=this._data.points[1],f=g.x+this._targetWidth-e.canvas.width+5;this._targetRectLeftOffset=Math.max(20,Math.min(this._targetWidth-15,f));var T="up"===this._data.direction?"down":"up",b=this.drawBalloon(e,g,this._targetWidth,this._targetHeight,T,this._targetRectLeftOffset);e.fillStyle=v.generateColor(this._data.targetBackColor,this._data.transparency),e.fill(),e.lineWidth=2,e.strokeStyle=v.generateColor(this._data.targetStrokeColor,this._data.transparency),e.stroke();e.beginPath(),e.arc(g.x,g.y,3,0,2*Math.PI,!1),e.fillStyle=this._data.centersColor,e.fill(),e.textBaseline="top",e.fillStyle=this._data.targetTextColor;var P=2+b.x+4,L=2+b.y+3,S=this._targetWidth-8-4;e.font=t,e.textAlign=w()?"right":"left";var C=m(e,S-d-h);e.fillText(r,P+C,L);var M=m(e,S-l);e.fillText(s,P+l+h+M,L),e.font=n;var I=L+this._targetFontSize1+3,A=m(e,S-u-_-p);e.fillText(o,P+A,I);var k=m(e,S-c-p-_-u);this._data.clockWhite&&e.drawImage(this._data.clockWhite,P+c+p+k,I+1);var N=m(e,S-c-_);if(e.fillText(a,P+c+_+2*p+N,I),this._data.status){var D,B,z,E;switch(e.font=y(this._targetFontSize1,this._font,"bold"),this._data.status){case x.AlertStatus.Success:D=i(44352).t(null,void 0,i(26787)),B=v.generateColor(this._data.successBackground,this._data.transparency),z=this._data.successTextColor,E=this._data.successIcon;break;case x.AlertStatus.Failure:D=i(44352).t(null,void 0,i(968)),B=v.generateColor(this._data.failureBackground,this._data.transparency),z=this._data.failureTextColor,E=this._data.failureIcon}var H=this._targetFontSize1+4,O=e.measureText(D).width,V=Math.round((this._targetWidth-O)/2),W=m(e,O);e.fillStyle=B,"up"===this._data.direction?(R(e,b.x-1,b.y-H-2,this._targetWidth+2,H,5),e.fill(),e.fillStyle=z,e.fillText(D,b.x+V+W,b.y-H+1), -E&&e.drawImage(E,b.x+V-E.width-4,b.y-H-2+Math.abs(H-E.height)/2)):(R(e,b.x-1,b.y+this._targetHeight+2,this._targetWidth+2,H,5),e.fill(),e.fillStyle=z,e.fillText(D,b.x+V+W,b.y+this._targetHeight+5),E&&e.drawImage(E,b.x+V-E.width-4,b.y+this._targetHeight+10-Math.abs(H-E.height)/2)),e.restore()}else e.restore()}drawStartLabel(e){e.save(),e.translate(.5,.5);var t=y(this._sourceFontSize1,this._font,"normal"),i=y(this._sourceFontSize2,this._font,"normal");e.font=t;var n=e.measureText(this._data.sourceLine1).width;e.font=i;var r=e.measureText(this._data.sourceLine2).width;this._sourceWidth=Math.max(n,r)+6+4,this._sourceHeight=this._sourceFontSize1+this._sourceFontSize2+6+4;var s=this._data.points[0],o=s.x+this._sourceWidth-e.canvas.width+5;this._sourceRectLeftOffset=Math.max(20,Math.min(this._sourceWidth-15,o));var a=this.drawBalloon(e,s,this._sourceWidth,this._sourceHeight,this._data.direction,this._sourceRectLeftOffset);e.fillStyle=v.generateColor(this._data.sourceBackColor,this._data.transparency),e.fill(),e.lineWidth=2,e.strokeStyle=v.generateColor(this._data.sourceStrokeColor,this._data.transparency),e.stroke(),e.textAlign=w()?"right":"left",e.textBaseline="top",e.fillStyle=this._data.sourceTextColor;var l=m(e,this._sourceWidth-6-4),d=2+a.x+3+l,h=2+a.y+2;e.font=t,e.fillText(this._data.sourceLine1,d,h),e.font=i,e.fillText(this._data.sourceLine2,d,h+this._sourceFontSize1+2);e.beginPath(),e.arc(s.x,s.y,3,0,2*Math.PI,!1),e.fillStyle=this._data.centersColor,e.fill(),e.restore()}_drawImpl(e){if(!(null===this._data||this._data.points.length<2)){var t=e.context;t.lineCap="butt",t.strokeStyle=this._data.color,t.lineWidth=this._data.linewidth,t.lineStyle=this._data.linestyle;var i=this._data.points[0],n=this._data.points[1],r=n.subtract(i);Math.abs(r.x)<1||Math.abs(r.y)<1?(t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(n.x,n.y),t.stroke()):(t.save(),t.beginPath(),t.translate(i.x,i.y),t.scale(1,r.y/r.x),t.moveTo(0,0),t.arcTo(r.x,0,r.x,r.x,Math.abs(r.x)),t.lineTo(r.x,r.x),t.restore(),t.stroke()),this.drawTargetLabel(t),this.drawStartLabel(t);var s=Math.max(8,4*this._data.linewidth);t.fillStyle=this._data.color;var o=r.y<0?1:-1;if(Math.abs(r.x)<1||Math.abs(r.y)<1)var a=Math.atan(r.x/r.y);else{var l,d,h=Math.abs(r.x),c=Math.abs(r.y),u=0,p=Math.PI/2,_=(u+p)/2;if(r.length()>s)for(;;){l=h*Math.sin(_),d=c*(1-Math.cos(_));var g=Math.sqrt((l-h)*(l-h)+(d-c)*(d-c));if(Math.abs(g-s)<1)break;g>s?u=_:p=_,_=(u+p)/2}a=Math.atan((h-l)/(c-d)),r.x*r.y<0&&(a=-a)}t.save(),t.beginPath(),t.translate(n.x,n.y),t.rotate(-a),t.moveTo(0,0),t.lineTo(-s/2,o*s),t.lineTo(s/2,o*s),t.lineTo(0,0),t.restore(),t.fill()}}targetLabelHitTest(e){if(void 0===this._targetWidth||void 0===this._targetHeight||void 0===this._targetRectLeftOffset)return null;var t=this._targetHeight+this._arrowHeight;this._data.status&&(t+=this._targetFontSize1+10);var i="up"===this._data.direction?-1:1,n=this._radius,r=this._data.points[1],s=r.x-this._targetRectLeftOffset,l=r.y+i*n,d=r.y+i*(t+n),h=Math.min(l,d),c=Math.max(l,d) -;return e.x>=s&&e.x<=s+this._targetWidth&&e.y>=h&&e.y<=c?new o(a.MovePoint):null}sourceLabelHitTest(e){if(void 0===this._sourceHeight||void 0===this._sourceWidth||void 0===this._sourceRectLeftOffset)return null;var t="up"===this._data.direction?1:-1,i=this._radius,n=this._data.points[0],r=n.x-this._sourceRectLeftOffset,s=n.y+i*t,l=n.y+(i+this._sourceHeight+this._arrowHeight)*t,d=Math.min(s,l),h=Math.max(s,l);return e.x>=r&&e.x<=r+this._sourceWidth&&e.y>=d&&e.y<=h?new o(a.MovePoint):null}hitTest(e){if(null===this._data||this._data.points.length<2)return null;var t=this._data.points[0],i=this._data.points[1],n=i.subtract(t),r=(n=i.subtract(t),e.subtract(t)),s=Math.abs(n.x),l=Math.abs(n.y),d=h.sign(n.y)*(l-l*Math.sqrt(1-r.x*r.x/(s*s)));if(Math.abs(d-r.y)<3)return new o(a.MovePoint);var c=this.targetLabelHitTest(e);return c||this.sourceLabelHitTest(e)}}t.PredictionPaneView=class extends r{constructor(e,t){super(e,t),this._pendingIcons=3;var n=this;function r(){n._pendingIcons-=1,0===n._pendingIcons&&n._source.model().updateSource(n._source)}this._clockWhite=null,this._successIcon=null,this._failureIcon=null,d("prediction-clock-white",i(99620)).then((function(e){n._clockWhite=e,r()})),d("prediction-success-white",i(14012)).then((function(e){n._successIcon=e,r()})),d("prediction-failure-white",i(88249)).then((function(e){n._failureIcon=e,r()})),this._percentageFormatter=new c,this._predictionRenderer=new C,this._renderer=null}iconsReady(){return 0===this._pendingIcons}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){if((super._updateImpl(),this._renderer=null,this._targetLine1="",this._targetLine2="",this._targetLine3="",this._targetLine4="",!(this._source.points().length<2))&&this._source.priceScale()){var e=this._source.ownerSource().formatter(),t=this._source.points()[1],n=this._source.points()[0];this._targetLine3=P(e.format(t.price));var r=t.price-n.price,o=r/Math.abs(n.price)*100;this._targetLine1=P(e.format(r)+" ("+this._percentageFormatter.format(o)+")");var a=this._model.timeScale().indexToUserTime(n.index),d=this._model.timeScale().indexToUserTime(t.index);n.time&&t.time&&(a=TradingView.isString(n.time)?new Date(Date.parse(n.time)):n.time,d=TradingView.isString(t.time)?new Date(Date.parse(t.time)):t.time);var h=this._model.mainSeries().isDWM(),c=s.parse(this._model.mainSeries().interval()),v=c.isSeconds()||c.isTicks();if(d&&a){this._targetLine4=(new u).format(d),h||(this._targetLine4=this._targetLine4+" "+new p(v?g:_).format(d));var m=(d.valueOf()-a.valueOf())/1e3;this._targetLine2=i(44352).t(null,{context:"dates"},i(91481))+" "+L((new f).format(m))}this._sourceLine1=e.format(n.price),this._sourceLine2="";var w=this._model.timeScale().indexToUserTime(n.index);w&&(this._sourceLine2=(new u).format(w),h||(this._sourceLine2=this._sourceLine2+" "+new p(v?g:_).format(w))),this._direction=this._source.direction()===x.Direction.Up?"up":"down", -this._finished=this._model.lineBeingCreated()!==this._source&&this._model.lineBeingEdited()!==this._source&&!this._model.sourcesBeingMoved().includes(this._source);var R={};R.points=this._points,R.color=this._source.properties().linecolor.value(),R.linewidth=this._source.properties().linewidth.value(),R.targetLine1=this._targetLine1,R.targetLine2=this._targetLine2,R.targetLine3=this._targetLine3,R.targetLine4=this._targetLine4,R.status=this._source.properties().status.value(),R.transparency=this._source.properties().transparency.value(),R.targetBackColor=this._source.properties().targetBackColor.value(),R.targetStrokeColor=this._source.properties().targetStrokeColor.value(),R.targetTextColor=this._source.properties().targetTextColor.value(),R.sourceBackColor=this._source.properties().sourceBackColor.value(),R.sourceStrokeColor=this._source.properties().sourceStrokeColor.value(),R.sourceTextColor=this._source.properties().sourceTextColor.value(),R.successBackground=this._source.properties().successBackground.value(),R.successTextColor=this._source.properties().successTextColor.value(),R.failureBackground=this._source.properties().failureBackground.value(),R.failureTextColor=this._source.properties().failureTextColor.value(),R.intermediateBackColor=this._source.properties().intermediateBackColor.value(),R.intermediateTextColor=this._source.properties().intermediateTextColor.value(),R.sourceLine1=this._sourceLine1,R.sourceLine2=this._sourceLine2,R.direction=this._direction,R.clockWhite=this._clockWhite,R.successIcon=this._successIcon,R.failureIcon=this._failureIcon,R.finished=this._finished,R.centersColor=this._model.backgroundCounterColor().value(),this._predictionRenderer.setData(R);var y=new l;y.append(this._predictionRenderer),this.addAnchors(y),this._renderer=y}}}},86583:(e,t,i)=>{"use strict";var n=i(86441),r=n.Point,s=n.box,o=i(34026).pointInBox,a=i(79191).LineSourcePaneView,l=i(80101).SelectionRenderer,d=i(18807).HitTestResult,h=i(18807).HitTarget,c=i(19266).CompositeRenderer,u=i(87095),p=i(74359).calcTextHorizontalShift,_=i(38223).isRtl,g=i(15187).MediaCoordinatesPaneRenderer,f=i(46501);class v extends g{constructor(e,t){super(),this._data=null,this._measureCache=e,this._chartModel=t,this._points=null}setData(e){this._data=e,this._points=e.points}_drawImpl(e){if(null!==this._data&&null!==this._points&&0!==this._points.length){var t=e.context;t.font=[this._data.fontWeight,this._data.fontSize+"px",this._data.fontFamily].join(" ");var i=t.measureText(this._data.label);i.height=this._data.fontSize;var n=10,r=5,s=i.width+2*n,o=i.height+2*r,a=this._points[0].x- -9,l=this._points[0].y-(o+15);t.textAlign=_()?"right":"left";var d=p(t,i.width);this._measureCache&&Object.assign(this._measureCache,{innerWidth:s,innerHeight:o,tailLeft:-9,tailHeight:15}),t.translate(.5+a,.5+l),t.beginPath(),t.moveTo(12,o),t.lineTo(-9,o+15),t.lineTo(-10,o+15-1),t.lineTo(5,o),t.lineTo(3,o),t.arcTo(0,o,0,0,3),t.lineTo(0,3),t.arcTo(0,0,s,0,3),t.lineTo(s-3,0),t.arcTo(s,0,s,o,3),t.lineTo(s,o-3),t.arcTo(s,o,0,o,3),t.lineTo(12,o), -t.fillStyle=u.generateColor(this._data.backgroundColor,this._data.transparency),t.fill(),t.strokeStyle=this._data.borderColor,t.lineWidth=2,t.stroke(),t.closePath(),t.textBaseline="alphabetic",t.fillStyle=this._data.color,t.fillText(this._data.label,n+d,o/2+Math.floor(.35*this._data.fontSize)),t.translate(-.5,-.5),t.beginPath(),t.arc(-9,o+15,2.5,0,2*Math.PI,!1),t.fillStyle=u.generateColor(this._data.borderColor,this._data.transparency),t.fill(),t.strokeStyle=this._chartModel.backgroundColor().value(),t.lineWidth=1,t.stroke(),t.closePath()}}hitTest(e){if(null===this._data||null===this._points||0===this._points.length)return null;var t=this._points[0].x-this._measureCache.tailLeft,i=this._points[0].y-(this._measureCache.innerHeight+this._measureCache.tailHeight),n=s(new r(t,i),new r(t+this._measureCache.innerWidth,i+this._measureCache.innerHeight));return o(e,n)?new d(h.MovePoint):null}}t.PriceLabelPaneView=class extends a{constructor(e,t,i){super(e,t),this._rendererCache={},this._priceLabelRenderer=new v(this._rendererCache,t),this._renderer=null}_updateImpl(){if(super._updateImpl(),this._renderer=null,this._source.points().length>0){var e=this._source.points()[0].price,t=this._source.priceScale();if(!t||t.isEmpty())return;var i=this._source.ownerSource().firstValue();this._priceLabel=t.formatPrice(e,i)}var n={};if(n.points=this._points,n.borderColor=this._source.properties().borderColor.value(),n.backgroundColor=this._source.properties().backgroundColor.value(),n.color=this._source.properties().color.value(),n.fontWeight=this._source.properties().fontWeight.value(),n.fontSize=this._source.properties().fontsize.value(),n.fontFamily=f.CHART_FONT_FAMILY,n.transparency=this._source.properties().transparency.value(),n.label=this._priceLabel,this._priceLabelRenderer.setData(n),1===n.points.length){var r=new c;return r.append(this._priceLabelRenderer),r.append(new l({points:n.points,bgColors:this._lineAnchorColors(n.points),visible:this.areAnchorsVisible()})),void(this._renderer=r)}this._renderer=this._priceLabelRenderer}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}}},29734:(e,t,i)=>{"use strict";i.r(t),i.d(t,{PriceNotePaneView:()=>m});var n=i(50151),r=i(86441),s=i(48891),o=i(19266),a=i(80657),l=i(79191),d=i(4652),h=i(79849),c=i(74359),u=i(46501),p=i(38325),_=i(18807),g=i(68441),f=i(45197);function v(e){let t,i;return e>=-135&&e<=-45?(t="center",i="bottom"):e>-45&&e<45?(t="left",i="middle"):e>=45&&e<=135?(t="center",i="top"):(t="right",i="middle"),{horzAlign:t,vertAlign:i}}class x{constructor(){this._data=null,this._priceLabelRenderer=new a.TextRenderer(void 0,new _.HitTestResult(_.HitTarget.MovePoint,{areaName:_.AreaName.Style,activeItem:1})),this._hittest=new _.HitTestResult(_.HitTarget.MovePoint,{areaName:_.AreaName.Style})}setData(e){this._data=e;const t=e.points[0],i=e.points[1],n=Math.round(180*Math.atan2(i.y-t.y,i.x-t.x)/Math.PI);this._priceLabelRenderer.setData({...v(n),points:[i],text:e.text,color:e.textColor,font:u.CHART_FONT_FAMILY,fontSize:e.fontSize,bold:e.bold,italic:e.italic, -offsetX:0,offsetY:0,borderColor:e.borderColor,borderWidth:1,backgroundColor:e.backgroundColor,backgroundRoundRect:4,boxPaddingVert:6,boxPaddingHorz:8})}setHitTest(e){this._hittest=e}draw(e,t){const i=this._data;if(null===i||i.points.length<2)return;e.save();const n=t.pixelRatio,r=Math.round(i.points[0].x*n),s=Math.round(i.points[0].y*n),o=Math.round(i.points[1].x*n),a=Math.round(i.points[1].y*n);e.lineCap="round",(0,g.setLineStyle)(e,h.LINESTYLE_SOLID),e.strokeStyle=i.lineColor,e.fillStyle=i.lineColor,e.lineWidth=Math.round(1*n);const l=(0,f.fillScaledRadius)(2,n);(0,g.createCircle)(e,r,s,l),e.fill(),void 0!==i.excludeBoundaries&&(e.save(),(0,c.addExclusionArea)(e,t,i.excludeBoundaries)),(0,g.drawLine)(e,r,s,o,a),void 0!==i.excludeBoundaries&&e.restore(),this._priceLabelRenderer.draw(e,t);const d=1*n;e.strokeStyle=i.circleBorderColor,e.lineWidth=d;const u=l+d/2;(0,g.createCircle)(e,r,s,u),e.stroke(),e.restore()}hitTest(e){const t=this._data;if(null===t)return null;const i=(0,p.lastMouseOrTouchEventInfo)().isTouch?20:3;return(0,d.distanceToSegment)(t.points[0],t.points[1],e).distance<=i?this._hittest:this._priceLabelRenderer.hitTest(e)}}class m extends l.LineSourcePaneView{constructor(){super(...arguments),this._renderer=new o.CompositeRenderer,this._priceNoteRenderer=new x,this._customLabelRenderer=new a.TextRenderer}renderer(e,t){return this._invalidated&&this._updateImpl(e,t),this._renderer}_updateImpl(e,t){var i;super._updateImpl(),this._renderer.clear();const o=this._source.priceScale();if(!o||o.isEmpty())return;const l=this._points;if(l.length<2)return;const d=(0,n.ensureNotNull)(this._source.ownerSource()).firstValue();if(null===d)return;const h=this._source.properties().childs(),c=this._model.dark().value()?s.colorsPalette["color-cold-gray-900"]:s.colorsPalette["color-white"],p=this._source.points()[0].price,_={text:o.formatPrice(p,d),points:l,lineColor:h.lineColor.value(),circleBorderColor:c,backgroundColor:h.priceLabelBackgroundColor.value(),borderColor:h.priceLabelBorderColor.value(),textColor:h.priceLabelTextColor.value(),fontSize:h.priceLabelFontSize.value(),bold:h.priceLabelBold.value(),italic:h.priceLabelItalic.value()};if(h.showLabel&&h.showLabel.value()){const n=l[0],s=l[1],o=n.x{"use strict";i.r(t),i.d(t,{ -PriceRangePaneView:()=>v});var n=i(50151),r=i(86441),s=i(38223),o=i(80657),a=i(72739),l=i(99031),d=i(19266),h=i(93572),c=i(79849),u=i(73436),p=i(57322),_=i(46501),g=i(99734);const f=new h.PercentageFormatter;class v extends g.DateAndPriceRangeBasePaneView{constructor(){super(...arguments),this._topBorderRenderer=new l.TrendLineRenderer,this._bottomBorderRenderer=new l.TrendLineRenderer,this._distanceRenderer=new l.TrendLineRenderer,this._backgroundRenderer=new a.RectangleRenderer,this._labelRenderer=new o.TextRenderer,this._renderer=new d.CompositeRenderer,this._pipFormatter=null,this._lastSymbolInfo=null}renderer(e,t){return this._invalidated&&this._updateImpl(e,t),this._renderer}_updateImpl(e,t){var i,a,l;if(super._updateImpl(),this._renderer.clear(),this._points.length<2||this._source.points().length<2)return;const d=this._source.properties().childs(),h=d.extendLeft.value(),g=d.extendRight.value(),[v,x]=this._points,m=Math.min(v.x,x.x),w=Math.max(v.x,x.x);d.fillBackground.value()&&(this._backgroundRenderer.setData({points:[new r.Point(m,v.y),new r.Point(w,x.y)],color:"white",linewidth:0,backcolor:d.backgroundColor.value(),fillBackground:!0,transparency:d.backgroundTransparency.value(),extendLeft:h,extendRight:g}),this._renderer.append(this._backgroundRenderer));const R=(e,t,i)=>{e.setData({points:[t,i],color:d.linecolor.value(),linewidth:d.linewidth.value(),linestyle:c.LINESTYLE_SOLID,extendleft:h,extendright:g,leftend:u.LineEnd.Normal,rightend:u.LineEnd.Normal}),this._renderer.append(e)};let y=m,T=w;y===T&&(h&&(y-=1),g&&(T+=1)),R(this._topBorderRenderer,new r.Point(y,v.y),new r.Point(T,v.y)),R(this._bottomBorderRenderer,new r.Point(y,x.y),new r.Point(T,x.y));const b=Math.round((v.x+x.x)/2),P=new r.Point(b,v.y),L=new r.Point(b,x.y),S=this._updateCustomTextRenderer(e,t);this._distanceRenderer.setData({points:[P,L],color:d.linecolor.value(),linewidth:d.linewidth.value(),linestyle:c.LINESTYLE_SOLID,extendleft:!1,extendright:!1,leftend:u.LineEnd.Normal,rightend:Math.abs(P.y-L.y)>=15*d.linewidth.value()?u.LineEnd.Arrow:u.LineEnd.Normal,excludeBoundaries:null!=S?S:void 0}),this._renderer.append(this._distanceRenderer);const C=this._source.points()[0].price,M=this._source.points()[1].price,I=M-C,A=100*I/Math.abs(C),k=this._model.mainSeries().symbolInfo();k&&k!==this._lastSymbolInfo&&(this._pipFormatter=new p.PipFormatter(k.pricescale,k.minmov,k.type,k.minmove2,k.typespecs),this._lastSymbolInfo=k);const N=(0,n.ensureNotNull)(this._source.ownerSource()).formatter(),D=null!==(a=null===(i=N.formatChange)||void 0===i?void 0:i.call(N,M,C))&&void 0!==a?a:N.format(I),B=(0,s.forceLTRStr)(D+" ("+f.format(A)+") "+(this._pipFormatter?this._pipFormatter.format(I):""));let z;z=M>C?new r.Point(.5*(v.x+x.x),x.y-2*d.fontsize.value()):new r.Point(.5*(v.x+x.x),x.y+.7*d.fontsize.value());const E={x:0,y:10},H=d.fontsize.value(),O={points:[z],text:B,color:d.textcolor.value(),font:_.CHART_FONT_FAMILY,offsetX:E.x,offsetY:E.y,padding:8,vertAlign:"middle",horzAlign:"center",fontsize:H,backgroundRoundRect:4,backgroundHorzInflate:.4*H, -backgroundVertInflate:.2*H};(null===(l=d.fillLabelBackground)||void 0===l?void 0:l.value())&&(O.boxShadow={shadowColor:d.shadow.value(),shadowBlur:4,shadowOffsetY:1},O.backgroundColor=d.labelBackgroundColor.value()),this._labelRenderer.setData(O);const V=this._labelRenderer.measure(),W=(0,o.calculateLabelPosition)(V,v,x,E,e);this._labelRenderer.setPoints([W]),this._renderer.append(this._labelRenderer),this._renderer.append(this._customTextrenderer),this.addAnchors(this._renderer)}_needLabelExclusionPath(e){return e.getLinesInfo().lines.length>0}}},75219:(e,t,i)=>{"use strict";var n=i(81139).ArcWedgeRenderer,r=i(60322).FibWedgePaneView,s=i(99031).TrendLineRenderer,o=i(19266).CompositeRenderer,a=i(73436).LineEnd;t.ProjectionLinePaneView=class extends r{constructor(e,t){super(e,t),this._baseTrendRenderer=new s,this._edgeTrendRenderer=new s,this._arcWedgeRenderer=new n}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateRenderer(){if(!(this._points.length<2)){var e=new o,t=this._source.properties(),i=this._points,n=i[0],r=i[1],s={points:[n,r],width:this._model.timeScale().width(),height:this._source.priceScale().height(),color:t.trendline.color.value(),linewidth:t.linewidth.value(),linestyle:t.trendline.linestyle.value(),extendleft:!1,extendright:!1,leftend:a.Normal,rightend:a.Normal};if(this._baseTrendRenderer.setData(s),e.append(this._baseTrendRenderer),this._points.length<3)return this.addAnchors(e),void(this._renderer=e);var l=i[2],d=l.data,h=r.subtract(n).length(),c=l.subtract(n).normalized();(l=n.add(c.scaled(h))).data=d,s={points:[n,l],width:this._model.timeScale().width(),height:this._source.priceScale().height(),color:t.trendline.color.value(),linewidth:t.linewidth.value(),linestyle:t.trendline.linestyle.value(),extendleft:!1,extendright:!1,leftend:a.Normal,rightend:a.Normal},this._edgeTrendRenderer.setData(s),e.append(this._edgeTrendRenderer);var u=this._levels[0],p={};p.center=this._points[0],p.radius=u.radius,p.prevRadius=0,p.edge=this._edge,p.color=t.trendline.color.value(),p.color1=t.color1.value(),p.color2=t.color2.value(),p.linewidth=t.linewidth.value(),p.edge1=this._edge1,p.edge2=this._edge2,p.p1=u.p1,p.p2=u.p2,p.fillBackground=t.fillBackground.value(),p.transparency=t.transparency.value(),p.gradient=!0,this._arcWedgeRenderer.setData(p),e.append(this._arcWedgeRenderer),this.addAnchors(e),this._renderer=e}}}},31320:(e,t,i)=>{"use strict";i.r(t),i.d(t,{RectanglePaneView:()=>h});var n=i(86441),r=i(46501),s=i(72739),o=i(19266),a=i(80657),l=i(79191),d=i(66103);class h extends l.LineSourcePaneView{constructor(e,t){super(e,t),this._rectangleRenderer=new s.RectangleRenderer,this._textRenderer=new a.TextRenderer,this._renderer=null}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){if(super._updateImpl(),this._renderer=null,this._points.length<2)return;const e=this._getSource().properties().childs(),t={points:this._points,color:e.color.value(),linewidth:e.linewidth.value(),backcolor:e.backgroundColor.value(),fillBackground:e.fillBackground.value(), -transparency:e.transparency.value(),extendLeft:e.extendLeft.value(),extendRight:e.extendRight.value()};this._rectangleRenderer.setData(t);const i=new o.CompositeRenderer;i.append(this._rectangleRenderer);const s=this._points[0],a=this._points[1];if(e.showLabel.value()){const t=Math.min(s.x,a.x),o=Math.max(s.x,a.x),l=Math.min(s.y,a.y),d=Math.max(s.y,a.y);let h,c,u,p;const _=e.fontSize.value()/3;let g,f,v=0;switch(e.vertLabelsAlign.value()){case"middle":p=(l+d)/2,c="middle",v=_;break;case"top":p=d,c="top";break;case"bottom":p=l,c="bottom"}switch(e.horzLabelsAlign.value()){case"center":u=(t+o)/2,h="center";break;case"left":u=t,h="left";break;case"right":u=o,h="right"}"middle"===c&&(g=o-t-2*v,f=d-l);const x={points:[new n.Point(u,p)],text:e.text.value(),fontSize:e.fontSize.value(),font:r.CHART_FONT_FAMILY,bold:e.bold.value(),italic:e.italic.value(),horzAlign:h,vertAlign:c,color:e.textColor.value(),wordWrapWidth:g,maxHeight:f,offsetX:0,offsetY:0,boxPaddingVert:_,boxPaddingHorz:v,forceTextAlign:!0};this._textRenderer.setData(x),i.append(this._textRenderer)}this._addAnchors(s,a,i),this._renderer=i}_addAnchors(e,t,i){const r=new n.Point(e.x,t.y);r.data=2;const s=new n.Point(t.x,e.y);s.data=3;const o=new n.Point(e.x,.5*(e.y+t.y));o.data=4;const a=new n.Point(t.x,.5*(e.y+t.y));a.data=5;const l=new n.Point(.5*(e.x+t.x),e.y);l.data=6;const h=new n.Point(.5*(e.x+t.x),t.y);h.data=7,[o,a,l,h].forEach((e=>e.square=!0));const c=e.x-t.x,u=e.y-t.y,p=Math.sign(c*u),_=[p<0?d.PaneCursorType.DiagonalNeSwResize:d.PaneCursorType.DiagonalNwSeResize,p<0?d.PaneCursorType.DiagonalNeSwResize:d.PaneCursorType.DiagonalNwSeResize,p>0?d.PaneCursorType.DiagonalNeSwResize:d.PaneCursorType.DiagonalNwSeResize,p>0?d.PaneCursorType.DiagonalNeSwResize:d.PaneCursorType.DiagonalNwSeResize,d.PaneCursorType.HorizontalResize,d.PaneCursorType.HorizontalResize,d.PaneCursorType.VerticalResize,d.PaneCursorType.VerticalResize];i.append(this.createLineAnchor({points:[e,t,r,s,o,a,l,h],pointsCursorType:_},0))}}},5374:(e,t,i)=>{"use strict";i.r(t),i.d(t,{RegressionTrendPaneView:()=>g});var n=i(50151),r=i(87095),s=i(18807),o=i(19266),a=i(28621),l=i(80657),d=i(99031),h=i(80101),c=i(86441),u=i(73436),p=i(46501);var _=i(79191);class g extends _.LineSourcePaneView{constructor(e,t){super(e,t),this._data=null,this._pearsonsLabelRenderer=new l.TextRenderer,this._renderer=null,this._renderer=null}renderer(){return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){super._updateImpl(),this._data=function(e,t){const i={lines:[],pearsons:null};if(!t.properties().visible.value())return i;const r=e.timeScale(),s=t.priceScale(),o=e.mainSeries().firstBar();if(!s||s.isEmpty()||r.isEmpty()||!o)return i;const a=t.startIndex(),l=t.endIndex();if(null===a||null===l)return i;const d=[t.baseLine(),t.downLine(),t.upLine()],h=Math.round(r.indexToCoordinate(a)),_=Math.round(r.indexToCoordinate(l)),g=t.properties(),f=[g.styles.baseLine,g.styles.downLine,g.styles.upLine],v=o[4];for(let r=0;r!!e)),l=this._source.properties().childs().styles.childs().transparency.value();for(let t=1;t=1&&e.append(new h.SelectionRenderer({points:t,bgColors:this._lineAnchorColors(t),visible:this.areAnchorsVisible(),hittestResult:s.HitTarget.Regular,barSpacing:this._model.timeScale().barSpacing()})),this._renderer=e}_getTransparencyResetLines(){return(0,n.ensureNotNull)(this._data).lines.map((e=>({...e,color:(0,r.resetTransparency)(e.color)})))}}},56457:(e,t,i)=>{"use strict";i.r(t),i.d(t,{RiskRewardPaneView:()=>A});var n=i(86441),r=i(50151),s=i(44352),o=i(79191),a=i(99031),l=i(80657),d=i(72739),h=i(18807),c=i(19266),u=i(93572),p=i(87663),_=i(57322),g=i(87095),f=i(73436),v=i(95539),x=i(38223),m=i(66103),w=i(88145),R=i(46501),y=i(79849);const T=[m.PaneCursorType.Default,m.PaneCursorType.HorizontalResize,m.PaneCursorType.VerticalResize,m.PaneCursorType.VerticalResize],b=s.t(null,void 0,i(72892)),P=s.t(null,{context:"line_tool_position"},i(50140)),L=s.t(null,{context:"line_tool_position"},i(44143)),S=s.t(null,void 0,i(53115)),C=s.t(null,void 0,i(438)),M=s.t(null,void 0,i(15166)),I=s.t(null,void 0,i(87061));class A extends o.LineSourcePaneView{constructor(){super(...arguments), -this._percentageFormatter=new u.PercentageFormatter,this._numericFormatter=new p.NumericFormatter,this._pipFormatter=null,this._lastSymbolInfo=null,this._entryLineRenderer=new a.TrendLineRenderer,this._stopLineRenderer=new a.TrendLineRenderer,this._targetLineRenderer=new a.TrendLineRenderer,this._positionLineRenderer=new a.TrendLineRenderer,this._fullStopBgRenderer=new d.RectangleRenderer(new h.HitTestResult(h.HitTarget.MovePoint),new h.HitTestResult(h.HitTarget.MovePoint)),this._stopBgRenderer=new d.RectangleRenderer(new h.HitTestResult(h.HitTarget.MovePoint),new h.HitTestResult(h.HitTarget.MovePoint)),this._fullTargetBgRenderer=new d.RectangleRenderer(new h.HitTestResult(h.HitTarget.MovePoint),new h.HitTestResult(h.HitTarget.MovePoint)),this._targetBgRenderer=new d.RectangleRenderer(new h.HitTestResult(h.HitTarget.MovePoint),new h.HitTestResult(h.HitTarget.MovePoint)),this._stopLabelRenderer=new l.TextRenderer,this._middleLabelRenderer=new l.TextRenderer,this._profitLabelRenderer=new l.TextRenderer,this._renderer=new c.CompositeRenderer}isLabelVisible(){return this.isHoveredSource()||this.isSelectedSource()||this._source.properties().childs().alwaysShowStats.value()}renderer(e,t){return this._invalidated&&this._updateImpl(e,t),this._renderer}_updateImpl(e,t){super._updateImpl(e,t),this._renderer.clear();const i=this._model.timeScale(),s=this._source.priceScale();if(!s||s.isEmpty()||i.isEmpty())return;const o=this._source.points();if(o.length<2||this._points.length<2)return;const a=(0,r.ensureNotNull)(this._source.ownerSource()),l=null==a?void 0:a.barsProvider().bars();if(!l||l.isEmpty())return;if(null===l.last())return;const d=4===o.length,h=this._source.lastBarData();if(!h)return;const c=h.closePrice,u=this._source.stopPrice(),p=this._source.profitPrice(),g=this._source.calculatePL(c),f=a.symbolSource().symbolInfo();if(!f)return;const x=a.firstValue();if(null===x)return;const m=this._points[v.RiskRewardPointIndex.Entry].y,w=s.priceToCoordinate(u,x),R=s.priceToCoordinate(p,x),y=s.priceToCoordinate(h.closePrice,x),b=i.indexToCoordinate(h.index),P=this._points[v.RiskRewardPointIndex.Entry].x,L=this._points[v.RiskRewardPointIndex.ActualEntry]?this._points[v.RiskRewardPointIndex.ActualEntry].x:this._points[v.RiskRewardPointIndex.Close].x,S=this._points[v.RiskRewardPointIndex.ActualClose]?this._points[v.RiskRewardPointIndex.ActualClose].x:this._points[v.RiskRewardPointIndex.Close].x,C=this._points[v.RiskRewardPointIndex.Close].x,M=this._source.entryPrice(),I=this._source.stopPrice(),A=this._source.profitPrice(),k={pl:g,isClosed:d,entryLevel:m,stopLevel:w,profitLevel:R,closeLevel:y,closeBar:b,left:P,entryX:L,right:S,edge:C,entryPrice:M,stopPrice:I,profitPrice:A,currentPrice:c};let N=C<-5||P>t+5;if(this._createBackgroundRenderers(k,this._renderer),this._createLinesRenderers(k,this._renderer),this._createLabelsRenderers(k,this._renderer,f),f!==this._lastSymbolInfo&&(this._pipFormatter=new _.PipFormatter(f.pricescale,f.minmov,f.type,f.minmove2,f.typespecs),this._lastSymbolInfo=f), -N=[this._profitLabelRenderer,this._stopLabelRenderer,this._middleLabelRenderer].reduce(((i,n)=>i&&n.isOutOfScreen(t,e)),N),N)return;const D=this._points[0].clone();D.data=0,D.snappingPrice=M;const B=new n.Point(P,w);B.data=2,B.square=!0,B.snappingPrice=I;const z=new n.Point(P,R);z.data=3,z.square=!0,z.snappingPrice=A;const E=new n.Point(C,D.y);E.data=1,E.square=!0,E.snappingIndex=h.index;const H={points:[D,E,B,z],pointsCursorType:T};this._renderer.append(this.createLineAnchor(H,0))}_createBackgroundRenderers(e,t){const i=this._source.properties().childs();{const t={points:[new n.Point(e.left,e.entryLevel),new n.Point(e.edge,e.stopLevel)],color:"white",linewidth:0,backcolor:i.stopBackground.value(),fillBackground:!0,transparency:i.stopBackgroundTransparency.value(),extendLeft:!1,extendRight:!1};this._fullStopBgRenderer.setData(t),this._renderer.append(this._fullStopBgRenderer)}if(e.pl<0&&e.entryX!==e.right){const t=new n.Point(e.entryX,e.entryLevel),r=new n.Point(e.right,e.closeLevel),s=.01*i.stopBackgroundTransparency.value(),o=100-100*(1-s*s*s),a={points:[t,r],color:"white",linewidth:0,backcolor:i.stopBackground.value(),fillBackground:!0,transparency:o,extendLeft:!1,extendRight:!1};this._stopBgRenderer.setData(a),this._renderer.append(this._stopBgRenderer)}{const t={points:[new n.Point(e.left,e.entryLevel),new n.Point(e.edge,e.profitLevel)],color:"white",linewidth:0,backcolor:i.profitBackground.value(),fillBackground:!0,transparency:i.profitBackgroundTransparency.value(),extendLeft:!1,extendRight:!1};this._fullTargetBgRenderer.setData(t),this._renderer.append(this._fullTargetBgRenderer)}if(e.pl>0&&e.entryX!==e.right){const t=new n.Point(e.entryX,e.entryLevel),r=new n.Point(e.right,e.closeLevel),s=.01*i.profitBackgroundTransparency.value(),o=100-100*(1-s*s*s),a={points:[t,r],color:"white",linewidth:0,backcolor:i.profitBackground.value(),fillBackground:!0,transparency:o,extendLeft:!1,extendRight:!1};this._targetBgRenderer.setData(a),this._renderer.append(this._targetBgRenderer)}}_createLinesRenderers(e,t){const i=this._source.properties().childs(),r=(e,t,n,r)=>{const s={points:[t,n],color:null!=r?r:i.linecolor.value(),linewidth:i.linewidth.value(),linestyle:y.LINESTYLE_SOLID,extendleft:!1,extendright:!1,leftend:f.LineEnd.Normal,rightend:f.LineEnd.Normal};e.setData(s),this._renderer.append(e)};if(this._points[v.RiskRewardPointIndex.ActualEntry]){const t={points:[this._points[v.RiskRewardPointIndex.ActualEntry],e.isClosed?this._points[v.RiskRewardPointIndex.ActualClose]:new n.Point(e.closeBar,e.closeLevel)],color:this._source.properties().childs().linecolor.value(),linewidth:1,linestyle:y.LINESTYLE_DASHED,extendleft:!1,extendright:!1,leftend:f.LineEnd.Normal,rightend:f.LineEnd.Arrow};this._positionLineRenderer.setData(t),this._renderer.append(this._positionLineRenderer)}{const t=new n.Point(e.left,this._points[v.RiskRewardPointIndex.Entry].y),i=new n.Point(e.edge,this._points[v.RiskRewardPointIndex.Entry].y);r(this._entryLineRenderer,t,i)}{const t=new n.Point(e.left,e.stopLevel),s=new n.Point(e.edge,e.stopLevel) -;r(this._stopLineRenderer,t,s,i.stopBackground.value())}{const t=new n.Point(e.left,e.profitLevel),s=new n.Point(e.edge,e.profitLevel);r(this._targetLineRenderer,t,s,i.profitBackground.value())}}_addCenterLabel(e,t,i){const n=this._source.properties().childs(),r={font:R.CHART_FONT_FAMILY,offsetX:3,horzAlign:"center",backgroundRoundRect:4,backgroundHorzInflate:4,points:[i.p],text:i.txt,color:n.textcolor.value(),offsetY:i.offsetY,vertAlign:i.vertAlign,backgroundColor:(0,g.resetTransparency)(i.color),fontsize:n.fontsize.value(),borderColor:i.border};return t.setData(r),e.append(t),r}_creareMiddleLabel(e,t,i){const{entryPrice:s,profitPrice:o,stopPrice:a,currentPrice:l,pl:d,left:h,edge:c,isClosed:u}=e,p=Math.abs(s-o)/Math.abs(s-a),_=this._source.properties().childs(),g=(0,r.ensureNotNull)(this._source.ownerSource()),f=new n.Point((h+c)/2,Math.round(this._points[0].y));let v="",x="";const m=this._numericFormatter.format(Math.round(100*p)/100);if(this._points[1]){const e=g.formatter();if(e.formatChange){const t=Math.max(l,s),i=Math.min(l,s);x=d>=0?e.formatChange(t,i):e.formatChange(i,t)}else x=e.format(d)}const R=_.qty.value()/_.lotSize.value(),y="futures"===i.type||(0,w.hasCryptoTypespec)(i.typespecs||[])?Math.round(1e3*R)/1e3:Math.floor(R);if(_.compact.value())v+=x?x+" ~ ":"",v+=y+"\n",v+=m;else{const e=u?L:P;v+=x?b.format({status:e,pnl:x})+", ":"",v+=I.format({qty:""+y})+"\n",v+=S.format({ratio:m})+" "}let T=_.linecolor.value();return d<0?T=_.stopBackground.value():d>0&&(T=_.profitBackground.value()),this._addCenterLabel(t,this._middleLabelRenderer,{p:f,txt:v,color:T,vertAlign:"middle",offsetY:0,border:"white"})}_createStopLabel(e,t){var i,s;const{stopPrice:o,entryPrice:a,left:l,edge:d,stopLevel:h}=e,c=this._source.properties().childs(),u=(0,r.ensureNotNull)(this._source.ownerSource()),p=Math.abs(o-a),_=Math.round(1e4*p/a)/100,g=new n.Point((l+d)/2,h);let f="";const v=u.formatter(),m=null!==(s=null===(i=v.formatChange)||void 0===i?void 0:i.call(v,Math.max(o,a),Math.min(o,a)))&&void 0!==s?s:v.format(p),w=this._percentageFormatter.format(_);return f=c.compact.value()?m+" ("+w+") "+c.amountStop.value():C.format({stopChange:(0,x.forceLTRStr)(m),stopChangePercent:(0,x.forceLTRStr)(this._percentageFormatter.format(_)),stopChangePip:this._pipFormatter?(0,x.forceLTRStr)(this._pipFormatter.format(p)):"",amount:(0,x.forceLTRStr)(""+c.amountStop.value())}),this._addCenterLabel(t,this._stopLabelRenderer,{p:g,txt:f,color:c.stopBackground.value(),vertAlign:aMath.max(e,t.measure().width)),0),h=e.edge-e.left,c=this._anchorRadius();if(h-d-c<=8&&(l&&(l.offsetY+=c+8,this._profitLabelRenderer.setData(l)),a&&(a.offsetY+=c+8,this._stopLabelRenderer.setData(a)),o)){let t;if(null===(s=this._source.priceScale())||void 0===s?void 0:s.isLog()){const i=Math.abs(this._points[0].y-e.stopLevel);t=Math.abs(this._points[0].y-e.profitLevel)>i?-1:1}else{const i=Math.abs(e.stopPrice-e.entryPrice);t=Math.abs(e.profitPrice-e.entryPrice)>i?-1:1}const i=e.profitLevel{"use strict";var n=i(86441).Point,r=i(4652).distanceToLine,s=i(79191).LineSourcePaneView,o=i(79191).thirdPointCursorType,a=i(99031).TrendLineRenderer,l=i(79797).PolygonRenderer,d=i(19266).CompositeRenderer,h=i(73436).LineEnd,c=i(66103).PaneCursorType;const{LINESTYLE_SOLID:u}=i(79849);t.RotatedRectanglePaneView=class extends s{constructor(e,t){super(e,t),this._poligonRenderer=new l,this._renderer=null}_updateImpl(){if(super._updateImpl(),this._renderer=null,this._distance=0,3===this._points.length&&(this._distance=r(this._points[0],this._points[1],this._points[2]).distance),0!==this._points.length){var e,t,i,s,l=new d,p=this._source.properties(),_=this._points[0],g=this._points[1];if(2===this._points.length){(v={}).points=this._points,v.floatPoints=this._floatPoints,v.width=this._model.timeScale().width(),v.height=this._source.priceScale().height(),v.color=p.color.value(),v.linewidth=1,v.linestyle=u,v.extendleft=!1,v.extendright=!1,v.leftend=h.Normal,v.rightend=h.Normal;var f=new a;f.setData(v),l.append(f)}else if(3===this._points.length){var v,x=g.subtract(_),m=new n(x.y,-x.x).normalized().scaled(this._distance),w=m.scaled(-1);e=_.add(m),t=g.add(m),i=_.add(w),s=g.add(w),(v={}).points=[e,t,s,i],v.color=p.color.value(),v.linewidth=this._source.properties().linewidth.value(),v.linestyle=u,v.filled=!0,v.backcolor=p.backgroundColor.value(),v.fillBackground=p.fillBackground.value(),v.transparency=p.transparency.value(),this._poligonRenderer.setData(v),l.append(this._poligonRenderer)}var R=[];R.push(_),this._points.length>=2&&R.push(g);var y=[c.Default,c.Default];if(3===this._points.length){e.data=2,i.data=2,t.data=2,s.data=2,R.push(e,i,t,s);var T=o(_,g);y.push(T,T,T,T)}l.append(this.createLineAnchor({points:R,pointsCursorType:y},0)), -this._renderer=l}}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}}},26294:(e,t,i)=>{"use strict";i.r(t),i.d(t,{SignpostPaneView:()=>L});var n=i(86441),r=i(48891),s=i(19266),o=i(66103),a=i(18807),l=i(79191),d=i(85573),h=i(46501),c=i(4652),u=i(34026),p=i(50151),_=i(38325),g=i(80657),f=i(45197);function v(e){return void 0===e?0:e.poleTailHeight+2*e.circleRadius}function x(e){return e.poleStartY}function m(e){return e.inverseAnchorPosition?e.anchorY:e.anchorY+(e.labelHeight+v(e.plate))*e.direction}function w(e){return e.inverseAnchorPosition?e.anchorY+v(e.plate)*e.direction:e.anchorY+e.labelHeight*e.direction}class R{constructor(e,t){this._data=null,this._hitTestResult=e,this._phantomMode=Boolean(t)}setData(e){if(null===e)return void(this._data=null);this._data={...e,labelHeight:0,labelRenderer:new g.TextRenderer};const t=this._data,i=t.label,r={offsetX:0,offsetY:0,points:[new n.Point(t.x,t.anchorY)],forceCalculateMaxLineWidth:!0,vertAlign:-1===i.labelDirection?"bottom":"top",horzAlign:"center",horzTextAlign:"center",font:i.labelFont,fontSize:i.labelFontSize,bold:i.labelFontBold,italic:i.labelFontItalic,backgroundRoundRect:i.labelBorderRadius,padding:i.labelPadding,boxPaddingVert:i.labelBoxPaddingVert,boxPaddingHorz:i.labelBoxPaddingHorz,wordWrapWidth:i.labelWordWrapWidth,color:i.labelColor,borderColor:i.labelBorderColor,borderWidth:1,backgroundColor:i.labelBackgroundColor,text:i.text};if(t.labelRenderer.setData(r),this._data.labelHeight=this._data.labelRenderer.measure().height,t.inverseAnchorPosition){const e=(0,p.ensureDefined)(r.points);r.points=[new n.Point(e[0].x,w(t))]}else{const e=1===t.direction?Math.min(t.poleStartY-this._data.labelHeight,t.anchorY):Math.max(t.poleStartY+this._data.labelHeight,t.anchorY);t.anchorY!==e&&(t.anchorY=e,r.points=[new n.Point(t.x,e)])}t.labelRenderer.setData(r)}itemAnchorY(){return null===this._data?null:this._data.anchorY}hitTest(e,t){if(null===this._data)return null;const[i,r,s]=function(e,t){const i=(0,_.lastMouseOrTouchEventInfo)().isTouch?20:3,r=e.x,s=e.plate,o=(0,c.distanceToSegment)(new n.Point(r,x(e)),new n.Point(r,m(e)),t).distance0&&(0,u.pointInCircle)(t,new n.Point(r,o),s.circleRadius+i)}return[o,a,!o&&!a&&null!==e.labelRenderer.hitTest(t)]}(this._data,e);if(i||r||s){const e={hideCrosshairLinesOnHover:!0,activeItem:i||r?this._data.itemIndex:this._data.label.labelIndex};return s?e.areaName=a.AreaName.Text:r&&(e.areaName=a.AreaName.Style),new a.HitTestResult(this._hitTestResult,e)}return null}draw(e,t){if(null===this._data)return;e.save(),this._phantomMode&&(e.globalAlpha=.5);const{poleColor:i,emojiRadius:n}=this._data,r=t.pixelRatio,s=Math.max(1,Math.floor(r)),o=s%2?.5:0;e.beginPath(),e.strokeStyle=i,e.lineWidth=s;const a=Math.round(this._data.x*r)+o;e.moveTo(a,Math.round(x(this._data)*r)),e.lineTo(a,Math.round(m(this._data)*r)), -void 0!==this._data.plate&&0!==this._data.plate.poleTailHeight&&(e.moveTo(a,Math.round(w(this._data)*r)),e.lineTo(a,Math.round(function(e){var t,i;const n=null!==(i=null===(t=e.plate)||void 0===t?void 0:t.poleTailHeight)&&void 0!==i?i:0;return e.inverseAnchorPosition?w(e)-n*e.direction:w(e)+n*e.direction}(this._data)*r))),e.stroke(),void 0!==this._data.plate&&function(e,t,i,n,r){const s=r.pixelRatio,{circleRadius:o,poleTailHeight:a,circleBorderColor:l,circleBackgroundColor:d}=i;e.strokeStyle=l,e.fillStyle=d;const h=(0,f.fillScaledRadius)(o,s),c=Math.round(t.x*s),u=t.inverseAnchorPosition?Math.round(t.anchorY*s)+Math.round(o*s)*t.direction:Math.round(t.anchorY*s)+Math.round((t.labelHeight+a+o)*s)*t.direction,p=Math.max(1,Math.floor(s))%2/2,_=c+p,g=u+p;if(e.shadowOffsetY=1,e.shadowColor=i.shadowColor,e.shadowBlur=4,e.beginPath(),e.arc(_,g,h,0,2*Math.PI,!0),e.closePath(),e.fill(),e.shadowColor="transparent",t.svgRenderer){const i=2*(0,f.fillScaledRadius)(n,s);t.svgRenderer.render(e,{targetViewBox:{x:_-i/2,y:g-i/2,width:i,height:i}})}const v=Math.round(i.circleBorderWidth*s),x=(0,f.strokeScaledRadius)(o,s,v);if(e.lineWidth=v,e.beginPath(),e.arc(_,g,x,0,2*Math.PI,!0),e.closePath(),e.stroke(),i.outsideBorderWidth){e.save();const t=Math.round(i.outsideBorderWidth*s),n=x+v/2+t/2;e.lineWidth=t,e.strokeStyle=i.outsideBorderColor,e.beginPath(),e.arc(_,g,n,0,2*Math.PI,!0),e.closePath(),e.stroke(),e.restore()}}(e,this._data,this._data.plate,n,t),this._data.labelRenderer.draw(e,t),e.restore()}}var y=i(68616),T=i(69798);const b={circleBorderColor:(0,r.getHexColorByName)("color-cold-gray-900"),labelBackgroundColor:(0,r.getHexColorByName)("color-cold-gray-900"),labelBorderColor:(0,r.getHexColorByName)("color-cold-gray-800"),labelTextColor:(0,r.getHexColorByName)("color-cold-gray-200"),poleColor:(0,r.getHexColorByName)("color-cold-gray-500"),shadowColor:"rgba(0,0,0,0.4)",selectionColor:(0,r.getHexColorByName)("color-tv-blue-500")},P={circleBorderColor:(0,r.getHexColorByName)("color-white"),labelBackgroundColor:(0,r.getHexColorByName)("color-white"),labelBorderColor:(0,r.getHexColorByName)("color-cold-gray-150"),labelTextColor:(0,r.getHexColorByName)("color-cold-gray-900"),poleColor:(0,r.getHexColorByName)("color-cold-gray-500"),shadowColor:"rgba(0,0,0,0.2)",selectionColor:(0,r.getHexColorByName)("color-tv-blue-500")};class L extends l.LineSourcePaneView{constructor(e,t){super(e,t),this._renderer=new s.CompositeRenderer,this._emojiCache=null,this._destroyed=!1,this._signpostRenderer=new R(a.HitTarget.MovePoint,e.isPhantom()),e.properties().childs().emoji.subscribe(this,this._updateEmoji),this._updateEmoji()}destroy(){this._source.properties().childs().emoji.unsubscribeAll(this),this._destroyed=!0}renderer(e,t){return this._invalidated&&this._updateImpl(e,t),this._renderer}_updateImpl(e,t){if(super._updateImpl(),this._renderer.clear(),!this._updateTimelineRenderer(e))return;if(this._renderer.append(this._signpostRenderer),this._source.isPhantom())return;const i=this._itemAnchorY();if(null===i)return -;const r=this._points[0],s=new n.Point(r.x,i);s.data=r.data,s.square=!0,this._renderer.append(this.createLineAnchor({points:[s],pointsCursorType:[o.PaneCursorType.VerticalResize]},0))}_itemAnchorY(){return this._signpostRenderer.itemAnchorY()}_updateTimelineRenderer(e){var t;const i=this._source.ownerSource();if(null===i)return!1;const n=this._model.timeScale(),r=i.priceScale(),s=i.firstValue();if(n.isEmpty()||null===r||r.isEmpty()||null===s)return!1;const o=this._model.dark().value()?b:P,a=this._model.mainSeries(),l=this._source.properties().childs(),c=l.position.value(),u=this._source.customEvent(),p=i===a?(0,d.getSeriesPosition)(a,u):(0,d.getNoDataPosition)(u,r,s);if(null===p)return!1;const _=n.indexToCoordinate(p.index),g=r.priceToCoordinate(p.price,s),f=l.showImage.value();let v=(0,d.positionToCoordinate)(c,e,g,p.positionPointDirection);v>=-1e-10&&v<=e+1e-10&&(v=Math.min(e-2,Math.max(2,v)));const x=p.visualDirection!==p.positionPointDirection,m=p.visualDirection,w={emojiRadius:16,poleColor:o.poleColor,svgRenderer:null===(t=this._emojiCache)||void 0===t?void 0:t.emojiSvgRenderer,itemIndex:1,label:{labelIndex:1,labelDirection:p.positionPointDirection,labelFont:h.CHART_FONT_FAMILY,labelFontSize:l.fontSize.value(),labelFontBold:l.bold.value(),labelFontItalic:l.italic.value(),labelBorderRadius:4,labelPadding:3,labelBoxPaddingVert:6,labelBoxPaddingHorz:8,labelWordWrapWidth:134,labelColor:o.labelTextColor,labelBorderColor:o.labelBorderColor,labelBackgroundColor:o.labelBackgroundColor,text:l.text.value()},x:_,anchorY:v,poleStartY:p.poleStartY,direction:m*(x?-1:1),inverseAnchorPosition:x};return f&&(w.plate={circleBackgroundColor:l.backgroundsColors.value(),outsideBorderWidth:0,circleBorderColor:o.circleBorderColor,circleBorderWidth:1,poleTailHeight:l.text.value()?10:0,circleRadius:35,shadowColor:o.shadowColor,outsideBorderColor:o.selectionColor}),this._signpostRenderer.setData(w),!0}async _updateEmoji(){var e;const t=this._source.properties().childs().emoji.value();if(null!==this._emojiCache&&this._emojiCache.emoji===t)return;null!==this._emojiCache&&(null===(e=this._emojiCache.abortController)||void 0===e||e.abort(),this._emojiCache.abortController=void 0);const n=(0,y.getTwemojiUrl)(t,"svg"),r=new AbortController,s=(0,T.fetch)(n,{signal:r.signal}).then((e=>e.text())),o={emoji:t,abortController:r};this._emojiCache=o;const[a,{svgRenderer:l}]=await Promise.all([s,i.e(2616).then(i.bind(i,50765))]);!this._destroyed&&o.abortController&&(o.emojiSvgRenderer=l(a),this._model.updateSource(this._source))}}},5362:(e,t,i)=>{"use strict";i.r(t),i.d(t,{SineLinePaneView:()=>h});var n=i(86441),r=i(79191),s=i(19266),o=i(15187),a=i(18807),l=i(68441);class d extends o.MediaCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e,t){const i=(e.x-this._data.point.x)*Math.PI/this._data.width;let n=Math.sin(i-Math.PI/2)*this._data.height/2;return n=this._data.point.y+n+this._data.height/2,Math.abs(n-e.y)<=3?new a.HitTestResult(a.HitTarget.MovePoint):null}_drawImpl(e){const t=e.context;t.strokeStyle=this._data.color, -t.lineWidth=this._data.lineWidth,(0,l.setLineStyle)(t,this._data.lineStyle),t.beginPath(),t.moveTo(this._data.point.x,this._data.point.y);const i=Math.max(1,this._data.width/30),n=e.mediaSize.width-this._data.point.x+i;for(let e=1;e<=n;e+=i){const i=e*Math.PI/this._data.width,n=Math.sin(i-Math.PI/2)*this._data.height/2;t.lineTo(this._data.point.x+e,this._data.point.y+n+this._data.height/2)}t.stroke()}}class h extends r.LineSourcePaneView{constructor(e,t){super(e,t),this._renderer=new s.CompositeRenderer}renderer(e,t){return this._invalidated&&this._updateImpl(e,t),this._renderer}_updateImpl(e,t){if(super._updateImpl(),this._renderer.clear(),this._points.length<2)return;const[i,r]=this._source.points();if(0===2*Math.abs(i.index-r.index))return void this.addAnchors(this._renderer);const[s,o]=this._points,a=Math.abs(s.x-o.x),l=o.y-s.y,h=this._source.properties().childs(),c=h.linewidth.value();if(s.y<-c&&o.y<-c||s.y>e+c&&o.y>e+c)return;const u=2*a,p=s.x>0?s.x-Math.ceil(s.x/u)*u:s.x+Math.floor(-s.x/u)*u,_={point:new n.Point(p,s.y),width:a,height:l,color:h.linecolor.value(),lineWidth:h.linewidth.value(),lineStyle:h.linestyle.value()};this._renderer.append(new d(_)),this.addAnchors(this._renderer)}}},15378:(e,t,i)=>{"use strict";i.r(t),i.d(t,{StickerPaneView:()=>r});var n=i(50761);class r extends n.SvgIconPaneView{_iconColor(){return null}}},44666:(e,t,i)=>{"use strict";i.r(t),i.d(t,{StudyLineDataSourceAnchorsPaneView:()=>r});var n=i(79191);class r extends n.LineSourcePaneView{renderer(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this.createLineAnchor({points:this._getPoints()},0)}}},50761:(e,t,i)=>{"use strict";i.d(t,{SvgIconPaneView:()=>g});var n=i(86441),r=i(25422),s=i(50151),o=i(87095),a=i(19266),l=i(66103),d=i(79191),h=i(48891),c=i(15187),u=i(18807);const p=(0,h.getHexColorByName)("color-tv-blue-600");class _ extends c.MediaCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null}setData(e){this._data=e}hitTest(e,t){if(null===this._data)return null;const{size:i,angle:n,point:s}=this._data,o=(0,r.rotationMatrix)(-n),a=(0,r.transformPoint)(o,e.subtract(s));return Math.abs(a.y)<=i/2&&Math.abs(a.x)<=i/2?new u.HitTestResult(u.HitTarget.MovePoint):null}isOutOfScreen(e,t){if(null===this._data)return!0;const{size:i,point:n,angle:r}=this._data;let s;return s=r%(Math.PI/2)==0?i/2:Math.sqrt(i**2*2)/2,n.x+s<0||n.x-s>t||n.y+s<0||n.y-s>e}_drawImpl(e){if(null===this._data)return;const{size:t,svg:i,point:n,angle:r,color:s,background:o,selected:a}=this._data,l=e.context;l.translate(n.x,n.y);const d=r-Math.PI/2;l.rotate(d);const h=t/2;a&&(l.fillStyle=o,l.strokeStyle=p,l.beginPath(),l.rect(-h,-h,t,t),l.closePath(),l.fill(),l.stroke()),i&&(l.translate(-h,-h),null!==s&&(l.fillStyle=s),i.render(l,{targetViewBox:{x:0,y:0,width:t,height:t},doNotApplyColors:null!==s}))}}class g extends d.LineSourcePaneView{constructor(e,t,i){super(e,t),this._iconRenderer=new _,this._renderer=new a.CompositeRenderer,this._svg=i}renderer(e,t){return this._invalidated&&this._updateImpl(e,t),this._renderer} -_updateImpl(e,t){if(super._updateImpl(),this._renderer.clear(),this._points.length<1)return;const i=this._source.properties().childs(),s=i.size.value(),o={point:this._points[0],color:this._iconColor(),size:s,svg:this._svg,angle:i.angle.value(),selected:this.areAnchorsVisible(),background:this._calculateBackgroundColor()};this._iconRenderer.setData(o),this._iconRenderer.isOutOfScreen(e,t)||this._renderer.append(this._iconRenderer);const a=this._points[0],h=this._source.getAnchorLimit();let c=new n.Point(Math.max(h,s)/2,0),u=new n.Point(0,Math.max(h,s)/2);const p=(0,r.rotationMatrix)(i.angle.value());c=(0,r.transformPoint)(p,c),u=(0,r.transformPoint)(p,u);const _=a.add(c);_.data=0,_.nonDiscreteIndex=!0;const g=a.subtract(c);g.data=1,g.nonDiscreteIndex=!0;const f=a.add(u);f.data=2,f.square=!0,f.nonDiscreteIndex=!0;const v=a.subtract(u);v.data=3,v.square=!0,v.nonDiscreteIndex=!0;const x=(0,d.thirdPointCursorType)(_,g),m=[l.PaneCursorType.Default,l.PaneCursorType.Default,x,x];this._renderer.append(this.createLineAnchor({points:[_,g,f,v],pointsCursorType:m},0))}_calculateBackgroundColor(){return(0,o.generateColor)(this._model.backgroundColorAtYPercentFromTop(this._points[0].y/(0,s.ensureNotNull)(this._model.paneForSource(this._source)).height()),60,!0)}}},62912:(e,t,i)=>{"use strict";i.r(t),i.d(t,{TextPaneView:()=>_});var n=i(50151),r=i(86441),s=i(46501),o=i(66103),a=i(80657),l=i(19266),d=i(80101),h=i(78211),c=i(18807),u=i(79191);const p=[o.PaneCursorType.HorizontalResize];class _ extends u.LineSourcePaneView{constructor(e,t,i,n,r,s,o,l){super(e,t),this._textRenderer=new a.TextRenderer,this._noSelection=!1,this._renderer=null,this._offsetX=i,this._offsetY=n,this._vertAlign=r,this._horzAlign=s,this._forceTextAlign=Boolean(o),this._noSelection=!1,this._renderer=null,this._recalculateSourcePointsOnFirstUpdate=l}renderer(e,t){return this._invalidated&&this._updateImpl(e,t),this._renderer}disableSelection(){this._noSelection=!0}isEditMode(){return!this._getModel().readOnly()}_updateImpl(e,t){super._updateImpl(e,t),this._renderer=null;const i=this._getSource(),o=i.priceScale();if(!o||o.isEmpty())return;const a=i.properties().childs(),u=this._getModel(),_={text:a.text.value(),color:a.color.value(),fontSize:a.fontsize.value(),boxPadding:a.fontsize.value()/6,font:s.CHART_FONT_FAMILY,vertAlign:this._vertAlign||"top",horzAlign:this._horzAlign||"left",offsetX:this._offsetX||0,offsetY:this._offsetY||0,forceTextAlign:this._forceTextAlign};if(_.points=i.isFixed()?[(0,n.ensureDefined)(i.fixedPoint())]:this._points,a.fillBackground&&a.fillBackground.value()&&(_.backgroundColor=a.backgroundColor.value()),a.drawBorder&&a.drawBorder.value()&&(_.borderColor=a.borderColor.value()),a.wordWrap&&a.wordWrap.value()&&(_.wordWrapWidth=a.wordWrapWidth.value()),_.bold=a.bold&&a.bold.value(),_.italic=a.italic&&a.italic.value(),_.highlightBorder=u.selection().isSelected(i),!i.isFixed()&&a.fixedSize&&!a.fixedSize.value()){_.scaleX=u.timeScale().barSpacing()/i.barSpacing();const e=(0,n.ensureNotNull)(o.priceRange());let t=o.height()/e.length() -;const r=o.logFormula();i.isPriceDencityLog()&&!o.isLog()&&(t=o.height()/((0,h.toLog)(e.maxValue(),r)-(0,h.toLog)(e.minValue(),r))),!i.isPriceDencityLog()&&o.isLog()&&(t=o.height()/((0,h.fromLog)(e.maxValue(),r)-(0,h.fromLog)(e.minValue(),r)));const s=i.priceDencity();void 0!==s&&(_.scaleY=t/s),(void 0===s||void 0===_.scaleY||_.scaleY<=0)&&delete _.scaleY}if(this._textRenderer.setData(_),this._textRenderer.isOutOfScreen(t,e))return;const g=1===_.points.length;if(g&&void 0!==this._recalculateSourcePointsOnFirstUpdate){this._renderer=null;const e=this._textRenderer.measure();return this._recalculateSourcePointsOnFirstUpdate(e.width,e.height),void(this._recalculateSourcePointsOnFirstUpdate=void 0)}if(g&&!this._noSelection){const e=new l.CompositeRenderer;e.append(this._textRenderer);const t=_.points[0].clone(),i=this._textRenderer.measure(),n=i.width,s=i.height;if(_.wordWrapWidth){const i=new r.Point(t.x+n,t.y+s/2);i.data=1,e.append(this.createLineAnchor({points:[i],pointsCursorType:p},1))}const o=new r.Point(t.x+n/2,t.y+s);return o.data=0,e.append(new d.SelectionRenderer({points:[o],bgColors:this._lineAnchorColors([o]),visible:this.areAnchorsVisible(),hittestResult:c.HitTarget.MovePoint,barSpacing:u.timeScale().barSpacing()})),void(this._renderer=e)}this._renderer=this._textRenderer}}},90042:(e,t,i)=>{"use strict";i.r(t),i.d(t,{LineToolThreeDrivesPaneView:()=>u});var n=i(79849),r=i(19266),s=i(80657),o=i(87663),a=i(99031),l=i(73436),d=i(79797),h=i(79191),c=i(46501);class u extends h.LineSourcePaneView{constructor(){super(...arguments),this._numericFormatter=new o.NumericFormatter,this._retrace1LabelRenderer=new s.TextRenderer,this._retrace12LabelRenderer=new s.TextRenderer,this._polyLineRenderer=new d.PolygonRenderer,this._renderer=null}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){super._updateImpl(),this._renderer=null;let e=NaN,t=NaN;if(this._source.points().length>=4){const[,t,i,n]=this._source.points();e=Math.round(100*Math.abs((n.price-i.price)/(i.price-t.price)))/100}if(this._source.points().length>=6){const[,,,e,i,n]=this._source.points();t=Math.round(100*Math.abs((n.price-i.price)/(i.price-e.price)))/100}if(this._points.length<2)return;const i=this._source.properties().childs(),s=new r.CompositeRenderer,o=(e,t)=>({points:[e],text:t,color:i.textcolor.value(),vertAlign:"middle",horzAlign:"center",font:c.CHART_FONT_FAMILY,offsetX:0,offsetY:0,bold:i.bold&&i.bold.value(),italic:i.italic&&i.italic.value(),fontsize:i.fontsize.value(),backgroundColor:i.color.value(),backgroundRoundRect:4}),d=(e,t)=>({points:[e,t],color:i.color.value(),linewidth:i.linewidth.value(),linestyle:n.LINESTYLE_DOTTED,extendleft:!1,extendright:!1,leftend:l.LineEnd.Normal,rightend:l.LineEnd.Normal}),h={points:this._points,color:i.color.value(),linewidth:i.linewidth.value(),linestyle:n.LINESTYLE_SOLID,leftend:l.LineEnd.Normal,rightend:l.LineEnd.Normal,backcolor:"rgba(0, 0, 0, 0)",fillBackground:!1,filled:!1};if(this._polyLineRenderer.setData(h),s.append(this._polyLineRenderer),!isNaN(e)){ -const t=new a.TrendLineRenderer;t.setData(d(this._points[1],this._points[3])),s.append(t);const i=o(this._points[1].add(this._points[3]).scaled(.5),this._numericFormatter.format(e));this._retrace1LabelRenderer.setData(i),s.append(this._retrace1LabelRenderer)}if(!isNaN(t)){const e=new a.TrendLineRenderer;e.setData(d(this._points[3],this._points[5])),s.append(e);const i=o(this._points[5].add(this._points[3]).scaled(.5),this._numericFormatter.format(t));this._retrace12LabelRenderer.setData(i),s.append(this._retrace12LabelRenderer)}this.addAnchors(s),this._renderer=s}}},65557:(e,t,i)=>{"use strict";i.r(t),i.d(t,{TimeCyclesPaneView:()=>c});var n=i(86441),r=i(19266),s=i(79191),o=i(87095),a=i(18807),l=i(68441),d=i(15187);class h extends d.MediaCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null}setData(e){this._data=e}hitTest(e){if(null===this._data||e.y>this._data.point.y)return null;if(e.xthis._data.point.x+this._data.width)return null;const t=new n.Point(this._data.point.x+this._data.width/2,this._data.point.y);let i=e.subtract(t);const r=this._data.height/this._data.width;i=new n.Point(i.x,i.y/r);const s=i.length();return Math.abs(s-this._data.width/2)<3?new a.HitTestResult(a.HitTarget.MovePoint):null}_drawImpl(e){if(null===this._data)return;const t=e.context;t.strokeStyle=this._data.color,t.lineWidth=this._data.linewidth,(0,l.setLineStyle)(t,this._data.linestyle),t.save(),t.translate(this._data.point.x+1,this._data.point.y),t.scale(this._data.width,this._data.height),t.beginPath(),t.arc(.5,0,.5,Math.PI,0,!1),t.restore(),t.stroke(),this._data.fillBackground&&(t.fillStyle=(0,o.generateColor)(this._data.backcolor,this._data.transparency),t.fill())}}class c extends s.LineSourcePaneView{constructor(){super(...arguments),this._renderer=null}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){if(super._updateImpl(),this._renderer=null,this._points.length<2)return;const e=this._source.points(),t=e[0],i=e[1],s=Math.min(t.index,i.index),o=Math.max(t.index,i.index),a=o-s,l=this._points[0],d=this._points[1],c=Math.abs(l.x-d.x),u=new r.CompositeRenderer,p=this._source.properties().childs(),_=this._model.timeScale();if(0===a)return;let g=Math.min(l.x,d.x);const f=[];for(let e=s;g>-c;e-=a)g=_.indexToCoordinate(e),f.push(g);g=Math.max(l.x,d.x);for(let e=o;g<_.width();e+=a)g=_.indexToCoordinate(e),f.push(g);for(let e=0;e{"use strict";i.r(t),i.d(t,{TrendAnglePaneView:()=>m});var n=i(50151),r=i(86441),s=i(5531),o=i(34026),a=i(38223),l=i(18807),d=i(73436),h=i(9155),c=i(80657),u=i(99031),p=i(80101),_=i(46501),g=i(21477),f=i(15187);class v extends f.MediaCoordinatesPaneRenderer{constructor(){ -super(...arguments),this._data=null}setData(e){this._data=e}hitTest(e){return null}_drawImpl(e){if(null===this._data)return;const t=e.context;t.translate(this._data.point.x,this._data.point.y),t.strokeStyle=this._data.color,t.setLineDash([1,2]);const i=this._data.size;t.beginPath(),t.moveTo(0,0),t.lineTo(i,0),t.arc(0,0,i,0,-this._data.angle,this._data.angle>0),t.stroke()}}var x=i(48063);class m extends x.TrendToolWithStatsPaneView{constructor(e,t){super(e,t),this._secondPoint=null,this._trendRenderer=new u.TrendLineRenderer,this._angleRenderer=new v,this._angleLabelRenderer=new c.TextRenderer}_getPointsForStats(){return[this._points[0],(0,n.ensureNotNull)(this._middlePoint),(0,n.ensureNotNull)(this._secondPoint)]}_updateImpl(e,t){var i;this._renderer.clear(),super._updateImpl();const n=this._source,c=n.angle();if(this._points.length>0&&null!==c){const e=Math.cos(c),t=-Math.sin(c),i=new r.Point(e,t);this._secondPoint=this._points[0].addScaled(i,n.distance()),this._middlePoint=this._source.calcMiddlePoint(this._points[0],this._secondPoint)}this._invalidated=!1;const u=this._source.priceScale(),f=this._model.timeScale();if(!u||u.isEmpty()||f.isEmpty())return;if(null===this._model.timeScale().visibleBarsStrictRange())return;if(this._source.points().length<2)return;if(this._points.length<2||null===this._secondPoint)return;const v=this._points[0],x=this._points[1],m=this._source.properties().childs();m.showBarsRange.value()||m.showPriceRange.value()||m.showPercentPriceRange.value()||m.showPipsPriceRange.value()||(this._label=null,this._labelData&&(this._labelData.text=""));const w=m.linecolor.value(),R={points:[v,this._secondPoint],color:w,linewidth:m.linewidth.value(),linestyle:m.linestyle.value(),extendleft:m.extendLeft.value(),extendright:m.extendRight.value(),leftend:d.LineEnd.Normal,rightend:d.LineEnd.Normal};this._trendRenderer.setData(R),this._renderer.append(this._trendRenderer);const y=(0,r.box)(new r.Point(0,0),new r.Point(t,e));let T=!1;m.statsPosition.value()===h.StatsPosition.Auto&&(T=(0,r.equalPoints)(v,x)?!(0,o.pointInBox)(v,y):null===(0,s.intersectLineSegmentAndBox)((0,r.lineSegment)(v,x),y));if((this.isHoveredSource()||this.isSelectedSource()||m.alwaysShowStats.value())&&!T&&2===this._points.length){const e=new g.PaneRendererCachedImage(this,0);this._renderer.append(e)}const b=(this.isHoveredSource()||this.isSelectedSource())&&m.showMiddlePoint.value();this._middlePoint&&this._renderer.append(new p.SelectionRenderer({points:[this._middlePoint],bgColors:this._lineAnchorColors([this._middlePoint]),color:w,visible:b&&this.areAnchorsVisible(),hittestResult:l.HitTarget.Regular,barSpacing:0}));const P={point:v,angle:null!==(i=n.angle())&&void 0!==i?i:0,color:m.linecolor.value(),size:50};this._angleRenderer.setData(P),this._renderer.append(this._angleRenderer);const L=Math.round(180*P.angle/Math.PI)+"º",S={points:[new r.Point(v.x+50,v.y)],text:(0,a.forceLTRStr)(L),color:m.textcolor.value(),horzAlign:"left",font:_.CHART_FONT_FAMILY,offsetX:5,offsetY:0,bold:m.bold.value(),italic:m.italic.value(), -fontsize:m.fontsize.value(),vertAlign:"middle"};this._angleLabelRenderer.setData(S),this._renderer.append(this._angleLabelRenderer),R.points.length>=2&&this._addAlertRenderer(this._renderer,R.points);const C=new r.Point(this._secondPoint.x,this._secondPoint.y);C.data=1,this._renderer.append(this.createLineAnchor({points:[v,C]},0))}}},38058:(e,t,i)=>{"use strict";i.r(t),i.d(t,{TrendBasedFibExtensionPaneView:()=>u});var n=i(86441),r=i(72739),s=i(99031),o=i(18807),a=i(19266),l=i(73436),d=i(26702),h=i(80657),c=i(134);class u extends c.LineToolPaneViewFibWithLabels{constructor(e,t){super(e,t),this._trendLineRendererPoints12=new s.TrendLineRenderer,this._trendLineRendererPoints23=new s.TrendLineRenderer,this._rectangleRenderers={},this._hlevelLineRenderers={},this._renderer=new a.CompositeRenderer,this._levels=[]}renderer(e,t){return this._invalidated&&this._updateImpl(t,e),this._renderer}_updateImpl(e,t){var i,a;if(super._updateImpl(),this._renderer.clear(),this._points.length<2)return;const[c,u]=this._points,p=this._source.properties().childs();if(3===this._source.points().length){const e=this._source.priceScale();if(!e||e.isEmpty()||this._model.timeScale().isEmpty())return;const t=null===(i=this._source.ownerSource())||void 0===i?void 0:i.firstValue();if(null==t)return;const[n,r,s]=this._source.points();let o=!1;p.reverse&&p.reverse.value()&&(o=p.reverse.value()),this._levels=[];const a=o?n.price:r.price,l=o?r.price:n.price,h=a-l;let c,u,_;const g=e.isLog()&&p.fibLevelsBasedOnLogScale.value();if(g){c=e.priceToCoordinate(a,t);u=c-e.priceToCoordinate(l,t),_=e.priceToCoordinate(s.price,t)}const f={price:s.price,coordinate:_},v={price:h,coordinate:u},x=this._source.levelsCount();for(let i=1;i<=x;i++){const n=p["level"+i].childs();if(!n.visible.value())continue;const r=n.coeff.value(),s=n.color.value(),o=(0,d.fibLevelCoordinate)(f,v,r,e,t,g),a=(0,d.fibLevelPrice)(f,v,r,e,t,g);this._levels.push({color:s,price:a,y:o,linewidth:p.levelsStyle.childs().linewidth.value(),linestyle:p.levelsStyle.childs().linestyle.value(),index:i})}}const _=p.trendline.childs();if(_.visible.value()){const e={points:[c,u],color:_.color.value(),linewidth:_.linewidth.value(),linestyle:_.linestyle.value(),extendleft:!1,extendright:!1,leftend:l.LineEnd.Normal,rightend:l.LineEnd.Normal};this._trendLineRendererPoints12.setData(e),this._renderer.append(this._trendLineRendererPoints12)}if(this._points.length<3)return void this.addAnchors(this._renderer);const g=this._points[2];if(_.visible.value()){const e={points:[u,g],color:_.color.value(),linewidth:_.linewidth.value(),linestyle:_.linestyle.value(),extendleft:!1,extendright:!1,leftend:l.LineEnd.Normal,rightend:l.LineEnd.Normal};this._trendLineRendererPoints23.setData(e),this._renderer.append(this._trendLineRendererPoints23)}const f=Math.min(g.x,u.x),v=Math.max(g.x,u.x),x=p.fillBackground.value(),m=p.transparency.value(),w=p.extendLinesLeft.value(),R=p.extendLines.value();if(x)for(let e=0;e0&&x){const t=this._levels[e-1],i={ -points:[new n.Point(f,this._levels[e].y),new n.Point(v,t.y)],color:this._levels[e].color,linewidth:0,backcolor:this._levels[e].color,fillBackground:!0,transparency:m,extendLeft:w,extendRight:R};this._rectangleRenderers.hasOwnProperty(e)||(this._rectangleRenderers[e]=new r.RectangleRenderer(void 0,void 0,!0));const s=this._rectangleRenderers[e];s.setData(i),this._renderer.append(s)}let y=f,T=v;y===T&&(w&&(y-=1),R&&(T+=1));for(let i=0;i{"use strict";i.r(t),i.d(t,{TrendBasedFibTimePaneView:()=>p});var n=i(86441),r=i(71254),s=i(80657),o=i(72739),a=i(99031),l=i(18807),d=i(19266),h=i(73436),c=i(46501),u=i(79191);class p extends u.LineSourcePaneView{constructor(e,t){super(e,t),this._trendLineRendererPoints12=new a.TrendLineRenderer,this._trendLineRendererPoints23=new a.TrendLineRenderer,this._renderer=new d.CompositeRenderer,this._levels=[]}renderer(e,t){return this._invalidated&&this._updateImpl(e,t),this._renderer}_updateImpl(e,t){var i;super._updateImpl(),this._renderer.clear();const a=this._source.properties().childs();if(3===this._source.points().length){const e=this._model.timeScale();if(e.isEmpty())return;const[t,i,n]=this._source.points();if(this._levels=[],i.index===t.index)return;const r=i.index-t.index,s=n.index;if(null===e.visibleBarsStrictRange())return;for(let t=1;t<=11;t++){const i=a["level"+t].childs();if(!i.visible.value())continue;const n=i.coeff.value(),o=i.color.value(),l=Math.round(s+n*r),d={x:e.indexToCoordinate(l),coeff:n,color:o,linewidth:i.linewidth.value(),linestyle:i.linestyle.value(),index:t,text:String(n)};this._levels.push(d)}}if(this._points.length<2)return;const u=new d.CompositeRenderer,[p,_]=this._points,g=a.trendline.childs();if(g.visible.value()){const e={points:[p,_],color:g.color.value(),linewidth:g.linewidth.value(),linestyle:g.linestyle.value(),extendleft:!1,extendright:!1,leftend:h.LineEnd.Normal,rightend:h.LineEnd.Normal};this._trendLineRendererPoints12.setData(e),u.append(this._trendLineRendererPoints12)} -if(this._points.length<3)return this.addAnchors(u),void(this._renderer=u);const f=this._points[2];if(g.visible.value()){const e={points:[_,f],color:g.color.value(),linewidth:g.linewidth.value(),linestyle:g.linestyle.value(),extendleft:!1,extendright:!1,leftend:h.LineEnd.Normal,rightend:h.LineEnd.Normal};this._trendLineRendererPoints23.setData(e),u.append(this._trendLineRendererPoints23)}if(a.fillBackground.value()){const t=a.transparency.value();for(let i=1;i{"use strict";i.r(t),i.d(t,{TrendLinePaneView:()=>g});var n=i(50151),r=i(86441),s=i(34026),o=i(5531),a=i(21477),l=i(80657),d=i(9155),h=i(80101),c=i(99031),u=i(46501),p=i(18807),_=i(48063);class g extends _.TrendToolWithStatsPaneView{constructor(){super(...arguments),this._trendRenderer=new c.TrendLineRenderer,this._labelRenderer=new l.TextRenderer}_getPointsForStats(){return[this._points[0],(0,n.ensureNotNull)(this._middlePoint),this._points[1]]}_updateImpl(e,t){var i;this._renderer.clear(),this._invalidated=!1;const n=this._source.priceScale(),c=this._model.timeScale();if(!n||n.isEmpty()||c.isEmpty())return;const _=this._model.timeScale().visibleBarsStrictRange();if(null===_)return;const g=this._source.points();if(g.length<2)return;const f=g[0],v=g[1],x=this._source.properties().childs();if(f.index<_.firstBar()&&v.index<_.firstBar()&&!x.extendLeft.value()&&!x.extendRight.value())return;if(super._updateImpl(),this._points.length<2)return;x.showPriceRange.value()||x.showPercentPriceRange.value()||x.showPipsPriceRange.value()||x.showBarsRange.value()||x.showDateTimeRange.value()||x.showDistance.value()||x.showAngle.value()||(this._label=null, -this._labelData&&(this._labelData.text=""));const m=this._points[0],w=this._points[1];let R;if(x.showLabel&&x.showLabel.value()&&x.text.value().length>0){const n=m.x=2&&this._addAlertRenderer(this._renderer,T.points)}}},48063:(e,t,i)=>{"use strict";i.d(t,{TrendToolWithStatsPaneView:()=>V});var n=i(50151),r=i(86441),s=i(5531),o=i(44352),a=i(38223),l=i(19266),d=i(93572),h=i(87663),c=i(2043),u=i(57322),p=i(57352),_=i(27714),g=i(34026),f=i(49483),v=i(80657),x=i(18807),m=i(68441),w=i(1722),R=i(74359),y=i(57898);class T{constructor(e,t,i){this._ready=!1,this._img=function(e,t,i){const n=new Image;return n.width=t,n.height=t,n.onload=i,n.src=e,n}(e,t,(()=>{this._ready=!0,i()}))}ready(){return this._ready}image(){return this._img}}let b=null;const P=18,L=new class{constructor(e,t){this._icons=new Map,this._onAllIconsLoaded=new y.Delegate,this._pendingLoading=e.length;const i=()=>{0==--this._pendingLoading&&this._onAllIconsLoaded.fire()};e.forEach((e=>{const n=this._icons.get(e.name)||new Map;n.set(e.theme,new T(e.imageData,t,i)),this._icons.set(e.name,n)}))}getIcon(e,t){return(0,n.ensureDefined)((0,n.ensureDefined)(this._icons.get(e)).get(t))}onAllIconsReady(){return this._onAllIconsLoaded}}([{name:"angle",theme:"dark", -imageData:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHZpZXdCb3g9IjAgMCAxOCAxOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0zLjQ5OTk5IDE1SDIuNjU3NzFMMy4wNjEwNCAxNC4yNjA2TDkuMDYxMDQgMy4yNjA1N0w5LjMwMDQ2IDIuODIxNjJMMTAuMTc4NCAzLjMwMDQ4TDkuOTM4OTMgMy43Mzk0Mkw3LjUxMzg1IDguMTg1NDJDMTAuNTYyMSA5LjY3MjA1IDEwLjk0NTEgMTIuNjI2MSAxMC45OTMxIDE0SDE0LjVIMTVWMTVIMTQuNUgzLjQ5OTk5Wk05Ljk5MTk3IDE0QzkuOTQyMzYgMTIuNzI1OSA5LjU4NjI5IDEwLjI4OCA3LjAzNDM1IDkuMDY0NDlMNC4zNDIyNiAxNEg5Ljk5MTk3WiIgZmlsbD0iI0Y4RjlGRCIvPgo8L3N2Zz4K"},{name:"angle",theme:"light",imageData:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHZpZXdCb3g9IjAgMCAxOCAxOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNMy40OTk5OSAxNUgyLjY1NzcxTDMuMDYxMDQgMTQuMjYwNkw5LjA2MTA0IDMuMjYwNTdMOS4zMDA0NiAyLjgyMTYyTDEwLjE3ODQgMy4zMDA0OEw5LjkzODkzIDMuNzM5NDJMNy41MTM4NSA4LjE4NTQyQzEwLjU2MjEgOS42NzIwNSAxMC45NDUxIDEyLjYyNjEgMTAuOTkzMSAxNEgxNC41SDE1VjE1SDE0LjVIMy40OTk5OVpNOS45OTE5NyAxNEM5Ljk0MjM2IDEyLjcyNTkgOS41ODYyOSAxMC4yODggNy4wMzQzNSA5LjA2NDQ5TDQuMzQyMjYgMTRIOS45OTE5N1oiIGZpbGw9IiMyQTJFMzkiLz4NCjwvc3ZnPg0K"},{name:"barsRange",theme:"dark",imageData:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHZpZXdCb3g9IjAgMCAxOCAxOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNMiAzVjMuNVY1SDFWNlYxM1YxNEgyVjE1LjVWMTZIM1YxNS41VjE0SDRWMTNWNlY1SDNWMy41VjNIMlpNOC4yMDcxMSA3LjVMNy44NTM1NSA3Ljg1MzU1TDYuNzA3MTEgOUgxMS4yOTI5TDEwLjE0NjQgNy44NTM1NUw5Ljc5Mjg5IDcuNUwxMC41IDYuNzkyODlMMTAuODUzNiA3LjE0NjQ1TDEyLjg1MzYgOS4xNDY0NUwxMy4yMDcxIDkuNUwxMi44NTM2IDkuODUzNTVMMTAuODUzNiAxMS44NTM2TDEwLjUgMTIuMjA3MUw5Ljc5Mjg5IDExLjVMMTAuMTQ2NCAxMS4xNDY0TDExLjI5MjkgMTBINi43MDcxMUw3Ljg1MzU1IDExLjE0NjRMOC4yMDcxMSAxMS41TDcuNSAxMi4yMDcxTDcuMTQ2NDUgMTEuODUzNkw1LjE0NjQ1IDkuODUzNTVMNC43OTI4OSA5LjVMNS4xNDY0NSA5LjE0NjQ1TDcuMTQ2NDUgNy4xNDY0NUw3LjUgNi43OTI4OUw4LjIwNzExIDcuNVpNMyA2SDJWMTNIM1Y2Wk0xNSAzLjVWM0gxNlYzLjVWNUgxN1Y2VjEzVjE0SDE2VjE1LjVWMTZIMTVWMTUuNVYxNEgxNFYxM1Y2VjVIMTVWMy41Wk0xNSA2SDE2VjEzSDE1VjZaIiBmaWxsPSIjRjhGOUZEIi8+DQo8L3N2Zz4NCg=="},{name:"barsRange",theme:"light", +v||"bottom"!==x||(e.lineTo(m+y,R+_),e.lineTo(m,R+_+y),e.lineTo(m-y,R+_)),e.lineTo(w,R+_),e.closePath(),e.fill(),e.stroke(),e.textBaseline="middle",e.fillStyle=i.textColor,e.textAlign=(0,c.isRtl)()?"right":"left";const T=(0,u.calcTextHorizontalShift)(e,s),b=g+i.tooltipPadding+T;let P=f+i.tooltipPadding+i.fontSize/2;(0,u.drawScaled)(e,t.pixelRatio,t.pixelRatio,(()=>{for(let t=0;t{"use strict";function n(e,t,i){const n=t-i;if("percentage"===e.getLineLengthUnit()){const r=Math.max(e.getLineLength()/100*t,1),s=Math.round(t-Math.min(n,r));return{right:s,left:s-i}}const r=e.getLineLength();if(r<0){const e=Math.round(Math.min(n,-1*r));return{left:e,right:e+i}}{const e=Math.round(t-Math.min(n,r));return{right:e,left:e-i}}}i.d(t,{orderLineLocation:()=>n})},61144:(e,t,i)=>{"use strict";i.r(t),i.d(t,{OrderPaneView:()=>x});var n=i(86441),r=i(79191),s=i(19266),o=i(44352),a=i(82161),l=i(68441),d=i(15187),h=i(18807),c=i(53180),u=i(47043),p=i(14002);const _=o.t(null,void 0,i(33241)),g=o.t(null,void 0,i(16075));class f extends d.MediaCoordinatesPaneRenderer{constructor(e){super(),this._data=null,this._cache={},this._data=null,this._adapter=e}setData(e){this._data=e}hitTest(e,t){if(null===this._data||0===this._data.points.length)return null;const i=this._cache;if(e.yi.bottom)return null;if(this._adapter.getBlocked()&&e.x>=i.left&&e.x=i.left&&e.x=i.bodyRight&&e.x=i.quantityRight&&e.x0){const t=this._points[0].y,i=e-3.5-1,r=this._adapter.hasMoveCallback()?h.HitTarget.MovePoint:h.HitTarget.Regular,s=[new n.Point(i,t)];this._selectionData={barSpacing:this._model.timeScale().barSpacing(),points:s,bgColors:this._lineAnchorColors(s),hittestResult:r,visible:!0}}this._orderRenderer.setData({points:this._points}),this._selectionRenderer.setData(this._selectionData)}}},26013:(e,t,i)=>{"use strict";i.r(t),i.d(t,{ParallelChannelPaneView:()=>d});var n=i(86441),r=i(66103),s=i(19266),o=i(28621),a=i(33295);const l=[r.PaneCursorType.Default,r.PaneCursorType.Default,r.PaneCursorType.Default,r.PaneCursorType.Default,r.PaneCursorType.VerticalResize,r.PaneCursorType.VerticalResize];class d extends a.AlertableLineSourcePaneView{constructor(){super(...arguments),this._channelRenderer=new o.ParallelChannelRenderer,this._renderer=null}renderer(e,t){ +return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){super._updateImpl(),this._renderer=null;const e=this._source.priceScale();if(!e||e.isEmpty())return;if(0===this._source.points().length)return;let t=null,i=null;if(3===this._points.length){const e=this._points[0],r=this._points[1],s=this._points[2].y-this._points[0].y;t=e.add((0,n.point)(0,s)),i=r.add((0,n.point)(0,s))}if(this._points.length<=1)return;const r=this._source.properties(),o={points:this._points.length>2&&null!==t&&null!==i?[this._points[0],this._points[1],t,i]:[this._points[0],this._points[1]],color:r.childs().linecolor.value(),linewidth:r.childs().linewidth.value(),linestyle:r.childs().linestyle.value(),extendleft:r.childs().extendLeft.value(),extendright:r.childs().extendRight.value(),fillBackground:r.childs().fillBackground.value(),backcolor:r.childs().backgroundColor.value(),transparency:r.childs().transparency.value(),showMidline:r.childs().showMidline.value(),midlinewidth:r.childs().midlinewidth.value(),midlinestyle:r.childs().midlinestyle.value(),midcolor:r.childs().midlinecolor.value(),hittestOnBackground:!0};this._channelRenderer.setData(o);const a=new s.CompositeRenderer;a.append(this._channelRenderer);const d=[];if(this._points[0]&&d.push(this._points[0]),this._points[1]&&d.push(this._points[1]),t&&i){const e=t;e.data=2,d.push(e);const n=i;n.data=3,d.push(n);const r=t.add(i).scaled(.5);r.data=4,r.square=!0,d.push(r);const s=d[0].add(d[1]).scaled(.5);s.data=5,s.square=!0,d.push(s)}const h=3===this._points.length&&!t;if(this._model.lineBeingCreated()!==this._source||h||(d.pop(),d.pop()),a.append(this.createLineAnchor({points:d,pointsCursorType:l},0)),this._points.length>=2){const e=this._points;this._addAlertRenderer(a,[e[0],e[1]])}this._renderer=a}}},62801:(e,t,i)=>{"use strict";i.r(t),i.d(t,{PathPaneView:()=>o});var n=i(79797),r=i(19266),s=i(79191);class o extends s.LineSourcePaneView{constructor(e,t){super(e,t),this._polygonRenderer=new n.PolygonRenderer,this._renderer=new r.CompositeRenderer}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){super._updateImpl(),this._renderer.clear();const e=this._source.properties().childs(),t={points:this._points,color:e.lineColor.value(),linewidth:e.lineWidth.value(),linestyle:e.lineStyle.value(),leftend:e.leftEnd.value(),rightend:e.rightEnd.value(),filled:!1,backcolor:"",fillBackground:!1,transparency:0};this._polygonRenderer.setData(t),this._renderer.append(this._polygonRenderer),this.addAnchors(this._renderer)}}},87202:(e,t,i)=>{"use strict";i.r(t),i.d(t,{PitchfanLinePaneView:()=>d});var n=i(18807),r=i(14146),s=i(19266),o=i(73436),a=i(99031),l=i(79191);class d extends l.LineSourcePaneView{constructor(){super(...arguments),this._medianRenderer=new a.TrendLineRenderer,this._sideRenderer=new a.TrendLineRenderer,this._renderer=null,this._medianPoint=null}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){if(super._updateImpl(),this._renderer=null,0===this._points.length)return +;if(3===this._points.length?(this._medianPoint=this._points[1].add(this._points[2]).scaled(.5),this._medianPoint.data=3):2===this._points.length?(this._medianPoint=this._points[1].clone(),this._medianPoint.data=3):(this._medianPoint=this._points[0].clone(),this._medianPoint.data=3),this._points.length<2)return;if(!this._medianPoint)return;const e=new s.CompositeRenderer,t=this._source.properties().childs(),i=t.median.childs(),l={points:[this._points[0],this._medianPoint],color:i.color.value(),linewidth:i.linewidth.value(),linestyle:i.linestyle.value(),extendleft:!1,extendright:!0,leftend:o.LineEnd.Normal,rightend:o.LineEnd.Normal};if(this._medianRenderer.setData(l),e.append(this._medianRenderer),this._points.length<3)return this.addAnchors(e),void(this._renderer=e);const d={points:[this._points[1],this._points[2]],color:i.color.value(),linewidth:i.linewidth.value(),linestyle:i.linestyle.value(),extendleft:!1,extendright:!1,leftend:o.LineEnd.Normal,rightend:o.LineEnd.Normal};this._sideRenderer.setData(d),e.append(this._sideRenderer);let h=0;const c=this._points[2].subtract(this._points[1]).scaled(.5),u=t.fillBackground.value(),p=t.transparency.value();for(let t=0;t<=8;t++){const i="level"+t,s=this._source.properties().child(i);if(s.childs().visible.value()){const i=this._medianPoint.addScaled(c,s.childs().coeff.value()),l=this._medianPoint.addScaled(c,-s.childs().coeff.value());if(u){{const t={p1:this._points[0],p2:i,p3:this._points[0],p4:this._medianPoint.addScaled(c,h),color:s.childs().color.value(),transparency:p,hittestOnBackground:!0,extendLeft:!1},n=new r.ChannelRenderer;n.setData(t),e.append(n)}{const t={p1:this._points[0],p2:l,p3:this._points[0],p4:this._medianPoint.addScaled(c,-h),color:s.childs().color.value(),transparency:p,hittestOnBackground:!0,extendLeft:!1},i=new r.ChannelRenderer;i.setData(t),e.append(i)}}h=s.childs().coeff.value();{const r={points:[this._points[0],i],color:s.childs().color.value(),linewidth:s.childs().linewidth.value(),linestyle:s.childs().linestyle.value(),extendleft:!1,extendright:!0,leftend:o.LineEnd.Normal,rightend:o.LineEnd.Normal},l=new a.TrendLineRenderer;l.setData(r),l.setHitTest(new n.HitTestResult(n.HitTarget.MovePoint,void 0,t)),e.append(l)}{const i={points:[this._points[0],l],color:s.childs().color.value(),linewidth:s.childs().linewidth.value(),linestyle:s.childs().linestyle.value(),extendleft:!1,extendright:!0,leftend:o.LineEnd.Normal,rightend:o.LineEnd.Normal},r=new a.TrendLineRenderer;r.setData(i),r.setHitTest(new n.HitTestResult(n.HitTarget.MovePoint,void 0,t)),e.append(r)}}}this.addAnchors(e),this._renderer=e}}},95337:(e,t,i)=>{"use strict";i.r(t),i.d(t,{InsidePitchforkLinePaneView:()=>p,PitchforkLinePaneView:()=>h,SchiffPitchfork2LinePaneView:()=>u,SchiffPitchforkLinePaneView:()=>c});var n=i(86441),r=i(18807),s=i(14146),o=i(19266),a=i(73436),l=i(99031),d=i(79191);class h extends d.LineSourcePaneView{constructor(){super(...arguments),this._medianRenderer=new l.TrendLineRenderer,this._sideRenderer=new l.TrendLineRenderer,this._renderer=null,this._medianPoint=null} +renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){super._updateImpl(),this._renderer=null,0!==this._points.length&&(3===this._points.length?(this._medianPoint=this._points[1].add(this._points[2]).scaled(.5),this._medianPoint.data=3):2===this._points.length?(this._medianPoint=this._points[1].clone(),this._medianPoint.data=3):(this._medianPoint=this._points[0].clone(),this._medianPoint.data=3),this._updateRenderer())}_updateRenderer(){if(this._points.length<2)return;if(!this._medianPoint)return;const e=this._source.properties(),t=e.childs().median.childs(),i=new o.CompositeRenderer,n={points:[this._points[0],this._medianPoint],color:t.color.value(),linewidth:t.linewidth.value(),linestyle:t.linestyle.value(),extendleft:e.childs().extendLines.value(),extendright:!0,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal};if(this._medianRenderer.setData(n),i.append(this._medianRenderer),this._points.length<3)return this.addAnchors(i),void(this._renderer=i);const d={points:[this._points[1],this._points[2]],color:t.color.value(),linewidth:t.linewidth.value(),linestyle:t.linestyle.value(),extendleft:!1,extendright:!1,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal};this._sideRenderer.setData(d),i.append(this._sideRenderer);const h=this._points[2].subtract(this._points[1]).scaled(.5),c=this._medianPoint.subtract(this._points[0]);let u=0;const p=e.childs().fillBackground.value(),_=e.childs().transparency.value();for(let t=0;t<=8;t++){const n="level"+t,o=e.childs()[n];if(o.childs().visible.value()){const n=this._medianPoint.addScaled(h,o.childs().coeff.value()),d=n.add(c),g=this._medianPoint.addScaled(h,-o.childs().coeff.value()),f=g.add(c);if(p){{const t=this._medianPoint.addScaled(h,u),r={p1:n,p2:d,p3:t,p4:t.add(c),color:o.childs().color.value(),transparency:_,hittestOnBackground:!0,extendLeft:e.childs().extendLines.value()},a=new s.ChannelRenderer;a.setData(r),i.append(a)}{const t=this._medianPoint.addScaled(h,-u),n={p1:g,p2:f,p3:t,p4:t.add(c),color:o.childs().color.value(),transparency:_,hittestOnBackground:!0,extendLeft:e.childs().extendLines.value()},r=new s.ChannelRenderer;r.setData(n),i.append(r)}}u=o.childs().coeff.value();const v={points:[n,d],color:o.childs().color.value(),linewidth:o.childs().linewidth.value(),linestyle:o.childs().linestyle.value(),extendleft:e.childs().extendLines.value(),extendright:!0,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal},x=new l.TrendLineRenderer;x.setData(v),x.setHitTest(new r.HitTestResult(r.HitTarget.MovePoint,void 0,t)),i.append(x);const m={points:[g,f],color:o.childs().color.value(),linewidth:o.childs().linewidth.value(),linestyle:o.childs().linestyle.value(),extendleft:e.childs().extendLines.value(),extendright:!0,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal},w=new l.TrendLineRenderer;w.setData(m),w.setHitTest(new r.HitTestResult(r.HitTarget.MovePoint,void 0,t)),i.append(w)}}this.addAnchors(i),this._renderer=i}}class c extends h{constructor(){super(...arguments),this._modifiedBase=null,this._backSideRenderer=new l.TrendLineRenderer} +renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateRenderer(){if(this._points.length<2)return;this._calcMofifiedBase();const e=this._source.properties(),t=new o.CompositeRenderer,i=e.childs().median.childs();{const e={points:[this._points[0],this._points[1]],color:i.color.value(),linewidth:i.linewidth.value(),linestyle:i.linestyle.value(),extendleft:!1,extendright:!1,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal};if(this._backSideRenderer.setData(e),t.append(this._backSideRenderer),!this._medianPoint||!this._modifiedBase)return this.addAnchors(t),void(this._renderer=t)}{const n={points:[this._modifiedBase,this._medianPoint],color:i.color.value(),linewidth:i.linewidth.value(),linestyle:i.linestyle.value(),extendleft:e.childs().extendLines.value(),extendright:!0,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal};if(this._medianRenderer.setData(n),t.append(this._medianRenderer),this._points.length<3)return this.addAnchors(t),void(this._renderer=t)}{const e={points:[this._points[1],this._points[2]],color:i.color.value(),linewidth:i.linewidth.value(),linestyle:i.linestyle.value(),extendleft:!1,extendright:!1,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal};this._sideRenderer.setData(e),t.append(this._sideRenderer)}{const i=this._points[2].subtract(this._points[1]).scaled(.5),n=this._medianPoint.subtract(this._modifiedBase);let o=0;const d=e.childs().fillBackground.value(),h=e.childs().transparency.value();for(let c=0;c<=8;c++){const u="level"+c,p=e.child(u);if(p.childs().visible.value()){const u=this._medianPoint.addScaled(i,p.childs().coeff.value()),_=u.add(n),g=this._medianPoint.addScaled(i,-p.childs().coeff.value()),f=g.add(n);if(d){const r=this._medianPoint.addScaled(i,o);{const i={p1:u,p2:_,p3:r,p4:r.add(n),color:p.childs().color.value(),transparency:h,hittestOnBackground:!0,extendLeft:e.childs().extendLines.value()},o=new s.ChannelRenderer;o.setData(i),t.append(o)}{const r=this._medianPoint.addScaled(i,-o),a={p1:g,p2:f,p3:r,p4:r.add(n),color:p.childs().color.value(),transparency:h,hittestOnBackground:!0,extendLeft:e.childs().extendLines.value()},l=new s.ChannelRenderer;l.setData(a),t.append(l)}}o=p.childs().coeff.value();const v={points:[u,_],color:p.childs().color.value(),linewidth:p.childs().linewidth.value(),linestyle:p.childs().linestyle.value(),extendleft:e.childs().extendLines.value(),extendright:!0,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal},x=new l.TrendLineRenderer;x.setData(v),x.setHitTest(new r.HitTestResult(r.HitTarget.MovePoint,void 0,c)),t.append(x);const m={points:[g,f],color:p.childs().color.value(),linewidth:p.childs().linewidth.value(),linestyle:p.childs().linestyle.value(),extendleft:e.childs().extendLines.value(),extendright:!0,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal},w=new l.TrendLineRenderer;w.setData(m),w.setHitTest(new r.HitTestResult(r.HitTarget.MovePoint,void 0,c)),t.append(w)}}}this.addAnchors(t),this._renderer=t}_calcMofifiedBase(){this._points.length>1&&(this._modifiedBase=this._points[0].add(this._points[1]).scaled(.5))}} +class u extends c{_calcMofifiedBase(){if(this._points.length>2){const e=this._points[0].x,t=.5*(this._points[0].y+this._points[1].y),i=new n.Point(e,t);this._modifiedBase=i}}}class p extends h{constructor(){super(...arguments),this._backSideRenderer=new l.TrendLineRenderer,this._centerRenderer=new l.TrendLineRenderer,this._modifiedBase=null}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateRenderer(){if(this._points.length>1&&(this._modifiedBase=this._points[0].add(this._points[1]).scaled(.5)),this._points.length<2)return;const e=new o.CompositeRenderer;if(!this._medianPoint||!this._modifiedBase)return void this.addAnchors(e);const t=this._source.properties(),i=t.childs().median.childs();if(3===this._points.length){const t={points:[this._modifiedBase,this._points[2]],color:i.color.value(),linewidth:i.linewidth.value(),linestyle:i.linestyle.value(),extendleft:!1,extendright:!1,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal};this._medianRenderer.setData(t),e.append(this._medianRenderer)}{const t={points:[this._points[0],this._points[1]],color:i.color.value(),linewidth:i.linewidth.value(),linestyle:i.linestyle.value(),extendleft:!1,extendright:!1,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal};if(this._backSideRenderer.setData(t),e.append(this._backSideRenderer),this._points.length<3)return this.addAnchors(e),void(this._renderer=e)}{const t={points:[this._points[1],this._points[2]],color:i.color.value(),linewidth:i.linewidth.value(),linestyle:i.linestyle.value(),extendleft:!1,extendright:!1,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal};this._sideRenderer.setData(t),e.append(this._sideRenderer)}{const n=this._points[2].subtract(this._points[1]).scaled(.5),o=this._points[2].subtract(this._modifiedBase);let d=0;const h=t.childs().fillBackground.value(),c=t.childs().transparency.value(),u={points:[this._medianPoint,this._medianPoint.add(o)],color:i.color.value(),linewidth:i.linewidth.value(),linestyle:i.linestyle.value(),extendleft:t.childs().extendLines.value(),extendright:!0,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal};this._centerRenderer.setData(u),e.append(this._centerRenderer);for(let i=0;i<=8;i++){const u="level"+i,p=t.child(u).childs();if(p.visible.value()){const u=this._medianPoint.addScaled(n,p.coeff.value()),_=u.add(o),g=this._medianPoint.addScaled(n,-p.coeff.value()),f=g.add(o);if(h){{const i=this._medianPoint.addScaled(n,d),r={p1:u,p2:_,p3:i,p4:i.add(o),color:p.color.value(),transparency:c,hittestOnBackground:!0,extendLeft:t.childs().extendLines.value()},a=new s.ChannelRenderer;a.setData(r),e.append(a)}{const i=this._medianPoint.addScaled(n,-d),r={p1:g,p2:f,p3:i,p4:i.add(o),color:p.color.value(),transparency:c,hittestOnBackground:!0,extendLeft:t.childs().extendLines.value()},a=new s.ChannelRenderer;a.setData(r),e.append(a)}}d=p.coeff.value();const v={points:[u,_],color:p.color.value(),linewidth:p.linewidth.value(),linestyle:p.linestyle.value(),extendleft:t.childs().extendLines.value(),extendright:!0,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal +},x=new l.TrendLineRenderer;x.setData(v),x.setHitTest(new r.HitTestResult(r.HitTarget.MovePoint,void 0,i)),e.append(x);const m={points:[g,f],color:p.color.value(),linewidth:p.linewidth.value(),linestyle:p.linestyle.value(),extendleft:t.childs().extendLines.value(),extendright:!0,leftend:a.LineEnd.Normal,rightend:a.LineEnd.Normal},w=new l.TrendLineRenderer;w.setData(m),w.setHitTest(new r.HitTestResult(r.HitTarget.MovePoint,void 0,i)),e.append(w)}}}this.addAnchors(e),this._renderer=e}}},50253:(e,t,i)=>{"use strict";i.r(t),i.d(t,{PolylinePaneView:()=>o});var n=i(79797),r=i(19266),s=i(79191);class o extends s.LineSourcePaneView{constructor(e,t){super(e,t),this._polygonRenderer=new n.PolygonRenderer,this._renderer=new r.CompositeRenderer}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){super._updateImpl(),this._renderer.clear();const e=this._source.properties().childs(),t={points:this._points,color:e.linecolor.value(),linewidth:e.linewidth.value(),linestyle:e.linestyle.value(),filled:e.filled.value(),backcolor:e.backgroundColor.value(),fillBackground:e.fillBackground.value(),transparency:e.transparency.value()};this._polygonRenderer.setData(t),this._renderer.append(this._polygonRenderer),this.addAnchors(this._renderer)}}},46258:(e,t,i)=>{"use strict";var n=i(79191).LineSourcePaneView,r=i(47043),s=i(18807).HitTestResult,o=i(18807).HitTarget,a=i(82161).splitThousands,l=i(38223),d=i(53180).appendEllipsis,h=i(15187).MediaCoordinatesPaneRenderer,c=i(14002).orderLineLocation;const{setLineStyle:u,drawLine:p,drawPoly:_}=i(68441),{LINESTYLE_SOLID:g}=i(79849);class f extends h{constructor(e,t){super(),this._data=null,this._cache=e,this._adapter=t}setData(e){this._data=e}_height(){return Math.max(20,1+Math.max(r.fontHeight(this._adapter.getBodyFont()),r.fontHeight(this._adapter.getQuantityFont())))}_bodyWidth(e){if(0===this._adapter.getText().length)return 0;e.save(),e.font=this._adapter.getBodyFont();var t=e.measureText(this._adapter.getText()).width;return e.restore(),Math.round(10+t)}_getQuantity(){var e=this._adapter.getQuantity();return isNaN(e)?e:a(this._adapter.getQuantity()," ")}_quantityWidth(e){if(0===this._getQuantity().length)return 0;e.save(),e.font=this._adapter.getQuantityFont();var t=e.measureText(this._getQuantity()).width;return e.restore(),Math.round(Math.max(this._height(),10+t))}_reverseButtonWidth(){return this._adapter.isOnReverseCallbackPresent()?this._height():0}_closeButtonWidth(){return this._adapter.isOnCloseCallbackPresent()?this._height():0}_drawLines(e,t,i,n,r){e.save(),e.strokeStyle=this._adapter.getLineColor(),u(e,this._adapter.getLineStyle()),e.lineWidth=this._adapter.getLineWidth(),p(e,i,n,r,n),this._adapter.getExtendLeft()&&p(e,0,n,t,n),e.restore()}_drawBody(e,t,i){e.strokeStyle=this._adapter.getBodyBorderColor(),e.fillStyle=this._adapter.getBodyBackgroundColor();var n=this._bodyWidth(e),r=this._height();e.fillRect(t+.5,i+.5,n-1,r-1),e.strokeRect(t,i,n,r)}_drawBodyText(e,t,i){e.save(),e.textAlign="center",e.textBaseline="middle", +e.font=this._adapter.getBodyFont(),e.fillStyle=this._adapter.getBodyTextColor();var n=t+this._bodyWidth(e)/2,r=i+this._height()/2;e.fillText(this._adapter.getText(),n,r),e.restore()}_drawQuantity(e,t,i){e.strokeStyle=this._adapter.getQuantityBorderColor(),e.fillStyle=this._adapter.getQuantityBackgroundColor();var n=this._quantityWidth(e),r=this._height();e.fillRect(t+.5,i+.5,n-1,r-1),e.strokeRect(t,i,n,r)}_drawQuantityText(e,t,i){e.save(),e.textAlign="center",e.textBaseline="middle",e.font=this._adapter.getQuantityFont(),e.fillStyle=this._adapter.getQuantityTextColor();var n=t+this._quantityWidth(e)/2,r=i+this._height()/2;e.fillText(l.startWithLTR(this._getQuantity()+""),n,r),e.restore()}_drawReverseButton(e,t,i){e.save(),e.strokeStyle=this._adapter.getReverseButtonBorderColor(),e.fillStyle=this._adapter.getReverseButtonBackgroundColor();var n=this._reverseButtonWidth(),r=this._height();e.fillRect(t+.5,i+.5,n-1,r-1),e.strokeRect(t,i,n,r),e.strokeStyle=this._adapter.getReverseButtonIconColor();var s=function(e,t){u(e,g),p(e,0,0,0,t),p(e,-1,1,1,1),p(e,-2,2,2,2)},o=t+Math.round((this._reverseButtonWidth()-6)/2),a=i+5;e.save(),e.translate(o,a),s(e,10),e.translate(6,10),e.rotate(Math.PI),s(e,10),e.restore(),this._adapter._blocked&&(e.fillStyle="rgba(140, 140, 140, 0.75)",e.fillRect(t+.5,i+.5,n-1,r-1)),e.restore()}_drawCloseButton(e,t,i){e.save(),e.strokeStyle=this._adapter.getCloseButtonBorderColor(),e.fillStyle=this._adapter.getCloseButtonBackgroundColor();var n=this._closeButtonWidth(),r=this._height();e.fillRect(t+.5,i+.5,n-1,r-1),e.strokeRect(t,i,n,r);var s=t+n,o=i+r;e.strokeStyle=this._adapter.getCloseButtonIconColor();var a=(this._closeButtonWidth()-8)/2,l=(this._height()-8)/2;_(e,[{x:t+a,y:i+l},{x:s-a,y:o-l}],!0),_(e,[{x:s-a,y:i+l},{x:t+a,y:o-l}],!0),this._adapter._blocked&&(e.fillStyle="rgba(140, 140, 140, 0.75)",e.fillRect(t+.5,i+.5,n-1,r-1)),e.restore()}_drawImpl(e){if(null===this._data||!this._data.points||this._data.points.length<1)return;var t=e.context,i=this._data.width,n=this._bodyWidth(t),r=this._quantityWidth(t),s=this._reverseButtonWidth(t),o=n+r+s+this._closeButtonWidth();const{left:a,right:l}=c(this._adapter,i,o);var d=Math.round(this._data.points[0].y),h=Math.round(d-(this._height()+1)/2);this._cache.bodyRight=a+n,this._cache.quantityRight=this._cache.bodyRight+r,this._cache.reverseButtonRight=this._cache.quantityRight+s,this._cache.top=h,this._cache.bottom=h+this._height(),this._cache.left=a,this._cache.right=l,this._drawLines(t,a,l,d,i),0!==n&&(this._drawBody(t,a,h),this._drawBodyText(t,a,h)),0!==r&&(this._drawQuantity(t,this._cache.bodyRight,h),this._drawQuantityText(t,this._cache.bodyRight,h)),0!==s&&this._drawReverseButton(t,this._cache.quantityRight,h),0!==this._closeButtonWidth()&&this._drawCloseButton(t,this._cache.reverseButtonRight,h)}hitTest(e){ +return null===this._data||0===this._data.points.length||e.ythis._cache.bottom||e.x=this._cache.bodyRight&&e.x=this._cache.quantityRight&&e.x=this._cache.reverseButtonRight&&e.x{"use strict";var n=i(86441).Point,r=i(79191).LineSourcePaneView,s=i(36274).Interval,o=i(18807).HitTestResult,a=i(18807).HitTarget,l=i(19266).CompositeRenderer,d=i(12767).getImage,h=i(37160),c=i(93572).PercentageFormatter,u=i(53741).DateFormatter,p=i(79206).TimeFormatter,_=i(79206).hourMinuteFormat,g=i(79206).hourMinuteSecondFormat,f=i(2043).TimeSpanFormatter,v=i(87095),x=i(21316),m=i(74359).calcTextHorizontalShift,w=i(38223).isRtl,R=i(68441).drawRoundRect,y=i(29764).makeFont,T=i(15187).MediaCoordinatesPaneRenderer,b=i(38223),P=b.forceLTRStr,L=b.startWithLTR,S=i(46501).CHART_FONT_FAMILY;class C extends T{constructor(){super(),this._data=null,this._font=S,this._targetFontSize1=14,this._targetFontSize2=11,this._sourceFontSize1=12,this._sourceFontSize2=10,this._arrowOffset=6,this._arrowWidth=5,this._arrowHeight=5,this._radius=3,this._sourceWidth=void 0,this._sourceHeight=void 0,this._sourceRectLeftOffset=void 0,this._targetWidth=void 0,this._targetHeight=void 0,this._targetRectLeftOffset=void 0}setData(e){ +this._data=e}drawBalloon(e,t,i,r,s,o){var a=o||20;if(e.beginPath(),"down"===s){var l=new n(t.x-a,t.y-this._arrowOffset-this._arrowHeight-r);return e.moveTo(l.x+this._radius,l.y),e.lineTo(l.x+i-this._radius,l.y),e.arcTo(l.x+i,l.y,l.x+i,l.y+this._radius,this._radius),e.lineTo(l.x+i,l.y+r-this._radius),e.arcTo(l.x+i,l.y+r,l.x+i-this._radius,l.y+r,this._radius),e.lineTo(l.x+a+this._arrowWidth,l.y+r),e.lineTo(l.x+a,l.y+r+this._arrowHeight),e.lineTo(l.x+a-this._arrowWidth,l.y+r),e.lineTo(l.x+this._radius,l.y+r),e.arcTo(l.x,l.y+r,l.x,l.y+r-this._radius,this._radius),e.lineTo(l.x,l.y+this._radius),e.arcTo(l.x,l.y,l.x+this._radius,l.y,this._radius),l}var d=new n(t.x-a,t.y+this._arrowOffset+this._arrowHeight+r);return e.moveTo(d.x+this._radius,d.y),e.lineTo(d.x+i-this._radius,d.y),e.arcTo(d.x+i,d.y,d.x+i,d.y-this._radius,this._radius),e.lineTo(d.x+i,d.y-r+this._radius),e.arcTo(d.x+i,d.y-r,d.x+i-this._radius,d.y-r,this._radius),e.lineTo(d.x+a+this._arrowWidth,d.y-r),e.lineTo(d.x+a,d.y-r-this._arrowHeight),e.lineTo(d.x+a-this._arrowWidth,d.y-r),e.lineTo(d.x+this._radius,d.y-r),e.arcTo(d.x,d.y-r,d.x,d.y-r+this._radius,this._radius),e.lineTo(d.x,d.y-this._radius),e.arcTo(d.x,d.y,d.x+this._radius,d.y,this._radius),new n(d.x,d.y-r)}drawTargetLabel(e){e.save(),e.translate(.5,.5);var t=y(this._targetFontSize1,this._font,"normal"),n=y(this._targetFontSize2,this._font,"normal"),r=this._data.targetLine1,s=this._data.targetLine2,o=this._data.targetLine3,a=this._data.targetLine4;e.font=t;var l=e.measureText(r).width,d=e.measureText(s).width,h=e.measureText(" ").width;e.font=n;var c=e.measureText(o).width,u=e.measureText(a).width,p=e.measureText(" ").width,_=this._data.clockWhite&&this._data.clockWhite.width||0;this._targetWidth=Math.max(l+d+h,c+u+_+2*p)+8+4,this._targetHeight=this._targetFontSize1+this._targetFontSize2+9+4;var g=this._data.points[1],f=g.x+this._targetWidth-e.canvas.width+5;this._targetRectLeftOffset=Math.max(20,Math.min(this._targetWidth-15,f));var T="up"===this._data.direction?"down":"up",b=this.drawBalloon(e,g,this._targetWidth,this._targetHeight,T,this._targetRectLeftOffset);e.fillStyle=v.generateColor(this._data.targetBackColor,this._data.transparency),e.fill(),e.lineWidth=2,e.strokeStyle=v.generateColor(this._data.targetStrokeColor,this._data.transparency),e.stroke();e.beginPath(),e.arc(g.x,g.y,3,0,2*Math.PI,!1),e.fillStyle=this._data.centersColor,e.fill(),e.textBaseline="top",e.fillStyle=this._data.targetTextColor;var P=2+b.x+4,L=2+b.y+3,S=this._targetWidth-8-4;e.font=t,e.textAlign=w()?"right":"left";var C=m(e,S-d-h);e.fillText(r,P+C,L);var M=m(e,S-l);e.fillText(s,P+l+h+M,L),e.font=n;var I=L+this._targetFontSize1+3,A=m(e,S-u-_-p);e.fillText(o,P+A,I);var k=m(e,S-c-p-_-u);this._data.clockWhite&&e.drawImage(this._data.clockWhite,P+c+p+k,I+1);var N=m(e,S-c-_);if(e.fillText(a,P+c+_+2*p+N,I),this._data.status){var D,B,z,E;switch(e.font=y(this._targetFontSize1,this._font,"bold"),this._data.status){case x.AlertStatus.Success:D=i(44352).t(null,void 0,i(26787)), +B=v.generateColor(this._data.successBackground,this._data.transparency),z=this._data.successTextColor,E=this._data.successIcon;break;case x.AlertStatus.Failure:D=i(44352).t(null,void 0,i(968)),B=v.generateColor(this._data.failureBackground,this._data.transparency),z=this._data.failureTextColor,E=this._data.failureIcon}var H=this._targetFontSize1+4,O=e.measureText(D).width,V=Math.round((this._targetWidth-O)/2),W=m(e,O);e.fillStyle=B,"up"===this._data.direction?(R(e,b.x-1,b.y-H-2,this._targetWidth+2,H,5),e.fill(),e.fillStyle=z,e.fillText(D,b.x+V+W,b.y-H+1),E&&e.drawImage(E,b.x+V-E.width-4,b.y-H-2+Math.abs(H-E.height)/2)):(R(e,b.x-1,b.y+this._targetHeight+2,this._targetWidth+2,H,5),e.fill(),e.fillStyle=z,e.fillText(D,b.x+V+W,b.y+this._targetHeight+5),E&&e.drawImage(E,b.x+V-E.width-4,b.y+this._targetHeight+10-Math.abs(H-E.height)/2)),e.restore()}else e.restore()}drawStartLabel(e){e.save(),e.translate(.5,.5);var t=y(this._sourceFontSize1,this._font,"normal"),i=y(this._sourceFontSize2,this._font,"normal");e.font=t;var n=e.measureText(this._data.sourceLine1).width;e.font=i;var r=e.measureText(this._data.sourceLine2).width;this._sourceWidth=Math.max(n,r)+6+4,this._sourceHeight=this._sourceFontSize1+this._sourceFontSize2+6+4;var s=this._data.points[0],o=s.x+this._sourceWidth-e.canvas.width+5;this._sourceRectLeftOffset=Math.max(20,Math.min(this._sourceWidth-15,o));var a=this.drawBalloon(e,s,this._sourceWidth,this._sourceHeight,this._data.direction,this._sourceRectLeftOffset);e.fillStyle=v.generateColor(this._data.sourceBackColor,this._data.transparency),e.fill(),e.lineWidth=2,e.strokeStyle=v.generateColor(this._data.sourceStrokeColor,this._data.transparency),e.stroke(),e.textAlign=w()?"right":"left",e.textBaseline="top",e.fillStyle=this._data.sourceTextColor;var l=m(e,this._sourceWidth-6-4),d=2+a.x+3+l,h=2+a.y+2;e.font=t,e.fillText(this._data.sourceLine1,d,h),e.font=i,e.fillText(this._data.sourceLine2,d,h+this._sourceFontSize1+2);e.beginPath(),e.arc(s.x,s.y,3,0,2*Math.PI,!1),e.fillStyle=this._data.centersColor,e.fill(),e.restore()}_drawImpl(e){if(!(null===this._data||this._data.points.length<2)){var t=e.context;t.lineCap="butt",t.strokeStyle=this._data.color,t.lineWidth=this._data.linewidth,t.lineStyle=this._data.linestyle;var i=this._data.points[0],n=this._data.points[1],r=n.subtract(i);Math.abs(r.x)<1||Math.abs(r.y)<1?(t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(n.x,n.y),t.stroke()):(t.save(),t.beginPath(),t.translate(i.x,i.y),t.scale(1,r.y/r.x),t.moveTo(0,0),t.arcTo(r.x,0,r.x,r.x,Math.abs(r.x)),t.lineTo(r.x,r.x),t.restore(),t.stroke()),this.drawTargetLabel(t),this.drawStartLabel(t);var s=Math.max(8,4*this._data.linewidth);t.fillStyle=this._data.color;var o=r.y<0?1:-1;if(Math.abs(r.x)<1||Math.abs(r.y)<1)var a=Math.atan(r.x/r.y);else{var l,d,h=Math.abs(r.x),c=Math.abs(r.y),u=0,p=Math.PI/2,_=(u+p)/2;if(r.length()>s)for(;;){l=h*Math.sin(_),d=c*(1-Math.cos(_));var g=Math.sqrt((l-h)*(l-h)+(d-c)*(d-c));if(Math.abs(g-s)<1)break;g>s?u=_:p=_,_=(u+p)/2}a=Math.atan((h-l)/(c-d)),r.x*r.y<0&&(a=-a)}t.save(),t.beginPath(), +t.translate(n.x,n.y),t.rotate(-a),t.moveTo(0,0),t.lineTo(-s/2,o*s),t.lineTo(s/2,o*s),t.lineTo(0,0),t.restore(),t.fill()}}targetLabelHitTest(e){if(void 0===this._targetWidth||void 0===this._targetHeight||void 0===this._targetRectLeftOffset)return null;var t=this._targetHeight+this._arrowHeight;this._data.status&&(t+=this._targetFontSize1+10);var i="up"===this._data.direction?-1:1,n=this._radius,r=this._data.points[1],s=r.x-this._targetRectLeftOffset,l=r.y+i*n,d=r.y+i*(t+n),h=Math.min(l,d),c=Math.max(l,d);return e.x>=s&&e.x<=s+this._targetWidth&&e.y>=h&&e.y<=c?new o(a.MovePoint):null}sourceLabelHitTest(e){if(void 0===this._sourceHeight||void 0===this._sourceWidth||void 0===this._sourceRectLeftOffset)return null;var t="up"===this._data.direction?1:-1,i=this._radius,n=this._data.points[0],r=n.x-this._sourceRectLeftOffset,s=n.y+i*t,l=n.y+(i+this._sourceHeight+this._arrowHeight)*t,d=Math.min(s,l),h=Math.max(s,l);return e.x>=r&&e.x<=r+this._sourceWidth&&e.y>=d&&e.y<=h?new o(a.MovePoint):null}hitTest(e){if(null===this._data||this._data.points.length<2)return null;var t=this._data.points[0],i=this._data.points[1],n=i.subtract(t),r=(n=i.subtract(t),e.subtract(t)),s=Math.abs(n.x),l=Math.abs(n.y),d=h.sign(n.y)*(l-l*Math.sqrt(1-r.x*r.x/(s*s)));if(Math.abs(d-r.y)<3)return new o(a.MovePoint);var c=this.targetLabelHitTest(e);return c||this.sourceLabelHitTest(e)}}t.PredictionPaneView=class extends r{constructor(e,t){super(e,t),this._pendingIcons=3;var n=this;function r(){n._pendingIcons-=1,0===n._pendingIcons&&n._source.model().updateSource(n._source)}this._clockWhite=null,this._successIcon=null,this._failureIcon=null,d("prediction-clock-white",i(99620)).then((function(e){n._clockWhite=e,r()})),d("prediction-success-white",i(14012)).then((function(e){n._successIcon=e,r()})),d("prediction-failure-white",i(88249)).then((function(e){n._failureIcon=e,r()})),this._percentageFormatter=new c,this._predictionRenderer=new C,this._renderer=null}iconsReady(){return 0===this._pendingIcons}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){if((super._updateImpl(),this._renderer=null,this._targetLine1="",this._targetLine2="",this._targetLine3="",this._targetLine4="",!(this._source.points().length<2))&&this._source.priceScale()){var e=this._source.ownerSource().formatter(),t=this._source.points()[1],n=this._source.points()[0];this._targetLine3=P(e.format(t.price));var r=t.price-n.price,o=r/Math.abs(n.price)*100;this._targetLine1=P(e.format(r)+" ("+this._percentageFormatter.format(o)+")");var a=this._model.timeScale().indexToUserTime(n.index),d=this._model.timeScale().indexToUserTime(t.index);n.time&&t.time&&(a=TradingView.isString(n.time)?new Date(Date.parse(n.time)):n.time,d=TradingView.isString(t.time)?new Date(Date.parse(t.time)):t.time);var h=this._model.mainSeries().isDWM(),c=s.parse(this._model.mainSeries().interval()),v=c.isSeconds()||c.isTicks();if(d&&a){this._targetLine4=(new u).format(d),h||(this._targetLine4=this._targetLine4+" "+new p(v?g:_).format(d));var m=(d.valueOf()-a.valueOf())/1e3 +;this._targetLine2=i(44352).t(null,{context:"dates"},i(91481))+" "+L((new f).format(m))}this._sourceLine1=e.format(n.price),this._sourceLine2="";var w=this._model.timeScale().indexToUserTime(n.index);w&&(this._sourceLine2=(new u).format(w),h||(this._sourceLine2=this._sourceLine2+" "+new p(v?g:_).format(w))),this._direction=this._source.direction()===x.Direction.Up?"up":"down",this._finished=this._model.lineBeingCreated()!==this._source&&this._model.lineBeingEdited()!==this._source&&!this._model.sourcesBeingMoved().includes(this._source);var R={};R.points=this._points,R.color=this._source.properties().linecolor.value(),R.linewidth=this._source.properties().linewidth.value(),R.targetLine1=this._targetLine1,R.targetLine2=this._targetLine2,R.targetLine3=this._targetLine3,R.targetLine4=this._targetLine4,R.status=this._source.properties().status.value(),R.transparency=this._source.properties().transparency.value(),R.targetBackColor=this._source.properties().targetBackColor.value(),R.targetStrokeColor=this._source.properties().targetStrokeColor.value(),R.targetTextColor=this._source.properties().targetTextColor.value(),R.sourceBackColor=this._source.properties().sourceBackColor.value(),R.sourceStrokeColor=this._source.properties().sourceStrokeColor.value(),R.sourceTextColor=this._source.properties().sourceTextColor.value(),R.successBackground=this._source.properties().successBackground.value(),R.successTextColor=this._source.properties().successTextColor.value(),R.failureBackground=this._source.properties().failureBackground.value(),R.failureTextColor=this._source.properties().failureTextColor.value(),R.intermediateBackColor=this._source.properties().intermediateBackColor.value(),R.intermediateTextColor=this._source.properties().intermediateTextColor.value(),R.sourceLine1=this._sourceLine1,R.sourceLine2=this._sourceLine2,R.direction=this._direction,R.clockWhite=this._clockWhite,R.successIcon=this._successIcon,R.failureIcon=this._failureIcon,R.finished=this._finished,R.centersColor=this._model.backgroundCounterColor().value(),this._predictionRenderer.setData(R);var y=new l;y.append(this._predictionRenderer),this.addAnchors(y),this._renderer=y}}}},86583:(e,t,i)=>{"use strict";var n=i(86441),r=n.Point,s=n.box,o=i(34026).pointInBox,a=i(79191).LineSourcePaneView,l=i(80101).SelectionRenderer,d=i(18807).HitTestResult,h=i(18807).HitTarget,c=i(19266).CompositeRenderer,u=i(87095),p=i(74359).calcTextHorizontalShift,_=i(38223).isRtl,g=i(15187).MediaCoordinatesPaneRenderer,f=i(46501);class v extends g{constructor(e,t){super(),this._data=null,this._measureCache=e,this._chartModel=t,this._points=null}setData(e){this._data=e,this._points=e.points}_drawImpl(e){if(null!==this._data&&null!==this._points&&0!==this._points.length){var t=e.context;t.font=[this._data.fontWeight,this._data.fontSize+"px",this._data.fontFamily].join(" ");var i=t.measureText(this._data.label);i.height=this._data.fontSize;var n=10,r=5,s=i.width+2*n,o=i.height+2*r,a=this._points[0].x- -9,l=this._points[0].y-(o+15);t.textAlign=_()?"right":"left";var d=p(t,i.width) +;this._measureCache&&Object.assign(this._measureCache,{innerWidth:s,innerHeight:o,tailLeft:-9,tailHeight:15}),t.translate(.5+a,.5+l),t.beginPath(),t.moveTo(12,o),t.lineTo(-9,o+15),t.lineTo(-10,o+15-1),t.lineTo(5,o),t.lineTo(3,o),t.arcTo(0,o,0,0,3),t.lineTo(0,3),t.arcTo(0,0,s,0,3),t.lineTo(s-3,0),t.arcTo(s,0,s,o,3),t.lineTo(s,o-3),t.arcTo(s,o,0,o,3),t.lineTo(12,o),t.fillStyle=u.generateColor(this._data.backgroundColor,this._data.transparency),t.fill(),t.strokeStyle=this._data.borderColor,t.lineWidth=2,t.stroke(),t.closePath(),t.textBaseline="alphabetic",t.fillStyle=this._data.color,t.fillText(this._data.label,n+d,o/2+Math.floor(.35*this._data.fontSize)),t.translate(-.5,-.5),t.beginPath(),t.arc(-9,o+15,2.5,0,2*Math.PI,!1),t.fillStyle=u.generateColor(this._data.borderColor,this._data.transparency),t.fill(),t.strokeStyle=this._chartModel.backgroundColor().value(),t.lineWidth=1,t.stroke(),t.closePath()}}hitTest(e){if(null===this._data||null===this._points||0===this._points.length)return null;var t=this._points[0].x-this._measureCache.tailLeft,i=this._points[0].y-(this._measureCache.innerHeight+this._measureCache.tailHeight),n=s(new r(t,i),new r(t+this._measureCache.innerWidth,i+this._measureCache.innerHeight));return o(e,n)?new d(h.MovePoint):null}}t.PriceLabelPaneView=class extends a{constructor(e,t,i){super(e,t),this._rendererCache={},this._priceLabelRenderer=new v(this._rendererCache,t),this._renderer=null}_updateImpl(){if(super._updateImpl(),this._renderer=null,this._source.points().length>0){var e=this._source.points()[0].price,t=this._source.priceScale();if(!t||t.isEmpty())return;var i=this._source.ownerSource().firstValue();this._priceLabel=t.formatPrice(e,i)}var n={};if(n.points=this._points,n.borderColor=this._source.properties().borderColor.value(),n.backgroundColor=this._source.properties().backgroundColor.value(),n.color=this._source.properties().color.value(),n.fontWeight=this._source.properties().fontWeight.value(),n.fontSize=this._source.properties().fontsize.value(),n.fontFamily=f.CHART_FONT_FAMILY,n.transparency=this._source.properties().transparency.value(),n.label=this._priceLabel,this._priceLabelRenderer.setData(n),1===n.points.length){var r=new c;return r.append(this._priceLabelRenderer),r.append(new l({points:n.points,bgColors:this._lineAnchorColors(n.points),visible:this.areAnchorsVisible()})),void(this._renderer=r)}this._renderer=this._priceLabelRenderer}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}}},29734:(e,t,i)=>{"use strict";i.r(t),i.d(t,{PriceNotePaneView:()=>m});var n=i(50151),r=i(86441),s=i(48891),o=i(19266),a=i(80657),l=i(79191),d=i(4652),h=i(79849),c=i(74359),u=i(46501),p=i(38325),_=i(18807),g=i(68441),f=i(45197);function v(e){let t,i;return e>=-135&&e<=-45?(t="center",i="bottom"):e>-45&&e<45?(t="left",i="middle"):e>=45&&e<=135?(t="center",i="top"):(t="right",i="middle"),{horzAlign:t,vertAlign:i}}class x{constructor(){this._data=null,this._priceLabelRenderer=new a.TextRenderer(void 0,new _.HitTestResult(_.HitTarget.MovePoint,{areaName:_.AreaName.Style, +activeItem:1})),this._hittest=new _.HitTestResult(_.HitTarget.MovePoint,{areaName:_.AreaName.Style})}setData(e){this._data=e;const t=e.points[0],i=e.points[1],n=Math.round(180*Math.atan2(i.y-t.y,i.x-t.x)/Math.PI);this._priceLabelRenderer.setData({...v(n),points:[i],text:e.text,color:e.textColor,font:u.CHART_FONT_FAMILY,fontSize:e.fontSize,bold:e.bold,italic:e.italic,offsetX:0,offsetY:0,borderColor:e.borderColor,borderWidth:1,backgroundColor:e.backgroundColor,backgroundRoundRect:4,boxPaddingVert:6,boxPaddingHorz:8})}setHitTest(e){this._hittest=e}draw(e,t){const i=this._data;if(null===i||i.points.length<2)return;e.save();const n=t.pixelRatio,r=Math.round(i.points[0].x*n),s=Math.round(i.points[0].y*n),o=Math.round(i.points[1].x*n),a=Math.round(i.points[1].y*n);e.lineCap="round",(0,g.setLineStyle)(e,h.LINESTYLE_SOLID),e.strokeStyle=i.lineColor,e.fillStyle=i.lineColor,e.lineWidth=Math.round(1*n);const l=(0,f.fillScaledRadius)(2,n);(0,g.createCircle)(e,r,s,l),e.fill(),void 0!==i.excludeBoundaries&&(e.save(),(0,c.addExclusionArea)(e,t,i.excludeBoundaries)),(0,g.drawLine)(e,r,s,o,a),void 0!==i.excludeBoundaries&&e.restore(),this._priceLabelRenderer.draw(e,t);const d=1*n;e.strokeStyle=i.circleBorderColor,e.lineWidth=d;const u=l+d/2;(0,g.createCircle)(e,r,s,u),e.stroke(),e.restore()}hitTest(e){const t=this._data;if(null===t)return null;const i=(0,p.lastMouseOrTouchEventInfo)().isTouch?20:3;return(0,d.distanceToSegment)(t.points[0],t.points[1],e).distance<=i?this._hittest:this._priceLabelRenderer.hitTest(e)}}class m extends l.LineSourcePaneView{constructor(){super(...arguments),this._renderer=new o.CompositeRenderer,this._priceNoteRenderer=new x,this._customLabelRenderer=new a.TextRenderer}renderer(e,t){return this._invalidated&&this._updateImpl(e,t),this._renderer}_updateImpl(e,t){var i;super._updateImpl(),this._renderer.clear();const o=this._source.priceScale();if(!o||o.isEmpty())return;const l=this._points;if(l.length<2)return;const d=(0,n.ensureNotNull)(this._source.ownerSource()).firstValue();if(null===d)return;const h=this._source.properties().childs(),c=this._model.dark().value()?s.colorsPalette["color-cold-gray-900"]:s.colorsPalette["color-white"],p=this._source.points()[0].price,_={text:o.formatPrice(p,d),points:l,lineColor:h.lineColor.value(),circleBorderColor:c,backgroundColor:h.priceLabelBackgroundColor.value(),borderColor:h.priceLabelBorderColor.value(),textColor:h.priceLabelTextColor.value(),fontSize:h.priceLabelFontSize.value(),bold:h.priceLabelBold.value(),italic:h.priceLabelItalic.value()};if(h.showLabel&&h.showLabel.value()){const n=l[0],s=l[1],o=n.x{"use strict";i.r(t),i.d(t,{PriceRangePaneView:()=>v});var n=i(50151),r=i(86441),s=i(38223),o=i(80657),a=i(72739),l=i(99031),d=i(19266),h=i(93572),c=i(79849),u=i(73436),p=i(57322),_=i(46501),g=i(99734);const f=new h.PercentageFormatter;class v extends g.DateAndPriceRangeBasePaneView{constructor(){super(...arguments),this._topBorderRenderer=new l.TrendLineRenderer,this._bottomBorderRenderer=new l.TrendLineRenderer,this._distanceRenderer=new l.TrendLineRenderer,this._backgroundRenderer=new a.RectangleRenderer,this._labelRenderer=new o.TextRenderer,this._renderer=new d.CompositeRenderer,this._pipFormatter=null,this._lastSymbolInfo=null}renderer(e,t){return this._invalidated&&this._updateImpl(e,t),this._renderer}_updateImpl(e,t){var i,a,l;if(super._updateImpl(),this._renderer.clear(),this._points.length<2||this._source.points().length<2)return;const d=this._source.properties().childs(),h=d.extendLeft.value(),g=d.extendRight.value(),[v,x]=this._points,m=Math.min(v.x,x.x),w=Math.max(v.x,x.x);d.fillBackground.value()&&(this._backgroundRenderer.setData({points:[new r.Point(m,v.y),new r.Point(w,x.y)],color:"white",linewidth:0,backcolor:d.backgroundColor.value(),fillBackground:!0,transparency:d.backgroundTransparency.value(),extendLeft:h,extendRight:g}),this._renderer.append(this._backgroundRenderer));const R=(e,t,i)=>{e.setData({points:[t,i],color:d.linecolor.value(),linewidth:d.linewidth.value(),linestyle:c.LINESTYLE_SOLID,extendleft:h,extendright:g,leftend:u.LineEnd.Normal,rightend:u.LineEnd.Normal}),this._renderer.append(e)};let y=m,T=w;y===T&&(h&&(y-=1),g&&(T+=1)),R(this._topBorderRenderer,new r.Point(y,v.y),new r.Point(T,v.y)),R(this._bottomBorderRenderer,new r.Point(y,x.y),new r.Point(T,x.y));const b=Math.round((v.x+x.x)/2),P=new r.Point(b,v.y),L=new r.Point(b,x.y),S=this._updateCustomTextRenderer(e,t);this._distanceRenderer.setData({points:[P,L],color:d.linecolor.value(),linewidth:d.linewidth.value(),linestyle:c.LINESTYLE_SOLID,extendleft:!1,extendright:!1,leftend:u.LineEnd.Normal,rightend:Math.abs(P.y-L.y)>=15*d.linewidth.value()?u.LineEnd.Arrow:u.LineEnd.Normal,excludeBoundaries:null!=S?S:void 0}),this._renderer.append(this._distanceRenderer);const C=this._source.points()[0].price,M=this._source.points()[1].price,I=M-C,A=100*I/Math.abs(C),k=this._model.mainSeries().symbolInfo();k&&k!==this._lastSymbolInfo&&(this._pipFormatter=new p.PipFormatter(k.pricescale,k.minmov,k.type,k.minmove2,k.typespecs),this._lastSymbolInfo=k);const N=(0,n.ensureNotNull)(this._source.ownerSource()).formatter(),D=null!==(a=null===(i=N.formatChange)||void 0===i?void 0:i.call(N,M,C))&&void 0!==a?a:N.format(I),B=(0,s.forceLTRStr)(D+" ("+f.format(A)+") "+(this._pipFormatter?this._pipFormatter.format(I):""));let z +;z=M>C?new r.Point(.5*(v.x+x.x),x.y-2*d.fontsize.value()):new r.Point(.5*(v.x+x.x),x.y+.7*d.fontsize.value());const E={x:0,y:10},H=d.fontsize.value(),O={points:[z],text:B,color:d.textcolor.value(),font:_.CHART_FONT_FAMILY,offsetX:E.x,offsetY:E.y,padding:8,vertAlign:"middle",horzAlign:"center",fontsize:H,backgroundRoundRect:4,backgroundHorzInflate:.4*H,backgroundVertInflate:.2*H};(null===(l=d.fillLabelBackground)||void 0===l?void 0:l.value())&&(O.boxShadow={shadowColor:d.shadow.value(),shadowBlur:4,shadowOffsetY:1},O.backgroundColor=d.labelBackgroundColor.value()),this._labelRenderer.setData(O);const V=this._labelRenderer.measure(),W=(0,o.calculateLabelPosition)(V,v,x,E,e);this._labelRenderer.setPoints([W]),this._renderer.append(this._labelRenderer),this._renderer.append(this._customTextrenderer),this.addAnchors(this._renderer)}_needLabelExclusionPath(e){return e.getLinesInfo().lines.length>0}}},75219:(e,t,i)=>{"use strict";var n=i(81139).ArcWedgeRenderer,r=i(60322).FibWedgePaneView,s=i(99031).TrendLineRenderer,o=i(19266).CompositeRenderer,a=i(73436).LineEnd;t.ProjectionLinePaneView=class extends r{constructor(e,t){super(e,t),this._baseTrendRenderer=new s,this._edgeTrendRenderer=new s,this._arcWedgeRenderer=new n}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateRenderer(){if(!(this._points.length<2)){var e=new o,t=this._source.properties(),i=this._points,n=i[0],r=i[1],s={points:[n,r],width:this._model.timeScale().width(),height:this._source.priceScale().height(),color:t.trendline.color.value(),linewidth:t.linewidth.value(),linestyle:t.trendline.linestyle.value(),extendleft:!1,extendright:!1,leftend:a.Normal,rightend:a.Normal};if(this._baseTrendRenderer.setData(s),e.append(this._baseTrendRenderer),this._points.length<3)return this.addAnchors(e),void(this._renderer=e);var l=i[2],d=l.data,h=r.subtract(n).length(),c=l.subtract(n).normalized();(l=n.add(c.scaled(h))).data=d,s={points:[n,l],width:this._model.timeScale().width(),height:this._source.priceScale().height(),color:t.trendline.color.value(),linewidth:t.linewidth.value(),linestyle:t.trendline.linestyle.value(),extendleft:!1,extendright:!1,leftend:a.Normal,rightend:a.Normal},this._edgeTrendRenderer.setData(s),e.append(this._edgeTrendRenderer);var u=this._levels[0],p={};p.center=this._points[0],p.radius=u.radius,p.prevRadius=0,p.edge=this._edge,p.color=t.trendline.color.value(),p.color1=t.color1.value(),p.color2=t.color2.value(),p.linewidth=t.linewidth.value(),p.edge1=this._edge1,p.edge2=this._edge2,p.p1=u.p1,p.p2=u.p2,p.fillBackground=t.fillBackground.value(),p.transparency=t.transparency.value(),p.gradient=!0,this._arcWedgeRenderer.setData(p),e.append(this._arcWedgeRenderer),this.addAnchors(e),this._renderer=e}}}},31320:(e,t,i)=>{"use strict";i.r(t),i.d(t,{RectanglePaneView:()=>h});var n=i(86441),r=i(46501),s=i(72739),o=i(19266),a=i(80657),l=i(79191),d=i(66103);class h extends l.LineSourcePaneView{constructor(e,t){super(e,t),this._rectangleRenderer=new s.RectangleRenderer,this._textRenderer=new a.TextRenderer,this._renderer=null} +renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){if(super._updateImpl(),this._renderer=null,this._points.length<2)return;const e=this._getSource().properties().childs(),t={points:this._points,color:e.color.value(),linewidth:e.linewidth.value(),backcolor:e.backgroundColor.value(),fillBackground:e.fillBackground.value(),transparency:e.transparency.value(),extendLeft:e.extendLeft.value(),extendRight:e.extendRight.value()};this._rectangleRenderer.setData(t);const i=new o.CompositeRenderer;i.append(this._rectangleRenderer);const s=this._points[0],a=this._points[1];if(e.showLabel.value()){const t=Math.min(s.x,a.x),o=Math.max(s.x,a.x),l=Math.min(s.y,a.y),d=Math.max(s.y,a.y);let h,c,u,p;const _=e.fontSize.value()/3;let g,f,v=0;switch(e.vertLabelsAlign.value()){case"middle":p=(l+d)/2,c="middle",v=_;break;case"top":p=d,c="top";break;case"bottom":p=l,c="bottom"}switch(e.horzLabelsAlign.value()){case"center":u=(t+o)/2,h="center";break;case"left":u=t,h="left";break;case"right":u=o,h="right"}"middle"===c&&(g=o-t-2*v,f=d-l);const x={points:[new n.Point(u,p)],text:e.text.value(),fontSize:e.fontSize.value(),font:r.CHART_FONT_FAMILY,bold:e.bold.value(),italic:e.italic.value(),horzAlign:h,vertAlign:c,color:e.textColor.value(),wordWrapWidth:g,maxHeight:f,offsetX:0,offsetY:0,boxPaddingVert:_,boxPaddingHorz:v,forceTextAlign:!0};this._textRenderer.setData(x),i.append(this._textRenderer)}this._addAnchors(s,a,i),this._renderer=i}_addAnchors(e,t,i){const r=new n.Point(e.x,t.y);r.data=2;const s=new n.Point(t.x,e.y);s.data=3;const o=new n.Point(e.x,.5*(e.y+t.y));o.data=4;const a=new n.Point(t.x,.5*(e.y+t.y));a.data=5;const l=new n.Point(.5*(e.x+t.x),e.y);l.data=6;const h=new n.Point(.5*(e.x+t.x),t.y);h.data=7,[o,a,l,h].forEach((e=>e.square=!0));const c=e.x-t.x,u=e.y-t.y,p=Math.sign(c*u),_=[p<0?d.PaneCursorType.DiagonalNeSwResize:d.PaneCursorType.DiagonalNwSeResize,p<0?d.PaneCursorType.DiagonalNeSwResize:d.PaneCursorType.DiagonalNwSeResize,p>0?d.PaneCursorType.DiagonalNeSwResize:d.PaneCursorType.DiagonalNwSeResize,p>0?d.PaneCursorType.DiagonalNeSwResize:d.PaneCursorType.DiagonalNwSeResize,d.PaneCursorType.HorizontalResize,d.PaneCursorType.HorizontalResize,d.PaneCursorType.VerticalResize,d.PaneCursorType.VerticalResize];i.append(this.createLineAnchor({points:[e,t,r,s,o,a,l,h],pointsCursorType:_},0))}}},5374:(e,t,i)=>{"use strict";i.r(t),i.d(t,{RegressionTrendPaneView:()=>g});var n=i(50151),r=i(87095),s=i(18807),o=i(19266),a=i(28621),l=i(80657),d=i(99031),h=i(80101),c=i(86441),u=i(73436),p=i(46501);var _=i(79191);class g extends _.LineSourcePaneView{constructor(e,t){super(e,t),this._data=null,this._pearsonsLabelRenderer=new l.TextRenderer,this._renderer=null,this._renderer=null}renderer(){return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){super._updateImpl(),this._data=function(e,t){const i={lines:[],pearsons:null};if(!t.properties().visible.value())return i;const r=e.timeScale(),s=t.priceScale(),o=e.mainSeries().firstBar();if(!s||s.isEmpty()||r.isEmpty()||!o)return i +;const a=t.startIndex(),l=t.endIndex();if(null===a||null===l)return i;const d=[t.baseLine(),t.downLine(),t.upLine()],h=Math.round(r.indexToCoordinate(a)),_=Math.round(r.indexToCoordinate(l)),g=t.properties(),f=[g.styles.baseLine,g.styles.downLine,g.styles.upLine],v=o[4];for(let r=0;r!!e)),l=this._source.properties().childs().styles.childs().transparency.value();for(let t=1;t=1&&e.append(new h.SelectionRenderer({points:t,bgColors:this._lineAnchorColors(t),visible:this.areAnchorsVisible(),hittestResult:s.HitTarget.Regular,barSpacing:this._model.timeScale().barSpacing()})),this._renderer=e}_getTransparencyResetLines(){return(0,n.ensureNotNull)(this._data).lines.map((e=>({...e,color:(0,r.resetTransparency)(e.color)})))}}},56457:(e,t,i)=>{"use strict";i.r(t),i.d(t,{RiskRewardPaneView:()=>A});var n=i(86441),r=i(50151),s=i(44352),o=i(79191),a=i(99031),l=i(80657),d=i(72739),h=i(18807),c=i(19266),u=i(93572),p=i(87663),_=i(57322),g=i(87095),f=i(73436),v=i(95539),x=i(38223),m=i(66103),w=i(88145),R=i(46501),y=i(79849) +;const T=[m.PaneCursorType.Default,m.PaneCursorType.HorizontalResize,m.PaneCursorType.VerticalResize,m.PaneCursorType.VerticalResize],b=s.t(null,void 0,i(72892)),P=s.t(null,{context:"line_tool_position"},i(50140)),L=s.t(null,{context:"line_tool_position"},i(44143)),S=s.t(null,void 0,i(53115)),C=s.t(null,void 0,i(438)),M=s.t(null,void 0,i(15166)),I=s.t(null,void 0,i(87061));class A extends o.LineSourcePaneView{constructor(){super(...arguments),this._percentageFormatter=new u.PercentageFormatter,this._numericFormatter=new p.NumericFormatter,this._pipFormatter=null,this._lastSymbolInfo=null,this._entryLineRenderer=new a.TrendLineRenderer,this._stopLineRenderer=new a.TrendLineRenderer,this._targetLineRenderer=new a.TrendLineRenderer,this._positionLineRenderer=new a.TrendLineRenderer,this._fullStopBgRenderer=new d.RectangleRenderer(new h.HitTestResult(h.HitTarget.MovePoint),new h.HitTestResult(h.HitTarget.MovePoint)),this._stopBgRenderer=new d.RectangleRenderer(new h.HitTestResult(h.HitTarget.MovePoint),new h.HitTestResult(h.HitTarget.MovePoint)),this._fullTargetBgRenderer=new d.RectangleRenderer(new h.HitTestResult(h.HitTarget.MovePoint),new h.HitTestResult(h.HitTarget.MovePoint)),this._targetBgRenderer=new d.RectangleRenderer(new h.HitTestResult(h.HitTarget.MovePoint),new h.HitTestResult(h.HitTarget.MovePoint)),this._stopLabelRenderer=new l.TextRenderer,this._middleLabelRenderer=new l.TextRenderer,this._profitLabelRenderer=new l.TextRenderer,this._renderer=new c.CompositeRenderer}isLabelVisible(){return this.isHoveredSource()||this.isSelectedSource()||this._source.properties().childs().alwaysShowStats.value()}renderer(e,t){return this._invalidated&&this._updateImpl(e,t),this._renderer}_updateImpl(e,t){super._updateImpl(e,t),this._renderer.clear();const i=this._model.timeScale(),s=this._source.priceScale();if(!s||s.isEmpty()||i.isEmpty())return;const o=this._source.points();if(o.length<2||this._points.length<2)return;const a=(0,r.ensureNotNull)(this._source.ownerSource()),l=null==a?void 0:a.barsProvider().bars();if(!l||l.isEmpty())return;if(null===l.last())return;const d=4===o.length,h=this._source.lastBarData();if(!h)return;const c=h.closePrice,u=this._source.stopPrice(),p=this._source.profitPrice(),g=this._source.calculatePL(c),f=a.symbolSource().symbolInfo();if(!f)return;const x=a.firstValue();if(null===x)return;const m=this._points[v.RiskRewardPointIndex.Entry].y,w=s.priceToCoordinate(u,x),R=s.priceToCoordinate(p,x),y=s.priceToCoordinate(h.closePrice,x),b=i.indexToCoordinate(h.index),P=this._points[v.RiskRewardPointIndex.Entry].x,L=this._points[v.RiskRewardPointIndex.ActualEntry]?this._points[v.RiskRewardPointIndex.ActualEntry].x:this._points[v.RiskRewardPointIndex.Close].x,S=this._points[v.RiskRewardPointIndex.ActualClose]?this._points[v.RiskRewardPointIndex.ActualClose].x:this._points[v.RiskRewardPointIndex.Close].x,C=this._points[v.RiskRewardPointIndex.Close].x,M=this._source.entryPrice(),I=this._source.stopPrice(),A=this._source.profitPrice(),k={pl:g,isClosed:d,entryLevel:m,stopLevel:w,profitLevel:R,closeLevel:y, +closeBar:b,left:P,entryX:L,right:S,edge:C,entryPrice:M,stopPrice:I,profitPrice:A,currentPrice:c};let N=C<-5||P>t+5;if(this._createBackgroundRenderers(k,this._renderer),this._createLinesRenderers(k,this._renderer),this._createLabelsRenderers(k,this._renderer,f),f!==this._lastSymbolInfo&&(this._pipFormatter=new _.PipFormatter(f.pricescale,f.minmov,f.type,f.minmove2,f.typespecs),this._lastSymbolInfo=f),N=[this._profitLabelRenderer,this._stopLabelRenderer,this._middleLabelRenderer].reduce(((i,n)=>i&&n.isOutOfScreen(t,e)),N),N)return;const D=this._points[0].clone();D.data=0,D.snappingPrice=M;const B=new n.Point(P,w);B.data=2,B.square=!0,B.snappingPrice=I;const z=new n.Point(P,R);z.data=3,z.square=!0,z.snappingPrice=A;const E=new n.Point(C,D.y);E.data=1,E.square=!0,E.snappingIndex=h.index;const H={points:[D,E,B,z],pointsCursorType:T};this._renderer.append(this.createLineAnchor(H,0))}_createBackgroundRenderers(e,t){const i=this._source.properties().childs();{const t={points:[new n.Point(e.left,e.entryLevel),new n.Point(e.edge,e.stopLevel)],color:"white",linewidth:0,backcolor:i.stopBackground.value(),fillBackground:!0,transparency:i.stopBackgroundTransparency.value(),extendLeft:!1,extendRight:!1};this._fullStopBgRenderer.setData(t),this._renderer.append(this._fullStopBgRenderer)}if(e.pl<0&&e.entryX!==e.right){const t=new n.Point(e.entryX,e.entryLevel),r=new n.Point(e.right,e.closeLevel),s=.01*i.stopBackgroundTransparency.value(),o=100-100*(1-s*s*s),a={points:[t,r],color:"white",linewidth:0,backcolor:i.stopBackground.value(),fillBackground:!0,transparency:o,extendLeft:!1,extendRight:!1};this._stopBgRenderer.setData(a),this._renderer.append(this._stopBgRenderer)}{const t={points:[new n.Point(e.left,e.entryLevel),new n.Point(e.edge,e.profitLevel)],color:"white",linewidth:0,backcolor:i.profitBackground.value(),fillBackground:!0,transparency:i.profitBackgroundTransparency.value(),extendLeft:!1,extendRight:!1};this._fullTargetBgRenderer.setData(t),this._renderer.append(this._fullTargetBgRenderer)}if(e.pl>0&&e.entryX!==e.right){const t=new n.Point(e.entryX,e.entryLevel),r=new n.Point(e.right,e.closeLevel),s=.01*i.profitBackgroundTransparency.value(),o=100-100*(1-s*s*s),a={points:[t,r],color:"white",linewidth:0,backcolor:i.profitBackground.value(),fillBackground:!0,transparency:o,extendLeft:!1,extendRight:!1};this._targetBgRenderer.setData(a),this._renderer.append(this._targetBgRenderer)}}_createLinesRenderers(e,t){const i=this._source.properties().childs(),r=(e,t,n,r)=>{const s={points:[t,n],color:null!=r?r:i.linecolor.value(),linewidth:i.linewidth.value(),linestyle:y.LINESTYLE_SOLID,extendleft:!1,extendright:!1,leftend:f.LineEnd.Normal,rightend:f.LineEnd.Normal};e.setData(s),this._renderer.append(e)};if(this._points[v.RiskRewardPointIndex.ActualEntry]){const t={points:[this._points[v.RiskRewardPointIndex.ActualEntry],e.isClosed?this._points[v.RiskRewardPointIndex.ActualClose]:new n.Point(e.closeBar,e.closeLevel)],color:this._source.properties().childs().linecolor.value(),linewidth:1,linestyle:y.LINESTYLE_DASHED,extendleft:!1, +extendright:!1,leftend:f.LineEnd.Normal,rightend:f.LineEnd.Arrow};this._positionLineRenderer.setData(t),this._renderer.append(this._positionLineRenderer)}{const t=new n.Point(e.left,this._points[v.RiskRewardPointIndex.Entry].y),i=new n.Point(e.edge,this._points[v.RiskRewardPointIndex.Entry].y);r(this._entryLineRenderer,t,i)}{const t=new n.Point(e.left,e.stopLevel),s=new n.Point(e.edge,e.stopLevel);r(this._stopLineRenderer,t,s,i.stopBackground.value())}{const t=new n.Point(e.left,e.profitLevel),s=new n.Point(e.edge,e.profitLevel);r(this._targetLineRenderer,t,s,i.profitBackground.value())}}_addCenterLabel(e,t,i){const n=this._source.properties().childs(),r={font:R.CHART_FONT_FAMILY,offsetX:3,horzAlign:"center",backgroundRoundRect:4,backgroundHorzInflate:4,points:[i.p],text:i.txt,color:n.textcolor.value(),offsetY:i.offsetY,vertAlign:i.vertAlign,backgroundColor:(0,g.resetTransparency)(i.color),fontsize:n.fontsize.value(),borderColor:i.border};return t.setData(r),e.append(t),r}_creareMiddleLabel(e,t,i){const{entryPrice:s,profitPrice:o,stopPrice:a,currentPrice:l,pl:d,left:h,edge:c,isClosed:u}=e,p=Math.abs(s-o)/Math.abs(s-a),_=this._source.properties().childs(),g=(0,r.ensureNotNull)(this._source.ownerSource()),f=new n.Point((h+c)/2,Math.round(this._points[0].y));let v="",x="";const m=this._numericFormatter.format(Math.round(100*p)/100);if(this._points[1]){const e=g.formatter();if(e.formatChange){const t=Math.max(l,s),i=Math.min(l,s);x=d>=0?e.formatChange(t,i):e.formatChange(i,t)}else x=e.format(d)}const R=_.qty.value()/_.lotSize.value(),y="futures"===i.type||(0,w.hasCryptoTypespec)(i.typespecs||[])?Math.round(1e3*R)/1e3:Math.floor(R);if(_.compact.value())v+=x?x+" ~ ":"",v+=y+"\n",v+=m;else{const e=u?L:P;v+=x?b.format({status:e,pnl:x})+", ":"",v+=I.format({qty:""+y})+"\n",v+=S.format({ratio:m})+" "}let T=_.linecolor.value();return d<0?T=_.stopBackground.value():d>0&&(T=_.profitBackground.value()),this._addCenterLabel(t,this._middleLabelRenderer,{p:f,txt:v,color:T,vertAlign:"middle",offsetY:0,border:"white"})}_createStopLabel(e,t){var i,s;const{stopPrice:o,entryPrice:a,left:l,edge:d,stopLevel:h}=e,c=this._source.properties().childs(),u=(0,r.ensureNotNull)(this._source.ownerSource()),p=Math.abs(o-a),_=Math.round(1e4*p/a)/100,g=new n.Point((l+d)/2,h);let f="";const v=u.formatter(),m=null!==(s=null===(i=v.formatChange)||void 0===i?void 0:i.call(v,Math.max(o,a),Math.min(o,a)))&&void 0!==s?s:v.format(p),w=this._percentageFormatter.format(_);return f=c.compact.value()?m+" ("+w+") "+c.amountStop.value():C.format({stopChange:(0,x.forceLTRStr)(m),stopChangePercent:(0,x.forceLTRStr)(this._percentageFormatter.format(_)),stopChangePip:this._pipFormatter?(0,x.forceLTRStr)(this._pipFormatter.format(p)):"",amount:(0,x.forceLTRStr)(""+c.amountStop.value())}),this._addCenterLabel(t,this._stopLabelRenderer,{p:g,txt:f,color:c.stopBackground.value(),vertAlign:aMath.max(e,t.measure().width)),0),h=e.edge-e.left,c=this._anchorRadius();if(h-d-c<=8&&(l&&(l.offsetY+=c+8,this._profitLabelRenderer.setData(l)),a&&(a.offsetY+=c+8,this._stopLabelRenderer.setData(a)),o)){let t;if(null===(s=this._source.priceScale())||void 0===s?void 0:s.isLog()){const i=Math.abs(this._points[0].y-e.stopLevel);t=Math.abs(this._points[0].y-e.profitLevel)>i?-1:1}else{const i=Math.abs(e.stopPrice-e.entryPrice);t=Math.abs(e.profitPrice-e.entryPrice)>i?-1:1}const i=e.profitLevel{"use strict";var n=i(86441).Point,r=i(4652).distanceToLine,s=i(79191).LineSourcePaneView,o=i(79191).thirdPointCursorType,a=i(99031).TrendLineRenderer,l=i(79797).PolygonRenderer,d=i(19266).CompositeRenderer,h=i(73436).LineEnd,c=i(66103).PaneCursorType;const{LINESTYLE_SOLID:u}=i(79849);t.RotatedRectanglePaneView=class extends s{constructor(e,t){super(e,t),this._poligonRenderer=new l,this._renderer=null}_updateImpl(){if(super._updateImpl(),this._renderer=null,this._distance=0,3===this._points.length&&(this._distance=r(this._points[0],this._points[1],this._points[2]).distance),0!==this._points.length){var e,t,i,s,l=new d,p=this._source.properties(),_=this._points[0],g=this._points[1];if(2===this._points.length){(v={}).points=this._points,v.floatPoints=this._floatPoints,v.width=this._model.timeScale().width(),v.height=this._source.priceScale().height(),v.color=p.color.value(),v.linewidth=1,v.linestyle=u,v.extendleft=!1,v.extendright=!1,v.leftend=h.Normal,v.rightend=h.Normal;var f=new a;f.setData(v),l.append(f)}else if(3===this._points.length){var v,x=g.subtract(_),m=new n(x.y,-x.x).normalized().scaled(this._distance),w=m.scaled(-1);e=_.add(m),t=g.add(m),i=_.add(w),s=g.add(w),(v={}).points=[e,t,s,i],v.color=p.color.value(),v.linewidth=this._source.properties().linewidth.value(),v.linestyle=u,v.filled=!0,v.backcolor=p.backgroundColor.value(), +v.fillBackground=p.fillBackground.value(),v.transparency=p.transparency.value(),this._poligonRenderer.setData(v),l.append(this._poligonRenderer)}var R=[];R.push(_),this._points.length>=2&&R.push(g);var y=[c.Default,c.Default];if(3===this._points.length){e.data=2,i.data=2,t.data=2,s.data=2,R.push(e,i,t,s);var T=o(_,g);y.push(T,T,T,T)}l.append(this.createLineAnchor({points:R,pointsCursorType:y},0)),this._renderer=l}}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}}},26294:(e,t,i)=>{"use strict";i.r(t),i.d(t,{SignpostPaneView:()=>L});var n=i(86441),r=i(48891),s=i(19266),o=i(66103),a=i(18807),l=i(79191),d=i(85573),h=i(46501),c=i(4652),u=i(34026),p=i(50151),_=i(38325),g=i(80657),f=i(45197);function v(e){return void 0===e?0:e.poleTailHeight+2*e.circleRadius}function x(e){return e.poleStartY}function m(e){return e.inverseAnchorPosition?e.anchorY:e.anchorY+(e.labelHeight+v(e.plate))*e.direction}function w(e){return e.inverseAnchorPosition?e.anchorY+v(e.plate)*e.direction:e.anchorY+e.labelHeight*e.direction}class R{constructor(e,t){this._data=null,this._hitTestResult=e,this._phantomMode=Boolean(t)}setData(e){if(null===e)return void(this._data=null);this._data={...e,labelHeight:0,labelRenderer:new g.TextRenderer};const t=this._data,i=t.label,r={offsetX:0,offsetY:0,points:[new n.Point(t.x,t.anchorY)],forceCalculateMaxLineWidth:!0,vertAlign:-1===i.labelDirection?"bottom":"top",horzAlign:"center",horzTextAlign:"center",font:i.labelFont,fontSize:i.labelFontSize,bold:i.labelFontBold,italic:i.labelFontItalic,backgroundRoundRect:i.labelBorderRadius,padding:i.labelPadding,boxPaddingVert:i.labelBoxPaddingVert,boxPaddingHorz:i.labelBoxPaddingHorz,wordWrapWidth:i.labelWordWrapWidth,color:i.labelColor,borderColor:i.labelBorderColor,borderWidth:1,backgroundColor:i.labelBackgroundColor,text:i.text};if(t.labelRenderer.setData(r),this._data.labelHeight=this._data.labelRenderer.measure().height,t.inverseAnchorPosition){const e=(0,p.ensureDefined)(r.points);r.points=[new n.Point(e[0].x,w(t))]}else{const e=1===t.direction?Math.min(t.poleStartY-this._data.labelHeight,t.anchorY):Math.max(t.poleStartY+this._data.labelHeight,t.anchorY);t.anchorY!==e&&(t.anchorY=e,r.points=[new n.Point(t.x,e)])}t.labelRenderer.setData(r)}itemAnchorY(){return null===this._data?null:this._data.anchorY}hitTest(e,t){if(null===this._data)return null;const[i,r,s]=function(e,t){const i=(0,_.lastMouseOrTouchEventInfo)().isTouch?20:3,r=e.x,s=e.plate,o=(0,c.distanceToSegment)(new n.Point(r,x(e)),new n.Point(r,m(e)),t).distance0&&(0,u.pointInCircle)(t,new n.Point(r,o),s.circleRadius+i)}return[o,a,!o&&!a&&null!==e.labelRenderer.hitTest(t)]}(this._data,e);if(i||r||s){const e={hideCrosshairLinesOnHover:!0,activeItem:i||r?this._data.itemIndex:this._data.label.labelIndex};return s?e.areaName=a.AreaName.Text:r&&(e.areaName=a.AreaName.Style), +new a.HitTestResult(this._hitTestResult,e)}return null}draw(e,t){if(null===this._data)return;e.save(),this._phantomMode&&(e.globalAlpha=.5);const{poleColor:i,emojiRadius:n}=this._data,r=t.pixelRatio,s=Math.max(1,Math.floor(r)),o=s%2?.5:0;e.beginPath(),e.strokeStyle=i,e.lineWidth=s;const a=Math.round(this._data.x*r)+o;e.moveTo(a,Math.round(x(this._data)*r)),e.lineTo(a,Math.round(m(this._data)*r)),void 0!==this._data.plate&&0!==this._data.plate.poleTailHeight&&(e.moveTo(a,Math.round(w(this._data)*r)),e.lineTo(a,Math.round(function(e){var t,i;const n=null!==(i=null===(t=e.plate)||void 0===t?void 0:t.poleTailHeight)&&void 0!==i?i:0;return e.inverseAnchorPosition?w(e)-n*e.direction:w(e)+n*e.direction}(this._data)*r))),e.stroke(),void 0!==this._data.plate&&function(e,t,i,n,r){const s=r.pixelRatio,{circleRadius:o,poleTailHeight:a,circleBorderColor:l,circleBackgroundColor:d}=i;e.strokeStyle=l,e.fillStyle=d;const h=(0,f.fillScaledRadius)(o,s),c=Math.round(t.x*s),u=t.inverseAnchorPosition?Math.round(t.anchorY*s)+Math.round(o*s)*t.direction:Math.round(t.anchorY*s)+Math.round((t.labelHeight+a+o)*s)*t.direction,p=Math.max(1,Math.floor(s))%2/2,_=c+p,g=u+p;if(e.shadowOffsetY=1,e.shadowColor=i.shadowColor,e.shadowBlur=4,e.beginPath(),e.arc(_,g,h,0,2*Math.PI,!0),e.closePath(),e.fill(),e.shadowColor="transparent",t.svgRenderer){const i=2*(0,f.fillScaledRadius)(n,s);t.svgRenderer.render(e,{targetViewBox:{x:_-i/2,y:g-i/2,width:i,height:i}})}const v=Math.round(i.circleBorderWidth*s),x=(0,f.strokeScaledRadius)(o,s,v);if(e.lineWidth=v,e.beginPath(),e.arc(_,g,x,0,2*Math.PI,!0),e.closePath(),e.stroke(),i.outsideBorderWidth){e.save();const t=Math.round(i.outsideBorderWidth*s),n=x+v/2+t/2;e.lineWidth=t,e.strokeStyle=i.outsideBorderColor,e.beginPath(),e.arc(_,g,n,0,2*Math.PI,!0),e.closePath(),e.stroke(),e.restore()}}(e,this._data,this._data.plate,n,t),this._data.labelRenderer.draw(e,t),e.restore()}}var y=i(68616),T=i(69798);const b={circleBorderColor:(0,r.getHexColorByName)("color-cold-gray-900"),labelBackgroundColor:(0,r.getHexColorByName)("color-cold-gray-900"),labelBorderColor:(0,r.getHexColorByName)("color-cold-gray-800"),labelTextColor:(0,r.getHexColorByName)("color-cold-gray-200"),poleColor:(0,r.getHexColorByName)("color-cold-gray-500"),shadowColor:"rgba(0,0,0,0.4)",selectionColor:(0,r.getHexColorByName)("color-tv-blue-500")},P={circleBorderColor:(0,r.getHexColorByName)("color-white"),labelBackgroundColor:(0,r.getHexColorByName)("color-white"),labelBorderColor:(0,r.getHexColorByName)("color-cold-gray-150"),labelTextColor:(0,r.getHexColorByName)("color-cold-gray-900"),poleColor:(0,r.getHexColorByName)("color-cold-gray-500"),shadowColor:"rgba(0,0,0,0.2)",selectionColor:(0,r.getHexColorByName)("color-tv-blue-500")};class L extends l.LineSourcePaneView{constructor(e,t){super(e,t),this._renderer=new s.CompositeRenderer,this._emojiCache=null,this._destroyed=!1,this._signpostRenderer=new R(a.HitTarget.MovePoint,e.isPhantom()),e.properties().childs().emoji.subscribe(this,this._updateEmoji),this._updateEmoji()}destroy(){ +this._source.properties().childs().emoji.unsubscribeAll(this),this._destroyed=!0}renderer(e,t){return this._invalidated&&this._updateImpl(e,t),this._renderer}_updateImpl(e,t){if(super._updateImpl(),this._renderer.clear(),!this._updateTimelineRenderer(e))return;if(this._renderer.append(this._signpostRenderer),this._source.isPhantom())return;const i=this._itemAnchorY();if(null===i)return;const r=this._points[0],s=new n.Point(r.x,i);s.data=r.data,s.square=!0,this._renderer.append(this.createLineAnchor({points:[s],pointsCursorType:[o.PaneCursorType.VerticalResize]},0))}_itemAnchorY(){return this._signpostRenderer.itemAnchorY()}_updateTimelineRenderer(e){var t;const i=this._source.ownerSource();if(null===i)return!1;const n=this._model.timeScale(),r=i.priceScale(),s=i.firstValue();if(n.isEmpty()||null===r||r.isEmpty()||null===s)return!1;const o=this._model.dark().value()?b:P,a=this._model.mainSeries(),l=this._source.properties().childs(),c=l.position.value(),u=this._source.customEvent(),p=i===a?(0,d.getSeriesPosition)(a,u):(0,d.getNoDataPosition)(u,r,s);if(null===p)return!1;const _=n.indexToCoordinate(p.index),g=r.priceToCoordinate(p.price,s),f=l.showImage.value();let v=(0,d.positionToCoordinate)(c,e,g,p.positionPointDirection);v>=-1e-10&&v<=e+1e-10&&(v=Math.min(e-2,Math.max(2,v)));const x=p.visualDirection!==p.positionPointDirection,m=p.visualDirection,w={emojiRadius:16,poleColor:o.poleColor,svgRenderer:null===(t=this._emojiCache)||void 0===t?void 0:t.emojiSvgRenderer,itemIndex:1,label:{labelIndex:1,labelDirection:p.positionPointDirection,labelFont:h.CHART_FONT_FAMILY,labelFontSize:l.fontSize.value(),labelFontBold:l.bold.value(),labelFontItalic:l.italic.value(),labelBorderRadius:4,labelPadding:3,labelBoxPaddingVert:6,labelBoxPaddingHorz:8,labelWordWrapWidth:134,labelColor:o.labelTextColor,labelBorderColor:o.labelBorderColor,labelBackgroundColor:o.labelBackgroundColor,text:l.text.value()},x:_,anchorY:v,poleStartY:p.poleStartY,direction:m*(x?-1:1),inverseAnchorPosition:x};return f&&(w.plate={circleBackgroundColor:l.backgroundsColors.value(),outsideBorderWidth:0,circleBorderColor:o.circleBorderColor,circleBorderWidth:1,poleTailHeight:l.text.value()?10:0,circleRadius:35,shadowColor:o.shadowColor,outsideBorderColor:o.selectionColor}),this._signpostRenderer.setData(w),!0}async _updateEmoji(){var e;const t=this._source.properties().childs().emoji.value();if(null!==this._emojiCache&&this._emojiCache.emoji===t)return;null!==this._emojiCache&&(null===(e=this._emojiCache.abortController)||void 0===e||e.abort(),this._emojiCache.abortController=void 0);const n=(0,y.getTwemojiUrl)(t,"svg"),r=new AbortController,s=(0,T.fetch)(n,{signal:r.signal}).then((e=>e.text())),o={emoji:t,abortController:r};this._emojiCache=o;const[a,{svgRenderer:l}]=await Promise.all([s,i.e(2616).then(i.bind(i,50765))]);!this._destroyed&&o.abortController&&(o.emojiSvgRenderer=l(a),this._model.updateSource(this._source))}}},5362:(e,t,i)=>{"use strict";i.r(t),i.d(t,{SineLinePaneView:()=>h});var n=i(86441),r=i(79191),s=i(19266),o=i(15187),a=i(18807),l=i(68441) +;class d extends o.MediaCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e,t){const i=(e.x-this._data.point.x)*Math.PI/this._data.width;let n=Math.sin(i-Math.PI/2)*this._data.height/2;return n=this._data.point.y+n+this._data.height/2,Math.abs(n-e.y)<=3?new a.HitTestResult(a.HitTarget.MovePoint):null}_drawImpl(e){const t=e.context;t.strokeStyle=this._data.color,t.lineWidth=this._data.lineWidth,(0,l.setLineStyle)(t,this._data.lineStyle),t.beginPath(),t.moveTo(this._data.point.x,this._data.point.y);const i=Math.max(1,this._data.width/30),n=e.mediaSize.width-this._data.point.x+i;for(let e=1;e<=n;e+=i){const i=e*Math.PI/this._data.width,n=Math.sin(i-Math.PI/2)*this._data.height/2;t.lineTo(this._data.point.x+e,this._data.point.y+n+this._data.height/2)}t.stroke()}}class h extends r.LineSourcePaneView{constructor(e,t){super(e,t),this._renderer=new s.CompositeRenderer}renderer(e,t){return this._invalidated&&this._updateImpl(e,t),this._renderer}_updateImpl(e,t){if(super._updateImpl(),this._renderer.clear(),this._points.length<2)return;const[i,r]=this._source.points();if(0===2*Math.abs(i.index-r.index))return void this.addAnchors(this._renderer);const[s,o]=this._points,a=Math.abs(s.x-o.x),l=o.y-s.y,h=this._source.properties().childs(),c=h.linewidth.value();if(s.y<-c&&o.y<-c||s.y>e+c&&o.y>e+c)return;const u=2*a,p=s.x>0?s.x-Math.ceil(s.x/u)*u:s.x+Math.floor(-s.x/u)*u,_={point:new n.Point(p,s.y),width:a,height:l,color:h.linecolor.value(),lineWidth:h.linewidth.value(),lineStyle:h.linestyle.value()};this._renderer.append(new d(_)),this.addAnchors(this._renderer)}}},15378:(e,t,i)=>{"use strict";i.r(t),i.d(t,{StickerPaneView:()=>r});var n=i(50761);class r extends n.SvgIconPaneView{_iconColor(){return null}}},44666:(e,t,i)=>{"use strict";i.r(t),i.d(t,{StudyLineDataSourceAnchorsPaneView:()=>r});var n=i(79191);class r extends n.LineSourcePaneView{renderer(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this.createLineAnchor({points:this._getPoints()},0)}}},50761:(e,t,i)=>{"use strict";i.d(t,{SvgIconPaneView:()=>g});var n=i(86441),r=i(25422),s=i(50151),o=i(87095),a=i(19266),l=i(66103),d=i(79191),h=i(48891),c=i(15187),u=i(18807);const p=(0,h.getHexColorByName)("color-tv-blue-600");class _ extends c.MediaCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null}setData(e){this._data=e}hitTest(e,t){if(null===this._data)return null;const{size:i,angle:n,point:s}=this._data,o=(0,r.rotationMatrix)(-n),a=(0,r.transformPoint)(o,e.subtract(s));return Math.abs(a.y)<=i/2&&Math.abs(a.x)<=i/2?new u.HitTestResult(u.HitTarget.MovePoint):null}isOutOfScreen(e,t){if(null===this._data)return!0;const{size:i,point:n,angle:r}=this._data;let s;return s=r%(Math.PI/2)==0?i/2:Math.sqrt(i**2*2)/2,n.x+s<0||n.x-s>t||n.y+s<0||n.y-s>e}_drawImpl(e){if(null===this._data)return;const{size:t,svg:i,point:n,angle:r,color:s,background:o,selected:a}=this._data,l=e.context;l.translate(n.x,n.y);const d=r-Math.PI/2;l.rotate(d);const h=t/2;a&&(l.fillStyle=o,l.strokeStyle=p,l.beginPath(),l.rect(-h,-h,t,t),l.closePath(), +l.fill(),l.stroke()),i&&(l.translate(-h,-h),null!==s&&(l.fillStyle=s),i.render(l,{targetViewBox:{x:0,y:0,width:t,height:t},doNotApplyColors:null!==s}))}}class g extends d.LineSourcePaneView{constructor(e,t,i){super(e,t),this._iconRenderer=new _,this._renderer=new a.CompositeRenderer,this._svg=i}renderer(e,t){return this._invalidated&&this._updateImpl(e,t),this._renderer}_updateImpl(e,t){if(super._updateImpl(),this._renderer.clear(),this._points.length<1)return;const i=this._source.properties().childs(),s=i.size.value(),o={point:this._points[0],color:this._iconColor(),size:s,svg:this._svg,angle:i.angle.value(),selected:this.areAnchorsVisible(),background:this._calculateBackgroundColor()};this._iconRenderer.setData(o),this._iconRenderer.isOutOfScreen(e,t)||this._renderer.append(this._iconRenderer);const a=this._points[0],h=this._source.getAnchorLimit();let c=new n.Point(Math.max(h,s)/2,0),u=new n.Point(0,Math.max(h,s)/2);const p=(0,r.rotationMatrix)(i.angle.value());c=(0,r.transformPoint)(p,c),u=(0,r.transformPoint)(p,u);const _=a.add(c);_.data=0,_.nonDiscreteIndex=!0;const g=a.subtract(c);g.data=1,g.nonDiscreteIndex=!0;const f=a.add(u);f.data=2,f.square=!0,f.nonDiscreteIndex=!0;const v=a.subtract(u);v.data=3,v.square=!0,v.nonDiscreteIndex=!0;const x=(0,d.thirdPointCursorType)(_,g),m=[l.PaneCursorType.Default,l.PaneCursorType.Default,x,x];this._renderer.append(this.createLineAnchor({points:[_,g,f,v],pointsCursorType:m},0))}_calculateBackgroundColor(){return(0,o.generateColor)(this._model.backgroundColorAtYPercentFromTop(this._points[0].y/(0,s.ensureNotNull)(this._model.paneForSource(this._source)).height()),60,!0)}}},62912:(e,t,i)=>{"use strict";i.r(t),i.d(t,{TextPaneView:()=>_});var n=i(50151),r=i(86441),s=i(46501),o=i(66103),a=i(80657),l=i(19266),d=i(80101),h=i(78211),c=i(18807),u=i(79191);const p=[o.PaneCursorType.HorizontalResize];class _ extends u.LineSourcePaneView{constructor(e,t,i,n,r,s,o,l){super(e,t),this._textRenderer=new a.TextRenderer,this._noSelection=!1,this._renderer=null,this._offsetX=i,this._offsetY=n,this._vertAlign=r,this._horzAlign=s,this._forceTextAlign=Boolean(o),this._noSelection=!1,this._renderer=null,this._recalculateSourcePointsOnFirstUpdate=l}renderer(e,t){return this._invalidated&&this._updateImpl(e,t),this._renderer}disableSelection(){this._noSelection=!0}isEditMode(){return!this._getModel().readOnly()}_updateImpl(e,t){super._updateImpl(e,t),this._renderer=null;const i=this._getSource(),o=i.priceScale();if(!o||o.isEmpty())return;const a=i.properties().childs(),u=this._getModel(),_={text:a.text.value(),color:a.color.value(),fontSize:a.fontsize.value(),boxPadding:a.fontsize.value()/6,font:s.CHART_FONT_FAMILY,vertAlign:this._vertAlign||"top",horzAlign:this._horzAlign||"left",offsetX:this._offsetX||0,offsetY:this._offsetY||0,forceTextAlign:this._forceTextAlign};if(_.points=i.isFixed()?[(0,n.ensureDefined)(i.fixedPoint())]:this._points,a.fillBackground&&a.fillBackground.value()&&(_.backgroundColor=a.backgroundColor.value()), +a.drawBorder&&a.drawBorder.value()&&(_.borderColor=a.borderColor.value()),a.wordWrap&&a.wordWrap.value()&&(_.wordWrapWidth=a.wordWrapWidth.value()),_.bold=a.bold&&a.bold.value(),_.italic=a.italic&&a.italic.value(),_.highlightBorder=u.selection().isSelected(i),!i.isFixed()&&a.fixedSize&&!a.fixedSize.value()){_.scaleX=u.timeScale().barSpacing()/i.barSpacing();const e=(0,n.ensureNotNull)(o.priceRange());let t=o.height()/e.length();const r=o.logFormula();i.isPriceDencityLog()&&!o.isLog()&&(t=o.height()/((0,h.toLog)(e.maxValue(),r)-(0,h.toLog)(e.minValue(),r))),!i.isPriceDencityLog()&&o.isLog()&&(t=o.height()/((0,h.fromLog)(e.maxValue(),r)-(0,h.fromLog)(e.minValue(),r)));const s=i.priceDencity();void 0!==s&&(_.scaleY=t/s),(void 0===s||void 0===_.scaleY||_.scaleY<=0)&&delete _.scaleY}if(this._textRenderer.setData(_),this._textRenderer.isOutOfScreen(t,e))return;const g=1===_.points.length;if(g&&void 0!==this._recalculateSourcePointsOnFirstUpdate){this._renderer=null;const e=this._textRenderer.measure();return this._recalculateSourcePointsOnFirstUpdate(e.width,e.height),void(this._recalculateSourcePointsOnFirstUpdate=void 0)}if(g&&!this._noSelection){const e=new l.CompositeRenderer;e.append(this._textRenderer);const t=_.points[0].clone(),i=this._textRenderer.measure(),n=i.width,s=i.height;if(_.wordWrapWidth){const i=new r.Point(t.x+n,t.y+s/2);i.data=1,e.append(this.createLineAnchor({points:[i],pointsCursorType:p},1))}const o=new r.Point(t.x+n/2,t.y+s);return o.data=0,e.append(new d.SelectionRenderer({points:[o],bgColors:this._lineAnchorColors([o]),visible:this.areAnchorsVisible(),hittestResult:c.HitTarget.MovePoint,barSpacing:u.timeScale().barSpacing()})),void(this._renderer=e)}this._renderer=this._textRenderer}}},90042:(e,t,i)=>{"use strict";i.r(t),i.d(t,{LineToolThreeDrivesPaneView:()=>u});var n=i(79849),r=i(19266),s=i(80657),o=i(87663),a=i(99031),l=i(73436),d=i(79797),h=i(79191),c=i(46501);class u extends h.LineSourcePaneView{constructor(){super(...arguments),this._numericFormatter=new o.NumericFormatter,this._retrace1LabelRenderer=new s.TextRenderer,this._retrace12LabelRenderer=new s.TextRenderer,this._polyLineRenderer=new d.PolygonRenderer,this._renderer=null}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){super._updateImpl(),this._renderer=null;let e=NaN,t=NaN;if(this._source.points().length>=4){const[,t,i,n]=this._source.points();e=Math.round(100*Math.abs((n.price-i.price)/(i.price-t.price)))/100}if(this._source.points().length>=6){const[,,,e,i,n]=this._source.points();t=Math.round(100*Math.abs((n.price-i.price)/(i.price-e.price)))/100}if(this._points.length<2)return;const i=this._source.properties().childs(),s=new r.CompositeRenderer,o=(e,t)=>({points:[e],text:t,color:i.textcolor.value(),vertAlign:"middle",horzAlign:"center",font:c.CHART_FONT_FAMILY,offsetX:0,offsetY:0,bold:i.bold&&i.bold.value(),italic:i.italic&&i.italic.value(),fontsize:i.fontsize.value(),backgroundColor:i.color.value(),backgroundRoundRect:4}),d=(e,t)=>({points:[e,t],color:i.color.value(), +linewidth:i.linewidth.value(),linestyle:n.LINESTYLE_DOTTED,extendleft:!1,extendright:!1,leftend:l.LineEnd.Normal,rightend:l.LineEnd.Normal}),h={points:this._points,color:i.color.value(),linewidth:i.linewidth.value(),linestyle:n.LINESTYLE_SOLID,leftend:l.LineEnd.Normal,rightend:l.LineEnd.Normal,backcolor:"rgba(0, 0, 0, 0)",fillBackground:!1,filled:!1};if(this._polyLineRenderer.setData(h),s.append(this._polyLineRenderer),!isNaN(e)){const t=new a.TrendLineRenderer;t.setData(d(this._points[1],this._points[3])),s.append(t);const i=o(this._points[1].add(this._points[3]).scaled(.5),this._numericFormatter.format(e));this._retrace1LabelRenderer.setData(i),s.append(this._retrace1LabelRenderer)}if(!isNaN(t)){const e=new a.TrendLineRenderer;e.setData(d(this._points[3],this._points[5])),s.append(e);const i=o(this._points[5].add(this._points[3]).scaled(.5),this._numericFormatter.format(t));this._retrace12LabelRenderer.setData(i),s.append(this._retrace12LabelRenderer)}this.addAnchors(s),this._renderer=s}}},65557:(e,t,i)=>{"use strict";i.r(t),i.d(t,{TimeCyclesPaneView:()=>c});var n=i(86441),r=i(19266),s=i(79191),o=i(87095),a=i(18807),l=i(68441),d=i(15187);class h extends d.MediaCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null}setData(e){this._data=e}hitTest(e){if(null===this._data||e.y>this._data.point.y)return null;if(e.xthis._data.point.x+this._data.width)return null;const t=new n.Point(this._data.point.x+this._data.width/2,this._data.point.y);let i=e.subtract(t);const r=this._data.height/this._data.width;i=new n.Point(i.x,i.y/r);const s=i.length();return Math.abs(s-this._data.width/2)<3?new a.HitTestResult(a.HitTarget.MovePoint):null}_drawImpl(e){if(null===this._data)return;const t=e.context;t.strokeStyle=this._data.color,t.lineWidth=this._data.linewidth,(0,l.setLineStyle)(t,this._data.linestyle),t.save(),t.translate(this._data.point.x+1,this._data.point.y),t.scale(this._data.width,this._data.height),t.beginPath(),t.arc(.5,0,.5,Math.PI,0,!1),t.restore(),t.stroke(),this._data.fillBackground&&(t.fillStyle=(0,o.generateColor)(this._data.backcolor,this._data.transparency),t.fill())}}class c extends s.LineSourcePaneView{constructor(){super(...arguments),this._renderer=null}renderer(e,t){return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){if(super._updateImpl(),this._renderer=null,this._points.length<2)return;const e=this._source.points(),t=e[0],i=e[1],s=Math.min(t.index,i.index),o=Math.max(t.index,i.index),a=o-s,l=this._points[0],d=this._points[1],c=Math.abs(l.x-d.x),u=new r.CompositeRenderer,p=this._source.properties().childs(),_=this._model.timeScale();if(0===a)return;let g=Math.min(l.x,d.x);const f=[];for(let e=s;g>-c;e-=a)g=_.indexToCoordinate(e),f.push(g);g=Math.max(l.x,d.x);for(let e=o;g<_.width();e+=a)g=_.indexToCoordinate(e),f.push(g);for(let e=0;e{"use strict";i.r(t),i.d(t,{TrendAnglePaneView:()=>m});var n=i(50151),r=i(86441),s=i(5531),o=i(34026),a=i(38223),l=i(18807),d=i(73436),h=i(9155),c=i(80657),u=i(99031),p=i(80101),_=i(46501),g=i(21477),f=i(15187);class v extends f.MediaCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null}setData(e){this._data=e}hitTest(e){return null}_drawImpl(e){if(null===this._data)return;const t=e.context;t.translate(this._data.point.x,this._data.point.y),t.strokeStyle=this._data.color,t.setLineDash([1,2]);const i=this._data.size;t.beginPath(),t.moveTo(0,0),t.lineTo(i,0),t.arc(0,0,i,0,-this._data.angle,this._data.angle>0),t.stroke()}}var x=i(48063);class m extends x.TrendToolWithStatsPaneView{constructor(e,t){super(e,t),this._secondPoint=null,this._trendRenderer=new u.TrendLineRenderer,this._angleRenderer=new v,this._angleLabelRenderer=new c.TextRenderer}_getPointsForStats(){return[this._points[0],(0,n.ensureNotNull)(this._middlePoint),(0,n.ensureNotNull)(this._secondPoint)]}_updateImpl(e,t){var i;this._renderer.clear(),super._updateImpl();const n=this._source,c=n.angle();if(this._points.length>0&&null!==c){const e=Math.cos(c),t=-Math.sin(c),i=new r.Point(e,t);this._secondPoint=this._points[0].addScaled(i,n.distance()),this._middlePoint=this._source.calcMiddlePoint(this._points[0],this._secondPoint)}this._invalidated=!1;const u=this._source.priceScale(),f=this._model.timeScale();if(!u||u.isEmpty()||f.isEmpty())return;if(null===this._model.timeScale().visibleBarsStrictRange())return;if(this._source.points().length<2)return;if(this._points.length<2||null===this._secondPoint)return;const v=this._points[0],x=this._points[1],m=this._source.properties().childs();m.showBarsRange.value()||m.showPriceRange.value()||m.showPercentPriceRange.value()||m.showPipsPriceRange.value()||(this._label=null,this._labelData&&(this._labelData.text=""));const w=m.linecolor.value(),R={points:[v,this._secondPoint],color:w,linewidth:m.linewidth.value(),linestyle:m.linestyle.value(),extendleft:m.extendLeft.value(),extendright:m.extendRight.value(),leftend:d.LineEnd.Normal,rightend:d.LineEnd.Normal};this._trendRenderer.setData(R),this._renderer.append(this._trendRenderer);const y=(0,r.box)(new r.Point(0,0),new r.Point(t,e));let T=!1;m.statsPosition.value()===h.StatsPosition.Auto&&(T=(0,r.equalPoints)(v,x)?!(0,o.pointInBox)(v,y):null===(0,s.intersectLineSegmentAndBox)((0,r.lineSegment)(v,x),y));if((this.isHoveredSource()||this.isSelectedSource()||m.alwaysShowStats.value())&&!T&&2===this._points.length){const e=new g.PaneRendererCachedImage(this,0);this._renderer.append(e)}const b=(this.isHoveredSource()||this.isSelectedSource())&&m.showMiddlePoint.value();this._middlePoint&&this._renderer.append(new p.SelectionRenderer({points:[this._middlePoint],bgColors:this._lineAnchorColors([this._middlePoint]),color:w,visible:b&&this.areAnchorsVisible(),hittestResult:l.HitTarget.Regular, +barSpacing:0}));const P={point:v,angle:null!==(i=n.angle())&&void 0!==i?i:0,color:m.linecolor.value(),size:50};this._angleRenderer.setData(P),this._renderer.append(this._angleRenderer);const L=Math.round(180*P.angle/Math.PI)+"º",S={points:[new r.Point(v.x+50,v.y)],text:(0,a.forceLTRStr)(L),color:m.textcolor.value(),horzAlign:"left",font:_.CHART_FONT_FAMILY,offsetX:5,offsetY:0,bold:m.bold.value(),italic:m.italic.value(),fontsize:m.fontsize.value(),vertAlign:"middle"};this._angleLabelRenderer.setData(S),this._renderer.append(this._angleLabelRenderer),R.points.length>=2&&this._addAlertRenderer(this._renderer,R.points);const C=new r.Point(this._secondPoint.x,this._secondPoint.y);C.data=1,this._renderer.append(this.createLineAnchor({points:[v,C]},0))}}},38058:(e,t,i)=>{"use strict";i.r(t),i.d(t,{TrendBasedFibExtensionPaneView:()=>u});var n=i(86441),r=i(72739),s=i(99031),o=i(18807),a=i(19266),l=i(73436),d=i(26702),h=i(80657),c=i(134);class u extends c.LineToolPaneViewFibWithLabels{constructor(e,t){super(e,t),this._trendLineRendererPoints12=new s.TrendLineRenderer,this._trendLineRendererPoints23=new s.TrendLineRenderer,this._rectangleRenderers={},this._hlevelLineRenderers={},this._renderer=new a.CompositeRenderer,this._levels=[]}renderer(e,t){return this._invalidated&&this._updateImpl(t,e),this._renderer}_updateImpl(e,t){var i,a;if(super._updateImpl(),this._renderer.clear(),this._points.length<2)return;const[c,u]=this._points,p=this._source.properties().childs();if(3===this._source.points().length){const e=this._source.priceScale();if(!e||e.isEmpty()||this._model.timeScale().isEmpty())return;const t=null===(i=this._source.ownerSource())||void 0===i?void 0:i.firstValue();if(null==t)return;const[n,r,s]=this._source.points();let o=!1;p.reverse&&p.reverse.value()&&(o=p.reverse.value()),this._levels=[];const a=o?n.price:r.price,l=o?r.price:n.price,h=a-l;let c,u,_;const g=e.isLog()&&p.fibLevelsBasedOnLogScale.value();if(g){c=e.priceToCoordinate(a,t);u=c-e.priceToCoordinate(l,t),_=e.priceToCoordinate(s.price,t)}const f={price:s.price,coordinate:_},v={price:h,coordinate:u},x=this._source.levelsCount();for(let i=1;i<=x;i++){const n=p["level"+i].childs();if(!n.visible.value())continue;const r=n.coeff.value(),s=n.color.value(),o=(0,d.fibLevelCoordinate)(f,v,r,e,t,g),a=(0,d.fibLevelPrice)(f,v,r,e,t,g);this._levels.push({color:s,price:a,y:o,linewidth:p.levelsStyle.childs().linewidth.value(),linestyle:p.levelsStyle.childs().linestyle.value(),index:i})}}const _=p.trendline.childs();if(_.visible.value()){const e={points:[c,u],color:_.color.value(),linewidth:_.linewidth.value(),linestyle:_.linestyle.value(),extendleft:!1,extendright:!1,leftend:l.LineEnd.Normal,rightend:l.LineEnd.Normal};this._trendLineRendererPoints12.setData(e),this._renderer.append(this._trendLineRendererPoints12)}if(this._points.length<3)return void this.addAnchors(this._renderer);const g=this._points[2];if(_.visible.value()){const e={points:[u,g],color:_.color.value(),linewidth:_.linewidth.value(),linestyle:_.linestyle.value(),extendleft:!1,extendright:!1, +leftend:l.LineEnd.Normal,rightend:l.LineEnd.Normal};this._trendLineRendererPoints23.setData(e),this._renderer.append(this._trendLineRendererPoints23)}const f=Math.min(g.x,u.x),v=Math.max(g.x,u.x),x=p.fillBackground.value(),m=p.transparency.value(),w=p.extendLinesLeft.value(),R=p.extendLines.value();if(x)for(let e=0;e0&&x){const t=this._levels[e-1],i={points:[new n.Point(f,this._levels[e].y),new n.Point(v,t.y)],color:this._levels[e].color,linewidth:0,backcolor:this._levels[e].color,fillBackground:!0,transparency:m,extendLeft:w,extendRight:R};this._rectangleRenderers.hasOwnProperty(e)||(this._rectangleRenderers[e]=new r.RectangleRenderer(void 0,void 0,!0));const s=this._rectangleRenderers[e];s.setData(i),this._renderer.append(s)}let y=f,T=v;y===T&&(w&&(y-=1),R&&(T+=1));for(let i=0;i{"use strict";i.r(t),i.d(t,{TrendBasedFibTimePaneView:()=>p});var n=i(86441),r=i(71254),s=i(80657),o=i(72739),a=i(99031),l=i(18807),d=i(19266),h=i(73436),c=i(46501),u=i(79191);class p extends u.LineSourcePaneView{constructor(e,t){super(e,t),this._trendLineRendererPoints12=new a.TrendLineRenderer,this._trendLineRendererPoints23=new a.TrendLineRenderer,this._renderer=new d.CompositeRenderer,this._levels=[]}renderer(e,t){return this._invalidated&&this._updateImpl(e,t),this._renderer}_updateImpl(e,t){var i;super._updateImpl(),this._renderer.clear();const a=this._source.properties().childs();if(3===this._source.points().length){const e=this._model.timeScale();if(e.isEmpty())return;const[t,i,n]=this._source.points();if(this._levels=[],i.index===t.index)return;const r=i.index-t.index,s=n.index;if(null===e.visibleBarsStrictRange())return;for(let t=1;t<=11;t++){const i=a["level"+t].childs();if(!i.visible.value())continue;const n=i.coeff.value(),o=i.color.value(),l=Math.round(s+n*r),d={x:e.indexToCoordinate(l),coeff:n,color:o,linewidth:i.linewidth.value(),linestyle:i.linestyle.value(),index:t,text:String(n)};this._levels.push(d)}}if(this._points.length<2)return +;const u=new d.CompositeRenderer,[p,_]=this._points,g=a.trendline.childs();if(g.visible.value()){const e={points:[p,_],color:g.color.value(),linewidth:g.linewidth.value(),linestyle:g.linestyle.value(),extendleft:!1,extendright:!1,leftend:h.LineEnd.Normal,rightend:h.LineEnd.Normal};this._trendLineRendererPoints12.setData(e),u.append(this._trendLineRendererPoints12)}if(this._points.length<3)return this.addAnchors(u),void(this._renderer=u);const f=this._points[2];if(g.visible.value()){const e={points:[_,f],color:g.color.value(),linewidth:g.linewidth.value(),linestyle:g.linestyle.value(),extendleft:!1,extendright:!1,leftend:h.LineEnd.Normal,rightend:h.LineEnd.Normal};this._trendLineRendererPoints23.setData(e),u.append(this._trendLineRendererPoints23)}if(a.fillBackground.value()){const t=a.transparency.value();for(let i=1;i{"use strict";i.r(t),i.d(t,{TrendLinePaneView:()=>g});var n=i(50151),r=i(86441),s=i(34026),o=i(5531),a=i(21477),l=i(80657),d=i(9155),h=i(80101),c=i(99031),u=i(46501),p=i(18807),_=i(48063);class g extends _.TrendToolWithStatsPaneView{constructor(){super(...arguments),this._trendRenderer=new c.TrendLineRenderer,this._labelRenderer=new l.TextRenderer}_getPointsForStats(){return[this._points[0],(0,n.ensureNotNull)(this._middlePoint),this._points[1]]}_updateImpl(e,t){var i;this._renderer.clear(),this._invalidated=!1;const n=this._source.priceScale(),c=this._model.timeScale();if(!n||n.isEmpty()||c.isEmpty())return;const _=this._model.timeScale().visibleBarsStrictRange();if(null===_)return;const g=this._source.points();if(g.length<2)return;const f=g[0],v=g[1],x=this._source.properties().childs() +;if(f.index<_.firstBar()&&v.index<_.firstBar()&&!x.extendLeft.value()&&!x.extendRight.value())return;if(super._updateImpl(),this._points.length<2)return;x.showPriceRange.value()||x.showPercentPriceRange.value()||x.showPipsPriceRange.value()||x.showBarsRange.value()||x.showDateTimeRange.value()||x.showDistance.value()||x.showAngle.value()||(this._label=null,this._labelData&&(this._labelData.text=""));const m=this._points[0],w=this._points[1];let R;if(x.showLabel&&x.showLabel.value()&&x.text.value().length>0){const n=m.x=2&&this._addAlertRenderer(this._renderer,T.points)}}},48063:(e,t,i)=>{"use strict";i.d(t,{TrendToolWithStatsPaneView:()=>V});var n=i(50151),r=i(86441),s=i(5531),o=i(44352),a=i(38223),l=i(19266),d=i(93572),h=i(87663),c=i(2043),u=i(57322),p=i(57352),_=i(27714),g=i(34026),f=i(49483),v=i(80657),x=i(18807),m=i(68441),w=i(1722),R=i(74359),y=i(57898);class T{constructor(e,t,i){this._ready=!1,this._img=function(e,t,i){const n=new Image;return n.width=t,n.height=t,n.onload=i,n.src=e,n}(e,t,(()=>{this._ready=!0,i()}))}ready(){return this._ready}image(){return this._img}}let b=null;const P=18,L=new class{constructor(e,t){this._icons=new Map,this._onAllIconsLoaded=new y.Delegate,this._pendingLoading=e.length;const i=()=>{ +0==--this._pendingLoading&&this._onAllIconsLoaded.fire()};e.forEach((e=>{const n=this._icons.get(e.name)||new Map;n.set(e.theme,new T(e.imageData,t,i)),this._icons.set(e.name,n)}))}getIcon(e,t){return(0,n.ensureDefined)((0,n.ensureDefined)(this._icons.get(e)).get(t))}onAllIconsReady(){return this._onAllIconsLoaded}}([{name:"angle",theme:"dark",imageData:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHZpZXdCb3g9IjAgMCAxOCAxOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0zLjQ5OTk5IDE1SDIuNjU3NzFMMy4wNjEwNCAxNC4yNjA2TDkuMDYxMDQgMy4yNjA1N0w5LjMwMDQ2IDIuODIxNjJMMTAuMTc4NCAzLjMwMDQ4TDkuOTM4OTMgMy43Mzk0Mkw3LjUxMzg1IDguMTg1NDJDMTAuNTYyMSA5LjY3MjA1IDEwLjk0NTEgMTIuNjI2MSAxMC45OTMxIDE0SDE0LjVIMTVWMTVIMTQuNUgzLjQ5OTk5Wk05Ljk5MTk3IDE0QzkuOTQyMzYgMTIuNzI1OSA5LjU4NjI5IDEwLjI4OCA3LjAzNDM1IDkuMDY0NDlMNC4zNDIyNiAxNEg5Ljk5MTk3WiIgZmlsbD0iI0Y4RjlGRCIvPgo8L3N2Zz4K"},{name:"angle",theme:"light",imageData:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHZpZXdCb3g9IjAgMCAxOCAxOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNMy40OTk5OSAxNUgyLjY1NzcxTDMuMDYxMDQgMTQuMjYwNkw5LjA2MTA0IDMuMjYwNTdMOS4zMDA0NiAyLjgyMTYyTDEwLjE3ODQgMy4zMDA0OEw5LjkzODkzIDMuNzM5NDJMNy41MTM4NSA4LjE4NTQyQzEwLjU2MjEgOS42NzIwNSAxMC45NDUxIDEyLjYyNjEgMTAuOTkzMSAxNEgxNC41SDE1VjE1SDE0LjVIMy40OTk5OVpNOS45OTE5NyAxNEM5Ljk0MjM2IDEyLjcyNTkgOS41ODYyOSAxMC4yODggNy4wMzQzNSA5LjA2NDQ5TDQuMzQyMjYgMTRIOS45OTE5N1oiIGZpbGw9IiMyQTJFMzkiLz4NCjwvc3ZnPg0K"},{name:"barsRange",theme:"dark",imageData:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHZpZXdCb3g9IjAgMCAxOCAxOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNMiAzVjMuNVY1SDFWNlYxM1YxNEgyVjE1LjVWMTZIM1YxNS41VjE0SDRWMTNWNlY1SDNWMy41VjNIMlpNOC4yMDcxMSA3LjVMNy44NTM1NSA3Ljg1MzU1TDYuNzA3MTEgOUgxMS4yOTI5TDEwLjE0NjQgNy44NTM1NUw5Ljc5Mjg5IDcuNUwxMC41IDYuNzkyODlMMTAuODUzNiA3LjE0NjQ1TDEyLjg1MzYgOS4xNDY0NUwxMy4yMDcxIDkuNUwxMi44NTM2IDkuODUzNTVMMTAuODUzNiAxMS44NTM2TDEwLjUgMTIuMjA3MUw5Ljc5Mjg5IDExLjVMMTAuMTQ2NCAxMS4xNDY0TDExLjI5MjkgMTBINi43MDcxMUw3Ljg1MzU1IDExLjE0NjRMOC4yMDcxMSAxMS41TDcuNSAxMi4yMDcxTDcuMTQ2NDUgMTEuODUzNkw1LjE0NjQ1IDkuODUzNTVMNC43OTI4OSA5LjVMNS4xNDY0NSA5LjE0NjQ1TDcuMTQ2NDUgNy4xNDY0NUw3LjUgNi43OTI4OUw4LjIwNzExIDcuNVpNMyA2SDJWMTNIM1Y2Wk0xNSAzLjVWM0gxNlYzLjVWNUgxN1Y2VjEzVjE0SDE2VjE1LjVWMTZIMTVWMTUuNVYxNEgxNFYxM1Y2VjVIMTVWMy41Wk0xNSA2SDE2VjEzSDE1VjZaIiBmaWxsPSIjRjhGOUZEIi8+DQo8L3N2Zz4NCg=="},{name:"barsRange",theme:"light", imageData:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHZpZXdCb3g9IjAgMCAxOCAxOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNMiAzVjMuNVY1SDFWNlYxM1YxNEgyVjE1LjVWMTZIM1YxNS41VjE0SDRWMTNWNlY1SDNWMy41VjNIMlpNOC4yMDcxMSA3LjVMNy44NTM1NSA3Ljg1MzU1TDYuNzA3MTEgOUgxMS4yOTI5TDEwLjE0NjQgNy44NTM1NUw5Ljc5Mjg5IDcuNUwxMC41IDYuNzkyODlMMTAuODUzNiA3LjE0NjQ1TDEyLjg1MzYgOS4xNDY0NUwxMy4yMDcxIDkuNUwxMi44NTM2IDkuODUzNTVMMTAuODUzNiAxMS44NTM2TDEwLjUgMTIuMjA3MUw5Ljc5Mjg5IDExLjVMMTAuMTQ2NCAxMS4xNDY0TDExLjI5MjkgMTBINi43MDcxMUw3Ljg1MzU1IDExLjE0NjRMOC4yMDcxMSAxMS41TDcuNSAxMi4yMDcxTDcuMTQ2NDUgMTEuODUzNkw1LjE0NjQ1IDkuODUzNTVMNC43OTI4OSA5LjVMNS4xNDY0NSA5LjE0NjQ1TDcuMTQ2NDUgNy4xNDY0NUw3LjUgNi43OTI4OUw4LjIwNzExIDcuNVpNMyA2SDJWMTNIM1Y2Wk0xNSAzLjVWM0gxNlYzLjVWNUgxN1Y2VjEzVjE0SDE2VjE1LjVWMTZIMTVWMTUuNVYxNEgxNFYxM1Y2VjVIMTVWMy41Wk0xNSA2SDE2VjEzSDE1VjZaIiBmaWxsPSIjMkEyRTM5Ii8+DQo8L3N2Zz4NCg=="},{name:"priceRange",theme:"dark",imageData:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHZpZXdCb3g9IjAgMCAxOCAxOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNMyAySDMuNUgxMy41SDE0VjNIMTMuNUgzLjVIM1YyWk04LjUgMy43OTI4OUw4Ljg1MzU1IDQuMTQ2NDVMMTAuODUzNiA2LjE0NjQ1TDExLjIwNzEgNi41TDEwLjUgNy4yMDcxMUwxMC4xNDY0IDYuODUzNTVMOSA1LjcwNzExVjEyLjI5MjlMMTAuMTQ2NCAxMS4xNDY0TDEwLjUgMTAuNzkyOUwxMS4yMDcxIDExLjVMMTAuODUzNiAxMS44NTM2TDguODUzNTUgMTMuODUzNkw4LjUgMTQuMjA3MUw4LjE0NjQ1IDEzLjg1MzZMNi4xNDY0NSAxMS44NTM2TDUuNzkyODkgMTEuNUw2LjUgMTAuNzkyOUw2Ljg1MzU1IDExLjE0NjRMOCAxMi4yOTI5VjUuNzA3MTFMNi44NTM1NSA2Ljg1MzU1TDYuNSA3LjIwNzExTDUuNzkyODkgNi41TDYuMTQ2NDUgNi4xNDY0NUw4LjE0NjQ1IDQuMTQ2NDVMOC41IDMuNzkyODlaTTMuNSAxNkgzVjE1SDMuNUgxMy41SDE0VjE2SDEzLjVIMy41WiIgZmlsbD0iI0Y4RjlGRCIvPg0KPC9zdmc+DQo="},{name:"priceRange",theme:"light",imageData:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHZpZXdCb3g9IjAgMCAxOCAxOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNMyAySDMuNUgxMy41SDE0VjNIMTMuNUgzLjVIM1YyWk04LjUgMy43OTI4OUw4Ljg1MzU1IDQuMTQ2NDVMMTAuODUzNiA2LjE0NjQ1TDExLjIwNzEgNi41TDEwLjUgNy4yMDcxMUwxMC4xNDY0IDYuODUzNTVMOSA1LjcwNzExVjEyLjI5MjlMMTAuMTQ2NCAxMS4xNDY0TDEwLjUgMTAuNzkyOUwxMS4yMDcxIDExLjVMMTAuODUzNiAxMS44NTM2TDguODUzNTUgMTMuODUzNkw4LjUgMTQuMjA3MUw4LjE0NjQ1IDEzLjg1MzZMNi4xNDY0NSAxMS44NTM2TDUuNzkyODkgMTEuNUw2LjUgMTAuNzkyOUw2Ljg1MzU1IDExLjE0NjRMOCAxMi4yOTI5VjUuNzA3MTFMNi44NTM1NSA2Ljg1MzU1TDYuNSA3LjIwNzExTDUuNzkyODkgNi41TDYuMTQ2NDUgNi4xNDY0NUw4LjE0NjQ1IDQuMTQ2NDVMOC41IDMuNzkyODlaTTMuNSAxNkgzVjE1SDMuNUgxMy41SDE0VjE2SDEzLjVIMy41WiIgZmlsbD0iIzJBMkUzOSIvPg0KPC9zdmc+DQo="}],P),S=new Map;class C{constructor(e,t,i){this._fontSize=0,this._preRendered=!1,this._boundingBox=null,this._rect=null,this._padding=null,this._textPoint=null,this._textSizeCache=t,this._data=e,this._fontSize=e.fontSize?e.fontSize:12,this._lineSpacing=(0, w.isNumber)(this._data.lineSpacing)&&this._data.lineSpacing?this._data.lineSpacing:0,e.lines=this._lines=null===e.text?[]:(0,v.wordWrap)(e.text,this.fontStyle(),e.wordWrapWidth),this._hittest=i||new x.HitTestResult(x.HitTarget.MovePoint)}fontStyle(){return`${this._data.bold?"bold ":""}${this._data.italic?"italic ":""}${this._fontSize}px ${this._data.font}`}draw(e,t){if(0===this._data.points.length||null===this._data.text)return{width:0};this._preRender();const i=this._fontSize+this._lineSpacing;e.textBaseline="top",e.font=this.fontStyle();const r=(0,n.ensureNotNull)(this._rect);if(this._rect){if("right"!==this._data.horzAlign&&"center"!==this._data.horzAlign||!0!==this._data.doNotAlignText&&(e.textAlign="right"===this._data.horzAlign?"end":"center"),this._data.backgroundRoundRect?((0,m.drawRoundRect)(e,r.x,r.y,r.w,r.h,this._data.backgroundRoundRect),e.fillStyle=this._data.backgroundColor,e.fill(),e.globalAlpha=1):(e.fillStyle=this._data.backgroundColor,e.fillRect(r.x,r.y,r.w,r.h),e.globalAlpha=1),this._data.icons){let s=0;const o=Math.ceil((P-this._fontSize)/2),a=(0,n.ensureNotNull)(this._padding);for(const n of this._data.icons){const l=Math.round(r.x+a.left),d=Math.round(r.y+a.top+i*s-o);this._drawIcon(e,l,d,n,Boolean(this._data.isDark),t),s+=1}}}else"right"===this._data.horzAlign?e.textAlign="end":"center"===this._data.horzAlign&&(e.textAlign="center");const s=(0,n.ensureNotNull)(this._textPoint),o=s.x;let a=s.y;e.fillStyle=this._data.color;for(const t of this._lines)e.fillText(t,o,a),a+=i;return{width:r.w+2}}hitTest(e){return 0===this._data.points.length?null:(this._preRender(),this._boundingBox&&(0,g.pointInBox)(e,this._boundingBox)?this._hittest:null)}_preRender(){if(this._preRendered)return;const e=function(){if(null!==b)return b;const e=(0,R.createDisconnectedCanvas)(document,(0,_.size)({width:0,height:0}));return b=(0,R.getPrescaledContext2D)(e),b}(),t=this._data.points[0].x;let i=t;const n=this._data.points[0].y;let s=n;const o=this._fontSize,a=this._lineSpacing,l=(o+a)*this._lines.length-a;e.textBaseline="top",e.font=this.fontStyle();const d=[];let h;if(this._data.wordWrapWidth){h=this._data.wordWrapWidth;for(let e=0;e=this._actualCapacity&&(this._actualCapacity++,this._recreateCanvas()),t}_effectiveState(e){var t,i diff --git a/charting_library/bundles/new-edit-object-dialog.4788a10b2e7019e41282.js b/charting_library/bundles/new-edit-object-dialog.59756c2933ec24d194f0.js similarity index 94% rename from charting_library/bundles/new-edit-object-dialog.4788a10b2e7019e41282.js rename to charting_library/bundles/new-edit-object-dialog.59756c2933ec24d194f0.js index 83d09795..8bb207ec 100644 --- a/charting_library/bundles/new-edit-object-dialog.4788a10b2e7019e41282.js +++ b/charting_library/bundles/new-edit-object-dialog.59756c2933ec24d194f0.js @@ -7,8 +7,8 @@ o.ensureDefined)(null!==(e=null==d?void 0:d.value())&&void 0!==e?e:n),onChange:t title:(0,o.ensureDefined)(null===(l=null==p?void 0:p[a])||void 0===l?void 0:l.title),property:d,isRGB:m,isFundamental:false,showLineWidth:"line"===u});if("arrows"===u){const e=this._getPlotSwitch(a,Ze(s,a),d.display);if(m)return e;const t=i.up,l=i.down;return t||l?r.createElement(r.Fragment,null,e,t&&t.palette&&t.paletteProps?r.createElement(ce,{title:Fe,plot:n,palette:t.palette,paletteProps:t.paletteProps,styleProp:d,showSeparator:!1,showOnlyTitle:!0,offset:!0}):r.createElement(ge,{id:a,isRGB:m,title:Fe,color:d.colorup,display:d.display,transparency:d.transparency,switchable:!1,grouped:!0,offset:!0}),l&&l.palette&&l.paletteProps?r.createElement(ce,{title:Ge,plot:n,palette:l.palette,paletteProps:l.paletteProps,styleProp:d,showSeparator:!1,showOnlyTitle:!0,offset:!0}):r.createElement(ge,{id:a,isRGB:m,title:Ge,color:d.colordown,display:d.display,transparency:d.transparency,switchable:!1,grouped:!0,offset:!0}),r.createElement(oe.PropertyTable.GroupSeparator,null)):r.createElement(be,{id:a,property:d,isRGB:m,plot:n,palettes:i,styleProp:d})}if("chars"===u||"shapes"===u){const e=(0,o.ensureDefined)(null==p?void 0:p[a]),t=e.title;return r.createElement(r.Fragment,null,"chars"===u?r.createElement(De,{id:a,title:t,char:e.char,property:d,hasPalette:Boolean(h&&h.palette),isRGB:m}):r.createElement(ze,{id:a,title:t,property:d,hasPalette:Boolean(h&&h.palette),isRGB:m}),h&&h.palette&&h.paletteProps&&r.createElement(ce,{title:t,plot:n,palette:h.palette,paletteProps:h.paletteProps,hideVisibilitySwitch:!0,styleProp:d}))}if((0,x.isOhlcPlot)(n)){const e=n.target,t=s.properties().ohlcPlots[e],l=(0,o.ensureDefined)((0,o.ensureDefined)(s.metaInfo().ohlcPlots)[e]),c=this._getPlotSwitch(a,l.title,t.display);if(m)return c;const p=i.wick&&i.wick.palette&&i.wick.paletteProps,d=i.border&&i.border.palette&&i.border.paletteProps;return r.createElement(r.Fragment,null,c,h&&h.palette&&h.paletteProps?r.createElement(ce,{title:Ue,plot:n,palette:h.palette,paletteProps:h.paletteProps,styleProp:t,showSeparator:!1,showOnlyTitle:!0,offset:!0}):r.createElement(ge,{id:a,isRGB:m,title:Ue,display:t.display,color:t.color,transparency:t.transparency,switchable:!1,grouped:!0,offset:!0}),i.wick&&i.wick.palette&&i.wick.paletteProps&&r.createElement(ce,{title:Oe,plot:n,palette:i.wick.palette,paletteProps:i.wick.paletteProps,styleProp:t,showSeparator:!1,showOnlyTitle:!0,offset:!0}),Boolean(!p&&t.wickColor)&&r.createElement(ge,{id:a,isRGB:m,title:Oe,display:t.display,color:t.wickColor,transparency:t.transparency,switchable:!1,grouped:!0,offset:!0}),i.border&&i.border.palette&&i.border.paletteProps&&r.createElement(ce,{title:je,plot:n,palette:i.border.palette,paletteProps:i.border.paletteProps,styleProp:t,showSeparator:!1,showOnlyTitle:!0,offset:!0}),Boolean(!d&&t.borderColor)&&r.createElement(ge,{id:a,isRGB:m,title:je,display:t.display,color:t.borderColor,transparency:t.transparency,switchable:!1,grouped:!0,offset:!0}),r.createElement(oe.PropertyTable.GroupSeparator,null))}return He.logError("Unknown plot type: "+u),null}_getPlotSwitch(e,t,l){ return r.createElement(oe.PropertyTable.Row,null,r.createElement(oe.PropertyTable.Cell,{placement:"first",colSpan:2},r.createElement(pe,{id:e,title:t,display:l})))}}function Ze(e,t){const l=(0,o.ensureDefined)(e.metaInfo().styles),{title:n}=(0,o.ensureDefined)(l[t]);return(0,o.ensureDefined)(n)}var qe=l(47510),Ke=l(53598);const $e=new s.TranslatedString("change line style",i.t(null,void 0,l(28691)));class Xe extends r.PureComponent{constructor(){super(...arguments),this._onLineStyleChange=e=>{const{setValue:t}=this.context,{lineStyle:l}=this.props;(0,V.setPropertyValue)(l,(l=>t(l,e,$e)))}}render(){const{lineStyle:e,...t}=this.props;return r.createElement(Ke.LineStyleSelect,{...t,lineStyle:(0,V.getPropertyValue)(e),lineStyleChange:this._onLineStyleChange})}}Xe.contextType=L.StylePropertyContext;const Ye=new s.TranslatedString("change value",i.t(null,void 0,l(50463)));class Je extends r.PureComponent{constructor(){super(...arguments),this._onValueChange=e=>{const{setValue:t}=this.context,{value:l}=this.props.property;t(l,e,Ye)}}render(){const{id:e,name:t,property:{color:l,linestyle:n,linewidth:o,transparency:i,value:s,visible:a}}=this.props;return r.createElement(B.InputRow,{labelAlign:"adaptive",label:r.createElement(M,{id:e,title:t,visible:a})},r.createElement("div",{className:te.block},r.createElement("div",{className:te.group},r.createElement(ee.ColorWithThicknessSelect,{disabled:!a.value(),color:l,transparency:i,thickness:o}),r.createElement(Xe,{id:(0,_.createDomId)(e,"line-style-select"),disabled:!a.value(),className:te.smallStyleControl,lineStyle:n})),r.createElement("div",{className:Ce(te.wrapGroup,te.defaultSelect,te.additionalSelect)},r.createElement(qe.FloatInputComponent,{input:{id:"",name:"",type:"float",defval:0},value:s.value(),disabled:!a.value(),onChange:this._onValueChange}))))}}Je.contextType=L.StylePropertyContext;class et extends r.PureComponent{render(){const{orders:{visible:e,showLabels:t,showQty:n}}=this.props;return r.createElement(r.Fragment,null,r.createElement(oe.PropertyTable.Row,null,r.createElement(oe.PropertyTable.Cell,{placement:"first",colSpan:2},r.createElement(M,{id:"chart-orders-switch",title:i.t(null,void 0,l(77409)),visible:e}))),r.createElement(oe.PropertyTable.Row,null,r.createElement(oe.PropertyTable.Cell,{placement:"first",colSpan:2},r.createElement(M,{id:"chart-orders-labels-switch",title:i.t(null,void 0,l(86520)),visible:t}))),r.createElement(oe.PropertyTable.Row,null,r.createElement(oe.PropertyTable.Cell,{placement:"first",colSpan:2},r.createElement(M,{id:"chart-orders-qty-switch",title:i.t(null,void 0,l(66596)),visible:n}))))}}et.contextType=L.StylePropertyContext;var tt=l(90164),lt=l(96438);const nt=new s.TranslatedString("change percent width",i.t(null,void 0,l(51081))),rt=new s.TranslatedString("change placement",i.t(null,void 0,l(47634))),ot=new s.TranslatedString("change values visibility",i.t(null,void 0,l(12628))),it=[{value:tt.HHistDirection.LeftToRight,content:i.t(null,void 0,l(19286))},{value:tt.HHistDirection.RightToLeft,content:i.t(null,void 0,l(21141)) }],st=i.t(null,void 0,l(95247)),at=i.t(null,void 0,l(91502)),ct=i.t(null,void 0,l(91322)),pt=i.t(null,void 0,l(19221));class dt extends r.PureComponent{constructor(){super(...arguments),this._onPercentWidthChange=e=>{const{setValue:t}=this.context,{percentWidth:l}=this.props.property.childs();t(l,e,nt)},this._onPlacementChange=e=>{const{setValue:t}=this.context,{direction:l}=this.props.property.childs();t(l,e,rt)},this._onShowValuesChange=e=>{const{setValue:t}=this.context,{showValues:l}=this.props.property.childs();t(l,e,ot)}}render(){const{hHistInfo:e,property:t}=this.props,{percentWidth:l,direction:n,showValues:o,valuesColor:i,visible:s}=t.childs(),{title:a}=e;return r.createElement(r.Fragment,null,r.createElement(oe.PropertyTable.Row,null,r.createElement(oe.PropertyTable.Cell,{placement:"first",colSpan:2,grouped:!0},r.createElement(M,{id:a,title:a,visible:s}))),r.createElement(B.InputRow,{label:r.createElement("div",{className:te.childRowContainer},st),grouped:!0},r.createElement(lt.IntegerInputComponent,{input:{id:"",name:"",type:"integer",defval:0},value:l.value(),disabled:!s.value(),onChange:this._onPercentWidthChange})),r.createElement(B.InputRow,{label:r.createElement("div",{className:te.childRowContainer},at),grouped:!0},r.createElement(Ee.Select,{id:"hhist-graphic-placement-select",disabled:!s.value(),className:te.defaultSelect,menuItemClassName:te.defaultSelectItem,items:it,value:n.value(),onChange:this._onPlacementChange})),r.createElement(oe.PropertyTable.Row,null,r.createElement(oe.PropertyTable.Cell,{className:te.childRowContainer,placement:"first",colSpan:2,grouped:!0},r.createElement(D.BoolInputComponent,{label:ct,input:{id:a+"_showValues",type:"bool",defval:!0,name:"visible"},value:!o||o.value(),disabled:!s.value(),onChange:this._onShowValuesChange}))),r.createElement(B.InputRow,{label:r.createElement("div",{className:te.childRowContainer},pt),grouped:!0},r.createElement(ee.ColorWithThicknessSelect,{disabled:s&&!s.value(),color:i})),this._renderColors(),r.createElement(oe.PropertyTable.GroupSeparator,null))}_renderColors(){const{property:e,hHistInfo:t}=this.props,{colors:l,transparencies:n,visible:o}=e.childs(),{titles:i}=t;return l.childNames().map((e=>r.createElement(B.InputRow,{key:e,grouped:!0,label:r.createElement("div",{className:te.childRowContainer},i[+e])},r.createElement(ee.ColorWithThicknessSelect,{disabled:!o.value(),color:l[+e],transparency:n[+e]}))))}}dt.contextType=L.StylePropertyContext;class ut extends r.PureComponent{render(){const{title:e,property:t}=this.props,{color:l,width:n,style:o,visible:i}=t.childs();return r.createElement(B.InputRow,{label:r.createElement(M,{id:e,title:e,visible:i})},r.createElement(ee.ColorWithThicknessSelect,{disabled:!i.value(),color:l,transparency:t.child("transparency"),thickness:n}),r.createElement(Xe,{id:(0,_.createDomId)(e,"line-style-select"),disabled:!i.value(),className:te.smallStyleControl,lineStyle:o}))}}ut.contextType=L.StylePropertyContext;var ht,mt;l(1115);!function(e){e.Triangle="triangle",e.Rectangle="rectangle"}(ht||(ht={})), -function(e){e.Verdana="Verdana",e.CourierNew="Courier New",e.TimesNewRoman="Times New Roman",e.Arial="Arial"}(mt||(mt={}));class vt extends r.PureComponent{render(){const{graphicType:e,study:t}=this.props,l=t.metaInfo(),n=l.graphics,i=t.properties().graphics.childs(),s=(0,o.ensureDefined)(n[e]);return Object.keys(s).map(((t,n)=>{var s,a,c,p;const d=(0,o.ensureDefined)(null===(s=i[e])||void 0===s?void 0:s.childs()[t]);return"horizlines"===e||"vertlines"===e?r.createElement(ut,{key:t,title:(0,o.ensureDefined)(null===(a=l.graphics[e])||void 0===a?void 0:a[t]).name,property:d}):"lines"===e?r.createElement(ut,{key:t,title:(0,o.ensureDefined)(null===(c=l.graphics.lines)||void 0===c?void 0:c[t]).title,property:d}):"hhists"===e?r.createElement(dt,{key:t,hHistInfo:(0,o.ensureDefined)(null===(p=l.graphics.hhists)||void 0===p?void 0:p[t]),property:d}):null}))}}var yt=l(66045);const gt=new s.TranslatedString("change font size",i.t(null,void 0,l(7378))),bt=[10,11,12,14,16,20,24,28,32,40].map((e=>({value:e,title:e.toString()})));class wt extends r.PureComponent{constructor(){super(...arguments),this._onFontSizeChange=e=>{const{setValue:t}=this.context,{fontSize:l}=this.props;t(l,e,gt)}}render(){const{fontSize:e,...t}=this.props;return r.createElement(yt.FontSizeSelect,{...t,fontSizes:bt,fontSize:e.value(),fontSizeChange:this._onFontSizeChange})}}wt.contextType=L.StylePropertyContext;const ft=new s.TranslatedString("change visibility",i.t(null,void 0,l(21511))),Ct=i.t(null,void 0,l(64606)),Pt=i.t(null,void 0,l(94420)),St={Traditional:new Set(["S5/R5","S4/R4","S3/R3","S2/R2","S1/R1","P"]),Fibonacci:new Set(["S3/R3","S2/R2","S1/R1","P"]),Woodie:new Set(["S4/R4","S3/R3","S2/R2","S1/R1","P"]),Classic:new Set(["S4/R4","S3/R3","S2/R2","S1/R1","P"]),DM:new Set(["S1/R1","P"]),DeMark:new Set(["S1/R1","P"]),Camarilla:new Set(["S4/R4","S3/R3","S2/R2","S1/R1","P"])};class Et extends r.PureComponent{constructor(){super(...arguments),this._onChange=e=>{const{setValue:t}=this.context,{levelsStyle:l}=this.props.property.childs(),{showLabels:n}=l.childs();t(n,e,ft)}}render(){const{fontsize:e,levelsStyle:t}=this.props.property.childs();return r.createElement(r.Fragment,null,r.createElement(B.InputRow,{labelAlign:"adaptive",label:r.createElement("span",null,Ct)},r.createElement("div",{className:te.block},r.createElement("div",{className:Ce(te.wrapGroup,te.additionalSelect)},r.createElement(wt,{id:"pivot-points-standard-font-size-select",fontSize:e})))),r.createElement(oe.PropertyTable.Row,null,r.createElement(oe.PropertyTable.Cell,{placement:"first",colSpan:2},r.createElement(D.BoolInputComponent,{label:Pt,input:{id:"ShowLabels",type:"bool",defval:!0,name:"visible"},value:t.childs().showLabels.value(),onChange:this._onChange}))),this._renderColors())}_renderColors(){const{levelsStyle:e,inputs:t}=this.props.property.childs(),{colors:l,widths:n,visibility:i}=e.childs(),{kind:s}=t.childs(),a=(0,o.ensureDefined)(St[s.value()]);return l.childNames().filter((e=>a.has(e))).map((e=>r.createElement(ye,{key:e,id:e,title:e,color:l.childs()[e], -visible:i.childs()[e],thickness:n.childs()[e]})))}}Et.contextType=L.StylePropertyContext;const Tt=i.t(null,void 0,l(91502)),kt=[{value:tt.HHistDirection.RightToLeft,content:i.t(null,void 0,l(21141))},{value:tt.HHistDirection.LeftToRight,content:i.t(null,void 0,l(19286))}],_t=new s.TranslatedString("change visibility",i.t(null,void 0,l(21511))),xt=i.t(null,void 0,l(14414)),It=i.t(null,void 0,l(91322)),Lt=i.t(null,void 0,l(95247)),Dt=i.t(null,void 0,l(31577)),Vt=i.t(null,{context:"input"},l(45811)),Rt=i.t(null,{context:"input"},l(41596));class Mt extends r.PureComponent{constructor(){super(...arguments),this._onChange=e=>{this._setHhistsProperty("visible",e)},this._onShowValuesChange=e=>{this._setHhistsProperty("showValues",e)},this._onValueChange=e=>{this._setHhistsProperty("percentWidth",e)},this._onDirectionChange=e=>{this._setHhistsProperty("direction",e)}}render(){var e,t,n,s,a,c;const{metaInfo:p}=this.props,{graphics:d,styles:u,showLabelsOnPriceScale:h,showLegendValues:m}=this.props.property.childs(),{hhists:v,horizlines:y,polygons:g}=d.childs(),b=(0,o.ensureDefined)(p.graphics.hhists),w=Object.keys(b),f=v.childs()[w[0]],C=f.childs().visible,P=w.map((e=>v.childs()[e].childs().showValues)),S=f.childs().percentWidth,E=f.childs().direction,T=w.map((e=>v.childs()[e].childs().valuesColor)),k=null===(e=y.childs())||void 0===e?void 0:e.vahLines,_=null===(t=p.graphics.horizlines)||void 0===t?void 0:t.vahLines,x=null===(n=y.childs())||void 0===n?void 0:n.valLines,I=null===(s=p.graphics.horizlines)||void 0===s?void 0:s.valLines,L=y.childs().pocLines,V=(0,o.ensureDefined)(null===(a=p.graphics.horizlines)||void 0===a?void 0:a.pocLines),R=u.childs().developingPoc,N=new ae.StudyPlotVisibleProperty(R.childs().display),W=(0,o.ensureDefined)(null===(c=p.styles)||void 0===c?void 0:c.developingPoc),A=u.childs().developingVAHigh,z=new ae.StudyPlotVisibleProperty(A.childs().display),H=u.childs().developingVALow,F=new ae.StudyPlotVisibleProperty(H.childs().display),G=p.graphics.polygons&&p.graphics.polygons.histBoxBg;return r.createElement(r.Fragment,null,r.createElement(oe.PropertyTable.Row,null,r.createElement(oe.PropertyTable.Cell,{placement:"first",colSpan:2},r.createElement(D.BoolInputComponent,{label:xt,input:{id:"VolumeProfile",type:"bool",defval:!0,name:"visible"},value:C.value(),onChange:this._onChange}))),r.createElement(oe.PropertyTable.Row,null,r.createElement(oe.PropertyTable.Cell,{placement:"first"},r.createElement("div",{className:te.childRowContainer},r.createElement(D.BoolInputComponent,{disabled:!C.value(),label:It,input:{id:"ShowValues",type:"bool",defval:!0,name:"visible"},value:P[0].value(),onChange:this._onShowValuesChange}))),r.createElement(oe.PropertyTable.Cell,{placement:"last"},r.createElement(ee.ColorWithThicknessSelect,{disabled:!C.value()||!P[0].value(),color:T}))),r.createElement(oe.PropertyTable.Row,null,r.createElement(oe.PropertyTable.Cell,{placement:"first"},r.createElement("div",{className:te.childRowContainer},Lt)),r.createElement(oe.PropertyTable.Cell,{placement:"last" +function(e){e.Verdana="Verdana",e.CourierNew="Courier New",e.TimesNewRoman="Times New Roman",e.Arial="Arial"}(mt||(mt={}));class vt extends r.PureComponent{render(){const{graphicType:e,study:t}=this.props,l=t.metaInfo(),n=l.graphics,i=t.properties().graphics.childs(),s=(0,o.ensureDefined)(n[e]);return Object.keys(s).map(((t,n)=>{var s,a,c,p;const d=(0,o.ensureDefined)(null===(s=i[e])||void 0===s?void 0:s.childs()[t]);return"horizlines"===e||"vertlines"===e?r.createElement(ut,{key:t,title:(0,o.ensureDefined)(null===(a=l.graphics[e])||void 0===a?void 0:a[t]).name,property:d}):"lines"===e?r.createElement(ut,{key:t,title:(0,o.ensureDefined)(null===(c=l.graphics.lines)||void 0===c?void 0:c[t]).title,property:d}):"hhists"===e?r.createElement(dt,{key:t,hHistInfo:(0,o.ensureDefined)(null===(p=l.graphics.hhists)||void 0===p?void 0:p[t]),property:d}):null}))}}var yt=l(66045);const gt=new s.TranslatedString("change font size",i.t(null,void 0,l(7378))),bt=[10,11,12,14,16,20,24,28,32,40].map((e=>({value:e,title:e.toString()})));class wt extends r.PureComponent{constructor(){super(...arguments),this._onFontSizeChange=e=>{const{setValue:t}=this.context,{fontSize:l}=this.props;t(l,e,gt)}}render(){const{fontSize:e,...t}=this.props;return r.createElement(yt.FontSizeSelect,{...t,fontSizes:bt,fontSize:e.value(),fontSizeChange:this._onFontSizeChange})}}wt.contextType=L.StylePropertyContext;const ft=new s.TranslatedString("change visibility",i.t(null,void 0,l(21511))),Ct=i.t(null,void 0,l(64606)),Pt=i.t(null,void 0,l(94420)),St={Traditional:new Set(["S5/R5","S4/R4","S3/R3","S2/R2","S1/R1","P"]),Fibonacci:new Set(["S3/R3","S2/R2","S1/R1","P"]),Woodie:new Set(["S4/R4","S3/R3","S2/R2","S1/R1","P"]),Classic:new Set(["S4/R4","S3/R3","S2/R2","S1/R1","P"]),DM:new Set(["S1/R1","P"]),DeMark:new Set(["S1/R1","P"]),Camarilla:new Set(["S4/R4","S3/R3","S2/R2","S1/R1","P"]),Floor:new Set(["S3/R3","S2/R2","S1/R1","P"])};class Et extends r.PureComponent{constructor(){super(...arguments),this._onChange=e=>{const{setValue:t}=this.context,{levelsStyle:l}=this.props.property.childs(),{showLabels:n}=l.childs();t(n,e,ft)}}render(){const{fontsize:e,levelsStyle:t}=this.props.property.childs();return r.createElement(r.Fragment,null,r.createElement(B.InputRow,{labelAlign:"adaptive",label:r.createElement("span",null,Ct)},r.createElement("div",{className:te.block},r.createElement("div",{className:Ce(te.wrapGroup,te.additionalSelect)},r.createElement(wt,{id:"pivot-points-standard-font-size-select",fontSize:e})))),r.createElement(oe.PropertyTable.Row,null,r.createElement(oe.PropertyTable.Cell,{placement:"first",colSpan:2},r.createElement(D.BoolInputComponent,{label:Pt,input:{id:"ShowLabels",type:"bool",defval:!0,name:"visible"},value:t.childs().showLabels.value(),onChange:this._onChange}))),this._renderColors())}_renderColors(){const{levelsStyle:e,inputs:t}=this.props.property.childs(),{colors:l,widths:n,visibility:i}=e.childs(),{kind:s}=t.childs(),a=(0,o.ensureDefined)(St[s.value()]);return l.childNames().filter((e=>a.has(e))).map((e=>r.createElement(ye,{key:e,id:e, +title:e,color:l.childs()[e],visible:i.childs()[e],thickness:n.childs()[e]})))}}Et.contextType=L.StylePropertyContext;const Tt=i.t(null,void 0,l(91502)),kt=[{value:tt.HHistDirection.RightToLeft,content:i.t(null,void 0,l(21141))},{value:tt.HHistDirection.LeftToRight,content:i.t(null,void 0,l(19286))}],_t=new s.TranslatedString("change visibility",i.t(null,void 0,l(21511))),xt=i.t(null,void 0,l(14414)),It=i.t(null,void 0,l(91322)),Lt=i.t(null,void 0,l(95247)),Dt=i.t(null,void 0,l(31577)),Vt=i.t(null,{context:"input"},l(45811)),Rt=i.t(null,{context:"input"},l(41596));class Mt extends r.PureComponent{constructor(){super(...arguments),this._onChange=e=>{this._setHhistsProperty("visible",e)},this._onShowValuesChange=e=>{this._setHhistsProperty("showValues",e)},this._onValueChange=e=>{this._setHhistsProperty("percentWidth",e)},this._onDirectionChange=e=>{this._setHhistsProperty("direction",e)}}render(){var e,t,n,s,a,c;const{metaInfo:p}=this.props,{graphics:d,styles:u,showLabelsOnPriceScale:h,showLegendValues:m}=this.props.property.childs(),{hhists:v,horizlines:y,polygons:g}=d.childs(),b=(0,o.ensureDefined)(p.graphics.hhists),w=Object.keys(b),f=v.childs()[w[0]],C=f.childs().visible,P=w.map((e=>v.childs()[e].childs().showValues)),S=f.childs().percentWidth,E=f.childs().direction,T=w.map((e=>v.childs()[e].childs().valuesColor)),k=null===(e=y.childs())||void 0===e?void 0:e.vahLines,_=null===(t=p.graphics.horizlines)||void 0===t?void 0:t.vahLines,x=null===(n=y.childs())||void 0===n?void 0:n.valLines,I=null===(s=p.graphics.horizlines)||void 0===s?void 0:s.valLines,L=y.childs().pocLines,V=(0,o.ensureDefined)(null===(a=p.graphics.horizlines)||void 0===a?void 0:a.pocLines),R=u.childs().developingPoc,N=new ae.StudyPlotVisibleProperty(R.childs().display),W=(0,o.ensureDefined)(null===(c=p.styles)||void 0===c?void 0:c.developingPoc),A=u.childs().developingVAHigh,z=new ae.StudyPlotVisibleProperty(A.childs().display),H=u.childs().developingVALow,F=new ae.StudyPlotVisibleProperty(H.childs().display),G=p.graphics.polygons&&p.graphics.polygons.histBoxBg;return r.createElement(r.Fragment,null,r.createElement(oe.PropertyTable.Row,null,r.createElement(oe.PropertyTable.Cell,{placement:"first",colSpan:2},r.createElement(D.BoolInputComponent,{label:xt,input:{id:"VolumeProfile",type:"bool",defval:!0,name:"visible"},value:C.value(),onChange:this._onChange}))),r.createElement(oe.PropertyTable.Row,null,r.createElement(oe.PropertyTable.Cell,{placement:"first"},r.createElement("div",{className:te.childRowContainer},r.createElement(D.BoolInputComponent,{disabled:!C.value(),label:It,input:{id:"ShowValues",type:"bool",defval:!0,name:"visible"},value:P[0].value(),onChange:this._onShowValuesChange}))),r.createElement(oe.PropertyTable.Cell,{placement:"last"},r.createElement(ee.ColorWithThicknessSelect,{disabled:!C.value()||!P[0].value(),color:T}))),r.createElement(oe.PropertyTable.Row,null,r.createElement(oe.PropertyTable.Cell,{placement:"first"},r.createElement("div",{className:te.childRowContainer},Lt)),r.createElement(oe.PropertyTable.Cell,{placement:"last" },r.createElement(lt.IntegerInputComponent,{disabled:!C.value(),input:{id:"",name:"",type:"integer",defval:0},value:S.value(),onChange:this._onValueChange}))),r.createElement(oe.PropertyTable.Row,null,r.createElement(oe.PropertyTable.Cell,{placement:"first"},r.createElement("div",{className:te.childRowContainer},Tt)),r.createElement(oe.PropertyTable.Cell,{placement:"last"},r.createElement(Ee.Select,{id:"hhist-direction-select",disabled:!C.value(),className:te.defaultSelect,menuItemClassName:te.defaultSelectItem,items:kt,value:E.value(),onChange:this._onDirectionChange}))),w.map((e=>r.createElement(r.Fragment,{key:e},v.childs()[e].childs().colors.childNames().map(((t,n)=>{const o=b[e];return r.createElement(B.InputRow,{key:n,label:r.createElement("div",{className:te.childRowContainer},o&&i.t(o.titles[n],{context:"input"},l(88601))||"")},r.createElement(ee.ColorWithThicknessSelect,{disabled:!C.value(),color:v.childs()[e].childs().colors.childs()[n],transparency:v.childs()[e].childs().transparencies.childs()[n]}))}))))),_&&k&&r.createElement(ye,{id:"vahLines",title:_.name,color:k.childs().color,visible:k.childs().visible,thickness:k.childs().width},r.createElement(Xe,{id:"vah-lines-line-style-select",disabled:!k.childs().visible.value(),className:te.smallStyleControl,lineStyle:k.childs().style})),I&&x&&r.createElement(ye,{id:"valLines",title:I.name,color:x.childs().color,visible:x.childs().visible,thickness:x.childs().width},r.createElement(Xe,{id:"val-lines-line-style-select",disabled:!x.childs().visible.value(),className:te.smallStyleControl,lineStyle:x.childs().style})),r.createElement(ye,{id:"pocLines",title:V.name,color:L.childs().color,visible:L.childs().visible,thickness:L.childs().width},r.createElement(Xe,{id:"poc-lines-line-style-select",disabled:!L.childs().visible.value(),className:te.smallStyleControl,lineStyle:L.childs().style})),R&&r.createElement(ye,{id:"developingPoc",title:W.title&&i.t(W.title,{context:"input"},l(88601))||"",color:R.childs().color,visible:N,thickness:R.childs().linewidth},r.createElement(Xe,{id:"developing-poc-line-style-select",disabled:!N.value(),className:te.smallStyleControl,lineStyle:R.childs().linestyle})),A&&H&&r.createElement(ye,{id:"developingPoc",title:Dt,color:[A.childs().color,H.childs().color],visible:[z,F],thickness:[A.childs().linewidth,H.childs().linewidth]},r.createElement(Xe,{id:"developing-VA-line-style-select",disabled:!z.value()&&!F.value(),className:te.smallStyleControl,lineStyle:[A.childs().linestyle,H.childs().linestyle]})),g&&r.createElement(B.InputRow,{label:r.createElement("div",null,G&&i.t(G.name,{context:"input"},l(88601))||"")},r.createElement(ee.ColorWithThicknessSelect,{color:g.childs().histBoxBg.childs().color,transparency:g.childs().histBoxBg.childs().transparency})),(h||m)&&"VbPFixed"!==p.shortId&&r.createElement(r.Fragment,null,h&&r.createElement(oe.PropertyTable.Cell,{placement:"first",colSpan:2},r.createElement(M,{id:"showLabelsOnPriceScale",title:Rt,visible:h})),m&&r.createElement(oe.PropertyTable.Cell,{placement:"first",colSpan:2 },r.createElement(M,{id:"showLegendValues",title:Vt,visible:m}))))}_setHhistsProperty(e,t){const{setValue:l}=this.context,{metaInfo:n,property:r}=this.props,i=r.childs().graphics.childs().hhists,s=Object.keys((0,o.ensureDefined)(n.graphics.hhists));for(let n=0;nr.createElement(L.StylePropertyContainer,{property:(0,o.ensureNotNull)(t).properties(),model:e},r.createElement(oe.PropertyTable,null,this._renderCustomContent((0,o.ensureNotNull)(t).metaInfo().shortId)))))}_renderCustomContent(e){if(e in Wt){const t=Wt[e];return r.createElement(t,null)}return null}}At.contextType=Nt.ModelContext;var zt=l(43886);const Ht=new s.TranslatedString("change precision",i.t(null,void 0,l(164))),Ft=i.t(null,void 0,l(4329)),Gt=i.t(null,void 0,l(73947)),Ut=[{value:"default",content:Ft}];for(let e=0;e<=8;e++)Ut.push({value:e,content:e.toString()});class Ot extends r.PureComponent{constructor(){super(...arguments),this._onChange=e=>{const{setValue:t}=this.context,{precision:l}=this.props;t(l,e,Ht)}}render(){const{id:e,precision:t}=this.props;return r.createElement(B.InputRow,{label:Gt},r.createElement(Ee.Select,{id:e,className:te.defaultSelect,menuItemClassName:te.defaultSelectItem,items:Ut,value:t.value(),onChange:this._onChange}))}}Ot.contextType=L.StylePropertyContext;const jt=new s.TranslatedString("change min tick",i.t(null,void 0,l(20834))),Qt=i.t(null,void 0,l(4329)),Zt=i.t(null,void 0,l(36993)),qt=[{priceScale:1,minMove:1,frac:!1},{priceScale:10,minMove:1,frac:!1},{priceScale:100,minMove:1,frac:!1},{priceScale:1e3,minMove:1,frac:!1},{priceScale:1e4,minMove:1,frac:!1},{priceScale:1e5,minMove:1,frac:!1},{priceScale:1e6,minMove:1,frac:!1},{priceScale:1e7,minMove:1,frac:!1},{priceScale:1e8,minMove:1,frac:!1},{priceScale:2,minMove:1,frac:!0},{priceScale:4,minMove:1,frac:!0},{priceScale:8,minMove:1,frac:!0},{priceScale:16,minMove:1,frac:!0},{priceScale:32,minMove:1,frac:!0},{priceScale:64,minMove:1,frac:!0},{priceScale:128,minMove:1,frac:!0},{priceScale:320,minMove:1,frac:!0}],Kt=[{id:"tick-default",value:"default",content:Qt}];for(let e=0;e{const{setValue:t}=this.context,{minTick:l}=this.props;t(l,e,jt)}}render(){const{id:e,minTick:t}=this.props;return r.createElement(B.InputRow,{label:Zt},r.createElement(Ee.Select,{id:e,className:te.defaultSelect, menuItemClassName:te.defaultSelectItem,items:Kt,value:t.value(),onChange:this._onChange}))}}$t.contextType=L.StylePropertyContext;var Xt=l(73146),Yt=l(86067);class Jt extends r.PureComponent{render(){const{id:e,isRGB:t,title:l,visible:n,bottomColor:o,topColor:i,transparency:s,children:a,switchable:c=!0,offset:p,grouped:d}=this.props;return r.createElement(B.InputRow,{label:c?r.createElement(M,{id:e,title:l,visible:n}):l,offset:p,grouped:d},t?null:r.createElement(r.Fragment,null,i&&r.createElement(ee.ColorWithThicknessSelect,{disabled:n&&!(Array.isArray(n)?n[0].value():n.value()),color:i,transparency:s}),o&&r.createElement("div",{className:Pe()(o&&i&&te.additionalSelect)},r.createElement(ee.ColorWithThicknessSelect,{disabled:n&&!(Array.isArray(n)?n[0].value():n.value()),color:o,transparency:s}))),a)}}Jt.contextType=L.StylePropertyContext;const el=i.t(null,void 0,l(27331)),tl=i.t(null,{context:"input"},l(45811)),ll=i.t(null,{context:"input"},l(41596)),nl=i.t(null,void 0,l(40297));class rl extends r.PureComponent{constructor(){super(...arguments),this._findPlotPalettes=e=>{const{study:t}=this.props,l=t.metaInfo(),n=(0,o.ensureDefined)(l.palettes);return(0,x.isBarColorerPlot)(e)||(0,x.isBgColorerPlot)(e)?{main:{palette:n[e.palette],paletteProps:t.properties().palettes[e.palette]}}:this._findPalettesByTargetId(e.id)}}render(){const{study:e}=this.props,t=e.metaInfo();if((0,zt.isCustomStudy)(t.shortId))return r.createElement(At,null);const l=e.properties(),{precision:n,strategy:o,minTick:i,showLabelsOnPriceScale:s,showLegendValues:a}=l,c=t.plots.length>0,p=t.plots.some((e=>!(0,x.isPlotWithTechnicalValues)(e))),d=c||t.inputs.some((e=>"price"===e.type)),u=(0,Xt.createAdapter)(e).canOverrideMinTick();return r.createElement(oe.PropertyTable,null,this._plotsElement(),this._bandsElement(),this._bandsBackgroundsElement(),this._areasBackgroundsElement(),this._filledAreasElement(),this._graphicsElement(),u&&r.createElement($t,{id:(0,_.createDomId)(t.id,"min-tick-select"),minTick:i}),I.StudyMetaInfo.isScriptStrategy(t)&&r.createElement(et,{orders:o.orders}),(d||p)&&r.createElement(oe.PropertyTable.Row,null,r.createElement(oe.PropertyTable.GroupSeparator,{size:1}),r.createElement(Yt.GroupTitleSection,{title:nl,name:nl}),d&&r.createElement(Ot,{id:(0,_.createDomId)(t.id,"precision-select"),precision:n}),p&&r.createElement(r.Fragment,null,r.createElement(oe.PropertyTable.Cell,{placement:"first",colSpan:2},r.createElement(M,{id:"showLabelsOnPriceScale",title:ll,visible:s})),r.createElement(oe.PropertyTable.Cell,{placement:"first",colSpan:2},r.createElement(M,{id:"showLegendValues",title:tl,visible:a})))))}_plotsElement(){const{study:e}=this.props,t=e.metaInfo();return new T.MetaInfoHelper(t).getUserEditablePlots().filter((e=>!((0,x.isUpColorerPlot)(e)||(0,x.isDownColorerPlot)(e)||(0,x.isCandleBorderColorerPlot)(e)||(0,x.isCandleWickColorerPlot)(e)))).map((t=>{const l=(0,x.isOhlcPlot)(t)?{...t,id:t.target}:t,n=this._findPlotPalettes(l);return r.createElement(Qe,{key:t.id,plot:t,palettes:n,study:e})}))}_bandsElement(){ diff --git a/charting_library/bundles/runtime.93ba548e6a7994d2a8f1.js b/charting_library/bundles/runtime.73eaf5da31fa198fb54c.js similarity index 98% rename from charting_library/bundles/runtime.93ba548e6a7994d2a8f1.js rename to charting_library/bundles/runtime.73eaf5da31fa198fb54c.js index a5188f75..a12f25ef 100644 --- a/charting_library/bundles/runtime.93ba548e6a7994d2a8f1.js +++ b/charting_library/bundles/runtime.73eaf5da31fa198fb54c.js @@ -1,5 +1,5 @@ (()=>{"use strict";var e,a,c,d,f,t={},b={};function r(e){var a=b[e];if(void 0!==a)return a.exports;var c=b[e]={id:e,loaded:!1,exports:{}};return t[e].call(c.exports,c,c.exports,r),c.loaded=!0,c.exports}r.m=t,r.c=b,e=[],r.O=(a,c,d,f)=>{if(!c){var t=1/0;for(i=0;i=f)&&Object.keys(r.O).every((e=>r.O[e](c[o])))?c.splice(o--,1):(b=!1,f0&&e[i-1][2]>f;i--)e[i]=e[i-1];e[i]=[c,d,f]},r.n=e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return r.d(a,{a}),a},c=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,r.t=function(e,d){if(1&d&&(e=this(e)),8&d)return e;if("object"==typeof e&&e){if(4&d&&e.__esModule)return e;if(16&d&&"function"==typeof e.then)return e}var f=Object.create(null);r.r(f);var t={};a=a||[null,c({}),c([]),c(c)];for(var b=2&d&&e;"object"==typeof b&&!~a.indexOf(b);b=c(b))Object.getOwnPropertyNames(b).forEach((a=>t[a]=()=>e[a]));return t.default=()=>e,r.d(f,t),f},r.d=(e,a)=>{for(var c in a)r.o(a,c)&&!r.o(e,c)&&Object.defineProperty(e,c,{enumerable:!0,get:a[c]})},r.f={},r.e=e=>Promise.all(Object.keys(r.f).reduce(((a,c)=>(r.f[c](e,a),a)),[])),r.u=e=>5652===e?"__LANG__.5652.afa01acb54a69426de69.js":2427===e?"__LANG__.2427.9e75295442d2edc53485.js":77===e?"__LANG__.77.99662205014782bfbe4a.js":6196===e?"__LANG__.6196.1cb6c0cf4b3c1139a67d.js":9871===e?"__LANG__.9871.80491970c40a96588ffd.js":7201===e?"__LANG__.7201.d9e269cc77c4bebf986c.js":3753===e?"__LANG__.3753.453e4c91d1197ef94e09.js":2521===e?"__LANG__.2521.8eba2dc07079697338fc.js":8884===e?"__LANG__.8884.377844211bfc698fda75.js":2684===e?"__LANG__.2684.89c78924594078c4eeb0.js":({92:"chart-screenshot-hint",139:"get-error-card",507:"study-pane-views",607:"study-property-pages-with-definitions",731:"add-compare-dialog",1583:"lt-pane-views",1584:"context-menu-renderer",1702:"manage-drawings-dialog",1754:"symbol-search-dialog",1859:"go-to-date-dialog-impl",1890:"line-tools-icons",2077:"change-interval-dialog",2183:"study-inputs-pane-views",2306:"floating-toolbars",2377:"hammerjs",2616:"svg-renderer",2704:"currency-label-menu",2878:"drawing-toolbar",3005:"header-toolbar",3030:"new-confirm-inputs-dialog",3596:"general-property-page",4013:"custom-intervals-add-dialog",4079:"series-pane-views",4389:"take-chart-image-impl",4665:"share-chart-to-social-utils",4862:"object-tree-dialog",5009:"load-chart-dialog",5093:"chart-widget-gui",5516:"restricted-toolset",5551:"favorite-drawings-api",5598:"lt-stickers-atlas",6166:"chart-event-hint",6265:"new-edit-object-dialog",6456:"study-market",6631:"study-template-dialog",6780:"source-properties-editor",7078:"general-chart-properties-dialog",7260:"chart-bottom-toolbar",7271:"compare-model",7648:"show-theme-save-dialog",7987:"lt-icons-atlas",8020:"user-defined-bars-marks-tooltip",8537:"lt-property-pages-with-definitions",8643:"full-tooltips-popup",8890:"simple-dialog",9039:"lollipop-tooltip-renderer",9374:"symbol-info-dialog-impl",9498:"export-data", -9685:"series-icons-map"}[e]||e)+"."+{6:"a03a8ff024d47ed075c6",92:"bfb76cc7578ab709169b",139:"02c0064b96893d572f7c",306:"6c2d5d0bc3a42274d1e6",507:"ed33f2a0cf4f0d37ca70",607:"8ba8754a2a9412395338",731:"f9dfb2d8c088196803c5",769:"9e4ee987380cde8a482f",855:"61db310932f8af2c5989",898:"b63568700f1380e37b1a",962:"e2eb6a85de39a3d76e5d",1013:"ccba7f12442264960551",1033:"bb804c64fe58de0bace7",1044:"c0b266912178dd5523e1",1054:"c09e1aa220385adef79a",1109:"845f0f111ff830ab93c8",1365:"e1fe1d66c5bb17da7c3a",1553:"c076714f5e24887f0b94",1583:"f9c2f48c51585106118a",1584:"429d5a2ad09b6791326c",1702:"3f5b604134bebba28c6c",1754:"33210ecad56124f25ac1",1762:"9511e5b410d7d629bc49",1859:"a3a8e03aafa01f2649cb",1890:"8b313f77ea6c1f51530a",2020:"4a7196a939413830080e",2077:"53c155e0d72b7d0f0e3d",2109:"291fa715b6ded706c3dd",2183:"a80a3e282aa441e156d1",2191:"2197cc1b66a1db8969cc",2260:"95dc0a20b147b6b2eeed",2306:"e8314762db1d7d9aac81",2377:"6e30e0c48af40bf2f6c0",2587:"615babc52637decdb6e2",2616:"f065beaf6b5b37da27d9",2639:"a55d77a7912be54f7b9d",2666:"d28c0fa0a323b8118f22",2676:"a9a5ede4d514162164fa",2704:"b2d329d398bc58f1b425",2731:"55eed17fefac5e82c077",2878:"1077ac737eee4d6fdb30",2984:"dc61504f5c150afee786",3005:"d2aa6e1dc6d61ae08053",3016:"37427b1dab6d44713245",3030:"dbb4bdcbf10acf6b5280",3066:"8b1d2ceb22d9fedde67b",3127:"dbb10377920ca14e55a2",3179:"b87763465b433e5b66fd",3291:"1b7cd1c0d6b4fdf5f9e9",3502:"1985af3fa836c4248178",3596:"ca806447f87d03e5b322",3610:"c79c6bddd919cb78428a",3717:"6f65e91a870250a6e450",3842:"8758110ab553b5368121",3889:"c5a6834243c3ccfc1fcb",3896:"14d9e7509c300245c219",3980:"9d7eeb2bacce45c508b3",3986:"aee89bf9b2348c0d0d7f",4013:"38f48de95854d191751c",4015:"9b6607a6f543f077c5a5",4062:"9229fac3ef3db26fd5bc",4079:"97a8e6dbe1a94532eb49",4081:"c86fb8f04554726af6c0",4215:"8934b190aaed2663c300",4378:"a2a37780b99d50d784f7",4387:"b928c72ea82decd4ae7b",4389:"c0ec40f417c36a1c6179",4403:"fc4cac3ecee3925b9ec2",4665:"d7331dbca4a2aa0909e7",4713:"365b703a3ce33b603ace",4717:"ff71583495773a86dd1b",4862:"f3c95c3754723530ee6d",4894:"035fecc664874bb752b0",4987:"a23484dfcca6d5fae195",5009:"4b08ba7264d2d6e73f2e",5050:"cc5e2d631f109ee4d535",5093:"e192c9080b7e430f8bfc",5145:"da831552b3b54ca47682",5163:"953e65e04ed31b0ea0b3",5403:"a8ce3bbae4ddbe632714",5516:"6b6f00fca2682a673f64",5551:"340e60e2342b0d93ebe7",5598:"52ad6e6d7d7b134ab0ba",5649:"5c1e55c9dad604880876",5711:"592f6b06b20ea7958f2e",5866:"039e25226b82968cca61",5871:"1571b33c7b086a73eadd",5899:"610e274e70fffca8c232",5901:"bf6858d021c8e6c577d5",5993:"0e5f49179c6a516963de",6025:"d669a0315da9d6fda6b3",6036:"5b373caaaa6e1ba4495f",6106:"1d31df88e63bf542ea7b",6166:"8b7dc7926d170fc11eac",6214:"5a578175aab923a979dc",6221:"56c4d15c823c019ddb39",6265:"4788a10b2e7019e41282",6456:"44f6b4ef758efe0fb876",6494:"7f264af8142cb9910c06",6625:"364cf21fe24d7e675de8",6631:"f4fa646ba9150ed60d55",6639:"a1bd5bf1d51c681561a1",6752:"912872ffa56a7243d664",6780:"36857414f568c0fc82b2",6831:"912351c7cf5f8ac16dfe",6884:"07642217627127113fb0",6925:"665969c4af4481df0691",6949:"f50051a55eaa8dd5e780", +9685:"series-icons-map"}[e]||e)+"."+{6:"a03a8ff024d47ed075c6",92:"bfb76cc7578ab709169b",139:"02c0064b96893d572f7c",306:"6c2d5d0bc3a42274d1e6",507:"ed33f2a0cf4f0d37ca70",607:"8ba8754a2a9412395338",731:"f9dfb2d8c088196803c5",769:"9e4ee987380cde8a482f",855:"61db310932f8af2c5989",898:"b63568700f1380e37b1a",962:"e2eb6a85de39a3d76e5d",1013:"ccba7f12442264960551",1033:"bb804c64fe58de0bace7",1044:"c0b266912178dd5523e1",1054:"c09e1aa220385adef79a",1109:"845f0f111ff830ab93c8",1365:"e1fe1d66c5bb17da7c3a",1553:"c076714f5e24887f0b94",1583:"9222abe1a9c6cc59d449",1584:"429d5a2ad09b6791326c",1702:"3f5b604134bebba28c6c",1754:"33210ecad56124f25ac1",1762:"9511e5b410d7d629bc49",1859:"a3a8e03aafa01f2649cb",1890:"8b313f77ea6c1f51530a",2020:"4a7196a939413830080e",2077:"53c155e0d72b7d0f0e3d",2109:"291fa715b6ded706c3dd",2183:"a80a3e282aa441e156d1",2191:"2197cc1b66a1db8969cc",2260:"95dc0a20b147b6b2eeed",2306:"e8314762db1d7d9aac81",2377:"6e30e0c48af40bf2f6c0",2587:"615babc52637decdb6e2",2616:"f065beaf6b5b37da27d9",2639:"a55d77a7912be54f7b9d",2666:"d28c0fa0a323b8118f22",2676:"a9a5ede4d514162164fa",2704:"b2d329d398bc58f1b425",2731:"55eed17fefac5e82c077",2878:"1077ac737eee4d6fdb30",2984:"dc61504f5c150afee786",3005:"d2aa6e1dc6d61ae08053",3016:"37427b1dab6d44713245",3030:"dbb4bdcbf10acf6b5280",3066:"8b1d2ceb22d9fedde67b",3127:"dbb10377920ca14e55a2",3179:"b87763465b433e5b66fd",3291:"1b7cd1c0d6b4fdf5f9e9",3502:"1985af3fa836c4248178",3596:"ca806447f87d03e5b322",3610:"c79c6bddd919cb78428a",3717:"6f65e91a870250a6e450",3842:"8758110ab553b5368121",3889:"c5a6834243c3ccfc1fcb",3896:"14d9e7509c300245c219",3980:"9d7eeb2bacce45c508b3",3986:"aee89bf9b2348c0d0d7f",4013:"38f48de95854d191751c",4015:"9b6607a6f543f077c5a5",4062:"9229fac3ef3db26fd5bc",4079:"97a8e6dbe1a94532eb49",4081:"c86fb8f04554726af6c0",4215:"8934b190aaed2663c300",4378:"a2a37780b99d50d784f7",4387:"b928c72ea82decd4ae7b",4389:"c0ec40f417c36a1c6179",4403:"fc4cac3ecee3925b9ec2",4665:"d7331dbca4a2aa0909e7",4713:"365b703a3ce33b603ace",4717:"ff71583495773a86dd1b",4862:"f3c95c3754723530ee6d",4894:"035fecc664874bb752b0",4987:"a23484dfcca6d5fae195",5009:"4b08ba7264d2d6e73f2e",5050:"cc5e2d631f109ee4d535",5093:"e192c9080b7e430f8bfc",5145:"da831552b3b54ca47682",5163:"953e65e04ed31b0ea0b3",5403:"a8ce3bbae4ddbe632714",5516:"6b6f00fca2682a673f64",5551:"340e60e2342b0d93ebe7",5598:"52ad6e6d7d7b134ab0ba",5649:"5c1e55c9dad604880876",5711:"592f6b06b20ea7958f2e",5866:"039e25226b82968cca61",5871:"1571b33c7b086a73eadd",5899:"610e274e70fffca8c232",5901:"3f691f17bd266aac284c",5993:"0e5f49179c6a516963de",6025:"d669a0315da9d6fda6b3",6036:"5b373caaaa6e1ba4495f",6106:"1d31df88e63bf542ea7b",6166:"8b7dc7926d170fc11eac",6214:"5a578175aab923a979dc",6221:"56c4d15c823c019ddb39",6265:"59756c2933ec24d194f0",6456:"44f6b4ef758efe0fb876",6494:"7f264af8142cb9910c06",6625:"364cf21fe24d7e675de8",6631:"f4fa646ba9150ed60d55",6639:"a1bd5bf1d51c681561a1",6752:"912872ffa56a7243d664",6780:"36857414f568c0fc82b2",6831:"912351c7cf5f8ac16dfe",6884:"07642217627127113fb0",6925:"665969c4af4481df0691",6949:"f50051a55eaa8dd5e780", 6959:"61ce9bf171293ea37c54",7078:"aef234c059b0b7c64ae8",7111:"4716f3208dc337521c10",7149:"d450e8145ad7e6fbd67f",7194:"098c1a8da1ddbbda98f6",7232:"abf9ba18c92e46a44f3b",7260:"4c9c01959c7ebe94b74f",7271:"1c3f95ada81fc7c425a4",7350:"aa555ff9e17c4029aedd",7391:"c63bd39c42093cc4130c",7413:"3a52b91975b98e6fe8e4",7555:"ea682716c26bc13db765",7648:"d599965fb89ec8e183eb",7871:"df6a9177c293c0c53e80",7987:"2267a50d874703af7f28",8020:"520f315000510aab3003",8056:"c06a1c8fb4a1f18cf217",8115:"aef220eae07f8df278f7",8149:"9fb525d10e5c8ba95701",8167:"fd915cf05676c668486e",8385:"32e961c4a8591abe04cd",8399:"ebb97a8311b57f015b11",8537:"168b8df16f57900a29da",8643:"71b6b063699eb3e1407e",8890:"9d651e36d783aafef499",8904:"87e94e93ade13962a48f",9039:"0a3f1b99d355b6297d18",9138:"f516266ddcf6ca8c7064",9322:"fcbf1e7bff530c95a44f",9327:"0c38440ca52f144413ac",9374:"4660d2cad62644ff2ea9",9498:"3892fbd90646aa80aef1",9685:"6b7b2f52a18274053c99",9727:"f86b3426312923af0159",9789:"458feb5c8c0263b0618b",9795:"d66be24693cf931f6914",9842:"581808dd4a8651b16779",9916:"0c2cb2d12479a20efce1"}[e]+".js",r.miniCssF=e=>e+"."+{6:"362fa6a7ab1f3e3b06c4",855:"26e8cce3ad082b02cc26",898:"f909d7c1efc95f635922",1013:"01583b91f7384f25e038",1033:"5197f9f8b8500206d06c",1054:"d5b8033c360af91ed458",1109:"ec16a629917db2baf412",1365:"0116666d16b5bc64c47a",1762:"7ff6b353c441db2276da",2109:"39627406fe95483ff7db",2191:"6563d97efc3339a1e518",2260:"b98824e4829a1aa9b444",2587:"1f1100dc01693edfe269",2639:"c87f745c32020e3a8cff",2666:"fbb750fd312778403036",2676:"2d3cabbd39a3b0d6e9ea",2731:"df45c9c18811872fec07",2984:"57f5ad22257d1a4e1ef9",3066:"2acb4b086c32c9448837",3127:"fd89143aebe89e23faed",3502:"c49903f7222870ff8aca",3610:"62c553543d76c38edfbc",3717:"da244b56f00e05470918",3842:"6a8a7842ee841f6d2cff",3889:"a2646d6c3b33d166eee2",3896:"019229d7d874e1da11be",3980:"b2ff45a2d8bb6a131d7c",4015:"1d0e3a62a59d173c81f3",4081:"1a314e4dade74df359f0",4215:"d24836a292b1969ab4bb",4387:"bf2665aacf1dc00074fa",4894:"cc39b3740f4022cbd5cf",4987:"861f49973c19dc84365b",5145:"a2b224fd27ab2941c565",5163:"8dc3fd2d8bb68b7d880e",5403:"d6bd43a35209059f1060",5649:"b60ed09c5ea8c55827d4",5866:"c89b7fc29afe92efc1f3",5993:"d3e96a56dd65b0b2db55",6025:"263b457b1a7f9ca139b2",6036:"3b493a9f0ab052e6447c",6106:"cf6f129517250c80b39f",6214:"65b7dbf8be6cca5ac143",6221:"25d30f095d6a54fbf276",6494:"e9af15c073886bef781b",6625:"cd54dd2a77c47eb6003d",6639:"cea47dbe77ae73ace44b",6752:"207eb3cc75b3ed2c6754",6831:"ac1745947bd2665f6c9a",6884:"bb7d30a7bbbe5af36556",6925:"43e91cba4f1aefba5311",6949:"19355e81a60b640ea097",6959:"0cd4b06da6b4fd1fcc56",7111:"b16b4eb739a7e8577559",7149:"12adbb19fdefe9b66b18",7194:"e04f69c8933166966874",7232:"dfa17050a6458c8bf3da",7350:"abf568a3d6ce7b47cc59",7391:"9c809fa91ed0c8f75bc0",7413:"f830ad1ad6ee6f9b1cb3",7555:"8c1e3939e7666b0f8c69",7871:"cb99fc4ec9bbe0895a26",8056:"a83d512c1dc2173349a1",8149:"21f2b01074a4d082e268",8399:"525ea48565b11d84e370",8904:"a302177fe7e3ccd50cb0",9138:"03b8fbcfabcae851949a",9322:"beec29aa1b9aa9601ccf",9327:"e6fe2b8bd7bfc4b93efe",9789:"cb5ad20bc727d3820b6c", 9842:"2f8e5864b0d72a886373",9916:"60c48148a54dba9504a0"}[e]+".css",r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.hmd=e=>((e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e),r.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),d={},f="tradingview:",r.l=(e,a,c,t)=>{if(d[e])d[e].push(a);else{var b,o;if(void 0!==c)for(var n=document.getElementsByTagName("script"),i=0;i{b.onerror=b.onload=null,clearTimeout(u);var f=d[e];if(delete d[e],b.parentNode&&b.parentNode.removeChild(b),f&&f.forEach((e=>e(c))),a)return a(c)},u=setTimeout(l.bind(null,void 0,{type:"timeout",target:b}),12e4);b.onerror=l.bind(null,b.onerror),b.onload=l.bind(null,b.onload),o&&document.head.appendChild(b)}},r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e;r.g.importScripts&&(e=r.g.location+"");var a=r.g.document;if(!e&&a&&(a.currentScript&&(e=a.currentScript.src),!e)){var c=a.getElementsByTagName("script");c.length&&(e=c[c.length-1].src)}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r.p=e})(),r.g.location&&r.p.startsWith(r.g.location.origin)&&(r.p=r.p.slice(r.g.location.origin.length)),(()=>{const e=r.u;r.u=a=>e(a).replace("__LANG__",r.g.language)})(),r.p=r.g.WEBPACK_PUBLIC_PATH||r.p;var o=r.e,n=Object.create(null);function i(e,a){return o(e).catch((function(){return new Promise((function(c){var d=function(){self.removeEventListener("online",d,!1),!1===navigator.onLine?self.addEventListener("online",d,!1):c(a<2?i(e,a+1):o(e))};setTimeout(d,a*a*1e3)}))}))}r.e=function(e){if(!n[e]){n[e]=i(e,0);var a=function(){delete n[e]};n[e].then(a,a)}return n[e]},(()=>{if("undefined"!=typeof document){var e=e=>new Promise(((a,c)=>{var d=r.miniCssF(e),f=r.p+d;if(((e,a)=>{for(var c=document.getElementsByTagName("link"),d=0;d{var t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.onerror=t.onload=c=>{if(t.onerror=t.onload=null, "load"===c.type)d();else{var b=c&&("load"===c.type?"missing":c.type),r=c&&c.target&&c.target.href||a,o=new Error("Loading CSS chunk "+e+" failed.\n("+r+")");o.code="CSS_CHUNK_LOAD_FAILED",o.type=b,o.request=r,t.parentNode&&t.parentNode.removeChild(t),f(o)}},t.href=a,0!==t.href.indexOf(window.location.origin+"/")&&(t.crossOrigin="anonymous"),c?c.parentNode.insertBefore(t,c.nextSibling):document.head.appendChild(t)})(e,f,null,a,c)})),a={3666:0};r.f.miniCss=(c,d)=>{a[c]?d.push(a[c]):0!==a[c]&&{6:1,855:1,898:1,1013:1,1033:1,1054:1,1109:1,1365:1,1762:1,2109:1,2191:1,2260:1,2587:1,2639:1,2666:1,2676:1,2731:1,2984:1,3066:1,3127:1,3502:1,3610:1,3717:1,3842:1,3889:1,3896:1,3980:1,4015:1,4081:1,4215:1,4387:1,4894:1,4987:1,5145:1,5163:1,5403:1,5649:1,5866:1,5993:1,6025:1,6036:1,6106:1,6214:1,6221:1,6494:1,6625:1,6639:1,6752:1,6831:1,6884:1,6925:1,6949:1,6959:1,7111:1,7149:1,7194:1,7232:1,7350:1,7391:1,7413:1,7555:1,7871:1,8056:1,8149:1,8399:1,8904:1,9138:1,9322:1,9327:1,9789:1,9842:1,9916:1}[c]&&d.push(a[c]=e(c).then((()=>{a[c]=0}),(e=>{throw delete a[c],e})))}}})(),(()=>{var e={3666:0,3515:0};r.f.j=(a,c)=>{var d=r.o(e,a)?e[a]:void 0;if(0!==d)if(d)c.push(d[2]);else if(/^(1(0(13|33|54)|109|365|762)|2(6(39|66|76)|109|191|260|587|731|984)|3(8(42|89|96)|[06]66|127|502|515|610|717|980)|4([02]15|[39]87|081|894)|5((16|40|99)3|145|649|866)|6(9(25|49|59)|[06]25|(21|49|88)4||036|106|221|639|752|831)|7(1(11|49|94)|232|350|391|413|555|871)|8(056|149|399|55|904|98)|9(32[27]|138|789|842|916))$/.test(a))e[a]=0;else{var f=new Promise(((c,f)=>d=e[a]=[c,f]));c.push(d[2]=f);var t=r.p+r.u(a),b=new Error;r.l(t,(c=>{if(r.o(e,a)&&(0!==(d=e[a])&&(e[a]=void 0),d)){var f=c&&("load"===c.type?"missing":c.type),t=c&&c.target&&c.target.src;b.message="Loading chunk "+a+" failed.\n("+f+": "+t+")",b.name="ChunkLoadError",b.type=f,b.request=t,d[1](b)}}),"chunk-"+a,a)}},r.O.j=a=>0===e[a];var a=(a,c)=>{var d,f,[t,b,o]=c,n=0;if(t.some((a=>0!==e[a]))){for(d in b)r.o(b,d)&&(r.m[d]=b[d]);if(o)var i=o(r)}for(a&&a(c);n{const{miniCssF:e}=r;r.miniCssF=a=>self.document&&"rtl"===self.document.dir?e(a).replace(/\.css$/,".rtl.css"):e(a)})()})(); \ No newline at end of file diff --git a/charting_library/charting_library.cjs.js b/charting_library/charting_library.cjs.js index a988c7db..47ec7b4d 100644 --- a/charting_library/charting_library.cjs.js +++ b/charting_library/charting_library.cjs.js @@ -1 +1 @@ -"use strict";function t(e,n){const i={...e};for(const o in n)"object"!=typeof e[o]||null===e[o]||Array.isArray(e[o])?void 0!==n[o]&&(i[o]=n[o]):i[o]=t(e[o],n[o]);return i}Object.defineProperty(exports,"__esModule",{value:!0});const e={width:800,height:500,interval:"1D",timezone:"Etc/UTC",container:"",library_path:"",locale:"en",widgetbar:{details:!1,watchlist:!1,news:!1,datawindow:!1,watchlist_settings:{default_symbols:[]}},overrides:{"mainSeriesProperties.showCountdown":!1},studies_overrides:{},trading_customization:{position:{},order:{}},brokerConfig:{configFlags:{}},fullscreen:!1,autosize:!1,disabled_features:[],enabled_features:[],debug:!1,logo:{},time_frames:[{text:"5y",resolution:"1W"},{text:"1y",resolution:"1W"},{text:"6m",resolution:"120"},{text:"3m",resolution:"60"},{text:"1m",resolution:"30"},{text:"5d",resolution:"5"},{text:"1d",resolution:"1"}],client_id:"0",user_id:"0",charts_storage_api_version:"1.0",favorites:{intervals:[],chartTypes:[],indicators:[],drawingTools:[]}},n=JSON.parse('[{"iso":"ar","dir":"rtl","language":"ar"},{"iso":"pt","dir":"ltr","language":"pt"},{"iso":"ca","dir":"ltr","language":"ca_ES"},{"iso":"cs","dir":"ltr","language":"cs"},{"iso":"de","dir":"ltr","language":"de"},{"iso":"en","dir":"ltr","language":"en"},{"iso":"es","dir":"ltr","language":"es"},{"iso":"fa","dir":"rtl","language":"fa"},{"iso":"fr","dir":"ltr","language":"fr"},{"iso":"he","dir":"rtl","language":"he_IL"},{"iso":"hu","dir":"ltr","language":"hu_HU"},{"iso":"id","dir":"ltr","language":"id_ID"},{"iso":"en","dir":"ltr","language":"en"},{"iso":"it","dir":"ltr","language":"it"},{"iso":"ja","dir":"ltr","language":"ja"},{"iso":"ko","dir":"ltr","language":"ko"},{"iso":"ms","dir":"ltr","language":"ms_MY"},{"iso":"pl","dir":"ltr","language":"pl"},{"iso":"ru","dir":"ltr","language":"ru"},{"iso":"sv","dir":"ltr","language":"sv"},{"iso":"th","dir":"ltr","language":"th"},{"iso":"tr","dir":"ltr","language":"tr"},{"iso":"vi","dir":"ltr","language":"vi"},{"iso":"zh-Hans","dir":"ltr","language":"zh"},{"iso":"zh-Hant","dir":"ltr","language":"zh_TW"},{"iso":"el","dir":"ltr","language":"el"},{"iso":"nl","dir":"ltr","language":"nl_NL"},{"iso":"ro","dir":"ltr","language":"ro"}]');let i=!1;function o(){return"CL v26.001 (internal id 04caa94e @ 2023-08-09T11:45:15.021Z)"}const s=class{constructor(n){var o,s;if(this._id=`tradingview_${(1048576*(1+Math.random())|0).toString(16).substring(1)}`,this._ready=!1,this._readyHandlers=[],this._onWindowResize=this._autoResizeChart.bind(this),!n.datafeed)throw new Error("Datafeed is not defined");(null===(o=n.overrides)||void 0===o?void 0:o["mainSeriesProperties.priceAxisProperties.lockScale"])&&(console.warn("mainSeriesProperties.priceAxisProperties.lockScale can not be set to true within the widget constructor"),delete n.overrides["mainSeriesProperties.priceAxisProperties.lockScale"]),this._options=t(e,n);"dark"===(null!==(s=this._options.theme)&&void 0!==s?s:"light").toLowerCase()&&void 0===this._options.loading_screen&&(this._options.loading_screen={backgroundColor:"#131722"}),this._options.debug&&(i||(i=!0,console.log("Using CL v26.001 (internal id 04caa94e @ 2023-08-09T11:45:15.021Z)"))),this._create()}setDebugMode(t){this._innerAPI().setDebugMode(t)}onChartReady(t){this._ready?t.call(this):this._readyHandlers.push(t)}headerReady(){return this._innerWindowLoaded.then((()=>this._innerWindow().headerReady()))}onGrayedObjectClicked(t){this._doWhenInnerApiLoaded((e=>{e.onGrayedObjectClicked(t)}))}onShortcut(t,e){this._doWhenInnerWindowLoaded((n=>{n.createShortcutAction(t,e)}))}subscribe(t,e){this._doWhenInnerApiLoaded((n=>{n.subscribe(t,e)}))}unsubscribe(t,e){this._doWhenInnerApiLoaded((n=>{n.unsubscribe(t,e)}))}chart(t){return this._innerAPI().chart(t)}getLanguage(){return this._options.locale}setSymbol(t,e,n){this._innerAPI().changeSymbol(t,e,n)}remove(){window.removeEventListener("resize",this._onWindowResize),this._readyHandlers.splice(0,this._readyHandlers.length),delete window[this._id],this._iFrame.parentNode&&this._iFrame.parentNode.removeChild(this._iFrame)}closePopupsAndDialogs(){this._doWhenInnerApiLoaded((t=>{t.closePopupsAndDialogs()}))}selectLineTool(t,e){this._innerAPI().selectLineTool(t,e)}selectedLineTool(){return this._innerAPI().selectedLineTool()}save(t){this._innerAPI().saveChart(t)}load(t,e){this._innerAPI().loadChart({json:t,extendedData:e})}getSavedCharts(t){this._innerAPI().getSavedCharts(t)}loadChartFromServer(t){this._innerAPI().loadChartFromServer(t)}saveChartToServer(t,e,n){this._innerAPI().saveChartToServer(t,e,n)}removeChartFromServer(t,e){this._innerAPI().removeChartFromServer(t,e)}onContextMenu(t){this._doWhenInnerApiLoaded((e=>{e.onContextMenu(t)}))}createButton(t){return this._innerWindow().createButton(t)}createDropdown(t){return this._innerWindow().createDropdown(t)}showNoticeDialog(t){this._doWhenInnerApiLoaded((e=>{e.showNoticeDialog(t)}))}showConfirmDialog(t){this._doWhenInnerApiLoaded((e=>{e.showConfirmDialog(t)}))}showLoadChartDialog(){this._innerAPI().showLoadChartDialog()}showSaveAsChartDialog(){this._innerAPI().showSaveAsChartDialog()}symbolInterval(){return this._innerAPI().getSymbolInterval()}mainSeriesPriceFormatter(){return this._innerAPI().mainSeriesPriceFormatter()}getIntervals(){return this._innerAPI().getIntervals()}getStudiesList(){return this._innerAPI().getStudiesList()}getStudyInputs(t){return this._innerAPI().getStudyInputs(t)}getStudyStyles(t){return this._innerAPI().getStudyStyles(t)}addCustomCSSFile(t){this._innerWindow().addCustomCSSFile(t)}applyOverrides(e){this._options=t(this._options,{overrides:e}),this._doWhenInnerWindowLoaded((t=>{t.applyOverrides(e)}))}applyStudiesOverrides(t){this._doWhenInnerWindowLoaded((e=>{e.applyStudiesOverrides(t)}))}watchList(){return this._innerAPI().watchlist()}news(){return this._innerAPI().news()}widgetbar(){return this._innerAPI().widgetbar()}activeChart(){return this._innerAPI().activeChart()}activeChartIndex(){return this._innerAPI().activeChartIndex()}setActiveChart(t){return this._innerAPI().setActiveChart(t)}chartsCount(){return this._innerAPI().chartsCount()}layout(){return this._innerAPI().layout()}setLayout(t){this._innerAPI().setLayout(t)}layoutName(){return this._innerAPI().layoutName()}changeTheme(t,e){return this._innerWindow().changeTheme(t,e)}getTheme(){return this._innerWindow().getTheme()}takeScreenshot(){this._doWhenInnerApiLoaded((t=>{t.takeScreenshot()}))}lockAllDrawingTools(){return this._innerAPI().lockAllDrawingTools()}hideAllDrawingTools(){return this._innerAPI().hideAllDrawingTools()}drawOnAllCharts(t){this._innerAPI().drawOnAllCharts(t)}magnetEnabled(){return this._innerAPI().magnetEnabled()}magnetMode(){return this._innerAPI().magnetMode()}undoRedoState(){return this._innerAPI().undoRedoState()}setIntervalLinkingEnabled(t){this._innerAPI().setIntervalLinkingEnabled(t)}setTimeFrame(t){this._innerAPI().setTimeFrame(t)}symbolSync(){return this._innerAPI().symbolSync()}intervalSync(){return this._innerAPI().intervalSync()}crosshairSync(){return this._innerAPI().crosshairSync()}timeSync(){return this._innerAPI().timeSync()}dateRangeSync(){return this._innerAPI().dateRangeSync()}setFeatureEnabled(t,e){this._innerAPI().setFeatureEnabled(t,e)}getAllFeatures(){return this._innerWindow().getAllFeatures()}clearUndoHistory(){return this._innerAPI().clearUndoHistory()}undo(){return this._innerAPI().undo()}redo(){return this._innerAPI().redo()}startFullscreen(){this._innerAPI().startFullscreen()}exitFullscreen(){this._innerAPI().exitFullscreen()}takeClientScreenshot(t){return this._innerAPI().takeClientScreenshot(t)}navigationButtonsVisibility(){return this._innerWindow().getNavigationButtonsVisibility()}paneButtonsVisibility(){return this._innerWindow().getPaneButtonsVisibility()}dateFormat(){return this._innerWindow().getDateFormat()}timeHoursFormat(){return this._innerWindow().getTimeHoursFormat()}currencyAndUnitVisibility(){return this._innerWindow().getCurrencyAndUnitVisibility()}supportedChartTypes(){return this._innerAPI().supportedChartTypes()}watermark(){return this._innerAPI().watermark()}customSymbolStatus(){return this._innerWindow().customSymbolStatus()}setCSSCustomProperty(t,e){if(!1===t.startsWith("--"))throw new Error("customPropertyName should begin with a double hyphen");this._innerWindow().document.body.style.setProperty(t,e)}getCSSCustomPropertyValue(t){if(!1===t.startsWith("--"))throw new Error("customPropertyName should begin with a double hyphen");const e=this._innerWindow().document.body,n=e.style.getPropertyValue(t);if(n)return n;return getComputedStyle(e).getPropertyValue(t)}linking(){return this._innerAPI().linking}_innerAPI(){return this._innerWindow().tradingViewApi}_innerWindow(){return this._iFrame.contentWindow}_doWhenInnerWindowLoaded(t){this._ready?t(this._innerWindow()):this._innerWindowLoaded.then((()=>{t(this._innerWindow())}))}_doWhenInnerApiLoaded(t){this._doWhenInnerWindowLoaded((e=>{e.doWhenApiIsReady((()=>t(this._innerAPI())))}))}_autoResizeChart(){this._options.fullscreen&&(this._iFrame.style.height=window.innerHeight+"px",r&&setTimeout((()=>{this._iFrame.style.height=window.innerHeight+"px"}),30))}_create(){var t,e;const n=null!==(e=null===(t=this._options.enabled_features)||void 0===t?void 0:t.includes("iframe_loading_compatibility_mode"))&&void 0!==e&&e,[i,o]=this._render(!n),s=this._options.container,r="string"==typeof s?document.getElementById(s):s;if(null===r)throw new Error(`There is no such element - #${this._options.container}`);r.innerHTML=i,this._iFrame=r.querySelector(`#${this._id}`);const a=this._iFrame;n&&(a.contentWindow?(a.contentWindow.document.open(),a.contentWindow.document.write(o),a.contentWindow.document.close()):console.warn("Unable to locate contentWindow for the created iframe. Please try disabling the `iframe_loading_compatibility_mode` featureset.")),(this._options.autosize||this._options.fullscreen)&&(a.style.width="100%",this._options.fullscreen||(a.style.height="100%")),window.addEventListener("resize",this._onWindowResize),this._onWindowResize(),this._innerWindowLoaded=new Promise((t=>{const e=()=>{a.removeEventListener("load",e,!1),t()};a.addEventListener("load",e,!1)})),this._innerWindowLoaded.then((()=>{try{this._innerWindow().widgetReady((()=>{this._ready=!0;for(const t of this._readyHandlers)try{t.call(this)}catch(t){console.error(t)}this._innerWindow().initializationFinished()}))}catch(t){if(t instanceof Error&&/widgetReady is not a function/.test(t.message))throw new Error(`There was an error when loading the library. Usually this error means the library failed to load its static files. Check that the library files are available at ${window.location.host}/${this._options.library_path||""} or correct the library_path option.`)}}))}_render(t){const e=window;if(e[this._id]={datafeed:this._options.datafeed,customFormatters:this._options.custom_formatters||this._options.customFormatters,brokerFactory:this._options.broker_factory||this._options.brokerFactory,overrides:this._options.overrides,studiesOverrides:this._options.studies_overrides,tradingCustomization:this._options.trading_customization,disabledFeatures:this._options.disabled_features,enabledFeatures:this._options.enabled_features,brokerConfig:this._options.broker_config||this._options.brokerConfig,restConfig:this._options.restConfig,favorites:this._options.favorites,logo:this._options.logo,numeric_formatting:this._options.numeric_formatting,rss_news_feed:this._options.rss_news_feed,newsProvider:this._options.news_provider,loadLastChart:this._options.load_last_chart,saveLoadAdapter:this._options.save_load_adapter,loading_screen:this._options.loading_screen,settingsAdapter:this._options.settings_adapter,getCustomIndicators:this._options.custom_indicators_getter,additionalSymbolInfoFields:this._options.additional_symbol_info_fields,headerWidgetButtonsMode:this._options.header_widget_buttons_mode,customTranslateFunction:this._options.custom_translate_function,symbolSearchComplete:this._options.symbol_search_complete,contextMenu:this._options.context_menu,settingsOverrides:this._options.settings_overrides,timeframe:this._options.timeframe,customTimezones:this._options.custom_timezones},this._options.saved_data)e[this._id].chartContent={json:this._options.saved_data},this._options.saved_data_meta_info&&(e[this._id].chartContentExtendedData=this._options.saved_data_meta_info);else if(!this._options.load_last_chart&&!this._options.symbol)throw new Error("Symbol is not defined: either 'symbol' or 'load_last_chart' option must be set");if(this._options.library_path&&!this._options.library_path.endsWith("/")&&console.warn("library_path option should contain a trailing forward slash"),this._options.locale){const t=encodeURIComponent(this._options.locale);n.findIndex((e=>e.language===t))>=0||(console.warn("locale isn't supported. Using default of `en`."),this._options.locale="en")}const i=function(t,e){var i;const o=new URL(`${t||""}`,location.href).href,s=JSON.parse('["bundles/runtime.93ba548e6a7994d2a8f1.js","bundles/__LANG__.5008.e5d7d914577969582fa4.js","bundles/3515.2f722d33cebe31a154b1.css","bundles/1564.94d55d014a317059a934.js","bundles/library.0f3decc3cfc32a3eb326.js"]'),r=encodeURIComponent(e),a=null!==(i=n.find((t=>t.language===r)))&&void 0!==i?i:{iso:"en",dir:"ltr"},d=`lang="${a.iso}" dir="${a.dir}"`,l=`\n${function(t,e,n){if(void 0===t)return"";const i=[],o=[];for(const s of t)s.endsWith(".js")?i.push(`