import{c as h,s as n,l as r,S as C}from"./index-VDTWCae_.chunk.mjs";import{d as F,t as s}from"./dav-D-0Zsvk_.chunk.mjs";import{a as g,b as f}from"./collectionFetcher-BH3RSWlN.chunk.mjs";import{A as d}from"./AbortControllerMixin-C4cpCLeS.chunk.mjs";const b=F({name:"FetchCollectionContentMixin",data(){return{fetchSemaphore:new C(1),loadingCollection:!1,loadingCollectionFiles:!1,errorFetchingCollection:null,errorFetchingCollectionFiles:null}},mixins:[d],methods:{async fetchCollection(e,i,l){if(this.loadingCollection)return null;try{this.loadingCollection=!0,this.errorFetchingCollection=null;const t=await f(e,{signal:this.abortController.signal},i,l);return this.$store.dispatch("addCollections",{collections:[t]}),t}catch(t){if(t.response?.status===404)return this.errorFetchingCollection=404,null;this.errorFetchingCollection=t,r.error("[PublicCollectionContent] Error fetching collection",{error:t}),n(s("photos","Failed to fetch collection."))}finally{this.loadingCollection=!1}return null},async fetchCollectionFiles(e,i=[],l){if(this.loadingCollectionFiles)return[];i=[...i,...h];const t=await this.fetchSemaphore.acquire();try{this.errorFetchingCollectionFiles=null,this.loadingCollectionFiles=!0;const o=await g(e,{signal:this.abortController.signal},i,l),c=o.map(a=>a.fileid?.toString());return this.$store.dispatch("appendFiles",o),await this.$store.commit("setCollectionFiles",{collectionFileName:e,fileIds:c}),o}catch(o){if(o.response?.status===404)return this.errorFetchingCollectionFiles=404,[];this.errorFetchingCollectionFiles=o,n(s("photos","Failed to fetch collections list.")),r.error("[PublicCollectionContent] Error fetching collection files",{error:o})}finally{this.loadingCollectionFiles=!1,this.fetchSemaphore.release(t)}return[]}}});export{b as F};
//# sourceMappingURL=FetchCollectionContentMixin-DeRSEkiD.chunk.mjs.map
