import * as i0 from '@angular/core';
import { Component, Inject, Optional, ViewChild, NgModule } from '@angular/core';
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i2 from '@angular/forms';
import { NgModel, NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
import * as i3 from '@wm/components/base';
import { PROP_STRING, PROP_BOOLEAN, PROP_NUMBER, register, registerFormWidget, styler, provideAs, provideAsWidgetRef, WmComponentsModule } from '@wm/components/base';
import { BaseFormCustomComponent } from '@wm/components/input';
import { FormWidgetType } from '@wm/core';

const sliderProps = new Map([
    ['class', PROP_STRING],
    ['datavalue', PROP_STRING],
    ['disabled', PROP_BOOLEAN],
    ['hint', PROP_STRING],
    ['arialabel', PROP_STRING],
    ['maxvalue', PROP_NUMBER],
    ['minvalue', PROP_NUMBER],
    ['name', PROP_STRING],
    ['readonly', PROP_BOOLEAN],
    ['shortcutkey', PROP_STRING],
    ['show', { value: true, ...PROP_BOOLEAN }],
    ['step', PROP_NUMBER],
    ['tabindex', { value: 0, ...PROP_NUMBER }]
]);
const registerProps = () => {
    register('wm-slider', sliderProps);
    registerFormWidget(FormWidgetType.SLIDER, new Map(sliderProps));
};

const _c0 = ["wmSlider", ""];
const _c1 = () => ({ standalone: true });
function SliderComponent_div_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "div", 4);
} }
const DEFAULT_CLS = 'app-slider slider';
const WIDGET_CONFIG = {
    widgetType: 'wm-slider',
    hostClass: DEFAULT_CLS
};
class SliderComponent extends BaseFormCustomComponent {
    static { this.initializeProps = registerProps(); }
    constructor(inj, explicitContext) {
        super(inj, WIDGET_CONFIG, explicitContext);
        styler(this.nativeElement, this);
    }
    // change and blur events are added from the template
    handleEvent(node, eventName, callback, locals) {
        if (eventName !== 'change' && eventName !== 'blur') {
            super.handleEvent(node, eventName, callback, locals);
        }
    }
    handleChange(newVal) {
        this.invokeOnChange(this.datavalue, { type: 'change' }, this.ngModel.valid);
    }
    onPropertyChange(key, nv, ov) {
        if (key === 'tabindex') {
            return;
        }
        super.onPropertyChange(key, nv, ov);
    }
    static { this.ɵfac = function SliderComponent_Factory(t) { return new (t || SliderComponent)(i0.ɵɵdirectiveInject(i0.Injector), i0.ɵɵdirectiveInject('EXPLICIT_CONTEXT', 8)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SliderComponent, selectors: [["", "wmSlider", ""]], viewQuery: function SliderComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(NgModel, 5);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.ngModel = _t.first);
        } }, features: [i0.ɵɵProvidersFeature([
                provideAs(SliderComponent, NG_VALUE_ACCESSOR, true),
                provideAsWidgetRef(SliderComponent)
            ]), i0.ɵɵInheritDefinitionFeature], attrs: _c0, decls: 4, vars: 15, consts: [[1, "app-slider-value", "pull-left", 3, "textContent"], [1, "app-slider-value", "pull-right", 3, "textContent"], ["aria-orientation", "horizontal", "focus-target", "", "type", "range", 1, "range-input", 3, "ngModelChange", "blur", "title", "ngModel", "ngModelOptions", "disabled", "tabindex"], ["aria-readonly", "true", "class", "readonly-wrapper", 4, "ngIf"], ["aria-readonly", "true", 1, "readonly-wrapper"]], template: function SliderComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelement(0, "span", 0)(1, "span", 1);
            i0.ɵɵelementStart(2, "input", 2);
            i0.ɵɵtwoWayListener("ngModelChange", function SliderComponent_Template_input_ngModelChange_2_listener($event) { i0.ɵɵtwoWayBindingSet(ctx.datavalue, $event) || (ctx.datavalue = $event); return $event; });
            i0.ɵɵlistener("blur", function SliderComponent_Template_input_blur_2_listener($event) { return ctx.invokeOnTouched($event); })("ngModelChange", function SliderComponent_Template_input_ngModelChange_2_listener($event) { return ctx.handleChange($event); });
            i0.ɵɵelementEnd();
            i0.ɵɵtemplate(3, SliderComponent_div_3_Template, 1, 0, "div", 3);
        } if (rf & 2) {
            i0.ɵɵproperty("textContent", ctx.minvalue);
            i0.ɵɵadvance();
            i0.ɵɵproperty("textContent", ctx.maxvalue);
            i0.ɵɵadvance();
            i0.ɵɵproperty("title", ctx.datavalue);
            i0.ɵɵtwoWayProperty("ngModel", ctx.datavalue);
            i0.ɵɵproperty("ngModelOptions", i0.ɵɵpureFunction0(14, _c1))("disabled", ctx.disabled)("tabindex", ctx.tabindex);
            i0.ɵɵattribute("min", ctx.minvalue)("max", ctx.maxvalue)("step", ctx.step)("accesskey", ctx.shortcutkey)("aria-label", ctx.arialabel)("name", ctx.name);
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngIf", ctx.readonly || ctx.disabled);
        } }, dependencies: [i1.NgIf, i2.DefaultValueAccessor, i2.RangeValueAccessor, i2.NgControlStatus, i2.NgModel, i3.TextContentDirective], encapsulation: 2 }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SliderComponent, [{
        type: Component,
        args: [{ selector: '[wmSlider]', providers: [
                    provideAs(SliderComponent, NG_VALUE_ACCESSOR, true),
                    provideAsWidgetRef(SliderComponent)
                ], template: "<span [textContent]=\"minvalue\" class=\"app-slider-value pull-left\"></span>\n<span [textContent]=\"maxvalue\" class=\"app-slider-value pull-right\"></span>\n<input class=\"range-input\" aria-orientation=\"horizontal\"\n       focus-target\n       type=\"range\" [title]=\"datavalue\"\n       [attr.min]=\"minvalue\"\n       [attr.max]=\"maxvalue\"\n       [attr.step]=\"step\"\n       [(ngModel)]=\"datavalue\"\n       [ngModelOptions]=\"{standalone: true}\"\n       [disabled]=\"disabled\"\n       [attr.accesskey]=\"shortcutkey\"\n       [attr.aria-label]=\"arialabel\"\n       (blur)=\"invokeOnTouched($event)\"\n       (ngModelChange)=\"handleChange($event)\"\n       [attr.name]=\"name\"\n       [tabindex]=\"tabindex\"/>\n<div *ngIf=\"readonly || disabled\" aria-readonly=\"true\" class=\"readonly-wrapper\"></div>\n" }]
    }], () => [{ type: i0.Injector }, { type: undefined, decorators: [{
                type: Inject,
                args: ['EXPLICIT_CONTEXT']
            }, {
                type: Optional
            }] }], { ngModel: [{
            type: ViewChild,
            args: [NgModel]
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(SliderComponent, { className: "SliderComponent", filePath: "slider.component.ts", lineNumber: 24 }); })();

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

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

export { SliderComponent, SliderModule };
//# sourceMappingURL=index.mjs.map
