{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./cartridges/app_storefront_base/cartridge/client/default/js/util.js","webpack:///./cartridges/int_custom_melco/cartridge/client/default/js/melco.js","webpack:///./cartridges/int_custom_melco/cartridge/client/default/js/melco/melco.js"],"names":[],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;AClFa;;AAEb;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;;;;;;;;;;;;ACZa;;AAEb,qBAAqB,mBAAO,CAAC,uFAAW;;AAExC;AACA,mBAAmB,mBAAO,CAAC,+FAAe;AAC1C,CAAC;;;;;;;;;;;;;ACNY;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA,mCAAmC,8BAA8B;AACjE;AACA;;AAEA,4CAA4C,eAAe;AAC3D,gGAAgG,gCAAgC,GAAG,MAAM;AACzI;AACA,oGAAoG,2BAA2B,UAAU,oCAAoC;AAC7K,sGAAsG,4BAA4B,UAAU,sBAAsB;AAClK,oGAAoG,2BAA2B,UAAU,0BAA0B;AACnK;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uCAAuC,8BAA8B;AACrE;AACA;AACA,gDAAgD,eAAe;AAC/D,oGAAoG,gCAAgC,GAAG,MAAM;AAC7I;AACA,wGAAwG,2BAA2B,UAAU,oCAAoC;AACjL,0GAA0G,4BAA4B,UAAU,sBAAsB;AACtK,wGAAwG,2BAA2B,UAAU,0BAA0B;AACvK;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA,iBAAiB;AACjB,aAAa;AACb;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA,oEAAoE,EAAE;AACtE;AACA,iBAAiB;AACjB;AACA,SAAS;AACT,wDAAwD,EAAE;AAC1D;AACA,KAAK;AACL;;AAEA;AACA,sBAAsB;AACtB;AACA;;AAEA,mBAAmB,8BAA8B;AACjD;AACA;AACA;AACA;AACA;AACA,wBAAwB,iBAAiB,kCAAkC,6CAA6C;AACxH,+BAA+B,cAAc,8BAA8B;AAC3E;AACA,0CAA0C;AAC1C,iCAAiC;AACjC;AACA;AACA,YAAY,WAAW,cAAc,eAAe,gBAAgB,UAAU,+BAA+B,EAAE,GAAG,GAAG,GAAG;AACxH;;AAEA;AACA;AACA;AACA;AACA","file":"default/js/melco.js","sourcesContent":[" \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 \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\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.l = 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// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./cartridges/int_custom_melco/cartridge/client/default/js/melco.js\");\n","'use strict';\n\nmodule.exports = function (include) {\n if (typeof include === 'function') {\n include();\n } else if (typeof include === 'object') {\n Object.keys(include).forEach(function (key) {\n if (typeof include[key] === 'function') {\n include[key]();\n }\n });\n }\n};\n","'use strict';\n\nvar processInclude = require('base/util');\n\n$(document).ready(function () {\n processInclude(require('./melco/melco'));\n});\n","'use strict';\n\nconst customizeEmbroidery = function () {\n $('body').on('click', '.customize-button-embroidery', function (event) {\n event.preventDefault();\n const $customizebtn = $(this);\n const productToken = $customizebtn.data('token');\n const melcoConfigurator = new window.MelcoConfigurator();\n const apiKey = $customizebtn.data('configkey');\n const $sessionid = $('.melcoSessionID');\n const sessionToken = $sessionid.val();\n const options = {\n onComplete: function (data) {\n $sessionid.val(data.session_id);\n $(\".melcoProductToken\").val(data.product.token);\n var cutData = cutPersonalizationData(data);\n $(\".melcoPersonalizationData\").val(JSON.stringify(cutData));\n if ($('#page-bear-builder').length > 0) {\n var options = {\n url: $customizebtn.data('url'),\n method: 'POST',\n data: {\n pid: $customizebtn.data('pid'),\n sessionToken: data.session_id,\n readyToken: data.product.token,\n personalizationData: JSON.stringify(cutData)\n }\n };\n $.ajax(options).done(function (res) {\n if (res.enabled) {\n $('.embrodiery-required-message').hide();\n $('.summary-add-to-bag').prop('disabled', false);\n }\n });\n }\n const melcoPersonalizationDataObj = cutData;\n if (melcoPersonalizationDataObj.product.view_list.length > 0) {\n const melcoImageDataObj = melcoPersonalizationDataObj.product.view_list[0].color_list[0].design_list[0].design.element_list;\n let melcoDetailObj = '';\n for (let i = 0; i < melcoImageDataObj.length; i++) {\n const selectedColorObj = melcoImageDataObj[i].color_collection.color_list;\n const selectedAlphabateObj = melcoImageDataObj[i].lettering.alphabet_list;\n\n melcoDetailObj = `${melcoDetailObj}
\n
${$customizebtn.data('text-line')} ${i + 1}
\n
\n
${$customizebtn.data('text')} ${melcoImageDataObj[i].lettering.text}
\n
${$customizebtn.data('color')} ${selectedColorObj.name}
\n
${$customizebtn.data('font')} ${selectedAlphabateObj.name}
\n
`;\n }\n $(\".updateColor\").empty().html(melcoDetailObj);\n }\n $(\".show-embroidery-detail\").removeClass('d-none');\n $('.prices-add-to-cart-actions .customize-button').addClass('btn-primary').removeClass('btn-outline-primary');\n if (sessionToken === '') {\n $(\".embroidery-option\").addClass('d-none');\n $(\".add-to-cart-emb\").removeClass('d-none');\n }\n },\n sessionId: sessionToken\n };\n melcoConfigurator.start(productToken, apiKey, options);\n });\n};\n\nconst customizeEmbroideryCart = function () {\n $('body').on('click', '.customize-button-embroidery-cart', function (event) {\n event.preventDefault();\n const $customizebtn = $(this);\n const productToken = $customizebtn.parent().find('.melcoProductToken').val();\n const melcoConfigurator = new window.MelcoConfigurator();\n const apiKey = $customizebtn.data('configkey');\n const sessionToken = $customizebtn.parent().find('.melcoSessionID').val();\n const productID = $customizebtn.data('pid');\n const url = $customizebtn.data('action');\n const uuid = $customizebtn.data('uuid');\n const options = {\n onComplete: function (data) {\n var cutData = cutPersonalizationData(data);\n const urlParams = {\n pid: productID,\n uuid: uuid,\n productToken: productToken,\n melcoSessionID: data.session_id,\n melcoPersonalizationData: JSON.stringify(cutData)\n };\n $customizebtn.parents('.card').spinner().start();\n $('body').trigger('cart:beforeUpdate');\n $.ajax({\n url: url,\n type: 'POST',\n context: this,\n dataType: 'json',\n data: urlParams,\n success: function (result) {\n $('body').trigger('cart:update', result);\n const $lineItem = $customizebtn.closest('.product-info');\n const lineItemObj = result.items.filter(item => item.UUID.toString() === uuid)[0];\n $lineItem.find('.melcoSessionID').val(lineItemObj.melcoSessionID);\n $lineItem.find('.melcoProductToken').val(lineItemObj.melcoProductToken);\n $lineItem.find('.melcoPersonalizationData').val(JSON.stringify(lineItemObj.melcoPersonalizationData));\n const melcoPersonalizationDataObj = JSON.parse(lineItemObj.melcoPersonalizationData);\n const melcoImageDataObj = melcoPersonalizationDataObj.product.view_list[0].color_list[0].design_list[0].design.element_list;\n let melcoDetailObj = '';\n for (let i = 0; i < melcoImageDataObj.length; i++) {\n const selectedColorObj = melcoImageDataObj[i].color_collection.color_list;\n const selectedAlphabateObj = melcoImageDataObj[i].lettering.alphabet_list;\n melcoDetailObj = `${melcoDetailObj}
\n
${$customizebtn.data('text-line')} ${i + 1}
\n
\n
${$customizebtn.data('text')} ${melcoImageDataObj[i].lettering.text}
\n
${$customizebtn.data('color')} ${selectedColorObj.name}
\n
${$customizebtn.data('font')} ${selectedAlphabateObj.name}
\n
`;\n }\n $lineItem.find(\".updateColor\").empty().html(melcoDetailObj);\n $.spinner().stop();\n },\n error: function (event) {\n console.log(event);\n }\n });\n },\n sessionId: sessionToken\n };\n melcoConfigurator.start(productToken, apiKey, options);\n });\n};\n\n// This script is used to fire gtm event add_payment_info on cart page for paypal payment method\nconst fireGtmEvent = function () {\n $('body').on('click', '.checkout-continue .paypal-checkout', function () {\n let form = {};\n form.method = 'PayPal';\n form.payment_page = 'cart';\n\n try {\n if (window.gtmUrls && window.gtmUrls.GTM_ajaxRoute) {\n $.ajax({\n url: window.gtmUrls.GTM_ajaxRoute,\n type: 'post',\n data: form,\n dataType: 'json',\n success: function (data) {\n if (data.gtmData && window.dataLayer) {\n window.dataLayer.push(JSON.parse(data.gtmData));\n }\n },\n error: function (error) {\n window.console.error('\\nmelco.js: error in {0}', error);\n }\n });\n }\n } catch (error) {\n window.console.error('\\nmelco.js: error in {0}', error);\n }\n });\n};\n\nfunction cutPersonalizationData(data) {\n console.log(data); // eslint-disable-line\n const melcoImageDataObj = data.product.view_list[0].color_list[0].design_list[0].design.element_list;\n var cutElementList = [];\n\n for (let i = 0; i < melcoImageDataObj.length; i++) {\n const defaultColorID = melcoImageDataObj[i].default_color_id;\n const defaultAlphabateID = melcoImageDataObj[i].lettering.default_alphabet_id;\n const selectedColorObj = melcoImageDataObj[i].color_collection.color_list.filter(color => color.id.toString().toUpperCase() === defaultColorID.toUpperCase())[0];\n const selectedAlphabateObj = melcoImageDataObj[i].lettering.alphabet_list.filter(alpha => alpha.id.toUpperCase() === defaultAlphabateID.toUpperCase())[0];\n var thisElement = {\n lettering: { alphabet_list: { name: selectedAlphabateObj.name }, text: melcoImageDataObj[i].lettering.text },\n color_collection: { color_list: { name: selectedColorObj.name } }\n };\n console.log(melcoImageDataObj[i]); // eslint-disable-line\n console.log(thisElement); // eslint-disable-line\n cutElementList[i] = thisElement;\n }\n return { product: { view_list: [{ color_list: [{ design_list: [{ design: { element_list: cutElementList } }] }] }] } };\n}\n\nmodule.exports = {\n customizeEmbroidery: customizeEmbroidery,\n customizeEmbroideryCart: customizeEmbroideryCart,\n fireGtmEvent: fireGtmEvent\n};\n"],"sourceRoot":""}