From fab01d3884ccf76acc75480747eea3b0924dfc31 Mon Sep 17 00:00:00 2001 From: Abdi Tolessa <41271840+AbdiTolesa@users.noreply.github.com> Date: Wed, 11 Feb 2026 22:03:09 +0300 Subject: [PATCH 1/3] Fix duplicate html id errors --- classes/views/frm-forms/add_field_links.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/views/frm-forms/add_field_links.php b/classes/views/frm-forms/add_field_links.php index fc3146898c..fe22838b1a 100644 --- a/classes/views/frm-forms/add_field_links.php +++ b/classes/views/frm-forms/add_field_links.php @@ -13,7 +13,7 @@
")).replaceAll("
  • ",'
  • ",""),t.outerHTML=r)}),null===(e=document.querySelector(".preview.dropdown .frm-dropdown-toggle"))||void 0===e||e.setAttribute("data-bs-toggle","dropdown"),document.querySelectorAll("[data-toggle]").forEach(function(e){return e.setAttribute("data-bs-toggle",e.getAttribute("data-toggle"))})}),window.frm_show_div=function(e,t,r,n){t==r?jQuery(n+e).fadeIn("slow").css("visibility","visible"):jQuery(n+e).fadeOut("slow")},window.frmCheckAll=function(e,t){jQuery('input[name^="'+t+'"]').prop("checked",!!e)},window.frmCheckAllLevel=function(e,t,r){jQuery(".frm_catlevel_"+r).children(".frm_checkbox").children("label").children('input[name^="'+t+'"]').prop("checked",!!e)},window.frmGetFieldValues=function(e,t,r,n,i,o){e&&jQuery.ajax({type:"POST",url:ajaxurl,data:"action=frm_get_field_values¤t_field="+t+"&field_id="+e+"&name="+i+"&t="+n+"&form_action="+jQuery('input[name="frm_action"]').val()+"&nonce="+frmGlobal.nonce,success:function(e){document.getElementById("frm_show_selected_values_"+t+"_"+r).innerHTML=e,"function"==typeof o&&o()}})},window.frmImportCsv=function(e){var t="";"undefined"!=typeof __FRMURLVARS&&(t=__FRMURLVARS),jQuery.ajax({type:"POST",url:ajaxurl,data:"action=frm_import_csv&nonce="+frmGlobal.nonce+"&frm_skip_cookie=1"+t,success:function(t){var r=jQuery(".frm_admin_progress_bar").attr("aria-valuemax"),n=r-t,i=n/r*100;jQuery(".frm_admin_progress_bar").css("width",i+"%").attr("aria-valuenow",n),parseInt(t,10)>0?(jQuery(".frm_csv_remaining").html(t),frmImportCsv(e)):(jQuery(document.getElementById("frm_import_message")).html(frm_admin_js.import_complete),setTimeout(function(){location.href="?page=formidable-entries&frm_action=list&form="+e+"&import-message=1"},2e3))}})}})(); \ No newline at end of file +/******/ (() => { // webpackBootstrap +/******/ var __webpack_modules__ = ({ + +/***/ "./node_modules/@tannin/compile/index.js": +/*!***********************************************!*\ + !*** ./node_modules/@tannin/compile/index.js ***! + \***********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ compile) +/* harmony export */ }); +/* harmony import */ var _tannin_postfix__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tannin/postfix */ "./node_modules/@tannin/postfix/index.js"); +/* harmony import */ var _tannin_evaluate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tannin/evaluate */ "./node_modules/@tannin/evaluate/index.js"); + + + +/** + * Given a C expression, returns a function which can be called to evaluate its + * result. + * + * @example + * + * ```js + * import compile from '@tannin/compile'; + * + * const evaluate = compile( 'n > 1' ); + * + * evaluate( { n: 2 } ); + * // ⇒ true + * ``` + * + * @param {string} expression C expression. + * + * @return {(variables?:{[variable:string]:*})=>*} Compiled evaluator. + */ +function compile( expression ) { + var terms = (0,_tannin_postfix__WEBPACK_IMPORTED_MODULE_0__["default"])( expression ); + + return function( variables ) { + return (0,_tannin_evaluate__WEBPACK_IMPORTED_MODULE_1__["default"])( terms, variables ); + }; +} + + +/***/ }), + +/***/ "./node_modules/@tannin/evaluate/index.js": +/*!************************************************!*\ + !*** ./node_modules/@tannin/evaluate/index.js ***! + \************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ evaluate) +/* harmony export */ }); +/** + * Operator callback functions. + * + * @type {Object} + */ +var OPERATORS = { + '!': function( a ) { + return ! a; + }, + '*': function( a, b ) { + return a * b; + }, + '/': function( a, b ) { + return a / b; + }, + '%': function( a, b ) { + return a % b; + }, + '+': function( a, b ) { + return a + b; + }, + '-': function( a, b ) { + return a - b; + }, + '<': function( a, b ) { + return a < b; + }, + '<=': function( a, b ) { + return a <= b; + }, + '>': function( a, b ) { + return a > b; + }, + '>=': function( a, b ) { + return a >= b; + }, + '==': function( a, b ) { + return a === b; + }, + '!=': function( a, b ) { + return a !== b; + }, + '&&': function( a, b ) { + return a && b; + }, + '||': function( a, b ) { + return a || b; + }, + '?:': function( a, b, c ) { + if ( a ) { + throw b; + } + + return c; + }, +}; + +/** + * Given an array of postfix terms and operand variables, returns the result of + * the postfix evaluation. + * + * @example + * + * ```js + * import evaluate from '@tannin/evaluate'; + * + * // 3 + 4 * 5 / 6 ⇒ '3 4 5 * 6 / +' + * const terms = [ '3', '4', '5', '*', '6', '/', '+' ]; + * + * evaluate( terms, {} ); + * // ⇒ 6.333333333333334 + * ``` + * + * @param {string[]} postfix Postfix terms. + * @param {Object} variables Operand variables. + * + * @return {*} Result of evaluation. + */ +function evaluate( postfix, variables ) { + var stack = [], + i, j, args, getOperatorResult, term, value; + + for ( i = 0; i < postfix.length; i++ ) { + term = postfix[ i ]; + + getOperatorResult = OPERATORS[ term ]; + if ( getOperatorResult ) { + // Pop from stack by number of function arguments. + j = getOperatorResult.length; + args = Array( j ); + while ( j-- ) { + args[ j ] = stack.pop(); + } + + try { + value = getOperatorResult.apply( null, args ); + } catch ( earlyReturn ) { + return earlyReturn; + } + } else if ( variables.hasOwnProperty( term ) ) { + value = variables[ term ]; + } else { + value = +term; + } + + stack.push( value ); + } + + return stack[ 0 ]; +} + + +/***/ }), + +/***/ "./node_modules/@tannin/plural-forms/index.js": +/*!****************************************************!*\ + !*** ./node_modules/@tannin/plural-forms/index.js ***! + \****************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ pluralForms) +/* harmony export */ }); +/* harmony import */ var _tannin_compile__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tannin/compile */ "./node_modules/@tannin/compile/index.js"); + + +/** + * Given a C expression, returns a function which, when called with a value, + * evaluates the result with the value assumed to be the "n" variable of the + * expression. The result will be coerced to its numeric equivalent. + * + * @param {string} expression C expression. + * + * @return {Function} Evaluator function. + */ +function pluralForms( expression ) { + var evaluate = (0,_tannin_compile__WEBPACK_IMPORTED_MODULE_0__["default"])( expression ); + + return function( n ) { + return +evaluate( { n: n } ); + }; +} + + +/***/ }), + +/***/ "./node_modules/@tannin/postfix/index.js": +/*!***********************************************!*\ + !*** ./node_modules/@tannin/postfix/index.js ***! + \***********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ postfix) +/* harmony export */ }); +var PRECEDENCE, OPENERS, TERMINATORS, PATTERN; + +/** + * Operator precedence mapping. + * + * @type {Object} + */ +PRECEDENCE = { + '(': 9, + '!': 8, + '*': 7, + '/': 7, + '%': 7, + '+': 6, + '-': 6, + '<': 5, + '<=': 5, + '>': 5, + '>=': 5, + '==': 4, + '!=': 4, + '&&': 3, + '||': 2, + '?': 1, + '?:': 1, +}; + +/** + * Characters which signal pair opening, to be terminated by terminators. + * + * @type {string[]} + */ +OPENERS = [ '(', '?' ]; + +/** + * Characters which signal pair termination, the value an array with the + * opener as its first member. The second member is an optional operator + * replacement to push to the stack. + * + * @type {string[]} + */ +TERMINATORS = { + ')': [ '(' ], + ':': [ '?', '?:' ], +}; + +/** + * Pattern matching operators and openers. + * + * @type {RegExp} + */ +PATTERN = /<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/; + +/** + * Given a C expression, returns the equivalent postfix (Reverse Polish) + * notation terms as an array. + * + * If a postfix string is desired, simply `.join( ' ' )` the result. + * + * @example + * + * ```js + * import postfix from '@tannin/postfix'; + * + * postfix( 'n > 1' ); + * // ⇒ [ 'n', '1', '>' ] + * ``` + * + * @param {string} expression C expression. + * + * @return {string[]} Postfix terms. + */ +function postfix( expression ) { + var terms = [], + stack = [], + match, operator, term, element; + + while ( ( match = expression.match( PATTERN ) ) ) { + operator = match[ 0 ]; + + // Term is the string preceding the operator match. It may contain + // whitespace, and may be empty (if operator is at beginning). + term = expression.substr( 0, match.index ).trim(); + if ( term ) { + terms.push( term ); + } + + while ( ( element = stack.pop() ) ) { + if ( TERMINATORS[ operator ] ) { + if ( TERMINATORS[ operator ][ 0 ] === element ) { + // Substitution works here under assumption that because + // the assigned operator will no longer be a terminator, it + // will be pushed to the stack during the condition below. + operator = TERMINATORS[ operator ][ 1 ] || operator; + break; + } + } else if ( OPENERS.indexOf( element ) >= 0 || PRECEDENCE[ element ] < PRECEDENCE[ operator ] ) { + // Push to stack if either an opener or when pop reveals an + // element of lower precedence. + stack.push( element ); + break; + } + + // For each popped from stack, push to terms. + terms.push( element ); + } + + if ( ! TERMINATORS[ operator ] ) { + stack.push( operator ); + } + + // Slice matched fragment from expression to continue match. + expression = expression.substr( match.index + operator.length ); + } + + // Push remainder of operand, if exists, to terms. + expression = expression.trim(); + if ( expression ) { + terms.push( expression ); + } + + // Pop remaining items from stack into terms. + return terms.concat( stack.reverse() ); +} + + +/***/ }), + +/***/ "./node_modules/@wordpress/hooks/build-module/createAddHook.js": +/*!*********************************************************************!*\ + !*** ./node_modules/@wordpress/hooks/build-module/createAddHook.js ***! + \*********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var _validateNamespace_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./validateNamespace.js */ "./node_modules/@wordpress/hooks/build-module/validateNamespace.js"); +/* harmony import */ var _validateHookName_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./validateHookName.js */ "./node_modules/@wordpress/hooks/build-module/validateHookName.js"); +/** + * Internal dependencies + */ + + +/** + * @callback AddHook + * + * Adds the hook to the appropriate hooks container. + * + * @param {string} hookName Name of hook to add + * @param {string} namespace The unique namespace identifying the callback in the form `vendor/plugin/function`. + * @param {import('.').Callback} callback Function to call when the hook is run + * @param {number} [priority=10] Priority of this hook + */ + +/** + * Returns a function which, when invoked, will add a hook. + * + * @param {import('.').Hooks} hooks Hooks instance. + * @param {import('.').StoreKey} storeKey + * + * @return {AddHook} Function that adds a new hook. + */ + +function createAddHook(hooks, storeKey) { + return function addHook(hookName, namespace, callback) { + var priority = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 10; + var hooksStore = hooks[storeKey]; + + if (!(0,_validateHookName_js__WEBPACK_IMPORTED_MODULE_1__["default"])(hookName)) { + return; + } + + if (!(0,_validateNamespace_js__WEBPACK_IMPORTED_MODULE_0__["default"])(namespace)) { + return; + } + + if ('function' !== typeof callback) { + // eslint-disable-next-line no-console + console.error('The hook callback must be a function.'); + return; + } // Validate numeric priority + + + if ('number' !== typeof priority) { + // eslint-disable-next-line no-console + console.error('If specified, the hook priority must be a number.'); + return; + } + + var handler = { + callback: callback, + priority: priority, + namespace: namespace + }; + + if (hooksStore[hookName]) { + // Find the correct insert index of the new hook. + var handlers = hooksStore[hookName].handlers; + /** @type {number} */ + + var i; + + for (i = handlers.length; i > 0; i--) { + if (priority >= handlers[i - 1].priority) { + break; + } + } + + if (i === handlers.length) { + // If append, operate via direct assignment. + handlers[i] = handler; + } else { + // Otherwise, insert before index via splice. + handlers.splice(i, 0, handler); + } // We may also be currently executing this hook. If the callback + // we're adding would come after the current callback, there's no + // problem; otherwise we need to increase the execution index of + // any other runs by 1 to account for the added element. + + + hooksStore.__current.forEach(function (hookInfo) { + if (hookInfo.name === hookName && hookInfo.currentIndex >= i) { + hookInfo.currentIndex++; + } + }); + } else { + // This is the first hook of its type. + hooksStore[hookName] = { + handlers: [handler], + runs: 0 + }; + } + + if (hookName !== 'hookAdded') { + hooks.doAction('hookAdded', hookName, namespace, callback, priority); + } + }; +} + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (createAddHook); +//# sourceMappingURL=createAddHook.js.map + +/***/ }), + +/***/ "./node_modules/@wordpress/hooks/build-module/createCurrentHook.js": +/*!*************************************************************************!*\ + !*** ./node_modules/@wordpress/hooks/build-module/createCurrentHook.js ***! + \*************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/** + * Returns a function which, when invoked, will return the name of the + * currently running hook, or `null` if no hook of the given type is currently + * running. + * + * @param {import('.').Hooks} hooks Hooks instance. + * @param {import('.').StoreKey} storeKey + * + * @return {() => string | null} Function that returns the current hook name or null. + */ +function createCurrentHook(hooks, storeKey) { + return function currentHook() { + var _hooksStore$__current, _hooksStore$__current2; + + var hooksStore = hooks[storeKey]; + return (_hooksStore$__current = (_hooksStore$__current2 = hooksStore.__current[hooksStore.__current.length - 1]) === null || _hooksStore$__current2 === void 0 ? void 0 : _hooksStore$__current2.name) !== null && _hooksStore$__current !== void 0 ? _hooksStore$__current : null; + }; +} + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (createCurrentHook); +//# sourceMappingURL=createCurrentHook.js.map + +/***/ }), + +/***/ "./node_modules/@wordpress/hooks/build-module/createDidHook.js": +/*!*********************************************************************!*\ + !*** ./node_modules/@wordpress/hooks/build-module/createDidHook.js ***! + \*********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var _validateHookName_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./validateHookName.js */ "./node_modules/@wordpress/hooks/build-module/validateHookName.js"); +/** + * Internal dependencies + */ + +/** + * @callback DidHook + * + * Returns the number of times an action has been fired. + * + * @param {string} hookName The hook name to check. + * + * @return {number | undefined} The number of times the hook has run. + */ + +/** + * Returns a function which, when invoked, will return the number of times a + * hook has been called. + * + * @param {import('.').Hooks} hooks Hooks instance. + * @param {import('.').StoreKey} storeKey + * + * @return {DidHook} Function that returns a hook's call count. + */ + +function createDidHook(hooks, storeKey) { + return function didHook(hookName) { + var hooksStore = hooks[storeKey]; + + if (!(0,_validateHookName_js__WEBPACK_IMPORTED_MODULE_0__["default"])(hookName)) { + return; + } + + return hooksStore[hookName] && hooksStore[hookName].runs ? hooksStore[hookName].runs : 0; + }; +} + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (createDidHook); +//# sourceMappingURL=createDidHook.js.map + +/***/ }), + +/***/ "./node_modules/@wordpress/hooks/build-module/createDoingHook.js": +/*!***********************************************************************!*\ + !*** ./node_modules/@wordpress/hooks/build-module/createDoingHook.js ***! + \***********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/** + * @callback DoingHook + * Returns whether a hook is currently being executed. + * + * @param {string} [hookName] The name of the hook to check for. If + * omitted, will check for any hook being executed. + * + * @return {boolean} Whether the hook is being executed. + */ + +/** + * Returns a function which, when invoked, will return whether a hook is + * currently being executed. + * + * @param {import('.').Hooks} hooks Hooks instance. + * @param {import('.').StoreKey} storeKey + * + * @return {DoingHook} Function that returns whether a hook is currently + * being executed. + */ +function createDoingHook(hooks, storeKey) { + return function doingHook(hookName) { + var hooksStore = hooks[storeKey]; // If the hookName was not passed, check for any current hook. + + if ('undefined' === typeof hookName) { + return 'undefined' !== typeof hooksStore.__current[0]; + } // Return the __current hook. + + + return hooksStore.__current[0] ? hookName === hooksStore.__current[0].name : false; + }; +} + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (createDoingHook); +//# sourceMappingURL=createDoingHook.js.map + +/***/ }), + +/***/ "./node_modules/@wordpress/hooks/build-module/createHasHook.js": +/*!*********************************************************************!*\ + !*** ./node_modules/@wordpress/hooks/build-module/createHasHook.js ***! + \*********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/** + * @callback HasHook + * + * Returns whether any handlers are attached for the given hookName and optional namespace. + * + * @param {string} hookName The name of the hook to check for. + * @param {string} [namespace] Optional. The unique namespace identifying the callback + * in the form `vendor/plugin/function`. + * + * @return {boolean} Whether there are handlers that are attached to the given hook. + */ + +/** + * Returns a function which, when invoked, will return whether any handlers are + * attached to a particular hook. + * + * @param {import('.').Hooks} hooks Hooks instance. + * @param {import('.').StoreKey} storeKey + * + * @return {HasHook} Function that returns whether any handlers are + * attached to a particular hook and optional namespace. + */ +function createHasHook(hooks, storeKey) { + return function hasHook(hookName, namespace) { + var hooksStore = hooks[storeKey]; // Use the namespace if provided. + + if ('undefined' !== typeof namespace) { + return hookName in hooksStore && hooksStore[hookName].handlers.some(function (hook) { + return hook.namespace === namespace; + }); + } + + return hookName in hooksStore; + }; +} + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (createHasHook); +//# sourceMappingURL=createHasHook.js.map + +/***/ }), + +/***/ "./node_modules/@wordpress/hooks/build-module/createHooks.js": +/*!*******************************************************************!*\ + !*** ./node_modules/@wordpress/hooks/build-module/createHooks.js ***! + \*******************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ _Hooks: () => (/* binding */ _Hooks), +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var _babel_runtime_helpers_esm_classCallCheck__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/classCallCheck */ "./node_modules/@babel/runtime/helpers/esm/classCallCheck.js"); +/* harmony import */ var _createAddHook__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./createAddHook */ "./node_modules/@wordpress/hooks/build-module/createAddHook.js"); +/* harmony import */ var _createRemoveHook__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./createRemoveHook */ "./node_modules/@wordpress/hooks/build-module/createRemoveHook.js"); +/* harmony import */ var _createHasHook__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./createHasHook */ "./node_modules/@wordpress/hooks/build-module/createHasHook.js"); +/* harmony import */ var _createRunHook__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./createRunHook */ "./node_modules/@wordpress/hooks/build-module/createRunHook.js"); +/* harmony import */ var _createCurrentHook__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./createCurrentHook */ "./node_modules/@wordpress/hooks/build-module/createCurrentHook.js"); +/* harmony import */ var _createDoingHook__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./createDoingHook */ "./node_modules/@wordpress/hooks/build-module/createDoingHook.js"); +/* harmony import */ var _createDidHook__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./createDidHook */ "./node_modules/@wordpress/hooks/build-module/createDidHook.js"); + + +/** + * Internal dependencies + */ + + + + + + + +/** + * Internal class for constructing hooks. Use `createHooks()` function + * + * Note, it is necessary to expose this class to make its type public. + * + * @private + */ + +var _Hooks = function _Hooks() { + (0,_babel_runtime_helpers_esm_classCallCheck__WEBPACK_IMPORTED_MODULE_0__["default"])(this, _Hooks); + + /** @type {import('.').Store} actions */ + this.actions = Object.create(null); + this.actions.__current = []; + /** @type {import('.').Store} filters */ + + this.filters = Object.create(null); + this.filters.__current = []; + this.addAction = (0,_createAddHook__WEBPACK_IMPORTED_MODULE_1__["default"])(this, 'actions'); + this.addFilter = (0,_createAddHook__WEBPACK_IMPORTED_MODULE_1__["default"])(this, 'filters'); + this.removeAction = (0,_createRemoveHook__WEBPACK_IMPORTED_MODULE_2__["default"])(this, 'actions'); + this.removeFilter = (0,_createRemoveHook__WEBPACK_IMPORTED_MODULE_2__["default"])(this, 'filters'); + this.hasAction = (0,_createHasHook__WEBPACK_IMPORTED_MODULE_3__["default"])(this, 'actions'); + this.hasFilter = (0,_createHasHook__WEBPACK_IMPORTED_MODULE_3__["default"])(this, 'filters'); + this.removeAllActions = (0,_createRemoveHook__WEBPACK_IMPORTED_MODULE_2__["default"])(this, 'actions', true); + this.removeAllFilters = (0,_createRemoveHook__WEBPACK_IMPORTED_MODULE_2__["default"])(this, 'filters', true); + this.doAction = (0,_createRunHook__WEBPACK_IMPORTED_MODULE_4__["default"])(this, 'actions'); + this.applyFilters = (0,_createRunHook__WEBPACK_IMPORTED_MODULE_4__["default"])(this, 'filters', true); + this.currentAction = (0,_createCurrentHook__WEBPACK_IMPORTED_MODULE_5__["default"])(this, 'actions'); + this.currentFilter = (0,_createCurrentHook__WEBPACK_IMPORTED_MODULE_5__["default"])(this, 'filters'); + this.doingAction = (0,_createDoingHook__WEBPACK_IMPORTED_MODULE_6__["default"])(this, 'actions'); + this.doingFilter = (0,_createDoingHook__WEBPACK_IMPORTED_MODULE_6__["default"])(this, 'filters'); + this.didAction = (0,_createDidHook__WEBPACK_IMPORTED_MODULE_7__["default"])(this, 'actions'); + this.didFilter = (0,_createDidHook__WEBPACK_IMPORTED_MODULE_7__["default"])(this, 'filters'); +}; +/** @typedef {_Hooks} Hooks */ + +/** + * Returns an instance of the hooks object. + * + * @return {Hooks} A Hooks instance. + */ + +function createHooks() { + return new _Hooks(); +} + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (createHooks); +//# sourceMappingURL=createHooks.js.map + +/***/ }), + +/***/ "./node_modules/@wordpress/hooks/build-module/createRemoveHook.js": +/*!************************************************************************!*\ + !*** ./node_modules/@wordpress/hooks/build-module/createRemoveHook.js ***! + \************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var _validateNamespace_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./validateNamespace.js */ "./node_modules/@wordpress/hooks/build-module/validateNamespace.js"); +/* harmony import */ var _validateHookName_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./validateHookName.js */ "./node_modules/@wordpress/hooks/build-module/validateHookName.js"); +/** + * Internal dependencies + */ + + +/** + * @callback RemoveHook + * Removes the specified callback (or all callbacks) from the hook with a given hookName + * and namespace. + * + * @param {string} hookName The name of the hook to modify. + * @param {string} namespace The unique namespace identifying the callback in the + * form `vendor/plugin/function`. + * + * @return {number | undefined} The number of callbacks removed. + */ + +/** + * Returns a function which, when invoked, will remove a specified hook or all + * hooks by the given name. + * + * @param {import('.').Hooks} hooks Hooks instance. + * @param {import('.').StoreKey} storeKey + * @param {boolean} [removeAll=false] Whether to remove all callbacks for a hookName, + * without regard to namespace. Used to create + * `removeAll*` functions. + * + * @return {RemoveHook} Function that removes hooks. + */ + +function createRemoveHook(hooks, storeKey) { + var removeAll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + return function removeHook(hookName, namespace) { + var hooksStore = hooks[storeKey]; + + if (!(0,_validateHookName_js__WEBPACK_IMPORTED_MODULE_1__["default"])(hookName)) { + return; + } + + if (!removeAll && !(0,_validateNamespace_js__WEBPACK_IMPORTED_MODULE_0__["default"])(namespace)) { + return; + } // Bail if no hooks exist by this name + + + if (!hooksStore[hookName]) { + return 0; + } + + var handlersRemoved = 0; + + if (removeAll) { + handlersRemoved = hooksStore[hookName].handlers.length; + hooksStore[hookName] = { + runs: hooksStore[hookName].runs, + handlers: [] + }; + } else { + // Try to find the specified callback to remove. + var handlers = hooksStore[hookName].handlers; + + var _loop = function _loop(i) { + if (handlers[i].namespace === namespace) { + handlers.splice(i, 1); + handlersRemoved++; // This callback may also be part of a hook that is + // currently executing. If the callback we're removing + // comes after the current callback, there's no problem; + // otherwise we need to decrease the execution index of any + // other runs by 1 to account for the removed element. + + hooksStore.__current.forEach(function (hookInfo) { + if (hookInfo.name === hookName && hookInfo.currentIndex >= i) { + hookInfo.currentIndex--; + } + }); + } + }; + + for (var i = handlers.length - 1; i >= 0; i--) { + _loop(i); + } + } + + if (hookName !== 'hookRemoved') { + hooks.doAction('hookRemoved', hookName, namespace); + } + + return handlersRemoved; + }; +} + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (createRemoveHook); +//# sourceMappingURL=createRemoveHook.js.map + +/***/ }), + +/***/ "./node_modules/@wordpress/hooks/build-module/createRunHook.js": +/*!*********************************************************************!*\ + !*** ./node_modules/@wordpress/hooks/build-module/createRunHook.js ***! + \*********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var _babel_runtime_helpers_esm_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/toConsumableArray */ "./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js"); + + +/** + * Returns a function which, when invoked, will execute all callbacks + * registered to a hook of the specified type, optionally returning the final + * value of the call chain. + * + * @param {import('.').Hooks} hooks Hooks instance. + * @param {import('.').StoreKey} storeKey + * @param {boolean} [returnFirstArg=false] Whether each hook callback is expected to + * return its first argument. + * + * @return {(hookName:string, ...args: unknown[]) => unknown} Function that runs hook callbacks. + */ +function createRunHook(hooks, storeKey) { + var returnFirstArg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + return function runHooks(hookName) { + var hooksStore = hooks[storeKey]; + + if (!hooksStore[hookName]) { + hooksStore[hookName] = { + handlers: [], + runs: 0 + }; + } + + hooksStore[hookName].runs++; + var handlers = hooksStore[hookName].handlers; // The following code is stripped from production builds. + + if (true) { + // Handle any 'all' hooks registered. + if ('hookAdded' !== hookName && hooksStore.all) { + handlers.push.apply(handlers, (0,_babel_runtime_helpers_esm_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__["default"])(hooksStore.all.handlers)); + } + } + + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + if (!handlers || !handlers.length) { + return returnFirstArg ? args[0] : undefined; + } + + var hookInfo = { + name: hookName, + currentIndex: 0 + }; + + hooksStore.__current.push(hookInfo); + + while (hookInfo.currentIndex < handlers.length) { + var handler = handlers[hookInfo.currentIndex]; + var result = handler.callback.apply(null, args); + + if (returnFirstArg) { + args[0] = result; + } + + hookInfo.currentIndex++; + } + + hooksStore.__current.pop(); + + if (returnFirstArg) { + return args[0]; + } + }; +} + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (createRunHook); +//# sourceMappingURL=createRunHook.js.map + +/***/ }), + +/***/ "./node_modules/@wordpress/hooks/build-module/index.js": +/*!*************************************************************!*\ + !*** ./node_modules/@wordpress/hooks/build-module/index.js ***! + \*************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ actions: () => (/* binding */ actions), +/* harmony export */ addAction: () => (/* binding */ addAction), +/* harmony export */ addFilter: () => (/* binding */ addFilter), +/* harmony export */ applyFilters: () => (/* binding */ applyFilters), +/* harmony export */ createHooks: () => (/* reexport safe */ _createHooks__WEBPACK_IMPORTED_MODULE_0__["default"]), +/* harmony export */ currentAction: () => (/* binding */ currentAction), +/* harmony export */ currentFilter: () => (/* binding */ currentFilter), +/* harmony export */ defaultHooks: () => (/* binding */ defaultHooks), +/* harmony export */ didAction: () => (/* binding */ didAction), +/* harmony export */ didFilter: () => (/* binding */ didFilter), +/* harmony export */ doAction: () => (/* binding */ doAction), +/* harmony export */ doingAction: () => (/* binding */ doingAction), +/* harmony export */ doingFilter: () => (/* binding */ doingFilter), +/* harmony export */ filters: () => (/* binding */ filters), +/* harmony export */ hasAction: () => (/* binding */ hasAction), +/* harmony export */ hasFilter: () => (/* binding */ hasFilter), +/* harmony export */ removeAction: () => (/* binding */ removeAction), +/* harmony export */ removeAllActions: () => (/* binding */ removeAllActions), +/* harmony export */ removeAllFilters: () => (/* binding */ removeAllFilters), +/* harmony export */ removeFilter: () => (/* binding */ removeFilter) +/* harmony export */ }); +/* harmony import */ var _createHooks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./createHooks */ "./node_modules/@wordpress/hooks/build-module/createHooks.js"); +/** + * Internal dependencies + */ + +/** @typedef {(...args: any[])=>any} Callback */ + +/** + * @typedef Handler + * @property {Callback} callback The callback + * @property {string} namespace The namespace + * @property {number} priority The namespace + */ + +/** + * @typedef Hook + * @property {Handler[]} handlers Array of handlers + * @property {number} runs Run counter + */ + +/** + * @typedef Current + * @property {string} name Hook name + * @property {number} currentIndex The index + */ + +/** + * @typedef {Record & {__current: Current[]}} Store + */ + +/** + * @typedef {'actions' | 'filters'} StoreKey + */ + +/** + * @typedef {import('./createHooks').Hooks} Hooks + */ + +var defaultHooks = (0,_createHooks__WEBPACK_IMPORTED_MODULE_0__["default"])(); +var addAction = defaultHooks.addAction, + addFilter = defaultHooks.addFilter, + removeAction = defaultHooks.removeAction, + removeFilter = defaultHooks.removeFilter, + hasAction = defaultHooks.hasAction, + hasFilter = defaultHooks.hasFilter, + removeAllActions = defaultHooks.removeAllActions, + removeAllFilters = defaultHooks.removeAllFilters, + doAction = defaultHooks.doAction, + applyFilters = defaultHooks.applyFilters, + currentAction = defaultHooks.currentAction, + currentFilter = defaultHooks.currentFilter, + doingAction = defaultHooks.doingAction, + doingFilter = defaultHooks.doingFilter, + didAction = defaultHooks.didAction, + didFilter = defaultHooks.didFilter, + actions = defaultHooks.actions, + filters = defaultHooks.filters; + +//# sourceMappingURL=index.js.map + +/***/ }), + +/***/ "./node_modules/@wordpress/hooks/build-module/validateHookName.js": +/*!************************************************************************!*\ + !*** ./node_modules/@wordpress/hooks/build-module/validateHookName.js ***! + \************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/** + * Validate a hookName string. + * + * @param {string} hookName The hook name to validate. Should be a non empty string containing + * only numbers, letters, dashes, periods and underscores. Also, + * the hook name cannot begin with `__`. + * + * @return {boolean} Whether the hook name is valid. + */ +function validateHookName(hookName) { + if ('string' !== typeof hookName || '' === hookName) { + // eslint-disable-next-line no-console + console.error('The hook name must be a non-empty string.'); + return false; + } + + if (/^__/.test(hookName)) { + // eslint-disable-next-line no-console + console.error('The hook name cannot begin with `__`.'); + return false; + } + + if (!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(hookName)) { + // eslint-disable-next-line no-console + console.error('The hook name can only contain numbers, letters, dashes, periods and underscores.'); + return false; + } + + return true; +} + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (validateHookName); +//# sourceMappingURL=validateHookName.js.map + +/***/ }), + +/***/ "./node_modules/@wordpress/hooks/build-module/validateNamespace.js": +/*!*************************************************************************!*\ + !*** ./node_modules/@wordpress/hooks/build-module/validateNamespace.js ***! + \*************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/** + * Validate a namespace string. + * + * @param {string} namespace The namespace to validate - should take the form + * `vendor/plugin/function`. + * + * @return {boolean} Whether the namespace is valid. + */ +function validateNamespace(namespace) { + if ('string' !== typeof namespace || '' === namespace) { + // eslint-disable-next-line no-console + console.error('The namespace must be a non-empty string.'); + return false; + } + + if (!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(namespace)) { + // eslint-disable-next-line no-console + console.error('The namespace can only contain numbers, letters, dashes, periods, underscores and slashes.'); + return false; + } + + return true; +} + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (validateNamespace); +//# sourceMappingURL=validateNamespace.js.map + +/***/ }), + +/***/ "./node_modules/@wordpress/i18n/build-module/create-i18n.js": +/*!******************************************************************!*\ + !*** ./node_modules/@wordpress/i18n/build-module/create-i18n.js ***! + \******************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ createI18n: () => (/* binding */ createI18n) +/* harmony export */ }); +/* harmony import */ var _babel_runtime_helpers_esm_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/defineProperty */ "./node_modules/@babel/runtime/helpers/esm/defineProperty.js"); +/* harmony import */ var tannin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tannin */ "./node_modules/tannin/index.js"); + + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0,_babel_runtime_helpers_esm_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +/** + * External dependencies + */ + +/** + * @typedef {Record} LocaleData + */ + +/** + * Default locale data to use for Tannin domain when not otherwise provided. + * Assumes an English plural forms expression. + * + * @type {LocaleData} + */ + +var DEFAULT_LOCALE_DATA = { + '': { + /** @param {number} n */ + plural_forms: function plural_forms(n) { + return n === 1 ? 0 : 1; + } + } +}; +/* + * Regular expression that matches i18n hooks like `i18n.gettext`, `i18n.ngettext`, + * `i18n.gettext_domain` or `i18n.ngettext_with_context` or `i18n.has_translation`. + */ + +var I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/; +/** + * @typedef {(domain?: string) => LocaleData} GetLocaleData + * + * Returns locale data by domain in a + * Jed-formatted JSON object shape. + * + * @see http://messageformat.github.io/Jed/ + */ + +/** + * @typedef {(data?: LocaleData, domain?: string) => void} SetLocaleData + * + * Merges locale data into the Tannin instance by domain. Accepts data in a + * Jed-formatted JSON object shape. + * + * @see http://messageformat.github.io/Jed/ + */ + +/** + * @typedef {(data?: LocaleData, domain?: string) => void} ResetLocaleData + * + * Resets all current Tannin instance locale data and sets the specified + * locale data for the domain. Accepts data in a Jed-formatted JSON object shape. + * + * @see http://messageformat.github.io/Jed/ + */ + +/** @typedef {() => void} SubscribeCallback */ + +/** @typedef {() => void} UnsubscribeCallback */ + +/** + * @typedef {(callback: SubscribeCallback) => UnsubscribeCallback} Subscribe + * + * Subscribes to changes of locale data + */ + +/** + * @typedef {(domain?: string) => string} GetFilterDomain + * Retrieve the domain to use when calling domain-specific filters. + */ + +/** + * @typedef {(text: string, domain?: string) => string} __ + * + * Retrieve the translation of text. + * + * @see https://developer.wordpress.org/reference/functions/__/ + */ + +/** + * @typedef {(text: string, context: string, domain?: string) => string} _x + * + * Retrieve translated string with gettext context. + * + * @see https://developer.wordpress.org/reference/functions/_x/ + */ + +/** + * @typedef {(single: string, plural: string, number: number, domain?: string) => string} _n + * + * Translates and retrieves the singular or plural form based on the supplied + * number. + * + * @see https://developer.wordpress.org/reference/functions/_n/ + */ + +/** + * @typedef {(single: string, plural: string, number: number, context: string, domain?: string) => string} _nx + * + * Translates and retrieves the singular or plural form based on the supplied + * number, with gettext context. + * + * @see https://developer.wordpress.org/reference/functions/_nx/ + */ + +/** + * @typedef {() => boolean} IsRtl + * + * Check if current locale is RTL. + * + * **RTL (Right To Left)** is a locale property indicating that text is written from right to left. + * For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common + * language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages, + * including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`). + */ + +/** + * @typedef {(single: string, context?: string, domain?: string) => boolean} HasTranslation + * + * Check if there is a translation for a given string in singular form. + */ + +/** @typedef {import('@wordpress/hooks').Hooks} Hooks */ + +/** + * An i18n instance + * + * @typedef I18n + * @property {GetLocaleData} getLocaleData Returns locale data by domain in a Jed-formatted JSON object shape. + * @property {SetLocaleData} setLocaleData Merges locale data into the Tannin instance by domain. Accepts data in a + * Jed-formatted JSON object shape. + * @property {ResetLocaleData} resetLocaleData Resets all current Tannin instance locale data and sets the specified + * locale data for the domain. Accepts data in a Jed-formatted JSON object shape. + * @property {Subscribe} subscribe Subscribes to changes of Tannin locale data. + * @property {__} __ Retrieve the translation of text. + * @property {_x} _x Retrieve translated string with gettext context. + * @property {_n} _n Translates and retrieves the singular or plural form based on the supplied + * number. + * @property {_nx} _nx Translates and retrieves the singular or plural form based on the supplied + * number, with gettext context. + * @property {IsRtl} isRTL Check if current locale is RTL. + * @property {HasTranslation} hasTranslation Check if there is a translation for a given string. + */ + +/** + * Create an i18n instance + * + * @param {LocaleData} [initialData] Locale data configuration. + * @param {string} [initialDomain] Domain for which configuration applies. + * @param {Hooks} [hooks] Hooks implementation. + * @return {I18n} I18n instance + */ + +var createI18n = function createI18n(initialData, initialDomain, hooks) { + /** + * The underlying instance of Tannin to which exported functions interface. + * + * @type {Tannin} + */ + var tannin = new tannin__WEBPACK_IMPORTED_MODULE_1__["default"]({}); + var listeners = new Set(); + + var notifyListeners = function notifyListeners() { + listeners.forEach(function (listener) { + return listener(); + }); + }; + /** + * Subscribe to changes of locale data. + * + * @param {SubscribeCallback} callback Subscription callback. + * @return {UnsubscribeCallback} Unsubscribe callback. + */ + + + var subscribe = function subscribe(callback) { + listeners.add(callback); + return function () { + return listeners.delete(callback); + }; + }; + /** @type {GetLocaleData} */ + + + var getLocaleData = function getLocaleData() { + var domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default'; + return tannin.data[domain]; + }; + /** + * @param {LocaleData} [data] + * @param {string} [domain] + */ + + + var doSetLocaleData = function doSetLocaleData(data) { + var domain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default'; + tannin.data[domain] = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_LOCALE_DATA), tannin.data[domain]), data); // Populate default domain configuration (supported locale date which omits + // a plural forms expression). + + tannin.data[domain][''] = _objectSpread(_objectSpread({}, DEFAULT_LOCALE_DATA['']), tannin.data[domain]['']); + }; + /** @type {SetLocaleData} */ + + + var setLocaleData = function setLocaleData(data, domain) { + doSetLocaleData(data, domain); + notifyListeners(); + }; + /** @type {ResetLocaleData} */ + + + var resetLocaleData = function resetLocaleData(data, domain) { + // Reset all current Tannin locale data. + tannin.data = {}; // Reset cached plural forms functions cache. + + tannin.pluralForms = {}; + setLocaleData(data, domain); + }; + /** + * Wrapper for Tannin's `dcnpgettext`. Populates default locale data if not + * otherwise previously assigned. + * + * @param {string|undefined} domain Domain to retrieve the translated text. + * @param {string|undefined} context Context information for the translators. + * @param {string} single Text to translate if non-plural. Used as + * fallback return value on a caught error. + * @param {string} [plural] The text to be used if the number is + * plural. + * @param {number} [number] The number to compare against to use + * either the singular or plural form. + * + * @return {string} The translated string. + */ + + + var dcnpgettext = function dcnpgettext() { + var domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default'; + var context = arguments.length > 1 ? arguments[1] : undefined; + var single = arguments.length > 2 ? arguments[2] : undefined; + var plural = arguments.length > 3 ? arguments[3] : undefined; + var number = arguments.length > 4 ? arguments[4] : undefined; + + if (!tannin.data[domain]) { + // use `doSetLocaleData` to set silently, without notifying listeners + doSetLocaleData(undefined, domain); + } + + return tannin.dcnpgettext(domain, context, single, plural, number); + }; + /** @type {GetFilterDomain} */ + + + var getFilterDomain = function getFilterDomain() { + var domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default'; + return domain; + }; + /** @type {__} */ + + + var __ = function __(text, domain) { + var translation = dcnpgettext(domain, undefined, text); + + if (!hooks) { + return translation; + } + /** + * Filters text with its translation. + * + * @param {string} translation Translated text. + * @param {string} text Text to translate. + * @param {string} domain Text domain. Unique identifier for retrieving translated strings. + */ + + + translation = + /** @type {string} */ + + /** @type {*} */ + hooks.applyFilters('i18n.gettext', translation, text, domain); + return ( + /** @type {string} */ + + /** @type {*} */ + hooks.applyFilters('i18n.gettext_' + getFilterDomain(domain), translation, text, domain) + ); + }; + /** @type {_x} */ + + + var _x = function _x(text, context, domain) { + var translation = dcnpgettext(domain, context, text); + + if (!hooks) { + return translation; + } + /** + * Filters text with its translation based on context information. + * + * @param {string} translation Translated text. + * @param {string} text Text to translate. + * @param {string} context Context information for the translators. + * @param {string} domain Text domain. Unique identifier for retrieving translated strings. + */ + + + translation = + /** @type {string} */ + + /** @type {*} */ + hooks.applyFilters('i18n.gettext_with_context', translation, text, context, domain); + return ( + /** @type {string} */ + + /** @type {*} */ + hooks.applyFilters('i18n.gettext_with_context_' + getFilterDomain(domain), translation, text, context, domain) + ); + }; + /** @type {_n} */ + + + var _n = function _n(single, plural, number, domain) { + var translation = dcnpgettext(domain, undefined, single, plural, number); + + if (!hooks) { + return translation; + } + /** + * Filters the singular or plural form of a string. + * + * @param {string} translation Translated text. + * @param {string} single The text to be used if the number is singular. + * @param {string} plural The text to be used if the number is plural. + * @param {string} number The number to compare against to use either the singular or plural form. + * @param {string} domain Text domain. Unique identifier for retrieving translated strings. + */ + + + translation = + /** @type {string} */ + + /** @type {*} */ + hooks.applyFilters('i18n.ngettext', translation, single, plural, number, domain); + return ( + /** @type {string} */ + + /** @type {*} */ + hooks.applyFilters('i18n.ngettext_' + getFilterDomain(domain), translation, single, plural, number, domain) + ); + }; + /** @type {_nx} */ + + + var _nx = function _nx(single, plural, number, context, domain) { + var translation = dcnpgettext(domain, context, single, plural, number); + + if (!hooks) { + return translation; + } + /** + * Filters the singular or plural form of a string with gettext context. + * + * @param {string} translation Translated text. + * @param {string} single The text to be used if the number is singular. + * @param {string} plural The text to be used if the number is plural. + * @param {string} number The number to compare against to use either the singular or plural form. + * @param {string} context Context information for the translators. + * @param {string} domain Text domain. Unique identifier for retrieving translated strings. + */ + + + translation = + /** @type {string} */ + + /** @type {*} */ + hooks.applyFilters('i18n.ngettext_with_context', translation, single, plural, number, context, domain); + return ( + /** @type {string} */ + + /** @type {*} */ + hooks.applyFilters('i18n.ngettext_with_context_' + getFilterDomain(domain), translation, single, plural, number, context, domain) + ); + }; + /** @type {IsRtl} */ + + + var isRTL = function isRTL() { + return 'rtl' === _x('ltr', 'text direction'); + }; + /** @type {HasTranslation} */ + + + var hasTranslation = function hasTranslation(single, context, domain) { + var _tannin$data, _tannin$data2; + + var key = context ? context + "\x04" + single : single; + var result = !!((_tannin$data = tannin.data) !== null && _tannin$data !== void 0 && (_tannin$data2 = _tannin$data[domain !== null && domain !== void 0 ? domain : 'default']) !== null && _tannin$data2 !== void 0 && _tannin$data2[key]); + + if (hooks) { + /** + * Filters the presence of a translation in the locale data. + * + * @param {boolean} hasTranslation Whether the translation is present or not.. + * @param {string} single The singular form of the translated text (used as key in locale data) + * @param {string} context Context information for the translators. + * @param {string} domain Text domain. Unique identifier for retrieving translated strings. + */ + result = + /** @type { boolean } */ + + /** @type {*} */ + hooks.applyFilters('i18n.has_translation', result, single, context, domain); + result = + /** @type { boolean } */ + + /** @type {*} */ + hooks.applyFilters('i18n.has_translation_' + getFilterDomain(domain), result, single, context, domain); + } + + return result; + }; + + if (initialData) { + setLocaleData(initialData, initialDomain); + } + + if (hooks) { + /** + * @param {string} hookName + */ + var onHookAddedOrRemoved = function onHookAddedOrRemoved(hookName) { + if (I18N_HOOK_REGEXP.test(hookName)) { + notifyListeners(); + } + }; + + hooks.addAction('hookAdded', 'core/i18n', onHookAddedOrRemoved); + hooks.addAction('hookRemoved', 'core/i18n', onHookAddedOrRemoved); + } + + return { + getLocaleData: getLocaleData, + setLocaleData: setLocaleData, + resetLocaleData: resetLocaleData, + subscribe: subscribe, + __: __, + _x: _x, + _n: _n, + _nx: _nx, + isRTL: isRTL, + hasTranslation: hasTranslation + }; +}; +//# sourceMappingURL=create-i18n.js.map + +/***/ }), + +/***/ "./node_modules/@wordpress/i18n/build-module/default-i18n.js": +/*!*******************************************************************!*\ + !*** ./node_modules/@wordpress/i18n/build-module/default-i18n.js ***! + \*******************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ __: () => (/* binding */ __), +/* harmony export */ _n: () => (/* binding */ _n), +/* harmony export */ _nx: () => (/* binding */ _nx), +/* harmony export */ _x: () => (/* binding */ _x), +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__), +/* harmony export */ getLocaleData: () => (/* binding */ getLocaleData), +/* harmony export */ hasTranslation: () => (/* binding */ hasTranslation), +/* harmony export */ isRTL: () => (/* binding */ isRTL), +/* harmony export */ resetLocaleData: () => (/* binding */ resetLocaleData), +/* harmony export */ setLocaleData: () => (/* binding */ setLocaleData), +/* harmony export */ subscribe: () => (/* binding */ subscribe) +/* harmony export */ }); +/* harmony import */ var _create_i18n__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./create-i18n */ "./node_modules/@wordpress/i18n/build-module/create-i18n.js"); +/* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/hooks */ "./node_modules/@wordpress/hooks/build-module/index.js"); +/** + * Internal dependencies + */ + +/** + * WordPress dependencies + */ + + +var i18n = (0,_create_i18n__WEBPACK_IMPORTED_MODULE_0__.createI18n)(undefined, undefined, _wordpress_hooks__WEBPACK_IMPORTED_MODULE_1__.defaultHooks); +/** + * Default, singleton instance of `I18n`. + */ + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (i18n); +/* + * Comments in this file are duplicated from ./i18n due to + * https://github.com/WordPress/gutenberg/pull/20318#issuecomment-590837722 + */ + +/** + * @typedef {import('./create-i18n').LocaleData} LocaleData + * @typedef {import('./create-i18n').SubscribeCallback} SubscribeCallback + * @typedef {import('./create-i18n').UnsubscribeCallback} UnsubscribeCallback + */ + +/** + * Returns locale data by domain in a Jed-formatted JSON object shape. + * + * @see http://messageformat.github.io/Jed/ + * + * @param {string} [domain] Domain for which to get the data. + * @return {LocaleData} Locale data. + */ + +var getLocaleData = i18n.getLocaleData.bind(i18n); +/** + * Merges locale data into the Tannin instance by domain. Accepts data in a + * Jed-formatted JSON object shape. + * + * @see http://messageformat.github.io/Jed/ + * + * @param {LocaleData} [data] Locale data configuration. + * @param {string} [domain] Domain for which configuration applies. + */ + +var setLocaleData = i18n.setLocaleData.bind(i18n); +/** + * Resets all current Tannin instance locale data and sets the specified + * locale data for the domain. Accepts data in a Jed-formatted JSON object shape. + * + * @see http://messageformat.github.io/Jed/ + * + * @param {LocaleData} [data] Locale data configuration. + * @param {string} [domain] Domain for which configuration applies. + */ + +var resetLocaleData = i18n.resetLocaleData.bind(i18n); +/** + * Subscribes to changes of locale data + * + * @param {SubscribeCallback} callback Subscription callback + * @return {UnsubscribeCallback} Unsubscribe callback + */ + +var subscribe = i18n.subscribe.bind(i18n); +/** + * Retrieve the translation of text. + * + * @see https://developer.wordpress.org/reference/functions/__/ + * + * @param {string} text Text to translate. + * @param {string} [domain] Domain to retrieve the translated text. + * + * @return {string} Translated text. + */ + +var __ = i18n.__.bind(i18n); +/** + * Retrieve translated string with gettext context. + * + * @see https://developer.wordpress.org/reference/functions/_x/ + * + * @param {string} text Text to translate. + * @param {string} context Context information for the translators. + * @param {string} [domain] Domain to retrieve the translated text. + * + * @return {string} Translated context string without pipe. + */ + +var _x = i18n._x.bind(i18n); +/** + * Translates and retrieves the singular or plural form based on the supplied + * number. + * + * @see https://developer.wordpress.org/reference/functions/_n/ + * + * @param {string} single The text to be used if the number is singular. + * @param {string} plural The text to be used if the number is plural. + * @param {number} number The number to compare against to use either the + * singular or plural form. + * @param {string} [domain] Domain to retrieve the translated text. + * + * @return {string} The translated singular or plural form. + */ + +var _n = i18n._n.bind(i18n); +/** + * Translates and retrieves the singular or plural form based on the supplied + * number, with gettext context. + * + * @see https://developer.wordpress.org/reference/functions/_nx/ + * + * @param {string} single The text to be used if the number is singular. + * @param {string} plural The text to be used if the number is plural. + * @param {number} number The number to compare against to use either the + * singular or plural form. + * @param {string} context Context information for the translators. + * @param {string} [domain] Domain to retrieve the translated text. + * + * @return {string} The translated singular or plural form. + */ + +var _nx = i18n._nx.bind(i18n); +/** + * Check if current locale is RTL. + * + * **RTL (Right To Left)** is a locale property indicating that text is written from right to left. + * For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common + * language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages, + * including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`). + * + * @return {boolean} Whether locale is RTL. + */ + +var isRTL = i18n.isRTL.bind(i18n); +/** + * Check if there is a translation for a given string (in singular form). + * + * @param {string} single Singular form of the string to look up. + * @param {string} [context] Context information for the translators. + * @param {string} [domain] Domain to retrieve the translated text. + * @return {boolean} Whether the translation exists or not. + */ + +var hasTranslation = i18n.hasTranslation.bind(i18n); +//# sourceMappingURL=default-i18n.js.map + +/***/ }), + +/***/ "./node_modules/@wordpress/i18n/build-module/index.js": +/*!************************************************************!*\ + !*** ./node_modules/@wordpress/i18n/build-module/index.js ***! + \************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ __: () => (/* reexport safe */ _default_i18n__WEBPACK_IMPORTED_MODULE_2__.__), +/* harmony export */ _n: () => (/* reexport safe */ _default_i18n__WEBPACK_IMPORTED_MODULE_2__._n), +/* harmony export */ _nx: () => (/* reexport safe */ _default_i18n__WEBPACK_IMPORTED_MODULE_2__._nx), +/* harmony export */ _x: () => (/* reexport safe */ _default_i18n__WEBPACK_IMPORTED_MODULE_2__._x), +/* harmony export */ createI18n: () => (/* reexport safe */ _create_i18n__WEBPACK_IMPORTED_MODULE_1__.createI18n), +/* harmony export */ defaultI18n: () => (/* reexport safe */ _default_i18n__WEBPACK_IMPORTED_MODULE_2__["default"]), +/* harmony export */ getLocaleData: () => (/* reexport safe */ _default_i18n__WEBPACK_IMPORTED_MODULE_2__.getLocaleData), +/* harmony export */ hasTranslation: () => (/* reexport safe */ _default_i18n__WEBPACK_IMPORTED_MODULE_2__.hasTranslation), +/* harmony export */ isRTL: () => (/* reexport safe */ _default_i18n__WEBPACK_IMPORTED_MODULE_2__.isRTL), +/* harmony export */ resetLocaleData: () => (/* reexport safe */ _default_i18n__WEBPACK_IMPORTED_MODULE_2__.resetLocaleData), +/* harmony export */ setLocaleData: () => (/* reexport safe */ _default_i18n__WEBPACK_IMPORTED_MODULE_2__.setLocaleData), +/* harmony export */ sprintf: () => (/* reexport safe */ _sprintf__WEBPACK_IMPORTED_MODULE_0__.sprintf), +/* harmony export */ subscribe: () => (/* reexport safe */ _default_i18n__WEBPACK_IMPORTED_MODULE_2__.subscribe) +/* harmony export */ }); +/* harmony import */ var _sprintf__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sprintf */ "./node_modules/@wordpress/i18n/build-module/sprintf.js"); +/* harmony import */ var _create_i18n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./create-i18n */ "./node_modules/@wordpress/i18n/build-module/create-i18n.js"); +/* harmony import */ var _default_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./default-i18n */ "./node_modules/@wordpress/i18n/build-module/default-i18n.js"); + + + +//# sourceMappingURL=index.js.map + +/***/ }), + +/***/ "./node_modules/@wordpress/i18n/build-module/sprintf.js": +/*!**************************************************************!*\ + !*** ./node_modules/@wordpress/i18n/build-module/sprintf.js ***! + \**************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ sprintf: () => (/* binding */ sprintf) +/* harmony export */ }); +/* harmony import */ var memize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! memize */ "./node_modules/memize/index.js"); +/* harmony import */ var memize__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(memize__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var sprintf_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! sprintf-js */ "./node_modules/sprintf-js/src/sprintf.js"); +/* harmony import */ var sprintf_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(sprintf_js__WEBPACK_IMPORTED_MODULE_1__); +/** + * External dependencies + */ + + +/** + * Log to console, once per message; or more precisely, per referentially equal + * argument set. Because Jed throws errors, we log these to the console instead + * to avoid crashing the application. + * + * @param {...*} args Arguments to pass to `console.error` + */ + +var logErrorOnce = memize__WEBPACK_IMPORTED_MODULE_0___default()(console.error); // eslint-disable-line no-console + +/** + * Returns a formatted string. If an error occurs in applying the format, the + * original format string is returned. + * + * @param {string} format The format of the string to generate. + * @param {...*} args Arguments to apply to the format. + * + * @see https://www.npmjs.com/package/sprintf-js + * + * @return {string} The formatted string. + */ + +function sprintf(format) { + try { + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + return sprintf_js__WEBPACK_IMPORTED_MODULE_1___default().sprintf.apply((sprintf_js__WEBPACK_IMPORTED_MODULE_1___default()), [format].concat(args)); + } catch (error) { + logErrorOnce('sprintf error: \n\n' + error.toString()); + return format; + } +} +//# sourceMappingURL=sprintf.js.map + +/***/ }), + +/***/ "./js/src/admin/addon-state.js": +/*!*************************************!*\ + !*** ./js/src/admin/addon-state.js ***! + \*************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ addonError: () => (/* binding */ addonError), +/* harmony export */ afterAddonInstall: () => (/* binding */ afterAddonInstall), +/* harmony export */ extractErrorFromAddOnResponse: () => (/* binding */ extractErrorFromAddOnResponse), +/* harmony export */ toggleAddonState: () => (/* binding */ toggleAddonState) +/* harmony export */ }); +/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/i18n */ "./node_modules/@wordpress/i18n/build-module/index.js"); + +var _frmDom = frmDom, + div = _frmDom.div, + svg = _frmDom.svg; + +/** + * Toggles the state of an add-on (ie. enable or disable an add-on). + * + * @param {Element} clicked + * @param {string} action + */ +function toggleAddonState(clicked, action) { + var _window$ajaxurl; + var ajaxurl = (_window$ajaxurl = window.ajaxurl) !== null && _window$ajaxurl !== void 0 ? _window$ajaxurl : frm_js.ajax_url; // eslint-disable-line camelcase + + // Remove any leftover error messages, output an icon and get the plugin basename that needs to be activated. + jQuery('.frm-addon-error').remove(); + var button = jQuery(clicked); + var plugin = button.attr('rel'); + var el = button.parent(); + var message = el.parent().find('.addon-status-label'); + button.addClass('frm_loading_button'); + + // Process the Ajax to perform the activation. + jQuery.ajax({ + url: ajaxurl, + type: 'POST', + async: true, + cache: false, + dataType: 'json', + data: { + action: action, + nonce: frmGlobal.nonce, + plugin: plugin + }, + success: function success(response) { + var _response$data, _response; + response = (_response$data = (_response = response) === null || _response === void 0 ? void 0 : _response.data) !== null && _response$data !== void 0 ? _response$data : response; + var saveAndReload; + if ('string' !== typeof response && 'string' === typeof response.message) { + if ('undefined' !== typeof response.saveAndReload) { + saveAndReload = response.saveAndReload; + } + response = response.message; + } + var error = extractErrorFromAddOnResponse(response); + if (error) { + addonError(error, el, button); + return; + } + afterAddonInstall(response, button, message, el, saveAndReload, action); + + /** + * Trigger an action after successfully toggling the addon state. + * + * @param {Object} response + */ + wp.hooks.doAction('frm_update_addon_state', response); + }, + error: function error() { + button.removeClass('frm_loading_button'); + } + }); +} +function extractErrorFromAddOnResponse(response) { + if (typeof response !== 'string') { + if (typeof response.success !== 'undefined' && response.success) { + return false; + } + if (response.form) { + if (jQuery(response.form).is('#message')) { + return { + message: jQuery(response.form).find('p').html() + }; + } + } + return response; + } + return false; +} +function afterAddonInstall(response, button, message, el, saveAndReload) { + var action = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 'frm_activate_addon'; + var frmAdminJs = frm_admin_js; // eslint-disable-line camelcase + + var addonStatuses = document.querySelectorAll('.frm-addon-status'); + addonStatuses.forEach(function (addonStatus) { + addonStatus.textContent = response; + addonStatus.style.display = 'block'; + }); + + // The Ajax request was successful, so let's update the output. + button.css({ + opacity: '0' + }); + document.querySelectorAll('.frm-oneclick').forEach(function (oneClick) { + oneClick.style.display = 'none'; + }); + showUpgradeModalSuccess(); + + // Proceed with CSS changes + var actionMap = { + frm_activate_addon: { + class: 'frm-addon-active', + message: frmAdminJs.active + }, + frm_deactivate_addon: { + class: 'frm-addon-installed', + message: frmAdminJs.installed + }, + frm_uninstall_addon: { + class: 'frm-addon-not-installed', + message: frmAdminJs.not_installed + } + }; + actionMap.frm_install_addon = actionMap.frm_activate_addon; + var messageElement = message[0]; + if (messageElement) { + messageElement.textContent = actionMap[action].message; + } + var parentElement = el[0].parentElement; + parentElement.classList.remove('frm-addon-not-installed', 'frm-addon-installed', 'frm-addon-active'); + parentElement.classList.add(actionMap[action].class); + var buttonElement = button[0]; + buttonElement.classList.remove('frm_loading_button'); + + // Maybe refresh import and SMTP pages + var refreshPage = document.querySelectorAll('.frm-admin-page-import, #frm-admin-smtp, #frm-welcome'); + if (refreshPage.length > 0) { + window.location.reload(); + return; + } + if (['settings', 'form_builder'].includes(saveAndReload)) { + addonStatuses.forEach(function (addonStatus) { + var inModal = null !== addonStatus.closest('#frm_upgrade_modal'); + addonStatus.append(getSaveAndReloadSettingsOptions(saveAndReload, inModal)); + }); + } +} +function addonError(response, el, button) { + if (response.form) { + jQuery('.frm-inline-error').remove(); + button.closest('.frm-card').html(response.form).css({ + padding: 5 + }).find('#upgrade').attr('rel', button.attr('rel')).on('click', installAddonWithCreds); + } else { + el.append('

    ' + response.message + '

    '); + button.removeClass('frm_loading_button'); + jQuery('.frm-addon-error').delay(4000).fadeOut(); + } +} +function getSaveAndReloadSettingsOptions(saveAndReload, inModal) { + var className = 'frm-save-and-reload-options'; + var children = [saveAndReloadSettingsButton(saveAndReload)]; + if (inModal) { + children.push(closePopupButton()); + } + return div({ + className: className, + children: children + }); +} +function saveAndReloadSettingsButton(saveAndReload) { + var button = document.createElement('button'); + button.classList.add('frm-save-and-reload', 'button', 'button-primary', 'frm-button-primary'); + button.textContent = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__.__)('Save and Reload', 'formidable'); + button.addEventListener('click', function () { + if (saveAndReload === 'form_builder') { + saveAndReloadFormBuilder(); + } else if (saveAndReload === 'settings') { + saveAndReloadSettings(); + } + }); + return button; +} +function saveAndReloadSettings() { + var page = document.getElementById('form_settings_page'); + if (null !== page) { + var form = page.querySelector('form.frm_form_settings'); + if (null !== form) { + wp.hooks.doAction('frm_reset_fields_updated'); + form.submit(); + } + } +} +function closePopupButton() { + var a = document.createElement('a'); + a.setAttribute('href', '#'); + a.classList.add('button', 'button-secondary', 'frm-button-secondary', 'dismiss'); + a.textContent = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__.__)('Not Now', 'formidable'); + return a; +} +function saveAndReloadFormBuilder() { + var submitButton = document.getElementById('frm_submit_side_top'); + if (submitButton.classList.contains('frm_submit_ajax')) { + submitButton.setAttribute('data-new-addon-installed', true); + } + submitButton.click(); +} + +/** + * Updates the upgrade modal to show successful addon installation state. + * + * @private + * @return {void} + */ +function showUpgradeModalSuccess() { + var upgradeModal = document.getElementById('frm_upgrade_modal'); + if (!upgradeModal) { + return; + } + upgradeModal.classList.add('frm-success'); + var upgradeMessage = upgradeModal.querySelector('.frm-upgrade-message'); + if (upgradeMessage) { + var image = upgradeMessage.querySelector('img'); + upgradeMessage.replaceChildren((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__.__)('Great! Everything\'s ready to go!', 'formidable'), document.createElement('br'), (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__.__)('You just need to refresh the builder so the new field becomes available.', 'formidable')); + if (image) { + upgradeMessage.append(image); + } + } + var frmAddonStatus = document.querySelector('.frm-addon-status'); + if (frmAddonStatus) { + frmAddonStatus.textContent = ''; + } + var circledIcon = upgradeModal.querySelector('.frm-circled-icon'); + if (circledIcon) { + var _circledIcon$querySel; + circledIcon.classList.add('frm-circled-icon-green'); + (_circledIcon$querySel = circledIcon.querySelector('svg')) === null || _circledIcon$querySel === void 0 || _circledIcon$querySel.replaceWith(svg({ + href: '#frm_checkmark_icon' + })); + } +} +function installAddonWithCreds(e) { + // Prevent the default action, let the user know we are attempting to install again and go with it. + e.preventDefault(); + + // Now let's make another Ajax request once the user has submitted their credentials. + var proceed = jQuery(this); + var el = proceed.parent().parent(); + var plugin = proceed.attr('rel'); + proceed.addClass('frm_loading_button'); + jQuery.ajax({ + url: ajaxurl, + type: 'POST', + async: true, + cache: false, + dataType: 'json', + data: { + action: 'frm_install_addon', + nonce: frmAdminJs.nonce, + plugin: plugin, + hostname: el.find('#hostname').val(), + username: el.find('#username').val(), + password: el.find('#password').val() + }, + success: function success(response) { + var _response$data2, _response2; + response = (_response$data2 = (_response2 = response) === null || _response2 === void 0 ? void 0 : _response2.data) !== null && _response$data2 !== void 0 ? _response$data2 : response; + var error = extractErrorFromAddOnResponse(response); + if (error) { + addonError(error, el, proceed); + return; + } + afterAddonInstall(response, proceed, message, el); + }, + error: function error() { + proceed.removeClass('frm_loading_button'); + } + }); +} + +/***/ }), + +/***/ "./js/src/admin/upgrade-popup.js": +/*!***************************************!*\ + !*** ./js/src/admin/upgrade-popup.js ***! + \***************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ addOneClick: () => (/* binding */ addOneClick), +/* harmony export */ initModal: () => (/* binding */ initModal), +/* harmony export */ initUpgradeModal: () => (/* binding */ initUpgradeModal) +/* harmony export */ }); +/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/i18n */ "./node_modules/@wordpress/i18n/build-module/index.js"); + +var _frmDom = frmDom, + svg = _frmDom.svg; +function getShowLinkHrefValue(link, showLink) { + var customLink = link.getAttribute('data-link'); + if (customLink === null || typeof customLink === 'undefined' || customLink === '') { + customLink = showLink.getAttribute('data-default'); + } + return customLink; +} + +/** + * Allow addons to be installed from the upgrade modal. + * + * @param {Element} link + * @param {string} context Either 'modal' or 'tab'. + * @param {string|undefined} upgradeLabel + */ +function addOneClick(link, context, upgradeLabel) { + var container; + if ('modal' === context) { + container = document.getElementById('frm_upgrade_modal'); + } else if ('tab' === context) { + container = document.getElementById(link.getAttribute('href').substr(1)); + } else { + return; + } + var oneclickMessage = container.querySelector('.frm-oneclick'); + var upgradeMessage = container.querySelector('.frm-upgrade-message'); + var showLink = container.querySelector('.frm-upgrade-link'); + var button = container.querySelector('.frm-oneclick-button'); + var addonStatus = container.querySelector('.frm-addon-status'); + var oneclick = link.getAttribute('data-oneclick'); + var newMessage = link.getAttribute('data-message'); + var showIt = 'block'; + var showMsg = 'block'; + var hideIt = 'none'; + var modalIconWrapper = container.querySelector('.frm-circled-icon'); + if (modalIconWrapper) { + var _modalIconWrapper$que; + modalIconWrapper.classList.remove('frm-circled-icon-green'); + (_modalIconWrapper$que = modalIconWrapper.querySelector('svg')) === null || _modalIconWrapper$que === void 0 || _modalIconWrapper$que.replaceWith(svg({ + href: '#frm_filled_lock_icon' + })); + } + var learnMoreLink = container.querySelector('.frm-learn-more'); + if (learnMoreLink) { + learnMoreLink.href = link.dataset.learnMore; + } + + // If one click upgrade, hide other content. + if (oneclickMessage !== null && button !== null && typeof oneclick !== 'undefined' && oneclick) { + if (newMessage === null) { + showMsg = 'none'; + } + showIt = 'none'; + hideIt = 'block'; + oneclick = JSON.parse(oneclick); + button.className = button.className.replace(' frm-install-addon', '').replace(' frm-activate-addon', ''); + button.className = button.className + ' ' + oneclick.class; + button.rel = oneclick.url; + oneclickMessage.textContent = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__.__)('This plugin is not activated. Would you like to activate it now?', 'formidable'); + button.textContent = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__.__)('Activate', 'formidable'); + var linkIcon = link.querySelector('use'); + if (linkIcon) { + modalIconWrapper === null || modalIconWrapper === void 0 || modalIconWrapper.querySelector('svg').replaceWith(svg({ + href: linkIcon.getAttribute('href') || linkIcon.getAttribute('xlink:href'), + // Get the icon from xlink:href if it has not been updated to use href + classList: ['frm_svg32'] + })); + } + } + if (!newMessage) { + newMessage = upgradeMessage.getAttribute('data-default'); + } + if (undefined !== upgradeLabel) { + newMessage = newMessage.replace('', upgradeLabel); + } + upgradeMessage.innerHTML = newMessage; + if (link.dataset.upsellImage) { + upgradeMessage.append(frmDom.img({ + src: link.dataset.upsellImage, + alt: link.dataset.upgrade + })); + } + + // Either set the link or use the default. + showLink.href = getShowLinkHrefValue(link, showLink); + addonStatus.style.display = 'none'; + if (oneclickMessage) { + oneclickMessage.style.display = hideIt; + } + if (button) { + button.style.display = hideIt === 'block' ? 'inline-block' : hideIt; + } + upgradeMessage.style.display = showMsg; + showLink.style.display = showIt === 'block' ? 'inline-block' : showIt; + var showLinkParent = showLink.closest('.frm-upgrade-modal-actions'); + if (showLinkParent) { + showLinkParent.style.display = showIt === 'block' ? 'flex' : showIt; + } +} +function initModal(id, width) { + var $info = jQuery(id); + if (!$info.length) { + return false; + } + if (typeof width === 'undefined') { + width = '552px'; + } + var dialogArgs = { + dialogClass: 'frm-dialog', + modal: true, + autoOpen: false, + closeOnEscape: true, + width: width, + resizable: false, + draggable: false, + open: function open() { + jQuery('.ui-dialog-titlebar').addClass('frm_hidden').removeClass('ui-helper-clearfix'); + jQuery('#wpwrap').addClass('frm_overlay'); + jQuery('.frm-dialog').removeClass('ui-widget ui-widget-content ui-corner-all'); + $info.removeClass('ui-dialog-content ui-widget-content'); + bindClickForDialogClose($info); + }, + close: function close() { + jQuery('#wpwrap').removeClass('frm_overlay'); + jQuery('.spinner').css('visibility', 'hidden'); + this.removeAttribute('data-option-type'); + var optionType = document.getElementById('bulk-option-type'); + if (optionType) { + optionType.value = ''; + } + } + }; + $info.dialog(dialogArgs); + return $info; +} +function bindClickForDialogClose($modal) { + var closeModal = function closeModal() { + $modal.dialog('close'); + }; + jQuery('.ui-widget-overlay').on('click', closeModal); + $modal.on('click', 'a.dismiss', closeModal); +} +function initUpgradeModal() { + var $info = initModal('#frm_upgrade_modal'); + if ($info === false) { + return; + } + document.addEventListener('click', handleUpgradeClick); + frmDom.util.documentOn('change', 'select.frm_select_with_upgrade', handleUpgradeClick); + function handleUpgradeClick(event) { + var element, link, content; + element = event.target; + if (!element.classList) { + return; + } + var showExpiredModal = element.classList.contains('frm_show_expired_modal') || null !== element.querySelector('.frm_show_expired_modal') || element.closest('.frm_show_expired_modal'); + + // If a `select` element is clicked, check if the selected option has a 'data-upgrade' attribute + if (event.type === 'change' && element.classList.contains('frm_select_with_upgrade')) { + var selectedOption = element.options[element.selectedIndex]; + if (selectedOption && selectedOption.dataset.upgrade) { + element = selectedOption; + } + } + if (!element.dataset.upgrade) { + var parent = element.closest('[data-upgrade]'); + if (!parent) { + parent = element.closest('.frm_field_box'); + if (!parent) { + return; + } + // Fake it if it's missing to avoid error. + element.dataset.upgrade = ''; + } + element = parent; + } + if (showExpiredModal) { + var hookName = 'frm_show_expired_modal'; + wp.hooks.doAction(hookName, element); + return; + } + var upgradeLabel = element.dataset.upgrade; + if (!upgradeLabel || element.classList.contains('frm_show_upgrade_tab')) { + return; + } + event.preventDefault(); + var modal = $info.get(0); + var lockIcon = modal.querySelector('.frm_lock_icon'); + if (lockIcon) { + lockIcon.style.display = 'block'; + lockIcon.classList.remove('frm_lock_open_icon'); + lockIcon.querySelector('use').setAttribute('href', '#frm_lock_icon'); + } + var upgradeImageId = 'frm_upgrade_modal_image'; + var oldImage = document.getElementById(upgradeImageId); + if (oldImage) { + oldImage.remove(); + } + if (element.dataset.image && lockIcon) { + lockIcon.style.display = 'none'; + lockIcon.parentNode.insertBefore(frmDom.img({ + id: upgradeImageId, + src: frmGlobal.url + '/images/' + element.dataset.image + }), lockIcon); + } + var level = modal.querySelector('.license-level'); + if (level) { + level.textContent = getRequiredLicenseFromTrigger(element); + } + + // If one click upgrade, hide other content + addOneClick(element, 'modal', upgradeLabel); + modal.querySelector('.frm_are_not_installed').style.display = element.dataset.image || element.dataset.oneclick ? 'none' : 'inline-block'; + modal.querySelector('.frm-upgrade-modal-title-prefix').style.display = element.dataset.oneclick ? 'inline' : 'none'; + modal.querySelector('.frm_feature_label').textContent = upgradeLabel; + modal.querySelector('.frm-upgrade-modal-title-suffix').style.display = 'none'; + modal.querySelector('h2').style.display = 'block'; + $info.dialog('open'); + + // set the utm medium + var button = modal.querySelector('.button-primary:not(.frm-oneclick-button)'); + link = button.getAttribute('href').replace(/(medium=)[a-z_-]+/ig, '$1' + element.getAttribute('data-medium')); + content = element.getAttribute('data-content'); + if (content === null) { + content = ''; + } + link = link.replace(/(content=)[a-z_-]+/ig, '$1' + content); + button.setAttribute('href', link); + } +} +function getRequiredLicenseFromTrigger(element) { + if (element.dataset.requires) { + return element.dataset.requires; + } + return 'Pro'; +} + +/***/ }), + +/***/ "./node_modules/memize/index.js": +/*!**************************************!*\ + !*** ./node_modules/memize/index.js ***! + \**************************************/ +/***/ ((module) => { + +/** + * Memize options object. + * + * @typedef MemizeOptions + * + * @property {number} [maxSize] Maximum size of the cache. + */ + +/** + * Internal cache entry. + * + * @typedef MemizeCacheNode + * + * @property {?MemizeCacheNode|undefined} [prev] Previous node. + * @property {?MemizeCacheNode|undefined} [next] Next node. + * @property {Array<*>} args Function arguments for cache + * entry. + * @property {*} val Function result. + */ + +/** + * Properties of the enhanced function for controlling cache. + * + * @typedef MemizeMemoizedFunction + * + * @property {()=>void} clear Clear the cache. + */ + +/** + * Accepts a function to be memoized, and returns a new memoized function, with + * optional options. + * + * @template {Function} F + * + * @param {F} fn Function to memoize. + * @param {MemizeOptions} [options] Options object. + * + * @return {F & MemizeMemoizedFunction} Memoized function. + */ +function memize( fn, options ) { + var size = 0; + + /** @type {?MemizeCacheNode|undefined} */ + var head; + + /** @type {?MemizeCacheNode|undefined} */ + var tail; + + options = options || {}; + + function memoized( /* ...args */ ) { + var node = head, + len = arguments.length, + args, i; + + searchCache: while ( node ) { + // Perform a shallow equality test to confirm that whether the node + // under test is a candidate for the arguments passed. Two arrays + // are shallowly equal if their length matches and each entry is + // strictly equal between the two sets. Avoid abstracting to a + // function which could incur an arguments leaking deoptimization. + + // Check whether node arguments match arguments length + if ( node.args.length !== arguments.length ) { + node = node.next; + continue; + } + + // Check whether node arguments match arguments values + for ( i = 0; i < len; i++ ) { + if ( node.args[ i ] !== arguments[ i ] ) { + node = node.next; + continue searchCache; + } + } + + // At this point we can assume we've found a match + + // Surface matched node to head if not already + if ( node !== head ) { + // As tail, shift to previous. Must only shift if not also + // head, since if both head and tail, there is no previous. + if ( node === tail ) { + tail = node.prev; + } + + // Adjust siblings to point to each other. If node was tail, + // this also handles new tail's empty `next` assignment. + /** @type {MemizeCacheNode} */ ( node.prev ).next = node.next; + if ( node.next ) { + node.next.prev = node.prev; + } + + node.next = head; + node.prev = null; + /** @type {MemizeCacheNode} */ ( head ).prev = node; + head = node; + } + + // Return immediately + return node.val; + } + + // No cached value found. Continue to insertion phase: + + // Create a copy of arguments (avoid leaking deoptimization) + args = new Array( len ); + for ( i = 0; i < len; i++ ) { + args[ i ] = arguments[ i ]; + } + + node = { + args: args, + + // Generate the result from original function + val: fn.apply( null, args ), + }; + + // Don't need to check whether node is already head, since it would + // have been returned above already if it was + + // Shift existing head down list + if ( head ) { + head.prev = node; + node.next = head; + } else { + // If no head, follows that there's no tail (at initial or reset) + tail = node; + } + + // Trim tail if we're reached max size and are pending cache insertion + if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) { + tail = /** @type {MemizeCacheNode} */ ( tail ).prev; + /** @type {MemizeCacheNode} */ ( tail ).next = null; + } else { + size++; + } + + head = node; + + return node.val; + } + + memoized.clear = function() { + head = null; + tail = null; + size = 0; + }; + + if ( false ) {} + + // Ignore reason: There's not a clear solution to create an intersection of + // the function with additional properties, where the goal is to retain the + // function signature of the incoming argument and add control properties + // on the return value. + + // @ts-ignore + return memoized; +} + +module.exports = memize; + + +/***/ }), + +/***/ "./node_modules/sprintf-js/src/sprintf.js": +/*!************************************************!*\ + !*** ./node_modules/sprintf-js/src/sprintf.js ***! + \************************************************/ +/***/ ((module, exports, __webpack_require__) => { + +var __WEBPACK_AMD_DEFINE_RESULT__;/* global window, exports, define */ + +!function() { + 'use strict' + + var re = { + not_string: /[^s]/, + not_bool: /[^t]/, + not_type: /[^T]/, + not_primitive: /[^v]/, + number: /[diefg]/, + numeric_arg: /[bcdiefguxX]/, + json: /[j]/, + not_json: /[^j]/, + text: /^[^\x25]+/, + modulo: /^\x25{2}/, + placeholder: /^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/, + key: /^([a-z_][a-z_\d]*)/i, + key_access: /^\.([a-z_][a-z_\d]*)/i, + index_access: /^\[(\d+)\]/, + sign: /^[+-]/ + } + + function sprintf(key) { + // `arguments` is not an array, but should be fine for this call + return sprintf_format(sprintf_parse(key), arguments) + } + + function vsprintf(fmt, argv) { + return sprintf.apply(null, [fmt].concat(argv || [])) + } + + function sprintf_format(parse_tree, argv) { + var cursor = 1, tree_length = parse_tree.length, arg, output = '', i, k, ph, pad, pad_character, pad_length, is_positive, sign + for (i = 0; i < tree_length; i++) { + if (typeof parse_tree[i] === 'string') { + output += parse_tree[i] + } + else if (typeof parse_tree[i] === 'object') { + ph = parse_tree[i] // convenience purposes only + if (ph.keys) { // keyword argument + arg = argv[cursor] + for (k = 0; k < ph.keys.length; k++) { + if (arg == undefined) { + throw new Error(sprintf('[sprintf] Cannot access property "%s" of undefined value "%s"', ph.keys[k], ph.keys[k-1])) + } + arg = arg[ph.keys[k]] + } + } + else if (ph.param_no) { // positional argument (explicit) + arg = argv[ph.param_no] + } + else { // positional argument (implicit) + arg = argv[cursor++] + } + + if (re.not_type.test(ph.type) && re.not_primitive.test(ph.type) && arg instanceof Function) { + arg = arg() + } + + if (re.numeric_arg.test(ph.type) && (typeof arg !== 'number' && isNaN(arg))) { + throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg)) + } + + if (re.number.test(ph.type)) { + is_positive = arg >= 0 + } + + switch (ph.type) { + case 'b': + arg = parseInt(arg, 10).toString(2) + break + case 'c': + arg = String.fromCharCode(parseInt(arg, 10)) + break + case 'd': + case 'i': + arg = parseInt(arg, 10) + break + case 'j': + arg = JSON.stringify(arg, null, ph.width ? parseInt(ph.width) : 0) + break + case 'e': + arg = ph.precision ? parseFloat(arg).toExponential(ph.precision) : parseFloat(arg).toExponential() + break + case 'f': + arg = ph.precision ? parseFloat(arg).toFixed(ph.precision) : parseFloat(arg) + break + case 'g': + arg = ph.precision ? String(Number(arg.toPrecision(ph.precision))) : parseFloat(arg) + break + case 'o': + arg = (parseInt(arg, 10) >>> 0).toString(8) + break + case 's': + arg = String(arg) + arg = (ph.precision ? arg.substring(0, ph.precision) : arg) + break + case 't': + arg = String(!!arg) + arg = (ph.precision ? arg.substring(0, ph.precision) : arg) + break + case 'T': + arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase() + arg = (ph.precision ? arg.substring(0, ph.precision) : arg) + break + case 'u': + arg = parseInt(arg, 10) >>> 0 + break + case 'v': + arg = arg.valueOf() + arg = (ph.precision ? arg.substring(0, ph.precision) : arg) + break + case 'x': + arg = (parseInt(arg, 10) >>> 0).toString(16) + break + case 'X': + arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase() + break + } + if (re.json.test(ph.type)) { + output += arg + } + else { + if (re.number.test(ph.type) && (!is_positive || ph.sign)) { + sign = is_positive ? '+' : '-' + arg = arg.toString().replace(re.sign, '') + } + else { + sign = '' + } + pad_character = ph.pad_char ? ph.pad_char === '0' ? '0' : ph.pad_char.charAt(1) : ' ' + pad_length = ph.width - (sign + arg).length + pad = ph.width ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : '' + output += ph.align ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg) + } + } + } + return output + } + + var sprintf_cache = Object.create(null) + + function sprintf_parse(fmt) { + if (sprintf_cache[fmt]) { + return sprintf_cache[fmt] + } + + var _fmt = fmt, match, parse_tree = [], arg_names = 0 + while (_fmt) { + if ((match = re.text.exec(_fmt)) !== null) { + parse_tree.push(match[0]) + } + else if ((match = re.modulo.exec(_fmt)) !== null) { + parse_tree.push('%') + } + else if ((match = re.placeholder.exec(_fmt)) !== null) { + if (match[2]) { + arg_names |= 1 + var field_list = [], replacement_field = match[2], field_match = [] + if ((field_match = re.key.exec(replacement_field)) !== null) { + field_list.push(field_match[1]) + while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') { + if ((field_match = re.key_access.exec(replacement_field)) !== null) { + field_list.push(field_match[1]) + } + else if ((field_match = re.index_access.exec(replacement_field)) !== null) { + field_list.push(field_match[1]) + } + else { + throw new SyntaxError('[sprintf] failed to parse named argument key') + } + } + } + else { + throw new SyntaxError('[sprintf] failed to parse named argument key') + } + match[2] = field_list + } + else { + arg_names |= 2 + } + if (arg_names === 3) { + throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported') + } + + parse_tree.push( + { + placeholder: match[0], + param_no: match[1], + keys: match[2], + sign: match[3], + pad_char: match[4], + align: match[5], + width: match[6], + precision: match[7], + type: match[8] + } + ) + } + else { + throw new SyntaxError('[sprintf] unexpected placeholder') + } + _fmt = _fmt.substring(match[0].length) + } + return sprintf_cache[fmt] = parse_tree + } + + /** + * export to either browser or node.js + */ + /* eslint-disable quote-props */ + if (true) { + exports.sprintf = sprintf + exports.vsprintf = vsprintf + } + if (typeof window !== 'undefined') { + window['sprintf'] = sprintf + window['vsprintf'] = vsprintf + + if (true) { + !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { + return { + 'sprintf': sprintf, + 'vsprintf': vsprintf + } + }).call(exports, __webpack_require__, exports, module), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) + } + } + /* eslint-enable quote-props */ +}(); // eslint-disable-line + + +/***/ }), + +/***/ "./node_modules/tannin/index.js": +/*!**************************************!*\ + !*** ./node_modules/tannin/index.js ***! + \**************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Tannin) +/* harmony export */ }); +/* harmony import */ var _tannin_plural_forms__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tannin/plural-forms */ "./node_modules/@tannin/plural-forms/index.js"); + + +/** + * Tannin constructor options. + * + * @typedef {Object} TanninOptions + * + * @property {string} [contextDelimiter] Joiner in string lookup with context. + * @property {Function} [onMissingKey] Callback to invoke when key missing. + */ + +/** + * Domain metadata. + * + * @typedef {Object} TanninDomainMetadata + * + * @property {string} [domain] Domain name. + * @property {string} [lang] Language code. + * @property {(string|Function)} [plural_forms] Plural forms expression or + * function evaluator. + */ + +/** + * Domain translation pair respectively representing the singular and plural + * translation. + * + * @typedef {[string,string]} TanninTranslation + */ + +/** + * Locale data domain. The key is used as reference for lookup, the value an + * array of two string entries respectively representing the singular and plural + * translation. + * + * @typedef {{[key:string]:TanninDomainMetadata|TanninTranslation,'':TanninDomainMetadata|TanninTranslation}} TanninLocaleDomain + */ + +/** + * Jed-formatted locale data. + * + * @see http://messageformat.github.io/Jed/ + * + * @typedef {{[domain:string]:TanninLocaleDomain}} TanninLocaleData + */ + +/** + * Default Tannin constructor options. + * + * @type {TanninOptions} + */ +var DEFAULT_OPTIONS = { + contextDelimiter: '\u0004', + onMissingKey: null, +}; + +/** + * Given a specific locale data's config `plural_forms` value, returns the + * expression. + * + * @example + * + * ``` + * getPluralExpression( 'nplurals=2; plural=(n != 1);' ) === '(n != 1)' + * ``` + * + * @param {string} pf Locale data plural forms. + * + * @return {string} Plural forms expression. + */ +function getPluralExpression( pf ) { + var parts, i, part; + + parts = pf.split( ';' ); + + for ( i = 0; i < parts.length; i++ ) { + part = parts[ i ].trim(); + if ( part.indexOf( 'plural=' ) === 0 ) { + return part.substr( 7 ); + } + } +} + +/** + * Tannin constructor. + * + * @class + * + * @param {TanninLocaleData} data Jed-formatted locale data. + * @param {TanninOptions} [options] Tannin options. + */ +function Tannin( data, options ) { + var key; + + /** + * Jed-formatted locale data. + * + * @name Tannin#data + * @type {TanninLocaleData} + */ + this.data = data; + + /** + * Plural forms function cache, keyed by plural forms string. + * + * @name Tannin#pluralForms + * @type {Object} + */ + this.pluralForms = {}; + + /** + * Effective options for instance, including defaults. + * + * @name Tannin#options + * @type {TanninOptions} + */ + this.options = {}; + + for ( key in DEFAULT_OPTIONS ) { + this.options[ key ] = options !== undefined && key in options + ? options[ key ] + : DEFAULT_OPTIONS[ key ]; + } +} + +/** + * Returns the plural form index for the given domain and value. + * + * @param {string} domain Domain on which to calculate plural form. + * @param {number} n Value for which plural form is to be calculated. + * + * @return {number} Plural form index. + */ +Tannin.prototype.getPluralForm = function( domain, n ) { + var getPluralForm = this.pluralForms[ domain ], + config, plural, pf; + + if ( ! getPluralForm ) { + config = this.data[ domain ][ '' ]; + + pf = ( + config[ 'Plural-Forms' ] || + config[ 'plural-forms' ] || + // Ignore reason: As known, there's no way to document the empty + // string property on a key to guarantee this as metadata. + // @ts-ignore + config.plural_forms + ); + + if ( typeof pf !== 'function' ) { + plural = getPluralExpression( + config[ 'Plural-Forms' ] || + config[ 'plural-forms' ] || + // Ignore reason: As known, there's no way to document the empty + // string property on a key to guarantee this as metadata. + // @ts-ignore + config.plural_forms + ); + + pf = (0,_tannin_plural_forms__WEBPACK_IMPORTED_MODULE_0__["default"])( plural ); + } + + getPluralForm = this.pluralForms[ domain ] = pf; + } + + return getPluralForm( n ); +}; + +/** + * Translate a string. + * + * @param {string} domain Translation domain. + * @param {string|void} context Context distinguishing terms of the same name. + * @param {string} singular Primary key for translation lookup. + * @param {string=} plural Fallback value used for non-zero plural + * form index. + * @param {number=} n Value to use in calculating plural form. + * + * @return {string} Translated string. + */ +Tannin.prototype.dcnpgettext = function( domain, context, singular, plural, n ) { + var index, key, entry; + + if ( n === undefined ) { + // Default to singular. + index = 0; + } else { + // Find index by evaluating plural form for value. + index = this.getPluralForm( domain, n ); + } + + key = singular; + + // If provided, context is prepended to key with delimiter. + if ( context ) { + key = context + this.options.contextDelimiter + singular; + } + + entry = this.data[ domain ][ key ]; + + // Verify not only that entry exists, but that the intended index is within + // range and non-empty. + if ( entry && entry[ index ] ) { + return entry[ index ]; + } + + if ( this.options.onMissingKey ) { + this.options.onMissingKey( singular, domain ); + } + + // If entry not found, fall back to singular vs. plural with zero index + // representing the singular value. + return index === 0 ? singular : plural; +}; + + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js": +/*!*********************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js ***! + \*********************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ _arrayLikeToArray) +/* harmony export */ }); +function _arrayLikeToArray(r, a) { + (null == a || a > r.length) && (a = r.length); + for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; + return n; +} + + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js": +/*!**********************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js ***! + \**********************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ _arrayWithoutHoles) +/* harmony export */ }); +/* harmony import */ var _arrayLikeToArray_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arrayLikeToArray.js */ "./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js"); + +function _arrayWithoutHoles(r) { + if (Array.isArray(r)) return (0,_arrayLikeToArray_js__WEBPACK_IMPORTED_MODULE_0__["default"])(r); +} + + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/esm/classCallCheck.js": +/*!*******************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js ***! + \*******************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ _classCallCheck) +/* harmony export */ }); +function _classCallCheck(a, n) { + if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); +} + + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/esm/defineProperty.js": +/*!*******************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/esm/defineProperty.js ***! + \*******************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ _defineProperty) +/* harmony export */ }); +/* harmony import */ var _toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./toPropertyKey.js */ "./node_modules/@babel/runtime/helpers/esm/toPropertyKey.js"); + +function _defineProperty(e, r, t) { + return (r = (0,_toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__["default"])(r)) in e ? Object.defineProperty(e, r, { + value: t, + enumerable: !0, + configurable: !0, + writable: !0 + }) : e[r] = t, e; +} + + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/esm/iterableToArray.js": +/*!********************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js ***! + \********************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ _iterableToArray) +/* harmony export */ }); +function _iterableToArray(r) { + if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); +} + + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js": +/*!**********************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js ***! + \**********************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ _nonIterableSpread) +/* harmony export */ }); +function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js": +/*!**********************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js ***! + \**********************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ _toConsumableArray) +/* harmony export */ }); +/* harmony import */ var _arrayWithoutHoles_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arrayWithoutHoles.js */ "./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js"); +/* harmony import */ var _iterableToArray_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./iterableToArray.js */ "./node_modules/@babel/runtime/helpers/esm/iterableToArray.js"); +/* harmony import */ var _unsupportedIterableToArray_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./unsupportedIterableToArray.js */ "./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js"); +/* harmony import */ var _nonIterableSpread_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nonIterableSpread.js */ "./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js"); + + + + +function _toConsumableArray(r) { + return (0,_arrayWithoutHoles_js__WEBPACK_IMPORTED_MODULE_0__["default"])(r) || (0,_iterableToArray_js__WEBPACK_IMPORTED_MODULE_1__["default"])(r) || (0,_unsupportedIterableToArray_js__WEBPACK_IMPORTED_MODULE_2__["default"])(r) || (0,_nonIterableSpread_js__WEBPACK_IMPORTED_MODULE_3__["default"])(); +} + + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/esm/toPrimitive.js": +/*!****************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/esm/toPrimitive.js ***! + \****************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ toPrimitive) +/* harmony export */ }); +/* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/esm/typeof.js"); + +function toPrimitive(t, r) { + if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(t) || !t) return t; + var e = t[Symbol.toPrimitive]; + if (void 0 !== e) { + var i = e.call(t, r || "default"); + if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i)) return i; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return ("string" === r ? String : Number)(t); +} + + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/esm/toPropertyKey.js": +/*!******************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/esm/toPropertyKey.js ***! + \******************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ toPropertyKey) +/* harmony export */ }); +/* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/esm/typeof.js"); +/* harmony import */ var _toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./toPrimitive.js */ "./node_modules/@babel/runtime/helpers/esm/toPrimitive.js"); + + +function toPropertyKey(t) { + var i = (0,_toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__["default"])(t, "string"); + return "symbol" == (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i) ? i : i + ""; +} + + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/esm/typeof.js": +/*!***********************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/esm/typeof.js ***! + \***********************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ _typeof) +/* harmony export */ }); +function _typeof(o) { + "@babel/helpers - typeof"; + + return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return typeof o; + } : function (o) { + return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; + }, _typeof(o); +} + + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js": +/*!*******************************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js ***! + \*******************************************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ _unsupportedIterableToArray) +/* harmony export */ }); +/* harmony import */ var _arrayLikeToArray_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arrayLikeToArray.js */ "./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js"); + +function _unsupportedIterableToArray(r, a) { + if (r) { + if ("string" == typeof r) return (0,_arrayLikeToArray_js__WEBPACK_IMPORTED_MODULE_0__["default"])(r, a); + var t = {}.toString.call(r).slice(8, -1); + return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? (0,_arrayLikeToArray_js__WEBPACK_IMPORTED_MODULE_0__["default"])(r, a) : void 0; + } +} + + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ (() => { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = (module) => { +/******/ var getter = module && module.__esModule ? +/******/ () => (module['default']) : +/******/ () => (module); +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ (() => { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = (exports, definition) => { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ (() => { +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ (() => { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = (exports) => { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ })(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk. +(() => { +/*!*******************************!*\ + !*** ./js/src/admin/admin.js ***! + \*******************************/ +function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); } +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } +function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); } +function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); } +function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; } +function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } +function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } +/* exported frm_add_logic_row, frm_remove_tag, frm_show_div, frmCheckAll, frmCheckAllLevel */ +/* eslint-disable jsdoc/require-param, prefer-const, no-redeclare, @wordpress/no-unused-vars-before-return, jsdoc/check-types, jsdoc/check-tag-names, @wordpress/i18n-translator-comments, @wordpress/valid-sprintf, jsdoc/require-returns-description, jsdoc/require-param-type, no-unused-expressions, compat/compat */ + +window.FrmFormsConnect = window.FrmFormsConnect || function (document, window, $) { + /*global jQuery:false, frm_admin_js, frmGlobal, ajaxurl */ + + var el = { + messageBox: null, + reset: null, + setElements: function setElements() { + el.messageBox = document.querySelector('.frm_pro_license_msg'); + el.reset = document.getElementById('frm_reconnect_link'); + } + }; + + /** + * Public functions and properties. + * + * @since 4.03 + * + * @type {Object} + */ + var app = { + /** + * Register connect button event. + * + * @since 4.03 + */ + init: function init() { + el.setElements(); + $(document.getElementById('frm_deauthorize_link')).on('click', app.deauthorize); + $('.frm_authorize_link').on('click', app.authorize); + // Handles FF dashboard Authorize & Reauthorize events. + // Attach click event to parent as #frm_deauthorize_link & #frm_reconnect_link dynamically recreated by bootstrap.setupBootstrapDropdowns in dom.js + $('.frm-dashboard-license-options').on('click', '#frm_deauthorize_link', app.deauthorize); + $('.frm-dashboard-license-options').on('click', '#frm_reconnect_link', app.reauthorize); + if (el.reset !== null) { + $(el.reset).on('click', app.reauthorize); + } + }, + /* Manual license authorization */ + authorize: function authorize() { + /*jshint validthis:true */ + var button = this; + var pluginSlug = this.getAttribute('data-plugin'); + var input = document.getElementById('edd_' + pluginSlug + '_license_key'); + var license = input.value; + var wpmu = document.getElementById('proplug-wpmu'); + this.classList.add('frm_loading_button'); + if (wpmu === null) { + wpmu = 0; + } else if (wpmu.checked) { + wpmu = 1; + } else { + wpmu = 0; + } + $.ajax({ + type: 'POST', + url: ajaxurl, + dataType: 'json', + data: { + action: 'frm_addon_activate', + license: license, + plugin: pluginSlug, + wpmu: wpmu, + nonce: frmGlobal.nonce + }, + success: function success(msg) { + app.afterAuthorize(msg, input); + button.classList.remove('frm_loading_button'); + } + }); + }, + afterAuthorize: function afterAuthorize(msg, input) { + if (msg.success === true) { + input.value = '•••••••••••••••••••'; + } + wp.hooks.doAction('frm_after_authorize', msg); + app.showMessage(msg); + }, + showProgress: function showProgress(msg) { + if (el.messageBox === null) { + // In case the message box was added after page load. + el.setElements(); + } + var messageBox = el.messageBox; + if (messageBox === null) { + return; + } + if (msg.success === true) { + messageBox.classList.remove('frm_error_style'); + messageBox.classList.add('frm_message', 'frm_updated_message'); + } else { + messageBox.classList.add('frm_error_style'); + messageBox.classList.remove('frm_message', 'frm_updated_message'); + } + messageBox.classList.remove('frm_hidden'); + messageBox.innerHTML = msg.message; + }, + showMessage: function showMessage(msg) { + if (el.messageBox === null) { + // In case the message box was added after page load. + el.setElements(); + } + var messageBox = el.messageBox; + if (msg.success === true) { + app.showAuthorized(true); + app.showInlineSuccess(); + + /** + * Triggers the after license is authorized action for a confirmation/success modal. + * + * @param {Object} msg An object containing message data received from Authorize request. + */ + wp.hooks.doAction('frmAdmin.afterLicenseAuthorizeSuccess', { + msg: msg + }); + } + app.showProgress(msg); + if (msg.message !== '') { + setTimeout(function () { + messageBox.innerHTML = ''; + messageBox.classList.add('frm_hidden'); + messageBox.classList.remove('frm_error_style', 'frm_message', 'frm_updated_message'); + }, 10000); + var refreshPage = document.querySelector('.frm-admin-page-dashboard'); + if (refreshPage) { + setTimeout(function () { + window.location.reload(); + }, 1000); + } + } + }, + showAuthorized: function showAuthorized(show) { + var from = show ? 'unauthorized' : 'authorized'; + var to = show ? 'authorized' : 'unauthorized'; + var container = document.querySelectorAll('.frm_' + from + '_box'); + if (container.length) { + // Replace all authorized boxes with unauthorized boxes. + container.forEach(function (box) { + box.className = box.className.replace('frm_' + from + '_box', 'frm_' + to + '_box'); + }); + } + }, + /** + * Use the data-success element to replace the element content. + */ + showInlineSuccess: function showInlineSuccess() { + var successElement = document.querySelectorAll('.frm-confirm-msg [data-success]'); + if (successElement.length) { + successElement.forEach(function (element) { + element.innerHTML = frmAdminBuild.purifyHtml(element.getAttribute('data-success')); + }); + } + }, + /* Clear the site license cache */ + reauthorize: function reauthorize() { + /*jshint validthis:true */ + this.innerHTML = ''; + $.ajax({ + type: 'POST', + url: ajaxurl, + dataType: 'json', + data: { + action: 'frm_reset_cache', + plugin: 'formidable_pro', + nonce: frmGlobal.nonce + }, + success: function success(msg) { + el.reset.textContent = msg.message; + if (el.reset.getAttribute('data-refresh') === '1') { + window.location.reload(); + } + } + }); + return false; + }, + deauthorize: function deauthorize() { + /*jshint validthis:true */ + if (!confirm(frmGlobal.deauthorize)) { + return false; + } + var pluginSlug = this.getAttribute('data-plugin'), + input = document.getElementById('edd_' + pluginSlug + '_license_key'), + license = input.value, + link = this; + this.innerHTML = ''; + $.ajax({ + type: 'POST', + url: ajaxurl, + data: { + action: 'frm_addon_deactivate', + license: license, + plugin: pluginSlug, + nonce: frmGlobal.nonce + }, + success: function success() { + app.showAuthorized(false); + input.value = ''; + link.replaceWith('Disconnected'); + + /** + * Triggers the after license is deauthorized sruccess action. + */ + wp.hooks.doAction('frmAdmin.afterLicenseDeauthorizeSuccess', {}); + } + }); + return false; + } + }; + + // Provide access to public functions/properties. + return app; +}(document, window, jQuery); +window.frmAdminBuildJS = function () { + //'use strict'; + + /*global jQuery:false, frm_admin_js, frmGlobal, ajaxurl, fromDom */ + + var MAX_FIELD_GROUP_SIZE = 12; + var frmAdminJs = frm_admin_js; // eslint-disable-line camelcase + var _frmDom = frmDom, + tag = _frmDom.tag, + div = _frmDom.div, + span = _frmDom.span, + a = _frmDom.a, + svg = _frmDom.svg, + img = _frmDom.img; + var onClickPreventDefault = frmDom.util.onClickPreventDefault; + var doJsonPost = frmDom.ajax.doJsonPost; + frmAdminJs.contextualShortcodes = getContextualShortcodes(); + var icons = { + save: svg({ + href: '#frm_save_icon' + }), + drag: svg({ + href: '#frm_drag_icon', + classList: ['frm_drag_icon', 'frm-drag'] + }) + }; + var $newFields = jQuery(document.getElementById('frm-show-fields')), + builderForm = document.getElementById('new_fields'), + thisForm = document.getElementById('form_id'), + copyHelper = false, + fieldsUpdated = 0, + thisFormId = 0, + autoId = 0, + optionMap = {}, + lastNewActionIdReturned = 0; + var _wp$i18n = wp.i18n, + __ = _wp$i18n.__, + sprintf = _wp$i18n.sprintf; + var debouncedSyncAfterDragAndDrop, postBodyContent, $postBodyContent; + var dragState = { + dragging: false + }; + if (thisForm !== null) { + thisFormId = thisForm.value; + } + var currentURL = new URL(window.location.href); + var urlParams = currentURL.searchParams; + var builderPage = document.getElementById('frm_builder_page'); + + // Global settings + var s; + function showElement(element) { + if (!element[0]) { + return; + } + element[0].style.display = ''; + } + function empty($obj) { + if ($obj !== null) { + while ($obj.firstChild) { + $obj.firstChild.remove(); + } + } + } + function addClass($obj, className) { + if ($obj.classList) { + $obj.classList.add(className); + } else { + $obj.className += ' ' + className; + } + } + function confirmClick(e) { + /*jshint validthis:true */ + e.stopPropagation(); + e.preventDefault(); + confirmLinkClick(this); + } + function confirmLinkClick(link) { + var message = link.getAttribute('data-frmverify'), + loadedFrom = link.getAttribute('data-loaded-from'); + if (message === null || link.id === 'frm-confirmed-click') { + return true; + } + if ('entries-list' === loadedFrom) { + return wp.hooks.applyFilters('frm_on_multiple_entries_delete', { + link: link, + initModal: initModal + }); + } + return confirmModal(link); + } + function confirmModal(link) { + var verify, + $confirmMessage, + i, + dataAtts, + btnClass, + $info = initModal('#frm_confirm_modal', '400px'), + continueButton = document.getElementById('frm-confirmed-click'); + if ($info === false) { + return false; + } + + // The confirm button is hidden when showLimitModal is called, + // so make sure it is visible every time we open the modal. + if (continueButton) { + continueButton.style.display = 'block'; + } + verify = link.getAttribute('data-frmverify'); + btnClass = verify ? link.getAttribute('data-frmverify-btn') : ''; + $confirmMessage = jQuery('.frm-confirm-msg'); + $confirmMessage.empty(); + if (verify) { + $confirmMessage.append(document.createTextNode(verify)); + if (btnClass) { + continueButton === null || continueButton === void 0 || continueButton.classList.add(btnClass); + } + } + dataAtts = link.dataset; + if (continueButton) { + for (i in continueButton.dataset) { + continueButton.removeAttribute('data-' + i); + } + for (i in dataAtts) { + if (i !== 'frmverify') { + continueButton.setAttribute('data-' + i, dataAtts[i]); + } + } + } + + /** + * Triggers the pre-open action for a confirmation modal. This action passes + * relevant modal information and associated link to any listening hooks. + * + * @param {Object} options An object containing modal elements and data. + * @param {HTMLElement} options.$info The HTML element containing modal information. + * @param {string} options.link The link associated with the modal action. + */ + wp.hooks.doAction('frmAdmin.beforeOpenConfirmModal', { + $info: $info, + link: link + }); + $info.dialog('open'); + continueButton === null || continueButton === void 0 || continueButton.setAttribute('href', link.getAttribute('href') || link.getAttribute('data-href')); + return false; + } + function infoModal(msg) { + var $info = initModal('#frm_info_modal', '400px'); + if ($info === false) { + return false; + } + jQuery('.frm-info-msg').html(msg); + $info.dialog('open'); + return false; + } + function toggleItem(e) { + /*jshint validthis:true */ + var toggle = this.getAttribute('data-frmtoggle'); + var text = this.getAttribute('data-toggletext'); + var $items = jQuery(toggle); + e.preventDefault(); + $items.toggle(); + if (text !== null && text !== '') { + this.setAttribute('data-toggletext', this.innerHTML); + this.textContent = text; + } + return false; + } + + /** + * Toggle a class on target elements when an anchor is clicked, or when a radio or checkbox has been selected. + * + * @param {Event} e Event with either the change or click type. + * @return {false} + */ + function hideShowItem(e) { + /*jshint validthis:true */ + var hide = this.getAttribute('data-frmhide'); + var show = this.getAttribute('data-frmshow'); + var uncheckList = this.getAttribute('data-frmuncheck'); + var uncheckListArray = uncheckList ? uncheckList.split(',') : []; + + // Flip unchecked checkboxes so an off value undoes the on value. + if (isUncheckedCheckbox(this)) { + if (hide !== null) { + show = hide; + hide = null; + } else if (show !== null) { + hide = show; + show = null; + } + } + e.preventDefault(); + var toggleClass = this.getAttribute('data-toggleclass') || 'frm_hidden'; + if (hide !== null) { + jQuery(hide).addClass(toggleClass); + } + if (show !== null) { + jQuery(show).removeClass(toggleClass); + } + var current = this.parentNode.querySelectorAll('a.current'); + if (current !== null) { + for (var i = 0; i < current.length; i++) { + current[i].classList.remove('current'); + } + this.classList.add('current'); + } + if (uncheckListArray.length) { + uncheckListArray.forEach(function (uncheckItem) { + var uncheckItemElement = document.querySelector(uncheckItem); + if (uncheckItemElement) { + uncheckItemElement.checked = false; + } + }); + } + return false; + } + function isUncheckedCheckbox(element) { + return 'INPUT' === element.nodeName && 'checkbox' === element.type && !element.checked; + } + + /** + * Load a tooltip for a single element. + * + * @since 6.26 + * + * @param {HTMLElement} element + * @param {boolean} show + */ + function loadTooltip(element) { + var show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + var tooltipTarget = element; + + // Bootstrap 5 does not allow tooltips on dropdown triggers, so move the tooltip to the parent element. + if (tooltipTarget.hasAttribute('data-toggle') || tooltipTarget.hasAttribute('data-bs-toggle')) { + tooltipTarget.parentElement.setAttribute('title', tooltipTarget.getAttribute('title')); + tooltipTarget.removeAttribute('title'); + tooltipTarget.classList.remove('frm_bstooltip'); + tooltipTarget.parentElement.classList.add('frm_bstooltip'); + tooltipTarget = tooltipTarget.parentElement; + } + jQuery(tooltipTarget).tooltip(); + if (show) { + deleteTooltips(); + jQuery(tooltipTarget).tooltip('show'); + } + } + function loadTooltips() { + var wrapClass = jQuery('.wrap, .frm_wrap'), + confirmModal = document.getElementById('frm_confirm_modal'), + doAction = false, + confirmedBulkDelete = false; + jQuery(confirmModal).on('click', '[data-deletefield]', deleteFieldConfirmed); + jQuery(confirmModal).on('click', '[data-removeid]', removeThisTag); + jQuery(confirmModal).on('click', '[data-trashtemplate]', trashTemplate); + wrapClass.on('click', '.frm_remove_tag, .frm_remove_form_action', removeThisTag); + wrapClass.on('click', 'a[data-frmverify]', confirmClick); + wrapClass.on('click', 'a[data-frmtoggle]', toggleItem); + wrapClass.on('click', 'a[data-frmhide], a[data-frmshow]', hideShowItem); + wrapClass.on('change', 'input[data-frmhide], input[data-frmshow]', hideShowItem); + wrapClass.on('click', '.widget-top,a.widget-action', clickWidget); + wrapClass.on('mouseenter.frm', '.frm_bstooltip, .frm_help', function () { + jQuery(this).off('mouseenter.frm'); + loadTooltip(this, true); + }); + jQuery(document).on('click', '#doaction, #doaction2', function (event) { + var isTop = this.id === 'doaction', + suffix = isTop ? 'top' : 'bottom', + bulkActionSelector = document.getElementById('bulk-action-selector-' + suffix), + confirmBulkDelete = document.getElementById('confirm-bulk-delete-' + suffix); + if (bulkActionSelector !== null && confirmBulkDelete !== null) { + doAction = this; + if (!confirmedBulkDelete && bulkActionSelector.value === 'bulk_delete') { + event.preventDefault(); + confirmLinkClick(confirmBulkDelete); + return false; + } + } else { + doAction = false; + } + }); + jQuery(document).on('click', '#frm-confirmed-click', function (event) { + if (doAction === false || event.target.classList.contains('frm-btn-inactive')) { + return; + } + if (this.getAttribute('href') === 'confirm-bulk-delete') { + event.preventDefault(); + confirmedBulkDelete = true; + doAction.click(); + return false; + } + }); + } + function deleteTooltips() { + document.querySelectorAll('.tooltip').forEach(function (tooltip) { + tooltip.remove(); + }); + } + function removeThisTag() { + /*jshint validthis:true */ + var show, hide, removeMore; + if (parseInt(this.getAttribute('data-skip-frm-js')) || confirmLinkClick(this) === false) { + return; + } + var deleteButton = jQuery(this); + var id = deleteButton.attr('data-removeid'); + show = deleteButton.attr('data-showlast'); + if (typeof show === 'undefined') { + show = ''; + } + hide = deleteButton.attr('data-hidelast'); + if (typeof hide === 'undefined') { + hide = ''; + } + removeMore = deleteButton.attr('data-removemore'); + if (show !== '') { + if (deleteButton.closest('.frm_add_remove').find('.frm_remove_tag:visible').length > 1) { + show = ''; + hide = ''; + } + } else if (id.indexOf('frm_postmeta_') === 0) { + if (jQuery('#frm_postmeta_rows .frm_postmeta_row').length < 2) { + show = '.frm_add_postmeta_row.button'; + } + if (jQuery('.frm_toggle_cf_opts').length && jQuery('#frm_postmeta_rows .frm_postmeta_row:not(#' + id + ')').last().length) { + if (show !== '') { + show += ','; + } + show += '#' + jQuery('#frm_postmeta_rows .frm_postmeta_row:not(#' + id + ')').last().attr('id') + ' .frm_toggle_cf_opts'; + } + } + var fadeEle = document.getElementById(id); + var $fadeEle = jQuery(fadeEle); + $fadeEle.fadeOut(300, function () { + var _document$querySelect; + $fadeEle.remove(); + fieldUpdated(); + if (hide !== '') { + jQuery(hide).hide(); + } + if (show !== '') { + jQuery(show + ' a,' + show).removeClass('frm_hidden').fadeIn('slow'); + } + if (this.closest('.frm_form_action_settings')) { + var type = this.closest('.frm_form_action_settings').querySelector('.frm_action_name').value; + afterActionRemoved(type); + } + (_document$querySelect = document.querySelector('.tooltip')) === null || _document$querySelect === void 0 || _document$querySelect.remove(); + }); + if (typeof removeMore !== 'undefined') { + removeMore = jQuery(removeMore); + removeMore.fadeOut(400, function () { + removeMore.remove(); + }); + } + if (show !== '') { + jQuery(this).closest('.frm_logic_rows').fadeOut('slow'); + } + + /** + * Fires after a tag element has been removed in the admin interface. + * + * @param {string} id The ID of the removed element + * @param {HTMLElement} fadeEle The removed element that was faded out + */ + wp.hooks.doAction('frm_admin_tag_removed', id, fadeEle); + return false; + } + function afterActionRemoved(type) { + checkActiveAction(type); + var hookName = 'frm_after_action_removed'; + var hookArgs = { + type: type + }; + wp.hooks.doAction(hookName, hookArgs); + } + function clickWidget(event, b) { + /*jshint validthis:true */ + if (typeof b === 'undefined') { + b = this; + } + popCalcFields(b, false); + var cont = jQuery(b).closest('.frm_form_action_settings'); + var target = event.target; + if (cont.length && typeof target !== 'undefined') { + var className = target.parentElement.className; + if ('string' === typeof className) { + if (className.includes('frm_email_icons') || className.includes('frm_toggle')) { + // clicking on delete icon shouldn't open it + event.stopPropagation(); + return; + } + } + } + var inside = cont.children('.widget-inside'); + if (cont.length && inside.find('p, div, table').length < 1) { + var actionId = cont.find('input[name$="[ID]"]').val(); + var actionType = cont.find('input[name$="[post_excerpt]"]').val(); + if (actionType) { + inside.html(''); + cont.find('.spinner').fadeIn('slow'); + jQuery.ajax({ + type: 'POST', + url: ajaxurl, + data: { + action: 'frm_form_action_fill', + action_id: actionId, + action_type: actionType, + nonce: frmGlobal.nonce + }, + success: function success(html) { + inside.html(html); + initiateMultiselect(); + showInputIcon('#' + cont.attr('id')); + initAutocomplete(inside); + jQuery(b).trigger('frm-action-loaded'); + + /** + * Fires after filling form action content when opening. + * + * @since 5.5.4 + * + * @param {Object} insideElement JQuery object of form action inside element. + */ + wp.hooks.doAction('frm_filled_form_action', inside); + } + }); + } + } + jQuery(b).closest('.frm_field_box').siblings().find('.widget-inside').slideUp('fast'); + if (typeof b.className !== 'undefined' && b.className.includes('widget-action') || jQuery(b).closest('.start_divider').length < 1) { + return; + } + inside = jQuery(b).closest('div.widget').children('.widget-inside'); + if (inside.is(':hidden')) { + inside.slideDown('fast'); + } else { + inside.slideUp('fast'); + } + } + function clickNewTab() { + /*jshint validthis:true */ + var t = this.getAttribute('href'); + if (typeof t === 'undefined') { + return false; + } + var c = t.replace('#', '.'); + var $link = jQuery(this); + $link.closest('li').addClass('frm-tabs active').siblings('li').removeClass('frm-tabs active starttab'); + $link.closest('div').children('.tabs-panel').not(t).not(c).hide(); + var tabContent = document.getElementById(t.replace('#', '')); + if (tabContent) { + tabContent.style.display = 'block'; + } + + // clearSettingsBox would hide field settings when opening the fields modal and we want to skip it there. + if (this.id === 'frm_insert_fields_tab' && !this.closest('#frm_adv_info')) { + clearSettingsBox(); + } + return false; + } + function clickTab(link, auto) { + link = jQuery(link); + var t = link.attr('href'); + if (typeof t === 'undefined') { + return; + } + var c = t.replace('#', '.'); + link.closest('li').addClass('frm-tabs active').siblings('li').removeClass('frm-tabs active starttab'); + if (link.closest('div').find('.tabs-panel').length) { + link.closest('div').children('.tabs-panel').not(t).not(c).hide(); + } else if (document.getElementById('form_global_settings') !== null) { + /* global settings */ + var ajax = link.data('frmajax'); + link.closest('.frm_wrap').find('.tabs-panel, .hide_with_tabs').hide(); + if (typeof ajax !== 'undefined' && ajax == '1') { + loadSettingsTab(t); + } + } else { + /* form settings page */ + jQuery('#frm-categorydiv .tabs-panel, .hide_with_tabs').hide(); + } + jQuery(t).show(); + jQuery(c).show(); + hideShortcodes(); + if (auto !== 'auto') { + // Hide success message on tab change. + jQuery('.frm_updated_message').hide(); + jQuery('.frm_warning_style').hide(); + } + if (jQuery(link).closest('#frm_adv_info').length) { + return; + } + if (jQuery('.frm_form_settings').length) { + jQuery('.frm_form_settings').attr('action', '?page=formidable&frm_action=settings&id=' + jQuery('.frm_form_settings input[name="id"]').val() + '&t=' + t.replace('#', '')); + } else { + jQuery('.frm_settings_form').attr('action', '?page=formidable-settings&t=' + t.replace('#', '')); + } + } + function setupSortable(sortableSelector) { + document.querySelectorAll(sortableSelector).forEach(function (list) { + makeDroppable(list); + Array.from(list.children).forEach(function (child) { + return makeDraggable(child, '.frm-move'); + }); + var $sectionTitle = jQuery(list).children('[data-type="divider"]').children('.divider_section_only'); + if ($sectionTitle.length) { + makeDroppable($sectionTitle); + } + }); + setupFieldOptionSorting(jQuery('#frm_builder_page')); + } + function makeDroppable(list) { + jQuery(list).droppable({ + accept: '.frmbutton, li.frm_field_box', + deactivate: handleFieldDrop, + over: onDragOverDroppable, + out: onDraggableLeavesDroppable, + tolerance: 'pointer' + }); + } + function onDragOverDroppable(event, ui) { + var droppable = getDroppableForOnDragOver(event.target); + var draggable = ui.draggable[0]; + if (!allowDrop(draggable, droppable, event)) { + droppable.classList.remove('frm-over-droppable'); + jQuery(droppable).parents('ul.frm_sorting').addClass('frm-over-droppable'); + return; + } + document.querySelectorAll('.frm-over-droppable').forEach(function (droppable) { + return droppable.classList.remove('frm-over-droppable'); + }); + droppable.classList.add('frm-over-droppable'); + jQuery(droppable).parents('ul.frm_sorting').addClass('frm-over-droppable'); + } + + /** + * Maybe change the droppable. + * Section titles are made droppable, but are not a list, so we need to change the droppable to the section's list instead. + * + * @param {Element} droppable + * @return {Element} + */ + function getDroppableForOnDragOver(droppable) { + if (droppable.classList.contains('divider_section_only')) { + droppable = jQuery(droppable).nextAll('.start_divider.frm_sorting').get(0); + } + return droppable; + } + function onDraggableLeavesDroppable(event) { + var droppable = event.target; + droppable.classList.remove('frm-over-droppable'); + } + function makeDraggable(draggable, handle) { + var settings = { + helper: getDraggableHelper, + revert: 'invalid', + delay: 10, + start: handleDragStart, + stop: handleDragStop, + drag: handleDrag, + cursor: 'grabbing', + refreshPositions: true, + cursorAt: { + top: 0, + left: 90 // The width of draggable button is 180. 90 should center the draggable on the cursor. + } + }; + if ('string' === typeof handle) { + settings.handle = handle; + } + jQuery(draggable).draggable(settings); + } + function getDraggableHelper(event) { + var draggable = event.delegateTarget; + if (isFieldGroup(draggable)) { + var newTextFieldClone = document.getElementById('frm-insert-fields').querySelector('.frm_ttext').cloneNode(true); + newTextFieldClone.querySelector('use').setAttributeNS('http://www.w3.org/1999/xlink', 'href', '#frm_field_group_layout_icon'); + newTextFieldClone.querySelector('span').textContent = __('Field Group', 'formidable'); + newTextFieldClone.classList.add('frm_field_box'); + newTextFieldClone.classList.add('ui-sortable-helper'); + return newTextFieldClone; + } + var copyTarget; + var isNewField = draggable.classList.contains('frmbutton'); + if (isNewField) { + copyTarget = draggable.cloneNode(true); + copyTarget.classList.add('ui-sortable-helper'); + draggable.classList.add('frm-new-field'); + return copyTarget; + } + if (draggable.hasAttribute('data-ftype')) { + var fieldType = draggable.getAttribute('data-ftype'); + copyTarget = document.getElementById('frm-insert-fields').querySelector('.frm_t' + fieldType); + if (copyTarget) { + copyTarget = copyTarget.cloneNode(true); + copyTarget.classList.add('form-field'); + copyTarget.classList.add('ui-sortable-helper'); + return copyTarget.cloneNode(true); + } + } + return div({ + className: 'frmbutton' + }); + } + function handleDragStart(event, ui) { + if (event.target.classList.contains('frm_at_limit')) { + showLimitModal(); + return false; + } + dragState.dragging = true; + var container = postBodyContent; + container.classList.add('frm-dragging-field'); + document.body.classList.add('frm-dragging'); + ui.helper.addClass('frm-sortable-helper'); + ui.helper.initialOffset = container.scrollTop; + event.target.classList.add('frm-drag-fade'); + unselectFieldGroups(); + deleteEmptyDividerWrappers(); + maybeRemoveGroupHoverTarget(); + closeOpenFieldDropdowns(); + deleteTooltips(); + } + function handleDragStop() { + var container = postBodyContent; + container.classList.remove('frm-dragging-field'); + document.body.classList.remove('frm-dragging'); + var fade = document.querySelector('.frm-drag-fade'); + if (fade) { + fade.classList.remove('frm-drag-fade'); + } + } + function handleDrag(event, ui) { + maybeScrollBuilder(event); + var draggable = event.target; + var droppable = getDroppableTarget(); + var placeholder = document.getElementById('frm_drag_placeholder'); + if (!allowDrop(draggable, droppable, event)) { + if (placeholder) { + placeholder.remove(); + } + return; + } + if (!placeholder) { + placeholder = tag('li', { + id: 'frm_drag_placeholder', + className: 'sortable-placeholder' + }); + } + var frmSortableHelper = ui.helper.get(0); + if (frmSortableHelper.classList.contains('form-field') || frmSortableHelper.classList.contains('frm_field_box')) { + // Sync the y position of the draggable so it still follows the cursor after scrolling up and down the field list. + frmSortableHelper.style.transform = 'translateY(' + getDragOffset(ui.helper) + 'px)'; + } + if ('frm-show-fields' === droppable.id || droppable.classList.contains('start_divider')) { + placeholder.style.left = 0; + handleDragOverYAxis({ + droppable: droppable, + y: event.clientY, + placeholder: placeholder + }); + return; + } + placeholder.style.top = ''; + handleDragOverFieldGroup({ + droppable: droppable, + x: event.clientX, + placeholder: placeholder + }); + } + function maybeScrollBuilder(event) { + $postBodyContent.scrollTop(function (_, v) { + var moved = event.clientY; + var h = postBodyContent.offsetHeight; + var relativePos = event.clientY - postBodyContent.offsetTop; + var y = relativePos - h / 2; + if (relativePos > h - 50 && moved > 5) { + // Scrolling down. + return v + y * 0.1; + } + if (relativePos < 70 && moved < 130) { + // Scrolling up. + return v - Math.abs(y * 0.1); + } + return v; + }); + } + function getDragOffset($helper) { + return postBodyContent.scrollTop - $helper.initialOffset; + } + function getDroppableTarget() { + var droppable = document.getElementById('frm-show-fields'); + while (droppable.querySelector('.frm-over-droppable')) { + droppable = droppable.querySelector('.frm-over-droppable'); + } + if ('frm-show-fields' === droppable.id && !droppable.classList.contains('frm-over-droppable')) { + droppable = false; + } + return droppable; + } + function handleFieldDrop(_, ui) { + if (!dragState.dragging) { + // dragState.dragging is set to true on drag start. + // The deactivate event gets called for every droppable. This check to make sure it happens once. + return; + } + dragState.dragging = false; + var draggable = ui.draggable[0]; + var placeholder = document.getElementById('frm_drag_placeholder'); + if (!placeholder) { + ui.helper.remove(); + debouncedSyncAfterDragAndDrop(); + return; + } + maybeOpenCollapsedPage(placeholder); + var $previousFieldContainer = ui.helper.parent(); + var previousSection = ui.helper.get(0).closest('ul.start_divider'); + var newSection = placeholder.closest('ul.start_divider'); + if (draggable.classList.contains('frm-new-field')) { + insertNewFieldByDragging(draggable.id); + } else { + moveFieldThatAlreadyExists(draggable, placeholder); + maybeMakeFieldGroupDraggableAfterDragging(placeholder.parentElement); + } + var previousSectionId = previousSection ? parseInt(previousSection.closest('.edit_field_type_divider').getAttribute('data-fid')) : 0; + var newSectionId = newSection ? parseInt(newSection.closest('.edit_field_type_divider').getAttribute('data-fid')) : 0; + placeholder.remove(); + ui.helper.remove(); + var $previousContainerFields = $previousFieldContainer.length ? getFieldsInRow($previousFieldContainer) : []; + maybeUpdatePreviousFieldContainerAfterDrop($previousFieldContainer, $previousContainerFields); + maybeUpdateDraggableClassAfterDrop(draggable, $previousContainerFields); + if (previousSectionId !== newSectionId) { + updateFieldAfterMovingBetweenSections(jQuery(draggable), previousSection); + } + debouncedSyncAfterDragAndDrop(); + } + + /** + * When a field is moved into a field group, make sure the field group is draggable. + * + * @since 6.24 + * + * @param {HTMLElement} placeholderParent + * @return {void} + */ + function maybeMakeFieldGroupDraggableAfterDragging(placeholderParent) { + var isDroppingIntoFieldGroup = placeholderParent.nodeName === 'UL' && !placeholderParent.classList.contains('start_divider') && 'frm-show-fields' !== placeholderParent.id; + if (!isDroppingIntoFieldGroup) { + return; + } + var fieldGroupLi = placeholderParent.closest('li'); + if (fieldGroupLi && !fieldGroupLi.classList.contains('ui-draggable')) { + makeDraggable(fieldGroupLi, '.frm-move'); + } + } + + /** + * If a page if collapsed, expand it before dragging since only the page break will move. + * + * @param {Element} placeholder + * @return {void} + */ + function maybeOpenCollapsedPage(placeholder) { + if (!placeholder.previousElementSibling || !placeholder.previousElementSibling.classList.contains('frm-is-collapsed')) { + return; + } + var $pageBreakField = jQuery(placeholder).prevUntil('[data-type="break"]'); + if (!$pageBreakField.length) { + return; + } + var collapseButton = $pageBreakField.find('.frm-collapse-page').get(0); + if (collapseButton) { + collapseButton.click(); + } + } + function maybeUpdatePreviousFieldContainerAfterDrop($previousFieldContainer, $previousContainerFields) { + if (!$previousFieldContainer.length) { + return; + } + if ($previousContainerFields.length) { + syncLayoutClasses($previousContainerFields.first()); + } else { + maybeDeleteAnEmptyFieldGroup($previousFieldContainer.get(0)); + } + } + function maybeUpdateDraggableClassAfterDrop(draggable, $previousContainerFields) { + if (0 !== $previousContainerFields.length || 1 !== getFieldsInRow(jQuery(draggable.parentNode)).length) { + syncLayoutClasses(jQuery(draggable)); + } + } + + /** + * Remove an empty field group, but don't remove an empty section. + * + * @param {Element} previousFieldContainer + * @return {void} + */ + function maybeDeleteAnEmptyFieldGroup(previousFieldContainer) { + var closestFieldBox = previousFieldContainer.closest('li.frm_field_box'); + if (closestFieldBox && !closestFieldBox.classList.contains('edit_field_type_divider')) { + closestFieldBox.remove(); + } + } + function handleDragOverYAxis(_ref) { + var droppable = _ref.droppable, + y = _ref.y, + placeholder = _ref.placeholder; + var $list = jQuery(droppable); + var top; + var $children = $list.children().not('.edit_field_type_end_divider'); + if (0 === $children.length) { + $list.prepend(placeholder); + top = 0; + } else { + var insertAtIndex = determineIndexBasedOffOfMousePositionInList($list, y); + if (insertAtIndex === $children.length) { + var $lastChild = jQuery($children.get(insertAtIndex - 1)); + top = $lastChild.offset().top + $lastChild.outerHeight(); + $list.append(placeholder); + + // Make sure nothing gets inserted after the end divider. + var $endDivider = $list.children('.edit_field_type_end_divider'); + if ($endDivider.length) { + $list.append($endDivider); + } + } else { + top = jQuery($children.get(insertAtIndex)).offset().top; + jQuery($children.get(insertAtIndex)).before(placeholder); + } + } + top -= $list.offset().top; + placeholder.style.top = top + 'px'; + } + function determineIndexBasedOffOfMousePositionInList($list, y) { + var $items = $list.children().not('.edit_field_type_end_divider'); + var length = $items.length; + var index, item, itemTop, returnIndex; + if (!document.querySelector('.frm-has-fields .frm_no_fields')) { + // Always return 0 when there are no fields. + return 0; + } + returnIndex = 0; + for (index = length - 1; index >= 0; --index) { + item = $items.get(index); + itemTop = jQuery(item).offset().top; + if (y > itemTop) { + returnIndex = index; + if (y > itemTop + jQuery(item).outerHeight() / 2) { + returnIndex = index + 1; + } + break; + } + } + return returnIndex; + } + function handleDragOverFieldGroup(_ref2) { + var droppable = _ref2.droppable, + x = _ref2.x, + placeholder = _ref2.placeholder; + var $row = jQuery(droppable); + var $children = getFieldsInRow($row); + if (!$children.length) { + return; + } + var left; + var insertAtIndex = determineIndexBasedOffOfMousePositionInRow($row, x); + if (insertAtIndex === $children.length) { + var $lastChild = jQuery($children.get(insertAtIndex - 1)); + left = $lastChild.offset().left + $lastChild.outerWidth(); + $row.append(placeholder); + } else { + left = jQuery($children.get(insertAtIndex)).offset().left; + jQuery($children.get(insertAtIndex)).before(placeholder); + var amountToOffsetLeftBy = 0 === insertAtIndex ? 4 : 8; // Offset by 8 in between rows, but only 4 for the first item in a group. + left -= amountToOffsetLeftBy; // Offset the placeholder slightly so it appears between two fields. + } + left -= $row.offset().left; + placeholder.style.left = left + 'px'; + } + function syncAfterDragAndDrop() { + fixUnwrappedListItems(); + toggleSectionHolder(); + maybeFixEndDividers(); + maybeDeleteEmptyFieldGroups(); + updateFieldOrder(); + var event = new Event('frm_sync_after_drag_and_drop', { + bubbles: false + }); + document.dispatchEvent(event); + } + function maybeFixEndDividers() { + document.querySelectorAll('.edit_field_type_end_divider').forEach(function (endDivider) { + return endDivider.parentNode.append(endDivider); + }); + } + function maybeDeleteEmptyFieldGroups() { + document.querySelectorAll('li.form_field_box:not(.form-field)').forEach(function (fieldGroup) { + return !fieldGroup.children.length && fieldGroup.remove(); + }); + } + function fixUnwrappedListItems() { + var lists = document.querySelectorAll('ul#frm-show-fields, ul.start_divider'); + lists.forEach(function (list) { + list.childNodes.forEach(function (child) { + if ('undefined' === typeof child.classList) { + return; + } + if (child.classList.contains('edit_field_type_end_divider')) { + // Never wrap end divider in place. + return; + } + if ('undefined' !== typeof child.classList && child.classList.contains('form-field')) { + wrapFieldLiInPlace(child); + } + }); + }); + } + function deleteEmptyDividerWrappers() { + var dividers = document.querySelectorAll('ul.start_divider'); + if (!dividers.length) { + return; + } + dividers.forEach(function (divider) { + var children = [].slice.call(divider.children); + children.forEach(function (child) { + if (0 === child.children.length) { + child.remove(); + } else if (1 === child.children.length && 'ul' === child.firstElementChild.nodeName.toLowerCase() && 0 === child.firstElementChild.children.length) { + child.remove(); + } + }); + }); + } + function getFieldsInRow($row) { + var $fields = jQuery(); + var row = $row.get(0); + if (!row.children) { + return $fields; + } + Array.from(row.children).forEach(function (child) { + if ('none' === child.style.display) { + return; + } + var classes = child.classList; + if (!classes.contains('form-field') || classes.contains('edit_field_type_end_divider') || classes.contains('frm-sortable-helper')) { + return; + } + $fields = $fields.add(child); + }); + return $fields; + } + function determineIndexBasedOffOfMousePositionInRow($row, x) { + var $inputs = getFieldsInRow($row), + length = $inputs.length, + index, + input, + inputLeft, + returnIndex; + returnIndex = 0; + for (index = length - 1; index >= 0; --index) { + input = $inputs.get(index); + inputLeft = jQuery(input).offset().left; + if (x > inputLeft) { + returnIndex = index; + if (x > inputLeft + jQuery(input).outerWidth() / 2) { + returnIndex = index + 1; + } + break; + } + } + return returnIndex; + } + function syncLayoutClasses($item, type) { + var $fields, size, layoutClasses, classToAddFunction; + if ('undefined' === typeof type) { + type = 'even'; + } + $fields = $item.parent().children('li.form-field, li.frmbutton_loadingnow').not('.edit_field_type_end_divider'); + size = $fields.length; + layoutClasses = getLayoutClasses(); + if ('even' === type && 5 !== size) { + $fields.each(getSyncLayoutClass(layoutClasses, getEvenClassForSize(size))); + } else if ('clear' === type) { + $fields.each(getSyncLayoutClass(layoutClasses, '')); + } else { + if (-1 !== ['left', 'right', 'middle', 'even'].indexOf(type)) { + classToAddFunction = function classToAddFunction(index) { + return getClassForBlock(size, type, index); + }; + } else { + classToAddFunction = function classToAddFunction(index) { + var size = type[index]; + return getLayoutClassForSize(size); + }; + } + $fields.each(getSyncLayoutClass(layoutClasses, classToAddFunction)); + } + updateFieldGroupControls($item.parent(), $fields.length); + } + function updateFieldGroupControls($row, count) { + var rowOffset, shouldShowControls, controls; + rowOffset = $row.offset(); + if ('undefined' === typeof rowOffset) { + return; + } + shouldShowControls = count >= 2; + controls = document.getElementById('frm_field_group_controls'); + if (null === controls) { + if (!shouldShowControls) { + // exit early. if we do not need controls and they do not exist, do nothing. + return; + } + controls = div(); + controls.id = 'frm_field_group_controls'; + controls.setAttribute('role', 'group'); + controls.setAttribute('tabindex', 0); + setFieldControlsHtml(controls); + builderPage.append(controls); + } + $row.append(controls); + controls.style.display = shouldShowControls ? 'block' : 'none'; + } + function setFieldControlsHtml(controls) { + var layoutOption, moveOption; + layoutOption = document.createElement('span'); + layoutOption.innerHTML = ''; + var layoutOptionLabel = __('Set Row Layout', 'formidable'); + addTooltip(layoutOption, layoutOptionLabel); + makeTabbable(layoutOption, layoutOptionLabel); + moveOption = document.createElement('span'); + moveOption.innerHTML = ''; + moveOption.classList.add('frm-move'); + var moveOptionLabel = __('Move Field Group', 'formidable'); + addTooltip(moveOption, moveOptionLabel); + makeTabbable(moveOption, moveOptionLabel); + controls.innerHTML = ''; + controls.append(layoutOption); + controls.append(moveOption); + controls.append(getFieldControlsDropdown()); + } + function addTooltip(element, title) { + element.setAttribute('data-bs-toggle', 'tooltip'); + element.setAttribute('data-bs-container', 'body'); + element.setAttribute('title', title); + element.addEventListener('mouseover', function () { + if (null === element.getAttribute('data-original-title')) { + jQuery(element).tooltip(); + } + }); + } + function getFieldControlsDropdown() { + var dropdown = span({ + className: 'dropdown' + }); + var trigger = a({ + className: 'frm_bstooltip frm-hover-icon frm-dropdown-toggle dropdown-toggle', + children: [span({ + child: svg({ + href: '#frm_thick_more_vert_icon' + }) + }), span({ + className: 'screen-reader-text', + text: __('Toggle More Options Dropdown', 'formidable') + })] + }); + frmDom.setAttributes(trigger, { + title: __('More Options', 'formidable'), + 'data-bs-toggle': 'dropdown', + 'data-bs-container': 'body', + 'data-bs-display': 'static' + }); + makeTabbable(trigger, __('More Options', 'formidable')); + dropdown.append(trigger); + var ul = div({ + className: 'frm-dropdown-menu dropdown-menu dropdown-menu-right' + }); + ul.setAttribute('role', 'menu'); + dropdown.append(ul); + return dropdown; + } + function getSyncLayoutClass(layoutClasses, classToAdd) { + return function (itemIndex) { + var currentClassToAdd, length, layoutClassIndex, currentClass, activeLayoutClass, fieldId, layoutClassesInput; + currentClassToAdd = 'function' === typeof classToAdd ? classToAdd(itemIndex) : classToAdd; + length = layoutClasses.length; + activeLayoutClass = false; + for (layoutClassIndex = 0; layoutClassIndex < length; ++layoutClassIndex) { + currentClass = layoutClasses[layoutClassIndex]; + if (this.classList.contains(currentClass)) { + activeLayoutClass = currentClass; + break; + } + } + fieldId = this.dataset.fid; + if ('undefined' === typeof fieldId) { + // we are syncing the drag/drop placeholder before the actual field has loaded. + // this will get called again afterward and the input will exist then. + this.classList.add(currentClassToAdd); + return; + } + moveFieldSettings(document.getElementById('frm-single-settings-' + fieldId)); + layoutClassesInput = document.getElementById('frm_classes_' + fieldId); + if (null === layoutClassesInput) { + // not every field type has a layout class input. + return; + } + if (false === activeLayoutClass) { + if ('' !== currentClassToAdd) { + layoutClassesInput.value = layoutClassesInput.value.concat(' ' + currentClassToAdd); + } + } else { + this.classList.remove(activeLayoutClass); + layoutClassesInput.value = layoutClassesInput.value.replace(activeLayoutClass, currentClassToAdd); + } + if (this.classList.contains('frm_first')) { + this.classList.remove('frm_first'); + layoutClassesInput.value = layoutClassesInput.value.replace('frm_first', '').trim(); + } + if (0 === itemIndex) { + this.classList.add('frm_first'); + layoutClassesInput.value = layoutClassesInput.value.concat(' frm_first'); + } + jQuery(layoutClassesInput).trigger('change'); + }; + } + function getLayoutClasses() { + return ['frm_full', 'frm_half', 'frm_third', 'frm_fourth', 'frm_sixth', 'frm_two_thirds', 'frm_three_fourths', 'frm1', 'frm2', 'frm3', 'frm4', 'frm5', 'frm6', 'frm7', 'frm8', 'frm9', 'frm10', 'frm11', 'frm12']; + } + function setupFieldOptionSorting(sort) { + var opts = { + items: '.frm_sortable_field_opts li', + axis: 'y', + opacity: 0.65, + forcePlaceholderSize: false, + handle: '.frm-drag', + helper: function helper(e, li) { + copyHelper = li.clone().insertAfter(li); + return li.clone(); + }, + stop: function stop(e, ui) { + copyHelper && copyHelper.remove(); + var fieldId = ui.item.attr('id').replace('frm_delete_field_', '').replace('-' + ui.item.data('optkey') + '_container', ''); + resetDisplayedOpts(fieldId); + fieldUpdated(); + } + }; + jQuery(sort).sortable(opts); + } + + // Get the section where a field is dropped + function getSectionForFieldPlacement(currentItem) { + var section = ''; + if (typeof currentItem !== 'undefined' && !currentItem.hasClass('edit_field_type_divider')) { + section = currentItem.closest('.edit_field_type_divider'); + } + return section; + } + + // Get the form ID where a field is dropped + function getFormIdForFieldPlacement(section) { + var formId = ''; + if (typeof section[0] !== 'undefined') { + var sDivide = section.children('.start_divider'); + sDivide.children('.edit_field_type_end_divider').appendTo(sDivide); + if (typeof section.attr('data-formid') !== 'undefined') { + var fieldId = section.attr('data-fid'); + formId = jQuery('input[name="field_options[form_select_' + fieldId + ']"]').val(); + } + } + if (typeof formId === 'undefined' || formId === '') { + formId = thisFormId; + } + return formId; + } + + // Get the section ID where a field is dropped + function getSectionIdForFieldPlacement(section) { + var sectionId = 0; + if (typeof section[0] !== 'undefined') { + sectionId = section.attr('id').replace('frm_field_id_', ''); + } + return sectionId; + } + + /** + * Update a field after it is dragged and dropped into, out of, or between sections + * + * @param {Object} currentItem + * @param {Object} previousSection + * @return {void} + */ + function updateFieldAfterMovingBetweenSections(currentItem, previousSection) { + if (!currentItem.hasClass('form-field')) { + // currentItem is a field group. Call for children recursively. + getFieldsInRow(jQuery(currentItem.get(0).firstChild)).each(function () { + updateFieldAfterMovingBetweenSections(jQuery(this), previousSection); + }); + return; + } + var fieldId = currentItem.attr('id').replace('frm_field_id_', ''); + var section = getSectionForFieldPlacement(currentItem); + var formId = getFormIdForFieldPlacement(section); + var sectionId = getSectionIdForFieldPlacement(section); + var previousFormId = previousSection ? getFormIdForFieldPlacement(jQuery(previousSection.parentNode)) : 0; + jQuery.ajax({ + type: 'POST', + url: ajaxurl, + data: { + action: 'frm_update_field_after_move', + form_id: formId, + field: fieldId, + section_id: sectionId, + previous_form_id: previousFormId, + nonce: frmGlobal.nonce + }, + success: function success() { + toggleSectionHolder(); + updateInSectionValue(fieldId, sectionId); + } + }); + } + + // Update the in_section field value + function updateInSectionValue(fieldId, sectionId) { + document.getElementById('frm_in_section_' + fieldId).value = sectionId; + } + + /** + * Get the arguments for inserting a new field. + * + * @since 6.23 + * + * @param {string} fieldType + * @param {string} sectionId + * @param {string} formId + * @param {Number} hasBreak + * + * @return {Object} + */ + function getInsertNewFieldArgs(fieldType, sectionId, formId, hasBreak) { + var fieldArgs = { + action: 'frm_insert_field', + form_id: formId, + field_type: fieldType, + section_id: sectionId, + nonce: frmGlobal.nonce, + has_break: hasBreak + }; + + // Only send last row field IDs to update their order if this field isn't added to a repeater. + var isInRepeater = sectionId > 0 && document.getElementById('form_id').value !== formId; + if (!isInRepeater) { + fieldArgs.last_row_field_ids = getFieldIdsInSubmitRow(); + } + return fieldArgs; + } + + /** + * Returns true if it's a range field type and slider type is not selected. + * + * @since 6.23 + * + * @param {string} fieldType + * @return {boolean} + */ + function shouldStopInsertingField(fieldType) { + return wp.hooks.applyFilters('frm_should_stop_inserting_field', false, fieldType); + } + + /** + * Add a new field by dragging and dropping it from the Fields sidebar + * + * @param {string} fieldType + */ + function insertNewFieldByDragging(fieldType) { + if (shouldStopInsertingField(fieldType)) { + wp.hooks.doAction('frm_stopped_inserting_by_dragging', fieldType); + return; + } + var placeholder = document.getElementById('frm_drag_placeholder'); + var loadingID = fieldType.replace('|', '-') + '_' + getAutoId(); + var loading = tag('li', { + id: loadingID, + className: 'frm-wait frmbutton_loadingnow' + }); + var $placeholder = jQuery(loading); + var currentItem = jQuery(placeholder); + var section = getSectionForFieldPlacement(currentItem); + var formId = getFormIdForFieldPlacement(section); + var sectionId = getSectionIdForFieldPlacement(section); + placeholder.parentNode.insertBefore(loading, placeholder); + placeholder.remove(); + syncLayoutClasses($placeholder); + var hasBreak = 0; + if ('summary' === fieldType) { + // see if we need to insert a page break before this newly-added summary field. Check for at least 1 page break + hasBreak = jQuery('.frmbutton_loadingnow#' + loadingID).prevAll('li[data-type="break"]').length ? 1 : 0; + } + jQuery.ajax({ + type: 'POST', + url: ajaxurl, + data: getInsertNewFieldArgs(fieldType, sectionId, formId, hasBreak), + success: function success(msg) { + handleInsertFieldByDraggingResponse(msg, $placeholder); + var fieldId = checkMsgForFieldId(msg); + if (fieldId) { + /** + * Fires after a field is added. + * + * @since 6.23 + * + * @param {Object} fieldData The field data. + * @param {string} fieldData.field The field HTML. + * @param {string} fieldData.field_type The field type. + * @param {string} fieldData.form_id The form ID. + */ + wp.hooks.doAction('frm_after_field_added_in_form_builder', { + field: msg, + fieldId: fieldId, + fieldType: fieldType, + form_id: formId + }); + } + }, + error: handleInsertFieldError + }); + } + + /** + * @param {string} msg + * @param {Object} $placeholder jQuery object. + */ + function handleInsertFieldByDraggingResponse(msg, $placeholder) { + var replaceWith; + document.getElementById('frm_form_editor_container').classList.add('frm-has-fields'); + var $siblings = $placeholder.siblings('li.form-field').not('.edit_field_type_end_divider'); + if (!$siblings.length) { + // if dragging into a new row, we need to wrap the li first. + replaceWith = wrapFieldLi(msg); + } else { + replaceWith = msgAsjQueryObject(msg); + if (!$placeholder.get(0).parentNode.parentNode.classList.contains('ui-draggable')) { + // If a field group wasn't draggable because it only had a single field, make it draggable. + makeDraggable($placeholder.get(0).parentNode.parentNode, '.frm-move'); + } + } + $placeholder.replaceWith(replaceWith); + updateFieldOrder(); + afterAddField(msg, false); + if ($siblings.length) { + syncLayoutClasses($siblings.first()); + } + toggleSectionHolder(); + if (!$siblings.length) { + makeDroppable(replaceWith.get(0).querySelector('ul.frm_sorting')); + makeDraggable(replaceWith.get(0).querySelector('li.form-field'), '.frm-move'); + } else { + makeDraggable(replaceWith.get(0), '.frm-move'); + } + } + + /** + * Get the field ID from the response message. + * + * @since 6.23 + * + * @param {string} msg + * @return {Number} + */ + function checkMsgForFieldId(msg) { + var result = msg.match(/data-fid="(\d+)"/); + return result ? parseInt(result[1]) : 0; + } + function getFieldIdsInSubmitRow() { + var submitField = document.querySelector('.edit_field_type_submit'); + if (!submitField) { + return []; + } + var lastRowFields = submitField.parentNode.children; + var ids = []; + for (var i = 0; i < lastRowFields.length; i++) { + ids.push(lastRowFields[i].dataset.fid); + } + return ids; + } + function moveFieldThatAlreadyExists(draggable, placeholder) { + placeholder.parentNode.insertBefore(draggable, placeholder); + } + function msgAsjQueryObject(msg) { + var element = div(); + element.innerHTML = msg; + return jQuery(element.firstChild); + } + function handleInsertFieldError(jqXHR, _, errorThrown) { + maybeShowInsertFieldError(errorThrown, jqXHR); + } + function maybeShowInsertFieldError(errorThrown, jqXHR) { + if (!jqXHRAborted(jqXHR)) { + infoModal(errorThrown + '. Please try again.'); + } + } + function jqXHRAborted(jqXHR) { + return jqXHR.status === 0 || jqXHR.readyState === 0; + } + + /** + * Get a unique id that automatically increments with every function call. + * Can be used for any UI that requires a unique id. + * Not to be used in data. + * + * @return {number} + */ + function getAutoId() { + return ++autoId; + } + + /** + * Determine if a draggable element can be droppable into a droppable element. + * + * Don't allow page break, embed form, or section inside section field + * Don't allow page breaks inside of field groups. + * Don't allow field groups with sections inside of sections. + * Don't allow field groups in field groups. + * Don't allow hidden fields inside of field groups but allow them in sections. + * Don't allow any fields below the submit button field. + * Don't allow submit button field above any fields. + * Don't allow GDPR fields in repeaters. + * + * @param {HTMLElement} draggable + * @param {HTMLElement} droppable + * @param {Event} event + * @return {Boolean} + */ + function allowDrop(draggable, droppable, event) { + if (false === droppable) { + // Don't show drop placeholder if dragging somewhere off of the droppable area. + return false; + } + if (droppable.closest('.frm-sortable-helper')) { + // Do not allow drop into draggable. + return false; + } + var isSubmitBtn = draggable.classList.contains('edit_field_type_submit'); + var containSubmitBtn = !draggable.classList.contains('form_field') && !!draggable.querySelector('.edit_field_type_submit'); + if ('frm-show-fields' === droppable.id) { + var draggableIndex = determineIndexBasedOffOfMousePositionInList(jQuery(droppable), event.clientY); + if (isSubmitBtn || containSubmitBtn) { + // Do not allow dropping submit button to above position. + var lastRowIndex = droppable.childElementCount - 1; + return draggableIndex > lastRowIndex; + } + + // Do not allow dropping other fields to below submit button. + var submitButtonIndex = jQuery(droppable.querySelector('.edit_field_type_submit').closest('#frm-show-fields > li')).index(); + return draggableIndex <= submitButtonIndex; + } + if (isSubmitBtn) { + if (droppable.classList.contains('start_divider')) { + // Don't allow dropping submit button into a repeater. + return false; + } + if (isLastRow(droppable.parentElement)) { + // Allow dropping submit button into the last row. + return true; + } + if (!isLastRow(droppable.parentElement.nextElementSibling)) { + // Don't a dropping submit button into the row that isn't the second one from bottom. + return false; + } + + // Allow dropping submit button into the second row from bottom if there is only submit button in the last row. + return !draggable.parentElement.querySelector('li.frm_field_box:not(.edit_field_type_submit)'); + } + var droppableIsARepeater = droppable.classList.contains('start_divider') && null !== droppable.closest('.repeat_section'); + var droppableIsInsideOfARepeater = null !== droppable.closest('.repeat_section'); + if (droppableIsARepeater || droppableIsInsideOfARepeater) { + var isGdpr = draggable.classList.contains('edit_field_type_gdpr') || draggable.id === 'gdpr'; + if (isGdpr) { + return false; + } + + /** + * @since 6.27 + * + * @param {boolean} denyDropInRepeater + * @param {HTMLElement} draggable + */ + var shouldDenyDropInRepeater = wp.hooks.applyFilters('frm_deny_drop_in_repeater', false, draggable); + if (shouldDenyDropInRepeater) { + return false; + } + } + if (!droppableIsARepeater) { + var $fieldsInRow = getFieldsInRow(jQuery(droppable)); + if (!groupCanFitAnotherField($fieldsInRow, jQuery(draggable))) { + // Field group is full and cannot accept another field. + return false; + } + if (draggable.id === 'divider' && droppable.closest('.start_divider')) { + return false; + } + } + var isNewField = draggable.classList.contains('frm-new-field'); + if (isNewField) { + return allowNewFieldDrop(draggable, droppable); + } + return allowMoveField(draggable, droppable); + } + + /** + * Checks if given element is the last row in form builder. + * + * @param {HTMLElement} element Element. + * @return {Boolean} + */ + function isLastRow(element) { + return element && element.matches('#frm-show-fields > li:last-child'); + } + + // Don't allow a new page break or hidden field in a field group. + // Don't allow a new field into a field group that includes a page break or hidden field. + // Don't allow a new section inside of a section. + // Don't allow an embedded form in a section. + function allowNewFieldDrop(draggable, droppable) { + var classes = draggable.classList; + var newPageBreakField = classes.contains('frm_tbreak'); + var newHiddenField = classes.contains('frm_thidden'); + var newSectionField = classes.contains('frm_tdivider'); + var newEmbedField = classes.contains('frm_tform'); + var newUserIdField = classes.contains('frm_tuser_id'); + var newFieldWillBeAddedToAGroup = !('frm-show-fields' === droppable.id || droppable.classList.contains('start_divider')); + if (newFieldWillBeAddedToAGroup) { + if (groupIncludesBreakOrHiddenOrUserId(droppable)) { + // Never allow any field beside a page break or a hidden field. + return false; + } + return !newHiddenField && !newPageBreakField && !newUserIdField; + } + var fieldTypeIsAlwaysAllowed = !newPageBreakField && !newHiddenField && !newSectionField && !newEmbedField; + if (fieldTypeIsAlwaysAllowed) { + return true; + } + var newFieldWillBeAddedToASection = droppable.classList.contains('start_divider') || null !== droppable.closest('.start_divider'); + if (newFieldWillBeAddedToASection) { + // Don't allow a section or an embedded form in a section. + return !newEmbedField && !newSectionField; + } + return true; + } + function allowMoveField(draggable, droppable) { + if (isFieldGroup(draggable)) { + return allowMoveFieldGroup(draggable, droppable); + } + var isPageBreak = draggable.classList.contains('edit_field_type_break'); + if (isPageBreak) { + // Page breaks are only allowed in the main list of fields, not in sections or in field groups. + return false; + } + if (droppable.classList.contains('start_divider')) { + return allowMoveFieldToSection(draggable); + } + var isHiddenField = draggable.classList.contains('edit_field_type_hidden'); + var isUserIdField = draggable.classList.contains('edit_field_type_user_id'); + if (isHiddenField || isUserIdField) { + // Hidden fields and user id fields should not be added to field groups since they're not shown + // and don't make sense with the grid distribution. + return false; + } + return allowMoveFieldToGroup(draggable, droppable); + } + function isFieldGroup(draggable) { + return draggable.classList.contains('frm_field_box') && !draggable.classList.contains('form-field'); + } + function allowMoveFieldGroup(fieldGroup, droppable) { + if (droppable.classList.contains('start_divider') && null === fieldGroup.querySelector('.start_divider')) { + // Allow a field group with no section inside of a section. + return true; + } + return false; + } + function allowMoveFieldToSection(draggable) { + var draggableIncludeEmbedForm = draggable.classList.contains('edit_field_type_form') || draggable.querySelector('.edit_field_type_form'); + if (draggableIncludeEmbedForm) { + // Do not allow an embedded form inside of a section. + return false; + } + var draggableIncludesSection = draggable.classList.contains('edit_field_type_divider') || draggable.querySelector('.edit_field_type_divider'); + if (draggableIncludesSection) { + // Do not allow a section inside of a section. + return false; + } + return true; + } + function allowMoveFieldToGroup(draggable, group) { + if (groupIncludesBreakOrHiddenOrUserId(group)) { + // Never allow any field beside a page break or a hidden field. + return false; + } + var isFieldGroup = jQuery(draggable).children('ul.frm_sorting').not('.start_divider').length > 0; + if (isFieldGroup) { + // Do not allow a field group directly inside of a field group unless it's in a section. + return false; + } + var draggableIncludesASection = draggable.classList.contains('edit_field_type_divider') || draggable.querySelector('.edit_field_type_divider'); + var draggableIsEmbedField = draggable.classList.contains('edit_field_type_form'); + var groupIsInASection = null !== group.closest('.start_divider'); + if (groupIsInASection && (draggableIncludesASection || draggableIsEmbedField)) { + // Do not allow a section or an embed field inside of a section. + return false; + } + return true; + } + function groupIncludesBreakOrHiddenOrUserId(group) { + return null !== group.querySelector('.edit_field_type_break, .edit_field_type_hidden, .edit_field_type_user_id'); + } + function groupCanFitAnotherField(fieldsInRow, $field) { + var fieldId; + if (fieldsInRow.length < MAX_FIELD_GROUP_SIZE) { + return true; + } + if (fieldsInRow.length > MAX_FIELD_GROUP_SIZE) { + return false; + } + fieldId = $field.attr('data-fid'); + // Allow the maximum number if we're not changing field groups. + return 1 === jQuery(fieldsInRow).filter('[data-fid="' + fieldId + '"]').length; + } + function loadFields(fieldId) { + var thisField = document.getElementById(fieldId); + var $thisField = jQuery(thisField); + var field = []; + var addHtmlToField = function addHtmlToField(element) { + var frmHiddenFdata = element.querySelector('.frm_hidden_fdata'); + element.classList.add('frm_load_now'); + if (frmHiddenFdata !== null) { + field.push(frmHiddenFdata.innerHTML); + } + }; + addHtmlToField(thisField); + var nextField = getNextField(thisField); + while (nextField && field.length < 15) { + addHtmlToField(nextField); + nextField = getNextField(nextField); + } + jQuery.ajax({ + type: 'POST', + url: ajaxurl, + data: { + action: 'frm_load_field', + field: field, + form_id: thisFormId, + nonce: frmGlobal.nonce + }, + success: function success(html) { + return handleAjaxLoadFieldSuccess(html, $thisField, field); + } + }); + } + function getNextField(field) { + var _field$parentNode; + if (field.nextElementSibling) { + return field.nextElementSibling; + } + return (_field$parentNode = field.parentNode) === null || _field$parentNode === void 0 || (_field$parentNode = _field$parentNode.closest('.frm_field_box')) === null || _field$parentNode === void 0 || (_field$parentNode = _field$parentNode.nextElementSibling) === null || _field$parentNode === void 0 ? void 0 : _field$parentNode.querySelector('.form-field'); + } + function handleAjaxLoadFieldSuccess(html, $thisField, field) { + var key, $nextSet; + html = html.replace(/^\s+|\s+$/g, ''); + if (html.indexOf('{') !== 0) { + jQuery('.frm_load_now').removeClass('.frm_load_now').html('Error'); + return; + } + html = JSON.parse(html); + for (key in html) { + jQuery('#frm_field_id_' + key).replaceWith(html[key]); + var newReplacedField = document.getElementById('frm_field_id_' + key); + if (newReplacedField) { + newReplacedField.querySelectorAll('[data-toggle]').forEach(function (toggle) { + return toggle.setAttribute('data-bs-toggle', toggle.getAttribute('data-toggle')); + }); + newReplacedField.querySelectorAll('.frm-dropdown-menu').forEach(function (dropdownMenu) { + return dropdownMenu.classList.add('dropdown-menu'); + }); + } + setupSortable('#frm_field_id_' + key + '.edit_field_type_divider ul.frm_sorting'); + makeDraggable(document.getElementById('frm_field_id_' + key)); + } + $nextSet = $thisField.nextAll('.frm_field_loading:not(.frm_load_now)'); + if ($nextSet.length) { + loadFields($nextSet.attr('id')); + } else { + // go up a level + $nextSet = jQuery(document.getElementById('frm-show-fields')).find('.frm_field_loading:not(.frm_load_now)'); + if ($nextSet.length) { + loadFields($nextSet.attr('id')); + } + } + initiateMultiselect(); + renumberPageBreaks(); + maybeHideQuantityProductFieldOption(); + var loadedEvent = new Event('frm_ajax_loaded_field', { + bubbles: false + }); + loadedEvent.frmFields = field.map(function (f) { + return JSON.parse(f); + }); + document.dispatchEvent(loadedEvent); + } + function addFieldClick() { + /*jshint validthis:true */ + var $thisObj = jQuery(this); + // there is no real way to disable a (with a valid href attribute) in HTML - https://css-tricks.com/how-to-disable-links/ + if ($thisObj.hasClass('disabled')) { + return false; + } + var $button = $thisObj.closest('.frmbutton'); + var fieldType = $button.attr('id'); + if ($button.hasClass('frm_at_limit')) { + showLimitModal(); + return false; + } + if (shouldStopInsertingField(fieldType)) { + // We do not want to return false here. + // Otherwise it causes issues with trying to add a new slider field + // when clicking the button. + return; + } + var hasBreak = 0; + if ('summary' === fieldType) { + hasBreak = $newFields.children('li[data-type="break"]').length > 0 ? 1 : 0; + } + var formId = thisFormId; + jQuery.ajax({ + type: 'POST', + url: ajaxurl, + data: getInsertNewFieldArgs(fieldType, 0, formId, hasBreak), + success: function success(msg) { + handleAddFieldClickResponse(msg); + var fieldId = checkMsgForFieldId(msg); + if (fieldId) { + /** + * Fires after a field is added. + * + * @since 6.23 + * + * @param {Object} fieldData The field data. + * @param {string} fieldData.field The field HTML. + * @param {string} fieldData.field_type The field type. + * @param {string} fieldData.form_id The form ID. + */ + wp.hooks.doAction('frm_after_field_added_in_form_builder', { + field: msg, + fieldId: fieldId, + fieldType: fieldType, + form_id: formId + }); + } + }, + error: handleInsertFieldError + }); + return false; + } + function showLimitModal() { + var wrapper = document.querySelector('.frm_wrap'); + if (!wrapper) { + return; + } + var temporaryAnchor = document.createElement('a'); + temporaryAnchor.setAttribute('data-frmverify', __('This field type has reached its limit.', 'formidable')); + wrapper.append(temporaryAnchor); + temporaryAnchor.click(); + temporaryAnchor.remove(); + var confirmButton = document.getElementById('frm-confirmed-click'); + if (confirmButton) { + confirmButton.style.display = 'none'; + } + } + function handleAddFieldClickResponse(msg) { + document.getElementById('frm_form_editor_container').classList.add('frm-has-fields'); + var replaceWith = wrapFieldLi(msg); + var submitField = $newFields[0].querySelector('.edit_field_type_submit'); + if (!submitField) { + $newFields.append(replaceWith); + } else { + jQuery(submitField.closest('.frm_field_box:not(.form-field)')).before(replaceWith); + } + afterAddField(msg, true); + replaceWith.each(function () { + makeDroppable(this.querySelector('ul.frm_sorting')); + makeDraggable(this.querySelector('.form-field'), '.frm-move'); + }); + } + function insertFormField(fieldType) { + var fieldOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + return new Promise(function (resolve) { + var formId = thisFormId; + var hasBreak = 0; + if ('summary' === fieldType) { + hasBreak = $newFields.children('li[data-type="break"]').length > 0 ? 1 : 0; + } + jQuery.ajax({ + type: 'POST', + url: ajaxurl, + data: Object.assign(getInsertNewFieldArgs(fieldType, 0, formId, hasBreak), { + field_options: fieldOptions + }), + success: function success(msg) { + resolve(msg); + setTimeout(function () { + updateFieldOrder(); + afterAddField(msg, true); + var fieldId = checkMsgForFieldId(msg); + if (fieldId) { + /** + * Fires after a field is added. + * + * @since 6.23 + * + * @param {Object} fieldData The field data. + * @param {string} fieldData.field The field HTML. + * @param {string} fieldData.field_type The field type. + * @param {string} fieldData.form_id The form ID. + */ + wp.hooks.doAction('frm_after_field_added_in_form_builder', { + field: msg, + fieldId: fieldId, + fieldType: fieldType, + form_id: formId + }); + } + }, 10); + }, + error: handleInsertFieldError + }); + }); + } + function maybeHideQuantityProductFieldOption() { + var hide = true, + opts = document.querySelectorAll('.frmjs_prod_field_opt_cont'); + if ($newFields.find('li.edit_field_type_product').length > 1) { + hide = false; + } + for (var i = 0; i < opts.length; i++) { + if (hide) { + opts[i].classList.add('frm_hidden'); + } else { + opts[i].classList.remove('frm_hidden'); + } + } + } + + /** + * Returns true if a field can be duplicated. + * + * @since 6.19 + * + * @param {HTMLElement} field + * @param {number} maxFieldsInGroup + * + * @return {Boolean} + */ + function canDuplicateField(field, maxFieldsInGroup) { + if (field.classList.contains('frm-page-collapsed')) { + return false; + } + var fieldGroup = field.closest('li.frm_field_box:not(.form-field)'); + if (!fieldGroup) { + return true; + } + var fieldsInGroup = getFieldsInRow(jQuery(fieldGroup.querySelector('ul'))).length; + return fieldsInGroup < maxFieldsInGroup; + } + function duplicateField() { + var $field, fieldId, children, newRowId, fieldOrder; + var maxFieldsInGroup = MAX_FIELD_GROUP_SIZE; + $field = jQuery(this).closest('li.form-field'); + newRowId = this.getAttribute('frm-target-row-id'); + if (!(newRowId && newRowId.startsWith('frm_field_group_')) && !canDuplicateField($field.get(0), maxFieldsInGroup)) { + /* translators: %1$d: Maximum number of fields allowed in a field group. */ + infoModal(sprintf(__('You can only have a maximum of %1$d fields in a field group. Delete or move out a field from the group and try again.', 'formidable'), maxFieldsInGroup)); + return; + } + closeOpenFieldDropdowns(); + fieldId = $field.data('fid'); + children = fieldsInSection(fieldId); + if (null !== newRowId) { + fieldOrder = this.getAttribute('frm-field-order'); + } + jQuery.ajax({ + type: 'POST', + url: ajaxurl, + data: { + action: 'frm_duplicate_field', + field_id: fieldId, + form_id: thisFormId, + children: children, + nonce: frmGlobal.nonce + }, + success: function success(msg) { + var _$field$0$querySelect; + var newRow; + var replaceWith; + if (null !== newRowId) { + newRow = document.getElementById(newRowId); + if (null !== newRow) { + replaceWith = msgAsjQueryObject(msg); + jQuery(newRow).append(replaceWith); + makeDraggable(replaceWith.get(0), '.frm-move'); + if (null !== fieldOrder) { + newRow.lastElementChild.setAttribute('frm-field-order', fieldOrder); + } + jQuery(newRow).trigger('frm_added_duplicated_field_to_row', { + duplicatedFieldHtml: msg, + originalFieldId: fieldId + }); + afterAddField(msg, false); + setLayoutClassesForDuplicatedFieldInGroup($field.get(0), replaceWith.get(0)); + return; + } + } + if ($field.siblings('li.form-field').length) { + replaceWith = msgAsjQueryObject(msg); + $field.after(replaceWith); + syncLayoutClasses($field); + makeDraggable(replaceWith.get(0), '.frm-move'); + } else { + replaceWith = wrapFieldLi(msg); + $field.parent().parent().after(replaceWith); + makeDroppable(replaceWith.get(0).querySelector('ul.frm_sorting')); + makeDraggable(replaceWith.get(0).querySelector('li.form-field'), '.frm-move'); + } + updateFieldOrder(); + afterAddField(msg, false); + maybeDuplicateUnsavedSettings(fieldId, msg); + toggleOneSectionHolder(replaceWith.find('.start_divider')); + (_$field$0$querySelect = $field[0].querySelector('.frm-dropdown-menu.dropdown-menu-right')) === null || _$field$0$querySelect === void 0 || _$field$0$querySelect.classList.remove('show'); + setLayoutClassesForDuplicatedFieldInGroup($field.get(0), replaceWith.get(0)); + } + }); + return false; + } + + /** + * Sets the layout classes for a duplicated field in a field group from the layout classes of the original field. + * + * @param {HTMLElement} field The original field. + * @param {HTMLElement} newField The duplicated field. + * + * @return {void} + */ + function setLayoutClassesForDuplicatedFieldInGroup(field, newField) { + var _document$getElementB; + var hoverTarget = field.closest('.frm-field-group-hover-target'); + if (!hoverTarget || !isFieldGroup(hoverTarget.parentElement)) { + return; + } + var fieldId = field.dataset.fid; + var fieldClasses = (_document$getElementB = document.getElementById('frm_classes_' + fieldId)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.value; + if (!fieldClasses) { + return; + } + fieldClasses = fieldClasses.replace('frm_first', ''); + if (!newField.className.includes(fieldClasses)) { + newField.className += ' ' + fieldClasses; + var classesInput = document.getElementById('frm_classes_' + newField.dataset.fid); + if (classesInput) { + classesInput.value = fieldClasses; + } + } + } + function maybeDuplicateUnsavedSettings(originalFieldId, newFieldHtml) { + var originalSettings, newFieldId, copySettings, fieldOptionKeys, originalDefault, copyDefault; + originalSettings = document.getElementById('frm-single-settings-' + originalFieldId); + if (null === originalSettings) { + return; + } + newFieldId = jQuery(newFieldHtml).attr('data-fid'); + if ('undefined' === typeof newFieldId) { + return; + } + copySettings = document.getElementById('frm-single-settings-' + newFieldId); + if (null === copySettings) { + return; + } + fieldOptionKeys = ['name', 'required', 'unique', 'read_only', 'placeholder', 'description', 'size', 'max', 'format', 'prepend', 'append', 'separate_value']; + originalSettings.querySelectorAll('input[name^="field_options["], textarea[name^="field_options["]').forEach(function (originalSetting) { + var key, tagType, copySetting; + key = getKeyFromSettingInput(originalSetting); + if ('options' === key) { + copyOption(originalSetting, copySettings, originalFieldId, newFieldId); + return; + } + if (-1 === fieldOptionKeys.indexOf(key)) { + return; + } + tagType = originalSetting.matches('input') ? 'input' : 'textarea'; + copySetting = copySettings.querySelector(tagType + '[name="field_options[' + key + '_' + newFieldId + ']"]'); + if (null === copySetting) { + return; + } + if ('checkbox' === originalSetting.type) { + if (originalSetting.checked !== copySetting.checked) { + jQuery(copySetting).trigger('click'); + } + } else if ('text' === originalSetting.type || 'textarea' === tagType) { + if (originalSetting.value !== copySetting.value) { + copySetting.value = originalSetting.value; + jQuery(copySetting).trigger('change'); + } + } + }); + originalDefault = originalSettings.querySelector('input[name="default_value_' + originalFieldId + '"]'); + if (null !== originalDefault) { + copyDefault = copySettings.querySelector('input[name="default_value_' + newFieldId + '"]'); + if (null !== copyDefault && originalDefault.value !== copyDefault.value) { + copyDefault.value = originalDefault.value; + jQuery(copyDefault).trigger('change'); + } + } + } + function copyOption(originalSetting, copySettings, originalFieldId, newFieldId) { + var remainingKeyDetails, copyKey, copySetting; + remainingKeyDetails = originalSetting.name.substr(23 + ('' + originalFieldId).length); + copyKey = 'field_options[options_' + newFieldId + ']' + remainingKeyDetails; + copySetting = copySettings.querySelector('input[name="' + copyKey + '"]'); + if (null !== copySetting && copySetting.value !== originalSetting.value) { + copySetting.value = originalSetting.value; + jQuery(copySetting).trigger('change'); + } + } + function getKeyFromSettingInput(input) { + var nameWithoutPrefix, nameSplit; + nameWithoutPrefix = input.name.substr(14); + nameSplit = nameWithoutPrefix.split('_'); + nameSplit.pop(); + return nameSplit.join('_'); + } + function closeOpenFieldDropdowns() { + var openSettings = document.querySelector('.frm-field-settings-open'); + if (null !== openSettings) { + openSettings.classList.remove('frm-field-settings-open'); + jQuery(document).off('click', '#frm_builder_page', handleClickOutsideOfFieldSettings); + jQuery('.frm-field-action-icons .dropdown.open').removeClass('open'); + } + } + function handleClickOutsideOfFieldSettings(event) { + if (!jQuery(event.originalEvent.target).closest('.frm-field-action-icons').length) { + closeOpenFieldDropdowns(); + } + } + function checkForMultiselectKeysOnMouseMove(event) { + var keyIsDown = !!(event.ctrlKey || event.metaKey || event.shiftKey); + jQuery(builderPage).toggleClass('frm-multiselect-key-is-down', keyIsDown); + checkForActiveHoverTarget(event); + } + function checkForActiveHoverTarget(event) { + var container, elementFromPoint, list, previousHoverTarget; + container = postBodyContent; + if (container.classList.contains('frm-dragging-field')) { + return; + } + if (null !== document.querySelector('.frm-field-group-hover-target .frm-field-settings-open')) { + // do not set a hover target if a dropdown is open for the current hover target. + return; + } + elementFromPoint = document.elementFromPoint(event.clientX, event.clientY); + if (null !== elementFromPoint && !elementFromPoint.classList.contains('edit_field_type_divider')) { + list = elementFromPoint.closest('ul.frm_sorting'); + if (null !== list && !list.classList.contains('start_divider') && 'frm-show-fields' !== list.id) { + previousHoverTarget = maybeRemoveGroupHoverTarget(); + if (false !== previousHoverTarget && !jQuery(previousHoverTarget).is(list)) { + destroyFieldGroupPopup(); + } + updateFieldGroupControls(jQuery(list), getFieldsInRow(jQuery(list)).length); + list.classList.add('frm-field-group-hover-target'); + jQuery('#wpbody-content').on('mousemove', maybeRemoveHoverTargetOnMouseMove); + } + } + } + function maybeRemoveGroupHoverTarget() { + var controls, previousHoverTarget; + controls = document.getElementById('frm_field_group_controls'); + if (null !== controls) { + controls.style.display = 'none'; + } + previousHoverTarget = document.querySelector('.frm-field-group-hover-target'); + if (null === previousHoverTarget) { + return false; + } + jQuery('#wpbody-content').off('mousemove', maybeRemoveHoverTargetOnMouseMove); + previousHoverTarget.classList.remove('frm-field-group-hover-target'); + return previousHoverTarget; + } + function maybeRemoveHoverTargetOnMouseMove(event) { + var elementFromPoint = document.elementFromPoint(event.clientX, event.clientY); + if (null !== elementFromPoint && null !== elementFromPoint.closest('#frm-show-fields')) { + return; + } + maybeRemoveGroupHoverTarget(); + deleteTooltips(); + } + function onFieldActionDropdownShow(isFieldGroup) { + unselectFieldGroups(); + + // maybe offset the dropdown if it goes off of the right of the screen. + setTimeout(function () { + var ul, $ul; + ul = document.querySelector('.dropdown .frm-dropdown-menu.show'); + if (null === ul) { + return; + } + if (null === ul.getAttribute('aria-label')) { + ul.setAttribute('aria-label', __('More Options', 'formidable')); + } + if (0 === ul.children.length) { + fillFieldActionDropdown(ul, true === isFieldGroup); + } + $ul = jQuery(ul); + if ($ul.offset().left > jQuery(window).width() - $ul.outerWidth()) { + ul.style.left = -$ul.outerWidth() + 'px'; + } + var firstAnchor = ul.firstElementChild.querySelector('a'); + if (firstAnchor) { + firstAnchor.focus(); + } + }, 0); + } + function onFieldGroupActionDropdownShow() { + onFieldActionDropdownShow(true); + } + function changeSectionStyle(e) { + var collapsedSection = e.target.closest('.frm-section-collapsed'); + if (!collapsedSection) { + return; + } + if (e.type === 'show') { + collapsedSection.style.zIndex = 3; + } else { + collapsedSection.style.zIndex = 1; + } + } + function fillFieldActionDropdown(ul, isFieldGroup) { + var classSuffix, options; + classSuffix = isFieldGroup ? '_field_group' : '_field'; + options = [getDeleteActionOption(isFieldGroup), getDuplicateActionOption(isFieldGroup)]; + if (!isFieldGroup) { + options.push({ + class: 'frm_select', + icon: 'frm_settings_icon', + label: __('Field Settings', 'formidable') + }); + } + options.forEach(function (option) { + var li, anchor, span; + li = document.createElement('div'); + li.classList.add('frm_more_options_li', 'dropdown-item'); + anchor = document.createElement('a'); + anchor.classList.add(option.class + classSuffix); + anchor.setAttribute('href', '#'); + makeTabbable(anchor); + span = document.createElement('span'); + span.textContent = option.label; + anchor.innerHTML = ''; + anchor.append(document.createTextNode(' ')); + anchor.append(span); + li.append(anchor); + ul.append(li); + }); + } + function getDeleteActionOption(isFieldGroup) { + var option = { + class: 'frm_delete', + icon: 'frm_delete_icon' + }; + option.label = isFieldGroup ? __('Delete Group', 'formidable') : __('Delete', 'formidable'); + return option; + } + function getDuplicateActionOption(isFieldGroup) { + var option = { + class: 'frm_clone', + icon: 'frm_clone_icon' + }; + option.label = isFieldGroup ? __('Duplicate Group', 'formidable') : __('Duplicate', 'formidable'); + return option; + } + function wrapFieldLi(field) { + var wrapper = div(); + if ('string' === typeof field) { + wrapper.innerHTML = field; + } else { + wrapper.append(field); + } + var result = jQuery(); + Array.from(wrapper.children).forEach(function (li) { + result = result.add(jQuery('
  • ').addClass('frm_field_box').html(jQuery('