import { p as proxyCustomElement, H, c as createEvent, h, d as Host } from './p-a53686b3.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 = /*@__PURE__*/ proxyCustomElement(class Link extends H {
    constructor() {
        super();
        this.__registerHost();
        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: '36de914eb05e1be6530fcde9b6d1313b1e5f9412', class: Object.assign({ 'digi-link': true }, this.cssModifiers) }, !this.afLinkContainer && (h("a", { key: '8640db8775088dcb3bf087c09b3395e23517126a', 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: '9e5877b58f0cbf1898032ede39eb124af52023e6', class: "digi-link__icon-wrapper", "aria-hidden": "true" }, h("slot", { key: '606a894726711c4224f86bf96e2bfe154c2c78d0', name: "icon" }))), h("slot", { key: '2df9ffa30ac0a98e9f7867670e2f331ccd42d6e6' }))), this.afLinkContainer && h("slot", { key: '0c74dfb1c0d70ff062cbaa51256b272a5994751d' })));
    }
    get hostElement() { return this; }
    static get watchers() { return {
        "afTarget": ["setRel"]
    }; }
    static get style() { return DigiLinkStyle0; }
}, [6, "digi-link", {
        "afHref": [1, "af-href"],
        "afDescribedby": [1, "af-describedby"],
        "afAriaLabel": [1, "af-aria-label"],
        "afTarget": [1, "af-target"],
        "afOverrideLink": [4, "af-override-link"],
        "afLinkContainer": [4, "af-link-container"],
        "hideVisitedColor": [4, "hide-visited-color"],
        "afDownload": [1, "af-download"],
        "hasIcon": [32],
        "relation": [32],
        "afMGetLinkElement": [64]
    }, undefined, {
        "afTarget": ["setRel"]
    }]);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["digi-link"];
    components.forEach(tagName => { switch (tagName) {
        case "digi-link":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, Link);
            }
            break;
    } });
}

export { Link as L, defineCustomElement as d };
