'use strict';
Object.defineProperty(exports, '__esModule', {
    value: true
});
exports.default = eventsMixin;
var defaultEvents = {
    onChange: function () {}
};
function eventsMixin() {
    return {
        data() {
            return {
                inputEvents: defaultEvents
            };
        },
        lifetimes: {
            created: function () {
                this._oriTriggerEvent = this.triggerEvent;
                this.triggerEvent = this._triggerEvent;
            }
        },
        props: {
            events: {
                type: Object,
                value: defaultEvents
            }
        },
        definitionFilter: function (t) {
            Object.assign((t.data = t.data || {}), {
                inputEvents: Object.assign({}, defaultEvents, t.inputEvents)
            });
            Object.assign((t.methods = t.methods || {}), {
                _triggerEvent: function (t, e, n, i) {
                    var s = !(2 < arguments.length && void 0 !== n) || n;
                    if (3 < arguments.length) {
                        var a = i;
                    } else {
                        var a = void 0;
                    }
                    var r = this.inputEvents['on'.concat(t[0].toUpperCase()).concat(t.slice(1))];
                    if (s && 'function' == typeof r) {
                        r.call(this, e);
                    }
                    this._oriTriggerEvent(t, e, a);
                }
            });
            Object.assign((t.observers = t.observers || {}), {
                events: function (t) {
                    this.setData({
                        inputEvents: Object.assign({}, defaultEvents, this.inputEvents, t)
                    });
                }
            });
        }
    };
}
