@charset 'UTF-8';

////
/// Flavor SCSS Mixins Text
/// @group mixins-text
/// @author blackmirror1980
////

/// Text decoration line modes
///
/// @access private
/// @requires {function} array-concat
/// @type list
$text-decoration-line-modes: array-concat((none, underline, overline, line-through), $css-default-modes);

/// Checks if something is a supported text-decoration-line mode
///
/// @access public
/// @param {text-decoration-line-mode} $tdlm - the text-decoration-line mode
/// @return {boolean} - true if is text-decoration-line mode
@function is-text-decoration-line($tdlm) {
  @return is-defined($tdlm) and array-contains($text-decoration-line-modes, $tdlm);
}

/// Text decoration line mixin
///
/// @example scss - Usage
///   .text-decoration-line-element {
///     @include text-decoration-line(overline);
///   }
///
/// @example css - Output
///   .text-decoration-line-element {
///     -webkit-text-decoration-line: overline;
///     -moz-decoration-line: overline;
///     text-decoration-line: overline;
///   }
/// @link https://www.w3schools.com/cssref/css3_pr_text-decoration-line.asp - W3Schools text-decoration-line docs
/// @access public
/// @param {text-decoration-line-mode} $tdlm - the text-decoration-line value
/// @param {boolean} $important [false] - if true, will render the important rule
@mixin text-decoration-line($tdlm, $important: false) {
  @if(is-text-decoration-line($tdlm)) {
    @include prefixer(text-decoration-line, $tdlm, webkit moz spec, $important);
  }
  @else {
    @warn '`text-decoration-line: #{$tdlm}` is not a valid text-decoration-line value';
  }
}

/// Text decoration style modes
///
/// @access private
/// @requires {function} array-concat
/// @type list
$text-decoration-style-modes: array-concat((solid, double, dotted, dashed, wavy), $css-default-modes);

/// Checks if something is a supported text-decoration-style mode
///
/// @access public
/// @param {text-decoration-style-mode} $tdsm - the text-decoration-style mode
/// @return {boolean} - true if is text-decoration-style mode
@function is-text-decoration-style($tdsm) {
  @return is-defined($tdsm) and array-contains($text-decoration-style-modes, $tdsm);
}

/// Text decoration style mixin
///
/// @example scss - Usage
///   .text-decoration-style-element {
///     @include text-decoration-style(wavy);
///   }
///
/// @example css - Output
///   .text-decoration-style-element {
///     -moz-text-decoration-style: wavy;
///     text-decoration-style: wavy;
///   }
/// @link https://www.w3schools.com/cssref/css3_pr_text-decoration-style.asp - W3Schools text-decoration-style docs
/// @access public
/// @param {text-decoration-style-mode} $tdsm - the text-decoration-style value
/// @param {boolean} $important [false] - if true, will render the important rule
@mixin text-decoration-style($tdsm, $important: false) {
  @if(is-text-decoration-style($tdsm)) {
    @include prefixer(text-decoration-style, $tdsm, moz spec, $important);
  }
  @else {
    @warn '`text-decoration-style: #{$tdsm}` is not a valid text-decoration-style value';
  }
}

/// Checks if something is a supported text-decoration-color mode
///
/// @access public
/// @param {text-decoration-color} $tdc - the text-decoration-color value
/// @return {boolean} - true if is text-decoration-color value
@function is-text-decoration-color($tdc) {
  @return is-defined($tdc) and (is-color($tdc) or array-contains($css-default-modes, $tdc));
}

/// Text decoration color mixin
///
/// @example scss - Usage
///   .text-decoration-color-element {
///     @include text-decoration-color(red);
///   }
///
/// @example css - Output
///   .text-decoration-color-element {
///     -webkit-text-decoration-color: red;
///     -moz-decoration-color: red;
///     text-decoration-color: red;
///   }
/// @link https://www.w3schools.com/cssref/css3_pr_text-decoration-color.asp - W3Schools text-decoration-color docs
/// @access public
/// @param {text-decoration-color-mode} $tdc - the text-decoration-color value
/// @param {boolean} $important [false] - if true, will render the important rule
@mixin text-decoration-color($tdc, $important: false) {
  @if(is-text-decoration-color($tdc)) {
    @include prefixer(text-decoration-color, $tdc, webkit moz spec, $important);
  }
  @else {
    @warn '`text-decoration-color: #{$tdc}` is not a valid text-decoration-color value';
  }
}

/// Text decoration modes
///
/// @access private
/// @requires {function} array-concat
/// @type list
$text-decoration-modes: array-concat((none), $css-default-modes);

/// Checks if something is a supported text-decoration mode
///
/// @access public
/// @param {text-decoration-mode} $tdm - the text-decoration mode
/// @return {boolean} - true if is text-decoration mode
@function is-text-decoration-mode($tdm) {
  @return is-defined($tdm) and (array-contains($text-decoration-modes, $tdm));
}

/// Text decoration mixin
///
/// @example scss - Usage
///   .text-decoration-element {
///     @include text-decoration(none);
///   }
///
/// @example css - Output
///   .text-decoration {
///     text-decoration: none;
///   }
/// @todo Add support to multiple text-decoration-line options
/// @link https://www.w3schools.com/cssref/pr_text_text-decoration.asp - W3Schools text-decoration docs
/// @access public
/// @param {string | object | map} $options - the text-decoration options
/// @param {text-decoration-line} $options.line [none] - text-decoration-line
/// @param {text-decoration-style} $options.style [solid] - text-decoration-style
/// @param {text-decoration-color} $options.color [transparent] - text-decoration-color
/// @param {boolean} $shorthand [false] - if true, will render the shorthand form of text-decoration property
/// @param {boolean} $important [false] - if true, will render the important rule
@mixin text-decoration($options, $shorthand: false, $important: false) {
  @if(is-text-decoration-mode($options)) {
    text-decoration: $options important($important);
  }
  @else {
    $settings: (line: none, style: null, color: null);

    @if is-object($options) {
      $settings: extend($settings, $options);
    }
    @else {
      $line: nth-value($options, 1);

      @if is-defined($line) {
        $settings: extend($settings, (line: $line));
      }

      $style: nth-value($options, 2);

      @if is-defined($style) {
        $settings: extend($settings, (style: $style));
      }

      $color: nth-value($options, 3);

      @if is-defined($color) {
        $settings: extend($settings, (color: $color));
      }
    }

    $text-decoration: ();

    $text-decoration-line: get($settings, line);

    @if is-defined($text-decoration-line) {
      @if $shorthand == false {
        @include text-decoration-line($text-decoration-line, $important);
      }
      @else if is-text-decoration-line($text-decoration-line) {
        $text-decoration: append($text-decoration, $text-decoration-line);
      }
      @else {
        @warn '`text-decoration-line: #{$text-decoration-line}` is not a valid text-decoration-line value';
      }
    }

    $text-decoration-style: get($settings, style);

    @if is-defined($text-decoration-style) {
      @if $shorthand == false {
        @include text-decoration-style($text-decoration-style, $important);
      }
      @else if is-text-decoration-style($text-decoration-style) {
        $text-decoration: append($text-decoration, $text-decoration-style);
      }
      @else {
        @warn '`text-decoration-style: #{$text-decoration-style}` is not a valid text-decoration-style value';
      }
    }

    $text-decoration-color: get($settings, color);

    @if is-defined($text-decoration-color) {
      @if $shorthand == false {
        @include text-decoration-color($text-decoration-color, $important);
      }
      @else if is-text-decoration-color($text-decoration-color) {
        $text-decoration: append($text-decoration, $text-decoration-color);
      }
      @else {
        @warn '`text-decoration-color: #{$text-decoration-color}` is not a valid css color';
      }
    }

    @if $shorthand == true {
      text-decoration: $text-decoration important($important);
    }
  }
}

/// Text decoration skip modes
///
/// @access private
/// @requires {function} array-concat
/// @type list
$text-decoration-skip-modes: array-concat((none, objects, spaces, ink, edges, box-decoration, unset), $css-default-modes);

/// Checks if something is a supported text-decoration-skip mode
///
/// @access public
/// @param {text-decoration-skip-mode} $tds - the text-decoration-skip mode
/// @return {boolean} - true if is text-decoration-skip mode
@function is-text-decoration-skip($tds) {
  @return is-defined($tds) and array-contains($text-decoration-skip-modes, $tds);
}

/// Text decoration skip mixin
///
/// @example scss - Usage
///   .text-decoration-skip-element {
///     @include text-decoration-skip(objects);
///   }
///
/// @example css - Output
///   .text-decoration-skip-element {
///     -webkit-text-decoration-skip: objects;
///     text-decoration-skip: objects;
///   }
/// @link https://www.w3schools.com/cssref/css3_pr_text-decoration-skip.asp - W3Schools text-decoration-skip docs
/// @access public
/// @param {text-decoration-skip-mode} $tds - the text-decoration-skip value
/// @param {boolean} $important [false] - if true, will render the important rule
@mixin text-decoration-skip($tds, $important: false) {
  @if(is-text-decoration-skip($tds)) {
    @include prefixer(text-decoration-skip, $tds, webkit spec, $important);
  }
  @else {
    @warn '`text-decoration-skip: #{$tds}` is not a valid text-decoration-skip value';
  }
}

/// Text underline position modes
///
/// @access private
/// @requires {function} array-concat
/// @type list
$text-underline-position-modes: array-concat((auto, left, right, under, unset), $css-default-modes);

/// Checks if something is a supported text-underline-position mode
///
/// @access public
/// @param {text-underline-position-mode} $tup - the text-underline-position mode
/// @return {boolean} - true if is text-underline-position mode
@function is-text-underline-position($tup) {
  @return is-defined($tup) and array-contains($text-underline-position-modes, $tup);
}

/// Text underline position mixin
///
/// @example scss - Usage
///   .text-underline-position-element {
///     @include text-underline-position(under);
///   }
///
/// @example css - Output
///   .text-underline-position-element {
///     -webkit-text-underline-position: under;
///     text-underline-position: under;
///   }
/// @link https://www.w3schools.com/cssref/css3_pr_text-underline-position.asp - W3Schools text-underline-position docs
/// @access public
/// @param {text-underline-position-mode} $tup - the text-underline-position value
/// @param {boolean} $important [false] - if true, will render the important rule
@mixin text-underline-position($tup, $important: false) {
  @if(is-text-underline-position($tup)) {
    @include prefixer(text-underline-position, $tup, webkit spec, $important);
  }
  @else {
    @warn '`text-underline-position: #{$tup}` is not a valid text-underline-position value';
  }
}
