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, Host, h, Element, Prop, Watch, State } from '@stencil/core';
import { sanitizeVegaComponent } from '../../utils/component';
import { InjectKeyboardManager } from '../../decorators/property-decorators/inject-keyboard-manager';
import { InjectVegaGlobalSlimmer, InjectVegaSlimmer, methodPlaceholder, } from 'vega-slimmer/core';
import { VegaTooltipElementAppenderController } from './slimmers/controllers/vega-tooltip-element-appender-controller';
import { VegaTooltipContentBoxRenderer } from './slimmers/renderers/vega-tooltip-content-box-renderer';
import { createDeprecatedPropertySlimmer, } from '../../helpers/slimmers/deprecated-property-slimmer';
import { VegaComponentUsageRuntimeMetricsSlimmer } from '../../helpers/slimmers/component-usage-runtime-metrics';
import { VegaTooltipRuntimeMetricsPayloadDefinition } from '../../constants/runtime-metrics-payload-definition/vega-tooltip/runtime-metrics-payload-definition';
/**
 * @vegaVersion 1.3.0
 */
export class VegaTooltip {
  constructor() {
    this.globalSlimmers = {};
    this.vegaTooltipElementAppenderController = new VegaTooltipElementAppenderController();
    this.vegaTooltipContentBoxRenderer = new VegaTooltipContentBoxRenderer();
    /**
     * The below method is e2e-test covered in
     * @see{module:vega-tooltip-keyboard-control-with-hover-trigger-e2e}
     * @see{module:vega-tooltip-keyboard-control-with-click-trigger-e2e}
     */
    /* istanbul ignore next */
    this.deprecatedPropertySlimmer = createDeprecatedPropertySlimmer(VegaTooltip, 'text', 'content', undefined);
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer(VegaTooltipRuntimeMetricsPayloadDefinition);
    this.isTooltipShow = false;
    /**
     * Specifies the trigger mode for the tooltip.
     * - click: means the tooltip show/hide by click.
     * - hover: means the tooltip show/hide by hover.
     * - none: means tooltip is not displayed regardless of hover or click.
     *
     * @vegaVersion 1.3.0
     */
    this.trigger = 'hover';
    /**
     * Specifies the vertical positioning of the tooltip
     *    within its container or relative to a reference point.
     *
     * @vegaVersion 1.3.0
     */
    this.placement = 'top';
    /**
     * Determines the horizontal positioning of the tooltip
     *    within its container or relative to a reference point.
     *
     * @vegaVersion 1.41.0
     */
    this.alignment = 'center';
    /**
     * The tooltip is interactive by default.
     * Set `disableInteractive` to `true` to deactivate this feature, causing the tooltip to close upon hover.
     *
     * @vegaVersion 1.52.0
     */
    this.disableInteractive = false;
  }
  watchTrigger() {
    methodPlaceholder();
  }
  /**
   * Monitor the property text updates.
   */
  watchTextChange() {
    methodPlaceholder();
  }
  watchToShowTooltip() {
    methodPlaceholder();
  }
  render() {
    return sanitizeVegaComponent(h(Host, null,
      h("slot", null),
      this.vegaTooltipContentBoxRenderer.render()), this.host);
  }
  static get is() { return "vega-tooltip"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() { return {
    "$": ["vega-tooltip.scss"]
  }; }
  static get styleUrls() { return {
    "$": ["vega-tooltip.css"]
  }; }
  static get properties() { return {
    "size": {
      "type": "any",
      "mutable": false,
      "complexType": {
        "original": "ResponsiveType<SizeType>",
        "resolved": "`${number}%` | number | { S?: SizeType; M?: SizeType; L?: SizeType; XL?: SizeType; default?: SizeType; }",
        "references": {
          "ResponsiveType": {
            "location": "import",
            "path": "../../types/ui.type"
          },
          "SizeType": {
            "location": "import",
            "path": "../../types/ui.type"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "1.3.0"
          }],
        "text": "Determines the fixed size (width) of the tooltip.\n\nIt can be provided as a number or a ResponsiveType."
      },
      "attribute": "size",
      "reflect": false
    },
    "minWidth": {
      "type": "any",
      "mutable": false,
      "complexType": {
        "original": "ResponsiveType<SizeType>",
        "resolved": "`${number}%` | number | { S?: SizeType; M?: SizeType; L?: SizeType; XL?: SizeType; default?: SizeType; }",
        "references": {
          "ResponsiveType": {
            "location": "import",
            "path": "../../types/ui.type"
          },
          "SizeType": {
            "location": "import",
            "path": "../../types/ui.type"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "1.30.0"
          }],
        "text": "Determines the minimum width of the tooltip.\n\nIt can be provided as a number or a ResponsiveType."
      },
      "attribute": "min-width",
      "reflect": false
    },
    "maxWidth": {
      "type": "any",
      "mutable": false,
      "complexType": {
        "original": "ResponsiveType<SizeType>",
        "resolved": "`${number}%` | number | { S?: SizeType; M?: SizeType; L?: SizeType; XL?: SizeType; default?: SizeType; }",
        "references": {
          "ResponsiveType": {
            "location": "import",
            "path": "../../types/ui.type"
          },
          "SizeType": {
            "location": "import",
            "path": "../../types/ui.type"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "1.30.0"
          }],
        "text": "Determines the maximum width of the tooltip.\n\nIt can be provided as a number or a ResponsiveType."
      },
      "attribute": "max-width",
      "reflect": false
    },
    "trigger": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "'hover' | 'click' | 'none'",
        "resolved": "\"click\" | \"hover\" | \"none\"",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "1.3.0"
          }],
        "text": "Specifies the trigger mode for the tooltip.\n- click: means the tooltip show/hide by click.\n- hover: means the tooltip show/hide by hover.\n- none: means tooltip is not displayed regardless of hover or click."
      },
      "attribute": "trigger",
      "reflect": false,
      "defaultValue": "'hover'"
    },
    "content": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "deprecated",
            "text": "This property will be removed soon and replaced by prop text"
          }, {
            "name": "vegaVersion",
            "text": "1.3.0"
          }],
        "text": "Specifies the content that is displayed\n   inside the tooltip."
      },
      "attribute": "content",
      "reflect": false
    },
    "text": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.0.0"
          }],
        "text": "Specifies the text that is displayed\n   inside the tooltip.\n\nLine breaks (`\\n`) are supported and rendered as new lines. Consecutive\nregular spaces are collapsed; to preserve indentation (e.g. hanging indent\nfor bullet lists) use the non-breaking space character `\\u00A0`."
      },
      "attribute": "text",
      "reflect": false
    },
    "placement": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "ElementAppenderPlacementType",
        "resolved": "\"bottom\" | \"left\" | \"right\" | \"top\" | (\"left\" | \"right\" | \"top\" | \"bottom\")[]",
        "references": {
          "ElementAppenderPlacementType": {
            "location": "import",
            "path": "../../types/ui.type"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "1.3.0"
          }],
        "text": "Specifies the vertical positioning of the tooltip\n   within its container or relative to a reference point."
      },
      "attribute": "placement",
      "reflect": false,
      "defaultValue": "'top'"
    },
    "alignment": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "ElementAppenderAlignmentType",
        "resolved": "\"center\" | \"end\" | \"start\" | (\"center\" | \"start\" | \"end\")[]",
        "references": {
          "ElementAppenderAlignmentType": {
            "location": "import",
            "path": "../../types/ui.type"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "1.41.0"
          }],
        "text": "Determines the horizontal positioning of the tooltip\n   within its container or relative to a reference point."
      },
      "attribute": "alignment",
      "reflect": false,
      "defaultValue": "'center'"
    },
    "positionRelativeTo": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "VegaWarning",
            "text": "The value of this property should be an element that is\nthe parent of this component or an ancestor of the parent element.\nUsing any other element may lead to unexpected behavior."
          }, {
            "name": "vegaVersion",
            "text": "1.3.0"
          }],
        "text": "Specifies the target element that will contain the tooltip popup.\n\nIf not provided, the popup will be appended to the\n   body by default. Adjust this property if you\n   encounter scrolling or positioning issues."
      },
      "attribute": "position-relative-to",
      "reflect": false
    },
    "disableInteractive": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "1.52.0"
          }],
        "text": "The tooltip is interactive by default.\nSet `disableInteractive` to `true` to deactivate this feature, causing the tooltip to close upon hover."
      },
      "attribute": "disable-interactive",
      "reflect": false,
      "defaultValue": "false"
    }
  }; }
  static get states() { return {
    "isTooltipShow": {}
  }; }
  static get elementRef() { return "host"; }
  static get watchers() { return [{
      "propName": "trigger",
      "methodName": "watchTrigger"
    }, {
      "propName": "content",
      "methodName": "watchTextChange"
    }, {
      "propName": "text",
      "methodName": "watchTextChange"
    }, {
      "propName": "size",
      "methodName": "watchToShowTooltip"
    }, {
      "propName": "placement",
      "methodName": "watchToShowTooltip"
    }, {
      "propName": "alignment",
      "methodName": "watchToShowTooltip"
    }]; }
}
__decorate([
  InjectVegaGlobalSlimmer()
], VegaTooltip.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaTooltip.prototype, "vegaTooltipElementAppenderController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaTooltip.prototype, "vegaTooltipContentBoxRenderer", void 0);
__decorate([
  InjectKeyboardManager((target) => [
    {
      keyCode: 'Tab',
      activeElementInScope: [target.host],
      callback: /* istanbul ignore next */ () => target.trigger === 'hover' && target.vegaTooltipElementAppenderController.show(),
    },
    {
      keyCode: 'Escape',
      activeElementInScope: [
        target.host,
        target.vegaTooltipContentBoxRenderer.getTooltipContentBoxRef(),
      ],
      callback: /* istanbul ignore next */ () => target.vegaTooltipElementAppenderController.hide(),
    },
    {
      keyCode: 'Tab',
      activeElementOutScope: [
        target.host,
        target.vegaTooltipContentBoxRenderer.getTooltipContentBoxRef(),
      ],
      callback: /* istanbul ignore next */ () => target.isTooltipShow && target.vegaTooltipElementAppenderController.hide(),
    },
  ]),
  InjectVegaSlimmer()
], VegaTooltip.prototype, "deprecatedPropertySlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaTooltip.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
