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 { Fragment, h } from '@stencil/core';
import { MapToComponentField, VegaSlimmer } from 'vega-slimmer/core';
export class VegaSegmentRenderer extends VegaSlimmer {
  render(props) {
    return (h("button", { key: props.key, class: {
        'vega-segment': true,
        'selected': this.selected === props.key,
        'disabled': props.disabled,
        [`${this.size}`]: true,
      }, 
      // eslint-disable-next-line react/jsx-no-bind
      onClick: () => this.selectedController.setSelected(props), disabled: props.disabled }, this.renderSegments(props)));
  }
  /** The below method is e2e-test covered in
   *  @see{module:vega-segment-control-set-block-e2e}
   *  @see{module:vega-segment-control-set-block-resize-screen-e2e}
   */
  /* istanbul ignore next */
  renderSegments(props) {
    return (h(Fragment, null,
      (this.isOverflowBlockSegments ||
        (!this.isOverflowBlockSegments && this.variant !== 'text-only')) &&
        props.icon &&
        this.renderIcon(props),
      ((this.isOverflowBlockSegments && !props.icon) ||
        (!this.isOverflowBlockSegments && this.variant !== 'icon-only')) &&
        props.text &&
        this.renderText(props)));
  }
  renderIcon(props) {
    return (h("vega-tooltip", { text: props.text, trigger: props.text &&
        (this.isOverflowBlockSegments ||
          (!this.isOverflowBlockSegments && this.variant === 'icon-only'))
        ? 'hover'
        : 'none', placement: ['bottom', 'top'], disableInteractive: false },
      h("vega-icon", { icon: props.icon, size: "size-16" })));
  }
  renderText(props) {
    return (h("vega-text", { overflow: "ellipsis", tooltip: { placement: ['bottom', 'top'] } }, props.text));
  }
}
__decorate([
  MapToComponentField()
], VegaSegmentRenderer.prototype, "host", void 0);
__decorate([
  MapToComponentField()
], VegaSegmentRenderer.prototype, "size", void 0);
__decorate([
  MapToComponentField()
], VegaSegmentRenderer.prototype, "selected", void 0);
__decorate([
  MapToComponentField()
], VegaSegmentRenderer.prototype, "variant", void 0);
__decorate([
  MapToComponentField()
], VegaSegmentRenderer.prototype, "block", void 0);
__decorate([
  MapToComponentField()
], VegaSegmentRenderer.prototype, "isOverflowBlockSegments", void 0);
__decorate([
  MapToComponentField()
], VegaSegmentRenderer.prototype, "selectedController", void 0);
