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, Host } from '@stencil/core';
import { VegaSlimmer, MapToComponentField, MapToComponentMethod } from 'vega-slimmer/core';
import ResponsiveFormatFacade from '../../../../helpers/formatter/responsive-map-formatter/responsive-format-facade';
import { createEnterKeyHandlerToTriggerClick } from '../../../../utils/accessibility';
export class VegaSelectionChipRenderer extends VegaSlimmer {
  componentWillRender() {
    this.currentSize = ResponsiveFormatFacade.formatCustom(this.size);
  }
  render() {
    return (h(Host, { class: {
        block: this.block,
      } }, this.renderTooltip()));
  }
  renderTooltip() {
    return (h("vega-tooltip", Object.assign({ trigger: this.disabled && this.disabledTooltip ? 'hover' : 'none', alignment: "center" }, this.disabledTooltip), this.renderSelectionChip()));
  }
  renderSelectionChip() {
    return (h("vega-box", { corners: "rounded-full", class: {
        'vega-selection-chip': true,
        [`size-${this.currentSize}`]: true,
        [`variant-${this.variant || 'text'}`]: true,
        'checked': this.checked,
        'error': this.showError,
        'disabled': this.disabled,
      }, "aria-label": this.label || 'No label defined', 
      /* eslint-disable-next-line react/jsx-no-bind */
      onClick: () => {
        if (!(this.selectType === 'radio' && this.checked)) {
          this.checkedController.onCheck(!this.checked);
        }
      }, onKeyDown: createEnterKeyHandlerToTriggerClick(), tabIndex: this.disabled ? -1 : 0 }, this.renderContent()));
  }
  renderContent() {
    return (h("vega-flex", { gap: VegaSelectionChipRenderer.gapSizeMap[this.currentSize], "align-items": "center", "justify-content": this.variant === 'text' ? `center` : `start` },
      this.variant === 'swatch' && this.renderSwatch(),
      this.renderLabel()));
  }
  renderLabel() {
    return (h("vega-font", { color: "text-primary", class: "label vega-flex-grow", variant: VegaSelectionChipRenderer.labelFontMap[this.currentSize] }, this.label));
  }
  renderSwatch() {
    return (h("vega-box", { "background-color": "bg-primary", corners: "rounded-full", class: "swatch vega-flex-shrink-0" },
      h("vega-box", { "background-color": this.swatchColor, corners: "rounded-full" })));
  }
}
VegaSelectionChipRenderer.gapSizeMap = {
  'extra-small': 'size-4',
  'small': 'size-4',
  'medium': 'size-8',
  'large': 'size-8',
};
VegaSelectionChipRenderer.labelFontMap = {
  'extra-small': 'font-field-label-xs',
  'small': 'font-field-label-sm',
  'medium': 'font-field-label',
  'large': 'font-field-label-lg',
};
__decorate([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "host", void 0);
__decorate([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "label", void 0);
__decorate([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "block", void 0);
__decorate([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "size", void 0);
__decorate([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "variant", void 0);
__decorate([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "swatchColor", void 0);
__decorate([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "disabledTooltip", void 0);
__decorate([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "disabled", void 0);
__decorate([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "selectType", void 0);
__decorate([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "checked", void 0);
__decorate([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "checkedController", void 0);
__decorate([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "showError", void 0);
__decorate([
  MapToComponentMethod('componentWillRender')
], VegaSelectionChipRenderer.prototype, "componentWillRender", null);
