{"version":3,"sources":["webpack:///scripts/validate-form--3234af2eecd73bb7acf1.js","webpack:///./client/src/core/components/form-validation/validate-field.js","webpack:///./client/src/core/components/form-validation/validate-form.js","webpack:///./client/src/core/plugins/extract-options.js"],"names":["webpackJsonpHairCare","D:\\a\\1\\s\\node_modules\\babel-loader\\lib\\index.js??ref--12-0!D:\\a\\1\\s\\node_modules\\eslint-loader\\index.js??ref--12-1!D:\\a\\1\\s\\client\\src\\core\\components\\form-validation\\validate-field.js","module","exports","__webpack_require__","_toConsumableArray","arr","Array","isArray","i","arr2","length","from","_classCallCheck","instance","Constructor","TypeError","getJSONValue","stringValue","JSON","parse","error","getFormData","form","formData","FormData","result","entries","field","getLengthValidator","maxValidator","minValidator","data","message","valLengthMessage","valLength","valLengthMin","push","test","bind","valLengthMax","getRegexValidator","validators","valRegexMessage","valRegex","valRegexPatternName","valRegexPattern","regex","handleInitialError","initialMessage","hasDefaultChanged","input","value","defaultValue","setNativeRequired","element","dataset","val","setAttribute","truthy","Object","defineProperty","_createClass","defineProperties","target","props","descriptor","enumerable","configurable","writable","key","protoProps","staticProps","prototype","_debug2","obj","__esModule","default","_debug","log","hidden_required","at_least_one_checked","inputs","filter","checked","email","equal_to","equalToInput","expression","RegExp","visa","replaceAll","onlyNumbers","prefix","mastercard","slice","amex","maxLength","minLength","creditcard","some","validator","creditcardtype","counterpartName","cardType","ValidateField","options","this","isFieldset","nodeName","isPassword","type","inputSet","querySelectorAll","errorMessageSuppressed","errorSelector","errorElementSelectorScope","document","errorElement","querySelector","id","showErrors","classList","includes","invalidMessageClass","hasErrorDisplayedOnInit","attributeObserver","MutationObserver","onAttributeChange","init","watch","registerInitialError","validate","wasValid","validity","valid","addEventListener","updateValidity","observe","attributes","textContent","initialErrorHandler","tests","setCustomValidity","validateField","results","map","errors","rule","console","updateFieldsetValidity","customError","validationMessage","validateFieldErrorMessage","valueMissing","valRequiredMessage","valRequired","parts","split","part","trim","bold","text","innerHTML","wrapper","createElement","appendChild","container","boldElement","createTextNode","errorMessage","getErrorMessage","isValid","clearDynamicErrorMessage","fillDynamicErrorMessage","notifyForm","remove","invalidInputClass","add","validMessageClass","undefined","name","renderErrorMessage","splitErrorMessage","eventName","setTimeout","dispatchEvent","CustomEvent","bubbles","updateErrorDisplay","mutationList","observer","mutation","attributeName","componentErrorAttribute","forEach","onShowErrorsChange","DEFAULTS","D:\\a\\1\\s\\node_modules\\babel-loader\\lib\\index.js??ref--12-0!D:\\a\\1\\s\\node_modules\\eslint-loader\\index.js??ref--12-1!D:\\a\\1\\s\\client\\src\\core\\components\\form-validation\\validate-form.js","_interopRequireDefault","buildShowIf","conditions","condition","showIfCondition","Error","buildSetIf","setIfCondition","attribute","setIf","updateDisabled","disable","parent","elements","disabled","switchElementValidation","willValidate","containerSelector","closest","required","hide","showIfSelector","hidden","disableElementValidation","show","enableElementValidation","hideShow","item","setUnset","disableHidden","disableFormElements","isInViewport","bounding","getBoundingClientRect","top","left","bottom","window","innerHeight","documentElement","clientHeight","right","innerWidth","clientWidth","_validateField2","_validateField","_extractOptions2","_extractOptions","FormValidation","showIfCollection","setIfCollection","errorSummarySelector","errorSummary","errorSummaryList","submitButton","childObserver","onChildMutation","showIfConditions","System","then","formShowIfElements","setIfElements","setIfSelector","pageShowIfElements","concat","updateShowIf","getValidatedFormElements","initFieldValidation","isInvalid","event","errorsShown","updateSubmitDisabled","onFormChange","onFormSubmit","onSubmitting","onSubmitError","childList","subtree","errorClickHandler","validateFieldInstance","assign","isElementNode","node","nodeType","added","addedNodes","removed","removedNodes","parentElement","matches","validateElementSelector","submitDisabledClass","getAttribute","scrollIntoView","href","focusTargetSelector","substring","indexOf","focus","staleSummaryItems","children","createErrorSummaryItem","itemAnchor","validateFieldSummaryLabel","itemHtml","updateErrorSummary","fields","component","firstInvalid","find","showSummary","focusError","preventDefault","stopImmediatePropagation","hideSummary","detail","submitFormEvent","removeAttribute","componentErrorSelector","D:\\a\\1\\s\\node_modules\\babel-loader\\lib\\index.js??ref--12-0!D:\\a\\1\\s\\node_modules\\eslint-loader\\index.js??ref--12-1!D:\\a\\1\\s\\client\\src\\core\\plugins\\extract-options.js","camelCase","string","replace","match","p1","p2","toUpperCase","toLowerCase","getOptionData","prop","hasOwnProperty","extractComponentOptions","cameledName","startsWith"],"mappings":"AAAAA,sBAAsB,kBAEhBC,iNACA,SAAUC,EAAQC,EAASC,GAEjC,YAeA,SAASC,GAAmBC,GAAO,GAAIC,MAAMC,QAAQF,GAAM,CAAE,IAAK,GAAIG,GAAI,EAAGC,EAAOH,MAAMD,EAAIK,QAASF,EAAIH,EAAIK,OAAQF,IAAOC,EAAKD,GAAKH,EAAIG,EAAM,OAAOC,GAAe,MAAOH,OAAMK,KAAKN,GAE1L,QAASO,GAAgBC,EAAUC,GAAe,KAAMD,YAAoBC,IAAgB,KAAM,IAAIC,WAAU,qCClBhH,QAASC,GAAaC,GACrB,IACC,MAAOC,MAAKC,MAAMF,GACjB,MAAOG,GACR,MAAOH,IAIT,QAASI,GAAYC,GACpB,GAAMC,GAAW,GAAIC,UAASF,GACxBG,KAFoB,uBAI1B,YAAkBF,EAASG,UAA3B,+CAAsC,IAA7BC,GAA6B,OACrCF,GAAOE,EAAM,IAAMX,EAAaW,EAAM,KALb,6EAO1B,MAAOF,GA+GR,QAASG,GAAmBC,EAAcC,EAAcC,GACvD,GAAMC,GAAUD,EAAKE,kBAAoBF,EAAKG,UACxCT,IAaN,OAZIM,GAAKI,cACRV,EAAOW,MACNC,KAAMP,EAAaQ,KAAK,KAAMP,EAAKI,cACnCH,YAGED,EAAKQ,cACRd,EAAOW,MACNC,KAAMR,EAAaS,KAAK,KAAMP,EAAKQ,cACnCP,YAGKP,EAeR,QAASe,GAAkBC,EAAYV,GACtC,GAAMC,GAAUD,EAAKW,iBAAmBX,EAAKY,QAE7C,OAAIZ,GAAKa,qBAAuBH,EAAWV,EAAKa,sBACtCP,KAAMI,EAAWV,EAAKa,qBAAsBZ,aAElDD,EAAKc,kBAEPR,KAAMI,EAAWK,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CR9C,OAAOC,eAAe1D,EAAS,cAC9BiD,OAAO,IAGRjD,EAAQ0E,QGpgCO,SAASwG,EAAM9H,GAC7B,MAAOmR,GAAwBrJ,EAAMkJ,EAAchR","file":"scripts/validate-form--3234af2eecd73bb7acf1.js","sourcesContent":["webpackJsonpHairCare([\"validate-form\"],{\n\n/***/ \"D:\\\\a\\\\1\\\\s\\\\node_modules\\\\babel-loader\\\\lib\\\\index.js??ref--12-0!D:\\\\a\\\\1\\\\s\\\\node_modules\\\\eslint-loader\\\\index.js??ref--12-1!D:\\\\a\\\\1\\\\s\\\\client\\\\src\\\\core\\\\components\\\\form-validation\\\\validate-field.js\":\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n\tvalue: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _debug = __webpack_require__(\"D:\\\\a\\\\1\\\\s\\\\node_modules\\\\babel-loader\\\\lib\\\\index.js??ref--12-0!D:\\\\a\\\\1\\\\s\\\\node_modules\\\\eslint-loader\\\\index.js??ref--12-1!D:\\\\a\\\\1\\\\s\\\\node_modules\\\\debug\\\\src\\\\browser.js\");\n\nvar _debug2 = _interopRequireDefault(_debug);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar log = (0, _debug2.default)(\"validate-field\");\n\nfunction getJSONValue(stringValue) {\n\ttry {\n\t\treturn JSON.parse(stringValue);\n\t} catch (error) {\n\t\treturn stringValue;\n\t}\n}\n\nfunction getFormData(form) {\n\tvar formData = new FormData(form);\n\tvar result = {};\n\n\tvar _iteratorNormalCompletion = true;\n\tvar _didIteratorError = false;\n\tvar _iteratorError = undefined;\n\n\ttry {\n\t\tfor (var _iterator = formData.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n\t\t\tvar field = _step.value;\n\n\t\t\tresult[field[0]] = getJSONValue(field[1]);\n\t\t}\n\t} catch (err) {\n\t\t_didIteratorError = true;\n\t\t_iteratorError = err;\n\t} finally {\n\t\ttry {\n\t\t\tif (!_iteratorNormalCompletion && _iterator.return) {\n\t\t\t\t_iterator.return();\n\t\t\t}\n\t\t} finally {\n\t\t\tif (_didIteratorError) {\n\t\t\t\tthrow _iteratorError;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}\n\nvar validators = {\n\thidden_required: function hidden_required(input) {\n\t\treturn input.value ? \"\" : \"required\";\n\t},\n\tat_least_one_checked: function at_least_one_checked(inputs) {\n\t\t// intended for checkboxes - but works on radio\n\t\treturn inputs.filter(function (input) {\n\t\t\treturn input.checked;\n\t\t}).length > 0 ? \"\" : \"check at least one\";\n\t},\n\temail: function email(input) {\n\t\treturn (/^\\b([^@\\s]+@){1}[^@\\s]+\\.[^@\\s]+\\b$/.test(input.value)\n\t\t);\n\t},\n\tequal_to: function equal_to(input, equalToInput) {\n\t\treturn input.value == equalToInput.value;\n\t},\n\tregex: function regex(expression, input) {\n\t\tvar regex = new RegExp(expression);\n\t\treturn regex.test(input.value);\n\t},\n\tvisa: function visa(input) {\n\t\t// prefix: 4\n\t\t// length: 13,16\n\t\t// ignore spaces\n\t\tvar value = input.value.replaceAll(\" \", \"\");\n\t\tvar onlyNumbers = /^\\d+$/;\n\t\tvar prefix = value[0];\n\t\treturn onlyNumbers.test(value) && (value.length === 13 || value.length === 16) && prefix === \"4\";\n\t},\n\tmastercard: function mastercard(input) {\n\t\t// prefix: 51-55\n\t\t// length: 16\n\t\t// ignore spaces\n\t\tvar value = input.value.replaceAll(\" \", \"\");\n\t\tvar onlyNumbers = /^\\d+$/;\n\t\tvar prefix = +value.slice(0, 2);\n\t\treturn onlyNumbers.test(value) && value.length === 16 && prefix >= 51 && prefix <= 55;\n\t},\n\tamex: function amex(input) {\n\t\t// prefix: 34,37\n\t\t// length: 15\n\t\t// ignore spaces\n\t\tvar value = input.value.replaceAll(\" \", \"\");\n\t\tvar onlyNumbers = /^\\d+$/;\n\t\tvar prefix = value.slice(0, 2);\n\t\treturn onlyNumbers.test(value) && value.length === 15 && prefix === \"34\" || prefix === \"37\";\n\t},\n\tmaxLength: function maxLength(length, input) {\n\t\treturn input.value.length <= length;\n\t},\n\tminLength: function minLength(length, input) {\n\t\treturn input.value.length >= length;\n\t}\n};\n\n// any one of visa, mastercard, or max\nvalidators.creditcard = function (input) {\n\tvar cardTypes = [validators.amex, validators.visa, validators.mastercard];\n\n\treturn cardTypes.some(function (validator) {\n\t\treturn validator(input);\n\t});\n};\n\n// any one of visa, mastercard, or max\nvalidators.creditcardtype = function (input, counterpartName) {\n\tvar formData = getFormData(input.form);\n\n\tif (counterpartName && formData[counterpartName]) {\n\t\tvar cardType = formData[counterpartName];\n\t\treturn validators[cardType](input);\n\t}\n\n\tvar cardTypes = [validators.amex, validators.visa, validators.mastercard];\n\n\treturn cardTypes.some(function (validator) {\n\t\treturn validator(input);\n\t});\n};\n\n/*\r\n\tCharacter length validation\r\n\telement.dataset\r\n\r\n\tFrom MVC:\r\n\tvalLengthMax: \"3\"\r\n\tvalLengthMin: \"Length error message\"\r\n\tvalLength: \"Length error message\"\r\n\r\n\tOverriding MVC:\r\n\tvalLengthMessage: \"Custom length error message\"\r\n*/\nfunction getLengthValidator(maxValidator, minValidator, data) {\n\tvar message = data.valLengthMessage || data.valLength;\n\tvar result = [];\n\tif (data.valLengthMin) {\n\t\tresult.push({\n\t\t\ttest: minValidator.bind(null, data.valLengthMin),\n\t\t\tmessage: message\n\t\t});\n\t}\n\tif (data.valLengthMax) {\n\t\tresult.push({\n\t\t\ttest: maxValidator.bind(null, data.valLengthMax),\n\t\t\tmessage: message\n\t\t});\n\t}\n\treturn result;\n}\n\n/*\r\n\tRegex Validation Properties:\r\n\telement.dataset\r\n\r\n\tFrom MVC:\r\n\tvalRegexPattern: \"/regex/\"\r\n\tvalRegex: \"Regex error message\"\r\n\r\n\tOverriding MVC:\r\n\tvalRegexPatternName: \"email\" (uses look up in `validators`)\r\n\tvalRegexMessage: \"Custom regex error message\"\r\n*/\nfunction getRegexValidator(validators, data) {\n\tvar message = data.valRegexMessage || data.valRegex;\n\n\tif (data.valRegexPatternName && validators[data.valRegexPatternName]) {\n\t\treturn { test: validators[data.valRegexPatternName], message: message };\n\t}\n\tif (data.valRegexPattern) {\n\t\treturn {\n\t\t\ttest: validators.regex.bind(null, data.valRegexPattern),\n\t\t\tmessage: message\n\t\t};\n\t}\n\treturn false;\n}\n\nfunction handleInitialError(initialMessage) {\n\n\tfunction hasDefaultChanged(input) {\n\n\t\t// prevent resubmission of server validation failed value\n\t\t// until it is changed\n\t\treturn input.value !== input.defaultValue;\n\t}\n\n\treturn {\n\t\ttest: hasDefaultChanged,\n\t\tmessage: initialMessage\n\t};\n}\n\nfunction setNativeRequired(element) {\n\t// MVC forms indicate required elements with data-val\n\tif (element.dataset.val === \"true\") {\n\t\telement.setAttribute(\"required\", \"\");\n\t}\n}\n\nfunction truthy(value) {\n\treturn value;\n}\n\nvar ValidateField = function () {\n\tfunction ValidateField(element, options) {\n\t\t_classCallCheck(this, ValidateField);\n\n\t\tlog(\"element\", element);\n\t\tlog(\"options\", options);\n\n\t\tthis.options = options;\n\t\tthis.element = element;\n\n\t\tthis.isFieldset = this.element.nodeName === \"FIELDSET\";\n\t\tthis.isPassword = this.element.type === \"password\";\n\n\t\tthis.inputSet = [].concat(_toConsumableArray(this.element.querySelectorAll(\"[name=\\\"\" + this.options.inputSet + \"\\\"]\")));\n\n\t\tif (!this.options.errorMessageSuppressed) {\n\t\t\tif (this.options.errorSelector) {\n\t\t\t\tthis.errorElementSelectorScope = this.options.errorSelector[0] === \"#\" ? document : this.element;\n\n\t\t\t\tthis.errorElement = this.errorElementSelectorScope.querySelector(this.options.errorSelector);\n\t\t\t} else {\n\t\t\t\t// Fallback to MVC default\n\t\t\t\t// Note ids on form elements have dots converted to underscores\n\t\t\t\tthis.errorElement = document.querySelector(\"[data-valmsg-for=\\\"\" + element.id.replaceAll(\"_\", \".\") + \"\\\"]\");\n\t\t\t}\n\n\t\t\t// TODO: element error message either doesn't exist\n\t\t\t// or is a custom element with built in message we don't want to change\n\t\t\t// or is not specified on this element or incorporates mark-up such as links\n\t\t\t// the validated element input may not be editable\n\t\t\t// although we may want to toggle visibility of the error\n\n\t\t\tthis.showErrors = getJSONValue(this.element.dataset.showErrors) || [].concat(_toConsumableArray(this.errorElement.classList)).includes(this.options.invalidMessageClass);\n\t\t}\n\n\t\tif (this.showErrors) {\n\t\t\tthis.hasErrorDisplayedOnInit = true;\n\t\t}\n\n\t\tthis.attributeObserver = new MutationObserver(this.onAttributeChange.bind(this));\n\n\t\tthis.init();\n\t\tthis.watch();\n\n\t\tlog(\"ready\", this, this.element);\n\t}\n\n\t_createClass(ValidateField, [{\n\t\tkey: \"init\",\n\t\tvalue: function init() {\n\t\t\tsetNativeRequired(this.element);\n\t\t\tthis.registerInitialError();\n\t\t\tthis.validate();\n\t\t\tthis.wasValid = this.element.validity.valid;\n\t\t}\n\t}, {\n\t\tkey: \"watch\",\n\t\tvalue: function watch() {\n\t\t\tlog(\"watching\");\n\t\t\tthis.element.addEventListener(\"input\", this.updateValidity.bind(this));\n\t\t\tthis.element.addEventListener(\"validate\", this.updateValidity.bind(this));\n\t\t\tthis.attributeObserver.observe(this.element, { attributes: true });\n\t\t}\n\t}, {\n\t\tkey: \"registerInitialError\",\n\t\tvalue: function registerInitialError() {\n\t\t\tvar initialMessage = this.errorElement.textContent;\n\t\t\tthis.initialErrorHandler = this.hasErrorDisplayedOnInit ? handleInitialError(initialMessage) : false;\n\t\t}\n\n\t\t/*\r\n \tRequired Validation Properties:\r\n \telement.dataset\r\n \n \tFrom MVC:\r\n \tval: \"true\" (field value is required)\r\n \tvalRequired: \"Required error message\"\r\n \n \tOverriding MVC:\r\n \tvalRequiredMessage: \"Custom required error message\"\r\n */\n\n\t}, {\n\t\tkey: \"validate\",\n\t\tvalue: function validate() {\n\t\t\tvar _this = this;\n\n\t\t\tvar tests = [this.initialErrorHandler].concat(_toConsumableArray(getLengthValidator(validators[\"maxLength\"], validators[\"minLength\"], this.element.dataset)), [getRegexValidator(validators, this.element.dataset)]).filter(truthy);\n\n\t\t\t// Reset custom validity\n\t\t\tthis.element.setCustomValidity(\"\");\n\n\t\t\t// Validation may have been disabled if this field was hidden\n\t\t\tif (this.element.dataset.validateField === \"false\") {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// For good security practice password input values are not preserved.\n\t\t\t// Until client side validation is in place to match server password rules\n\t\t\t// we special case password input to ensure server error is displayed\n\t\t\t// otherwise required field message is displayed in response to empty value\n\t\t\tif (this.isPassword && this.hasErrorDisplayedOnInit && this.element.value === \"\") {\n\t\t\t\tthis.element.setCustomValidity(this.errorElement.textContent);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (this.element.value !== \"\" && tests.length) {\n\t\t\t\tvar results = tests.map(function (validator) {\n\t\t\t\t\treturn validator.test(_this.element, _this.options.counterpartName) ? \"\" : validator.message;\n\t\t\t\t});\n\n\t\t\t\tvar errors = results.filter(function (result) {\n\t\t\t\t\treturn result !== \"\";\n\t\t\t\t});\n\n\t\t\t\tif (errors.length) {\n\t\t\t\t\tthis.element.setCustomValidity(errors[0]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.options.rule) {\n\t\t\t\tvar validator = validators[this.options.rule];\n\n\t\t\t\tif (!validator) {\n\t\t\t\t\tconsole.error(\"Validation rule data-field-validation-rule=\\\"\" + this.options.rule + \"\\\" is not defined. See\", this.element);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// TODO: merge fieldset handling and this into one code path\n\t\t\t\tif (this.isFieldset) {\n\t\t\t\t\tthis.updateFieldsetValidity();\n\t\t\t\t} else {\n\t\t\t\t\tthis.element.setCustomValidity(validator(this.element));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, {\n\t\tkey: \"getErrorMessage\",\n\t\tvalue: function getErrorMessage() {\n\t\t\tif (!this.element.validity.valid) {\n\t\t\t\tif (this.element.validity.customError) {\n\t\t\t\t\tvar customMessage = this.element.validationMessage !== \"\" ? this.element.validationMessage : this.element.dataset.validateFieldErrorMessage;\n\t\t\t\t\treturn customMessage;\n\t\t\t\t} else if (this.element.validity.valueMissing) {\n\t\t\t\t\treturn this.element.dataset.valRequiredMessage || this.element.dataset.valRequired;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn \"\";\n\t\t}\n\t}, {\n\t\tkey: \"splitErrorMessage\",\n\t\tvalue: function splitErrorMessage(message) {\n\t\t\tvar parts = message.split(\"|\").map(function (part) {\n\t\t\t\treturn part.trim();\n\t\t\t}).filter(function (part) {\n\t\t\t\treturn part !== \"\";\n\t\t\t});\n\n\t\t\tvar bold = parts.length > 1 ? parts[0] : false;\n\t\t\tvar text = parts.length > 1 ? parts[1] : parts[0];\n\n\t\t\treturn {\n\t\t\t\tbold: bold,\n\t\t\t\ttext: text\n\t\t\t};\n\t\t}\n\t}, {\n\t\tkey: \"renderErrorMessage\",\n\t\tvalue: function renderErrorMessage(element, message) {\n\t\t\tvar bold = message.bold,\n\t\t\t text = message.text;\n\n\n\t\t\telement.innerHTML = \"\";\n\n\t\t\tvar wrapper = bold && text ? document.createElement(\"span\") : false;\n\t\t\tif (wrapper) {\n\t\t\t\telement.appendChild(wrapper);\n\t\t\t}\n\t\t\tvar container = wrapper || element;\n\n\t\t\tif (bold) {\n\t\t\t\tvar boldElement = document.createElement(\"strong\");\n\t\t\t\tboldElement.textContent = bold;\n\t\t\t\tcontainer.appendChild(boldElement);\n\t\t\t}\n\t\t\tif (bold && text) {\n\t\t\t\tcontainer.appendChild(document.createElement(\"br\"));\n\t\t\t}\n\t\t\tif (text) {\n\t\t\t\tcontainer.appendChild(document.createTextNode(text));\n\t\t\t}\n\t\t}\n\t}, {\n\t\tkey: \"updateFieldsetValidity\",\n\t\tvalue: function updateFieldsetValidity() {\n\t\t\tvar validator = validators[this.options.rule];\n\t\t\tif (!this.isFieldset || !validator) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tthis.element.setCustomValidity(validator(this.inputSet));\n\t\t}\n\t}, {\n\t\tkey: \"updateErrorDisplay\",\n\t\tvalue: function updateErrorDisplay() {\n\t\t\t// Short circuit when error message is embedded in the page and unchanging\n\t\t\t// Doesn't need to be shown/hidden/updated\n\t\t\tif (this.options.errorMessageSuppressed) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tvar errorMessage = this.getErrorMessage();\n\t\t\tvar isValid = errorMessage === \"\";\n\n\t\t\tif (isValid) {\n\t\t\t\tthis.clearDynamicErrorMessage();\n\t\t\t} else {\n\t\t\t\tthis.fillDynamicErrorMessage(errorMessage);\n\t\t\t}\n\n\t\t\tthis.notifyForm(isValid);\n\t\t}\n\t}, {\n\t\tkey: \"clearDynamicErrorMessage\",\n\t\tvalue: function clearDynamicErrorMessage() {\n\t\t\tthis.element.classList.remove(this.options.invalidInputClass);\n\t\t\tthis.errorElement.innerHTML = \"\";\n\t\t\tthis.errorElement.classList.remove(this.options.invalidMessageClass);\n\t\t\tthis.errorElement.classList.add(this.options.validMessageClass);\n\t\t}\n\t}, {\n\t\tkey: \"fillDynamicErrorMessage\",\n\t\tvalue: function fillDynamicErrorMessage(errorMessage) {\n\t\t\tthis.element.classList.add(this.options.invalidInputClass);\n\n\t\t\tif (errorMessage === undefined) {\n\t\t\t\tlog(\"Missing error message for [name=\\\"\" + this.element.name + \"]\");\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tthis.renderErrorMessage(this.errorElement, this.splitErrorMessage(errorMessage));\n\t\t\tthis.errorElement.classList.add(this.options.invalidMessageClass);\n\t\t\tthis.errorElement.classList.remove(this.options.validMessageClass);\n\t\t}\n\t}, {\n\t\tkey: \"notifyForm\",\n\t\tvalue: function notifyForm(isValid) {\n\t\t\tvar _this2 = this;\n\n\t\t\tvar eventName = isValid ? \"validation-error-hidden\" : \"validation-error-displayed\";\n\n\t\t\tif (!isValid || isValid && !this.wasValid) {\n\t\t\t\t// Give form a chance to init listeners first:\n\t\t\t\tsetTimeout(function () {\n\t\t\t\t\t_this2.element.dispatchEvent(new CustomEvent(eventName, {\n\t\t\t\t\t\tbubbles: true\n\t\t\t\t\t}));\n\t\t\t\t});\n\t\t\t}\n\t\t\tthis.wasValid = isValid;\n\t\t}\n\t}, {\n\t\tkey: \"updateValidity\",\n\t\tvalue: function updateValidity() {\n\t\t\tthis.validate();\n\n\t\t\tif (this.showErrors) {\n\t\t\t\tthis.updateErrorDisplay();\n\t\t\t}\n\t\t}\n\t}, {\n\t\tkey: \"onAttributeChange\",\n\t\tvalue: function onAttributeChange(mutationList, observer) {\n\t\t\tmutationList.filter(function (mutation) {\n\t\t\t\treturn mutation.type === \"attributes\" && mutation.attributeName === this.options.componentErrorAttribute;\n\t\t\t}.bind(this)).forEach(this.onShowErrorsChange.bind(this));\n\t\t}\n\t}, {\n\t\tkey: \"onShowErrorsChange\",\n\t\tvalue: function onShowErrorsChange(mutation) {\n\t\t\tthis.showErrors = getJSONValue(this.element.dataset.showErrors);\n\t\t\tthis.updateErrorDisplay();\n\t\t}\n\t}]);\n\n\treturn ValidateField;\n}();\n\nValidateField.DEFAULTS = {\n\tcomponentErrorAttribute: \"data-show-errors\",\n\tvalidMessageClass: \"field-validation-valid\",\n\tinvalidMessageClass: \"field-validation-error\",\n\tinvalidInputClass: \"input-validation-error\"\n};\n\nexports.default = ValidateField;\n\n/***/ }),\n\n/***/ \"D:\\\\a\\\\1\\\\s\\\\node_modules\\\\babel-loader\\\\lib\\\\index.js??ref--12-0!D:\\\\a\\\\1\\\\s\\\\node_modules\\\\eslint-loader\\\\index.js??ref--12-1!D:\\\\a\\\\1\\\\s\\\\client\\\\src\\\\core\\\\components\\\\form-validation\\\\validate-form.js\":\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n\tvalue: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _validateField = __webpack_require__(\"D:\\\\a\\\\1\\\\s\\\\node_modules\\\\babel-loader\\\\lib\\\\index.js??ref--12-0!D:\\\\a\\\\1\\\\s\\\\node_modules\\\\eslint-loader\\\\index.js??ref--12-1!D:\\\\a\\\\1\\\\s\\\\client\\\\src\\\\core\\\\components\\\\form-validation\\\\validate-field.js\");\n\nvar _validateField2 = _interopRequireDefault(_validateField);\n\nvar _extractOptions = __webpack_require__(\"D:\\\\a\\\\1\\\\s\\\\node_modules\\\\babel-loader\\\\lib\\\\index.js??ref--12-0!D:\\\\a\\\\1\\\\s\\\\node_modules\\\\eslint-loader\\\\index.js??ref--12-1!D:\\\\a\\\\1\\\\s\\\\client\\\\src\\\\core\\\\plugins\\\\extract-options.js\");\n\nvar _extractOptions2 = _interopRequireDefault(_extractOptions);\n\nvar _debug = __webpack_require__(\"D:\\\\a\\\\1\\\\s\\\\node_modules\\\\babel-loader\\\\lib\\\\index.js??ref--12-0!D:\\\\a\\\\1\\\\s\\\\node_modules\\\\eslint-loader\\\\index.js??ref--12-1!D:\\\\a\\\\1\\\\s\\\\node_modules\\\\debug\\\\src\\\\browser.js\");\n\nvar _debug2 = _interopRequireDefault(_debug);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }\n\nvar log = (0, _debug2.default)(\"validate-form\");\n\nfunction getJSONValue(stringValue) {\n\ttry {\n\t\treturn JSON.parse(stringValue);\n\t} catch (error) {\n\t\treturn stringValue;\n\t}\n}\n\nfunction getFormData(form) {\n\tvar formData = new FormData(form);\n\tvar result = {};\n\n\tvar _iteratorNormalCompletion = true;\n\tvar _didIteratorError = false;\n\tvar _iteratorError = undefined;\n\n\ttry {\n\t\tfor (var _iterator = formData.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n\t\t\tvar field = _step.value;\n\n\t\t\tresult[field[0]] = getJSONValue(field[1]);\n\t\t}\n\t} catch (err) {\n\t\t_didIteratorError = true;\n\t\t_iteratorError = err;\n\t} finally {\n\t\ttry {\n\t\t\tif (!_iteratorNormalCompletion && _iterator.return) {\n\t\t\t\t_iterator.return();\n\t\t\t}\n\t\t} finally {\n\t\t\tif (_didIteratorError) {\n\t\t\t\tthrow _iteratorError;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}\n\nfunction buildShowIf(conditions, element) {\n\tvar condition = conditions[element.dataset.showIfCondition];\n\n\t// Throw error if condition not found\n\tif (typeof condition === \"function\") {\n\t\treturn {\n\t\t\tcondition: condition,\n\t\t\telement: element\n\t\t};\n\t} else {\n\t\tthrow new Error(element.dataset.showIfCondition + \" in data-show-if-condition=\\\"\" + element.dataset.showIfCondition + \"\\\" is not a defined condition function\");\n\t}\n}\n\nfunction buildSetIf(conditions, element) {\n\tvar condition = conditions[element.dataset.setIfCondition];\n\tvar attribute = element.dataset.setIf;\n\n\tlog({ condition: condition, attribute: attribute });\n\n\t// Throw error if condition not found\n\tif (typeof condition !== \"function\") {\n\t\tthrow new Error(element.dataset.setIfCondition + \" in data-set-if-condition=\\\"\" + element.dataset.setIfCondition + \"\\\" is not a defined condition function\");\n\t}\n\n\tif (!attribute) {\n\t\tthrow new Error(\"Define a data attribute to set when data-set-if-condition=\\\"\" + element.dataset.setIfCondition + \"\\\" by providing a value for data-set-if=\\\"data-???\\\"\");\n\t}\n\n\treturn {\n\t\tcondition: condition,\n\t\telement: element,\n\t\tattribute: attribute\n\t};\n}\n\nfunction updateDisabled(disable, parent) {\n\t// TODO: consider adding an element attr to preserve the disabled state\n\t// similar to data-required\n\tvar elements = [].concat(_toConsumableArray(parent.querySelectorAll(\"input,select,button,textarea\")));\n\telements.forEach(function (element) {\n\t\telement.disabled = disable;\n\t});\n}\n\n// const enableFormElements = updateDisabled.bind(null, false);\nvar disableFormElements = updateDisabled.bind(null, true);\n\nfunction switchElementValidation(willValidate, parent, containerSelector) {\n\tvar elements = [].concat(_toConsumableArray(parent.querySelectorAll(\"[data-validate-field]\")));\n\n\tvar elementsToUpdate = elements.filter(function (element) {\n\t\treturn element.closest(containerSelector) === parent;\n\t});\n\n\telementsToUpdate.forEach(function (element) {\n\t\telement.required = willValidate;\n\t\telement.dataset.validateField = willValidate;\n\t});\n\n\t// Use data-required value as a proxy for required property\n\t//\ton fieldset elements with customValidity\n\tif (parent.nodeName === \"FIELDSET\" && parent.dataset.required !== undefined) {\n\t\tparent.dataset.required = willValidate;\n\t}\n}\n\nvar enableElementValidation = switchElementValidation.bind(null, true);\nvar disableElementValidation = switchElementValidation.bind(null, false);\n\nfunction hide(element, showIfSelector) {\n\tlog(\"hide\", element);\n\telement.hidden = true;\n\tdisableElementValidation(element, showIfSelector);\n}\n\nfunction show(element, showIfSelector) {\n\tlog(\"show\", element);\n\telement.hidden = false;\n\tenableElementValidation(element, showIfSelector);\n}\n\nfunction hideShow(formData, options, item) {\n\tif (item.condition(formData, options)) {\n\t\tshow(item.element, options.showIfSelector);\n\t} else {\n\t\thide(item.element, options.showIfSelector);\n\t}\n}\n\nfunction setUnset(formData, options, item) {\n\tif (item.condition(formData, options)) {\n\t\titem.element.setAttribute(item.attribute, \"true\");\n\t} else {\n\t\titem.element.setAttribute(item.attribute, \"false\");\n\t}\n}\n\nfunction disableHidden(formData, options, item) {\n\tif (!item.condition(formData, options)) {\n\t\tdisableFormElements(item.element);\n\t}\n}\n\nfunction isInViewport(element) {\n\tvar bounding = element.getBoundingClientRect();\n\treturn bounding.top >= 0 && bounding.left >= 0 && bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) && bounding.right <= (window.innerWidth || document.documentElement.clientWidth);\n}\n\nvar FormValidation = function () {\n\tfunction FormValidation(element, options) {\n\t\t_classCallCheck(this, FormValidation);\n\n\t\tlog(\"element\", element);\n\t\tlog(\"options\", options);\n\n\t\tthis.options = options;\n\t\tthis.form = element;\n\t\tthis.showIfCollection = [];\n\t\tthis.setIfCollection = [];\n\n\t\tif (this.options.errorSummarySelector) {\n\t\t\tthis.errorSummary = this.form.querySelector(this.options.errorSummarySelector);\n\n\t\t\tif (!this.errorSummary) {\n\t\t\t\tlog(\"Specified error summary element not found:\\ndata-validate-form-error-summary=\\\"\" + this.options.errorSummarySelector + \"\\\" Aborting\");\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tthis.errorSummaryList = this.errorSummary.querySelector(\"ul\");\n\t\t}\n\n\t\tthis.submitButton = this.form.querySelector('[type=\"submit\"]');\n\n\t\tthis.childObserver = new MutationObserver(this.onChildMutation.bind(this));\n\n\t\tthis.init();\n\t\tthis.watch();\n\n\t\tlog(\"ready\", this, this.form);\n\t}\n\n\t_createClass(FormValidation, [{\n\t\tkey: \"init\",\n\t\tvalue: function init() {\n\t\t\tvar _this = this;\n\n\t\t\t// See quote-form/choose-form in pch001 for conditional show/hide examples\n\t\t\tif (this.options.showIfConditions) {\n\t\t\t\t__webpack_require__.e/* import() */(\"conditions\").then(__webpack_require__.bind(null, \"D:\\\\a\\\\1\\\\s\\\\node_modules\\\\babel-loader\\\\lib\\\\index.js??ref--12-0!D:\\\\a\\\\1\\\\s\\\\node_modules\\\\eslint-loader\\\\index.js??ref--12-1!D:\\\\a\\\\1\\\\s\\\\client\\\\src\\\\core\\\\components\\\\form-validation\\\\conditions\\\\index.js\")).then(function (module) {\n\t\t\t\t\t_this.conditions = module.default[_this.options.showIfConditions];\n\t\t\t\t\tlog(\"conditions\", module.default);\n\t\t\t\t}).then(function () {\n\t\t\t\t\t// Find elements within the same form with show if data attr\n\t\t\t\t\tvar formShowIfElements = [].concat(_toConsumableArray(_this.form.querySelectorAll(_this.options.showIfSelector)));\n\n\t\t\t\t\tvar setIfElements = [].concat(_toConsumableArray(_this.form.querySelectorAll(_this.options.setIfSelector)));\n\n\t\t\t\t\t// Find elements within the whole document with page show if data attr\n\t\t\t\t\tvar pageShowIfElements = [].concat(_toConsumableArray(document.querySelectorAll(\"[data-show-if-form=\\\"\" + _this.options.showIfConditions + \"\\\"]\")));\n\n\t\t\t\t\t_this.showIfCollection = formShowIfElements.concat(pageShowIfElements).map(buildShowIf.bind(_this, _this.conditions));\n\n\t\t\t\t\t_this.setIfCollection = setIfElements.map(buildSetIf.bind(_this, _this.conditions));\n\n\t\t\t\t\t_this.updateShowIf(getFormData(_this.form));\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Disable default native validation - we want control\n\t\t\tthis.form.setAttribute(\"novalidate\", \"\");\n\t\t\tthis.getValidatedFormElements(this.form).forEach(this.initFieldValidation);\n\t\t\tthis.isInvalid();\n\t\t}\n\t}, {\n\t\tkey: \"watch\",\n\t\tvalue: function watch() {\n\t\t\tvar _this2 = this;\n\n\t\t\tlog(\"watching\");\n\n\t\t\tthis.form.addEventListener(\"validation-error-displayed\", function (event) {\n\t\t\t\t_this2.errorsShown = true;\n\t\t\t\t_this2.updateSubmitDisabled(true);\n\t\t\t});\n\t\t\tthis.form.addEventListener(\"validation-error-hidden\", function (event) {\n\t\t\t\t_this2.updateSubmitDisabled(_this2.isInvalid());\n\t\t\t});\n\t\t\tthis.form.addEventListener(\"change\", this.onFormChange.bind(this));\n\t\t\tthis.form.addEventListener(\"submit\", this.onFormSubmit.bind(this));\n\t\t\tthis.form.addEventListener(\"submit\", this.onSubmitting.bind(this));\n\t\t\tthis.form.addEventListener(\"submit error\", this.onSubmitError.bind(this));\n\t\t\tthis.childObserver.observe(this.form, {\n\t\t\t\tchildList: true,\n\t\t\t\tsubtree: true\n\t\t\t});\n\n\t\t\tif (this.errorSummary) {\n\t\t\t\tthis.errorSummary.addEventListener(\"click\", this.errorClickHandler.bind(this));\n\t\t\t}\n\t\t}\n\t}, {\n\t\tkey: \"initFieldValidation\",\n\t\tvalue: function initFieldValidation(element) {\n\t\t\t// TODO: safer way to test if ValidateField already applied?\n\t\t\tif (element.validateFieldInstance !== undefined) {\n\t\t\t\tlog(\"Already init\", element);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tvar options = Object.assign({}, _validateField2.default.DEFAULTS, (0, _extractOptions2.default)(\"validateField\", element));\n\t\t\tvar instance = new _validateField2.default(element, options);\n\t\t\telement.validateFieldInstance = instance;\n\t\t}\n\t}, {\n\t\tkey: \"onChildMutation\",\n\t\tvalue: function onChildMutation(mutationList, observer) {\n\t\t\tvar _this3 = this;\n\n\t\t\tmutationList.filter(function (mutation) {\n\t\t\t\treturn mutation.type === \"childList\";\n\t\t\t}).forEach(function (mutation) {\n\t\t\t\tlog(\"mutation item\", mutation);\n\n\t\t\t\tfunction isElementNode(node) {\n\t\t\t\t\treturn node.nodeType === 1;\n\t\t\t\t}\n\n\t\t\t\tvar added = Array.from(mutation.addedNodes).filter(isElementNode);\n\t\t\t\tvar removed = Array.from(mutation.removedNodes).filter(isElementNode);\n\n\t\t\t\t// may include elements to validate\n\t\t\t\t// find and init\n\t\t\t\tadded.forEach(function (node) {\n\t\t\t\t\t_this3.getValidatedFormElements(node).forEach(_this3.initFieldValidation);\n\t\t\t\t});\n\n\t\t\t\t// if nodes removed\n\t\t\t\t// may include conditional elements/values\n\t\t\t\t// re-evaluate form conditions\n\t\t\t\tif (added.length || removed.length) {\n\t\t\t\t\t_this3.updateShowIf(getFormData(_this3.form));\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\t// Elements that may have error messages to display\n\n\t}, {\n\t\tkey: \"getValidatedFormElements\",\n\t\tvalue: function getValidatedFormElements(parentElement) {\n\t\t\tvar _this4 = this;\n\n\t\t\treturn Array.from(parentElement.querySelectorAll(\"input,textarea,select,fieldset[data-validate-field]\")).filter(function (element) {\n\t\t\t\treturn element.matches(_this4.options.validateElementSelector);\n\t\t\t});\n\t\t}\n\t}, {\n\t\tkey: \"updateSubmitDisabled\",\n\t\tvalue: function updateSubmitDisabled(isInvalid) {\n\t\t\tif (!this.submitButton) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (isInvalid && this.errorsShown) {\n\t\t\t\tthis.submitButton.classList.add(this.options.submitDisabledClass);\n\t\t\t} else {\n\t\t\t\tthis.submitButton.classList.remove(this.options.submitDisabledClass);\n\t\t\t}\n\t\t}\n\t}, {\n\t\tkey: \"onFormChange\",\n\t\tvalue: function onFormChange(event) {\n\t\t\tlog(\"onFormChange\", event);\n\t\t\tthis.updateShowIf(getFormData(this.form));\n\n\t\t\t// Keep changed element in view after layout shifts\n\t\t\tif (event.target.getAttribute(\"type\") !== \"hidden\") {\n\t\t\t\tif (!isInViewport(event.target)) {\n\t\t\t\t\t// A more thorough implementation would attempt to restore\n\t\t\t\t\t// the previous relative view port postion of the element\n\t\t\t\t\tevent.target.scrollIntoView();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Trigger a validation update - change may have occurred in a hidden input\n\t\t\t// Hidden inputs do not emit events so\n\t\t\t// we fallback to catching change events on the form\n\t\t\tthis.updateSubmitDisabled(this.isInvalid());\n\t\t}\n\t}, {\n\t\tkey: \"errorClickHandler\",\n\t\tvalue: function errorClickHandler(event) {\n\t\t\tif (event.target.matches(\"a\")) {\n\t\t\t\t// not preventing default to allow normal anchor scroll to behaviour\n\t\t\t\t// event.preventDefault();\n\t\t\t\tvar href = event.target.href;\n\t\t\t\tvar focusTargetSelector = href.substring(href.indexOf(\"#\"), href.length);\n\n\t\t\t\tsetTimeout(function () {\n\t\t\t\t\tdocument.querySelector(focusTargetSelector).focus();\n\t\t\t\t}, 300);\n\t\t\t}\n\t\t}\n\t}, {\n\t\tkey: \"isInvalid\",\n\t\tvalue: function isInvalid() {\n\t\t\tvar result = this.getValidatedFormElements(this.form).filter(function (field) {\n\t\t\t\treturn field.dataset.validateField !== \"false\";\n\t\t\t}).map(function (element) {\n\t\t\t\t//\tdata-required used as a proxy for required property on validated fieldset elements\n\t\t\t\t// Replace this by setting custom validity on the fieldset if necessary\n\n\t\t\t\t// if (element.dataset.required === \"true\") {\n\t\t\t\t// \treturn element.validity.valid;\n\t\t\t\t// }\n\t\t\t\t// if (element.dataset.required === \"false\") {\n\t\t\t\t// \treturn true;\n\t\t\t\t// }\n\t\t\t\telement.dispatchEvent(new CustomEvent(\"validate\", { bubbles: false }));\n\n\t\t\t\treturn element.validity.valid;\n\t\t\t}).includes(false);\n\n\t\t\tif (this.errorsShown && !result) {\n\t\t\t\tthis.errorsShown = false;\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t}, {\n\t\tkey: \"updateErrorSummary\",\n\t\tvalue: function updateErrorSummary() {\n\t\t\tvar _this5 = this;\n\n\t\t\tvar staleSummaryItems = Array.from(this.errorSummaryList.children);\n\t\t\tstaleSummaryItems && staleSummaryItems.forEach(function (item) {\n\t\t\t\titem.remove();\n\t\t\t});\n\n\t\t\tthis.getValidatedFormElements(this.form).filter(function (element) {\n\t\t\t\treturn !element.validity.valid;\n\t\t\t}).map(this.createErrorSummaryItem).forEach(function (item) {\n\t\t\t\t_this5.errorSummaryList.appendChild(item);\n\t\t\t});\n\t\t}\n\t}, {\n\t\tkey: \"createErrorSummaryItem\",\n\t\tvalue: function createErrorSummaryItem(element) {\n\t\t\tvar itemAnchor = document.createElement(\"a\");\n\t\t\titemAnchor.href = \"#\" + element.id;\n\t\t\titemAnchor.textContent = element.dataset.validateFieldSummaryLabel || element.name;\n\t\t\tvar itemHtml = document.createElement(\"li\");\n\t\t\titemHtml.appendChild(itemAnchor);\n\t\t\treturn itemHtml;\n\t\t}\n\t}, {\n\t\tkey: \"showSummary\",\n\t\tvalue: function showSummary() {\n\t\t\tif (this.errorSummary) {\n\t\t\t\tthis.updateErrorSummary();\n\t\t\t\tthis.errorSummary.hidden = false;\n\t\t\t}\n\t\t}\n\t}, {\n\t\tkey: \"hideSummary\",\n\t\tvalue: function hideSummary() {\n\t\t\tif (this.errorSummary) {\n\t\t\t\tthis.errorSummary.hidden = true;\n\t\t\t}\n\t\t}\n\t}, {\n\t\tkey: \"showErrors\",\n\t\tvalue: function showErrors() {\n\t\t\tvar fields = this.getValidatedFormElements(this.form).filter(function (field) {\n\t\t\t\treturn field.dataset.validateField !== \"false\";\n\t\t\t}).map(function (component) {\n\t\t\t\tcomponent.dataset.showErrors = true;\n\t\t\t\treturn component;\n\t\t\t});\n\t\t\tvar firstInvalid = fields.find(function (element) {\n\t\t\t\treturn !element.validity.valid;\n\t\t\t});\n\t\t\tthis.showSummary();\n\t\t\tthis.focusError(firstInvalid);\n\t\t}\n\t}, {\n\t\tkey: \"focusError\",\n\t\tvalue: function focusError(field) {\n\t\t\tif (this.errorSummary) {\n\t\t\t\tthis.errorSummary.focus();\n\t\t\t} else {\n\t\t\t\tfield.focus();\n\t\t\t}\n\t\t}\n\t}, {\n\t\tkey: \"onFormSubmit\",\n\t\tvalue: function onFormSubmit(event) {\n\t\t\tif (this.isInvalid()) {\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\t// Prevent subsequent submitting handler from being called\n\t\t\t\tevent.stopImmediatePropagation();\n\t\t\t\tthis.showErrors();\n\t\t\t} else {\n\t\t\t\tthis.hideSummary();\n\t\t\t\tvar formData = getFormData(this.form);\n\t\t\t\tthis.showIfCollection.forEach(disableHidden.bind(null, formData, this.options));\n\n\t\t\t\tthis.form.dispatchEvent(new CustomEvent(\"validate-form-valid\", {\n\t\t\t\t\tbubbles: false,\n\t\t\t\t\tdetail: { submitFormEvent: event }\n\t\t\t\t}));\n\t\t\t}\n\t\t}\n\n\t\t// only if validation succeeds\n\n\t}, {\n\t\tkey: \"onSubmitting\",\n\t\tvalue: function onSubmitting() {\n\t\t\tif (!this.submitButton) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.submitButton.classList.remove(this.options.submitDisabledClass);\n\t\t\tthis.submitButton.setAttribute(\"disabled\", \"\");\n\t\t\tthis.submitButton.classList.add(\"is-submitting\");\n\t\t}\n\n\t\t// this function is used when the form is wrapped in an ajax-submit\n\n\t}, {\n\t\tkey: \"onSubmitError\",\n\t\tvalue: function onSubmitError() {\n\t\t\tif (!this.submitButton) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tthis.submitButton.removeAttribute(\"disabled\");\n\t\t\tthis.submitButton.classList.remove(\"is-submitting\");\n\t\t}\n\t}, {\n\t\tkey: \"updateShowIf\",\n\t\tvalue: function updateShowIf(formData) {\n\t\t\tlog(\"formData\", formData);\n\n\t\t\tthis.showIfCollection.forEach(hideShow.bind(this, formData, this.options));\n\n\t\t\tthis.setIfCollection.forEach(setUnset.bind(this, formData, this.options));\n\t\t}\n\t}]);\n\n\treturn FormValidation;\n}();\n\nFormValidation.DEFAULTS = {\n\tcomponentErrorSelector: \"[data-show-errors]\",\n\tvalidateElementSelector: \"[data-validate-field]\",\n\tshowIfSelector: \"[data-show-if-condition]\",\n\tsetIfSelector: \"[data-set-if][data-set-if-condition]\",\n\tsubmitDisabledClass: \"is-disabled\"\n};\n\nexports.default = FormValidation;\n\n/***/ }),\n\n/***/ \"D:\\\\a\\\\1\\\\s\\\\node_modules\\\\babel-loader\\\\lib\\\\index.js??ref--12-0!D:\\\\a\\\\1\\\\s\\\\node_modules\\\\eslint-loader\\\\index.js??ref--12-1!D:\\\\a\\\\1\\\\s\\\\client\\\\src\\\\core\\\\plugins\\\\extract-options.js\":\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n\tvalue: true\n});\n\nexports.default = function (name, element) {\n\treturn extractComponentOptions(name, getOptionData(element));\n};\n\n/*\r\n * Unlike other utility files, this is not adding functions to the utility scope\r\n * This is instead included by some components\r\n */\n\nfunction getJSONValue(stringValue) {\n\ttry {\n\t\treturn JSON.parse(stringValue);\n\t} catch (error) {\n\t\treturn stringValue;\n\t}\n}\n\nfunction camelCase(string) {\n\treturn string.replace(/^([A-Z])|[\\s-_](\\w)/g, function (match, p1, p2) {\n\t\tif (p2) {\n\t\t\treturn p2.toUpperCase();\n\t\t}\n\n\t\treturn p1.toLowerCase();\n\t});\n}\n\nfunction getOptionData(element) {\n\tvar dataset = element.dataset;\n\tvar data = {};\n\n\tfor (var prop in dataset) {\n\t\tif (dataset.hasOwnProperty(prop)) {\n\t\t\tdata[prop] = dataset[prop];\n\t\t}\n\t}\n\treturn data || {};\n}\n\nfunction extractComponentOptions(name, data) {\n\tvar options = {};\n\tvar cameledName = camelCase(name);\n\tfor (var prop in data) {\n\t\tif (prop.startsWith(cameledName) && prop !== cameledName) {\n\t\t\toptions[camelCase(prop.slice(cameledName.length))] = getJSONValue(data[prop]);\n\t\t}\n\t}\n\treturn options;\n}\n\n/***/ })\n\n});\n\n\n// WEBPACK FOOTER //\n// scripts/validate-form--3234af2eecd73bb7acf1.js","import debug from \"debug\";\r\n\r\nconst log = debug(\"validate-field\");\r\n\r\nfunction getJSONValue(stringValue) {\r\n\ttry {\r\n\t\treturn JSON.parse(stringValue);\r\n\t} catch (error) {\r\n\t\treturn stringValue;\r\n\t}\r\n}\r\n\r\nfunction getFormData(form) {\r\n\tconst formData = new FormData(form);\r\n\tconst result = {};\r\n\r\n\tfor (var field of formData.entries()) {\r\n\t\tresult[field[0]] = getJSONValue(field[1]);\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nconst validators = {\r\n\thidden_required: (input) => {\r\n\t\treturn input.value ? \"\" : \"required\";\r\n\t},\r\n\tat_least_one_checked: (inputs) => {\r\n\t\t// intended for checkboxes - but works on radio\r\n\t\treturn inputs.filter((input) => {\r\n\t\t\treturn input.checked;\r\n\t\t}).length > 0\r\n\t\t\t? \"\"\r\n\t\t\t: \"check at least one\";\r\n\t},\r\n\temail: (input) => {\r\n\t\treturn /^\\b([^@\\s]+@){1}[^@\\s]+\\.[^@\\s]+\\b$/.test(input.value);\r\n\t},\r\n\tequal_to: (input, equalToInput) => {\r\n\t\treturn input.value == equalToInput.value;\r\n\t},\r\n\tregex: (expression, input) => {\r\n\t\tconst regex = new RegExp(expression);\r\n\t\treturn regex.test(input.value);\r\n\t},\r\n\tvisa: (input) => {\r\n\t\t// prefix: 4\r\n\t\t// length: 13,16\r\n\t\t// ignore spaces\r\n\t\tconst value = input.value.replaceAll(\" \", \"\");\r\n\t\tconst onlyNumbers = /^\\d+$/;\r\n\t\tconst prefix = value[0];\r\n\t\treturn (\r\n\t\t\tonlyNumbers.test(value) &&\r\n\t\t\t(value.length === 13 || value.length === 16) &&\r\n\t\t\tprefix === \"4\"\r\n\t\t);\r\n\t},\r\n\tmastercard: (input) => {\r\n\t\t// prefix: 51-55\r\n\t\t// length: 16\r\n\t\t// ignore spaces\r\n\t\tconst value = input.value.replaceAll(\" \", \"\");\r\n\t\tconst onlyNumbers = /^\\d+$/;\r\n\t\tconst prefix = +value.slice(0, 2);\r\n\t\treturn (\r\n\t\t\tonlyNumbers.test(value) &&\r\n\t\t\tvalue.length === 16 &&\r\n\t\t\tprefix >= 51 &&\r\n\t\t\tprefix <= 55\r\n\t\t);\r\n\t},\r\n\tamex: (input) => {\r\n\t\t// prefix: 34,37\r\n\t\t// length: 15\r\n\t\t// ignore spaces\r\n\t\tconst value = input.value.replaceAll(\" \", \"\");\r\n\t\tconst onlyNumbers = /^\\d+$/;\r\n\t\tconst prefix = value.slice(0, 2);\r\n\t\treturn (\r\n\t\t\t(onlyNumbers.test(value) &&\r\n\t\t\t\tvalue.length === 15 &&\r\n\t\t\t\tprefix === \"34\") ||\r\n\t\t\tprefix === \"37\"\r\n\t\t);\r\n\t},\r\n\tmaxLength: (length, input) => {\r\n\t\treturn input.value.length <= length;\r\n\t},\r\n\tminLength: (length, input) => {\r\n\t\treturn input.value.length >= length;\r\n\t},\r\n};\r\n\r\n// any one of visa, mastercard, or max\r\nvalidators.creditcard = (input) => {\r\n\tconst cardTypes = [validators.amex, validators.visa, validators.mastercard];\r\n\r\n\treturn cardTypes.some((validator) => {\r\n\t\treturn validator(input);\r\n\t});\r\n};\r\n\r\n// any one of visa, mastercard, or max\r\nvalidators.creditcardtype = (input, counterpartName) => {\r\n\tconst formData = getFormData(input.form);\r\n\r\n\tif (counterpartName && formData[counterpartName]) {\r\n\t\tconst cardType = formData[counterpartName];\r\n\t\treturn validators[cardType](input);\r\n\t}\r\n\r\n\tconst cardTypes = [validators.amex, validators.visa, validators.mastercard];\r\n\r\n\treturn cardTypes.some((validator) => {\r\n\t\treturn validator(input);\r\n\t});\r\n};\r\n\r\n/*\r\n\tCharacter length validation\r\n\telement.dataset\r\n\r\n\tFrom MVC:\r\n\tvalLengthMax: \"3\"\r\n\tvalLengthMin: \"Length error message\"\r\n\tvalLength: \"Length error message\"\r\n\r\n\tOverriding MVC:\r\n\tvalLengthMessage: \"Custom length error message\"\r\n*/\r\nfunction getLengthValidator(maxValidator, minValidator, data) {\r\n\tconst message = data.valLengthMessage || data.valLength;\r\n\tconst result = [];\r\n\tif (data.valLengthMin) {\r\n\t\tresult.push({\r\n\t\t\ttest: minValidator.bind(null, data.valLengthMin),\r\n\t\t\tmessage,\r\n\t\t});\r\n\t}\r\n\tif (data.valLengthMax) {\r\n\t\tresult.push({\r\n\t\t\ttest: maxValidator.bind(null, data.valLengthMax),\r\n\t\t\tmessage,\r\n\t\t});\r\n\t}\r\n\treturn result;\r\n}\r\n\r\n/*\r\n\tRegex Validation Properties:\r\n\telement.dataset\r\n\r\n\tFrom MVC:\r\n\tvalRegexPattern: \"/regex/\"\r\n\tvalRegex: \"Regex error message\"\r\n\r\n\tOverriding MVC:\r\n\tvalRegexPatternName: \"email\" (uses look up in `validators`)\r\n\tvalRegexMessage: \"Custom regex error message\"\r\n*/\r\nfunction getRegexValidator(validators, data) {\r\n\tconst message = data.valRegexMessage || data.valRegex;\r\n\r\n\tif (data.valRegexPatternName && validators[data.valRegexPatternName]) {\r\n\t\treturn { test: validators[data.valRegexPatternName], message };\r\n\t}\r\n\tif (data.valRegexPattern) {\r\n\t\treturn {\r\n\t\t\ttest: validators.regex.bind(null, data.valRegexPattern),\r\n\t\t\tmessage,\r\n\t\t};\r\n\t}\r\n\treturn false;\r\n}\r\n\r\nfunction handleInitialError(initialMessage) {\r\n\r\n\tfunction hasDefaultChanged(input) {\r\n\r\n\t\t// prevent resubmission of server validation failed value\r\n\t\t// until it is changed\r\n\t\treturn input.value !== input.defaultValue;\r\n\t}\r\n\r\n\treturn {\r\n\t\ttest: hasDefaultChanged,\r\n\t\tmessage: initialMessage\r\n\t};\r\n}\r\n\r\n\r\nfunction setNativeRequired(element) {\r\n\t// MVC forms indicate required elements with data-val\r\n\tif (element.dataset.val === \"true\") {\r\n\t\telement.setAttribute(\"required\", \"\");\r\n\t}\r\n}\r\n\r\nfunction truthy(value) {\r\n\treturn value;\r\n}\r\nclass ValidateField {\r\n\tconstructor(element, options) {\r\n\t\tlog(\"element\", element);\r\n\t\tlog(\"options\", options);\r\n\r\n\t\tthis.options = options;\r\n\t\tthis.element = element;\r\n\r\n\t\tthis.isFieldset = this.element.nodeName === \"FIELDSET\";\r\n\t\tthis.isPassword = this.element.type === \"password\";\r\n\r\n\t\tthis.inputSet = [\r\n\t\t\t...this.element.querySelectorAll(\r\n\t\t\t\t`[name=\"${this.options.inputSet}\"]`\r\n\t\t\t),\r\n\t\t];\r\n\r\n\t\tif (!this.options.errorMessageSuppressed) {\r\n\t\t\tif (this.options.errorSelector) {\r\n\t\t\t\tthis.errorElementSelectorScope =\r\n\t\t\t\t\tthis.options.errorSelector[0] === \"#\"\r\n\t\t\t\t\t\t? document\r\n\t\t\t\t\t\t: this.element;\r\n\r\n\t\t\t\tthis.errorElement =\r\n\t\t\t\t\tthis.errorElementSelectorScope.querySelector(\r\n\t\t\t\t\t\tthis.options.errorSelector\r\n\t\t\t\t\t);\r\n\t\t\t} else {\r\n\t\t\t\t// Fallback to MVC default\r\n\t\t\t\t// Note ids on form elements have dots converted to underscores\r\n\t\t\t\tthis.errorElement = document.querySelector(\r\n\t\t\t\t\t`[data-valmsg-for=\"${element.id.replaceAll(\"_\", \".\")}\"]`\r\n\t\t\t\t);\r\n\t\t\t}\r\n\r\n\t\t\t// TODO: element error message either doesn't exist\r\n\t\t\t// or is a custom element with built in message we don't want to change\r\n\t\t\t// or is not specified on this element or incorporates mark-up such as links\r\n\t\t\t// the validated element input may not be editable\r\n\t\t\t// although we may want to toggle visibility of the error\r\n\r\n\t\t\tthis.showErrors =\r\n\t\t\t\tgetJSONValue(this.element.dataset.showErrors) ||\r\n\t\t\t\t[...this.errorElement.classList].includes(\r\n\t\t\t\t\tthis.options.invalidMessageClass\r\n\t\t\t\t);\r\n\t\t}\r\n\r\n\t\tif (this.showErrors) {\r\n\t\t\tthis.hasErrorDisplayedOnInit = true;\r\n\t\t}\r\n\r\n\t\tthis.attributeObserver = new MutationObserver(\r\n\t\t\tthis.onAttributeChange.bind(this)\r\n\t\t);\r\n\r\n\t\tthis.init();\r\n\t\tthis.watch();\r\n\r\n\t\tlog(\"ready\", this, this.element);\r\n\t}\r\n\r\n\tinit() {\r\n\t\tsetNativeRequired(this.element);\r\n\t\tthis.registerInitialError();\r\n\t\tthis.validate();\r\n\t\tthis.wasValid = this.element.validity.valid;\r\n\t}\r\n\r\n\twatch() {\r\n\t\tlog(\"watching\");\r\n\t\tthis.element.addEventListener(\"input\", this.updateValidity.bind(this));\r\n\t\tthis.element.addEventListener(\r\n\t\t\t\"validate\",\r\n\t\t\tthis.updateValidity.bind(this)\r\n\t\t);\r\n\t\tthis.attributeObserver.observe(this.element, { attributes: true });\r\n\t}\r\n\r\n\tregisterInitialError() {\r\n\t\tconst initialMessage = this.errorElement.textContent;\r\n\t\tthis.initialErrorHandler = this.hasErrorDisplayedOnInit\r\n\t\t\t? handleInitialError(initialMessage)\r\n\t\t\t: false;\r\n\t}\r\n\r\n\t/*\r\n\t\tRequired Validation Properties:\r\n\t\telement.dataset\r\n\r\n\t\tFrom MVC:\r\n\t\tval: \"true\" (field value is required)\r\n\t\tvalRequired: \"Required error message\"\r\n\r\n\t\tOverriding MVC:\r\n\t\tvalRequiredMessage: \"Custom required error message\"\r\n\t*/\r\n\tvalidate() {\r\n\t\tconst tests = [\r\n\t\t\tthis.initialErrorHandler,\r\n\t\t\t...getLengthValidator(\r\n\t\t\t\tvalidators[\"maxLength\"],\r\n\t\t\t\tvalidators[\"minLength\"],\r\n\t\t\t\tthis.element.dataset\r\n\t\t\t),\r\n\t\t\tgetRegexValidator(validators, this.element.dataset),\r\n\t\t].filter(truthy);\r\n\r\n\t\t// Reset custom validity\r\n\t\tthis.element.setCustomValidity(\"\");\r\n\r\n\t\t// Validation may have been disabled if this field was hidden\r\n\t\tif (this.element.dataset.validateField === \"false\") {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\t// For good security practice password input values are not preserved.\r\n\t\t// Until client side validation is in place to match server password rules\r\n\t\t// we special case password input to ensure server error is displayed\r\n\t\t// otherwise required field message is displayed in response to empty value\r\n\t\tif (this.isPassword && this.hasErrorDisplayedOnInit && this.element.value === \"\") {\r\n\t\t\tthis.element.setCustomValidity(this.errorElement.textContent);\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tif (this.element.value !== \"\" && tests.length) {\r\n\t\t\tconst results = tests.map((validator) => {\r\n\t\t\t\treturn validator.test(\r\n\t\t\t\t\tthis.element,\r\n\t\t\t\t\tthis.options.counterpartName\r\n\t\t\t\t)\r\n\t\t\t\t\t? \"\"\r\n\t\t\t\t\t: validator.message;\r\n\t\t\t});\r\n\r\n\t\t\tconst errors = results.filter((result) => {\r\n\t\t\t\treturn result !== \"\";\r\n\t\t\t});\r\n\r\n\t\t\tif (errors.length) {\r\n\t\t\t\tthis.element.setCustomValidity(errors[0]);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (this.options.rule) {\r\n\t\t\tconst validator = validators[this.options.rule];\r\n\r\n\t\t\tif (!validator) {\r\n\t\t\t\tconsole.error(\r\n\t\t\t\t\t`Validation rule data-field-validation-rule=\"${this.options.rule}\" is not defined. See`,\r\n\t\t\t\t\tthis.element\r\n\t\t\t\t);\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\r\n\t\t\t// TODO: merge fieldset handling and this into one code path\r\n\t\t\tif (this.isFieldset) {\r\n\t\t\t\tthis.updateFieldsetValidity();\r\n\t\t\t} else {\r\n\t\t\t\tthis.element.setCustomValidity(validator(this.element));\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tgetErrorMessage() {\r\n\t\tif (!this.element.validity.valid) {\r\n\t\t\tif (this.element.validity.customError) {\r\n\t\t\t\tconst customMessage =\r\n\t\t\t\t\tthis.element.validationMessage !== \"\"\r\n\t\t\t\t\t\t? this.element.validationMessage\r\n\t\t\t\t\t\t: this.element.dataset.validateFieldErrorMessage;\r\n\t\t\t\treturn customMessage;\r\n\t\t\t} else if (this.element.validity.valueMissing) {\r\n\t\t\t\treturn (\r\n\t\t\t\t\tthis.element.dataset.valRequiredMessage ||\r\n\t\t\t\t\tthis.element.dataset.valRequired\r\n\t\t\t\t);\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn \"\";\r\n\t}\r\n\r\n\tsplitErrorMessage(message) {\r\n\t\tconst parts = message\r\n\t\t\t.split(\"|\")\r\n\t\t\t.map((part) => {\r\n\t\t\t\treturn part.trim();\r\n\t\t\t})\r\n\t\t\t.filter((part) => {\r\n\t\t\t\treturn part !== \"\";\r\n\t\t\t});\r\n\r\n\t\tconst bold = parts.length > 1 ? parts[0] : false;\r\n\t\tconst text = parts.length > 1 ? parts[1] : parts[0];\r\n\r\n\t\treturn {\r\n\t\t\tbold,\r\n\t\t\ttext,\r\n\t\t};\r\n\t}\r\n\r\n\trenderErrorMessage(element, message) {\r\n\t\tconst { bold, text } = message;\r\n\r\n\t\telement.innerHTML = \"\";\r\n\r\n\t\tconst wrapper = bold && text ? document.createElement(\"span\") : false;\r\n\t\tif (wrapper) {\r\n\t\t\telement.appendChild(wrapper);\r\n\t\t}\r\n\t\tconst container = wrapper || element;\r\n\r\n\t\tif (bold) {\r\n\t\t\tconst boldElement = document.createElement(\"strong\");\r\n\t\t\tboldElement.textContent = bold;\r\n\t\t\tcontainer.appendChild(boldElement);\r\n\t\t}\r\n\t\tif (bold && text) {\r\n\t\t\tcontainer.appendChild(document.createElement(\"br\"));\r\n\t\t}\r\n\t\tif (text) {\r\n\t\t\tcontainer.appendChild(document.createTextNode(text));\r\n\t\t}\r\n\t}\r\n\r\n\tupdateFieldsetValidity() {\r\n\t\tconst validator = validators[this.options.rule];\r\n\t\tif (!this.isFieldset || !validator) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tthis.element.setCustomValidity(validator(this.inputSet));\r\n\t}\r\n\r\n\tupdateErrorDisplay() {\r\n\t\t// Short circuit when error message is embedded in the page and unchanging\r\n\t\t// Doesn't need to be shown/hidden/updated\r\n\t\tif (this.options.errorMessageSuppressed) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tconst errorMessage = this.getErrorMessage();\r\n\t\tconst isValid = errorMessage === \"\";\r\n\r\n\t\tif (isValid) {\r\n\t\t\tthis.clearDynamicErrorMessage();\r\n\t\t} else {\r\n\t\t\tthis.fillDynamicErrorMessage(errorMessage);\r\n\t\t}\r\n\r\n\t\tthis.notifyForm(isValid);\r\n\t}\r\n\r\n\tclearDynamicErrorMessage() {\r\n\t\tthis.element.classList.remove(this.options.invalidInputClass);\r\n\t\tthis.errorElement.innerHTML = \"\";\r\n\t\tthis.errorElement.classList.remove(this.options.invalidMessageClass);\r\n\t\tthis.errorElement.classList.add(this.options.validMessageClass);\r\n\t}\r\n\r\n\tfillDynamicErrorMessage(errorMessage) {\r\n\t\tthis.element.classList.add(this.options.invalidInputClass);\r\n\r\n\t\tif (errorMessage === undefined) {\r\n\t\t\tlog(`Missing error message for [name=\"${this.element.name}]`);\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tthis.renderErrorMessage(\r\n\t\t\tthis.errorElement,\r\n\t\t\tthis.splitErrorMessage(errorMessage)\r\n\t\t);\r\n\t\tthis.errorElement.classList.add(this.options.invalidMessageClass);\r\n\t\tthis.errorElement.classList.remove(this.options.validMessageClass);\r\n\t}\r\n\r\n\tnotifyForm(isValid) {\r\n\t\tconst eventName = isValid\r\n\t\t\t? \"validation-error-hidden\"\r\n\t\t\t: \"validation-error-displayed\";\r\n\r\n\t\tif (!isValid || (isValid && !this.wasValid)) {\r\n\t\t\t// Give form a chance to init listeners first:\r\n\t\t\tsetTimeout(() => {\r\n\t\t\t\tthis.element.dispatchEvent(\r\n\t\t\t\t\tnew CustomEvent(eventName, {\r\n\t\t\t\t\t\tbubbles: true,\r\n\t\t\t\t\t})\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t\t}\r\n\t\tthis.wasValid = isValid;\r\n\t}\r\n\r\n\tupdateValidity() {\r\n\t\tthis.validate();\r\n\r\n\t\tif (this.showErrors) {\r\n\t\t\tthis.updateErrorDisplay();\r\n\t\t}\r\n\t}\r\n\r\n\tonAttributeChange(mutationList, observer) {\r\n\t\tmutationList\r\n\t\t\t.filter(\r\n\t\t\t\tfunction (mutation) {\r\n\t\t\t\t\treturn (\r\n\t\t\t\t\t\tmutation.type === \"attributes\" &&\r\n\t\t\t\t\t\tmutation.attributeName ===\r\n\t\t\t\t\t\t\tthis.options.componentErrorAttribute\r\n\t\t\t\t\t);\r\n\t\t\t\t}.bind(this)\r\n\t\t\t)\r\n\t\t\t.forEach(this.onShowErrorsChange.bind(this));\r\n\t}\r\n\r\n\tonShowErrorsChange(mutation) {\r\n\t\tthis.showErrors = getJSONValue(this.element.dataset.showErrors);\r\n\t\tthis.updateErrorDisplay();\r\n\t}\r\n}\r\n\r\nValidateField.DEFAULTS = {\r\n\tcomponentErrorAttribute: \"data-show-errors\",\r\n\tvalidMessageClass: \"field-validation-valid\",\r\n\tinvalidMessageClass: \"field-validation-error\",\r\n\tinvalidInputClass: \"input-validation-error\",\r\n};\r\n\r\nexport default ValidateField;\r\n\n\n\n// WEBPACK FOOTER //\n// ./client/src/core/components/form-validation/validate-field.js","import ValidateField from \"./validate-field\";\r\nimport extractOptions from '@core/plugins/extract-options';\r\n\r\nimport debug from \"debug\";\r\nconst log = debug(\"validate-form\");\r\n\r\nfunction getJSONValue(stringValue) {\r\n\ttry {\r\n\t\treturn JSON.parse(stringValue);\r\n\t} catch (error) {\r\n\t\treturn stringValue;\r\n\t}\r\n}\r\n\r\nfunction getFormData(form) {\r\n\tconst formData = new FormData(form);\r\n\tconst result = {};\r\n\r\n\tfor (var field of formData.entries()) {\r\n\t\tresult[field[0]] = getJSONValue(field[1]);\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nfunction buildShowIf(conditions, element) {\r\n\tconst condition = conditions[element.dataset.showIfCondition];\r\n\r\n\t// Throw error if condition not found\r\n\tif (typeof condition === \"function\") {\r\n\t\treturn {\r\n\t\t\tcondition,\r\n\t\t\telement,\r\n\t\t};\r\n\t} else {\r\n\t\tthrow new Error(\r\n\t\t\t`${element.dataset.showIfCondition} in data-show-if-condition=\"${element.dataset.showIfCondition}\" is not a defined condition function`\r\n\t\t);\r\n\t}\r\n}\r\n\r\nfunction buildSetIf(conditions, element) {\r\n\tconst condition = conditions[element.dataset.setIfCondition];\r\n\tconst attribute = element.dataset.setIf;\r\n\r\n\tlog({ condition, attribute });\r\n\r\n\t// Throw error if condition not found\r\n\tif (typeof condition !== \"function\") {\r\n\t\tthrow new Error(\r\n\t\t\t`${element.dataset.setIfCondition} in data-set-if-condition=\"${element.dataset.setIfCondition}\" is not a defined condition function`\r\n\t\t);\r\n\t}\r\n\r\n\tif (!attribute) {\r\n\t\tthrow new Error(\r\n\t\t\t`Define a data attribute to set when data-set-if-condition=\"${element.dataset.setIfCondition}\" by providing a value for data-set-if=\"data-???\"`\r\n\t\t);\r\n\t}\r\n\r\n\treturn {\r\n\t\tcondition,\r\n\t\telement,\r\n\t\tattribute,\r\n\t};\r\n}\r\n\r\nfunction updateDisabled(disable, parent) {\r\n\t// TODO: consider adding an element attr to preserve the disabled state\r\n\t// similar to data-required\r\n\tconst elements = [\r\n\t\t...parent.querySelectorAll(\"input,select,button,textarea\"),\r\n\t];\r\n\telements.forEach((element) => {\r\n\t\telement.disabled = disable;\r\n\t});\r\n}\r\n\r\n// const enableFormElements = updateDisabled.bind(null, false);\r\nconst disableFormElements = updateDisabled.bind(null, true);\r\n\r\nfunction switchElementValidation(willValidate, parent, containerSelector) {\r\n\tconst elements = [...parent.querySelectorAll(\"[data-validate-field]\")];\r\n\r\n\tconst elementsToUpdate = elements.filter((element) => {\r\n\t\treturn element.closest(containerSelector) === parent;\r\n\t});\r\n\r\n\telementsToUpdate.forEach((element) => {\r\n\t\telement.required = willValidate;\r\n\t\telement.dataset.validateField = willValidate;\r\n\t});\r\n\r\n\t// Use data-required value as a proxy for required property\r\n\t//\ton fieldset elements with customValidity\r\n\tif (\r\n\t\tparent.nodeName === \"FIELDSET\" &&\r\n\t\tparent.dataset.required !== undefined\r\n\t) {\r\n\t\tparent.dataset.required = willValidate;\r\n\t}\r\n}\r\n\r\nconst enableElementValidation = switchElementValidation.bind(null, true);\r\nconst disableElementValidation = switchElementValidation.bind(null, false);\r\n\r\nfunction hide(element, showIfSelector) {\r\n\tlog(\"hide\", element);\r\n\telement.hidden = true;\r\n\tdisableElementValidation(element, showIfSelector);\r\n}\r\n\r\nfunction show(element, showIfSelector) {\r\n\tlog(\"show\", element);\r\n\telement.hidden = false;\r\n\tenableElementValidation(element, showIfSelector);\r\n}\r\n\r\nfunction hideShow(formData, options, item) {\r\n\tif (item.condition(formData, options)) {\r\n\t\tshow(item.element, options.showIfSelector);\r\n\t} else {\r\n\t\thide(item.element, options.showIfSelector);\r\n\t}\r\n}\r\n\r\nfunction setUnset(formData, options, item) {\r\n\tif (item.condition(formData, options)) {\r\n\t\titem.element.setAttribute(item.attribute, \"true\");\r\n\t} else {\r\n\t\titem.element.setAttribute(item.attribute, \"false\");\r\n\t}\r\n}\r\n\r\nfunction disableHidden(formData, options, item) {\r\n\tif (!item.condition(formData, options)) {\r\n\t\tdisableFormElements(item.element);\r\n\t}\r\n}\r\n\r\nfunction isInViewport(element) {\r\n\tconst bounding = element.getBoundingClientRect();\r\n\treturn (\r\n\t\tbounding.top >= 0 &&\r\n\t\tbounding.left >= 0 &&\r\n\t\tbounding.bottom <=\r\n\t\t\t(window.innerHeight || document.documentElement.clientHeight) &&\r\n\t\tbounding.right <=\r\n\t\t\t(window.innerWidth || document.documentElement.clientWidth)\r\n\t);\r\n}\r\n\r\nclass FormValidation {\r\n\tconstructor(element, options) {\r\n\t\tlog(\"element\", element);\r\n\t\tlog(\"options\", options);\r\n\r\n\t\tthis.options = options;\r\n\t\tthis.form = element;\r\n\t\tthis.showIfCollection = [];\r\n\t\tthis.setIfCollection = [];\r\n\r\n\t\tif (this.options.errorSummarySelector) {\r\n\t\t\tthis.errorSummary = this.form.querySelector(\r\n\t\t\t\tthis.options.errorSummarySelector\r\n\t\t\t);\r\n\r\n\t\t\tif (!this.errorSummary) {\r\n\t\t\t\tlog(`Specified error summary element not found:\r\ndata-validate-form-error-summary=\"${this.options.errorSummarySelector}\" Aborting`);\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\r\n\t\t\tthis.errorSummaryList = this.errorSummary.querySelector(\"ul\");\r\n\t\t}\r\n\r\n\t\tthis.submitButton = this.form.querySelector('[type=\"submit\"]');\r\n\r\n\t\tthis.childObserver = new MutationObserver(\r\n\t\t\tthis.onChildMutation.bind(this)\r\n\t\t);\r\n\r\n\t\tthis.init();\r\n\t\tthis.watch();\r\n\r\n\t\tlog(\"ready\", this, this.form);\r\n\t}\r\n\r\n\tinit() {\r\n\t\t// See quote-form/choose-form in pch001 for conditional show/hide examples\r\n\t\tif (this.options.showIfConditions) {\r\n\t\t\tSystem.import(/* webpackChunkName: \"conditions\" */ \"./conditions\")\r\n\t\t\t\t.then((module) => {\r\n\t\t\t\t\tthis.conditions =\r\n\t\t\t\t\t\tmodule.default[this.options.showIfConditions];\r\n\t\t\t\t\tlog(\"conditions\", module.default);\r\n\t\t\t\t})\r\n\t\t\t\t.then(() => {\r\n\t\t\t\t\t// Find elements within the same form with show if data attr\r\n\t\t\t\t\tconst formShowIfElements = [\r\n\t\t\t\t\t\t...this.form.querySelectorAll(\r\n\t\t\t\t\t\t\tthis.options.showIfSelector\r\n\t\t\t\t\t\t),\r\n\t\t\t\t\t];\r\n\r\n\t\t\t\t\tconst setIfElements = [\r\n\t\t\t\t\t\t...this.form.querySelectorAll(\r\n\t\t\t\t\t\t\tthis.options.setIfSelector\r\n\t\t\t\t\t\t),\r\n\t\t\t\t\t];\r\n\r\n\t\t\t\t\t// Find elements within the whole document with page show if data attr\r\n\t\t\t\t\tconst pageShowIfElements = [\r\n\t\t\t\t\t\t...document.querySelectorAll(\r\n\t\t\t\t\t\t\t`[data-show-if-form=\"${this.options.showIfConditions}\"]`\r\n\t\t\t\t\t\t),\r\n\t\t\t\t\t];\r\n\r\n\t\t\t\t\tthis.showIfCollection = formShowIfElements\r\n\t\t\t\t\t\t.concat(pageShowIfElements)\r\n\t\t\t\t\t\t.map(buildShowIf.bind(this, this.conditions));\r\n\r\n\t\t\t\t\tthis.setIfCollection = setIfElements.map(\r\n\t\t\t\t\t\tbuildSetIf.bind(this, this.conditions)\r\n\t\t\t\t\t);\r\n\r\n\t\t\t\t\tthis.updateShowIf(getFormData(this.form));\r\n\t\t\t\t});\r\n\t\t}\r\n\r\n\t\t// Disable default native validation - we want control\r\n\t\tthis.form.setAttribute(\"novalidate\", \"\");\r\n\t\tthis.getValidatedFormElements(this.form).forEach(\r\n\t\t\tthis.initFieldValidation\r\n\t\t);\r\n\t\tthis.isInvalid();\r\n\t}\r\n\r\n\twatch() {\r\n\t\tlog(\"watching\");\r\n\r\n\t\tthis.form.addEventListener(\"validation-error-displayed\", (event) => {\r\n\t\t\tthis.errorsShown = true;\r\n\t\t\tthis.updateSubmitDisabled(true);\r\n\t\t});\r\n\t\tthis.form.addEventListener(\"validation-error-hidden\", (event) => {\r\n\t\t\tthis.updateSubmitDisabled(this.isInvalid());\r\n\t\t});\r\n\t\tthis.form.addEventListener(\"change\", this.onFormChange.bind(this));\r\n\t\tthis.form.addEventListener(\"submit\", this.onFormSubmit.bind(this));\r\n\t\tthis.form.addEventListener(\"submit\", this.onSubmitting.bind(this));\r\n\t\tthis.form.addEventListener(\r\n\t\t\t\"submit error\",\r\n\t\t\tthis.onSubmitError.bind(this)\r\n\t\t);\r\n\t\tthis.childObserver.observe(this.form, {\r\n\t\t\tchildList: true,\r\n\t\t\tsubtree: true,\r\n\t\t});\r\n\r\n\t\tif (this.errorSummary) {\r\n\t\t\tthis.errorSummary.addEventListener(\r\n\t\t\t\t\"click\",\r\n\t\t\t\tthis.errorClickHandler.bind(this)\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\tinitFieldValidation(element) {\r\n\t\t// TODO: safer way to test if ValidateField already applied?\r\n\t\tif (element.validateFieldInstance !== undefined) {\r\n\t\t\tlog(\"Already init\", element);\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\tconst options = Object.assign(\r\n\t\t\t{},\r\n\t\t\tValidateField.DEFAULTS,\r\n\t\t\textractOptions(\"validateField\", element)\r\n\t\t);\r\n\t\tconst instance = new ValidateField(element, options);\r\n\t\telement.validateFieldInstance = instance;\r\n\t}\r\n\r\n\tonChildMutation(mutationList, observer) {\r\n\t\tmutationList\r\n\t\t\t.filter((mutation) => {\r\n\t\t\t\treturn mutation.type === \"childList\";\r\n\t\t\t})\r\n\t\t\t.forEach((mutation) => {\r\n\t\t\t\tlog(\"mutation item\", mutation);\r\n\r\n\t\t\t\tfunction isElementNode(node) {\r\n\t\t\t\t\treturn node.nodeType === 1;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tconst added = Array.from(mutation.addedNodes).filter(\r\n\t\t\t\t\tisElementNode\r\n\t\t\t\t);\r\n\t\t\t\tconst removed = Array.from(mutation.removedNodes).filter(\r\n\t\t\t\t\tisElementNode\r\n\t\t\t\t);\r\n\r\n\t\t\t\t// may include elements to validate\r\n\t\t\t\t// find and init\r\n\t\t\t\tadded.forEach((node) => {\r\n\t\t\t\t\tthis.getValidatedFormElements(node).forEach(\r\n\t\t\t\t\t\tthis.initFieldValidation\r\n\t\t\t\t\t);\r\n\t\t\t\t});\r\n\r\n\t\t\t\t// if nodes removed\r\n\t\t\t\t// may include conditional elements/values\r\n\t\t\t\t// re-evaluate form conditions\r\n\t\t\t\tif (added.length || removed.length) {\r\n\t\t\t\t\tthis.updateShowIf(getFormData(this.form));\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t}\r\n\r\n\t// Elements that may have error messages to display\r\n\tgetValidatedFormElements(parentElement) {\r\n\t\treturn Array.from(\r\n\t\t\tparentElement.querySelectorAll(\r\n\t\t\t\t\"input,textarea,select,fieldset[data-validate-field]\"\r\n\t\t\t)\r\n\t\t).filter((element) => {\r\n\t\t\treturn element.matches(this.options.validateElementSelector);\r\n\t\t});\r\n\t}\r\n\r\n\tupdateSubmitDisabled(isInvalid) {\r\n\t\tif (!this.submitButton) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\tif (isInvalid && this.errorsShown) {\r\n\t\t\tthis.submitButton.classList.add(this.options.submitDisabledClass);\r\n\t\t} else {\r\n\t\t\tthis.submitButton.classList.remove(\r\n\t\t\t\tthis.options.submitDisabledClass\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\tonFormChange(event) {\r\n\t\tlog(\"onFormChange\", event);\r\n\t\tthis.updateShowIf(getFormData(this.form));\r\n\r\n\t\t// Keep changed element in view after layout shifts\r\n\t\tif (event.target.getAttribute(\"type\") !== \"hidden\") {\r\n\t\t\tif (!isInViewport(event.target)) {\r\n\t\t\t\t// A more thorough implementation would attempt to restore\r\n\t\t\t\t// the previous relative view port postion of the element\r\n\t\t\t\tevent.target.scrollIntoView();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Trigger a validation update - change may have occurred in a hidden input\r\n\t\t// Hidden inputs do not emit events so\r\n\t\t// we fallback to catching change events on the form\r\n\t\tthis.updateSubmitDisabled(this.isInvalid());\r\n\t}\r\n\r\n\terrorClickHandler(event) {\r\n\t\tif (event.target.matches(\"a\")) {\r\n\t\t\t// not preventing default to allow normal anchor scroll to behaviour\r\n\t\t\t// event.preventDefault();\r\n\t\t\tconst href = event.target.href;\r\n\t\t\tconst focusTargetSelector = href.substring(\r\n\t\t\t\thref.indexOf(\"#\"),\r\n\t\t\t\thref.length\r\n\t\t\t);\r\n\r\n\t\t\tsetTimeout(function () {\r\n\t\t\t\tdocument.querySelector(focusTargetSelector).focus();\r\n\t\t\t}, 300);\r\n\t\t}\r\n\t}\r\n\r\n\tisInvalid() {\r\n\t\tconst result = this.getValidatedFormElements(this.form)\r\n\t\t\t.filter((field) => {\r\n\t\t\t\treturn field.dataset.validateField !== \"false\";\r\n\t\t\t})\r\n\t\t\t.map((element) => {\r\n\t\t\t\t//\tdata-required used as a proxy for required property on validated fieldset elements\r\n\t\t\t\t// Replace this by setting custom validity on the fieldset if necessary\r\n\r\n\t\t\t\t// if (element.dataset.required === \"true\") {\r\n\t\t\t\t// \treturn element.validity.valid;\r\n\t\t\t\t// }\r\n\t\t\t\t// if (element.dataset.required === \"false\") {\r\n\t\t\t\t// \treturn true;\r\n\t\t\t\t// }\r\n\t\t\t\telement.dispatchEvent(\r\n\t\t\t\t\tnew CustomEvent(\"validate\", { bubbles: false })\r\n\t\t\t\t);\r\n\r\n\t\t\t\treturn element.validity.valid;\r\n\t\t\t})\r\n\t\t\t.includes(false);\r\n\r\n\t\tif (this.errorsShown && !result) {\r\n\t\t\tthis.errorsShown = false;\r\n\t\t}\r\n\t\treturn result;\r\n\t}\r\n\r\n\tupdateErrorSummary() {\r\n\t\tconst staleSummaryItems = Array.from(this.errorSummaryList.children);\r\n\t\tstaleSummaryItems &&\r\n\t\t\tstaleSummaryItems.forEach((item) => {\r\n\t\t\t\titem.remove();\r\n\t\t\t});\r\n\r\n\t\tthis.getValidatedFormElements(this.form)\r\n\t\t\t.filter((element) => {\r\n\t\t\t\treturn !element.validity.valid;\r\n\t\t\t})\r\n\t\t\t.map(this.createErrorSummaryItem)\r\n\t\t\t.forEach((item) => {\r\n\t\t\t\tthis.errorSummaryList.appendChild(item);\r\n\t\t\t});\r\n\t}\r\n\r\n\tcreateErrorSummaryItem(element) {\r\n\t\tconst itemAnchor = document.createElement(\"a\");\r\n\t\titemAnchor.href = `#${element.id}`;\r\n\t\titemAnchor.textContent =\r\n\t\t\telement.dataset.validateFieldSummaryLabel || element.name;\r\n\t\tconst itemHtml = document.createElement(\"li\");\r\n\t\titemHtml.appendChild(itemAnchor);\r\n\t\treturn itemHtml;\r\n\t}\r\n\r\n\tshowSummary() {\r\n\t\tif (this.errorSummary) {\r\n\t\t\tthis.updateErrorSummary();\r\n\t\t\tthis.errorSummary.hidden = false;\r\n\t\t}\r\n\t}\r\n\r\n\thideSummary() {\r\n\t\tif (this.errorSummary) {\r\n\t\t\tthis.errorSummary.hidden = true;\r\n\t\t}\r\n\t}\r\n\r\n\tshowErrors() {\r\n\t\tconst fields = this.getValidatedFormElements(this.form)\r\n\t\t\t.filter((field) => {\r\n\t\t\t\treturn field.dataset.validateField !== \"false\";\r\n\t\t\t})\r\n\t\t\t.map((component) => {\r\n\t\t\t\tcomponent.dataset.showErrors = true;\r\n\t\t\t\treturn component;\r\n\t\t\t});\r\n\t\tconst firstInvalid = fields\r\n\t\t\t.find((element) => {\r\n\t\t\t\treturn !element.validity.valid;\r\n\t\t\t});\r\n\t\tthis.showSummary();\r\n\t\tthis.focusError(firstInvalid);\r\n\t}\r\n\r\n\tfocusError(field) {\r\n\t\tif (this.errorSummary) {\r\n\t\t\tthis.errorSummary.focus();\r\n\t\t} else {\r\n\t\t\tfield.focus();\r\n\t\t}\r\n\t}\r\n\r\n\tonFormSubmit(event) {\r\n\t\tif (this.isInvalid()) {\r\n\t\t\tevent.preventDefault();\r\n\r\n\t\t\t// Prevent subsequent submitting handler from being called\r\n\t\t\tevent.stopImmediatePropagation();\r\n\t\t\tthis.showErrors();\r\n\t\t} else {\r\n\t\t\tthis.hideSummary();\r\n\t\t\tconst formData = getFormData(this.form);\r\n\t\t\tthis.showIfCollection.forEach(\r\n\t\t\t\tdisableHidden.bind(null, formData, this.options)\r\n\t\t\t);\r\n\r\n\t\t\tthis.form.dispatchEvent(\r\n\t\t\t\tnew CustomEvent(\"validate-form-valid\", {\r\n\t\t\t\t\tbubbles: false,\r\n\t\t\t\t\tdetail: { submitFormEvent: event },\r\n\t\t\t\t})\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\t// only if validation succeeds\r\n\tonSubmitting() {\r\n\t\tif (!this.submitButton) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\tthis.submitButton.classList.remove(this.options.submitDisabledClass);\r\n\t\tthis.submitButton.setAttribute(\"disabled\", \"\");\r\n\t\tthis.submitButton.classList.add(\"is-submitting\");\r\n\t}\r\n\r\n\t// this function is used when the form is wrapped in an ajax-submit\r\n\tonSubmitError() {\r\n\t\tif (!this.submitButton) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\tthis.submitButton.removeAttribute(\"disabled\");\r\n\t\tthis.submitButton.classList.remove(\"is-submitting\");\r\n\t}\r\n\r\n\tupdateShowIf(formData) {\r\n\t\tlog(\"formData\", formData);\r\n\r\n\t\tthis.showIfCollection.forEach(\r\n\t\t\thideShow.bind(this, formData, this.options)\r\n\t\t);\r\n\r\n\t\tthis.setIfCollection.forEach(\r\n\t\t\tsetUnset.bind(this, formData, this.options)\r\n\t\t);\r\n\t}\r\n}\r\n\r\nFormValidation.DEFAULTS = {\r\n\tcomponentErrorSelector: \"[data-show-errors]\",\r\n\tvalidateElementSelector: \"[data-validate-field]\",\r\n\tshowIfSelector: \"[data-show-if-condition]\",\r\n\tsetIfSelector: \"[data-set-if][data-set-if-condition]\",\r\n\tsubmitDisabledClass: \"is-disabled\",\r\n};\r\n\r\nexport default FormValidation;\r\n\n\n\n// WEBPACK FOOTER //\n// ./client/src/core/components/form-validation/validate-form.js","/*\r\n * Unlike other utility files, this is not adding functions to the utility scope\r\n * This is instead included by some components\r\n */\r\n\r\nfunction getJSONValue(stringValue) {\r\n\ttry {\r\n\t\treturn JSON.parse(stringValue);\r\n\t} catch (error) {\r\n\t\treturn stringValue;\r\n\t}\r\n}\r\n\r\nfunction camelCase(string) {\r\n return string.replace(/^([A-Z])|[\\s-_](\\w)/g, function(match, p1, p2) {\r\n if (p2) {\r\n return p2.toUpperCase();\r\n }\r\n\r\n return p1.toLowerCase();\r\n });\r\n}\r\n\r\nfunction getOptionData(element) {\r\n\tconst dataset = element.dataset;\r\n\tconst data = {};\r\n\r\n\tfor (const prop in dataset) {\r\n\t\tif (dataset.hasOwnProperty(prop)) {\r\n\t\t\tdata[prop] = dataset[prop];\r\n\t\t}\r\n\t}\r\n\treturn data || {};\r\n}\r\n\r\nfunction extractComponentOptions(name, data) {\r\n\tconst options = {};\r\n\tconst cameledName = camelCase(name);\r\n\tfor (const prop in data) {\r\n\t\tif (prop.startsWith(cameledName) && prop !== cameledName) {\r\n\t\t\toptions[camelCase(prop.slice(cameledName.length))] =\r\n\t\t\t\tgetJSONValue(data[prop]);\r\n\t\t}\r\n\t}\r\n\treturn options;\r\n}\r\n\r\nexport default function(name, element) {\r\n\treturn extractComponentOptions(name, getOptionData(element));\r\n}\r\n\n\n\n// WEBPACK FOOTER //\n// ./client/src/core/plugins/extract-options.js"],"sourceRoot":""}