import { __awaiter, __generator } from "tslib";
import { GuideTourDefaultProps } from './props';
import mixinValue from '../mixins/value';
import '../_util/assert-component2';
Component({
    mixins: [
        mixinValue({
            valueKey: 'current',
            defaultValueKey: 'defaultCurrent',
        }),
    ],
    props: GuideTourDefaultProps,
    methods: {
        onNext: function () {
            return __awaiter(this, void 0, void 0, function () {
                var currentValue, onChange, newCurrent;
                return __generator(this, function (_a) {
                    currentValue = this.getValue();
                    onChange = this.props.onChange;
                    newCurrent = currentValue + 1;
                    if (!this.isControlled()) {
                        this.update(newCurrent);
                    }
                    if (onChange) {
                        onChange(newCurrent);
                    }
                    return [2 /*return*/];
                });
            });
        },
        onPrev: function () {
            return __awaiter(this, void 0, void 0, function () {
                var currentValue, onChange, newCurrent;
                return __generator(this, function (_a) {
                    currentValue = this.getValue();
                    onChange = this.props.onChange;
                    newCurrent = currentValue - 1;
                    if (!this.isControlled()) {
                        this.update(newCurrent);
                    }
                    if (onChange) {
                        onChange(newCurrent);
                    }
                    return [2 /*return*/];
                });
            });
        },
        onCancel: function () {
            var onCancel = this.props.onCancel;
            if (onCancel) {
                onCancel();
            }
        },
        onSwiperChange: function (e) {
            return __awaiter(this, void 0, void 0, function () {
                var current, onChange;
                return __generator(this, function (_a) {
                    current = e.detail.current;
                    onChange = this.props.onChange;
                    if (!this.isControlled()) {
                        this.update(current);
                    }
                    if (onChange) {
                        onChange(current);
                    }
                    return [2 /*return*/];
                });
            });
        },
    },
});
