import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-090d31ca.js';
import { s as sanitizeVegaComponent } from './component-d58ca1d0.js';
import './global-slimmer-registry-0a7aa308.js';
import { I as InjectVegaSlimmer } from './inject-vega-slimmer-caffc2aa.js';
import { V as VegaComponentUsageRuntimeMetricsSlimmer, I as InjectVegaGlobalSlimmer } from './component-usage-runtime-metrics-4202784a.js';
import { c as createEventEmitSlimmer } from './event-emit-slimmer-50d423c0.js';
import { c as VegaClick } from './vega-event-id-1b737ae8.js';
import { C as ChildNodesEventPreventSlimmer } from './child-nodes-event-prevent-slimmer-08e29cdd.js';
import { h as htmlSanitizer, e as emptySanitizeStrategy } from './index-3b327f29.js';
import { A as AriaAttributesValueMapper } from './aria-attributes-value-mapper-0bfe3cfa.js';
import './dynamic-slimmer-60d5da5a.js';
import './change-manager-ecbd3a2a.js';
import './dom-node-subject-factory-6894df15.js';
import './ui-6dd51115.js';
import './dom-node-subject-observer-factory-61fda003.js';
import './observer-3959f9dd.js';
import './internal-vega-event-manager-a19d633d.js';
import './try-get-document-bef0f526.js';
import './vega-env-manager-8f8dc473.js';
import './feature-flag-controller-b7e7da75.js';
import './index-bfc6dfa2.js';
import './mutation-observer-slimmer-f6fcd32a.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) {
    registerInstance(this, hostRef);
    this.vegaClick = createEvent(this, "vegaClick", 7);
    this.click = createEvent(this, "click", 7);
    this.globalSlimmers = {};
    this.clickEventEmitter = createEventEmitSlimmer(VegaButtonLink, VegaClick);
    this.eventPrevent = new ChildNodesEventPreventSlimmer([VegaClick], () => this.host);
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer(VegaButtonLinkRuntimeMetricsPayloadDefinition);
    this.ariaAttributesValueMapper = new 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 = htmlSanitizer.sanitize('', emptySanitizeStrategy);
  }
  render() {
    const isButton = this.isButton();
    const href = isButton ? VegaButtonLink.defaultLink : this.link;
    return sanitizeVegaComponent(h(Host, { class: {
        'vega-button-link-disabled': this.disabled,
      } }, 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 }, 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 (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 && (h("span", { class: "vega-button-link-label", part: "label-container" }, h("vega-text", { part: "label-text" }, this.label))));
  }
  renderIcon() {
    return (h("div", { class: `vega-button-link-${this.iconType} vega-flex-shrink-0 v-min-w-min` }, this.iconType === 'icon' ? (this.renderVegaIcon()) : (h("div", { class: "vega-button-link-button-container" }, this.renderVegaIcon()))));
  }
  renderVegaIcon() {
    return 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 getElement(this); }
};
VegaButtonLink.defaultLink = 'javascript:void(0);';
__decorate([
  InjectVegaGlobalSlimmer()
], VegaButtonLink.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaButtonLink.prototype, "clickEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaButtonLink.prototype, "eventPrevent", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaButtonLink.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaButtonLink.prototype, "ariaAttributesValueMapper", void 0);
VegaButtonLink.style = vegaButtonLinkCss;

export { VegaButtonLink as vega_button_link };
