@import '../../style/index';

@transform-prefix-cls: ~'@{x6-prefix}-widget-transform';
@transform-box-padding: 4px;

.@{transform-prefix-cls} {
  position: absolute;
  box-sizing: content-box !important;
  margin: -@transform-box-padding - 1px 0 0 -@transform-box-padding - 1px;
  padding: @transform-box-padding;
  border: 1px dashed #000;
  border-radius: 5px;
  user-select: none;
  pointer-events: none;

  & > div {
    position: absolute;
    box-sizing: border-box;
    background-color: #fff;
    border: 1px solid #000;
    transition: background-color 0.2s;
    pointer-events: auto;
    -webkit-user-drag: none;
    user-drag: none; /* stylelint-disable-line */

    &:hover {
      background-color: #d3d3d3;
    }
  }

  &-cursor {
    &-n {
      cursor: n-resize;
    }

    &-s {
      cursor: s-resize;
    }

    &-e {
      cursor: e-resize;
    }

    &-w {
      cursor: w-resize;
    }

    &-ne {
      cursor: ne-resize;
    }

    &-nw {
      cursor: nw-resize;
    }

    &-se {
      cursor: se-resize;
    }

    &-sw {
      cursor: sw-resize;
    }
  }

  &-resize {
    width: 10px;
    height: 10px;
    border-radius: 6px;

    &[data-position='top-left'] {
      top: -5px;
      left: -5px;
    }

    &[data-position='top-right'] {
      top: -5px;
      right: -5px;
    }

    &[data-position='bottom-left'] {
      bottom: -5px;
      left: -5px;
    }

    &[data-position='bottom-right'] {
      right: -5px;
      bottom: -5px;
    }

    &[data-position='top'] {
      top: -5px;
      left: 50%;
      margin-left: -5px;
    }

    &[data-position='bottom'] {
      bottom: -5px;
      left: 50%;
      margin-left: -5px;
    }

    &[data-position='left'] {
      top: 50%;
      left: -5px;
      margin-top: -5px;
    }

    &[data-position='right'] {
      top: 50%;
      right: -5px;
      margin-top: -5px;
    }
  }

  &.prevent-aspect-ratio &-resize[data-position='top'],
  &.prevent-aspect-ratio &-resize[data-position='bottom'],
  &.prevent-aspect-ratio &-resize[data-position='left'],
  &.prevent-aspect-ratio &-resize[data-position='right'] {
    display: none;
  }

  &.no-orth-resize &-resize[data-position='bottom'],
  &.no-orth-resize &-resize[data-position='left'],
  &.no-orth-resize &-resize[data-position='right'],
  &.no-orth-resize &-resize[data-position='top'] {
    display: none;
  }

  &.no-resize &-resize {
    display: none;
  }

  &-rotate {
    top: -20px;
    left: -20px;
    width: 12px;
    height: 12px;
    border-radius: 6px;
    cursor: crosshair;
  }

  &.no-rotate &-rotate {
    display: none;
  }

  &-active {
    border-color: transparent;
    pointer-events: all;

    > div {
      display: none;
    }

    & > &-handle {
      display: block;
      background-color: #808080;
    }
  }
}
