'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-9a9efa1c.js');
const translations = require('./translations-67ac592a.js');

const pnProxioFindpriceResultCss = "pn-button-dropdown .pn-button-dropdown>pn-button>.pn-button{min-height:initial}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}@media screen and (max-width: 767px){.sr-only-mobile{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}}pn-proxio-findprice-result [slot=insurance]{display:flex;justify-content:center}pn-proxio-findprice-result .insurance-box{padding:0.4rem 0.8rem;border-radius:0.8rem;background-color:#8eddf9;text-align:center;font-size:1.2rem;font-weight:400;margin-bottom:2.4rem}";
const PnProxioFindpriceResultStyle0 = pnProxioFindpriceResultCss;

const PnProxioFindPriceResult = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.item = null;
        this.activeweight = null;
        this.shownitems = [];
        this.Usp1 = undefined;
        this.Usp2 = undefined;
        this.Usp3 = undefined;
        this.description = [];
        this.showMeasurement = false;
        this.showInternational = false;
        this.selectedCountrycode = '';
        this.market = '';
        this.language = 'sv';
        this.weightText = '';
        this.linkId = '';
        this.shopLabel = '';
        this.shopUrl = '';
        this.shopId = '';
        this.i18n = translations.translations[this.language];
    }
    componentWillLoad() {
        this.composeItems();
    }
    composeItems() {
        this.shownitems = [this.item];
    }
    getPriceString(product) {
        if (!product.productWeightGroupList) {
            return null;
        }
        const activeIndex = product.productWeightGroupList.findIndex(item => item.item1 === this.activeweight);
        let price = '';
        if (this.showInternational && this.selectedCountrycode && this.selectedCountrycode !== this.market && product.weightPriceCountryList) {
            let weightPriceCountryList = product.weightPriceCountryList.filter(item => item.item3.includes(this.selectedCountrycode.toUpperCase()));
            price = weightPriceCountryList ? weightPriceCountryList[activeIndex]?.item2 : '';
        }
        else {
            price = product.weightAndPriceList ? product?.weightAndPriceList[activeIndex]?.item2 : '';
        }
        return price ? this.i18n.from + price : '';
    }
    getProductLink(product, productWeightGroupList) {
        if (product.productWeightGroupList) {
            const activeIndex = product.productWeightGroupList.findIndex(item => item.item1 === this.activeweight);
            let productId = productWeightGroupList[activeIndex]?.item2;
            let productLink = product.productLink ? product?.productLink : '';
            return productLink ? productLink + (productId ? '?productId=' + productId : '') : '';
        }
        return null;
    }
    getDeliveryInformation(product) {
        if (!this.showInternational || !product.deliveryDateInternationalInformation) {
            return product.deliveryDateInformation;
        }
        const internationalShipment = product?.deliveryDateInternationalInformation?.find(info => info.item1.toLowerCase() === this.selectedCountrycode.toLowerCase());
        if (!internationalShipment?.item2 ?? true) {
            return product.deliveryDateInformation;
        }
        return internationalShipment.item2;
    }
    getInsuranceAmountText(product) {
        if (!product.insuranceAmounts) {
            return '';
        }
        const insuranceAmount = product?.insuranceAmounts?.find(info => info.item1.toLowerCase() === this.selectedCountrycode.toLowerCase());
        if (!insuranceAmount?.item2 ?? true) {
            return '';
        }
        return insuranceAmount.item2;
    }
    render() {
        return (index.h(index.Host, { key: 'ecd438774b07439e46b54ceef9b5765f0801528a' }, index.h("pn-proxio-productcard", { key: '35f51eeaca5e22ee97ce2c83b7d37db8a9595f5c' }, index.h("pn-illustration", { key: 'd9956a7b33ae8cf193b8e5f034b792481b5ec091', slot: "illustrationmobile", illustration: this.item.proxioProduct.productIcon }), index.h("h2", { key: 'dacb125fff58d8066b29d15087b3ad5857728bfb', slot: "title" }, this.item.proxioProduct.productTitle), index.h("pn-proxio-productcard-description", { key: 'f1bcebaa5353e0ab96654deb2e4471f8acbebad3', slot: "description", heading: this.item.proxioProduct.productPreamble, highlight: this.getDeliveryInformation(this.item.proxioProduct), list: this.item.proxioProduct.productDescriptionBulletListItems }), index.h("div", { key: 'cb3473832eb427806a066c895bd01336b815323c', slot: "information" }, index.h("pn-proxio-productcard-information", { key: '90f04ce244474d1246135f004a617bd7ff810084', label: this.i18n.labelMaxDimensions, information: this.item.proxioProduct.productPackageDimensionsList }), index.h("pn-proxio-productcard-information", { key: '4713fe074123aea99f6e970b91c286bbce41090a', label: this.i18n.labelMaxDimensionsRoll, information: this.item.proxioProduct.productRollDimensionsList })), index.h("div", { key: 'd3525b420a5d91e2866ecf931b2727a3d243414c', slot: "bottomtags" }, this.item.proxioProduct.usp1 ? index.h("pn-titletag", { color: "gray50" }, this.item.proxioProduct.usp1) : null, this.item.proxioProduct.usp2 ? index.h("pn-titletag", { color: "gray50" }, this.item.proxioProduct.usp2) : null, this.item.proxioProduct.usp3 ? index.h("pn-titletag", { color: "gray50" }, this.item.proxioProduct.usp3) : null), index.h("pn-illustration", { key: 'b6c623b3a0b0c9d4db5a825c974d055d06863322', slot: "illustration", illustration: this.item.proxioProduct.productIcon }), index.h("div", { key: '54687cb5e735ebfb3490c031273e7ff73fc42af6', slot: "pricelink" }, index.h("pn-proxio-productcard-pricelink", { key: 'e3b487d402199c3b72ad64f3a820e27a44d153e6', price: this.getPriceString(this.item.proxioProduct), link: this.getProductLink(this.item.proxioProduct, this.item.proxioProduct.productWeightGroupList), linktext: this.item.proxioProduct.productLinkText }), this.item.relatedProxioProducts
            ? this.item.relatedProxioProducts.map(product => (index.h("pn-proxio-productcard-pricelink", { price: this.getPriceString(product), link: product.productLink, linktext: product.productLinkText })))
            : null), this.getInsuranceAmountText(this.item.proxioProduct) ? (index.h("div", { slot: "insurance" }, index.h("div", { class: "insurance-box" }, this.getInsuranceAmountText(this.item.proxioProduct)))) : null)));
    }
    static get watchers() { return {
        "item": ["composeItems"],
        "activeweight": ["getPriceString", "getProductLink"]
    }; }
};
PnProxioFindPriceResult.style = PnProxioFindpriceResultStyle0;

exports.pn_proxio_findprice_result = PnProxioFindPriceResult;

//# sourceMappingURL=pn-proxio-findprice-result.cjs.entry.js.map