import * as i0 from '@angular/core';
import { Pipe } from '@angular/core';
import { coerceBooleanProperty } from '@angular/cdk/coercion';

/**
 * @description
 * Pipe for truncating strings to a specified length with trailing indicator.
 * Supports both start and end truncation based on limit sign.
 * Positive limit truncates from the end, negative limit truncates from the start.
 * Commonly used for displaying long text in constrained spaces like tables, cards, or lists.
 * @param value - The string to truncate
 * @param limit - Maximum character length (positive for end truncation, negative for start truncation). Default: 40
 * @param trail - Trailing indicator appended to truncated text. Default: '…' (ellipsis character U+2026)
 * @returns Truncated string with trail indicator, or original string if within limit
 */
class EuiTruncatePipe {
    transform(value, limit = 40, trail = '\u2026') {
        if (value) {
            if (limit < 0) {
                limit *= -1;
                return value.length > limit ? trail + value.substring(value.length - limit, value.length) : value;
            }
            else {
                return value.length > limit ? value.substring(0, limit) + trail : value;
            }
        }
        return;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: EuiTruncatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
    static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.2.16", ngImport: i0, type: EuiTruncatePipe, isStandalone: true, name: "euiTruncate" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: EuiTruncatePipe, decorators: [{
            type: Pipe,
            args: [{
                    name: 'euiTruncate',
                }]
        }] });

class EuiCoerceBooleanPipe {
    transform(value) {
        return coerceBooleanProperty(value);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: EuiCoerceBooleanPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
    static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.2.16", ngImport: i0, type: EuiCoerceBooleanPipe, isStandalone: true, name: "coerceBool" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: EuiCoerceBooleanPipe, decorators: [{
            type: Pipe,
            args: [{
                    name: 'coerceBool',
                    pure: true,
                }]
        }] });

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

export { EuiCoerceBooleanPipe, EuiTruncatePipe };
//# sourceMappingURL=eui-components-pipes.mjs.map
