"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProductMap = exports.ProductCluster = exports.Product = void 0;
const jackson_js_1 = require("jackson-js");
const catalog_1 = require("./catalog");
const offer_1 = require("./offer");
class Product {
    getBrand() {
        if (!this.cluster) {
            throw ("cluster not retrieved");
        }
        return this.cluster.getBrand();
    }
    getTags() {
        return this.tags || [];
    }
    getClusterTags() {
        if (!this.cluster) {
            throw ("cluster not retrieved");
        }
        return this.cluster.getTags();
    }
    getBin() {
        if (!this.cluster) {
            throw ("cluster not retrieved");
        }
        return this.cluster.bin;
    }
    getTitle() {
        if (!this.cluster) {
            throw ("cluster not retrieved");
        }
        return this.cluster.getTitle();
    }
    getDescription() {
        if (!this.cluster) {
            throw ("cluster not retrieved");
        }
        return this.cluster.getDescription();
    }
    getImage() {
        if (!this.cluster) {
            throw ("cluster not retrieved");
        }
        return this.cluster.getImage();
    }
}
__decorate([
    (0, jackson_js_1.JsonProperty)()
], Product.prototype, "sellerSku", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)()
], Product.prototype, "productId", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)()
], Product.prototype, "condition", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)()
], Product.prototype, "provider", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)(),
    (0, jackson_js_1.JsonClassType)({ type: () => [Array, [String]] })
], Product.prototype, "tags", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)(),
    (0, jackson_js_1.JsonClassType)({ type: () => [Array, [offer_1.Offer]] })
], Product.prototype, "offers", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)(),
    (0, jackson_js_1.JsonClassType)({ type: () => [ProductCluster] })
], Product.prototype, "cluster", void 0);
exports.Product = Product;
class ProductCluster {
    constructor() {
        this.equals = (product) => {
            if (product.bin == this.bin) {
                return true;
            }
            return false;
        };
    }
    getBrand() {
        return this.brand || "";
    }
    getTags() {
        return this.tags || [];
    }
    getTitle() {
        var _a;
        return ((_a = this.summary) === null || _a === void 0 ? void 0 : _a.title) || "";
    }
    getDescription() {
        var _a;
        return ((_a = this.summary) === null || _a === void 0 ? void 0 : _a.description) || "";
    }
    getImage() {
        var _a;
        return ((_a = this.summary) === null || _a === void 0 ? void 0 : _a.image) || "";
    }
}
__decorate([
    (0, jackson_js_1.JsonProperty)()
], ProductCluster.prototype, "bin", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)()
], ProductCluster.prototype, "nickname", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)()
], ProductCluster.prototype, "brand", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)()
], ProductCluster.prototype, "parent", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)(),
    (0, jackson_js_1.JsonClassType)({ type: () => [Array, [String]] })
], ProductCluster.prototype, "tags", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)(),
    (0, jackson_js_1.JsonClassType)({ type: () => [catalog_1.CatalogSummary] })
], ProductCluster.prototype, "summary", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)(),
    (0, jackson_js_1.JsonClassType)({ type: () => [Array, [Product]] })
], ProductCluster.prototype, "products", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)(),
    (0, jackson_js_1.JsonClassType)({ type: () => [Array, [ProductMap]] })
], ProductCluster.prototype, "productMaps", void 0);
exports.ProductCluster = ProductCluster;
class ProductMap {
    constructor(bin, productId) {
        this.bin = bin;
        this.productId = productId;
    }
}
__decorate([
    (0, jackson_js_1.JsonProperty)()
], ProductMap.prototype, "bin", void 0);
__decorate([
    (0, jackson_js_1.JsonProperty)()
], ProductMap.prototype, "productId", void 0);
exports.ProductMap = ProductMap;
//# sourceMappingURL=product.js.map