var ti_common;
(function (ti_common) {
    var file;
    (function (file) {
        'use strict';
        (function (ContentType) {
            ContentType[ContentType["Text"] = 0] = "Text";
            ContentType[ContentType["Blob"] = 1] = "Blob";
        })(file.ContentType || (file.ContentType = {}));
        var ContentType = file.ContentType;
        file.ContentTypeHeaderLookup = ["application/text", "application/octet-stream"];
        file.ResponseTypeConfigLookup = [null, 'blob'];
        // base file class
        var File = (function () {
            function File(path, type, size, isLocal) {
                if (size === void 0) { size = null; }
                if (isLocal === void 0) { isLocal = false; }
                this.path = path;
                this.type = type;
                this.size = size;
                this.isLocal = isLocal;
                this.isReady = true;
                this.name = this.getBaseName();
            }
            File.prototype.getBaseName = function () {
                this.path = this.path.replace(/\\/g, '/');
                var parts = this.path.split('/');
                return parts[parts.length - 1];
            };
            File.prototype.getDisplayTime = function () {
                return '';
            };
            File.prototype.getDisplaySize = function () {
                var size = this.size;
                if (typeof size === 'number') {
                    if (size > 1048576)
                        return (size / 1048576).toFixed(2) + ' MB';
                    else if (size > 1024)
                        return (size / 1024).toFixed(2) + ' KB';
                    else
                        return size + ' B';
                }
                else {
                    return 'unknown';
                }
            };
            File.prototype.toJSON = function () {
                return {
                    name: this.name,
                    path: this.path,
                    size: this.size,
                    type: this.type,
                    isLocal: this.isLocal
                };
            };
            return File;
        }());
        file.File = File;
    })(file = ti_common.file || (ti_common.file = {}));
})(ti_common || (ti_common = {}));
