import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
import { c as createStore } from './index4.js';
import { b as bolt, a as box_label } from './box_label.js';
import { d as defineCustomElement$4 } from './pn-product-card2.js';
import { d as defineCustomElement$3 } from './pn-product-card-info2.js';
import { d as defineCustomElement$2 } from './pn-product-card-price2.js';
import { d as defineCustomElement$1 } from './pn-titletag2.js';

const icon = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M12 2a8 8 0 0 0-6.857 12.124l.014.022 4.454 6.586a2.884 2.884 0 0 0 4.778 0l4.454-6.586.014-.022A8 8 0 0 0 12 2m-6 8a6 6 0 1 1 11.156 3.07l-4.424 6.541a.883.883 0 0 1-1.464 0L6.844 13.07A5.97 5.97 0 0 1 6 10m6-2.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5" clip-rule="evenodd"/></svg>';
const map_marker = icon;

const sizeCategories = [
  { name: 'Small', value: 'Small', illustration: 'eli1n', unit: 'small' },
  { name: 'Medium', value: 'Medium', illustration: 'medium-package', unit: 'medium' },
  { name: 'Large', value: 'Large', illustration: 'large-package', unit: 'large' },
];

const weights = {
  small: [
    { name: '50 g', abbreviation: 'g', value: 50 },
    { name: '100 g', abbreviation: 'g', value: 100 },
    { name: '250 g', abbreviation: 'g', value: 250 },
    { name: '500 g', abbreviation: 'g', value: 500 },
    { name: '1 kg', abbreviation: 'kg', value: 1 },
    { name: '2 kg', abbreviation: 'kg', value: 2 },
  ],
  medium: [
    { name: '1 kg', abbreviation: 'kg', value: 1 },
    { name: '2 kg', abbreviation: 'kg', value: 2 },
    { name: '3 kg', abbreviation: 'kg', value: 3 },
    { name: '5 kg', abbreviation: 'kg', value: 5 },
    { name: '10 kg', abbreviation: 'kg', value: 10 },
    { name: '15 kg', abbreviation: 'kg', value: 15 },
    { name: '20 kg', abbreviation: 'kg', value: 20 },
  ],
  large: [
    { name: '3 kg', abbreviation: 'kg', value: 3 },
    { name: '5 kg', abbreviation: 'kg', value: 5 },
    { name: '10 kg', abbreviation: 'kg', value: 10 },
    { name: '15 kg', abbreviation: 'kg', value: 15 },
    { name: '20 kg', abbreviation: 'kg', value: 20 },
  ],
};

const RealValues = {
  WebUrl: 'https://riktigavykort.postnord.se/sv',
  AndroidAppUrl: 'https://play.google.com/store/apps/details?id=se.posten.riktigavykort&hl=sv',
  AndroidImg: 'https://com-inte.postnord.com/globalassets/icons/logos-and-badges/google-play-badge_se.svg',
  IosAppUrl: 'https://apps.apple.com/se/app/riktiga-vykort/id444458799?l=sv',
  IosImg: 'https://com-inte.postnord.com/globalassets/icons/logos-and-badges/app_store_badge_se_rgb_blk.svg',
};

const fileLocation = 'https://com-inte.postnord.com/globalassets/global/prices/sv-findprice-1-PN.xlsx';

const sendDirectUrl = 'https://portal.postnord.com/skickadirekt/';

const stampShopUrl = 'https://shop.postnord.se/ebutik/default.aspx';

// Read more about how stencil stores work here: https://stenciljs.com/docs/stencil-store
const { state, onChange } = createStore({
    i18n: {
        componentheading: '',
        deliveryscopeheading: '',
        resultlistheading: '',
        sizeheading: '',
        weightheading: '',
        weightlabel: '',
        maxweightlabel: '',
        maxmeasurementlabel: '',
        senddirectcta: '',
        stampshopcta: '',
        message: '',
        servicePointHeader: '',
        servicePointLink: '',
        realPostcard: '',
        realPostcardMobile: '',
        ombudHeader: '',
    },
    market: {
        currency: '',
        country: '',
        servicePoint: '',
    },
});

const pnFindPriceResultCss = "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-find-price-result .test{margin:3em 0}.resultcontent{display:flex;justify-content:center;flex-grow:1}";
const PnFindPriceResultStyle0 = pnFindPriceResultCss;

const PnfindPriceResult = /*@__PURE__*/ proxyCustomElement(class PnfindPriceResult extends HTMLElement {
    constructor() {
        super();
        this.__registerHost();
        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 watchers() { return {
        "item": ["composeItems"]
    }; }
    static get style() { return PnFindPriceResultStyle0; }
}, [0, "pn-find-price-result", {
        "item": [1040],
        "shownitems": [16],
        "Usp1": [1, "usp-1"],
        "Usp2": [1, "usp-2"],
        "Usp3": [1, "usp-3"],
        "description": [16],
        "showMeasurement": [4, "show-measurement"],
        "weightText": [32],
        "linkId": [32],
        "shopLabel": [32],
        "shopUrl": [32],
        "shopId": [32]
    }, undefined, {
        "item": ["composeItems"]
    }]);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["pn-find-price-result", "pn-product-card", "pn-product-card-info", "pn-product-card-price", "pn-titletag"];
    components.forEach(tagName => { switch (tagName) {
        case "pn-find-price-result":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, PnfindPriceResult);
            }
            break;
        case "pn-product-card":
            if (!customElements.get(tagName)) {
                defineCustomElement$4();
            }
            break;
        case "pn-product-card-info":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "pn-product-card-price":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
        case "pn-titletag":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}

export { PnfindPriceResult as P, state as a, defineCustomElement as d, fileLocation as f, sizeCategories as s, weights as w };

//# sourceMappingURL=pn-find-price-result2.js.map