import{$ as l,B as o,Bg as y,Gf as p,Ic as d,Mc as f,R as h,Wf as I,Y as u,_f as S,af as b,kg as g,m,we as E}from"./chunk-X3RCWQ3R.js";import{i as n}from"./chunk-SR6RTMQI.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:3d16453f213eb5db982e7e7dd90631843ac5d3f860726a614777c3e9e3f9b57e*/
//# sourceMappingURL=chunk-6JFMB5SY.js.map
