import { Directive, Input, HostBinding } from '@angular/core';

/**
 * @deprecated use @sbb-esta/angular-core/icon module
 */
class IconBase {
    constructor(_dimension) {
        this._dimension = _dimension;
        /**
         * Configure the size of the SVG.
         * 'grow' will allow the SVG to grow or shrink to the parent size.
         * 'fixed' will apply the default width and height of the SVG.
         * 'small' will apply 24px as width and height.
         * 'medium' will apply 36px as width and height.
         * 'large' will apply 48px as width and height.
         * Defaults to 'grow'.
         */
        this.size = 'grow';
        /**
         * The given CSS class or classes will be applied to the SVG element.
         */
        this.svgClass = '';
        /** @docs-private */
        this.sbbIconComponent = true;
    }
    /**
     * Width of the icon.
     */
    get width() {
        return this._resolveDimension(this._inputWidth, this._dimension.width);
    }
    set width(value) {
        if (value === undefined) {
            this._inputWidth = undefined;
            return;
        }
        this._inputWidth = this._coerceDimensionValue(value);
        if (!this._inputHeight && !value.endsWith('%')) {
            this._inputHeight = this._resolveInput(value, (v) => v / this._dimension.ratio);
        }
    }
    /**
     * Height of the icon.
     */
    get height() {
        return this._resolveDimension(this._inputHeight, this._dimension.height);
    }
    set height(value) {
        if (value === undefined) {
            this._inputHeight = undefined;
            return;
        }
        this._inputHeight = this._coerceDimensionValue(value);
        if (!this._inputWidth && !value.endsWith('%')) {
            this._inputWidth = this._resolveInput(value, (v) => v * this._dimension.ratio);
        }
    }
    get display() {
        return this._isFixed() || this._inputHeight || this._inputWidth ? 'inline-block' : undefined;
    }
    _isFixed() {
        return !this.size.endsWith('grow');
    }
    _resolveDimension(growSize, fixedSize) {
        if (this.size === 'fixed') {
            return fixedSize;
        }
        else if (this.size === 'small') {
            return '24px';
        }
        else if (this.size === 'medium') {
            return '36px';
        }
        else if (this.size === 'large') {
            return '48px';
        }
        else {
            return growSize;
        }
    }
    _coerceDimensionValue(value) {
        return Number.isNaN(+value) ? value : `${value}px`;
    }
    _resolveInput(input, operation) {
        const match = /(\d*\.\d+|\d+)(\w*)/g.exec(input);
        return match && match[1] ? `${operation(Number(match[1]))}${match[2] || 'px'}` : undefined;
    }
}
IconBase.decorators = [
    { type: Directive }
];
IconBase.ctorParameters = () => [
    { type: undefined }
];
IconBase.propDecorators = {
    size: [{ type: Input }],
    width: [{ type: Input }, { type: HostBinding, args: ['style.width',] }],
    height: [{ type: Input }, { type: HostBinding, args: ['style.height',] }],
    svgClass: [{ type: Input }],
    display: [{ type: HostBinding, args: ['style.display',] }],
    sbbIconComponent: [{ type: HostBinding, args: ['class.sbb-icon-component',] }]
};

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

export { IconBase };
//# sourceMappingURL=core.js.map
