import{C as n,Cf as p,Kc as d,Oc as f,Rf as I,S as h,Xf as S,Ye as b,Z as u,aa as c,hg as g,n as m,ue as E,yg as y}from"./chunk-4JM6MIZ5.js";import{i as l}from"./chunk-QJQRWPYR.js";var a=class a{authHttp;restService;restExtractor;serverService;constructor(t,r,i,e){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(n(o=>this.restExtractor.handleError(o)))}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(n(o=>this.restExtractor.handleError(o)))}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)),n(s=>this.restExtractor.handleError(s)))}deleteVideoImport(t){return this.authHttp.delete(a.BASE_VIDEO_IMPORT_URL+t.id).pipe(n(r=>this.restExtractor.handleError(r)))}cancelVideoImport(t){return this.authHttp.post(a.BASE_VIDEO_IMPORT_URL+t.id+"/cancel",{}).pipe(n(r=>this.restExtractor.handleError(r)))}buildImportVideoObject(t){let r=t.language||null,i=t.licence||null,e=t.category||null,s=t.description||null,o=t.support||null,R=t.scheduleUpdate||null,O=t.originallyPublishedAt||null;return{name:t.name,category:e,licence:i,language:r,support:o,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)))}};l(a,"BASE_VIDEO_IMPORT_URL",b.apiUrl+"/api/v1/videos/imports/"),l(a,"\u0275fac",function(r){return new(r||a)(c(f),c(S),c(I),c(g))}),l(a,"\u0275prov",u({token:a,factory:a.\u0275fac}));var U=a;export{U as a};
/**i18n:68865f44f2a527c44cf5136a17c76a0ff8308c2bae5c7c8d50070a5fb9847c44*/
//# sourceMappingURL=chunk-OSNS7N54.js.map
