diff --git a/crates/brk_computer/src/storage/vecs/blocks.rs b/crates/brk_computer/src/storage/vecs/blocks.rs index 2f6dd8426..17cd52bb1 100644 --- a/crates/brk_computer/src/storage/vecs/blocks.rs +++ b/crates/brk_computer/src/storage/vecs/blocks.rs @@ -1,6 +1,9 @@ use std::{fs, path::Path}; -use brk_core::{CheckedSub, Height, StoredU32, StoredU64, StoredUsize, Timestamp, Weight}; +use brk_core::{ + CheckedSub, DifficultyEpoch, HalvingEpoch, Height, StoredU32, StoredU64, StoredUsize, + Timestamp, Weight, +}; use brk_exit::Exit; use brk_indexer::Indexer; use brk_parser::bitcoin; @@ -8,19 +11,22 @@ use brk_vec::{Compressed, Version}; use super::{ EagerVec, Indexes, - grouped::{ComputedVecsFromHeight, StorableVecGeneatorOptions}, + grouped::{ComputedVecsFromDateindex, ComputedVecsFromHeight, StorableVecGeneatorOptions}, indexes, }; #[derive(Clone)] pub struct Vecs { pub height_to_interval: EagerVec, - pub indexes_to_block_interval: ComputedVecsFromHeight, - pub indexes_to_block_count: ComputedVecsFromHeight, - pub indexes_to_block_weight: ComputedVecsFromHeight, pub height_to_vbytes: EagerVec, - pub indexes_to_block_vbytes: ComputedVecsFromHeight, + pub difficultyepoch_to_timestamp: EagerVec, + pub halvingepoch_to_timestamp: EagerVec, + pub timeindexes_to_timestamp: ComputedVecsFromDateindex, + pub indexes_to_block_count: ComputedVecsFromHeight, + pub indexes_to_block_interval: ComputedVecsFromHeight, pub indexes_to_block_size: ComputedVecsFromHeight, + pub indexes_to_block_vbytes: ComputedVecsFromHeight, + pub indexes_to_block_weight: ComputedVecsFromHeight, } impl Vecs { @@ -33,6 +39,13 @@ impl Vecs { Version::ZERO, compressed, )?, + timeindexes_to_timestamp: ComputedVecsFromDateindex::forced_import( + path, + "timestamp", + Version::ZERO, + compressed, + StorableVecGeneatorOptions::default().add_first(), + )?, indexes_to_block_interval: ComputedVecsFromHeight::forced_import( path, "block_interval", @@ -81,6 +94,16 @@ impl Vecs { compressed, StorableVecGeneatorOptions::default().add_sum().add_total(), )?, + difficultyepoch_to_timestamp: EagerVec::forced_import( + &path.join("difficultyepoch_to_timestamp"), + Version::ZERO, + compressed, + )?, + halvingepoch_to_timestamp: EagerVec::forced_import( + &path.join("halvingepoch_to_timestamp"), + Version::ZERO, + compressed, + )?, }) } @@ -91,9 +114,43 @@ impl Vecs { starting_indexes: &Indexes, exit: &Exit, ) -> color_eyre::Result<()> { + self.timeindexes_to_timestamp.compute( + indexer, + indexes, + starting_indexes, + exit, + |vec, _, indexes, starting_indexes, exit| { + vec.compute_transform( + starting_indexes.dateindex, + indexes.dateindex_to_date.mut_vec(), + |(di, d, ..)| (di, Timestamp::from(d)), + exit, + ) + }, + )?; + + self.indexes_to_block_count.compute_all( + indexer, + indexes, + starting_indexes, + exit, + |v, indexer, _, starting_indexes, exit| { + let indexer_vecs = indexer.mut_vecs(); + + v.compute_range( + starting_indexes.height, + indexer_vecs.height_to_weight.mut_vec(), + |h| (h, StoredU32::from(1_u32)), + exit, + ) + }, + )?; + + let indexer_vecs = indexer.mut_vecs(); + self.height_to_interval.compute_transform( starting_indexes.height, - indexer.mut_vecs().height_to_timestamp.mut_vec(), + indexer_vecs.height_to_timestamp.mut_vec(), |(height, timestamp, _, height_to_timestamp)| { let interval = height.decremented().map_or(Timestamp::ZERO, |prev_h| { let prev_timestamp = height_to_timestamp.double_unwrap_cached_get(prev_h); @@ -113,38 +170,23 @@ impl Vecs { Some(self.height_to_interval.mut_vec()), )?; - self.indexes_to_block_count.compute_all( - indexer, - indexes, - starting_indexes, - exit, - |v, indexer, _, starting_indexes, exit| { - v.compute_range( - starting_indexes.height, - indexer.mut_vecs().height_to_weight.mut_vec(), - |h| (h, StoredU32::from(1_u32)), - exit, - ) - }, - )?; - self.indexes_to_block_weight.compute_rest( indexes, starting_indexes, exit, - Some(indexer.mut_vecs().height_to_weight.mut_vec()), + Some(indexer_vecs.height_to_weight.mut_vec()), )?; self.indexes_to_block_size.compute_rest( indexes, starting_indexes, exit, - Some(indexer.mut_vecs().height_to_total_size.mut_vec()), + Some(indexer_vecs.height_to_total_size.mut_vec()), )?; self.height_to_vbytes.compute_transform( starting_indexes.height, - indexer.mut_vecs().height_to_weight.mut_vec(), + indexer_vecs.height_to_weight.mut_vec(), |(h, w, ..)| { ( h, @@ -161,6 +203,30 @@ impl Vecs { Some(self.height_to_vbytes.mut_vec()), )?; + self.difficultyepoch_to_timestamp.compute_transform( + starting_indexes.difficultyepoch, + indexes.difficultyepoch_to_first_height.mut_vec(), + |(i, h, ..)| { + ( + i, + indexer_vecs.height_to_timestamp.double_unwrap_cached_get(h), + ) + }, + exit, + )?; + + self.halvingepoch_to_timestamp.compute_transform( + starting_indexes.halvingepoch, + indexes.halvingepoch_to_first_height.mut_vec(), + |(i, h, ..)| { + ( + i, + indexer_vecs.height_to_timestamp.double_unwrap_cached_get(h), + ) + }, + exit, + )?; + Ok(()) } @@ -169,12 +235,15 @@ impl Vecs { vec![ self.height_to_interval.any_vec(), self.height_to_vbytes.any_vec(), + self.difficultyepoch_to_timestamp.any_vec(), + self.halvingepoch_to_timestamp.any_vec(), ], - self.indexes_to_block_interval.any_vecs(), + self.timeindexes_to_timestamp.any_vecs(), self.indexes_to_block_count.any_vecs(), - self.indexes_to_block_weight.any_vecs(), + self.indexes_to_block_interval.any_vecs(), self.indexes_to_block_size.any_vecs(), self.indexes_to_block_vbytes.any_vecs(), + self.indexes_to_block_weight.any_vecs(), ] .concat() } diff --git a/crates/brk_computer/src/storage/vecs/indexes.rs b/crates/brk_computer/src/storage/vecs/indexes.rs index 3bb8ae274..b4d181791 100644 --- a/crates/brk_computer/src/storage/vecs/indexes.rs +++ b/crates/brk_computer/src/storage/vecs/indexes.rs @@ -19,21 +19,17 @@ pub struct Vecs { pub dateindex_to_first_height: EagerVec, pub dateindex_to_last_height: EagerVec, pub dateindex_to_monthindex: EagerVec, - pub dateindex_to_timestamp: EagerVec, pub dateindex_to_weekindex: EagerVec, pub decadeindex_to_decadeindex: EagerVec, pub decadeindex_to_first_yearindex: EagerVec, pub decadeindex_to_last_yearindex: EagerVec, - pub decadeindex_to_timestamp: EagerVec, pub difficultyepoch_to_difficultyepoch: EagerVec, pub difficultyepoch_to_first_height: EagerVec, pub difficultyepoch_to_last_height: EagerVec, - pub difficultyepoch_to_timestamp: EagerVec, pub emptyoutputindex_to_emptyoutputindex: EagerVec, pub halvingepoch_to_first_height: EagerVec, pub halvingepoch_to_halvingepoch: EagerVec, pub halvingepoch_to_last_height: EagerVec, - pub halvingepoch_to_timestamp: EagerVec, pub height_to_date: EagerVec, pub height_to_date_fixed: EagerVec, pub height_to_dateindex: EagerVec, @@ -47,7 +43,6 @@ pub struct Vecs { pub monthindex_to_last_dateindex: EagerVec, pub monthindex_to_monthindex: EagerVec, pub monthindex_to_quarterindex: EagerVec, - pub monthindex_to_timestamp: EagerVec, pub monthindex_to_yearindex: EagerVec, pub opreturnindex_to_opreturnindex: EagerVec, pub outputindex_to_outputindex: EagerVec, @@ -63,7 +58,6 @@ pub struct Vecs { pub quarterindex_to_first_monthindex: EagerVec, pub quarterindex_to_last_monthindex: EagerVec, pub quarterindex_to_quarterindex: EagerVec, - pub quarterindex_to_timestamp: EagerVec, pub txindex_to_height: EagerVec, pub txindex_to_last_inputindex: EagerVec, pub txindex_to_last_outputindex: EagerVec, @@ -71,12 +65,10 @@ pub struct Vecs { pub unknownoutputindex_to_unknownoutputindex: EagerVec, pub weekindex_to_first_dateindex: EagerVec, pub weekindex_to_last_dateindex: EagerVec, - pub weekindex_to_timestamp: EagerVec, pub weekindex_to_weekindex: EagerVec, pub yearindex_to_decadeindex: EagerVec, pub yearindex_to_first_monthindex: EagerVec, pub yearindex_to_last_monthindex: EagerVec, - pub yearindex_to_timestamp: EagerVec, pub yearindex_to_yearindex: EagerVec, } @@ -265,41 +257,6 @@ impl Vecs { Version::ZERO, compressed, )?, - dateindex_to_timestamp: EagerVec::forced_import( - &path.join("dateindex_to_timestamp"), - Version::ZERO, - compressed, - )?, - decadeindex_to_timestamp: EagerVec::forced_import( - &path.join("decadeindex_to_timestamp"), - Version::ZERO, - compressed, - )?, - difficultyepoch_to_timestamp: EagerVec::forced_import( - &path.join("difficultyepoch_to_timestamp"), - Version::ZERO, - compressed, - )?, - halvingepoch_to_timestamp: EagerVec::forced_import( - &path.join("halvingepoch_to_timestamp"), - Version::ZERO, - compressed, - )?, - monthindex_to_timestamp: EagerVec::forced_import( - &path.join("monthindex_to_timestamp"), - Version::ZERO, - compressed, - )?, - weekindex_to_timestamp: EagerVec::forced_import( - &path.join("weekindex_to_timestamp"), - Version::ZERO, - compressed, - )?, - yearindex_to_timestamp: EagerVec::forced_import( - &path.join("yearindex_to_timestamp"), - Version::ZERO, - compressed, - )?, height_to_timestamp_fixed: EagerVec::forced_import( &path.join("height_to_timestamp_fixed"), Version::ZERO, @@ -325,11 +282,6 @@ impl Vecs { Version::ZERO, compressed, )?, - quarterindex_to_timestamp: EagerVec::forced_import( - &path.join("quarterindex_to_timestamp"), - Version::ZERO, - compressed, - )?, p2pk33index_to_p2pk33index: EagerVec::forced_import( &path.join("p2pk33index_to_p2pk33index"), Version::ZERO, @@ -421,6 +373,158 @@ impl Vecs { let inputindexes_count = indexer_vecs.inputindex_to_outputindex.len(); let outputindexes_count = indexer_vecs.outputindex_to_value.len(); + // --- + // OutputIndex + // --- + + self.outputindex_to_outputindex.compute_range( + starting_indexes.outputindex, + indexer_vecs.outputindex_to_value.mut_vec(), + |i| (i, i), + exit, + )?; + + self.p2pk33index_to_p2pk33index.compute_range( + starting_indexes.p2pk33index, + indexer_vecs.p2pk33index_to_p2pk33bytes.mut_vec(), + |i| (i, i), + exit, + )?; + + self.p2pk65index_to_p2pk65index.compute_range( + starting_indexes.p2pk65index, + indexer_vecs.p2pk65index_to_p2pk65bytes.mut_vec(), + |i| (i, i), + exit, + )?; + + self.p2pkhindex_to_p2pkhindex.compute_range( + starting_indexes.p2pkhindex, + indexer_vecs.p2pkhindex_to_p2pkhbytes.mut_vec(), + |i| (i, i), + exit, + )?; + + self.p2shindex_to_p2shindex.compute_range( + starting_indexes.p2shindex, + indexer_vecs.p2shindex_to_p2shbytes.mut_vec(), + |i| (i, i), + exit, + )?; + + self.p2trindex_to_p2trindex.compute_range( + starting_indexes.p2trindex, + indexer_vecs.p2trindex_to_p2trbytes.mut_vec(), + |i| (i, i), + exit, + )?; + + self.p2wpkhindex_to_p2wpkhindex.compute_range( + starting_indexes.p2wpkhindex, + indexer_vecs.p2wpkhindex_to_p2wpkhbytes.mut_vec(), + |i| (i, i), + exit, + )?; + + self.p2wshindex_to_p2wshindex.compute_range( + starting_indexes.p2wshindex, + indexer_vecs.p2wshindex_to_p2wshbytes.mut_vec(), + |i| (i, i), + exit, + )?; + + self.emptyoutputindex_to_emptyoutputindex.compute_range( + starting_indexes.emptyoutputindex, + indexer_vecs.emptyoutputindex_to_txindex.mut_vec(), + |i| (i, i), + exit, + )?; + + self.p2msindex_to_p2msindex.compute_range( + starting_indexes.p2msindex, + indexer_vecs.p2msindex_to_txindex.mut_vec(), + |i| (i, i), + exit, + )?; + + self.opreturnindex_to_opreturnindex.compute_range( + starting_indexes.opreturnindex, + indexer_vecs.opreturnindex_to_txindex.mut_vec(), + |i| (i, i), + exit, + )?; + + self.p2aindex_to_p2aindex.compute_range( + starting_indexes.p2aindex, + indexer_vecs.p2aindex_to_p2abytes.mut_vec(), + |i| (i, i), + exit, + )?; + + self.unknownoutputindex_to_unknownoutputindex + .compute_range( + starting_indexes.unknownoutputindex, + indexer_vecs.unknownoutputindex_to_txindex.mut_vec(), + |i| (i, i), + exit, + )?; + + // --- + // InputIndex + // --- + + self.inputindex_to_inputindex.compute_range( + starting_indexes.inputindex, + indexer_vecs.inputindex_to_outputindex.mut_vec(), + |i| (i, i), + exit, + )?; + + // --- + // TxIndex + // --- + + self.txindex_to_last_inputindex + .compute_last_index_from_first( + starting_indexes.txindex, + indexer_vecs.txindex_to_first_inputindex.mut_vec(), + inputindexes_count, + exit, + )?; + + self.txindex_to_last_outputindex + .compute_last_index_from_first( + starting_indexes.txindex, + indexer_vecs.txindex_to_first_outputindex.mut_vec(), + outputindexes_count, + exit, + )?; + + self.txindex_to_txindex.compute_range( + starting_indexes.txindex, + self.txindex_to_last_inputindex.mut_vec(), + |i| (i, i), + exit, + )?; + + self.height_to_last_txindex.compute_last_index_from_first( + starting_indexes.height, + indexer_vecs.height_to_first_txindex.mut_vec(), + txindexes_count, + exit, + )?; + + self.txindex_to_height.compute_inverse_less_to_more( + starting_indexes.height, + indexer_vecs.height_to_first_txindex.mut_vec(), + self.height_to_last_txindex.mut_vec(), + exit, + )?; + + // --- + // Height + // --- + self.height_to_height.compute_range( starting_indexes.height, indexer_vecs.height_to_timestamp.mut_vec(), @@ -457,6 +561,10 @@ impl Vecs { let decremented_starting_height = starting_indexes.height.decremented().unwrap_or_default(); + // --- + // DateIndex + // --- + let starting_dateindex = self .height_to_dateindex .unwrap_cached_get(decremented_starting_height) @@ -509,36 +617,8 @@ impl Vecs { exit, )?; - self.dateindex_to_timestamp.compute_transform( - starting_dateindex, - self.dateindex_to_date.mut_vec(), - |(di, d, ..)| (di, Timestamp::from(d)), - exit, - )?; - - self.txindex_to_last_inputindex - .compute_last_index_from_first( - starting_indexes.txindex, - indexer_vecs.txindex_to_first_inputindex.mut_vec(), - inputindexes_count, - exit, - )?; - - self.txindex_to_last_outputindex - .compute_last_index_from_first( - starting_indexes.txindex, - indexer_vecs.txindex_to_first_outputindex.mut_vec(), - outputindexes_count, - exit, - )?; - - self.height_to_last_txindex.compute_last_index_from_first( - starting_indexes.height, - indexer_vecs.height_to_first_txindex.mut_vec(), - txindexes_count, - exit, - )?; - + // --- + // WeekIndex // --- let starting_weekindex = self @@ -575,13 +655,46 @@ impl Vecs { exit, )?; - self.weekindex_to_timestamp.compute_transform( - starting_weekindex, - self.weekindex_to_first_dateindex.mut_vec(), - |(i, d, ..)| (i, self.dateindex_to_timestamp.double_unwrap_cached_get(d)), + // --- + // DifficultyEpoch + // --- + + let starting_difficultyepoch = self + .height_to_difficultyepoch + .unwrap_cached_get(decremented_starting_height) + .unwrap_or_default(); + + self.height_to_difficultyepoch.compute_range( + starting_indexes.height, + self.height_to_height.mut_vec(), + |h| (h, DifficultyEpoch::from(h)), exit, )?; + self.difficultyepoch_to_first_height + .compute_inverse_more_to_less( + starting_indexes.height, + self.height_to_difficultyepoch.mut_vec(), + exit, + )?; + + self.difficultyepoch_to_last_height + .compute_last_index_from_first( + starting_difficultyepoch, + self.difficultyepoch_to_first_height.mut_vec(), + height_count, + exit, + )?; + + self.difficultyepoch_to_difficultyepoch.compute_range( + starting_difficultyepoch, + self.difficultyepoch_to_first_height.mut_vec(), + |i| (i, i), + exit, + )?; + + // --- + // MonthIndex // --- let starting_monthindex = self @@ -620,13 +733,8 @@ impl Vecs { exit, )?; - self.monthindex_to_timestamp.compute_transform( - starting_monthindex, - self.monthindex_to_first_dateindex.mut_vec(), - |(i, d, ..)| (i, self.dateindex_to_timestamp.double_unwrap_cached_get(d)), - exit, - )?; - + // --- + // QuarterIndex // --- let starting_quarterindex = self @@ -665,13 +773,8 @@ impl Vecs { exit, )?; - self.quarterindex_to_timestamp.compute_transform( - starting_quarterindex, - self.quarterindex_to_first_monthindex.mut_vec(), - |(i, m, ..)| (i, self.monthindex_to_timestamp.double_unwrap_cached_get(m)), - exit, - )?; - + // --- + // YearIndex // --- let starting_yearindex = self @@ -710,104 +813,8 @@ impl Vecs { exit, )?; - self.yearindex_to_timestamp.compute_transform( - starting_yearindex, - self.yearindex_to_first_monthindex.mut_vec(), - |(i, m, ..)| (i, self.monthindex_to_timestamp.double_unwrap_cached_get(m)), - exit, - )?; - // --- - - let starting_decadeindex = self - .yearindex_to_decadeindex - .unwrap_cached_get(starting_yearindex) - .unwrap_or_default(); - - self.yearindex_to_decadeindex.compute_range( - starting_yearindex, - self.yearindex_to_yearindex.mut_vec(), - |i| (i, DecadeIndex::from(i)), - exit, - )?; - - self.decadeindex_to_first_yearindex - .compute_inverse_more_to_less( - starting_yearindex, - self.yearindex_to_decadeindex.mut_vec(), - exit, - )?; - - self.decadeindex_to_last_yearindex - .compute_last_index_from_first( - starting_decadeindex, - self.decadeindex_to_first_yearindex.mut_vec(), - year_count, - exit, - )?; - - self.decadeindex_to_decadeindex.compute_range( - starting_decadeindex, - self.decadeindex_to_first_yearindex.mut_vec(), - |i| (i, i), - exit, - )?; - - self.decadeindex_to_timestamp.compute_transform( - starting_decadeindex, - self.decadeindex_to_first_yearindex.mut_vec(), - |(i, y, ..)| (i, self.yearindex_to_timestamp.double_unwrap_cached_get(y)), - exit, - )?; - - // --- - - let starting_difficultyepoch = self - .height_to_difficultyepoch - .unwrap_cached_get(decremented_starting_height) - .unwrap_or_default(); - - self.height_to_difficultyepoch.compute_range( - starting_indexes.height, - self.height_to_height.mut_vec(), - |h| (h, DifficultyEpoch::from(h)), - exit, - )?; - - self.difficultyepoch_to_first_height - .compute_inverse_more_to_less( - starting_indexes.height, - self.height_to_difficultyepoch.mut_vec(), - exit, - )?; - - self.difficultyepoch_to_last_height - .compute_last_index_from_first( - starting_difficultyepoch, - self.difficultyepoch_to_first_height.mut_vec(), - height_count, - exit, - )?; - - self.difficultyepoch_to_difficultyepoch.compute_range( - starting_difficultyepoch, - self.difficultyepoch_to_first_height.mut_vec(), - |i| (i, i), - exit, - )?; - - self.difficultyepoch_to_timestamp.compute_transform( - starting_difficultyepoch, - self.difficultyepoch_to_first_height.mut_vec(), - |(i, h, ..)| { - ( - i, - indexer_vecs.height_to_timestamp.double_unwrap_cached_get(h), - ) - }, - exit, - )?; - + // HalvingEpoch // --- let starting_halvingepoch = self @@ -844,112 +851,44 @@ impl Vecs { exit, )?; - // self.difficultyepoch_to_timestamp.compute_transform( - // starting_difficultyepoch, - // self.difficultyepoch_to_first_height.mut_vec(), - // |(i, h, ..)| { - // ( - // i, - // *indexer_vecs.height_to_timestamp.unwraped_cached_get(h).unwrap().unwrap(), - // ) - // }, - // exit, - // )?; - + // --- + // DecadeIndex // --- - self.outputindex_to_outputindex.compute_range( - starting_indexes.outputindex, - indexer_vecs.outputindex_to_value.mut_vec(), - |i| (i, i), + let starting_decadeindex = self + .yearindex_to_decadeindex + .unwrap_cached_get(starting_yearindex) + .unwrap_or_default(); + + self.yearindex_to_decadeindex.compute_range( + starting_yearindex, + self.yearindex_to_yearindex.mut_vec(), + |i| (i, DecadeIndex::from(i)), exit, )?; - self.p2pk33index_to_p2pk33index.compute_range( - starting_indexes.p2pk33index, - indexer_vecs.p2pk33index_to_p2pk33bytes.mut_vec(), - |i| (i, i), - exit, - )?; - self.p2pk65index_to_p2pk65index.compute_range( - starting_indexes.p2pk65index, - indexer_vecs.p2pk65index_to_p2pk65bytes.mut_vec(), - |i| (i, i), - exit, - )?; - self.p2pkhindex_to_p2pkhindex.compute_range( - starting_indexes.p2pkhindex, - indexer_vecs.p2pkhindex_to_p2pkhbytes.mut_vec(), - |i| (i, i), - exit, - )?; - self.p2shindex_to_p2shindex.compute_range( - starting_indexes.p2shindex, - indexer_vecs.p2shindex_to_p2shbytes.mut_vec(), - |i| (i, i), - exit, - )?; - self.p2trindex_to_p2trindex.compute_range( - starting_indexes.p2trindex, - indexer_vecs.p2trindex_to_p2trbytes.mut_vec(), - |i| (i, i), - exit, - )?; - self.p2wpkhindex_to_p2wpkhindex.compute_range( - starting_indexes.p2wpkhindex, - indexer_vecs.p2wpkhindex_to_p2wpkhbytes.mut_vec(), - |i| (i, i), - exit, - )?; - self.p2wshindex_to_p2wshindex.compute_range( - starting_indexes.p2wshindex, - indexer_vecs.p2wshindex_to_p2wshbytes.mut_vec(), - |i| (i, i), - exit, - )?; - self.txindex_to_txindex.compute_range( - starting_indexes.txindex, - self.txindex_to_height.mut_vec(), - |i| (i, i), - exit, - )?; - self.inputindex_to_inputindex.compute_range( - starting_indexes.inputindex, - indexer_vecs.inputindex_to_outputindex.mut_vec(), - |i| (i, i), - exit, - )?; - self.emptyoutputindex_to_emptyoutputindex.compute_range( - starting_indexes.emptyoutputindex, - indexer_vecs.emptyoutputindex_to_txindex.mut_vec(), - |i| (i, i), - exit, - )?; - self.p2msindex_to_p2msindex.compute_range( - starting_indexes.p2msindex, - indexer_vecs.p2msindex_to_txindex.mut_vec(), - |i| (i, i), - exit, - )?; - self.opreturnindex_to_opreturnindex.compute_range( - starting_indexes.opreturnindex, - indexer_vecs.opreturnindex_to_txindex.mut_vec(), - |i| (i, i), - exit, - )?; - self.p2aindex_to_p2aindex.compute_range( - starting_indexes.p2aindex, - indexer_vecs.p2aindex_to_p2abytes.mut_vec(), - |i| (i, i), - exit, - )?; - self.unknownoutputindex_to_unknownoutputindex - .compute_range( - starting_indexes.unknownoutputindex, - indexer_vecs.unknownoutputindex_to_txindex.mut_vec(), - |i| (i, i), + + self.decadeindex_to_first_yearindex + .compute_inverse_more_to_less( + starting_yearindex, + self.yearindex_to_decadeindex.mut_vec(), exit, )?; + self.decadeindex_to_last_yearindex + .compute_last_index_from_first( + starting_decadeindex, + self.decadeindex_to_first_yearindex.mut_vec(), + year_count, + exit, + )?; + + self.decadeindex_to_decadeindex.compute_range( + starting_decadeindex, + self.decadeindex_to_first_yearindex.mut_vec(), + |i| (i, i), + exit, + )?; + Ok(Indexes { indexes: starting_indexes, dateindex: starting_dateindex, @@ -1000,19 +939,11 @@ impl Vecs { self.decadeindex_to_decadeindex.any_vec(), self.difficultyepoch_to_difficultyepoch.any_vec(), self.halvingepoch_to_halvingepoch.any_vec(), - self.dateindex_to_timestamp.any_vec(), - self.decadeindex_to_timestamp.any_vec(), - self.difficultyepoch_to_timestamp.any_vec(), - self.halvingepoch_to_timestamp.any_vec(), - self.monthindex_to_timestamp.any_vec(), - self.weekindex_to_timestamp.any_vec(), - self.yearindex_to_timestamp.any_vec(), self.height_to_timestamp_fixed.any_vec(), self.monthindex_to_quarterindex.any_vec(), self.quarterindex_to_first_monthindex.any_vec(), self.quarterindex_to_last_monthindex.any_vec(), self.quarterindex_to_quarterindex.any_vec(), - self.quarterindex_to_timestamp.any_vec(), self.p2pk33index_to_p2pk33index.any_vec(), self.p2pk65index_to_p2pk65index.any_vec(), self.p2pkhindex_to_p2pkhindex.any_vec(), diff --git a/crates/brk_computer/src/storage/vecs/mining.rs b/crates/brk_computer/src/storage/vecs/mining.rs new file mode 100644 index 000000000..f24b210bf --- /dev/null +++ b/crates/brk_computer/src/storage/vecs/mining.rs @@ -0,0 +1,122 @@ +use std::{fs, path::Path}; + +use brk_core::{DifficultyEpoch, HalvingEpoch, StoredF64}; +use brk_exit::Exit; +use brk_indexer::Indexer; +use brk_vec::{Compressed, DynamicVec, Version}; + +use super::{ + Indexes, + grouped::{ComputedVecsFromDateindex, ComputedVecsFromHeight, StorableVecGeneatorOptions}, + indexes, +}; + +#[derive(Clone)] +pub struct Vecs { + pub indexes_to_difficulty: ComputedVecsFromHeight, + pub indexes_to_difficultyepoch: ComputedVecsFromDateindex, + pub indexes_to_halvingepoch: ComputedVecsFromDateindex, +} + +impl Vecs { + pub fn forced_import(path: &Path, compressed: Compressed) -> color_eyre::Result { + fs::create_dir_all(path)?; + + Ok(Self { + indexes_to_difficulty: ComputedVecsFromHeight::forced_import( + path, + "difficulty", + false, + Version::ZERO, + compressed, + StorableVecGeneatorOptions::default().add_last(), + )?, + indexes_to_difficultyepoch: ComputedVecsFromDateindex::forced_import( + path, + "difficultyepoch", + Version::ZERO, + compressed, + StorableVecGeneatorOptions::default().add_last(), + )?, + indexes_to_halvingepoch: ComputedVecsFromDateindex::forced_import( + path, + "halvingepoch", + Version::ZERO, + compressed, + StorableVecGeneatorOptions::default().add_last(), + )?, + }) + } + + pub fn compute( + &mut self, + indexer: &mut Indexer, + indexes: &mut indexes::Vecs, + starting_indexes: &Indexes, + exit: &Exit, + ) -> color_eyre::Result<()> { + self.indexes_to_difficultyepoch.compute( + indexer, + indexes, + starting_indexes, + exit, + |vec, _, indexes, starting_indexes, exit| { + vec.compute_transform( + starting_indexes.dateindex, + indexes.dateindex_to_last_height.mut_vec(), + |(di, height, ..)| { + ( + di, + indexes + .height_to_difficultyepoch + .mut_vec() + .double_unwrap_cached_get(height), + ) + }, + exit, + ) + }, + )?; + + self.indexes_to_halvingepoch.compute( + indexer, + indexes, + starting_indexes, + exit, + |vec, _, indexes, starting_indexes, exit| { + vec.compute_transform( + starting_indexes.dateindex, + indexes.dateindex_to_last_height.mut_vec(), + |(di, height, ..)| { + ( + di, + indexes + .height_to_halvingepoch + .mut_vec() + .double_unwrap_cached_get(height), + ) + }, + exit, + ) + }, + )?; + + self.indexes_to_difficulty.compute_rest( + indexes, + starting_indexes, + exit, + Some(indexer.mut_vecs().height_to_difficulty.mut_vec()), + )?; + + Ok(()) + } + + pub fn as_any_vecs(&self) -> Vec<&dyn brk_vec::AnyStoredVec> { + [ + self.indexes_to_difficulty.any_vecs(), + self.indexes_to_difficultyepoch.any_vecs(), + self.indexes_to_halvingepoch.any_vecs(), + ] + .concat() + } +} diff --git a/crates/brk_computer/src/storage/vecs/mod.rs b/crates/brk_computer/src/storage/vecs/mod.rs index cf8b8c316..ee2284758 100644 --- a/crates/brk_computer/src/storage/vecs/mod.rs +++ b/crates/brk_computer/src/storage/vecs/mod.rs @@ -9,6 +9,7 @@ pub mod blocks; pub mod grouped; pub mod indexes; pub mod marketprice; +pub mod mining; pub mod transactions; pub mod vec; @@ -19,7 +20,8 @@ pub use vec::*; pub struct Vecs { pub blocks: blocks::Vecs, pub indexes: indexes::Vecs, - pub transactions: transactions::Vecs, + pub mining: mining::Vecs, + // pub transactions: transactions::Vecs, pub marketprice: Option, } @@ -30,7 +32,8 @@ impl Vecs { Ok(Self { blocks: blocks::Vecs::forced_import(path, compressed)?, indexes: indexes::Vecs::forced_import(path, compressed)?, - transactions: transactions::Vecs::forced_import(path, compressed, fetch)?, + mining: mining::Vecs::forced_import(path, compressed)?, + // transactions: transactions::Vecs::forced_import(path, compressed, fetch)?, marketprice: fetch.then(|| marketprice::Vecs::forced_import(path, compressed).unwrap()), }) } @@ -47,6 +50,9 @@ impl Vecs { self.blocks .compute(indexer, &mut self.indexes, &starting_indexes, exit)?; + self.mining + .compute(indexer, &mut self.indexes, &starting_indexes, exit)?; + if let Some(marketprice) = self.marketprice.as_mut() { marketprice.compute( indexer, @@ -57,13 +63,13 @@ impl Vecs { )?; } - self.transactions.compute( - indexer, - &mut self.indexes, - &starting_indexes, - &mut self.marketprice.as_mut(), - exit, - )?; + // self.transactions.compute( + // indexer, + // &mut self.indexes, + // &starting_indexes, + // &mut self.marketprice.as_mut(), + // exit, + // )?; Ok(()) } @@ -72,7 +78,8 @@ impl Vecs { [ self.indexes.as_any_vecs(), self.blocks.as_any_vecs(), - self.transactions.as_any_vecs(), + self.mining.as_any_vecs(), + // self.transactions.as_any_vecs(), self.marketprice .as_ref() .map_or(vec![], |v| v.as_any_vecs()), diff --git a/crates/brk_computer/src/storage/vecs/transactions.rs b/crates/brk_computer/src/storage/vecs/transactions.rs index 0b65785d8..a10d8bdae 100644 --- a/crates/brk_computer/src/storage/vecs/transactions.rs +++ b/crates/brk_computer/src/storage/vecs/transactions.rs @@ -25,11 +25,11 @@ pub struct Vecs { pub indexes_to_feerate: ComputedVecsFromTxindex, pub indexes_to_input_value: ComputedVecsFromTxindex, pub indexes_to_output_value: ComputedVecsFromTxindex, - // pub txindex_to_is_v1: ComputedVec, + // pub txindex_to_is_v1: LazyVec, pub indexes_to_tx_v1: ComputedVecsFromHeight, - // pub txindex_to_is_v2: ComputedVec, + // pub txindex_to_is_v2: LazyVec, pub indexes_to_tx_v2: ComputedVecsFromHeight, - // pub txindex_to_is_v3: ComputedVec, + // pub txindex_to_is_v3: LazyVec, pub indexes_to_tx_v3: ComputedVecsFromHeight, pub indexes_to_tx_vsize: ComputedVecsFromTxindex, pub indexes_to_tx_weight: ComputedVecsFromTxindex, diff --git a/crates/brk_computer/src/storage/vecs/vec/eager.rs b/crates/brk_computer/src/storage/vecs/vec/eager.rs index 2abafdca0..f64f1533d 100644 --- a/crates/brk_computer/src/storage/vecs/vec/eager.rs +++ b/crates/brk_computer/src/storage/vecs/vec/eager.rs @@ -252,7 +252,7 @@ where first_indexes.iter_from(index, |(value, first_index, ..)| { let first_index = (first_index).to_usize()?; let last_index = (last_indexes.double_unwrap_cached_get(value)).to_usize()?; - (first_index..last_index) + (first_index..=last_index) .try_for_each(|index| self.forced_push_at(I::from(index), value, exit)) })?; diff --git a/crates/brk_core/src/structs/difficultyepoch.rs b/crates/brk_core/src/structs/difficultyepoch.rs index f9520847d..fb6963392 100644 --- a/crates/brk_core/src/structs/difficultyepoch.rs +++ b/crates/brk_core/src/structs/difficultyepoch.rs @@ -1,4 +1,7 @@ -use std::{fmt::Debug, ops::Add}; +use std::{ + fmt::Debug, + ops::{Add, Div}, +}; use serde::{Deserialize, Serialize}; use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout}; @@ -43,6 +46,14 @@ impl From for usize { } } +impl Add for DifficultyEpoch { + type Output = Self; + + fn add(self, rhs: Self) -> Self::Output { + Self::from(self.0 + rhs.0) + } +} + impl Add for DifficultyEpoch { type Output = Self; @@ -51,6 +62,13 @@ impl Add for DifficultyEpoch { } } +impl Div for DifficultyEpoch { + type Output = Self; + fn div(self, rhs: usize) -> Self::Output { + Self::from(self.0 as usize / rhs) + } +} + impl From for DifficultyEpoch { fn from(value: Height) -> Self { Self((u32::from(value) / 2016) as u16) diff --git a/crates/brk_core/src/structs/halvingepoch.rs b/crates/brk_core/src/structs/halvingepoch.rs index 1c4f2ca0e..a989a4c19 100644 --- a/crates/brk_core/src/structs/halvingepoch.rs +++ b/crates/brk_core/src/structs/halvingepoch.rs @@ -1,4 +1,7 @@ -use std::{fmt::Debug, ops::Add}; +use std::{ + fmt::Debug, + ops::{Add, Div}, +}; use serde::{Deserialize, Serialize}; use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout}; @@ -43,6 +46,14 @@ impl From for usize { } } +impl Add for HalvingEpoch { + type Output = Self; + + fn add(self, rhs: Self) -> Self::Output { + Self::from(self.0 + rhs.0) + } +} + impl Add for HalvingEpoch { type Output = Self; @@ -62,3 +73,10 @@ impl CheckedSub for HalvingEpoch { self.0.checked_sub(rhs.0).map(Self) } } + +impl Div for HalvingEpoch { + type Output = Self; + fn div(self, rhs: usize) -> Self::Output { + Self::from(self.0 as usize / rhs) + } +} diff --git a/crates/brk_core/src/structs/mod.rs b/crates/brk_core/src/structs/mod.rs index 09ca3e141..e03165e23 100644 --- a/crates/brk_core/src/structs/mod.rs +++ b/crates/brk_core/src/structs/mod.rs @@ -24,6 +24,7 @@ mod outputtypeindex; mod quarterindex; mod rawlocktime; mod sats; +mod stored_f64; mod stored_u32; mod stored_u64; mod stored_u8; @@ -66,6 +67,7 @@ pub use outputtypeindex::*; pub use quarterindex::*; pub use rawlocktime::*; pub use sats::*; +pub use stored_f64::*; pub use stored_u8::*; pub use stored_u32::*; pub use stored_u64::*; diff --git a/crates/brk_core/src/structs/ohlc.rs b/crates/brk_core/src/structs/ohlc.rs index bb14126c6..e48ac4481 100644 --- a/crates/brk_core/src/structs/ohlc.rs +++ b/crates/brk_core/src/structs/ohlc.rs @@ -6,7 +6,7 @@ use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout}; use super::{Cents, Dollars, Sats}; -#[derive(Debug, Default, Clone, FromBytes, Immutable, IntoBytes, KnownLayout, Serialize)] +#[derive(Debug, Default, Clone, FromBytes, Immutable, IntoBytes, KnownLayout)] #[repr(C)] pub struct OHLCCents { pub open: Open, @@ -37,6 +37,20 @@ impl From> for OHLCCents { } } +impl Serialize for OHLCCents { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut tup = serializer.serialize_tuple(4)?; + tup.serialize_element(&self.open)?; + tup.serialize_element(&self.high)?; + tup.serialize_element(&self.low)?; + tup.serialize_element(&self.close)?; + tup.end() + } +} + #[derive(Debug, Default, Clone, FromBytes, Immutable, IntoBytes, KnownLayout)] #[repr(C)] pub struct OHLCDollars { diff --git a/crates/brk_core/src/structs/stored_f64.rs b/crates/brk_core/src/structs/stored_f64.rs new file mode 100644 index 000000000..9369b5ecb --- /dev/null +++ b/crates/brk_core/src/structs/stored_f64.rs @@ -0,0 +1,69 @@ +use std::ops::{Add, Div}; + +use derive_deref::Deref; +use serde::Serialize; +use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout}; + +use crate::CheckedSub; + +#[derive( + Debug, + Deref, + Clone, + Copy, + PartialEq, + PartialOrd, + FromBytes, + Immutable, + IntoBytes, + KnownLayout, + Serialize, +)] +pub struct StoredF64(f64); + +impl From for StoredF64 { + fn from(value: f64) -> Self { + Self(value) + } +} + +impl From for StoredF64 { + fn from(value: usize) -> Self { + Self(value as f64) + } +} + +impl CheckedSub for StoredF64 { + fn checked_sub(self, rhs: Self) -> Option { + Some(Self(self.0 - rhs.0)) + } +} + +impl Div for StoredF64 { + type Output = Self; + fn div(self, rhs: usize) -> Self::Output { + Self(self.0 / rhs as f64) + } +} + +impl Add for StoredF64 { + type Output = Self; + fn add(self, rhs: Self) -> Self::Output { + Self(self.0 + rhs.0) + } +} + +impl From for f64 { + fn from(value: StoredF64) -> Self { + value.0 + } +} + +impl Eq for StoredF64 {} + +#[allow(clippy::derive_ord_xor_partial_ord)] +impl Ord for StoredF64 { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.0.partial_cmp(&other.0).unwrap() + } +} diff --git a/crates/brk_indexer/README.md b/crates/brk_indexer/README.md index a63653b86..231d28efd 100644 --- a/crates/brk_indexer/README.md +++ b/crates/brk_indexer/README.md @@ -58,10 +58,9 @@ Stores: `src/storage/stores/mod.rs` ## Benchmark -### Result 1 - 2025-04-12 +### `v0.0.21` -- version: `v0.0.21` -- machine: `Macbook Pro M3 Pro (36GB RAM)` +- machine: `MBP M3 Pro (36GB RAM)` - mode: `raw` - from: `0` - to: `892_098` @@ -69,3 +68,10 @@ Stores: `src/storage/stores/mod.rs` - peak memory: `6.1GB` - disk usage: `270 GB` - overhead: `36%` (`270 GB / 741 GB`) + +### `v0.0.31` + +- machine: `MBP M3 Pro (36GB RAM)` +- mode: `raw` +- disk usage: `208 GB` +- overhead: `28%` (`208 GB / 744 GB`) diff --git a/crates/brk_indexer/src/lib.rs b/crates/brk_indexer/src/lib.rs index 7285336a6..596d0c516 100644 --- a/crates/brk_indexer/src/lib.rs +++ b/crates/brk_indexer/src/lib.rs @@ -32,7 +32,7 @@ pub use stores::*; pub use vecs::*; const SNAPSHOT_BLOCK_RANGE: usize = 1000; -const COLLISIONS_CHECKED_UP_TO: u32 = 0; +const COLLISIONS_CHECKED_UP_TO: u32 = 893_000; #[derive(Clone)] pub struct Indexer { @@ -166,39 +166,35 @@ impl Indexer { vecs.height_to_blockhash.push_if_needed(height, blockhash)?; vecs.height_to_difficulty - .push_if_needed(height, block.header.difficulty_float())?; + .push_if_needed(height, block.header.difficulty_float().into())?; vecs.height_to_timestamp .push_if_needed(height, Timestamp::from(block.header.time))?; vecs.height_to_total_size.push_if_needed(height, block.total_size().into())?; vecs.height_to_weight.push_if_needed(height, block.weight().into())?; - let (inputs, outputs) = thread::scope(|s| { - let inputs_handle = s.spawn(|| block - .txdata - .iter() - .enumerate() - .flat_map(|(index, tx)| { - tx.input - .iter() - .enumerate() - .map(move |(vin, txin)| (TxIndex::from(index), Vin::from(vin), txin, tx)) - }) - .collect::>()); + let inputs = block + .txdata + .iter() + .enumerate() + .flat_map(|(index, tx)| { + tx.input + .iter() + .enumerate() + .map(move |(vin, txin)| (TxIndex::from(index), Vin::from(vin), txin, tx)) + }) + .collect::>(); - let outputs_handle = s.spawn(|| block - .txdata - .iter() - .enumerate() - .flat_map(|(index, tx)| { - tx.output - .iter() - .enumerate() - .map(move |(vout, txout)| (TxIndex::from(index), Vout::from(vout), txout, tx)) - }) - .collect::>()); - - (inputs_handle.join().unwrap(), outputs_handle.join().unwrap()) - }); + let outputs = block + .txdata + .iter() + .enumerate() + .flat_map(|(index, tx)| { + tx.output + .iter() + .enumerate() + .map(move |(vout, txout)| (TxIndex::from(index), Vout::from(vout), txout, tx)) + }) + .collect::>(); let tx_len = block.txdata.len(); let outputs_len = outputs.len(); diff --git a/crates/brk_indexer/src/vecs/mod.rs b/crates/brk_indexer/src/vecs/mod.rs index 27c8ef058..38c9efe5f 100644 --- a/crates/brk_indexer/src/vecs/mod.rs +++ b/crates/brk_indexer/src/vecs/mod.rs @@ -4,8 +4,8 @@ use brk_core::{ AddressBytes, BlockHash, EmptyOutputIndex, Height, InputIndex, OpReturnIndex, OutputIndex, OutputType, OutputTypeIndex, P2ABytes, P2AIndex, P2MSIndex, P2PK33Bytes, P2PK33Index, P2PK65Bytes, P2PK65Index, P2PKHBytes, P2PKHIndex, P2SHBytes, P2SHIndex, P2TRBytes, P2TRIndex, - P2WPKHBytes, P2WPKHIndex, P2WSHBytes, P2WSHIndex, RawLockTime, Sats, StoredU32, StoredUsize, - Timestamp, TxIndex, TxVersion, Txid, UnknownOutputIndex, Weight, + P2WPKHBytes, P2WPKHIndex, P2WSHBytes, P2WSHIndex, RawLockTime, Sats, StoredF64, StoredU32, + StoredUsize, Timestamp, TxIndex, TxVersion, Txid, UnknownOutputIndex, Weight, }; use brk_vec::{AnyStoredVec, Compressed, Result, Version}; use rayon::prelude::*; @@ -20,7 +20,7 @@ pub use base::*; pub struct Vecs { pub emptyoutputindex_to_txindex: IndexedVec, pub height_to_blockhash: IndexedVec, - pub height_to_difficulty: IndexedVec, + pub height_to_difficulty: IndexedVec, pub height_to_first_emptyoutputindex: IndexedVec, pub height_to_first_inputindex: IndexedVec, pub height_to_first_opreturnindex: IndexedVec, diff --git a/crates/brk_parser/examples/p2a.rs b/crates/brk_parser/examples/p2a.rs new file mode 100644 index 000000000..c858c7800 --- /dev/null +++ b/crates/brk_parser/examples/p2a.rs @@ -0,0 +1,69 @@ +use bitcoincore_rpc::{Auth, Client}; +use brk_core::{Height, OutputType, default_bitcoin_path}; +use brk_parser::Parser; + +fn main() { + let i = std::time::Instant::now(); + + let bitcoin_dir = default_bitcoin_path(); + + let rpc = Box::leak(Box::new( + Client::new( + "http://localhost:8332", + Auth::CookieFile(bitcoin_dir.join(".cookie")), + ) + .unwrap(), + )); + + // let start = None; + // let end = None; + + let parser = Parser::new(bitcoin_dir.join("blocks"), rpc); + + // parser + // .parse(start, end) + // .iter() + // .for_each(|(height, _block, hash)| { + // println!("{height}: {hash}"); + // }); + + // println!( + // "{}", + // parser + // .get(Height::new(0)) + // .txdata + // .first() + // .unwrap() + // .output + // .first() + // .unwrap() + // .script_pubkey + // ); + + let block_850_000 = parser.get(Height::new(850_000)); + + let tx = block_850_000.txdata.iter().find(|tx| { + tx.compute_txid().to_string() + == "b10c0000004da5a9d1d9b4ae32e09f0b3e62d21a5cce5428d4ad714fb444eb5d" + }); + + let output = tx.unwrap().tx_out(7).unwrap(); + + dbg!(OutputType::from(&output.script_pubkey)); + + dbg!(output); + + // println!( + // "{}", + + // .txdata + // .first() + // .unwrap() + // .output + // .first() + // .unwrap() + // .value + // ); + + dbg!(i.elapsed()); +} diff --git a/crates/brk_query/src/index.rs b/crates/brk_query/src/index.rs index fe823c686..7380b2b23 100644 --- a/crates/brk_query/src/index.rs +++ b/crates/brk_query/src/index.rs @@ -4,92 +4,89 @@ use color_eyre::eyre::eyre; #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] pub enum Index { - Addressindex, - Dateindex, + DateIndex, + DecadeIndex, + DifficultyEpoch, + EmptyOutputIndex, + HalvingEpoch, Height, - P2PK33index, - P2PK65index, - P2PKHindex, - P2SHindex, - P2TRindex, - P2WPKHindex, - P2WSHindex, - Txindex, - Inputindex, - Outputindex, - Weekindex, - Monthindex, - Quarterindex, - Yearindex, - Decadeindex, - Difficultyepoch, - Halvingepoch, - Emptyindex, - P2MSindex, - Opreturnindex, - Pushonlyindex, - Unknownindex, + InputIndex, + MonthIndex, + OpReturnIndex, + OutputIndex, + P2AIndex, + P2MSIndex, + P2PK33Index, + P2PK65Index, + P2PKHIndex, + P2SHIndex, + P2TRIndex, + P2WPKHIndex, + P2WSHIndex, + QuarterIndex, + TxIndex, + UnknownOutputIndex, + WeekIndex, + YearIndex, } impl Index { - pub fn all() -> [Self; 25] { + pub fn all() -> [Self; 24] { [ + Self::DateIndex, + Self::DecadeIndex, + Self::DifficultyEpoch, + Self::EmptyOutputIndex, + Self::HalvingEpoch, Self::Height, - Self::Dateindex, - Self::Weekindex, - Self::Difficultyepoch, - Self::Monthindex, - Self::Quarterindex, - Self::Yearindex, - Self::Decadeindex, - Self::Halvingepoch, - Self::Addressindex, - Self::P2PK33index, - Self::P2PK65index, - Self::P2PKHindex, - Self::P2SHindex, - Self::P2TRindex, - Self::P2WPKHindex, - Self::P2WSHindex, - Self::Txindex, - Self::Inputindex, - Self::Outputindex, - Self::Emptyindex, - Self::P2MSindex, - Self::Opreturnindex, - Self::Pushonlyindex, - Self::Unknownindex, + Self::InputIndex, + Self::MonthIndex, + Self::OpReturnIndex, + Self::OutputIndex, + Self::P2AIndex, + Self::P2MSIndex, + Self::P2PK33Index, + Self::P2PK65Index, + Self::P2PKHIndex, + Self::P2SHIndex, + Self::P2TRIndex, + Self::P2WPKHIndex, + Self::P2WSHIndex, + Self::QuarterIndex, + Self::TxIndex, + Self::UnknownOutputIndex, + Self::WeekIndex, + Self::YearIndex, ] } pub fn possible_values(&self) -> &[&str] { // Always have the "correct" id at the end match self { + Self::DateIndex => &["d", "date", "dateindex"], + Self::DecadeIndex => &["decade", "decadeindex"], + Self::DifficultyEpoch => &["difficulty", "difficultyepoch"], + Self::EmptyOutputIndex => &["empty", "emptyoutputindex"], + Self::HalvingEpoch => &["h", "halving", "halvingepoch"], Self::Height => &["h", "height"], - Self::Dateindex => &["d", "date", "dateindex"], - Self::Weekindex => &["w", "week", "weekindex"], - Self::Difficultyepoch => &["difficulty", "difficultyepoch"], - Self::Monthindex => &["m", "month", "monthindex"], - Self::Quarterindex => &["q", "quarter", "quarterindex"], - Self::Yearindex => &["y", "year", "yearindex"], - Self::Decadeindex => &["decade", "decadeindex"], - Self::Halvingepoch => &["h", "halving", "halvingepoch"], - Self::Txindex => &["tx", "txindex"], - Self::Inputindex => &["txin", "inputindex"], - Self::Outputindex => &["txout", "outputindex"], - Self::Addressindex => &["a", "address", "addressindex"], - Self::P2PK33index => &["p2pk33", "p2pk33index"], - Self::P2PK65index => &["p2pk65", "p2pk65index"], - Self::P2PKHindex => &["p2pkh", "p2pkhindex"], - Self::P2SHindex => &["p2sh", "p2shindex"], - Self::P2TRindex => &["p2tr", "p2trindex"], - Self::P2WPKHindex => &["p2wpkh", "p2wpkhindex"], - Self::P2WSHindex => &["p2wsh", "p2wshindex"], - Self::Emptyindex => &["empty", "emptyoutputindex"], - Self::P2MSindex => &["multisig", "p2msindex"], - Self::Opreturnindex => &["opreturn", "opreturnindex"], - Self::Pushonlyindex => &["pushonly", "pushonlyindex"], - Self::Unknownindex => &["unknown", "unknownoutputindex"], + Self::InputIndex => &["txin", "inputindex"], + Self::MonthIndex => &["m", "month", "monthindex"], + Self::OpReturnIndex => &["opreturn", "opreturnindex"], + Self::OutputIndex => &["txout", "outputindex"], + Self::P2AIndex => &["p2a", "p2aindex"], + Self::P2MSIndex => &["p2ms", "p2msindex"], + Self::P2PK33Index => &["p2pk33", "p2pk33index"], + Self::P2PK65Index => &["p2pk65", "p2pk65index"], + Self::P2PKHIndex => &["p2pkh", "p2pkhindex"], + Self::P2SHIndex => &["p2sh", "p2shindex"], + Self::P2TRIndex => &["p2tr", "p2trindex"], + Self::P2WPKHIndex => &["p2wpkh", "p2wpkhindex"], + Self::P2WSHIndex => &["p2wsh", "p2wshindex"], + Self::QuarterIndex => &["q", "quarter", "quarterindex"], + Self::TxIndex => &["tx", "txindex"], + Self::UnknownOutputIndex => &["unknown", "unknownoutputindex"], + Self::WeekIndex => &["w", "week", "weekindex"], + Self::YearIndex => &["y", "year", "yearindex"], } } @@ -117,32 +114,33 @@ impl TryFrom<&str> for Index { type Error = color_eyre::Report; fn try_from(value: &str) -> Result { Ok(match value.to_lowercase().as_str() { - v if (Self::Dateindex).possible_values().contains(&v) => Self::Dateindex, + v if (Self::DateIndex).possible_values().contains(&v) => Self::DateIndex, + v if (Self::DecadeIndex).possible_values().contains(&v) => Self::DecadeIndex, + v if (Self::DifficultyEpoch).possible_values().contains(&v) => Self::DifficultyEpoch, + v if (Self::EmptyOutputIndex).possible_values().contains(&v) => Self::EmptyOutputIndex, + v if (Self::HalvingEpoch).possible_values().contains(&v) => Self::HalvingEpoch, v if (Self::Height).possible_values().contains(&v) => Self::Height, - v if (Self::Txindex).possible_values().contains(&v) => Self::Txindex, - v if (Self::Inputindex).possible_values().contains(&v) => Self::Inputindex, - v if (Self::Outputindex).possible_values().contains(&v) => Self::Outputindex, - v if (Self::Addressindex).possible_values().contains(&v) => Self::Addressindex, - v if (Self::P2PK33index).possible_values().contains(&v) => Self::P2PK33index, - v if (Self::P2PK65index).possible_values().contains(&v) => Self::P2PK65index, - v if (Self::P2PKHindex).possible_values().contains(&v) => Self::P2PKHindex, - v if (Self::P2SHindex).possible_values().contains(&v) => Self::P2SHindex, - v if (Self::P2TRindex).possible_values().contains(&v) => Self::P2TRindex, - v if (Self::P2WPKHindex).possible_values().contains(&v) => Self::P2WPKHindex, - v if (Self::P2WSHindex).possible_values().contains(&v) => Self::P2WSHindex, - v if (Self::Weekindex).possible_values().contains(&v) => Self::Weekindex, - v if (Self::Monthindex).possible_values().contains(&v) => Self::Monthindex, - v if (Self::Yearindex).possible_values().contains(&v) => Self::Yearindex, - v if (Self::Decadeindex).possible_values().contains(&v) => Self::Decadeindex, - v if (Self::Difficultyepoch).possible_values().contains(&v) => Self::Difficultyepoch, - v if (Self::Halvingepoch).possible_values().contains(&v) => Self::Halvingepoch, - v if (Self::Quarterindex).possible_values().contains(&v) => Self::Quarterindex, - v if (Self::Quarterindex).possible_values().contains(&v) => Self::Quarterindex, - v if (Self::Emptyindex).possible_values().contains(&v) => Self::Emptyindex, - v if (Self::P2MSindex).possible_values().contains(&v) => Self::P2MSindex, - v if (Self::Opreturnindex).possible_values().contains(&v) => Self::Opreturnindex, - v if (Self::Pushonlyindex).possible_values().contains(&v) => Self::Pushonlyindex, - v if (Self::Unknownindex).possible_values().contains(&v) => Self::Unknownindex, + v if (Self::InputIndex).possible_values().contains(&v) => Self::InputIndex, + v if (Self::MonthIndex).possible_values().contains(&v) => Self::MonthIndex, + v if (Self::OpReturnIndex).possible_values().contains(&v) => Self::OpReturnIndex, + v if (Self::OutputIndex).possible_values().contains(&v) => Self::OutputIndex, + v if (Self::P2AIndex).possible_values().contains(&v) => Self::P2AIndex, + v if (Self::P2MSIndex).possible_values().contains(&v) => Self::P2MSIndex, + v if (Self::P2PK33Index).possible_values().contains(&v) => Self::P2PK33Index, + v if (Self::P2PK65Index).possible_values().contains(&v) => Self::P2PK65Index, + v if (Self::P2PKHIndex).possible_values().contains(&v) => Self::P2PKHIndex, + v if (Self::P2SHIndex).possible_values().contains(&v) => Self::P2SHIndex, + v if (Self::P2TRIndex).possible_values().contains(&v) => Self::P2TRIndex, + v if (Self::P2WPKHIndex).possible_values().contains(&v) => Self::P2WPKHIndex, + v if (Self::P2WSHIndex).possible_values().contains(&v) => Self::P2WSHIndex, + v if (Self::QuarterIndex).possible_values().contains(&v) => Self::QuarterIndex, + v if (Self::QuarterIndex).possible_values().contains(&v) => Self::QuarterIndex, + v if (Self::TxIndex).possible_values().contains(&v) => Self::TxIndex, + v if (Self::WeekIndex).possible_values().contains(&v) => Self::WeekIndex, + v if (Self::YearIndex).possible_values().contains(&v) => Self::YearIndex, + v if (Self::UnknownOutputIndex).possible_values().contains(&v) => { + Self::UnknownOutputIndex + } _ => return Err(eyre!("Bad index")), }) } diff --git a/websites/kibo.money/packages/lightweight-charts/v5.0.6-treeshaked/script.js b/websites/kibo.money/packages/lightweight-charts/v5.0.6-treeshaked/script.js new file mode 100644 index 000000000..d50964a27 --- /dev/null +++ b/websites/kibo.money/packages/lightweight-charts/v5.0.6-treeshaked/script.js @@ -0,0 +1,8 @@ +// @ts-nocheck +/*! + * @license + * TradingView Lightweight Charts™ v5.0.6-dev+202504261520 + * Copyright (c) 2025 TradingView, Inc. + * Licensed under Apache License 2.0 https://www.apache.org/licenses/LICENSE-2.0 + */ +const t={title:"",visible:!0,lastValueVisible:!0,priceLineVisible:!0,priceLineSource:0,priceLineWidth:1,priceLineColor:"",priceLineStyle:2,baseLineVisible:!0,baseLineWidth:1,baseLineColor:"#B2B5BE",baseLineStyle:0,priceFormat:{type:"price",precision:2,minMove:.01}};var i,s;function n(t,i){const s={0:[],1:[t.lineWidth,t.lineWidth],2:[2*t.lineWidth,2*t.lineWidth],3:[6*t.lineWidth,6*t.lineWidth],4:[t.lineWidth,4*t.lineWidth]}[i];t.setLineDash(s)}function e(t,i,s,n){t.beginPath();const e=t.lineWidth%2?.5:0;t.moveTo(s,i+e),t.lineTo(n,i+e),t.stroke()}function r(t,i){if(!t)throw new Error("Assertion failed"+(i?": "+i:""))}function h(t){if(void 0===t)throw new Error("Value is undefined");return t}function l(t){if(null===t)throw new Error("Value is null");return t}function a(t){return l(h(t))}!function(t){t[t.Simple=0]="Simple",t[t.WithSteps=1]="WithSteps",t[t.Curved=2]="Curved"}(i||(i={})),function(t){t[t.Solid=0]="Solid",t[t.Dotted=1]="Dotted",t[t.Dashed=2]="Dashed",t[t.LargeDashed=3]="LargeDashed",t[t.SparseDotted=4]="SparseDotted"}(s||(s={}));class o{constructor(){this.t=[]}i(t,i,s){const n={h:t,l:i,o:!0===s};this.t.push(n)}_(t){const i=this.t.findIndex((i=>t===i.h));i>-1&&this.t.splice(i,1)}u(t){this.t=this.t.filter((i=>i.l!==t))}p(t,i,s){const n=[...this.t];this.t=this.t.filter((t=>!t.o)),n.forEach((n=>n.h(t,i,s)))}v(){return this.t.length>0}m(){this.t=[]}}function _(t,...i){for(const s of i)for(const i in s)void 0!==s[i]&&Object.prototype.hasOwnProperty.call(s,i)&&!["__proto__","constructor","prototype"].includes(i)&&("object"!=typeof s[i]||void 0===t[i]||Array.isArray(s[i])?t[i]=s[i]:_(t[i],s[i]));return t}function u(t){return"number"==typeof t&&isFinite(t)}function c(t){return"number"==typeof t&&t%1==0}function d(t){return"string"==typeof t}function f(t){return"boolean"==typeof t}function p(t){const i=t;if(!i||"object"!=typeof i)return i;let s,n,e;for(n in s=Array.isArray(i)?[]:{},i)i.hasOwnProperty(n)&&(e=i[n],s[n]=e&&"object"==typeof e?p(e):e);return s}function v(t){return null!==t}function m(t){return null===t?void 0:t}const w="-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif";function g(t,i,s){return void 0===i&&(i=w),`${s=void 0!==s?`${s} `:""}${t}px ${i}`}class b{constructor(t){this.M={S:1,P:5,C:NaN,T:"",k:"",R:"",D:"",V:0,I:0,A:0,B:0,L:0},this.O=t}N(){const t=this.M,i=this.F(),s=this.W();return t.C===i&&t.k===s||(t.C=i,t.k=s,t.T=g(i,s),t.B=2.5/12*i,t.V=t.B,t.I=i/12*t.P,t.A=i/12*t.P,t.L=0),t.R=this.H(),t.D=this.$(),this.M}H(){return this.O.N().layout.textColor}$(){return this.O.U()}F(){return this.O.N().layout.fontSize}W(){return this.O.N().layout.fontFamily}}function M(t){return t<0?0:t>255?255:Math.round(t)||0}function S(t){return.199*t[0]+.687*t[1]+.114*t[2]}class x{constructor(t,i){this.j=new Map,this.Y=t,i&&(this.j=i)}X(t,i){if("transparent"===t)return t;const s=this.Z(t),n=s[3];return`rgba(${s[0]}, ${s[1]}, ${s[2]}, ${i*n})`}q(t){const i=this.Z(t);return{K:`rgb(${i[0]}, ${i[1]}, ${i[2]})`,G:S(i)>160?"black":"white"}}J(t){return S(this.Z(t))}tt(t,i,s){const[n,e,r,h]=this.Z(t),[l,a,o,_]=this.Z(i),u=[M(n+s*(l-n)),M(e+s*(a-e)),M(r+s*(o-r)),(c=h+s*(_-h),c<=0||c>1?Math.min(Math.max(c,0),1):Math.round(1e4*c)/1e4)];var c;return`rgba(${u[0]}, ${u[1]}, ${u[2]}, ${u[3]})`}Z(t){const i=this.j.get(t);if(i)return i;const s=function(t){const i=document.createElement("div");i.style.display="none",document.body.appendChild(i),i.style.color=t;const s=window.getComputedStyle(i).color;return document.body.removeChild(i),s}(t),n=s.match(/^rgba?\s*\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d+))?\)$/);if(!n){if(this.Y.length)for(const i of this.Y){const s=i(t);if(s)return this.j.set(t,s),s}throw new Error(`Failed to parse color: ${t}`)}const e=[parseInt(n[1],10),parseInt(n[2],10),parseInt(n[3],10),n[4]?parseFloat(n[4]):1];return this.j.set(t,e),e}}class y{constructor(){this.it=[]}st(t){this.it=t}nt(t,i,s){this.it.forEach((n=>{n.nt(t,i,s)}))}}class P{nt(t,i,s){t.useBitmapCoordinateSpace((t=>this.et(t,i,s)))}}class C extends P{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){if(null===this.rt||null===this.rt.lt)return;const n=this.rt.lt,e=this.rt,r=Math.max(1,Math.floor(i))%2/2,h=h=>{t.beginPath();for(let l=n.to-1;l>=n.from;--l){const n=e.ot[l],a=Math.round(n._t*i)+r,o=n.ut*s,_=h*s+r;t.moveTo(a,o),t.arc(a,o,_,0,2*Math.PI)}t.fill()};e.ct>0&&(t.fillStyle=e.dt,h(e.ft+e.ct)),t.fillStyle=e.vt,h(e.ft)}}function T(){return{ot:[{_t:0,ut:0,wt:0,gt:0}],vt:"",dt:"",ft:0,ct:0,lt:null}}const k={from:0,to:1};class R{constructor(t,i,s){this.bt=new y,this.Mt=[],this.St=[],this.xt=!0,this.O=t,this.yt=i,this.Pt=s,this.bt.st(this.Mt)}Ct(t){this.Tt(),this.xt=!0}kt(){return this.xt&&(this.Rt(),this.xt=!1),this.bt}Tt(){const t=this.Pt.Dt();t.length!==this.Mt.length&&(this.St=t.map(T),this.Mt=this.St.map((t=>{const i=new C;return i.ht(t),i})),this.bt.st(this.Mt))}Rt(){const t=2===this.yt.N().mode||!this.yt.Et(),i=this.Pt.zt(),s=this.yt.Vt(),n=this.O.It();this.Tt(),i.forEach(((i,e)=>{const r=this.St[e],h=i.At(s),l=i.Bt();!t&&null!==h&&i.Et()&&null!==l?(r.vt=h.Lt,r.ft=h.ft,r.ct=h.Ot,r.ot[0].gt=h.gt,r.ot[0].ut=i.Ft().Nt(h.gt,l.Wt),r.dt=h.Ht??this.O.$t(r.ot[0].ut/i.Ft().Ut()),r.ot[0].wt=s,r.ot[0]._t=n.jt(s),r.lt=k):r.lt=null}))}}class D extends P{constructor(t){super(),this.Yt=t}et({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:r}){if(null===this.Yt)return;const h=this.Yt.Xt.Et,l=this.Yt.Zt.Et;if(!h&&!l)return;const a=Math.round(this.Yt._t*s),o=Math.round(this.Yt.ut*r);t.lineCap="butt",h&&a>=0&&(t.lineWidth=Math.floor(this.Yt.Xt.ct*s),t.strokeStyle=this.Yt.Xt.R,t.fillStyle=this.Yt.Xt.R,n(t,this.Yt.Xt.qt),function(t,i,s,n){t.beginPath();const e=t.lineWidth%2?.5:0;t.moveTo(i+e,s),t.lineTo(i+e,n),t.stroke()}(t,a,0,i.height)),l&&o>=0&&(t.lineWidth=Math.floor(this.Yt.Zt.ct*r),t.strokeStyle=this.Yt.Zt.R,t.fillStyle=this.Yt.Zt.R,n(t,this.Yt.Zt.qt),e(t,o,0,i.width))}}class E{constructor(t,i){this.xt=!0,this.Kt={Xt:{ct:1,qt:0,R:"",Et:!1},Zt:{ct:1,qt:0,R:"",Et:!1},_t:0,ut:0},this.Gt=new D(this.Kt),this.Jt=t,this.Pt=i}Ct(){this.xt=!0}kt(t){return this.xt&&(this.Rt(),this.xt=!1),this.Gt}Rt(){const t=this.Jt.Et(),i=this.Pt.Qt().N().crosshair,s=this.Kt;if(2===i.mode)return s.Zt.Et=!1,void(s.Xt.Et=!1);s.Zt.Et=t&&this.Jt.ti(this.Pt),s.Xt.Et=t&&this.Jt.ii(),s.Zt.ct=i.horzLine.width,s.Zt.qt=i.horzLine.style,s.Zt.R=i.horzLine.color,s.Xt.ct=i.vertLine.width,s.Xt.qt=i.vertLine.style,s.Xt.R=i.vertLine.color,s._t=this.Jt.si(),s.ut=this.Jt.ni()}}function z(t,i,s,n,e,r){t.fillRect(i+r,s,n-2*r,r),t.fillRect(i+r,s+e-r,n-2*r,r),t.fillRect(i,s,r,e),t.fillRect(i+n-r,s,r,e)}function V(t,i,s,n,e,r){t.save(),t.globalCompositeOperation="copy",t.fillStyle=r,t.fillRect(i,s,n,e),t.restore()}function I(t,i,s,n,e,r){t.beginPath(),t.roundRect?t.roundRect(i,s,n,e,r):(t.lineTo(i+n-r[1],s),0!==r[1]&&t.arcTo(i+n,s,i+n,s+r[1],r[1]),t.lineTo(i+n,s+e-r[2]),0!==r[2]&&t.arcTo(i+n,s+e,i+n-r[2],s+e,r[2]),t.lineTo(i+r[3],s+e),0!==r[3]&&t.arcTo(i,s+e,i,s+e-r[3],r[3]),t.lineTo(i,s+r[0]),0!==r[0]&&t.arcTo(i,s,i+r[0],s,r[0]))}function A(t,i,s,n,e,r,h=0,l=[0,0,0,0],a=""){if(t.save(),!h||!a||a===r)return I(t,i,s,n,e,l),t.fillStyle=r,t.fill(),void t.restore();const o=h/2;var _;I(t,i+o,s+o,n-h,e-h,(_=-o,l.map((t=>0===t?t:t+_)))),"transparent"!==r&&(t.fillStyle=r,t.fill()),"transparent"!==a&&(t.lineWidth=h,t.strokeStyle=a,t.closePath(),t.stroke()),t.restore()}function B(t,i,s,n,e,r,h){t.save(),t.globalCompositeOperation="copy";const l=t.createLinearGradient(0,0,0,e);l.addColorStop(0,r),l.addColorStop(1,h),t.fillStyle=l,t.fillRect(i,s,n,e),t.restore()}class L{constructor(t,i){this.ht(t,i)}ht(t,i){this.Yt=t,this.ei=i}Ut(t,i){return this.Yt.Et?t.C+t.B+t.V:0}nt(t,i,s,n){if(!this.Yt.Et||0===this.Yt.ri.length)return;const e=this.Yt.R,r=this.ei.K,h=t.useBitmapCoordinateSpace((t=>{const h=t.context;h.font=i.T;const l=this.hi(t,i,s,n),a=l.li;return l.ai?A(h,a.oi,a._i,a.ui,a.ci,r,a.di,[a.ft,0,0,a.ft],r):A(h,a.fi,a._i,a.ui,a.ci,r,a.di,[0,a.ft,a.ft,0],r),this.Yt.pi&&(h.fillStyle=e,h.fillRect(a.fi,a.mi,a.wi-a.fi,a.gi)),this.Yt.bi&&(h.fillStyle=i.D,h.fillRect(l.ai?a.Mi-a.di:0,a._i,a.di,a.Si-a._i)),l}));t.useMediaCoordinateSpace((({context:t})=>{const s=h.xi;t.font=i.T,t.textAlign=h.ai?"right":"left",t.textBaseline="middle",t.fillStyle=e,t.fillText(this.Yt.ri,s.yi,(s._i+s.Si)/2+s.Pi)}))}hi(t,i,s,n){const{context:e,bitmapSize:r,mediaSize:h,horizontalPixelRatio:l,verticalPixelRatio:a}=t,o=this.Yt.pi||!this.Yt.Ci?i.P:0,_=this.Yt.Ti?i.S:0,u=i.B+this.ei.ki,c=i.V+this.ei.Ri,d=i.I,f=i.A,p=this.Yt.ri,v=i.C,m=s.Di(e,p),w=Math.ceil(s.Ei(e,p)),g=v+u+c,b=i.S+d+f+w+o,M=Math.max(1,Math.floor(a));let S=Math.round(g*a);S%2!=M%2&&(S+=1);const x=_>0?Math.max(1,Math.floor(_*l)):0,y=Math.round(b*l),P=Math.round(o*l),C=this.ei.zi??this.ei.Vi,T=Math.round(C*a)-Math.floor(.5*a),k=Math.floor(T+M/2-S/2),R=k+S,D="right"===n,E=D?h.width-_:_,z=D?r.width-x:x;let V,I,A;return D?(V=z-y,I=z-P,A=E-o-d-_):(V=z+y,I=z+P,A=E+o+d),{ai:D,li:{_i:k,mi:T,Si:R,ui:y,ci:S,ft:2*l,di:x,oi:V,fi:z,wi:I,gi:M,Mi:r.width},xi:{_i:k/a,Si:R/a,yi:A,Pi:m}}}}class O{constructor(t){this.Ii={Vi:0,K:"#000",Ri:0,ki:0},this.Ai={ri:"",Et:!1,pi:!0,Ci:!1,Ht:"",R:"#FFF",bi:!1,Ti:!1},this.Bi={ri:"",Et:!1,pi:!1,Ci:!0,Ht:"",R:"#FFF",bi:!0,Ti:!0},this.xt=!0,this.Li=new(t||L)(this.Ai,this.Ii),this.Oi=new(t||L)(this.Bi,this.Ii)}ri(){return this.Ni(),this.Ai.ri}Vi(){return this.Ni(),this.Ii.Vi}Ct(){this.xt=!0}Ut(t,i=!1){return Math.max(this.Li.Ut(t,i),this.Oi.Ut(t,i))}Fi(){return this.Ii.zi||0}Wi(t){this.Ii.zi=t}Hi(){return this.Ni(),this.Ai.Et||this.Bi.Et}$i(){return this.Ni(),this.Ai.Et}kt(t){return this.Ni(),this.Ai.pi=this.Ai.pi&&t.N().ticksVisible,this.Bi.pi=this.Bi.pi&&t.N().ticksVisible,this.Li.ht(this.Ai,this.Ii),this.Oi.ht(this.Bi,this.Ii),this.Li}Ui(){return this.Ni(),this.Li.ht(this.Ai,this.Ii),this.Oi.ht(this.Bi,this.Ii),this.Oi}Ni(){this.xt&&(this.Ai.pi=!0,this.Bi.pi=!1,this.ji(this.Ai,this.Bi,this.Ii))}}class N extends O{constructor(t,i,s){super(),this.Jt=t,this.Yi=i,this.Xi=s}ji(t,i,s){if(t.Et=!1,2===this.Jt.N().mode)return;const n=this.Jt.N().horzLine;if(!n.labelVisible)return;const e=this.Yi.Bt();if(!this.Jt.Et()||this.Yi.Zi()||null===e)return;const r=this.Yi.qi().q(n.labelBackgroundColor);s.K=r.K,t.R=r.G;const h=2/12*this.Yi.C();s.ki=h,s.Ri=h;const l=this.Xi(this.Yi);s.Vi=l.Vi,t.ri=this.Yi.Ki(l.gt,e),t.Et=!0}}const F=/[1-9]/g;class W{constructor(){this.Yt=null}ht(t){this.Yt=t}nt(t,i){if(null===this.Yt||!1===this.Yt.Et||0===this.Yt.ri.length)return;const s=t.useMediaCoordinateSpace((({context:t})=>(t.font=i.T,Math.round(i.Gi.Ei(t,l(this.Yt).ri,F)))));if(s<=0)return;const n=i.Ji,e=s+2*n,r=e/2,h=this.Yt.Qi;let a=this.Yt.Vi,o=Math.floor(a-r)+.5;o<0?(a+=Math.abs(0-o),o=Math.floor(a-r)+.5):o+e>h&&(a-=Math.abs(h-(o+e)),o=Math.floor(a-r)+.5);const _=o+e,u=Math.ceil(0+i.S+i.P+i.B+i.C+i.V);t.useBitmapCoordinateSpace((({context:t,horizontalPixelRatio:s,verticalPixelRatio:n})=>{const e=l(this.Yt);t.fillStyle=e.K;const r=Math.round(o*s),h=Math.round(0*n),a=Math.round(_*s),c=Math.round(u*n),d=Math.round(2*s);if(t.beginPath(),t.moveTo(r,h),t.lineTo(r,c-d),t.arcTo(r,c,r+d,c,d),t.lineTo(a-d,c),t.arcTo(a,c,a,c-d,d),t.lineTo(a,h),t.fill(),e.pi){const r=Math.round(e.Vi*s),l=h,a=Math.round((l+i.P)*n);t.fillStyle=e.R;const o=Math.max(1,Math.floor(s)),_=Math.floor(.5*s);t.fillRect(r-_,l,o,a-l)}})),t.useMediaCoordinateSpace((({context:t})=>{const s=l(this.Yt),e=0+i.S+i.P+i.B+i.C/2;t.font=i.T,t.textAlign="left",t.textBaseline="middle",t.fillStyle=s.R;const r=i.Gi.Di(t,"Apr0");t.translate(o+n,e+r),t.fillText(s.ri,0,0)}))}}class H{constructor(t,i,s){this.xt=!0,this.Gt=new W,this.Kt={Et:!1,K:"#4c525e",R:"white",ri:"",Qi:0,Vi:NaN,pi:!0},this.yt=t,this.ts=i,this.Xi=s}Ct(){this.xt=!0}kt(){return this.xt&&(this.Rt(),this.xt=!1),this.Gt.ht(this.Kt),this.Gt}Rt(){const t=this.Kt;if(t.Et=!1,2===this.yt.N().mode)return;const i=this.yt.N().vertLine;if(!i.labelVisible)return;const s=this.ts.It();if(s.Zi())return;t.Qi=s.Qi();const n=this.Xi();if(null===n)return;t.Vi=n.Vi;const e=s.ss(this.yt.Vt());t.ri=s.ns(l(e)),t.Et=!0;const r=this.ts.qi().q(i.labelBackgroundColor);t.K=r.K,t.R=r.G,t.pi=s.N().ticksVisible}}class ${constructor(){this.es=null,this.rs=0}hs(){return this.rs}ls(t){this.rs=t}Ft(){return this.es}os(t){this.es=t}_s(t){return[]}us(){return[]}Et(){return!0}}var U;!function(t){t[t.Normal=0]="Normal",t[t.Magnet=1]="Magnet",t[t.Hidden=2]="Hidden",t[t.MagnetOHLC=3]="MagnetOHLC"}(U||(U={}));class j extends ${constructor(t,i){super(),this.Pt=null,this.cs=NaN,this.ds=0,this.fs=!1,this.ps=new Map,this.vs=!1,this.ws=new WeakMap,this.gs=new WeakMap,this.bs=NaN,this.Ms=NaN,this.Ss=NaN,this.xs=NaN,this.ts=t,this.ys=i;this.Ps=((t,i)=>s=>{const n=i(),e=t();if(s===l(this.Pt).Cs())return{gt:e,Vi:n};{const t=l(s.Bt());return{gt:s.Ts(n,t),Vi:n}}})((()=>this.cs),(()=>this.Ms));const s=((t,i)=>()=>{const s=this.ts.It().ks(t()),n=i();return s&&Number.isFinite(n)?{wt:s,Vi:n}:null})((()=>this.ds),(()=>this.si()));this.Rs=new H(this,t,s)}N(){return this.ys}Ds(t,i){this.Ss=t,this.xs=i}Es(){this.Ss=NaN,this.xs=NaN}zs(){return this.Ss}Vs(){return this.xs}Is(t,i,s){this.vs||(this.vs=!0),this.fs=!0,this.As(t,i,s)}Vt(){return this.ds}si(){return this.bs}ni(){return this.Ms}Et(){return this.fs}Bs(){this.fs=!1,this.Ls(),this.cs=NaN,this.bs=NaN,this.Ms=NaN,this.Pt=null,this.Es(),this.Os()}Ns(t){let i=this.ws.get(t);i||(i=new E(this,t),this.ws.set(t,i));let s=this.gs.get(t);return s||(s=new R(this.ts,this,t),this.gs.set(t,s)),[i,s]}ti(t){return t===this.Pt&&this.ys.horzLine.visible}ii(){return this.ys.vertLine.visible}Fs(t,i){this.fs&&this.Pt===t||this.ps.clear();const s=[];return this.Pt===t&&s.push(this.Ws(this.ps,i,this.Ps)),s}us(){return this.fs?[this.Rs]:[]}Hs(){return this.Pt}Os(){this.ts.$s().forEach((t=>{this.ws.get(t)?.Ct(),this.gs.get(t)?.Ct()})),this.ps.forEach((t=>t.Ct())),this.Rs.Ct()}Us(t){return t&&!t.Cs().Zi()?t.Cs():null}As(t,i,s){this.js(t,i,s)&&this.Os()}js(t,i,s){const n=this.bs,e=this.Ms,r=this.cs,h=this.ds,l=this.Pt,a=this.Us(s);this.ds=t,this.bs=isNaN(t)?NaN:this.ts.It().jt(t),this.Pt=s;const o=null!==a?a.Bt():null;return null!==a&&null!==o?(this.cs=i,this.Ms=a.Nt(i,o)):(this.cs=NaN,this.Ms=NaN),n!==this.bs||e!==this.Ms||h!==this.ds||r!==this.cs||l!==this.Pt}Ls(){const t=this.ts.Ys().map((t=>t.Zs().Xs())).filter(v),i=0===t.length?null:Math.max(...t);this.ds=null!==i?i:NaN}Ws(t,i,s){let n=t.get(i);return void 0===n&&(n=new N(this,i,s),t.set(i,n)),n}}function Y(t){return"left"===t||"right"===t}class X{constructor(t){this.qs=new Map,this.Ks=[],this.Gs=t}Js(t,i){const s=function(t,i){return void 0===t?i:{Qs:Math.max(t.Qs,i.Qs),tn:t.tn||i.tn}}(this.qs.get(t),i);this.qs.set(t,s)}sn(){return this.Gs}nn(t){const i=this.qs.get(t);return void 0===i?{Qs:this.Gs}:{Qs:Math.max(this.Gs,i.Qs),tn:i.tn}}en(){this.rn(),this.Ks=[{hn:0}]}ln(t){this.rn(),this.Ks=[{hn:1,Wt:t}]}an(t){this._n(),this.Ks.push({hn:5,Wt:t})}rn(){this._n(),this.Ks.push({hn:6})}un(){this.rn(),this.Ks=[{hn:4}]}cn(t){this.rn(),this.Ks.push({hn:2,Wt:t})}dn(t){this.rn(),this.Ks.push({hn:3,Wt:t})}fn(){return this.Ks}pn(t){for(const i of t.Ks)this.vn(i);this.Gs=Math.max(this.Gs,t.Gs),t.qs.forEach(((t,i)=>{this.Js(i,t)}))}static mn(){return new X(2)}static wn(){return new X(3)}vn(t){switch(t.hn){case 0:this.en();break;case 1:this.ln(t.Wt);break;case 2:this.cn(t.Wt);break;case 3:this.dn(t.Wt);break;case 4:this.un();break;case 5:this.an(t.Wt);break;case 6:this._n()}}_n(){const t=this.Ks.findIndex((t=>5===t.hn));-1!==t&&this.Ks.splice(t,1)}}const Z=".";function q(t,i){if(!u(t))return"n/a";if(!c(i))throw new TypeError("invalid length");if(i<0||i>16)throw new TypeError("invalid length");if(0===i)return t.toString();return("0000000000000000"+t.toString()).slice(-i)}class K{constructor(t,i){if(i||(i=1),u(t)&&c(t)||(t=100),t<0)throw new TypeError("invalid base");this.Yi=t,this.gn=i,this.bn()}format(t){const i=t<0?"−":"";return t=Math.abs(t),i+this.Mn(t)}bn(){if(this.Sn=0,this.Yi>0&&this.gn>0){let t=this.Yi;for(;t>1;)t/=10,this.Sn++}}Mn(t){const i=this.Yi/this.gn;let s=Math.floor(t),n="";const e=void 0!==this.Sn?this.Sn:NaN;if(i>1){let r=+(Math.round(t*i)-s*i).toFixed(this.Sn);r>=i&&(r-=i,s+=1),n=Z+q(+r.toFixed(this.Sn)*this.gn,e)}else s=Math.round(s*i)/i,e>0&&(n=Z+q(0,e));return s.toFixed(0)+n}}class G extends K{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class J{constructor(t){this.xn=t}format(t){let i="";return t<0&&(i="-",t=-t),t<995?i+this.yn(t):t<999995?i+this.yn(t/1e3)+"K":t<999999995?(t=1e3*Math.round(t/1e3),i+this.yn(t/1e6)+"M"):(t=1e6*Math.round(t/1e6),i+this.yn(t/1e9)+"B")}yn(t){let i;const s=Math.pow(10,this.xn);return i=(t=Math.round(t*s)/s)>=1e-15&&t<1?t.toFixed(this.xn).replace(/\.?0+$/,""):String(t),i.replace(/(\.[1-9]*)0+$/,((t,i)=>i))}}const Q=/[2-9]/g;class tt{constructor(t=50){this.Pn=0,this.Cn=1,this.Tn=1,this.kn={},this.Rn=new Map,this.Dn=t}En(){this.Pn=0,this.Rn.clear(),this.Cn=1,this.Tn=1,this.kn={}}Ei(t,i,s){return this.zn(t,i,s).width}Di(t,i,s){const n=this.zn(t,i,s);return((n.actualBoundingBoxAscent||0)-(n.actualBoundingBoxDescent||0))/2}zn(t,i,s){const n=s||Q,e=String(i).replace(n,"0");if(this.Rn.has(e))return h(this.Rn.get(e)).Vn;if(this.Pn===this.Dn){const t=this.kn[this.Tn];delete this.kn[this.Tn],this.Rn.delete(t),this.Tn++,this.Pn--}t.save(),t.textBaseline="middle";const r=t.measureText(e);return t.restore(),0===r.width&&i.length||(this.Rn.set(e,{Vn:r,In:this.Cn}),this.kn[this.Cn]=e,this.Pn++,this.Cn++),r}}class it{constructor(t){this.An=null,this.M=null,this.Bn="right",this.Ln=t}On(t,i,s){this.An=t,this.M=i,this.Bn=s}nt(t){null!==this.M&&null!==this.An&&this.An.nt(t,this.M,this.Ln,this.Bn)}}class st{constructor(t,i,s){this.Nn=t,this.Ln=new tt(50),this.Fn=i,this.O=s,this.F=-1,this.Gt=new it(this.Ln)}kt(){const t=this.O.Wn(this.Fn);if(null===t)return null;const i=t.Hn(this.Fn)?t.$n():this.Fn.Ft();if(null===i)return null;const s=t.Un(i);if("overlay"===s)return null;const n=this.O.jn();return n.C!==this.F&&(this.F=n.C,this.Ln.En()),this.Gt.On(this.Nn.Ui(),n,s),this.Gt}}class nt extends P{constructor(){super(...arguments),this.Yt=null}ht(t){this.Yt=t}Yn(t,i){if(!this.Yt?.Et)return null;const{ut:s,ct:n,Xn:e}=this.Yt;return i>=s-n-7&&i<=s+n+7?{Zn:this.Yt,Xn:e}:null}et({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:r}){if(null===this.Yt)return;if(!1===this.Yt.Et)return;const h=Math.round(this.Yt.ut*r);h<0||h>i.height||(t.lineCap="butt",t.strokeStyle=this.Yt.R,t.lineWidth=Math.floor(this.Yt.ct*s),n(t,this.Yt.qt),e(t,h,0,i.width))}}class et{constructor(t){this.qn={ut:0,R:"rgba(0, 0, 0, 0)",ct:1,qt:0,Et:!1},this.Kn=new nt,this.xt=!0,this.Gn=t,this.Jn=t.Qt(),this.Kn.ht(this.qn)}Ct(){this.xt=!0}kt(){return this.Gn.Et()?(this.xt&&(this.Qn(),this.xt=!1),this.Kn):null}}class rt extends et{constructor(t){super(t)}Qn(){this.qn.Et=!1;const t=this.Gn.Ft(),i=t.te().te;if(2!==i&&3!==i)return;const s=this.Gn.N();if(!s.baseLineVisible||!this.Gn.Et())return;const n=this.Gn.Bt();null!==n&&(this.qn.Et=!0,this.qn.ut=t.Nt(n.Wt,n.Wt),this.qn.R=s.baseLineColor,this.qn.ct=s.baseLineWidth,this.qn.qt=s.baseLineStyle)}}class ht extends P{constructor(){super(...arguments),this.Yt=null}ht(t){this.Yt=t}ie(){return this.Yt}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:s}){const n=this.Yt;if(null===n)return;const e=Math.max(1,Math.floor(i)),r=e%2/2,h=Math.round(n.se.x*i)+r,l=n.se.y*s;t.fillStyle=n.ne,t.beginPath();const a=Math.max(2,1.5*n.ee)*i;t.arc(h,l,a,0,2*Math.PI,!1),t.fill(),t.fillStyle=n.re,t.beginPath(),t.arc(h,l,n.ft*i,0,2*Math.PI,!1),t.fill(),t.lineWidth=e,t.strokeStyle=n.he,t.beginPath(),t.arc(h,l,n.ft*i+e/2,0,2*Math.PI,!1),t.stroke()}}const lt=[{le:0,ae:.25,oe:4,_e:10,ue:.25,ce:0,de:.4,fe:.8},{le:.25,ae:.525,oe:10,_e:14,ue:0,ce:0,de:.8,fe:0},{le:.525,ae:1,oe:14,_e:14,ue:0,ce:0,de:0,fe:0}];class at{constructor(t){this.Gt=new ht,this.xt=!0,this.pe=!0,this.ve=performance.now(),this.me=this.ve-1,this.we=t}ge(){this.me=this.ve-1,this.Ct()}be(){if(this.Ct(),2===this.we.N().lastPriceAnimation){const t=performance.now(),i=this.me-t;if(i>0)return void(i<650&&(this.me+=2600));this.ve=t,this.me=t+2600}}Ct(){this.xt=!0}Me(){this.pe=!0}Et(){return 0!==this.we.N().lastPriceAnimation}Se(){switch(this.we.N().lastPriceAnimation){case 0:return!1;case 1:return!0;case 2:return performance.now()<=this.me}}kt(){return this.xt?(this.Rt(),this.xt=!1,this.pe=!1):this.pe&&(this.xe(),this.pe=!1),this.Gt}Rt(){this.Gt.ht(null);const t=this.we.Qt().It(),i=t.ye(),s=this.we.Bt();if(null===i||null===s)return;const n=this.we.Pe(!0);if(n.Ce||!i.Te(n.ke))return;const e={x:t.jt(n.ke),y:this.we.Ft().Nt(n.gt,s.Wt)},r=n.R,h=this.we.N().lineWidth,l=this.Re(this.De(),r);this.Gt.ht({ne:r,ee:h,re:l.re,he:l.he,ft:l.ft,se:e})}xe(){const t=this.Gt.ie();if(null!==t){const i=this.Re(this.De(),t.ne);t.re=i.re,t.he=i.he,t.ft=i.ft}}De(){return this.Se()?performance.now()-this.ve:2599}Ee(t,i,s,n){const e=s+(n-s)*i;return this.we.Qt().qi().X(t,e)}Re(t,i){const s=t%2600/2600;let n;for(const t of lt)if(s>=t.le&&s<=t.ae){n=t;break}r(void 0!==n,"Last price animation internal logic error");const e=(s-n.le)/(n.ae-n.le);return{re:this.Ee(i,e,n.ue,n.ce),he:this.Ee(i,e,n.de,n.fe),ft:(h=e,l=n.oe,a=n._e,l+(a-l)*h)};var h,l,a}}class ot extends et{constructor(t){super(t)}Qn(){const t=this.qn;t.Et=!1;const i=this.Gn.N();if(!i.priceLineVisible||!this.Gn.Et())return;const s=this.Gn.Pe(0===i.priceLineSource);s.Ce||(t.Et=!0,t.ut=s.Vi,t.R=this.Gn.ze(s.R),t.ct=i.priceLineWidth,t.qt=i.priceLineStyle)}}class _t extends O{constructor(t){super(),this.Jt=t}ji(t,i,s){t.Et=!1,i.Et=!1;const n=this.Jt;if(!n.Et())return;const e=n.N(),r=e.lastValueVisible,h=""!==n.Ve(),l=0===e.seriesLastValueMode,a=n.Pe(!1);if(a.Ce)return;r&&(t.ri=this.Ie(a,r,l),t.Et=0!==t.ri.length),(h||l)&&(i.ri=this.Ae(a,r,h,l),i.Et=i.ri.length>0);const o=n.ze(a.R),_=this.Jt.Qt().qi().q(o);s.K=_.K,s.Vi=a.Vi,i.Ht=n.Qt().$t(a.Vi/n.Ft().Ut()),t.Ht=o,t.R=_.G,i.R=_.G}Ae(t,i,s,n){let e="";const r=this.Jt.Ve();return s&&0!==r.length&&(e+=`${r} `),i&&n&&(e+=this.Jt.Ft().Be()?t.Le:t.Oe),e.trim()}Ie(t,i,s){return i?s?this.Jt.Ft().Be()?t.Oe:t.Le:t.ri:""}}function ut(t,i,s,n){const e=Number.isFinite(i),r=Number.isFinite(s);return e&&r?t(i,s):e||r?e?i:s:n}class ct{constructor(t,i){this.Ne=t,this.Fe=i}We(t){return null!==t&&(this.Ne===t.Ne&&this.Fe===t.Fe)}He(){return new ct(this.Ne,this.Fe)}$e(){return this.Ne}Ue(){return this.Fe}je(){return this.Fe-this.Ne}Zi(){return this.Fe===this.Ne||Number.isNaN(this.Fe)||Number.isNaN(this.Ne)}pn(t){return null===t?this:new ct(ut(Math.min,this.$e(),t.$e(),-1/0),ut(Math.max,this.Ue(),t.Ue(),1/0))}Ye(t){if(!u(t))return;if(0===this.Fe-this.Ne)return;const i=.5*(this.Fe+this.Ne);let s=this.Fe-i,n=this.Ne-i;s*=t,n*=t,this.Fe=i+s,this.Ne=i+n}Xe(t){u(t)&&(this.Fe+=t,this.Ne+=t)}Ze(){return{minValue:this.Ne,maxValue:this.Fe}}static qe(t){return null===t?null:new ct(t.minValue,t.maxValue)}}class dt{constructor(t,i){this.Ke=t,this.Ge=i||null}Je(){return this.Ke}Qe(){return this.Ge}Ze(){return{priceRange:null===this.Ke?null:this.Ke.Ze(),margins:this.Ge||void 0}}static qe(t){return null===t?null:new dt(ct.qe(t.priceRange),t.margins)}}class ft extends et{constructor(t,i){super(t),this.tr=i}Qn(){const t=this.qn;t.Et=!1;const i=this.tr.N();if(!this.Gn.Et()||!i.lineVisible)return;const s=this.tr.ir();null!==s&&(t.Et=!0,t.ut=s,t.R=i.color,t.ct=i.lineWidth,t.qt=i.lineStyle,t.Xn=this.tr.N().id)}}class pt extends O{constructor(t,i){super(),this.we=t,this.tr=i}ji(t,i,s){t.Et=!1,i.Et=!1;const n=this.tr.N(),e=n.axisLabelVisible,r=""!==n.title,h=this.we;if(!e||!h.Et())return;const l=this.tr.ir();if(null===l)return;r&&(i.ri=n.title,i.Et=!0),i.Ht=h.Qt().$t(l/h.Ft().Ut()),t.ri=this.sr(n.price),t.Et=!0;const a=this.we.Qt().qi().q(n.axisLabelColor||n.color);s.K=a.K;const o=n.axisLabelTextColor||a.G;t.R=o,i.R=o,s.Vi=l}sr(t){const i=this.we.Bt();return null===i?"":this.we.Ft().Ki(t,i.Wt)}}class vt{constructor(t,i){this.we=t,this.ys=i,this.nr=new ft(t,this),this.Nn=new pt(t,this),this.er=new st(this.Nn,t,t.Qt())}rr(t){_(this.ys,t),this.Ct(),this.we.Qt().hr()}N(){return this.ys}lr(){return this.nr}ar(){return this.er}_r(){return this.Nn}Ct(){this.nr.Ct(),this.Nn.Ct()}ir(){const t=this.we,i=t.Ft();if(t.Qt().It().Zi()||i.Zi())return null;const s=t.Bt();return null===s?null:i.Nt(this.ys.price,s.Wt)}}class mt extends ${constructor(t){super(),this.ts=t}Qt(){return this.ts}}const wt={Bar:(t,i,s,n)=>{const e=i.upColor,r=i.downColor,h=l(t(s,n)),o=a(h.Wt[0])<=a(h.Wt[3]);return{ur:h.R??(o?e:r)}},Candlestick:(t,i,s,n)=>{const e=i.upColor,r=i.downColor,h=i.borderUpColor,o=i.borderDownColor,_=i.wickUpColor,u=i.wickDownColor,c=l(t(s,n)),d=a(c.Wt[0])<=a(c.Wt[3]);return{ur:c.R??(d?e:r),cr:c.Ht??(d?h:o),dr:c.pr??(d?_:u)}},Custom:(t,i,s,n)=>({ur:l(t(s,n)).R??i.color}),Area:(t,i,s,n)=>{const e=l(t(s,n));return{ur:e.vt??i.lineColor,vt:e.vt??i.lineColor,vr:e.vr??i.topColor,mr:e.mr??i.bottomColor}},Baseline:(t,i,s,n)=>{const e=l(t(s,n));return{ur:e.Wt[3]>=i.baseValue.price?i.topLineColor:i.bottomLineColor,wr:e.wr??i.topLineColor,gr:e.gr??i.bottomLineColor,br:e.br??i.topFillColor1,Mr:e.Mr??i.topFillColor2,Sr:e.Sr??i.bottomFillColor1,yr:e.yr??i.bottomFillColor2}},Line:(t,i,s,n)=>{const e=l(t(s,n));return{ur:e.R??i.color,vt:e.R??i.color}},Histogram:(t,i,s,n)=>({ur:l(t(s,n)).R??i.color})};class gt{constructor(t){this.Pr=(t,i)=>void 0!==i?i.Wt:this.we.Zs().Cr(t),this.we=t,this.Tr=wt[t.kr()]}Rr(t,i){return this.Tr(this.Pr,this.we.N(),t,i)}}function bt(t,i,s,n,e=0,r=i.length){let h=r-e;for(;0>1,l=e+r;n(i[l],s)===t?(e=l+1,h-=r+1):h=r}return e}const Mt=bt.bind(null,!0),St=bt.bind(null,!1);var xt;!function(t){t[t.NearestLeft=-1]="NearestLeft",t[t.None=0]="None",t[t.NearestRight=1]="NearestRight"}(xt||(xt={}));const yt=30;class Pt{constructor(){this.Dr=[],this.Er=new Map,this.zr=new Map,this.Vr=[]}Ir(){return this.Ar()>0?this.Dr[this.Dr.length-1]:null}Br(){return this.Ar()>0?this.Lr(0):null}Xs(){return this.Ar()>0?this.Lr(this.Dr.length-1):null}Ar(){return this.Dr.length}Zi(){return 0===this.Ar()}Te(t){return null!==this.Or(t,0)}Cr(t){return this.Nr(t)}Nr(t,i=0){const s=this.Or(t,i);return null===s?null:{...this.Fr(s),ke:this.Lr(s)}}Wr(){return this.Dr}Hr(t,i,s){if(this.Zi())return null;let n=null;for(const e of s){n=Ct(n,this.$r(t,i,e))}return n}ht(t){this.zr.clear(),this.Er.clear(),this.Dr=t,this.Vr=t.map((t=>t.ke))}Ur(){return this.Vr}Lr(t){return this.Dr[t].ke}Fr(t){return this.Dr[t]}Or(t,i){const s=this.jr(t);if(null===s&&0!==i)switch(i){case-1:return this.Yr(t);case 1:return this.Xr(t);default:throw new TypeError("Unknown search mode")}return s}Yr(t){let i=this.Zr(t);return i>0&&(i-=1),i!==this.Dr.length&&this.Lr(i)t.ket.ke>i))}Kr(t,i,s){let n=null;for(let e=t;en.Jr&&(n.Jr=t)))}return n}$r(t,i,s){if(this.Zi())return null;let n=null;const e=l(this.Br()),r=l(this.Xs()),h=Math.max(t,e),a=Math.min(i,r),o=Math.ceil(h/yt)*yt,_=Math.max(o,Math.floor(a/yt)*yt);{const t=this.Zr(h),e=this.qr(Math.min(a,o,i));n=Ct(n,this.Kr(t,e,s))}let u=this.Er.get(s);void 0===u&&(u=new Map,this.Er.set(s,u));for(let t=Math.max(o+1,h);t<_;t+=yt){const i=Math.floor(t/yt);let e=u.get(i);if(void 0===e){const t=this.Zr(i*yt),n=this.qr((i+1)*yt-1);e=this.Kr(t,n,s),u.set(i,e)}n=Ct(n,e)}{const t=this.Zr(_),i=this.qr(a);n=Ct(n,this.Kr(t,i,s))}return n}}function Ct(t,i){if(null===t)return i;if(null===i)return t;return{Gr:Math.min(t.Gr,i.Gr),Jr:Math.max(t.Jr,i.Jr)}}class Tt{constructor(t){this.Qr=t}nt(t,i,s){this.Qr.draw(t)}th(t,i,s){this.Qr.drawBackground?.(t)}}class kt{constructor(t){this.Rn=null,this.ih=t}kt(){const t=this.ih.renderer();if(null===t)return null;if(this.Rn?.sh===t)return this.Rn.nh;const i=new Tt(t);return this.Rn={sh:t,nh:i},i}eh(){return this.ih.zOrder?.()??"normal"}}class Rt{constructor(t){this.rh=null,this.hh=t}ah(){return this.hh}Os(){this.hh.updateAllViews?.()}Ns(){const t=this.hh.paneViews?.()??[];if(this.rh?.sh===t)return this.rh.nh;const i=t.map((t=>new kt(t)));return this.rh={sh:t,nh:i},i}Yn(t,i){return this.hh.hitTest?.(t,i)??null}}class Dt extends Rt{_s(){return[]}}class Et{constructor(t){this.Qr=t}nt(t,i,s){this.Qr.draw(t)}th(t,i,s){this.Qr.drawBackground?.(t)}}class zt{constructor(t){this.Rn=null,this.ih=t}kt(){const t=this.ih.renderer();if(null===t)return null;if(this.Rn?.sh===t)return this.Rn.nh;const i=new Et(t);return this.Rn={sh:t,nh:i},i}eh(){return this.ih.zOrder?.()??"normal"}}function Vt(t){return{ri:t.text(),Vi:t.coordinate(),zi:t.fixedCoordinate?.(),R:t.textColor(),K:t.backColor(),Et:t.visible?.()??!0,pi:t.tickVisible?.()??!0}}class It{constructor(t,i){this.Gt=new W,this.oh=t,this._h=i}kt(){return this.Gt.ht({Qi:this._h.Qi(),...Vt(this.oh)}),this.Gt}}class At extends O{constructor(t,i){super(),this.oh=t,this.Yi=i}ji(t,i,s){const n=Vt(this.oh);s.K=n.K,t.R=n.R;const e=2/12*this.Yi.C();s.ki=e,s.Ri=e,s.Vi=n.Vi,s.zi=n.zi,t.ri=n.ri,t.Et=n.Et,t.pi=n.pi}}class Bt extends Rt{constructor(t,i){super(t),this.uh=null,this.dh=null,this.fh=null,this.ph=null,this.we=i}us(){const t=this.hh.timeAxisViews?.()??[];if(this.uh?.sh===t)return this.uh.nh;const i=this.we.Qt().It(),s=t.map((t=>new It(t,i)));return this.uh={sh:t,nh:s},s}Fs(){const t=this.hh.priceAxisViews?.()??[];if(this.dh?.sh===t)return this.dh.nh;const i=this.we.Ft(),s=t.map((t=>new At(t,i)));return this.dh={sh:t,nh:s},s}mh(){const t=this.hh.priceAxisPaneViews?.()??[];if(this.fh?.sh===t)return this.fh.nh;const i=t.map((t=>new zt(t)));return this.fh={sh:t,nh:i},i}wh(){const t=this.hh.timeAxisPaneViews?.()??[];if(this.ph?.sh===t)return this.ph.nh;const i=t.map((t=>new zt(t)));return this.ph={sh:t,nh:i},i}gh(t,i){return this.hh.autoscaleInfo?.(t,i)??null}}function Lt(t,i,s,n){t.forEach((t=>{i(t).forEach((t=>{t.eh()===s&&n.push(t)}))}))}function Ot(t){return t.Ns()}function Nt(t){return t.mh()}function Ft(t){return t.wh()}const Wt=["Area","Line","Baseline"];class Ht extends mt{constructor(t,i,s,n,e){super(t),this.Yt=new Pt,this.nr=new ot(this),this.bh=[],this.Mh=new rt(this),this.Sh=null,this.xh=null,this.yh=null,this.Ph=[],this.ys=s,this.Ch=i;const r=new _t(this);this.ps=[r],this.er=new st(r,this,t),Wt.includes(this.Ch)&&(this.Sh=new at(this)),this.Th(),this.ih=n(this,this.Qt(),e)}m(){null!==this.yh&&clearTimeout(this.yh)}ze(t){return this.ys.priceLineColor||t}Pe(t){const i={Ce:!0},s=this.Ft();if(this.Qt().It().Zi()||s.Zi()||this.Yt.Zi())return i;const n=this.Qt().It().ye(),e=this.Bt();if(null===n||null===e)return i;let r,h;if(t){const t=this.Yt.Ir();if(null===t)return i;r=t,h=t.ke}else{const t=this.Yt.Nr(n.Mi(),-1);if(null===t)return i;if(r=this.Yt.Cr(t.ke),null===r)return i;h=t.ke}const l=r.Wt[3],a=this.kh().Rr(h,{Wt:r}),o=s.Nt(l,e.Wt);return{Ce:!1,gt:l,ri:s.Ki(l,e.Wt),Le:s.Rh(l),Oe:s.Dh(l,e.Wt),R:a.ur,Vi:o,ke:h}}kh(){return null!==this.xh||(this.xh=new gt(this)),this.xh}N(){return this.ys}rr(t){const i=t.priceScaleId;void 0!==i&&i!==this.ys.priceScaleId&&this.Qt().Eh(this,i),_(this.ys,t),void 0!==t.priceFormat&&(this.Th(),this.Qt().zh()),this.Qt().Vh(this),this.Qt().Ih(),this.ih.Ct("options")}ht(t,i){this.Yt.ht(t),this.ih.Ct("data"),null!==this.Sh&&(i&&i.Ah?this.Sh.be():0===t.length&&this.Sh.ge());const s=this.Qt().Wn(this);this.Qt().Bh(s),this.Qt().Vh(this),this.Qt().Ih(),this.Qt().hr()}Lh(t){const i=new vt(this,t);return this.bh.push(i),this.Qt().Vh(this),i}Oh(t){const i=this.bh.indexOf(t);-1!==i&&this.bh.splice(i,1),this.Qt().Vh(this)}Nh(){return this.bh}kr(){return this.Ch}Bt(){const t=this.Fh();return null===t?null:{Wt:t.Wt[3],Wh:t.wt}}Fh(){const t=this.Qt().It().ye();if(null===t)return null;const i=t.Hh();return this.Yt.Nr(i,1)}Zs(){return this.Yt}$h(t){const i=this.Yt.Cr(t);return null===i?null:"Bar"===this.Ch||"Candlestick"===this.Ch||"Custom"===this.Ch?{Uh:i.Wt[0],jh:i.Wt[1],Yh:i.Wt[2],Xh:i.Wt[3]}:i.Wt[3]}Zh(t){const i=[];Lt(this.Ph,Ot,"top",i);const s=this.Sh;return null!==s&&s.Et()?(null===this.yh&&s.Se()&&(this.yh=setTimeout((()=>{this.yh=null,this.Qt().qh()}),0)),s.Me(),i.unshift(s),i):i}Ns(){const t=[];this.Kh()||t.push(this.Mh),t.push(this.ih,this.nr);const i=this.bh.map((t=>t.lr()));return t.push(...i),Lt(this.Ph,Ot,"normal",t),t}Gh(){return this.Jh(Ot,"bottom")}Qh(t){return this.Jh(Nt,t)}tl(t){return this.Jh(Ft,t)}il(t,i){return this.Ph.map((s=>s.Yn(t,i))).filter((t=>null!==t))}_s(){return[this.er,...this.bh.map((t=>t.ar()))]}Fs(t,i){if(i!==this.es&&!this.Kh())return[];const s=[...this.ps];for(const t of this.bh)s.push(t._r());return this.Ph.forEach((t=>{s.push(...t.Fs())})),s}us(){const t=[];return this.Ph.forEach((i=>{t.push(...i.us())})),t}gh(t,i){if(void 0!==this.ys.autoscaleInfoProvider){const s=this.ys.autoscaleInfoProvider((()=>{const s=this.sl(t,i);return null===s?null:s.Ze()}));return dt.qe(s)}return this.sl(t,i)}nl(){return this.ys.priceFormat.minMove}el(){return this.rl}Os(){this.ih.Ct();for(const t of this.ps)t.Ct();for(const t of this.bh)t.Ct();this.nr.Ct(),this.Mh.Ct(),this.Sh?.Ct(),this.Ph.forEach((t=>t.Os()))}Ft(){return l(super.Ft())}At(t){if(!(("Line"===this.Ch||"Area"===this.Ch||"Baseline"===this.Ch)&&this.ys.crosshairMarkerVisible))return null;const i=this.Yt.Cr(t);if(null===i)return null;return{gt:i.Wt[3],ft:this.hl(),Ht:this.ll(),Ot:this.al(),Lt:this.ol(t)}}Ve(){return this.ys.title}Et(){return this.ys.visible}_l(t){this.Ph.push(new Bt(t,this))}ul(t){this.Ph=this.Ph.filter((i=>i.ah()!==t))}cl(){if("Custom"===this.Ch)return t=>this.ih.dl(t)}fl(){if("Custom"===this.Ch)return t=>this.ih.pl(t)}vl(){return this.Yt.Ur()}Kh(){return!Y(this.Ft().ml())}sl(t,i){if(!c(t)||!c(i)||this.Yt.Zi())return null;const s="Line"===this.Ch||"Area"===this.Ch||"Baseline"===this.Ch||"Histogram"===this.Ch?[3]:[2,1],n=this.Yt.Hr(t,i,s);let e=null!==n?new ct(n.Gr,n.Jr):null,r=null;if("Histogram"===this.kr()){const t=this.ys.base,i=new ct(t,t);e=null!==e?e.pn(i):i}return this.Ph.forEach((s=>{const n=s.gh(t,i);if(n?.priceRange){const t=new ct(n.priceRange.minValue,n.priceRange.maxValue);e=null!==e?e.pn(t):t}n?.margins&&(r=n.margins)})),new dt(e,r)}hl(){switch(this.Ch){case"Line":case"Area":case"Baseline":return this.ys.crosshairMarkerRadius}return 0}ll(){switch(this.Ch){case"Line":case"Area":case"Baseline":{const t=this.ys.crosshairMarkerBorderColor;if(0!==t.length)return t}}return null}al(){switch(this.Ch){case"Line":case"Area":case"Baseline":return this.ys.crosshairMarkerBorderWidth}return 0}ol(t){switch(this.Ch){case"Line":case"Area":case"Baseline":{const t=this.ys.crosshairMarkerBackgroundColor;if(0!==t.length)return t}}return this.kh().Rr(t).ur}Th(){switch(this.ys.priceFormat.type){case"custom":this.rl={format:this.ys.priceFormat.formatter};break;case"volume":this.rl=new J(this.ys.priceFormat.precision);break;case"percent":this.rl=new G(this.ys.priceFormat.precision);break;default:{const t=Math.pow(10,this.ys.priceFormat.precision);this.rl=new K(t,this.ys.priceFormat.minMove*t)}}null!==this.es&&this.es.wl()}Jh(t,i){const s=[];return Lt(this.Ph,t,i,s),s}}const $t=[3],Ut=[0,1,2,3];class jt{constructor(t){this.ys=t}gl(t,i,s){let n=t;if(0===this.ys.mode)return n;const e=s.Cs(),r=e.Bt();if(null===r)return n;const h=e.Nt(t,r),l=s.bl().filter((t=>t instanceof Ht)).reduce(((t,n)=>{if(s.Hn(n)||!n.Et())return t;const e=n.Ft(),r=n.Zs();if(e.Zi()||!r.Te(i))return t;const h=r.Cr(i);if(null===h)return t;const l=a(n.Bt()),o=3===this.ys.mode?Ut:$t;return t.concat(o.map((t=>e.Nt(h.Wt[t],l.Wt))))}),[]);if(0===l.length)return n;l.sort(((t,i)=>Math.abs(t-h)-Math.abs(i-h)));const o=l[0];return n=e.Ts(o,r),n}}function Yt(t,i,s){return Math.min(Math.max(t,i),s)}function Xt(t,i,s){return i-t<=s}class Zt extends P{constructor(){super(...arguments),this.Yt=null}ht(t){this.Yt=t}et({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:e}){if(null===this.Yt)return;const r=Math.max(1,Math.floor(s));t.lineWidth=r,function(t,i){t.save(),t.lineWidth%2&&t.translate(.5,.5),i(),t.restore()}(t,(()=>{const h=l(this.Yt);if(h.Ml){t.strokeStyle=h.Sl,n(t,h.xl),t.beginPath();for(const n of h.yl){const e=Math.round(n.Pl*s);t.moveTo(e,-r),t.lineTo(e,i.height+r)}t.stroke()}if(h.Cl){t.strokeStyle=h.Tl,n(t,h.kl),t.beginPath();for(const s of h.Rl){const n=Math.round(s.Pl*e);t.moveTo(-r,n),t.lineTo(i.width+r,n)}t.stroke()}}))}}class qt{constructor(t){this.Gt=new Zt,this.xt=!0,this.Pt=t}Ct(){this.xt=!0}kt(){if(this.xt){const t=this.Pt.Qt().N().grid,i={Cl:t.horzLines.visible,Ml:t.vertLines.visible,Tl:t.horzLines.color,Sl:t.vertLines.color,kl:t.horzLines.style,xl:t.vertLines.style,Rl:this.Pt.Cs().Dl(),yl:(this.Pt.Qt().It().Dl()||[]).map((t=>({Pl:t.coord})))};this.Gt.ht(i),this.xt=!1}return this.Gt}}class Kt{constructor(t){this.ih=new qt(t)}lr(){return this.ih}}const Gt={El:4,zl:1e-4};function Jt(t,i){const s=100*(t-i)/i;return i<0?-s:s}function Qt(t,i){const s=Jt(t.$e(),i),n=Jt(t.Ue(),i);return new ct(s,n)}function ti(t,i){const s=100*(t-i)/i+100;return i<0?-s:s}function ii(t,i){const s=ti(t.$e(),i),n=ti(t.Ue(),i);return new ct(s,n)}function si(t,i){const s=Math.abs(t);if(s<1e-15)return 0;const n=Math.log10(s+i.zl)+i.El;return t<0?-n:n}function ni(t,i){const s=Math.abs(t);if(s<1e-15)return 0;const n=Math.pow(10,s-i.El)-i.zl;return t<0?-n:n}function ei(t,i){if(null===t)return null;const s=si(t.$e(),i),n=si(t.Ue(),i);return new ct(s,n)}function ri(t,i){if(null===t)return null;const s=ni(t.$e(),i),n=ni(t.Ue(),i);return new ct(s,n)}function hi(t){if(null===t)return Gt;const i=Math.abs(t.Ue()-t.$e());if(i>=1||i<1e-15)return Gt;const s=Math.ceil(Math.abs(Math.log10(i))),n=Gt.El+s;return{El:n,zl:1/Math.pow(10,n)}}class li{constructor(t,i){if(this.Vl=t,this.Il=i,function(t){if(t<0)return!1;for(let i=t;i>1;i/=10)if(i%10!=0)return!1;return!0}(this.Vl))this.Al=[2,2.5,2];else{this.Al=[];for(let t=this.Vl;1!==t;){if(t%2==0)this.Al.push(2),t/=2;else{if(t%5!=0)throw new Error("unexpected base");this.Al.push(2,2.5),t/=5}if(this.Al.length>100)throw new Error("something wrong with base")}}}Bl(t,i,s){const n=0===this.Vl?0:1/this.Vl;let e=Math.pow(10,Math.max(0,Math.ceil(Math.log10(t-i)))),r=0,h=this.Il[0];for(;;){const t=Xt(e,n,1e-14)&&e>n+1e-14,i=Xt(e,s*h,1e-14),l=Xt(e,1,1e-14);if(!(t&&i&&l))break;e/=h,h=this.Il[++r%this.Il.length]}if(e<=n+1e-14&&(e=n),e=Math.max(1,e),this.Al.length>0&&(l=e,a=1,o=1e-14,Math.abs(l-a)n+1e-14;)e/=h,h=this.Al[++r%this.Al.length];var l,a,o;return e}}class ai{constructor(t,i,s,n){this.Ll=[],this.Yi=t,this.Vl=i,this.Ol=s,this.Nl=n}Bl(t,i){if(t=o?1:-1;let d=null,f=0;for(let s=a-u;s>o;s-=_){const n=this.Nl(s,i,!0);null!==d&&Math.abs(n-d)l||(fl(t.hs())-l(i.hs())))}var _i;!function(t){t[t.Normal=0]="Normal",t[t.Logarithmic=1]="Logarithmic",t[t.Percentage=2]="Percentage",t[t.IndexedTo100=3]="IndexedTo100"}(_i||(_i={}));const ui=new G,ci=new K(100,1);class di{constructor(t,i,s,n,e){this.Yl=0,this.Xl=null,this.Ke=null,this.Zl=null,this.ql={Kl:!1,Gl:null},this.Jl=0,this.Ql=0,this.ta=new o,this.ia=new o,this.sa=[],this.na=null,this.ea=null,this.ra=null,this.ha=null,this.la=null,this.rl=ci,this.aa=hi(null),this.oa=t,this.ys=i,this._a=s,this.ua=n,this.ca=e,this.da=new ai(this,100,this.fa.bind(this),this.pa.bind(this))}ml(){return this.oa}N(){return this.ys}rr(t){if(_(this.ys,t),this.wl(),void 0!==t.mode&&this.va({te:t.mode}),void 0!==t.scaleMargins){const i=h(t.scaleMargins.top),s=h(t.scaleMargins.bottom);if(i<0||i>1)throw new Error(`Invalid top margin - expect value between 0 and 1, given=${i}`);if(s<0||s>1)throw new Error(`Invalid bottom margin - expect value between 0 and 1, given=${s}`);if(i+s>1)throw new Error(`Invalid margins - sum of margins must be less than 1, given=${i+s}`);this.ma(),this.ra=null}}wa(){return this.ys.autoScale}jl(){return 1===this.ys.mode}Be(){return 2===this.ys.mode}ga(){return 3===this.ys.mode}te(){return{tn:this.ys.autoScale,ba:this.ys.invertScale,te:this.ys.mode}}va(t){const i=this.te();let s=null;void 0!==t.tn&&(this.ys.autoScale=t.tn),void 0!==t.te&&(this.ys.mode=t.te,2!==t.te&&3!==t.te||(this.ys.autoScale=!0),this.ql.Kl=!1),1===i.te&&t.te!==i.te&&(!function(t,i){if(null===t)return!1;const s=ni(t.$e(),i),n=ni(t.Ue(),i);return isFinite(s)&&isFinite(n)}(this.Ke,this.aa)?this.ys.autoScale=!0:(s=ri(this.Ke,this.aa),null!==s&&this.Ma(s))),1===t.te&&t.te!==i.te&&(s=ei(this.Ke,this.aa),null!==s&&this.Ma(s));const n=i.te!==this.ys.mode;n&&(2===i.te||this.Be())&&this.wl(),n&&(3===i.te||this.ga())&&this.wl(),void 0!==t.ba&&i.ba!==t.ba&&(this.ys.invertScale=t.ba,this.Sa()),this.ia.p(i,this.te())}xa(){return this.ia}C(){return this._a.fontSize}Ut(){return this.Yl}ya(t){this.Yl!==t&&(this.Yl=t,this.ma(),this.ra=null)}Pa(){if(this.Xl)return this.Xl;const t=this.Ut()-this.Ca()-this.Ta();return this.Xl=t,t}Je(){return this.ka(),this.Ke}Ma(t,i){const s=this.Ke;(i||null===s&&null!==t||null!==s&&!s.We(t))&&(this.ra=null,this.Ke=t)}Zi(){return this.ka(),0===this.Yl||!this.Ke||this.Ke.Zi()}Ra(t){return this.ba()?t:this.Ut()-1-t}Nt(t,i){return this.Be()?t=Jt(t,i):this.ga()&&(t=ti(t,i)),this.pa(t,i)}Da(t,i,s){this.ka();const n=this.Ta(),e=l(this.Je()),r=e.$e(),h=e.Ue(),a=this.Pa()-1,o=this.ba(),_=a/(h-r),u=void 0===s?0:s.from,c=void 0===s?t.length:s.to,d=this.Ea();for(let s=u;st.Os()))}wl(){this.ra=null;let t=1/0;this.na=null;for(const i of this.sa)i.hs()si(t,this.aa):null}Qa(t,i,s){return void 0===i?(void 0===s&&(s=this.el()),s.format(t)):i(t)}sr(t,i){return this.Qa(t,this.ua.priceFormatter,i)}qa(t,i){return this.Qa(t,this.ua.percentageFormatter,i)}}function fi(t){return t instanceof Ht}class pi{constructor(t,i){this.sa=[],this.io=new Map,this.Yl=0,this.so=0,this.no=1e3,this.ea=null,this.eo=new o,this.Ph=[],this._h=t,this.ts=i,this.ro=new Kt(this);const s=i.N();this.ho=this.lo("left",s.leftPriceScale),this.ao=this.lo("right",s.rightPriceScale),this.ho.xa().i(this.oo.bind(this,this.ho),this),this.ao.xa().i(this.oo.bind(this,this.ao),this),this._o(s)}_o(t){if(t.leftPriceScale&&this.ho.rr(t.leftPriceScale),t.rightPriceScale&&this.ao.rr(t.rightPriceScale),t.localization&&(this.ho.wl(),this.ao.wl()),t.overlayPriceScales){const i=Array.from(this.io.values());for(const s of i){const i=l(s[0].Ft());i.rr(t.overlayPriceScales),t.localization&&i.wl()}}}uo(t){switch(t){case"left":return this.ho;case"right":return this.ao}return this.io.has(t)?h(this.io.get(t))[0].Ft():null}m(){this.Qt().co().u(this),this.ho.xa().u(this),this.ao.xa().u(this),this.sa.forEach((t=>{t.m&&t.m()})),this.Ph=this.Ph.filter((t=>{const i=t.ah();return i.detached&&i.detached(),!1})),this.eo.p()}do(){return this.no}fo(t){this.no=t}Qt(){return this.ts}Qi(){return this.so}Ut(){return this.Yl}po(t){this.so=t,this.vo()}ya(t){this.Yl=t,this.ho.ya(t),this.ao.ya(t),this.sa.forEach((i=>{if(this.Hn(i)){const s=i.Ft();null!==s&&s.ya(t)}})),this.vo()}mo(){return this.sa.filter(fi)}bl(){return this.sa}Hn(t){const i=t.Ft();return null===i||this.ho!==i&&this.ao!==i}Oa(t,i,s){this.wo(t,i,s?t.hs():this.sa.length)}Fa(t,i){const s=this.sa.indexOf(t);r(-1!==s,"removeDataSource: invalid data source"),this.sa.splice(s,1),i||this.sa.forEach(((t,i)=>t.ls(i)));const n=l(t.Ft()).ml();if(this.io.has(n)){const i=h(this.io.get(n)),s=i.indexOf(t);-1!==s&&(i.splice(s,1),0===i.length&&this.io.delete(n))}const e=t.Ft();e&&e.bl().indexOf(t)>=0&&(e.Fa(t),this.bo(e)),this.ea=null}Un(t){return t===this.ho?"left":t===this.ao?"right":"overlay"}Mo(){return this.ho}So(){return this.ao}xo(t,i){t.$a(i)}yo(t,i){t.Ua(i),this.vo()}Po(t){t.ja()}Co(t,i){t.Ya(i)}To(t,i){t.Xa(i),this.vo()}ko(t){t.Za()}vo(){this.sa.forEach((t=>{t.Os()}))}Cs(){let t=null;return this.ts.N().rightPriceScale.visible&&0!==this.ao.bl().length?t=this.ao:this.ts.N().leftPriceScale.visible&&0!==this.ho.bl().length?t=this.ho:0!==this.sa.length&&(t=this.sa[0].Ft()),null===t&&(t=this.ao),t}$n(){let t=null;return this.ts.N().rightPriceScale.visible?t=this.ao:this.ts.N().leftPriceScale.visible&&(t=this.ho),t}bo(t){null!==t&&t.wa()&&this.Ro(t)}Do(t){const i=this._h.ye();t.va({tn:!0}),null!==i&&t.Ga(i),this.vo()}Eo(){this.Ro(this.ho),this.Ro(this.ao)}zo(){this.bo(this.ho),this.bo(this.ao),this.sa.forEach((t=>{this.Hn(t)&&this.bo(t.Ft())})),this.vo(),this.ts.hr()}Dt(){return null===this.ea&&(this.ea=oi(this.sa)),this.ea}Vo(t,i){i=Yt(i,0,this.sa.length-1);const s=this.sa.indexOf(t);r(-1!==s,"setSeriesOrder: invalid data source"),this.sa.splice(s,1),this.sa.splice(i,0,t),this.sa.forEach(((t,i)=>t.ls(i))),this.ea=null;for(const t of[this.ho,this.ao])t.Na(),t.wl();this.ts.hr()}zt(){return this.Dt().filter(fi)}Io(){return this.eo}Ao(){return this.ro}_l(t){this.Ph.push(new Dt(t))}ul(t){this.Ph=this.Ph.filter((i=>i.ah()!==t)),t.detached&&t.detached(),this.ts.hr()}Bo(){return this.Ph}il(t,i){return this.Ph.map((s=>s.Yn(t,i))).filter((t=>null!==t))}Ro(t){const i=t.Ka();if(i&&i.length>0&&!this._h.Zi()){const i=this._h.ye();null!==i&&t.Ga(i)}t.Os()}wo(t,i,s){let n=this.uo(i);if(null===n&&(n=this.lo(i,this.ts.N().overlayPriceScales)),this.sa.splice(s,0,t),!Y(i)){const s=this.io.get(i)||[];s.push(t),this.io.set(i,s)}t.ls(s),n.Oa(t),t.os(n),this.bo(n),this.ea=null}oo(t,i,s){i.te!==s.te&&this.Ro(t)}lo(t,i){const s={visible:!0,autoScale:!0,...p(i)},n=new di(t,s,this.ts.N().layout,this.ts.N().localization,this.ts.qi());return n.ya(this.Ut()),n}}function vi(t){return{Lo:t.Lo,Oo:{Xn:t.No.externalId},Fo:t.No.cursorStyle}}function mi(t,i,s,n){for(const e of t){const t=e.kt(n);if(null!==t&&t.Yn){const n=t.Yn(i,s);if(null!==n)return{Wo:e,Oo:n}}}return null}function wi(t){return void 0!==t.Ns}function gi(t,i,s){const n=[t,...t.Dt()],e=function(t,i,s){let n,e;for(const l of t){const t=l.il?.(i,s)??[];for(const i of t)r=i.zOrder,h=n?.zOrder,(!h||"top"===r&&"top"!==h||"normal"===r&&"bottom"===h)&&(n=i,e=l)}var r,h;return n&&e?{No:n,Lo:e}:null}(n,i,s);if("top"===e?.No.zOrder)return vi(e);for(const r of n){if(e&&e.Lo===r&&"bottom"!==e.No.zOrder&&!e.No.isBackground)return vi(e);if(wi(r)){const n=mi(r.Ns(t),i,s,t);if(null!==n)return{Lo:r,Wo:n.Wo,Oo:n.Oo}}if(e&&e.Lo===r&&"bottom"!==e.No.zOrder&&e.No.isBackground)return vi(e)}return e?.No?vi(e):null}class bi{constructor(t,i,s=50){this.Pn=0,this.Cn=1,this.Tn=1,this.Rn=new Map,this.kn=new Map,this.Ho=t,this.$o=i,this.Dn=s}Uo(t){const i=t.time,s=this.$o.cacheKey(i),n=this.Rn.get(s);if(void 0!==n)return n.jo;if(this.Pn===this.Dn){const t=this.kn.get(this.Tn);this.kn.delete(this.Tn),this.Rn.delete(h(t)),this.Tn++,this.Pn--}const e=this.Ho(t);return this.Rn.set(s,{jo:e,In:this.Cn}),this.kn.set(this.Cn,s),this.Pn++,this.Cn++,e}}class Mi{constructor(t,i){r(t<=i,"right should be >= left"),this.Yo=t,this.Xo=i}Hh(){return this.Yo}Mi(){return this.Xo}Zo(){return this.Xo-this.Yo+1}Te(t){return this.Yo<=t&&t<=this.Xo}We(t){return this.Yo===t.Hh()&&this.Xo===t.Mi()}}function Si(t,i){return null===t||null===i?t===i:t.We(i)}class xi{constructor(){this.qo=new Map,this.Rn=null,this.Ko=!1}Go(t){this.Ko=t,this.Rn=null}Jo(t,i){this.Qo(i),this.Rn=null;for(let s=i;s{t<=s[0].index?i.push(n):s.splice(Mt(s,t,(i=>i.index!i||s.has(t.index);for(const i of Array.from(this.qo.keys()).sort(((t,i)=>i-t))){if(!this.qo.get(i))continue;const s=n;n=[];const r=s.length;let l=0;const a=h(this.qo.get(i)),o=a.length;let _=1/0,u=-1/0;for(let i=0;i=t&&o-u>=t&&e(h))n.push(h),u=o;else if(this.Ko)return s}for(;li.weight?t:i}class Ci{constructor(t,i,s,n){this.so=0,this.o_=null,this.__=[],this.la=null,this.ha=null,this.u_=new xi,this.c_=new Map,this.d_=yi.a_(),this.f_=!0,this.p_=new o,this.v_=new o,this.m_=new o,this.w_=null,this.g_=null,this.b_=new Map,this.M_=-1,this.S_=[],this.ys=i,this.ua=s,this.x_=i.rightOffset,this.y_=i.barSpacing,this.ts=t,this.$o=n,this.P_(),this.u_.Go(i.uniformDistribution),this.C_()}N(){return this.ys}T_(t){_(this.ua,t),this.k_(),this.P_()}rr(t,i){_(this.ys,t),this.ys.fixLeftEdge&&this.R_(),this.ys.fixRightEdge&&this.D_(),void 0!==t.barSpacing&&this.ts.cn(t.barSpacing),void 0!==t.rightOffset&&this.ts.dn(t.rightOffset),void 0===t.minBarSpacing&&void 0===t.maxBarSpacing||this.ts.cn(t.barSpacing??this.y_),void 0!==t.ignoreWhitespaceIndices&&t.ignoreWhitespaceIndices!==this.ys.ignoreWhitespaceIndices&&this.C_(),this.k_(),this.P_(),this.m_.p()}ks(t){return this.__[t]?.time??null}ss(t){return this.__[t]??null}E_(t,i){if(this.__.length<1)return null;if(this.$o.key(t)>this.$o.key(this.__[this.__.length-1].time))return i?this.__.length-1:null;const s=Mt(this.__,this.$o.key(t),((t,i)=>this.$o.key(t.time)0}ye(){return this.V_(),this.d_.h_()}I_(){return this.V_(),this.d_.l_()}A_(){const t=this.ye();if(null===t)return null;const i={from:t.Hh(),to:t.Mi()};return this.B_(i)}B_(t){const i=Math.round(t.from),s=Math.round(t.to),n=l(this.L_()),e=l(this.O_());return{from:l(this.ss(Math.max(n,i))),to:l(this.ss(Math.min(e,s)))}}N_(t){return{from:l(this.E_(t.from,!0)),to:l(this.E_(t.to,!0))}}Qi(){return this.so}po(t){if(!isFinite(t)||t<=0)return;if(this.so===t)return;const i=this.I_(),s=this.so;if(this.so=t,this.f_=!0,this.ys.lockVisibleTimeRangeOnResize&&0!==s){const i=this.y_*t/s;this.y_=i}if(this.ys.fixLeftEdge&&null!==i&&i.Hh()<=0){const i=s-t;this.x_-=Math.round(i/this.y_)+1,this.f_=!0}this.F_(),this.W_()}jt(t){if(this.Zi()||!c(t))return 0;const i=this.H_()+this.x_-t;return this.so-(i+.5)*this.y_-1}U_(t,i){const s=this.H_(),n=void 0===i?0:i.from,e=void 0===i?t.length:i.to;for(let i=n;ii/2&&!_?s.needAlignCoordinate=!1:s.needAlignCoordinate=u&&t.index<=a||c&&t.index>=o,d++}return this.S_.length=d,this.g_=this.S_,this.S_}iu(){this.f_=!0,this.cn(this.ys.barSpacing),this.dn(this.ys.rightOffset)}su(t){this.f_=!0,this.o_=t,this.W_(),this.R_()}nu(t,i){const s=this.Y_(t),n=this.K_(),e=n+i*(n/10);this.cn(e),this.ys.rightBarStaysOnScroll||this.dn(this.J_()+(s-this.Y_(t)))}$a(t){this.la&&this.Za(),null===this.ha&&null===this.w_&&(this.Zi()||(this.ha=t,this.eu()))}Ua(t){if(null===this.w_)return;const i=Yt(this.so-t,0,this.so),s=Yt(this.so-l(this.ha),0,this.so);0!==i&&0!==s&&this.cn(this.w_.K_*i/s)}ja(){null!==this.ha&&(this.ha=null,this.ru())}Ya(t){null===this.la&&null===this.w_&&(this.Zi()||(this.la=t,this.eu()))}Xa(t){if(null===this.la)return;const i=(this.la-t)/this.K_();this.x_=l(this.w_).J_+i,this.f_=!0,this.W_()}Za(){null!==this.la&&(this.la=null,this.ru())}hu(){this.lu(this.ys.rightOffset)}lu(t,i=400){if(!isFinite(t))throw new RangeError("offset is required and must be finite number");if(!isFinite(i)||i<=0)throw new RangeError("animationDuration (optional) must be finite positive number");const s=this.x_,n=performance.now();this.ts.an({au:t=>(t-n)/i>=1,ou:e=>{const r=(e-n)/i;return r>=1?t:s+(t-s)*r}})}Ct(t,i){this.f_=!0,this.__=t,this.u_.Jo(t,i),this.W_()}_u(){return this.p_}uu(){return this.v_}cu(){return this.m_}H_(){return this.o_||0}du(t){const i=t.Zo();this.G_(this.so/i),this.x_=t.Mi()-this.H_(),this.W_(),this.f_=!0,this.ts.q_(),this.ts.hr()}fu(){const t=this.L_(),i=this.O_();null!==t&&null!==i&&this.du(new Mi(t,i+this.ys.rightOffset))}pu(t){const i=new Mi(t.from,t.to);this.du(i)}ns(t){return void 0!==this.ua.timeFormatter?this.ua.timeFormatter(t.originalTime):this.$o.formatHorzItem(t.time)}C_(){if(!this.ys.ignoreWhitespaceIndices)return;this.b_.clear();const t=this.ts.Ys();for(const i of t)for(const t of i.vl())this.b_.set(t,!0);this.M_++}Q_(){const t=this.ts.N().handleScroll,i=this.ts.N().handleScale;return!(t.horzTouchDrag||t.mouseWheel||t.pressedMouseMove||t.vertTouchDrag||i.axisDoubleClickReset.time||i.axisPressedMouseMove.time||i.mouseWheel||i.pinch)}L_(){return 0===this.__.length?null:0}O_(){return 0===this.__.length?null:this.__.length-1}vu(t){return(this.so-1-t)/this.y_}Y_(t){const i=this.vu(t),s=this.H_()+this.x_-i;return Math.round(1e6*s)/1e6}G_(t){const i=this.y_;this.y_=t,this.F_(),i!==this.y_&&(this.f_=!0,this.mu())}V_(){if(!this.f_)return;if(this.f_=!1,this.Zi())return void this.wu(yi.a_());const t=this.H_(),i=this.so/this.y_,s=this.x_+t,n=new Mi(s-i+1,s);this.wu(new yi(n))}F_(){const t=Yt(this.y_,this.gu(),this.bu());this.y_!==t&&(this.y_=t,this.f_=!0)}bu(){return this.ys.maxBarSpacing>0?this.ys.maxBarSpacing:.5*this.so}gu(){return this.ys.fixLeftEdge&&this.ys.fixRightEdge&&0!==this.__.length?this.so/this.__.length:this.ys.minBarSpacing}W_(){const t=this.Mu();null!==t&&this.x_i&&(this.x_=i,this.f_=!0)}Mu(){const t=this.L_(),i=this.o_;if(null===t||null===i)return null;return t-i-1+(this.ys.fixLeftEdge?this.so/this.y_:Math.min(2,this.__.length))}Su(){return this.ys.fixRightEdge?0:this.so/this.y_-Math.min(2,this.__.length)}eu(){this.w_={K_:this.K_(),J_:this.J_()}}ru(){this.w_=null}tu(t){let i=this.c_.get(t.weight);return void 0===i&&(i=new bi((t=>this.xu(t)),this.$o),this.c_.set(t.weight,i)),i.Uo(t)}xu(t){return this.$o.formatTickmark(t,this.ua)}wu(t){const i=this.d_;this.d_=t,Si(i.h_(),this.d_.h_())||this.p_.p(),Si(i.l_(),this.d_.l_())||this.v_.p(),this.mu()}mu(){this.g_=null}k_(){this.mu(),this.c_.clear()}P_(){this.$o.updateFormatter(this.ua)}R_(){if(!this.ys.fixLeftEdge)return;const t=this.L_();if(null===t)return;const i=this.ye();if(null===i)return;const s=i.Hh()-t;if(s<0){const t=this.x_-s-1;this.dn(t)}this.F_()}D_(){this.W_(),this.F_()}X_(t){return!this.ys.ignoreWhitespaceIndices||(this.b_.get(t)||!1)}Z_(t){const i=function*(t){const i=Math.round(t),s=is)break}return t}}var Ti,ki,Ri,Di,Ei;!function(t){t[t.OnTouchEnd=0]="OnTouchEnd",t[t.OnNextTap=1]="OnNextTap"}(Ti||(Ti={}));class zi{constructor(t,i,s){this.yu=[],this.Pu=[],this.so=0,this.Cu=null,this.Tu=new o,this.ku=new o,this.Ru=null,this.Du=t,this.ys=i,this.$o=s,this.ca=new x(this.ys.layout.colorParsers),this.Eu=new b(this),this._h=new Ci(this,i.timeScale,this.ys.localization,s),this.yt=new j(this,i.crosshair),this.zu=new jt(i.crosshair),this.Vu(0),this.yu[0].fo(2e3),this.Iu=this.Au(0),this.Bu=this.Au(1)}zh(){this.Lu(X.wn())}hr(){this.Lu(X.mn())}qh(){this.Lu(new X(1))}Vh(t){const i=this.Ou(t);this.Lu(i)}Nu(){return this.Cu}Fu(t){if(this.Cu?.Lo===t?.Lo&&this.Cu?.Oo?.Xn===t?.Oo?.Xn)return;const i=this.Cu;this.Cu=t,null!==i&&this.Vh(i.Lo),null!==t&&t.Lo!==i?.Lo&&this.Vh(t.Lo)}N(){return this.ys}rr(t){_(this.ys,t),this.yu.forEach((i=>i._o(t))),void 0!==t.timeScale&&this._h.rr(t.timeScale),void 0!==t.localization&&this._h.T_(t.localization),(t.leftPriceScale||t.rightPriceScale)&&this.Tu.p(),this.Iu=this.Au(0),this.Bu=this.Au(1),this.zh()}Wu(t,i,s=0){const n=this.yu[s];if(void 0===n)return;if("left"===t)return _(this.ys,{leftPriceScale:i}),n._o({leftPriceScale:i}),this.Tu.p(),void this.zh();if("right"===t)return _(this.ys,{rightPriceScale:i}),n._o({rightPriceScale:i}),this.Tu.p(),void this.zh();const e=this.Hu(t,s);null!==e&&(e.Ft.rr(i),this.Tu.p())}Hu(t,i){const s=this.yu[i];if(void 0===s)return null;const n=s.uo(t);return null!==n?{Hs:s,Ft:n}:null}It(){return this._h}$s(){return this.yu}$u(){return this.yt}Uu(){return this.ku}ju(t,i){t.ya(i),this.q_()}po(t){this.so=t,this._h.po(this.so),this.yu.forEach((i=>i.po(t))),this.q_()}Yu(t){1!==this.yu.length&&(r(t>=0&&t=0&&tt+i.do()),0),e=this.yu.reduce(((t,i)=>t+i.Ut()),0),h=e-30*(this.yu.length-1);i=Math.min(h,Math.max(30,i));const l=n/e,a=s.Ut();s.fo(i*l);let o=i-a,_=this.yu.length-1;for(const t of this.yu)if(t!==s){const i=Math.min(h,Math.max(30,t.Ut()-o/_));o-=t.Ut()-i,_-=1;const s=i*l;t.fo(s)}this.zh()}Zu(t,i){r(t>=0&&t=0&&ithis.$o.key(e),a=null!==t&&t>r&&!l,o=this._h.N().allowShiftVisibleRangeOnWhitespaceReplacement,_=i&&(!(void 0===s)||o)&&this._h.N().shiftVisibleRangeOnNewBar;if(a&&!_){const i=t-r;this._h.dn(this._h.J_()-i)}}this._h.su(t)}Bh(t){null!==t&&t.zo()}Wn(t){if(function(t){return t instanceof pi}(t))return t;const i=this.yu.find((i=>i.Dt().includes(t)));return void 0===i?null:i}q_(){this.yu.forEach((t=>t.zo())),this.Ih()}m(){this.yu.forEach((t=>t.m())),this.yu.length=0,this.ys.localization.priceFormatter=void 0,this.ys.localization.percentageFormatter=void 0,this.ys.localization.timeFormatter=void 0}oc(){return this.Eu}jn(){return this.Eu.N()}co(){return this.Tu}_c(t,i){const s=this.Vu(i);this.uc(t,s),this.Pu.push(t),1===this.Pu.length?this.zh():this.hr()}cc(t){const i=this.Wn(t),s=this.Pu.indexOf(t);r(-1!==s,"Series not found");const n=l(i);this.Pu.splice(s,1),n.Fa(t),t.m&&t.m(),this._h.C_(),this.dc(n)}Eh(t,i){const s=l(this.Wn(t));s.Fa(t,!0),s.Oa(t,i,!0)}fu(){const t=X.mn();t.en(),this.Lu(t)}fc(t){const i=X.mn();i.ln(t),this.Lu(i)}un(){const t=X.mn();t.un(),this.Lu(t)}cn(t){const i=X.mn();i.cn(t),this.Lu(i)}dn(t){const i=X.mn();i.dn(t),this.Lu(i)}an(t){const i=X.mn();i.an(t),this.Lu(i)}rn(){const t=X.mn();t.rn(),this.Lu(t)}vc(){return this.ys.rightPriceScale.visible?"right":"left"}mc(t,i){r(i>=0,"Index should be greater or equal to 0");if(i===this.wc(t))return;const s=l(this.Wn(t));s.Fa(t);const n=this.Vu(i);this.uc(t,n),0===s.bl().length&&this.dc(s)}gc(){return this.Bu}U(){return this.Iu}$t(t){const i=this.Bu,s=this.Iu;if(i===s)return i;if(t=Math.max(0,Math.min(100,Math.round(100*t))),null===this.Ru||this.Ru.vr!==s||this.Ru.mr!==i)this.Ru={vr:s,mr:i,bc:new Map};else{const i=this.Ru.bc.get(t);if(void 0!==i)return i}const n=this.ca.tt(s,i,t/100);return this.Ru.bc.set(t,n),n}Mc(t){return this.yu.indexOf(t)}qi(){return this.ca}Vu(t){if(r(t>=0,"Index should be greater or equal to 0"),(t=Math.min(this.yu.length,t))i.mo().includes(t)))}qu(t,i){const s=new X(i);if(null!==t){const n=this.yu.indexOf(t);s.Js(n,{Qs:i})}return s}Ou(t,i){return void 0===i&&(i=2),this.qu(this.Wn(t),i)}Lu(t){this.Du&&this.Du(t),this.yu.forEach((t=>t.Ao().lr().Ct()))}uc(t,i){const s=t.N().priceScaleId,n=void 0!==s?s:this.vc();i.Oa(t,n),Y(n)||t.rr(t.N())}Au(t){const i=this.ys.layout;return"gradient"===i.background.type?0===t?i.background.topColor:i.background.bottomColor:i.background.color}dc(t){0===t.bl().length&&this.yu.length>1&&(this.yu.splice(this.Mc(t),1),this.zh())}}function Vi(t){return!u(t)&&!d(t)}function Ii(t){return u(t)}!function(t){t[t.Disabled=0]="Disabled",t[t.Continuous=1]="Continuous",t[t.OnDataUpdate=2]="OnDataUpdate"}(ki||(ki={})),function(t){t[t.LastBar=0]="LastBar",t[t.LastVisible=1]="LastVisible"}(Ri||(Ri={})),function(t){t.Solid="solid",t.VerticalGradient="gradient"}(Di||(Di={})),function(t){t[t.Year=0]="Year",t[t.Month=1]="Month",t[t.DayOfMonth=2]="DayOfMonth",t[t.Time=3]="Time",t[t.TimeWithSeconds=4]="TimeWithSeconds"}(Ei||(Ei={}));const Ai=t=>t.getUTCFullYear();function Bi(t,i,s){return i.replace(/yyyy/g,(t=>q(Ai(t),4))(t)).replace(/yy/g,(t=>q(Ai(t)%100,2))(t)).replace(/MMMM/g,((t,i)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"long"}))(t,s)).replace(/MMM/g,((t,i)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"short"}))(t,s)).replace(/MM/g,(t=>q((t=>t.getUTCMonth()+1)(t),2))(t)).replace(/dd/g,(t=>q((t=>t.getUTCDate())(t),2))(t))}class Li{constructor(t="yyyy-MM-dd",i="default"){this.Sc=t,this.xc=i}Uo(t){return Bi(t,this.Sc,this.xc)}}class Oi{constructor(t){this.yc=t||"%h:%m:%s"}Uo(t){return this.yc.replace("%h",q(t.getUTCHours(),2)).replace("%m",q(t.getUTCMinutes(),2)).replace("%s",q(t.getUTCSeconds(),2))}}const Ni={Pc:"yyyy-MM-dd",Cc:"%h:%m:%s",Tc:" ",kc:"default"};class Fi{constructor(t={}){const i={...Ni,...t};this.Rc=new Li(i.Pc,i.kc),this.Dc=new Oi(i.Cc),this.Ec=i.Tc}Uo(t){return`${this.Rc.Uo(t)}${this.Ec}${this.Dc.Uo(t)}`}}function Wi(t){return 60*t*60*1e3}function Hi(t){return 60*t*1e3}const $i=[{zc:(Ui=1,1e3*Ui),Vc:10},{zc:Hi(1),Vc:20},{zc:Hi(5),Vc:21},{zc:Hi(30),Vc:22},{zc:Wi(1),Vc:30},{zc:Wi(3),Vc:31},{zc:Wi(6),Vc:32},{zc:Wi(12),Vc:33}];var Ui;function ji(t,i){if(t.getUTCFullYear()!==i.getUTCFullYear())return 70;if(t.getUTCMonth()!==i.getUTCMonth())return 60;if(t.getUTCDate()!==i.getUTCDate())return 50;for(let s=$i.length-1;s>=0;--s)if(Math.floor(i.getTime()/$i[s].zc)!==Math.floor(t.getTime()/$i[s].zc))return $i[s].Vc;return 0}function Yi(t){let i=t;if(d(t)&&(i=Zi(t)),!Vi(i))throw new Error("time must be of type BusinessDay");const s=new Date(Date.UTC(i.year,i.month-1,i.day,0,0,0,0));return{Ic:Math.round(s.getTime()/1e3),Ac:i}}function Xi(t){if(!Ii(t))throw new Error("time must be of type isUTCTimestamp");return{Ic:t}}function Zi(t){const i=new Date(t);if(isNaN(i.getTime()))throw new Error(`Invalid date string=${t}, expected format=yyyy-mm-dd`);return{day:i.getUTCDate(),month:i.getUTCMonth()+1,year:i.getUTCFullYear()}}function qi(t){d(t.time)&&(t.time=Zi(t.time))}class Ki{options(){return this.ys}setOptions(t){this.ys=t,this.updateFormatter(t.localization)}preprocessData(t){Array.isArray(t)?function(t){t.forEach(qi)}(t):qi(t)}createConverterToInternalObj(t){return l(function(t){return 0===t.length?null:Vi(t[0].time)||d(t[0].time)?Yi:Xi}(t))}key(t){return"object"==typeof t&&"Ic"in t?t.Ic:this.key(this.convertHorzItemToInternal(t))}cacheKey(t){const i=t;return void 0===i.Ac?new Date(1e3*i.Ic).getTime():new Date(Date.UTC(i.Ac.year,i.Ac.month-1,i.Ac.day)).getTime()}convertHorzItemToInternal(t){return Ii(i=t)?Xi(i):Vi(i)?Yi(i):Yi(Zi(i));var i}updateFormatter(t){if(!this.ys)return;const i=t.dateFormat;this.ys.timeScale.timeVisible?this.Bc=new Fi({Pc:i,Cc:this.ys.timeScale.secondsVisible?"%h:%m:%s":"%h:%m",Tc:" ",kc:t.locale}):this.Bc=new Li(i,t.locale)}formatHorzItem(t){const i=t;return this.Bc.Uo(new Date(1e3*i.Ic))}formatTickmark(t,i){const s=function(t,i,s){switch(t){case 0:case 10:return i?s?4:3:2;case 20:case 21:case 22:case 30:case 31:case 32:case 33:return i?3:2;case 50:return 2;case 60:return 1;case 70:return 0}}(t.weight,this.ys.timeScale.timeVisible,this.ys.timeScale.secondsVisible),n=this.ys.timeScale;if(void 0!==n.tickMarkFormatter){const e=n.tickMarkFormatter(t.originalTime,s,i.locale);if(null!==e)return e}return function(t,i,s){const n={};switch(i){case 0:n.year="numeric";break;case 1:n.month="short";break;case 2:n.day="numeric";break;case 3:n.hour12=!1,n.hour="2-digit",n.minute="2-digit";break;case 4:n.hour12=!1,n.hour="2-digit",n.minute="2-digit",n.second="2-digit"}const e=void 0===t.Ac?new Date(1e3*t.Ic):new Date(Date.UTC(t.Ac.year,t.Ac.month-1,t.Ac.day));return new Date(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()).toLocaleString(s,n)}(t.time,s,i.locale)}maxTickMarkWeight(t){let i=t.reduce(Pi,t[0]).weight;return i>30&&i<50&&(i=30),i}fillWeightsForPoints(t,i){!function(t,i=0){if(0===t.length)return;let s=0===i?null:t[i-1].time.Ic,n=null!==s?new Date(1e3*s):null,e=0;for(let r=i;r1){const i=Math.ceil(e/(t.length-1)),s=new Date(1e3*(t[0].time.Ic-i));t[0].timeWeight=ji(new Date(1e3*t[0].time.Ic),s)}}(t,i)}static Lc(t){return _({localization:{dateFormat:"dd MMM 'yy"}},t??{})}}function Gi(t){var i=t.width,s=t.height;if(i<0)throw new Error("Negative width is not allowed for Size");if(s<0)throw new Error("Negative height is not allowed for Size");return{width:i,height:s}}function Ji(t,i){return t.width===i.width&&t.height===i.height}var Qi=function(){function t(t){var i=this;this._resolutionListener=function(){return i._onResolutionChanged()},this._resolutionMediaQueryList=null,this._observers=[],this._window=t,this._installResolutionListener()}return t.prototype.dispose=function(){this._uninstallResolutionListener(),this._window=null},Object.defineProperty(t.prototype,"value",{get:function(){return this._window.devicePixelRatio},enumerable:!1,configurable:!0}),t.prototype.subscribe=function(t){var i=this,s={next:t};return this._observers.push(s),{unsubscribe:function(){i._observers=i._observers.filter((function(t){return t!==s}))}}},t.prototype._installResolutionListener=function(){if(null!==this._resolutionMediaQueryList)throw new Error("Resolution listener is already installed");var t=this._window.devicePixelRatio;this._resolutionMediaQueryList=this._window.matchMedia("all and (resolution: ".concat(t,"dppx)")),this._resolutionMediaQueryList.addListener(this._resolutionListener)},t.prototype._uninstallResolutionListener=function(){null!==this._resolutionMediaQueryList&&(this._resolutionMediaQueryList.removeListener(this._resolutionListener),this._resolutionMediaQueryList=null)},t.prototype._reinstallResolutionListener=function(){this._uninstallResolutionListener(),this._installResolutionListener()},t.prototype._onResolutionChanged=function(){var t=this;this._observers.forEach((function(i){return i.next(t._window.devicePixelRatio)})),this._reinstallResolutionListener()},t}();var ts=function(){function t(t,i,s){var n;this._canvasElement=null,this._bitmapSizeChangedListeners=[],this._suggestedBitmapSize=null,this._suggestedBitmapSizeChangedListeners=[],this._devicePixelRatioObservable=null,this._canvasElementResizeObserver=null,this._canvasElement=t,this._canvasElementClientSize=Gi({width:this._canvasElement.clientWidth,height:this._canvasElement.clientHeight}),this._transformBitmapSize=null!=i?i:function(t){return t},this._allowResizeObserver=null===(n=null==s?void 0:s.allowResizeObserver)||void 0===n||n,this._chooseAndInitObserver()}return t.prototype.dispose=function(){var t,i;if(null===this._canvasElement)throw new Error("Object is disposed");null===(t=this._canvasElementResizeObserver)||void 0===t||t.disconnect(),this._canvasElementResizeObserver=null,null===(i=this._devicePixelRatioObservable)||void 0===i||i.dispose(),this._devicePixelRatioObservable=null,this._suggestedBitmapSizeChangedListeners.length=0,this._bitmapSizeChangedListeners.length=0,this._canvasElement=null},Object.defineProperty(t.prototype,"canvasElement",{get:function(){if(null===this._canvasElement)throw new Error("Object is disposed");return this._canvasElement},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasElementClientSize",{get:function(){return this._canvasElementClientSize},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bitmapSize",{get:function(){return Gi({width:this.canvasElement.width,height:this.canvasElement.height})},enumerable:!1,configurable:!0}),t.prototype.resizeCanvasElement=function(t){this._canvasElementClientSize=Gi(t),this.canvasElement.style.width="".concat(this._canvasElementClientSize.width,"px"),this.canvasElement.style.height="".concat(this._canvasElementClientSize.height,"px"),this._invalidateBitmapSize()},t.prototype.subscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners.push(t)},t.prototype.unsubscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners=this._bitmapSizeChangedListeners.filter((function(i){return i!==t}))},Object.defineProperty(t.prototype,"suggestedBitmapSize",{get:function(){return this._suggestedBitmapSize},enumerable:!1,configurable:!0}),t.prototype.subscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners.push(t)},t.prototype.unsubscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners=this._suggestedBitmapSizeChangedListeners.filter((function(i){return i!==t}))},t.prototype.applySuggestedBitmapSize=function(){if(null!==this._suggestedBitmapSize){var t=this._suggestedBitmapSize;this._suggestedBitmapSize=null,this._resizeBitmap(t),this._emitSuggestedBitmapSizeChanged(t,this._suggestedBitmapSize)}},t.prototype._resizeBitmap=function(t){var i=this.bitmapSize;Ji(i,t)||(this.canvasElement.width=t.width,this.canvasElement.height=t.height,this._emitBitmapSizeChanged(i,t))},t.prototype._emitBitmapSizeChanged=function(t,i){var s=this;this._bitmapSizeChangedListeners.forEach((function(n){return n.call(s,t,i)}))},t.prototype._suggestNewBitmapSize=function(t){var i=this._suggestedBitmapSize,s=Gi(this._transformBitmapSize(t,this._canvasElementClientSize)),n=Ji(this.bitmapSize,s)?null:s;null===i&&null===n||null!==i&&null!==n&&Ji(i,n)||(this._suggestedBitmapSize=n,this._emitSuggestedBitmapSizeChanged(i,n))},t.prototype._emitSuggestedBitmapSizeChanged=function(t,i){var s=this;this._suggestedBitmapSizeChangedListeners.forEach((function(n){return n.call(s,t,i)}))},t.prototype._chooseAndInitObserver=function(){var t=this;this._allowResizeObserver?new Promise((function(t){var i=new ResizeObserver((function(s){t(s.every((function(t){return"devicePixelContentBoxSize"in t}))),i.disconnect()}));i.observe(document.body,{box:"device-pixel-content-box"})})).catch((function(){return!1})).then((function(i){return i?t._initResizeObserver():t._initDevicePixelRatioObservable()})):this._initDevicePixelRatioObservable()},t.prototype._initDevicePixelRatioObservable=function(){var t=this;if(null!==this._canvasElement){var i=is(this._canvasElement);if(null===i)throw new Error("No window is associated with the canvas");this._devicePixelRatioObservable=function(t){return new Qi(t)}(i),this._devicePixelRatioObservable.subscribe((function(){return t._invalidateBitmapSize()})),this._invalidateBitmapSize()}},t.prototype._invalidateBitmapSize=function(){var t,i;if(null!==this._canvasElement){var s=is(this._canvasElement);if(null!==s){var n=null!==(i=null===(t=this._devicePixelRatioObservable)||void 0===t?void 0:t.value)&&void 0!==i?i:s.devicePixelRatio,e=this._canvasElement.getClientRects(),r=void 0!==e[0]?function(t,i){return Gi({width:Math.round(t.left*i+t.width*i)-Math.round(t.left*i),height:Math.round(t.top*i+t.height*i)-Math.round(t.top*i)})}(e[0],n):Gi({width:this._canvasElementClientSize.width*n,height:this._canvasElementClientSize.height*n});this._suggestNewBitmapSize(r)}}},t.prototype._initResizeObserver=function(){var t=this;null!==this._canvasElement&&(this._canvasElementResizeObserver=new ResizeObserver((function(i){var s=i.find((function(i){return i.target===t._canvasElement}));if(s&&s.devicePixelContentBoxSize&&s.devicePixelContentBoxSize[0]){var n=s.devicePixelContentBoxSize[0],e=Gi({width:n.inlineSize,height:n.blockSize});t._suggestNewBitmapSize(e)}})),this._canvasElementResizeObserver.observe(this._canvasElement,{box:"device-pixel-content-box"}))},t}();function is(t){return t.ownerDocument.defaultView}var ss=function(){function t(t,i,s){if(0===i.width||0===i.height)throw new TypeError("Rendering target could only be created on a media with positive width and height");if(this._mediaSize=i,0===s.width||0===s.height)throw new TypeError("Rendering target could only be created using a bitmap with positive integer width and height");this._bitmapSize=s,this._context=t}return t.prototype.useMediaCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),this._context.scale(this._horizontalPixelRatio,this._verticalPixelRatio),t({context:this._context,mediaSize:this._mediaSize})}finally{this._context.restore()}},t.prototype.useBitmapCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),t({context:this._context,mediaSize:this._mediaSize,bitmapSize:this._bitmapSize,horizontalPixelRatio:this._horizontalPixelRatio,verticalPixelRatio:this._verticalPixelRatio})}finally{this._context.restore()}},Object.defineProperty(t.prototype,"_horizontalPixelRatio",{get:function(){return this._bitmapSize.width/this._mediaSize.width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_verticalPixelRatio",{get:function(){return this._bitmapSize.height/this._mediaSize.height},enumerable:!1,configurable:!0}),t}();function ns(t,i){var s=t.canvasElementClientSize;if(0===s.width||0===s.height)return null;var n=t.bitmapSize;if(0===n.width||0===n.height)return null;var e=t.canvasElement.getContext("2d",i);return null===e?null:new ss(e,s,n)}const es="undefined"!=typeof window;function rs(){return!!es&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function hs(){return!!es&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function ls(t){return t+t%2}function as(t){es&&void 0!==window.chrome&&t.addEventListener("mousedown",(t=>{if(1===t.button)return t.preventDefault(),!1}))}class os{constructor(t,i,s){this.Oc=0,this.Nc=null,this.Fc={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.Wc=0,this.Hc=null,this.$c={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.Uc=null,this.jc=!1,this.Yc=null,this.Xc=null,this.Zc=!1,this.qc=!1,this.Kc=!1,this.Gc=null,this.Jc=null,this.Qc=null,this.td=null,this.sd=null,this.nd=null,this.ed=null,this.rd=0,this.hd=!1,this.ld=!1,this.ad=!1,this.od=0,this._d=null,this.ud=!hs(),this.dd=t=>{this.fd(t)},this.pd=t=>{if(this.vd(t)){const i=this.md(t);if(++this.Wc,this.Hc&&this.Wc>1){const{wd:s}=this.gd(cs(t),this.$c);s<30&&!this.Kc&&this.bd(i,this.Sd.Md),this.xd()}}else{const i=this.md(t);if(++this.Oc,this.Nc&&this.Oc>1){const{wd:s}=this.gd(cs(t),this.Fc);s<5&&!this.qc&&this.yd(i,this.Sd.Pd),this.Cd()}}},this.Td=t,this.Sd=i,this.ys=s,this.kd()}m(){null!==this.Gc&&(this.Gc(),this.Gc=null),null!==this.Jc&&(this.Jc(),this.Jc=null),null!==this.td&&(this.td(),this.td=null),null!==this.sd&&(this.sd(),this.sd=null),null!==this.nd&&(this.nd(),this.nd=null),null!==this.Qc&&(this.Qc(),this.Qc=null),this.Rd(),this.Cd()}Dd(t){this.td&&this.td();const i=this.Ed.bind(this);if(this.td=()=>{this.Td.removeEventListener("mousemove",i)},this.Td.addEventListener("mousemove",i),this.vd(t))return;const s=this.md(t);this.yd(s,this.Sd.zd),this.ud=!0}Cd(){null!==this.Nc&&clearTimeout(this.Nc),this.Oc=0,this.Nc=null,this.Fc={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}xd(){null!==this.Hc&&clearTimeout(this.Hc),this.Wc=0,this.Hc=null,this.$c={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}Ed(t){if(this.ad||null!==this.Xc)return;if(this.vd(t))return;const i=this.md(t);this.yd(i,this.Sd.Vd),this.ud=!0}Id(t){const i=fs(t.changedTouches,l(this._d));if(null===i)return;if(this.od=ds(t),null!==this.ed)return;if(this.ld)return;this.hd=!0;const s=this.gd(cs(i),l(this.Xc)),{Ad:n,Bd:e,wd:r}=s;if(this.Zc||!(r<5)){if(!this.Zc){const t=.5*n,i=e>=t&&!this.ys.Ld(),s=t>e&&!this.ys.Od();i||s||(this.ld=!0),this.Zc=!0,this.Kc=!0,this.Rd(),this.xd()}if(!this.ld){const s=this.md(t,i);this.bd(s,this.Sd.Nd),us(t)}}}Fd(t){if(0!==t.button)return;const i=this.gd(cs(t),l(this.Yc)),{wd:s}=i;if(s>=5&&(this.qc=!0,this.Cd()),this.qc){const i=this.md(t);this.yd(i,this.Sd.Wd)}}gd(t,i){const s=Math.abs(i._t-t._t),n=Math.abs(i.ut-t.ut);return{Ad:s,Bd:n,wd:s+n}}Hd(t){let i=fs(t.changedTouches,l(this._d));if(null===i&&0===t.touches.length&&(i=t.changedTouches[0]),null===i)return;this._d=null,this.od=ds(t),this.Rd(),this.Xc=null,this.nd&&(this.nd(),this.nd=null);const s=this.md(t,i);if(this.bd(s,this.Sd.$d),++this.Wc,this.Hc&&this.Wc>1){const{wd:t}=this.gd(cs(i),this.$c);t<30&&!this.Kc&&this.bd(s,this.Sd.Md),this.xd()}else this.Kc||(this.bd(s,this.Sd.Ud),this.Sd.Ud&&us(t));0===this.Wc&&us(t),0===t.touches.length&&this.jc&&(this.jc=!1,us(t))}fd(t){if(0!==t.button)return;const i=this.md(t);if(this.Yc=null,this.ad=!1,this.sd&&(this.sd(),this.sd=null),rs()){this.Td.ownerDocument.documentElement.removeEventListener("mouseleave",this.dd)}if(!this.vd(t))if(this.yd(i,this.Sd.jd),++this.Oc,this.Nc&&this.Oc>1){const{wd:s}=this.gd(cs(t),this.Fc);s<5&&!this.qc&&this.yd(i,this.Sd.Pd),this.Cd()}else this.qc||this.yd(i,this.Sd.Yd)}Rd(){null!==this.Uc&&(clearTimeout(this.Uc),this.Uc=null)}Xd(t){if(null!==this._d)return;const i=t.changedTouches[0];this._d=i.identifier,this.od=ds(t);const s=this.Td.ownerDocument.documentElement;this.Kc=!1,this.Zc=!1,this.ld=!1,this.Xc=cs(i),this.nd&&(this.nd(),this.nd=null);{const i=this.Id.bind(this),n=this.Hd.bind(this);this.nd=()=>{s.removeEventListener("touchmove",i),s.removeEventListener("touchend",n)},s.addEventListener("touchmove",i,{passive:!1}),s.addEventListener("touchend",n,{passive:!1}),this.Rd(),this.Uc=setTimeout(this.Zd.bind(this,t),240)}const n=this.md(t,i);this.bd(n,this.Sd.qd),this.Hc||(this.Wc=0,this.Hc=setTimeout(this.xd.bind(this),500),this.$c=cs(i))}Kd(t){if(0!==t.button)return;const i=this.Td.ownerDocument.documentElement;rs()&&i.addEventListener("mouseleave",this.dd),this.qc=!1,this.Yc=cs(t),this.sd&&(this.sd(),this.sd=null);{const t=this.Fd.bind(this),s=this.fd.bind(this);this.sd=()=>{i.removeEventListener("mousemove",t),i.removeEventListener("mouseup",s)},i.addEventListener("mousemove",t),i.addEventListener("mouseup",s)}if(this.ad=!0,this.vd(t))return;const s=this.md(t);this.yd(s,this.Sd.Gd),this.Nc||(this.Oc=0,this.Nc=setTimeout(this.Cd.bind(this),500),this.Fc=cs(t))}kd(){this.Td.addEventListener("mouseenter",this.Dd.bind(this)),this.Td.addEventListener("touchcancel",this.Rd.bind(this));{const t=this.Td.ownerDocument,i=t=>{this.Sd.Jd&&(t.composed&&this.Td.contains(t.composedPath()[0])||t.target&&this.Td.contains(t.target)||this.Sd.Jd())};this.Jc=()=>{t.removeEventListener("touchstart",i)},this.Gc=()=>{t.removeEventListener("mousedown",i)},t.addEventListener("mousedown",i),t.addEventListener("touchstart",i,{passive:!0})}hs()&&(this.Qc=()=>{this.Td.removeEventListener("dblclick",this.pd)},this.Td.addEventListener("dblclick",this.pd)),this.Td.addEventListener("mouseleave",this.Qd.bind(this)),this.Td.addEventListener("touchstart",this.Xd.bind(this),{passive:!0}),as(this.Td),this.Td.addEventListener("mousedown",this.Kd.bind(this)),this.tf(),this.Td.addEventListener("touchmove",(()=>{}),{passive:!1})}tf(){void 0===this.Sd.if&&void 0===this.Sd.sf&&void 0===this.Sd.nf||(this.Td.addEventListener("touchstart",(t=>this.ef(t.touches)),{passive:!0}),this.Td.addEventListener("touchmove",(t=>{if(2===t.touches.length&&null!==this.ed&&void 0!==this.Sd.sf){const i=_s(t.touches[0],t.touches[1])/this.rd;this.Sd.sf(this.ed,i),us(t)}}),{passive:!1}),this.Td.addEventListener("touchend",(t=>{this.ef(t.touches)})))}ef(t){1===t.length&&(this.hd=!1),2!==t.length||this.hd||this.jc?this.rf():this.hf(t)}hf(t){const i=this.Td.getBoundingClientRect()||{left:0,top:0};this.ed={_t:(t[0].clientX-i.left+(t[1].clientX-i.left))/2,ut:(t[0].clientY-i.top+(t[1].clientY-i.top))/2},this.rd=_s(t[0],t[1]),void 0!==this.Sd.if&&this.Sd.if(),this.Rd()}rf(){null!==this.ed&&(this.ed=null,void 0!==this.Sd.nf&&this.Sd.nf())}Qd(t){if(this.td&&this.td(),this.vd(t))return;if(!this.ud)return;const i=this.md(t);this.yd(i,this.Sd.lf),this.ud=!hs()}Zd(t){const i=fs(t.touches,l(this._d));if(null===i)return;const s=this.md(t,i);this.bd(s,this.Sd.af),this.Kc=!0,this.jc=!0}vd(t){return t.sourceCapabilities&&void 0!==t.sourceCapabilities.firesTouchEvents?t.sourceCapabilities.firesTouchEvents:ds(t){"touchstart"!==t.type&&us(t)}}}}function _s(t,i){const s=t.clientX-i.clientX,n=t.clientY-i.clientY;return Math.sqrt(s*s+n*n)}function us(t){t.cancelable&&t.preventDefault()}function cs(t){return{_t:t.pageX,ut:t.pageY}}function ds(t){return t.timeStamp||performance.now()}function fs(t,i){for(let s=0;s!1,Od:()=>!0}),this.ff={Ef:s,Df:t}}yf(){this.xf.style.background=this.wf.N().layout.panes.separatorColor}zf(t){null!==this.ff&&(this.ff.Ef.style.backgroundColor=this.wf.N().layout.panes.separatorHoverColor)}Vf(t){null!==this.ff&&null===this.mf&&(this.ff.Ef.style.backgroundColor="")}If(t){if(null===this.ff)return;const i=this.gf.Lf().do()+this.Mf.Lf().do(),s=i/(this.gf.Tf().height+this.Mf.Tf().height),n=30*s;i<=2*n||(this.mf={Of:t.pageY,Nf:this.gf.Lf().do(),Ff:i-n,Wf:i,Hf:s,$f:n},this.ff.Df.style.display="block")}Af(t){const i=this.mf;if(null===i)return;const s=(t.pageY-i.Of)*i.Hf,n=Yt(i.Nf+s,i.$f,i.Ff);this.gf.Lf().fo(n),this.Mf.Lf().fo(i.Wf-n),this.wf.Qt().zh()}Bf(t){null!==this.mf&&null!==this.ff&&(this.mf=null,this.ff.Df.style.display="none")}}function vs(t,i){return t.Uf-i.Uf}function ms(t,i,s){const n=(t.Uf-i.Uf)/(t.wt-i.wt);return Math.sign(n)*Math.min(Math.abs(n),s)}class ws{constructor(t,i,s,n){this.jf=null,this.Yf=null,this.Xf=null,this.Zf=null,this.qf=null,this.Kf=0,this.Gf=0,this.Jf=t,this.Qf=i,this.tp=s,this.gn=n}ip(t,i){if(null!==this.jf){if(this.jf.wt===i)return void(this.jf.Uf=t);if(Math.abs(this.jf.Uf-t)50)return;let s=0;const n=ms(this.jf,this.Yf,this.Qf),e=vs(this.jf,this.Yf),r=[n],h=[e];if(s+=e,null!==this.Xf){const t=ms(this.Yf,this.Xf,this.Qf);if(Math.sign(t)===Math.sign(n)){const i=vs(this.Yf,this.Xf);if(r.push(t),h.push(i),s+=i,null!==this.Zf){const t=ms(this.Xf,this.Zf,this.Qf);if(Math.sign(t)===Math.sign(n)){const i=vs(this.Xf,this.Zf);r.push(t),h.push(i),s+=i}}}}let l=0;for(let t=0;t160?"dark":"light"}up(){return this.lp.N().layout.attributionLogo}dp(){const t=new URL(location.href);return t.hostname?"&utm_source="+t.hostname+t.pathname:""}ap(){this._p()&&(this.op(),this.fs=this.up(),this.fs&&(this.rp=this.cp(),this.ep=document.createElement("style"),this.ep.innerText="a#tv-attr-logo{--fill:#131722;--stroke:#fff;position:absolute;left:10px;bottom:10px;height:19px;width:35px;margin:0;padding:0;border:0;z-index:3;}a#tv-attr-logo[data-dark]{--fill:#D1D4DC;--stroke:#131722;}",this.np=document.createElement("a"),this.np.href=`https://www.tradingview.com/?utm_medium=lwc-link&utm_campaign=lwc-chart${this.dp()}`,this.np.title="Charting by TradingView",this.np.id="tv-attr-logo",this.np.target="_blank",this.np.innerHTML='',this.np.toggleAttribute("data-dark","dark"===this.rp),this.hp.appendChild(this.ep),this.hp.appendChild(this.np)))}}function bs(t,i){const s=l(t.ownerDocument).createElement("canvas");t.appendChild(s);const n=function(t,i){if("device-pixel-content-box"===i.type)return new ts(t,i.transform,i.options);throw new Error("Unsupported binding target")}(s,{type:"device-pixel-content-box",options:{allowResizeObserver:!0},transform:(t,i)=>({width:Math.max(t.width,i.width),height:Math.max(t.height,i.height)})});return n.resizeCanvasElement(i),n}function Ms(t){t.width=1,t.height=1,t.getContext("2d")?.clearRect(0,0,1,1)}function Ss(t,i,s,n){t.th&&t.th(i,s,n)}function xs(t,i,s,n){t.nt(i,s,n)}function ys(t,i,s,n){const e=t(s,n);for(const t of e){const s=t.kt(n);null!==s&&i(s)}}function Ps(t,i){return s=>{if(!function(t){return void 0!==t.Ft}(s))return[];return(s.Ft()?.ml()??"")!==i?[]:s.Qh?.(t)??[]}}function Cs(t,i,s,n){if(!t.length)return;let e=0;const r=t[0].Ut(n,!0);let h=1===i?s/2-(t[0].Fi()-r/2):t[0].Fi()-r/2-s/2;h=Math.max(0,h);for(let r=1;ru-o:_s)&&h>0){const n=1===i?-1-r:r-s,l=Math.min(n,h);for(let s=e;s{this.gp||this.Pt.Mp().Qt().hr()},this.Sp=()=>{this.gp||this.Pt.Mp().Qt().hr()},this.Pt=t,this.ys=i,this._a=i.layout,this.Eu=s,this.xp="left"===n,this.yp=Ps("normal",n),this.Pp=Ps("top",n),this.Cp=Ps("bottom",n),this.xf=document.createElement("div"),this.xf.style.height="100%",this.xf.style.overflow="hidden",this.xf.style.width="25px",this.xf.style.left="0",this.xf.style.position="relative",this.Tp=bs(this.xf,Gi({width:16,height:16})),this.Tp.subscribeSuggestedBitmapSizeChanged(this.bp);const e=this.Tp.canvasElement;e.style.position="absolute",e.style.zIndex="1",e.style.left="0",e.style.top="0",this.kp=bs(this.xf,Gi({width:16,height:16})),this.kp.subscribeSuggestedBitmapSizeChanged(this.Sp);const r=this.kp.canvasElement;r.style.position="absolute",r.style.zIndex="2",r.style.left="0",r.style.top="0";const h={Gd:this.If.bind(this),qd:this.If.bind(this),Wd:this.Af.bind(this),Nd:this.Af.bind(this),Jd:this.Rp.bind(this),jd:this.Bf.bind(this),$d:this.Bf.bind(this),Pd:this.Dp.bind(this),Md:this.Dp.bind(this),zd:this.Ep.bind(this),lf:this.Vf.bind(this)};this.pf=new os(this.kp.canvasElement,h,{Ld:()=>!this.ys.handleScroll.vertTouchDrag,Od:()=>!0})}m(){this.pf.m(),this.kp.unsubscribeSuggestedBitmapSizeChanged(this.Sp),Ms(this.kp.canvasElement),this.kp.dispose(),this.Tp.unsubscribeSuggestedBitmapSizeChanged(this.bp),Ms(this.Tp.canvasElement),this.Tp.dispose(),null!==this.Yi&&this.Yi.Ha().u(this),this.Yi=null}Cf(){return this.xf}C(){return this._a.fontSize}zp(){const t=this.Eu.N();return this.mp!==t.T&&(this.vp.En(),this.mp=t.T),t}Vp(){if(null===this.Yi)return 0;let t=0;const i=this.zp(),s=l(this.Tp.canvasElement.getContext("2d",{colorSpace:this.Pt.Mp().N().layout.colorSpace}));s.save();const n=this.Yi.Dl();s.font=this.Ip(),n.length>0&&(t=Math.max(this.vp.Ei(s,n[0].$l),this.vp.Ei(s,n[n.length-1].$l)));const e=this.Ap();for(let i=e.length;i--;){const n=this.vp.Ei(s,e[i].ri());n>t&&(t=n)}const r=this.Yi.Bt();if(null!==r&&null!==this.fp&&(2!==(h=this.ys.crosshair).mode&&h.horzLine.visible&&h.horzLine.labelVisible)){const i=this.Yi.Ts(1,r),n=this.Yi.Ts(this.fp.height-2,r);t=Math.max(t,this.vp.Ei(s,this.Yi.Ki(Math.floor(Math.min(i,n))+.11111111111111,r)),this.vp.Ei(s,this.Yi.Ki(Math.ceil(Math.max(i,n))-.11111111111111,r)))}var h;s.restore();const a=t||34;return ls(Math.ceil(i.S+i.P+i.I+i.A+5+a))}Bp(t){null!==this.fp&&Ji(this.fp,t)||(this.fp=t,this.gp=!0,this.Tp.resizeCanvasElement(t),this.kp.resizeCanvasElement(t),this.gp=!1,this.xf.style.width=`${t.width}px`,this.xf.style.height=`${t.height}px`)}Lp(){return l(this.fp).width}os(t){this.Yi!==t&&(null!==this.Yi&&this.Yi.Ha().u(this),this.Yi=t,t.Ha().i(this.ta.bind(this),this))}Ft(){return this.Yi}En(){const t=this.Pt.Lf();this.Pt.Mp().Qt().Do(t,l(this.Ft()))}Op(t){if(null===this.fp)return;const i={colorSpace:this.Pt.Mp().N().layout.colorSpace};if(1!==t){this.Np(),this.Tp.applySuggestedBitmapSize();const t=ns(this.Tp,i);null!==t&&(t.useBitmapCoordinateSpace((t=>{this.Fp(t),this.Wp(t)})),this.Pt.Hp(t,this.Cp),this.$p(t),this.Pt.Hp(t,this.yp),this.Up(t))}this.kp.applySuggestedBitmapSize();const s=ns(this.kp,i);null!==s&&(s.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.jp(s),this.Pt.Hp(s,this.Pp))}kf(){return this.Tp.bitmapSize}Rf(t,i,s){const n=this.kf();n.width>0&&n.height>0&&t.drawImage(this.Tp.canvasElement,i,s)}Ct(){this.Yi?.Dl()}If(t){if(null===this.Yi||this.Yi.Zi()||!this.ys.handleScale.axisPressedMouseMove.price)return;const i=this.Pt.Mp().Qt(),s=this.Pt.Lf();this.pp=!0,i.xo(s,this.Yi,t.localY)}Af(t){if(null===this.Yi||!this.ys.handleScale.axisPressedMouseMove.price)return;const i=this.Pt.Mp().Qt(),s=this.Pt.Lf(),n=this.Yi;i.yo(s,n,t.localY)}Rp(){if(null===this.Yi||!this.ys.handleScale.axisPressedMouseMove.price)return;const t=this.Pt.Mp().Qt(),i=this.Pt.Lf(),s=this.Yi;this.pp&&(this.pp=!1,t.Po(i,s))}Bf(t){if(null===this.Yi||!this.ys.handleScale.axisPressedMouseMove.price)return;const i=this.Pt.Mp().Qt(),s=this.Pt.Lf();this.pp=!1,i.Po(s,this.Yi)}Dp(t){this.ys.handleScale.axisDoubleClickReset.price&&this.En()}Ep(t){if(null===this.Yi)return;!this.Pt.Mp().Qt().N().handleScale.axisPressedMouseMove.price||this.Yi.Be()||this.Yi.ga()||this.Yp(1)}Vf(t){this.Yp(0)}Ap(){const t=[],i=null===this.Yi?void 0:this.Yi;return(s=>{for(let n=0;n{t.fillStyle=s.borderColor;const l=Math.max(1,Math.floor(h)),a=Math.floor(.5*h),o=Math.round(n.P*r);t.beginPath();for(const s of i)t.rect(Math.floor(e*r),Math.round(s.Pl*h)-a,o,l);t.fill()})),t.useMediaCoordinateSpace((({context:t})=>{t.font=this.Ip(),t.fillStyle=s.textColor??this._a.textColor,t.textAlign=this.xp?"right":"left",t.textBaseline="middle";const r=this.xp?Math.round(e-n.I):Math.round(e+n.P+n.I),h=i.map((i=>this.vp.Di(t,i.$l)));for(let s=i.length;s--;){const n=i[s];t.fillText(n.$l,r,n.Pl+h[s])}}))}Np(){if(null===this.fp||null===this.Yi)return;let t=this.fp.height/2;const i=[],s=this.Yi.Dt().slice(),n=this.Pt.Lf(),e=this.zp();this.Yi===n.$n()&&this.Pt.Lf().Dt().forEach((t=>{n.Hn(t)&&s.push(t)}));const r=this.Yi.bl()[0],h=this.Yi;s.forEach((s=>{const e=s.Fs(n,h);e.forEach((t=>{t.Wi(null),t.Hi()&&i.push(t)})),r===s&&e.length>0&&(t=e[0].Vi())})),i.forEach((t=>t.Wi(t.Vi())));this.Yi.N().alignLabels&&this.Xp(i,e,t)}Xp(t,i,s){if(null===this.fp)return;const n=t.filter((t=>t.Vi()<=s)),e=t.filter((t=>t.Vi()>s));n.sort(((t,i)=>i.Vi()-t.Vi())),n.length&&e.length&&e.push(n[0]),e.sort(((t,i)=>t.Vi()-i.Vi()));for(const s of t){const t=Math.floor(s.Ut(i)/2),n=s.Vi();n>-t&&nthis.fp.height-t&&n{if(i.$i()){i.kt(l(this.Yi)).nt(t,s,this.vp,n)}}))}jp(t){if(null===this.fp||null===this.Yi)return;const i=this.Pt.Mp().Qt(),s=[],n=this.Pt.Lf(),e=i.$u().Fs(n,this.Yi);e.length&&s.push(e);const r=this.zp(),h=this.xp?"right":"left";s.forEach((i=>{i.forEach((i=>{i.kt(l(this.Yi)).nt(t,r,this.vp,h)}))}))}Yp(t){this.xf.style.cursor=1===t?"ns-resize":"default"}ta(){const t=this.Vp();this.wp{this.gp||null===this.lv||this.ts().hr()},this.Sp=()=>{this.gp||null===this.lv||this.ts().hr()},this.lp=t,this.lv=i,this.lv.Io().i(this.av.bind(this),this,!0),this.ov=document.createElement("td"),this.ov.style.padding="0",this.ov.style.position="relative";const s=document.createElement("div");s.style.width="100%",s.style.height="100%",s.style.position="relative",s.style.overflow="hidden",this._v=document.createElement("td"),this._v.style.padding="0",this.uv=document.createElement("td"),this.uv.style.padding="0",this.ov.appendChild(s),this.Tp=bs(s,Gi({width:16,height:16})),this.Tp.subscribeSuggestedBitmapSizeChanged(this.bp);const n=this.Tp.canvasElement;n.style.position="absolute",n.style.zIndex="1",n.style.left="0",n.style.top="0",this.kp=bs(s,Gi({width:16,height:16})),this.kp.subscribeSuggestedBitmapSizeChanged(this.Sp);const e=this.kp.canvasElement;e.style.position="absolute",e.style.zIndex="2",e.style.left="0",e.style.top="0",this.Sf=document.createElement("tr"),this.Sf.appendChild(this._v),this.Sf.appendChild(this.ov),this.Sf.appendChild(this.uv),this.cv(),this.pf=new os(this.kp.canvasElement,this,{Ld:()=>null===this.nv&&!this.lp.N().handleScroll.vertTouchDrag,Od:()=>null===this.nv&&!this.lp.N().handleScroll.horzTouchDrag})}m(){null!==this.Zp&&this.Zp.m(),null!==this.qp&&this.qp.m(),this.Kp=null,this.kp.unsubscribeSuggestedBitmapSizeChanged(this.Sp),Ms(this.kp.canvasElement),this.kp.dispose(),this.Tp.unsubscribeSuggestedBitmapSizeChanged(this.bp),Ms(this.Tp.canvasElement),this.Tp.dispose(),null!==this.lv&&(this.lv.Io().u(this),this.lv.m()),this.pf.m()}Lf(){return l(this.lv)}dv(t){null!==this.lv&&this.lv.Io().u(this),this.lv=t,null!==this.lv&&this.lv.Io().i(zs.prototype.av.bind(this),this,!0),this.cv(),this.lp.bf().indexOf(this)===this.lp.bf().length-1?(this.Kp=this.Kp??new gs(this.ov,this.lp),this.Kp.Ct()):(this.Kp?.op(),this.Kp=null)}Mp(){return this.lp}Cf(){return this.Sf}cv(){if(null!==this.lv&&(this.fv(),0!==this.ts().Ys().length)){if(null!==this.Zp){const t=this.lv.Mo();this.Zp.os(l(t))}if(null!==this.qp){const t=this.lv.So();this.qp.os(l(t))}}}pv(){null!==this.Zp&&this.Zp.Ct(),null!==this.qp&&this.qp.Ct()}do(){return null!==this.lv?this.lv.do():0}fo(t){this.lv&&this.lv.fo(t)}zd(t){if(!this.lv)return;this.vv();const i=t.localX,s=t.localY;this.mv(i,s,t)}Gd(t){this.vv(),this.wv(),this.mv(t.localX,t.localY,t)}Vd(t){if(!this.lv)return;this.vv();const i=t.localX,s=t.localY;this.mv(i,s,t)}Yd(t){null!==this.lv&&(this.vv(),this.gv(t))}Pd(t){null!==this.lv&&this.bv(this.tv,t)}Md(t){this.Pd(t)}Wd(t){this.vv(),this.Mv(t),this.mv(t.localX,t.localY,t)}jd(t){null!==this.lv&&(this.vv(),this.sv=!1,this.Sv(t))}Ud(t){null!==this.lv&&this.gv(t)}af(t){if(this.sv=!0,null===this.nv){const i={x:t.localX,y:t.localY};this.xv(i,i,t)}}lf(t){null!==this.lv&&(this.vv(),this.lv.Qt().Fu(null),this.yv())}Pv(){return this.Qp}Cv(){return this.tv}if(){this.iv=1,this.ts().rn()}sf(t,i){if(!this.lp.N().handleScale.pinch)return;const s=5*(i-this.iv);this.iv=i,this.ts().Gu(t._t,s)}qd(t){this.sv=!1,this.ev=null!==this.nv,this.wv();const i=this.ts().$u();null!==this.nv&&i.Et()&&(this.rv={x:i.si(),y:i.ni()},this.nv={x:t.localX,y:t.localY})}Nd(t){if(null===this.lv)return;const i=t.localX,s=t.localY;if(null===this.nv)this.Mv(t);else{this.ev=!1;const n=l(this.rv),e=n.x+(i-this.nv.x),r=n.y+(s-this.nv.y);this.mv(e,r,t)}}$d(t){0===this.Mp().N().trackingMode.exitMode&&(this.ev=!0),this.Tv(),this.Sv(t)}Yn(t,i){const s=this.lv;return null===s?null:gi(s,t,i)}kv(t,i){l("left"===i?this.Zp:this.qp).Bp(Gi({width:t,height:this.fp.height}))}Tf(){return this.fp}Bp(t){Ji(this.fp,t)||(this.fp=t,this.gp=!0,this.Tp.resizeCanvasElement(t),this.kp.resizeCanvasElement(t),this.gp=!1,this.ov.style.width=t.width+"px",this.ov.style.height=t.height+"px")}Rv(){const t=l(this.lv);t.bo(t.Mo()),t.bo(t.So());for(const i of t.bl())if(t.Hn(i)){const s=i.Ft();null!==s&&t.bo(s),i.Os()}for(const i of t.Bo())i.Os()}kf(){return this.Tp.bitmapSize}Rf(t,i,s){const n=this.kf();n.width>0&&n.height>0&&t.drawImage(this.Tp.canvasElement,i,s)}Op(t){if(0===t)return;if(null===this.lv)return;t>1&&this.Rv(),null!==this.Zp&&this.Zp.Op(t),null!==this.qp&&this.qp.Op(t);const i={colorSpace:this.lp.N().layout.colorSpace};if(1!==t){this.Tp.applySuggestedBitmapSize();const t=ns(this.Tp,i);null!==t&&(t.useBitmapCoordinateSpace((t=>{this.Fp(t)})),this.lv&&(this.Dv(t,ks),this.Ev(t),this.Dv(t,Rs),this.Dv(t,Ds)))}this.kp.applySuggestedBitmapSize();const s=ns(this.kp,i);null!==s&&(s.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.zv(s),this.Dv(s,Es),this.Dv(s,Ds))}Vv(){return this.Zp}Iv(){return this.qp}Hp(t,i){this.Dv(t,i)}av(){null!==this.lv&&this.lv.Io().u(this),this.lv=null}gv(t){this.bv(this.Qp,t)}bv(t,i){const s=i.localX,n=i.localY;t.v()&&t.p(this.ts().It().j_(s),{x:s,y:n},i)}Fp({context:t,bitmapSize:i}){const{width:s,height:n}=i,e=this.ts(),r=e.U(),h=e.gc();r===h?V(t,0,0,s,n,h):B(t,0,0,s,n,r,h)}Ev(t){const i=l(this.lv),s=i.Ao().lr().kt(i);null!==s&&s.nt(t,!1)}zv(t){this.Av(t,Rs,xs,this.ts().$u())}Dv(t,i){const s=l(this.lv),n=s.Dt(),e=s.Bo();for(const s of e)this.Av(t,i,Ss,s);for(const s of n)this.Av(t,i,Ss,s);for(const s of e)this.Av(t,i,xs,s);for(const s of n)this.Av(t,i,xs,s)}Av(t,i,s,n){const e=l(this.lv),r=e.Qt().Nu(),h=null!==r&&r.Lo===n,a=null!==r&&h&&void 0!==r.Oo?r.Oo.Zn:void 0;ys(i,(i=>s(i,t,h,a)),n,e)}fv(){if(null===this.lv)return;const t=this.lp,i=this.lv.Mo().N().visible,s=this.lv.So().N().visible;i||null===this.Zp||(this._v.removeChild(this.Zp.Cf()),this.Zp.m(),this.Zp=null),s||null===this.qp||(this.uv.removeChild(this.qp.Cf()),this.qp.m(),this.qp=null);const n=t.Qt().oc();i&&null===this.Zp&&(this.Zp=new Ts(this,t.N(),n,"left"),this._v.appendChild(this.Zp.Cf())),s&&null===this.qp&&(this.qp=new Ts(this,t.N(),n,"right"),this.uv.appendChild(this.qp.Cf()))}Bv(t){return t._f&&this.sv||null!==this.nv}Lv(t){return Math.max(0,Math.min(t,this.fp.width-1))}Ov(t){return Math.max(0,Math.min(t,this.fp.height-1))}mv(t,i,s){this.ts().rc(this.Lv(t),this.Ov(i),s,l(this.lv))}yv(){this.ts().lc()}Tv(){this.ev&&(this.nv=null,this.yv())}xv(t,i,s){this.nv=t,this.ev=!1,this.mv(i.x,i.y,s);const n=this.ts().$u();this.rv={x:n.si(),y:n.ni()}}ts(){return this.lp.Qt()}Sv(t){if(!this.Jp)return;const i=this.ts(),s=this.Lf();if(i.ko(s,s.Cs()),this.Gp=null,this.Jp=!1,i.sc(),null!==this.hv){const t=performance.now(),s=i.It();this.hv.le(s.J_(),t),this.hv.au(t)||i.an(this.hv)}}vv(){this.nv=null}wv(){if(!this.lv)return;if(this.ts().rn(),document.activeElement!==document.body&&document.activeElement!==document.documentElement)l(document.activeElement).blur();else{const t=document.getSelection();null!==t&&t.removeAllRanges()}!this.lv.Cs().Zi()&&this.ts().It().Zi()}Mv(t){if(null===this.lv)return;const i=this.ts(),s=i.It();if(s.Zi())return;const n=this.lp.N(),e=n.handleScroll,r=n.kineticScroll;if((!e.pressedMouseMove||t._f)&&(!e.horzTouchDrag&&!e.vertTouchDrag||!t._f))return;const h=this.lv.Cs(),l=performance.now();if(null!==this.Gp||this.Bv(t)||(this.Gp={x:t.clientX,y:t.clientY,Ic:l,Nv:t.localX,Fv:t.localY}),null!==this.Gp&&!this.Jp&&(this.Gp.x!==t.clientX||this.Gp.y!==t.clientY)){if(t._f&&r.touch||!t._f&&r.mouse){const t=s.K_();this.hv=new ws(.2/t,7/t,.997,15/t),this.hv.ip(s.J_(),this.Gp.Ic)}else this.hv=null;h.Zi()||i.Co(this.lv,h,t.localY),i.Qu(t.localX),this.Jp=!0}this.Jp&&(h.Zi()||i.To(this.lv,h,t.localY),i.tc(t.localX),null!==this.hv&&this.hv.ip(s.J_(),l))}}class Vs{constructor(t,i,s,n,e){this.xt=!0,this.fp=Gi({width:0,height:0}),this.bp=()=>this.Op(3),this.xp="left"===t,this.Eu=s.oc,this.ys=i,this.Wv=n,this.Hv=e,this.xf=document.createElement("div"),this.xf.style.width="25px",this.xf.style.height="100%",this.xf.style.overflow="hidden",this.Tp=bs(this.xf,Gi({width:16,height:16})),this.Tp.subscribeSuggestedBitmapSizeChanged(this.bp)}m(){this.Tp.unsubscribeSuggestedBitmapSizeChanged(this.bp),Ms(this.Tp.canvasElement),this.Tp.dispose()}Cf(){return this.xf}Tf(){return this.fp}Bp(t){Ji(this.fp,t)||(this.fp=t,this.Tp.resizeCanvasElement(t),this.xf.style.width=`${t.width}px`,this.xf.style.height=`${t.height}px`,this.xt=!0)}Op(t){if(t<3&&!this.xt)return;if(0===this.fp.width||0===this.fp.height)return;this.xt=!1,this.Tp.applySuggestedBitmapSize();const i=ns(this.Tp,{colorSpace:this.ys.layout.colorSpace});null!==i&&i.useBitmapCoordinateSpace((t=>{this.Fp(t),this.Wp(t)}))}kf(){return this.Tp.bitmapSize}Rf(t,i,s){const n=this.kf();n.width>0&&n.height>0&&t.drawImage(this.Tp.canvasElement,i,s)}Wp({context:t,bitmapSize:i,horizontalPixelRatio:s,verticalPixelRatio:n}){if(!this.Wv())return;t.fillStyle=this.ys.timeScale.borderColor;const e=Math.floor(this.Eu.N().S*s),r=Math.floor(this.Eu.N().S*n),h=this.xp?i.width-e:0;t.fillRect(h,0,e,r)}Fp({context:t,bitmapSize:i}){V(t,0,0,i.width,i.height,this.Hv())}}function Is(t){return i=>i.tl?.(t)??[]}const As=Is("normal"),Bs=Is("top"),Ls=Is("bottom");class Os{constructor(t,i){this.$v=null,this.Uv=null,this.M=null,this.jv=!1,this.fp=Gi({width:0,height:0}),this.Yv=new o,this.vp=new tt(5),this.gp=!1,this.bp=()=>{this.gp||this.lp.Qt().hr()},this.Sp=()=>{this.gp||this.lp.Qt().hr()},this.lp=t,this.$o=i,this.ys=t.N().layout,this.np=document.createElement("tr"),this.Xv=document.createElement("td"),this.Xv.style.padding="0",this.Zv=document.createElement("td"),this.Zv.style.padding="0",this.xf=document.createElement("td"),this.xf.style.height="25px",this.xf.style.padding="0",this.qv=document.createElement("div"),this.qv.style.width="100%",this.qv.style.height="100%",this.qv.style.position="relative",this.qv.style.overflow="hidden",this.xf.appendChild(this.qv),this.Tp=bs(this.qv,Gi({width:16,height:16})),this.Tp.subscribeSuggestedBitmapSizeChanged(this.bp);const s=this.Tp.canvasElement;s.style.position="absolute",s.style.zIndex="1",s.style.left="0",s.style.top="0",this.kp=bs(this.qv,Gi({width:16,height:16})),this.kp.subscribeSuggestedBitmapSizeChanged(this.Sp);const n=this.kp.canvasElement;n.style.position="absolute",n.style.zIndex="2",n.style.left="0",n.style.top="0",this.np.appendChild(this.Xv),this.np.appendChild(this.xf),this.np.appendChild(this.Zv),this.Kv(),this.lp.Qt().co().i(this.Kv.bind(this),this),this.pf=new os(this.kp.canvasElement,this,{Ld:()=>!0,Od:()=>!this.lp.N().handleScroll.horzTouchDrag})}m(){this.pf.m(),null!==this.$v&&this.$v.m(),null!==this.Uv&&this.Uv.m(),this.kp.unsubscribeSuggestedBitmapSizeChanged(this.Sp),Ms(this.kp.canvasElement),this.kp.dispose(),this.Tp.unsubscribeSuggestedBitmapSizeChanged(this.bp),Ms(this.Tp.canvasElement),this.Tp.dispose()}Cf(){return this.np}Gv(){return this.$v}Jv(){return this.Uv}Gd(t){if(this.jv)return;this.jv=!0;const i=this.lp.Qt();!i.It().Zi()&&this.lp.N().handleScale.axisPressedMouseMove.time&&i.Ku(t.localX)}qd(t){this.Gd(t)}Jd(){const t=this.lp.Qt();!t.It().Zi()&&this.jv&&(this.jv=!1,this.lp.N().handleScale.axisPressedMouseMove.time&&t.ec())}Wd(t){const i=this.lp.Qt();!i.It().Zi()&&this.lp.N().handleScale.axisPressedMouseMove.time&&i.nc(t.localX)}Nd(t){this.Wd(t)}jd(){this.jv=!1;const t=this.lp.Qt();t.It().Zi()&&!this.lp.N().handleScale.axisPressedMouseMove.time||t.ec()}$d(){this.jd()}Pd(){this.lp.N().handleScale.axisDoubleClickReset.time&&this.lp.Qt().un()}Md(){this.Pd()}zd(){this.lp.Qt().N().handleScale.axisPressedMouseMove.time&&this.Yp(1)}lf(){this.Yp(0)}Tf(){return this.fp}Qv(){return this.Yv}tm(t,i,s){Ji(this.fp,t)||(this.fp=t,this.gp=!0,this.Tp.resizeCanvasElement(t),this.kp.resizeCanvasElement(t),this.gp=!1,this.xf.style.width=`${t.width}px`,this.xf.style.height=`${t.height}px`,this.Yv.p(t)),null!==this.$v&&this.$v.Bp(Gi({width:i,height:t.height})),null!==this.Uv&&this.Uv.Bp(Gi({width:s,height:t.height}))}im(){const t=this.sm();return Math.ceil(t.S+t.P+t.C+t.B+t.V+t.nm)}Ct(){this.lp.Qt().It().Dl()}kf(){return this.Tp.bitmapSize}Rf(t,i,s){const n=this.kf();n.width>0&&n.height>0&&t.drawImage(this.Tp.canvasElement,i,s)}Op(t){if(0===t)return;const i={colorSpace:this.ys.colorSpace};if(1!==t){this.Tp.applySuggestedBitmapSize();const s=ns(this.Tp,i);null!==s&&(s.useBitmapCoordinateSpace((t=>{this.Fp(t),this.Wp(t),this.rm(s,Ls)})),this.$p(s),this.rm(s,As)),null!==this.$v&&this.$v.Op(t),null!==this.Uv&&this.Uv.Op(t)}this.kp.applySuggestedBitmapSize();const s=ns(this.kp,i);null!==s&&(s.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.hm([...this.lp.Qt().Ys(),this.lp.Qt().$u()],s),this.rm(s,Bs))}rm(t,i){const s=this.lp.Qt().Ys();for(const n of s)ys(i,(i=>Ss(i,t,!1,void 0)),n,void 0);for(const n of s)ys(i,(i=>xs(i,t,!1,void 0)),n,void 0)}Fp({context:t,bitmapSize:i}){V(t,0,0,i.width,i.height,this.lp.Qt().gc())}Wp({context:t,bitmapSize:i,verticalPixelRatio:s}){if(this.lp.N().timeScale.borderVisible){t.fillStyle=this.lm();const n=Math.max(1,Math.floor(this.sm().S*s));t.fillRect(0,0,i.width,n)}}$p(t){const i=this.lp.Qt().It(),s=i.Dl();if(!s||0===s.length)return;const n=this.$o.maxTickMarkWeight(s),e=this.sm(),r=i.N();r.borderVisible&&r.ticksVisible&&t.useBitmapCoordinateSpace((({context:t,horizontalPixelRatio:i,verticalPixelRatio:n})=>{t.strokeStyle=this.lm(),t.fillStyle=this.lm();const r=Math.max(1,Math.floor(i)),h=Math.floor(.5*i);t.beginPath();const l=Math.round(e.P*n);for(let n=s.length;n--;){const e=Math.round(s[n].coord*i);t.rect(e-h,0,r,l)}t.fill()})),t.useMediaCoordinateSpace((({context:t})=>{const i=e.S+e.P+e.B+e.C/2;t.textAlign="center",t.textBaseline="middle",t.fillStyle=this.H(),t.font=this.Ip();for(const e of s)if(e.weight=n){const s=e.needAlignCoordinate?this.am(t,e.coord,e.label):e.coord;t.fillText(e.label,s,i)}}))}am(t,i,s){const n=this.vp.Ei(t,s),e=n/2,r=Math.floor(i-e)+.5;return r<0?i+=Math.abs(0-r):r+n>this.fp.width&&(i-=Math.abs(this.fp.width-(r+n))),i}hm(t,i){const s=this.sm();for(const n of t)for(const t of n.us())t.kt().nt(i,s)}lm(){return this.lp.N().timeScale.borderColor}H(){return this.ys.textColor}F(){return this.ys.fontSize}Ip(){return g(this.F(),this.ys.fontFamily)}om(){return g(this.F(),this.ys.fontFamily,"bold")}sm(){null===this.M&&(this.M={S:1,L:NaN,B:NaN,V:NaN,Ji:NaN,P:5,C:NaN,T:"",Gi:new tt,nm:0});const t=this.M,i=this.Ip();if(t.T!==i){const s=this.F();t.C=s,t.T=i,t.B=3*s/12,t.V=3*s/12,t.Ji=9*s/12,t.L=0,t.nm=4*s/12,t.Gi.En()}return this.M}Yp(t){this.xf.style.cursor=1===t?"ew-resize":"default"}Kv(){const t=this.lp.Qt(),i=t.N();i.leftPriceScale.visible||null===this.$v||(this.Xv.removeChild(this.$v.Cf()),this.$v.m(),this.$v=null),i.rightPriceScale.visible||null===this.Uv||(this.Zv.removeChild(this.Uv.Cf()),this.Uv.m(),this.Uv=null);const s={oc:this.lp.Qt().oc()},n=()=>i.leftPriceScale.borderVisible&&t.It().N().borderVisible,e=()=>t.gc();i.leftPriceScale.visible&&null===this.$v&&(this.$v=new Vs("left",i,s,n,e),this.Xv.appendChild(this.$v.Cf())),i.rightPriceScale.visible&&null===this.Uv&&(this.Uv=new Vs("right",i,s,n,e),this.Zv.appendChild(this.Uv.Cf()))}}const Ns=!!es&&!!navigator.userAgentData&&navigator.userAgentData.brands.some((t=>t.brand.includes("Chromium")))&&!!es&&(navigator?.userAgentData?.platform?"Windows"===navigator.userAgentData.platform:navigator.userAgent.toLowerCase().indexOf("win")>=0);class Fs{constructor(t,i,s){var n;this._m=[],this.um=[],this.dm=0,this.Yl=0,this.so=0,this.fm=0,this.pm=0,this.vm=null,this.wm=!1,this.Qp=new o,this.tv=new o,this.ku=new o,this.gm=null,this.bm=null,this.hp=t,this.ys=i,this.$o=s,this.np=document.createElement("div"),this.np.classList.add("tv-lightweight-charts"),this.np.style.overflow="hidden",this.np.style.direction="ltr",this.np.style.width="100%",this.np.style.height="100%",(n=this.np).style.userSelect="none",n.style.webkitUserSelect="none",n.style.msUserSelect="none",n.style.MozUserSelect="none",n.style.webkitTapHighlightColor="transparent",this.Mm=document.createElement("table"),this.Mm.setAttribute("cellspacing","0"),this.np.appendChild(this.Mm),this.Sm=this.xm.bind(this),Ws(this.ys)&&this.ym(!0),this.ts=new zi(this.Du.bind(this),this.ys,s),this.Qt().Uu().i(this.Pm.bind(this),this),this.Cm=new Os(this,this.$o),this.Mm.appendChild(this.Cm.Cf());const e=i.autoSize&&this.Tm();let r=this.ys.width,h=this.ys.height;if(e||0===r||0===h){const i=t.getBoundingClientRect();r=r||i.width,h=h||i.height}this.km(r,h),this.Rm(),t.appendChild(this.np),this.Dm(),this.ts.It().cu().i(this.ts.zh.bind(this.ts),this),this.ts.co().i(this.ts.zh.bind(this.ts),this)}Qt(){return this.ts}N(){return this.ys}bf(){return this._m}Em(){return this.Cm}m(){this.ym(!1),0!==this.dm&&window.cancelAnimationFrame(this.dm),this.ts.Uu().u(this),this.ts.It().cu().u(this),this.ts.co().u(this),this.ts.m();for(const t of this._m)this.Mm.removeChild(t.Cf()),t.Pv().u(this),t.Cv().u(this),t.m();this._m=[];for(const t of this.um)this.zm(t);this.um=[],l(this.Cm).m(),null!==this.np.parentElement&&this.np.parentElement.removeChild(this.np),this.ku.m(),this.Qp.m(),this.tv.m(),this.Vm()}km(t,i,s=!1){if(this.Yl===i&&this.so===t)return;const n=function(t){const i=Math.floor(t.width),s=Math.floor(t.height);return Gi({width:i-i%2,height:s-s%2})}(Gi({width:t,height:i}));this.Yl=n.height,this.so=n.width;const e=this.Yl+"px",r=this.so+"px";l(this.np).style.height=e,l(this.np).style.width=r,this.Mm.style.height=e,this.Mm.style.width=r,s?this.Im(X.wn(),performance.now()):this.ts.zh()}Op(t){void 0===t&&(t=X.wn());for(let i=0;i{t.Ct()}))}Bm(t){(void 0!==t.autoSize||!this.gm||void 0===t.width&&void 0===t.height)&&(t.autoSize&&!this.gm&&this.Tm(),!1===t.autoSize&&null!==this.gm&&this.Vm(),t.autoSize||void 0===t.width&&void 0===t.height||this.km(t.width||this.so,t.height||this.Yl))}Om(t){let i=0,s=0;const n=this._m[0],e=(i,s)=>{let n=0;for(let e=0;e{l("left"===i?this.Cm.Gv():this.Cm.Jv()).Rf(l(t),s,n)};if(this.ys.timeScale.visible){const i=this.Cm.kf();if(null!==t){let e=0;this.Fm()&&(r("left",e,s),e=l(n.Vv()).kf().width),this.Cm.Rf(t,e,s),e+=i.width,this.Wm()&&r("right",e,s)}s+=i.height}return Gi({width:i,height:s})}Ym(){let t=0,i=0,s=0;for(const n of this._m)this.Fm()&&(i=Math.max(i,l(n.Vv()).Vp(),this.ys.leftPriceScale.minimumWidth)),this.Wm()&&(s=Math.max(s,l(n.Iv()).Vp(),this.ys.rightPriceScale.minimumWidth)),t+=n.do();i=ls(i),s=ls(s);const n=this.so,e=this.Yl,r=Math.max(n-i-s,0),h=1*this.um.length,a=this.ys.timeScale.visible;let o=a?Math.max(this.Cm.im(),this.ys.timeScale.minimumHeight):0;var _;o=(_=o)+_%2;const u=h+o,c=e{t.pv()})),3===this.vm?.sn()&&(this.vm.pn(t),this.Zm(),this.qm(this.vm),this.Km(this.vm,i),t=this.vm,this.vm=null)),this.Op(t)}Km(t,i){for(const s of t.fn())this.vn(s,i)}qm(t){const i=this.ts.$s();for(let s=0;s{if(this.wm=!1,this.dm=0,null!==this.vm){const i=this.vm;this.vm=null,this.Im(i,t);for(const s of i.fn())if(5===s.hn&&!s.Wt.au(t)){this.Qt().an(s.Wt);break}}})))}Zm(){this.Rm()}zm(t){this.Mm.removeChild(t.Cf()),t.m()}Rm(){const t=this.ts.$s(),i=t.length,s=this._m.length;for(let t=i;t0){const t=new ps(this,n-1,n);this.um.push(t),this.Mm.insertBefore(t.Cf(),this.Cm.Cf())}this.Mm.insertBefore(i.Cf(),this.Cm.Cf())}for(let s=0;s{const s=i.Zs().Nr(t);null!==s&&e.set(i,s)}))}let r;if(null!==t){const i=this.ts.It().ss(t)?.originalTime;void 0!==i&&(r=i)}const h=this.Qt().Nu(),l=null!==h&&h.Lo instanceof Ht?h.Lo:void 0,a=null!==h&&void 0!==h.Oo?h.Oo.Xn:void 0,o=this.tw(n);return{iw:r,ke:t??void 0,sw:i??void 0,nw:-1!==o?o:void 0,ew:l,rw:e,hw:a,lw:s??void 0}}tw(t){let i=-1;if(t)i=this._m.indexOf(t);else{const t=this.Qt().$u().Hs();null!==t&&(i=this.Qt().$s().indexOf(t))}return i}Gm(t,i,s,n){this.Qp.p((()=>this.Qm(i,s,n,t)))}Jm(t,i,s,n){this.tv.p((()=>this.Qm(i,s,n,t)))}Pm(t,i,s){this.$m(this.Qt().Nu()?.Fo??null),this.ku.p((()=>this.Qm(t,i,s)))}Dm(){const t=this.ys.timeScale.visible?"":"none";this.Cm.Cf().style.display=t}Fm(){return this._m[0].Lf().Mo().N().visible}Wm(){return this._m[0].Lf().So().N().visible}Tm(){return"ResizeObserver"in window&&(this.gm=new ResizeObserver((t=>{const i=t[t.length-1];i&&this.km(i.contentRect.width,i.contentRect.height)})),this.gm.observe(this.hp,{box:"border-box"}),!0)}Vm(){null!==this.gm&&this.gm.disconnect(),this.gm=null}}function Ws(t){return Boolean(t.handleScroll.mouseWheel||t.handleScale.mouseWheel)}function Hs(t){return function(t){return void 0!==t.open}(t)||function(t){return void 0!==t.value}(t)}function $s(t,i,s,n){const e=s.value,r={ke:i,wt:t,Wt:[e,e,e,e],iw:n};return void 0!==s.color&&(r.R=s.color),r}function Us(t,i,s,n){const e=s.value,r={ke:i,wt:t,Wt:[e,e,e,e],iw:n};return void 0!==s.lineColor&&(r.vt=s.lineColor),void 0!==s.topColor&&(r.vr=s.topColor),void 0!==s.bottomColor&&(r.mr=s.bottomColor),r}function js(t,i,s,n){const e=s.value,r={ke:i,wt:t,Wt:[e,e,e,e],iw:n};return void 0!==s.topLineColor&&(r.wr=s.topLineColor),void 0!==s.bottomLineColor&&(r.gr=s.bottomLineColor),void 0!==s.topFillColor1&&(r.br=s.topFillColor1),void 0!==s.topFillColor2&&(r.Mr=s.topFillColor2),void 0!==s.bottomFillColor1&&(r.Sr=s.bottomFillColor1),void 0!==s.bottomFillColor2&&(r.yr=s.bottomFillColor2),r}function Ys(t,i,s,n){const e={ke:i,wt:t,Wt:[s.open,s.high,s.low,s.close],iw:n};return void 0!==s.color&&(e.R=s.color),e}function Xs(t,i,s,n){const e={ke:i,wt:t,Wt:[s.open,s.high,s.low,s.close],iw:n};return void 0!==s.color&&(e.R=s.color),void 0!==s.borderColor&&(e.Ht=s.borderColor),void 0!==s.wickColor&&(e.pr=s.wickColor),e}function Zs(t,i,s,n,e){const r=h(e)(s),l=Math.max(...r),a=Math.min(...r),o=r[r.length-1],_=[o,l,a,o],{time:u,color:c,...d}=s;return{ke:i,wt:t,Wt:_,iw:n,ie:d,R:c}}function qs(t){return void 0!==t.Wt}function Ks(t,i){return void 0!==i.customValues&&(t.aw=i.customValues),t}function Gs(t){return(i,s,n,e,r,h)=>function(t,i){return i?i(t):void 0===(s=t).open&&void 0===s.value;var s}(n,h)?Ks({wt:i,ke:s,iw:e},n):Ks(t(i,s,n,e,r),n)}function Js(t){return{Candlestick:Gs(Xs),Bar:Gs(Ys),Area:Gs(Us),Baseline:Gs(js),Histogram:Gs($s),Line:Gs($s),Custom:Gs(Zs)}[t]}function Qs(t){return{ke:0,ow:new Map,Wh:t}}function tn(t,i){if(void 0!==t&&0!==t.length)return{_w:i.key(t[0].wt),uw:i.key(t[t.length-1].wt)}}function sn(t){let i;return t.forEach((t=>{void 0===i&&(i=t.iw)})),h(i)}class nn{constructor(t){this.cw=new Map,this.dw=new Map,this.fw=new Map,this.pw=[],this.$o=t}m(){this.cw.clear(),this.dw.clear(),this.fw.clear(),this.pw=[]}mw(t,i){let s=0!==this.cw.size,n=!1;const e=this.dw.get(t);if(void 0!==e)if(1===this.dw.size)s=!1,n=!0,this.cw.clear();else for(const i of this.pw)i.pointData.ow.delete(t)&&(n=!0);let r=[];if(0!==i.length){const s=i.map((t=>t.time)),e=this.$o.createConverterToInternalObj(i),h=Js(t.kr()),l=t.cl(),a=t.fl();r=i.map(((i,r)=>{const o=e(i.time),_=this.$o.key(o);let u=this.cw.get(_);void 0===u&&(u=Qs(o),this.cw.set(_,u),n=!0);const c=h(o,u.ke,i,s[r],l,a);return u.ow.set(t,c),c}))}s&&this.ww(),this.gw(t,r);let h=-1;if(n){const t=[];this.cw.forEach((i=>{t.push({timeWeight:0,time:i.Wh,pointData:i,originalTime:sn(i.ow)})})),t.sort(((t,i)=>this.$o.key(t.time)-this.$o.key(i.time))),h=this.bw(t)}return this.Mw(t,h,function(t,i,s){const n=tn(t,s),e=tn(i,s);if(void 0!==n&&void 0!==e)return{Sw:!1,Ah:n.uw>=e.uw&&n._w>=e._w}}(this.dw.get(t),e,this.$o))}cc(t){return this.mw(t,[])}xw(t,i,s){const n=i;!function(t){void 0===t.iw&&(t.iw=t.time)}(n),this.$o.preprocessData(i);const e=this.$o.createConverterToInternalObj([i])(i.time),r=this.fw.get(t);if(!s&&void 0!==r&&this.$o.key(e)this.$o.key(t.time)this.$o.key(n.wt)?qs(i)&&s.push(i):qs(i)?s[s.length-1]=i:s.splice(-1,1),this.fw.set(t,i.wt)}yw(t,i,s){const n=this.dw.get(t);if(void 0===n)return;const e=Mt(n,s,((t,i)=>t.ke{0!==i.length&&(t=Math.max(t,i[i.length-1].ke))})),t}Mw(t,i,s){const n={mo:new Map,It:{H_:this.Cw()}};if(-1!==i)this.dw.forEach(((i,e)=>{n.mo.set(e,{ie:i,Tw:e===t?s:void 0})})),this.dw.has(t)||n.mo.set(t,{ie:[],Tw:s}),n.It.kw=this.pw,n.It.Rw=i;else{const i=this.dw.get(t);n.mo.set(t,{ie:i||[],Tw:s})}return n}}function en(t,i){t.ke=i,t.ow.forEach((t=>{t.ke=i}))}function rn(t,i){return t.wt({...t,...this.Gn.kh().Rr(t.wt)})))}Nw(){this.Iw=null}Bw(){this.Ew&&(this.Fw(),this.Ew=!1),this.zw&&(this.Ow(),this.zw=!1),this.Dw&&(this.Ww(),this.Dw=!1)}Ww(){const t=this.Gn.Ft(),i=this.Jn.It();if(this.Nw(),i.Zi()||t.Zi())return;const s=i.ye();if(null===s)return;if(0===this.Gn.Zs().Ar())return;const n=this.Gn.Bt();null!==n&&(this.Iw=function(t,i,s){const n=i.Hh(),e=i.Mi(),r=Mt(t,n,rn),h=St(t,e,hn);if(!s)return{from:r,to:h};let l=r,a=h;return r>0&&r=n&&(l=r-1),h>0&&h{const s=t.Bt();return null===s?null:t.Ft().Nt(i,s.Wt)}))}dl(t){return this.ih.priceValueBuilder(t)}pl(t){return this.ih.isWhitespace(t)}Fw(){const t=this.Gn.kh();this.Vw=this.Gn.Zs().Wr().map((i=>({wt:i.ke,_t:NaN,...t.Rr(i.ke),jw:i.ie})))}Hw(t,i){i.U_(this.Vw,m(this.Iw))}$w(){this.ih.update({bars:this.Vw.map(_n),barSpacing:this.Jn.It().K_(),visibleRange:this.Iw},this.Gn.N())}}function _n(t){return{x:t._t,time:t.wt,originalData:t.jw,barColor:t.ur}}const un={color:"#2196f3"},cn=(t,i,s)=>{const n=a(s);return new on(t,i,n)};function dn(t){const i={value:t.Wt[3],time:t.iw};return void 0!==t.aw&&(i.customValues=t.aw),i}function fn(t){const i=dn(t);return void 0!==t.R&&(i.color=t.R),i}function pn(t){const i=dn(t);return void 0!==t.vt&&(i.lineColor=t.vt),void 0!==t.vr&&(i.topColor=t.vr),void 0!==t.mr&&(i.bottomColor=t.mr),i}function vn(t){const i=dn(t);return void 0!==t.wr&&(i.topLineColor=t.wr),void 0!==t.gr&&(i.bottomLineColor=t.gr),void 0!==t.br&&(i.topFillColor1=t.br),void 0!==t.Mr&&(i.topFillColor2=t.Mr),void 0!==t.Sr&&(i.bottomFillColor1=t.Sr),void 0!==t.yr&&(i.bottomFillColor2=t.yr),i}function mn(t){const i={open:t.Wt[0],high:t.Wt[1],low:t.Wt[2],close:t.Wt[3],time:t.iw};return void 0!==t.aw&&(i.customValues=t.aw),i}function wn(t){const i=mn(t);return void 0!==t.R&&(i.color=t.R),i}function gn(t){const i=mn(t),{R:s,Ht:n,pr:e}=t;return void 0!==s&&(i.color=s),void 0!==n&&(i.borderColor=n),void 0!==e&&(i.wickColor=e),i}function bn(t){return{Area:pn,Line:fn,Baseline:vn,Histogram:fn,Bar:wn,Candlestick:gn,Custom:Mn}[t]}function Mn(t){const i=t.iw;return{...t.ie,time:i}}const Sn={vertLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},horzLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},mode:1},xn={vertLines:{color:"#D6DCDE",style:0,visible:!0},horzLines:{color:"#D6DCDE",style:0,visible:!0}},yn={background:{type:"solid",color:"#FFFFFF"},textColor:"#191919",fontSize:12,fontFamily:w,panes:{enableResize:!0,separatorColor:"#E0E3EB",separatorHoverColor:"rgba(178, 181, 189, 0.2)"},attributionLogo:!0,colorSpace:"srgb",colorParsers:[]},Pn={autoScale:!0,mode:0,invertScale:!1,alignLabels:!0,borderVisible:!0,borderColor:"#2B2B43",entireTextOnly:!1,visible:!1,ticksVisible:!1,scaleMargins:{bottom:.1,top:.2},minimumWidth:0},Cn={rightOffset:0,barSpacing:6,minBarSpacing:.5,maxBarSpacing:0,fixLeftEdge:!1,fixRightEdge:!1,lockVisibleTimeRangeOnResize:!1,rightBarStaysOnScroll:!1,borderVisible:!0,borderColor:"#2B2B43",visible:!0,timeVisible:!1,secondsVisible:!0,shiftVisibleRangeOnNewBar:!0,allowShiftVisibleRangeOnWhitespaceReplacement:!1,ticksVisible:!1,uniformDistribution:!1,minimumHeight:0,allowBoldLabels:!0,ignoreWhitespaceIndices:!1};function Tn(){return{width:0,height:0,autoSize:!1,layout:yn,crosshair:Sn,grid:xn,overlayPriceScales:{...Pn},leftPriceScale:{...Pn,visible:!1},rightPriceScale:{...Pn,visible:!0},timeScale:Cn,localization:{locale:es?navigator.language:"",dateFormat:"dd MMM 'yy"},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0},handleScale:{axisPressedMouseMove:{time:!0,price:!0},axisDoubleClickReset:{time:!0,price:!0},mouseWheel:!0,pinch:!0},kineticScroll:{mouse:!1,touch:!0},trackingMode:{exitMode:1}}}class kn{constructor(t,i,s){this.wf=t,this.Yw=i,this.Xw=s??0}applyOptions(t){this.wf.Qt().Wu(this.Yw,t,this.Xw)}options(){return this.Yi().N()}width(){return Y(this.Yw)?this.wf.Nm(this.Yw):0}Yi(){return l(this.wf.Qt().Hu(this.Yw,this.Xw)).Ft}}class Rn{constructor(t,i,s,n){this.wf=t,this.Pt=s,this.Zw=i,this.qw=n}getHeight(){return this.Pt.Ut()}setHeight(t){const i=this.wf.Qt(),s=i.Mc(this.Pt);i.Xu(s,t)}paneIndex(){return this.wf.Qt().Mc(this.Pt)}moveTo(t){const i=this.paneIndex();i!==t&&(r(t>=0&&tthis.Zw(t)))??[]}getHTMLElement(){return this.wf.bf()[this.paneIndex()].Cf()}attachPrimitive(t){this.Pt._l(t),t.attached&&t.attached({chart:this.qw,requestUpdate:()=>this.Pt.Qt().zh()})}detachPrimitive(t){this.Pt.ul(t)}priceScale(t){if(null===this.Pt.uo(t))throw new Error(`Cannot find price scale with id: ${t}`);return new kn(this.wf,t,this.paneIndex())}}const Dn={color:"#FF0000",price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:"",axisLabelColor:"",axisLabelTextColor:""};class En{constructor(t){this.tr=t}applyOptions(t){this.tr.rr(t)}options(){return this.tr.N()}Kw(){return this.tr}}class zn{constructor(t,i,s,n,e,r){this.Gw=new o,this.Gn=t,this.Jw=i,this.Qw=s,this.$o=e,this.qw=n,this.tg=r}m(){this.Gw.m()}priceFormatter(){return this.Gn.el()}priceToCoordinate(t){const i=this.Gn.Bt();return null===i?null:this.Gn.Ft().Nt(t,i.Wt)}coordinateToPrice(t){const i=this.Gn.Bt();return null===i?null:this.Gn.Ft().Ts(t,i.Wt)}barsInLogicalRange(t){if(null===t)return null;const i=new yi(new Mi(t.from,t.to)).h_(),s=this.Gn.Zs();if(s.Zi())return null;const n=s.Nr(i.Hh(),1),e=s.Nr(i.Mi(),-1),r=l(s.Br()),h=l(s.Xs());if(null!==n&&null!==e&&n.ke>e.ke)return{barsBefore:t.from-r,barsAfter:h-t.to};const a={barsBefore:null===n||n.ke===r?t.from-r:n.ke-r,barsAfter:null===e||e.ke===h?h-t.to:h-e.ke};return null!==n&&null!==e&&(a.from=n.iw,a.to=e.iw),a}setData(t){this.$o,this.Gn.kr(),this.Jw.ig(this.Gn,t),this.sg("full")}update(t,i=!1){this.Gn.kr(),this.Jw.ng(this.Gn,t,i),this.sg("update")}dataByIndex(t,i){const s=this.Gn.Zs().Nr(t,i);if(null===s)return null;return bn(this.seriesType())(s)}data(){const t=bn(this.seriesType());return this.Gn.Zs().Wr().map((i=>t(i)))}subscribeDataChanged(t){this.Gw.i(t)}unsubscribeDataChanged(t){this.Gw._(t)}applyOptions(t){this.Gn.rr(t)}options(){return p(this.Gn.N())}priceScale(){return this.Qw.priceScale(this.Gn.Ft().ml(),this.getPane().paneIndex())}createPriceLine(t){const i=_(p(Dn),t),s=this.Gn.Lh(i);return new En(s)}removePriceLine(t){this.Gn.Oh(t.Kw())}priceLines(){return this.Gn.Nh().map((t=>new En(t)))}seriesType(){return this.Gn.kr()}attachPrimitive(t){this.Gn._l(t),t.attached&&t.attached({chart:this.qw,series:this,requestUpdate:()=>this.Gn.Qt().zh(),horzScaleBehavior:this.$o})}detachPrimitive(t){this.Gn.ul(t),t.detached&&t.detached(),this.Gn.Qt().zh()}getPane(){const t=this.Gn,i=l(this.Gn.Qt().Wn(t));return this.tg(i)}moveToPane(t){this.Gn.Qt().mc(this.Gn,t)}seriesOrder(){const t=this.Gn.Qt().Wn(this.Gn);return null===t?-1:t.mo().indexOf(this.Gn)}setSeriesOrder(t){const i=this.Gn.Qt().Wn(this.Gn);null!==i&&i.Vo(this.Gn,t)}sg(t){this.Gw.v()&&this.Gw.p(t)}}class Vn{constructor(t,i,s){this.eg=new o,this.v_=new o,this.Yv=new o,this.ts=t,this._h=t.It(),this.Cm=i,this._h._u().i(this.rg.bind(this)),this._h.uu().i(this.hg.bind(this)),this.Cm.Qv().i(this.lg.bind(this)),this.$o=s}m(){this._h._u().u(this),this._h.uu().u(this),this.Cm.Qv().u(this),this.eg.m(),this.v_.m(),this.Yv.m()}scrollPosition(){return this._h.J_()}scrollToPosition(t,i){i?this._h.lu(t,1e3):this.ts.dn(t)}scrollToRealTime(){this._h.hu()}getVisibleRange(){const t=this._h.A_();return null===t?null:{from:t.from.originalTime,to:t.to.originalTime}}setVisibleRange(t){const i={from:this.$o.convertHorzItemToInternal(t.from),to:this.$o.convertHorzItemToInternal(t.to)},s=this._h.N_(i);this.ts.fc(s)}getVisibleLogicalRange(){const t=this._h.I_();return null===t?null:{from:t.Hh(),to:t.Mi()}}setVisibleLogicalRange(t){r(t.from<=t.to,"The from index cannot be after the to index."),this.ts.fc(t)}resetTimeScale(){this.ts.un()}fitContent(){this.ts.fu()}logicalToCoordinate(t){const i=this.ts.It();return i.Zi()?null:i.jt(t)}coordinateToLogical(t){return this._h.Zi()?null:this._h.j_(t)}timeToIndex(t,i){const s=this.$o.convertHorzItemToInternal(t);return this._h.E_(s,i)}timeToCoordinate(t){const i=this.timeToIndex(t,!1);return null===i?null:this._h.jt(i)}coordinateToTime(t){const i=this.ts.It(),s=i.j_(t),n=i.ss(s);return null===n?null:n.originalTime}width(){return this.Cm.Tf().width}height(){return this.Cm.Tf().height}subscribeVisibleTimeRangeChange(t){this.eg.i(t)}unsubscribeVisibleTimeRangeChange(t){this.eg._(t)}subscribeVisibleLogicalRangeChange(t){this.v_.i(t)}unsubscribeVisibleLogicalRangeChange(t){this.v_._(t)}subscribeSizeChange(t){this.Yv.i(t)}unsubscribeSizeChange(t){this.Yv._(t)}applyOptions(t){this._h.rr(t)}options(){return{...p(this._h.N()),barSpacing:this._h.K_()}}rg(){this.eg.v()&&this.eg.p(this.getVisibleRange())}hg(){this.v_.v()&&this.v_.p(this.getVisibleLogicalRange())}lg(t){this.Yv.p(t.width,t.height)}}function In(t){if(void 0===t||"custom"===t.type)return;const i=t;void 0!==i.minMove&&void 0===i.precision&&(i.precision=function(t){if(t>=1)return 0;let i=0;for(;i<8;i++){const s=Math.round(t);if(Math.abs(s-t)<1e-8)return i;t*=10}return i}(i.minMove))}function An(t){return function(t){if(f(t.handleScale)){const i=t.handleScale;t.handleScale={axisDoubleClickReset:{time:i,price:i},axisPressedMouseMove:{time:i,price:i},mouseWheel:i,pinch:i}}else if(void 0!==t.handleScale){const{axisPressedMouseMove:i,axisDoubleClickReset:s}=t.handleScale;f(i)&&(t.handleScale.axisPressedMouseMove={time:i,price:i}),f(s)&&(t.handleScale.axisDoubleClickReset={time:s,price:s})}const i=t.handleScroll;f(i)&&(t.handleScroll={horzTouchDrag:i,vertTouchDrag:i,mouseWheel:i,pressedMouseMove:i})}(t),t}class Bn{constructor(t,i,s){this.ag=new Map,this.og=new Map,this._g=new o,this.ug=new o,this.cg=new o,this.yu=new WeakMap,this.dg=new nn(i);const n=void 0===s?p(Tn()):_(p(Tn()),An(s));this.fg=i,this.wf=new Fs(t,n,i),this.wf.Pv().i((t=>{this._g.v()&&this._g.p(this.pg(t()))}),this),this.wf.Cv().i((t=>{this.ug.v()&&this.ug.p(this.pg(t()))}),this),this.wf.Uu().i((t=>{this.cg.v()&&this.cg.p(this.pg(t()))}),this);const e=this.wf.Qt();this.vg=new Vn(e,this.wf.Em(),this.fg)}remove(){this.wf.Pv().u(this),this.wf.Cv().u(this),this.wf.Uu().u(this),this.vg.m(),this.wf.m(),this.ag.clear(),this.og.clear(),this._g.m(),this.ug.m(),this.cg.m(),this.dg.m()}resize(t,i,s){this.autoSizeActive()||this.wf.km(t,i,s)}addCustomSeries(t,i={},s=0){const n=(t=>({type:"Custom",isBuiltIn:!1,defaultOptions:{...un,...t.defaultOptions()},mg:cn,wg:t}))(a(t));return this.gg(n,i,s)}addSeries(t,i={},s=0){return this.gg(t,i,s)}removeSeries(t){const i=h(this.ag.get(t)),s=this.dg.cc(i);this.wf.Qt().cc(i),this.bg(s),this.ag.delete(t),this.og.delete(i)}ig(t,i){this.bg(this.dg.mw(t,i))}ng(t,i,s){this.bg(this.dg.xw(t,i,s))}subscribeClick(t){this._g.i(t)}unsubscribeClick(t){this._g._(t)}subscribeCrosshairMove(t){this.cg.i(t)}unsubscribeCrosshairMove(t){this.cg._(t)}subscribeDblClick(t){this.ug.i(t)}unsubscribeDblClick(t){this.ug._(t)}priceScale(t,i=0){return new kn(this.wf,t,i)}timeScale(){return this.vg}applyOptions(t){this.wf.rr(An(t))}options(){return this.wf.N()}takeScreenshot(){return this.wf.Lm()}removePane(t){this.wf.Qt().Yu(t)}swapPanes(t,i){this.wf.Qt().Zu(t,i)}autoSizeActive(){return this.wf.Hm()}chartElement(){return this.wf.Ef()}panes(){return this.wf.Qt().$s().map((t=>this.Mg(t)))}paneSize(t=0){const i=this.wf.jm(t);return{height:i.height,width:i.width}}setCrosshairPosition(t,i,s){const n=this.ag.get(s);if(void 0===n)return;const e=this.wf.Qt().Wn(n);null!==e&&this.wf.Qt().hc(t,i,e)}clearCrosshairPosition(){this.wf.Qt().lc(!0)}horzBehaviour(){return this.fg}gg(i,s={},n=0){r(void 0!==i.mg),In(s.priceFormat),"Candlestick"===i.type&&function(t){void 0!==t.borderColor&&(t.borderUpColor=t.borderColor,t.borderDownColor=t.borderColor),void 0!==t.wickColor&&(t.wickUpColor=t.wickColor,t.wickDownColor=t.wickColor)}(s);const e=_(p(t),p(i.defaultOptions),s),h=i.mg,l=new Ht(this.wf.Qt(),i.type,e,h,i.wg);this.wf.Qt()._c(l,n);const a=new zn(l,this,this,this,this.fg,(t=>this.Mg(t)));return this.ag.set(a,l),this.og.set(l,a),a}bg(t){const i=this.wf.Qt();i.ac(t.It.H_,t.It.kw,t.It.Rw),t.mo.forEach(((t,i)=>i.ht(t.ie,t.Tw))),i.It().C_(),i.q_()}Sg(t){return h(this.og.get(t))}pg(t){const i=new Map;t.rw.forEach(((t,s)=>{const n=s.kr(),e=bn(n)(t);if("Custom"!==n)r(Hs(e));else{const t=s.fl();r(!t||!1===t(e))}i.set(this.Sg(s),e)}));const s=void 0!==t.ew&&this.og.has(t.ew)?this.Sg(t.ew):void 0;return{time:t.iw,logical:t.ke,point:t.sw,paneIndex:t.nw,hoveredSeries:s,hoveredObjectId:t.hw,seriesData:i,sourceEvent:t.lw}}Mg(t){let i=this.yu.get(t);return i||(i=new Rn(this.wf,(t=>this.Sg(t)),t,this),this.yu.set(t,i)),i}}function Ln(t,i,s){const n=function(t){if(d(t)){const i=document.getElementById(t);return r(null!==i,`Cannot find element in DOM with id=${t}`),i}return t}(t),e=new Bn(n,i,s);return i.setOptions(e.options()),e}function On(t,i){return Ln(t,new Ki,Ki.Lc(i))}class Nn extends ln{constructor(t,i){super(t,i,!0)}Hw(t,i,s){i.U_(this.Vw,m(this.Iw)),t.Da(this.Vw,s,m(this.Iw))}xg(t,i){return{wt:t,gt:i,_t:NaN,ut:NaN}}Fw(){const t=this.Gn.kh();this.Vw=this.Gn.Zs().Wr().map((i=>{const s=i.Wt[3];return this.yg(i.ke,s,t)}))}}const Fn=6;function Wn(t,i){return{_t:t._t-i._t,ut:t.ut-i.ut}}function Hn(t,i){return{_t:t._t/i,ut:t.ut/i}}function $n(t,i,s){const n=Math.max(0,i-1),e=Math.min(t.length-1,s+1);var r,h;return[(r=t[i],h=Hn(Wn(t[s],t[n]),Fn),{_t:r._t+h._t,ut:r.ut+h.ut}),Wn(t[s],Hn(Wn(t[e],t[i]),Fn))]}function Un(t,i){const s=t.context;s.strokeStyle=i,s.stroke()}class jn extends P{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et(t){if(null===this.rt)return;const{ot:i,lt:s,Pg:e,Cg:r,ct:h,qt:l,Tg:a}=this.rt;if(null===s)return;const o=t.context;o.lineCap="butt",o.lineWidth=h*t.verticalPixelRatio,n(o,l),o.lineJoin="round";const _=this.kg.bind(this);void 0!==r&&function(t,i,s,n,e,r,h){if(0===i.length||n.from>=i.length||n.to<=0)return;const{context:l,horizontalPixelRatio:a,verticalPixelRatio:o}=t,_=i[n.from];let u=r(t,_),c=_;if(n.to-n.from<2){const i=e/2;l.beginPath();const s={_t:_._t-i,ut:_.ut},n={_t:_._t+i,ut:_.ut};l.moveTo(s._t*a,s.ut*o),l.lineTo(n._t*a,n.ut*o),h(t,u,s,n)}else{const e=(i,s)=>{h(t,u,c,s),l.beginPath(),u=i,c=s};let d=c;l.beginPath(),l.moveTo(_._t*a,_.ut*o);for(let h=n.from+1;h=n.from;--s){const n=i[s];if(n){const i=e(t,n);i!==a&&(l.beginPath(),null!==a&&l.fill(),l.fillStyle=i,a=i);const s=Math.round(n._t*r)+o,u=n.ut*h;l.moveTo(s,u),l.arc(s,u,_,0,2*Math.PI)}}l.fill()}(t,i,a,s,_)}}class Yn extends jn{kg(t,i){return i.vt}}class Xn extends Nn{constructor(){super(...arguments),this.Lw=new Yn}yg(t,i,s){return{...this.xg(t,i),...s.Rr(t)}}$w(){const t=this.Gn.N(),i={ot:this.Vw,qt:t.lineStyle,Cg:t.lineVisible?t.lineType:void 0,ct:t.lineWidth,Tg:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0,lt:this.Iw,Pg:this.Jn.It().K_()};this.Lw.ht(i)}}const Zn={type:"Line",isBuiltIn:!0,defaultOptions:{color:"#2196f3",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},mg:(t,i)=>new Xn(t,i)};class qn extends P{constructor(){super(...arguments),this.Yt=null,this.Rg=0}ht(t){this.Yt=t}et(t){if(null===this.Yt||0===this.Yt.Zs.length||null===this.Yt.lt)return;const{horizontalPixelRatio:i}=t;if(this.Rg=function(t,i){if(t>=2.5&&t<=4)return Math.floor(3*i);const s=1-.2*Math.atan(Math.max(4,t)-4)/(.5*Math.PI),n=Math.floor(t*s*i),e=Math.floor(t*i),r=Math.min(n,e);return Math.max(Math.floor(i),r)}(this.Yt.K_,i),this.Rg>=2){Math.floor(i)%2!=this.Rg%2&&this.Rg--}const s=this.Yt.Zs;this.Yt.Dg&&this.Eg(t,s,this.Yt.lt),this.Yt.bi&&this.Wp(t,s,this.Yt.lt);const n=this.zg(i);(!this.Yt.bi||this.Rg>2*n)&&this.Vg(t,s,this.Yt.lt)}Eg(t,i,s){if(null===this.Yt)return;const{context:n,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="",l=Math.min(Math.floor(e),Math.floor(this.Yt.K_*e));l=Math.max(Math.floor(e),Math.min(l,this.Rg));const a=Math.floor(.5*l);let o=null;for(let t=s.from;t2*l)z(n,o,u,_-o+1,c-u+1,l);else{const t=_-o+1;n.fillRect(o,u,t,c-u+1)}a=_}}Vg(t,i,s){if(null===this.Yt)return;const{context:n,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="";const l=this.zg(e);for(let t=s.from;to||n.fillRect(_,a,u-_+1,o-a+1)}}}class Kn extends ln{constructor(t,i){super(t,i,!1)}Hw(t,i,s){i.U_(this.Vw,m(this.Iw)),t.za(this.Vw,s,m(this.Iw))}Ig(t,i,s){return{wt:t,Uh:i.Wt[0],jh:i.Wt[1],Yh:i.Wt[2],Xh:i.Wt[3],_t:NaN,Va:NaN,Ia:NaN,Aa:NaN,Ba:NaN}}Fw(){const t=this.Gn.kh();this.Vw=this.Gn.Zs().Wr().map((i=>this.yg(i.ke,i,t)))}}class Gn extends Kn{constructor(){super(...arguments),this.Lw=new qn}yg(t,i,s){return{...this.Ig(t,i,s),...s.Rr(t)}}$w(){const t=this.Gn.N();this.Lw.ht({Zs:this.Vw,K_:this.Jn.It().K_(),Dg:t.wickVisible,bi:t.borderVisible,lt:this.Iw})}}const Jn={type:"Candlestick",isBuiltIn:!0,defaultOptions:{upColor:"#26a69a",downColor:"#ef5350",wickVisible:!0,borderVisible:!0,borderColor:"#378658",borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickColor:"#737375",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},mg:(t,i)=>new Gn(t,i)},Qn={...t,color:"#2196f3"};export{Jn as CandlestickSeries,Di as ColorType,U as CrosshairMode,ki as LastPriceAnimationMode,Zn as LineSeries,s as LineStyle,i as LineType,xt as MismatchDirection,Ri as PriceLineSource,_i as PriceScaleMode,Ei as TickMarkType,Ti as TrackingModeExitMode,On as createChart,Qn as customSeriesDefaultOptions,Vi as isBusinessDay,Ii as isUTCTimestamp}; diff --git a/websites/kibo.money/packages/lightweight-charts/v5.0.6-treeshaked/types.ts b/websites/kibo.money/packages/lightweight-charts/v5.0.6-treeshaked/types.ts new file mode 100644 index 000000000..14721c743 --- /dev/null +++ b/websites/kibo.money/packages/lightweight-charts/v5.0.6-treeshaked/types.ts @@ -0,0 +1,3920 @@ +// Generated by dts-bundle-generator v9.5.1 + +import { CanvasRenderingTarget2D } from 'fancy-canvas'; + +declare const candlestickSeries: SeriesDefinition<"Candlestick">; +declare const lineSeries: SeriesDefinition<"Line">; +export declare const customSeriesDefaultOptions: CustomSeriesOptions; +/** + * Represents a type of color. + */ +export declare enum ColorType { + /** Solid color */ + Solid = "solid", + /** Vertical gradient color */ + VerticalGradient = "gradient" +} +/** + * Represents the crosshair mode. + */ +export declare enum CrosshairMode { + /** + * This mode allows crosshair to move freely on the chart. + */ + Normal = 0, + /** + * This mode sticks crosshair's horizontal line to the price value of a single-value series or to the close price of OHLC-based series. + */ + Magnet = 1, + /** + * This mode disables rendering of the crosshair. + */ + Hidden = 2, + /** + * This mode sticks crosshair's horizontal line to the price value of a single-value series or to the open/high/low/close price of OHLC-based series. + */ + MagnetOHLC = 3 +} +/** + * Represents the type of the last price animation for series such as area or line. + */ +export declare enum LastPriceAnimationMode { + /** + * Animation is always disabled + */ + Disabled = 0, + /** + * Animation is always enabled. + */ + Continuous = 1, + /** + * Animation is active after new data. + */ + OnDataUpdate = 2 +} +/** + * Represents the possible line styles. + */ +export declare enum LineStyle { + /** + * A solid line. + */ + Solid = 0, + /** + * A dotted line. + */ + Dotted = 1, + /** + * A dashed line. + */ + Dashed = 2, + /** + * A dashed line with bigger dashes. + */ + LargeDashed = 3, + /** + * A dotted line with more space between dots. + */ + SparseDotted = 4 +} +/** + * Represents the possible line types. + */ +export declare enum LineType { + /** + * A line. + */ + Simple = 0, + /** + * A stepped line. + */ + WithSteps = 1, + /** + * A curved line. + */ + Curved = 2 +} +/** + * Search direction if no data found at provided index + */ +export declare enum MismatchDirection { + /** + * Search the nearest left item + */ + NearestLeft = -1, + /** + * Do not search + */ + None = 0, + /** + * Search the nearest right item + */ + NearestRight = 1 +} +/** + * Represents the source of data to be used for the horizontal price line. + */ +export declare enum PriceLineSource { + /** + * Use the last bar data. + */ + LastBar = 0, + /** + * Use the last visible data of the chart viewport. + */ + LastVisible = 1 +} +/** + * Represents the price scale mode. + */ +export declare enum PriceScaleMode { + /** + * Price scale shows prices. Price range changes linearly. + */ + Normal = 0, + /** + * Price scale shows prices. Price range changes logarithmically. + */ + Logarithmic = 1, + /** + * Price scale shows percentage values according the first visible value of the price scale. + * The first visible value is 0% in this mode. + */ + Percentage = 2, + /** + * The same as percentage mode, but the first value is moved to 100. + */ + IndexedTo100 = 3 +} +/** + * Represents the type of a tick mark on the time axis. + */ +export declare enum TickMarkType { + /** + * The start of the year (e.g. it's the first tick mark in a year). + */ + Year = 0, + /** + * The start of the month (e.g. it's the first tick mark in a month). + */ + Month = 1, + /** + * A day of the month. + */ + DayOfMonth = 2, + /** + * A time without seconds. + */ + Time = 3, + /** + * A time with seconds. + */ + TimeWithSeconds = 4 +} +/** + * Determine how to exit the tracking mode. + * + * By default, mobile users will long press to deactivate the scroll and have the ability to check values and dates. + * Another press is required to activate the scroll, be able to move left/right, zoom, etc. + */ +export declare enum TrackingModeExitMode { + /** + * Tracking Mode will be deactivated on touch end event. + */ + OnTouchEnd = 0, + /** + * Tracking Mode will be deactivated on the next tap event. + */ + OnNextTap = 1 +} +/** + * This function is the simplified main entry point of the Lightweight Charting Library with time points for the horizontal scale. + * + * @param container - ID of HTML element or element itself + * @param options - Any subset of options to be applied at start. + * @returns An interface to the created chart + */ +export declare function createChart(container: string | HTMLElement, options?: DeepPartial): IChartApi; +/** + * Check if a time value is a business day object. + * + * @param time - The time to check. + * @returns `true` if `time` is a {@link BusinessDay} object, false otherwise. + */ +export declare function isBusinessDay(time: Time): time is BusinessDay; +/** + * Check if a time value is a UTC timestamp number. + * + * @param time - The time to check. + * @returns `true` if `time` is a {@link UTCTimestamp} number, false otherwise. + */ +export declare function isUTCTimestamp(time: Time): time is UTCTimestamp; +/** + * Structure describing a single item of data for area series + */ +export interface AreaData extends SingleValueData { + /** + * Optional line color value for certain data item. If missed, color from options is used + */ + lineColor?: string; + /** + * Optional top color value for certain data item. If missed, color from options is used + */ + topColor?: string; + /** + * Optional bottom color value for certain data item. If missed, color from options is used + */ + bottomColor?: string; +} +/** + * Represents style options for an area series. + */ +export interface AreaStyleOptions { + /** + * Color of the top part of the area. + * + * @defaultValue `'rgba( 46, 220, 135, 0.4)'` + */ + topColor: string; + /** + * Color of the bottom part of the area. + * + * @defaultValue `'rgba( 40, 221, 100, 0)'` + */ + bottomColor: string; + /** + * Gradient is relative to the base value and the currently visible range. + * If it is false, the gradient is relative to the top and bottom of the chart. + * + * @defaultValue `false` + */ + relativeGradient: boolean; + /** + * Invert the filled area. Fills the area above the line if set to true. + * + * @defaultValue `false` + */ + invertFilledArea: boolean; + /** + * Line color. + * + * @defaultValue `'#33D778'` + */ + lineColor: string; + /** + * Line style. + * + * @defaultValue {@link LineStyle.Solid} + */ + lineStyle: LineStyle; + /** + * Line width in pixels. + * + * @defaultValue `3` + */ + lineWidth: LineWidth; + /** + * Line type. + * + * @defaultValue {@link LineType.Simple} + */ + lineType: LineType; + /** + * Show series line. + * + * @defaultValue `true` + */ + lineVisible: boolean; + /** + * Show circle markers on each point. + * + * @defaultValue `false` + */ + pointMarkersVisible: boolean; + /** + * Circle markers radius in pixels. + * + * @defaultValue `undefined` + */ + pointMarkersRadius?: number; + /** + * Show the crosshair marker. + * + * @defaultValue `true` + */ + crosshairMarkerVisible: boolean; + /** + * Crosshair marker radius in pixels. + * + * @defaultValue `4` + */ + crosshairMarkerRadius: number; + /** + * Crosshair marker border color. An empty string falls back to the color of the series under the crosshair. + * + * @defaultValue `''` + */ + crosshairMarkerBorderColor: string; + /** + * The crosshair marker background color. An empty string falls back to the color of the series under the crosshair. + * + * @defaultValue `''` + */ + crosshairMarkerBackgroundColor: string; + /** + * Crosshair marker border width in pixels. + * + * @defaultValue `2` + */ + crosshairMarkerBorderWidth: number; + /** + * Last price animation mode. + * + * @defaultValue {@link LastPriceAnimationMode.Disabled} + */ + lastPriceAnimation: LastPriceAnimationMode; +} +/** + * Represents the margin used when updating a price scale. + */ +export interface AutoScaleMargins { + /** The number of pixels for bottom margin */ + below: number; + /** The number of pixels for top margin */ + above: number; +} +/** + * Represents information used to update a price scale. + */ +export interface AutoscaleInfo { + /** + * Price range. + */ + priceRange: PriceRange | null; + /** + * Scale margins. + */ + margins?: AutoScaleMargins; +} +/** + * Represents options for how the time and price axes react to mouse double click. + */ +export interface AxisDoubleClickOptions { + /** + * Enable resetting scaling the time axis by double-clicking the left mouse button. + * + * @defaultValue `true` + */ + time: boolean; + /** + * Enable reseting scaling the price axis by by double-clicking the left mouse button. + * + * @defaultValue `true` + */ + price: boolean; +} +/** + * Represents options for how the time and price axes react to mouse movements. + */ +export interface AxisPressedMouseMoveOptions { + /** + * Enable scaling the time axis by holding down the left mouse button and moving the mouse. + * + * @defaultValue `true` + */ + time: boolean; + /** + * Enable scaling the price axis by holding down the left mouse button and moving the mouse. + * + * @defaultValue `true` + */ + price: boolean; +} +/** + * Structure describing a single item of data for bar series + */ +export interface BarData extends OhlcData { + /** + * Optional color value for certain data item. If missed, color from options is used + */ + color?: string; +} +/** + * Represents style options for a bar series. + */ +export interface BarStyleOptions { + /** + * Color of rising bars. + * + * @defaultValue `'#26a69a'` + */ + upColor: string; + /** + * Color of falling bars. + * + * @defaultValue `'#ef5350'` + */ + downColor: string; + /** + * Show open lines on bars. + * + * @defaultValue `true` + */ + openVisible: boolean; + /** + * Show bars as sticks. + * + * @defaultValue `true` + */ + thinBars: boolean; +} +/** + * Represents a range of bars and the number of bars outside the range. + */ +export interface BarsInfo extends Partial> { + /** + * The number of bars before the start of the range. + * Positive value means that there are some bars before (out of logical range from the left) the {@link IRange.from} logical index in the series. + * Negative value means that the first series' bar is inside the passed logical range, and between the first series' bar and the {@link IRange.from} logical index are some bars. + */ + barsBefore: number; + /** + * The number of bars after the end of the range. + * Positive value in the `barsAfter` field means that there are some bars after (out of logical range from the right) the {@link IRange.to} logical index in the series. + * Negative value means that the last series' bar is inside the passed logical range, and between the last series' bar and the {@link IRange.to} logical index are some bars. + */ + barsAfter: number; +} +/** + * Represents a type of priced base value of baseline series type. + */ +export interface BaseValuePrice { + /** + * Distinguished type value. + */ + type: "price"; + /** + * Price value. + */ + price: number; +} +/** + * Structure describing a single item of data for baseline series + */ +export interface BaselineData extends SingleValueData { + /** + * Optional top area top fill color value for certain data item. If missed, color from options is used + */ + topFillColor1?: string; + /** + * Optional top area bottom fill color value for certain data item. If missed, color from options is used + */ + topFillColor2?: string; + /** + * Optional top area line color value for certain data item. If missed, color from options is used + */ + topLineColor?: string; + /** + * Optional bottom area top fill color value for certain data item. If missed, color from options is used + */ + bottomFillColor1?: string; + /** + * Optional bottom area bottom fill color value for certain data item. If missed, color from options is used + */ + bottomFillColor2?: string; + /** + * Optional bottom area line color value for certain data item. If missed, color from options is used + */ + bottomLineColor?: string; +} +/** + * Represents style options for a baseline series. + */ +export interface BaselineStyleOptions { + /** + * Base value of the series. + * + * @defaultValue `{ type: 'price', price: 0 }` + */ + baseValue: BaseValueType; + /** + * Gradient is relative to the base value and the currently visible range. + * If it is false, the gradient is relative to the top and bottom of the chart. + * + * @defaultValue `false` + */ + relativeGradient: boolean; + /** + * The first color of the top area. + * + * @defaultValue `'rgba(38, 166, 154, 0.28)'` + */ + topFillColor1: string; + /** + * The second color of the top area. + * + * @defaultValue `'rgba(38, 166, 154, 0.05)'` + */ + topFillColor2: string; + /** + * The line color of the top area. + * + * @defaultValue `'rgba(38, 166, 154, 1)'` + */ + topLineColor: string; + /** + * The first color of the bottom area. + * + * @defaultValue `'rgba(239, 83, 80, 0.05)'` + */ + bottomFillColor1: string; + /** + * The second color of the bottom area. + * + * @defaultValue `'rgba(239, 83, 80, 0.28)'` + */ + bottomFillColor2: string; + /** + * The line color of the bottom area. + * + * @defaultValue `'rgba(239, 83, 80, 1)'` + */ + bottomLineColor: string; + /** + * Line width. + * + * @defaultValue `3` + */ + lineWidth: LineWidth; + /** + * Line style. + * + * @defaultValue {@link LineStyle.Solid} + */ + lineStyle: LineStyle; + /** + * Line type. + * + * @defaultValue {@link LineType.Simple} + */ + lineType: LineType; + /** + * Show series line. + * + * @defaultValue `true` + */ + lineVisible: boolean; + /** + * Show circle markers on each point. + * + * @defaultValue `false` + */ + pointMarkersVisible: boolean; + /** + * Circle markers radius in pixels. + * + * @defaultValue `undefined` + */ + pointMarkersRadius?: number; + /** + * Show the crosshair marker. + * + * @defaultValue `true` + */ + crosshairMarkerVisible: boolean; + /** + * Crosshair marker radius in pixels. + * + * @defaultValue `4` + */ + crosshairMarkerRadius: number; + /** + * Crosshair marker border color. An empty string falls back to the color of the series under the crosshair. + * + * @defaultValue `''` + */ + crosshairMarkerBorderColor: string; + /** + * The crosshair marker background color. An empty string falls back to the color of the series under the crosshair. + * + * @defaultValue `''` + */ + crosshairMarkerBackgroundColor: string; + /** + * Crosshair marker border width in pixels. + * + * @defaultValue `2` + */ + crosshairMarkerBorderWidth: number; + /** + * Last price animation mode. + * + * @defaultValue {@link LastPriceAnimationMode.Disabled} + */ + lastPriceAnimation: LastPriceAnimationMode; +} +/** + * Represents a time as a day/month/year. + * + * @example + * ```js + * const day = { year: 2019, month: 6, day: 1 }; // June 1, 2019 + * ``` + */ +export interface BusinessDay { + /** + * The year. + */ + year: number; + /** + * The month. + */ + month: number; + /** + * The day. + */ + day: number; +} +/** + * Structure describing a single item of data for candlestick series + */ +export interface CandlestickData extends OhlcData { + /** + * Optional color value for certain data item. If missed, color from options is used + */ + color?: string; + /** + * Optional border color value for certain data item. If missed, color from options is used + */ + borderColor?: string; + /** + * Optional wick color value for certain data item. If missed, color from options is used + */ + wickColor?: string; +} +/** + * Represents style options for a candlestick series. + */ +export interface CandlestickStyleOptions { + /** + * Color of rising candles. + * + * @defaultValue `'#26a69a'` + */ + upColor: string; + /** + * Color of falling candles. + * + * @defaultValue `'#ef5350'` + */ + downColor: string; + /** + * Enable high and low prices candle wicks. + * + * @defaultValue `true` + */ + wickVisible: boolean; + /** + * Enable candle borders. + * + * @defaultValue `true` + */ + borderVisible: boolean; + /** + * Border color. + * + * @defaultValue `'#378658'` + */ + borderColor: string; + /** + * Border color of rising candles. + * + * @defaultValue `'#26a69a'` + */ + borderUpColor: string; + /** + * Border color of falling candles. + * + * @defaultValue `'#ef5350'` + */ + borderDownColor: string; + /** + * Wick color. + * + * @defaultValue `'#737375'` + */ + wickColor: string; + /** + * Wick color of rising candles. + * + * @defaultValue `'#26a69a'` + */ + wickUpColor: string; + /** + * Wick color of falling candles. + * + * @defaultValue `'#ef5350'` + */ + wickDownColor: string; +} +/** + * Represents common chart options + */ +export interface ChartOptionsBase { + /** + * Width of the chart in pixels + * + * @defaultValue If `0` (default) or none value provided, then a size of the widget will be calculated based its container's size. + */ + width: number; + /** + * Height of the chart in pixels + * + * @defaultValue If `0` (default) or none value provided, then a size of the widget will be calculated based its container's size. + */ + height: number; + /** + * Setting this flag to `true` will make the chart watch the chart container's size and automatically resize the chart to fit its container whenever the size changes. + * + * This feature requires [`ResizeObserver`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) class to be available in the global scope. + * Note that calling code is responsible for providing a polyfill if required. If the global scope does not have `ResizeObserver`, a warning will appear and the flag will be ignored. + * + * Please pay attention that `autoSize` option and explicit sizes options `width` and `height` don't conflict with one another. + * If you specify `autoSize` flag, then `width` and `height` options will be ignored unless `ResizeObserver` has failed. If it fails then the values will be used as fallback. + * + * The flag `autoSize` could also be set with and unset with `applyOptions` function. + * ```js + * const chart = LightweightCharts.createChart(document.body, { + * autoSize: true, + * }); + * ``` + */ + autoSize: boolean; + /** + * Layout options + */ + layout: LayoutOptions; + /** + * Left price scale options + */ + leftPriceScale: VisiblePriceScaleOptions; + /** + * Right price scale options + */ + rightPriceScale: VisiblePriceScaleOptions; + /** + * Overlay price scale options + */ + overlayPriceScales: OverlayPriceScaleOptions; + /** + * Time scale options + */ + timeScale: HorzScaleOptions; + /** + * The crosshair shows the intersection of the price and time scale values at any point on the chart. + * + */ + crosshair: CrosshairOptions; + /** + * A grid is represented in the chart background as a vertical and horizontal lines drawn at the levels of visible marks of price and the time scales. + */ + grid: GridOptions; + /** + * Scroll options, or a boolean flag that enables/disables scrolling + */ + handleScroll: HandleScrollOptions | boolean; + /** + * Scale options, or a boolean flag that enables/disables scaling + */ + handleScale: HandleScaleOptions | boolean; + /** + * Kinetic scroll options + */ + kineticScroll: KineticScrollOptions; + /** @inheritDoc TrackingModeOptions + */ + trackingMode: TrackingModeOptions; + /** + * Basic localization options + */ + localization: LocalizationOptionsBase; +} +/** + * Structure describing options of the chart. Series options are to be set separately + */ +export interface ChartOptionsImpl extends ChartOptionsBase { + /** + * Localization options. + */ + localization: LocalizationOptions; +} +/** Structure describing a crosshair line (vertical or horizontal) */ +export interface CrosshairLineOptions { + /** + * Crosshair line color. + * + * @defaultValue `'#758696'` + */ + color: string; + /** + * Crosshair line width. + * + * @defaultValue `1` + */ + width: LineWidth; + /** + * Crosshair line style. + * + * @defaultValue {@link LineStyle.LargeDashed} + */ + style: LineStyle; + /** + * Display the crosshair line. + * + * Note that disabling crosshair lines does not disable crosshair marker on Line and Area series. + * It can be disabled by using `crosshairMarkerVisible` option of a relevant series. + * + * @see {@link LineStyleOptions.crosshairMarkerVisible} + * @see {@link AreaStyleOptions.crosshairMarkerVisible} + * @see {@link BaselineStyleOptions.crosshairMarkerVisible} + * @defaultValue `true` + */ + visible: boolean; + /** + * Display the crosshair label on the relevant scale. + * + * @defaultValue `true` + */ + labelVisible: boolean; + /** + * Crosshair label background color. + * + * @defaultValue `'#4c525e'` + */ + labelBackgroundColor: string; +} +/** Structure describing crosshair options */ +export interface CrosshairOptions { + /** + * Crosshair mode + * + * @defaultValue {@link CrosshairMode.Magnet} + */ + mode: CrosshairMode; + /** + * Vertical line options. + */ + vertLine: CrosshairLineOptions; + /** + * Horizontal line options. + */ + horzLine: CrosshairLineOptions; +} +/** + * Renderer data for an item within the custom series. + */ +export interface CustomBarItemData = CustomData> { + /** + * Horizontal coordinate for the item. Measured from the left edge of the pane in pixels. + */ + x: number; + /** + * Time scale index for the item. This isn't the timestamp but rather the logical index. + */ + time: number; + /** + * Original data for the item. + */ + originalData: TData; + /** + * Color assigned for the item, typically used for price line and price scale label. + */ + barColor: string; +} +/** + * Base structure describing a single item of data for a custom series. + * + * This type allows for any properties to be defined + * within the interface. It is recommended that you extend this interface with + * the required data structure. + */ +export interface CustomData extends CustomSeriesWhitespaceData { + /** + * If defined then this color will be used for the price line and price scale line + * for this specific data item of the custom series. + */ + color?: string; +} +/** + * Represents a whitespace data item, which is a data point without a value. + */ +export interface CustomSeriesWhitespaceData { + /** + * The time of the data. + */ + time: HorzScaleItem; + /** + * Additional custom values which will be ignored by the library, but + * could be used by plugins. + */ + customValues?: Record; +} +/** + * Represents style options for a custom series. + */ +export interface CustomStyleOptions { + /** + * Color used for the price line and price scale label. + */ + color: string; +} +/** Grid line options. */ +export interface GridLineOptions { + /** + * Line color. + * + * @defaultValue `'#D6DCDE'` + */ + color: string; + /** + * Line style. + * + * @defaultValue {@link LineStyle.Solid} + */ + style: LineStyle; + /** + * Display the lines. + * + * @defaultValue `true` + */ + visible: boolean; +} +/** Structure describing grid options. */ +export interface GridOptions { + /** + * Vertical grid line options. + */ + vertLines: GridLineOptions; + /** + * Horizontal grid line options. + */ + horzLines: GridLineOptions; +} +/** + * Represents options for how the chart is scaled by the mouse and touch gestures. + */ +export interface HandleScaleOptions { + /** + * Enable scaling with the mouse wheel. + * + * @defaultValue `true` + */ + mouseWheel: boolean; + /** + * Enable scaling with pinch/zoom gestures. + * + * @defaultValue `true` + */ + pinch: boolean; + /** + * Enable scaling the price and/or time scales by holding down the left mouse button and moving the mouse. + */ + axisPressedMouseMove: AxisPressedMouseMoveOptions | boolean; + /** + * Enable resetting scaling by double-clicking the left mouse button. + */ + axisDoubleClickReset: AxisDoubleClickOptions | boolean; +} +/** + * Represents options for how the chart is scrolled by the mouse and touch gestures. + */ +export interface HandleScrollOptions { + /** + * Enable scrolling with the mouse wheel. + * + * @defaultValue `true` + */ + mouseWheel: boolean; + /** + * Enable scrolling by holding down the left mouse button and moving the mouse. + * + * @defaultValue `true` + */ + pressedMouseMove: boolean; + /** + * Enable horizontal touch scrolling. + * + * When enabled the chart handles touch gestures that would normally scroll the webpage horizontally. + * + * @defaultValue `true` + */ + horzTouchDrag: boolean; + /** + * Enable vertical touch scrolling. + * + * When enabled the chart handles touch gestures that would normally scroll the webpage vertically. + * + * @defaultValue `true` + */ + vertTouchDrag: boolean; +} +/** + * Structure describing a single item of data for histogram series + */ +export interface HistogramData extends SingleValueData { + /** + * Optional color value for certain data item. If missed, color from options is used + */ + color?: string; +} +/** + * Represents style options for a histogram series. + */ +export interface HistogramStyleOptions { + /** + * Column color. + * + * @defaultValue `'#26a69a'` + */ + color: string; + /** + * Initial level of histogram columns. + * + * @defaultValue `0` + */ + base: number; +} +/** + * Options for the time scale; the horizontal scale at the bottom of the chart that displays the time of data. + */ +export interface HorzScaleOptions { + /** + * The margin space in bars from the right side of the chart. + * + * @defaultValue `0` + */ + rightOffset: number; + /** + * The space between bars in pixels. + * + * @defaultValue `6` + */ + barSpacing: number; + /** + * The minimum space between bars in pixels. + * + * @defaultValue `0.5` + */ + minBarSpacing: number; + /** + * The maximum space between bars in pixels. + * + * Has no effect if value is set to `0`. + * + * @defaultValue `0` + */ + maxBarSpacing: number; + /** + * Prevent scrolling to the left of the first bar. + * + * @defaultValue `false` + */ + fixLeftEdge: boolean; + /** + * Prevent scrolling to the right of the most recent bar. + * + * @defaultValue `false` + */ + fixRightEdge: boolean; + /** + * Prevent changing the visible time range during chart resizing. + * + * @defaultValue `false` + */ + lockVisibleTimeRangeOnResize: boolean; + /** + * Prevent the hovered bar from moving when scrolling. + * + * @defaultValue `false` + */ + rightBarStaysOnScroll: boolean; + /** + * Show the time scale border. + * + * @defaultValue `true` + */ + borderVisible: boolean; + /** + * The time scale border color. + * + * @defaultValue `'#2B2B43'` + */ + borderColor: string; + /** + * Show the time scale. + * + * @defaultValue `true` + */ + visible: boolean; + /** + * Show the time, not just the date, in the time scale and vertical crosshair label. + * + * @defaultValue `false` + */ + timeVisible: boolean; + /** + * Show seconds in the time scale and vertical crosshair label in `hh:mm:ss` format for intraday data. + * + * @defaultValue `true` + */ + secondsVisible: boolean; + /** + * Shift the visible range to the right (into the future) by the number of new bars when new data is added. + * + * Note that this only applies when the last bar is visible. + * + * @defaultValue `true` + */ + shiftVisibleRangeOnNewBar: boolean; + /** + * Allow the visible range to be shifted to the right when a new bar is added which + * is replacing an existing whitespace time point on the chart. + * + * Note that this only applies when the last bar is visible & `shiftVisibleRangeOnNewBar` is enabled. + * + * @defaultValue `false` + */ + allowShiftVisibleRangeOnWhitespaceReplacement: boolean; + /** + * Draw small vertical line on time axis labels. + * + * @defaultValue `false` + */ + ticksVisible: boolean; + /** + * Maximum tick mark label length. Used to override the default 8 character maximum length. + * + * @defaultValue `undefined` + */ + tickMarkMaxCharacterLength?: number; + /** + * Changes horizontal scale marks generation. + * With this flag equal to `true`, marks of the same weight are either all drawn or none are drawn at all. + */ + uniformDistribution: boolean; + /** + * Define a minimum height for the time scale. + * Note: This value will be exceeded if the + * time scale needs more space to display it's contents. + * + * Setting a minimum height could be useful for ensuring that + * multiple charts positioned in a horizontal stack each have + * an identical time scale height, or for plugins which + * require a bit more space within the time scale pane. + * + * @defaultValue 0 + */ + minimumHeight: number; + /** + * Allow major time scale labels to be rendered in a bolder font weight. + * + * @defaultValue true + */ + allowBoldLabels: boolean; + /** + * Ignore time scale points containing only whitespace (for all series) when + * drawing grid lines, tick marks, and snapping the crosshair to time scale points. + * + * For the yield curve chart type it defaults to `true`. + * + * @defaultValue false + */ + ignoreWhitespaceIndices: boolean; +} +/** + * The main interface of a single chart using time for horizontal scale. + */ +export interface IChartApi extends IChartApiBase