import { r as registerInstance, c as createEvent, h } from './materials-6a67d110.js';
/**
 * thanks to  https://github.com/andregoncalves/stencil-timepicker/
 */
var Timepicker = /** @class */ (function () {
    function Timepicker(hostRef) {
        registerInstance(this, hostRef);
        this.step = 15;
        this.clock24 = true;
        this.timeSelectedChange = createEvent(this, "timeSelectedChange", 7);
    }
    Timepicker.prototype._getOptions = function () {
        var start = 0;
        var total = Math.round((60 / this.step) * 24);
        var hours = [];
        for (var i = start; i < total; i++) {
            hours.push(i * this.step);
        }
        return hours;
    };
    Timepicker.prototype._format = function (h, m) {
        var indicator = '';
        if (!this.clock24 && h >= 12) {
            indicator = 'PM';
            h = h - 12;
        }
        else {
            if (!this.clock24 && h < 12) {
                indicator = 'AM';
            }
        }
        if (!this.clock24 && h === 0) {
            h = 12;
        }
        if (h < 10) {
            h = "0" + h;
        }
        if (m < 10) {
            m = "0" + m;
        }
        if (indicator)
            m = m + (" " + indicator);
        return h + ":" + m;
    };
    Timepicker.prototype._renderOption = function (m) {
        var _this = this;
        var base = new Date(0);
        base.setMinutes(m);
        var hours = base.getUTCHours();
        var minutes = base.getUTCMinutes();
        var formatted = this._format(hours, minutes);
        if (this.timeSelected === formatted)
            return h("materials-list-item", { selected: true, onClick: function () { return _this.timeSelectedChange.emit(formatted); } }, formatted);
        else
            return h("materials-list-item", { onClick: function () { return _this.timeSelectedChange.emit(formatted); } }, formatted);
    };
    Timepicker.prototype.render = function () {
        var _this = this;
        return this._getOptions().map(function (e) { return _this._renderOption(e); });
    };
    return Timepicker;
}());
export { Timepicker as materials_timepicker };
