/*!
 * KoliBri - The accessible HTML-Standard
 */
import{r as i,h as t,H as s,g as e}from"./index-a5e15b1e.js";import{k as a,a9 as h,h as n,ax as l,ay as d,l as r,az as o,R as c,aw as u,aA as f,U as v,aB as b,aC as _,V as p,aD as g,i as k,M as x}from"./index-c3ae175d.js";import{a as m}from"./i18n-73edd5e1.js";import{o as y}from"./ariaCurrentService-6fe36ebc.js";import{p as w}from"./events-29e84d75.js";import"./index-eb50dd62.js";import"./dev.utils-c7d151c6.js";const A=class{constructor(t){i(this,t),this.catchRef=t=>{this.ref=t,a(this.host,this.ref)},this.onClick=t=>{var e,a;!0===this.state._disabled?w(t):"function"==typeof(null===(e=this.state._on)||void 0===e?void 0:e.onClick)&&(t.preventDefault(),t.stopPropagation(),h(t,this.ref),null===(a=this.state._on)||void 0===a||a.onClick(t,this.state._href))},this.getRenderValues=()=>{const t="string"==typeof this.state._target&&"_self"!==this.state._target,e={href:"string"==typeof this.state._href&&this.state._href.length>0?this.state._href:"javascript:void(0);",target:"string"==typeof this.state._target&&this.state._target.length>0?this.state._target:void 0,rel:t?"noopener":void 0,download:"string"==typeof this.state._download?this.state._download:void 0};return!0!==this.state._hideLabel||this.state._label||n("[KolLink] Es muss ein Aria-Label gesetzt werden, wenn _hide-label gesetzt ist."),{isExternal:t,tagAttrs:e}},this._accessKey=void 0,this._ariaCurrentValue=void 0,this._disabled=!1,this._download=void 0,this._hideLabel=!1,this._href=void 0,this._icons=void 0,this._label=void 0,this._on=void 0,this._role=void 0,this._tabIndex=void 0,this._target=void 0,this._tooltipAlign="right",this.state={_ariaCurrentValue:"page",_href:"",_icons:{}}}render(){const{isExternal:e,tagAttrs:a}=this.getRenderValues(),i=x(this.state._label);return t(s,null,t("a",Object.assign({ref:this.catchRef},a,{accessKey:this.state._accessKey,"aria-current":this.state._ariaCurrent,"aria-disabled":this.state._disabled?"true":void 0,"aria-label":this.state._hideLabel&&"string"==typeof this.state._label?`${this.state._label}${e?` (${m("kol-open-link-in-tab")})`:""}`:void 0,class:{disabled:!0===this.state._disabled,"external-link":e,"hide-label":!0===this.state._hideLabel}},this.state._on,{onClick:this.onClick,onKeyPress:this.onClick,role:this.state._role,tabIndex:this.state._disabled?-1:this.state._tabIndex}),t("kol-span-wc",{_accessKey:this.state._accessKey,_icons:this.state._icons,_hideLabel:this.state._hideLabel,_label:i?"":this.state._label||this.state._href},t("slot",{name:"expert",slot:"expert"})),e&&t("kol-icon",{class:"external-link-icon",_label:this.state._hideLabel?"":m("kol-open-link-in-tab"),_icons:"codicon codicon-link-external","aria-hidden":this.state._hideLabel})),t("kol-tooltip-wc",{"aria-hidden":"true",hidden:i||!this.state._hideLabel,_accessKey:this.state._accessKey,_align:this.state._tooltipAlign,_label:this.state._label||this.state._href}))}validateAccessKey(t){l(this,t)}validateAriaCurrentValue(t){d(this,t)}validateDisabled(t){r(this,t)}validateDownload(t){o(this,t)}validateHideLabel(t){c(this,t)}validateHref(t){u(this,t,{required:!0})}validateIcons(t){f(this,t)}validateLabel(t){v(this,t)}validateOn(t){b(this,t)}validateRole(t){_(this,t)}validateTabIndex(t){p(this,t)}validateTarget(t){g(this,t)}validateTooltipAlign(t){k(this,t)}componentWillLoad(){this.validateAccessKey(this._accessKey),this.validateAriaCurrentValue(this._ariaCurrentValue),this.validateDisabled(this._disabled),this.validateDownload(this._download),this.validateHideLabel(this._hideLabel),this.validateHref(this._href),this.validateIcons(this._icons),this.validateLabel(this._label),this.validateOn(this._on),this.validateRole(this._role),this.validateTabIndex(this._tabIndex),this.validateTarget(this._target),this.validateTooltipAlign(this._tooltipAlign),this.unsubscribeOnLocationChange=y((t=>{this.state._ariaCurrent=t===this.state._href?this.state._ariaCurrentValue:void 0}))}disconnectedCallback(){this.unsubscribeOnLocationChange&&this.unsubscribeOnLocationChange()}get host(){return e(this)}static get watchers(){return{_accessKey:["validateAccessKey"],_ariaCurrentValue:["validateAriaCurrentValue"],_disabled:["validateDisabled"],_download:["validateDownload"],_hideLabel:["validateHideLabel"],_href:["validateHref"],_icons:["validateIcons"],_label:["validateLabel"],_on:["validateOn"],_role:["validateRole"],_tabIndex:["validateTabIndex"],_target:["validateTarget"],_tooltipAlign:["validateTooltipAlign"]}}};export{A as kol_link_wc};