import { h } from "@stencil/core";
import { InfoCardVariation } from "./info-card-variation.enum";
import { InfoCardType } from "./info-card-type.enum";
import { InfoCardSize } from "./info-card-size.enum";
import { InfoCardBorderPosition } from "./info-card-border-position.enum";
import { logger } from "../../../global/utils/logger";
/**
 * @slot default - Kan innehålla vad som helst
 *
 * @enums InfoCardType - info-card-type.enum.ts
 * @enums InfoCardVariation - info-card-variation.enum.ts
 * @enums InfoCardHeadingLevel - info-card-heading-level.enum.ts
 * @swedishName Infokort
 */
export class InfoCard {
    constructor() {
        this.afHeading = undefined;
        this.afHeadingLevel = undefined;
        this.afType = InfoCardType.TIP;
        this.afSize = InfoCardSize.STANDARD;
        this.afBorderPosition = InfoCardBorderPosition.TOP;
        this.afVariation = InfoCardVariation.PRIMARY;
        this.afLinkText = undefined;
        this.afLinkHref = undefined;
        this.hideVisitedColor = undefined;
        this.activeLink = false;
        this.afSvgAriaHidden = undefined;
        this.hasListIcon = false;
    }
    // get shouldRenderListIcon() {
    // 	return true
    // }
    setHasListIcon() {
        const List = this.hostElement.querySelector('digi-list');
        if (List) {
            this.hasListIcon = true;
        }
    }
    componentWillLoad() {
        this.validateHeading();
        this.setHasListIcon();
    }
    validateHeading() {
        if (!this.afHeading || !this.afHeadingLevel) {
            logger.warn(`digi-info-card must have a heading and a heading level. Please add af-heading and af-heading-level`, this.hostElement);
        }
    }
    clickLinkHandler(e) {
        this.afOnClickLink.emit(e);
    }
    get shouldRenderInternalLink() {
        return this.afType !== this.afLinkText && this.afLinkHref;
    }
    get cssModifiers() {
        return {
            'digi-info-card--primary': this.afVariation === InfoCardVariation.PRIMARY &&
                this.afType === InfoCardType.TIP,
            'digi-info-card--secondary': this.afVariation === InfoCardVariation.SECONDARY,
            'digi-info-card--tip': this.afType === InfoCardType.TIP,
            'digi-info-card--related': this.afType === InfoCardType.RELATED,
            'digi-info-card--standard': this.afSize === InfoCardSize.STANDARD,
            'digi-info-card--border-top': this.afBorderPosition === InfoCardBorderPosition.TOP &&
                this.afType === InfoCardType.RELATED,
            'digi-info-card--border-left': this.afBorderPosition === InfoCardBorderPosition.LEFT &&
                this.afType === InfoCardType.RELATED,
            'digi-info-card--active-link': this.activeLink === true
        };
    }
    render() {
        return (h("div", { key: 'd329c1893d18b70ddb6e8d3823f8a97f8855b05f', class: Object.assign({ 'digi-info-card': true }, this.cssModifiers) }, h("div", { key: '2477bfc64a4c8042800baf4810a3a18cd7873d95', class: "digi-info-card__content" }, h("div", { key: 'c49f79c689160a902802682a3487c222ea59f530', class: "digi-info-card__icon" }, this.hasListIcon && (h("span", { key: '482ce58bd638ef055f9baacdd2ef9d4cd1f124ae', class: "digi-info-card__icon" }, h("slot", { key: '4f95901bb6f9ddb794f019bf3ee5efb242dcae4b', name: "icon" })))), h(this.afHeadingLevel, { key: '8793659ade0389f010cea838fd75275a5ac6c044', class: "digi-info-card__heading" }, this.afHeading), h("digi-typography", { key: '70d3f1b8a475742d8f679c13422762778922d085' }, h("slot", { key: '032c50f8c0044c7858a5b1f02ae5f9d46fa5da4a' })), this.shouldRenderInternalLink && (h("digi-link-internal", { key: 'a4960ea9eb277d21ab6b90bfe673c671a07f3f7f', class: "digi-info-card__link", afHref: this.afLinkHref, onAfOnClick: (e) => this.clickLinkHandler(e), hideVisitedColor: this.hideVisitedColor }, this.afLinkText)))));
    }
    static get is() { return "digi-info-card"; }
    static get encapsulation() { return "scoped"; }
    static get originalStyleUrls() {
        return {
            "$": ["info-card.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["info-card.css"]
        };
    }
    static get properties() {
        return {
            "afHeading": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "The heading text"
                        }],
                    "text": "Rubrikens text"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-heading",
                "reflect": false
            },
            "afHeadingLevel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "InfoCardHeadingLevel",
                    "resolved": "InfoCardHeadingLevel.H1 | InfoCardHeadingLevel.H2 | InfoCardHeadingLevel.H3 | InfoCardHeadingLevel.H4 | InfoCardHeadingLevel.H5 | InfoCardHeadingLevel.H6",
                    "references": {
                        "InfoCardHeadingLevel": {
                            "location": "import",
                            "path": "./info-card-heading-level.enum",
                            "id": "src/components/_info-card/info-card/info-card-heading-level.enum.ts::InfoCardHeadingLevel"
                        }
                    }
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Set heading level (h1-h6)"
                        }],
                    "text": "S\u00E4tter rubrikens vikt (h1-h6)"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-heading-level",
                "reflect": false
            },
            "afType": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "InfoCardType",
                    "resolved": "InfoCardType.RELATED | InfoCardType.TIP",
                    "references": {
                        "InfoCardType": {
                            "location": "import",
                            "path": "./info-card-type.enum",
                            "id": "src/components/_info-card/info-card/info-card-type.enum.ts::InfoCardType"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Set info card variation. Can be 'tip' or 'related'."
                        }],
                    "text": "S\u00E4tter typ. Kan vara 'tip' or 'related'."
                },
                "getter": false,
                "setter": false,
                "attribute": "af-type",
                "reflect": false,
                "defaultValue": "InfoCardType.TIP"
            },
            "afSize": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "InfoCardSize",
                    "resolved": "InfoCardSize",
                    "references": {
                        "InfoCardSize": {
                            "location": "import",
                            "path": "./info-card-size.enum",
                            "id": "src/components/_info-card/info-card/info-card-size.enum.ts::InfoCardSize"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Set info card size. Can be 'Standard'."
                        }],
                    "text": "S\u00E4tter storlek p\u00E5 kortet. Kan vara 'Standard'."
                },
                "getter": false,
                "setter": false,
                "attribute": "af-size",
                "reflect": false,
                "defaultValue": "InfoCardSize.STANDARD"
            },
            "afBorderPosition": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "InfoCardBorderPosition",
                    "resolved": "InfoCardBorderPosition.LEFT | InfoCardBorderPosition.TOP",
                    "references": {
                        "InfoCardBorderPosition": {
                            "location": "import",
                            "path": "./info-card-border-position.enum",
                            "id": "src/components/_info-card/info-card/info-card-border-position.enum.ts::InfoCardBorderPosition"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Set border position. Can be 'top' or 'left'. This only applies if 'af-type' is 'related'."
                        }],
                    "text": "S\u00E4tter position f\u00F6r kantlinjen. Kan vara 'top' eller 'left'. Detta har endast genomslag om 'af-type' \u00E4r 'related'."
                },
                "getter": false,
                "setter": false,
                "attribute": "af-border-position",
                "reflect": false,
                "defaultValue": "InfoCardBorderPosition.TOP"
            },
            "afVariation": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "InfoCardVariation",
                    "resolved": "InfoCardVariation.PRIMARY | InfoCardVariation.SECONDARY",
                    "references": {
                        "InfoCardVariation": {
                            "location": "import",
                            "path": "./info-card-variation.enum",
                            "id": "src/components/_info-card/info-card/info-card-variation.enum.ts::InfoCardVariation"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Set info card variation. Can be 'primary' or 'secondary'. This only applies if 'af-type' is 'tip'."
                        }],
                    "text": "S\u00E4tter variant. Kan vara 'primary' eller 'secondary'. Detta har endast genomslag om 'af-type' \u00E4r 'tip'."
                },
                "getter": false,
                "setter": false,
                "attribute": "af-variation",
                "reflect": false,
                "defaultValue": "InfoCardVariation.PRIMARY"
            },
            "afLinkText": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Text for optional link (required if afType is set to \"single\")"
                        }],
                    "text": "Text till en valfri l\u00E4nk. NOTERA: L\u00E4nken \u00E4r obligatorisk om 'af-type' \u00E4r 'single'."
                },
                "getter": false,
                "setter": false,
                "attribute": "af-link-text",
                "reflect": false
            },
            "afLinkHref": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Link href attribute"
                        }],
                    "text": "S\u00E4tter attributet 'href' p\u00E5 l\u00E4nken"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-link-href",
                "reflect": false
            },
            "hideVisitedColor": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "If link color should change when visited"
                        }],
                    "text": "Avg\u00F6r om f\u00E4rgen p\u00E5 l\u00E4nken inte ska \u00E4ndras p\u00E5 bes\u00F6kta l\u00E4nkar"
                },
                "getter": false,
                "setter": false,
                "attribute": "hide-visited-color",
                "reflect": false
            },
            "afSvgAriaHidden": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Hides the icon for screen readers."
                        }],
                    "text": "F\u00F6r att d\u00F6lja ikon f\u00F6r sk\u00E4rml\u00E4sare."
                },
                "getter": false,
                "setter": false,
                "attribute": "af-svg-aria-hidden",
                "reflect": false
            }
        };
    }
    static get states() {
        return {
            "activeLink": {},
            "hasListIcon": {}
        };
    }
    static get events() {
        return [{
                "method": "afOnClickLink",
                "name": "afOnClickLink",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Link element's 'onclick' event"
                        }],
                    "text": "L\u00E4nkelementets 'onclick'-event"
                },
                "complexType": {
                    "original": "any",
                    "resolved": "any",
                    "references": {}
                }
            }];
    }
    static get elementRef() { return "hostElement"; }
    static get watchers() {
        return [{
                "propName": "afHeading",
                "methodName": "validateHeading"
            }, {
                "propName": "afHeadingLevel",
                "methodName": "validateHeading"
            }];
    }
}
