'use strict';

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

const index = require('./index-58ea899e.js');
const component = require('./component-1e352960.js');
const globalSlimmerRegistry = require('./global-slimmer-registry-b3bce7e0.js');
const componentUsageRuntimeMetrics = require('./component-usage-runtime-metrics-4572c5b7.js');
const eventEmitSlimmer = require('./event-emit-slimmer-73c42d7e.js');
const vegaEventId = require('./vega-event-id-f95480b7.js');
const childNodesEventPreventSlimmer = require('./child-nodes-event-prevent-slimmer-1f212162.js');
const index$1 = require('./index-592b4052.js');
const ariaAttributesValueMapper = require('./aria-attributes-value-mapper-9a41b9cf.js');
require('./dynamic-slimmer-f31fdfd7.js');
require('./change-manager-a297e4d2.js');
require('./dom-node-subject-observer-factory-ba6a95f3.js');
require('./observer-f49483e8.js');
require('./ui-3727d685.js');
require('./internal-vega-event-manager-063c17cb.js');
require('./try-get-document-c0ebd39a.js');
require('./vega-env-manager-23b8b23c.js');
require('./feature-flag-controller-9129ef52.js');
require('./index-f054eb5d.js');
require('./mutation-observer-slimmer-749d5020.js');

const VegaButtonLinkRuntimeMetricsPayloadDefinition = [
  {
    payloadKey: 'EVENTFUL_IS_TRUE',
    payloadDescription: '@deprecated Specifies whether the button link will emit a vegaClick event when clicked. If set to true, the event will be emitted.',
    /**
     * The function checks if the `eventful` property of the `host` element is equal to 'true'.
     * If it is, the function will return `true`.
     *
     * @param {HTMLElement} host - The element to check
     * @returns {boolean} A boolean value
     */
    payloadValue: (host) => host.eventful === true,
  },
  {
    payloadKey: 'EVENTFUL_IS_FALSE',
    payloadDescription: '@deprecated Specifies whether the button link will emit a vegaClick event when clicked. If set to false, the component will function as a regular link to another page or URL, and no events will be emitted.',
    /**
     * The function checks if the `eventful` property of the `host` element is equal to 'false'.
     * If it is, the function will return `true`.
     *
     * @param {HTMLElement} host - The element to check
     * @returns {boolean} A boolean value
     */
    payloadValue: (host) => host.eventful === false,
  },
];

const vegaButtonLinkCss = ":host{display:inline-block;position:relative;margin:0px;line-height:normal}a{text-decoration:none;color:rgba(var(--v-text-link, 19, 98, 226, 1));background-color:rgba(var(--v-bg-transparent, 0, 0, 0, 0));display:inline-block;outline:none}a:visited{color:rgba(var(--v-text-link-visited, 95, 56, 206, 1))}a:hover{color:rgba(var(--v-text-link-hover, 4, 112, 236, 1))}a:active{color:rgba(var(--v-text-link-active, 29, 65, 195, 1))}a:focus-visible{color:rgba(var(--v-text-link-focus, 4, 112, 236, 1));outline:2px solid rgba(var(--v-border-color-action, 19, 98, 226, 1));outline-offset:2px}a.default:focus-visible,a.large:focus-visible{border-radius:8px}a.small:focus-visible{border-radius:4px}a.icon:focus-visible{outline:2px solid rgba(var(--v-border-color-action, 19, 98, 226, 1));outline-offset:4px}a:not(.vega-button-link-danger):visited vega-icon svg *[fill=currentColor]{fill:rgba(var(--v-text-link-visited, 95, 56, 206, 1))}a:not(.vega-button-link-danger):visited vega-icon svg *[stroke=currentColor]{stroke:rgba(var(--v-text-link-visited, 95, 56, 206, 1))}a:not(.vega-button-link-danger):hover vega-icon svg *[fill=currentColor]{fill:rgba(var(--v-text-link-hover, 4, 112, 236, 1))}a:not(.vega-button-link-danger):hover vega-icon svg *[stroke=currentColor]{stroke:rgba(var(--v-text-link-hover, 4, 112, 236, 1))}a:not(.vega-button-link-danger):active vega-icon svg *[fill=currentColor]{fill:rgba(var(--v-text-link-active, 29, 65, 195, 1))}a:not(.vega-button-link-danger):active vega-icon svg *[stroke=currentColor]{stroke:rgba(var(--v-text-link-active, 29, 65, 195, 1))}a:not(.vega-button-link-danger):focus-visible vega-icon svg *[fill=currentColor]{fill:rgba(var(--v-text-link-focus, 4, 112, 236, 1))}a:not(.vega-button-link-danger):focus-visible vega-icon svg *[stroke=currentColor]{stroke:rgba(var(--v-text-link-focus, 4, 112, 236, 1))}a:active{text-decoration:none}a:active:hover .vega-button-link-label{text-decoration:none}a.vega-button-link-danger{color:rgba(var(--v-text-danger-link, 230, 50, 87, 1))}a.vega-button-link-danger:visited{color:rgba(var(--v-text-danger-link-visited, 230, 50, 87, 1))}a.vega-button-link-danger:hover{color:rgba(var(--v-text-danger-link-hover, 233, 71, 104, 1))}a.vega-button-link-danger:active{color:rgba(var(--v-text-danger-link-active, 189, 41, 71, 1))}a.vega-button-link-danger:focus-visible{color:rgba(var(--v-text-danger-link-focus, 240, 52, 91, 1))}a.vega-button-link-danger:focus-visible.default:focus-visible,a.vega-button-link-danger:focus-visible.large:focus-visible{outline:2px solid rgba(var(--v-border-color-danger, 230, 50, 87, 1));outline-offset:4px}a.vega-button-link-danger:focus-visible.small:focus-visible{outline:2px solid rgba(var(--v-border-color-danger, 230, 50, 87, 1));outline-offset:2px}a .vega-button-link-button-container{border-radius:9999px;cursor:pointer;background-color:rgba(var(--v-bg-action-secondary, 252, 252, 252, 1));color:rgba(var(--v-text-link, 19, 98, 226, 1));box-sizing:border-box;border:2px solid rgba(var(--v-border-secondary-btn, 19, 98, 226, 1))}a:visited .vega-button-link-button-container{color:rgba(var(--v-text-link-visited, 95, 56, 206, 1));border-color:var(--v-text-link-visited)}a:hover .vega-button-link-button-container{border:2px solid rgba(var(--v-border-secondary-btn-hover, 4, 112, 236, 1));background-color:rgba(var(--v-bg-action-secondary-hover, 4, 112, 236, 0.1));color:rgba(var(--v-text-link-hover, 4, 112, 236, 1))}a:focus .vega-button-link-button-container{border:2px solid rgba(var(--v-border-secondary-btn, 19, 98, 226, 1))}a:active .vega-button-link-button-container{border:2px solid rgba(var(--v-border-secondary-btn-active, 29, 65, 195, 1));background-color:rgba(var(--v-bg-action-secondary-active, 29, 65, 195, 0.1));color:rgba(var(--v-text-link-active, 29, 65, 195, 1))}a.vega-button-link-danger .vega-button-link-button-container{border:2px solid rgba(var(--v-border-secondary-danger-btn, 230, 50, 87, 1));color:rgba(var(--v-text-danger-link, 230, 50, 87, 1))}a.vega-button-link-danger:hover .vega-button-link-button-container{border:2px solid rgba(var(--v-border-secondary-danger-btn-hover, 255, 87, 114, 1));background-color:rgba(var(--v-bg-danger-tertiary-hover, 255, 87, 114, 0.2));color:rgba(var(--v-text-danger-link-hover, 233, 71, 104, 1))}a.vega-button-link-danger:focus .vega-button-link-button-container{border:2px solid rgba(var(--v-border-secondary-danger-btn, 230, 50, 87, 1))}a.vega-button-link-danger:active .vega-button-link-button-container{border:2px solid rgba(var(--v-border-secondary-danger-btn-active, 189, 41, 71, 1));background-color:rgba(var(--v-bg-danger-tertiary-active, 189, 41, 71, 0.2));color:rgba(var(--v-text-danger-link-active, 189, 41, 71, 1))}a.vega-button-link-size-default .vega-button-link-button-container{width:40px;height:40px;padding:10px}a.vega-button-link-size-large .vega-button-link-button-container{width:56px;height:56px;padding:14px}a.vega-button-link-size-small .vega-button-link-button-container{width:32px;height:32px;padding:6px}a.vega-button-link-size-default .vega-button-link-icon,a.vega-button-link-size-small .vega-button-link-icon{width:16px;height:16px;line-height:16px}a.vega-button-link-size-large .vega-button-link-icon{width:24px;height:24px;line-height:24px}a .vega-button-link-label{min-width:-webkit-min-content;min-width:-moz-min-content;min-width:min-content}a.vega-button-link-size-small .vega-button-link-label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:700;line-height:24px;letter-spacing:0px}@media screen and (min-width: 768px) and (max-width: 1023px){a.vega-button-link-size-small .vega-button-link-label{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:700;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){a.vega-button-link-size-small .vega-button-link-label{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:700;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){a.vega-button-link-size-small .vega-button-link-label{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:700;line-height:18px;letter-spacing:0px}}a.vega-button-link-size-default .vega-button-link-label{font-family:\"Inter\", sans-serif;font-size:18px;font-weight:700;line-height:24px;letter-spacing:0px}@media screen and (min-width: 768px) and (max-width: 1023px){a.vega-button-link-size-default .vega-button-link-label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:700;line-height:24px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){a.vega-button-link-size-default .vega-button-link-label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:700;line-height:24px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){a.vega-button-link-size-default .vega-button-link-label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:700;line-height:24px;letter-spacing:0px}}a.vega-button-link-size-large .vega-button-link-label{font-family:\"Inter\", sans-serif;font-size:20px;font-weight:700;line-height:24px;letter-spacing:0px}@media screen and (min-width: 768px) and (max-width: 1023px){a.vega-button-link-size-large .vega-button-link-label{font-family:\"Inter\", sans-serif;font-size:18px;font-weight:700;line-height:24px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){a.vega-button-link-size-large .vega-button-link-label{font-family:\"Inter\", sans-serif;font-size:18px;font-weight:700;line-height:24px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){a.vega-button-link-size-large .vega-button-link-label{font-family:\"Inter\", sans-serif;font-size:18px;font-weight:700;line-height:24px;letter-spacing:0px}}:host(.vega-button-link-disabled){pointer-events:none}:host(.vega-button-link-disabled) a{color:rgba(var(--v-text-disabled, 176, 180, 181, 1));text-decoration:none;background-color:rgba(var(--v-bg-transparent, 0, 0, 0, 0))}:host(.vega-button-link-disabled) a.vega-button-link .vega-button-link-button-container{color:rgba(var(--v-text-disabled, 176, 180, 181, 1));border:2px solid rgba(var(--v-border-secondary-btn-disabled, 176, 180, 181, 1));background-color:rgba(var(--v-bg-action-secondary, 252, 252, 252, 1))}:host(.vega-button-link-disabled) a:focus>.vega-button-link-content{color:rgba(var(--v-text-disabled, 176, 180, 181, 1))}:host(.button-group-item-button-tertiary.vega-button-link-disabled) a{background-color:rgba(var(--v-bg-transparent, 0, 0, 0, 0))}";

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 VegaButtonLink = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.vegaClick = index.createEvent(this, "vegaClick", 7);
    this.click = index.createEvent(this, "click", 7);
    this.globalSlimmers = {};
    this.clickEventEmitter = eventEmitSlimmer.createEventEmitSlimmer(VegaButtonLink, vegaEventId.VegaClick);
    this.eventPrevent = new childNodesEventPreventSlimmer.ChildNodesEventPreventSlimmer([vegaEventId.VegaClick], () => this.host);
    this.vegaComponentUsageRuntimeMetricsSlimmer = new componentUsageRuntimeMetrics.VegaComponentUsageRuntimeMetricsSlimmer(VegaButtonLinkRuntimeMetricsPayloadDefinition);
    this.ariaAttributesValueMapper = new ariaAttributesValueMapper.AriaAttributesValueMapper(() => {
      // the target element which we will apply the aria label to this element
      return this.host.shadowRoot.querySelector('a');
    }, {
      'aria-label': {
        // meaning if data-aria-label is defined, we will use it as the value of aria-label, otherwise we will use label as the value of aria-label
        dependency: ['data-aria-label', 'label'],
        // meaning if the all the values in the above array are all empty or undefined, the default value will be used as the final value of aria-label
        defaultValue: 'No label defined',
      },
    });
    /**
     * Specifies the URL associated with the button link.
     *   If no URL is set, the component behaves as a button and triggers the click event.
     * 	 If a URL is provided, it behaves as a link and the click event is not emitted.
     *
     * @vegaVersion 1.0.4
     * @defaultValue javascript:void(0);
     */
    this.link = VegaButtonLink.defaultLink;
    /**
     * Specifies the size of the button link.
     *
     * @vegaVersion 1.0.2
     */
    this.size = 'default';
    /**
     * Specifies the type of icon used in the button link.
     *
     * The following options are available for the `iconType` parameter:
     * - `icon`:
     *      The icon is rendered as a regular icon without
     *      any additional styling or background.
     * - `button`:
     *      The icon is rendered with a circular background,
     *      providing additional emphasis and visual prominence
     *      to the icon in the button link.
     *
     * @vegaVersion 1.0.5
     */
    this.iconType = 'icon';
    /**
     * Specifies the placement of the icon in relation to
     *    the button link's label.
     *
     * @vegaVersion 1.3.0
     */
    this.iconAlign = 'left';
    /**
     * Specifies the text displayed on the button link.
     *
     * @vegaVersion 1.0.4
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.label = '';
    /**
     * Specifies whether the button link element is disabled.
     *
     * @vegaVersion 1.3.0
     */
    this.disabled = false;
    /**
     * Indicates the danger status of the button link,
     *    typically used for destructive actions.
     *
     * @vegaVersion 1.3.0
     */
    this.danger = false;
    /**
     * Specifies whether the button link will emit a vegaClick event when clicked.
     *    When set to true, the component behaves as a link but also triggers the click event when clicked,
     *    allowing both navigation and custom click handling.
     *
     * @vegaVersion 1.3.0
     */
    this.eventful = false;
    /**
     * Specifies the location where the linked document will be opened,
     *    helping users understand how the link will behave when activated.
     *
     * @vegaVersion 2.33.0
     */
    this.target = '_self';
    this.onClick = (e) => {
      if (!this.isButton() && !this.eventful)
        return;
      if (this.disabled) {
        e.preventDefault();
      }
      else {
        const clickEvent = this.clickEventEmitter.emit(this.host.dataset.key, e);
        if (clickEvent.defaultPrevented) {
          e.preventDefault();
        }
      }
    };
  }
  componentWillLoad() {
    if (!this.label) {
      this.label = this.host.textContent;
    }
    this.host.innerHTML = index$1.htmlSanitizer.sanitize('', index$1.emptySanitizeStrategy);
  }
  render() {
    const isButton = this.isButton();
    const href = isButton ? VegaButtonLink.defaultLink : this.link;
    return component.sanitizeVegaComponent(index.h(index.Host, { class: {
        'vega-button-link-disabled': this.disabled,
      } }, index.h("a", { part: "link", tabIndex: this.disabled ? -1 : 0, role: isButton ? 'button' : 'link', "aria-label": this.label.trim() || 'No label defined', href: href, onClick: this.onClick, class: {
        'vega-button-link': true,
        [`vega-button-link-size-${this.size}`]: true,
        'vega-button-link-left-button': this.hasIconButton('left'),
        'vega-button-link-right-button': this.hasIconButton('right'),
        'vega-button-link-danger': this.danger,
        'icon': this.icon ? true : false,
        [this.size]: true,
      }, rel: "noopener noreferrer", target: this.target }, index.h("div", { class: "vega-button-link-content" }, this.renderContent()))), this.host);
  }
  hasIconButton(position) {
    return this.icon && this.iconType === 'button' && this.iconAlign === position;
  }
  renderContent() {
    if (this.icon) {
      return (index.h("vega-flex", { alignItems: "center", gap: this.getGapByButtonSize(), justifyContent: "center" }, this.iconAlign === 'left' && this.renderIcon(), this.renderLabel(), this.iconAlign === 'right' && this.renderIcon()));
    }
    else {
      return this.renderLabel();
    }
  }
  getGapByButtonSize() {
    if (this.size === 'large') {
      return this.iconType === 'icon' ? 'size-8' : 'size-12';
    }
    if (this.size === 'small') {
      return this.iconType === 'icon' ? 'size-4' : 'size-8';
    }
    if (this.size === 'default') {
      return 'size-8';
    }
  }
  renderLabel() {
    return (this.label && (index.h("span", { class: "vega-button-link-label", part: "label-container" }, index.h("vega-text", { part: "label-text" }, this.label))));
  }
  renderIcon() {
    return (index.h("div", { class: `vega-button-link-${this.iconType} vega-flex-shrink-0 v-min-w-min` }, this.iconType === 'icon' ? (this.renderVegaIcon()) : (index.h("div", { class: "vega-button-link-button-container" }, this.renderVegaIcon()))));
  }
  renderVegaIcon() {
    return index.h("vega-icon", { icon: this.icon, size: this.size === 'large' ? 'size-24' : 'size-16' });
  }
  isButton() {
    return !this.link || this.link === VegaButtonLink.defaultLink;
  }
  get host() { return index.getElement(this); }
};
VegaButtonLink.defaultLink = 'javascript:void(0);';
__decorate([
  componentUsageRuntimeMetrics.InjectVegaGlobalSlimmer()
], VegaButtonLink.prototype, "globalSlimmers", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaButtonLink.prototype, "clickEventEmitter", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaButtonLink.prototype, "eventPrevent", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaButtonLink.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaButtonLink.prototype, "ariaAttributesValueMapper", void 0);
VegaButtonLink.style = vegaButtonLinkCss;

exports.vega_button_link = VegaButtonLink;
