import { Host, h, } from "@stencil/core";
import { isNestedInIfxComponent } from "../..//shared/utils/dom-utils";
import { detectFramework } from "../..//shared/utils/framework-detection";
import { trackComponent } from "../../shared/utils/tracking";
export class Card {
    el;
    noBtns;
    direction = "vertical";
    alignment;
    noImg;
    href = "";
    internalHref = "";
    target = "_self";
    ariaLabel;
    setImgPosition(event) {
        this.alignment = event.detail;
    }
    handleComponentAdjustment() {
        const image = this.el.querySelector("ifx-card-image");
        const links = this.el.querySelector("ifx-card-links");
        this.noImg = !image;
        this.noBtns = !links;
        if (this.href.trim() === "") {
            this.internalHref = undefined;
        }
        else {
            this.internalHref = this.href;
        }
    }
    componentWillLoad() {
        this.handleComponentAdjustment();
    }
    async componentDidLoad() {
        if (!isNestedInIfxComponent(this.el)) {
            const framework = detectFramework();
            trackComponent("ifx-card", await framework);
        }
    }
    componentWillUpdate() {
        this.handleComponentAdjustment();
    }
    render() {
        return (h(Host, { key: 'bc39e464f1baae707bbcf1f0c5bf46a6736850d8' }, h("div", { key: '815797671f34136bad1720c80ca5b1fc34614a8b', "aria-label": this.ariaLabel, class: `card 
            ${this.noBtns ? "noBtns" : ""}
            ${this.direction} 
            ${this.alignment}`, role: "group" }, this.direction === "horizontal" && (h("div", { key: '29cb5772e0d455f9d44d91f203dde50f2b1f104f', class: "horizontal" }, h("a", { key: 'a0e62ce5e0ea6fb78219b69a458aad0bb4f788da', class: `card-img ${this.noImg ? "noImage" : ""} ${this.internalHref ? "card-href" : ""}`, href: this.internalHref }, h("slot", { key: '900b7277c8b35b8e30592a61c607520b8fa6d923', name: "img" })), h("div", { key: 'b91cb7a606b7bdab6ce41a3beb664e747bc23209', class: "lower__body-wrapper" }, h("a", { key: '920ae268da088aa2d19c8f5f37e88b3778e4b049', class: `upper-body ${this.internalHref ? "card-href" : ""}`, href: this.internalHref, id: "upper-body-content" }, h("slot", { key: '4b289a4a0b1eb1ba1d5f35c92dd3ca6c88301428' })), h("div", { key: '472517824772b6b0ffb0dfebcd2e97ff9c5a142a' }, h("slot", { key: 'f2e36bf7eaad6d9f94a9bcba6c65513aff1b26d9', name: "buttons" }))))), this.direction === "vertical" && (h("div", { key: '81afdc1c3e381668127d51401265254fcefa4d46', class: "vertical" }, h("a", { key: '876869226dd985f89603d723ea029c84bb5d7a62', class: `upper__body-wrapper ${this.internalHref ? "card-href" : ""}`, href: this.internalHref, target: this.target }, h("div", { key: 'bbe2947a3e960a5908e7f4dc0a375f35758b3535', class: `card-img ${this.noImg ? "noImage" : ""}` }, h("slot", { key: '1ebb22404fb5278a2d6bc047b9b6a20134591141', name: "img" })), h("div", { key: '54c23f72393d5a955c28baf7786b453504aa53f4', class: "upper-body", id: "upper-body-content" }, h("slot", { key: '6fb57a25333757fd915c0b2857af67356fcbe02f' }))), h("div", { key: 'c1aa5dcd8bae39230e0cc489a95dbb01213ec60e', class: "lower__body-wrapper", role: "group", "aria-labelledby": "upper-body-content" }, h("slot", { key: '7edeeb55da6d87f0fc4d02fec8b2842c13b96562', name: "buttons" })))))));
    }
    static get is() { return "ifx-card"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["card.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["card.css"]
        };
    }
    static get properties() {
        return {
            "direction": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "\"horizontal\" | \"vertical\"",
                    "resolved": "\"horizontal\" | \"vertical\"",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "direction",
                "defaultValue": "\"vertical\""
            },
            "href": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "href",
                "defaultValue": "\"\""
            },
            "target": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "target",
                "defaultValue": "\"_self\""
            },
            "ariaLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string | null",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "aria-label"
            }
        };
    }
    static get states() {
        return {
            "noBtns": {},
            "alignment": {},
            "noImg": {},
            "internalHref": {}
        };
    }
    static get elementRef() { return "el"; }
    static get listeners() {
        return [{
                "name": "imgPosition",
                "method": "setImgPosition",
                "target": undefined,
                "capture": false,
                "passive": false
            }];
    }
}
//# sourceMappingURL=card.js.map
