(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@awesome-cordova-plugins/barcode-scanner/ngx'), require('@wm/components/base'), require('@wm/core'), require('@angular/common')) :
    typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@awesome-cordova-plugins/barcode-scanner/ngx', '@wm/components/base', '@wm/core', '@angular/common'], factory) :
    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.wm = global.wm || {}, global.wm.mobile = global.wm.mobile || {}, global.wm.mobile.components = global.wm.mobile.components || {}, global.wm.mobile.components.device = global.wm.mobile.components.device || {}, global.wm.mobile.components.device.barcodescanner = {}), global.ng.core, global.awesomeCordova.plugins, global.wm.components.base, global.wm.core, global.ng.common));
})(this, (function (exports, i0, i1, i3, core, i2) { '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 i1__namespace = /*#__PURE__*/_interopNamespaceDefault(i1);
    var i3__namespace = /*#__PURE__*/_interopNamespaceDefault(i3);
    var i2__namespace = /*#__PURE__*/_interopNamespaceDefault(i2);

    const registerProps = () => {
        i3.register('wm-barcodescanner', new Map([
            ['barcodeformat', { value: 'ALL', ...i3.PROP_STRING }],
            ['caption', { value: '', ...i3.PROP_STRING }],
            ['class', i3.PROP_STRING],
            ['iconclass', { value: 'glyphicon glyphicon-barcode', ...i3.PROP_STRING }],
            ['iconsize', { value: '2em', ...i3.PROP_STRING }],
            ['name', i3.PROP_STRING],
            ['show', { value: true, ...i3.PROP_BOOLEAN }],
            ['hint', i3.PROP_STRING],
            ['arialabel', i3.PROP_STRING]
        ]));
    };

    const _c0 = ["wmBarcodescanner", ""];
    const _c1 = a0 => ({ "font-size": a0 });
    const DEFAULT_CLS = 'btn app-barcode';
    const WIDGET_CONFIG = { widgetType: 'wm-barcodescanner', hostClass: DEFAULT_CLS };
    class BarcodeScannerComponent extends i3.StylableComponent {
        static { this.initializeProps = registerProps(); }
        constructor(scanner, inj, explicitContext) {
            super(inj, WIDGET_CONFIG, explicitContext);
            this.scanner = scanner;
            i3.styler(this.nativeElement, this, i3.APPLY_STYLES_TYPE.SCROLLABLE_CONTAINER);
        }
        openBarcodescanner($event) {
            this.scan().then(text => {
                this.datavalue = text;
                this.invokeEventCallback('success', { $event });
            });
        }
        scan() {
            let options = {
                showFlipCameraButton: true,
                showTorchButton: true
            };
            if (core.hasCordova()) {
                if (this.barcodeformat && this.barcodeformat !== 'ALL') {
                    options.formats = this.barcodeformat;
                }
                return this.scanner.scan(options)
                    .then(data => data.text);
            }
            return Promise.resolve('BAR_CODE');
        }
        static { this.ɵfac = function BarcodeScannerComponent_Factory(t) { return new (t || BarcodeScannerComponent)(i0__namespace.ɵɵdirectiveInject(i1__namespace.BarcodeScanner), i0__namespace.ɵɵdirectiveInject(i0__namespace.Injector), i0__namespace.ɵɵdirectiveInject('EXPLICIT_CONTEXT', 8)); }; }
        static { this.ɵcmp = /*@__PURE__*/ i0__namespace.ɵɵdefineComponent({ type: BarcodeScannerComponent, selectors: [["button", "wmBarcodescanner", ""]], hostBindings: function BarcodeScannerComponent_HostBindings(rf, ctx) { if (rf & 1) {
                i0__namespace.ɵɵlistener("click", function BarcodeScannerComponent_click_HostBindingHandler($event) { return ctx.openBarcodescanner($event); });
            } }, exportAs: ["wmBarcodescanner"], features: [i0__namespace.ɵɵProvidersFeature([
                    i3.provideAsWidgetRef(BarcodeScannerComponent)
                ]), i0__namespace.ɵɵInheritDefinitionFeature], attrs: _c0, decls: 2, vars: 5, consts: [[3, "ngClass", "ngStyle"], [1, "btn-caption", 3, "textContent"]], template: function BarcodeScannerComponent_Template(rf, ctx) { if (rf & 1) {
                i0__namespace.ɵɵelement(0, "i", 0)(1, "span", 1);
            } if (rf & 2) {
                i0__namespace.ɵɵproperty("ngClass", ctx.iconclass)("ngStyle", i0__namespace.ɵɵpureFunction1(3, _c1, ctx.iconsize));
                i0__namespace.ɵɵadvance();
                i0__namespace.ɵɵproperty("textContent", ctx.caption);
            } }, dependencies: [i2__namespace.NgClass, i2__namespace.NgStyle, i3__namespace.TextContentDirective], encapsulation: 2 }); }
    }
    (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(BarcodeScannerComponent, [{
            type: i0.Component,
            args: [{ selector: 'button[wmBarcodescanner]', providers: [
                        i3.provideAsWidgetRef(BarcodeScannerComponent)
                    ], exportAs: 'wmBarcodescanner', template: "<i [ngClass]=\"iconclass\" [ngStyle]=\"{'font-size': iconsize}\"></i>\n<span class=\"btn-caption\" [textContent]=\"caption\"></span>" }]
        }], () => [{ type: i1__namespace.BarcodeScanner }, { type: i0__namespace.Injector }, { type: undefined, decorators: [{
                    type: i0.Inject,
                    args: ['EXPLICIT_CONTEXT']
                }, {
                    type: i0.Optional
                }] }], { openBarcodescanner: [{
                type: i0.HostListener,
                args: ['click', ['$event']]
            }] }); })();
    (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassDebugInfo(BarcodeScannerComponent, { className: "BarcodeScannerComponent", filePath: "barcode-scanner.component.ts", lineNumber: 21 }); })();

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

    exports.BarcodeScannerComponent = BarcodeScannerComponent;
    exports.BarcodeScannerModule = BarcodeScannerModule;

}));
