@tony01/astroneum 0.4.1-beta.2 → 0.4.1-beta.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +281 -237
  2. package/LICENSE +21 -21
  3. package/README.md +250 -198
  4. package/dist/{Indicator-BBI3L_lx.d.ts → Indicator-BQQcVGGT.d.ts} +51 -227
  5. package/dist/astroneum.css +1 -1
  6. package/dist/chunk-47YGQEL5.js +399 -0
  7. package/dist/chunk-67XM5LOK.js +2 -0
  8. package/dist/{chunk-2YYGUSVX.js → chunk-DFJMDDL5.js} +1 -1
  9. package/dist/chunk-EFAS6F4C.js +59 -0
  10. package/dist/chunk-EHZN52CY.js +2 -0
  11. package/dist/chunk-HKLWNPMP.js +35 -0
  12. package/dist/chunk-ONPPQW65.js +2 -0
  13. package/dist/chunk-SCTHEM27.js +3 -0
  14. package/dist/chunk-UQXYMB6X.js +2 -0
  15. package/dist/chunk-WSIR5T2M.js +3 -0
  16. package/dist/entries/alerts.d.ts +36 -10
  17. package/dist/entries/alerts.js +1 -1
  18. package/dist/entries/datafeeds/crypto.d.ts +5 -1
  19. package/dist/entries/datafeeds/crypto.js +1 -1
  20. package/dist/entries/datafeeds/polygon.d.ts +3 -1
  21. package/dist/entries/datafeeds/polygon.js +1 -1
  22. package/dist/entries/headless.d.ts +78 -0
  23. package/dist/entries/headless.js +2 -0
  24. package/dist/entries/multichart.d.ts +12 -1
  25. package/dist/entries/multichart.js +1 -1
  26. package/dist/entries/replay.d.ts +3 -1
  27. package/dist/entries/script.d.ts +2 -68
  28. package/dist/entries/script.js +1 -1
  29. package/dist/entries/watchlist.d.ts +32 -2
  30. package/dist/entries/watchlist.js +1 -1
  31. package/dist/entries/workspace.d.ts +61 -0
  32. package/dist/entries/workspace.js +2 -0
  33. package/dist/index-BiXdqLA4.d.ts +45 -0
  34. package/dist/index-_JgHTy8X.d.ts +19 -0
  35. package/dist/index.d.ts +188 -27
  36. package/dist/index.js +1 -1
  37. package/dist/script-BU9StbN-.d.ts +120 -0
  38. package/dist/types-W6SIYQ9m.d.ts +232 -0
  39. package/dist/types-yETgeYsE.d.ts +28 -0
  40. package/dist/zh-CN-NDTUDZGZ.js +3 -0
  41. package/package.json +157 -147
  42. package/dist/chunk-4YOLQ5DC.js +0 -2
  43. package/dist/chunk-I4YQBP2M.js +0 -3
  44. package/dist/chunk-OOMZRONH.js +0 -35
  45. package/dist/chunk-PV2GAINM.js +0 -2
  46. package/dist/chunk-YW3STIPY.js +0 -653
  47. package/dist/zh-CN-Y2C6RSOI.js +0 -3
  48. package/docs/STRUCTURE.md +0 -231
  49. package/docs/TODO-DESIGN.md +0 -261
  50. package/docs/TODO.md +0 -222
  51. package/docs/api.md +0 -528
  52. package/docs/datafeed-guide.md +0 -311
  53. package/docs/design-astroneum.md +0 -479
  54. package/docs/plugin-development.md +0 -565
  55. package/docs/tv-functions-skill.md +0 -706
package/dist/index.d.ts CHANGED
@@ -1,25 +1,22 @@
1
- import { I as IndicatorTemplate, O as OverlayTemplate, X as XAxisTemplate, Y as YAxisTemplate, A as AstroneumOptions, a as AstroneumHandle, C as CandleData, b as IndicatorPlugin, P as Price, T as Timestamp, V as Volume, c as Chart, S as SerializedChartState, d as Period, e as SymbolInfo, D as Datafeed } from './Indicator-BBI3L_lx.js';
2
- export { f as ChartEventMap, g as ChartPlugin, h as ChartPluginContext, i as DatafeedSubscribeCallback, j as Viewport } from './Indicator-BBI3L_lx.js';
1
+ import { a as CandleData, C as Chart } from './Indicator-BQQcVGGT.js';
2
+ export { c as createIndicatorTemplateFromPlugin, g as getSupportedIndicators, a as getSupportedOverlays, r as registerIndicator, b as registerIndicatorPlugin, d as registerIndicatorPlugins, e as registerOverlay, f as registerXAxis, h as registerYAxis } from './index-_JgHTy8X.js';
3
3
  export { DefaultDatafeed, WebSocketDatafeed, WebSocketDatafeedOptions } from './entries/datafeeds/polygon.js';
4
4
  export { BinanceAdapter, BitgetAdapter, CryptoSymbolInfo, DATAFEED_ERROR_EVENT, DatafeedErrorDetail, DatafeedErrorType, ExchangeAdapter, OkxAdapter, STANDARD_CRYPTO_SYMBOLS, StandardCryptoDatafeed, StandardCryptoDatafeedOptions, createStandardCryptoDatafeed } from './entries/datafeeds/crypto.js';
5
5
  import * as react from 'react';
6
+ import { A as AstroneumOptions, a as AstroneumHandle, S as SymbolInfo, b as SerializedChartState, P as Period, D as Datafeed } from './types-W6SIYQ9m.js';
7
+ export { C as ChartEventMap, c as ChartPlugin, d as ChartPluginContext, e as ChartToolbarActions, f as DatafeedSubscribeCallback, Q as QuoteSnapshot, g as SerializedIndicator } from './types-W6SIYQ9m.js';
6
8
  export { MultiChartCount, MultiChartLayout, MultiChartLayoutOptions, MultiChartSlot } from './entries/multichart.js';
7
9
  export { BarReplay, BarReplayOptions, BarReplayState } from './entries/replay.js';
8
- export { Alert, AlertCheckInput, AlertCondition, AlertCreate, AlertFrequency, AlertManager, AlertStatus, AlertTriggeredCallback, NotificationSchedule, SoundDuration, SoundTitle } from './entries/alerts.js';
9
- export { CompiledIndicator, InputOptions, PlotOptions, ScriptEngine, StudyOptions } from './entries/script.js';
10
- export { WatchSymbol, Watchlist, WatchlistManager } from './entries/watchlist.js';
10
+ export { Alert, AlertChangeCallback, AlertCheckInput, AlertCondition, AlertConditionDef, AlertCreate, AlertFrequency, AlertManager, AlertOperator, AlertSource, AlertStatus, AlertTriggeredCallback, NotificationSchedule, SoundDuration, SoundTitle, WebhookStatus } from './entries/alerts.js';
11
+ import { S as StrategySide, B as BacktestConfig, a as BacktestResult } from './script-BU9StbN-.js';
12
+ export { b as BacktestMetrics, c as BacktestTrade, C as CompiledIndicator, d as CompiledStrategy, E as EquityPoint, I as InputOptions, P as PlotOptions, e as ScriptEngine, f as StudyOptions } from './script-BU9StbN-.js';
13
+ export { WatchSymbol, Watchlist, WatchlistColumn, WatchlistManager, WatchlistSort, WatchlistSortDirection } from './entries/watchlist.js';
11
14
  import { Position } from './entries/portfolio.js';
12
15
  export { PnLResult, PortfolioTracker, PositionSide } from './entries/portfolio.js';
13
-
14
- declare function registerIndicator<D = unknown, C = unknown, E = unknown>(indicator: IndicatorTemplate<D, C, E>): void;
15
- declare function getSupportedIndicators(): string[];
16
-
17
- declare function registerOverlay<E = unknown>(template: OverlayTemplate<E>): void;
18
- declare function getSupportedOverlays(): string[];
19
-
20
- declare function registerXAxis(axis: XAxisTemplate): void;
21
-
22
- declare function registerYAxis(axis: YAxisTemplate): void;
16
+ import { C as Component } from './index-BiXdqLA4.js';
17
+ export { A as AlertModal, I as IndicatorSourceOption, L as LayerProvider, u as useLayer, a as useLayerProvider } from './index-BiXdqLA4.js';
18
+ import { P as Price, T as Timestamp, V as Volume, I as IndicatorPlugin } from './types-yETgeYsE.js';
19
+ export { a as Viewport } from './types-yETgeYsE.js';
23
20
 
24
21
  declare const AstroneumChart: react.ForwardRefExoticComponent<AstroneumOptions & react.RefAttributes<AstroneumHandle>>;
25
22
 
@@ -140,6 +137,13 @@ declare class DrawingTemplates {
140
137
  }, overlayId: string, color: string): void;
141
138
  }
142
139
 
140
+ interface StrategySignal {
141
+ index: number;
142
+ action: 'enter' | 'exit';
143
+ side?: StrategySide;
144
+ }
145
+ declare function runBacktest(bars: CandleData[], signals: StrategySignal[], config?: Partial<BacktestConfig>): BacktestResult;
146
+
143
147
  /**
144
148
  * PerformanceMode — data decimation and virtualization utilities.
145
149
  *
@@ -194,6 +198,14 @@ declare class PerformanceMode {
194
198
  static heikinAshi: typeof heikinAshi;
195
199
  }
196
200
 
201
+ interface SymbolSearchModalProps {
202
+ locale: string;
203
+ searchSymbols: (query?: string) => Promise<SymbolInfo[]>;
204
+ onSymbolSelected: (symbol: SymbolInfo) => void;
205
+ onClose: () => void;
206
+ }
207
+ declare const SymbolSearchModal: Component<SymbolSearchModalProps>;
208
+
197
209
  var indicator = "Indicator";
198
210
  var main_indicator = "Main Indicator";
199
211
  var sub_indicator = "Sub Indicator";
@@ -270,6 +282,11 @@ var fibonacci_circle = "Fibonacci Circle";
270
282
  var fibonacci_spiral = "Fibonacci Spiral";
271
283
  var fibonacci_speed_resistance_fan = "Fibonacci Sector";
272
284
  var fibonacci_extension = "Fibonacci Extension";
285
+ var fibonacci_channel = "Fibonacci Channel";
286
+ var fibonacci_wedge = "Fibonacci Wedge";
287
+ var fibonacci_time_zones = "Fibonacci Time Zones";
288
+ var fibonacci_arcs = "Fibonacci Arcs";
289
+ var fibonacci_fan = "Fibonacci Fan";
273
290
  var gann_box = "Gann Box";
274
291
  var gann_fan = "Gann Fan";
275
292
  var pitchfork = "Andrews Pitchfork";
@@ -285,8 +302,10 @@ var abcd = "ABCD Pattern";
285
302
  var xabcd = "XABCD Pattern";
286
303
  var weak_magnet = "Weak Magnet";
287
304
  var strong_magnet = "Strong Magnet";
288
- var symbol_search = "Symbol Search";
289
- var symbol_code = "Symbol Code";
305
+ var symbol_search = "Symbol search";
306
+ var symbol_code = "Symbol, ISIN, or CUSIP";
307
+ var sample_study = "Sample Study";
308
+ var sample_study_desc = "Alertable oscillator (0-100) demonstrating indicator-based alerts";
290
309
  var params_1 = "Parameter 1";
291
310
  var params_2 = "Parameter 2";
292
311
  var params_3 = "Parameter 3";
@@ -319,15 +338,43 @@ var grid_show = "Show Grids";
319
338
  var restore_default = "Restore Defaults";
320
339
  var alerts = "Alerts";
321
340
  var alert_create = "Create";
341
+ var alert_create_alert = "Create alert";
342
+ var alert_create_on = "Create alert on";
343
+ var alert_save = "Save";
322
344
  var alert_history = "History";
323
345
  var alert_condition = "Condition";
324
346
  var alert_price = "Price";
347
+ var alert_source = "Source";
348
+ var alert_source_price = "Price";
349
+ var alert_operator = "Operator";
350
+ var alert_value = "Value";
351
+ var alert_crosses = "Crosses";
352
+ var alert_is_between = "Is between";
353
+ var alert_add_condition = "Add condition";
325
354
  var alert_note = "Note";
326
355
  var alert_note_placeholder = "Optional label…";
327
356
  var alert_add = "Add Alert";
357
+ var alert_create_button = "Create";
358
+ var alert_submitting = "Creating…";
359
+ var alert_saving = "Saving…";
360
+ var alert_invalid_price = "Please enter a valid number";
361
+ var alert_invalid_condition = "At least one valid condition is required";
362
+ var alert_quota_exceeded = "Alert limit reached";
363
+ var alert_retry = "Retry";
328
364
  var alert_active = "Active";
365
+ var alert_no_active = "No active alerts";
329
366
  var alert_no_history = "No triggered alerts yet";
330
367
  var alert_reactivate = "Re-activate";
368
+ var alert_pause = "Pause";
369
+ var alert_resume = "Resume";
370
+ var alert_edit = "Edit";
371
+ var alert_delete = "Delete";
372
+ var alert_search = "Search alerts…";
373
+ var alert_filter_all = "All symbols";
374
+ var alert_filter_current = "Current symbol";
375
+ var alert_paused = "Paused";
376
+ var alert_expired = "Expired";
377
+ var alert_dismissed = "Dismissed";
331
378
  var alert_above = "Above";
332
379
  var alert_below = "Below";
333
380
  var alert_crosses_above = "Crosses ↑";
@@ -344,6 +391,7 @@ var alert_expiration_1m = "In 1 month";
344
391
  var alert_expiration_2m = "In 2 months";
345
392
  var alert_message = "Message";
346
393
  var alert_message_hint = "Sent as the webhook body when a webhook URL is set.";
394
+ var alert_message_done = "Done";
347
395
  var alert_webhook_body = "Webhook body";
348
396
  var alert_notifications = "Notifications";
349
397
  var alert_back = "Back";
@@ -396,6 +444,45 @@ var watchlist_delete_list = "Delete watchlist";
396
444
  var watchlist_add_symbol = "Add";
397
445
  var watchlist_remove_symbol = "Remove symbol";
398
446
  var watchlist_enter_symbol = "Enter ticker…";
447
+ var cross_cursor = "Cross";
448
+ var dot_cursor = "Dot";
449
+ var arrow_cursor = "Arrow";
450
+ var eraser_cursor = "Eraser";
451
+ var measure = "Measure";
452
+ var zoom_in = "Zoom In";
453
+ var keep_drawing = "Keep Drawing";
454
+ var long_position = "Long Position";
455
+ var short_position = "Short Position";
456
+ var position_forecast = "Position Forecast";
457
+ var bars_pattern = "Bars Pattern";
458
+ var ghost_feed = "Ghost Feed";
459
+ var sector = "Sector";
460
+ var anchored_vwap = "Anchored VWAP";
461
+ var fixed_range_volume_profile = "Fixed Range Volume Profile";
462
+ var anchored_volume_profile = "Anchored Volume Profile";
463
+ var price_range = "Price Range";
464
+ var date_range = "Date Range";
465
+ var date_and_price_range = "Date and Price Range";
466
+ var forecasting = "Forecasting";
467
+ var volume_based = "Volume-based";
468
+ var measurers = "Measurers";
469
+ var text_note = "Text";
470
+ var annotation = "Annotation";
471
+ var symbol_search_all = "All";
472
+ var symbol_search_stocks = "Stocks";
473
+ var symbol_search_funds = "Funds";
474
+ var symbol_search_futures = "Futures";
475
+ var symbol_search_forex = "Forex";
476
+ var symbol_search_crypto = "Crypto";
477
+ var symbol_search_indices = "Indices";
478
+ var symbol_search_bonds = "Bonds";
479
+ var symbol_search_economy = "Economy";
480
+ var symbol_search_options = "Options";
481
+ var symbol_search_more = "More";
482
+ var symbol_search_footer = "Search using ISIN and CUSIP codes";
483
+ var symbol_search_no_results = "No symbols found";
484
+ var symbol_search_loading = "Searching...";
485
+ var symbol_search_clear = "Clear search";
399
486
  var enUS = {
400
487
  indicator: indicator,
401
488
  main_indicator: main_indicator,
@@ -473,6 +560,11 @@ var enUS = {
473
560
  fibonacci_spiral: fibonacci_spiral,
474
561
  fibonacci_speed_resistance_fan: fibonacci_speed_resistance_fan,
475
562
  fibonacci_extension: fibonacci_extension,
563
+ fibonacci_channel: fibonacci_channel,
564
+ fibonacci_wedge: fibonacci_wedge,
565
+ fibonacci_time_zones: fibonacci_time_zones,
566
+ fibonacci_arcs: fibonacci_arcs,
567
+ fibonacci_fan: fibonacci_fan,
476
568
  gann_box: gann_box,
477
569
  gann_fan: gann_fan,
478
570
  pitchfork: pitchfork,
@@ -490,6 +582,8 @@ var enUS = {
490
582
  strong_magnet: strong_magnet,
491
583
  symbol_search: symbol_search,
492
584
  symbol_code: symbol_code,
585
+ sample_study: sample_study,
586
+ sample_study_desc: sample_study_desc,
493
587
  params_1: params_1,
494
588
  params_2: params_2,
495
589
  params_3: params_3,
@@ -522,15 +616,43 @@ var enUS = {
522
616
  restore_default: restore_default,
523
617
  alerts: alerts,
524
618
  alert_create: alert_create,
619
+ alert_create_alert: alert_create_alert,
620
+ alert_create_on: alert_create_on,
621
+ alert_save: alert_save,
525
622
  alert_history: alert_history,
526
623
  alert_condition: alert_condition,
527
624
  alert_price: alert_price,
625
+ alert_source: alert_source,
626
+ alert_source_price: alert_source_price,
627
+ alert_operator: alert_operator,
628
+ alert_value: alert_value,
629
+ alert_crosses: alert_crosses,
630
+ alert_is_between: alert_is_between,
631
+ alert_add_condition: alert_add_condition,
528
632
  alert_note: alert_note,
529
633
  alert_note_placeholder: alert_note_placeholder,
530
634
  alert_add: alert_add,
635
+ alert_create_button: alert_create_button,
636
+ alert_submitting: alert_submitting,
637
+ alert_saving: alert_saving,
638
+ alert_invalid_price: alert_invalid_price,
639
+ alert_invalid_condition: alert_invalid_condition,
640
+ alert_quota_exceeded: alert_quota_exceeded,
641
+ alert_retry: alert_retry,
531
642
  alert_active: alert_active,
643
+ alert_no_active: alert_no_active,
532
644
  alert_no_history: alert_no_history,
533
645
  alert_reactivate: alert_reactivate,
646
+ alert_pause: alert_pause,
647
+ alert_resume: alert_resume,
648
+ alert_edit: alert_edit,
649
+ alert_delete: alert_delete,
650
+ alert_search: alert_search,
651
+ alert_filter_all: alert_filter_all,
652
+ alert_filter_current: alert_filter_current,
653
+ alert_paused: alert_paused,
654
+ alert_expired: alert_expired,
655
+ alert_dismissed: alert_dismissed,
534
656
  alert_above: alert_above,
535
657
  alert_below: alert_below,
536
658
  alert_crosses_above: alert_crosses_above,
@@ -547,6 +669,7 @@ var enUS = {
547
669
  alert_expiration_2m: alert_expiration_2m,
548
670
  alert_message: alert_message,
549
671
  alert_message_hint: alert_message_hint,
672
+ alert_message_done: alert_message_done,
550
673
  alert_webhook_body: alert_webhook_body,
551
674
  alert_notifications: alert_notifications,
552
675
  alert_back: alert_back,
@@ -599,7 +722,46 @@ var enUS = {
599
722
  watchlist_delete_list: watchlist_delete_list,
600
723
  watchlist_add_symbol: watchlist_add_symbol,
601
724
  watchlist_remove_symbol: watchlist_remove_symbol,
602
- watchlist_enter_symbol: watchlist_enter_symbol
725
+ watchlist_enter_symbol: watchlist_enter_symbol,
726
+ cross_cursor: cross_cursor,
727
+ dot_cursor: dot_cursor,
728
+ arrow_cursor: arrow_cursor,
729
+ eraser_cursor: eraser_cursor,
730
+ measure: measure,
731
+ zoom_in: zoom_in,
732
+ keep_drawing: keep_drawing,
733
+ long_position: long_position,
734
+ short_position: short_position,
735
+ position_forecast: position_forecast,
736
+ bars_pattern: bars_pattern,
737
+ ghost_feed: ghost_feed,
738
+ sector: sector,
739
+ anchored_vwap: anchored_vwap,
740
+ fixed_range_volume_profile: fixed_range_volume_profile,
741
+ anchored_volume_profile: anchored_volume_profile,
742
+ price_range: price_range,
743
+ date_range: date_range,
744
+ date_and_price_range: date_and_price_range,
745
+ forecasting: forecasting,
746
+ volume_based: volume_based,
747
+ measurers: measurers,
748
+ text_note: text_note,
749
+ annotation: annotation,
750
+ symbol_search_all: symbol_search_all,
751
+ symbol_search_stocks: symbol_search_stocks,
752
+ symbol_search_funds: symbol_search_funds,
753
+ symbol_search_futures: symbol_search_futures,
754
+ symbol_search_forex: symbol_search_forex,
755
+ symbol_search_crypto: symbol_search_crypto,
756
+ symbol_search_indices: symbol_search_indices,
757
+ symbol_search_bonds: symbol_search_bonds,
758
+ symbol_search_economy: symbol_search_economy,
759
+ symbol_search_options: symbol_search_options,
760
+ symbol_search_more: symbol_search_more,
761
+ symbol_search_footer: symbol_search_footer,
762
+ symbol_search_no_results: symbol_search_no_results,
763
+ symbol_search_loading: symbol_search_loading,
764
+ symbol_search_clear: symbol_search_clear
603
765
  };
604
766
 
605
767
  type LocaleKey = keyof typeof enUS;
@@ -712,11 +874,6 @@ declare function formatPeriod(period: {
712
874
  */
713
875
  declare function detectPricePrecision(price: number): number;
714
876
 
715
- type NormalizedIndicatorRow = Record<string, number | null>;
716
- declare function createIndicatorTemplateFromPlugin<TOutput>(plugin: IndicatorPlugin<TOutput>): IndicatorTemplate<NormalizedIndicatorRow, number>;
717
- declare function registerIndicatorPlugin<TOutput>(plugin: IndicatorPlugin<TOutput>): void;
718
- declare function registerIndicatorPlugins(plugins: ReadonlyArray<IndicatorPlugin<unknown>>): void;
719
-
720
877
  /** Cast a raw number to the Price brand. Use only when the number is known to be a price. */
721
878
  declare function asPrice(n: number): Price;
722
879
  /** Cast a raw number to the Volume brand. Use only when the number is known to be a volume. */
@@ -1032,13 +1189,12 @@ interface ChartTemplate {
1032
1189
  name: string;
1033
1190
  state: SerializedChartState;
1034
1191
  createdAt: string;
1192
+ updatedAt?: string;
1035
1193
  }
1036
1194
  /**
1037
1195
  * ChartTemplateManager — save/load named chart configurations.
1038
1196
  *
1039
- * Templates persist to localStorage and include theme, locale, timezone,
1040
- * styles, indicators, and overlay state. Symbols and periods are intentionally
1041
- * NOT included — templates apply chart settings to any symbol.
1197
+ * Templates persist the complete chart state to localStorage.
1042
1198
  *
1043
1199
  * Usage:
1044
1200
  * const templates = ChartTemplateManager.getInstance()
@@ -1062,6 +1218,11 @@ declare class ChartTemplateManager {
1062
1218
  get(name: string): ChartTemplate | undefined;
1063
1219
  /** Get all templates. */
1064
1220
  getAll(): ChartTemplate[];
1221
+ rename(name: string, nextName: string): ChartTemplate | null;
1222
+ duplicate(name: string): ChartTemplate | null;
1223
+ setActiveName(name: string): boolean;
1224
+ getActiveName(): string | null;
1225
+ clearActiveName(): void;
1065
1226
  private _persist;
1066
1227
  private _load;
1067
1228
  }
@@ -1431,4 +1592,4 @@ declare function generatePointAndFigure(data: CandleData[], boxSize?: number, re
1431
1592
  */
1432
1593
  declare const pointAndFigurePlugin: IndicatorPlugin<number>;
1433
1594
 
1434
- export { AstroneumChart, AstroneumHandle, AstroneumOptions, BUILTIN_LOCALES, CandleData, type ChartTemplate, ChartTemplateManager, type CompareIndicatorOptions, type DOMLevel, Datafeed, type DateFormatStyle, type DrawingStyleTemplate, DrawingTemplates, EventBus, type FormatPriceOptions, IndicatorPlugin, MultiPeriodLayout, type MultiPeriodLayoutOptions, type OverlayStylePreset, PATTERN_CATALOGUE, type PFColumn, type PFConfig, type PatternDef, type PatternMatch, type Bar as PerformanceBar, PerformanceMode, Period, Position, type PositionVisual, PositionVisualizer, Price, type PriceScaleMode, RingBuffer, SerializedChartState, type SessionConfig, SessionVisualizer, SymbolInfo, TickAnimator, type TickAnimatorOptions, type TimeFormatStyle, Timestamp, UndoManager, Volume, type VolumeProfileRow, asPrice, asTimestamp, asVolume, computePFColumns, createCompareIndicator, createIndicatorTemplateFromPlugin, deepClone, deepSet, detectPricePrecision, detectSupportResistance, domPlugin, formatDate, formatDateTime, formatDuration, formatPercent, formatPeriod, formatPrice, formatScaleTick, formatTime, formatVolume, forwardFill, generateKagi, generatePointAndFigure, generateRangeBars, generateRenko, generateTickBars, getSupportedIndicators, getSupportedOverlays, heikinAshi, loadLocale, load as loadLocales, mtfIndicator, patternRecognitionPlugin, pfColumnsToBars, pointAndFigurePlugin, rafCoalesce, rafMergeTick, registerIndicator, registerIndicatorPlugin, registerIndicatorPlugins, registerOverlay, registerXAxis, registerYAxis, resampleBars, transformCandles, untransformPrice, volumeProfilePlugin, zigzag, zigzagPlugin };
1595
+ export { AstroneumChart, AstroneumHandle, AstroneumOptions, BUILTIN_LOCALES, BacktestConfig, BacktestResult, CandleData, type ChartTemplate, ChartTemplateManager, type CompareIndicatorOptions, type DOMLevel, Datafeed, type DateFormatStyle, type DrawingStyleTemplate, DrawingTemplates, EventBus, type FormatPriceOptions, IndicatorPlugin, MultiPeriodLayout, type MultiPeriodLayoutOptions, type OverlayStylePreset, PATTERN_CATALOGUE, type PFColumn, type PFConfig, type PatternDef, type PatternMatch, type Bar as PerformanceBar, PerformanceMode, Period, Position, type PositionVisual, PositionVisualizer, Price, type PriceScaleMode, RingBuffer, SerializedChartState, type SessionConfig, SessionVisualizer, StrategySide, type StrategySignal, SymbolInfo, SymbolSearchModal, type SymbolSearchModalProps, TickAnimator, type TickAnimatorOptions, type TimeFormatStyle, Timestamp, UndoManager, Volume, type VolumeProfileRow, asPrice, asTimestamp, asVolume, computePFColumns, createCompareIndicator, deepClone, deepSet, detectPricePrecision, detectSupportResistance, domPlugin, formatDate, formatDateTime, formatDuration, formatPercent, formatPeriod, formatPrice, formatScaleTick, formatTime, formatVolume, forwardFill, generateKagi, generatePointAndFigure, generateRangeBars, generateRenko, generateTickBars, heikinAshi, loadLocale, load as loadLocales, mtfIndicator, patternRecognitionPlugin, pfColumnsToBars, pointAndFigurePlugin, rafCoalesce, rafMergeTick, resampleBars, runBacktest, transformCandles, untransformPrice, volumeProfilePlugin, zigzag, zigzagPlugin };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- export{a as DefaultDatafeed}from'./chunk-2YYGUSVX.js';import {l}from'./chunk-OOMZRONH.js';export{l as AstroneumChart,c as BUILTIN_LOCALES,m as MultiChartLayout,e as PerformanceMode,i as createIndicatorTemplateFromPlugin,h as formatScaleTick,d as heikinAshi,b as loadLocale,a as loadLocales,j as registerIndicatorPlugin,k as registerIndicatorPlugins,f as transformCandles,g as untransformPrice}from'./chunk-OOMZRONH.js';export{a as asPrice,c as asTimestamp,b as asVolume,g as deepClone,f as deepSet,d as rafCoalesce,e as rafMergeTick}from'./chunk-YFPXTHZX.js';export{a as AlertManager}from'./chunk-4YOLQ5DC.js';export{a as PortfolioTracker}from'./chunk-2SN3RH42.js';export{a as BarReplay}from'./chunk-3GJSZFLM.js';import {c,k}from'./chunk-YW3STIPY.js';export{l as ScriptEngine,b as getSupportedIndicators,d as getSupportedOverlays,a as registerIndicator,c as registerOverlay,h as registerXAxis,g as registerYAxis}from'./chunk-YW3STIPY.js';export{a as WatchlistManager}from'./chunk-PV2GAINM.js';export{c as BinanceAdapter,d as BitgetAdapter,b as DATAFEED_ERROR_EVENT,e as OkxAdapter,a as STANDARD_CRYPTO_SYMBOLS,f as StandardCryptoDatafeed,g as createStandardCryptoDatafeed}from'./chunk-I4YQBP2M.js';export{a as TickAnimator,b as WebSocketDatafeed}from'./chunk-SDXH2WAI.js';import Tr from'react';import {createRoot}from'react-dom/client';import {flushSync}from'react-dom';function P(e,t,r){let n=(e.x-t.x)*Math.cos(r)-(e.y-t.y)*Math.sin(r)+t.x,o=(e.x-t.x)*Math.sin(r)+(e.y-t.y)*Math.cos(r)+t.y;return {x:n,y:o}}function A(e,t){if(e.length>1){let r;return e[0].x===e[1].x&&e[0].y!==e[1].y?e[0].y<e[1].y?r={x:e[0].x,y:t.height}:r={x:e[0].x,y:0}:e[0].x>e[1].x?r={x:0,y:k.getLinearYFromCoordinates(e[0],e[1],{x:0,y:e[0].y})}:r={x:t.width,y:k.getLinearYFromCoordinates(e[0],e[1],{x:t.width,y:e[0].y})},{coordinates:[e[0],r]}}return []}var C="rgba(22, 119, 255, 0.08)";function E(e,t){let r=t.x>e.x?0:1,n=k.getLinearSlopeIntercept(e,t);return n?Math.atan(n[0])+Math.PI*r:t.y>e.y?Math.PI/2:Math.PI/2*3}function w(e,t){let r=Math.abs(e.x-t.x),n=Math.abs(e.y-t.y);return Math.sqrt(r*r+n*n)}function z(e,t,r,n,o,i,a){let s=r.x>t.x?t.x:r.x,u=[],l=[];return e.forEach(c=>{let m=r.y+n*c,p=(i+o*c).toFixed(a);u.push({coordinates:[{x:t.x,y:m},{x:r.x,y:m}]}),l.push({x:s,y:m,text:`${p} (${(c*100).toFixed(1)}%)`,baseline:"bottom"});}),{lines:u,texts:l}}var Ct={name:"arrow",totalStep:3,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:e})=>{if(e.length>1){let t=E(e[0],e[1]),r=P({x:e[1].x-8,y:e[1].y+4},e[1],t),n=P({x:e[1].x-8,y:e[1].y-4},e[1],t);return [{type:"line",attrs:{coordinates:e}},{type:"line",ignoreEvent:true,attrs:{coordinates:[r,e[1],n]}}]}return []}},ae=Ct;var Mt={name:"circle",totalStep:3,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,styles:{circle:{color:C}},createPointFigures:({coordinates:e})=>{if(e.length>1){let t=w(e[0],e[1]);return {type:"circle",attrs:{...e[0],r:t},styles:{style:"stroke_fill"}}}return []}},se=Mt;var Pt={name:"rect",totalStep:3,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,styles:{polygon:{color:C}},createPointFigures:({coordinates:e})=>e.length>1?[{type:"polygon",attrs:{coordinates:[e[0],{x:e[1].x,y:e[0].y},e[1],{x:e[0].x,y:e[1].y}]},styles:{style:"stroke_fill"}}]:[]},le=Pt;var wt={name:"parallelogram",totalStep:4,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,styles:{polygon:{color:C}},createPointFigures:({coordinates:e})=>{if(e.length===2)return [{type:"line",ignoreEvent:true,attrs:{coordinates:e}}];if(e.length===3){let t={x:e[0].x+(e[2].x-e[1].x),y:e[2].y};return [{type:"polygon",attrs:{coordinates:[e[0],e[1],e[2],t]},styles:{style:"stroke_fill"}}]}return []},performEventPressedMove:({points:e,performPointIndex:t,performPoint:r})=>{t<2&&(e[0].price=r.price,e[1].price=r.price);},performEventMoveForDrawing:({currentStep:e,points:t,performPoint:r})=>{e===2&&(t[0].price=r.price);}},ue=wt;var St={name:"triangle",totalStep:4,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,styles:{polygon:{color:C}},createPointFigures:({coordinates:e})=>[{type:"polygon",attrs:{coordinates:e},styles:{style:"stroke_fill"}}]},me=St;var Tt={name:"fibonacciCircle",totalStep:3,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:e})=>{if(e.length>1){let t=w(e[0],e[1]),r=[.236,.382,.5,.618,.786,1],n=[],o=[];return r.forEach(i=>{let a=t*i;n.push({...e[0],r:a}),o.push({x:e[0].x,y:e[0].y+a+6,text:`${(i*100).toFixed(1)}%`});}),[{type:"circle",attrs:n,styles:{style:"stroke"}},{type:"text",ignoreEvent:true,attrs:o}]}return []}},ce=Tt;var At={name:"fibonacciSegment",totalStep:3,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:e,overlay:t,chart:r})=>{if(e.length<=1)return [{type:"line",attrs:[]},{type:"text",ignoreEvent:true,attrs:[]}];let n=t.points,o=n[0].value-n[1].value,i=e[0].y-e[1].y,a=r.getSymbol()?.pricePrecision??2,{lines:s,texts:u}=z([1,.786,.618,.5,.382,.236,0],e[0],e[1],i,o,n[1].value,a);return [{type:"line",attrs:s},{type:"text",ignoreEvent:true,attrs:u}]}},pe=At;var Ft={name:"fibonacciSpiral",totalStep:3,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:e,bounding:t})=>{if(e.length>1){let r=w(e[0],e[1])/Math.sqrt(24),n=E(e[0],e[1]),o=P({x:e[0].x-r,y:e[0].y},e[0],n),i=P({x:e[0].x-r,y:e[0].y-r},e[0],n),a=[{...o,r,startAngle:n,endAngle:n+Math.PI/2},{...i,r:r*2,startAngle:n+Math.PI/2,endAngle:n+Math.PI}],s=e[0].x-r,u=e[0].y-r;for(let l=2;l<9;l++){let c=a[l-2].r+a[l-1].r,m=0;switch(l%4){case 0:{m=n,s-=a[l-2].r;break}case 1:{m=n+Math.PI/2,u-=a[l-2].r;break}case 2:{m=n+Math.PI,s+=a[l-2].r;break}case 3:{m=n+Math.PI/2*3,u+=a[l-2].r;break}}let p=m+Math.PI/2,y=P({x:s,y:u},e[0],n);a.push({...y,r:c,startAngle:m,endAngle:p});}return [{type:"arc",attrs:a},{type:"line",attrs:A(e,t)}]}return []}},he=Ft;var Ot={name:"fibonacciSpeedResistanceFan",totalStep:3,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:e,bounding:t})=>{let r=[],n=[],o=[];if(e.length>1){let i=e[1].x>e[0].x?-38:4,a=e[1].y>e[0].y?-2:20,s=e[1].x-e[0].x,u=e[1].y-e[0].y;[1,.75,.618,.5,.382,.25,0].forEach(c=>{let m=e[1].x-s*c,p=e[1].y-u*c;r.push({coordinates:[{x:m,y:e[0].y},{x:m,y:e[1].y}]}),r.push({coordinates:[{x:e[0].x,y:p},{x:e[1].x,y:p}]}),n=n.concat(A([e[0],{x:m,y:e[1].y}],t)),n=n.concat(A([e[0],{x:e[1].x,y:p}],t)),o.unshift({x:e[0].x+i,y:p+10,text:`${c.toFixed(3)}`}),o.unshift({x:m-18,y:e[0].y+a,text:`${c.toFixed(3)}`});});}return [{type:"line",attrs:r},{type:"line",attrs:n},{type:"text",ignoreEvent:true,attrs:o}]}},fe=Ot;var Lt={name:"fibonacciExtension",totalStep:4,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:e,overlay:t,chart:r})=>{if(e.length<=2)return [{type:"line",attrs:{coordinates:e},styles:{style:"dashed"}},{type:"line",attrs:[]},{type:"text",ignoreEvent:true,attrs:[]}];let n=t.points,o=n[1].value-n[0].value,i=e[1].y-e[0].y,a=r.getSymbol()?.pricePrecision??2,{lines:s,texts:u}=z([0,.236,.382,.5,.618,.786,1],e[1],e[2],i,o,n[2].value,a);return [{type:"line",attrs:{coordinates:e},styles:{style:"dashed"}},{type:"line",attrs:s},{type:"text",ignoreEvent:true,attrs:u}]}},ye=Lt;var kt={name:"gannBox",totalStep:3,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,styles:{polygon:{color:C}},createPointFigures:({coordinates:e})=>{if(e.length>1){let t=(e[1].y-e[0].y)/4,r=e[1].x-e[0].x,n=[{coordinates:[e[0],{x:e[1].x,y:e[1].y-t}]},{coordinates:[e[0],{x:e[1].x,y:e[1].y-t*2}]},{coordinates:[{x:e[0].x,y:e[1].y},{x:e[1].x,y:e[0].y+t}]},{coordinates:[{x:e[0].x,y:e[1].y},{x:e[1].x,y:e[0].y+t*2}]},{coordinates:[{...e[0]},{x:e[0].x+r*.236,y:e[1].y}]},{coordinates:[{...e[0]},{x:e[0].x+r*.5,y:e[1].y}]},{coordinates:[{x:e[0].x,y:e[1].y},{x:e[0].x+r*.236,y:e[0].y}]},{coordinates:[{x:e[0].x,y:e[1].y},{x:e[0].x+r*.5,y:e[0].y}]}],o=[{coordinates:[e[0],e[1]]},{coordinates:[{x:e[0].x,y:e[1].y},{x:e[1].x,y:e[0].y}]}];return [{type:"line",attrs:[{coordinates:[e[0],{x:e[1].x,y:e[0].y}]},{coordinates:[{x:e[1].x,y:e[0].y},e[1]]},{coordinates:[e[1],{x:e[0].x,y:e[1].y}]},{coordinates:[{x:e[0].x,y:e[1].y},e[0]]}]},{type:"polygon",ignoreEvent:true,attrs:{coordinates:[e[0],{x:e[1].x,y:e[0].y},e[1],{x:e[0].x,y:e[1].y}]},styles:{style:"fill"}},{type:"line",attrs:n,styles:{style:"dashed"}},{type:"line",attrs:o}]}return []}},ge=kt;var It=[{label:"1x8",ratio:8},{label:"1x4",ratio:4},{label:"1x3",ratio:3},{label:"1x2",ratio:2},{label:"1x1",ratio:1},{label:"2x1",ratio:.5},{label:"3x1",ratio:.3333333333333333},{label:"4x1",ratio:.25},{label:"8x1",ratio:.125}],Rt={name:"gannFan",totalStep:3,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:e,bounding:t})=>{if(e.length<2)return [];let[r,n]=e,o=n.x-r.x,i=n.y-r.y;if(Math.abs(o)<1e-6)return [];let a=i/o,s=[],u=[];for(let{label:l,ratio:c}of It){let m=a*c,p=Et(r,m,o>0,t);s.push({coordinates:[r,p]}),u.push({x:p.x,y:p.y,text:l,baseline:"bottom"});}return [{type:"line",attrs:s},{type:"text",ignoreEvent:true,attrs:u}]}};function Et(e,t,r,n){let o=[],i=r?n.width:0,a=e.y+t*(i-e.x);if(a>=0&&a<=n.height&&o.push({x:i,y:a}),Math.abs(t)>1e-6){let s=e.x+(0-e.y)/t;s>=0&&s<=n.width&&(r?s>e.x:s<e.x)&&o.push({x:s,y:0});let u=e.x+(n.height-e.y)/t;u>=0&&u<=n.width&&(r?u>e.x:u<e.x)&&o.push({x:u,y:n.height});}return o.length===0?{x:i,y:a}:o.reduce((s,u)=>{let l=Math.hypot(s.x-e.x,s.y-e.y);return Math.hypot(u.x-e.x,u.y-e.y)>l?u:s})}var de=Rt;var zt={name:"pitchfork",totalStep:4,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:e,bounding:t})=>{if(e.length<2)return [];let[r,n,o]=e;if(e.length===2)return [{type:"line",attrs:{coordinates:[r,n]}}];let i={x:(n.x+o.x)/2,y:(n.y+o.y)/2},a=i.x-r.x,s=i.y-r.y,u=F(r,i,t),l={x:n.x+a*10,y:n.y+s*10},c={x:o.x+a*10,y:o.y+s*10},m=F(n,l,t),p=F(o,c,t),y=xe(n,i,.5),h=xe(o,i,.5),f={x:y.x+a*10,y:y.y+s*10},d={x:h.x+a*10,y:h.y+s*10},g=F(y,f,t),D=F(h,d,t);return [{type:"line",attrs:u},{type:"line",attrs:m},{type:"line",attrs:p},{type:"line",attrs:[{coordinates:[r,n]},{coordinates:[r,o]}],styles:{style:"dashed"}},{type:"line",attrs:[g,D],styles:{style:"dashed"}}]}};function F(e,t,r){let n=t.x-e.x,o=t.y-e.y;if(Math.abs(n)<1e-6)return {coordinates:[{x:e.x,y:0},{x:e.x,y:r.height}]};let i=o/n,a=e.y-i*e.x,s=a,u=i*r.width+a;return {coordinates:[{x:0,y:s},{x:r.width,y:u}]}}function xe(e,t,r){return {x:e.x+(t.x-e.x)*r,y:e.y+(t.y-e.y)*r}}var be=zt;function H(e,t){return {name:e,totalStep:t,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:r})=>{let n=r.map((o,i)=>({...o,text:`(${i})`,baseline:"bottom"}));return [{type:"line",attrs:{coordinates:r}},{type:"text",ignoreEvent:true,attrs:n}]}}}var _e=H("threeWaves",5),ve=H("fiveWaves",7),De=H("eightWaves",10),Ce=H("anyWaves",Number.MAX_SAFE_INTEGER);var Ht={name:"abcd",totalStep:5,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:e})=>{let t=[],r=[],n=["A","B","C","D"],o=e.map((i,a)=>({...i,baseline:"bottom",text:`(${n[a]})`}));return e.length>2&&(t=[e[0],e[2]],e.length>3&&(r=[e[1],e[3]])),[{type:"line",attrs:{coordinates:e}},{type:"line",attrs:[{coordinates:t},{coordinates:r}],styles:{style:"dashed"}},{type:"text",ignoreEvent:true,attrs:o}]}},Me=Ht;var Vt={name:"xabcd",totalStep:6,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,styles:{polygon:{color:C}},createPointFigures:({coordinates:e,overlay:t})=>{let r=[],n=[],o=["X","A","B","C","D"],i=e.map((a,s)=>({...a,baseline:"bottom",text:`(${o[s]})`}));return e.length>2&&(r.push({coordinates:[e[0],e[2]]}),n.push({coordinates:[e[0],e[1],e[2]]}),e.length>3&&(r.push({coordinates:[e[1],e[3]]}),e.length>4&&(r.push({coordinates:[e[2],e[4]]}),n.push({coordinates:[e[2],e[3],e[4]]})))),[{type:"line",attrs:{coordinates:e}},{type:"line",attrs:r,styles:{style:"dashed"}},{type:"polygon",ignoreEvent:true,attrs:n},{type:"text",ignoreEvent:true,attrs:i}]}},Pe=Vt;var Bt={name:"measure",totalStep:3,needDefaultPointFigure:true,needDefaultXAxisFigure:true,needDefaultYAxisFigure:true,createPointFigures:({coordinates:e})=>{if(e.length<2)return [];let t=e[0],r=e[1],n=e.length>2?e[2]:void 0,o=Math.abs(r.x-t.x),i=Math.abs(r.y-t.y),a=Math.sqrt(o*o+i*i),s=r.x>t.x?r.x+6:r.x-80,u=[{type:"line",attrs:{coordinates:[t,r]}},{type:"text",ignoreEvent:true,attrs:{x:s,y:r.y+4,text:`${a.toFixed(0)}px`,align:"left",baseline:"top"}}];return n&&u.push({type:"line",attrs:{coordinates:[t,n]}}),u}},we=Bt;var Se=[ae,se,le,me,ue,ce,pe,he,fe,ye,ge,de,be,_e,ve,De,Ce,Me,Pe,we];var V=[{id:"default",name:"Default",styles:{line:{color:"#1677FF",size:1,style:"solid"},polygon:{color:"rgba(22,119,255,0.15)"},text:{color:"#1677FF",size:12,family:"Helvetica Neue",weight:"normal"},point:{color:"#1677FF",radius:4,borderColor:"#ffffff",borderSize:2}}},{id:"bullish",name:"Bullish (Green)",styles:{line:{color:"#22ab94",size:1,style:"solid"},polygon:{color:"rgba(34,171,148,0.15)"},text:{color:"#22ab94",size:12,family:"Helvetica Neue",weight:"normal"},point:{color:"#22ab94",radius:4,borderColor:"#ffffff",borderSize:2}}},{id:"bearish",name:"Bearish (Red)",styles:{line:{color:"#f7525f",size:1,style:"solid"},polygon:{color:"rgba(247,82,95,0.15)"},text:{color:"#f7525f",size:12,family:"Helvetica Neue",weight:"normal"},point:{color:"#f7525f",radius:4,borderColor:"#ffffff",borderSize:2}}},{id:"neutral",name:"Neutral (Gray)",styles:{line:{color:"#9598a1",size:1,style:"solid"},polygon:{color:"rgba(149,152,161,0.15)"},text:{color:"#9598a1",size:12,family:"Helvetica Neue",weight:"normal"},point:{color:"#9598a1",radius:4,borderColor:"#ffffff",borderSize:2}}},{id:"highlight",name:"Highlight (Yellow)",styles:{line:{color:"#f6a825",size:2,style:"solid"},polygon:{color:"rgba(246,168,37,0.18)"},text:{color:"#f6a825",size:13,family:"Helvetica Neue",weight:"bold"},point:{color:"#f6a825",radius:5,borderColor:"#ffffff",borderSize:2}}},{id:"dashed_blue",name:"Dashed Blue",styles:{line:{color:"#1677FF",size:1,style:"dashed"},polygon:{color:"rgba(22,119,255,0.10)"},text:{color:"#1677FF",size:12,family:"Helvetica Neue",weight:"normal"},point:{color:"#1677FF",radius:4,borderColor:"#ffffff",borderSize:2}}},{id:"thick_orange",name:"Thick Orange",styles:{line:{color:"#f77c00",size:3,style:"solid"},polygon:{color:"rgba(247,124,0,0.15)"},text:{color:"#f77c00",size:13,family:"Helvetica Neue",weight:"bold"},point:{color:"#f77c00",radius:6,borderColor:"#ffffff",borderSize:2}}}],Te="astroneum-drawing-templates",K=class e{static _instance=null;_custom=[];constructor(){this._loadCustom();}static getInstance(){return e._instance||(e._instance=new e),e._instance}_loadCustom(){try{let t=localStorage.getItem(Te);if(!t){this._custom=[];return}let r=JSON.parse(t);if(!Array.isArray(r)){this._custom=[];return}this._custom=r.filter(n=>{if(n===null||typeof n!="object")return !1;let o=n;return typeof o.id=="string"&&typeof o.name=="string"&&typeof o.styles=="object"&&o.styles!==null});}catch{this._custom=[];}}_saveCustom(){try{localStorage.setItem(Te,JSON.stringify(this._custom));}catch{}}getAll(){return [...V,...this._custom]}getBuiltIn(){return [...V]}getCustom(){return [...this._custom]}getPreset(t){return this.getAll().find(r=>r.id===t)}saveCustomPreset(t){if(V.some(n=>n.id===t.id))throw new Error(`Cannot overwrite built-in preset "${t.id}"`);let r=this._custom.findIndex(n=>n.id===t.id);r>=0?this._custom[r]=t:this._custom.push(t),this._saveCustom();}deleteCustomPreset(t){if(V.some(n=>n.id===t))return false;let r=this._custom.length;return this._custom=this._custom.filter(n=>n.id!==t),this._custom.length<r?(this._saveCustom(),true):false}toOverlayStyles(t){return this.getPreset(t)?.styles}preview(t,r,n){let o=this.getPreset(t);if(!o)return null;let s=n.getOverlays().find(u=>u.id===r)?.styles;return n.overrideOverlay({id:r,styles:o.styles}),()=>{s!==void 0&&n.overrideOverlay({id:r,styles:s});}}static applyColor(t,r,n){t.overrideOverlay({id:r,styles:{line:{color:n},text:{color:n},point:{color:n}}});}},Nt=K;function Yt(e,t,r={}){let{precision:n=2,compact:o=false,currency:i}=r;return isFinite(e)?i?new Intl.NumberFormat(t,{style:"currency",currency:i,minimumFractionDigits:n,maximumFractionDigits:n}).format(e):o?new Intl.NumberFormat(t,{notation:"compact",maximumFractionDigits:1}).format(e):new Intl.NumberFormat(t,{minimumFractionDigits:n,maximumFractionDigits:n}).format(e):String(e)}function Wt(e,t){return isFinite(e)?new Intl.NumberFormat(t,{notation:"compact",maximumFractionDigits:2}).format(e):String(e)}function $t(e,t,r=2){return isFinite(e)?new Intl.NumberFormat(t,{style:"percent",minimumFractionDigits:r,maximumFractionDigits:r}).format(e):String(e)}function Xt(e,t,r="medium"){let n=e>1e10?e:e*1e3;return new Intl.DateTimeFormat(t,{dateStyle:r}).format(new Date(n))}function Kt(e,t,r="short"){let n=e>1e10?e:e*1e3;return new Intl.DateTimeFormat(t,{timeStyle:r}).format(new Date(n))}function Ut(e,t,r="medium",n="short"){let o=e>1e10?e:e*1e3;return new Intl.DateTimeFormat(t,{dateStyle:r,timeStyle:n}).format(new Date(o))}function jt(e,t){let r=Math.abs(e),n=new Intl.RelativeTimeFormat(t,{numeric:"auto",style:"long"});return r<6e4?n.format(Math.round(e/1e3),"second"):r<36e5?n.format(Math.round(e/6e4),"minute"):r<864e5?n.format(Math.round(e/36e5),"hour"):r<2592e6?n.format(Math.round(e/864e5),"day"):n.format(Math.round(e/2592e6),"month")}var Ae={"en-US":{second:"s",minute:"m",hour:"h",day:"D",week:"W",month:"M",year:"Y"},"zh-CN":{second:"\u79D2",minute:"\u5206",hour:"\u65F6",day:"\u65E5",week:"\u5468",month:"\u6708",year:"\u5E74"},"ja-JP":{second:"\u79D2",minute:"\u5206",hour:"\u6642",day:"\u65E5",week:"\u9031",month:"\u6708",year:"\u5E74"},"ko-KR":{second:"\uCD08",minute:"\uBD84",hour:"\uC2DC",day:"\uC77C",week:"\uC8FC",month:"\uC6D4",year:"\uB144"},"de-DE":{second:"S",minute:"M",hour:"Std",day:"T",week:"W",month:"Mo",year:"J"},"fr-FR":{second:"s",minute:"m",hour:"h",day:"J",week:"S",month:"M",year:"A"},"es-ES":{second:"s",minute:"m",hour:"h",day:"D",week:"S",month:"M",year:"A"},"ar-SA":{second:"\u062B",minute:"\u062F",hour:"\u0633",day:"\u064A",week:"\u0623",month:"\u0634",year:"\u0633"}};function Gt(e,t){let n=(Ae[t]??Ae["en-US"])[e.timespan]??e.timespan;return `${e.multiplier}${n}`}function Jt(e){if(!isFinite(e)||e===0)return 2;let t=Math.abs(e);return t>=1e3?0:t>=1?2:t>=.01?4:t>=1e-4?6:8}var U=class{_listeners=new Map;on(t,r){let n=this._listeners.get(t);return n||(n=new Set,this._listeners.set(t,n)),n.add(r),()=>{this.off(t,r);}}off(t,r){this._listeners.get(t)?.delete(r);}emit(t,r){this._listeners.get(t)?.forEach(n=>{n(r);});}clear(t){t!==void 0?this._listeners.get(t)?.clear():this._listeners.clear();}};var j=class{_buf;_capacity;_head=0;_size=0;constructor(t){if(t<1)throw new RangeError("[RingBuffer] capacity must be \u2265 1");this._capacity=t,this._buf=new Array(t).fill(void 0);}get length(){return Math.min(this._size,this._capacity)}get capacity(){return this._capacity}get isFull(){return this._size>=this._capacity}push(t){let r=(this._head+Math.min(this._size,this._capacity-1)+(this.isFull?1:0))%this._capacity;this.isFull?(this._buf[r]=t,this._head=(this._head+1)%this._capacity):(this._buf[(this._head+this._size)%this._capacity]=t,this._size++);}updateLast(t){if(this._size===0){this.push(t);return}let r=(this._head+Math.min(this._size,this._capacity)-1)%this._capacity;this._buf[r]=t;}at(t){let r=this.length;if(r===0)return;let n=t<0?r+t:t;if(!(n<0||n>=r))return this._buf[(this._head+n)%this._capacity]}last(){return this.at(-1)}first(){return this.at(0)}[Symbol.iterator](){let t=this.length,r=0;return {next:()=>r>=t?{value:void 0,done:true}:{value:this.at(r++),done:false}}}toArray(){let t=new Array(this.length);for(let r=0;r<this.length;r++)t[r]=this.at(r);return t}clear(){this._buf.fill(void 0),this._head=0,this._size=0;}};var G=class{_chart;_stack=[];_redoStack=[];_maxDepth;_lastSnapshot=null;constructor(t,r=50){this._chart=t,this._maxDepth=r;}record(){let t=this._chart.serializeState(),r=JSON.stringify(t.overlays);if(r!==this._lastSnapshot)for(this._lastSnapshot=r,this._stack.push(t),this._redoStack=[];this._stack.length>this._maxDepth;)this._stack.shift();}undo(){if(this._stack.length<=1)return false;let t=this._chart.serializeState();this._redoStack.push(t),this._stack.pop();let r=this._stack[this._stack.length-1];return this._chart.loadState(r),this._lastSnapshot=JSON.stringify(r.overlays),true}redo(){if(this._redoStack.length===0)return false;let t=this._chart.serializeState();this._stack.push(t);let r=this._redoStack.pop();return this._chart.loadState(r),this._lastSnapshot=JSON.stringify(r.overlays),true}clear(){this._stack=[],this._redoStack=[],this._lastSnapshot=null;}get canUndo(){return this._stack.length>1}get canRedo(){return this._redoStack.length>0}};var Fe="__session_guides__";function qt(e){let t=-1/0;for(let r=0;r<e.length;r++)e[r]>t&&(t=e[r]);return t}function Zt(e){let t=1/0;for(let r=0;r<e.length;r++)e[r]<t&&(t=e[r]);return t}var J=class{_chart;_config;_enabled=false;_animFrame=null;constructor(t,r={}){this._chart=t,this._config={timezone:r.timezone??"America/New_York",openHour:r.openHour??9,openMinute:r.openMinute??30,closeHour:r.closeHour??16,closeMinute:r.closeMinute??0,showExtendedHours:r.showExtendedHours??true,showSessionLevels:r.showSessionLevels??true};}get enabled(){return this._enabled}enable(){this._enabled||(this._enabled=true,this._refresh());}disable(){this._enabled&&(this._enabled=false,this._removeGuides(),this._animFrame!==null&&(cancelAnimationFrame(this._animFrame),this._animFrame=null));}toggle(){this._enabled?this.disable():this.enable();}refresh(){this._enabled&&(this._animFrame!==null&&cancelAnimationFrame(this._animFrame),this._animFrame=requestAnimationFrame(()=>{this._animFrame=null,this._refresh();}));}_refresh(){this._removeGuides();let t=this._chart.getDataList?.();if(!t||t.length===0)return;let r=864e5,n=t[t.length-1],o=n.timestamp-r,i=t.filter(a=>a.timestamp>=o&&a.timestamp<=n.timestamp);if(i.length!==0&&this._config.showSessionLevels){let a=i.map(l=>l.high),s=i.map(l=>l.low),u=[{price:i[0].open,label:"Open",color:"rgba(41,98,255,0.45)",style:"solid"},{price:n.close,label:"Close",color:"rgba(255,255,255,0.35)",style:"dashed"},{price:qt(a),label:"High",color:"rgba(34,171,148,0.45)",style:"solid"},{price:Zt(s),label:"Low",color:"rgba(247,82,95,0.45)",style:"solid"}];for(let l of u)try{this._chart.createOverlay({name:"priceLine",groupId:Fe,lock:!0,visible:!0,mode:"normal",points:[{value:l.price}],extendData:l.label,styles:{line:{color:l.color,size:1,style:l.style,dashedValue:[4,4]}}});}catch{}}}_removeGuides(){try{this._chart.removeOverlay({groupId:Fe});}catch{}}};function Qt(e,t=30){if(e.length===0)return [];let r=-1/0,n=1/0;for(let l of e){let c=l.high,m=l.low;c>r&&(r=c),m<n&&(n=m);}let o=r-n;if(o<=0)return [];let i=o/t,a=new Array(t).fill(0);for(let l of e){let c=l.volume??0,m=l.high-l.low;if(m<=0){let p=Math.floor((l.close-n)/i);p>=0&&p<t&&(a[p]+=c);}else {let p=c/m;for(let y=0;y<t;y++){let h=n+y*i,f=h+i,d=Math.max(l.low,h),g=Math.min(l.high,f);g>d&&(a[y]+=(g-d)*p);}}}let s=[],u=0;for(let l=0;l<t;l++)u+=a[l],s.push({price:n+l*i+i/2,volume:a[l],cumulative:u});return s}var er={name:"volume_profile",shortName:"VProfile",calcParams:[30],calc(e,t){let r=Math.max(5,Math.min(100,Math.round(t[0]??30)));return Qt(e,r)},render2D(e,t,r){if(t.length===0)return;let[n,o]=r.resolution,i=r.priceMin,s=r.priceMax-i;if(s<=0)return;let u=0;for(let f of t)u=Math.max(u,f.volume);if(u===0)return;let l=n*.25,c=n-l-8,m=t[0];for(let f of t)f.volume>m.volume&&(m=f);let p=t[t.length-1].cumulative,y=p*.7;for(let f of t){let d=(f.price-i)/s,g=Math.round(o*(1-d)),D=Math.max(1,f.volume/u*l),M=f.cumulative>=(p-y)/2&&f.cumulative<=p-(p-y)/2;e.fillStyle=f===m?"rgba(255, 235, 59, 0.7)":M?"rgba(76, 175, 80, 0.5)":"rgba(158, 158, 158, 0.4)",e.fillRect(c,g-1,D,Math.max(1,o/t.length-1));}let h=Math.round(o*(1-(m.price-i)/s));e.strokeStyle="rgba(255, 235, 59, 0.9)",e.lineWidth=1,e.setLineDash([4,2]),e.beginPath(),e.moveTo(0,h),e.lineTo(n,h),e.stroke(),e.setLineDash([]),e.fillStyle="rgba(255, 235, 59, 0.9)",e.font="10px sans-serif",e.textAlign="left",e.fillText(`POC ${m.price.toFixed(2)}`,4,h-3);}};var Oe="astroneum-chart-templates",q=class e{static _instance=null;_templates=[];constructor(){this._load();}static getInstance(){return e._instance||(e._instance=new e),e._instance}save(t,r){let n={...r,symbol:{ticker:""},period:{multiplier:1,timespan:"minute",text:"1m"}},o=this._templates.findIndex(a=>a.name===t),i={id:`${Date.now()}_${Math.random().toString(36).slice(2,7)}`,name:t.trim(),state:n,createdAt:new Date().toISOString()};return o>=0?this._templates[o]=i:this._templates.push(i),this._persist(),i}load(t,r){let n=this._templates.find(o=>o.name===t);return n?(r.loadState(n.state),true):false}delete(t){let r=this._templates.length;return this._templates=this._templates.filter(n=>n.name!==t),this._templates.length<r?(this._persist(),true):false}list(){return this._templates.map(t=>t.name)}get(t){return this._templates.find(r=>r.name===t)}getAll(){return [...this._templates]}_persist(){try{localStorage.setItem(Oe,JSON.stringify(this._templates));}catch{}}_load(){try{let t=localStorage.getItem(Oe);if(!t)return;let r=JSON.parse(t);if(!Array.isArray(r))return;this._templates=r.filter(n=>{if(n===null||typeof n!="object")return !1;let o=n;return typeof o.id=="string"&&typeof o.name=="string"&&typeof o.state=="object"&&o.state!==null&&typeof o.createdAt=="string"});}catch{}}};function Le(e,t){if(e.length===0)return [];let r=ke(t);if(r<=0)return e;let n=[],o=Math.floor(e[0].timestamp/r)*r,i=null;for(let a of e){let s=Math.floor(a.timestamp/r)*r;s!==o||i===null?(i!==null&&n.push(i),o=s,i={timestamp:o,open:a.open,high:a.high,low:a.low,close:a.close,volume:a.volume??0,turnover:a.turnover??0}):(i.high=Math.max(i.high,a.high),i.low=Math.min(i.low,a.low),i.close=a.close,i.volume=(i.volume??0)+(a.volume??0),i.turnover=(i.turnover??0)+(a.turnover??0));}return i!==null&&n.push(i),n}function tr(e,t,r){if(e.length===0||t.length===0||r.length===0)return new Array(r.length).fill(NaN);let n=new Array(r.length),o=0;for(let i=0;i<r.length;i++){for(;o+1<t.length&&t[o+1].timestamp<=r[i].timestamp;)o++;n[i]=e[Math.min(o,e.length-1)];}return n}function ke(e){return ({second:1e3,minute:6e4,hour:36e5,day:864e5,week:6048e5,month:2592e6,year:31536e6}[e.timespan]??6e4)*e.multiplier}function rr(e,t,r){let n=Le(e,t),o=r(n);return {result:o,getValue(i){if(i<0||i>=e.length)return null;let a=e[i].timestamp,s=ke(t),u=Math.floor(a/s)*s;for(let l=n.length-1;l>=0;l--)if(n[l].timestamp<=u)return o[l]??null;return null}}}var Ie="__position_lines__",Z=class{_chart;_active=false;constructor(t){this._chart=t;}show(t){this.hide();let r=t.position,n=r.side,o=r.entryPrice;if(this._createLine(o,"Entry","rgba(255, 255, 255, 0.6)","solid"),t.stopPrice!==void 0&&this._createLine(t.stopPrice,`Stop: ${t.stopPrice}`,"rgba(247, 82, 95, 0.7)","dashed"),t.targetPrice!==void 0&&this._createLine(t.targetPrice,`Target: ${t.targetPrice}`,"rgba(34, 171, 148, 0.7)","dashed"),!r.exitPrice&&t.stopPrice!==void 0&&t.targetPrice!==void 0){let i=Math.abs(t.targetPrice-o),a=Math.abs(o-t.stopPrice),s=a>0?`R:R ${(i/a).toFixed(1)}`:"";this._createLabel(o,`${n.toUpperCase()} ${r.quantity} @ ${o} | ${s}`,"rgba(255, 255, 255, 0.8)");}this._active=true;}hide(){try{this._chart.removeOverlay({groupId:Ie});}catch{}this._active=false;}update(t){this.show(t);}get active(){return this._active}_createLine(t,r,n,o){try{this._chart.createOverlay({name:"priceLine",groupId:Ie,lock:!0,visible:!0,mode:"normal",points:[{value:t}],extendData:r,styles:{line:{color:n,size:1.5,style:o,dashedValue:o==="dashed"?[4,4]:[]}}});}catch{}}_createLabel(t,r,n){this._createLine(t,r,n,"solid");}};function Q(e,t=5){let r=e.length,n=new Array(r).fill(NaN);if(r<t*2+1)return n;let o=false,i=-1;for(let a=t;a<r-t;a++){let s=e[a],u=s.high,l=s.low,c=true;for(let p=a-t;p<=a+t;p++)if(p!==a&&e[p].high>=u){c=false;break}let m=true;for(let p=a-t;p<=a+t;p++)if(p!==a&&e[p].low<=l){m=false;break}c&&(i===-1||!o)?(n[a]=u,o=true,i=a):m&&(i===-1||o)&&(n[a]=l,o=false,i=a);}return n}function nr(e,t=5,r=.005){let n=Q(e,t),o=[];for(let s of n)isNaN(s)||o.push(s);let i=[];for(let s of o){let u=false;for(let l of i)if(Math.abs(l.price-s)/l.price<=r){l.price=(l.price*l.count+s)/(l.count+1),l.count++,u=true;break}u||i.push({price:s,count:1,highs:0,lows:0});}let a=o.reduce((s,u)=>s+u,0)/o.length;return i.filter(s=>s.count>=2).map(s=>({price:s.price,count:s.count,type:s.price>a?"resistance":"support"})).sort((s,u)=>s.price-u.price)}var or={name:"zigzag",shortName:"ZigZag",calcParams:[5],calc(e,t){let r=Math.max(2,Math.min(20,Math.round(t[0]??5)));return Q(e,r)},render2D(e,t,r){if(t.length===0)return;let[n,o]=r.resolution,i=r.priceMin,s=r.priceMax-i,u=r.timeMin,c=r.timeMax-u;if(s<=0||c<=0)return;let m=[];for(let p=0;p<t.length;p++){if(isNaN(t[p]))continue;let y={timestamp:u+c*p/t.length},h=Math.round((y.timestamp-u)/c*n),f=Math.round(o*(1-(t[p]-i)/s));m.push({x:Math.max(0,Math.min(n,h)),y:Math.max(0,Math.min(o,f))});}if(!(m.length<2)){e.strokeStyle="rgba(255, 152, 0, 0.7)",e.lineWidth=1.5,e.beginPath(),e.moveTo(m[0].x,m[0].y);for(let p=1;p<m.length;p++)e.lineTo(m[p].x,m[p].y);e.stroke(),e.fillStyle="rgba(255, 152, 0, 0.9)";for(let p of m)e.beginPath(),e.arc(p.x,p.y,3,0,Math.PI*2),e.fill();}}};var ir="#26a69a",ar="#ef5350",sr="#2962ff";function x(e){return Math.abs(e.close-e.open)}function O(e){return e.high-Math.max(e.open,e.close)}function L(e){return Math.min(e.open,e.close)-e.low}function S(e){return e.high-e.low}function _(e){return e.close>e.open}function v(e){return e.close<e.open}function Re(e,t,r){let n=Math.max(0,t-r+1),o=0,i=0;for(let a=n;a<=t;a++)o+=x(e[a]),i++;return i>0?o/i:0}function lr(e,t){if(t<0||t>=e.length)return null;let r=e[t],n=S(r);return n===0?null:x(r)/n<.05?{index:t,pattern:"Doji",type:"neutral",timestamp:r.timestamp,high:r.high,low:r.low}:null}function ur(e,t){if(t<0||t>=e.length)return null;let r=e[t],n=S(r);if(n===0)return null;let o=L(r),i=O(r),a=x(r);return o>2*a&&i<a*.3&&a/n<.4?{index:t,pattern:"Hammer",type:"bullish",timestamp:r.timestamp,high:r.high,low:r.low}:null}function mr(e,t){if(t<0||t>=e.length)return null;let r=e[t],n=S(r);if(n===0)return null;let o=O(r),i=L(r),a=x(r);return o>2*a&&i<a*.3&&a/n<.4?{index:t,pattern:"Inverted Hammer",type:"bullish",timestamp:r.timestamp,high:r.high,low:r.low}:null}function cr(e,t){if(t<0||t>=e.length)return null;let r=e[t],n=S(r);if(n===0)return null;let o=O(r),i=L(r),a=x(r);return v(r)&&o>2*a&&i<a*.3&&a/n<.4?{index:t,pattern:"Shooting Star",type:"bearish",timestamp:r.timestamp,high:r.high,low:r.low}:null}function pr(e,t){if(t<0||t>=e.length)return null;let r=e[t],n=S(r);if(n===0)return null;let o=L(r),i=O(r),a=x(r);return _(r)&&o>2*a&&i<a*.3&&a/n<.4?{index:t,pattern:"Hanging Man",type:"bearish",timestamp:r.timestamp,high:r.high,low:r.low}:null}function hr(e,t){if(t<0||t>=e.length)return null;let r=e[t],n=S(r);if(n===0)return null;let o=x(r),i=O(r),a=L(r);return o/n<.3&&i>o&&a>o?{index:t,pattern:"Spinning Top",type:"neutral",timestamp:r.timestamp,high:r.high,low:r.low}:null}function fr(e,t){if(t<1||t>=e.length)return null;let r=e[t-1],n=e[t];return v(r)&&_(n)&&n.close>=r.open&&n.open<=r.close&&x(n)>x(r)?{index:t,pattern:"Bullish Engulfing",type:"bullish",timestamp:n.timestamp,high:n.high,low:n.low}:null}function yr(e,t){if(t<1||t>=e.length)return null;let r=e[t-1],n=e[t];return _(r)&&v(n)&&n.open>=r.close&&n.close<=r.open&&x(n)>x(r)?{index:t,pattern:"Bearish Engulfing",type:"bearish",timestamp:n.timestamp,high:n.high,low:n.low}:null}function gr(e,t){if(t<1||t>=e.length)return null;let r=e[t-1],n=e[t],o=(r.open+r.close)/2;return v(r)&&_(n)&&n.open<r.low&&n.close>o&&n.close<r.open?{index:t,pattern:"Piercing Line",type:"bullish",timestamp:n.timestamp,high:n.high,low:n.low}:null}function dr(e,t){if(t<1||t>=e.length)return null;let r=e[t-1],n=e[t],o=(r.open+r.close)/2;return _(r)&&v(n)&&n.open>r.high&&n.close<o&&n.close>r.open?{index:t,pattern:"Dark Cloud Cover",type:"bearish",timestamp:n.timestamp,high:n.high,low:n.low}:null}function xr(e,t){if(t<1||t>=e.length)return null;let r=e[t-1],n=e[t];return v(r)&&_(n)&&n.open>r.close&&n.close<r.open&&x(n)<x(r)*.6?{index:t,pattern:"Bullish Harami",type:"bullish",timestamp:n.timestamp,high:n.high,low:n.low}:null}function br(e,t){if(t<1||t>=e.length)return null;let r=e[t-1],n=e[t];return _(r)&&v(n)&&n.open<r.close&&n.close>r.open&&x(n)<x(r)*.6?{index:t,pattern:"Bearish Harami",type:"bearish",timestamp:n.timestamp,high:n.high,low:n.low}:null}function _r(e,t){if(t<2||t>=e.length)return null;let r=e[t-2],n=e[t-1],o=e[t],i=Re(e,t,10);return v(r)&&x(r)>i*.7&&x(n)<i*.3&&_(o)&&o.close>(r.open+r.close)/2?{index:t,pattern:"Morning Star",type:"bullish",timestamp:o.timestamp,high:o.high,low:o.low}:null}function vr(e,t){if(t<2||t>=e.length)return null;let r=e[t-2],n=e[t-1],o=e[t],i=Re(e,t,10);return _(r)&&x(r)>i*.7&&x(n)<i*.3&&v(o)&&o.close<(r.open+r.close)/2?{index:t,pattern:"Evening Star",type:"bearish",timestamp:o.timestamp,high:o.high,low:o.low}:null}function Dr(e,t){if(t<2||t>=e.length)return null;let r=e[t-2],n=e[t-1],o=e[t];return _(r)&&_(n)&&_(o)&&n.close>r.close&&o.close>n.close&&n.open>r.open&&o.open>n.open?{index:t,pattern:"Three White Soldiers",type:"bullish",timestamp:o.timestamp,high:o.high,low:o.low}:null}function Cr(e,t){if(t<2||t>=e.length)return null;let r=e[t-2],n=e[t-1],o=e[t];return v(r)&&v(n)&&v(o)&&n.close<r.close&&o.close<n.close&&n.open<r.open&&o.open<n.open?{index:t,pattern:"Three Black Crows",type:"bearish",timestamp:o.timestamp,high:o.high,low:o.low}:null}function Mr(e,t){if(t<2||t>=e.length)return null;let r=e[t-2],n=e[t-1],o=e[t];return v(r)&&_(n)&&n.open>r.close&&n.close<r.open&&_(o)&&o.close>n.close?{index:t,pattern:"Three Inside Up",type:"bullish",timestamp:o.timestamp,high:o.high,low:o.low}:null}function Pr(e,t){if(t<2||t>=e.length)return null;let r=e[t-2],n=e[t-1],o=e[t];return _(r)&&v(n)&&n.open<r.close&&n.close>r.open&&v(o)&&o.close<n.close?{index:t,pattern:"Three Inside Down",type:"bearish",timestamp:o.timestamp,high:o.high,low:o.low}:null}var B=[{id:"doji",name:"Doji",category:"single",type:"neutral",fn:lr},{id:"hammer",name:"Hammer",category:"single",type:"bullish",fn:ur},{id:"inverted_hammer",name:"Inverted Hammer",category:"single",type:"bullish",fn:mr},{id:"shooting_star",name:"Shooting Star",category:"single",type:"bearish",fn:cr},{id:"hanging_man",name:"Hanging Man",category:"single",type:"bearish",fn:pr},{id:"spinning_top",name:"Spinning Top",category:"single",type:"neutral",fn:hr},{id:"bullish_engulfing",name:"Bullish Engulfing",category:"two",type:"bullish",fn:fr},{id:"bearish_engulfing",name:"Bearish Engulfing",category:"two",type:"bearish",fn:yr},{id:"piercing_line",name:"Piercing Line",category:"two",type:"bullish",fn:gr},{id:"dark_cloud_cover",name:"Dark Cloud Cover",category:"two",type:"bearish",fn:dr},{id:"bullish_harami",name:"Bullish Harami",category:"two",type:"bullish",fn:xr},{id:"bearish_harami",name:"Bearish Harami",category:"two",type:"bearish",fn:br},{id:"morning_star",name:"Morning Star",category:"three",type:"bullish",fn:_r},{id:"evening_star",name:"Evening Star",category:"three",type:"bearish",fn:vr},{id:"three_white_soldiers",name:"Three White Soldiers",category:"three",type:"bullish",fn:Dr},{id:"three_black_crows",name:"Three Black Crows",category:"three",type:"bearish",fn:Cr},{id:"three_inside_up",name:"Three Inside Up",category:"three",type:"bullish",fn:Mr},{id:"three_inside_down",name:"Three Inside Down",category:"three",type:"bearish",fn:Pr}];function wr(e,t){let r=[];for(let n=0;n<e.length;n++)for(let o=0;o<B.length;o++){if(o<t.length&&t[o]===0)continue;let i=B[o].fn(e,n);if(i){r.push(i);break}}return r}var Sr={name:"patterns",shortName:"Patterns",calcParams:[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],calc(e,t){let r=t.length>0?t:B.map(()=>1);return wr(e,r)},render2D(e,t,r){if(t.length===0)return;let[n,o]=r.resolution,i=r.timeMin,a=r.timeMax,s=a-i;if(s<=0)return;let u=r.priceMin,c=r.priceMax-u;if(!(c<=0))for(let m of t){if(m.timestamp<i||m.timestamp>a)continue;let p=(m.timestamp-i)/s,y=Math.round(p*n),h=m.type==="bullish"?ir:m.type==="bearish"?ar:sr,f=Math.round(o*(1-(m.high-u)/c)),d=Math.round(o*(1-(m.low-u)/c)),g=m.type==="bullish"?d+12:f-12,D=m.type==="bullish"?g+10:g-6;e.fillStyle=h,e.beginPath(),e.arc(y,g,3,0,Math.PI*2),e.fill(),e.font="9px Trebuchet MS, sans-serif",e.fillStyle=h,e.textAlign="center",e.fillText(m.pattern,y,D);}}};var Or=[{multiplier:4,timespan:"hour",text:"4H"},{multiplier:1,timespan:"hour",text:"1H"},{multiplier:15,timespan:"minute",text:"15m"}],ee=class{_container;_periods;_charts=[];_options;_storageKey;_wrapperEl=null;constructor(t){if(this._options=t,this._periods=t.periods??Or,this._storageKey=t.storageKey!==void 0?t.storageKey:"astroneum-multi-period",typeof t.container=="string"){let r=document.getElementById(t.container);if(!r)throw new Error(`MultiPeriodLayout: container #${t.container} not found`);this._container=r;}else this._container=t.container;this._render();}_render(){this._destroy();let t=document.createElement("div");t.className="astroneum-multi-period",Object.assign(t.style,{display:"flex",flexDirection:"column",width:"100%",height:"100%",gap:"2px",boxSizing:"border-box"}),this._wrapperEl=t;for(let r=0;r<this._periods.length;r++){let n=this._periods[r],o=document.createElement("div");o.className="astroneum-multi-period-cell",Object.assign(o.style,{position:"relative",overflow:"hidden",flex:"1",minHeight:"100px"}),r===this._periods.length-1&&(o.style.outline="2px solid #1677ff"),t.appendChild(o);let i={...this._options,symbol:this._options.symbol,period:n,drawingBarVisible:false},a=null,s=createRoot(o);if(flushSync(()=>{s.render(Tr.createElement(l,{...i,ref:u=>{u&&(a=u);}}));}),!a)throw new Error("MultiPeriodLayout: chart initialization failed");this._charts.push({container:o,instance:a,root:s});}this._charts.length>1&&this._charts[this._charts.length-1].instance.onCrosshairMove(n=>{for(let o=0;o<this._charts.length-1;o++)this._charts[o].instance.setCrosshair(n);}),this._container.innerHTML="",this._container.appendChild(t);}_destroy(){for(let{root:t}of this._charts)t.unmount();this._charts=[],this._wrapperEl&&(this._container.removeChild(this._wrapperEl),this._wrapperEl=null);}setTheme(t){for(let{instance:r}of this._charts)r.setTheme(t);}setLocale(t){for(let{instance:r}of this._charts)r.setLocale(t);}getCharts(){return this._charts.map(t=>t.instance)}destroy(){this._destroy();}};function Lr(e,t,r,n="#ff6d00"){let o=[],i=[],a=-1,s=null;return {name:`compare_${e.ticker.replace(/[^a-zA-Z0-9]/g,"_")}`,shortName:e.ticker.split(":").pop()??e.ticker,calcParams:[],calc(l,c){if(l.length!==a&&l.length>0){a=l.length;let m=l[0].timestamp,p=l[l.length-1].timestamp;s===null&&(s=t.getHistoryData(e,r,m,p).then(y=>{if(o=y.sort((h,f)=>h.timestamp-f.timestamp),o.length>0){let h=o[0].close;h!==0?i=o.map(f=>(f.close-h)/h*100):i=o.map(()=>0);}s=null;}).catch(()=>{s=null;}));}return i.length===l.length?i:new Array(l.length).fill(NaN)},render2D(l,c,m){if(c.length===0||m.resolution[0]===0)return;let p=m.resolution[0],y=m.resolution[1],h=1/0,f=-1/0;for(let b of c)isFinite(b)&&(b<h&&(h=b),b>f&&(f=b));if(!isFinite(h))return;let g=(f-h||1)*.05,D=h-g,M=f+g,T=p/(c.length-1),N=255,Y=109,W=0,te=.9;if(n.startsWith("#")){let b=n.replace("#","");N=parseInt(b.slice(0,2),16),Y=parseInt(b.slice(2,4),16),W=parseInt(b.slice(4,6),16);}l.strokeStyle=`rgba(${N},${Y},${W},${te})`,l.lineWidth=1.5,l.beginPath();let $=false;for(let b=0;b<c.length;b++){let k=c[b];if(!isFinite(k)){$=false;continue}let re=b*T,ne=y-(k-D)/(M-D)*y;$?l.lineTo(re,ne):(l.moveTo(re,ne),$=true);}l.stroke();let He=c.length-1,X=c[He];if(isFinite(X)){let b=p-4,k=y-(X-D)/(M-D)*y;l.fillStyle=`rgba(${N},${Y},${W},${te})`,l.font="10px sans-serif",l.textAlign="right",l.textBaseline="middle",l.fillText(`${e.ticker} ${X.toFixed(2)}%`,b,Math.max(10,Math.min(y-4,k)));}}}}function kr(e,t=20){if(e.length===0)return [];let r=-1/0,n=1/0;for(let s of e)s.high>r&&(r=s.high),s.low<n&&(n=s.low);let o=r-n;if(o<=0)return [];let i=o/t,a=[];for(let s=0;s<t;s++){let u=r-s*i-i/2,l=0,c=0;for(let m of e){let p=m.volume??0,y=m.high-m.low;if(y<=0)continue;let h=p/y,f=Math.max(m.low,u-i/2),d=Math.min(m.high,u+i/2);if(d>f){let g=(d-f)*h;m.close<=u?l+=g:c+=g;}}a.push({price:u,bidVolume:l,askVolume:c,totalVolume:l+c});}return a.sort((s,u)=>u.price-s.price)}var Ir={name:"dom",shortName:"DOM",calcParams:[20],calc(e,t){let r=Math.max(5,Math.min(50,Math.round(t[0]??20)));return kr(e,r)},render2D(e,t,r){if(t.length===0)return;let[n,o]=r.resolution,i=r.priceMin,s=r.priceMax-i;if(s<=0)return;let u=n*.3,l=n-u-8,c=Math.max(2,Math.floor(o/t.length)),m=0;for(let d of t){let g=d.bidVolume+d.askVolume;g>m&&(m=g);}if(m===0)return;for(let d of t){let g=(d.price-i)/s;if(g<0||g>1)continue;let D=Math.round(o*(1-g)),M=d.bidVolume/m*u,T=d.askVolume/m*u;M>0&&(e.fillStyle="rgba(76, 175, 80, 0.5)",e.fillRect(l,D,M,c)),T>0&&(e.fillStyle="rgba(244, 67, 54, 0.5)",e.fillRect(l+M,D,T,c));}e.fillStyle="rgba(255, 255, 255, 0.5)",e.font="9px monospace",e.textAlign="right";let p=t[0],y=Math.round(o*(1-(p.price-i)/s));e.fillText(p.price.toFixed(2),n-4,Math.max(12,y+4));let h=t[t.length-1],f=Math.round(o*(1-(h.price-i)/s));e.fillText(h.price.toFixed(2),n-4,Math.min(o-4,f+4));}};function Rr(e,t){if(e.length===0||t<=0)return [];let r=[],n=Math.round(e[0].close/t)*t,o=e[0].timestamp;r.push({timestamp:o,open:n,high:n+t,low:n-t,close:n,volume:e[0].volume});for(let i=1;i<e.length;i++){let a=e[i],s=Math.floor(Math.abs(a.close-n)/t);if(s>=1){let u=a.close>n?1:-1;for(let l=0;l<s;l++){o+=6e4,n+=u*t;let c=n,m=c-u*t;r.push({timestamp:o,open:m,high:Math.max(m,c),low:Math.min(m,c),close:c,volume:a.volume?a.volume/s:0});}}}return r}function Er(e,t=3){if(e.length===0)return [];let r=[],n=e[0].close,o=e[0].close,i=1,a=e[0].timestamp,s=t/100;for(let u=1;u<e.length;u++){let l=e[u];i===1?l.close>n?n=l.close:l.close<n*(1-s)&&(a+=6e4,r.push({timestamp:a,open:n,high:n,low:l.close,close:l.close,volume:l.volume}),i=-1,o=l.close,n=l.close):l.close<o?o=l.close:l.close>o*(1+s)&&(a+=6e4,r.push({timestamp:a,open:o,high:l.close,low:o,close:l.close,volume:l.volume}),i=1,n=l.close,o=l.close);}return r}function zr(e,t){if(e.length===0||t<=0)return [];let r=[],n=e[0].timestamp;for(let o=0;o<e.length;o+=t){let i=e.slice(o,o+t);if(i.length===0)break;let a=i[0].open,s=-1/0,u=1/0,l=0,c=0;for(let m of i)m.high>s&&(s=m.high),m.low<u&&(u=m.low),l+=m.volume??0,c+=m.turnover??0;n+=6e4,r.push({timestamp:n,open:a,high:s,low:u,close:i[i.length-1].close,volume:l,turnover:c});}return r}function Hr(e,t){if(e.length===0||t<=0)return [];let r=[],n=e[0].timestamp,o=e[0].high,i=e[0].low,a=e[0].open,s=e[0].volume??0,u=e[0].turnover??0;for(let l=1;l<e.length;l++){let c=e[l];c.high>o&&(o=c.high),c.low<i&&(i=c.low),o-i>=t?(n+=6e4,r.push({timestamp:n,open:a,high:o,low:i,close:c.close,volume:s,turnover:u}),a=c.close,o=c.high,i=c.low,s=c.volume??0,u=c.turnover??0):(s+=c.volume??0,u+=c.turnover??0);}return r}function Ee(e,t={}){if(e.length===0)return [];let r=Math.max(1,t.reversal??3),n=t.boxSize??(()=>{let s=0;for(let l of e)s+=l.close;let u=s/e.length;return Math.max(.01,u*.01)})(),o=[],i=null,a=Math.round(e[0].close/n)*n;for(let s of e){let u=t.method==="hilo"?[s.high,s.low]:[s.high,s.low,s.close];for(let l of u){let c=Math.round(l/n)*n;if(i===null){c>a?i={type:"X",top:c,bottom:a,boxes:1,columnIndex:o.length}:c<a&&(i={type:"O",top:a,bottom:c,boxes:1,columnIndex:o.length}),a=c;continue}if(i.type==="X"){if(c>i.top){let m=Math.round((c-i.top)/n);i.top=c,i.boxes+=m;}else if(c<=i.top-r*n){o.push(i);let m=c,p=Math.round((i.top-m)/n);i={type:"O",top:i.top-n,bottom:m,boxes:Math.max(1,p),columnIndex:o.length};}}else if(c<i.bottom){let m=Math.round((i.bottom-c)/n);i.bottom=c,i.boxes+=m;}else if(c>=i.bottom+r*n){o.push(i);let m=c,p=Math.round((m-i.bottom)/n);i={type:"X",top:m,bottom:i.bottom+n,boxes:Math.max(1,p),columnIndex:o.length};}a=c;}}return i!==null&&o.push(i),o}function ze(e){let t=[],r=Date.now(),n=6e4;for(let o of e){let i=(o.top-o.bottom)/Math.max(1,o.boxes);for(let a=0;a<o.boxes;a++){let s=o.bottom+a*i,u=s+i,l=r+o.columnIndex*n*2+a*n;o.type==="X"?t.push({timestamp:l,open:s,high:u,low:s,close:u,volume:1}):t.push({timestamp:l,open:u,high:u,low:s,close:s,volume:1});}}return t}function Vr(e,t,r){return ze(Ee(e,{boxSize:t,reversal:r}))}var Br={name:"point_and_figure",shortName:"P&F",calcParams:[10,3],calc(e,t){let r=t[0]??10,n=Math.max(1,Math.round(t[1]??3));return [r,n]},render2D(e,t,r){}};Se.forEach(e=>{c(e);});export{q as ChartTemplateManager,Nt as DrawingTemplates,U as EventBus,ee as MultiPeriodLayout,B as PATTERN_CATALOGUE,Z as PositionVisualizer,j as RingBuffer,J as SessionVisualizer,G as UndoManager,Ee as computePFColumns,Lr as createCompareIndicator,Jt as detectPricePrecision,nr as detectSupportResistance,Ir as domPlugin,Xt as formatDate,Ut as formatDateTime,jt as formatDuration,$t as formatPercent,Gt as formatPeriod,Yt as formatPrice,Kt as formatTime,Wt as formatVolume,tr as forwardFill,Er as generateKagi,Vr as generatePointAndFigure,Hr as generateRangeBars,Rr as generateRenko,zr as generateTickBars,rr as mtfIndicator,Sr as patternRecognitionPlugin,ze as pfColumnsToBars,Br as pointAndFigurePlugin,Le as resampleBars,er as volumeProfilePlugin,Q as zigzag,or as zigzagPlugin};
2
+ export{c as BinanceAdapter,d as BitgetAdapter,b as DATAFEED_ERROR_EVENT,e as OkxAdapter,a as STANDARD_CRYPTO_SYMBOLS,f as StandardCryptoDatafeed,g as createStandardCryptoDatafeed}from'./chunk-WSIR5T2M.js';export{a as DefaultDatafeed}from'./chunk-DFJMDDL5.js';export{a as TickAnimator,b as WebSocketDatafeed}from'./chunk-SDXH2WAI.js';import {a as a$1}from'./chunk-EHZN52CY.js';import {f}from'./chunk-HKLWNPMP.js';export{f as AstroneumChart,g as MultiChartLayout,b as PerformanceMode,e as formatScaleTick,a as heikinAshi,c as transformCandles,d as untransformPrice}from'./chunk-HKLWNPMP.js';export{t as AlertModal,n as BUILTIN_LOCALES,p as LayerProvider,s as SymbolSearchModal,m as loadLocale,l as loadLocales,r as useLayer,q as useLayerProvider}from'./chunk-SCTHEM27.js';export{a as asPrice,c as asTimestamp,b as asVolume,g as deepClone,f as deepSet,d as rafCoalesce,e as rafMergeTick}from'./chunk-YFPXTHZX.js';export{a as AlertManager}from'./chunk-67XM5LOK.js';export{a as createIndicatorTemplateFromPlugin,b as registerIndicatorPlugin,c as registerIndicatorPlugins}from'./chunk-ONPPQW65.js';export{a as PortfolioTracker}from'./chunk-2SN3RH42.js';export{a as BarReplay}from'./chunk-3GJSZFLM.js';export{b as ScriptEngine,a as runBacktest}from'./chunk-EFAS6F4C.js';import {a,d,e}from'./chunk-47YGQEL5.js';export{c as getSupportedIndicators,f as getSupportedOverlays,b as registerIndicator,e as registerOverlay,o as registerXAxis,n as registerYAxis}from'./chunk-47YGQEL5.js';export{a as WatchlistManager}from'./chunk-UQXYMB6X.js';import Wt from'react';import {createRoot}from'react-dom/client';import {flushSync}from'react-dom';var k=[{id:"default",name:"Default",styles:{line:{color:"#1677FF",size:1,style:"solid"},polygon:{color:"rgba(22,119,255,0.15)"},text:{color:"#1677FF",size:12,family:"Helvetica Neue",weight:"normal"},point:{color:"#1677FF",radius:4,borderColor:"#ffffff",borderSize:2}}},{id:"bullish",name:"Bullish (Green)",styles:{line:{color:"#22ab94",size:1,style:"solid"},polygon:{color:"rgba(34,171,148,0.15)"},text:{color:"#22ab94",size:12,family:"Helvetica Neue",weight:"normal"},point:{color:"#22ab94",radius:4,borderColor:"#ffffff",borderSize:2}}},{id:"bearish",name:"Bearish (Red)",styles:{line:{color:"#f7525f",size:1,style:"solid"},polygon:{color:"rgba(247,82,95,0.15)"},text:{color:"#f7525f",size:12,family:"Helvetica Neue",weight:"normal"},point:{color:"#f7525f",radius:4,borderColor:"#ffffff",borderSize:2}}},{id:"neutral",name:"Neutral (Gray)",styles:{line:{color:"#9598a1",size:1,style:"solid"},polygon:{color:"rgba(149,152,161,0.15)"},text:{color:"#9598a1",size:12,family:"Helvetica Neue",weight:"normal"},point:{color:"#9598a1",radius:4,borderColor:"#ffffff",borderSize:2}}},{id:"highlight",name:"Highlight (Yellow)",styles:{line:{color:"#f6a825",size:2,style:"solid"},polygon:{color:"rgba(246,168,37,0.18)"},text:{color:"#f6a825",size:13,family:"Helvetica Neue",weight:"bold"},point:{color:"#f6a825",radius:5,borderColor:"#ffffff",borderSize:2}}},{id:"dashed_blue",name:"Dashed Blue",styles:{line:{color:"#1677FF",size:1,style:"dashed"},polygon:{color:"rgba(22,119,255,0.10)"},text:{color:"#1677FF",size:12,family:"Helvetica Neue",weight:"normal"},point:{color:"#1677FF",radius:4,borderColor:"#ffffff",borderSize:2}}},{id:"thick_orange",name:"Thick Orange",styles:{line:{color:"#f77c00",size:3,style:"solid"},polygon:{color:"rgba(247,124,0,0.15)"},text:{color:"#f77c00",size:13,family:"Helvetica Neue",weight:"bold"},point:{color:"#f77c00",radius:6,borderColor:"#ffffff",borderSize:2}}}],te="astroneum-drawing-templates",z=class r{static _instance=null;_custom=[];constructor(){this._loadCustom();}static getInstance(){return r._instance||(r._instance=new r),r._instance}_loadCustom(){try{let e=localStorage.getItem(te);if(!e){this._custom=[];return}let t=JSON.parse(e);if(!Array.isArray(t)){this._custom=[];return}this._custom=t.filter(n=>{if(n===null||typeof n!="object")return !1;let o=n;return typeof o.id=="string"&&typeof o.name=="string"&&typeof o.styles=="object"&&o.styles!==null});}catch{this._custom=[];}}_saveCustom(){try{localStorage.setItem(te,JSON.stringify(this._custom));}catch{}}getAll(){return [...k,...this._custom]}getBuiltIn(){return [...k]}getCustom(){return [...this._custom]}getPreset(e){return this.getAll().find(t=>t.id===e)}saveCustomPreset(e){if(k.some(n=>n.id===e.id))throw new Error(`Cannot overwrite built-in preset "${e.id}"`);let t=this._custom.findIndex(n=>n.id===e.id);t>=0?this._custom[t]=e:this._custom.push(e),this._saveCustom();}deleteCustomPreset(e){if(k.some(n=>n.id===e))return false;let t=this._custom.length;return this._custom=this._custom.filter(n=>n.id!==e),this._custom.length<t?(this._saveCustom(),true):false}toOverlayStyles(e){return this.getPreset(e)?.styles}preview(e,t,n){let o=this.getPreset(e);if(!o)return null;let l=n.getOverlays().find(m=>m.id===t)?.styles;return n.overrideOverlay({id:t,styles:o.styles}),()=>{l!==void 0&&n.overrideOverlay({id:t,styles:l});}}static applyColor(e,t,n){e.overrideOverlay({id:t,styles:{line:{color:n},text:{color:n},point:{color:n}}});}},rt=z;function nt(r,e,t={}){let{precision:n=2,compact:o=false,currency:i}=t;return isFinite(r)?i?new Intl.NumberFormat(e,{style:"currency",currency:i,minimumFractionDigits:n,maximumFractionDigits:n}).format(r):o?new Intl.NumberFormat(e,{notation:"compact",maximumFractionDigits:1}).format(r):new Intl.NumberFormat(e,{minimumFractionDigits:n,maximumFractionDigits:n}).format(r):String(r)}function ot(r,e){return isFinite(r)?new Intl.NumberFormat(e,{notation:"compact",maximumFractionDigits:2}).format(r):String(r)}function it(r,e,t=2){return isFinite(r)?new Intl.NumberFormat(e,{style:"percent",minimumFractionDigits:t,maximumFractionDigits:t}).format(r):String(r)}function at(r,e,t="medium"){let n=r>1e10?r:r*1e3;return new Intl.DateTimeFormat(e,{dateStyle:t}).format(new Date(n))}function st(r,e,t="short"){let n=r>1e10?r:r*1e3;return new Intl.DateTimeFormat(e,{timeStyle:t}).format(new Date(n))}function lt(r,e,t="medium",n="short"){let o=r>1e10?r:r*1e3;return new Intl.DateTimeFormat(e,{dateStyle:t,timeStyle:n}).format(new Date(o))}function ct(r,e){let t=Math.abs(r),n=new Intl.RelativeTimeFormat(e,{numeric:"auto",style:"long"});return t<6e4?n.format(Math.round(r/1e3),"second"):t<36e5?n.format(Math.round(r/6e4),"minute"):t<864e5?n.format(Math.round(r/36e5),"hour"):t<2592e6?n.format(Math.round(r/864e5),"day"):n.format(Math.round(r/2592e6),"month")}var re={"en-US":{second:"s",minute:"m",hour:"h",day:"D",week:"W",month:"M",year:"Y"},"zh-CN":{second:"\u79D2",minute:"\u5206",hour:"\u65F6",day:"\u65E5",week:"\u5468",month:"\u6708",year:"\u5E74"},"ja-JP":{second:"\u79D2",minute:"\u5206",hour:"\u6642",day:"\u65E5",week:"\u9031",month:"\u6708",year:"\u5E74"},"ko-KR":{second:"\uCD08",minute:"\uBD84",hour:"\uC2DC",day:"\uC77C",week:"\uC8FC",month:"\uC6D4",year:"\uB144"},"de-DE":{second:"S",minute:"M",hour:"Std",day:"T",week:"W",month:"Mo",year:"J"},"fr-FR":{second:"s",minute:"m",hour:"h",day:"J",week:"S",month:"M",year:"A"},"es-ES":{second:"s",minute:"m",hour:"h",day:"D",week:"S",month:"M",year:"A"},"ar-SA":{second:"\u062B",minute:"\u062F",hour:"\u0633",day:"\u064A",week:"\u0623",month:"\u0634",year:"\u0633"}};function ut(r,e){let n=(re[e]??re["en-US"])[r.timespan]??r.timespan;return `${r.multiplier}${n}`}function mt(r){if(!isFinite(r)||r===0)return 2;let e=Math.abs(r);return e>=1e3?0:e>=1?2:e>=.01?4:e>=1e-4?6:8}var H=class{_listeners=new Map;on(e,t){let n=this._listeners.get(e);return n||(n=new Set,this._listeners.set(e,n)),n.add(t),()=>{this.off(e,t);}}off(e,t){this._listeners.get(e)?.delete(t);}emit(e,t){this._listeners.get(e)?.forEach(n=>{n(t);});}clear(e){e!==void 0?this._listeners.get(e)?.clear():this._listeners.clear();}};var N=class{_buf;_capacity;_head=0;_size=0;constructor(e){if(e<1)throw new RangeError("[RingBuffer] capacity must be \u2265 1");this._capacity=e,this._buf=new Array(e).fill(void 0);}get length(){return Math.min(this._size,this._capacity)}get capacity(){return this._capacity}get isFull(){return this._size>=this._capacity}push(e){let t=(this._head+Math.min(this._size,this._capacity-1)+(this.isFull?1:0))%this._capacity;this.isFull?(this._buf[t]=e,this._head=(this._head+1)%this._capacity):(this._buf[(this._head+this._size)%this._capacity]=e,this._size++);}updateLast(e){if(this._size===0){this.push(e);return}let t=(this._head+Math.min(this._size,this._capacity)-1)%this._capacity;this._buf[t]=e;}at(e){let t=this.length;if(t===0)return;let n=e<0?t+e:e;if(!(n<0||n>=t))return this._buf[(this._head+n)%this._capacity]}last(){return this.at(-1)}first(){return this.at(0)}[Symbol.iterator](){let e=this.length,t=0;return {next:()=>t>=e?{value:void 0,done:true}:{value:this.at(t++),done:false}}}toArray(){let e=new Array(this.length);for(let t=0;t<this.length;t++)e[t]=this.at(t);return e}clear(){this._buf.fill(void 0),this._head=0,this._size=0;}};var V=class{_chart;_stack=[];_redoStack=[];_maxDepth;_lastSnapshot=null;constructor(e,t=50){this._chart=e,this._maxDepth=t;}record(){let e=this._chart.serializeState(),t=JSON.stringify(e.overlays);if(t!==this._lastSnapshot)for(this._lastSnapshot=t,this._stack.push(e),this._redoStack=[];this._stack.length>this._maxDepth;)this._stack.shift();}undo(){if(this._stack.length<=1)return false;let e=this._chart.serializeState();this._redoStack.push(e),this._stack.pop();let t=this._stack[this._stack.length-1];return this._chart.loadState(t),this._lastSnapshot=JSON.stringify(t.overlays),true}redo(){if(this._redoStack.length===0)return false;let e=this._chart.serializeState();this._stack.push(e);let t=this._redoStack.pop();return this._chart.loadState(t),this._lastSnapshot=JSON.stringify(t.overlays),true}clear(){this._stack=[],this._redoStack=[],this._lastSnapshot=null;}get canUndo(){return this._stack.length>1}get canRedo(){return this._redoStack.length>0}};var ne="__session_guides__";function ht(r){let e=-1/0;for(let t=0;t<r.length;t++)r[t]>e&&(e=r[t]);return e}function pt(r){let e=1/0;for(let t=0;t<r.length;t++)r[t]<e&&(e=r[t]);return e}var B=class{_chart;_config;_enabled=false;_animFrame=null;constructor(e,t={}){this._chart=e,this._config={timezone:t.timezone??"America/New_York",openHour:t.openHour??9,openMinute:t.openMinute??30,closeHour:t.closeHour??16,closeMinute:t.closeMinute??0,showExtendedHours:t.showExtendedHours??true,showSessionLevels:t.showSessionLevels??true};}get enabled(){return this._enabled}enable(){this._enabled||(this._enabled=true,this._refresh());}disable(){this._enabled&&(this._enabled=false,this._removeGuides(),this._animFrame!==null&&(cancelAnimationFrame(this._animFrame),this._animFrame=null));}toggle(){this._enabled?this.disable():this.enable();}refresh(){this._enabled&&(this._animFrame!==null&&cancelAnimationFrame(this._animFrame),this._animFrame=requestAnimationFrame(()=>{this._animFrame=null,this._refresh();}));}_refresh(){this._removeGuides();let e=this._chart.getDataList?.();if(!e||e.length===0)return;let t=864e5,n=e[e.length-1],o=n.timestamp-t,i=e.filter(a=>a.timestamp>=o&&a.timestamp<=n.timestamp);if(i.length!==0&&this._config.showSessionLevels){let a=i.map(s=>s.high),l=i.map(s=>s.low),m=[{price:i[0].open,label:"Open",color:"rgba(41,98,255,0.45)",style:"solid"},{price:n.close,label:"Close",color:"rgba(255,255,255,0.35)",style:"dashed"},{price:ht(a),label:"High",color:"rgba(34,171,148,0.45)",style:"solid"},{price:pt(l),label:"Low",color:"rgba(247,82,95,0.45)",style:"solid"}];for(let s of m)try{this._chart.createOverlay({name:"priceLine",groupId:ne,lock:!0,visible:!0,mode:"normal",points:[{value:s.price}],extendData:s.label,styles:{line:{color:s.color,size:1,style:s.style,dashedValue:[4,4]}}});}catch{}}}_removeGuides(){try{this._chart.removeOverlay({groupId:ne});}catch{}}};function ft(r,e=30){if(r.length===0)return [];let t=-1/0,n=1/0;for(let s of r){let u=s.high,c=s.low;u>t&&(t=u),c<n&&(n=c);}let o=t-n;if(o<=0)return [];let i=o/e,a=new Array(e).fill(0);for(let s of r){let u=s.volume??0,c=s.high-s.low;if(c<=0){let h=Math.floor((s.close-n)/i);h>=0&&h<e&&(a[h]+=u);}else {let h=u/c;for(let d=0;d<e;d++){let f=n+d*i,p=f+i,b=Math.max(s.low,f),g=Math.min(s.high,p);g>b&&(a[d]+=(g-b)*h);}}}let l=[],m=0;for(let s=0;s<e;s++)m+=a[s],l.push({price:n+s*i+i/2,volume:a[s],cumulative:m});return l}var dt={name:"volume_profile",shortName:"VProfile",calcParams:[30],calc(r,e){let t=Math.max(5,Math.min(100,Math.round(e[0]??30)));return ft(r,t)},render2D(r,e,t){if(e.length===0)return;let[n,o]=t.resolution,i=t.priceMin,l=t.priceMax-i;if(l<=0)return;let m=0;for(let p of e)m=Math.max(m,p.volume);if(m===0)return;let s=n*.25,u=n-s-8,c=e[0];for(let p of e)p.volume>c.volume&&(c=p);let h=e[e.length-1].cumulative,d=h*.7;for(let p of e){let b=(p.price-i)/l,g=Math.round(o*(1-b)),w=Math.max(1,p.volume/m*s),C=p.cumulative>=(h-d)/2&&p.cumulative<=h-(h-d)/2;r.fillStyle=p===c?"rgba(255, 235, 59, 0.7)":C?"rgba(76, 175, 80, 0.5)":"rgba(158, 158, 158, 0.4)",r.fillRect(u,g-1,w,Math.max(1,o/e.length-1));}let f=Math.round(o*(1-(c.price-i)/l));r.strokeStyle="rgba(255, 235, 59, 0.9)",r.lineWidth=1,r.setLineDash([4,2]),r.beginPath(),r.moveTo(0,f),r.lineTo(n,f),r.stroke(),r.setLineDash([]),r.fillStyle="rgba(255, 235, 59, 0.9)",r.font="10px sans-serif",r.textAlign="left",r.fillText(`POC ${c.price.toFixed(2)}`,4,f-3);}};var oe="astroneum-chart-templates",$="astroneum-active-chart-template",W=class r{static _instance=null;_templates=[];constructor(){this._load();}static getInstance(){return r._instance||(r._instance=new r),r._instance}save(e,t){let n=e.trim();if(!n)throw new TypeError("Template name is required");let o=this._templates.findIndex(l=>l.name===n),i=new Date().toISOString(),a=o>=0?{...this._templates[o],state:t,updatedAt:i}:{id:`${Date.now()}_${Math.random().toString(36).slice(2,7)}`,name:n,state:t,createdAt:i,updatedAt:i};return o>=0?this._templates[o]=a:this._templates.push(a),this._persist(),a}load(e,t){let n=this._templates.find(o=>o.name===e);return n?(t.loadState(n.state),true):false}delete(e){let t=this._templates.length;return this._templates=this._templates.filter(n=>n.name!==e),this._templates.length<t?(this._persist(),this.getActiveName()===e&&this.clearActiveName(),true):false}list(){return this._templates.map(e=>e.name)}get(e){return this._templates.find(t=>t.name===e)}getAll(){return [...this._templates]}rename(e,t){let n=this._templates.findIndex(a=>a.name===e),o=t.trim();if(n<0||!o||o!==e&&this._templates.some(a=>a.name===o))return null;if(o===e)return this._templates[n];let i={...this._templates[n],name:o,updatedAt:new Date().toISOString()};return this._templates[n]=i,this._persist(),this.getActiveName()===e&&this.setActiveName(o),i}duplicate(e){let t=this.get(e);if(!t)return null;let n=`${t.name} copy`,o=2;for(;this._templates.some(i=>i.name===n);)n=`${t.name} copy ${o++}`;return this.save(n,structuredClone(t.state))}setActiveName(e){if(!this._templates.some(t=>t.name===e))return false;try{return localStorage.setItem($,e),!0}catch{return false}}getActiveName(){try{let e=localStorage.getItem($);return e&&this._templates.some(t=>t.name===e)?e:null}catch{return null}}clearActiveName(){try{localStorage.removeItem($);}catch{}}_persist(){localStorage.setItem(oe,JSON.stringify(this._templates));}_load(){try{let e=localStorage.getItem(oe);if(!e)return;let t=JSON.parse(e);if(!Array.isArray(t))return;this._templates=t.filter(n=>{if(n===null||typeof n!="object")return !1;let o=n;return typeof o.id=="string"&&typeof o.name=="string"&&typeof o.state=="object"&&o.state!==null&&typeof o.createdAt=="string"}).map(n=>({...n,updatedAt:typeof n.updatedAt=="string"?n.updatedAt:n.createdAt}));}catch{}}};function ie(r,e){if(r.length===0)return [];let t=ae(e);if(t<=0)return r;let n=[],o=Math.floor(r[0].timestamp/t)*t,i=null;for(let a of r){let l=Math.floor(a.timestamp/t)*t;l!==o||i===null?(i!==null&&n.push(i),o=l,i={timestamp:o,open:a.open,high:a.high,low:a.low,close:a.close,volume:a.volume??0,turnover:a.turnover??0}):(i.high=Math.max(i.high,a.high),i.low=Math.min(i.low,a.low),i.close=a.close,i.volume=(i.volume??0)+(a.volume??0),i.turnover=(i.turnover??0)+(a.turnover??0));}return i!==null&&n.push(i),n}function gt(r,e,t){if(r.length===0||e.length===0||t.length===0)return new Array(t.length).fill(NaN);let n=new Array(t.length),o=0;for(let i=0;i<t.length;i++){for(;o+1<e.length&&e[o+1].timestamp<=t[i].timestamp;)o++;n[i]=r[Math.min(o,r.length-1)];}return n}function ae(r){return ({second:1e3,minute:6e4,hour:36e5,day:864e5,week:6048e5,month:2592e6,year:31536e6}[r.timespan]??6e4)*r.multiplier}function yt(r,e,t){let n=ie(r,e),o=t(n);return {result:o,getValue(i){if(i<0||i>=r.length)return null;let a=r[i].timestamp,l=ae(e),m=Math.floor(a/l)*l;for(let s=n.length-1;s>=0;s--)if(n[s].timestamp<=m)return o[s]??null;return null}}}var se="__position_lines__",K=class{_chart;_active=false;constructor(e){this._chart=e;}show(e){this.hide();let t=e.position,n=t.side,o=t.entryPrice;if(this._createLine(o,"Entry","rgba(255, 255, 255, 0.6)","solid"),e.stopPrice!==void 0&&this._createLine(e.stopPrice,`Stop: ${e.stopPrice}`,"rgba(247, 82, 95, 0.7)","dashed"),e.targetPrice!==void 0&&this._createLine(e.targetPrice,`Target: ${e.targetPrice}`,"rgba(34, 171, 148, 0.7)","dashed"),!t.exitPrice&&e.stopPrice!==void 0&&e.targetPrice!==void 0){let i=Math.abs(e.targetPrice-o),a=Math.abs(o-e.stopPrice),l=a>0?`R:R ${(i/a).toFixed(1)}`:"";this._createLabel(o,`${n.toUpperCase()} ${t.quantity} @ ${o} | ${l}`,"rgba(255, 255, 255, 0.8)");}this._active=true;}hide(){try{this._chart.removeOverlay({groupId:se});}catch{}this._active=false;}update(e){this.show(e);}get active(){return this._active}_createLine(e,t,n,o){try{this._chart.createOverlay({name:"priceLine",groupId:se,lock:!0,visible:!0,mode:"normal",points:[{value:e}],extendData:t,styles:{line:{color:n,size:1.5,style:o,dashedValue:o==="dashed"?[4,4]:[]}}});}catch{}}_createLabel(e,t,n){this._createLine(e,t,n,"solid");}};function U(r,e=5){let t=r.length,n=new Array(t).fill(NaN);if(t<e*2+1)return n;let o=false,i=-1;for(let a=e;a<t-e;a++){let l=r[a],m=l.high,s=l.low,u=true;for(let h=a-e;h<=a+e;h++)if(h!==a&&r[h].high>=m){u=false;break}let c=true;for(let h=a-e;h<=a+e;h++)if(h!==a&&r[h].low<=s){c=false;break}u&&(i===-1||!o)?(n[a]=m,o=true,i=a):c&&(i===-1||o)&&(n[a]=s,o=false,i=a);}return n}function bt(r,e=5,t=.005){let n=U(r,e),o=[];for(let l of n)isNaN(l)||o.push(l);let i=[];for(let l of o){let m=false;for(let s of i)if(Math.abs(s.price-l)/s.price<=t){s.price=(s.price*s.count+l)/(s.count+1),s.count++,m=true;break}m||i.push({price:l,count:1,highs:0,lows:0});}let a=o.reduce((l,m)=>l+m,0)/o.length;return i.filter(l=>l.count>=2).map(l=>({price:l.price,count:l.count,type:l.price>a?"resistance":"support"})).sort((l,m)=>l.price-m.price)}var _t={name:"zigzag",shortName:"ZigZag",calcParams:[5],calc(r,e){let t=Math.max(2,Math.min(20,Math.round(e[0]??5)));return U(r,t)},render2D(r,e,t){if(e.length===0)return;let[n,o]=t.resolution,i=t.priceMin,l=t.priceMax-i,m=t.timeMin,u=t.timeMax-m;if(l<=0||u<=0)return;let c=[];for(let h=0;h<e.length;h++){if(isNaN(e[h]))continue;let d={timestamp:m+u*h/e.length},f=Math.round((d.timestamp-m)/u*n),p=Math.round(o*(1-(e[h]-i)/l));c.push({x:Math.max(0,Math.min(n,f)),y:Math.max(0,Math.min(o,p))});}if(!(c.length<2)){r.strokeStyle="rgba(255, 152, 0, 0.7)",r.lineWidth=1.5,r.beginPath(),r.moveTo(c[0].x,c[0].y);for(let h=1;h<c.length;h++)r.lineTo(c[h].x,c[h].y);r.stroke(),r.fillStyle="rgba(255, 152, 0, 0.9)";for(let h of c)r.beginPath(),r.arc(h.x,h.y,3,0,Math.PI*2),r.fill();}}};var vt="#26a69a",xt="#ef5350",wt="#2962ff";function y(r){return Math.abs(r.close-r.open)}function S(r){return r.high-Math.max(r.open,r.close)}function P(r){return Math.min(r.open,r.close)-r.low}function M(r){return r.high-r.low}function v(r){return r.close>r.open}function x(r){return r.close<r.open}function le(r,e,t){let n=Math.max(0,e-t+1),o=0,i=0;for(let a=n;a<=e;a++)o+=y(r[a]),i++;return i>0?o/i:0}function Ct(r,e){if(e<0||e>=r.length)return null;let t=r[e],n=M(t);return n===0?null:y(t)/n<.05?{index:e,pattern:"Doji",type:"neutral",timestamp:t.timestamp,high:t.high,low:t.low}:null}function Mt(r,e){if(e<0||e>=r.length)return null;let t=r[e],n=M(t);if(n===0)return null;let o=P(t),i=S(t),a=y(t);return o>2*a&&i<a*.3&&a/n<.4?{index:e,pattern:"Hammer",type:"bullish",timestamp:t.timestamp,high:t.high,low:t.low}:null}function St(r,e){if(e<0||e>=r.length)return null;let t=r[e],n=M(t);if(n===0)return null;let o=S(t),i=P(t),a=y(t);return o>2*a&&i<a*.3&&a/n<.4?{index:e,pattern:"Inverted Hammer",type:"bullish",timestamp:t.timestamp,high:t.high,low:t.low}:null}function Pt(r,e){if(e<0||e>=r.length)return null;let t=r[e],n=M(t);if(n===0)return null;let o=S(t),i=P(t),a=y(t);return x(t)&&o>2*a&&i<a*.3&&a/n<.4?{index:e,pattern:"Shooting Star",type:"bearish",timestamp:t.timestamp,high:t.high,low:t.low}:null}function Dt(r,e){if(e<0||e>=r.length)return null;let t=r[e],n=M(t);if(n===0)return null;let o=P(t),i=S(t),a=y(t);return v(t)&&o>2*a&&i<a*.3&&a/n<.4?{index:e,pattern:"Hanging Man",type:"bearish",timestamp:t.timestamp,high:t.high,low:t.low}:null}function Tt(r,e){if(e<0||e>=r.length)return null;let t=r[e],n=M(t);if(n===0)return null;let o=y(t),i=S(t),a=P(t);return o/n<.3&&i>o&&a>o?{index:e,pattern:"Spinning Top",type:"neutral",timestamp:t.timestamp,high:t.high,low:t.low}:null}function At(r,e){if(e<1||e>=r.length)return null;let t=r[e-1],n=r[e];return x(t)&&v(n)&&n.close>=t.open&&n.open<=t.close&&y(n)>y(t)?{index:e,pattern:"Bullish Engulfing",type:"bullish",timestamp:n.timestamp,high:n.high,low:n.low}:null}function kt(r,e){if(e<1||e>=r.length)return null;let t=r[e-1],n=r[e];return v(t)&&x(n)&&n.open>=t.close&&n.close<=t.open&&y(n)>y(t)?{index:e,pattern:"Bearish Engulfing",type:"bearish",timestamp:n.timestamp,high:n.high,low:n.low}:null}function It(r,e){if(e<1||e>=r.length)return null;let t=r[e-1],n=r[e],o=(t.open+t.close)/2;return x(t)&&v(n)&&n.open<t.low&&n.close>o&&n.close<t.open?{index:e,pattern:"Piercing Line",type:"bullish",timestamp:n.timestamp,high:n.high,low:n.low}:null}function Ot(r,e){if(e<1||e>=r.length)return null;let t=r[e-1],n=r[e],o=(t.open+t.close)/2;return v(t)&&x(n)&&n.open>t.high&&n.close<o&&n.close>t.open?{index:e,pattern:"Dark Cloud Cover",type:"bearish",timestamp:n.timestamp,high:n.high,low:n.low}:null}function Rt(r,e){if(e<1||e>=r.length)return null;let t=r[e-1],n=r[e];return x(t)&&v(n)&&n.open>t.close&&n.close<t.open&&y(n)<y(t)*.6?{index:e,pattern:"Bullish Harami",type:"bullish",timestamp:n.timestamp,high:n.high,low:n.low}:null}function Ft(r,e){if(e<1||e>=r.length)return null;let t=r[e-1],n=r[e];return v(t)&&x(n)&&n.open<t.close&&n.close>t.open&&y(n)<y(t)*.6?{index:e,pattern:"Bearish Harami",type:"bearish",timestamp:n.timestamp,high:n.high,low:n.low}:null}function Lt(r,e){if(e<2||e>=r.length)return null;let t=r[e-2],n=r[e-1],o=r[e],i=le(r,e,10);return x(t)&&y(t)>i*.7&&y(n)<i*.3&&v(o)&&o.close>(t.open+t.close)/2?{index:e,pattern:"Morning Star",type:"bullish",timestamp:o.timestamp,high:o.high,low:o.low}:null}function Et(r,e){if(e<2||e>=r.length)return null;let t=r[e-2],n=r[e-1],o=r[e],i=le(r,e,10);return v(t)&&y(t)>i*.7&&y(n)<i*.3&&x(o)&&o.close<(t.open+t.close)/2?{index:e,pattern:"Evening Star",type:"bearish",timestamp:o.timestamp,high:o.high,low:o.low}:null}function zt(r,e){if(e<2||e>=r.length)return null;let t=r[e-2],n=r[e-1],o=r[e];return v(t)&&v(n)&&v(o)&&n.close>t.close&&o.close>n.close&&n.open>t.open&&o.open>n.open?{index:e,pattern:"Three White Soldiers",type:"bullish",timestamp:o.timestamp,high:o.high,low:o.low}:null}function Ht(r,e){if(e<2||e>=r.length)return null;let t=r[e-2],n=r[e-1],o=r[e];return x(t)&&x(n)&&x(o)&&n.close<t.close&&o.close<n.close&&n.open<t.open&&o.open<n.open?{index:e,pattern:"Three Black Crows",type:"bearish",timestamp:o.timestamp,high:o.high,low:o.low}:null}function Nt(r,e){if(e<2||e>=r.length)return null;let t=r[e-2],n=r[e-1],o=r[e];return x(t)&&v(n)&&n.open>t.close&&n.close<t.open&&v(o)&&o.close>n.close?{index:e,pattern:"Three Inside Up",type:"bullish",timestamp:o.timestamp,high:o.high,low:o.low}:null}function Vt(r,e){if(e<2||e>=r.length)return null;let t=r[e-2],n=r[e-1],o=r[e];return v(t)&&x(n)&&n.open<t.close&&n.close>t.open&&x(o)&&o.close<n.close?{index:e,pattern:"Three Inside Down",type:"bearish",timestamp:o.timestamp,high:o.high,low:o.low}:null}var I=[{id:"doji",name:"Doji",category:"single",type:"neutral",fn:Ct},{id:"hammer",name:"Hammer",category:"single",type:"bullish",fn:Mt},{id:"inverted_hammer",name:"Inverted Hammer",category:"single",type:"bullish",fn:St},{id:"shooting_star",name:"Shooting Star",category:"single",type:"bearish",fn:Pt},{id:"hanging_man",name:"Hanging Man",category:"single",type:"bearish",fn:Dt},{id:"spinning_top",name:"Spinning Top",category:"single",type:"neutral",fn:Tt},{id:"bullish_engulfing",name:"Bullish Engulfing",category:"two",type:"bullish",fn:At},{id:"bearish_engulfing",name:"Bearish Engulfing",category:"two",type:"bearish",fn:kt},{id:"piercing_line",name:"Piercing Line",category:"two",type:"bullish",fn:It},{id:"dark_cloud_cover",name:"Dark Cloud Cover",category:"two",type:"bearish",fn:Ot},{id:"bullish_harami",name:"Bullish Harami",category:"two",type:"bullish",fn:Rt},{id:"bearish_harami",name:"Bearish Harami",category:"two",type:"bearish",fn:Ft},{id:"morning_star",name:"Morning Star",category:"three",type:"bullish",fn:Lt},{id:"evening_star",name:"Evening Star",category:"three",type:"bearish",fn:Et},{id:"three_white_soldiers",name:"Three White Soldiers",category:"three",type:"bullish",fn:zt},{id:"three_black_crows",name:"Three Black Crows",category:"three",type:"bearish",fn:Ht},{id:"three_inside_up",name:"Three Inside Up",category:"three",type:"bullish",fn:Nt},{id:"three_inside_down",name:"Three Inside Down",category:"three",type:"bearish",fn:Vt}];function Bt(r,e){let t=[];for(let n=0;n<r.length;n++)for(let o=0;o<I.length;o++){if(o<e.length&&e[o]===0)continue;let i=I[o].fn(r,n);if(i){t.push(i);break}}return t}var $t={name:"patterns",shortName:"Patterns",calcParams:[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],calc(r,e){let t=e.length>0?e:I.map(()=>1);return Bt(r,t)},render2D(r,e,t){if(e.length===0)return;let[n,o]=t.resolution,i=t.timeMin,a=t.timeMax,l=a-i;if(l<=0)return;let m=t.priceMin,u=t.priceMax-m;if(!(u<=0))for(let c of e){if(c.timestamp<i||c.timestamp>a)continue;let h=(c.timestamp-i)/l,d=Math.round(h*n),f=c.type==="bullish"?vt:c.type==="bearish"?xt:wt,p=Math.round(o*(1-(c.high-m)/u)),b=Math.round(o*(1-(c.low-m)/u)),g=c.type==="bullish"?b+12:p-12,w=c.type==="bullish"?g+10:g-6;r.fillStyle=f,r.beginPath(),r.arc(d,g,3,0,Math.PI*2),r.fill(),r.font="9px Trebuchet MS, sans-serif",r.fillStyle=f,r.textAlign="center",r.fillText(c.pattern,d,w);}}};var Yt=[{multiplier:4,timespan:"hour",text:"4H"},{multiplier:1,timespan:"hour",text:"1H"},{multiplier:15,timespan:"minute",text:"15m"}],Y=class{_container;_periods;_charts=[];_options;_storageKey;_wrapperEl=null;constructor(e){if(this._options=e,this._periods=e.periods??Yt,this._storageKey=e.storageKey!==void 0?e.storageKey:"astroneum-multi-period",typeof e.container=="string"){let t=document.getElementById(e.container);if(!t)throw new Error(`MultiPeriodLayout: container #${e.container} not found`);this._container=t;}else this._container=e.container;this._render();}_render(){this._destroy();let e=document.createElement("div");e.className="astroneum-multi-period",Object.assign(e.style,{display:"flex",flexDirection:"column",width:"100%",height:"100%",gap:"2px",boxSizing:"border-box"}),this._wrapperEl=e;for(let t=0;t<this._periods.length;t++){let n=this._periods[t],o=document.createElement("div");o.className="astroneum-multi-period-cell",Object.assign(o.style,{position:"relative",overflow:"hidden",flex:"1",minHeight:"100px"}),t===this._periods.length-1&&(o.style.outline="2px solid #1677ff"),e.appendChild(o);let i={...this._options,symbol:this._options.symbol,period:n,drawingBarVisible:false},a=null,l=createRoot(o);if(flushSync(()=>{l.render(Wt.createElement(f,{...i,ref:m=>{m&&(a=m);}}));}),!a)throw new Error("MultiPeriodLayout: chart initialization failed");this._charts.push({container:o,instance:a,root:l});}this._charts.length>1&&this._charts[this._charts.length-1].instance.onCrosshairMove(n=>{for(let o=0;o<this._charts.length-1;o++)this._charts[o].instance.setCrosshair(n);}),this._container.innerHTML="",this._container.appendChild(e);}_destroy(){for(let{root:e}of this._charts)e.unmount();this._charts=[],this._wrapperEl&&(this._container.removeChild(this._wrapperEl),this._wrapperEl=null);}setTheme(e){for(let{instance:t}of this._charts)t.setTheme(e);}setLocale(e){for(let{instance:t}of this._charts)t.setLocale(e);}getCharts(){return this._charts.map(e=>e.instance)}destroy(){this._destroy();}};function jt(r,e,t,n="#ff6d00"){let o=[],i=[],a=-1,l=null;return {name:`compare_${r.ticker.replace(/[^a-zA-Z0-9]/g,"_")}`,shortName:r.ticker.split(":").pop()??r.ticker,calcParams:[],calc(s,u){if(s.length!==a&&s.length>0){a=s.length;let c=s[0].timestamp,h=s[s.length-1].timestamp;l===null&&(l=e.getHistoryData(r,t,c,h).then(d=>{if(o=d.sort((f,p)=>f.timestamp-p.timestamp),o.length>0){let f=o[0].close;f!==0?i=o.map(p=>(p.close-f)/f*100):i=o.map(()=>0);}l=null;}).catch(()=>{l=null;}));}return i.length===s.length?i:new Array(s.length).fill(NaN)},render2D(s,u,c){if(u.length===0||c.resolution[0]===0)return;let h=c.resolution[0],d=c.resolution[1],f=1/0,p=-1/0;for(let _ of u)isFinite(_)&&(_<f&&(f=_),_>p&&(p=_));if(!isFinite(f))return;let g=(p-f||1)*.05,w=f-g,C=p+g,D=h/(u.length-1),O=255,R=109,F=0,j=.9;if(n.startsWith("#")){let _=n.replace("#","");O=parseInt(_.slice(0,2),16),R=parseInt(_.slice(2,4),16),F=parseInt(_.slice(4,6),16);}s.strokeStyle=`rgba(${O},${R},${F},${j})`,s.lineWidth=1.5,s.beginPath();let L=false;for(let _=0;_<u.length;_++){let T=u[_];if(!isFinite(T)){L=false;continue}let G=_*D,J=d-(T-w)/(C-w)*d;L?s.lineTo(G,J):(s.moveTo(G,J),L=true);}s.stroke();let me=u.length-1,E=u[me];if(isFinite(E)){let _=h-4,T=d-(E-w)/(C-w)*d;s.fillStyle=`rgba(${O},${R},${F},${j})`,s.font="10px sans-serif",s.textAlign="right",s.textBaseline="middle",s.fillText(`${r.ticker} ${E.toFixed(2)}%`,_,Math.max(10,Math.min(d-4,T)));}}}}function Gt(r,e=20){if(r.length===0)return [];let t=-1/0,n=1/0;for(let l of r)l.high>t&&(t=l.high),l.low<n&&(n=l.low);let o=t-n;if(o<=0)return [];let i=o/e,a=[];for(let l=0;l<e;l++){let m=t-l*i-i/2,s=0,u=0;for(let c of r){let h=c.volume??0,d=c.high-c.low;if(d<=0)continue;let f=h/d,p=Math.max(c.low,m-i/2),b=Math.min(c.high,m+i/2);if(b>p){let g=(b-p)*f;c.close<=m?s+=g:u+=g;}}a.push({price:m,bidVolume:s,askVolume:u,totalVolume:s+u});}return a.sort((l,m)=>m.price-l.price)}var Jt={name:"dom",shortName:"DOM",calcParams:[20],calc(r,e){let t=Math.max(5,Math.min(50,Math.round(e[0]??20)));return Gt(r,t)},render2D(r,e,t){if(e.length===0)return;let[n,o]=t.resolution,i=t.priceMin,l=t.priceMax-i;if(l<=0)return;let m=n*.3,s=n-m-8,u=Math.max(2,Math.floor(o/e.length)),c=0;for(let b of e){let g=b.bidVolume+b.askVolume;g>c&&(c=g);}if(c===0)return;for(let b of e){let g=(b.price-i)/l;if(g<0||g>1)continue;let w=Math.round(o*(1-g)),C=b.bidVolume/c*m,D=b.askVolume/c*m;C>0&&(r.fillStyle="rgba(76, 175, 80, 0.5)",r.fillRect(s,w,C,u)),D>0&&(r.fillStyle="rgba(244, 67, 54, 0.5)",r.fillRect(s+C,w,D,u));}r.fillStyle="rgba(255, 255, 255, 0.5)",r.font="9px monospace",r.textAlign="right";let h=e[0],d=Math.round(o*(1-(h.price-i)/l));r.fillText(h.price.toFixed(2),n-4,Math.max(12,d+4));let f=e[e.length-1],p=Math.round(o*(1-(f.price-i)/l));r.fillText(f.price.toFixed(2),n-4,Math.min(o-4,p+4));}};function Xt(r,e){if(r.length===0||e<=0)return [];let t=[],n=Math.round(r[0].close/e)*e,o=r[0].timestamp;t.push({timestamp:o,open:n,high:n+e,low:n-e,close:n,volume:r[0].volume});for(let i=1;i<r.length;i++){let a=r[i],l=Math.floor(Math.abs(a.close-n)/e);if(l>=1){let m=a.close>n?1:-1;for(let s=0;s<l;s++){o+=6e4,n+=m*e;let u=n,c=u-m*e;t.push({timestamp:o,open:c,high:Math.max(c,u),low:Math.min(c,u),close:u,volume:a.volume?a.volume/l:0});}}}return t}function qt(r,e=3){if(r.length===0)return [];let t=[],n=r[0].close,o=r[0].close,i=1,a=r[0].timestamp,l=e/100;for(let m=1;m<r.length;m++){let s=r[m];i===1?s.close>n?n=s.close:s.close<n*(1-l)&&(a+=6e4,t.push({timestamp:a,open:n,high:n,low:s.close,close:s.close,volume:s.volume}),i=-1,o=s.close,n=s.close):s.close<o?o=s.close:s.close>o*(1+l)&&(a+=6e4,t.push({timestamp:a,open:o,high:s.close,low:o,close:s.close,volume:s.volume}),i=1,n=s.close,o=s.close);}return t}function Zt(r,e){if(r.length===0||e<=0)return [];let t=[],n=r[0].timestamp;for(let o=0;o<r.length;o+=e){let i=r.slice(o,o+e);if(i.length===0)break;let a=i[0].open,l=-1/0,m=1/0,s=0,u=0;for(let c of i)c.high>l&&(l=c.high),c.low<m&&(m=c.low),s+=c.volume??0,u+=c.turnover??0;n+=6e4,t.push({timestamp:n,open:a,high:l,low:m,close:i[i.length-1].close,volume:s,turnover:u});}return t}function Qt(r,e){if(r.length===0||e<=0)return [];let t=[],n=r[0].timestamp,o=r[0].high,i=r[0].low,a=r[0].open,l=r[0].volume??0,m=r[0].turnover??0;for(let s=1;s<r.length;s++){let u=r[s];u.high>o&&(o=u.high),u.low<i&&(i=u.low),o-i>=e?(n+=6e4,t.push({timestamp:n,open:a,high:o,low:i,close:u.close,volume:l,turnover:m}),a=u.close,o=u.high,i=u.low,l=u.volume??0,m=u.turnover??0):(l+=u.volume??0,m+=u.turnover??0);}return t}function ce(r,e={}){if(r.length===0)return [];let t=Math.max(1,e.reversal??3),n=e.boxSize??(()=>{let l=0;for(let s of r)l+=s.close;let m=l/r.length;return Math.max(.01,m*.01)})(),o=[],i=null,a=Math.round(r[0].close/n)*n;for(let l of r){let m=e.method==="hilo"?[l.high,l.low]:[l.high,l.low,l.close];for(let s of m){let u=Math.round(s/n)*n;if(i===null){u>a?i={type:"X",top:u,bottom:a,boxes:1,columnIndex:o.length}:u<a&&(i={type:"O",top:a,bottom:u,boxes:1,columnIndex:o.length}),a=u;continue}if(i.type==="X"){if(u>i.top){let c=Math.round((u-i.top)/n);i.top=u,i.boxes+=c;}else if(u<=i.top-t*n){o.push(i);let c=u,h=Math.round((i.top-c)/n);i={type:"O",top:i.top-n,bottom:c,boxes:Math.max(1,h),columnIndex:o.length};}}else if(u<i.bottom){let c=Math.round((i.bottom-u)/n);i.bottom=u,i.boxes+=c;}else if(u>=i.bottom+t*n){o.push(i);let c=u,h=Math.round((c-i.bottom)/n);i={type:"X",top:c,bottom:i.bottom+n,boxes:Math.max(1,h),columnIndex:o.length};}a=u;}}return i!==null&&o.push(i),o}function ue(r){let e=[],t=Date.now(),n=6e4;for(let o of r){let i=(o.top-o.bottom)/Math.max(1,o.boxes);for(let a=0;a<o.boxes;a++){let l=o.bottom+a*i,m=l+i,s=t+o.columnIndex*n*2+a*n;o.type==="X"?e.push({timestamp:s,open:l,high:m,low:l,close:m,volume:1}):e.push({timestamp:s,open:m,high:m,low:l,close:l,volume:1});}}return e}function er(r,e,t){return ue(ce(r,{boxSize:e,reversal:t}))}var tr={name:"point_and_figure",shortName:"P&F",calcParams:[10,3],calc(r,e){let t=e[0]??10,n=Math.max(1,Math.round(e[1]??3));return [t,n]},render2D(r,e,t){}};a();d();a$1.forEach(r=>{e(r);});export{W as ChartTemplateManager,rt as DrawingTemplates,H as EventBus,Y as MultiPeriodLayout,I as PATTERN_CATALOGUE,K as PositionVisualizer,N as RingBuffer,B as SessionVisualizer,V as UndoManager,ce as computePFColumns,jt as createCompareIndicator,mt as detectPricePrecision,bt as detectSupportResistance,Jt as domPlugin,at as formatDate,lt as formatDateTime,ct as formatDuration,it as formatPercent,ut as formatPeriod,nt as formatPrice,st as formatTime,ot as formatVolume,gt as forwardFill,qt as generateKagi,er as generatePointAndFigure,Qt as generateRangeBars,Xt as generateRenko,Zt as generateTickBars,yt as mtfIndicator,$t as patternRecognitionPlugin,ue as pfColumnsToBars,tr as pointAndFigurePlugin,ie as resampleBars,dt as volumeProfilePlugin,U as zigzag,_t as zigzagPlugin};