1"use strict";(self.webpackChunk_mvps_genesis_quickstart_theme=self.webpackChunk_mvps_genesis_quickstart_theme||[]).push([[8306],{8306:(t,e,s)=>{s.d(e,{AjaxAddToWishlist:()=>c,AjaxInsertWishlist:()=>m,WishlistDialog:()=>h});var i=s(1171),n=s(1559),a=s(4191);class o{#t;actionInput;loadingUI;messageContainer;messageOptions;constructor(){let{actionInput:t,loadingElement:e,loadingOverlayElement:s,messageElement:i,messageOptions:o}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.#t=new n.A(this),this.actionInput=this.#t.isObject("actionInput",t),this.#t.isString("actionInput.name",this.actionInput.name),this.#t.isString("actionInput.value",this.actionInput.value),this.messageContainer=new a.MessageContainer({container:this.#t.isElement("messageElement",i)}),this.messageOptions=this.#t.isObject("messageOptions",o),this.#t.isObject("messageOptions.error",o.error),this.#t.isObject("messageOptions.success",o.success),this.setLoadingUI(e,s)}setLoadingUI(t,e){const s=this.#t.isElement("setLoadingUI.loadingElement",t,{required:!1});if(!s)return;const n=this.#t.isElement("setLoadingUI.overlayElement",e,{required:!1});this.loadingUI=new i.default(s,{overlayElement:n??!1})}createMessage(t,e){this.messageContainer.add(new a.Message(t,e))}getValidator(){return this.#t}}var l=s(2236),r=s(7889);class c extends o{#t;formElement;actionsContainerElement;actionElements;actionAttributes;actionUrl;constructor(t){let{actionElementClass:e="js-add-to-wishlist",actionInput:s={name:"Action",value:"ATWL"},actionsContainerElement:i=".g-add-to-wishlist-dialog__wishlists",loadingElement:n="#js-loading-container",loadingOverlayElement:a="#js-wishlist-container",messageElement:o="#js-add-to-wishlist-message",messageOptions:l={error:{dynamic:!0,message:"Unable to add to list <strong>%wishlistTitle%</strong>.",options:{autohide:!1,type:"error"},selector:".g-messages--error"},success:{message:"Successfully added to list <strong>%wishlistTitle%</strong>.",options:{autohide:!1,type:"success"},selector:".g-messages--success"}},wishlistIdAttribute:r="data-wishlist-id",wishlistListsAttribute:c="data-wishlist-lists",wishlistTitleAttribute:m="data-wishlist-title",wishlistUrlAttribute:d="data-wishlist-url"}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super({actionInput:s,loadingElement:n,loadingOverlayElement:a,messageElement:o,messageOptions:l}),this.#t=this.getValidator(),this.formElement=this.#t.isElement("formElement",t),this.actionsContainerElement=this.#t.isElement("actionsContainerElement",i),this.actionAttributes={actionElementClass:this.#t.isString("actionElementClass",e),wishlistIdAttribute:this.#t.isString("wishlistIdAttribute",r),wishlistListsAttribute:this.#t.isString("wishlistListsAttribute",c),wishlistTitleAttribute:this.#t.isString("wishlistTitleAttribute",m),wishlistUrlAttribute:this.#t.isString("wishlistUrlAttribute",d)},this.actionUrl=this.#t.isUrl("actionUrl",this.formElement.getAttribute(this.actionAttributes.wishlistUrlAttribute)||this.formElement.action),this.createActionElements(),this.actionElements=this.#t.isElementList("actionElements",this.actionsContainerElement.getElementsByClassName(this.actionAttributes.actionElementClass)),this.bindEvents()}bindEvents(){for(const t of this.actionElements)this.bindActionElementEvents(t)}bindActionElementEvents(t){t.addEventListener("click",this.onActionElementClick.bind(this))}createActionElements(){const t=this.actionsContainerElement.getAttribute(this.actionAttributes.wishlistListsAttribute);if(!t)return;const e=JSON.parse((0,l.A)(t));if(!e)throw new TypeError(`${this.constructor.name} :: Invalid ${this.actionAttributes.wishlistListsAttribute} attribute value provided`);let s=document.createDocumentFragment();e.forEach((t=>{s.appendChild(this.createActionHtmlElement(t))})),this.appendActionElement(s)}createActionElement(t){const e=this.createActionHtmlElement(t);return this.bindActionElementEvents(e),e}createActionHtmlElement(t){const e=document.createElement("button");e.classList.add(this.actionAttributes.actionElementClass,"g-add-to-wishlist-dialog__wishlist","g-button--no-styling"),e.setAttribute(this.actionAttributes.wishlistIdAttribute,t.id),e.setAttribute(this.actionAttributes.wishlistTitleAttribute,t.title);const s=document.createElement("span");
1s.classList.add("g-add-to-wishlist-dialog__wishlist-title"),s.textContent=t.title;const i=document.createElement("span");i.classList.add("g-add-to-wishlist-dialog__wishlist-action");const n=document.createElement("span");n.classList.add("g-add-to-wishlist-dialog__wishlist-action-icon","u-icon-add-circle"),n.setAttribute("aria-hidden","true");const a=document.createElement("span");return a.classList.add("u-hide-visually"),a.textContent=`Add this product to list ${t.title}.`,i.appendChild(n),i.appendChild(a),e.appendChild(s),e.appendChild(i),e}appendActionElement(t){this.actionsContainerElement.appendChild(t)}async onActionElementClick(t){const e=t.currentTarget,s=e.getAttribute(this.actionAttributes.wishlistIdAttribute),i=e.getAttribute(this.actionAttributes.wishlistTitleAttribute);if(!s||!i)return;t.preventDefault();const n=new FormData(this.formElement);n.set(this.actionInput.name,this.actionInput.value),n.set("WishList_ID",s);const a=new Request(this.actionUrl,{body:n,method:this.formElement.method||"POST"});let o={data:{},form:this.formElement,formData:n,message:"",request:a,success:!1};e.disabled=!0,this.messageContainer.clear(),this.loadingUI&&this.loadingUI.show();const l=await fetch(a);if(l.ok){const t=await l.text(),e=(new DOMParser).parseFromString(t,"text/html"),s=l.headers.get("g-mm-page-code");switch(o.data=e,s){case"PROD":this.onMissingAttributes(e,i);break;case"WISH":{const t=e.querySelector(this.messageOptions.error.selector);t?this.onFail(e,i,t):(this.onSuccess(e,i),o.success=!0);break}default:this.onFail(e,i)}o.message=this.messageContainer.currentMessage.message}else this.onFail({},i),o.message=`${this.constructor.name} - The request failed with a status of: ${l.status}`;e.disabled=!1,this.loadingUI&&this.loadingUI.hide(),r.default.dispatchEvent("MVPS:addToWishlist",o)}onMissingAttributes(t,e){const s=[],i=this.formElement.querySelectorAll(".g-product-layout-purchase__options .is-required");for(let t=0,e=i.length;t<e;t++)s.push((i[t].title?i[t].title:i[t].textContent).replace(/:$/,""));const n=document.createElement("div");n.innerHTML='All <strong>Required</strong> options have not been selected.<br>Please review the following options: <strong class="u-color-error">%missingAttributes%</strong>'.replace("%missingAttributes%",s.join(", ")),this.onFail(t,e,n)}onSuccess(t,e){this.createMessage(this.messageOptions.success.message.replace("%wishlistTitle%",e),this.messageOptions.success.options)}onFail(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=null,n=this.messageOptions.error.message.replace("%wishlistTitle%",e);s instanceof HTMLElement?i=s:this.messageOptions.error.dynamic&&(i=t.querySelector(this.messageOptions.error.selector)??null),i&&(n=i.innerHTML),this.createMessage(n,this.messageOptions.error.options)}}class m extends o{#t;formElement;submitElement;constructor(t){let{actionInput:e={name:"Action",value:"IWSH"},loadingElement:s="#js-loading-container",loadingOverlayElement:i="#js-wishlist-container",messageElement:n="#js-create-wishlist-message",messageOptions:a={error:{dynamic:!0,message:"Unable to create list <strong>%wishlistTitle%</strong>.",options:{autohide:!1,type:"error"},selector:".g-messages--error"},success:{message:"Successfully created list <strong>%wishlistTitle%</strong>.",options:{autohide:!1,type:"success"},selector:".g-messages--success"}},submitElement:o='[type="submit"]'}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super({actionInput:e,loadingElement:s,loadingOverlayElement:i,messageElement:n,messageOptions:a}),this.#t=this.getValidator(),this.formElement=this.#t.isElement("formElement",t),this.submitElement=this.#t.isElement("submitElement",o,{container:this.formElement}),this.bindEvents()}bindEvents(){this.formElement.addEventListener("submit",this.onSubmit.bind(this))}async onSubmit(t){t.preventDefault();const e=new FormData(this.formElement),s=e.get("WishList_Title");e.set(this.actionInput.name,this.actionInput.value);const i=new Request(this.formElement.action,{body:e,method:this.formElement.method||"POST"});let n={data:{},form:this.formElement,formData:e,message:"",request:i,success:!1};this.submitElement.disabled=!0,this.messageContainer.clear(),this.loadingUI&&this.loadingUI.show();const a=await fetch(i);if(a.ok){const t=a.headers.get("g-mm-page-code"),e=await a.json();if(n.data=e,"WISH"===t)n.data.wishlist?.id?(this.onSuccess(e,s),n.success=!0):this.onFail(e,s);else this.onFail(e,s);n.message=this.messageContainer.currentMessage.message}else this.onFail({},s),n.message=`${this.constructor.name} - The request failed with a status of: ${a.status}`;this.submitElement.disabled=!1,this.loadingUI&&this.loadingUI.hide(),r.default.dispatchEvent("MVPS:insertWishlist",n)}onSuccess(t,e){this.createMessage(this.messageOptions.success.message.replace("%wishlistTitle%",e),this.messageOptions.success.options)}onFail(t,e){let s=this.messageOptions.error.message.replace("%wishlistTitle%",e);if(this.messageOptions.error.dynamic&&t.messages?.error_message_count&&t.templates?.messages){const e=(new DOMParser).parseFromString(t.templates.messages,"text/html").querySelector(this.messageOptions.error.selector);e&&(s=e.innerHTML)}this.createMessage(s,this.messageOptions.error.options)}}var d=s(1821);class h{#t;dialogElement;dialogContainerElement;controlElement;toggle;showDialogParameter;
1constructor(t,e){let{dialogContainerElement:s=".g-add-to-wishlist-dialog__container",dialogScrollEnabled:i=!0,dialogScrollIntoView:a={behavior:"smooth",block:"center"},toggleEnabled:o=!0,toggleOpenClass:l="g-add-to-wishlist-dialog__toggle--open",togglePrimaryControlElementId:r="js-wishlists-primary-toggle-control",toggleSecondaryControlElementId:c="js-wishlists-secondary-toggle-control",showDialogParameter:m="show_wishlist"}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.#t=new n.A(this),this.dialogElement=this.#t.isElement("dialogElement",t),this.dialogContainerElement=this.#t.isElement("dialogContainerElement",s,{container:this.dialogElement}),this.controlElement=this.#t.isElement("controlElement",e),this.toggle={enabled:this.#t.isBoolean("toggleEnabled",o)},this.toggle.enabled&&(this.toggle.elements={primary:{controlElement:this.#t.isElement("togglePrimaryControlElementId",document.getElementById(r))},secondary:{controlElement:this.#t.isElement("toggleSecondaryControlElementId",document.getElementById(c))}},this.toggle.elements.primary.element=this.#t.isElement("toggle.elements.primary.element",document.getElementById(this.toggle.elements.primary.controlElement.getAttribute("aria-controls"))),this.toggle.elements.secondary.element=this.#t.isElement("toggle.elements.secondary.element",document.getElementById(this.toggle.elements.secondary.controlElement.getAttribute("aria-controls"))),this.toggle.openClass=this.#t.isString("toggleOpenClass",l)),this.showDialogParameter=this.#t.isString("showDialogParameter",m),this.#t.isBoolean("dialogScrollEnabled",i),this.init(!1!==i&&this.#t.isObject("dialogScrollIntoView",a))}init(t){this.bindEvents(),new URLSearchParams(window.location.search).has(this.showDialogParameter)&&(this.controlElement.click(),"object"==typeof t&&this.dialogElement.scrollIntoView(t))}bindEvents(){this.bindControlElementEvents(),this.toggle.enabled&&this.bindToggleEvents()}bindControlElementEvents(){this.controlElement.addEventListener("click",(t=>{t.preventDefault(),"true"===this.controlElement.getAttribute("aria-expanded")?d.A.close(this.dialogElement.id):d.A.show(this.dialogElement.id,{onClose:()=>{this.controlElement.setAttribute("aria-expanded","false")},onShow:()=>{this.controlElement.setAttribute("aria-expanded","true")}})})),this.dialogElement.classList.contains("has-overlay")||document.addEventListener("mousedown",(t=>{t.stopPropagation(),"false"!==this.controlElement.getAttribute("aria-expanded")&&(this.controlElement===t.target||this.controlElement.contains(t.target)||this.dialogContainerElement===t.target||this.dialogContainerElement.contains(t.target)||this.controlElement.click())}))}bindToggleEvents(){this.toggle.elements.primary.controlElement.addEventListener("click",(t=>{t.preventDefault(),this.toggleElements(this.toggle.elements.primary,this.toggle.elements.secondary)})),this.toggle.elements.secondary.controlElement.addEventListener("click",(t=>{t.preventDefault(),this.toggleElements(this.toggle.elements.secondary,this.toggle.elements.primary)}))}toggleElements(t,e){e.element.classList.remove(this.toggle.openClass),e.controlElement.setAttribute("aria-expanded","false"),e.controlElement.classList.remove("u-hidden"),e.controlElement.focus(),t.controlElement.classList.add("u-hidden"),t.controlElement.setAttribute("aria-expanded","true"),t.element.classList.add(this.toggle.openClass)}}}}]); 2//# sourceMappingURL=8306.e9e55ff3c098dd6c4742.chunk.js.map
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.