; (function () {
    'use strict';
    angular
        .module("app.filter")
        .filter('formByteLength', [ function () {
            return function (value) {
                if(!isFinite(value)){
                    return 0;
                }
              
                let kbSize = 1024,//1kb
                mbSize = kbSize * kbSize,//1mb
                gbSize = mbSize * kbSize; //gb

                if (value <= kbSize)
                    return `${value}B`

                if (value > kbSize && value < mbSize)
                    return  `${(value / kbSize).toFixed(1)}k`;

                if (value >= mbSize && value < gbSize)
                    return `${(value / mbSize).toFixed(1)}M`;

                return `${(value / gbSize).toFixed(1)}G`;
            }
        }])
        .filter('trustHtml', [ '$sce' ,function ($sce) {
            return function (value) {
                return $sce.trustAsHtml(value);
            }
        }]);
} ());