@use '@angular/material' as mat;
@mixin mw-mat-radio-override($theme) {
  $background: (
    mat-radio-ripple-press-opacity: 0.1,
    mat-radio-inactive-ripple-press-color: var(--black100),
  );

  $theme-background: map-get($theme, background);
  $theme-foreground: map-get($theme, foreground);

  $background: map-merge($background, $theme-background);
  $accent: map-get($theme, accent);

  mat-radio-group {
    &.mw-radio-column {
      display: flex;
      flex-direction: column;
      mat-radio-button:not(:first-child) {
        margin-top: 4px;
      }
      mat-radio-button:not(:last-child) {
        margin-bottom: 4px;
      }
      mat-label + mat-radio-button.mat-radio-button {
        margin-top: 0px;
      }
    }
    &:not(.mw-radio-column) {
      mat-radio-button:not(:first-child) {
        margin-left: 4px;
      }
      mat-radio-button:not(:last-child) {
        margin-right: 4px;
      }
      mat-label + mat-radio-button.mat-radio-button {
        margin-left: 0px;
      }
    }
    mat-radio-button.mat-accent.mat-radio-disabled.mat-radio-checked {
      .mat-radio-outer-circle {
        border-color: rgba(mat.get-color-from-palette($accent), 0.34);
      }
      .mat-radio-inner-circle {
        background-color: rgba(mat.get-color-from-palette($accent), 0.34);
      }
    }
    .mat-radio-label-content {
      @extend .mw-body2;
      color: var(--mw-text);
    }
    .mat-radio-button.mat-radio-disabled {
      .mat-radio-label-content {
        color: var(--mw-disabled-text);
      }
      .mat-radio-outer-circle {
        border-color: var(--mw-disabled-text);
      }
    }
    mat-radio-button:active {
      &:not(.mat-radio-checked) {
        .mat-radio-ripple {
          .mat-ripple-element:not(.mat-radio-persistent-ripple) {
            background-color: map-get(
              $background,
              mat-radio-inactive-ripple-press-color
            );
          }
        }
      }
      .mat-radio-ripple {
        .mat-ripple-element:not(.mat-radio-persistent-ripple) {
          opacity: map-get($background, mat-radio-ripple-press-opacity);
        }
      }
    }
    .mat-radio-ripple {
      width: 36px;
      height: 36px;
      top: -10px;
      left: -10px;
      .mat-ripple-element {
        width: 36px !important;
        height: 36px !important;
        left: 0px !important;
        top: 0px !important;
      }
    }
    mat-label {
      @extend .mw-caption;
      display: block;
      margin-bottom: 8px;
      color: var(--mw-secondary-text);
    }
  }

  .mat-radio-button:not(.mat-radio-disabled).cdk-keyboard-focused
    .mat-radio-persistent-ripple,
  .mat-radio-button:not(.mat-radio-disabled).cdk-program-focused
    .mat-radio-persistent-ripple {
    opacity: 0;
  }

  .mat-radio-outer-circle {
    border-width: 1px;
    border-color: var(--mw-secondary-text);
  }

  .mat-radio-container,
  .mat-radio-outer-circle,
  .mat-radio-inner-circle {
    height: 16px;
    width: 16px;
  }

  mat-radio-group[readonly] {
    pointer-events: none;

    mat-radio-button.mat-accent {
      .mat-radio-outer-circle {
        border-color: rgba(var(--mw-disabled-text), 0.34);
      }
      .mat-radio-inner-circle {
        background-color: rgba(var(--mw-disabled-text), 0.34);
      }
    }
    mat-radio-button.mat-accent.mat-radio-checked {
      .mat-radio-outer-circle {
        border-color: rgba(mat.get-color-from-palette($accent), 1);
      }
      .mat-radio-inner-circle {
        border-color: rgba(mat.get-color-from-palette($accent), 1);
        background-color: rgba(mat.get-color-from-palette($accent), 1);
      }
    }
    .mat-radio-label-content {
      @extend .mw-body2;
      color: var(--mw-text);
    }
    .mat-radio-button .mat-radio-label-content {
      color: var(--mw-disabled-text);
    }
    .mat-radio-button.mat-radio-checked .mat-radio-label-content {
      color: var(--mw-text);
    }
  }
}
