var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { VegaInternalIconManager } from '../../../../../helpers/icon/internal-icon-manager';
import outdent from '../../../assets/outdent';
import { BlockAnnotationTypeEnum } from '../../../dto/annotations/block-annotation.abstract';
import { IndentAnnotationAction } from '../../../dto/actions/indent-annotation-action';
import { MapToComponentField } from 'vega-slimmer/core';
import { VisualModeToolbarButtonSlimmer } from './visual-mode-toolbar-button-slimmer.abstract';
export class LessIndentToolbarButtonSlimmer extends VisualModeToolbarButtonSlimmer {
  constructor() {
    super({
      icon: 'outdent',
      tooltip: {
        text: 'Less Indent',
      },
    });
  }
  isSelected() {
    return false;
  }
  isDisabled() {
    const selectedBlocks = this.selectionController.getSelectedBlocks();
    return (super.isDisabled() ||
      selectedBlocks.some((node) => this.shouldDisabledToolbar(node, IndentAnnotationAction.name)));
  }
  onClick() {
    this.selectionController.getSelectedBlocks().forEach((item) => {
      var _a, _b;
      const indent = (_b = (_a = item.getAnnotationByType(BlockAnnotationTypeEnum.INDENT)) === null || _a === void 0 ? void 0 : _a.indent) !== null && _b !== void 0 ? _b : 0;
      const newIndent = indent > 1 ? indent - 1 : 0;
      item.apply(new IndentAnnotationAction(newIndent));
    });
  }
}
(() => {
  VegaInternalIconManager.register({ outdent: outdent });
})();
__decorate([
  MapToComponentField()
], LessIndentToolbarButtonSlimmer.prototype, "selectionController", void 0);
