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;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { bindable, bindingMode, computedFrom, customElement } from "aurelia-framework";
import { UIInternal } from "../../utils/ui-internal";
export var UIToggle = (function () {
    function UIToggle(element) {
        this.element = element;
        this.disabled = false;
        this.labelOn = "";
        this.labelOff = "";
        this.labelPosition = "outside";
        this.isDisabled = false;
    }
    Object.defineProperty(UIToggle.prototype, "optionStyle", {
        get: function () {
            var _a, _b, _c;
            var style = {};
            if (((_a = this.labelOn) === null || _a === void 0 ? void 0 : _a.length) > 0) {
                style["--toggle-on"] = "'".concat(this.labelOn, "'");
            }
            if (((_b = this.labelOff) === null || _b === void 0 ? void 0 : _b.length) > 0) {
                style["--toggle-off"] = "'".concat(this.labelOff, "'");
            }
            if (((_c = this.labelOff) === null || _c === void 0 ? void 0 : _c.length) > 0) {
                style["width"] = this.width;
            }
            if (this.labelPosition == "outside") {
                style["--toggle-on"] = "''";
                style["--toggle-off"] = "''";
            }
            return style;
        },
        enumerable: false,
        configurable: true
    });
    UIToggle.prototype.labelOnChanged = function () {
        var _a, _b;
        if (((_a = this.labelOn) === null || _a === void 0 ? void 0 : _a.length) == 0 && ((_b = this.labelOff) === null || _b === void 0 ? void 0 : _b.length) == 0) {
            this.labelPosition = "inside";
        }
    };
    UIToggle.prototype.labelOffChanged = function () {
        var _a, _b;
        if (((_a = this.labelOn) === null || _a === void 0 ? void 0 : _a.length) == 0 && ((_b = this.labelOff) === null || _b === void 0 ? void 0 : _b.length) == 0) {
            this.labelPosition = "inside";
        }
    };
    UIToggle.prototype.disable = function (b) {
        this.isDisabled = b;
    };
    UIToggle.prototype.bind = function () {
        if (isTrue(this.checked)) {
            this.checked = true;
        }
    };
    UIToggle.prototype.checkChanged = function ($event) {
        $event.preventDefault();
        $event.stopPropagation();
        if (!this.disabled) {
            this.checked = !this.checked;
        }
        this.element.dispatchEvent(UIInternal.createEvent("change", this));
    };
    __decorate([
        bindable({ defaultBindingMode: bindingMode.twoWay }),
        __metadata("design:type", Object)
    ], UIToggle.prototype, "checked", void 0);
    __decorate([
        bindable(),
        __metadata("design:type", Object)
    ], UIToggle.prototype, "model", void 0);
    __decorate([
        bindable(),
        __metadata("design:type", Function)
    ], UIToggle.prototype, "matcher", void 0);
    __decorate([
        bindable(),
        __metadata("design:type", Boolean)
    ], UIToggle.prototype, "disabled", void 0);
    __decorate([
        bindable(),
        __metadata("design:type", String)
    ], UIToggle.prototype, "labelOn", void 0);
    __decorate([
        bindable(),
        __metadata("design:type", String)
    ], UIToggle.prototype, "labelOff", void 0);
    __decorate([
        bindable(),
        __metadata("design:type", String)
    ], UIToggle.prototype, "width", void 0);
    __decorate([
        bindable(),
        __metadata("design:type", String)
    ], UIToggle.prototype, "labelPosition", void 0);
    __decorate([
        computedFrom('labelOn', 'labelOff', 'width', 'labelPosition'),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [])
    ], UIToggle.prototype, "optionStyle", null);
    UIToggle = __decorate([
        customElement("ui-toggle"),
        __metadata("design:paramtypes", [Element])
    ], UIToggle);
    return UIToggle;
}());

//# sourceMappingURL=ui-toggle.js.map
