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 { Component, Element, Event, Host, h, Prop, Watch, State } from '@stencil/core';
import { sanitizeVegaComponent } from '../../utils/component';
import { InjectVegaGlobalSlimmer, InjectVegaSlimmer, methodPlaceholder, } from 'vega-slimmer/core';
import { VegaSegmentControlRenderer } from './slimmers/renderers/vega-segment-control-renderer';
import { createEventEmitSlimmer, } from '../../helpers/event-manager/slimmers/event-emit-slimmer';
import { VegaChange } from '../../helpers/event-manager/event-id/vega-event-id';
import { VegaSegmentControlSelectedController } from './slimmers/controllers/vega-segment-control-selected-controller';
import { PageResizeObserverSlimmer } from '../../helpers/slimmers/page-resize-observer-slimmer';
import { VegaSegmentOverflowController } from './slimmers/controllers/vega-segment-overflow-controller';
import { VegaSegmentRenderer } from './slimmers/renderers/vega-segment-renderer';
import { VegaComponentUsageRuntimeMetricsSlimmer } from '../../helpers/slimmers/component-usage-runtime-metrics';
/**
 * @vegaVersion 2.3.0
 */
export class VegaSegmentControl {
  constructor() {
    this.globalSlimmers = {};
    this.segmentControlRenderer = new VegaSegmentControlRenderer();
    this.segmentOverflowController = new VegaSegmentOverflowController();
    this.segmentRenderer = new VegaSegmentRenderer();
    this.selectedController = new VegaSegmentControlSelectedController();
    this.changeEventEmitter = createEventEmitSlimmer(VegaSegmentControl, VegaChange);
    this.pageResizeObserverSlimmer = new PageResizeObserverSlimmer({
      callback: /* istanbul ignore next */ () => {
        this.segmentControlWidth = this.host.clientWidth;
        this.segmentOverflowController.setIsOverflowBlockSegments();
      },
      shouldTrigger: /* istanbul ignore next */ () => {
        return this.host.clientWidth !== this.segmentControlWidth;
      },
    });
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    this.segmentControlWidth = 0;
    this.isOverflowBlockSegments = false;
    /**
     * Specifies whether the segment control spans the
     *    full width of its parent element.
     *
     * @vegaVersion 2.3.0
     */
    this.block = false;
    /**
     * Specifies the size of the segment control.
     *
     * @vegaVersion 2.3.0
     */
    this.size = 'medium';
    /**
     * Specifies the options available within the segment control.
     *    Please note that we advise against having more than four segments in a segment control.
     *
     * @vegaVersion 2.3.0
     */
    this.segments = [];
    /**
     * Specifies the variant of the segment control.
     *
     * The following options are available for the `variant` property:
     * - `default`:
     *      The segment control is rendered with both icon and text if configured,
     * - `text-only`:
     *      The segment control is rendered with text only regardless of the configuration of icon.
     * - `icon-only`:
     *      The segment control is rendered with icon only, text will be showed as the icon's tooltip if configured.
     *
     * @vegaVersion 2.3.0
     */
    this.variant = 'default';
  }
  /** 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 */
  watchBlock() {
    methodPlaceholder();
  }
  watchSize() {
    methodPlaceholder();
  }
  watchSegments() {
    methodPlaceholder();
  }
  watchSelected() {
    methodPlaceholder();
  }
  componentWillLoad() {
    methodPlaceholder();
  }
  render() {
    return sanitizeVegaComponent(h(Host, { class: { 'vega-segment-control-block': this.block } }, this.segmentControlRenderer.render()), this.host);
  }
  static get is() { return "vega-segment-control"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() { return {
    "$": ["vega-segment-control.scss"]
  }; }
  static get styleUrls() { return {
    "$": ["vega-segment-control.css"]
  }; }
  static get properties() { return {
    "block": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.3.0"
          }],
        "text": "Specifies whether the segment control spans the\n   full width of its parent element."
      },
      "attribute": "block",
      "reflect": false,
      "defaultValue": "false"
    },
    "size": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "'medium' | 'small'",
        "resolved": "\"medium\" | \"small\"",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.3.0"
          }],
        "text": "Specifies the size of the segment control."
      },
      "attribute": "size",
      "reflect": false,
      "defaultValue": "'medium'"
    },
    "segments": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "VegaSegmentProps[]",
        "resolved": "VegaSegmentProps[]",
        "references": {
          "VegaSegmentProps": {
            "location": "import",
            "path": "./types"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.3.0"
          }],
        "text": "Specifies the options available within the segment control.\n   Please note that we advise against having more than four segments in a segment control."
      },
      "defaultValue": "[]"
    },
    "selected": {
      "type": "string",
      "mutable": true,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.3.0"
          }],
        "text": "Specifies the key of the currently selected segment\n   within the segment control."
      },
      "attribute": "selected",
      "reflect": false
    },
    "variant": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "VegaSegmentControlVariant",
        "resolved": "\"default\" | \"icon-only\" | \"text-only\"",
        "references": {
          "VegaSegmentControlVariant": {
            "location": "import",
            "path": "./types"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.3.0"
          }],
        "text": "Specifies the variant of the segment control.\n\nThe following options are available for the `variant` property:\n- `default`:\n     The segment control is rendered with both icon and text if configured,\n- `text-only`:\n     The segment control is rendered with text only regardless of the configuration of icon.\n- `icon-only`:\n     The segment control is rendered with icon only, text will be showed as the icon's tooltip if configured."
      },
      "attribute": "variant",
      "reflect": false,
      "defaultValue": "'default'"
    }
  }; }
  static get states() { return {
    "isOverflowBlockSegments": {}
  }; }
  static get events() { return [{
      "method": "vegaChange",
      "name": "vegaChange",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.3.0"
          }],
        "text": "An event emitter notifying changes\n   in the selected segment."
      },
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      }
    }, {
      "method": "change",
      "name": "change",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "eventSemantics",
            "text": "namespace:native"
          }, {
            "name": "vegaVersion",
            "text": "2.3.0"
          }],
        "text": "A native event emitter notifying changes\n   in the selected segment."
      },
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      }
    }]; }
  static get elementRef() { return "host"; }
  static get watchers() { return [{
      "propName": "block",
      "methodName": "watchBlock"
    }, {
      "propName": "size",
      "methodName": "watchSize"
    }, {
      "propName": "segments",
      "methodName": "watchSegments"
    }, {
      "propName": "selected",
      "methodName": "watchSelected"
    }]; }
}
__decorate([
  InjectVegaGlobalSlimmer()
], VegaSegmentControl.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSegmentControl.prototype, "segmentControlRenderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSegmentControl.prototype, "segmentOverflowController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSegmentControl.prototype, "segmentRenderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSegmentControl.prototype, "selectedController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSegmentControl.prototype, "changeEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSegmentControl.prototype, "pageResizeObserverSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSegmentControl.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
