import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
var _excluded = ["__designMode", "value", "defaultValue"],
  _excluded2 = ["__designMode"];
import * as React from 'react';
var createElement = React.createElement;
export var ValueWrapper = function ValueWrapper(NextFormComponent, displayName) {
  var WrappedComponent = function WrappedComponent(props) {
    var __designMode = props.__designMode,
      value = props.value,
      defaultValue = props.defaultValue,
      otherProps = _objectWithoutPropertiesLoose(props, _excluded);
    var finalValue = __designMode === 'design' ? defaultValue : value;
    if (typeof finalValue !== 'undefined') {
      otherProps.value = finalValue;
    }
    return createElement(NextFormComponent, _extends({}, otherProps));
  };
  WrappedComponent.displayName = displayName;
  return WrappedComponent;
};
export var DynamicPropWrapper = function DynamicPropWrapper(prop, NextFormComponent, displayName) {
  var WrappedComponent = function WrappedComponent(props) {
    var dynamicProp = prop;
    var defaultDynamicProp = "default" + prop.slice(0, 1).toUpperCase() + prop.slice(1);
    var __designMode = props.__designMode,
      otherProps = _objectWithoutPropertiesLoose(props, _excluded2);
    var dynamicPropValueValue = props[dynamicProp];
    var defaultDynamicPropValue = props[defaultDynamicProp];
    var finalValue = __designMode === 'design' ? defaultDynamicPropValue : dynamicPropValueValue;
    if (typeof finalValue !== 'undefined') {
      otherProps[dynamicProp] = finalValue;
    }
    return createElement(NextFormComponent, _extends({}, otherProps));
  };
  WrappedComponent.displayName = displayName;
  return WrappedComponent;
};