import{b as V,c as f}from"./chunk-DUP5W6EX.js";import{C as c,D as b,E as C,Ee as y,R as p,Z as S,ae as l,ba as d,hf as A,ig as D,ih as T,j as m,k as u,l as g,o as s,ph as I,qd as v,vh as $}from"./chunk-ZSQR4KTU.js";import{i as h}from"./chunk-IQVXR75E.js";var F=(()=>{let n=class n{authHttp=d(v);serverService=d($);restExtractor=d(T);confirmService=d(I);listCaptions(t,i){let r=V.buildVideoPasswordHeader(i);return this.authHttp.get(`${f.BASE_VIDEO_URL}/${t}/captions`,{headers:r}).pipe(p(e=>this.serverService.getServerLocale().pipe(s(o=>({captionsResult:e,translations:o})))),s(({captionsResult:e,translations:o})=>{for(let a of e.data)a.language.label=A(a.language.label,o);return e;}),s(e=>(y(e.data,"language","label"),e))).pipe(c(e=>this.restExtractor.handleError(e)));}removeCaption(t,i){return this.authHttp.delete(`${f.BASE_VIDEO_URL}/${t}/captions/${i}`).pipe(c(r=>this.restExtractor.handleError(r)));}addCaption(t,i,r){let o=D({captionfile:r});return this.authHttp.put(`${f.BASE_VIDEO_URL}/${t}/captions/${i}`,o).pipe(c(a=>this.restExtractor.handleError(a)));}updateCaptions(t,i){let r=u(void 0);for(let e of i)e.action==="CREATE"||e.action==="UPDATE"?r=r.pipe(p(()=>this.addCaption(t,e.language.id,e.captionfile))):e.action==="REMOVE"&&(r=r.pipe(p(()=>this.removeCaption(t,e.language.id))));return r;}getCaptionContent({fileUrl:t}){return this.authHttp.get(t,{responseType:"text"});}generateCaption(t){let{videos:i}=t;return m(i).pipe(C(r=>this.generateCaptionOfSpecificVideo({video:r,forceTranscription:!1})),b(),s(r=>r.reduce((e,o)=>(o==="success"&&(e.success+=1),o==="already-has-captions"&&(e.alreadyHasCaptions+=1),o==="already-being-transcribed"&&(e.alreadyBeingTranscribed+=1),e),{success:0,alreadyHasCaptions:0,alreadyBeingTranscribed:0})),c(r=>this.restExtractor.handleError(r)));}generateCaptionOfSpecificVideo(t){let{video:i,forceTranscription:r}=t,e={forceTranscription:r};return this.authHttp.post(`${f.BASE_VIDEO_URL}/${i.id}/captions/generate`,e).pipe(s(()=>"success"),c(o=>{let a=o.error;if(a?.code===l.VIDEO_ALREADY_BEING_TRANSCRIBED&&!r){let _="PeerTube\uB294 \""+i.name+"\" \uC601\uC0C1\uC758 \uC804\uC0AC\uAC00 \uC774\uBBF8 \uC9C4\uD589 \uC911\uC778 \uAC83\uC73C\uB85C \uAC04\uC8FC\uD569\uB2C8\uB2E4"+"PeerTube\uC5D0 \uBB38\uC81C\uAC00 \uC788\uB2E4\uACE0 \uD310\uB2E8\uB418\uB294 \uACBD\uC6B0(\uD06C\uB798\uC2DC \uD6C4 \uC601\uC0C1\uC774 \uC190\uC0C1\uB41C \uC0C1\uD0DC \uB4F1) \uC774 \uC601\uC0C1\uC744 \uAC15\uC81C\uB85C \uC804\uC0AC\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4"+" Do you still want to run transcription?";return m(this.confirmService.confirm(_,"\uAC15\uC81C \uC804\uC0AC")).pipe(p(O=>O===!1?g(()=>o):this.generateCaptionOfSpecificVideo({video:i,forceTranscription:!0})));}return a?.code===l.VIDEO_ALREADY_HAS_CAPTIONS?u("already-has-captions"):a?.code===l.VIDEO_ALREADY_BEING_TRANSCRIBED?u("already-being-transcribed"):g(()=>o);}));}};h(n,"\u0275fac",function(i){return new(i||n)();}),h(n,"\u0275prov",S({token:n,factory:n.ɵfac}));let E=n;return E;})();export{F as a};/**i18n:347eeb695970c32bc275618edc2e751c67145d9fc3012e70543c114a99b9e016*///# sourceMappingURL=chunk-HGGFRYYX.js.map