import{I as o,D as c,S as I,C,U as i,L as E,A as d,a as h,b as y,c as D,d as N,e as u,f as m,g as k}from"./app-k0jcl5PQ.js";import{BaseVideoUploadService as T}from"./BxxQBRpY.chunk.js";import"./B-3yfUAN.chunk.js";import"./Ec7UK8uC.chunk.js";var v=(e=>(e[e.Upload=1]="Upload",e[e.Tv=2]="Tv",e))(v||{}),A=(e=>(e[e.ExternalOnly=0]="ExternalOnly",e[e.EmbeddedOnly=1]="EmbeddedOnly",e))(A||{}),g=(e=>(e[e.IosApp=1]="IosApp",e[e.AndroidApp=2]="AndroidApp",e[e.WinApp=3]="WinApp",e[e.LibraryPublisher=4]="LibraryPublisher",e[e.ExchangeClient=5]="ExchangeClient",e[e.Online=6]="Online",e[e.Tinder=7]="Tinder",e[e.Cloud247=8]="Cloud247",e[e.Livestream=9]="Livestream",e[e.Curator=10]="Curator",e[e.LibraryEditor=11]="LibraryEditor",e[e.Lite=12]="Lite",e))(g||{});const n=E.encloseNamespace("upload.services");class _ extends T{constructor(t){super(t)}initialize(){super.initialize(),this.videoUploadDataService=o.getInstance(c.VideoUpload,this),this.pendingItemsService=o.getInstance(I.PendingItems,this),this.userDataService=o.getInstance(c.FlightUser,this),this.alertService=o.getInstance(C.ALERT,this),this.listenTo(this.channelName,i.FILES_ADDED,this.onUploadStart),this.listenTo(this.channelName,i.UPLOAD_COMPLETE,this.unlockNav),this.listenTo(this.channelName,i.UPLOAD_CANCELLED,this.unlockNav)}onUploadStart(t){const s={type:d.Success,heading:n("startUploadAlertHeading"),message:t.length===1?n("startUploadSingleAlertBody",{videoName:t[0].name}):n("startUploadMultipleAlertBody",{uploadCount:t.length})},{appLink:a}=h.getCurrentContext();!!y.getMyVideosAppLinks().find(r=>a.application===r.application&&a.action===r.action)||(s.appLinkText=n("startUploadAlertAppLinkText",{smartCount:t.length}),s.appLink={application:u.MY_VIDEOS,action:m.MyVideos.MY_VIDEOS},s.appLinkClassName="info-link"),this.alertService.createAlert(s)}unlockNav(){this.getCollection().some(s=>s.get("progress")<100)||D.Radio.channel(this.channelName).trigger(i.UNLOCK_NAV)}completeUpload(t,s){t.set("sending",!0),this.userDataService.getCurrentUser(a=>{this.userDataService.getCustomerSettings(a,l=>{this.userDataService.getWorkspace(p=>{const r={id:t.get("id"),userId:a.id,customerId:a.customerId,libraryId:p.id,categoryId:t.get("categoryId")||null,pendingProcessOrigin:v.Upload,origin:g.Lite,fileId:s.id,subtitleOptions:{subtitleExtractOptions:A.EmbeddedOnly},video:{name:t.get("name"),description:t.get("description")},autoCaption:!!l[N.AutoCaptioning].value},L=U=>{t.set("pendingProcessId",U.pendingProcessId),this.pendingItemsService.forceFetchPendingItems({resetTimeout:!0})},S=()=>{t.set("status",k.Errored),t.set("sending",!1),this.alertService.createAlert({type:d.Fail,heading:n("uploadErrorAlertHeading"),message:n("errorAlertMessage",{videoName:t.get("name")})})};this.videoUploadDataService.completeVideoUpload(r,L,S)})})})}onSuccess(t,s){super.onSuccess(t,s);const a=this.getUpload(t);a.get("editingMetadata")?this.listenToOnce(a,"change:editingMetadata",()=>{this.completeUpload(a,s)}):this.completeUpload(a,s)}getAdditionalFileInfo(t,s){const{appLink:a}=h.getCurrentRoute();return a.application!==u.MY_VIDEOS||a.action!==m.MyVideos.MY_VIDEOS_FOLDER?{}:{categoryId:+a.args[0]}}}export{_ as VideoUploadService};
//# sourceMappingURL=C4Pkp2VI.chunk.js.map
