document.addEventListener("DOMContentLoaded",function(){const modals={};Array.from(document.getElementsByClassName("ac-modal")).forEach(modalElement=>{const modal=modalElement,modalId=modalElement.getAttribute("id");modals[modalId]=modal}),Array.from(document.querySelectorAll(".ac-modal-trigger[data-ajax-url], .ac-modal-trigger[data-modal-target]")).forEach(trigger=>{const targetModalId=trigger.getAttribute("data-modal-target"),modal=modals[targetModalId];modal&&(trigger.addEventListener("click",()=>{onModalTriggerClick(trigger,modal)}),onModalClose(trigger,modal))})});async function onModalTriggerClick(trigger,modal){if(!trigger||!modal||trigger.dataset.ajaxLoaded)return;const{ajaxUrl,ajaxIframe,customCompare}=trigger.dataset;if(!ajaxUrl)return;toggleLoadingState(modal,!0);const html=await fetch(ajaxUrl).then(response=>response.text()).then(html2=>html2).catch(error=>{console.error(error)});if(html){if(ajaxIframe){const iframe=document.createElement("iframe");iframe.style.width="100%",iframe.style.height="100%",iframe.style.border="none",modal.appendChild(iframe),openLinkInNewTab(iframe),iframe.srcdoc=html}else(SDG?.Data?.template||"")?.includes("collection.plp")&&customCompare&&modal&&setTimeout(()=>{var $scripts=modal.querySelectorAll("script")||[];$scripts?.length>0&&$scripts.forEach(script=>{if(script.textContent.includes("channelCompare")){let scriptContent=script.textContent.replace(/const reorderDOM/g,"var reorderDOM");const $compareHeader=modal.querySelectorAll("#interactive-compare-header"),newScript=document.createElement("script");newScript.textContent=scriptContent,modal.appendChild(newScript),$compareHeader&&typeof channelCompare<"u"&&channelCompare?.init&&channelCompare.init()}})},500),modal.innerHTML=html;trigger.dataset.ajaxLoaded=!0,toggleLoadingState(modal,!1)}}function openLinkInNewTab(iframe){iframe.onload=function(){for(var iframeDocument=iframe.contentWindow.document,links=iframeDocument.querySelectorAll("a"),i=0;i<links.length;i++)links[i].getAttribute("target")||links[i].setAttribute("target","_parent"),links[i].addEventListener("click",function(event){event.preventDefault();var href=this.getAttribute("href");href&&window.open(href,"_parent")});setTimeout(()=>{window.adobeTrackMarketingPageIframeCtaClick(iframe),window.adobeTrackMarketingPageIframeScroll(iframe)},10)}}function toggleLoadingState($modal,isLoading){const $modalSpinnerParent=$modal.querySelector(".ac-progress-indicator")?.parentNode;isLoading?$modal.classList.add("is-loading"):($modal.classList.remove("is-loading"),$modalSpinnerParent&&$modal.removeChild($modalSpinnerParent))}function onModalClose($trigger,$modal){const observer=new MutationObserver(mutations=>{mutations.forEach(mutation=>{if(mutation.attributeName=="class"&&!mutation.target.classList.contains("modal-open")){const{ajaxUrl}=$trigger.dataset;if(ajaxUrl)setTimeout(()=>{const $modalContent=mutation.target.querySelector(".ac-modal");$modalContent.innerHTML=`
                    <div class="seedkit-component-standalone">
                      <div class="ac-progress-indicator">
                        <div data-progress-indicator="" class="progress-indicator progress-indicator-indeterminate progress-indicator-immediate progress-indicator-curtain progress-indicator-visible">
                          <svg class="progress-indicator-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 56 56" aria-hidden="true">
                              <g class="progress-indicator-spokes">
                                  <path class="progress-indicator-spoke" d="M28,8.5A2.5,2.5,0,0,1,30.5,11v7a2.5,2.5,0,0,1-5,0V11A2.5,2.5,0,0,1,28,8.5Z"></path>
                                  <path class="progress-indicator-spoke" d="M41.79,14.21a2.52,2.52,0,0,1,0,3.54L36.84,22.7a2.5,2.5,0,0,1-3.54-3.54l5-4.95A2.52,2.52,0,0,1,41.79,14.21Z"></path>
                                  <path class="progress-indicator-spoke" d="M47.5,28A2.5,2.5,0,0,1,45,30.5H38a2.5,2.5,0,0,1,0-5h7A2.5,2.5,0,0,1,47.5,28Z"></path>
                                  <path class="progress-indicator-spoke" d="M41.79,41.79a2.52,2.52,0,0,1-3.54,0l-5-4.95a2.5,2.5,0,0,1,3.54-3.54l4.95,5A2.52,2.52,0,0,1,41.79,41.79Z"></path>
                                  <path class="progress-indicator-spoke" d="M28,47.5A2.5,2.5,0,0,1,25.5,45V38a2.5,2.5,0,0,1,5,0v7A2.5,2.5,0,0,1,28,47.5Z"></path>
                                  <path class="progress-indicator-spoke" d="M14.21,41.79a2.52,2.52,0,0,1,0-3.54l4.95-5a2.5,2.5,0,0,1,3.54,3.54l-4.95,4.95A2.52,2.52,0,0,1,14.21,41.79Z"></path>
                                  <path class="progress-indicator-spoke" d="M8.5,28A2.5,2.5,0,0,1,11,25.5h7a2.5,2.5,0,0,1,0,5H11A2.5,2.5,0,0,1,8.5,28Z"></path>
                                  <path class="progress-indicator-spoke" d="M14.21,14.21a2.52,2.52,0,0,1,3.54,0l4.95,4.95a2.5,2.5,0,0,1-3.54,3.54l-4.95-4.95A2.52,2.52,0,0,1,14.21,14.21Z"></path>
                              </g>
                          </svg>
                        </div>
                      </div>
                    </div>
                  `,$trigger.removeAttribute("data-ajax-loaded")},500);else{const $video=mutation.target.querySelector("video");$video&&($video.pause(),$video.currentTime=0)}}})}),$modalRoot=$modal.closest(".modal");$modalRoot&&observer.observe($modalRoot,{attributes:!0})}
//# sourceMappingURL=/cdn/shop/t/14/assets/ac-modal-custom.js.map?v=65753906577603767491742784888
