import { Host, h } from "@stencil/core";
import { LinkClass, LinkSizes } from "./constants";
import { govHost } from "../../helpers/Dom/template";
import { validateProp } from "../../helpers/Validate/props";
import { inheritAriaAttributes } from "../../helpers/Accessibility/accessibility";
export class GovLink {
    constructor() {
        /**
         * Element size.
         */
        this.size = 'm';
        /**
         * Element size.
         */
        this.external = false;
        /**
         * Cutting text to one line
         */
        this.truncate = false;
        this.inheritedAttributes = {};
        this.h = govHost(this.host);
    }
    validateSize(newValue) {
        validateProp(LinkSizes, newValue, LinkClass.root);
    }
    componentWillLoad() {
        this.validateSize(this.size);
        this.inheritedAttributes = inheritAriaAttributes(this.host);
    }
    onAriaAttributeChange(attributeName, newValue) {
        this.host.removeAttribute(attributeName);
        this.inheritedAttributes = Object.assign(Object.assign({}, this.inheritedAttributes), { [attributeName]: newValue });
    }
    render() {
        return (h(Host, { key: '87da124a14ecd5515767b8583a98c8a24ea6b21b', class: this.h.classes(LinkClass.root), size: this.size, href: this.href, external: this.external, truncate: this.truncate }, h("a", Object.assign({ key: '7e9b80a7eb6527214cea32a1a6b2dfa7bdba56a9', class: "element", href: this.href, target: this.external ? '_blank' : this.target, rel: this.external ? "noreferrer" : null }, this.inheritedAttributes), h("slot", { key: '0620fa97529d8966460cd664ff4285719954ca26', name: "icon-start" }), h("span", { key: 'fc56fe240cda4ab1dde314deac56937fa9d53717' }, h("slot", { key: 'fdb01c25b213ee2c093136ff86a9f3d56a0b12ca' })), h("slot", { key: '1d077305b248a77e6b6730c32d5136ce4a9b2858', name: "icon-end" }), this.external && h("gov-icon", { key: 'c9d155610f0cbd4ddf1fd1945b8da78357ba2767', name: "box-arrow-up-right", type: "components", size: this.size, class: LinkClass.external }))));
    }
    static get is() { return "gov-link"; }
    static get properties() {
        return {
            "size": {
                "type": "string",
                "attribute": "size",
                "mutable": false,
                "complexType": {
                    "original": "LinkSizesType",
                    "resolved": "\"l\" | \"m\" | \"s\"",
                    "references": {
                        "LinkSizesType": {
                            "location": "import",
                            "path": "./constants",
                            "id": "../../../packages/core/src/components/gov-link/constants.ts::LinkSizesType"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Element size."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "'m'"
            },
            "external": {
                "type": "boolean",
                "attribute": "external",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Element size."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "false"
            },
            "truncate": {
                "type": "boolean",
                "attribute": "truncate",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Cutting text to one line"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "false"
            },
            "href": {
                "type": "string",
                "attribute": "href",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "link",
                            "text": "https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-href"
                        }],
                    "text": "Same as original parameter"
                },
                "getter": false,
                "setter": false,
                "reflect": false
            },
            "target": {
                "type": "string",
                "attribute": "target",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "link",
                            "text": "https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-target"
                        }],
                    "text": "Same as original parameter"
                },
                "getter": false,
                "setter": false,
                "reflect": false
            }
        };
    }
    static get states() {
        return {
            "inheritedAttributes": {}
        };
    }
    static get elementRef() { return "host"; }
    static get watchers() {
        return [{
                "propName": "size",
                "methodName": "validateSize"
            }];
    }
}
//# sourceMappingURL=gov-link.js.map
