import { DirectiveBase, PartType } from '../Abstracts/DirectiveBase';
import { directive } from 'lit/directive.js';
/**
 * @private
 */
class TextCaseDirective extends DirectiveBase {
    // #region Fields
    _mode;
    _value;
    // #endregion
    // #region Ctor
    /**
     * Constructs a new instance of the `TextCaseDirective` class.
     *
     * @public
     */
    constructor(args) {
        super(args);
        if (args.type !== PartType.PROPERTY) {
            throw new Error('The `textCase` directive can only be used on property bindings.');
        }
        this._mode = 'lower';
        this._value = '';
    }
    // #endregion
    // #region Methods
    /**
     * @public
     */
    render(mode, value) {
        this._mode = mode;
        // eslint-disable-next-line @typescript-eslint/no-base-to-string
        this._value = String(value ?? '');
        return this.transform(this._value);
    }
    /**
     * @public
     * @override
     */
    update(_part, [mode, value]) {
        this._mode = mode;
        // eslint-disable-next-line @typescript-eslint/no-base-to-string
        this._value = String(value ?? '');
        return this.transform(this._value);
    }
    transform(value) {
        switch (this._mode) {
            case 'upper':
                return value.toUpperCase();
            case 'lower':
                return value.toLowerCase();
            case 'capitalize':
                return value.charAt(0).toUpperCase() + value.slice(1);
            default:
                return value;
        }
    }
}
export const textCase = directive(TextCaseDirective);
//# sourceMappingURL=TextCaseDirective.js.map