import { h, Host } from "@stencil/core";
import { state } from "./pn-find-price-store";
import { sendDirectUrl, stampShopUrl, RealValues } from "./data.js";
import { bolt, box_label, map_marker } from "pn-design-assets/pn-assets/icons.js";
export class PnfindPriceResult {
    constructor() {
        this.item = null;
        this.shownitems = [];
        this.Usp1 = undefined;
        this.Usp2 = undefined;
        this.Usp3 = undefined;
        this.description = [];
        this.showMeasurement = false;
        this.weightText = '';
        this.linkId = '';
        this.shopLabel = '';
        this.shopUrl = '';
        this.shopId = '';
    }
    componentWillLoad() {
        this.composeItems();
    }
    composeItems() {
        if (this.item.additionalusp) {
            var x = this.item.additionalusp.split('/');
            this.Usp1 = x.length > 0 ? x[0] : null;
            this.Usp2 = x.length > 1 ? x[1] : null;
            this.Usp3 = x.length > 2 ? x[2] : null;
        }
        if (this.item.description) {
            this.description = this.item.description.split('#bullet').filter(x => x !== '');
        }
        this.showMeasurement = this.item.maxmått !== null || this.item.rulle !== null;
        this.linkId = `${this.item.id}-${this.item.maxweight}-${this.item.sizecategory}-${this.item.name.toLocaleLowerCase().replace(/[^a-zA-Z0-9]/g, '')}`;
        var showServicepointLink = this.item.ombudpurchase === 'Yes';
        this.shopLabel = showServicepointLink ? state.i18n.ombudHeader : state.i18n.stampshopcta;
        this.shopUrl = showServicepointLink ? state.market.servicePoint : stampShopUrl;
        this.shopId = showServicepointLink ? '-servicepoint' : '-stampshop';
    }
    render() {
        return (h(Host, { key: 'daab6ea6c934d4bfc90a8fcdd607a39d713fe8f3' }, h("pn-product-card", { key: '5452dc32d272a9c3f0507eb68efc8012e8799f1c', "data-productid": this.item.id }, h("pn-illustration", { key: 'eb941278b85c4e82b9195474a20033c6e33fbee6', slot: "illustration", illustration: this.item.illustration }), h("div", { key: 'cd9b46e6ac33625f9ace95703572e8c46eb94768', slot: "title" }, this.item.infopagelink ? (h("h2", null, h("a", { href: this.item.infopagelink, target: "_blank" }, this.item.name))) : (h("h2", null, this.item.name)), this.item.highestrankusp === 'Snabbast' ? (h("pn-titletag", { slot: "Snabbast", icon: bolt, color: "blue700" }, this.item.highestrankusp)) : this.item.highestrankusp === 'Billigast' ? (h("pn-titletag", { slot: "Billigast", icon: box_label, color: "green700" }, this.item.highestrankusp)) : null), h("div", { key: 'cace640fad734be8b40a08dd2f1e993fb1b0a505', slot: "content" }, h("div", { key: '09b7eac2a78ff80446ba97f24395deb18084e8c6', class: "content" }, this.item.description ? (h("div", { class: "description" }, this.description.map(desc => (h("li", null, desc))))) : null, this.item.info ? h("div", { class: "description" }, this.item.info) : null)), this.item.note ? (h("div", { slot: "note" }, h("p", null, this.item.note))) : null, this.item.additionalusp ? (h("div", { slot: "additionalUSP" }, this.Usp1 ? h("span", null, this.Usp1) : null, this.Usp2 ? h("span", null, this.Usp2) : null, this.Usp3 ? h("span", null, this.Usp3) : null)) : null, this.showMeasurement ? h("pn-product-card-info", { paket: this.item.maxmått, rulle: this.item.rulle }) : null, h("div", { key: 'ea20942191ccf5737dbe30f77dd29b1efec2c522', slot: "cardprice" }, this.item.pricesenddirect ? (h("pn-product-card-price", { slot: "sendDirectPrice", label: state.i18n.senddirectcta, amount: this.item.pricesenddirect + '', currency: state.market.currency, url: sendDirectUrl, linkid: this.linkId + '-portal' })) : null, this.item.pricestamps ? (this.item.name.toLocaleLowerCase() !== 'riktiga vykort' ? (h("pn-product-card-price", { slot: "stampPrice", label: this.shopLabel, amount: this.item.pricestamps + '', currency: state.market.currency, url: this.shopUrl, linkid: this.linkId + this.shopId })) : (h("pn-product-card-price", { slot: "riktiga", label: state.i18n.realPostcard, amount: this.item.pricestamps + '', currency: state.market.currency, url: RealValues['WebUrl'], linkid: this.linkId + '-riktiga' }))) : null), h("div", { key: '6ad06720a6744d54e1775e28b8eef3e61f8812e1', slot: "servicepoint" }, this.item.showservicepointlink ? (h("a", { href: state.market.servicePoint, target: "_blank" }, h("pn-icon", { icon: map_marker, color: "blue700" }), state.i18n.servicePointLink)) : null), h("div", { key: '02491eeeb559962192909f1cf5df40f1b688a9ba', slot: "mobiledownload" }, this.item.name.toLocaleLowerCase() === 'riktiga vykort' ? (h("div", { id: "riktiga" }, h("h4", null, state.i18n.realPostcardMobile), h("div", null, h("a", { href: RealValues['AndroidAppUrl'], target: "_blank" }, h("img", { class: "riktigaAndroidImg", src: RealValues['AndroidImg'] })), h("a", { href: RealValues['IosAppUrl'], target: "_blank" }, h("img", { class: "riktigaAppleImg", src: RealValues['IosImg'] }))))) : null))));
    }
    static get is() { return "pn-find-price-result"; }
    static get originalStyleUrls() {
        return {
            "$": ["pn-find-price-result.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["pn-find-price-result.css"]
        };
    }
    static get properties() {
        return {
            "item": {
                "type": "unknown",
                "mutable": true,
                "complexType": {
                    "original": "ProductPriceItem",
                    "resolved": "ProductPriceItem",
                    "references": {
                        "ProductPriceItem": {
                            "location": "import",
                            "path": "./pn-find-price-types",
                            "id": "src/components/widgets/pn-find-price/pn-find-price-types.ts::ProductPriceItem"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "defaultValue": "null"
            },
            "shownitems": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "ProductPriceItem[]",
                    "resolved": "ProductPriceItem[]",
                    "references": {
                        "ProductPriceItem": {
                            "location": "import",
                            "path": "./pn-find-price-types",
                            "id": "src/components/widgets/pn-find-price/pn-find-price-types.ts::ProductPriceItem"
                        }
                    }
                },
                "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"
            }
        };
    }
    static get states() {
        return {
            "weightText": {},
            "linkId": {},
            "shopLabel": {},
            "shopUrl": {},
            "shopId": {}
        };
    }
    static get watchers() {
        return [{
                "propName": "item",
                "methodName": "composeItems"
            }];
    }
}
//# sourceMappingURL=pn-find-price-result.js.map
