import{$ as l,B as o,Eg as y,Hf as p,Jc as d,Nc as f,R as h,Xf as I,Y as u,bf as b,bg as S,m,ng as g,xe as E}from"./chunk-QXV2GR6R.js";import{i as n}from"./chunk-JJ4RDTEF.js";var a=class a{constructor(t,r,i,e){n(this,"authHttp");n(this,"restService");n(this,"restExtractor");n(this,"serverService");this.authHttp=t,this.restService=r,this.restExtractor=i,this.serverService=e}importVideoUrl(t,r){let i=a.BASE_VIDEO_IMPORT_URL,e=this.buildImportVideoObject(r);e.targetUrl=t;let s=p(e);return this.authHttp.post(i,s).pipe(o(c=>this.restExtractor.handleError(c)))}importVideoTorrent(t,r){let i=a.BASE_VIDEO_IMPORT_URL,e=this.buildImportVideoObject(r);typeof t=="string"?e.magnetUri=t:e.torrentfile=t;let s=p(e);return this.authHttp.post(i,s).pipe(o(c=>this.restExtractor.handleError(c)))}getMyVideoImports(t,r,i){let e=new d;if(e=this.restService.addRestGetParams(e,t,r),i){let s=this.restService.parseQueryStringFilter(i,{videoChannelSyncId:{prefix:"videoChannelSyncId:"},targetUrl:{prefix:"targetUrl:"}});e=this.restService.addObjectParams(e,s)}return this.authHttp.get(y.BASE_USERS_URL+"me/videos/imports",{params:e}).pipe(h(s=>this.extractVideoImports(s)),o(s=>this.restExtractor.handleError(s)))}deleteVideoImport(t){return this.authHttp.delete(a.BASE_VIDEO_IMPORT_URL+t.id).pipe(o(r=>this.restExtractor.handleError(r)))}cancelVideoImport(t){return this.authHttp.post(a.BASE_VIDEO_IMPORT_URL+t.id+"/cancel",{}).pipe(o(r=>this.restExtractor.handleError(r)))}buildImportVideoObject(t){let r=t.language||null,i=t.licence||null,e=t.category||null,s=t.description||null,c=t.support||null,R=t.scheduleUpdate||null,O=t.originallyPublishedAt||null;return{name:t.name,category:e,licence:i,language:r,support:c,description:s,channelId:t.channelId,privacy:t.privacy,tags:t.tags,nsfw:t.nsfw,waitTranscoding:t.waitTranscoding,commentsPolicy:t.commentsPolicy,downloadEnabled:t.downloadEnabled,thumbnailfile:t.thumbnailfile,previewfile:t.previewfile,scheduleUpdate:R,originallyPublishedAt:O}}extractVideoImports(t){return this.serverService.getServerLocale().pipe(m(r=>(t.data.forEach(i=>i.state.label=E(i.state.label,r)),t)))}};n(a,"BASE_VIDEO_IMPORT_URL",b.apiUrl+"/api/v1/videos/imports/"),n(a,"\u0275fac",function(r){return new(r||a)(l(f),l(S),l(I),l(g))}),n(a,"\u0275prov",u({token:a,factory:a.\u0275fac}));var U=a;export{U as a};
/**i18n:224bcada6943fe8b17ea60808c2d370cec9507c3bd670ebe71692d099a3befa1*/
//# sourceMappingURL=chunk-IV6N2BUM.js.map
