import * as i0 from '@angular/core';
import { Injectable, Pipe } from '@angular/core';
import { isNullOrUndefined, isNumber } from '@ironsource/fusion-ui/utils';

/**
 * Convert number 'BIG' number to string with "weight" suffix K-kilo, M-mega, etc.
 * for example 500000 to 500 K
 */
class ShortNumberScaleSuffixPipe {
    transform(value, options) {
        const baseNumber = options?.intBase ? options.intBase : 1;
        if (value < baseNumber) {
            return value.toFixed(2);
        }
        const i = value === 0 ? 0 : Math.floor(Math.log(value) / Math.log(1000));
        const bigPart = value / Math.pow(1000, i);
        const noSpaceDelimiter = !isNullOrUndefined(options) && !!options.noSeparateBySpace;
        const precision = options?.precision;
        let numberToShow = bigPart.toFixed(Number.isInteger(bigPart) ? 0 : 1);
        if (precision) {
            numberToShow = bigPart.toPrecision(precision);
        }
        return `${numberToShow}${noSpaceDelimiter ? '' : ' '}${['', 'K', 'M', 'B', 'T', 'P', 'E', 'Z', 'Y'][i] ?? ''}`.trim();
    }
    static { this.ɵfac = function ShortNumberScaleSuffixPipe_Factory(t) { return new (t || ShortNumberScaleSuffixPipe)(); }; }
    static { this.ɵpipe = /*@__PURE__*/ i0.ɵɵdefinePipe({ name: "shortNumberScaleSuffix", type: ShortNumberScaleSuffixPipe, pure: true, standalone: true }); }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ShortNumberScaleSuffixPipe, factory: ShortNumberScaleSuffixPipe.ɵfac, providedIn: 'root' }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ShortNumberScaleSuffixPipe, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }, {
        type: Pipe,
        args: [{
                name: 'shortNumberScaleSuffix',
                standalone: true
            }]
    }], null, null); })();

/*
 * Created on 2020.9.23 By Andy Kononenko (andyk@ironsrc.com)
 */
class SecondsToMinutesPipe {
    transform(value) {
        let minutes;
        if (value && isNumber(value)) {
            const _minutes = Math.floor(value / 60);
            const seconds = value - _minutes * 60;
            minutes = `${_minutes < 10 ? '0' : ''}${_minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
        }
        else {
            minutes = '00:00';
        }
        return minutes;
    }
    static { this.ɵfac = function SecondsToMinutesPipe_Factory(t) { return new (t || SecondsToMinutesPipe)(); }; }
    static { this.ɵpipe = /*@__PURE__*/ i0.ɵɵdefinePipe({ name: "secondsToMinutes", type: SecondsToMinutesPipe, pure: true, standalone: true }); }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SecondsToMinutesPipe, factory: SecondsToMinutesPipe.ɵfac, providedIn: 'root' }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SecondsToMinutesPipe, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }, {
        type: Pipe,
        args: [{
                name: 'secondsToMinutes',
                standalone: true
            }]
    }], null, null); })();

/**
 * Generated bundle index. Do not edit.
 */

export { SecondsToMinutesPipe, ShortNumberScaleSuffixPipe };
//# sourceMappingURL=ironsource-fusion-ui-pipes-numbers.mjs.map
