{"version":3,"sources":["webpack:///./cartridges/app_storefront_widgets/cartridge/client/default/js/widgets/cart/Minicart.js","webpack:///./cartridges/app_storefront_widgets/cartridge/client/default/js/widgets/cart/MinicartDialog.js"],"names":["Widget","Minicart","prefs","refMinicartContent","accessibilityAlerts","init","eventBus","on","normalizeCartModel","response","cartModel","reRenderMinicartWrapper","cart","totals","isShownQtyTotal","parseInt","numItems","render","quantityTotal","isOpen","ref","then","showMinicart","cartQtyTotal","data","window","location","assign","cartUrl","emit","Modal","MinicartDialog","actionUrl","classesActivated","needUpdate","setUpdateFlag","showModal","attributes","refDialog","addClass","updateContent","toggleSpinner","getContentByUrl","catch","errorCode","close","undefined","String","addFocusTraps","updateQty","inputSelect","uuid","submitFormJson","pid","quantity","getValue","displayItemLevelErrorMessage","message","accessibilityAlert","quantitychanged","finally","confirmedRemoveProduct","button","movedToWishlist","removeProductLink","basket","movedtowishlist","productremoved","lineItemUUID","errorMessage","show","setText","removeProduct","link","getById","dialog","productName","onProductLinkClick","isBusy","removeClass","classesLoading","attr","toString","longWaitingTimeout","timeout","moveProductToWishlist","actionMovetowishlist"],"mappings":";;;;;;;;;;AAAA;AAAA;;;;AAIA;;;;;AAKe,yEAAUA,MAAV,EAAkB;AAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,QAAMC,QAAN,SAAuBD,MAAvB,CAA8B;AAC1B;;;;AAIAE,SAAK,GAAG;AACJ,aAAO;AACHC,0BAAkB,EAAE,iBADjB;AAEHC,2BAAmB,EAAE,EAFlB;AAGH,WAAG,MAAMF,KAAN;AAHA,OAAP;AAKH;AAED;;;;;;;;;;AAQAG,QAAI,GAAG;AACH,WAAKC,QAAL,GAAgBC,EAAhB,CAAmB,uBAAnB,EAA4C,yBAA5C;AACA,WAAKD,QAAL,GAAgBC,EAAhB,CAAmB,cAAnB,EAAmC,yBAAnC;AACA,WAAKD,QAAL,GAAgBC,EAAhB,CAAmB,iBAAnB,EAAsC,yBAAtC;AACA,WAAKD,QAA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AACxBZ,mFAAc,CAAC,KAAKlD,KAAL,GAAaoF,oBAAd,EAAoC;AAC9CjC,aAAG,EAAE,KAAKW,iBAAL,CAAuBxC,IAAvB,CAA4B,KAA5B;AADyC,SAApC,CAAd,CAEGH,IAFH,CAEQ,MAAM;AACV,eAAKwC,sBAAL,CAA4B,IAA5B,EAAkC,IAAlC;AACH,SAJD;AAKH;AACJ;;AAlQ8B;;AAqQnC,SAAO9B,cAAP;AACH,C","file":"minicart.widgets.bundle.js","sourcesContent":["/**\n * @typedef {typeof import('widgets/Widget').default} Widget\n */\n\n/**\n * @description Base Minicart implementation\n * @param {Widget} Widget Modal widget for extending\n * @returns {typeof Minicart} Minicart class\n */\nexport default function (Widget) {\n    /**\n     * @category widgets\n     * @subcategory cart\n     * @class Minicart\n     * @augments Widget\n     * @classdesc Minicart widget (located in header and shows only button with number of items in cart), used to:\n     * - Reflect actual products quantity in cart\n     * - Opens {@link MinicartDialog} by click, which contains all minicart content (products list, totals, buttons etc.)\n     * @property {string} data-widget - Widget name `minicart`\n     * @property {string} data-cart-url URL to be used for updating minicart widget (for ex. in case of removing products from minicart)\n     * @example <caption>Example of Minicart widget markup</caption>\n     * <div\n     *     data-widget=\"minicart\"\n     *     data-cart-url=\"${URLUtils.https('Cart-Show')}\"\n     * >\n     *     <div\n     *         data-ref=\"minicartContent\"\n     *         data-count=\"${pdict.quantityTotal}\"\n     *     >\n     *         ... show minicart button\n     *     </div>\n     *     <script data-ref=\"template\" type=\"template/mustache\">\n     *         <div data-ref=\"minicartContent\" data-count=\"{{quantityTotal}}\" class=\"b-minicart_icon\">\n     *             ... show minicart button\n     *         </div>\n     *     </script>\n     * </div>\n     */\n    class Minicart extends Widget {\n        /**\n         * @description Returns Widget configuration object\n         * @returns {object} Widget configuration object\n         */\n        prefs() {\n            return {\n                refMinicartContent: 'minicartContent',\n                accessibilityAlerts: {},\n                ...super.prefs()\n            };\n        }\n\n        /**\n         * @description Widget initialization logic\n         * @listens \"product.added.to.cart\"\n         * @listens \"cart.updated\"\n         * @listens \"product.updated\"\n         * @listens \"minicart.updated\"\n         * @returns {void}\n         */\n        init() {\n            this.eventBus().on('product.added.to.cart', 'reRenderMinicartWrapper');\n            this.eventBus().on('cart.updated', 'reRenderMinicartWrapper');\n            this.eventBus().on('product.updated', 'reRenderMinicartWrapper');\n            this.eventBus().on('minicart.updated', 'reRenderMinicartWrapper');\n        }\n\n        /**\n         * @description Used to obtain clear cart model object from server response\n         * @param {object} response Response from server\n         * @returns {object} Cart model object\n         */\n        normalizeCartModel(response) {\n            return response.cartModel ? response.cartModel : response;\n        }\n\n        /**\n         * @description Called when needs to re-render minicart (for ex. when cart / product in a cart was updated)\n         * @param {object} response response from server\n         * @returns {void}\n         */\n        reRenderMinicartWrapper(response) {\n            const cart = this.normalizeCartModel(response);\n            // Return if response have no Cart Model\n            if (!cart.totals) {\n                return;\n            }\n            const isShownQtyTotal = parseInt(cart.numItems, 10);\n\n            this.render('template', {\n                quantityTotal: cart.numItems,\n                isShownQtyTotal: isShownQtyTotal > 0,\n                isOpen: cart.isOpen\n            }, this.ref(\n                this.prefs().refMinicartContent\n            )).then(() => {\n                if (cart.showMinicart) {\n                    this.showMinicart();\n                }\n            });\n        }\n\n        /**\n         * @description A method, called when event `click` happens on minicart icon\n         * - Check cart total if empty redirect to cart page\n         * - Shows minicart popover\n         * @listens dom#click\n         * @returns {void}\n         */\n        showMinicart() {\n            const cartQtyTotal = parseInt(this.ref(this.prefs().refMinicartContent).data('count'), 10);\n\n            if (cartQtyTotal === 0) {\n                window.location.assign(this.prefs().cartUrl);\n                return;\n            }\n\n            this.eventBus().emit('minicart.show');\n        }\n    }\n\n    return Minicart;\n}\n","import { getContentByUrl, submitFormJson } from 'widgets/toolbox/ajax';\nimport { timeout } from 'widgets/toolbox/util';\n\n/**\n * @typedef {ReturnType <typeof import('widgets/global/Modal').default>} Modal\n * @typedef {InstanceType<ReturnType<typeof import('widgets/global/ConfirmDialog').default>>} confirmDialog\n * @typedef {InstanceType<typeof import('widgets/toolbox/RefElement').RefElement>} refElement\n * @typedef {InstanceType<ReturnType<typeof import('widgets/forms/InputSelect').default>>} inputSelect\n */\n\n/**\n * @description Base MinicartDialog implementation\n * @param {Modal} Modal Modal widget for extending\n * @returns {typeof MinicartDialog} MinicartDialog class\n */\nexport default function (Modal) {\n    /**\n     * @category widgets\n     * @subcategory cart\n     * @class MinicartDialog\n     * @augments Modal\n     * @classdesc MinicartDialog widget, that contains all needed logic to display/update minicart component.\n     * Widget manages next actions:\n     * 1. Change product quantity\n     * 2. Remove product (move to Wish list) from Cart\n     * 3. Communicate actions results\n     * 4. Re-render Minicart including products list and cart summary in case of actions like: quantity changed, product removed etc.\n     * 5. Enable/disable \"Secure Checkout\" button to move to Checkout process depending on if there are errors in cart, which prevents moving to Checkout\n     * Update of Minicart - uses re-render of Minicart wrapper with HTML-markup, which comes from server, but not based on Cart JSON model.\n     * @property {string} data-widget - Widget name `minicartDialog`\n     * @property {string} data-action-url - URL to be used for updating minicart widget (for ex. in case of removing products from minicart)\n     * @property {object} data-accessibility-alerts - Accessibility alerts per minicart action\n     * Possible values are: `quantitychanged`, `productremoved`\n     * @property {string} data-action-movetowishlist - Move product to Wish list action URL\n     * @example <caption>Example of MinicartDialog widget markup</caption>\n     * <div\n     *     ....\n     *     data-widget=\"minicartDialog\"\n     *     data-disable-rendering=\"true\"\n     *     data-classes-loading=\"m-loading_long\"\n     *     data-action-url=\"${URLUtils.url('Cart-MiniCartShow')}\"\n     *     data-accessibility-alerts='{\n     *         \"quantitychanged\": \"${Resource.msg('alert.quantitychanged', 'cart', null)}\",\n     *         \"productremoved\": \"${Resource.msg('alert.productremoved', 'cart', null)}\",\n     *         \"movedtowishlist\": \"${Resource.msg('alert.movedtowishlist', 'cart', null)}\"\n     *     }'\n     *     data-action-movetowishlist=\"${URLUtils.url('Wishlist-AddProduct').toString()}\"\n     * >\n     *     <div\n     *         class=\"b-minicart_panel-container\"\n     *         data-ref=\"container\"\n     *     >\n     *         <div\n     *             class=\"b-minicart\"\n     *             role=\"dialog\"\n     *             aria-modal=\"true\"\n     *             data-ref=\"dialog\"\n     *         >\n     *             <div class=\"b-minicart-inner\">\n     *                 <div class=\"b-minicart-header\">\n     *                     <div data-tau=\"minicart_close\">\n     *                         <isinclude template=\"components/modal/closeButton\"/>\n     *                     </div>\n     *                 </div>\n     *             </div>\n     *         </div>\n     *     </div>\n     *     <isinclude template=\"cart/cartRemoveProductModal\"/>\n     * </div>\n     */\n    class MinicartDialog extends Modal {\n        /**\n         * @description Returns Widget configuration object\n         * @returns {object} Widget configuration object\n         */\n        prefs() {\n            return {\n                actionUrl: '',\n                accessibilityAlerts: {},\n                classesActivated: 'm-activated',\n                ...super.prefs()\n            };\n        }\n\n        /**\n         * @description Widget initialization logic\n         * @listens \"minicart.show\"\n         * @listens \"product.added.to.cart\"\n         * @listens \"cart.updated\"\n         * @listens \"product.updated\"\n         * @returns {void}\n         */\n        init() {\n            super.init();\n            this.needUpdate = true;\n            this.eventBus().on('minicart.show', 'showMinicart');\n            this.eventBus().on('product.added.to.cart', 'setUpdateFlag');\n            this.eventBus().on('cart.updated', 'setUpdateFlag');\n            this.eventBus().on('product.updated', 'setUpdateFlag');\n        }\n\n        /**\n         * @description Set Update Flag - in which cases Minicart should be updated\n         * @param {object} response Response object from server\n         * @returns {void}\n         */\n        setUpdateFlag(response) {\n            if (response.cartModel || response.showMinicart || response.totals) {\n                this.needUpdate = true;\n            }\n        }\n\n        /**\n         * @description A method, called when event `click` happens on minicart icon\n         * - Check cart total if empty redirect to cart page\n         * - Shows minicart panel\n         * - Update content of the panel\n         * @returns {void}\n         */\n        showMinicart() {\n            this.showModal({\n                attributes: {\n                    'data-tau-unique': 'minicart_dialog'\n                }\n            }); // show minicart immediately for better UX\n            this.ref(this.prefs().refDialog).addClass(this.prefs().classesActivated);\n\n            this.updateContent();\n        }\n\n        /**\n         * @description Update minicart panel content\n         * Fetch actual content in case when it needed. Use flag `needUpdate` for this\n         * @returns {void}\n         */\n        updateContent() {\n            if (!this.needUpdate) {\n                return;\n            }\n\n            this.toggleSpinner(true);\n\n            getContentByUrl(this.prefs().actionUrl)\n                .catch(() => {\n                    this.eventBus().emit('alert.show', { errorCode: 500 });\n                    this.toggleSpinner(false);\n                    this.close();\n                })\n                .then((response) => {\n                    this.needUpdate = false;\n\n                    return this.render(\n                        undefined,\n                        {},\n                        this.ref(this.prefs().refDialog),\n                        String(response)\n                    ).then(() => {\n                        this.toggleSpinner(false);\n                        this.addFocusTraps(); // enclose new content with focus trap\n                    });\n                });\n        }\n\n        /**\n         * @description Updates quantity for concrete product in minicart widget\n         * @param {inputSelect} inputSelect - Target select input in minicart widget, which triggers quantity update\n         * @emits \"minicart.updated\"\n         * @returns {void}\n         */\n        updateQty(inputSelect) {\n            this.toggleSpinner(true);\n\n            const uuid = inputSelect.data('uuid');\n            submitFormJson(inputSelect.data('action'), {\n                pid: inputSelect.data('pid'),\n                uuid: uuid,\n                quantity: inputSelect.getValue()\n            }, 'GET')\n                .catch(response => {\n                    this.displayItemLevelErrorMessage(uuid, (response && response.message));\n                })\n                .then((response) => {\n                    if (!response) {\n                        return;\n                    }\n\n                    this.needUpdate = true;\n                    /**\n                     * @description Event to notify concerned widgets, that Minicart was updated\n                     * @event \"minicart.updated\"\n                     */\n                    this.eventBus().emit('minicart.updated', response);\n                    this.accessibilityAlert(this.prefs().accessibilityAlerts.quantitychanged);\n\n                    this.updateContent();\n                })\n                .finally(() => {\n                    this.toggleSpinner(false);\n                });\n        }\n\n        /**\n         * @description Called when Customer confirms product deletion in a modal\n         * <br>In fact sends request to server to delete product line item from basket\n         * <br>and updates minicart widget based on server response\n         * @emits \"minicart.remove.product\"\n         * @param {refElement|null} button - confirmation popup button, triggered action\n         * @param {boolean} [movedToWishlist] - Optional, if we need to move item to wishlist\n         * @returns {void}\n         */\n        confirmedRemoveProduct(button, movedToWishlist = false) {\n            if (!this.removeProductLink) {\n                return;\n            }\n\n            this.eventBus().emit('minicart.remove.product', this);\n\n            const uuid = this.removeProductLink.data('uuid');\n            submitFormJson(this.removeProductLink.data('removeAction') || this.removeProductLink.data('action'), {\n                pid: this.removeProductLink.data('pid'),\n                uuid: uuid\n            }, 'POST')\n                .catch(response => {\n                    this.displayItemLevelErrorMessage(uuid, (response && response.message));\n                })\n                .then((response) => {\n                    if (!response) {\n                        return;\n                    }\n\n                    this.needUpdate = true;\n                    this.eventBus().emit('minicart.updated', response.basket);\n                    this.accessibilityAlert(\n                        movedToWishlist\n                            ? this.prefs().accessibilityAlerts.movedtowishlist\n                            : this.prefs().accessibilityAlerts.productremoved\n                    );\n\n                    this.updateContent();\n                });\n\n            this.removeProductLink = null;\n        }\n\n        /**\n         * @description Display line item level error message.\n         * Usually comes with ajax request to remove product or update quantity,\n         * and in case if this product is no longer in a basket.\n         * @param {string} lineItemUUID - A line item UUID in minicart.\n         * @param {string} errorMessage - An error message to show.\n         * @returns {void}\n         */\n        displayItemLevelErrorMessage(lineItemUUID, errorMessage) {\n            this.ref(`miniCartItemErrorMessage-${lineItemUUID}`)\n                .show().setText(errorMessage || '');\n        }\n\n        /**\n         * @description Shows `remove product` dialog for Customer\n         * @param {refElement} link link which is clicked by user\n         * @returns {void}\n         */\n        removeProduct(link) {\n            this.removeProductLink = link;\n            this.getById('confirmDialog', (/** @type {confirmDialog} */ dialog) => dialog\n                .showModal({ productName: link.data('name') }));\n        }\n\n        /**\n         * @description Executes when user clicks on product details link in the minicart.\n         * Usually used by analytics etc.\n         * @emits \"minicart.product.link.click\"\n         * @param {refElement} link - clicked product tile link\n         * @returns {void}\n         */\n        onProductLinkClick(link) {\n            this.eventBus().emit('minicart.product.link.click', link);\n        }\n\n        /**\n         * @description Shows spinner bar in widget once any update operations (server calls) are pending\n         * @param {boolean} isBusy - show / hide spinner\n         * @returns {void}\n         */\n        toggleSpinner(isBusy) {\n            this.ref('dialog')\n                .removeClass(this.prefs().classesLoading)\n                .attr('aria-busy', isBusy.toString());\n\n            if (this.longWaitingTimeout) {\n                this.longWaitingTimeout();\n            }\n\n            if (isBusy) {\n                this.longWaitingTimeout = timeout(() => {\n                    this.ref('dialog')\n                        .addClass(this.prefs().classesLoading);\n                }, 1000);\n            }\n        }\n\n        /**\n         * @description Fires `alert.show` event to be handled with Global Alerting System\n         * @param {string} accessibilityAlert - alert string\n         * @returns {void}\n         */\n        accessibilityAlert(accessibilityAlert) {\n            this.eventBus().emit('alert.show', {\n                accessibilityAlert\n            });\n        }\n\n        /**\n         * @description Move product from minicart to wishlist.\n         * In fact this functionality implemented in 2 steps:\n         * 1. Add product to wishlist\n         * 2. Remove product from minicart\n         * This is done due to possible backend code duplication in one universal endpoint\n         * @returns {void}\n         */\n        moveProductToWishlist() {\n            if (this.removeProductLink) {\n                submitFormJson(this.prefs().actionMovetowishlist, {\n                    pid: this.removeProductLink.data('pid')\n                }).then(() => {\n                    this.confirmedRemoveProduct(null, true);\n                });\n            }\n        }\n    }\n\n    return MinicartDialog;\n}\n"],"sourceRoot":""}