'use strict';

var index = require('./index-pX0sBY0-.js');
var domUtils = require('./dom-utils-BdvOgC2b.js');
var tracking = require('./tracking-BPjaTlNR.js');

const cardCss = () => `:host{display:inline-flex}.card{position:relative;display:inline-flex;flex-direction:column;word-wrap:break-word;background-color:#FFFFFF;background-clip:border-box;border:2px solid #EEEDED;border-radius:2px;width:350px;height:auto;font-family:var(--ifx-font-family)}.card:has(.card-href:focus),.card:has(.card-href:hover){outline:none;border-color:#0A8276}.card:has(.card-href:focus) ::slotted(ifx-card-headline),.card:has(.card-href:hover) ::slotted(ifx-card-headline){color:#0A8276}.card.noBtns .vertical .lower__body-wrapper{padding-bottom:24px}.card.noBtns .horizontal .lower__body-wrapper{padding-bottom:24px}.card .horizontal{display:flex;flex-direction:row;min-height:218px}.card .horizontal .card-img{flex:1;text-decoration:none}.card .horizontal .card-img.noImage{display:none}.card .horizontal .card-img ::slotted([slot=img]){width:100%;vertical-align:bottom}.card .horizontal .lower__body-wrapper{flex:1;display:grid;grid-template-rows:1fr auto}.card .horizontal .lower__body-wrapper .upper-body{display:flex;flex-direction:column;text-decoration:none;color:#1D1D1D;padding:24px 24px 0px 24px}.card .vertical .upper__body-wrapper{text-decoration:none;color:#1D1D1D}.card .vertical .upper__body-wrapper .card-img{height:190px}.card .vertical .upper__body-wrapper .card-img.noImage{display:none}.card .vertical .upper__body-wrapper .upper-body{padding:24px 24px 0px 24px}.card .vertical .lower__body-wrapper:hover{border-color:#EEEDED}.card.horizontal{flex-direction:row;width:538px}.card.horizontal .card-img{flex:1;order:2}.card.horizontal .card-img ::slotted([slot=img]){width:100%;height:100%;vertical-align:bottom;object-fit:cover}.card.horizontal.left .horizontal .card-img{order:1}.card.horizontal.left .horizontal .lower__body-wrapper{order:2}.card .card-href:focus{outline:none}`;

const Card = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
    }
    get el() { return index.getElement(this); }
    noBtns;
    /** Layout direction of the card. */
    direction = "vertical";
    alignment;
    noImg;
    /** Link the card should navigate to when clicked. */
    href = "";
    internalHref = "";
    /** Where to open the link. */
    target = "_self";
    /** Accessible label for screen readers. */
    ariaLabelText;
    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 (!domUtils.isNestedInIfxComponent(this.el)) {
            const framework = tracking.detectFramework();
            tracking.trackComponent("ifx-card", await framework);
        }
    }
    componentWillUpdate() {
        this.handleComponentAdjustment();
    }
    render() {
        return (index.h(index.Host, { key: '287c7825bc85bd912363bf8fbba1943a5921b8da' }, index.h("div", { key: '8b201581f1f8c22454a06db017fe391cf15584f9', "aria-label": this.ariaLabelText, class: `card 
            ${this.noBtns ? "noBtns" : ""}
            ${this.direction} 
            ${this.alignment}`, role: "group" }, this.direction === "horizontal" && (index.h("div", { key: '0ce06ed6a84d25a6b5e66730c293a165b6b98471', class: "horizontal" }, index.h("a", { key: '87467383fe396ed66036d2531c7a6b261d64d683', class: `card-img ${this.noImg ? "noImage" : ""} ${this.internalHref ? "card-href" : ""}`, href: this.internalHref }, index.h("slot", { key: '20bf5ddce543ff6c6bd45f81275c3f1d1b972b83', name: "img" })), index.h("div", { key: 'ae70b486866c39597b5b1f29113a99074e5cec3e', class: "lower__body-wrapper" }, index.h("a", { key: '591ad844101c4761df16747ff9517caa3dd5cffc', class: `upper-body ${this.internalHref ? "card-href" : ""}`, href: this.internalHref, id: "upper-body-content" }, index.h("slot", { key: '877a3ae9e1e552fcd6df50e3a92c22a7fcafd016' })), index.h("div", { key: '7d0f7fc0c56e5a72e1b5d7d172d3a43f38fbe291' }, index.h("slot", { key: 'ade3b9567218a92bf48de6d5a1e7bf164f637949', name: "buttons" }))))), this.direction === "vertical" && (index.h("div", { key: 'ac76ceee673d8037e7d3134cfe03c60dd11df876', class: "vertical" }, index.h("a", { key: '8eb41549bcf01963df0593a949808f28ec7c46ef', class: `upper__body-wrapper ${this.internalHref ? "card-href" : ""}`, href: this.internalHref, target: this.target }, index.h("div", { key: 'dbf65b6919d28a900d2e43dac93b1875cc0fa89b', class: `card-img ${this.noImg ? "noImage" : ""}` }, index.h("slot", { key: '1732763e7c36478ebbda74919dc75ad05c052a7a', name: "img" })), index.h("div", { key: '13ae88e5f45b2ecbde57f03a63e6a760851c4eca', class: "upper-body", id: "upper-body-content" }, index.h("slot", { key: 'e7fb8ee2a6f6871572fa14b5a993060ace5f0569' }))), index.h("div", { key: '07f3c65b714d1dcd70990df94216fd390c7fea6e', class: "lower__body-wrapper", role: "group", "aria-labelledby": "upper-body-content" }, index.h("slot", { key: '69a7e7953158799d39ac17dc39c77b7efe9e89a1', name: "buttons" })))))));
    }
};
Card.style = cardCss();

exports.ifx_card = Card;
