"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DisabledDataGridWrapper = exports.DataGridWrapper = exports.Container = void 0;
const styled_1 = require("../styled");
const constants_1 = require("./Cell/constants");
const constants_2 = require("./constants");
const HeadCell_1 = require("./HeadCell");
const constants_3 = require("./Row/constants");
exports.Container = styled_1.styled.div `
  --max-height: initial;

  position: relative;

  overflow: hidden;
  display: flex;
  flex-direction: column;

  width: 100%;
  height: 100%;
  max-height: var(--max-height);

  &.${constants_2.dataGridClassnames.isAllowHorizontalScroll} {
    overflow: auto hidden;

    & .${constants_2.dataGridClassnames.wrapper} {
      overflow: auto hidden;
    }
  }

  &.${constants_2.dataGridClassnames.hasPinnedSections} {
    overflow: hidden;
  }

  &.${constants_2.dataGridClassnames.hasGroupedColumns} {
    & .${constants_2.dataGridClassnames.header} {
      grid-template-rows: repeat(2, auto);

      & .${HeadCell_1.headCellClassnames.groupParent} {
        grid-column: var(--grid-column-start) / var(--grid-column-end);
        grid-row: 1;
        justify-content: center;
      }

      & .${HeadCell_1.headCellClassnames.groupChild} {
        grid-row: 2;
        justify-content: center;
      }

      & .${HeadCell_1.headCellClassnames.singleColumn} {
        grid-row: 1 / -1;

        height: 80px;
      }
    }
  }

  @supports not (container-type: scroll-state) {
    &.${constants_2.dataGridClassnames.overflowed} {
      & .${constants_2.dataGridClassnames.rightPinnedSection} {
         box-shadow: -3px 0 4px 0 #63636326;
      }

      & .${constants_2.dataGridClassnames.leftPinnedSection} {
         box-shadow: 3px 0 4px 0 #63636326;
      }
    }
  }

  &.${constants_2.dataGridClassnames.gridViewFull} {
    & .${constants_2.dataGridClassnames.header} {
      background-color: ${({ theme }) => theme.palette.grey[100]};
      border-top-left-radius: ${({ theme }) => theme.shape.medium};
      border-top-right-radius: ${({ theme }) => theme.shape.medium};
    }

    & .${constants_1.dataGridCellClassnames.root},
    & .${HeadCell_1.headCellClassnames.root} {
      border-top: 1px solid ${({ theme }) => theme.palette.components.border.default};
      border-left: 1px solid ${({ theme }) => theme.palette.components.border.default};

      &:first-of-type,
      &:first-of-type + .${HeadCell_1.headCellClassnames.groupChild} {
        border-left: none;
      }
    }

    & .${HeadCell_1.headCellClassnames.singleColumn},
    & .${HeadCell_1.headCellClassnames.groupParent} {
      border-top: none;
    }

    & .${constants_3.dataGridRowClassnames.root}:last-of-type .${constants_1.dataGridCellClassnames.root} {
      border-bottom: 1px solid ${({ theme }) => theme.palette.components.border.default};
    }

    &:not(.${constants_2.dataGridClassnames.hasPinnedSections}) .${constants_2.dataGridClassnames.body},
    & .${constants_2.dataGridClassnames.pinnedSections} {
      container-name: data-grid-scroll-container;
      container-type: scroll-state;
    }

    /* Прогрессивное улучшение. Убираем нижнюю границу последней строки когда scrollbar находится в нижней точке. Для того что бы избежать двойного разделителя снизу */
    /* stylelint-disable-next-line plugin/no-unsupported-browser-features */
    @container data-grid-scroll-container scroll-state((scrollable: y) and (not (scrollable: bottom))) {
      & .${constants_3.dataGridRowClassnames.root}:last-of-type .${constants_1.dataGridCellClassnames.root} {
        border-bottom: none;
      }
    }

    & .${constants_3.dataGridRowClassnames.root}:first-of-type .${constants_1.dataGridCellClassnames.root} {
      border-top: none;
    }
  }

  ${({ theme }) => theme.breakpoints.down('sm')} {
    overflow: initial;

    & .${constants_2.dataGridClassnames.loadingPlaceholder} {
      justify-content: flex-start;
    }

    &.${constants_2.dataGridClassnames.hasPinnedSections} {
      overflow: initial;
    }

    &.${constants_2.dataGridClassnames.isAllowHorizontalScroll} {
      overflow: initial;

      & .${constants_2.dataGridClassnames.wrapper} {
        overflow: initial;
      }
    }

    &.${constants_2.dataGridClassnames.gridViewFull} {
      & .${constants_1.dataGridCellClassnames.root}, & .${HeadCell_1.headCellClassnames.root} {
        border: none;
      }

      & .${constants_3.dataGridRowClassnames.root}:last-of-type .${constants_1.dataGridCellClassnames.root} {
        border-bottom: none;
      }
    }
  }
`;
exports.DataGridWrapper = styled_1.styled.div `
  position: relative;

  overflow: hidden;
  display: flex;
  flex-direction: column;

  height: 100%;

  ${({ theme }) => theme.breakpoints.down('sm')} {
    overflow: initial;
  }
`;
exports.DisabledDataGridWrapper = (0, styled_1.styled)(exports.DataGridWrapper) `
  pointer-events: none;

  background: ${({ theme }) => theme.palette.background.element};
  /* stylelint-disable-next-line plugin/no-unsupported-browser-features */
  mix-blend-mode: luminosity;

  ${({ theme }) => theme.breakpoints.down('sm')} {
    opacity: 0.7;
  }
`;
