"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var moment_1 = __importDefault(require("moment"));
function formatSeconds(sec) {
    return formatTime(sec, 'seconds');
}
exports.formatSeconds = formatSeconds;
function formatTime(amount, unit) {
    var duration = moment_1.default.duration(amount, unit);
    var hours = Math.floor(duration.hours());
    var result = zerofill(Math.floor(duration.minutes())) + ':' + zerofill(Math.floor(duration.seconds()));
    if (hours >= 1) {
        result = hours + ':' + result;
    }
    return result;
}
exports.formatTime = formatTime;
function zerofill(value, prefix) {
    if (prefix === void 0) { prefix = '00'; }
    return (prefix + value).slice(-prefix.length);
}
function getProcessedPercentage(prcessedDistance, totalWidth, indicatorRadius) {
    var processPercentage = 0;
    if (prcessedDistance < indicatorRadius) {
        processPercentage = 0;
    }
    else if (prcessedDistance > totalWidth - indicatorRadius) {
        processPercentage = 1;
    }
    else {
        processPercentage =
            (prcessedDistance - indicatorRadius) / (totalWidth - indicatorRadius * 2);
    }
    return processPercentage;
}
exports.getProcessedPercentage = getProcessedPercentage;
exports.KEY_CODE = Object.freeze({
    LEFT: 37,
    UP: 38,
    RIGHT: 39,
    DOWN: 40,
    END: 35,
    HOME: 36,
    PAGEUP: 33,
    PAGEDOWN: 34
});
//# sourceMappingURL=utils.js.map