import{a as v,b as k}from"./chunk-JPJ4MDDS.js";import{$ as m,K as d,Nf as I,Y as g,b as h,c as u,m as o,of as f,x as b}from"./chunk-X3RCWQ3R.js";import{g as S,i as a}from"./chunk-SR6RTMQI.js";var p=S(I());var i=(0,p.default)("peertube:search:FindInBulkService"),C=(()=>{let n=class n{constructor(e){a(this,"searchService");a(this,"advancedSearchForBulk");a(this,"getVideoInBulk");a(this,"getChannelInBulk");a(this,"getPlaylistInBulk");this.searchService=e,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 i("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 i("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 i("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:c,finder:B}=e;return new h(s=>{t.result.pipe(b(r=>r.params.includes(c)),d(),o(r=>r.response.data),o(r=>r.find(B))).subscribe({next:r=>{if(!r){s.error(new Error("Element "+c+" nije prona\u0111en"));return;}s.next(r),s.complete();},error:r=>s.error(r)}),t.notifier.next(c);});}getVideosInBulk(e){return i("Fetching videos %s.",e.join(", ")),this.searchService.searchVideos({uuids:e,componentPagination:{itemsPerPage:e.length,currentPage:1},skipCount:!0,advancedSearch:this.advancedSearchForBulk});}getChannelsInBulk(e){return i("Fetching channels %s.",e.join(", ")),this.searchService.searchVideoChannels({handles:e,componentPagination:{itemsPerPage:e.length,currentPage:1},advancedSearch:this.advancedSearchForBulk});}getPlaylistsInBulk(e){return i("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()})};}};a(n,"\u0275fac",function(t){return new(t||n)(m(k));}),a(n,"\u0275prov",g({token:n,factory:n.ɵfac}));let l=n;return l;})();export{C as a};/**i18n:3d16453f213eb5db982e7e7dd90631843ac5d3f860726a614777c3e9e3f9b57e*///# sourceMappingURL=chunk-WRWV66Q6.js.map