import{l as y$1}from"./chunk-C6uGsfWa.js";import{Bc as zn,Gi as ar,H as Dm,Hs as se,Oi as Zt,Wa as g,Wt as Jn,_r as Se,er as Qc,fr as S,gt as G,ha as cf,no as hQ,or as Rg,pc as vn,ro as he,y as Be}from"./chunk-B_pj7Jpm.js";var y=class e{authHttp=g(zn);restService=g(Rg);restExtractor=g(Jn);serverService=g(Zt);static BASE_VIDEO_IMPORT_URL=se.apiUrl+`/api/v1/videos/imports/`;importVideo(t){let r=e.BASE_VIDEO_IMPORT_URL,o=hQ(t);return this.authHttp.post(r,o).pipe(he(a=>this.restExtractor.handleError(a)))}listMyVideoImports(t){let m=t,{pagination:r,sort:o}=m,a=y$1(m,[`pagination`,`sort`]),i=new vn;return i=this.restService.addRestGetParams(i,r,o),i=this.restService.addObjectParams(i,a),this.authHttp.get(Qc.BASE_USERS_URL+`me/videos/imports`,{params:i}).pipe(Be(n=>this.extractVideoImports(n)),he(n=>this.restExtractor.handleError(n)))}deleteVideoImport(t){return this.authHttp.delete(e.BASE_VIDEO_IMPORT_URL+t.id).pipe(he(r=>this.restExtractor.handleError(r)))}cancelVideoImport(t){return this.authHttp.post(e.BASE_VIDEO_IMPORT_URL+t.id+`/cancel`,{}).pipe(he(r=>this.restExtractor.handleError(r)))}retryVideoImport(t){return this.authHttp.post(e.BASE_VIDEO_IMPORT_URL+t.id+`/retry`,{}).pipe(he(r=>this.restExtractor.handleError(r)))}retryVideoImportByVideos(t){let r={start:0,count:1},o={field:`createdAt`,order:-1};return Se(t).pipe(ar(a=>this.listMyVideoImports({pagination:r,sort:o,includeCollaborations:!0,videoId:a.id}).pipe(Be(({data:i})=>{if(i.length===0)throw new Error(`No video import found for this video`);return this.authHttp.post(e.BASE_VIDEO_IMPORT_URL+i[0].id+`/retry`,{})}))),cf(),he(a=>this.restExtractor.handleError(a)))}extractVideoImports(t){return this.serverService.getServerLocale().pipe(G(r=>(t.data.forEach(o=>o.state.label=Dm(o.state.label,r)),t)))}static ɵfac=function(r){return new(r||e)};static ɵprov=S({token:e,factory:e.ɵfac})};export{y as t};
//# debugId=ef0457a4-88a6-5714-8aad-e5edb76e3ae3
//# sourceMappingURL=chunk-Ch-TBCUx.js.map