"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
const comp = require("../../ui/src/comp.js");
const XEUtils = require("xe-utils");
require("../../ui/index.js");
const utils = require("../../ui/src/utils.js");
const dom = require("../../ui/src/dom.js");
const util = require("./util.js");
const index$1 = require("../../tooltip/index.js");
const formConfigItem = require("./form-config-item.js");
const index = require("../../loading/index.js");
const vn = require("../../ui/src/vn.js");
const log = require("../../ui/src/log.js");
require("../render/index.js");
const validators = require("../../../../@vxe-ui/core/es/src/validators.js");
const config = require("../../../../@vxe-ui/core/es/src/config.js");
const useFns = require("../../../../@vxe-ui/core/es/src/useFns.js");
const event = require("../../../../@vxe-ui/core/es/src/event.js");
const renderer = require("../../../../@vxe-ui/core/es/src/renderer.js");
class Rule {
  constructor(rule) {
    Object.assign(this, {
      $options: rule,
      required: rule.required,
      min: rule.min,
      max: rule.min,
      type: rule.type,
      pattern: rule.pattern,
      validator: rule.validator,
      trigger: rule.trigger,
      maxWidth: rule.maxWidth
    });
  }
  get content() {
    return utils.getFuncText(this.$options.content || this.$options.message);
  }
  get message() {
    return this.content;
  }
}
function validREValue(pattern, val) {
  if (pattern && !(XEUtils.isRegExp(pattern) ? pattern : new RegExp(pattern)).test(val)) {
    return false;
  }
  return true;
}
function validMaxValue(max, num) {
  if (!XEUtils.eqNull(max) && num > XEUtils.toNumber(max)) {
    return false;
  }
  return true;
}
function validMinValue(min, num) {
  if (!XEUtils.eqNull(min) && num < XEUtils.toNumber(min)) {
    return false;
  }
  return true;
}
function validRuleValue(rule, val, required) {
  const { type, min, max, pattern } = rule;
  const isArrType = type === "array";
  const isNumType = type === "number";
  const isStrType = type === "string";
  const strVal = `${val}`;
  if (!validREValue(pattern, strVal)) {
    return false;
  }
  if (isArrType) {
    if (!XEUtils.isArray(val)) {
      return false;
    }
    if (required) {
      if (!val.length) {
        return false;
      }
    }
    if (!validMinValue(min, val.length)) {
      return false;
    }
    if (!validMaxValue(max, val.length)) {
      return false;
    }
  } else if (isNumType) {
    const numVal = Number(val);
    if (isNaN(numVal)) {
      return false;
    }
    if (!validMinValue(min, numVal)) {
      return false;
    }
    if (!validMaxValue(max, numVal)) {
      return false;
    }
  } else {
    if (isStrType) {
      if (!XEUtils.isString(val)) {
        return false;
      }
    }
    if (required) {
      if (!strVal) {
        return false;
      }
    }
    if (!validMinValue(min, strVal.length)) {
      return false;
    }
    if (!validMaxValue(max, strVal.length)) {
      return false;
    }
  }
  return true;
}
function checkRuleStatus(rule, data, val) {
  const { required, field } = rule;
  const currVal = field ? XEUtils.get(data, field) : val;
  const isEmptyVal = XEUtils.isArray(currVal) ? !currVal.length : utils.eqEmptyValue(currVal);
  if (required) {
    if (isEmptyVal) {
      return false;
    }
    if (!validRuleValue(rule, currVal, required)) {
      return false;
    }
  } else {
    if (!isEmptyVal) {
      if (!validRuleValue(rule, currVal, required)) {
        return false;
      }
    }
  }
  return true;
}
function createInternalData() {
  return {
    meTimeout: void 0,
    stTimeout: void 0,
    tooltipStore: {
      item: null,
      visible: false
    },
    itemFormatCache: {}
  };
}
const VxeFormComponent = comp.defineVxeComponent({
  name: "VxeForm",
  props: {
    collapseStatus: {
      type: Boolean,
      default: true
    },
    loading: Boolean,
    data: Object,
    size: {
      type: String,
      default: () => config.getConfig().form.size || config.getConfig().size
    },
    span: {
      type: [String, Number],
      default: () => config.getConfig().form.span
    },
    align: {
      type: String,
      default: () => config.getConfig().form.align
    },
    verticalAlign: {
      type: String,
      default: () => config.getConfig().form.verticalAlign
    },
    border: {
      type: Boolean,
      default: () => config.getConfig().form.border
    },
    titleBackground: {
      type: Boolean,
      default: () => config.getConfig().form.titleBackground
    },
    titleBold: {
      type: Boolean,
      default: () => config.getConfig().form.titleBold
    },
    titleAlign: {
      type: String,
      default: () => config.getConfig().form.titleAlign
    },
    titleWidth: {
      type: [String, Number],
      default: () => config.getConfig().form.titleWidth
    },
    titleColon: {
      type: Boolean,
      default: () => config.getConfig().form.titleColon
    },
    titleAsterisk: {
      type: Boolean,
      default: () => config.getConfig().form.titleAsterisk
    },
    titleOverflow: {
      type: [Boolean, String],
      default: () => config.getConfig().form.titleOverflow
    },
    vertical: {
      type: Boolean,
      default: () => config.getConfig().form.vertical
    },
    padding: {
      type: Boolean,
      default: () => config.getConfig().form.padding
    },
    className: [String, Function],
    readonly: Boolean,
    disabled: Boolean,
    items: Array,
    rules: Object,
    preventSubmit: {
      type: Boolean,
      default: () => config.getConfig().form.preventSubmit
    },
    validConfig: Object,
    tooltipConfig: Object,
    collapseConfig: Object,
    customLayout: {
      type: Boolean,
      default: () => config.getConfig().form.customLayout
    },
    params: Object
  },
  emits: [
    "update:collapseStatus",
    "collapse",
    "toggle-collapse",
    "submit",
    "submit-invalid",
    "reset"
  ],
  setup(props, context) {
    const { slots, emit } = context;
    const $xeGrid = vue.inject("$xeGrid", null);
    const xID = XEUtils.uniqueId();
    const { computeSize } = useFns.useSize(props);
    const reactData = vue.reactive({
      collapseAll: props.collapseStatus,
      staticItems: [],
      formItems: [],
      itemWidth: 0
    });
    const internalData = createInternalData();
    const refElem = vue.ref();
    const refTooltip = vue.ref();
    let formMethods = {};
    const computeValidOpts = vue.computed(() => {
      return Object.assign({}, config.getConfig().form.validConfig, props.validConfig);
    });
    const computeTooltipOpts = vue.computed(() => {
      return Object.assign({}, config.getConfig().tooltip, config.getConfig().form.tooltipConfig, props.tooltipConfig);
    });
    const computeCollapseOpts = vue.computed(() => {
      return Object.assign({}, config.getConfig().form.collapseConfig, props.collapseConfig);
    });
    const computeAutoItemWidthList = vue.computed(() => {
      const { titleWidth: allTitleWidth, vertical: allVertical } = props;
      const { formItems } = reactData;
      const itemList = [];
      XEUtils.eachTree(formItems, (item) => {
        const { titleWidth, vertical } = item;
        if (titleWidth === "auto") {
          itemList.push(item);
        } else {
          const itemVertical = XEUtils.eqNull(vertical) ? allVertical : vertical;
          const itemTitleWidth = itemVertical ? null : XEUtils.eqNull(titleWidth) ? allTitleWidth : titleWidth;
          if (itemTitleWidth === "auto" && (!item.children || !item.children.length)) {
            itemList.push(item);
          }
        }
      }, { children: "children" });
      return itemList;
    });
    const refMaps = {
      refElem
    };
    const computeMaps = {
      computeSize,
      computeValidOpts,
      computeTooltipOpts,
      computeCollapseOpts,
      computeAutoItemWidthList
    };
    const $xeForm = {
      xID,
      props,
      context,
      reactData,
      internalData,
      xeGrid: $xeGrid,
      getRefMaps: () => refMaps,
      getComputeMaps: () => computeMaps
    };
    const callSlot = (slotFunc, params) => {
      if (slotFunc) {
        if (XEUtils.isString(slotFunc)) {
          slotFunc = slots[slotFunc] || null;
        }
        if (XEUtils.isFunction(slotFunc)) {
          return vn.getSlotVNs(slotFunc(params));
        }
      }
      return [];
    };
    const loadItem = (list) => {
      if (list.length) {
        list.forEach((item) => {
          if (item.slots) {
            XEUtils.each(item.slots, (func) => {
              if (!XEUtils.isFunction(func)) {
                if (!slots[func]) {
                  log.errLog("vxe.error.notSlot", [`[form] ${func}`]);
                }
              }
            });
          }
        });
      }
      reactData.staticItems = XEUtils.mapTree(list, (item) => util.createItem($xeForm, item), { children: "children" });
      internalData.itemFormatCache = {};
      return vue.nextTick().then(() => {
        return recalculate();
      });
    };
    const getItems = () => {
      const itemList = [];
      XEUtils.eachTree(reactData.formItems, (item) => {
        itemList.push(item);
      }, { children: "children" });
      return itemList;
    };
    const getItemByField = (field) => {
      const rest = XEUtils.findTree(reactData.formItems, (item) => item.field === field, { children: "children" });
      return rest ? rest.item : null;
    };
    const getCollapseStatus = () => {
      return reactData.collapseAll;
    };
    const toggleCollapse = () => {
      const status = !getCollapseStatus();
      reactData.collapseAll = status;
      emit("update:collapseStatus", status);
      return vue.nextTick();
    };
    const toggleCollapseEvent = (evnt) => {
      const actionRest = toggleCollapse();
      const status = getCollapseStatus();
      formMethods.dispatchEvent("toggle-collapse", { status, collapse: status, data: props.data }, evnt);
      formMethods.dispatchEvent("collapse", { status, collapse: status, data: props.data }, evnt);
      actionRest.then(() => {
        recalculate().then(() => {
          if ($xeGrid) {
            $xeGrid.recalculate(true);
          }
        });
        if ($xeGrid) {
          $xeGrid.recalculate();
        }
      });
    };
    const clearValidate = (fieldOrItem) => {
      if (fieldOrItem) {
        let fields = fieldOrItem;
        if (!XEUtils.isArray(fieldOrItem)) {
          fields = [fieldOrItem];
        }
        fields.forEach((field) => {
          if (field) {
            const item = util.handleFieldOrItem($xeForm, field);
            if (item) {
              item.showError = false;
              item.showIconMsg = false;
            }
          }
        });
      } else {
        getItems().forEach((item) => {
          item.showError = false;
          item.showIconMsg = false;
        });
      }
      return vue.nextTick();
    };
    const getResetValue = (item, data, itemValue) => {
      const { field, resetValue } = item;
      if (XEUtils.isFunction(resetValue)) {
        return resetValue({ field, item, data, $form: $xeForm, $grid: $xeGrid });
      } else if (XEUtils.eqNull(resetValue)) {
        if (XEUtils.isArray(itemValue)) {
          return [];
        }
      }
      return resetValue;
    };
    const reset = () => {
      const { data } = props;
      const itemList = getItems();
      if (data) {
        itemList.forEach((item) => {
          const { field, itemRender } = item;
          if (utils.isEnableConf(itemRender)) {
            const { name, startField, endField } = itemRender;
            const compConf = renderer.renderer.get(name);
            const fiResetMethod = compConf ? compConf.formItemResetMethod || compConf.itemResetMethod : null;
            if (compConf && fiResetMethod) {
              fiResetMethod({ data, field, property: field, item, $form: $xeForm, $grid: $xeGrid });
            } else if (field) {
              const itemValue = XEUtils.get(data, field);
              XEUtils.set(data, field, getResetValue(item, data, itemValue));
            }
            if (startField && endField) {
              XEUtils.set(data, startField, getResetValue(item, data, XEUtils.get(data, startField)));
              XEUtils.set(data, endField, getResetValue(item, data, XEUtils.get(data, endField)));
            }
          }
        });
      }
      internalData.itemFormatCache = {};
      clearValidate();
      return recalculate();
    };
    const resetEvent = (evnt) => {
      evnt.preventDefault();
      reset();
      formMethods.dispatchEvent("reset", { data: props.data }, evnt);
    };
    const handleFocus = (fields) => {
      const el = refElem.value;
      if (el) {
        for (let i = 0; i < fields.length; i++) {
          const field = fields[i];
          const item = getItemByField(field);
          if (item && utils.isEnableConf(item.itemRender)) {
            const { itemRender } = item;
            const compConf = renderer.renderer.get(itemRender.name);
            if (!i) {
              dom.scrollToView(el.querySelector(`.${item.id}`));
            }
            let inputElem = null;
            const autoFocus = itemRender.autoFocus || itemRender.autofocus || (compConf ? compConf.formItemAutoFocus : null);
            if (XEUtils.isFunction(autoFocus)) {
              inputElem = autoFocus({ $form: $xeForm, $grid: $xeGrid, item, data: props.data, field });
            } else {
              if (autoFocus === true) {
                inputElem = el.querySelector(`.${item.id} input,textarea`);
              } else if (autoFocus) {
                inputElem = el.querySelector(`.${item.id} ${autoFocus}`);
              }
            }
            if (inputElem) {
              inputElem.focus();
              break;
            }
          }
        }
      }
    };
    const validItemRules = (validType, fields, val) => {
      const { data, rules: formRules } = props;
      const errorMaps = {};
      if (!XEUtils.isArray(fields)) {
        fields = [fields];
      }
      return Promise.all(fields.map((property) => {
        const errorRules = [];
        const syncVailds = [];
        if (property && formRules) {
          const rules = XEUtils.get(formRules, property);
          if (rules) {
            const itemValue = XEUtils.isUndefined(val) ? XEUtils.get(data, property) : val;
            rules.forEach((rule) => {
              const { trigger, validator } = rule;
              if (validType === "all" || !trigger || validType === trigger) {
                if (validator) {
                  const validParams = {
                    itemValue,
                    rule,
                    rules,
                    data,
                    field: property,
                    property,
                    $form: $xeForm
                  };
                  let customValid;
                  if (XEUtils.isString(validator)) {
                    const gvItem = validators.validators.get(validator);
                    if (gvItem) {
                      const validatorMethod = gvItem.formItemValidatorMethod || gvItem.itemValidatorMethod;
                      if (validatorMethod) {
                        customValid = validatorMethod(validParams);
                      } else {
                        log.warnLog("vxe.error.notValidators", [`[form] ${validator}`]);
                      }
                    } else {
                      log.errLog("vxe.error.notValidators", [`[form] ${validator}`]);
                    }
                  } else {
                    customValid = validator(validParams);
                  }
                  if (customValid) {
                    if (XEUtils.isError(customValid)) {
                      errorRules.push(new Rule({ type: "custom", trigger, content: customValid.message, rule: new Rule(rule) }));
                    } else if (customValid.catch) {
                      syncVailds.push(customValid.catch((e) => {
                        errorRules.push(new Rule({ type: "custom", trigger, content: e ? e.message : rule.content || rule.message, rule: new Rule(rule) }));
                      }));
                    }
                  }
                } else {
                  if (!checkRuleStatus(rule, data, itemValue)) {
                    errorRules.push(new Rule(rule));
                  }
                }
              }
            });
          }
        }
        return Promise.all(syncVailds).then(() => {
          if (errorRules.length) {
            errorMaps[property] = errorRules.map((rule) => {
              return {
                $form: $xeForm,
                rule,
                data,
                field: property,
                property
              };
            });
          }
        });
      })).then(() => {
        if (!XEUtils.isEmpty(errorMaps)) {
          return Promise.reject(errorMaps);
        }
      });
    };
    const beginValidate = (itemList, type, callback) => {
      const { data, rules: formRules } = props;
      const validOpts = computeValidOpts.value;
      const validRest = {};
      const validFields = [];
      const itemValids = [];
      clearTimeout(internalData.meTimeout);
      if (data && formRules) {
        itemList.forEach((item) => {
          const { field } = item;
          if (field && !util.isHiddenItem($xeForm, item) && util.isActiveItem($xeForm, item)) {
            itemValids.push(validItemRules(type || "all", field).then(() => {
              item.errRule = null;
            }).catch((errorMaps) => {
              const rest = errorMaps[field];
              if (!validRest[field]) {
                validRest[field] = [];
              }
              validRest[field].push(rest);
              validFields.push(field);
              item.errRule = rest[0].rule;
              return Promise.reject(rest);
            }));
          }
        });
        return Promise.all(itemValids).then(() => {
          if (callback) {
            callback();
          }
        }).catch(() => {
          return new Promise((resolve) => {
            internalData.meTimeout = setTimeout(() => {
              itemList.forEach((item) => {
                if (item.errRule) {
                  item.showError = true;
                }
              });
            }, 20);
            if (validOpts.autoPos !== false) {
              vue.nextTick(() => {
                handleFocus(validFields);
              });
            }
            if (callback) {
              callback(validRest);
              resolve();
            } else {
              resolve(validRest);
            }
          });
        });
      }
      if (callback) {
        callback();
      }
      return Promise.resolve();
    };
    const validate = (callback) => {
      const { readonly } = props;
      clearValidate();
      if (readonly) {
        return vue.nextTick();
      }
      return beginValidate(getItems(), "", callback).then((params) => {
        recalculate();
        return params;
      });
    };
    const validateField = (fieldOrItem, callback) => {
      const { readonly } = props;
      if (readonly) {
        return vue.nextTick();
      }
      let fields = [];
      if (fieldOrItem) {
        if (XEUtils.isArray(fieldOrItem)) {
          fields = fieldOrItem;
        } else {
          fields = [fieldOrItem];
        }
      }
      const itemList = fields.map((field) => util.handleFieldOrItem($xeForm, field));
      return beginValidate(itemList, "", callback).then((params) => {
        recalculate();
        return params;
      });
    };
    const handleSubmitEvent = (evnt) => {
      const { readonly } = props;
      clearValidate();
      if (readonly) {
        $xeForm.dispatchEvent("submit", { data: props.data }, evnt);
        recalculate();
        return;
      }
      beginValidate(getItems()).then((errMap) => {
        if (errMap) {
          $xeForm.dispatchEvent("submit-invalid", { data: props.data, errMap }, evnt);
        } else {
          $xeForm.dispatchEvent("submit", { data: props.data }, evnt);
        }
        recalculate();
      });
    };
    const submitEvent = (evnt) => {
      evnt.preventDefault();
      if (!props.preventSubmit) {
        handleSubmitEvent(evnt);
      }
    };
    const closeTooltip = () => {
      const { tooltipStore } = internalData;
      const $tooltip = refTooltip.value;
      if (tooltipStore.visible) {
        Object.assign(tooltipStore, {
          item: null,
          visible: false
        });
        if ($tooltip) {
          $tooltip.close();
        }
      }
      return vue.nextTick();
    };
    const triggerTitleTipEvent = (evnt, params) => {
      const { item } = params;
      const { tooltipStore } = internalData;
      const $tooltip = refTooltip.value;
      const overflowElem = evnt.currentTarget.children[0];
      const content = (overflowElem.textContent || "").trim();
      const isCellOverflow = overflowElem.scrollWidth > overflowElem.clientWidth;
      clearTimeout(internalData.stTimeout);
      if (tooltipStore.item !== item) {
        closeTooltip();
      }
      if (content && isCellOverflow) {
        Object.assign(tooltipStore, {
          item,
          visible: true
        });
        if ($tooltip) {
          $tooltip.open(overflowElem, content);
        }
      }
    };
    const handleTitleTipLeaveEvent = () => {
      const tooltipOpts = computeTooltipOpts.value;
      let $tooltip = refTooltip.value;
      if ($tooltip) {
        $tooltip.setActived(false);
      }
      if (tooltipOpts.enterable) {
        internalData.stTimeout = setTimeout(() => {
          $tooltip = refTooltip.value;
          if ($tooltip && !$tooltip.isActived()) {
            closeTooltip();
          }
        }, tooltipOpts.leaveDelay);
      } else {
        closeTooltip();
      }
    };
    const triggerItemEvent = (evnt, field, itemValue) => {
      if (field) {
        return validItemRules(evnt ? ["blur"].includes(evnt.type) ? "blur" : "change" : "all", field, itemValue).then(() => {
          clearValidate(field);
        }).catch((errorMaps) => {
          const rest = errorMaps[field];
          const item = getItemByField(field);
          if (rest && item) {
            item.showError = true;
            item.errRule = rest[0].rule;
          }
        });
      }
      return vue.nextTick();
    };
    const updateStatus = (scope, itemValue) => {
      const { field } = scope;
      return triggerItemEvent(new Event("change"), field, itemValue);
    };
    const recalculate = () => {
      const autoItemWidthList = computeAutoItemWidthList.value;
      const el = refElem.value;
      if (el && autoItemWidthList.length) {
        const itemElList = el.querySelectorAll(autoItemWidthList.map((item) => `.vxe-form--item-title[itemid="${item.id}"]`).join(","));
        let maxItemWidth = 0;
        XEUtils.arrayEach(itemElList, (itemEl) => {
          itemEl.style.width = "";
          maxItemWidth = Math.max(maxItemWidth, Math.ceil(itemEl.clientWidth + 2));
        });
        XEUtils.arrayEach(itemElList, (itemEl) => {
          itemEl.style.width = `${maxItemWidth}px`;
        });
      }
      return vue.nextTick();
    };
    const handleGlobalResizeEvent = () => {
      recalculate();
    };
    formMethods = {
      dispatchEvent(type, params, evnt) {
        emit(type, event.createEvent(evnt, { $form: $xeForm, $grid: $xeGrid }, params));
      },
      reset,
      validate,
      validateField,
      clearValidate,
      updateStatus,
      toggleCollapse,
      getItems,
      getItemByField,
      closeTooltip,
      recalculate
    };
    const formPrivateMethods = {
      callSlot,
      triggerItemEvent,
      toggleCollapseEvent,
      triggerTitleTipEvent,
      handleTitleTipLeaveEvent,
      handleValidIconEvent(evnt, params) {
        const { item } = params;
        item.showIconMsg = !item.showIconMsg;
      },
      handleSubmitEvent
    };
    Object.assign($xeForm, formMethods, formPrivateMethods);
    const renderVN = () => {
      const { loading, border, className, data, customLayout } = props;
      const { formItems } = reactData;
      const vSize = computeSize.value;
      const tooltipOpts = computeTooltipOpts.value;
      const defaultSlot = slots.default;
      return vue.h("form", {
        ref: refElem,
        class: ["vxe-form", className ? XEUtils.isFunction(className) ? className({ items: formItems, data, $form: $xeForm }) : className : "", {
          [`size--${vSize}`]: vSize,
          "is--border": border,
          "custom--layout": customLayout,
          "is--loading": loading
        }],
        onSubmit: submitEvent,
        onReset: resetEvent
      }, [
        vue.h("div", {
          class: "vxe-form--wrapper vxe-form--item-row"
        }, customLayout ? defaultSlot ? defaultSlot({}) : [] : formItems.map((item, index2) => {
          return vue.h(formConfigItem.default, {
            key: index2,
            itemConfig: item
          });
        })),
        vue.h("div", {
          class: "vxe-form-slots",
          ref: "hideItem"
        }, customLayout ? [] : defaultSlot ? defaultSlot({}) : []),
        /**
         * 加载中
         */
        vue.h(index.VxeLoading, {
          class: "vxe-form--loading",
          modelValue: loading
        }),
        /**
         * 工具提示
         */
        vue.h(index$1.VxeTooltip, Object.assign({ ref: refTooltip }, tooltipOpts))
      ]);
    };
    const recalcFlag = vue.ref(0);
    vue.watch(() => props.vertical, () => {
      recalcFlag.value++;
    });
    vue.watch(() => props.titleWidth, () => {
      recalcFlag.value++;
    });
    vue.watch(recalcFlag, () => {
      vue.nextTick().then(() => {
        recalculate();
      });
    });
    const staticItemFlag = vue.ref(0);
    vue.watch(() => reactData.staticItems.length, () => {
      staticItemFlag.value++;
    });
    vue.watch(() => reactData.staticItems, () => {
      staticItemFlag.value++;
    });
    vue.watch(staticItemFlag, () => {
      reactData.formItems = reactData.staticItems;
      recalcFlag.value++;
    });
    const itemFlag = vue.ref(0);
    vue.watch(() => props.items ? props.items.length : -1, () => {
      itemFlag.value++;
    });
    vue.watch(() => props.items, () => {
      itemFlag.value++;
    });
    vue.watch(itemFlag, () => {
      loadItem(props.items || []);
    });
    vue.watch(() => props.collapseStatus, (value) => {
      reactData.collapseAll = !!value;
    });
    vue.watch(() => props.readonly, () => {
      clearValidate();
    });
    vue.watch(() => props.disabled, () => {
      clearValidate();
    });
    vue.onMounted(() => {
      vue.nextTick(() => {
        if (props.customLayout && props.items) {
          log.errLog("vxe.error.errConflicts", ["[form] custom-layout", "items"]);
        }
      });
      event.globalEvents.on($xeForm, "resize", handleGlobalResizeEvent);
    });
    vue.onUnmounted(() => {
      event.globalEvents.off($xeForm, "resize");
      XEUtils.assign(internalData, createInternalData());
    });
    if (props.items) {
      loadItem(props.items);
    }
    vue.provide("xeFormItemInfo", null);
    vue.provide("$xeForm", $xeForm);
    vue.provide("$xeFormGroup", null);
    vue.provide("$xeFormItem", null);
    $xeForm.renderVN = renderVN;
    return $xeForm;
  },
  render() {
    return this.renderVN();
  }
});
exports.default = VxeFormComponent;
