import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-148a7577.js';

const linkCss = ".sc-digi-link-h{--digi--link--gap:var(--digi--gutter--medium);--digi--link--color--default:var(--digi--color--text--interactive--primary);--digi--link--color--hover:var(--digi--color--text--interactive--primary);--digi--link--color--visited:var(--digi--color--text--interactive--visited);--digi--link--font-size:var(--digi--typography--link--font-size--desktop);--digi--link--font-family:var(--digi--global--typography--font-family--default);--digi--link--font-weight:var(--digi--typography--link-bold--font-weight--desktop);--digi--link--line-height:var(--digi--typography--link--line-height--desktop);--digi--link--text-decoration--default:none;--digi--link--text-decoration--hover:underline;--digi--link--text-decoration--icon--default:var(--digi--global--typography--text-decoration--default);--digi--link--text-decoration--icon--hover:underline;--digi--link--text-decoration-thickness:0.156em;--digi--link--text-underline-offset:3px;--COLOR:var(--digi--link--color--default);--LINK-TEXT-DECORATION:var(--digi--link--text-decoration--default);position:relative}.sc-digi-link-h:focus-visible{outline:none}.digi-link--has-icon.sc-digi-link-h{--LINK-TEXT-DECORATION:var(--digi--link--text-decoration--icon--default)}.digi-link--has-icon.sc-digi-link-h:focus,.digi-link--has-icon.sc-digi-link-h:hover{--digi--link--text-decoration--hover:var(--digi--link--text-decoration--icon--hover)}.sc-digi-link-h a.sc-digi-link:hover{--LINK-TEXT-DECORATION:var(--digi--link--text-decoration--hover);text-underline-offset:var(--digi--link--text-underline-offset);text-decoration-thickness:var(--digi--link--text-decoration-thickness)}.sc-digi-link-h a.sc-digi-link:focus-visible{outline:2px solid black;outline-offset:2px;box-shadow:0px 0px 0px 5px white}.sc-digi-link-s>a{font-family:var(--digi--link--font-family);font-size:var(--digi--link--font-size);font-weight:var(--digi--link--font-weight);line-height:var(--digi--link--line-height);color:var(--COLOR);text-decoration:var(--LINK-TEXT-DECORATION);display:inline-flex;gap:var(--digi--link--gap);text-underline-offset:var(--digi--link--text-underline-offset);text-decoration-thickness:var(--digi--link--text-decoration-thickness)}.sc-digi-link-s>a:hover{cursor:pointer}.sc-digi-link-s>a:hover{--LINK-TEXT-DECORATION:var(--digi--link--text-decoration--hover)}.sc-digi-link-s>a:visited{color:var(--digi--link--color--visited)}.sc-digi-link-s>a:visited svg{color:var(--digi--link--color--visited)}.digi-link--hide-visited.sc-digi-link-s>a:visited,.digi-link--hide-visited .sc-digi-link-s>a:visited{color:var(--digi--link--color--default)}.digi-link--hide-visited.sc-digi-link-s>a:visited,.digi-link--hide-visited.sc-digi-link-s>a:visited svg,.digi-link--hide-visited .sc-digi-link-s>a:visited svg{color:var(--digi--link--color--default)}.sc-digi-link-s>a [class*=digi-icon],.sc-digi-link-s>a [slot^=icon]{--digi--icon--color:var(--COLOR);--digi--icon--height:1em;--digi--icon--width:1em}";
const DigiLinkStyle0 = linkCss;

const Link = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.afOnClick = createEvent(this, "afOnClick", 7);
        this.afOnReady = createEvent(this, "afOnReady", 3);
        this.hasIcon = undefined;
        this.relation = undefined;
        this.afHref = undefined;
        this.afDescribedby = undefined;
        this.afAriaLabel = undefined;
        this.afTarget = undefined;
        this.afOverrideLink = false;
        this.afLinkContainer = false;
        this.hideVisitedColor = undefined;
        this.afDownload = undefined;
    }
    async afMGetLinkElement() {
        if (this.afLinkContainer) {
            return this.hostElement.children.length > 0
                ? this.hostElement.children.item(0)
                : undefined;
        }
        return this._link;
    }
    clickLinkHandler(e) {
        if (this.afOverrideLink) {
            e.preventDefault();
        }
        this.afOnClick.emit(e);
    }
    setRel() {
        var _a;
        this.relation =
            ((_a = this.afTarget) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === '_blank' ? 'noopener noreferrer' : null;
    }
    setHasIcon() {
        this.hasIcon = !!this.hostElement.querySelector('[slot="icon"]');
    }
    componentWillLoad() {
        this.setHasIcon();
        this.setRel();
    }
    componentWillUpdate() {
        this.setHasIcon();
        this.setRel();
    }
    componentDidLoad() {
        this.afOnReady.emit();
    }
    get cssModifiers() {
        return {
            'digi-link--has-icon': this.hasIcon,
            'digi-link--hide-visited': this.hideVisitedColor
        };
    }
    render() {
        return (h(Host, { key: '4ee4404f8d6d0b1b94671fda57e6b50ddccbd352', class: Object.assign({ 'digi-link': true }, this.cssModifiers) }, !this.afLinkContainer && (h("a", { key: '6524be94c4ec907ed6955ddf7da8c7aaaad18eac', href: this.afHref, onClick: (e) => this.clickLinkHandler(e), target: this.afTarget, rel: this.relation, ref: (el) => (this._link = el), "aria-describedby": this.afDescribedby, "aria-label": this.afAriaLabel, download: this.afDownload }, this.hasIcon && (h("div", { key: '20a853c07f6caf088c40d8c9ef8b80840017d5f8', class: "digi-link__icon-wrapper", "aria-hidden": "true" }, h("slot", { key: 'b9dd777361252aa876ff5db52435bb794a2f2228', name: "icon" }))), h("slot", { key: '498b649a1207efe49d65848cf991fb5a9a9569b8' }))), this.afLinkContainer && h("slot", { key: 'c60ef08fda6a2b5ffc899e59a78949031985b67a' })));
    }
    get hostElement() { return getElement(this); }
    static get watchers() { return {
        "afTarget": ["setRel"]
    }; }
};
Link.style = DigiLinkStyle0;

export { Link as digi_link };
