import{a as v,b as k}from"./chunk-MYFUY6O2.js";import{Jg as f,K as d,Y as g,aa as m,b as h,c as u,ih as P,n as o,x as b}from"./chunk-GKQGDBUU.js";import{g as I,i as c}from"./chunk-QVFSZZWQ.js";var p=I(P());var n=(0,p.default)("peertube:search:FindInBulkService"),w=(()=>{let a=class a{searchService=m(k);advancedSearchForBulk;getVideoInBulk;getChannelInBulk;getPlaylistInBulk;constructor(){this.getVideoInBulk=this.buildBulkObservableObject(this.getVideosInBulk.bind(this)),this.getChannelInBulk=this.buildBulkObservableObject(this.getChannelsInBulk.bind(this)),this.getPlaylistInBulk=this.buildBulkObservableObject(this.getPlaylistsInBulk.bind(this)),this.advancedSearchForBulk=new v({searchTarget:"local"});}getVideo(e){return n("Schedule video fetch for uuid %s.",e),this.getData({observableObject:this.getVideoInBulk,finder:t=>t.uuid===e||t.shortUUID===e,param:e});}getChannel(e){return n("Schedule channel fetch for handle %s.",e),this.getData({observableObject:this.getChannelInBulk,finder:t=>t.nameWithHost===e||t.nameWithHostForced===e,param:e});}getPlaylist(e){return n("Schedule playlist fetch for uuid %s.",e),this.getData({observableObject:this.getPlaylistInBulk,finder:t=>t.uuid===e||t.shortUUID===e,param:e});}getData(e){let{observableObject:t,param:l,finder:B}=e;return new h(i=>{t.result.pipe(b(r=>r.params.includes(l)),d(),o(r=>r.response.data),o(r=>r.find(B))).subscribe({next:r=>{if(!r){i.error(new Error("Prvok "+l+" sa nena\u0161iel"));return;}i.next(r),i.complete();},error:r=>i.error(r)}),t.notifier.next(l);});}getVideosInBulk(e){return n("Fetching videos %s.",e.join(", ")),this.searchService.searchVideos({uuids:e,componentPagination:{itemsPerPage:e.length,currentPage:1},skipCount:!0,advancedSearch:this.advancedSearchForBulk});}getChannelsInBulk(e){return n("Fetching channels %s.",e.join(", ")),this.searchService.searchVideoChannels({handles:e,componentPagination:{itemsPerPage:e.length,currentPage:1},advancedSearch:this.advancedSearchForBulk});}getPlaylistsInBulk(e){return n("Fetching playlists %s.",e.join(", ")),this.searchService.searchVideoPlaylists({uuids:e,componentPagination:{itemsPerPage:e.length,currentPage:1},advancedSearch:this.advancedSearchForBulk});}buildBulkObservableObject(e){let t=new u();return{notifier:t,result:f({time:100,bulkGet:e,notifierObservable:t.asObservable()})};}};c(a,"\u0275fac",function(t){return new(t||a)();}),c(a,"\u0275prov",g({token:a,factory:a.ɵfac}));let s=a;return s;})();export{w as a};/**i18n:42345378061bf3c93df67acfa161b751a7b03cc91f3ede7c1f1cdf2bba62fe26*///# sourceMappingURL=chunk-XTWCK3HF.js.map