1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[72701],{44(t,e,i){i.d(e,{A:()=>s});var r=i(5683);class s extends r.A{constructor(t,e="before"){super(t,e),this._isValidElement()||console.warn(`[ButtonLoadingIndicatorUtil] Parent element is not of type <button> or <a>. Given element: ${this.parent}`)}create(){if(!this._isValidElement()){console.warn(`[ButtonLoadingIndicatorUtil] Unable to create loading indicator. Parent element is not of type <button> or <a>. Given element: ${this.parent}`);return}if("inner"===this.position){let t=this.parent.getBoundingClientRect().width;this.parent.style.width=`${t}px`}super.create(),this.parent.classList.add(`is-loading-indicator-${this.position}`),this._isButtonElement()?this.parent.disabled=!0:this._isAnchorElement()&&this.parent.classList.add("disabled")}remove(){if(!this.exists()){console.warn(`[ButtonLoadingIndicatorUtil] Unable to remove loading indicator. No indicator present on given element: ${this.parent}`);return}"inner"===this.position&&(this.parent.style.width="auto"),super.remove(),this.parent.classList.remove(`is-loading-indicator-${this.position}`),this._isButtonElement()?this.parent.disabled=!1:this._isAnchorElement()&&this.parent.classList.remove("disabled")}_isValidElement(){return this._isButtonElement()||this._isAnchorElement()}_isButtonElement(){return this.parent?.tagName.toLowerCase()==="button"}_isAnchorElement(){return this.parent?.tagName.toLowerCase()==="a"}}},1088(t,e,i){i.d(e,{A:()=>r});class r{static serialize(t){let e=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if("FORM"!==t.nodeName){if(e)throw Error("The passed element is not a form!");return{}}return new FormData(t)}static serializeJson(t){let e=!(arguments.length>1)||void 0===arguments[1]||arguments[1],i=r.serialize(t,e);if(!(i instanceof FormData)&&0===Object.keys(i).length||i instanceof FormData&&0===Array.from(i.entries()).length)return{};let s={};for(let[t,e]of i.entries())s[t]=e;return s}}},2701(t,e,i){i.r(e),i.d(e,{default:()=>n});var r=i(4335),s=i(1088),o=i(44);class n extends r.A{static #t=this.options={redirectSelector:'[name="redirectTo"]',redirectParamSelector:'[data-redirect-parameters="true"]',redirectTo:"frontend.cart.offcanvas",alertTemplateSelector:".js-add-to-cart-alert-template",alertDismissDelay:3e3,stockAlertTemplateSelector:".js-quantity-stock-adjusted-template",stockAlertClass:"quantity-stock-adjusted-alert",stockAdjustedText:null,outOfStockText:null,buyButtonSelector:'button[type="submit"].btn-buy',loadingIndicatorPosition:"inner"};init(){if(this._getForm(),!this._form)throw Error(`No form found for the plugin: ${this.constructor.name}`);this._buyButtonLoader=null,this._prepareFormRedirect(),this._registerEvents()}_prepareFormRedirect(){try{let t=this._form.querySelector(this.options.redirectSelector),e=this._form.querySelector(this.options.redirectParamSelector);t.value=this.options.redirectTo,e.disabled=!0}catch(t){}}_getForm(){this.el&&"FORM"===this.el.nodeName?this._form=this.el:this._form=this.el.closest("form")}_registerEvents(){this.el.addEventListener("submit",this._formSubmit.bind(this)),this._form.addEventListener("removeLoader",this.removeLoadingIndicator.bind(this)),this._form.addEventListener("QuantitySelector/StockAdjusted",this._handleStockAdjusted.bind(this)),this._form.addEventListener("QuantitySelector/OutOfStock",this._handleOutOfStock.bind(this))}_formSubmit(t){t.preventDefault();let e=this._form.getAttribute("action"),i=s.A.serialize(this._form);this._createLoadingIndicator(),this.$emitter.publish("beforeFormSubmit",i),this._shouldOpenOffcanvas()?this._openOffCanvasCarts(e,i):this._addToCartWithoutOffcanvas(e,i)}_shouldOpenOffcanvas(){return"0"!==window.openOffcanvasAfterAddToCart}_addToCartWithoutOffcanvas(t,e){fetch(t,{method:"POST",body:e}).then(t=>{if(this.removeLoadingIndicator(),!t.ok)throw Error("Add to cart failed");window.PluginManager.getPluginInstances("CartWidget")?.forEach(t=>{t.fetch()}),this._showSuccessAlert(),this.$emitter.publish("addToCartWithoutOffcanvas")}).catch(()=>{this._openOffCanvasCarts(t,e)})}_showSuccessAlert(){let t=document.querySelector(this.options.alertTemplateSelector);if(!t||!this._form)return;let e=this._form.parentElement.querySelector(".add-to-cart-alert");e&&e.remove();let i=t.content.firstElementChild.cloneNode(!0);i.classList.add("show","add-to-cart-alert"),this._form.insertAdjacentElement("afterend",i),setTimeout(()=>{i.addEventListener("transitionend",()=>i.remove(),{once:!0}),i.classList.remove("show")},this.options.alertDismissDelay)}_openOffCanvasCarts(t,e){let i=window.PluginManager.getPluginInstances("OffCanvasCart");if(!i.length){this.removeLoadingIndicator();return}i.forEach(i=>
1{this._openOffCanvasCart(i,t,e)})}_openOffCanvasCart(t,e,i){t.openOffCanvas(e,i,()=>{this.removeLoadingIndicator(),this.$emitter.publish("openOffCanvasCart")})}_createLoadingIndicator(){let t=this._form.querySelector(this.options.buyButtonSelector);t&&(this._buyButtonLoader=new o.A(t,this.options.loadingIndicatorPosition),this._buyButtonLoader.create())}removeLoadingIndicator(){this._buyButtonLoader&&(this._buyButtonLoader.remove(),this._buyButtonLoader=null)}_handleStockAdjusted(t){let e=this.options.stockAdjustedText||"";e=e.replace("%quantity%",t.detail.quantity),this._showStockAlert(e)}_handleOutOfStock(){this._showStockAlert(this.options.outOfStockText||"");let t=this._form.querySelector(this.options.buyButtonSelector);t&&(t.disabled=!0)}_showStockAlert(t){let e=this._form.querySelector(this.options.stockAlertTemplateSelector);if(!e)return;let i=e.parentElement.querySelector(`.${this.options.stockAlertClass}`);i&&i.remove();let r=e.content.firstElementChild.cloneNode(!0);r.classList.add(this.options.stockAlertClass);let s=r.querySelector(".alert-content-container");s&&(s.textContent=t),e.insertAdjacentElement("afterend",r)}}},5683(t,e,i){i.d(e,{A:()=>o,c:()=>s});let r="loader",s={BEFORE:"before",AFTER:"after",INNER:"inner"};class o{constructor(t,e=s.BEFORE){this.parent=t instanceof Element?t:document.body.querySelector(t),this.position=e}create(){if(!this.exists()){if(this.position===s.INNER){this._previousHTML=this.parent.innerHTML,this.parent.innerHTML=o.getTemplate();return}this.parent.insertAdjacentHTML(this._getPosition(),o.getTemplate())}}remove(){if(this.position===s.INNER){this.parent.innerHTML=this._previousHTML;return}this.parent.querySelectorAll(`.${r}`).forEach(t=>t.remove())}exists(){return this.parent.querySelectorAll(`.${r}`).length>0}_getPosition(){return this.position===s.BEFORE?"afterbegin":"beforeend"}static getTemplate(){return`<div class="${r}" role="status"> 2 <span class="visually-hidden">Loading...</span> 3 </div>`}static SELECTOR_CLASS(){return r}}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.