var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
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';
var VariantsEcComponent = /** @class */ (function (_super) {
    __extends(VariantsEcComponent, _super);
    function VariantsEcComponent(consts, productService) {
        var _this = _super.call(this) || this;
        _this.consts = consts;
        _this.productService = productService;
        _this.setSeleccion = function (values) {
            $('#op').attr('disabled', true);
            var valores = values.split(',');
            if (valores.length != 2)
                return;
            console.log(values);
            console.log(valores);
            _this.setOption(valores[0], valores[1]);
        };
        _this.view = function (length, options) {
            //   console.log('LAS OPCIONES', options);
            return length > 1;
        };
        _this.ecOnConstruct();
        return _this;
    }
    VariantsEcComponent.prototype.ngOnInit = function () {
        this.ecOnInit();
    };
    VariantsEcComponent.ctorParameters = function () { return [
        { 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}"]
        })
    ], VariantsEcComponent);
    return VariantsEcComponent;
}(ComponentHelper));
export { VariantsEcComponent };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFyaWFudHMtZWMuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6Im5nOi8vbmctZWFzeWNvbW1lcmNlLyIsInNvdXJjZXMiOlsibGliL2VjLWNvbXBvbmVudC92YXJpYW50cy1lYy92YXJpYW50cy1lYy5jb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLE9BQU8sRUFBRSxTQUFTLEVBQUUsS0FBSyxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBQ2pELE9BQU8sRUFBRSxlQUFlLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUNqRSxPQUFPLEVBQUUsU0FBUyxFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDOUMsT0FBTyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sZ0RBQWdELENBQUM7QUFRdEY7SUFBeUMsdUNBQWU7SUFNcEQsNkJBQW1CLE1BQWlCLEVBQVMsY0FBb0M7UUFBakYsWUFDSSxpQkFBTyxTQUVWO1FBSGtCLFlBQU0sR0FBTixNQUFNLENBQVc7UUFBUyxvQkFBYyxHQUFkLGNBQWMs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