(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('@wm/components/base'), require('@wm/components/input'), require('@wm/core')) :
    typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/common', '@angular/forms', '@wm/components/base', '@wm/components/input', '@wm/core'], factory) :
    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.wm = global.wm || {}, global.wm.components = global.wm.components || {}, global.wm.components.input = global.wm.components.input || {}, global.wm.components.input.currency = {}), global.ng.core, global.ng.common, global.ng.forms, global.wm.components.base, global.wm.components.input, global.wm.core));
})(this, (function (exports, i0, common, i3, i2, input, i1) { 'use strict';

    function _interopNamespaceDefault(e) {
        var n = Object.create(null);
        if (e) {
            Object.keys(e).forEach(function (k) {
                if (k !== 'default') {
                    var d = Object.getOwnPropertyDescriptor(e, k);
                    Object.defineProperty(n, k, d.get ? d : {
                        enumerable: true,
                        get: function () { return e[k]; }
                    });
                }
            });
        }
        n.default = e;
        return Object.freeze(n);
    }

    var i0__namespace = /*#__PURE__*/_interopNamespaceDefault(i0);
    var i3__namespace = /*#__PURE__*/_interopNamespaceDefault(i3);
    var i2__namespace = /*#__PURE__*/_interopNamespaceDefault(i2);
    var i1__namespace = /*#__PURE__*/_interopNamespaceDefault(i1);

    const currencyProps = new Map([
        ['class', i2.PROP_STRING],
        ['currency', i2.PROP_STRING],
        ['datavalue', i2.PROP_STRING],
        ['disabled', i2.PROP_BOOLEAN],
        ['hint', i2.PROP_STRING],
        ['arialabel', i2.PROP_STRING],
        ['maxvalue', i2.PROP_NUMBER],
        ['minvalue', i2.PROP_NUMBER],
        ['name', i2.PROP_STRING],
        ['placeholder', { value: 'Enter value', ...i2.PROP_STRING }],
        ['readonly', i2.PROP_BOOLEAN],
        ['required', i2.PROP_BOOLEAN],
        ['shortcutkey', i2.PROP_STRING],
        ['show', { value: true, ...i2.PROP_BOOLEAN }],
        ['step', { value: 1, ...i2.PROP_NUMBER }],
        ['tabindex', { value: 0, ...i2.PROP_NUMBER }],
        ['trailingzero', { value: false, ...i2.PROP_BOOLEAN }],
        ['inputmode', { value: 'natural', ...i2.PROP_STRING }]
    ]);
    const registerProps = () => {
        i2.register('wm-currency', currencyProps);
        i2.registerFormWidget(i1.FormWidgetType.CURRENCY, new Map(currencyProps));
    };

    const _c0 = ["input"];
    const _c1 = ["wmCurrency", ""];
    const DEFAULT_CLS = 'input-group app-currency';
    const WIDGET_CONFIG = {
        widgetType: 'wm-currency',
        hostClass: DEFAULT_CLS
    };
    class CurrencyComponent extends input.NumberLocale {
        static { this.initializeProps = registerProps(); }
        constructor(inj, appDefaults, i18nService, trailingZeroDecimalPipe, explicitContext) {
            super(inj, WIDGET_CONFIG, i18nService, trailingZeroDecimalPipe, explicitContext);
            this.appDefaults = appDefaults;
            this.currencyCode = this.appDefaults.currencyCode || 'USD';
            this.currencySymbol = i1.CURRENCY_INFO[this.appDefaults.currencyCode || "USD"].symbol;
        }
        onPropertyChange(key, nv, ov) {
            if (key === 'currency') {
                this.currencyCode = nv;
                this.currencySymbol = i1.CURRENCY_INFO[this.currencyCode || this.appDefaults.currencyCode].symbol;
            }
            else {
                super.onPropertyChange(key, nv, ov);
            }
        }
        static { this.ɵfac = function CurrencyComponent_Factory(t) { return new (t || CurrencyComponent)(i0__namespace.ɵɵdirectiveInject(i0__namespace.Injector), i0__namespace.ɵɵdirectiveInject(i1__namespace.AppDefaults), i0__namespace.ɵɵdirectiveInject(i1__namespace.AbstractI18nService), i0__namespace.ɵɵdirectiveInject(i2__namespace.TrailingZeroDecimalPipe), i0__namespace.ɵɵdirectiveInject('EXPLICIT_CONTEXT', 8)); }; }
        static { this.ɵcmp = /*@__PURE__*/ i0__namespace.ɵɵdefineComponent({ type: CurrencyComponent, selectors: [["", "wmCurrency", ""]], viewQuery: function CurrencyComponent_Query(rf, ctx) { if (rf & 1) {
                i0__namespace.ɵɵviewQuery(i3.NgModel, 7);
                i0__namespace.ɵɵviewQuery(_c0, 7, i0.ElementRef);
            } if (rf & 2) {
                let _t;
                i0__namespace.ɵɵqueryRefresh(_t = i0__namespace.ɵɵloadQuery()) && (ctx.ngModel = _t.first);
                i0__namespace.ɵɵqueryRefresh(_t = i0__namespace.ɵɵloadQuery()) && (ctx.inputEl = _t.first);
            } }, features: [i0__namespace.ɵɵProvidersFeature([
                    i2.provideAs(CurrencyComponent, i3.NG_VALUE_ACCESSOR, true),
                    i2.provideAs(CurrencyComponent, i3.NG_VALIDATORS, true),
                    i2.provideAsWidgetRef(CurrencyComponent)
                ]), i0__namespace.ɵɵInheritDefinitionFeature], attrs: _c1, decls: 3, vars: 13, consts: [["input", ""], [1, "input-group-addon", 3, "textContent"], ["role", "textbox", "type", "text", "inputmode", "decimal", "focus-target", "", 1, "form-control", "app-textbox", "app-currency-input", 3, "focus", "input", "blur", "ngModelChange", "keydown", "keydown.enter", "keydown.ArrowUp", "keydown.ArrowDown", "autofocus", "readonly", "disabled", "required", "pattern", "ngModel", "ngModelOptions"]], template: function CurrencyComponent_Template(rf, ctx) { if (rf & 1) {
                const _r1 = i0__namespace.ɵɵgetCurrentView();
                i0__namespace.ɵɵelement(0, "span", 1);
                i0__namespace.ɵɵelementStart(1, "input", 2, 0);
                i0__namespace.ɵɵlistener("focus", function CurrencyComponent_Template_input_focus_1_listener($event) { i0__namespace.ɵɵrestoreView(_r1); return i0__namespace.ɵɵresetView(ctx.checkForTrailingZeros($event)); })("input", function CurrencyComponent_Template_input_input_1_listener($event) { i0__namespace.ɵɵrestoreView(_r1); return i0__namespace.ɵɵresetView(ctx.onInputChange($event.target.value)); })("blur", function CurrencyComponent_Template_input_blur_1_listener($event) { i0__namespace.ɵɵrestoreView(_r1); ctx.handleBlur($event); return i0__namespace.ɵɵresetView(ctx.checkForTrailingZeros($event)); })("ngModelChange", function CurrencyComponent_Template_input_ngModelChange_1_listener($event) { i0__namespace.ɵɵrestoreView(_r1); return i0__namespace.ɵɵresetView(ctx.onModelChange($event)); })("keydown", function CurrencyComponent_Template_input_keydown_1_listener($event) { i0__namespace.ɵɵrestoreView(_r1); return i0__namespace.ɵɵresetView(ctx.validateInputEntry($event)); })("keydown.enter", function CurrencyComponent_Template_input_keydown_enter_1_listener($event) { i0__namespace.ɵɵrestoreView(_r1); return i0__namespace.ɵɵresetView(ctx.onEnter($event)); })("keydown.ArrowUp", function CurrencyComponent_Template_input_keydown_ArrowUp_1_listener($event) { i0__namespace.ɵɵrestoreView(_r1); return i0__namespace.ɵɵresetView(ctx.onArrowPress($event, "UP")); })("keydown.ArrowDown", function CurrencyComponent_Template_input_keydown_ArrowDown_1_listener($event) { i0__namespace.ɵɵrestoreView(_r1); return i0__namespace.ɵɵresetView(ctx.onArrowPress($event, "DOWN")); });
                i0__namespace.ɵɵelementEnd();
            } if (rf & 2) {
                i0__namespace.ɵɵproperty("textContent", ctx.currencySymbol);
                i0__namespace.ɵɵadvance();
                i0__namespace.ɵɵproperty("autofocus", ctx.autofocus)("readonly", ctx.readonly)("disabled", ctx.disabled)("required", ctx.required)("pattern", ctx.regexp)("ngModel", ctx.displayValue)("ngModelOptions", ctx.ngModelOptions);
                i0__namespace.ɵɵattribute("name", ctx.name)("aria-label", ctx.arialabel || ctx.currencyCode)("tabindex", ctx.tabindex)("placeholder", ctx.placeholder)("accesskey", ctx.shortcutkey);
            } }, dependencies: [i3__namespace.DefaultValueAccessor, i3__namespace.NgControlStatus, i3__namespace.RequiredValidator, i3__namespace.PatternValidator, i3__namespace.NgModel, i2__namespace.TextContentDirective], encapsulation: 2 }); }
    }
    (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(CurrencyComponent, [{
            type: i0.Component,
            args: [{ selector: '[wmCurrency]', providers: [
                        i2.provideAs(CurrencyComponent, i3.NG_VALUE_ACCESSOR, true),
                        i2.provideAs(CurrencyComponent, i3.NG_VALIDATORS, true),
                        i2.provideAsWidgetRef(CurrencyComponent)
                    ], template: "<span class=\"input-group-addon\" [textContent]=\"currencySymbol\"></span>\n<input class=\"form-control app-textbox app-currency-input\"\n       #input\n       role=\"textbox\"\n       type=\"text\"\n       inputmode=\"decimal\"\n       focus-target\n       [autofocus]=\"autofocus\"\n       [readonly]=\"readonly\"\n       [disabled]=\"disabled\"\n       [required]=\"required\"\n       [pattern]=\"regexp\"\n       [attr.name]=\"name\"\n       [attr.aria-label]=\"arialabel || currencyCode\"\n       [attr.tabindex]=\"tabindex\"\n       [attr.placeholder]=\"placeholder\"\n       [attr.accesskey]=\"shortcutkey\"\n       [ngModel]=\"displayValue\"\n       [ngModelOptions]=\"ngModelOptions\"\n\n       (focus)=\"checkForTrailingZeros($event)\"\n       (input)=\"onInputChange($event.target.value)\"\n       (blur)=\"handleBlur($event); checkForTrailingZeros($event);\"\n       (ngModelChange)=\"onModelChange($event)\"\n       (keydown)=\"validateInputEntry($event);\"\n       (keydown.enter)=\"onEnter($event)\"\n       (keydown.ArrowUp)=\"onArrowPress($event, 'UP')\"\n       (keydown.ArrowDown)=\"onArrowPress($event, 'DOWN')\">\n" }]
        }], () => [{ type: i0__namespace.Injector }, { type: i1__namespace.AppDefaults }, { type: i1__namespace.AbstractI18nService }, { type: i2__namespace.TrailingZeroDecimalPipe }, { type: undefined, decorators: [{
                    type: i0.Inject,
                    args: ['EXPLICIT_CONTEXT']
                }, {
                    type: i0.Optional
                }] }], { ngModel: [{
                type: i0.ViewChild,
                args: [i3.NgModel, { static: true }]
            }], inputEl: [{
                type: i0.ViewChild,
                args: ['input', { static: true, read: i0.ElementRef }]
            }] }); })();
    (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassDebugInfo(CurrencyComponent, { className: "CurrencyComponent", filePath: "currency.component.ts", lineNumber: 26 }); })();

    const components = [
        CurrencyComponent
    ];
    class CurrencyModule {
        static { this.ɵfac = function CurrencyModule_Factory(t) { return new (t || CurrencyModule)(); }; }
        static { this.ɵmod = /*@__PURE__*/ i0__namespace.ɵɵdefineNgModule({ type: CurrencyModule }); }
        static { this.ɵinj = /*@__PURE__*/ i0__namespace.ɵɵdefineInjector({ imports: [common.CommonModule,
                i3.FormsModule,
                input.InputModule,
                i2.WmComponentsModule] }); }
    }
    (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(CurrencyModule, [{
            type: i0.NgModule,
            args: [{
                    imports: [
                        common.CommonModule,
                        i3.FormsModule,
                        input.InputModule,
                        i2.WmComponentsModule
                    ],
                    declarations: [...components],
                    exports: [...components]
                }]
        }], null, null); })();
    (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0__namespace.ɵɵsetNgModuleScope(CurrencyModule, { declarations: [CurrencyComponent], imports: [common.CommonModule,
            i3.FormsModule,
            input.InputModule,
            i2.WmComponentsModule], exports: [CurrencyComponent] }); })();

    exports.CurrencyComponent = CurrencyComponent;
    exports.CurrencyModule = CurrencyModule;

}));
