import{b as V,c as f}from"./chunk-V4YGGZ4W.js";import{$c as v,B as c,Bh as I,C as b,D as C,Gh as $,Ld as l,Q as p,Qe as A,Y as S,aa as d,ah as D,i as m,j as u,k as g,le as y,n as s,uh as T}from"./chunk-GKQGDBUU.js";import{i as h}from"./chunk-QVFSZZWQ.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\u306F\u3001\u52D5\u753B\""+i.name+"\"\u306E\u6587\u5B57\u8D77\u3053\u3057\u304C\u65E2\u306B\u958B\u59CB\u3055\u308C\u3066\u3044\u308B\u3068\u5224\u65AD\u3057\u307E\u3057\u305F\u3002"+"PeerTube\u5074\u306B\u554F\u984C\u304C\u3042\u308B\uFF08\u30AF\u30E9\u30C3\u30B7\u30E5\u306A\u3069\u304C\u539F\u56E0\u3067\u3001\u52D5\u753B\u304C\u4E88\u671F\u305B\u306C\u72B6\u614B\u3067\u3042\u308B\u306A\u3069\uFF09\u3068\u601D\u308F\u308C\u308B\u5834\u5408\u3001\u3053\u306E\u52D5\u753B\u306E\u6587\u5B57\u8D77\u3053\u3057\u3092\u624B\u52D5\u3067\u5B9F\u884C\u3067\u304D\u307E\u3059\u3002"+" Do you still want to run transcription?";return m(this.confirmService.confirm(_,"\u6587\u5B57\u8D77\u3053\u3057\u3092\u624B\u52D5\u5B9F\u884C")).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:42345378061bf3c93df67acfa161b751a7b03cc91f3ede7c1f1cdf2bba62fe26*///# sourceMappingURL=chunk-VN5RUFMQ.js.map