HarmonicSwitches
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RozaniGhani-RG

//@version=5

// @description TODO: library for HarmonicSwitches
library('HarmonicSwitches')

// 0. TupleSwitchHL
// 1. TupleSwitchStyleColor 
// 2. TupleSwitchString
// 3. TupleSwitchValid
// 4. TupleSwitchTime
// 5. SwitchColor
// 6. SwitchExtend

// —————————————————————————————————————————————————————————————————————————————  0. TupleSwitchHL {
// @function : Tuple Switch for High Low
// @param    : _bool, low_X, high_X, low_A, high_A, low_B, high_B, low_C, high_C
// @returns  : price_X, price_A, price_B, price_C
export TupleSwitchHL(bool _bool, float low_X, float high_X, float low_A, float high_A, float low_B, float high_B, float low_C, float high_C) =>
    [price_X, price_A, price_B, price_C] = switch _bool
    // Output : price_X, price_A, price_B, price_C
        true => [ low_X,  high_A,   low_B,  high_C]
        =>      [high_X,   low_A,  high_B,   low_C]
    [price_X, price_A, price_B, price_C]
// }
// —————————————————————————————————————————————————————————————————————————————  1. TupleSwitchStyleColor {
// @function : Tuple switch for style and color
// @param    : _bool
// @returns  : style0, style1, col_dir
export TupleSwitchStyleColor(bool _bool) =>
    [style0, style1, col_dir] = switch _bool
    // Output :                  style0,                 style1,    col_dir
        true => [  label.style_label_up, label.style_label_down, color.lime]
        =>      [label.style_label_down,   label.style_label_up,  color.red]
    [style0, style1, col_dir] 
// }
// —————————————————————————————————————————————————————————————————————————————  2. TupleSwitchString {
// @function : Tuple switch for string
// @param    : _bool
// @returns  : str_dir, str_X, str_A
export TupleSwitchString(bool _bool) =>
    [str_dir, str_X, str_A] = switch _bool
    // Output :    str_dir,  str_X,  str_A
        true => ['BULLISH',  'LOW', 'HIGH']
        =>      ['BEARISH', 'HIGH',  'LOW']
    [str_dir, str_X, str_A]
// }
// —————————————————————————————————————————————————————————————————————————————  3. TupleSwitchValid {
// @function : Tuple switch for valid
// @param    : _str
// @returns  : str_invalid, str_valid
export TupleSwitchValid(string _str) =>
    [str_invalid, str_valid] = switch _str
    // Output :   str_invalid, str_valid
        'Text'  => ['INVALID', 'VALID']
        'Emoji' => [    '❌','✅']
    [str_invalid, str_valid]
// }
// —————————————————————————————————————————————————————————————————————————————  4. TupleSwitchTime {
// @function : Tuple switch for time
// @param    : _str, time_1, time_2, time_3
// @returns  : E1, E2
export TupleSwitchTime(string _str, int time_1, int time_2, int time_3) =>
    [E1, E2] = switch _str
        'Price C' => [time_1, time_2]
        'Price D' => [time_2, time_2 + time_3]
    [E1, E2]
// }
// —————————————————————————————————————————————————————————————————————————————  5. SwitchColor {
// @function : Switch color
// @param    : _str
// @returns  : col_valid
export SwitchColor(string _str) =>
    col_valid = switch _str
        'INVALID' => color.red
        '❌'     => color.red
        'VALID'   => color.blue
        '✅'     => color.blue
    col_valid
// }
// —————————————————————————————————————————————————————————————————————————————  6. SwitchExtend {
// @function : Extend line
// @param    : _str
// @returns  : _extend
export SwitchExtend(string _str) =>
    _extend  = switch _str
        'Right' => extend.right
        'None'  => extend.none
// }
