import { __decorate, __metadata } from "tslib";
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Product } from '../shared/product';
import { CONTACT_SALES } from '../pricing/pricing';
import { Addon } from '@vendasta/core/shared';
let VaProductDetailsComponent = class VaProductDetailsComponent {
    constructor() {
        this.hasVerifiedContract = false;
        this.canAccessContractPricing = false;
        this.showActionButton = false;
        this.showPricing = false;
        this.pricingLabel = 'Wholesale Price';
        this.showPricingAction = false;
        this.loaded = true;
        this.enableClicked = new EventEmitter();
        this.addonSelected = new EventEmitter();
        this.primaryPricingActionSelected = new EventEmitter();
        this.pricingActionSelected = new EventEmitter();
    }
    getAddons() {
        if (!this._addons) {
            this._addons = this.product.addons.map((addon) => Addon.fromApi(addon));
        }
        return this._addons;
    }
    getActionLabel() {
        if (this.product.isArchived) {
            return 'Enable';
        }
        return 'Enabled';
    }
    get price() {
        // NOTE: wholesalePrice = 0 means free, wholesalePrice = null || -1 means "contact sales"
        let prices = [];
        if (this.product.wholesalePrice !== CONTACT_SALES && this.product.wholesalePrice != null) {
            prices = [{
                    price: this.product.wholesalePrice,
                    frequency: this.product.billingFrequency
                }];
        }
        return {
            currency: this.product.currency,
            prices: prices
        };
    }
    onAddonSelected(addonId) {
        this.addonSelected.emit(addonId);
    }
};
__decorate([
    Input(),
    __metadata("design:type", Product)
], VaProductDetailsComponent.prototype, "product", void 0);
__decorate([
    Input(),
    __metadata("design:type", Object)
], VaProductDetailsComponent.prototype, "billedProduct", void 0);
__decorate([
    Input(),
    __metadata("design:type", Object)
], VaProductDetailsComponent.prototype, "hasVerifiedContract", void 0);
__decorate([
    Input(),
    __metadata("design:type", Object)
], VaProductDetailsComponent.prototype, "canAccessContractPricing", void 0);
__decorate([
    Input(),
    __metadata("design:type", Object)
], VaProductDetailsComponent.prototype, "showActionButton", void 0);
__decorate([
    Input(),
    __metadata("design:type", Object)
], VaProductDetailsComponent.prototype, "showPricing", void 0);
__decorate([
    Input(),
    __metadata("design:type", Object)
], VaProductDetailsComponent.prototype, "pricingLabel", void 0);
__decorate([
    Input(),
    __metadata("design:type", String)
], VaProductDetailsComponent.prototype, "primaryPricingActionLabel", void 0);
__decorate([
    Input(),
    __metadata("design:type", String)
], VaProductDetailsComponent.prototype, "pricingActionLabel", void 0);
__decorate([
    Input(),
    __metadata("design:type", Object)
], VaProductDetailsComponent.prototype, "showPricingAction", void 0);
__decorate([
    Input(),
    __metadata("design:type", Object)
], VaProductDetailsComponent.prototype, "loaded", void 0);
__decorate([
    Input(),
    __metadata("design:type", String)
], VaProductDetailsComponent.prototype, "partnerID", void 0);
__decorate([
    Output(),
    __metadata("design:type", Object)
], VaProductDetailsComponent.prototype, "enableClicked", void 0);
__decorate([
    Output(),
    __metadata("design:type", Object)
], VaProductDetailsComponent.prototype, "addonSelected", void 0);
__decorate([
    Output(),
    __metadata("design:type", Object)
], VaProductDetailsComponent.prototype, "primaryPricingActionSelected", void 0);
__decorate([
    Output(),
    __metadata("design:type", Object)
], VaProductDetailsComponent.prototype, "pricingActionSelected", void 0);
VaProductDetailsComponent = __decorate([
    Component({
        selector: 'va-product-details',
        template: "<div class=\"page\">\n    <va-header-container [iconUrl]=\"product.iconUrl\"\n                         [title]=\"product.name\"\n                         [tagline]=\"product.tagline\"\n                         [chipLabels]=\"product.getLmiCategoryNames()\"\n                         [pricing]=\"price\"\n                         [pricingLabel]=\"pricingLabel\"\n                         [primaryPricingActionLabel]=\"primaryPricingActionLabel\"\n                         [pricingActionLabel]=\"pricingActionLabel\"\n                         [pricingActionEnabled]=\"showPricingAction\"\n                         [actionLabel]=\"getActionLabel()\"\n                         [actionEnabled]=\"product.isArchived\"\n                         [showAction]=\"showActionButton\"\n                         [showPricing]=\"showPricing\"\n                         [billedProduct]=\"billedProduct\"\n                         [hasVerifiedContract]=\"hasVerifiedContract\"\n                         [loaded]=\"loaded\"\n                         (primaryPricingActionSelected)=\"primaryPricingActionSelected.emit()\"\n                         (pricingActionSelected)=\"pricingActionSelected.emit()\"\n                         (actionSelected)=\"enableClicked.emit()\">\n    </va-header-container>\n    <div class=\"product-details product-content\">\n      <div class=\"left-column\">\n        <ng-container *ngIf=\"product.description || product.keySellingPoints\">\n          <va-selling-info [description]=\"product.description\"\n                          [keySellingPoints]=\"product.keySellingPoints\"></va-selling-info>\n        </ng-container>\n        <section *ngIf=\"product.addons?.length > 0\">\n          <h2 class=\"va-component-title\">Add-Ons</h2>\n          <va-addon-list (addonSelected)=\"onAddonSelected($event)\"\n                         [addons]=\"getAddons()\"\n                         [showPricing]=\"showPricing\"\n                         [hasVerifiedContract]=\"hasVerifiedContract\"\n                         [canAccessContractPricing]=\"canAccessContractPricing\"\n                         [partnerID]=\"partnerID\">\n          </va-addon-list>\n        </section>\n\n        <section *ngIf=\"product.faqs?.length > 0\">\n          <h2 class=\"va-component-title\">FAQs</h2>\n          <va-faqs [faqs]=\"product.faqs\"></va-faqs>\n        </section>\n      </div>\n\n      <div class=\"right-column\">\n        <section *ngIf=\"product.restrictions?.country?.whitelist?.length > 0\">\n          <supported-countries [countryCodes]=\"product.restrictions.country.whitelist\"></supported-countries>\n        </section>\n\n        <section *ngIf=\"product.screenshotUrls?.length > 0\">\n          <h2 class=\"va-component-title\">Gallery</h2>\n          <va-image-gallery [imageUrls]=\"product.screenshotUrls\"></va-image-gallery>\n        </section>\n\n        <section *ngIf=\"product.files?.length > 0\">\n          <h2 class=\"va-component-title\">Files</h2>\n          <va-files [files]=\"product.files\"></va-files>\n        </section>\n      </div>\n    </div>\n</div>\n",
        styles: [":host{display:block;font-size:14px;line-height:1.4}:host *{box-sizing:border-box}.va-component-title{font-size:24px;font-weight:400;margin-top:0}@media screen and (min-width:600px){.va-component-title{font-size:32px}}img{max-width:100%}va-icon{display:inline-block}.sales-person-details{max-height:430px;overflow:hidden}.page{position:relative;margin:0 auto 20px;background:#fff;color:#212121;box-shadow:0 3px 10px rgba(33,33,33,.3);overflow:hidden;font-size:16px}.page .item-amount{color:#9e9e9e;font-size:14px;text-align:right;margin:0 24px 8px}section{padding:24px}.left-column{width:66%}@media screen and (max-width:600px){.left-column{width:100%}}.right-column{width:34%}.product-content{display:flex}@media screen and (max-width:600px){.right-column{width:100%}.product-content{flex-direction:column}}"]
    })
], VaProductDetailsComponent);
export { VaProductDetailsComponent };
//# sourceMappingURL=data:application/json;base64, 