@use 'sass:string';

/// Returns whether `$value` is "falsey" in a broader sense than by using the
/// `not` keyword. Doing a conditional such as `@if not $var { ... }` will only
/// test as `true` for `false` and `null` values in Sass. By using this function
/// like, `@if is-falsey($var) { ... }`, it will test true for `false` and `null`
/// values, but also for empty strings, empty lists, empty maps, the number `0`,
/// and the unquoted string value of `'false'`.
///
/// In Sass, empty strings and empty lists are all "truthy" and sometimes you
/// may want to check if something is false in the more traditional sense.
///
/// @param {*} $value - A value to check.
///
/// @return {Bool} Returns `true` if `$value` is falsey (not just `null` or
/// `false`).
///
/// @access public
/// @group Utilities
@function is-falsey($value) {
  @return not not (
      $value == '' or $value == () or $value == (()) or $value == [] or
      $value == [()] or $value == ([]) or $value == [[]] or $value == ('':'') or
      $value == ('':()) or $value == ('':(())) or $value == ('':[]) or
      $value == ('':[()]) or $value == ('':([])) or $value == ('':[[]]) or
      $value == ('':null) or $value == 0 or $value == string.unquote('false') or
      not $value
  );
}
