import { h, Host } from "@stencil/core";
import { state } from "./pn-find-service-and-price-store";
export class PnfindServiceAndPriceResult {
    constructor() {
        this.item = null;
        this.shownitems = [];
        this.weightText = '';
    }
    componentWillLoad() {
        this.composeItems();
    }
    composeItems() {
        this.shownitems = [this.item];
        // this.shownitems = [];
        // if (this.item.pricestamps) {
        //   this.shownitems.push({...this.item, priceagent: null, pricesenddirect: null});
        // }
        // if (this.item.priceagent) {
        //   this.shownitems.push({...this.item, pricestamps: null, pricesenddirect: null});
        // }
        // if (this.item.pricesenddirect) {
        //   this.shownitems.push({...this.item, pricestamps: null, priceagent: null});
        // }
        // Parcels are always in KG. Letter KG must be converted from grams
        // this.weightText = (this.item.what === "parcel") ? this.item.maxweight + 'kg' :
        // (this.item.what === "letter" && this.item.maxweight > 999) ? Math.round(this.item.maxweight/1000) + " kg" : this.item.maxweight + " g";
    }
    render() {
        return (h(Host, { key: 'bf4e52c4adcba72ffeb9063b1fd30dafe6fa39eb' }, this.shownitems.map(item => (h("pn-product-card", null, h("pn-illustration", { slot: "illustration", illustration: item.illustration }), h("div", { slot: "content" }, h("div", { class: "content" }, h("h3", null, item.name), item.description ? h("div", { class: "description" }, item.description) : null, item.info ? h("div", { class: "description" }, item.info) : null)), item.maxweight ? h("pn-product-tile-info", { label: state.i18n.maxweightlabel, text: this.weightText }) : null, item.pricestamps ? (h("pn-product-tile-price", { slot: "price", label: state.i18n.stampshopcta, amount: item.pricestamps + '', currency: state.market.currency })) : null, item.pricesenddirect ? (h("pn-product-tile-price", { slot: "price", label: state.i18n.senddirectcta, amount: item.pricesenddirect + '', currency: state.market.currency, url: "https://portal.postnord.com/skickadirekt/" })) : null, item.note ? (h("small", { slot: "note" }, h("p", null, item.note))) : null)))));
    }
    static get is() { return "pn-find-service-and-price-result"; }
    static get originalStyleUrls() {
        return {
            "$": ["pn-find-service-and-price-result.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["pn-find-service-and-price-result.css"]
        };
    }
    static get properties() {
        return {
            "item": {
                "type": "unknown",
                "mutable": true,
                "complexType": {
                    "original": "ProductPriceItem",
                    "resolved": "ProductPriceItem",
                    "references": {
                        "ProductPriceItem": {
                            "location": "import",
                            "path": "../../../globals/shared/productprice/product-price-types",
                            "id": "src/globals/shared/productprice/product-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": "../../../globals/shared/productprice/product-price-types",
                            "id": "src/globals/shared/productprice/product-price-types.ts::ProductPriceItem"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "defaultValue": "[]"
            }
        };
    }
    static get states() {
        return {
            "weightText": {}
        };
    }
    static get watchers() {
        return [{
                "propName": "item",
                "methodName": "composeItems"
            }];
    }
}
//# sourceMappingURL=pn-find-service-and-price-result.js.map
