1import{g as u}from"../../../../vendor/event-tag.js";function _(){const n={container:document.querySelector(".promotion-list-content"),filterForm:document.querySelector("#filter-form"),applyBtn:document.querySelector(".apply-filter-btn"),resetBtn:document.querySelector(".reset-filter-btn"),modalCloseBtn:document.querySelector("#modal-filter-form .modal-close"),inputFilter:document.querySelector(".input-filter"),iconWrapper:document.querySelector(".promotion-list-filter-input .icon"),appliedFiltersContainer:document.querySelector(".promotion-list-pill"),filterContainerMobile:document.querySelector("#filter-form .category-checkboxes-accordion"),filterContainerDesktop:document.querySelector("#filter-form .category-checkboxes")};if(!n.container)return;let a=window.matchMedia("(max-width: 1024px)").matches;const s=Array.from(n.container.querySelectorAll(".card-promo")),v=[...new Set(s.map(e=>e.dataset.category))].sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()));let p=[...s];const m={"new-to-old":{fn:(e,t)=>new Date(t.dataset.startDate)-new Date(e.dataset.startDate),label:"Newest to oldest"},"old-to-new":{fn:(e,t)=>new Date(e.dataset.startDate)-new Date(t.dataset.startDate),label:"Oldest to newest"},"ending-soon":{fn:(e,t)=>new Date(e.dataset.endDate)-new Date(t.dataset.endDate),label:"Ending soon"}};F(),L(),f(),d(),c();function d(){const e=new FormData(n.filterForm),t=e.getAll("categories"),o=e.get("sortBy")||"new-to-old";p=t.length===0?[...s]:s.filter(l=>t.includes(l.dataset.category)),p.sort(m[o].fn),w(t,o),k(),c()}function w(e,t){const o=[{type:"sort",value:t,label:m[t].label},...e.map(r=>({type:"category",value:r,label:r}))],l=o.length===1&&o[0].value==="new-to-old";n.inputFilter.value=l?a?"All filters":"":a?`All filters (${o.length})`:o.map(r=>r.label).join(", "),n.iconWrapper.classList.toggle("active",!l),C(o,l)}function C(e,t){if(n.appliedFiltersContainer.classList.toggle("d-none",t),t)return;const o=e.filter(l=>l.label!=="Newest to oldest");n.appliedFiltersContainer.innerHTML=o.slice(0,3).map((l,r)=>{const i=r<2?`<div class='pill-label'>${l.label}</div><i class='cursor-pointer income-icons-xmark pill-action-delete'></i>`:`<div class='pill-label'>${o.length-2} more</div>`;return`<div class="pill" data-filter-type="${l.type}" data-filter-value="${l.value}">${i}</div>`}).join("")+'<a class="btn btn-link btn-small">Clear all</a>',n.appliedFiltersContainer.querySelectorAll(".pill").forEach(l=>{l.addEventListener("click",r=>{n.inputFilter.click()})}),n.appliedFiltersContainer.querySelectorAll(".pill-action-delete").forEach(l=>{l.addEventListener("click",r=>{var h,b;r.stopPropagation(),r.preventDefault();const i=l.closest(".pill");
1S(i.dataset.filterType,i.dataset.filterValue);const D=((b=(h=i==null?void 0:i.querySelector(".pill-label"))==null?void 0:h.innerText)==null?void 0:b.trim())??"",y={...u(),click_text:`Close Icon-${D}`,user_action:"Select",current_section:"Featured deals",target_url:"",event_type:"Engagement"};window.dataLayer.push(y),console.log(y)})}),n.appliedFiltersContainer.querySelector(".btn").addEventListener("click",l=>{l.preventDefault(),g();const r={...u(),click_text:"Clear all",user_action:"Select",current_section:"Featured deals",target_url:"",event_type:"Engagement"};window.dataLayer.push(r),console.log(r)})}function c(){const e=new FormData(n.filterForm),t=e.getAll("categories"),o=e.get("sortBy")||"new-to-old";a=window.matchMedia("(max-width: 1024px)").matches;const l=o==="new-to-old"&&t.length===0;n.inputFilter.value=l?a?"All filters":"":a?`All filters (${t.length})`:t.join(", "),n.applyBtn.classList.toggle("disabled",l),n.resetBtn.classList.toggle("disabled",l)}function k(){n.container.innerHTML="",p.forEach(e=>n.container.appendChild(e))}function F(){const e=t=>v.map((o,l)=>` 2 <div class="form-check"> 3 <input type="checkbox" class="form-check-input" value="${o}" 4 name="categories" id="category_${l+1}_${t}"> 5 <label class="form-check-label font-body" for="category_${l+1}_${t}">${o}</label> 6 </div> 7 `).join("");n.filterContainerDesktop.innerHTML=e("desktop"),n.filterContainerMobile.innerHTML=e("mobile"),n.filterContainerDesktop.querySelectorAll('input[name="categories"]').forEach(t=>{t.addEventListener("change",()=>{var l;c();const o={...u(),click_text:t.value,user_action:`Checkbox-${t.checked?"Checked":"Unchecked"}`,current_section:"Featured deals-Product Category-Filter Popup",target_url:"",event_type:"Engagement"};(l=window.dataLayer)==null||l.push(o),console.log(o)})}),n.filterContainerMobile.querySelectorAll('input[name="categories"]').forEach(t=>{t.addEventListener("change",()=>{var l,r;c(),(l=t.closest(".form-check").querySelector("label"))!=null&&l.innerText;const o={...u(),click_text:t.value,user_action:`Checkbox-${t.checked?"Checked":"Unchecked"}`,current_section:"Featured deals-Product Category-Filter Popup",target_url:"",event_type:"Engagement"};(r=window.dataLayer)==null||r.push(o),console.log(o)})})}function g(){n.filterForm.querySelectorAll('input[name="categories"]').forEach(e=>e.checked=!1),f(),d()}function f(){document.querySelector(`.sortby-${a?"mobile":"desktop"} #new-to-old-${a?"mobile":"desktop"}`).checked=!0}function S(e,t){if(e==="sort")f();else if(e==="category"){const o=Array.from(n.filterForm.querySelectorAll('input[name="categories"]')).find(l=>l.value===t);o&&(o.checked=!1)}d()}function L(){n.applyBtn.addEventListener("click",e=>{e.preventDefault(),d(),n.modalCloseBtn.click(),n.inputFilter.setSelectionRange(0,0),n.inputFilter.focus()}),n.resetBtn.addEventListener("click",e=>{e.preventDefault(),g(),n.modalCloseBtn.click()}),document.querySelectorAll('input[name="sortBy"]').forEach(e=>{e.addEventListener("change",c)}),window.addEventListener("resize",c)}}document.addEventListener("DOMContentLoaded",_);
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.