/**
 * DevExtreme (esm/renovation/ui/scheduler/appointment_edit_form/layout.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 _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
import _extends from "@babel/runtime/helpers/esm/extends";
var _excluded = ["allowTimeZoneEditing", "allowUpdating", "appointmentData", "dataAccessors", "firstDayOfWeek", "formContentTemplate", "fullScreen", "maxWidth", "onVisibleChange", "visible"];
import {
    createComponentVNode,
    normalizeProps
} from "inferno";
import {
    BaseInfernoComponent
} from "@devextreme/runtime/inferno";
import {
    Popup
} from "../../overlays/popup";
import {
    defaultAnimation,
    getPopupToolbarItems,
    isPopupFullScreenNeeded,
    getMaxWidth
} from "./popup_config";
import {
    EditForm
} from "./edit_form/layout";
var APPOINTMENT_POPUP_CLASS = "dx-scheduler-appointment-popup";
var wrapperAttr = {
    class: APPOINTMENT_POPUP_CLASS
};
export var viewFunction = _ref => {
    var {
        props: {
            allowTimeZoneEditing: allowTimeZoneEditing,
            allowUpdating: allowUpdating,
            appointmentData: appointmentData,
            dataAccessors: dataAccessors,
            firstDayOfWeek: firstDayOfWeek,
            fullScreen: fullScreen,
            maxWidth: maxWidth,
            onVisibleChange: onVisibleChange,
            visible: visible
        },
        toolbarItems: toolbarItems
    } = _ref;
    return createComponentVNode(2, Popup, {
        className: APPOINTMENT_POPUP_CLASS,
        wrapperAttr: wrapperAttr,
        visible: visible,
        visibleChange: onVisibleChange,
        height: "auto",
        fullScreen: fullScreen,
        maxWidth: maxWidth,
        showCloseButton: false,
        showTitle: false,
        toolbarItems: toolbarItems,
        animation: defaultAnimation,
        children: createComponentVNode(2, EditForm, {
            appointmentData: appointmentData,
            dataAccessors: dataAccessors,
            allowUpdating: allowUpdating,
            firstDayOfWeek: firstDayOfWeek,
            allowTimeZoneEditing: allowTimeZoneEditing
        })
    })
};
export var AppointmentEditFormProps = {};
import {
    convertRulesToOptions
} from "../../../../core/options/utils";
var getTemplate = TemplateProp => TemplateProp && (TemplateProp.defaultProps ? props => normalizeProps(createComponentVNode(2, TemplateProp, _extends({}, props))) : TemplateProp);
export class AppointmentEditForm extends BaseInfernoComponent {
    constructor(props) {
        super(props);
        this.__getterCache = {};
        this.state = {
            isFullScreen: isPopupFullScreenNeeded(),
            maxWidth: getMaxWidth(isPopupFullScreenNeeded())
        }
    }
    get toolbarItems() {
        if (void 0 !== this.__getterCache.toolbarItems) {
            return this.__getterCache.toolbarItems
        }
        return this.__getterCache.toolbarItems = (() => getPopupToolbarItems(this.props.allowUpdating))()
    }
    get restAttributes() {
        var _this$props = this.props,
            restProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
        return restProps
    }
    componentWillUpdate(nextProps, nextState, context) {
        if (this.props.allowUpdating !== nextProps.allowUpdating) {
            this.__getterCache.toolbarItems = void 0
        }
    }
    render() {
        var props = this.props;
        return viewFunction({
            props: _extends({}, props, {
                formContentTemplate: getTemplate(props.formContentTemplate)
            }),
            isFullScreen: this.state.isFullScreen,
            maxWidth: this.state.maxWidth,
            toolbarItems: this.toolbarItems,
            restAttributes: this.restAttributes
        })
    }
}
AppointmentEditForm.defaultProps = AppointmentEditFormProps;
var __defaultOptionRules = [];
export function defaultOptions(rule) {
    __defaultOptionRules.push(rule);
    AppointmentEditForm.defaultProps = Object.create(Object.prototype, _extends(Object.getOwnPropertyDescriptors(AppointmentEditForm.defaultProps), Object.getOwnPropertyDescriptors(convertRulesToOptions(__defaultOptionRules))))
}
