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 { h } from '@stencil/core';
import { InjectVegaSlimmer, MapToComponentField, MapToComponentMethod } from 'vega-slimmer/core';
import { LeftAlignToolbarButtonSlimmer } from './left-align-toolbar-button-slimmer';
import { CenterAlignToolbarButtonSlimmer } from './center-align-toolbar-button-slimmer';
import { RightAlignToolbarButtonSlimmer } from './right-align-toolbar-button-slimmer';
import { JustifyAlignToolbarButtonSlimmer } from './justify-align-toolbar-button-slimmer';
import { VisualModeToolbarButtonSlimmer } from '../visual-mode-toolbar-button-slimmer.abstract';
import { HorizontalAlignmentAnnotationAction } from '../../../../dto/actions/horizontal-alignment-annotation-action';
export class HorizontalAlignmentToolbarButtonSlimmer extends VisualModeToolbarButtonSlimmer {
  constructor() {
    super({
      icon: 'align-left',
      tooltip: {
        text: 'Left Align',
      },
    });
    this.leftAlignToolbarButtonSlimmer = new LeftAlignToolbarButtonSlimmer();
    this.centerAlignToolbarButtonSlimmer = new CenterAlignToolbarButtonSlimmer();
    this.rightAlignToolbarButtonSlimmer = new RightAlignToolbarButtonSlimmer();
    this.justifiedToolbarButtonSlimmer = new JustifyAlignToolbarButtonSlimmer();
  }
  componentWillRender() {
    if (this.leftAlignToolbarButtonSlimmer.isSelected()) {
      super.setIcon('align-left');
    }
    else if (this.centerAlignToolbarButtonSlimmer.isSelected()) {
      super.setIcon('align-center');
    }
    else if (this.rightAlignToolbarButtonSlimmer.isSelected()) {
      super.setIcon('align-right');
    }
    else if (this.justifiedToolbarButtonSlimmer.isSelected()) {
      super.setIcon('align-justify');
    }
    else {
      super.setIcon('align-left');
    }
  }
  renderBtnWrapper(renderBtn) {
    return (h("vega-popover", { trigger: "click", showArrow: false, alignment: "center", placement: "bottom", ref: (ref) => (this.popoverRef = ref) },
      h("div", { slot: "popover-content" }, renderBtn({ showArrowIcon: true })),
      h("div", { slot: "popover" }, this.renderContent())));
  }
  renderContent() {
    return (h("vega-flex", { gap: "size-8", "justify-content": "center" },
      h("div", null, this.leftAlignToolbarButtonSlimmer.render()),
      h("div", null, this.centerAlignToolbarButtonSlimmer.render()),
      h("div", null, this.rightAlignToolbarButtonSlimmer.render()),
      h("div", null, this.justifiedToolbarButtonSlimmer.render())));
  }
  isSelected() {
    return false;
  }
  isDisabled() {
    return (super.isDisabled() ||
      this.selectionController
        .getSelectedBlocks()
        .some((block) => this.shouldDisabledToolbar(block, HorizontalAlignmentAnnotationAction.name)));
  }
}
__decorate([
  MapToComponentField()
], HorizontalAlignmentToolbarButtonSlimmer.prototype, "selectionController", void 0);
__decorate([
  InjectVegaSlimmer()
], HorizontalAlignmentToolbarButtonSlimmer.prototype, "leftAlignToolbarButtonSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], HorizontalAlignmentToolbarButtonSlimmer.prototype, "centerAlignToolbarButtonSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], HorizontalAlignmentToolbarButtonSlimmer.prototype, "rightAlignToolbarButtonSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], HorizontalAlignmentToolbarButtonSlimmer.prototype, "justifiedToolbarButtonSlimmer", void 0);
__decorate([
  MapToComponentMethod('componentWillRender')
], HorizontalAlignmentToolbarButtonSlimmer.prototype, "componentWillRender", null);
