Build 574548stable
Module 821925
2,223 characters · in b8e8f8808c8513d8.jsDependencies
Source Raw
function(e,t,r){r.d(t,{A:()=>a}),r(321073);var n=r(17928),l=r(228366);let i={},s={};class o extends n.Ay.Store{static displayName="StorefrontProductStore";getFetchState(e){return null!=e?i[e]?.state:void 0}getFetchStateForSku(e){return null!=e?s[e]?.state:void 0}getFetchedAt(e){return null!=e?i[e]?.fetchedAt:void 0}getFetchedAtForSku(e){return null!=e?s[e]?.fetchedAt:void 0}getFetchError(e){return null!=e?i[e]?.fetchError:void 0}getFetchErrorForSku(e){return null!=e?s[e]?.fetchError:void 0}getProduct(e){let t=null!=e?i[e]:null;return null==t||t?.state==="error"||null==t.product?null:t.product}getProductsForSku(e){return null!=e?s[e]?.products:void 0}}let a=new o(l.h,{STOREFRONT_PRODUCTS_WITH_SKUS_FETCH:function(e){let{productIds:t}=e;t.forEach(e=>{i[e]={state:"loading",product:i[e]?.product}})},STOREFRONT_PRODUCTS_WITH_SKUS_FETCH_SUCCESS:function(e){let{productIds:t,products:r}=e,n=Date.now(),l=new Set;r.forEach(e=>{l.add(e.id),i[e.id]={state:"success",product:e,fetchedAt:n}}),t.forEach(e=>{l.has(e)||delete i[e]})},STOREFRONT_PRODUCTS_WITH_SKUS_FETCH_FAILURE:function(e){let{productIds:t,apiError:r}=e,n=Date.now();t.forEach(e=>{i[e]={state:"error",fetchedAt:n,fetchError:r}})},STOREFRONT_PRODUCTS_BY_SKU_IDS_FETCH:function(e){let{skuIds:t}=e;t.forEach(e=>{s[e]={state:"loading",products:s[e]?.products}})},STOREFRONT_PRODUCTS_BY_SKU_IDS_FETCH_SUCCESS:function(e){let{skuIds:t,products:r}=e,n=Date.now(),l=r.reduce((e,t)=>(t.skuIds.forEach(r=>{null==e[r]?e[r]=[t]:e[r].push(t)}),e),{});t.forEach(e=>{null==l[e]?delete s[e]:s[e]={state:"success",products:l[e],fetchedAt:n}}),r.forEach(e=>{i[e.id]={state:"success",product:e,fetchedAt:n}})},STOREFRONT_PRODUCTS_BY_SKU_IDS_FETCH_FAILURE:function(e){let{skuIds:t,apiError:r}=e,n=Date.now();t.forEach(e=>{s[e]={state:"error",fetchedAt:n,fetchError:r}})},STOREFRONT_COLLECTIONS_WITH_PRODUCTS_FETCH_SUCCESS:function(e){let{collections:t}=e,r=Date.now();t.forEach(e=>{e.products.forEach(e=>{i[e.id]={state:"success",product:e,fetchedAt:r}})})},STOREFRONT_COLLECTIONS_FOR_APPLICATION_FETCH_SUCCESS:function(e){let{collections:t}=e,r=Date.now();t.forEach(e=>{e.products.forEach(e=>{i[e.id]={state:"success",product:e,fetchedAt:r}})})},LOGOUT:function(e){i={},s={}}})}