'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-58ea899e.js');
const component = require('./component-1e352960.js');
const injectKeyboardManager = require('./inject-keyboard-manager-2d9c4f92.js');
const globalSlimmerRegistry = require('./global-slimmer-registry-b3bce7e0.js');
const componentUsageRuntimeMetrics = require('./component-usage-runtime-metrics-4572c5b7.js');
const elementAppenderSlimmer = require('./element-appender-slimmer-dedd3a34.js');
const deprecatedPropertySlimmer = require('./deprecated-property-slimmer-300a3929.js');
require('./keyboard-manager-5ed6c472.js');
require('./ui-ae4ee13d.js');
require('./type-guard-3ec852d7.js');
require('./breakpoints-ebde4837.js');
require('./ui-32120990.js');
require('./typography-4560e7f1.js');
require('./internal-translation-controller-fb1532f4.js');
require('./change-manager-a297e4d2.js');
require('./static-subject-title-5829a298.js');
require('./internal-vega-z-index-manager-f03ddb37.js');
require('./number-4816603d.js');
require('./dynamic-slimmer-f31fdfd7.js');
require('./page-resize-observer-slimmer-273d62ef.js');
require('./breakpoints-1cc2c4c6.js');
require('./try-get-document-c0ebd39a.js');
require('./responsive-format-facade-2cab7344.js');
require('./pixel-98f2a10c.js');
require('./array-249289f2.js');
require('./feature-flag-controller-9129ef52.js');
require('./index-f054eb5d.js');
require('./observer-f49483e8.js');
require('./dom-node-subject-observer-factory-9110cb94.js');
require('./vega-internal-event-id-87014e4f.js');
require('./object-b53e9416.js');

var __decorate$3 = (undefined && undefined.__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;
};
/**
 * The class is responsible for managing the visibility and behavior of the tooltip content box.
 */
class VegaTooltipElementAppenderController extends elementAppenderSlimmer.ElementAppenderSlimmer {
  /**
   * This constructor of the tooltip element appender controller.
   */
  constructor() {
    super(() => this.getShowConfig(), () => this.trigger, 'isTooltipShow', () => this.disableInteractive);
    /**
     * Generate the element appender show config object.
     *
     * @returns {ElementAppenderShowConfig} - Show config object.
     */
    this.getShowConfig = () => {
      return {
        target: this.host,
        appendableElement: this.vegaTooltipContentBoxRenderer.getTooltipContentBoxRef(),
        positionRelativeTo: this.positionRelativeTo,
        isScreenPosition: true,
        matchTargetWidth: false,
        size: this.size,
        minWidth: this.minWidth,
        maxWidth: this.maxWidth,
        placement: this.placement,
        alignment: this.alignment,
      };
    };
  }
  /**
   * The `watchTrigger` function hides an element if the trigger is set to 'none'.
   */
  watchTrigger() {
    if (this.trigger === 'none') {
      this.hide();
    }
  }
  /**
   * The function `watchToShowTooltip` checks if the tooltip should be shown and then displays it if necessary.
   */
  watchToShowTooltip() {
    if (this.isTooltipShow) {
      this.show();
    }
  }
  /**
   * Hide the tooltip if the content change to empty.
   *
   * @param {string} newText - The property text or content new value.
   * @param {string} oldText - The property text or content old value.
   */
  watchTextChange(newText, oldText) {
    if (!newText && oldText && this.isTooltipShow) {
      this.hide();
    }
  }
  /**
   * Override the parent class `ElementAppenderSlimmer` show method to control the tooltip show according to the tooltip content.
   */
  show() {
    const text = this.deprecatedPropertySlimmer.getValue();
    if (text) {
      super.show();
    }
  }
}
__decorate$3([
  globalSlimmerRegistry.MapToComponentField()
], VegaTooltipElementAppenderController.prototype, "host", void 0);
__decorate$3([
  globalSlimmerRegistry.MapToComponentField()
], VegaTooltipElementAppenderController.prototype, "positionRelativeTo", void 0);
__decorate$3([
  globalSlimmerRegistry.MapToComponentField()
], VegaTooltipElementAppenderController.prototype, "size", void 0);
__decorate$3([
  globalSlimmerRegistry.MapToComponentField()
], VegaTooltipElementAppenderController.prototype, "minWidth", void 0);
__decorate$3([
  globalSlimmerRegistry.MapToComponentField()
], VegaTooltipElementAppenderController.prototype, "maxWidth", void 0);
__decorate$3([
  globalSlimmerRegistry.MapToComponentField()
], VegaTooltipElementAppenderController.prototype, "placement", void 0);
__decorate$3([
  globalSlimmerRegistry.MapToComponentField()
], VegaTooltipElementAppenderController.prototype, "alignment", void 0);
__decorate$3([
  globalSlimmerRegistry.MapToComponentField()
], VegaTooltipElementAppenderController.prototype, "trigger", void 0);
__decorate$3([
  globalSlimmerRegistry.MapToComponentField()
], VegaTooltipElementAppenderController.prototype, "disableInteractive", void 0);
__decorate$3([
  globalSlimmerRegistry.MapToComponentField()
], VegaTooltipElementAppenderController.prototype, "deprecatedPropertySlimmer", void 0);
__decorate$3([
  globalSlimmerRegistry.MapToComponentField({ writable: true })
], VegaTooltipElementAppenderController.prototype, "isTooltipShow", void 0);
__decorate$3([
  globalSlimmerRegistry.MapToComponentField()
], VegaTooltipElementAppenderController.prototype, "vegaTooltipContentBoxRenderer", void 0);
__decorate$3([
  globalSlimmerRegistry.MapToComponentMethod('watchTrigger')
], VegaTooltipElementAppenderController.prototype, "watchTrigger", null);
__decorate$3([
  globalSlimmerRegistry.MapToComponentMethod('watchToShowTooltip')
], VegaTooltipElementAppenderController.prototype, "watchToShowTooltip", null);
__decorate$3([
  globalSlimmerRegistry.MapToComponentMethod('watchTextChange')
], VegaTooltipElementAppenderController.prototype, "watchTextChange", null);

var __decorate$2 = (undefined && undefined.__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;
};
class VegaTooltipContentBoxRenderer {
  getTooltipContentBoxRef() {
    return this.tooltip;
  }
  render() {
    return (index.h("vega-tooltip-content-box", { ref: (e) => (this.tooltip = e), text: this.deprecatedPropertySlimmer.getValue() }));
  }
}
__decorate$2([
  globalSlimmerRegistry.MapToComponentField()
], VegaTooltipContentBoxRenderer.prototype, "deprecatedPropertySlimmer", void 0);

const VegaTooltipRuntimeMetricsPayloadDefinition = [
  {
    payloadKey: 'CONTENT_IS_EMPTY',
    payloadDescription: '@deprecated Specifies the content that is displayed inside the tooltip.',
    /**
     * The function checks if the `content` property of the `host` element is equal to 'undefined' or empty string.
     * If it is, the function will return `true`.
     *
     * @param {HTMLElement} host - The element to check
     * @returns {boolean} A boolean value
     */
    payloadValue: (host) => host.content === undefined || host.content === '',
  },
  {
    payloadKey: 'CONTENT_IS_NOT_EMPTY',
    payloadDescription: '@deprecated Specifies the content that is displayed inside the tooltip.',
    /**
     * The function checks if the `content` property of the `host` element is not equal to 'undefined' and empty string.
     * If it is, the function will return `true`.
     *
     * @param {HTMLElement} host - The element to check
     * @returns {boolean} A boolean value
     */
    payloadValue: (host) => host.content !== undefined && host.content !== '',
  },
];

const vegaTooltipCss = ":host{display:inline-block}";

var __decorate$1 = (undefined && undefined.__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;
};
const VegaTooltip = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    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 = deprecatedPropertySlimmer.createDeprecatedPropertySlimmer(VegaTooltip, 'text', 'content', undefined);
    this.vegaComponentUsageRuntimeMetricsSlimmer = new componentUsageRuntimeMetrics.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() {
  }
  /**
   * Monitor the property text updates.
   */
  watchTextChange() {
  }
  watchToShowTooltip() {
  }
  render() {
    return component.sanitizeVegaComponent(index.h(index.Host, null, index.h("slot", null), this.vegaTooltipContentBoxRenderer.render()), this.host);
  }
  get host() { return index.getElement(this); }
  static get watchers() { return {
    "trigger": ["watchTrigger"],
    "content": ["watchTextChange"],
    "text": ["watchTextChange"],
    "size": ["watchToShowTooltip"],
    "placement": ["watchToShowTooltip"],
    "alignment": ["watchToShowTooltip"]
  }; }
};
__decorate$1([
  componentUsageRuntimeMetrics.InjectVegaGlobalSlimmer()
], VegaTooltip.prototype, "globalSlimmers", void 0);
__decorate$1([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaTooltip.prototype, "vegaTooltipElementAppenderController", void 0);
__decorate$1([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaTooltip.prototype, "vegaTooltipContentBoxRenderer", void 0);
__decorate$1([
  injectKeyboardManager.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(),
    },
  ]),
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaTooltip.prototype, "deprecatedPropertySlimmer", void 0);
__decorate$1([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaTooltip.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
VegaTooltip.style = vegaTooltipCss;

const vegaTooltipContentBoxCss = ":host{position:absolute}:host(.vega-force-hidden){display:none !important}:host(.vega-placement-bottom){margin-top:8px}:host(.vega-placement-left){margin-left:-8px}:host(.vega-placement-right){margin-left:8px}:host(.vega-placement-top){margin-top:-8px}.vega-tooltip-content{border-radius:4px;padding-left:12px;padding-right:12px;padding-top:8px;padding-bottom:8px;overflow-wrap:break-word;background-color:rgba(var(--v-bg-inverted-primary, 4, 4, 28, 1));color:rgba(var(--v-text-inverted-primary, 252, 252, 252, 1));font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;white-space:pre-line}@media screen and (min-width: 768px) and (max-width: 1023px){.vega-tooltip-content{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px}}@media screen and (min-width: 1024px) and (max-width: 1439px){.vega-tooltip-content{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px}}@media screen and (min-width: 1440px) and (max-width: 9999px){.vega-tooltip-content{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px}}:host(.vega-no-suitable-placement) .vega-tooltip-content::after,:host(.vega-no-suitable-alignment) .vega-tooltip-content::after{display:none}.vega-tooltip-content::after{content:\"\";position:absolute;border-style:solid}:host(.vega-placement-bottom) .vega-tooltip-content::after{top:-4px;border-width:0 5px 4px 5px;border-bottom-color:rgba(var(--v-bg-inverted-primary, 4, 4, 28, 1));border-top-color:transparent;border-left-color:transparent;border-right-color:transparent}:host(.vega-placement-left) .vega-tooltip-content::after{left:100%;border-width:5px 0 5px 4px;border-left-color:rgba(var(--v-bg-inverted-primary, 4, 4, 28, 1));border-top-color:transparent;border-bottom-color:transparent;border-right-color:transparent}:host(.vega-placement-right) .vega-tooltip-content::after{left:-4px;border-width:5px 4px 5px 0;border-right-color:rgba(var(--v-bg-inverted-primary, 4, 4, 28, 1));border-top-color:transparent;border-left-color:transparent;border-bottom-color:transparent}:host(.vega-placement-top) .vega-tooltip-content::after{bottom:-4px;border-width:4px 5px 0px 5px;border-top-color:rgba(var(--v-bg-inverted-primary, 4, 4, 28, 1));border-bottom-color:transparent;border-left-color:transparent;border-right-color:transparent}:host(.vega-placement-bottom.vega-alignment-start) .vega-tooltip-content::after,:host(.vega-placement-top.vega-alignment-start) .vega-tooltip-content::after{left:8px}:host(.vega-placement-bottom.vega-alignment-center) .vega-tooltip-content::after,:host(.vega-placement-top.vega-alignment-center) .vega-tooltip-content::after{left:calc(50% - 5px)}:host(.vega-placement-bottom.vega-alignment-end) .vega-tooltip-content::after,:host(.vega-placement-top.vega-alignment-end) .vega-tooltip-content::after{right:8px}:host(.vega-placement-left.vega-alignment-start) .vega-tooltip-content::after,:host(.vega-placement-right.vega-alignment-start) .vega-tooltip-content::after{top:8px}:host(.vega-placement-left.vega-alignment-center) .vega-tooltip-content::after,:host(.vega-placement-right.vega-alignment-center) .vega-tooltip-content::after{top:calc(50% - 5px)}:host(.vega-placement-left.vega-alignment-end) .vega-tooltip-content::after,:host(.vega-placement-right.vega-alignment-end) .vega-tooltip-content::after{bottom:8px}";

var __decorate = (undefined && undefined.__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;
};
const VegaTooltipContentBox = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.globalSlimmers = {};
    this.vegaComponentUsageRuntimeMetricsSlimmer = new componentUsageRuntimeMetrics.VegaComponentUsageRuntimeMetricsSlimmer();
  }
  render() {
    return component.sanitizeVegaComponent(index.h(index.Host, { class: "vega-tooltip", role: "tooltip" }, index.h("div", { class: "vega-tooltip-content" }, this.text)), this.host);
  }
  get host() { return index.getElement(this); }
};
__decorate([
  componentUsageRuntimeMetrics.InjectVegaGlobalSlimmer()
], VegaTooltipContentBox.prototype, "globalSlimmers", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaTooltipContentBox.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
VegaTooltipContentBox.style = vegaTooltipContentBoxCss;

exports.vega_tooltip = VegaTooltip;
exports.vega_tooltip_content_box = VegaTooltipContentBox;
