1import{G as se,r as n,j as t}from"./vendors.BAJps33Q.chunk.js";import{o as E,aT as oe,n as re,hj as ne,aY as ce,X as ie,aF as le,d as $,ai as F,f as de,CZ as me,al as l,P as e,ky as pe,b6 as P,eV as ue,bx as D,bB as ge,gu as fe,gw as xe,gs as he,mv as ye,BH as be,gx as j,BI as Ce,wq as _e,jZ as $e,mw as Pe,A as je}from"./main.BhSogTmc.js";import{a as Se,f as ve,b as ke,d as O}from"./digitalFlyer.slice.BPSWRkew.chunk.js";import{P as H}from"./ProductCardCarousel.B50JU-Z8.chunk.js";import{a as we,i as Ne}from"./ProductCardCarousel.constant.DlKPNaO8.chunk.js";const Le=V=>{const{showComponent:B,bgColor:M,title:x,thumbnailAltText:S,thumbnail:v,ctaLabel:h,ctaLinkTarget:k,ctaLink:w,maximumNumberOfProductsPCMobile:G,maximumNumberOfProductsPCTablet:R,maximumNumberOfProductsPCDesktop:X}=V,{isFetching:N,categories:r,isProductFetching:m,productList:s}=se(Se),c=E(oe),d=re(),[W,L]=n.useState(),[p]=n.useState(window.innerWidth>=ne.desktopMinWidth),[y,u]=n.useState(""),[o,b]=n.useState(""),z=ce(),C=l.eventParameters?.location?.digitalFlyerPromo.trim().toLowerCase(),{general:Y={},categoryImages:Z={}}=E(ie),{placeHolderImg:q}=Y;le(C,s?.[o]?.products,l.eventParameters?.location?.digitalFlyerPromo,l.eventParameters?.labels?.dfpAddToCart);const g=!!(o&&$(s[o]));n.useEffect(()=>{F(m,g)&&d(ve({productList:s[o].products,storeId:c,selectedCategoryId:o}))},[s,N,m,g,d,o,c]),n.useEffect(()=>{c&&d(ke(c))},[d,c]);const _=n.useCallback(a=>{L&&L(a);const i=r.find(f=>f.name===a)?.code;i&&!$(s[i])&&(u(a),b(i),d(O({storeId:c,categoryId:i})))},[r,d,s,c]);n.useEffect(()=>{de(r)&&(p?(_(r[0].name),u(r[0].name)):(b(r[0].code),u(r[0].name)))},[r,p,_]),n.useEffect(()=>{!p&&c&&o&&!$(s[o])&&d(O({storeId:c,categoryId:o}))},[d,p,s,y,o,c]);const T=n.useCallback(a=>s[a]?.products.map(i=>me(i,y,!1)),[s,y]);n.useEffect(()=>{F(!m,g)&&(window.analyticsLayer=window.analyticsLayer||[],window?.analyticsLayer?.push({event:l.event.viewItemList,promotion:{promotion_name:l.promotion.digitalFlyerPromo},ecommerce:{products:T(o)}}))},[s,m,g,T,o]);const A=(a,i,f)=>{const ae=I=>{I.currentTarget.onerror=null,I.currentTarget.src=Z.categoryImageDetails.find(te=>te.code===f)?.image||""};return t.jsxs(t.Fragment,{children:[t.jsx("img",{className:`${e}-dfp__content-image`,src:a||"",alt:"",onError:ae}),t.jsx("span",{id:f,className:`${e}-dfp__content-text ${e}-md-align-items-center`,children:i})]})},K=(a,i)=>{u(a),b(i)},J=()=>t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`${e}-md-flex ${e}-md-align-items-center ${e}-dfp__header-title`,children:[t.jsx("img",{className:`${e}-dfp__image`,src:v,alt:S}),t.jsx(D,{variant:"h2",componentClass:`${e}-dfp__heading`,children:x})]}),t.jsx(ge,{stringContent:w,children:a=>t.jsx("a",{href:a,className:`${e}-button2 ${e}-button2--primary ${e}-button2--primary-light ${e}-button2--mini ${e}-dfp__header-cta-link`,target:k,"dap-wac-link":!0,"dap-wac-loc":l.promotion.digitalFlyerPromo,"dap-wac-value":h,children:h})})]}),Q=()=>t.jsx(fe,{customClass:`${e}-dfp__header-mcta-link`,variant:he.TERTIARY,color:xe.LIGHT,icon:{size:"lg",type:"ct-chevron-right"},a11y:{label:x},onClick:()=>{window.open(w,k)},"dap-wac-value":h,"dap-wac-link-section":l.promotion.digitalFlyerPromo,children:t.jsxs("div",{className:`${e}-xs-flex ${e}-xs-align-items-center ${e}-dfp__header-title`,children:[t.jsx("img",{className:`${e}-dfp__image`,src:v,alt:S}),t.jsx(D,{variant:"h2",componentClass:`${e}-dfp__heading`,children:x})]})}),U=()=>t.jsx("div",{className:`${e}-dfp__content`,children:t.jsx(ye,{tabCallback:a=>{_(a)},selected:W,style:{direction:$e.VERTICAL,position:_e.LEFT,color:Ce.LIGHT,tabGap:j.XS,tabsGap:j.XS,tabContentGap:j.SMALL,variant:be.SHADOW_BOX},children:r.map(a=>t.jsx(Pe,{label:A(a.image,a.name,a.code),"dap-wac-link-section":l.eventParameters.location.categorySection,"dap-wac-value":a.name,children:t.jsxs("div",{className:`${e}-md-flex ${e}-md-column ${e}-dfp__product`,children:[t.jsx("div",{className:`${e}-dfp__product-header`,children:a.name}),m?t.jsx(P,{skeletonClass:`${e}-dfp__product-skeleton`}):t.jsx(H,{productList:s[a.code]?.products||[],maximumNumberOfProducts:X,categoryName:a.name,addToCartSource:C})]})},a.id))})}),ee=()=>t.jsx("div",{className:`${e}-xs-flex ${e}-xs-column ${e}-dfp__mobile-content`,children:r.map(a=>t.jsx(je,{isHeaderOpen:o===a.code,title:A(a.image,a.name,a.code),collapseControl:()=>K(a.name,a.code),isChevronIcon:!0,analyticsSection:l.eventParameters.location.categorySection,analyticsValue:a.name,children:t.jsx("div",{className:`${e}-xs-flex ${e}-xs-column ${e}-dfp__product`,children:m?t.jsx(P,{skeletonClass:`${e}-dfp__product-skeleton`}):t.jsx(H,{productList:s[a.code]?.products||[],maximumNumberOfProducts:z?G:R,categoryName:a.name,addToCartSource:C})})},a.id))});return N?t.jsxs(t.Fragment,{children:[t.jsx("img",{className:`${e}-product-card__placeholder-image`,alt:we,...pe(q,Ne,!1)}),t.jsx(P,{skeletonClass:`${e}-dfp__skeleton`})]}):!B||ue(r)?null:t.jsxs("div",{className:`${e}-md-flex ${e}-md-column ${e}-md-justify-start ${e}-dfp`,style:{backgroundColor:`${M}`},children:[t.jsx("div",{className:`${e}-md-flex ${e}-md-justify-space-between ${e}-dfp__header`,children:p?J():Q()}),p?U():ee()]})},De={DigitalFlyerPromo:Le};export{De as default}; 2//# sourceMappingURL=digitalFlyerPromo.jq-F1NJg.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.