/**
 * DevExtreme (esm/renovation/ui/scheduler/appointment_edit_form/edit_form/editors/switchEditor.js)
 * Version: 22.2.7 (build 23185-0311)
 * Build date: Tue Jul 04 2023
 *
 * Copyright (c) 2012 - 2023 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
var _excluded = ["value", "valueChange"];
import {
    createComponentVNode
} from "inferno";
import {
    InfernoEffect,
    InfernoComponent
} from "@devextreme/runtime/inferno";
import {
    Switch
} from "../../../../editors/switch";
export var viewFunction = _ref => {
    var {
        onToggle: onToggle,
        value: value
    } = _ref;
    return createComponentVNode(2, Switch, {
        value: value,
        valueChange: onToggle
    })
};
export var SwitchEditorProps = {};
import {
    convertRulesToOptions
} from "../../../../../../core/options/utils";
export class SwitchEditor extends InfernoComponent {
    constructor(props) {
        super(props);
        this.state = {
            value: void 0
        };
        this.initDate = this.initDate.bind(this);
        this.onToggle = this.onToggle.bind(this)
    }
    createEffects() {
        return [new InfernoEffect(this.initDate, [])]
    }
    initDate() {
        if (!this.state.value) {
            this.setState(__state_argument => ({
                value: this.props.value
            }))
        }
    }
    onToggle(value) {
        this.setState(__state_argument => ({
            value: value
        }));
        this.props.valueChange(value)
    }
    get restAttributes() {
        var _this$props = this.props,
            restProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
        return restProps
    }
    render() {
        var props = this.props;
        return viewFunction({
            props: _extends({}, props),
            value: this.state.value,
            onToggle: this.onToggle,
            restAttributes: this.restAttributes
        })
    }
}
SwitchEditor.defaultProps = SwitchEditorProps;
var __defaultOptionRules = [];
export function defaultOptions(rule) {
    __defaultOptionRules.push(rule);
    SwitchEditor.defaultProps = Object.create(Object.prototype, _extends(Object.getOwnPropertyDescriptors(SwitchEditor.defaultProps), Object.getOwnPropertyDescriptors(convertRulesToOptions(__defaultOptionRules))))
}
