"use strict";
/*
 * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
 * This devtool is neither made for production nor for readable output files.
 * It uses "eval()" calls to create a separate source file in the browser devtools.
 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
 * or disable the default devtool with "devtool: false".
 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
 */
(self["webpackChunkwoocommerce_rtm_custom_emails"] = self["webpackChunkwoocommerce_rtm_custom_emails"] || []).push([["defaultVendors-1011~1013-4bcf9b47809968b8f518e7faa926923d-ObjectField.js"],{

/***/ 57662:
/*!**********************************************************************!*\
  !*** ./node_modules/@rjsf/core/lib/components/fields/ObjectField.js ***!
  \**********************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-runtime */ 85893);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ 99196);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _rjsf_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @rjsf/utils */ 64192);\n/* harmony import */ var markdown_to_jsx__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! markdown-to-jsx */ 35576);\n/* harmony import */ var lodash_get__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! lodash/get */ 27361);\n/* harmony import */ var lodash_get__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(lodash_get__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var lodash_has__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! lodash/has */ 18721);\n/* harmony import */ var lodash_has__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(lodash_has__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var lodash_isObject__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! lodash/isObject */ 13218);\n/* harmony import */ var lodash_isObject__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(lodash_isObject__WEBPACK_IMPORTED_MODULE_6__);\n/* harmony import */ var lodash_set__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! lodash/set */ 36968);\n/* harmony import */ var lodash_set__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(lodash_set__WEBPACK_IMPORTED_MODULE_7__);\n/* harmony import */ var lodash_unset__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! lodash/unset */ 98601);\n/* harmony import */ var lodash_unset__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(lodash_unset__WEBPACK_IMPORTED_MODULE_8__);\n\n\n\n\n\n\n\n\n\n/** The `ObjectField` component is used to render a field in the schema that is of type `object`. It tracks whether an\n * additional property key was modified and what it was modified to\n *\n * @param props - The `FieldProps` for this template\n */\nclass ObjectField extends react__WEBPACK_IMPORTED_MODULE_1__.Component {\n    constructor() {\n        super(...arguments);\n        /** Set up the initial state */\n        this.state = {\n            wasPropertyKeyModified: false,\n            additionalProperties: {},\n        };\n        /** Returns the `onPropertyChange` handler for the `name` field. Handles the special case where a user is attempting\n         * to clear the data for a field added as an additional property. Calls the `onChange()` handler with the updated\n         * formData.\n         *\n         * @param name - The name of the property\n         * @param addedByAdditionalProperties - Flag indicating whether this property is an additional property\n         * @returns - The onPropertyChange callback for the `name` property\n         */\n        this.onPropertyChange = (name, addedByAdditionalProperties = false) => {\n            return (value, newErrorSchema, id) => {\n                const { formData, onChange, errorSchema } = this.props;\n                if (value === undefined && addedByAdditionalProperties) {\n                    // Don't set value = undefined for fields added by\n                    // additionalProperties. Doing so removes them from the\n                    // formData, which causes them to completely disappear\n                    // (including the input field for the property name). Unlike\n                    // fields which are \"mandated\" by the schema, these fields can\n                    // be set to undefined by clicking a \"delete field\" button, so\n                    // set empty values to the empty string.\n                    value = '';\n                }\n                const newFormData = Object.assign(Object.assign({}, formData), { [name]: value });\n                onChange(newFormData, errorSchema &&\n                    errorSchema && Object.assign(Object.assign({}, errorSchema), { [name]: newErrorSchema }), id);\n            };\n        };\n        /** Returns a callback to handle the onDropPropertyClick event for the given `key` which removes the old `key` data\n         * and calls the `onChange` callback with it\n         *\n         * @param key - The key for which the drop callback is desired\n         * @returns - The drop property click callback\n         */\n        this.onDropPropertyClick = (key) => {\n            return (event) => {\n                event.preventDefault();\n                const { onChange, formData } = this.props;\n                const copiedFormData = Object.assign({}, formData);\n                lodash_unset__WEBPACK_IMPORTED_MODULE_8___default()(copiedFormData, key);\n                onChange(copiedFormData);\n            };\n        };\n        /** Computes the next available key name from the `preferredKey`, indexing through the already existing keys until one\n         * that is already not assigned is found.\n         *\n         * @param preferredKey - The preferred name of a new key\n         * @param [formData] - The form data in which to check if the desired key already exists\n         * @returns - The name of the next available key from `preferredKey`\n         */\n        this.getAvailableKey = (preferredKey, formData) => {\n            const { uiSchema, registry } = this.props;\n            const { duplicateKeySuffixSeparator = '-' } = (0,_rjsf_utils__WEBPACK_IMPORTED_MODULE_2__.getUiOptions)(uiSchema, registry.globalUiOptions);\n            let index = 0;\n            let newKey = preferredKey;\n            while (lodash_has__WEBPACK_IMPORTED_MODULE_5___default()(formData, newKey)) {\n                newKey = `${preferredKey}${duplicateKeySuffixSeparator}${++index}`;\n            }\n            return newKey;\n        };\n        /** Returns a callback function that deals with the rename of a key for an additional property for a schema. That\n         * callback will attempt to rename the key and move the existing data to that key, calling `onChange` when it does.\n         *\n         * @param oldValue - The old value of a field\n         * @returns - The key change callback function\n         */\n        this.onKeyChange = (oldValue) => {\n            return (value, newErrorSchema) => {\n                if (oldValue === value) {\n                    return;\n                }\n                const { formData, onChange, errorSchema } = this.props;\n                value = this.getAvailableKey(value, formData);\n                const newFormData = Object.assign({}, formData);\n                const newKeys = { [oldValue]: value };\n                const keyValues = Object.keys(newFormData).map((key) => {\n                    const newKey = newKeys[key] || key;\n                    return { [newKey]: newFormData[key] };\n                });\n                const renamedObj = Object.assign({}, ...keyValues);\n                this.setState({ wasPropertyKeyModified: true });\n                onChange(renamedObj, errorSchema &&\n                    errorSchema && Object.assign(Object.assign({}, errorSchema), { [value]: newErrorSchema }));\n            };\n        };\n        /** Handles the adding of a new additional property on the given `schema`. Calls the `onChange` callback once the new\n         * default data for that field has been added to the formData.\n         *\n         * @param schema - The schema element to which the new property is being added\n         */\n        this.handleAddClick = (schema) => () => {\n            if (!schema.additionalProperties) {\n                return;\n            }\n            const { formData, onChange, registry } = this.props;\n            const newFormData = Object.assign({}, formData);\n            let type = undefined;\n            if (lodash_isObject__WEBPACK_IMPORTED_MODULE_6___default()(schema.additionalProperties)) {\n                type = schema.additionalProperties.type;\n                let apSchema = schema.additionalProperties;\n                if (_rjsf_utils__WEBPACK_IMPORTED_MODULE_2__.REF_KEY in apSchema) {\n                    const { schemaUtils } = registry;\n                    apSchema = schemaUtils.retrieveSchema({ $ref: apSchema[_rjsf_utils__WEBPACK_IMPORTED_MODULE_2__.REF_KEY] }, formData);\n                    type = apSchema.type;\n                }\n                if (!type && (_rjsf_utils__WEBPACK_IMPORTED_MODULE_2__.ANY_OF_KEY in apSchema || _rjsf_utils__WEBPACK_IMPORTED_MODULE_2__.ONE_OF_KEY in apSchema)) {\n                    type = 'object';\n                }\n            }\n            const newKey = this.getAvailableKey('newKey', newFormData);\n            // Cast this to make the `set` work properly\n            lodash_set__WEBPACK_IMPORTED_MODULE_7___default()(newFormData, newKey, this.getDefaultValue(type));\n            onChange(newFormData);\n        };\n    }\n    /** Returns a flag indicating whether the `name` field is required in the object schema\n     *\n     * @param name - The name of the field to check for required-ness\n     * @returns - True if the field `name` is required, false otherwise\n     */\n    isRequired(name) {\n        const { schema } = this.props;\n        return Array.isArray(schema.required) && schema.required.indexOf(name) !== -1;\n    }\n    /** Returns a default value to be used for a new additional schema property of the given `type`\n     *\n     * @param type - The type of the new additional schema property\n     */\n    getDefaultValue(type) {\n        const { registry: { translateString }, } = this.props;\n        switch (type) {\n            case 'array':\n                return [];\n            case 'boolean':\n                return false;\n            case 'null':\n                return null;\n            case 'number':\n                return 0;\n            case 'object':\n                return {};\n            case 'string':\n            default:\n                // We don't have a datatype for some reason (perhaps additionalProperties was true)\n                return translateString(_rjsf_utils__WEBPACK_IMPORTED_MODULE_2__.TranslatableString.NewStringDefault);\n        }\n    }\n    /** Renders the `ObjectField` from the given props\n     */\n    render() {\n        var _a, _b, _c;\n        const { schema: rawSchema, uiSchema = {}, formData, errorSchema, idSchema, name, required = false, disabled = false, readonly = false, hideError, idPrefix, idSeparator, onBlur, onFocus, registry, } = this.props;\n        const { fields, formContext, schemaUtils, translateString, globalUiOptions } = registry;\n        const { SchemaField } = fields;\n        const schema = schemaUtils.retrieveSchema(rawSchema, formData);\n        const uiOptions = (0,_rjsf_utils__WEBPACK_IMPORTED_MODULE_2__.getUiOptions)(uiSchema, globalUiOptions);\n        const { properties: schemaProperties = {} } = schema;\n        const title = (_b = (_a = uiOptions.title) !== null && _a !== void 0 ? _a : schema.title) !== null && _b !== void 0 ? _b : name;\n        const description = (_c = uiOptions.description) !== null && _c !== void 0 ? _c : schema.description;\n        let orderedProperties;\n        try {\n            const properties = Object.keys(schemaProperties);\n            orderedProperties = (0,_rjsf_utils__WEBPACK_IMPORTED_MODULE_2__.orderProperties)(properties, uiOptions.order);\n        }\n        catch (err) {\n            return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(\"div\", { children: [(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(\"p\", Object.assign({ className: 'config-error', style: { color: 'red' } }, { children: (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(markdown_to_jsx__WEBPACK_IMPORTED_MODULE_3__[\"default\"], { children: translateString(_rjsf_utils__WEBPACK_IMPORTED_MODULE_2__.TranslatableString.InvalidObjectField, [name || 'root', err.message]) }) })), (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(\"pre\", { children: JSON.stringify(schema) })] }));\n        }\n        const Template = (0,_rjsf_utils__WEBPACK_IMPORTED_MODULE_2__.getTemplate)('ObjectFieldTemplate', registry, uiOptions);\n        const templateProps = {\n            // getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`\n            title: uiOptions.label === false ? '' : title,\n            description: uiOptions.label === false ? undefined : description,\n            properties: orderedProperties.map((name) => {\n                const addedByAdditionalProperties = lodash_has__WEBPACK_IMPORTED_MODULE_5___default()(schema, [_rjsf_utils__WEBPACK_IMPORTED_MODULE_2__.PROPERTIES_KEY, name, _rjsf_utils__WEBPACK_IMPORTED_MODULE_2__.ADDITIONAL_PROPERTY_FLAG]);\n                const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name];\n                const hidden = (0,_rjsf_utils__WEBPACK_IMPORTED_MODULE_2__.getUiOptions)(fieldUiSchema).widget === 'hidden';\n                const fieldIdSchema = lodash_get__WEBPACK_IMPORTED_MODULE_4___default()(idSchema, [name], {});\n                return {\n                    content: ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(SchemaField, { name: name, required: this.isRequired(name), schema: lodash_get__WEBPACK_IMPORTED_MODULE_4___default()(schema, [_rjsf_utils__WEBPACK_IMPORTED_MODULE_2__.PROPERTIES_KEY, name], {}), uiSchema: fieldUiSchema, errorSchema: lodash_get__WEBPACK_IMPORTED_MODULE_4___default()(errorSchema, name), idSchema: fieldIdSchema, idPrefix: idPrefix, idSeparator: idSeparator, formData: lodash_get__WEBPACK_IMPORTED_MODULE_4___default()(formData, name), formContext: formContext, wasPropertyKeyModified: this.state.wasPropertyKeyModified, onKeyChange: this.onKeyChange(name), onChange: this.onPropertyChange(name, addedByAdditionalProperties), onBlur: onBlur, onFocus: onFocus, registry: registry, disabled: disabled, readonly: readonly, hideError: hideError, onDropPropertyClick: this.onDropPropertyClick }, name)),\n                    name,\n                    readonly,\n                    disabled,\n                    required,\n                    hidden,\n                };\n            }),\n            readonly,\n            disabled,\n            required,\n            idSchema,\n            uiSchema,\n            errorSchema,\n            schema,\n            formData,\n            formContext,\n            registry,\n        };\n        return (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(Template, Object.assign({}, templateProps, { onAddClick: this.handleAddClick }));\n    }\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ObjectField);\n//# sourceMappingURL=ObjectField.js.map\n\n//# sourceURL=webpack://woocommerce-rtm-custom-emails/./node_modules/@rjsf/core/lib/components/fields/ObjectField.js?");

/***/ })

}]);