{"version":3,"sources":["webpack:///./cartridges/plugin_instorepickup/cartridge/client/default/js/storePickup/storePickup.js"],"names":["PRODUCT_CHANGE_EVENT","_updateErrorMessageVisibility","container","product","notReadyMsgEl","querySelector","notResultsMsgEl","readyToOrder","classList","add","remove","_hideContactForm","contactToggle","toggle","unset","_setupProductUpdateListener","$","off","on","evt","response","storeLocator","appendParamsToURL","window","SFRA","Urls","storeLocatorFindStores","renderView","pid","data","id","products","concat","getQuantitySelected","radius","postalCode","typeCheck","locatorEl","isProductUpdate","productData","showStoreLocator","payload","getPidValue","getAttribute","prompt","dataset","actionUrl","targetFormEl","getProductContainer","allowSearchAfterSelection","deselectStore","getQuantitySelector","removeAttribute","updateTriggerStatus","pickupTrigger","disabled","availableForStoreReservation","requestInventoryCheck","productContainer","searchPID","storeId","atsURL","atsActionUrl","qtyEl","ajax","url","quantitySelected","method","success","removeQuantityOptions","atsValue","trigger","productAtsValue","SitePreferences","allowProductLineItemRepeats","DOMSelectedValue","value","i","options","length","removeChild","selectedIndex","addQuantityOptions","responseSelectedValue","createElWithAttrs","showInStoreInventory","addEventListenerList","hasSelectedStore","selectedStoreDetails","selectedStoreInput","call","selectStoreWithInventory","subscribe","pickupChangeEl","locatorSettings","pickupTriggerEl","storeData","searchRadius","postal","searchPostalCode","storeID","changeStore","onStoreListChange","locatorContainer","checkAvailabilityTriggers","querySelectorAll","inputPID","inputBoutiqueID","productAvailabilityContainer","setupVariationListeners","onStoreUpdateRequest","closeStoreSelection"],"mappings":";;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAa;;AAE+C;AAChB;AACc;AACA;AACS;AACgD;AAChD;AAEnE,IAAMA,oBAAoB,GAAG,kDAAkD;;AAE/E;AACA;AACA;AACA;AACA,SAASC,6BAA6BA,CAACC,SAAS,EAAEC,OAAO,EAAE;EACvD,IAAIC,aAAa,GAAGF,SAAS,CAACG,aAAa,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AACiE,eAAe,CAACzD,SAAS,CAAC;MACpD;IACJ,CAAC,CAAC;EACN,CAAC;EAED;AACJ;AACA;AACA;EACI0E,mBAAmB,EAAE,SAArBA,mBAAmBA,CAAA,EAAa;IAC5BnB,iEAAS,CAAC,qBAAqB,EAAE,YAAW;MACxC;MACA;;MAEA;MACA;MACA;;MAEA5E,CAAC,CAAC,MAAM,CAAC,CAACC,GAAG,CAACjB,oBAAoB,CAAC;IACvC,CAAC,CAAC;EACN;AACJ,CAAC,E","file":"page-cart~page-product.js","sourcesContent":["'use strict';\n\nimport {createElWithAttrs} from '@borngroup/born-utilities';\nimport {subscribe} from '../helpers/pubSub';\nimport {addEventListenerList} from '../helpers/utilities';\nimport {appendParamsToURL} from '../helpers/urlUtilities';\nimport * as storeLocator from '../modules/module.store-locator.js';\nimport {getPidValue, getProductContainer, getQuantitySelector, getQuantitySelected} from '../product/productUtils';\nimport {setupVariationListeners} from '../product/variationsUtils';\n\nconst PRODUCT_CHANGE_EVENT = 'product:afterAttributeSelect.productAvailability';\n\n/**\n * Updates the error message display for \"not ready\" products, when switching\n * between product variations while the Product Availability modal is open.\n */\nfunction _updateErrorMessageVisibility(container, product) {\n let notReadyMsgEl = container.querySelector('[data-locator-component=\"not-ready\"]'),\n notResultsMsgEl = container.querySelector('[data-locator-component=\"no-results\"]');\n\n if (product.readyToOrder) {\n notReadyMsgEl.classList.add('hidden');\n } else {\n notResultsMsgEl.classList.add('hidden');\n notReadyMsgEl.classList.remove('hidden');\n }\n}\n\n/**\n * Hides the store's contact form whenever switching to a different product.\n */\nfunction _hideContactForm(container) {\n let contactToggle = container.querySelector('[data-locator-component=\"availability-trigger\"].set--show-form');\n\n if (contactToggle && contactToggle.toggle) {\n contactToggle.toggle.unset();\n }\n}\n\n/**\n * Attaches a listener to the `body` to align with SFRA's setup. This event is fired from `product/variationsUtils`.\n * When the event fires, request an update for the product store availability, by providing the updated product ID/Qty.\n * @return {[type]} [description]\n */\nfunction _setupProductUpdateListener() {\n $('body').off(PRODUCT_CHANGE_EVENT).on(PRODUCT_CHANGE_EVENT, function(evt, response) {\n storeLocator.requestStoreSearch(appendParamsToURL(window.SFRA.Urls.storeLocatorFindStores, {renderView: 'productAvailability'}), {\n pid: response.data.product.id,\n products: `${response.data.product.id}:${getQuantitySelected(response.container)}`,\n radius: 20000,\n postalCode: '',\n typeCheck: 'CR'\n }, {\n locatorEl: response.container,\n isProductUpdate: true,\n productData: response.data.product\n });\n });\n}\n\n/**\n * Replaces the content in the modal window with find stores components and\n * the result store list.\n * @param {string} pid - The product ID to search for\n * @param {number} quantity - Number of products to search inventory for\n * @param {number} selectedPostalCode - The postal code to search for inventory\n * @param {number} selectedRadius - The radius to search for inventory\n */\nexport function showStoreLocator() {\n let payload = {\n pid: getPidValue(this),\n products: `${getPidValue(this)}:${getQuantitySelected(this)}`,\n radius: this.getAttribute('data-radius') || '',\n postalCode: this.getAttribute('data-postal') || ''\n },\n prompt = this.getAttribute('data-prompt-url') || true;\n\n storeLocator.requestStoreSearch(this.dataset.actionUrl, payload, {prompt, targetFormEl: getProductContainer(this), allowSearchAfterSelection: true});\n}\n\n/**\n * Remove the selected store.\n * @param {HTMLElement} container - the target html element\n */\nexport function deselectStore(container) {\n storeLocator.removeTargetFormData({targetFormEl: container});\n\n getQuantitySelector(container).removeAttribute('data-original-html');\n}\n\n/**\n * Updates the store pickup trigger disabled status.\n */\nexport function updateTriggerStatus(response, container) {\n let pickupTrigger = container.querySelector('[data-product-component=\"pickup-trigger\"]');\n\n if (pickupTrigger) {\n // pickupTrigger.disabled = !response.product.readyToOrder || !response.product.available || !response.product.availableForStoreReservation;\n pickupTrigger.disabled = !response.product.availableForStoreReservation;\n\n response.product.availableForStoreReservation ? pickupTrigger.classList.remove('hidden') : pickupTrigger.classList.add('hidden');\n }\n}\n\n/**\n * Update quantity options. Only display quantity options that are available for the store.\n * @param {sring} searchPID - The product ID of the selected product.\n * @param {number} storeId - The store ID selected for in store pickup.\n */\nexport function requestInventoryCheck(productContainer, searchPID, storeId) {\n let atsURL = productContainer.querySelector('[data-product-component=\"pickup-trigger\"]').dataset.atsActionUrl,\n qtyEl = getQuantitySelector(productContainer);\n\n //Update Quantity dropdown, Remove quantity greater than inventory\n $.ajax({\n url: atsURL,\n data: {\n pid: searchPID,\n quantitySelected: getQuantitySelected(productContainer),\n storeId: storeId\n },\n method: 'GET',\n success: function(response) {\n removeQuantityOptions(qtyEl, response.atsValue);\n\n $('body').trigger('storePickup:afterInventoryCheck', {\n data: response, container: productContainer\n });\n }\n });\n}\n\n/**\n * Updates the Quantity Selector based on the In Store Quantity.\n * @param {string} qtyEl - Quantity Element\n * @param {number} productAtsValue - Inventory in the selected store\n */\nexport function removeQuantityOptions(qtyEl, productAtsValue) {\n //Do not attempt to generate Quantity Options if product QTY cannot be updated by the user.\n if (window.SFRA.SitePreferences.allowProductLineItemRepeats) {\n return false;\n }\n\n let DOMSelectedValue = qtyEl.value;\n\n for (let i = qtyEl.options.length - 1; i >= productAtsValue && i > 0; i--) {\n qtyEl.removeChild(qtyEl.options[i]);\n }\n\n //Select the max possible value if the available stock is lower than the previously-selected qty.\n if (DOMSelectedValue > productAtsValue) {\n qtyEl.selectedIndex = qtyEl.options.length - 1;\n }\n}\n\n/**\n * Updates the Quantity Selector based on the In Store Quantity.\n * @param {string} qtyEl - Quantity Element\n * @param {number} productAtsValue - Inventory in the selected store\n */\nexport function addQuantityOptions(qtyEl, productAtsValue, responseSelectedValue) {\n //Do not attempt to generate Quantity Options if product QTY cannot be updated by the user.\n if (window.SFRA.SitePreferences.allowProductLineItemRepeats) {\n return false;\n }\n\n let DOMSelectedValue = qtyEl.value;\n\n for (let i = qtyEl.options.length + 1; i <= productAtsValue; i++) {\n createElWithAttrs(qtyEl, {value: i}, 'option', i);\n }\n\n //Select the max possible value if the available stock is lower than the previously-selected qty.\n if (DOMSelectedValue > productAtsValue) {\n qtyEl.selectedIndex = qtyEl.options.length - 1;\n } else if (responseSelectedValue) {\n qtyEl.value = responseSelectedValue;\n }\n}\n\nexport default {\n /**\n * Handle store pickup option selection on PDP. Either displays a modal or shows the previously selected store data.\n */\n showInStoreInventory: function() {\n addEventListenerList('[data-product-component=\"pickup-trigger\"]', 'click', function() {\n // if (this.checked) {\n //If there is already a selected store, display the store info and set the `selectedStoreInput` value again.\n if (this.dataset.hasSelectedStore) {\n let productContainer = getProductContainer(this),\n selectedStoreDetails = productContainer.querySelector('[data-locator-component=\"selected-store-display\"]'),\n selectedStoreInput = storeLocator.getSelectedStoreInput(productContainer);\n\n selectedStoreInput.value = this.dataset.hasSelectedStore;\n selectedStoreDetails.classList.remove('hidden');\n\n requestInventoryCheck(productContainer, getPidValue(productContainer), this.dataset.hasSelectedStore);\n } else {\n //If there's no selection yet, load the store selection modal.\n showStoreLocator.call(this);\n }\n // }\n });\n },\n\n selectStoreWithInventory: function() {\n subscribe('storeLocator:confirmed', function(data) {\n let pickupChangeEl = data.locatorSettings.targetFormEl.querySelector('[data-product-component=\"pickup-change\"]'),\n pickupTriggerEl = data.locatorSettings.targetFormEl.querySelector('[data-product-component=\"pickup-trigger\"]');\n\n pickupChangeEl.dataset.radius = data.storeData.searchRadius;\n pickupChangeEl.dataset.postal = data.storeData.searchPostalCode;\n pickupTriggerEl.dataset.hasSelectedStore = data.storeData.storeID;\n\n requestInventoryCheck(data.locatorSettings.targetFormEl, getPidValue(data.locatorSettings.targetFormEl), data.storeData.storeID);\n });\n },\n\n changeStore: function() {\n addEventListenerList('[data-product-component=\"pickup-change\"]', 'click', showStoreLocator);\n },\n\n /**\n * Listen for module.store-locator's store list changes.\n * Re-bind the necessary events whenever the list of stores is updated, so that data is properly passed to the \"store reservation\" form.\n */\n onStoreListChange: function() {\n subscribe('storeLocator:updateRendered', function(data) {\n let locatorContainer = data.locatorSettings.locatorEl;\n\n if (locatorContainer) {\n let checkAvailabilityTriggers = locatorContainer.querySelectorAll('[data-locator-component=\"availability-trigger\"]'),\n inputPID = locatorContainer.querySelector('[data-locator-component=\"input-pid\"]'),\n inputBoutiqueID = locatorContainer.querySelector('[data-locator-component=\"input-boutiqueID\"]'),\n productAvailabilityContainer = locatorContainer.querySelector('[data-product-container=\"productAvailability\"]');\n\n addEventListenerList(checkAvailabilityTriggers, 'click', function() {\n inputPID.value = this.getAttribute('data-pid');\n inputBoutiqueID.value = this.getAttribute('data-store-id');\n });\n\n if (productAvailabilityContainer) {\n setupVariationListeners(productAvailabilityContainer);\n\n _setupProductUpdateListener();\n }\n }\n });\n },\n\n onStoreUpdateRequest: function() {\n subscribe('storeLocator:updateRequested', function(data) {\n if (data.locatorSettings.isProductUpdate) {\n _updateErrorMessageVisibility(data.locatorSettings.locatorEl, data.locatorSettings.productData);\n _hideContactForm(data.locatorSettings.locatorEl);\n }\n });\n },\n\n /**\n * Listen to when the store selection modal is closed, and if nothing was selected, reset the delivery option to the default (\"Home\").\n * @return {[type]} [description]\n */\n closeStoreSelection: function() {\n subscribe('storeLocator:closed', function() {\n // let pickupRemoveEl = data.locatorSettings.targetFormEl.querySelector('[data-product-component=\"pickup-remove\"]'),\n // pickupTriggerEl = data.locatorSettings.targetFormEl.querySelector('[data-product-component=\"pickup-trigger\"]');\n\n // if (!pickupTriggerEl.dataset.hasSelectedStore) {\n // pickupRemoveEl.checked = true;\n // }\n\n $('body').off(PRODUCT_CHANGE_EVENT);\n });\n }\n};\n"],"sourceRoot":""}