{"version":3,"file":"main.min.js","sources":["main.min.js"],"sourcesContent":["/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n\n\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\n\twindow.jQuery = window.$ = __webpack_require__(108);\n\tvar processInclude = __webpack_require__(3);\n\n\t$(document).ready(function () {\n\t processInclude(__webpack_require__(109));\n\t processInclude(__webpack_require__(112));\n\t processInclude(__webpack_require__(114));\n\t processInclude(__webpack_require__(115));\n\t processInclude(__webpack_require__(136));\n\t processInclude(__webpack_require__(137));\n\t processInclude(__webpack_require__(59));\n\t processInclude(__webpack_require__(139));\n\t processInclude(__webpack_require__(140));\n\t processInclude(__webpack_require__(141));\n\t processInclude(__webpack_require__(142));\n\t});\n\n\t__webpack_require__(143);\n\t__webpack_require__(155);\n\t__webpack_require__(108);\n\t__webpack_require__(156);\n\t__webpack_require__(157);\n\t__webpack_require__(158);\n\t__webpack_require__(159);\n\n/***/ }),\n/* 1 */,\n/* 2 */,\n/* 3 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\n\tvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\n\tmodule.exports = function (include) {\n\t if (typeof include === 'function') {\n\t include();\n\t } else if ((typeof include === 'undefined' ? 'undefined' : _typeof(include)) === 'object') {\n\t Object.keys(include).forEach(function (key) {\n\t if (typeof include[key] === 'function') {\n\t include[key]();\n\t }\n\t });\n\t }\n\t};\n\n/***/ }),\n/* 4 */,\n/* 5 */,\n/* 6 */,\n/* 7 */,\n/* 8 */,\n/* 9 */,\n/* 10 */,\n/* 11 */,\n/* 12 */,\n/* 13 */,\n/* 14 */,\n/* 15 */,\n/* 16 */,\n/* 17 */,\n/* 18 */,\n/* 19 */,\n/* 20 */,\n/* 21 */,\n/* 22 */,\n/* 23 */,\n/* 24 */,\n/* 25 */,\n/* 26 */,\n/* 27 */,\n/* 28 */,\n/* 29 */,\n/* 30 */,\n/* 31 */,\n/* 32 */,\n/* 33 */,\n/* 34 */,\n/* 35 */,\n/* 36 */,\n/* 37 */,\n/* 38 */,\n/* 39 */,\n/* 40 */,\n/* 41 */,\n/* 42 */,\n/* 43 */,\n/* 44 */,\n/* 45 */,\n/* 46 */,\n/* 47 */,\n/* 48 */,\n/* 49 */,\n/* 50 */,\n/* 51 */,\n/* 52 */,\n/* 53 */,\n/* 54 */,\n/* 55 */,\n/* 56 */,\n/* 57 */,\n/* 58 */,\n/* 59 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\n\t/**\n\t * Validate whole form. Requires `this` to be set to form object\n\t * @param {jQuery.event} event - Event to be canceled if form is invalid.\n\t * @returns {boolean} - Flag to indicate if form is valid\n\t */\n\n\tfunction _validateForm(event) {\n\t var valid = true;\n\t if (this.checkValidity && !this.checkValidity()) {\n\t // safari\n\t valid = false;\n\t if (event) {\n\t event.preventDefault();\n\t event.stopPropagation();\n\t event.stopImmediatePropagation();\n\t }\n\t $(this).find('input, select, textarea').each(function () {\n\t if (!this.validity.valid) {\n\t $(this).trigger('invalid', this.validity);\n\t }\n\t });\n\t }\n\t return valid;\n\t}\n\n\t/**\n\t * Remove all validation. Should be called every time before revalidating form\n\t * @param {element} form - Form to be cleared\n\t * @returns {void}\n\t */\n\tfunction clearForm(form) {\n\t $(form).find('.form-control.is-invalid').not('.custom-error').removeClass('is-invalid');\n\t $(form).find('.cc-phone-input-box.is-invalid').not('.custom-error').removeClass('is-invalid');\n\t $(form).find('.cc-is-invalid-container').removeClass('cc-is-invalid-container');\n\t}\n\n\t//eslint-disable-next-line complexity\n\tfunction insertInvalid(field) {\n\t var validationMessage;\n\t if (typeof field.validationMessage !== 'undefined') {\n\t validationMessage = field.validationMessage;\n\t } else {\n\t validationMessage = field[0].validationMessage;\n\t field = field[0];\n\t }\n\n\t if ($(field).data('rut-validation-enable')) {\n\t if ($(field).find('.custom-error, .is-invalid').length === 0 && validationMessage.length === 0) {\n\t validationMessage = $(field).data('external-rut-validation-error');\n\t }\n\t }\n\t if ($(field).data('max-acceptable-length')) {\n\t if ($(field).val().length > parseInt($(field).data('max-acceptable-length'))) {\n\t validationMessage = $(field).data('max-acceptable-length-error');\n\t }\n\t }\n\n\t if ($(field).hasClass('js-check-email')) {\n\t if ($(field).find('.custom-error, .is-invalid').length === 0 && validationMessage.length === 0) {\n\t validationMessage = $(field).data('email-exist');\n\t }\n\t }\n\n\t if ($(field).data('max') && $(field).val().length > parseInt($(field).data('max'))) {\n\t validationMessage = $(field).data('maxlength-error');\n\t }\n\n\t if ($(field).attr('minlength') && $(field).val().length < parseInt($(field).attr('minlength'))) {\n\t validationMessage = $(field).data('minlength-error');\n\t }\n\n\t if (!field.validity.valid) {\n\t if ($(field).closest('.js-phone-box-validator').find('.cc-phone-prefix').length) {\n\t $(field).closest('.js-phone-box-validator').addClass('is-invalid');\n\t } else {\n\t $(field).addClass('is-invalid');\n\t }\n\t //$(this).addClass('cc-invalid');\n\t $(field).closest('.cc-content-select').addClass('cc-is-invalid-container');\n\t if (field.validity.patternMismatch && $(field).data('pattern-mismatch')) {\n\t validationMessage = $(field).data('pattern-mismatch');\n\t }\n\t if ($(field).data('max-length-acceptable') !== null && $(field).data('range-error') && $(field).val().length > parseInt($(field).data('max-length-acceptable'))) {\n\t validationMessage = $(field).data('range-error');\n\t }\n\t if ((field.validity.rangeOverflow || field.validity.rangeUnderflow) && $(field).data('range-error')) {\n\t validationMessage = $(field).data('range-error');\n\t }\n\t if (field.validity.tooLong && ($(field).data('maxlength-error') || $(field).data('range-error'))) {\n\t validationMessage = $(field).data('maxlength-error') || $(field).data('range-error');\n\t }\n\t if (field.validity.tooShort && ($(field).data('minlength-error') || $(field).data('range-error'))) {\n\t validationMessage = $(field).data('minlength-error') || $(field).data('range-error');\n\t }\n\t if (field.validity.valueMissing && $(field).data('missing-error')) {\n\t validationMessage = $(field).data('missing-error');\n\t }\n\t if (field.validity.typeMismatch && $(field).data('type-mismatch')) {\n\t validationMessage = $(field).data('type-mismatch');\n\t }\n\n\t if ($(field).hasClass('js-validation-add-tick')) {\n\t if ($(field).is('input')) {\n\t $(field).closest('.cc-content-input').removeClass('cc-tick-ok is-valid');\n\t $('.cc-valid-success').addClass('d-none');\n\t }\n\t if ($(field).is('select')) {\n\t $(field).closest('.cc-content-select').removeClass('cc-tick-ok');\n\t }\n\t }\n\t }\n\t if ($(field).parents('.cc-form-group').find('.cc-text-message').length) {\n\t $(field).parents('.cc-form-group').find('.cc-text-message').text(validationMessage);\n\t } else {\n\t $(field).parents('.cc-form-group').find('.invalid-feedback').text(validationMessage);\n\t }\n\t}\n\n\tfunction removeInvalid(field) {\n\t if (typeof field.setCustomValidity !== 'undefined') {\n\t field.setCustomValidity('');\n\t } else {\n\t field = field[0];\n\t field.setCustomValidity('');\n\t }\n\t if (field.validity.valid) {\n\t $(field).removeClass('is-invalid');\n\t // some fields are inside a container which is marked as invalid -> remove the class in case\n\t var $elementInvalidFormContainer = $(field).closest('.form-control.is-invalid');\n\t if ($elementInvalidFormContainer.length) {\n\t $elementInvalidFormContainer.removeClass('is-invalid');\n\t }\n\t $(field).closest('.cc-content-select').removeClass('cc-is-invalid-container');\n\t $(field).closest('.cc-phone-input-box').removeClass('is-invalid');\n\t $(field).closest('.cc-content-select').find('.cc-select').removeClass('is-invalid');\n\t $('.js-input-title-radio').each(function () {\n\t if ($(this).prop('checked')) {\n\t $('.js-input-title-radio').removeClass('is-invalid');\n\t }\n\t });\n\t $(field).parents('.cc-form-group').find('.cc-text-message').text('');\n\t if ($(field).hasClass('js-validation-add-tick')) {\n\t if ($(field).is('input')) {\n\t $(field).closest('.cc-content-input').addClass('cc-tick-ok');\n\t $(field).closest('.cc-content-input').find('.cc-valid-success').removeClass('d-none');\n\t }\n\t if ($(field).is('select')) {\n\t $(field).closest('.cc-content-select').addClass('cc-tick-ok');\n\t $(field).closest('.cc-content-select').find('.cc-valid-success').addClass('d-none');\n\t }\n\t }\n\t }\n\t}\n\n\tfunction validateMaxAcceptableLength(field) {\n\t if (!$(field).data('max-acceptable-length')) {\n\t return;\n\t }\n\t field.setCustomValidity('');\n\n\t var $field = $(field);\n\t var fieldLength = $field.val().length;\n\t var maxLength = $field.data('max-acceptable-length');\n\t if (fieldLength > maxLength) {\n\t // If blank space is the last character over the limit,\n\t // then it is deleted and the error is not triggered\n\t if ($field.val()[maxLength] === ' ') {\n\t var trimmedAddress = $field.val().trimEnd();\n\t $field.val(trimmedAddress);\n\t $field.parents('.cc-form-group').find('.js-field-length-counter').text($field.val().length);\n\t } else {\n\t field.setCustomValidity($field.data('max-acceptable-length-error'));\n\t $field.siblings('.cc-form-description').addClass('is-invalid');\n\t // For mobile: Address is cut off at the max length + 1\n\t if (fieldLength > maxLength + 1) {\n\t $field.val($field.val().slice(0, maxLength + 1));\n\t }\n\t }\n\t } else if ($field.siblings('.cc-form-description').hasClass('is-invalid')) {\n\t $field.siblings('.cc-form-description').removeClass('is-invalid');\n\t }\n\t}\n\n\tfunction validateField(field) {\n\t validateMaxAcceptableLength(field);\n\t var isValidationSuccessful = true;\n\t if (field.validity) {\n\t if (!field.validity.valid) {\n\t insertInvalid(field);\n\t isValidationSuccessful = false;\n\t } else {\n\t removeInvalid(field);\n\t }\n\t }\n\t $(field).trigger('fieldValidated', {\n\t isValid: isValidationSuccessful\n\t });\n\n\t $(field).trigger('validateRUT', {\n\t isValid: isValidationSuccessful,\n\t insertInvalid: insertInvalid.bind(null, $(field)),\n\t removeInvalid: removeInvalid.bind(null, $(field))\n\t });\n\t}\n\n\tfunction validationForm(element) {\n\t var $form = $(element).closest('form');\n\t clearForm($form);\n\t $form.find('input, select, textarea').each(function () {\n\t insertInvalid(this);\n\t });\n\t var $invalidElements = $('.is-invalid, .custom-error');\n\t if ($invalidElements.length > 0) {\n\t var $formGroup = $invalidElements.first().parents('.cc-form-group');\n\t if ($formGroup.length > 0) {\n\t $formGroup[0].scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'nearest' });\n\t }\n\t }\n\t}\n\n\tfunction validateNoMandatoryField(field) {\n\t validateMaxAcceptableLength(field);\n\t if (field.validity) {\n\t if (!field.validity.valid) {\n\t insertInvalid(field);\n\t } else {\n\t removeInvalid(field);\n\t }\n\t }\n\t var checkIfValueIsEmpty = $(field).val();\n\t if ($(field).hasClass('js-validation-add-tick')) {\n\t if (checkIfValueIsEmpty === \"\") {\n\t $(field).closest('.cc-content-input').removeClass('cc-tick-ok');\n\t }\n\t }\n\t}\n\n\tmodule.exports = {\n\n\t invalid: function invalid() {\n\t $('form input, form select, form textarea').on('invalid', function (e) {\n\t e.preventDefault();\n\t insertInvalid(this);\n\t //$(this).parents('.cc-form-group').find('.cc-error-message').show();\n\t });\n\t },\n\n\t submit: function submit() {\n\t $('form').on('submit', function (e) {\n\t // e.preventDefault();\n\t return _validateForm.call(this, e);\n\t });\n\n\t // validation called in case the submit of the form comes from a button of type 'button'\n\t $('body').on('validateOnSubmit', function (e, form) {\n\t return _validateForm.call(form, e);\n\t });\n\t },\n\n\t buttonClick: function buttonClick() {\n\t $('form button[type=\"submit\"], form input[type=\"submit\"]').on('click', function () {\n\t validationForm(this);\n\t });\n\t },\n\t //Temporary solution\n\t buttonClickAjax: function buttonClickAjax() {\n\t $(document).on('click', 'form.js-ajaxCall button[type=\"submit\"], form.js-ajaxCall input[type=\"submit\"]', function () {\n\t validationForm(this);\n\t });\n\t },\n\n\t validateOnChange: function validateOnChange() {\n\t $('body').on('change', '.js-validate-on-change', function () {\n\t if ($(this).prop('required')) {\n\t validateField(this);\n\t } else {\n\t validateNoMandatoryField(this);\n\t }\n\t });\n\t },\n\n\t avoidLettersOnInput: function avoidLettersOnInput() {\n\t $('body').on('input', '.js-avoid-letter-on-input', function () {\n\t this.value = this.value.replace(/[^0-9]/g, '');\n\t });\n\t },\n\n\t validateOnInput: function validateOnInput() {\n\t $('body').on('input', '.js-validate-on-input', function () {\n\t if ($(this).prop('required')) {\n\t validateField(this);\n\t } else {\n\t validateNoMandatoryField(this);\n\t }\n\t });\n\t },\n\n\t checkRut: function checkRut() {\n\t $('#rut-validation-checkout').on('change', function () {\n\t var $rut = $(this);\n\t validateField($rut);\n\t });\n\t },\n\n\t inputFromDropdownList: function inputFromDropdownList() {\n\t $('[id^=\"dni-validation-\"]').on('change', function () {\n\t var $dni = $(this)[0];\n\t validateField($dni);\n\t });\n\t },\n\n\t validateCheckBoxesOnChange: function validateCheckBoxesOnChange() {\n\t $('.js-validation-checkbox').on('change', function () {\n\t var $checkBox = $(this);\n\t $checkBox.removeClass('is-invalid');\n\t if ($checkBox.prop(\"checked\") === false && $checkBox.closest('.cc-form-group').hasClass('required')) {\n\t $checkBox.addClass('is-invalid');\n\t $checkBox.parents('.cc-form-group').find('.invalid-feedback').text($checkBox.data('missing-error'));\n\t $('body').trigger('FE_validation:fieldValidated', { element: $(this), valid: false });\n\t } else {\n\t $('body').trigger('FE_validation:fieldValidated', { element: $(this), valid: true });\n\t }\n\t });\n\t },\n\n\t dropdownLists: function dropdownLists() {\n\t $('#documentPick').on('change', function () {\n\t $('[id^=\"dni-validation-\"]').val('');\n\t $('.cc-valid-success').addClass('d-none');\n\t var $dni = $('[id^=\"dni-validation-\"]');\n\t $($dni[0]).removeClass('is-invalid');\n\t $($dni[0]).closest('.cc-content-input').removeClass('cc-tick-ok');\n\t });\n\t },\n\n\t functions: {\n\t validateForm: function validateForm(form, event) {\n\t _validateForm.call($(form), event || null);\n\t },\n\t clearForm: clearForm\n\t },\n\n\t validateCedulaForm: function validateCedulaForm($field) {\n\t if ($field && $field[0]) {\n\t return validateField($field[0]);\n\t }\n\t return null;\n\t }\n\t};\n\n/***/ }),\n/* 60 */,\n/* 61 */\n/***/ (function(module, exports) {\n\n\t'use strict';\n\n\t/**\n\t * Given a list of values and an emptied dropdown element, it populates the dropdown with the values\n\t * @param {*} dropdown - the dropdown to fill\n\t * @param {Array} list - an array of object containing {ID, value} of the address fields\n\t */\n\n\tfunction populateDropdownFromList(dropdown, list) {\n\t // one empty option on top\n\t var option = document.createElement(\"option\");\n\t option.value = '';\n\t option.text = $(dropdown).data('empty-option');\n\t option.selected = true;\n\t option.disabled = true;\n\t dropdown.add(option);\n\n\t // then the options coming from the list\n\t for (var i in list) {\n\t option = document.createElement(\"option\");\n\t option.value = list[i].ID;\n\t option.text = list[i].value;\n\t dropdown.add(option);\n\t }\n\t}\n\n\t/**\n\t * Function used to empty the values assigned to a unique address field (for example, the zipcode w.r.t. the subdistrict in Bata ID)\n\t * @param {String} fieldName - the name of the unique address field to empty\n\t * @param {String} formId - the ID of the form in which such address field is located\n\t */\n\tfunction emptyUniqueField(fieldName, formId) {\n\t var uniqueField = $('#' + formId + '-' + fieldName);\n\t uniqueField.val('');\n\t uniqueField.data('selected-id', '');\n\t if (uniqueField.hasClass('js-calculate-shipping-cost')) {\n\t uniqueField.trigger('change');\n\t }\n\t}\n\n\t/**\n\t * Function used to update or empty an address field in case it is unique w.r.t. the previous one\n\t * @param {Object} backendData - it contains the list of dropdowns to update, to empty and the type of the next field if it's unique\n\t */\n\tfunction manageUniqueField(backendData, section) {\n\t if (backendData.nextFieldUnique.toUpperCase() === backendData.typeToUpdate) {\n\n\t // if the next -unique- field is to update\n\t var valueToAssign = backendData.listToUpdate[0] ? backendData.listToUpdate[0].ID : '';\n\t var textToAssign = backendData.listToUpdate[0] ? backendData.listToUpdate[0].value : '';\n\t // Notice: the ID is saved in the .data('selected-id'), the value in the .val() to make it visible\n\t var uniqueField = $('#' + backendData.formId + '-' + backendData.nextFieldUnique);\n\t // in the checkout there are multiple times the same address element type in the same form, therefore we have to identify the correct section\n\t if (section) {\n\t uniqueField = $('#' + backendData.formId).find('#' + backendData.nextFieldUnique + '-' + section);\n\t }\n\t uniqueField.data('selected-id', valueToAssign);\n\t uniqueField.val(textToAssign);\n\t if (uniqueField.hasClass('js-calculate-shipping-cost')) {\n\t uniqueField.trigger('change');\n\t }\n\t } else if (backendData.typesToEmpty.indexOf(backendData.nextFieldUnique.toUpperCase()) > -1) {\n\n\t // if the next -unique- field is to empty\n\t emptyUniqueField(backendData.nextFieldUnique, backendData.formId);\n\t }\n\t}\n\n\t/**\n\t * Function called externally on submit of a form to substitute the fields having unique values with their related ID\n\t * @param {FormData} formData - the FormData element\n\t */\n\tfunction handleUniqueFieldsFormValues(formData) {\n\t // the unique fields in the forms need to contain the class 'js-change-value-with-id' and the attribute 'data-selected-id' to trigger the following logic\n\t var uniqueFields = $('.js-change-value-with-id');\n\t uniqueFields.each(function (field) {\n\t var fieldName = $(uniqueFields[field]).attr('name');\n\t var fieldID = $(uniqueFields[field]).data('selected-id');\n\t if (fieldID) {\n\t formData.set(fieldName, fieldID);\n\t }\n\t });\n\t}\n\n\t/**\n\t * Function to update the lists of options related to one or many dropdowns\n\t * @param {Object} data - it contains the dropdowns (elements to update) and the valuesLists (Object with the new option values)\n\t */\n\tfunction updateDropdownOptions(data) {\n\t data.dropdowns.each(function (ind) {\n\t // populate the next dropdown with the new values\n\t $(data.dropdowns[ind]).find('option').remove();\n\t var fieldToUpdate = $(data.dropdowns[ind]).closest('.editable-block').data('field-type').toLowerCase();\n\t var listToUpdate = data.valuesLists[fieldToUpdate] ? data.valuesLists[fieldToUpdate] : [];\n\t populateDropdownFromList(data.dropdowns[ind], listToUpdate);\n\t });\n\t var $selectPicker = $('.selectpicker');\n\t if ($selectPicker.length) {\n\t $selectPicker.selectpicker('refresh');\n\t }\n\t}\n\n\t/**\n\t * Function to retrieve from the backend the lists of options related to one or many dropdowns\n\t * @param {Object} data - it contains the formId (telling which form to update) and the address fields' values on the form dropdowns\n\t */\n\tfunction updateDropdownOptionsAjax(data) {\n\t //TODO deprecated at 90%\n\t var url = $('.js-shipping-address-container').data('address-field-autocomplete-url');\n\t if (url.length > 0) {\n\t $.spinner().start();\n\t $.ajax({\n\t url: url,\n\t type: 'POST',\n\t data: {\n\t formId: data.formId,\n\t province: data.attrs.stateCode,\n\t city: data.attrs.city,\n\t district: data.attrs.district,\n\t subdistrict: data.attrs.subdistrict,\n\t postalCode: data.attrs.postalCode\n\t },\n\t success: function success(data) {\n\t $.spinner().stop();\n\t var dropdowns = $('#' + data.formId).find('.js-autofill-address-field select');\n\t updateDropdownOptions({\n\t dropdowns: dropdowns,\n\t valuesLists: data.valuesLists\n\t });\n\t },\n\t error: function error() {\n\t $.spinner().stop();\n\t },\n\t // this is important to prevent the code to move forward (since the next instruction would be the assignment of the variables -> not possible for select elements if the dropdown are not yet populated)\n\t async: false\n\t });\n\t }\n\t}\n\n\tmodule.exports = {\n\n\t // autofill method to populate the dropdown of an address field once the previous field gets selected, and clean the others if necessary (used by Bata ID and Bata TH)\n\t autofillAddressFields: function autofillAddressFields() {\n\t $('body').on('change', '.js-autofill-address-field select', function (e) {\n\t e.preventDefault();\n\t var $addressFieldElement = $(this);\n\t // $addressSectionContainer is checkout-exclusive\n\t var $addressSectionContainer = $addressFieldElement.closest('.addressContainer');\n\t var url = $addressFieldElement.data('url-action'),\n\t formId = $addressFieldElement.parents('form')[0].id,\n\t section = $addressSectionContainer.data('section'),\n\t fieldValue = $addressFieldElement.val(),\n\t fieldType = $addressFieldElement.closest('.editable-block').data('field-type'),\n\t nextFieldUnique = $addressFieldElement.closest('.editable-block').data('next-field-unique');\n\t $.spinner().start();\n\t $.ajax({\n\t url: url,\n\t type: 'POST',\n\t data: {\n\t formId: formId,\n\t fieldValue: fieldValue,\n\t fieldType: fieldType,\n\t nextFieldUnique: nextFieldUnique\n\t },\n\t success: function success(data) {\n\t if (data.success) {\n\t if (data.nextFieldUnique) {\n\t /* in case of unique text field (for example, the zipcode in ID), the previous field (in the example, the subdistrict)\n\t has an attribute 'data-next-field-unique' set, to autocomplete the next one straight away */\n\t manageUniqueField(data, section);\n\t } else {\n\t var addressFields = $addressSectionContainer.length ? $addressSectionContainer.find('.js-autofill-address-field select', '#' + data.formId) : $('.js-autofill-address-field select', '#' + data.formId);\n\t addressFields.each(function (ind) {\n\t var $currentField = $(addressFields[ind]);\n\t if ($currentField.closest('.editable-block').data('field-type') === data.typeToUpdate) {\n\t // populate the next dropdown with the new values\n\t $currentField.find('option').remove();\n\t populateDropdownFromList(addressFields[ind], data.listToUpdate);\n\t } else if (data.typesToEmpty.indexOf($(addressFields[ind]).closest('.editable-block').data('field-type')) > -1) {\n\t // empty the dropdowns after - if necessary\n\t $currentField.find('option').remove();\n\t populateDropdownFromList(addressFields[ind], []);\n\t }\n\t // empty also the other unique fields\n\t var otherUniqueField = $currentField.closest('.editable-block').data('next-field-unique');\n\t if (otherUniqueField) {\n\t emptyUniqueField(otherUniqueField, data.formId);\n\t }\n\t });\n\t }\n\t // update of bootstrap selectpicker - to apply the visualization of the update\n\t var $selectPicker = $('.selectpicker');\n\t if ($selectPicker.length) {\n\t $selectPicker.selectpicker('refresh');\n\t }\n\t }\n\t $.spinner().stop();\n\t },\n\t error: function error() {\n\t $.spinner().stop();\n\t },\n\t async: false\n\t });\n\t });\n\t },\n\n\t methods: {\n\t handleUniqueFieldsFormValues: handleUniqueFieldsFormValues,\n\t updateDropdownOptions: updateDropdownOptions,\n\t updateDropdownOptionsAjax: updateDropdownOptionsAjax\n\t }\n\t};\n\n/***/ }),\n/* 62 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\n\tvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\n\tvar addressFieldAutocomplete = __webpack_require__(61),\n\t formHelpers = __webpack_require__(63),\n\t addressAttributeList = [];\n\n\t/**\n\t * Given a map of attributes and a target element in the DOM, it updates the data\n\t * @param {Object} attrs - A map which contains all the fields to update\n\t * @param {Element} $form - The element which contains the fields to be updated\n\t * @param {Boolean} triggerAutocomplete - a boolean which eventually triggers autocomplete logics\n\t * @param {Boolean} forceUpdate - a boolean which force the target element update, even if the source data is null\n\t */\n\tfunction populateFieldsWithObject(attrs, $form, triggerAutocomplete, forceUpdate) {\n\t var currentAttribute, currentVal;\n\t for (var i = 0; i < addressAttributeList.length; i++) {\n\t currentAttribute = addressAttributeList[i];\n\t currentVal = attrs[currentAttribute];\n\t if (currentVal || forceUpdate) {\n\t // try to search the input field as a string input\n\t var $radioInput = $('input[name$=_' + currentAttribute + '][type=\"radio\"][value=\"' + currentVal + '\"]', $form),\n\t $standardInput = $('input[name$=_' + currentAttribute + ']:not([type=\"radio\"])', $form),\n\t $selectInput = $('select[name$=_' + currentAttribute + ']', $form),\n\t elementFound = false;\n\n\t if ($radioInput.length) {\n\t $radioInput.prop('checked', true);\n\t elementFound = $radioInput;\n\t } else if ($standardInput.length) {\n\t $standardInput.val(currentVal);\n\t elementFound = $standardInput;\n\t } else if ($selectInput.length) {\n\t // check if the option is already present in the dropdowns\n\t // if so selecte it, otherwhise build a new one and place it into the select element\n\t var $optionPresent = $selectInput.find('option[value=\"' + currentVal + '\"]');\n\t if ($optionPresent.length) {\n\t $optionPresent.prop('selected', true);\n\t } else {\n\t $selectInput.html('');\n\t }\n\t elementFound = $selectInput;\n\t }\n\n\t // if the element we just updated has some autocomplete logic -> trigger it to prefill the next element\n\t if (elementFound && triggerAutocomplete) {\n\t if (elementFound.is('select') && elementFound.closest('.js-autofill-address-field').length) {\n\t elementFound.trigger('change');\n\t } else if (elementFound.is('input') && elementFound.hasClass('js-city-autocomplete')) {\n\t elementFound.trigger('blur');\n\t }\n\t }\n\n\t // if the element doesn't exist (like address2, district, subdistrict in some countries, the element is simply skipped)\n\t }\n\t }\n\t}\n\n\t/**\n\t * Given an custome address element, retrieve the address data\n\t * @param {Element} $address - the element which contains the address data\n\t * @return {Object} - an object with all the address values\n\t */\n\tfunction getAddressObjectFromElement($address) {\n\t // standard attributes\n\t var address = {\n\t 'addressId': $address.data('address-id'),\n\t 'address1': $address.data('address1'),\n\t 'address2': $address.data('address2'),\n\t 'subdistrict': $address.data('subdistrict'),\n\t 'district': $address.data('district'),\n\t 'city': $address.data('city'),\n\t 'stateCode': $address.data('state-code'),\n\t 'countryCode': $address.data('country-code'),\n\t 'postalCode': $address.data('postal-code'),\n\t 'isValidated': $address.data('is-validated') || \"false\"\n\t };\n\n\t // those fields has to be optional, since the argument address could be the result of an address suggestion\n\t // (which doens't provide all the address information)\n\t var optionalAttributesForAddress = [{\n\t key: 'title',\n\t value: $address.data('title')\n\t }, {\n\t key: 'firstName',\n\t value: $address.data('first-name')\n\t }, {\n\t key: 'lastName',\n\t value: $address.data('last-name')\n\t }];\n\n\t var currentAttr = void 0;\n\t for (var i = 0; i < optionalAttributesForAddress.length; i++) {\n\t currentAttr = optionalAttributesForAddress[i];\n\t if (currentAttr.value && currentAttr.value.length >= 1) {\n\t address[currentAttr.key] = currentAttr.value;\n\t }\n\t }\n\t return address;\n\t}\n\n\t/**\n\t * Given an custome address element, it copies all it's data to the target address form\n\t * @param {Element} $customerAddressSelected - Object that contains shipping address\n\t * @param {Element} $formContainer - The element which contains the address form\n\t */\n\tfunction copyCustomerAddressToAddressForm($customerAddressSelected, $formContainer) {\n\t var attrs = getAddressObjectFromElement($customerAddressSelected);\n\t populateFieldsWithObject(attrs, $formContainer, true, true);\n\t}\n\n\t/**\n\t * Verify if the address already exists as a stored user address\n\t * @param {Object} address - Object that contains shipping address\n\t * @param {Object} storedAddresses - List of stored user addresses\n\t * @returns {boolean} - Boolean indicating if the address already exists\n\t */\n\tfunction checkIfAddressStored(address, storedAddresses) {\n\t for (var i = 0, l = storedAddresses.length; i < l; i++) {\n\t if (storedAddresses[i].address1 === address.address1 && storedAddresses[i].postalCode === address.postalCode && storedAddresses[i].firstName === address.firstName && storedAddresses[i].lastName === address.lastName && storedAddresses[i].title === address.title && storedAddresses[i].subdistrict === address.subdistrict && storedAddresses[i].district === address.district && storedAddresses[i].city === address.city && storedAddresses[i].stateCode === address.stateCode) {\n\t return true;\n\t }\n\t }\n\t return false;\n\t}\n\n\t/**\n\t * Substitute the title in the address with its localized version\n\t * @param {Object} address - Object that contains the address\n\t */\n\tfunction setLocalizedTitle(title) {\n\t var femaleTitle = $('.js-container-checkout').data('female-title'),\n\t femaleTitleToUse = $('.js-container-checkout').data('female-title-to-use'),\n\t maleTitleToUse = $('.js-container-checkout').data('male-title-to-use'),\n\t notUseDotForTitle = $('.js-container-checkout').data('no-use-dot-for-title'),\n\t titleToUse;\n\n\t if (title.endsWith(\".\")) {\n\t // first, remove the eventual dot we might have from the title received, to compare it with the data values\n\t title.slice(0, -1);\n\t }\n\t titleToUse = title === femaleTitle ? femaleTitleToUse : maleTitleToUse;\n\t // Finally we make sure that the title forwarded ends with a dot\n\t if (notUseDotForTitle || titleToUse.endsWith('.')) {\n\t return titleToUse;\n\t } else {\n\t return titleToUse + '.';\n\t }\n\t}\n\n\t/**\n\t * Populate the Billing Address Summary View\n\t * @param {string} parentSelector - the top level DOM selector for a unique address summary\n\t * @param {Object} address - the address data\n\t */\n\tfunction populateAddressSummary(parentSelector, address) {\n\t if (address.title) {\n\t address.title = setLocalizedTitle(address.title);\n\t }\n\t $.each(address, function (attr) {\n\t var val = address[attr];\n\t $('.' + attr, parentSelector).text(val ? val.value || val : '');\n\t });\n\t}\n\n\t/**\n\t * returns a formed element\n\t * @param {Object} shipping - the shipping object (shipment model)\n\t * @param {boolean} selected - current shipping is selected (for PLI)\n\t * @param {order} order - the Order model\n\t * @param {Object} [options] - options\n\t * @returns {Object} - the jQuery / DOMElement\n\t */\n\t// eslint-disable-next-line complexity\n\tfunction optionValueForAddress(shipping, selected, order, options) {\n\t var safeOptions = options || {};\n\t var isBilling = safeOptions.type && safeOptions.type === 'billing';\n\t var className = safeOptions.className || 'manual-entry';\n\t var isSelected = selected;\n\t var isNew = !shipping;\n\t var safeShipping = shipping || {};\n\t var shippingAddress = safeShipping.shippingAddress || {};\n\t var shippingMethod = order.shipping[0].selectedShippingMethod.ID;\n\n\t if (isBilling && isNew && !order.billing.matchingAddressId) {\n\t shippingAddress = order.billing.billingAddress.address || {};\n\t if (!shippingAddress) {\n\t isNew = false;\n\t isSelected = true;\n\t safeShipping.UUID = 'manual-entry';\n\t } else {\n\t isSelected = true;\n\t if (shippingMethod === 'STS' || order.isCollectionPoint) {\n\t shippingAddress = {};\n\t }\n\t }\n\t }\n\n\t var uuid = safeShipping.UUID ? safeShipping.UUID : 'new';\n\t var newAddressRadioID = isBilling ? 'newAddressRadio' : 'shipping-newAddressRadio';\n\t var addressRadioName = isBilling ? 'addressSelector' : 'shipping-radio';\n\t var id = isNew ? newAddressRadioID : uuid;\n\t var optionEl = $('