1import{n as e}from"./CU89Zi3L.js";import{nt as t}from"./DGJ9b2SS.js";import{Nn as n,Pn as r,t as i}from"./T195IlIx.js";var a=e=>{let{props:t}=e,n=new i(t?.start,t?.count);return{params:{$pageIndex:n.pageIndex,$pageSize:n.pageSize,sportId:t.sport_id&&t.sport_id!=`0`?t.sport_id:void 0},paginationHandler:n}},o=class{fetch;resource=`/api/v2/shop`;constructor({fetch:e}){this.fetch=e}async get(e){let{params:t,paginationHandler:r}=a(e);return this.fetch(`${this.resource}/products`,{params:t,onResponse:({response:e})=>{e.status===204&&(e._data=null)}}).then(e=>{if(!e?.items?.length)return[];let t=e.items.map(e=>n(e));return t?.length?r.getData(t):[]}).catch(e=>(console.error(`[ShopRepo] get() Request Failed`,e),[]))}async getProducts(e){let t={productIds:e?.productIds?.length?e?.productIds.join(`,`):void 0,sportId:e?.sportId??void 0,$pageSize:e?.$pageSize??void 0};return this.fetch(`${this.resource}/products`,{params:t,onResponse:({response:e})=>{e.status===204&&(e._data=null)}}).then(e=>e?.items?.length?e.items.map(e=>r(e)):null).catch(e=>(console.error(`[ShopRepo] getProducts() Request Failed`,e),null))}async getProductById(e){return this.fetch(`${this.resource}/product/${e}`,{onResponse:({response:e})=>{e.status===204&&(e._data=null)}}).then(e=>e?r(e):null).catch(e=>(console.error(`[ShopRepo] getProductById() Request Failed`,e),null))}},s=e=>e?.productIds?.length?`__allProducts__${t(e.productIds?.join(`,`))}`:e?.sportId?`__allProducts__bySport_${t(e.sportId)}`:`__allProducts__`,c=e(`shop`,{state:()=>({shopProducts:{},isLoadingMore:{},isLoading:{},moreToLoad:{},products:{},individualProduct:{},isLoadingProducts:{},isLoadingIndividualProduct:{}}),actions:{async fetchShopProducts(e){let{fetch:t,...n}=e;if(!(e.hash in this.shopProducts)){this.isLoading[e.hash]=!0;let r=await new o({fetch:t}).get(n);this.shopProducts[e.hash]=r,this.isLoading[e.hash]=!1;let{props:i}=e;(!r||!r.length||i.count&&r.length<i.count)&&(this.moreToLoad[e.hash]=!1)}},async fetchMoreShopProducts(e){let{fetch:t,...n}=e;this.isLoadingMore[e.hash]=!0;let r=await new o({fetch:t}).get(n),{props:i}=e;(!r||!r.length||r.length&&i.count&&r.length<i.count)&&(this.moreToLoad[e.hash]=!1),r?.length&&this.shopProducts[e.hash]?.length&&(this.shopProducts[e.hash]=[...this.shopProducts[e.hash]??[],...r]),(!r||!r.length||i.count&&r.length<i.count)&&(this.moreToLoad[e.hash]=!1),this.isLoadingMore[e.hash]=!1},async fetchProducts({payload:e,fetch:t}){let n=s(e);if(!(n in this.products)){this.isLoadingProducts[n]=!0;let r=await new o({fetch:t}).getProducts(e);this.products[n]=r,this.isLoadingProducts[n]=!1}},async fetchProductById({productId:e,fetch:t}){if(!(e in this.individualProduct)){this.isLoadingIndividualProduct[e]=!0;let n=await new o({fetch:t}).getProductById(e);this.individualProduct[e]=n,this.isLoadingIndividualProduct[e]=!1}}},getters:{getShopProducts:e=>t=>t in e.shopProducts&&e.shopProducts[t]?.length?e.shopProducts[t]:[],getLoadingMoreFlag:e=>t=>t in e.isLoadingMore?e.isLoadingMore[t]??!1:!1,getLoadingFlag:e=>t=>t in e.isLoading?e.isLoading[t]??!1:!1,getMoreToLoad:e=>t=>t in e.moreToLoad?e.moreToLoad[t]??!0:!0,getProducts:e=>t=>{let n=s(t);return n in e.products&&e.products[n]?e.products[n]:null},getProductById:e=>t=>t in e.individualProduct&&e.individualProduct[t]?e.individualProduct[t]:null,getLoadingProductsFlag:e=>t=>{let n=s(t);return n in e.isLoadingProducts?e.isLoadingProducts[n]??!1:!1},getLoadingProductByIdFlag:e=>t=>t in e.isLoadingIndividualProduct?e.isLoadingIndividualProduct[t]??!1:!1}});export{c as t};
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.