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 { Component, Input } from '@angular/core';
import { ComponentHelper } from '../../classes/component-helper';
import { Constants } from '../../core.consts';
import { ProductDetailService } from '../../services/products/product-detail.service';
let VariantsEcComponent = class VariantsEcComponent extends ComponentHelper {
    constructor(consts, productService) {
        super();
        this.consts = consts;
        this.productService = productService;
        this.setSeleccion = (values) => {
            $('#op').attr('disabled', true);
            let valores = values.split(',');
            if (valores.length != 2)
                return;
            console.log(values);
            console.log(valores);
            this.setOption(valores[0], valores[1]);
        };
        this.view = (length, options) => {
            //   console.log('LAS OPCIONES', options);
            return length > 1;
        };
        this.ecOnConstruct();
    }
    ngOnInit() {
        this.ecOnInit();
    }
};
VariantsEcComponent.ctorParameters = () => [
    { type: Constants },
    { type: ProductDetailService }
];
__decorate([
    Input()
], VariantsEcComponent.prototype, "product", void 0);
__decorate([
    Input('options')
], VariantsEcComponent.prototype, "options$", void 0);
__decorate([
    Input()
], VariantsEcComponent.prototype, "setOption", void 0);
VariantsEcComponent = __decorate([
    Component({
        selector: 'app-product-variants-ec',
        template: "<div *ngIf=\"(options$ | async) as options ; else loading\">\n     <div *ngIf=\"options && options.length && view(options.length, options)\">\n          <div *ngFor=\"let option of options; let i = index\" class=\"mb-2\">\n               <h5 class=\"text-lowercase\">{{option.name | titlecase}}</h5>\n               <div [ngSwitch]=\"option.type\">\n                    <div *ngSwitchCase=\"'color'\">\n                         <div class=\"row w-100 mx-auto pb-3 mb-2\">\n                              <a *ngFor=\"let value of option.values; let x = index\" role=\"buttom\"\n                                   (click)=\"setOption(option.code, value.name)\"\n                                   [class]=\"'rounded-0 color-item mr-2 ' + (value.selected ? 'shadow' : '')\"\n                                   [id]=\"x + value.name\" [style.background]=\"'#' + value.name\"\n                                   [style.border]=\"(value.selected ? '1px black solid' : '1px gray solid')\"></a>\n                         </div>\n                    </div>\n                    <div *ngSwitchCase=\"'size'\">\n                         <div class=\"row w-100 mx-auto pb-3\">\n                              <select (change)=\"setSeleccion($event.target.value)\" class=\"form-control pr-5\">\n                                   <option id=\"op\" value=\"\">Seleccione {{option.name | lowercase}}</option>\n                                   <option *ngFor=\"let value of option.values; let x = index\" role=\"buttom\"\n                                        [value]=\"option.code +','+ value.name\" [id]=\"x + value.name\"\n                                        [selected]=\"value.selected\">\n                                        {{ value.name  }}\n                                   </option>\n                              </select>\n                              <!-- <a *ngFor=\"let value of option.values; let x = index\" role=\"buttom\"\n                                   (click)=\"setOption(option.code, value.name)\"\n                                   [id]=\"x + value.name\"\n                                   [class]=\"'btn btn-outline-dark rounded-0 talle-item m-1 ' + (value.selected ? 'selected-size' : 'unselected-size')\">\n                                   {{ value.name }}\n                              </a> -->\n                         </div>\n                    </div>\n                    <div *ngSwitchDefault>\n                        <select (change)=\"setSeleccion($event.target.value)\" class=\"form-control \">\n                            <option id=\"op\" value=\"\">Seleccione {{option.name | lowercase}}</option>\n                            <option *ngFor=\"let value of option.values; let x = index\" role=\"buttom\"\n                                 [value]=\"option.code +','+ value.name\" [id]=\"x + value.name\"\n                                 [selected]=\"value.selected\">\n                                 {{ value.name  }}\n                            </option>\n                       </select>\n                    </div>\n               </div>\n          </div>\n     </div>\n</div>\n\n<ng-template #loading>\n     <div class=\"col-12 align-items-center\">\n          <div class=\"d-flex flex-column jusitfy-content-center align-items-center my-5\">\n               <app-loading-full-ec></app-loading-full-ec>\n          </div>\n     </div>\n</ng-template>",
        styles: ["*{font-size:15px}.selected-size{background-color:#343a40;color:#fff}.unselected-size{color:#000;background-color:#fff}.color-item{height:18px;width:18px;border-radius:1rem!important}"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