{"version":3,"file":"main_home.min.js","sources":["main_home.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__(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__(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/* 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 = $('