import { h, Host } from "@stencil/core";
import { translations } from "../pn-proxio-pricegroup/translations";
export class PnProxioFindPriceResult {
    constructor() {
        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[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 (h(Host, { key: 'ecd438774b07439e46b54ceef9b5765f0801528a' }, h("pn-proxio-productcard", { key: '35f51eeaca5e22ee97ce2c83b7d37db8a9595f5c' }, h("pn-illustration", { key: 'd9956a7b33ae8cf193b8e5f034b792481b5ec091', slot: "illustrationmobile", illustration: this.item.proxioProduct.productIcon }), h("h2", { key: 'dacb125fff58d8066b29d15087b3ad5857728bfb', slot: "title" }, this.item.proxioProduct.productTitle), 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 }), h("div", { key: 'cb3473832eb427806a066c895bd01336b815323c', slot: "information" }, h("pn-proxio-productcard-information", { key: '90f04ce244474d1246135f004a617bd7ff810084', label: this.i18n.labelMaxDimensions, information: this.item.proxioProduct.productPackageDimensionsList }), h("pn-proxio-productcard-information", { key: '4713fe074123aea99f6e970b91c286bbce41090a', label: this.i18n.labelMaxDimensionsRoll, information: this.item.proxioProduct.productRollDimensionsList })), h("div", { key: 'd3525b420a5d91e2866ecf931b2727a3d243414c', slot: "bottomtags" }, this.item.proxioProduct.usp1 ? h("pn-titletag", { color: "gray50" }, this.item.proxioProduct.usp1) : null, this.item.proxioProduct.usp2 ? h("pn-titletag", { color: "gray50" }, this.item.proxioProduct.usp2) : null, this.item.proxioProduct.usp3 ? h("pn-titletag", { color: "gray50" }, this.item.proxioProduct.usp3) : null), h("pn-illustration", { key: 'b6c623b3a0b0c9d4db5a825c974d055d06863322', slot: "illustration", illustration: this.item.proxioProduct.productIcon }), h("div", { key: '54687cb5e735ebfb3490c031273e7ff73fc42af6', slot: "pricelink" }, 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 => (h("pn-proxio-productcard-pricelink", { price: this.getPriceString(product), link: product.productLink, linktext: product.productLinkText })))
            : null), this.getInsuranceAmountText(this.item.proxioProduct) ? (h("div", { slot: "insurance" }, h("div", { class: "insurance-box" }, this.getInsuranceAmountText(this.item.proxioProduct)))) : null)));
    }
    static get is() { return "pn-proxio-findprice-result"; }
    static get originalStyleUrls() {
        return {
            "$": ["pn-proxio-findprice-result.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["pn-proxio-findprice-result.css"]
        };
    }
    static get properties() {
        return {
            "item": {
                "type": "unknown",
                "mutable": true,
                "complexType": {
                    "original": "ProxioPriceListGroupResponse",
                    "resolved": "ProxioPriceListGroupResponse",
                    "references": {
                        "ProxioPriceListGroupResponse": {
                            "location": "import",
                            "path": "../pn-proxio-pricegroup/types",
                            "id": "src/components/widgets/pn-proxio-pricegroup/types.ts::ProxioPriceListGroupResponse"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "defaultValue": "null"
            },
            "activeweight": {
                "type": "number",
                "mutable": true,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "activeweight",
                "reflect": false,
                "defaultValue": "null"
            },
            "shownitems": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "ProxioPriceListGroupResponse[]",
                    "resolved": "ProxioPriceListGroupResponse[]",
                    "references": {
                        "ProxioPriceListGroupResponse": {
                            "location": "import",
                            "path": "../pn-proxio-pricegroup/types",
                            "id": "src/components/widgets/pn-proxio-pricegroup/types.ts::ProxioPriceListGroupResponse"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "defaultValue": "[]"
            },
            "Usp1": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "usp-1",
                "reflect": false
            },
            "Usp2": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "usp-2",
                "reflect": false
            },
            "Usp3": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "usp-3",
                "reflect": false
            },
            "description": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "string[]",
                    "resolved": "string[]",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "defaultValue": "[]"
            },
            "showMeasurement": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "show-measurement",
                "reflect": false,
                "defaultValue": "false"
            },
            "showInternational": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "show-international",
                "reflect": false,
                "defaultValue": "false"
            },
            "selectedCountrycode": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "selected-countrycode",
                "reflect": false,
                "defaultValue": "''"
            },
            "market": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "market",
                "reflect": false,
                "defaultValue": "''"
            },
            "language": {
                "type": "string",
                "mutable": true,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "language",
                "reflect": false,
                "defaultValue": "'sv'"
            }
        };
    }
    static get states() {
        return {
            "weightText": {},
            "linkId": {},
            "shopLabel": {},
            "shopUrl": {},
            "shopId": {},
            "i18n": {}
        };
    }
    static get watchers() {
        return [{
                "propName": "item",
                "methodName": "composeItems"
            }, {
                "propName": "activeweight",
                "methodName": "getPriceString"
            }, {
                "propName": "activeweight",
                "methodName": "getProductLink"
            }];
    }
}
//# sourceMappingURL=pn-proxio-findprice-result.js.map
