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;
};
import { JsonProperty, JsonClassType } from "jackson-js";
import { CatalogSummary } from "./catalog";
import { Offer } from "./offer";
export 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([
    JsonProperty()
], Product.prototype, "sellerSku", void 0);
__decorate([
    JsonProperty()
], Product.prototype, "productId", void 0);
__decorate([
    JsonProperty()
], Product.prototype, "condition", void 0);
__decorate([
    JsonProperty()
], Product.prototype, "provider", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [Array, [String]] })
], Product.prototype, "tags", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [Array, [Offer]] })
], Product.prototype, "offers", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [ProductCluster] })
], Product.prototype, "cluster", void 0);
export 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([
    JsonProperty()
], ProductCluster.prototype, "bin", void 0);
__decorate([
    JsonProperty()
], ProductCluster.prototype, "nickname", void 0);
__decorate([
    JsonProperty()
], ProductCluster.prototype, "brand", void 0);
__decorate([
    JsonProperty()
], ProductCluster.prototype, "parent", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [Array, [String]] })
], ProductCluster.prototype, "tags", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [CatalogSummary] })
], ProductCluster.prototype, "summary", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [Array, [Product]] })
], ProductCluster.prototype, "products", void 0);
__decorate([
    JsonProperty(),
    JsonClassType({ type: () => [Array, [ProductMap]] })
], ProductCluster.prototype, "productMaps", void 0);
export class ProductMap {
    constructor(bin, productId) {
        this.bin = bin;
        this.productId = productId;
    }
}
__decorate([
    JsonProperty()
], ProductMap.prototype, "bin", void 0);
__decorate([
    JsonProperty()
], ProductMap.prototype, "productId", void 0);
//# sourceMappingURL=product.js.map