/*!
 * Crafted with ❤ by Salla
 */
import { h } from "@stencil/core";
import { closeModals } from "./functions";
export class SallaRewardAction {
    constructor() {
        this.isShopNow = (prize) => {
            if (!(salla.config.get('store.features') || []).includes('loyalty-system-v2')) {
                return false;
            }
            return prize.key?.toLowerCase() === 'free_product';
        };
        this.handleClick = (e) => {
            if (salla.config.isGuest()) {
                closeModals(() => salla.event.dispatch('login::open'));
                return;
            }
            this.actionClick.emit(e);
        };
    }
    render() {
        return (h("div", { key: '0d02cecaae79cf166555514890fbf6192e1cd438', class: "s-loyalty-program-rewards-modal-action" }, this.isShopNow(this.prize) ? (h("a", { href: this.prize.prize_url || salla.url.get(''), class: {
                's-loyalty-program-rewards-action-base': true,
                's-loyalty-program-rewards-action-on': true,
            } }, salla.lang.get('pages.loyalty_program.shop_now'))) : (h("button", { onClick: this.handleClick, class: {
                's-loyalty-program-rewards-action-base': true,
                's-loyalty-program-rewards-action-on': true,
            } }, salla.lang.get('pages.loyalty_program.redeem_reward')))));
    }
    static get is() { return "salla-reward-action"; }
    static get originalStyleUrls() {
        return {
            "$": ["salla-loyalty-program.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["salla-loyalty-program.css"]
        };
    }
    static get properties() {
        return {
            "prize": {
                "type": "unknown",
                "attribute": "prize",
                "mutable": false,
                "complexType": {
                    "original": "Prize",
                    "resolved": "Prize",
                    "references": {
                        "Prize": {
                            "location": "import",
                            "path": "./interfaces",
                            "id": "src/components/salla-loyalty-program/interfaces.ts::Prize"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false
            }
        };
    }
    static get events() {
        return [{
                "method": "actionClick",
                "name": "actionClick",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "MouseEvent",
                    "resolved": "MouseEvent",
                    "references": {
                        "MouseEvent": {
                            "location": "global",
                            "id": "global::MouseEvent"
                        }
                    }
                }
            }];
    }
}
