@use 'sass:map';

@mixin ng-scrollbar-overrides($config) {
  $container-color: if(
      map.has-key($config, container-color),
      map.get($config, container-color),
      inherit
  );
  $container-offset: if(
      map.has-key($config, container-offset),
      map.get($config, container-offset),
      inherit
  );
  $container-shape: if(
      map.has-key($config, container-shape),
      map.get($config, container-shape),
      inherit
  );

  $track-shape: if(
      map.has-key($config, track-shape),
      map.get($config, track-shape),
      inherit
  );
  $track-thickness: if(
      map.has-key($config, track-thickness),
      map.get($config, track-thickness),
      inherit
  );
  $track-hover-thickness: if(
      map.has-key($config, track-hover-thickness),
      map.get($config, track-hover-thickness),
      inherit
  );
  $track-active-thickness: if(
      map.has-key($config, track-active-thickness),
      map.get($config, track-active-thickness),
      inherit
  );
  $track-offset: if(
      map.has-key($config, track-offset),
      map.get($config, track-offset),
      inherit
  );
  $track-color: if(
      map.has-key($config, track-color),
      map.get($config, track-color),
      inherit
  );

  // Thumb variables
  $thumb-shape: if(
      map.has-key($config, thumb-shape),
      map.get($config, thumb-shape),
      inherit
  );
  $thumb-size: map.get($config, thumb-size);
  //$thumb-size: if(
  //    map.has-key($config, thumb-size),
  //    map.get($config, thumb-size),
  //    inherit
  //);
  $thumb-min-size: if(
      map.has-key($config, thumb-min-size),
      map.get($config, thumb-min-size),
      20px
  );
  $thumb-color: if(
      map.has-key($config, thumb-color),
      map.get($config, thumb-color),
      inherit
  );
  $thumb-hover-color: if(
      map.has-key($config, thumb-hover-color),
      map.get($config, thumb-hover-color),
      inherit
  );
  $thumb-active-color: if(
      map.has-key($config, thumb-active-color),
      map.get($config, thumb-active-color),
     inherit
  );

  // Visibility variables
  $hover-opacity-transition-enter-duration: if(
      map.has-key($config, hover-opacity-transition-enter-duration),
      map.get($config, hover-opacity-transition-enter-duration),
      inherit
  );
  $hover-opacity-transition-leave-duration: if(
      map.has-key($config, hover-opacity-transition-leave-duration),
      map.get($config, hover-opacity-transition-leave-duration),
      inherit
  );
  $hover-opacity-transition-leave-delay: if(
      map.has-key($config, hover-opacity-transition-leave-delay),
      map.get($config, hover-opacity-transition-leave-delay),
      inherit
  );

  $overscroll-behavior: if(
      map.has-key($config, overscroll-behavior),
      map.get($config, overscroll-behavior),
      inherit
  );
  $mobile-overscroll-behavior: if(
      map.has-key($config, mobile-overscroll-behavior),
      map.get($config, mobile-overscroll-behavior),
      inherit
  );

  $button-shape: if(
      map.has-key($config, button-shape),
      map.get($config, button-shape),
      inherit
  );
  $button-size: if(
      map.has-key($config, button-size),
      map.get($config, button-size),
      inherit
  );
  $button-gap: if(
      map.has-key($config, button-gap),
      map.get($config, button-gap),
      inherit
  );
  $button-color: if(
      map.has-key($config, button-color),
      map.get($config, button-color),
      inherit
  );
  $button-hover-color: if(
      map.has-key($config, button-hover-color),
      map.get($config, button-hover-color),
      inherit
  );
  $button-active-color: if(
      map.has-key($config, button-active-color),
      map.get($config, button-active-color),
      inherit
  );
  $button-inactive-color: if(
      map.has-key($config, button-inactive-color),
      map.get($config, button-inactive-color),
      inherit
  );
  $button-fill-color: if(
      map.has-key($config, button-fill-color),
      map.get($config, button-fill-color),
      inherit
  );
  $button-fill-hover-color: if(
      map.has-key($config, button-fill-hover-color),
      map.get($config, button-fill-hover-color),
      inherit
  );
  $button-fill-active-color: if(
      map.has-key($config, button-fill-active-color),
      map.get($config, button-fill-active-color),
      inherit
  );
  $button-fill-inactive-color: if(
      map.has-key($config, button-fill-inactive-color),
      map.get($config, button-fill-inactive-color),
      inherit
  );

  @if $container-color {
    --scrollbar-container-color: #{$container-color};
  }

  @if $container-offset {
    --scrollbar-container-offset: #{$container-offset};
  }

  @if $container-shape {
    --scrollbar-container-shape: #{$container-shape};
  }

  @if $track-shape {
    --scrollbar-track-shape: #{$track-shape};
  }

  @if $track-offset {
    --scrollbar-track-offset: #{$track-offset};
  }

  @if $track-color {
    --scrollbar-track-color: #{$track-color};
  }

  @if $track-thickness {
    --scrollbar-track-thickness: #{$track-thickness};
  }

  @if $track-hover-thickness {
    --scrollbar-track-hover-thickness: #{$track-hover-thickness};
  }

  @if $track-active-thickness {
    --scrollbar-track-active-thickness: #{$track-active-thickness};
  }

  @if $thumb-shape {
    // Strip the px unit from the size
    --scrollbar-thumb-shape: #{$thumb-shape};
  }

  @if $thumb-size {
    // Strip the px unit from the size
    --scrollbar-thumb-size: #{$thumb-size / 1px};
  }

  @if $thumb-min-size {
    // Strip the px unit from the size
    --scrollbar-thumb-min-size: #{$thumb-min-size / 1px};
  }

  @if $thumb-color {
    --scrollbar-thumb-color: #{$thumb-color};
  }

  @if $thumb-hover-color {
    --scrollbar-thumb-hover-color: #{$thumb-hover-color};
  }

  @if $thumb-active-color {
    --scrollbar-thumb-active-color: #{$thumb-active-color};
  }

  @if $hover-opacity-transition-enter-duration {
    --scrollbar-hover-opacity-transition-enter-duration: #{$hover-opacity-transition-enter-duration};
  }

  @if $hover-opacity-transition-leave-duration {
    --scrollbar-hover-opacity-transition-leave-duration: #{$hover-opacity-transition-leave-duration};
  }

  @if $hover-opacity-transition-leave-delay {
    --scrollbar-hover-opacity-transition-leave-delay: #{$hover-opacity-transition-leave-delay};
  }

  @if $overscroll-behavior {
    --scrollbar-overscroll-behavior: #{$overscroll-behavior};
  }

  @if $mobile-overscroll-behavior {
    --scrollbar-mobile-overscroll-behavior: #{$mobile-overscroll-behavior};
  }

  @if $button-shape {
    --scrollbar-button-shape: #{$button-shape};
  }

  @if $button-size {
    --scrollbar-button-size: #{$button-size};
  }

  @if $button-gap {
    --scrollbar-button-gap: #{$button-gap};
  }

  @if $button-color {
    --scrollbar-button-color: #{$button-color};
  }
  @if $button-hover-color {
    --scrollbar-button-hover-color: #{$button-hover-color};
  }
  @if $button-active-color {
    --scrollbar-button-active-color: #{$button-active-color};
  }
  @if $button-inactive-color {
    --scrollbar-button-inactive-color: #{$button-inactive-color};
  }
  @if $button-fill-color {
    --scrollbar-button-fill: #{$button-fill-color};
  }
  @if $button-fill-hover-color {
    --scrollbar-button-hover-fill: #{$button-fill-hover-color};
  }
  @if $button-fill-active-color {
    --scrollbar-button-active-fill: #{$button-fill-active-color};
  }
  @if $button-fill-inactive-color {
    --scrollbar-button-inactive-fill: #{$button-fill-inactive-color};
  }
}
