1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BuilderExplorer-Z5A07wOu.js","assets/vendor-vue-Dc2LPUoF.js","assets/vendor-others-Cb-_CJoS.js","assets/vendor-ali-oss-CxNDuD8w.js","assets/index-B2_rrUWa.js","assets/vendor-firebase-WYpYyPUs.js","assets/vendor-hls-DyG050JZ.js","assets/vendor-emoji-mart-vue-fast-D_gb4wpv.js","assets/vendor-emoji-mart-vue-fast-BBbumEJQ.css","assets/vendor-d3-Cl55k9wj.js","assets/vendor-fabric-BxHRdrKk.js","assets/vendor-fontawesome--uth9-aG.js","assets/vendor-aggrid-DzY6H3DO.js","assets/vendor-vuetify-CzUHjbwx.js","assets/vendor-vuetify-4i2PKXrf.css","assets/vendor-element-plus-C4_3ySuy.js","assets/vendor-element-plus-Beul3IQx.css","assets/index-Box2uqEm.css","assets/DStepCards-DKT0Uhqi.js","assets/useWorkflowStepsLoader-DAX51TFr.js","assets/image-maps-server-C-dveMM4.js","assets/resolveWorkflowSourceVideoDuration-u0s_c-N8.js","assets/DStepCards-D3xFp9TU.css","assets/DExplorerSearch-CxEom_Bj.js","assets/DGroupMenu-BfRD6K7v.js","assets/DGroupMenu-I5df2Qyf.css","assets/DExplorerSearch-BlQNlAk7.css","assets/DPagination-DTC8d1gX.js","assets/search-server-DkCJRgCz.js","assets/pickerType-Bj25TghO.js","assets/useDemoSelectable-B6Xr97nZ.js","assets/ReplacePopup-m0wE5u4H.js","assets/useReplaceWord-CrILEFwo.js","assets/editorReplaceWord-Qx6Atp4o.js","assets/segmentTime-CXEMVm2i.js","assets/EditorImportStepFlag-BqWN5n8k.js","assets/ZoomVideoClipItem-MBnmfzwM.js","assets/ZoomVideoClipItem-B6A0-Ole.css","assets/DBuilderPublishConfirmedPopup-DI2Z3wP_.js","assets/useVersionDescription-JT8yjUEF.js","assets/DAvatarList-GanvlLPy.js","assets/DAvatarList-BSFh4te-.css","assets/approvalWorkflow-AiVPj4pl.js","assets/file-request-server-C28AwhUT.js","assets/useVersionDescription-_FuWfja4.css","assets/useVersionNotesRequirement-CKsS4_0R.js","assets/DExternalIdDisplay-C46c1o8R.js","assets/useExternalId-uUOW8iI4.js","assets/DBuilderPublishConfirmedPopup-C6mBXDYG.css","assets/DBuilderCategoryPopup-mXcDJYfE.js","assets/CategoryExpansionPanel-D4WWDZuc.js","assets/CategoryExpansionPanel-DlOy81Ih.css","assets/DBuilderCategoryPopup-kRz91Lrd.css","assets/DBuilderReviewerPopup-C4ad56wm.js","assets/DBuilderReviewerPopup-C4cFSq75.css","assets/DBuilderReviewerSuccessPopup-BI4TU4id.js","assets/DBackToStudioWorkspaceBtn-D27dsA_p.js","assets/DPopupPlayer-C0_mnMP9.js","assets/DPopupPlayer-69s6HQGH.css","assets/BuilderPosterPopup-CoJp3GQA.js","assets/DResizeImage-DrY75S1g.js","assets/DVideoSecureMultistep-DeaWbE5L.js","assets/DVideoSecureMultistep-BQrmDabT.css","assets/BuilderPosterPopup-dNuu4E6a.css","assets/BuilderResetWorkflowPopup-B00jVWTc.js","assets/DIconCircleWithExclamation-DEgUSzRb.js","assets/DManageExternalIdPopup-DOnYbaOz.js","assets/DProductLineUnpublishConfirmPopup-C8RXZAsz.js","assets/EditorEntry-DBSLUcpN.js","assets/EntryCardGrid-BbtROJHa.js","assets/EditorAnnotation-VLpid9Qp.js","assets/BuilderAnnotationInvalidImageTypePop-BcZlHn7U.js","assets/useMapMutations-CPd50PBj.js","assets/BuilderAnnotationInvalidImageTypePop-CCaDp_jg.css","assets/BuilderAnnotationControl-CmLpl5NY.js","assets/timeRangeUtils-Bh8noy9t.js","assets/BuilderAnnotationControl-0_ru2ak9.css","assets/AnnotationVideoTimeRangeSelector-CdHRB0wk.js","assets/useDraggableHandle-BaPw27SQ.js","assets/AnnotationVideoTimeRangeSelector-ClI59rbX.css","assets/useAnnotationZoom-BuNFNOqP.js","assets/ChangeSpeedSegmentsOverlayTrack-CqOucaod.js","assets/ChangeSpeedSegmentsOverlayTrack-aAMGW-S-.css","assets/AnnotationZoomSelector-Bhb4bSI2.js","assets/addons-DNe8whWa.js","assets/checkEditorStatus-ByndP9TD.js","assets/useSwitchEditor-CXKGHaEf.js","assets/EditorReadModeBanner-e_Iz3lP0.js","assets/EditorReadModeBanner-Cghtdfdn.css","assets/useDerivedOutdated-DOV_fR62.js","assets/translations-BObjPR9Y.js","assets/useSummaryLanguageSupport-CUFYvelj.js","assets/wizardEditor-DcdOWrEV.js","assets/useExportPermission-Bht8cuDT.js","assets/useApprovalRequest-Dc7FZrXR.js","assets/useApprovalRequest-B915WbBB.css","assets/useSwitchEditor-B-I1YKNw.css","assets/PlayerControls-B5G-yPao.js","assets/PlayerControls-DmX5WXOH.css","assets/playbackRanges-C7V2aTUE.js","assets/MixinPlayerControl-CuGmUsae.js","assets/useWordEdit-Cd9mRpl6.js","assets/DIconCloudWithArrowUp-BeuwJOKG.js","assets/useWordPreviewTooltip-9CXIHt2z.js","assets/timelineFrameSnap-DnaM58L6.js","assets/timelineFrameSnap-CtTql-yb.css","assets/DWorkflowCircleProgress-Dq-CfcGP.js","assets/DWorkflowCircleProgress-CyQL_qkV.css","assets/VoiceOverTimeline-DY8nqd6m.js","assets/voiceover-DyA68oCm.js","assets/VoiceOverTimeline-CEkmpHDr.css","assets/EditorWaveClipItem-DvJay5AP.js","assets/EditorWaveClipItem-Cx8IAF4d.css","assets/useApprovalHistoryDeepLink-CNVWsQ3N.js","assets/useOpenShareExportFromRoute-BbHRR3mm.js","assets/sharePanel-B4Cqmefk.js","assets/useSaveWorkflow-BxxVTGbk.js","assets/useUnsavedChangesGuard-CX_944b4.js","assets/createWorkflowHistoryLogs-CKdaz0Lc.js","assets/EditorAnnotation-fVwrlWAX.css","assets/EditorAttachment-KiMTBDW9.js","assets/BuilderAttachments-sOG7HYTw.js","assets/BuilderAttachments-B1J_U8zN.css","assets/EditorTranslation-CgSTk9JK.js","assets/MixinTranslation-B1qzkufX.js","assets/useMultipleTranslation-CTQ-15oz.js","assets/useMultipleTranslation-CxQ1m_2U.css","assets/useSummaryTranslation-sAXV48P2.js","assets/TranslationEditor-D0W6XJjs.js","assets/d-auto-resize-Btpt9GCg.js","assets/TranslationEditor-
1Bu7NBxMh.css","assets/SopCollapseItemEditable-CqVAg-qc.js","assets/buildNewEditorAiContentSources-BOPM4q7a.js","assets/useDerivedHash-CmzTQf6N.js","assets/checkLanguage-IGyfc8WL.js","assets/translate-server-Dw3F3OVr.js","assets/EditorDubbing-DxWdwu7_.js","assets/DubbingLanguageAccentModal-D5Z0fyzd.js","assets/useAccentPlayer-C3Zp9GoD.js","assets/useVoiceOverAudio-B97TIoD1.js","assets/video-server-B1I7gjW5.js","assets/DubbingAccent-C__FjhjG.js","assets/audioPosition-DNyISwzs.js","assets/audio-DMcAx7NA.js","assets/MicVolume-DW1nT4o4.js","assets/MicVolume-D1zwM04W.css","assets/EditorQuiz-DuBQhXdi.js","assets/QuizLeftSide-CXMmXvOe.js","assets/DActivateSwitch-Du--3IsY.js","assets/QuizLeftSide-cL0k23Ys.css","assets/MixinQuizPublish-DLC_OdR3.js","assets/logQuizHistory-EPAToqfV.js","assets/EditorQuiz-DleWU03m.css","assets/GenerateQuizPopup-DbERHIAx.js","assets/WorkflowOrApprovalStatusTag-DPaEgyoc.js","assets/GenerateQuizPopup-BtU67yZa.css","assets/EditorAISummary-6pFGtb80.js","assets/AISummaryBody-D51NouJM.js","assets/AISummaryBody-CfhZ-qLi.css","assets/EditorImport-DSvbT5yT.js","assets/VideoEditingProcessingPopup-C0UE9ovm.js","assets/DExtendIdle-DOiKbp9v.js","assets/idle-ChQ8UjBk.js","assets/VideoEditingProcessingPopup-CXq31sKU.css","assets/WarnLeavePageWithoutSavingPop-JyzEfShO.js","assets/AudioGeneratedSuccessPop-BvRqnC7I.js"])))=>i.map(i=>d[i]); 2import{a1 as ge,jI as Ge,au as de,bd as Te,Z as Ae,jJ as At,Q as Xe,iC as Mt,dz as Rt,l as Ot,jK as ne,jL as $,jM as U,C as W,jb as Lt,jN as Bt,jO as Vt,bc as me,dC as Nt,jP as oe,jQ as Ut,jR as ce,jS as we,jT as M,jU as Ft,jV as Ht,c3 as qe,jW as zt,jX as Kt,jY as jt,jZ as Be,j_ as Se,i$ as Ye,j$ as Gt,k0 as Xt,dJ as qt,dF as Ze,am as Yt,an as Zt,n as Oe,u as Qt,ar as Jt,k1 as Qe,k2 as Je,k3 as $t,z as ei,k4 as ti,k5 as ii,k6 as oi,e1 as si,dH as ni,k7 as Ve,k8 as ri,cg as ai,k9 as li,ka as di,eM as ci,kb as ui,R as hi,kc as pi}from"./index-B2_rrUWa.js";import{r as F,s as te,aE as w,c as g,f as d,K as c,i as h,_,I as mi,Y as R,w as he,o as fi,Z as C,W as T,a1 as y,X as L,a0 as Y,a4 as Z,aF as Ie,b8 as A,O as gi,as as ae,at as x,a5 as re,av as ue,bP as Si,bC as Ne,a2 as ee,v as wi,J as Me,b$ as Ti,dt as Pe,du as pe,aq as ye,q as ve,g as $e,ar as ke,$ as _i,dl as Ei,P as Ue,G as Fe}from"./vendor-others-Cb-_CJoS.js";import{b as B,m as Q,d as O,u as yi}from"./vendor-vue-Dc2LPUoF.js";import{u as et}from"./addons-DNe8whWa.js";import{u as tt}from"./approvalWorkflow-AiVPj4pl.js";import{f as vi}from"./image-maps-server-C-dveMM4.js";import{c as He,a as ki}from"./checkEditorStatus-ByndP9TD.js";import{u as Ci,E as bi}from"./useSwitchEditor-CXKGHaEf.js";import Ii from"./PlayerControls-B5G-yPao.js";import{r as Pi,P as Re,a as Di}from"./playbackRanges-C7V2aTUE.js";import{_ as xi}from"./MixinPlayerControl-CuGmUsae.js";import{_ as ie}from"./vendor-emoji-mart-vue-fast-D_gb4wpv.js";import{S as Wi}from"./pickerType-Bj25TghO.js";import{u as it,a as Ai,b as Mi,c as Ri}from"./useWordEdit-Cd9mRpl6.js";import Oi from"./DIconCloudWithArrowUp-BeuwJOKG.js";import{u as _e,C as Li,_ as Bi,E as Vi}from"./ChangeSpeedSegmentsOverlayTrack-CqOucaod.js";import{g as fe,a as Le}from"./segmentTime-CXEMVm2i.js";import{u as Ni,a as Ui}from"./useReplaceWord-CrILEFwo.js";import{W as ze,u as Fi,a as Hi,b as zi}from"./useWordPreviewTooltip-9CXIHt2z.js";import{D as Ce}from"./useDraggableHandle-BaPw27SQ.js";import{Z as Ki,a as ji,s as Gi}from"./timelineFrameSnap-DnaM58L6.js";import Xi from"./DWorkflowCircleProgress-Dq-CfcGP.js";import{V as qi,E as Yi,b as Zi}from"./VoiceOverTimeline-DY8nqd6m.js";import{S as Qi,b as Ji,a as $i,E as eo}from"./EditorWaveClipItem-DvJay5AP.js";import{u as to}from"./useApprovalHistoryDeepLink-CNVWsQ3N.js";import{D as io,u as oo,R as so}from"./useExportPermission-Bht8cuDT.js";import{_ as no,u as ro}from"./useOpenShareExportFromRoute-BbHRR3mm.js";import{u as ot}from"./useSaveWorkflow-BxxVTGbk.js";import{u as st}from"./useDerivedOutdated-DOV_fR62.js";import{u as ao}from"./useUnsavedChangesGuard-CX_944b4.js";import{S as lo}from"./sharePanel-B4Cqmefk.js";import{c as co,a as uo}from"./createWorkflowHistoryLogs-CKdaz0Lc.js";import{u as ho}from"./useSummaryLanguageSupport-CUFYvelj.js";import{u as po}from"./useApprovalRequest-Dc7FZrXR.js";function mo(){const{getter_change_speed_segments:e}=ge("editorAdvance",["getter_change_speed_segments"]),t=F(null),n=F(null),o=te(()=>e.value||[]),s=()=>n==null?void 0:n.value;return{videoPlayerRef:n,currentSpeedSegment:t,changeSpeedSegments:o,applySpeedFromSegment:a=>{const l=s();if(!l)return;const p=o.value.find(m=>a>=m.start&&a<m.end);if(p!==t.value){t.value=p;const m=p?p.speed:1;l.playbackRate=m}},resetSpeed:a=>{const l=s();l&&(l.playbackRate=1,t.value=null)}}}const fo={name:"EditorPreviewPlayer",emits:["handleVideoOnTimeUpdate","handleOnPlay","handleOnPause","handleVideoSeek"],mixins:[xi],setup(){const{videoPlayerRef:e,applySpeedFromSegment:t}=mo(),{isKctBlocked:n}=de();return{videoPlayerRef:e,applySpeedFromSegment:t,isKctBlocked:n}},props:{isShowPlaybackRate:{type:Boolean,default:!0},isHideBigPlayPauseButton:{type:Boolean,default:!1},isAlwaysMuted:{type:Boolean,default:!1},canPlay:{type:Function,default:null},isToolbarBelowVideo:{type:Boolean,default:!1},workflow:{type:Object,default:null},countdown:{type:Number,default:0},disableControls:{type:Boolean,default:!1}},components:{PlayerControls:Ii}
2,data:function(){return{muted:!0,playPromise:null,rafId:null,lastUpdateTime:0,lastVideoTime:0}},computed:{...O("editorPlayer",["command","isPlaying"]),...O("editorAdvance",["videoSigned360","sourceWorkflow","segments"]),...Q("editorAdvance",["getter_clip_items","getter_adjusted_steps","getter_display_current_time","getter_display_duration"]),displayCurrentTime(){return this.getter_display_current_time},displayDuration(){return this.getter_display_duration},stepStages(){return this.getter_adjusted_steps.map(({endTime:e})=>e)},canPlayRanges(){return this.getter_clip_items.filter(({type:e})=>e===Ge.EXIST)}},watch:{command:{handler(e){Di(e,{hasVideo:()=>!!this.videoPlayerRef,onPlay:()=>this.handlePlayVideo(),onPause:()=>this.handlePauseVideo(),onSeek:t=>this.handleSetVideoCurrentTime(t),onMute:()=>this.handlePlayerMute(),onUnmute:()=>this.handlePlayerUnmute()})},immediate:!0},videoSigned360:{immediate:!0,handler(e){e&&this.setupVideoUrls({workflowId:this.sourceWorkflow.id,signed360Url:e,videoHDUrl:this.sourceWorkflow.videoGsURL})}},isPlaying:{handler(e){e?this.startTimeUpdateLoop():this.stopTimeUpdateLoop()}}},methods:{...B("editorAdvance",["setCurrentTime"]),...B("editorPlayer",["setIsVideoLoading","setIsPlaying"]),getCurrentTime(){return this.getter_display_current_time},handlePlayerMute(){this.muted=!0},handlePlayerUnmute(){this.isAlwaysMuted||(this.muted=!1)},startTimeUpdateLoop(){if(this.rafId)return;const e=t=>{var i;if(!this.isPlaying)return;const n=(i=this.videoPlayerRef)==null?void 0:i.currentTime;if(n===void 0){this.rafId=requestAnimationFrame(e);return}(Math.abs(n-this.lastVideoTime)>.09||t-this.lastUpdateTime>100||n>this.getter_display_duration-1)&&(this.handleVideoOnTimeUpdate(n),this.lastVideoTime=n,this.lastUpdateTime=t),this.rafId=requestAnimationFrame(e)};this.rafId=requestAnimationFrame(e)},stopTimeUpdateLoop(){this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null)},handlePlayVideo(){typeof this.canPlay=="function"&&!this.canPlay()||(this.playPromise=this.videoPlayerRef.play(),this.setIsPlaying(!0))},async handlePauseVideo(){this.playPromise!==null&&await this.playPromise,this.videoPlayerRef.pause(),this.playPromise=null,this.setIsPlaying(!1)},handleSetIsVideoLoading(e){this.isVideoLoading=e,this.setIsVideoLoading(e)},handleSetVideoCurrentTime(e){if(this.videoPlayerRef){const t=+e.toFixed(2);this.videoPlayerRef.currentTime=+e.toFixed(2),this.applySpeedFromSegment(t),this.setCurrentTime(t),this.$emit("handleVideoSeek",t)}},handleVideoLoaded(){this.handleSetIsVideoLoading(!1),this.reInitialPlayerStatusWhenVideoLoaded()},handleVideoEnded(){this.setIsPlaying(!1)},handleVideoOnTimeUpdate(e){var t;try{if(this.isQualitySwitching||this.canPlayRanges.length===0)return;if(this.applySpeedFromSegment(e),this.setCurrentTime(e),this.$emit("handleVideoOnTimeUpdate",e),!this.isPlaying){this.handlePlayerMute();return}const n=Pi(e,this.canPlayRanges,{videoMuted:!!((t=this.videoPlayerRef)!=null&&t.muted)});if(n.type===Re.PAUSE_AND_SEEK){this.handlePauseVideo(),this.handleSetVideoCurrentTime(n.seekTime);return}if(n.type===Re.SEEK){this.handleSetVideoCurrentTime(n.seekTime);return}n.type===Re.IN_RANGE&&n.shouldUnmute&&this.handlePlayerUnmute()}catch(n){console.error("handleVideoOnTimeUpdate",n)}},handleOnPlay(){this.$emit("handleOnPlay")},handleOnPause(){this.$emit("handleOnPause")},handleKeyDown(e){this.isKctBlocked||e.target.nodeName==="INPUT"||e.target.nodeName==="TEXTAREA"||e.target.contentEditable==="true"||e.code==="Space"&&(e.preventDefault(),this.isPlaying?this.handlePauseVideo():this.handlePlayVideo())}},mounted(){window.addEventListener("keydown",this.handleKeyDown)},beforeUnmount(){this.stopTimeUpdateLoop(),window.removeEventListener("keydown",this.handleKeyDown)}},go={class:"AnnotationZoom w-full h-full overflow-hidden"},So=["src","muted"];function wo(e,t,n,o,s,i){const r=w("PlayerControls");return d(),g("div",{class:R(["video-container",{"pointer-events-none":o.isKctBlocked}])},[c("div",go,[c("video",{ref:"videoPlayerRef",src:e.currentVideoSource,muted:n.isAlwaysMuted||e.muted,onLoadeddata:t[0]||(t[0]=(...a)=>i.handleVideoLoaded&&i.handleVideoLoaded(...a)),onPlay:t[1]||(t[1]=(...a)=>i.handleOnPlay&&i.handleOnPlay(...a)),onPause:t[2]||(t[2]=(...a)=>i.handleOnPause&&i.handleOnPause(...a)),onWaiting:t[3]||(t[3]=a=>i.handleSetIsVideoLoading(!0)),onCanplay:t[4]||(t[4]=a=>i.handleSetIsVideoLoading(!1)),onEnded:t[5]||(t[5]=(...a)=>i.handleVideoEnded&&i.handleVideoEnded(...a))}
2,null,40,So)]),h(r,{"disable-controls":n.disableControls||o.isKctBlocked,countdown:n.countdown,hasSD:e.hasSD,isLoading:e.isVideoLoading||e.isQualitySwitching,isPlaying:e.isPlaying,isSD:e.isSD,isHideBigPlayPauseButton:n.isHideBigPlayPauseButton,isShowPlaybackRate:n.isShowPlaybackRate,isToolbarBelowVideo:n.isToolbarBelowVideo,playerSpeed:e.playerSpeed,stepStages:i.stepStages,videoCurrentTime:i.displayCurrentTime,videoDuration:i.displayDuration,onPauseVideo:i.handlePauseVideo,onPlayVideo:i.handlePlayVideo,onSetIsSD:e.handleSetIsSD,onSetPlayerSpeed:e.handleSetPlayerSpeed,onSetVideoCurrentTime:i.handleSetVideoCurrentTime},{"right-tools":_(()=>[mi(e.$slots,"right-tools",{},void 0,!0)]),_:3},8,["disable-controls","countdown","hasSD","isLoading","isPlaying","isSD","isHideBigPlayPauseButton","isShowPlaybackRate","isToolbarBelowVideo","playerSpeed","stepStages","videoCurrentTime","videoDuration","onPauseVideo","onPlayVideo","onSetIsSD","onSetPlayerSpeed","onSetVideoCurrentTime"])],2)}const To=ie(fo,[["render",wo],["__scopeId","data-v-45ba5d9e"]]),_o={name:"IntroImageCard",components:{DIconCloudWithArrowUp:Oi},props:{allowImportStep:{type:Boolean,default:!1}},setup(){const{getter_intro:e}=ge("editorAdvance",["getter_intro"]),{setIntro:t,deleteIntro:n,updateIntroDuration:o}=Te("editorAdvance",["setIntro","deleteIntro","updateIntroDuration"]),{isEditMode:s}=_e(),{openAlert:i}=Xe(),{t:r}=yi(),a=F(null),l=F(!1),f=F(null),p=F(!1),m=F(3),S=te(()=>e.value),u=async()=>{var b;l.value||s.value&&((b=a.value)==null||b.click())},I=async b=>{var N;if(!s.value){b.target.value="";return}const E=(N=b.target.files)==null?void 0:N[0];if(E){if(!At(E)){i({type:"error",message:r("fileUpload.invalidImageFile")}),b.target.value="";return}try{if(l.value=!0,!await Mt(E)){i({type:"error",message:r("fileUpload.invalidImageFile")});return}const{url:H}=await Rt("poster",E,{generateNewName:!0}),X=await Ae(H);f.value=X||H,t({imageUrl:H,duration:3})}catch(G){Ot(G),console.error("Failed to upload image:",G)}finally{l.value=!1,b.target.value=""}}},k=b=>{const E=Number.parseFloat(b.target.value);Number.isNaN(E)||E<0?m.value=0:m.value=E},D=async()=>{s.value&&(m.value<0&&(m.value=0),p.value=!1,o(m.value))},v=async()=>{var b;s.value&&(m.value=((b=S.value)==null?void 0:b.duration)||3,p.value=!0)},P=async()=>{s.value&&(n(),f.value=null)};return he(()=>S.value,async b=>{if(b!=null&&b.imageUrl){const E=await Ae(b.imageUrl);E?f.value=E:f.value=b.imageUrl,m.value=b.duration||3}else b!=null&&b.imageUrl||(f.value=null)},{immediate:!0}),fi(async()=>{var b;if((b=S.value)!=null&&b.imageUrl){const E=await Ae(S.value.imageUrl);E?f.value=E:f.value=S.value.imageUrl,m.value=S.value.duration||3}}),{isEditMode:s,fileInputRef:a,isUploading:l,introImageUrl:f,editingIntroDuration:p,introDuration:m,intro:S,handleFileSelect:u,handleFileChange:I,handleIntroDurationInput:k,handleSaveIntroDuration:D,handleEditIntroDuration:v,handleDeleteIntro:P}}},Eo={key:0,class:"ReadModeIntro"},yo={class:"relative rounded-sm w-[160px] bg-[#202020] flex items-center justify-center aspect-video overflow-hidden"},vo=["src"],ko={class:"mt-[10px] flex items-center justify-between"},Co={class:"flex items-center gap-2"},bo={class:"flex items-center gap-2"},Io={class:"text-xs"},Po={class:"relative flex"},Do={class:"cursor-pointer group"},xo=["src"],Wo={key:0,class:"absolute opacity-0 group-hover:opacity-100 top-2 right-2 z-10 p-2 rounded-full bg-gray-700 w-8 h-8 flex items-center justify-center"},Ao={class:"flex items-center gap-2 text-white group-hover:hidden"},Mo={class:"hidden flex-col items-center justify-center gap-2 text-white group-hover:flex"},Ro={class:"text-sm"},Oo={key:0,class:"mt-[10px] flex items-center justify-between"},Lo={class:"flex items-center gap-2"},Bo={key:0,class:"flex items-center gap-2"},Vo={class:"text-xs"};function No(e,t,n,o,s,i){var f;const r=w("font-awesome-icon"),a=w("DIconCloudWithArrowUp"),l=w("DTooltip");return!o.isEditMode&&o.intro&&o.intro.imageUrl?(d(),g("div",Eo,[c("div",yo,[c("img",{src:o.introImageUrl,class:"w-full h-full object-contain",alt:"Intro"},null,8,vo)]),c("div",ko,[c("div",Co,[h(r,{icon:["fal","image"],class:"text-xs"}),t[4]||(t[4]=c("span",{class:"text-xs text-alert-400"},"Intro",-1))]),c("div",bo,[c("span",Io,y(((f=o.intro)==null?void 0:f.duration)||3)+"s",1)])])])):o.isEditMode&&(o.intro||n.allowImportStep)?(d(),C(l,{key:1,text:e.$t("newEditor.introTooltip"),disabled:n.allowImportStep},{default:_(()=>{var p,m,S;return[c("div",Po,[c("div",Do,[c("div",{class:R(["relative rounded-sm w-[160px] bg-[#202020] border-2 border-dashed border-gray-500 transition-all duration-300 flex items-center justify-center aspect-video overflow-hidden",{"hover:border-primary-500":!((p=o.intro)!=null&&p.imageUrl)}]),onClick:t[0]||(t[0]=(...u)=>o.handleFileSelect&&o.handleFileSelect(...u))},[(m=o.intro)!=null&&m.imageUrl?(d(),g(L,{key:0},[c("img",{src:o.introImageUrl,class:"w-full h-full object-contain",alt:"Intro"},null,8,xo),n.allowImportStep?(d(),g("div",Wo,[h(r,{class:"del-btn opacity-0 group-hover:opacity-100 w-4 h-4",icon:["far","trash-can"],onClick:Y(o.handleDeleteIntro,["stop"])},null,8,["onClick"])])):T("",!0)],64)):(d(),g(L,{key:1},[c("div",Ao,[h(r,{icon:["far","image"],class:"text-xl"}),t[5]||(t[5]=c("span",{class:"text-base"},"Intro",-1))]),c("div",Mo,[o.isUploading?(d(),C(r,{key:1,icon:["fas","spinner"],spin:"",class:"text-[32px]"})):(d(),C(a,{key:0,class:"text-[32px]"})),c("span",Ro,y(o.isUploading?"Uploading...":"Upload an image"),1)])],64))],2),o.intro?(d(),g("div",Oo,[c("div",Lo,[h(r,{icon:["fal","image"],class:"text-xs"}),t[6]||(t[6]=c("span",{class:"text-xs text-alert-400"},"Intro",-1))]),n.allowImportStep?(d(),g("div",Bo,[o.editingIntroDuration?(d(),g(L,{key:0},[Z(c("input",{"onUpdate:modelValue":t[1]||(t[1]=u=>o.introDuration=u),type:"number",min:"0",step:"0.1",class:"w-[50px] border text-center text-xs",onInput:t[2]||(t[2]=(...u)=>o.handleIntroDurationInput&&o.handleIntroDurationInput(...u))},null,544),[[Ie,o.introDuration,void 0,{number:!0}]]),h(r,{icon:["fas","check"],class:"text-xs text-success-400",onClick:o.handleSaveIntroDuration},null,8,["onClick"])],64)):(d(),g(L,{key:1},[c("span",Vo,y(((S=o.intro)==null?void 0:S.duration)||3)+"s",1),h(r,{icon:["far","pencil"],class:"text-xs",onClick:o.handleEditIntroDuration},null,8,["onClick"])],64))])):T("",!0)])):T("",!0)]),c("input",{ref:"fileInputRef",type:"file",accept:"image/jpeg, image/gif, image/png, image/webp, image/bmp, image/avif, image/x-icon",onChange:t[3]||(t[3]=(...u)=>o.handleFileChange&&o.handleFileChange(...u)),class:"hidden"},null,544)])]}),_:1},8,["text","disabled"])):T("",!0)}const Uo=ie(_o,[["render",No]]),Fo={name:"StepList",components:{BuilderExplorer:A(()=>W(()=>import("./BuilderExplorer-Z5A07wOu.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]))),IntroImageCard:Uo},props:{steps:{type:Array,required:!0},activeStep:{type:[String,Number],required:!0},imageMaps:{type:Object,required:!0},isEditMode:{type:Boolean,required:!0},sourceWorkflow:{type:Object,required:!0},addSegmentHandler:{type:Function,required:!0},allowImportStep:{type:Boolean,default:!1},layout:{type:String,default:"vertical"},hideIntroCard:{type:Boolean,default:!1}},emits:["step-click","step-delete"],expose:["scrollToStep"],setup(e){const t=gi(e,"isEditMode"),{isKctBlocked:n}=de(),{inputClass:o,editModeStepId:s,modifyTitle:i,toggleEditMode:r,clearEditStepId:a,saveStepTitle:l}=it({addSegment:f=>e.addSegmentHandler(f)});return{isEditMode:t,isKctBlocked:n,editModeStepId:s,modifyTitle:i,stepTitleInputClass:o,toggleEditModeCore:r,clearEditStepId:a,saveStepTitle:l}},data(){return{showConfirmDeleteId:null,showExplorer:!1,insertStepIdx:null,STEP_SELECTOR_TYPE:Wi,NEW_EDITOR_STEP_TYPE:ne}},methods:{isDeleteable(e){return this.isEditMode?this.isNativeStepEditable(e)||e.type===ne.IMPORT&&this.allowImportStep:!1},isNativeStepEditable(e){return this.isEditMode?e.type!==ne.IMPORT&&!this.allowImportStep:!1},handleClickStep(e){var t;this.isKctBlocked||((t=this.steps.find(n=>n.type===ne.IMPORT))==null?void 0:t.id)!==e&&this.$emit("step-click",e)},async toggleEditMode(e){this.isKctBlocked||e.type!==ne.IMPORT&&(this.$emit("step-click",e.id),this.isEditMode&&await this.toggleEditModeCore(e,{refs:this.$refs}))},async handleClickImportStep(e){if(!this.isEditMode)return!1;this.insertStepIdx=e,this.showExplorer=!0},handleAddSteps(e){const t=e.map(n=>({id:n.id,title:n.title,type:ne.IMPORT,poster:n.poster}));this.addSegmentHandler({type:U.IMPORT,target:$.STEP,steps:t,insertStepIdx:this.insertStepIdx}),this.showExplorer=!1},closeBuilderExplorer(){this.showExplorer=!1},async handleClickDeleteStep(e){if(!this.isEditMode)return!1;this.showConfirmDeleteId=e},handleConfirmDeleteStep(){this.$emit("step-delete",this.showConfirmDeleteId),this.showConfirmDeleteId=null},scrollToStep(e){var n;const t=(n=this.$refs[`step-${e}`])==null?void 0:n[0];t&&this.$refs.stepListContainer&&t.scrollIntoView({behavior:"smooth",block:"center"})}}},Ho=["onClick"],zo={key:0,class:"bg-danger-400 absolute z-20 w-full max-w-[160px] h-full rounded-lg flex flex-col items-center justify-center"},Ko={class:"text-sm text-center px-4"},jo={class:"mt-4 flex gap-2"},Go={key:0,class:"absolute opacity-0 group-hover:opacity-100 top-2 right-2 z-10 p-2 rounded-full bg-gray-700 w-8 h-8 flex items-center justify-center"},Xo=["onClick"],qo={key:0,class:"max-w-40 text-ellipsis overflow-hidden"},Yo={key:0,class:"text-alert-400 mr-1 capitalize"},Zo=["onBlur","onKeyup"],Qo=["onClick"];function Jo(e,t,n,o,s,i){const r=w("IntroImageCard"),a=w("font-awesome-icon"),l=w("DImage"),f=w("BuilderExplorer");return d(),g("div",{ref:"stepListContainer",class:R(["flex w-fit justify-start mx-auto items-start gap-6 h-full overflow-y-auto scrollbar-thin",{"flex-col":n.layout==="vertical","locked-scrollable":o.isKctBlocked}])},[n.hideIntroCard?T("",!0):(d(),C(r,{key:0,"allow-import-step":n.allowImportStep},null,8,["allow-import-step"])),(d(!0),g(L,null,ae(n.steps,(p,m)=>(d(),g("div",{ref_for:!0,ref:`step-${p.id}`,class:R(["relative w-full",{flex:n.layout==="horizontal"}]),key:`stepBadge-${p.id}`,onClick:Y(S=>i.handleClickStep(p.id),["stop"])},[n.allowImportStep&&o.isEditMode&&m===0?(d(),g("div",{key:0,class:"import-step-btn mr-6",onClick:t[0]||(t[0]=S=>i.handleClickImportStep(0))},[h(a,{icon:["fas","plus"],class:"text-white"})])):T("",!0),c("div",{class:R(["cursor-pointer group",{"w-[180px]":n.layout==="horizontal"}])},[s.showConfirmDeleteId===p.id?(d(),g("div",zo,[c("div",Ko,y(e.$t("editor.confirmRemoveStep")),1
2),c("div",jo,[c("button",{class:"rounded-lg border border-solid text-sm px-4 py-2 border-white text-white",onClick:t[1]||(t[1]=Y(S=>s.showConfirmDeleteId=null,["stop"]))},y(e.$t("action.no")),1),c("button",{class:"rounded-lg border border-solid text-sm px-4 py-2 border-white text-white",onClick:t[2]||(t[2]=Y((...S)=>i.handleConfirmDeleteStep&&i.handleConfirmDeleteStep(...S),["stop"]))},y(e.$t("action.yes")),1)])])):T("",!0),c("div",{class:R(["relative rounded-sm step-list-item",{"border-2 border-primary-500":n.activeStep===p.id}])},[i.isDeleteable(p)?(d(),g("div",Go,[h(a,{class:"del-btn opacity-0 group-hover:opacity-100 w-4 h-4",icon:["far","trash-can"],onClick:Y(S=>i.handleClickDeleteStep(p.id),["stop"])},null,8,["onClick"])])):T("",!0),h(l,{class:R(["h-full object-cover rounded-sm",`w-[${n.layout==="horizontal"?"160px":"100%"}]`]),src:p.poster||n.imageMaps[Math.floor(p.thumbnailTime??p.startTime)],"aspect-ratio":16/9},null,8,["class","src"])],2),c("div",{class:R(["step-list-item text-xs h-7 whitespace-nowrap text-ellipsis overflow-hidden mt-[10px] relative min-w-40",{"text-primary-500":n.activeStep===p.id}])},[c("div",{class:R(["flex items-center gap-2",{"cursor-pointer":p.type!==s.NEW_EDITOR_STEP_TYPE.IMPORT}]),onClick:Y(S=>i.toggleEditMode(p),["stop"])},[o.editModeStepId!==p.id?(d(),g("span",qo,[x(y(m+1)+". ",1),p.type===s.NEW_EDITOR_STEP_TYPE.IMPORT?(d(),g("span",Yo," ["+y(e.$t("newEditor.imported"))+"] ",1)):T("",!0),x(" "+y(p.title),1)])):T("",!0),i.isNativeStepEditable(p)?(d(),g(L,{key:1},[o.editModeStepId!==p.id?(d(),C(a,{key:0,class:"opacity-0 group-hover:opacity-100 cursor-pointer text-gray-400",icon:["far","pencil"]})):T("",!0)],64)):T("",!0)],10,Xo),Z(c("input",{ref_for:!0,ref:`stepTitleInput-${p.id}`,class:R([o.stepTitleInputClass,"w-40"]),type:"text","onUpdate:modelValue":t[3]||(t[3]=S=>o.modifyTitle=S),onBlur:S=>o.saveStepTitle(p.id),onKeyup:[ue(S=>o.saveStepTitle(p.id),["enter"]),t[4]||(t[4]=ue((...S)=>o.clearEditStepId&&o.clearEditStepId(...S),["esc"]))],maxlength:"90"},null,42,Zo),[[re,o.editModeStepId===p.id],[Ie,o.modifyTitle,void 0,{trim:!0}]])],2)],2),n.allowImportStep&&o.isEditMode?(d(),g("div",{key:1,class:"import-step-btn",onClick:S=>i.handleClickImportStep(m+1)},[h(a,{icon:["fas","plus"],class:"text-white"})],8,Qo)):T("",!0),s.showExplorer?(d(),C(f,{key:2,"picker-type":s.STEP_SELECTOR_TYPE.NEW_EDITOR,"added-steps":n.steps,"language-code":n.sourceWorkflow.languageCode,"workflow-id":n.sourceWorkflow.id,group:n.sourceWorkflow.group,onAddStepsEvent:i.handleAddSteps,onCloseExplorer:i.closeBuilderExplorer},null,8,["picker-type","added-steps","language-code","workflow-id","group","onAddStepsEvent","onCloseExplorer"])):T("",!0)],10,Ho))),128))],2)}const $o=ie(Fo,[["render",Jo],["__scopeId","data-v-a8987725"]]),es=["preview-top","preview-bottom"];function Ke(){document.querySelectorAll("[data-step-id]").forEach(t=>{t.classList.remove(...es)})}function ts({isEditMode:e,adjustedSteps:t,addSegment:n}){const o=F(!1),s=F(null),i=F(0),r=F(0);function a(){if(!s.value)return null;const S=t.value,u=S.findIndex(v=>v.id===s.value);if(u===-1)return null;const I=S[u];if(!I)return null;const k=S[u+1];if(!k)return null;const D=I.endTime>i.value;return{draggingStepIndex:u,draggingStep:I,isDraggingUp:D,nextStep:k}
2}function l(){if(i.value===0&&r.value===0)return null;const S=a();if(!S)return null;const{draggingStep:u,isDraggingUp:I,nextStep:k}=S;return I?{type:U.ADJUST,target:$.STEP,stepId:u.id,start:u.startTime,end:i.value}:{type:U.ADJUST,target:$.STEP,stepId:k.id,start:r.value,end:k.endTime}}function f(S,u){e.value&&(o.value=!0,s.value=u)}function p(S,u){const I=fe(u),k=Le(u);if(i.value===I&&r.value===k)return;Ke(),i.value=I,r.value=k;const D=a();if(!D)return;S.currentTarget.classList.add(D.isDraggingUp?"preview-top":"preview-bottom")}function m(){const S=l();S&&n(S),s.value=null,o.value=!1,i.value=0,r.value=0,Ke()}return{isDragging:o,draggingStepId:s,dragTargetSentenceStartTime:i,dragTargetSentenceEndTime:r,handleDragStart:f,handleDragOver:p,handleDragEnd:m}}const is=()=>{const{getter_adjusted_steps_with_import:e}=ge("editorAdvance",["getter_adjusted_steps_with_import"]),{setActiveStep:t}=Te("editorAdvance",["setActiveStep"]),n=F(null),o=i=>{if(!e.value||e.value.length===0)return null;const r=e.value.find(a=>i>=a.startTime&&i<a.endTime);return r?r.id:null};return{findCurrentStepByTime:o,scrollStepListToTime:i=>{const r=o(i);r&&(t(r),n.value&&n.value.scrollToStep(r))},stepListRef:n}},os=(e,t,n,o,s)=>({text:e.word,startTime:fe(e),endTime:Le(e),startStepId:t,endStepId:t,startSentenceIndex:n,endSentenceIndex:n,startWordIndex:o,endWordIndex:o,sentenceStartTime:fe(s),crossStep:!1}),ss=(e,t,n,o,s)=>os(e,t,n,o,s),ns=()=>({syncVideoToWord:(n,o,s,i)=>{const{setCurrentTime:r,seekVideo:a,setActiveStep:l,scrollStepListToTime:f,updateSentenceStartTime:p}=i,m=fe(n),S=(s==null?void 0:s.originalStartTime)??(s==null?void 0:s.startTime)??null;r(m),a(m),s&&p&&S!=null&&p(S),l(o),f(m)},syncVideoToSentence:(n,o)=>{const{setCurrentTime:s,seekVideo:i,updateSentenceStartTime:r}=o,a=fe(n);s(a),i(a),r&&r(a)}}),je={text:"",startTime:0,endTime:0,startStepId:"",endStepId:"",startSentenceIndex:-1,endSentenceIndex:-1,startWordIndex:-1,endWordIndex:-1,crossStep:!1},rs={name:"EditorContent",directives:{"click-outside":Bt},components:{EditorPreviewPlayer:To,StepList:$o,ReplacePopup:A(()=>W(()=>import("./ReplacePopup-m0wE5u4H.js"),__vite__mapDeps([31,4,2,3,1,5,6,7,8,9,10,11,12,13,14,15,16,17,32,33,34])))},setup(){const{addSegment:e}=Te("editorAdvance",["addSegment"]),{sourceWorkflow:t}=me("editorAdvance",["sourceWorkflow"]),{stepSentencesMap:n,getStepSentences:o}=Ni(),{DATA_ATTR_SENTENCE:s,DATA_ATTR_STEP:i,scrollToSentence:r,scrollToStep:a}=Ri(),{isTrimmedOrDeletedSubtitle:l,getTrimmedOrDeletedSubtitleSegment:f}=Fi(),{showReplaceDialog:p,correctedText:m,totalSearchedResult:S,currentSearchIdx:u,isCurrentHighlightedWord:I,isHighLightedWord:k,highlightWord:D,highlightPrev:v,highlightNext:P,replaceSingleWord:b,replaceAllWords:E,confirmCorrection:N,openReplaceDialog:G,closeReplaceDialog:H}=Ui(),{inputClass:X,editModeStepId:le,modifyTitle:V,toggleEditMode:z,clearEditStepId:K,saveStepTitle:De}=it({addSegment:e}),{stepListRef:xe,scrollStepListToTime:We}=is(),{isEditMode:q}=_e(),{isKctBlocked:J}=de(),{getter_adjusted_steps:Ee}=ge("editorAdvance",["getter_adjusted_steps"]),{isDragging:nt,draggingStepId:rt,dragTargetSentenceStartTime:at,dragTargetSentenceEndTime:lt,handleDragStart:dt,handleDragOver:ct,handleDragEnd:ut}=ts({isEditMode:q,adjustedSteps:Ee,addSegment:e}),{syncVideoToWord:ht,syncVideoToSentence:pt}=ns(),{findNextWord:mt}=Mi(),{editingWord:ft,editingWordText:gt,INPUT_MIN_WIDTH:St,INPUT_PADDING:wt,INPUT_WIDTH_OFFSET:Tt,isEditingWord:_t,adjustInputWidth:Et,handleWordInputResize:yt,startEditingWord:vt,clearEditingState:kt,applyWordEditIfChanged:Ct,shouldPreventContextMenuClose:bt}=Ai(),{getSentenceWordPreviewStates:It}=Hi(),{getWordPreviewTooltip:Pt,wordPreviewTooltip:Dt,onWordPreviewEnter:xt,onWordPreviewLeave:Wt}=zi();return{editorAdvanceAddSegment:e,sourceWorkflow:t,stepSentencesMap:n,getStepSentences:o,wordPreviewTooltip:Dt,onWordPreviewEnter:xt,onWordPreviewLeave:Wt,DATA_ATTR_SENTENCE:s,DATA_ATTR_STEP:i,scrollToSentence:r,scrollToStep:a,showReplaceDialog:p,correctedText:m,totalSearchedResult:S,currentSearchIdx:u,isCurrentHighlightedWord:I,isHighLightedWord:k,highlightWord:D,highlightPrev:v,highlightNext:P,replaceSingleWord:b,replaceAllWords:E,confirmCorrection:N,openReplaceDialog:G,closeReplaceDialog:H,editModeStepId:le,modifyTitle:V,stepTitleInputClass:X,toggleEditModeCore:z,clearEditStepId:K,saveStepTitle:De,stepListRef:xe,scrollStepListToTime:We,isEditMode:q,isKctBlocked:J,createSelectedTextFromWord:ss,syncVideoToWord:ht,syncVideoToSentence:pt,findNextWord:mt,editingWord:ft,editingWordText:gt,INPUT_MIN_WIDTH:St,INPUT_PADDING:wt,INPUT_WIDTH_OFFSET:Tt,isEditingWord:_t,adjustInputWidth:Et,handleWordInputResize:yt,startEditingWord:vt,clearEditingState:kt,applyWordEditIfChanged:Ct,shouldPreventContextMenuClose:bt,getSentenceWordPreviewStates:It,getWordPreviewTooltip:Pt,isTrimmedOrDeletedSubtitle:l,getTr
2immedOrDeletedSubtitleSegment:f,getEffectiveStartTime:fe,getEffectiveEndTime:Le,isDragging:nt,draggingStepId:rt,dragTargetSentenceStartTime:at,dragTargetSentenceEndTime:lt,handleDragStart:dt,handleDragOver:ct,handleDragEnd:ut}},computed:{...O("editorAdvance",["sentences","activeStep","currentTime","intro"]),...O("editorZoom",["imageMaps"]),...Q("editorAdvance",["getter_adjusted_steps","getter_adjusted_sentences_with_delete_subtitles","getter_adjusted_steps_with_import","getter_clip_items"]),steps(){return this.getter_adjusted_steps_with_import.map(e=>{var s;const t=this.activeStep===e.id,o=((s=Vt(this.getter_clip_items,e.startTime,e.endTime)[0])==null?void 0:s.startTime)??e.startTime;return{...e,thumbnailTime:o,classesConfig:{divider:["border-solid border-gray-700 group-hover:border-primary-500",t?"border-primary-500":"border-gray-500"]}}})},isSelectMultiSentence(){return this.selectedText.startStepId!==this.selectedText.endStepId},isSelectMultiWord(){return this.selectedText.startWordIndex!==this.selectedText.endWordIndex},workflowId(){return this.$route.params.workflowId},canBreakLine(){if(this.isSelectMultiWord)return!1;const t=this.getStepSentences(this.selectedText.startStepId)[this.selectedText.startSentenceIndex];return!t||!t.words?!1:!(this.selectedText.startWordIndex>=t.words.length-1)},canMergeSelection(){return!this.selectedText.text||!this.selectedText.startTime||!this.selectedText.endTime?!1:!(this.selectedText.startStepId===this.selectedText.endStepId&&this.selectedText.startSentenceIndex===this.selectedText.endSentenceIndex)&&!this.selectedText.crossStep},selectionHasTrimOrDeleteSubtitle(){const e=this.selectedText.startStepId;if(!e||this.selectedText.crossStep)return!1;const t=this.wordDisplayStatesByStep[e];if(!t)return!1;const n=this.selectedText.startSentenceIndex,o=this.selectedText.endSentenceIndex,s=this.selectedText.startWordIndex,i=this.selectedText.endWordIndex;for(let r=n;r<=o;r++){const a=t[r];if(!a)continue;const l=r===n?s:0,f=r===o?i:a.length-1;for(let p=l;p<=f;p++){const m=a[p];if((m==null?void 0:m.segmentType)===ze.TRIM||(m==null?void 0:m.segmentType)===ze.DELETE_SUBTITLE)return!0}}return!1},canCombineWords(){return this.isSelectMultiWord&&!this.canMergeSelection&&!this.selectedText.crossStep&&!this.selectionHasTrimOrDeleteSubtitle},wordDisplayStatesByStep(){const e=this.stepSentencesMap,t={};return Object.keys(e).forEach(n=>{const o=e[n];t[n]=o.map(s=>this.getSentenceWordPreviewStates(s,void 0,{interactive:!this.isKctBlocked}))}),t}},data(){return{currentSentenceStartTime:-1,showContextMenu:!1,contextMenuStyle:{to
2p:"0px",left:"0px"},selectedText:{...je},SEGMENT_TYPE:U,showRestoreContextMenu:!1,NEW_EDITOR_STEP_TYPE:ne}},methods:{...B("editorAdvance",["setActiveStep","deleteIntro","deleteStep","markTextAsDeleted","setCurrentTime","addSegment","createStep","removeSegment"]),...B("editorPlayer",["playVideo","seekVideo"]),getNumberWithZero:Lt,isPlayingWord({originalStartTime:e,originalEndTime:t}){return e<=this.currentTime&&t>this.currentTime},getWordDisplayState(e,t,n,o){var l,f;const s=(f=(l=this.wordDisplayStatesByStep[e])==null?void 0:l[t])==null?void 0:f[n],i=["inline break-all px-0.5",{"hover:cursor-pointer hover:bg-primary-400 hover:text-white":!this.isKctBlocked}],r=(s==null?void 0:s.classes)??"",a={"bg-gray-600":this.isHighLightedWord({stepId:e,sentenceIdx:t,wordIdx:n}),"!bg-success-400 !text-white":this.isCurrentHighlightedWord(this.selectedText,{stepId:e,sentenceIdx:t,wordIdx:n}),"bg-primary-400 text-white":o&&this.isPlayingWord(o)};return[i,r,a]},getWordPreviewTooltipText(e,t,n){var s,i,r;if(this.isKctBlocked)return null;const o=(r=(i=(s=this.wordDisplayStatesByStep[e])==null?void 0:s[t])==null?void 0:i[n])==null?void 0:r.segmentType;return this.getWordPreviewTooltip(o)},async handleDeleteStep(e){this.isEditMode&&this.deleteStep(e)},highlightWithScroll(e){const t=e();t&&this.scrollToSentence(t)},handleHighlightPrev(){this.highlightWithScroll(()=>this.highlightPrev(this.selectedText))},handleHighlightNext(){this.highlightWithScroll(()=>this.highlightNext(this.selectedText))},handleReplaceSingle(){const e=this.replaceSingleWord(this.selectedText);e?this.highlightWithScroll(()=>this.highlightWord(e,this.selectedText)):this.handleCloseReplaceDialog()},handleReplaceAll(){this.replaceAllWords(),this.handleCloseReplaceDialog()},handleCloseReplaceDialog(){this.closeReplaceDialog(),this.resetSelectedText(),this.closeContextMenu()},setVideoToWordTime(e,t){const n=this.getEffectiveStartTime(e),o=this.getter_adjusted_sentences_with_delete_subtitles.find(s=>s.words.some(i=>i.startTime===n));this.syncVideoToWord(e,t,o,{setCurrentTime:this.setCurrentTime,seekVideo:this.seekVideo,setActiveStep:this.setActiveStep,scrollStepListToTime:this.scrollStepListToTime,updateSentenceStartTime:s=>{this.currentSentenceStartTime=s}})},setVideoToSentenceTime(e){this.syncVideoToSentence(e,{setCurrentTime:this.setCurrentTime,seekVideo:this.seekVideo,updateSentenceStartTime:t=>{this.currentSentenceStartTime=t}})},goToStep(e){if(this.getter_adjusted_steps.findIndex(o=>o.id===e)===-1)return;const n=this.getStepSentences(e);n.length>0&&(this.setVideoToWordTime(n[0].words[0],e),this.scrollToStep(e))},videoTimeUpdate(e){const t=this.getter_adjusted_sentences_with_delete_subtitles;if(!t.length)return;const n=this.findSentenceIndexByTime(t,e),o=n>=0?t[n]:null;if(o){const s=this.getEffectiveStartTime(o);if(this.currentSentenceStartTime===s)return;this.currentSentenceStartTime=s,this.$nextTick(()=>{this.scrollToSentence(s)})}else this.currentSentenceStartTime=-1;this.scrollStepListToTime(e)},findSentenceIndexByTime(e,t){let n=0,o=e.length-1;for(;n<=o;){const s=n+o>>>1,i=e[s];if(t<i.startTime)o=s-1;else if(t>=i.endTime)n=s+1;else return s}return-1},handleTextSelection(){if(!this.isEditMode)return;const e=window.getSelection();if(!e||!e.toString()){this.closeContextMenu();return}if(!e.toString().trim())return;const n=e.getRangeAt(0),o=n.startContainer.parentNode,s=n.endContainer.parentNode,i=o.closest("[data-step-id]"),r=s.closest("[data-step-id]");if(!i||!r)return;const a=i.getAttribute("data-step-id"),l=r.getAttribute("data-step-id"),f=this.getStepSentences(a),p=this.getStepSentences(l),m=Array.from(i.parentNode.children).indexOf(i),S=Array.from(r.parentNode.children).indexOf(r),u=f[m-1],I=p[S-1],k=this.findWordInSentence(u,o),D=this.findWordInSentence(I,s);if(!k||!D)return;let v=o.closest("[data-word-index]"),P=s.closest("[data-word-index]");if(!v||!P)return;const b=document.createRange();b.setStart(v,0),b.setEnd(P,P.childNodes.length),e.removeAllRanges(),e.addRange(b);const E=e.toString().trim();this.selectedText={text:E,startTime:this.getEffectiveStartTime(k),endTime:this.getEffectiveEndTime(D),startStepId:a,endStepId:l,startSentenceIndex:m-1,endSentenceIndex:S-1,startWordIndex:parseInt(v.getAttribute("data-word-index")),endWordIndex:parseInt(P.getAttribute("data-word-index")),crossStep:a!==l},this.setActiveStep(a),this.openContextMenu(b)},openContextMenu(e){this.setContextMenuPosition(e,200,40),this.showContextMenu=!0},openRestoreContextMenu(e){this.setContextMenuPosition(e,120,40),this.showRestoreContextMenu=!0},findWordInSentence(e,t){var i;const o=((i=t==null?void 0:t.closest)==null?void 0:i.call(t,"[data-word-index]"))??null;if(!o)return null;const s=parseInt(o.getAttribute("data-word-index"));return e.words[s]},setContextMenuPosition(e,t=200,n=40){const o=e.getBoundingClientRect();let s=o.bottom+window.scrollY,i=o.left+window.scrollX;s+n>window.innerHeight+window.scrollY&&(s=o.top+window.scrollY-n),i+t>
2window.innerWidth+window.scrollX&&(i=window.innerWidth+window.scrollX-t),this.contextMenuStyle={top:`${s}px`,left:`${i}px`}},closeContextMenu(e){this.shouldPreventContextMenuClose(e)||(this.showContextMenu=!1,this.showRestoreContextMenu=!1,this.showReplaceDialog||this.resetSelectedText())},resetSelectedText(){this.selectedText={...je}},handleCombineWords(){const t=this.getStepSentences(this.selectedText.startStepId)[this.selectedText.startSentenceIndex],n=this.selectedText.startWordIndex,o=this.selectedText.endWordIndex,i=t.words.slice(n,o+1).map(r=>r.word).join("");this.addSegment({type:U.COMBINE,target:$.WORD,start:this.selectedText.startTime,end:this.selectedText.endTime,stepId:this.selectedText.startStepId,combinedText:i}),window.getSelection().removeAllRanges()},handleContextMenuAction(e){switch(e){case U.BREAK_LINE:this.handleBreakLine();break;case U.CORRECT:this.editingWord&&this.cancelWordEdit(),this.openReplaceDialog(this.selectedText);break;case U.VOICEOVER:console.log("Voice Over action:",this.selectedText);break;case U.DELETE:case U.DELETE_SUBTITLE:this.handleDeleteAction(e);break;case U.MERGE:this.handleMergeSentences();break;case U.COMBINE:this.handleCombineWords();break}this.closeContextMenu()},handleDeleteAction(e){if(this.selectedText.startStepId!==this.selectedText.endStepId){const t=this.getStepSentences(this.selectedText.startStepId),n=t[t.length-1];this.addSegment({type:e,target:$.SENTENCE,start:this.selectedText.startTime,end:this.getEffectiveEndTime(n)});const o=this.getter_adjusted_steps.findIndex(a=>a.id===this.selectedText.startStepId),s=this.getter_adjusted_steps.findIndex(a=>a.id===this.selectedText.endStepId);for(let a=o+1;a<s;a++){const l=this.getter_adjusted_steps[a],f=this.getStepSentences(l.id);if(f.length>0){const p=f[0],m=f[f.length-1];this.addSegment({type:e,target:$.SENTENCE,start:this.getEffectiveStartTime(p),end:this.getEffectiveEndTime(m)})}}const r=this.getStepSentences(this.selectedText.endStepId)[0];this.addSegment({type:e,target:$.SENTENCE,start:this.getEffectiveStartTime(r),end:this.selectedText.endTime})}else this.addSegment({type:e,target:$.SENTENCE,start:this.selectedText.startTime,end:this.selectedText.endTime})},handleMergeSentences(){this.addSegment({type:U.MERGE,target:$.SENTENCE,start:this.selectedText.startTime,end:this.selectedText.endTime,startStepId:this.selectedText.startStepId,endStepId:this.selectedText.endStepId,startSentenceIndex:this.selectedText.startSentenceIndex,endSentenceIndex:this.selectedText.endSentenceIndex}),window.getSelection().removeAllRanges()},handleBreakLine(){this.addSegment({type:U.BREAK_LINE,target:$.SENTENCE,start:this.selectedText.startTime,end:this.selectedText.endTime}),window.getSelection().removeAllRanges()},async insertStep(e,t){this.isEditMode&&this.createStep({insertIndex:e,start:t})},async toggleEditMode(e){this.isKctBlocked||e.type!==ne.IMPORT&&(this.setActiveStep(e.id),this.setCurrentTime(e.startTime),this.isEditMode&&await this.toggleEditModeCore(e,{refs:this.$refs}))},handleWordClick(e,t,n,o,s){if(!this.isEditMode)return;const i=this.getEffectiveStartTime(t),r=n.words.findIndex(f=>this.getEffectiveStartTime(f)===i),a=e.target,l=a.offsetWidth||a.getBoundingClientRect().width;this.startEditingWord(o,s,r,t.word,l),this.selectedText=this.createSelectedTextFromWord(t,o,s,r,n),this.scrollStepListToTime(i),this.isTrimmedOrDeletedSubtitle(t)?this.openRestoreContextMenu(a):this.openContextMenu(a),this.setActiveStep(o),this.focusWordInput(o,s,r,t),this.$nextTick(()=>{requestAnimationFrame(()=>{this.setVideoToWordTime(t,o)})})},focusWordInput(e,t,n,o,s=null){this.$nextTick(()=>{const i=this.$refs[`wordInput-${e}-${t}-${n}`];if(i&&i[0])this.adjustInputWidth(i[0]),i[0].focus(),i[0].select(),s&&(this.isTrimmedOrDeletedSubtitle(o)?this.openRestoreContextMenu(i[0]):this.openContextMenu(i[0]));else if(s){const r=this.getEffectiveStartTime(s),a=document.querySelector(`[data-step-id="${e}"][data-${this.DATA_ATTR_SENTENCE}="${r}"]`);if(a){const l=a.querySelector(`[data-word-index="${n}"]`);if(l&&this.editingWord){const f=l.offsetWidth||l.getBoundingClientRect().width;this.editingWord.width=Math.max(f,this.INPUT_MIN_WIDTH)}}}})},handleWordInputResizeWrapper(e){const t=e.target;this.handleWordInputResize(t)}
2,handleWordEditBlur(e,t,n,o,s){if(!this.editingWord)return;const i=s==null?void 0:s.relatedTarget;i&&i.closest(".fixed.bg-gray-800")||(this.applyWordEditIfChanged(e,t,n,o,(r,a,l,f)=>{this.replaceSingleWordDirectly(r,a,l,f)}),this.clearEditingState())},handleWordEditComplete(e,t,n,o){if(!this.editingWord)return;if(this.applyWordEditIfChanged(e,t,n,o,(i,r,a,l)=>{this.replaceSingleWordDirectly(i,r,a,l)})){const r=this.getStepSentences(e)[t];this.selectedText=this.createSelectedTextFromWord(o,e,t,n,r)}this.clearEditingState()},cancelWordEdit(){this.clearEditingState(),setTimeout(()=>{this.closeContextMenu()},1e3)},handleTabToNextWord(e,t,n,o){if(!this.editingWord)return;this.applyWordEditIfChanged(e,t,n,o,(i,r,a,l)=>{this.replaceSingleWordDirectly(i,r,a,l)});const s=this.findNextWord(e,t,n,{getStepSentences:this.getStepSentences,getter_adjusted_steps:this.getter_adjusted_steps,isDeleted:this.isTrimmedOrDeletedSubtitle});if(s){this.processNextWord(s);return}this.handleWordEditComplete(e,t,n,o)},processNextWord(e){const{word:t,stepId:n,sentenceIdx:o,wordIdx:s,sentence:i}=e;this.isTrimmedOrDeletedSubtitle(t)?this.switchToDeletedWord(n,o,s,t,i):this.switchToWordEdit(n,o,s,t,i)},switchToWordEdit(e,t,n,o,s){this.clearEditingState(),this.$nextTick(()=>{this.startEditingWord(e,t,n,o.word,this.INPUT_MIN_WIDTH),this.selectedText=this.createSelectedTextFromWord(o,e,t,n,s),this.syncVideoToWord(o,e,s,{setCurrentTime:this.setCurrentTime,seekVideo:this.seekVideo,setActiveStep:this.setActiveStep,scrollStepListToTime:this.scrollStepListToTime,updateSentenceStartTime:i=>{this.currentSentenceStartTime=i}}),this.focusWordInput(e,t,n,o,s)})},switchToDeletedWord(e,t,n,o,s){this.clearEditingState(),this.closeContextMenu(),this.selectedText=this.createSelectedTextFromWord(o,e,t,n,s),this.syncVideoToWord(o,e,s,{setCurrentTime:this.setCurrentTime,seekVideo:this.seekVideo,setActiveStep:this.setActiveStep,scrollStepListToTime:this.scrollStepListToTime,updateSentenceStartTime:i=>{this.currentSentenceStartTime=i}}),this.$nextTick(()=>{const i=document.querySelector(`[data-step-id="${e}"][data-${this.DATA_ATTR_SENTENCE}="${this.getEffectiveStartTime(s)}"]`);if(i){const r=i.querySelector(`[data-word-index="${n}"]`);r&&this.openRestoreContextMenu(r)}})},replaceSingleWordDirectly(e,t,n,o){if(!o||!o.trim())return;const i=this.getStepSentences(e)[t];if(!i||!i.words[n])return;const r={startStepId:e,startSentenceIndex:t,startWordIndex:n};this.confirmCorrection(r,o)},closeRestoreContextMenu(){this.showRestoreContextMenu=!1,this.resetSelectedText()},handleRestoreDeletedText(){const e=this.getTrimmedOrDeletedSubtitleSegment(this.selectedText);e?(this.removeSegment(e),this.openAlert({type:"success",message:this.$t("newEditor.textRestoredSuccessfully")})):this.openAlert({type:"error",message:this.$t("newEditor.unableToRestoreTextSegment")}),this.closeRestoreContextMenu()},async handleDeleteIntro(){this.isEditMode&&this.deleteIntro()}}},as={class:"flex items-start h-full py-6 px-4"},ls={class:"flex w-[15%] flex-col justify-start items-start gap-6 h-full overflow-y-auto pr-6"},ds={key:0,class:"step-title-container justify-between text-alert-400 border border-alert-400 shrink-0"},cs={class:"flex items-center gap-1"},us={class:"capitalize"},hs={key:0,class:"step-title-container justify-between text-alert-400 border border-alert-400"},ps={class:"flex items-center gap-1"},ms={class:"capitalize"},fs={class:"capitalize"},gs={class:"flex-shrink-0"},Ss={class:"text-ellipsis-1"},ws=["onClick"],Ts={class:"capitalize"},_s={class:"flex-shrink-0"},Es=["onClick"],ys={class:"text-ellipsis-1"},vs=["onBlur","onKeyup"],ks=["data-step-id","onDragover"],Cs=["data-word-index","onMouseenter","onClick"],bs=["onBlur","onKeyup","onKeydown"],Is={key:0,class:"flex py-2 opacity-0 hover:opacity-100 items-center w-full absolute -bottom-[23px] left-0"},Ps=["onClick"],Ds=["draggable","onDragstart"],xs=["onClick"],Ws={class:"w-1/2 h-full overflow-hidden"},As={class:"flex flex-row gap-2 text-gray-300 mt-5 text-sm whitespace-pre"},Ms={class:"capitalize"},Rs={class:"capitalize"},Os={class:"capitalize"},Ls={class:"capitalize"},Bs={class:"capitalize"},Vs={class:"capitalize"},Ns={class:"capitalize"};function Us(e,t,n,o,s,i){const r=w("StepList"),a=w("font-awesome-icon"),l=w("DTooltip"),f=w("EditorPreviewPlayer"),p=w("DDropdownItem2"),m=w("ReplacePopup"),S=Si("click-outside");return d(),g("div",as,[c("div",ls,[h(r,{ref:"stepListRef",steps:i.steps,"active-step":e.activeStep,"image-maps":e.imageMaps,"is-edit-mode":o.isEditMode,"source-workflow":o.sourceWorkflow,"add-segment-handler":o.editorAdvanceAddSegment,onStepClick:i.goToStep,onStepDelete:i.handleDeleteStep},null,8,["steps","active-step","image-maps","is-edit-mode","source-workflow","add-segment-handler","onStepClick","onStepDelete"])]),c("div",{class:R(["sentence-list w-[35%] flex-1 overflow-y-auto scrollbar-thin h-full inline-flex flex-col justify-start items-center gap-2 pr-6",{"locked-scrollable":o.isKctBlocked}])},[e.intro?(d(),g("div",ds,[c("div",cs,[h(a,{icon:["far","image"]}
2),c("span",us,y(e.$t("newEditor.intro")),1)]),o.isEditMode?(d(),g("div",{key:0,class:"text-soft cursor-pointer",onClick:t[0]||(t[0]=Y((...u)=>i.handleDeleteIntro&&i.handleDeleteIntro(...u),["stop"]))},[h(l,{text:e.$t("newEditor.deleteIntro")},{default:_(()=>[h(a,{icon:["far","trash-can"]})]),_:1},8,["text"])])):T("",!0)])):T("",!0),(d(!0),g(L,null,ae(i.steps,(u,I)=>(d(),g("div",{class:"mb-2 flex flex-col w-full",key:u.id},[u.type===s.NEW_EDITOR_STEP_TYPE.IMPORT?(d(),g("div",hs,[c("div",ps,[c("span",ms,"["+y(e.$t("newEditor.imported"))+"]",1),c("span",fs,y(e.$t("all.step")),1),c("span",gs,y(i.getNumberWithZero({num:I+1}))+" â¢",1),c("span",Ss,y(u.title),1)]),o.isEditMode?(d(),g("div",{key:0,class:"text-soft cursor-pointer",onClick:Y(k=>i.handleDeleteStep(u.id),["stop"])},[h(l,{text:e.$t("newEditor.deleteImportedStep")},{default:_(()=>[h(a,{icon:["far","trash-can"]})]),_:1},8,["text"])],8,ws)):T("",!0)])):(d(),g("div",Ne({key:1,class:"step-title-container",[`data-${o.DATA_ATTR_STEP}`||""]:u.id}),[c("span",Ts,y(e.$t("all.step")),1),c("span",_s,y(i.getNumberWithZero({num:I+1}))+" â¢",1),o.editModeStepId!==u.id?(d(),g("div",{key:0,class:R(["justify-start flex items-center gap-1 group",{"cursor-pointer":o.isEditMode}]),onClick:Y(k=>i.toggleEditMode(u),["stop"])},[c("span",ys,y(u.title),1),o.isEditMode?(d(),C(a,{key:0,class:"opacity-0 group-hover:opacity-100 text-gray-400",icon:["far","pencil"]})):T("",!0)],10,Es)):T("",!0),Z(c("input",{ref_for:!0,ref:`stepTitleInput-${u.id}`,class:R(o.stepTitleInputClass),type:"text","onUpdate:modelValue":t[1]||(t[1]=k=>o.modifyTitle=k),onBlur:k=>o.saveStepTitle(u.id),onKeyup:[ue(k=>o.saveStepTitle(u.id),["enter"]),t[2]||(t[2]=ue((...k)=>o.clearEditStepId&&o.clearEditStepId(...k),["esc"]))],maxlength:"90"},null,42,vs),[[re,o.isEditMode&&o.editModeStepId===u.id],[Ie,o.modifyTitle,void 0,{trim:!0}]])],16)),(d(!0),g(L,null,ae(o.stepSentencesMap[u.id]??[],(k,D)=>(d(),g("div",Ne({class:"mb-1 text-left px-4 py-2 text-lg relative",key:`stepContent-${u.id}-${o.getEffectiveStartTime(k)}`,"data-step-id":u.id,[`data-${o.DATA_ATTR_SENTENCE}`||""]:o.getEffectiveStartTime(k),onMouseup:t[8]||(t[8]=(...v)=>i.handleTextSelection&&i.handleTextSelection(...v)),onDragover:v=>o.handleDragOver(v,k)}),[(d(!0),g(L,null,ae(k.words,(v,P)=>{var b;return d(),g(L,{key:`step-${u.id}-sentenct${D}-word-${P}`},[o.isEditingWord(u.id,D,P)?Z((d(),g("input",{key:1,ref_for:!0,ref:`wordInput-${u.id}-${D}-${P}`,type:"text","onUpdate:modelValue":t[4]||(t[4]=E=>o.editingWordText=E),style:ee({width:(b=o.editingWord)!=null&&b.width?`${o.editingWord.width}px`:"auto",minWidth:"50px"}),class:"inline-block rounded px-0.5 text-white outline-none border-2 border-primary-500",onBlur:E=>i.handleWordEditBlur(u.id,D,P,v,E),onKeyup:[ue(E=>i.handleWordEditComplete(u.id,D,P,v),["enter"]),t[5]||(t[5]=ue((...E)=>i.cancelWordEdit&&i.cancelWordEdit(...E),["esc"]))],onKeydown:ue(Y(E=>i.handleTabToNextWord(u.id,D,P,v),["prevent"]),["tab"]),onInput:t[6]||(t[6]=E=>i.handleWordInputResizeWrapper(E)),onClick:t[7]||(t[7]=Y(()=>{},["stop"]))},null,44,bs)),[[Ie,o.editingWordText,void 0,{trim:!0}]]):(d(),g("div",{key:0,"data-word-index":P,class:R(i.getWordDisplayState(u.id,D,P,v)),onMouseenter:E=>o.onWordPreviewEnter(E,i.getWordPreviewTooltipText(u.id,D,P)),onMouseleave:t[3]||(t[3]=(...E)=>o.onWordPreviewLeave&&o.onWordPreviewLeave(...E)),onClick:E=>i.handleWordClick(E,v,k,u.id,D)},y(v.word),43,Cs))],64)}),128)),D!==(o.stepSentencesMap[u.id]??[]).length-1&&!o.isKctBlocked?(d(),g("div",Is,[t[20]||(t[20]=c("hr",{class:"w-4 border-primary-500 border-dashed"},null,-1)),o.isEditMode?(d(),g("button",{key:0,class:"w-5 h-5 text-primary-400 flex items-center justify-center text-[14px]",onClick:v=>i.insertStep(I,o.getEffectiveEndTime(k))},[h(a,{icon:["fas","scissors"],class:"text-primary-400"})],8,Ps)):T("",!0),t[21]||(t[21]=c("hr",{class:"flex-1 border-primary-500 border-dashed"},null,-1))])):T("",!0)],16,ks))),128)),I!==e.getter_adjusted_steps.length-1?(d(),g("div",{key:2,draggable:o.isEditMode,class:"flex justify-end w-full items-center group",onDragstart:k=>o.handleDragStart(k,u.id),onDragover:t[9]||(t[9]=Y(()=>{},["prevent"])),onDragend:t[10]||(t[10]=k=>o.handleDragEnd(k))},[c("hr",{class:R(["w-4",u.classesConfig.divider])},null,2),o.isEditMode?(d(),g("button",{key:0,class:R(["w-5 h-5 text-gray-500 flex items-center justify-center text-[14px] hover:text-gray-400",{"text-primary-500":e.activeStep===u.id}])},[h(a,{icon:["fas","angles-up-down"]})],2)):T("",!0),c("hr",{class:R(["w-4",u.classesConfig.divider])},null,2),o.isEditMode?(d(),C(l,{key:1,text:e.$t("newEditor.deleteStepTooltip")},{default:_(()=>[c("button",{onClick:k=>i.handleDeleteStep(i.steps[I+1].id),class:"hover:text-gray-400 w-5 h-5 text-gray-500 flex items-center justify-center text-[16px]"},[h(a,{icon:["far","trash-can"]})],8,xs)]),_:2},1032,["text"])):T("",!0),c("hr",{class:R(["flex-1",u.classesConfig.divider])},null,2)],40,Ds)):T("",!0)]))),128)),o.wordPreviewTooltip.visible?(d(),g("div",{key:1,class:"tooltip",style:ee(o.wordPreviewTooltip.style)},y(o.wordPreviewTooltip.text),5)):T("",!0)],2),t[22]||(t[22]=c("div",{class:"w-[1px] h-full bg-gray-3 mr-6"},null,-1)),c("div",Ws,[h(f,{onHandleVideoOnTimeUpdate:i.videoTimeUpdate},null,8,["onHandleVideoOnTimeUpdate"]),c("div",As,[h(a,{icon:["far","circle-info"],class:"flex-shrink-0 text-base mt-1"}),x(" "+y(e.$t("newEditor.previewLimitations")),1)])]),s.showContextMenu?Z((d(),g("div",{key:0,class:"fixed bg-gray-800 shadow-lg rounded p-2 z-50 flex flex-col gap-1",style:ee(s.contextMenuStyle),onMousedown:t[17]||(t[17]=Y(()=>{},["stop"]))},[h(l,{disabled:!i.isSelectMultiWord,text:e.$t("newEditor.onlyAvailableForSingleWords"),"placement-down":""},{default:_(()=>[h(p,{disabled:i.isSelectMultiWord,onClick:t[11]||(t[11]=u=>i.handleContextMenuAction(s.SEGMENT_TYPE.CORRECT))},{default:_(()=>[c("div",Ms,[h(a,{icon:["fas","text"],class:"mr-2"}),x(" "+y(e.$t("newEditor.replaceSubtitle")),1)])]),_:1},8,["disabled"])]),_:1},8,["disabled","text"]),h(p,{onClick:t[12]||(t[12]=u=>i.handleContextMenuAction(s.SEGMENT_TYPE.DELETE_SUBTITLE))},{default:_(()=>[c("div",Rs,[h(a,{icon:["far","trash-can"],class:"mr-2"}),x(" "+y(e.$t("newEditor.deleteSubtitle")),1)])]),_:1}),h(p,{onClick:t[13]||(t[13]=u=>i.handleContextMenuAction(s.SEGMENT_TYPE.DELETE))},{default:_(()=>[c("div",Os,[h(a,{icon:["far","scissors"],class:"mr-2"}),x(" "+y(e.$t("builder.trimVideo")),1)])]),_:1}),h(l,{disabled:i.canCombineWords,text:e.$t("newEditor.cannotCombineMultipleSentencesAndDeletedSegments"),"placement-down":""},{default:_(()=>[h(p,{disabled:!i.canCombineWords,onClick:t[14]||(t[14]=u=>i.handleContextMenuAction(s.SEGMENT_TYPE.COMBINE))},{default:_(()=>[c("div",Ls,[h(a,{icon:["far","down-left-and-up-right-to-center"],class:"mr-2"}),x(" "+y(e.$t("newEditor.combineWords")),1)])]),_:1},8,["disabled"])]),_:1},8,["disabled","text"]),h(l,{disabled:i.canMergeSelection,text:s.selectedText.crossStep?e.$t("newEditor.cannotMergeCrossStep"):e.$t("newEditor.cannotMergeSingleSentence"),"placement-down":""},{default:_(()=>[h(p,{disabled:!i.canMergeSelection,onClick:t[15]||(t[15]=u=>i.handleContextMenuAction(s.SEGMENT_TYPE.MERGE))},{default:_(()=>
2[c("div",Bs,[h(a,{icon:["far","merge"],class:"mr-2"}),x(" "+y(e.$t("newEditor.merge")),1)])]),_:1},8,["disabled"])]),_:1},8,["disabled","text"]),h(l,{disabled:i.canBreakLine,text:i.isSelectMultiWord?e.$t("newEditor.onlyAvailableForSingleWords"):e.$t("newEditor.cannotBreakAtLastWord"),"placement-down":""},{default:_(()=>[h(p,{disabled:!i.canBreakLine,onClick:t[16]||(t[16]=u=>i.handleContextMenuAction(s.SEGMENT_TYPE.BREAK_LINE))},{default:_(()=>[c("div",Vs,[h(a,{icon:["fas","turn-down-left"],class:"mr-2"}),x(" "+y(e.$t("newEditor.breakLine")),1)])]),_:1},8,["disabled"])]),_:1},8,["disabled","text"])],36)),[[S,i.closeContextMenu]]):T("",!0),s.showRestoreContextMenu?Z((d(),g("div",{key:1,class:"fixed bg-gray-800 shadow-lg rounded p-2 z-50",style:ee(s.contextMenuStyle)},[h(p,{onClick:i.handleRestoreDeletedText},{default:_(()=>[c("div",Ns,[h(a,{icon:["fas","arrow-rotate-left"],color:"#22C55E",class:"mr-2"}),x(" "+y(e.$t("newEditor.restore")),1)])]),_:1},8,["onClick"])],4)),[[S,i.closeRestoreContextMenu]]):T("",!0),o.showReplaceDialog?(d(),C(m,{key:2,"target-word":s.selectedText.text,"onUpdate:targetWord":t[18]||(t[18]=u=>s.selectedText.text=u),"replace-word":o.correctedText,"onUpdate:replaceWord":t[19]||(t[19]=u=>o.correctedText=u),"popup-title":e.$t("newEditor.replacePopupTitle"),"total-result":o.totalSearchedResult,"current-search-idx":o.currentSearchIdx,"disable-change-target-word":"",onHighlightPrev:i.handleHighlightPrev,onHighlightNext:i.handleHighlightNext,onClose:i.handleCloseReplaceDialog,onReplaceSingle:i.handleReplaceSingle,onReplaceAll:i.handleReplaceAll},null,8,["target-word","replace-word","popup-title","total-result","current-search-idx","onHighlightPrev","onHighlightNext","onClose","onReplaceSingle","onReplaceAll"])):T("",!0)])}const Fs=ie(rs,[["render",Us],["__scopeId","data-v-87e4e9f8"]]),Hs={name:"MixinAudioWave",data(){return{audioAbortController:null,audioBuffer:null,audioContext:null,isAudioLoading:!1,audioLoadProgress:0,verticalScale:1}},methods:{async loadAudioBuffer(e,t){if(!e)return null;try{this.audioAbortController=new AbortController;const n=this.audioAbortController.signal,o=await Nt({src:e}),s=await fetch(o,{signal:n}),i=+s.headers.get("Content-Length");if(!s.body||!i)throw new Error("Missing stream or content length");const r=s.body.getReader(),a=new Uint8Array(i);let l=0;for(;;){const{done:p,value:m}=await r.read();if(p)break;a.set(m,l),l+=m.length,t&&t(Math.round(l/i*95))}const f=new(window.AudioContext||window.webkitAudioContext);this.audioBuffer=await f.decodeAudioData(a.buffer),this.getVerticalScale(this.audioBuffer),this.audioLoadProgress=100;return}catch(n){throw console.error("Failed to load audio:",n),new Error("Audio loading failed")}},getVerticalScale(e){const t=e.getChannelData(0),n=Array.from(t).reduce((o,s)=>Math.max(o,Math.abs(s)),1e-4);this.verticalScale=1/n},async decodeAudioData(e){return this.audioContext=this.audioContext||new(window.AudioContext||window.webkitAudioContext),await this.audioContext.decodeAudioData(e,resolve,reject)},async loadAudioFromURL(e){this.isAudioLoading=!0,this.audioLoadProgress=0;try{await this.loadAudioBuffer(e,t=>{this.audioLoadProgress=t})}catch(t){console.error("Error loading audio",t)}finally{this.isAudioLoading=!1,this.audioLoadProgress=0}},cancelAudioLoading(){this.audioAbortController&&(this.audioAbortController.abort(),this.audioAbortController=null)}},beforeUnmount(){this.cancelAudioLoading(),this.audioBuffer&&(this.audioBuffer=null)}},zs={name:"EditorStepFlags",props:{containerWidth:{type:Number,default:0},scrollOffsetXDistance:{type:Number,default:0}},data(){return{LEFT_OFFSET:66,steps:[]}},components:{StepFlagsRow:Qi,EditorImportStepFlag:A(()=>W(()=>import("./EditorImportStepFlag-BqWN5n8k.js"),__vite__mapDeps([35,2,3])))},computed:{...Q("editorZoom",["getters_current_unit"]),...Q("editorAdvance",["getter_adjusted_steps_with_import"]),...O("editorAdvance",["intro"]),importStepPositions(){return $i(this.getter_adjusted_steps_with_import,this.getters_current_unit).map(e=>({...e,left:e.left-this.scrollOffsetXDistance}))}},methods:{updateSteps(){this.steps=Ji(this.getter_adjusted_steps_with_import,this.getters_current_unit)}},watch:{getters_current_unit:{handler(){this.updateSteps()},immediate:!0},getter_adjusted_steps_with_import:{handler(){this.updateSteps()}}}};function Ks(e,t,n,o,s,i){const r=w("StepFlagsRow"),a=w("EditorImportStepFlag");return d(),g(L,null,[h(r,{steps:s.steps},null,8,["steps"]),e.intro?(d(),C(a,{key:0,class:"fixed bottom-[
2110px]",style:{left:"72.172px"},type:"intro"})):T("",!0),(d(!0),g(L,null,ae(i.importStepPositions,l=>(d(),C(a,{key:l.no,class:R(["fixed bottom-[110px]",{hidden:l.left<0||l.left>n.containerWidth}]),style:ee({left:`${l.left+s.LEFT_OFFSET}px`}),no:l.no,title:l.title},null,8,["class","style","no","title"]))),128))],64)}const js=ie(zs,[["render",Ks]]),Gs={__name:"EditorSpeedSegmentsOverlay",props:{clipItemsTop:{type:Number,required:!0}},setup(e){const t=e,{getter_change_speed_segments:n}=ge("editorAdvance",["getter_change_speed_segments"]),{sourceWorkflow:o}=me("editorAdvance",["sourceWorkflow"]),{removeSegment:s}=Te("editorAdvance",["removeSegment"]),i=n,r=te(()=>`${t.clipItemsTop+Li}px`),a=te(()=>!o.value.published);function l(f){s(f)}return(f,p)=>(d(),C(Bi,{segments:wi(i),"can-edit":a.value,"overlay-top":r.value,onRemove:l},null,8,["segments","can-edit","overlay-top"]))}},se={RULER:32,STEP_FLAGS:24,MAIN_TRACK:64,SCROLLBAR:8,SUB_TRACK:32,THUMB_POINTER:22},Xs={name:"EditorTimeline",mixins:[Hs],components:{DWorkflowCircleProgress:Xi,ZoomCurrentTimeThumb:ji,ZoomRuler:Ki,EditorWaveClipItem:eo,EditorStepFlags:js,EditorAnnotationTimeline:Vi,EditorTextToSpeechTimeline:Yi,EditorVoiceOverTimeline:qi,EditorSpeedSegmentsOverlay:Gs,ZoomVideoClipItem:A(()=>W(()=>import("./ZoomVideoClipItem-MBnmfzwM.js"),__vite__mapDeps([36,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,37])))},inject:["getCurrentMenu","getIsDubbingMenuContent"],props:{isPreventMouseDefault:{type:Boolean,default:!0},isWaveform:{type:Boolean,default:!0},isSelecting:{type:Boolean,default:!1},selectionStartTime:{type:Number,default:0},selectionEndTime:{type:Number,default:0},enableAutoScroll:{type:Boolean,default:!0}},setup(){const{isKctBlocked:e}=de();return{isKctBlocked:e}},data(){const e={isWhiteThumbMoving:!1,containerWidth:0,isUserScrolling:!1},t={dragWidth:8,selectionStartX:0,selectionEndX:0,draggingHandleType:Ce.NULL,tooltipTime:0};return{CLIP_TYPE:Ge,HEIGHT:se,isMounted:!1,timeLineData:e,...t,offsetLeftDistance:0,resizeObserver:null}},computed:{...O("editorZoom",["unites","unitIndex"]),...O("editorAdvance",["sourceWorkflow","scrollOffsetXDistance"]),...O("editorDubbing",["blocks","audioSourceMaps","contentType","voice","isOriginalAudioPlaying"]),...Q("editorZoom",["getters_current_unit"]),...Q("editorAdvance",["getter_clip_items","getter_display_current_time","getter_total_duration"]),...Q("editorDubbing",["getter_each_block_available_time_range","getter_warning_status_list"]),...Q("editorVoiceOver",["getter_is_disabled_controls"]),lengthMap(){return this.isDubbingMenuContent?{stepFlagsHeight:0,editorSidebarWidth:0}:{stepFlagsHeight:se.STEP_FLAGS,editorSidebarWidth:78}},clipItemsTop(){return 0},dubbingClipItems(){return Zi({clipItems:this.getter_clip_items,blocks:this.blocks,audioSourceMaps:this.audioSourceMaps,playListMap:Ft.playListMap,passThroughDeleteClips:!0})},thumbHeight(){const e=this.lengthMap.stepFlagsHeight+se.MAIN_TRACK-se.THUMB_POINTER;return this.isAnnotationMenuContent||this.isTextToSpeechContent?e+se.SUB_TRACK:e},zoomTimelineStyle(){const e=se.RULER+this.lengthMap.stepFlagsHeight+se.MAIN_TRACK+se.SCROLLBAR;return{"--container-height":`${this.isAnnotationMenuContent||this.isTextToSpeechContent?e+se.SUB_TRACK:e}px`}},isAnnotationMenuContent(){return this.getCurrentMenu()===M.EDITOR_ANNOTATION},isShowDubbingWave(){return this.isTextToSpeechContent&&!this.isOriginalAudioPlaying},isDubbingMenuContent(){return this.getIsDubbingMenuContent()},isVoiceOverContent(){return this.isDubbingMenuContent&&this.contentType===we.VOICEOVER},isTextToSpeechContent(){return this.isDubbingMenuContent&&this.contentType!==we.VOICEOVER},v_on_container(){return{mousemove:e=>{this.draggingHandleType===Ce.NULL&&this.handleChangeCurrentOffsetDistance(e)},mousedown:e=>{this.isPreventMouseDefault&&e.preventDefault(),!(e.target.closest("[js-disableChangeVideoCurrentTime]")||this.getter_is_disabled_controls)&&(this.timeLineData.isWhiteThumbMoving=!0,this.handleChangeCurrentTimeByOffsetX(this.calculateOffsetXByPageX(e)))},mouseup:()=>{this.timeLineData.isWhiteThumbMoving=!1},mouseleave:()=>{this.timeLineData.isWhiteThumbMoving=!1}}},rulerStartTime(){return ce(this.scrollOffsetXDistance)},rulerEndTime(){return this.isMounted?ce(this.scrollOffsetXDistance+this.timeLineData.containerWidth):this.getter_total_duration},selectionWidth(){return Math.abs(this.selectionEndX-this.selectionStartX)},totalClipItemsWidth(){return oe(this.getter_total_duration)}},methods:{...B("editorAdvance",["setCurrentTime","setScrollOffsetXDistance"]),...B("editorPlayer",["seekVideo"]),toCentiSecondTimeFormat:Ut,convertCurrentTimeIntoWidth:oe,handleChangeCurrentOffsetDistance(e){!e.target.closest(".track-body")||!this.timeLineData.isWhiteThumbMoving||this.handleChangeCurrentTimeByOffsetX(this.calculateOffsetXByPageX(e))},handleChangeCurrentTimeByOffsetX(e){const t=Math.min(ce(e),this.getter_total_duration);this.offsetLeftDistance=e,this.setCurrentTime(t),this.seekVideo(t)},calculateOffsetXByPageX(e){const t=e.pageX-this.lengthMap.editorSidebarWidth+this.scrollOffsetXDistance,n=this.getters_current_unit,o=Gi(t,n);return n.time<1?o:Math.max(o,0)},handleTrackBodyScroll(e){const t=e.target.closest(".track-body");this.setScrollOffsetXDistance(t.scrollLeft),this.timeLineData.isUserScrolling=!0,clearTimeout(this.userScrollTimeout),this.userScrollTimeout=setTimeout(()=>{this.timeLineData.isUserScrolling=!1},500)},handleHandleMouseDown(e,t){e.stopPropagation(),e.preventDefault(),this.draggingHandleType=t;const n=s=>{if(!this.draggingHandleType)return;const i=this.calculateOffsetXByPageX(s);if(this.draggingHandleType===Ce.LEFT)this.selectionStartX=Math.min(i,this.selectionEndX),this.tooltipTime=ce(this.selectionStartX);else{const r=Math.max(i,this.selectionStartX),a=ce(r);if(a>this.getter_total_duration)return;this.selectionEndX=r,this.tooltipTime=a}},o=()=>{this.draggingHandleType=Ce.NULL,document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",o);const s=ce(Math.min(this.selectionStartX,this.selectionEndX)),i=ce(Math.max(this.selectionStartX,this.selectionEndX));this.$emit("selection-change",{startTime:s,endTime:i})};document.addEventListener("mousemove",n),document.addEventListener("mouseup",o)},scrollToCurrentTime(){if(!this.enableAutoScroll||!this.$refs["track-body"]||!this.isMounted||this.timeLineData.isUserScrolling)return;const e=oe(this.getter_display_current_time),t=this.$refs["track-body"].clientWidth,n=this.$refs["track-body"].scrollLeft,o=e-n,s=t*.2,i=t*.8;if(o<s||o>i){const r=e-t/2;this.$refs["track-body"].scrollTo({left:Math.max(0,r),behavior:"smooth"})}},handleContainerWidthChange(){this.timeLineData.containerWidth=this.$refs.ZoomTimeline__container.clientWidth}},watch:{getter_display_current_time(e){this.timeLineData.isWhiteThumbMoving||(this.offsetLeftDistance=oe(e))},getters_current_unit(){this.offsetLeftDistance=oe(this.getter_display_current_time),this.isSelecting&&(this.selectionStartX=oe(this.selectionStartTime),this.selectionEndX=oe(this.selectionEndTime))},"sourceWorkflow.audioGsURL":{handler(e){this.loadAudioFromURL(e)},immediate:!0},isSelecting(e){e&&(this.selectionStartX=oe(this.selectionStartTime),this.selectionEndX=oe(this.selectionEndTime))},offsetLeftDistance(){this.scrollToCurrentTime()}},mounted(){this.isMounted=!0,this.userScrollTimeout=null,this.handleContainerWidthChange(),this.resizeObserver=new ResizeObserver(()=>this.handleContainerWidthChange()),this.resizeObserver.observe(this.$refs.ZoomTimeline__container)},beforeUnmount(){var e;(e=this.resizeObserver)==null||e.disconnect()}},qs={key:1,class:"audio-loading flex flex-row items-center justify-center h-16"};function Ys(e,t,n,o,s,i){const r=w("ZoomRuler"),a=w("EditorStepFlags"),l=w("ZoomCurrentTimeThumb"),f=w("DWorkflowCircleProgress"),p=w("EditorWaveClipItem"),m=w("ZoomVideoClipItem"),S=w("EditorVoiceOverTimeline"),u=w("EditorSpeedSegmentsOverlay"),I=w("font-awesome-icon"),k=w("EditorAnnotationTimeline"),D=w("EditorTextToSpeechTimeline");return d(),g("section",{class:R(["ZoomTimeline",{"locked-block":o.isKctBlocked}]),style:ee(i.zoomTimelineStyle)}
2,[c("div",Me({ref:"ZoomTimeline__container",class:"ZoomTimeline__container"},Ti(i.v_on_container,!0)),[h(r,{"is-new-editor":"","track-body-offset-left-distance":e.scrollOffsetXDistance},null,8,["track-body-offset-left-distance"]),c("div",{class:"track-body",ref:"track-body",onScroll:t[2]||(t[2]=(...v)=>i.handleTrackBodyScroll&&i.handleTrackBodyScroll(...v)),onWheel:t[3]||(t[3]=(...v)=>i.handleTrackBodyScroll&&i.handleTrackBodyScroll(...v))},[i.isDubbingMenuContent?T("",!0):(d(),C(a,{key:0,"container-width":s.timeLineData.containerWidth,"scroll-offset-x-distance":e.scrollOffsetXDistance},null,8,["container-width","scroll-offset-x-distance"])),h(l,{ref:"ZoomCurrentTimeThumb","is-new-editor":"","is-frame-time-format":!1,"is-show-tooltip":s.timeLineData.isWhiteThumbMoving,"multi-editing-padding":0,"offset-left-distance":s.offsetLeftDistance,"ruler-start-time":i.rulerStartTime,"thumb-height":i.thumbHeight,"sidebar-width":i.lengthMap.editorSidebarWidth},null,8,["is-show-tooltip","offset-left-distance","ruler-start-time","thumb-height","sidebar-width"]),e.isAudioLoading&&n.isWaveform?(d(),g("div",qs,[h(f,{progress:e.audioLoadProgress},null,8,["progress"])])):(d(),g("div",{key:2,class:"keep-space h-16 relative",style:ee({width:`${i.totalClipItemsWidth}px`})},[n.isWaveform?(d(),g(L,{key:0},[c("div",{class:"initial-timeline-line",style:ee({top:`${i.clipItemsTop}px`})},t[4]||(t[4]=[c("div",{class:"horizontal-line"},null,-1)]),4),(d(!0),g(L,null,ae(i.isShowDubbingWave?i.dubbingClipItems:e.getter_clip_items,v=>(d(),C(p,Me({ref_for:!0},v,{height:s.HEIGHT.MAIN_TRACK,top:i.clipItemsTop,"is-dubbing":i.isShowDubbingWave,"vertical-scale":e.verticalScale,"ruler-start-time":i.rulerStartTime,"ruler-end-time":i.rulerEndTime,key:`${v.startTime}-${v.endTime}-${v.type}`,"audio-buffer":i.isShowDubbingWave?v.audioBuffer:e.audioBuffer}),null,16,["height","top","is-dubbing","vertical-scale","ruler-start-time","ruler-end-time","audio-buffer"]))),128))],64)):(d(!0),g(L,{key:1},ae(e.getter_clip_items,(v,P)=>(d(),C(m,Me({ref_for:!0},v,{"image-width":106,"clip-height":s.HEIGHT.MAIN_TRACK,top:i.clipItemsTop,key:`${v.startTime}-${v.endTime}-${v.type}`,class:`${v.type===s.CLIP_TYPE.DELETE?"erased":""}`,"clip-z-index":P,"ruler-end-time":i.rulerEndTime,"ruler-start-time":i.rulerStartTime}),null,16,["clip-height","top","class","clip-z-index","ruler-end-time","ruler-start-time"]))),128)),i.isVoiceOverContent?(d(),C(S,{key:2,"total-duration":e.getter_total_duration,"calculate-offset-x-by-page-x":i.calculateOffsetXByPageX,"total-width":i.totalClipItemsWidth},null,8,["total-duration","calculate-offset-x-by-page-x","total-width"])):T("",!0)],4)),h(u,{"clip-items-top":i.clipItemsTop},null,8,["clip-items-top"]),!e.isAudioLoading&&n.isSelecting?(d(),g("div",{key:3,class:"timeline__selection",style:ee({transform:`translate(${e.dragWidth+e.selectionStartX}px, -37px)`,width:`${i.selectionWidth}px`})},[c("div",{class:"timeline__selection-handle timeline__selection-handle--left",onMousedown:t[0]||(t[0]=v=>i.handleHandleMouseDown(v,"left"))},[h(I,{icon:["far","chevron-left"]})],32),c("div",{class:"timeline__selection-handle timeline__selection-handle--right",onMousedown:t[1]||(t[1]=v=>i.handleHandleMouseDown(v,"right"))},[h(I,{icon:["far","chevron-right"]})],32),e.draggingHandleType?(d(),g("div",{key:0,class:"absolute text-gray-2 bg-white rounded -top-6 p-0.5 text-xs select-none",style:ee({[e.draggingHandleType]:"0px"})},y(i.toCentiSecondTimeFormat(e.tooltipTime)),5)):T("",!0)],4)):T("",!0),i.isAnnotationMenuContent?(d(),C(k,{key:4,style:ee({width:`${i.totalClipItemsWidth}px`}),"timeline-offset-x":e.dragWidth},null,8,["style","timeline-offset-x"])):i.isTextToSpeechContent?(d(),C(D,{key:5,style:ee({width:`${i.totalClipItemsWidth}px`}),"video-duration":e.getter_total_duration,"each-block-available-time-range":e.getter_each_block_available_time_range,"block-warning-status-list":e.getter_warning_status_list},null,8,["style","video-duration","each-block-available-time-range","block-warning-status-list"])):T("",!0)],544)],16)],6)}const Zs=ie(Xs,[["render",Ys],["__scopeId","data-v-8162faa9"]]),Qs={name:"EditorFooter",mixins:[qe],setup(){const{isEditMode:e}=_e(),{isKctBlocked:t}=de();return{isEditMode:e,isKctBlocked:t}},inject:["getIsDubbingMenuContent"],props:{isLoading:{type:Boolean,default:!0}},emits:[],components:{EditorTimeline:Zs},data(){return{isWaveform:!1,showTimeline:!0,zoomMin:0,isChangingSpeed:!1,selectedSpeed:1,speedOptions:jt,selection:{isSelecting:!1,startTime:0,endTime:0}}},computed:{...O("editorAdvance",["currentTime","segments","redoStack"]),...O("editorZoom",["unites","unitIndex"]),...O("editorDubbing",["contentType"]),...Q("editorAdvance",["getter_clip_items","getter_total_duration","getter_display_current_time"]),btnDisabled(){return{undo:this.segments.filter(t=>!t.isPermanent).length===0||!this.isEditMode,redo:this.redoStack.length===0}},isDubbingMenuContent(){return this.getIsDubbingMenuContent()},zoomMax(){return this.unites.length-2},zoomValue:{get(){return this.unitIndex},set(e){this.changeUnitIndex(Number(e))}}},watch:{getter_total_duration(e){e&&(this.dynamicAddUniteByVideoDuration({sourceDuration:e}),Kt({videoDuration:e}))},contentType(e){this.isWaveform=this.isDubbingMenuContent?e!==we.VOICEOVER:!1}},methods:{...B("editorAdvance",["addSegment","undoSegment","redoSegment"]),...B("editorZoom",["changeUnitIndex","dynamicAddUniteByVideoDuration"]),handleKeyDown(e){if(e.target.tagName==="INPUT"||e.target.tagName==="TEXTAREA")return;const t=zt?e.metaKey:e.ctrlKey;t&&e.key==="z"&&!e.shiftKey&&(e.preventDefault(),this.btnDisabled.undo||this.undoSegment()),t&&e.key==="z"&&e.shiftKey&&(e.preventDefault(),this.btnDisabled.redo||this.redoSegment())},switchTimeline(){this.showTimeline=!this.showTimeline},async switchEditingMode(e){if(!this.isEditMode)return;e.cancelOtherMode&&e.cancelOtherMode();const t=!e.isActive;if(t){const n=this.getter_display_current_time+20;this.selection.startTime=this.getter_display_current_time,this.selection.endTime=n>this.getter_total_duration?this.getter_total_duration:n}else e.cancelCurrentMode();e.setActive(t)},switchEraseVideo(){this.switchEditingMode({isActive:this.selection.isSelecting,cancelOtherMode:this.isChangingSpeed?()=>this.cancelChangeSpeed():null,cancelCurrentMode:()=>
2this.cancelEraseVideo(),setActive:e=>this.selection.isSelecting=e})},switchChangeSpeed(){this.switchEditingMode({isActive:this.isChangingSpeed,cancelOtherMode:this.selection.isSelecting?()=>this.cancelEraseVideo():null,cancelCurrentMode:()=>this.cancelChangeSpeed(),setActive:e=>this.isChangingSpeed=e})},confirmEraseVideo(){this.selection.isSelecting=!1,this.addSegment({type:U.DELETE,target:$.TIMELINE,start:this.selection.startTime,end:this.selection.endTime})},getSpeedLabel:Ht,confirmChangeSpeed(){this.isChangingSpeed=!1,this.addSegment({type:U.CHANGE_SPEED,target:$.TIMELINE,start:this.selection.startTime,end:this.selection.endTime,speed:this.selectedSpeed})},updateSelectionTime(e,t){this.selection.startTime=e,this.selection.endTime=t},handleSelectRange(e){this.updateSelectionTime(e.startTime,e.endTime),this.isChangingSpeed||(this.selection.isSelecting=!0)},handleConfirm(){this.isChangingSpeed?this.confirmChangeSpeed():this.selection.isSelecting&&this.confirmEraseVideo()},handleCancel(){this.isChangingSpeed?this.cancelChangeSpeed():this.selection.isSelecting&&this.cancelEraseVideo()},cancelEraseVideo(){this.selection.isSelecting=!1,this.updateSelectionTime(0,0)},cancelChangeSpeed(){this.isChangingSpeed=!1,this.selectedSpeed=1,this.updateSelectionTime(0,0)}},mounted(){window.addEventListener("keydown",this.handleKeyDown)},beforeUnmount(){window.removeEventListener("keydown",this.handleKeyDown)}},Js={class:"flex flex-row px-4 h-16 justify-between items-center border-b border-gray-4"},$s={class:"flex flex-row gap-4"},en={class:"flex flex-row gap-1 border-line-r items-center pr-4"},tn={class:"text-soft pr-2 text-xs"},on={id:"EditorFooterCustomToolbar",class:"flex flex-row gap-4"},sn={key:0,class:"flex flex-row gap-4"},nn={class:"flex flex-row gap-2 items-center"},rn={class:"flex items-center justify-center w-full gap-3 px-2 py-2 text-white text-sm leading-6"},an={key:0,class:"w-4 h-4 flex items-center justify-center shrink-0 text-[var(--dPrimary-color)] text-xs"},ln={key:0,class:"ml-2"},dn={class:"flex flex-row gap-4"};function cn(e,t,n,o,s,i){const r=w("font-awesome-icon"),a=w("DIconButton"),l=w("DButton2"),f=w("DDropdownItem2"),p=w("DDropdown2"),m=w("DTooltip"),S=w("DSlider"),u=w("EditorTimeline");return d(),g("div",null,[c("div",Js,[c("div",$s,[Z(c("div",en,[c("span",tn,y(e.$t("newEditor.changeView"))+":",1),h(a,{shape:"square",type:"action",size:"md","active-type":"secondary",active:!s.isWaveform,disabled:o.isKctBlocked,onClick:t[0]||(t[0]=I=>s.isWaveform=!1)},{default:_(()=>[h(r,{icon:["far","clapperboard"]})]),_:1},8,["active","disabled"]),h(a,{shape:"square",type:"action",size:"md","active-type":"secondary",active:s.isWaveform,disabled:o.isKctBlocked,onClick:t[1]||(t[1]=I=>s.isWaveform=!0)},{default:_(()=>[h(r,{icon:["far","waveform-lines"]})]),_:1},8,["active","disabled"])],512),[[re,s.showTimeline]]),c("div",null,[Z(c("div",on,null,512),[[re,s.showTimeline]]),o.isEditMode?(d(),C(m,{key:0,open:s.showTimeline&&(s.selection.isSelecting||s.isChangingSpeed),interactive:""},{content:_(()=>[c("div",nn,[s.isChangingSpeed?(d(),C(p,{key:0,trigger:"click"},{dropdown:_(()=>[(d(!0),g(L,null,ae(s.speedOptions,I=>(d(),C(f,{key:I,active:I===s.selectedSpeed,onClick:k=>s.selectedSpeed=I},{default:_(()=>[c("div",rn,[c("span",null,y(i.getSpeedLabel(I)),1),I===s.selectedSpeed?(d(),g("div",an,[h(r,{icon:["fas","check"],class:"text-primary-400"})])):T("",!0)])]),_:2},1032,["active","onClick"]))),128))]),default:_(()=>[h(l,{type:"action",size:"md"},{suffix:_(()=>[h(r,{icon:["fas","chevron-down"]})]),default:_(()=>[x(y(i.getSpeedLabel(s.selectedSpeed))+" ",1)]),_:1})]),_:1})):T("",!0),h(l,{type:"success",size:"md",onClick:i.handleConfirm,disabled:s.selection.startTime===s.selection.endTime||s.isChangingSpeed&&s.selectedSpeed===1},{prefix:_(()=>[h(r,{icon:["far","check"]})]),default:_(()=>[x(" "+y(e.$t("all.confirm")),1)]),_:1},8,["onClick","disabled"]),h(l,{size:"md",type:"action-light",onClick:i.handleCancel},{default:_(()=>[h(r,{icon:["far","xmark"]}),s.isChangingSpeed?T("",!0):(d(),g("span",ln,y(e.$t("action.cancel")),1))]),_:1},8,["onClick"])])]),default:_(()=>[i.isDubbingMenuContent?T("",!0):(d(),g("div",sn,[Z(h(l,{class:"capitalize text-white",size:"md",type:s.selection.isSelecting?"secondary":"action",disabled:e.getter_total_duration===0,onClick:i.switchEraseVideo},{prefix:_(()=>[h(r,{icon:["far","scissors"],class:"text-primary-400"})]),default:_(()=>[x(" "+y(e.$t("builder.trimVideo")),1)]),_:1},8,["type","disabled","onClick"]),[[re,s.showTimeline]]),Z(h(l,{class:"capitalize text-white",size:"md",type:s.isChangingSpeed?"secondary":"action",disabled:e.getter_total_duration===0,onClick:i.switchChangeSpeed},{prefix:_(()=>[h(r,{icon:["fas","gauge-simple-high"],class:"text-primary-400"})]),default:_(()=>[x(" "+y(e.$t("builder.changeSpeed")),1)]),_:1},8,["type","disabled","onClick"]),[[re,s.showTimeline]])]))]),_:1},8,["open"])):T("",!0)])]),c("div",dn,[o.isEditMode&&!i.isDubbingMenuContent?(d(),g(L,{key:0},[h(a,{shape:"square",size:"md",type:"action",disabled:i.btnDisabled.undo,onClick:e.undoSegment},{default:_(()=>[h(r,{icon:["far","arrow-rotate-left"]})]),_:1},8,["disabled","onClick"]),h(a,{shape:"square",size:"md",type:"action",disabled:i.btnDisabled.redo,onClick:e.redoSegment},{default:_(()=>[h(r,{icon:["far","arrow-rotate-right"]})]),_:1},8,["disabled","onClick"])],64)):T("",!0),Z(c("div",{class:R(["w-40 dh-btn btn-md",o.isKctBlocked?"cursor-not-allowed text-white border border-gray-4 bg-gray-2 light:border-gray-300 light:bg-white light:text-gray-3":"btn-action cursor-default"])},[h(S,{type:"zoom",size:"sm",modelValue:i.zoomValue,"onUpdate:modelValue":t[2]||(t[2]=I=>i.zoomValue=I),disabled:s.zoomMin===i.zoomMax||o.isKctBlocked,min:s.zoomMin,max:i.zoomMax,step:1,"show-control":""},null,8,["modelValue","disabled","min","max"])],2),[[re,s.showTimeline]]),h(a,{shape:"square",size:"md",type:"action",disabled:o.isKctBlocked,onClick:i.switchTimeline},{default:_(()=>[h(r,{icon:["fas",s.showTimeline?"eye-slash":"eye"]},null,8,["icon"])]),_:1},8,["disabled","onClick"])])]),c("div",{class:R(["w-full flex flex-col gap-5 transition-all duration-300 ease-in-out",[s.showTimeline?"opacity-100 max-h-[200px]":"opacity-0 max-h-0"]])},[h(u,{ref:"editorTimeline","is-waveform":s.isWaveform,"is-loading":n.isLoading,"is-selecting":s.selection.isSelecting||s.isChangingSpeed,"selection-start-time":s.selection.startTime,"selection-end-time":s.selection.endTime,onSelectionChange:i.handleSelectRange},null,8,["is-waveform","is-loading","is-selecting","selection-start-time","selection-end-time","onSelectionChange"])],2)])}const un=ie(Qs,[["render",cn]]),j={CLOSE:"CLOSE",CLOSE_EDITOR:"CLOSE_EDITOR",DELETE_WORKFLOW:"DELETE_WORKFLOW",MANAGE_EXTERNAL_ID:"MANAGE_EXTERNAL_ID",PREVIEW_WORKFLOW:"PREVIEW_WORKFLOW",RESET_WORKFLOW:"RESET_WORKFLOW",SHARE_WORKFLOW:"SHARE_WORKFLOW",SEND_TO_REVIEWER:"SEND_TO_REVIEWER",SEND_TO_REVIEWER_SUCCESS:"SEND_TO_REVIEWER_SUCCESS",UPDATE_CATEGORY:"UPDATE_CATEGORY",UPDATE_POSTER:"UPDATE_POSTER",PUBLISH_CONFIRMED:"PUBLISH_CONFIRMED"},hn={name:"EditorHeader",inject:["getIsDubbingMenuContent","getCurrentMenu"],props:{allowPublish:{type:Boolean,default:!1},workflowId:{type:String,required:!0},isApprovalInProgress:{type:Boolean,default:!1},openShareExportTrigger:{type:Boolean,default:!1}},components:{DEditablePosterHeader:io,DBuilderPublishConfirmedPopup:A(()=>W(()=>import("./DBuilderPublishConfirmedPopup-DI2Z3wP_.js"),__vite__mapDeps([38,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,39,40,41,42,43,44,45,46,47,48]))),DBuilderCategoryPopup:A(()=>W(()=>import("./DBuilderCategoryPopup-mXcDJYfE.js"),__vite__mapDeps([49,4,2,3,1,5,6,7,8,9,10,11,12,13,14,15,16,17,50,51,52]))),DBuilderReviewerPopup:A(()=>W(()=>import("./DBuilderReviewerPopup-C4ad56wm.js"),__vite__mapDeps([53,4,2,3,1,5,6,7,8,9,10,11,12,13,14,15,16,17,54]))),DBuilderReviewerSuccessPopup:A(()=>W(()=>import("./DBuilderReviewerSuccessPopup-BI4TU4id.js"),__vite__mapDeps([55,56,4,2,3,1,5,6,7,8,9,10,11,12,13,14,15,16,17])
2)),DPopupPlayer:A(()=>W(()=>import("./DPopupPlayer-C0_mnMP9.js"),__vite__mapDeps([57,2,3,7,8,58]))),BuilderPosterPopup:A(()=>W(()=>import("./BuilderPosterPopup-CoJp3GQA.js"),__vite__mapDeps([59,4,2,3,1,5,6,7,8,9,10,11,12,13,14,15,16,17,60,61,62,63]))),BuilderResetWorkflowPopup:A(()=>W(()=>import("./BuilderResetWorkflowPopup-B00jVWTc.js"),__vite__mapDeps([64,4,2,3,1,5,6,7,8,9,10,11,12,13,14,15,16,17,65]))),DManageExternalIdPopup:A(()=>W(()=>import("./DManageExternalIdPopup-DOnYbaOz.js"),__vite__mapDeps([66,1,2,3,47,4,5,6,7,8,9,10,11,12,13,14,15,16,17]))),DProductLineUnpublishConfirmPopup:A(()=>W(()=>import("./DProductLineUnpublishConfirmPopup-C8RXZAsz.js"),__vite__mapDeps([67,1,2,3])))},emits:["close","reload-workflow","share-closed"],data(){return{POPUP_TYPE:j,popupType:j.CLOSE,publishedSteps:[],initialSharePanelKeyForShare:""}},setup(e){to(()=>({workflowId:e.workflowId}));const{getIsAllowShare:t}=Jt(),{isAllowExport:n}=oo(),{startSaving:o,finishSaving:s,startRefreshingAfterSaving:i,saveIndependentContentState:r,processStaticFilesUpload:a,saveWorkflowEditStep:l,updateWorkflow:f,publishWorkflow:p,unpublishWorkflow:m}=ot(),{switchToWizardEditor:S}=Ci(),u=ve(Qe,()=>({})),I=ve(Je,null),{ensureEditModePopup:k,isEditMode:D}=_e(),{isKctBlocked:v}=de(),{openAlert:P}=Xe(),{hasOutdatedContent:b}=st(),E=$e(),N=F(!1),G=F(!1),H=ve("handleDubbingSaveAndClose",null),X=ve("handleDubbingExitFallback",null),le=te(()=>{var q,J;return!N.value&&(((q=E==null?void 0:E.proxy)==null?void 0:q.isDataHasChanges)||((J=E==null?void 0:E.proxy)==null?void 0:J.getter_is_summary_dirty))}),{isBlocking:V,isSaving:z,tryExit:K,handleConfirm:De,handleDiscard:xe,handleCloseBlockedPopup:We}=ao({hasChanged:le,onSave:()=>{var q,J;return H!=null&&H.value?H.value():(J=(q=E==null?void 0:E.proxy)==null?void 0:q.handleSaveAndClose)==null?void 0:J.call(q)},fallback:()=>{var q,J,Ee;(q=X==null?void 0:X.value)==null||q.call(X),(Ee=(J=E==null?void 0:E.proxy)==null?void 0:J.handleConfirmCloseEditor)==null||Ee.call(J)}});return{isSwitchingToWizardEditor:N,showSwitchToWizardEditorConfirm:G,isBlocking:V,isSaving:z,tryExit:K,handleConfirm:De,handleDiscard:xe,handleCloseBlockedPopup:We,hasOutdatedContent:b,isEditMode:D,isKctBlocked:v,isAllowExport:n,startSaving:o,finishSaving:s,startRefreshingAfterSaving:i,saveIndependentContentState:r,processStaticFilesUpload:a,saveWorkflowEditStep:l,updateWorkflow:f,publishWorkflow:p,unpublishWorkflow:m,reloadWorkflowData:I,editorApprovalRequest:u,getIsAllowShare:t,ensureEditModePopup:k,openAlertHook:P,switchToWizardEditor:S}},mixins:[no],watch:{"sourceWorkflow.published":{handler(e){e&&this.getPublishedSteps()}},openShareExportTrigger:{handler(e){e&&(this.pauseVideo(),this.initialSharePanelKeyForShare=lo.EXPORT,this.popupType=j.SHARE_WORKFLOW)}}},computed:{...pe(Qt,["isGen2","userAccess","userId"]),...Q("editorAdvance",["getter_clip_items","getter_adjusted_steps_with_import","getter_adjusted_sentences","getter_needs_word_spacing"]),...Q("aiSummary",["getter_is_summary_dirty"]),...pe(tt,["needApprovalWorkflows"]),...pe(Oe,["integrations","orgCustomized","systemFeatureGates"]),...O("annotation",["sourceAnnotations","annotations"]),...pe(et,["addons","sourceAddons"]),...O("editorAdvance",["derivedHashMap","isHideSaveButton","isOpenEditModePop","isStateChanged","isStateSaving","sourceWorkflow","workflowForm","workflowTitleByLanguage","sourceSegments","segments","videoSigned360","intro","sourceIntro"]),...O("editorZoom",["imageMaps"]),disabledSaveAsDraft(){return!this.isDataHasChanges||this.isDataSaving||!this.isEditMode||this.getter_is_summary_dirty},canRecallWorkflow(){var e,t;return((t=(e=this.editorApprovalRequest)==null?void 0:e.getCanRecallWorkflow)==null?void 0:t.call(e))||!1},showRecallWorkflowPopup(){var e,t;return((t=(e=this.editorApprovalRequest)==null?void 0:e.getShowRecallWorkflowPopup)==null?void 0:t.call(e))||!1},isAllowShare(){return this.getIsAllowShare(this.sourceWorkflow.group)},hasChanges(){return this.sourceWorkflow.title!==this.workflowForm.title||!ye(this.sourceSegments,this.segments)||!ye(this.sourceAnnotations,this.annotations)||!ye(this.sourceAddons,this.addons)||!ye(this.sourceIntro,this.intro)},isDataSaving(){return this.isStateSaving},isDataHasChanges(){return this.hasChanges||this.isStateChanged},isDubbingMenuContent(){return this.getIsDubbingMenuContent()},isDisabledTitleAndPoster(){const e=this.getCurrentMenu();return this.isDubbingMenuContent||e===M.EDITOR_ENTRY||!this.isEditMode},workflowVideoToStepsFormatForPosterPopup(){const{duration:e,videoDuration:t}=this.sourceWorkflow;if(e!==t)return this.publishedSteps;const n=this.videoSigned360;return n?[{video:n,duration:e}]:[]},previewVideoSrc(){return`${window.location.origin}/PlayerPreview/${this.workflowId}`},confirmPopConfig(){return this.isOpenEditModePop?this.isKctBlocked?
2null:{title:this.$t("builder.popupMsgEditWorkflowTitle"),confirmText:this.$t("action.yes"),cancelText:this.$t("action.no"),contentText:this.$t("builder.popupMsgEditWorkflow"),cancel:()=>this.setOpenEditModePop(!1),confirm:this.handleConfirmEditMode}:this.showSwitchToWizardEditorConfirm?{title:this.$t("editor.switchToWizardEditor"),confirmText:this.$t("action.switchEditor"),cancelText:this.$t("action.cancel"),contentText:this.$t("editor.switchToWizardEditorConfirmDescription"),cancel:()=>{this.showSwitchToWizardEditorConfirm=!1},confirm:this.confirmSwitchToWizardEditor}:this.popupType===j.DELETE_WORKFLOW?{title:this.$t("explorer.deleteWorkflow"),confirmText:this.$t("explorer.popupBtnDelete"),cancelText:this.$t("all.no"),contentText:this.$t("explorer.popupMsgDeleteWorkflow"),cancel:this.handleClosePopup,confirm:this.handleConfirmDeleteWorkflow,showRedConfirm:!0}:null}},methods:{...B("editor",["storePublishApprovalWorkflowId"]),...B("annotation",["setSelectedId"]),...B("editorAdvance",["patchWorkflowForm","patchWorkflowSource","setOpenEditModePop","syncDerivedHashes"]),...B("editorPlayer",["pauseVideo"]),...Pe(Zt,["openVersionHistory"]),...Pe(Yt,["openApprovalHistory"]),async getPublishedSteps(){const{ok:e,data:t}=await Ze(this.workflowId,{needSign:!0});e&&(this.publishedSteps=t.items)},getWorkflowValidationError(e){var o;if(!((o=this.workflowForm.title)!=null&&o.trim()))return this.$t("newEditor.alertNoEmptyTitle");if(e!==Se.PUBLISH)return"";const t=this.getExpectedSteps({annotationElements:[]});if(t.length===0)return this.$t("newEditor.alertNoStepsToPublish");const n=t.map((s,i)=>s.type!==ne.IMPORT&&(!s.clipTimes||s.clipTimes.length===0)?i+1:null).filter(s=>s!=null);return n.length>0?this.$t("newEditor.alertStepsIncomplete",{indices:n.join(", ")}):""},getExpectedSteps({annotationElements:e=[]}){return qt({imageMaps:this.imageMaps,clips:this.getter_clip_items,adjustSteps:this.getter_adjusted_steps_with_import,adjustSentences:this.getter_adjusted_sentences,annotationElements:e,addons:this.addons||{},needsWordSpacing:this.getter_needs_word_spacing,segments:this.segments||[]})},handleClickHeader(){this.setSelectedId(null)},handleConfirmCloseEditor(){this.handleClosePopup(),this.$emit("close")},handleClosePopup(){this.popupType===j.SHARE_WORKFLOW&&(this.$emit("share-closed"),this.initialSharePanelKeyForShare=""),this.popupType=j.CLOSE},async handleSaveAndClose(){await this.handleSaveWorkflow()},async handleClickPoster(){this.isDisabledTitleAndPoster||this.isEditMode&&(this.popupType=j.UPDATE_POSTER)},handleConfirmEditMode(){this.setOpenEditModePop(!1),this.handleUnpublishWorkflow()},async handleConfirmDeleteWorkflow(){await Xt(this.workflowId)&&(this.handleClosePopup(),this.$emit("close"))},async handleConfirmResetWorkflow(e){const{ok:t,errorMessage:n}=await Gt({workflowId:this.workflowId,keepWorkflow:e});if(t){this.handleClosePopup(),this.$emit("close");return}this.openAlert({message:n||this.$t("alert.unexpectedError"),type:"error"})},handleConfirmPublishWorkflow({nextVersionHistoryNumber:e,versionDescription:t,isReTraining:n,quizActive:o,aiSummaryActive:s,approvalWorkflowId:i}){this.handleClosePopup(),this.handlePublishWorkflow({action:i?Se.PUBLISH_FOR_APPROVAL:Se.PUBLISH,retraining:n,quizActive:o,aiSummaryActive:s,version:e,versionDescription:t,approvalWorkflowId:i})},handleClickMenuCategory(){this.popupType=j.UPDATE_CATEGORY},handleClickMenuVersionHistory(){this.openVersionHistory({workflowId:this.workflowId})},executeRecall(){var e,t;return this.isApprovalInProgress?(this.canRecallWorkflow?(t=(e=this.editorApprovalRequest)==null?void 0:e.openRecallWorkflowPopup)==null||t.call(e):this.openAlert({type:"error",message:this.$t("approvalWorkflows.recallWorkflowNotAllowed")}),!0):!1},async handleClickMenuReset(){this.executeRecall()||await this.ensureEditModePopup()||(this.popupType=j.RESET_WORKFLOW)},handleClickMenuExternalId(){this.pauseVideo(),this.popupType=j.MANAGE_EXTERNAL_ID},handleClickSwitchToWizardEditor(){this.showSwitchToWizardEditorConfirm=!0},async confirmSwitchToWizardEditor(){if(this.showSwitchToWizardEditorConfirm=!1,!this.executeRecall()&&!await this.ensureEditModePopup())try{this.isSwitchingToWizardEditor=!0,await this.handleSaveWorkflow(),await this.switchToWizardEditor({currentMenu:this.getCurrentMenu(),segments:this.segments,workflowId:this.workflowId,workflowEditStep:this.sourceWorkflow.workflowEditStep})}finally{this.isSwitchingToWizardEditor=!1}},async handleClickMenuDelete(){this.executeRecall()||await this.ensureEditModePopup()||(this.popupType=j.DELETE_WORKFLOW)},handleClickShare(){this.pauseVideo(),this.popupType=j.SHARE_WORKFLOW},async handleClickPreview(){const{ok:e,data:t}=await Ye(this.workflowId);!e||!t.item.allowView||(this.pauseVideo(),this.popupType=j.PREVIEW_WORKFLOW)},async handleClickEdit(){if(this.pauseVideo(),!this.executeRecall()){if(this.isKctBlocked){this.setOpenEditModePop(!0);return}await this.ensureEditModePopup()||this.handleConfirmEditMode()}},async handleClickSave(){this.isEditMode&&await this.handleSaveWorkflow()},handleClickPublish(){this.pauseVideo(),this.popupType=j.PUBLISH_CONFIRMED},handleClickSendToReviewer(){this.pauseVideo(),this.popupType=j.SEND_TO_REVIEWER},handleChangeCategory(e){this.patchWorkflowSource(e)},handleChangePoster(e){this.patchWorkflowForm({poster:e})},handleChangeTitle(e){this.patchWorkflowForm({title:e})},async handleUnpublishWorkflow(){this.startSaving();try{await this.unpublishWorkflow(this.workflowId),await this.handleRefreshData(),this.openAlert({type:"success",message:this.$t("editor.alertWasUnpublished")})}catch(e){console.error(e),this.openAlert({type:"error",message:this.$t("builder.alertSaveFailed")})}finally{this.finishSaving()}},async handleSaveWorkflow(){const e=this.getWorkflowValidationError(Se.SAVE);if(e){this.openAlert({type:"error",message:e});return}this.startSaving();try{const{success:t,showDefaultError:n=!0}=await this.saveWorkflow();if(!t){this.handleSaveFailure({showDefaultError:n});return}await this.handleRefreshData(),this.openAlert({type:"success",message:this.$t(Be[Se.SAVE])})}catch(t){console.error({error:t}),this.openAlert({type:"error",message:this.$t("builder.alertSaveFailed")})}finally{this.finishSaving()}},handleSaveFailure({showDefaultError:e=!0}={}){e&&this.openAlert({type:"error",message:this.$t("builder.alertSaveFailed")})},async saveWorkflow(){try{if(this.isStateChanged){const{next:n,showDefaultError:o}=await this.saveIndependentContentState();if(!n)return{success:!1,showDefaultError:o}}const e=await this.processStaticFilesUpload(this.annotations);this.recordWorkflowChanges(),await this.saveWorkflowEditStep({id:this.sourceWorkflow.workflowEditStep,payload:{annotationElements:e,addons:this.addons,segments:this.segments,intro:this.intro,derivedHashMap:this.derivedHashMap}});const t={title:this.workflowForm.title,titleTranslations:this.workflowTitleByLanguage,steps:this.getExpectedSteps({annotationElements:e})};return await this.updateWorkflow(this.workflowId,t),{success:!0}}catch(e){return console.error({error:e}),{success:!1}}},async handlePublishWorkflow({action:e,retraining:t=!1,quizActive:n,aiSummaryActive:o,version:s=0,versionDescription:i="",approvalWorkflowId:r}){const a=this.getWorkflowValidationError(e);
2if(a){this.openAlert({type:"error",message:a});return}this.startSaving();try{this.storePublishApprovalWorkflowId(r||"");const{success:l,showDefaultError:f=!0}=await this.saveWorkflow();if(!l){this.handleSaveFailure({showDefaultError:f});return}this.hasOutdatedContent&&await this.syncDerivedHashes({overwriteOutdated:!0});const{ok:p,errorMessage:m,code:S}=await this.publishWorkflow(this.workflowId,{retraining:t,quizActive:n,aiSummaryActive:o,version:s,versionDescription:i,approvalWorkflowId:r,...this.intro&&{intro:this.intro}});if(!p){const u=new Error(m||this.$t("builder.alertSaveFailed"));throw u.code=S,u}await this.handleRefreshData(),this.openAlert({type:"success",message:this.$t(Be[e])})}catch(l){this.storePublishApprovalWorkflowId(""),console.error("error",l),this.openAlert({type:"error",message:(l==null?void 0:l.message)||this.$t("builder.alertSaveFailed")})}finally{this.finishSaving()}},async handleRefreshData(){this.startRefreshingAfterSaving(),await this.reloadWorkflowData()},recordWorkflowChanges(){var t,n,o,s;const e=co({includeMetadata:!0,workflowFormTitle:(t=this.workflowForm)==null?void 0:t.title,sourceWorkflowTitle:(n=this.sourceWorkflow)==null?void 0:n.title,workflowFormPoster:(o=this.workflowForm)==null?void 0:o.poster,sourceWorkflowPoster:(s=this.sourceWorkflow)==null?void 0:s.poster,segments:this.segments,sourceSegments:this.sourceSegments,annotations:this.annotations,sourceAnnotations:this.sourceAnnotations,addons:this.addons,sourceAddons:this.sourceAddons});uo(this.workflowId,e)}},mounted(){this.getPublishedSteps()}},pn={class:"text-danger-400"},mn=["innerHTML"];function fn(e,t,n,o,s,i){var le,V,z;const r=w("font-awesome-icon"),a=w("DIconButton"),l=w("DDropdownItem2"),f=w("DTooltip"),p=w("DDropdown2"),m=w("DButton2"),S=w("DEditablePosterHeader"),u=w("BuilderPosterPopup"),I=w("DBuilderCategoryPopup"),k=w("DBuilderReviewerPopup"),D=w("DBuilderReviewerSuccessPopup"),v=w("DBuilderPublishConfirmedPopup"),P=w("BuilderResetWorkflowPopup"),b=w("BuilderShare"),E=w("DManageExternalIdPopup"),N=w("DPopupPlayer"),G=w("DConfirmPop"),H=w("DProductLineUnpublishConfirmPopup"),X=w("DUnsavedChangesPopup");return d(),g("div",{onClick:t[6]||(t[6]=(...K)=>i.handleClickHeader&&i.handleClickHeader(...K))},[h(S,{title:e.workflowForm.title,poster:e.workflowForm.poster,"is-published":e.workflowForm.published,"is-poster-disabled":i.isDisabledTitleAndPoster,"is-title-disabled":i.isDisabledTitleAndPoster,workflow:e.sourceWorkflow,onClose:o.tryExit,onClickPoster:i.handleClickPoster,onChangeTitle:i.handleChangeTitle},{right:_(()=>[h(p,{trigger:"click","offset-y":4,disabled:o.isKctBlocked},{dropdown:_(()=>[e.userAccess.categories?(d(),C(l,{key:0,onClick:i.handleClickMenuCategory},{default:_(()=>[x(y(e.$t("admin.categoriesAssignment")),1)]),_:1},8,["onClick"])):T("",!0),h(l,{onClick:i.handleClickMenuVersionHistory},{default:_(()=>[x(y(e.$t("editor.versionHistory")),1)]),_:1},8,["onClick"]),e.orgCustomized.approvalWorkflowsEnabled?(d(),C(l,{key:1,onClick:t[0]||(t[0]=K=>e.openApprovalHistory({workflowId:n.workflowId}))},{default:_(()=>[x(y(e.$t("approvalWorkflows.approvalHistory")),1)]),_:1})):T("",!0),e.isGen2?T("",!0):(d(),C(l,{key:2,analytics:"reset-workflow",onClick:i.handleClickMenuReset},{default:_(()=>[x(y(e.$t("builder.resetWorkflow")),1)]),_:1},8,["onClick"])),e.integrations.externalIdEnabled?(d(),C(l,{key:3,onClick:i.handleClickMenuExternalId},{default:_(()=>[x(y(e.$t("editor.manageExternalId")),1)]),_:1},8,["onClick"])):T("",!0),e.systemFeatureGates.canUseWizardEditor?(d(),C(l,{key:4,onClick:i.handleClickSwitchToWizardEditor},{default:_(()=>[x(y(e.$t("editor.switchToWizardEditor"))+" ",1),h(f,{text:e.$t("editor.switchToWizardEditorTooltip")},{default:_(()=>[h(r,{icon:["far","circle-info"],class:"text-soft",size:"sm"})]),_:1},8,["text"])]),_:1},8,["onClick"])):T("",!0),h(l,{analytics:"delete-workflow",onClick:i.handleClickMenuDelete},{default:_(()=>[c("span",pn,y(e.$t("explorer.deleteWorkflow")),1)]),_:1},8,["onClick"])]),default:_(()=>[h(a,{type:"action",size:"lg",shape:"square",disabled:o.isKctBlocked},{default:_(()=>[h(r,{icon:["fas","ellipsis"]})]),_:1},8,["disabled"])]),_:1},8,["disabled"]),e.workflowForm.published?(d(),g(L,{key:0}
2,[i.isAllowShare||o.isAllowExport?(d(),C(m,{key:0,type:"action",size:"lg",disabled:o.isKctBlocked,onClick:i.handleClickShare,analytics:"share"},{prefix:_(()=>[h(r,{icon:["far","share"]})]),default:_(()=>[x(" "+y(e.$t("builder.share")),1)]),_:1},8,["disabled","onClick"])):T("",!0),h(m,{type:"action",size:"lg",disabled:o.isKctBlocked,onClick:i.handleClickPreview},{default:_(()=>[x(y(e.$t("builder.preview")),1)]),_:1},8,["disabled","onClick"])],64)):T("",!0),i.isDubbingMenuContent?T("",!0):(d(),g(L,{key:1},[h(m,{type:"secondary",size:"lg",disabled:i.disabledSaveAsDraft||o.isKctBlocked,onClick:i.handleClickSave},{default:_(()=>[x(y(e.$t("newEditor.saveAsDraft")),1)]),_:1},8,["disabled","onClick"]),e.workflowForm.published||n.isApprovalInProgress&&!o.isKctBlocked?(d(),C(m,{key:0,disabled:i.isDataSaving||n.isApprovalInProgress&&!i.canRecallWorkflow,size:"lg",onClick:i.handleClickEdit},{default:_(()=>[x(y(o.isKctBlocked?e.$t("action.unpublish"):e.$t("builder.editWorkflow")),1)]),_:1},8,["disabled","onClick"])):n.allowPublish?(d(),C(m,{key:1,disabled:i.isDataSaving||o.isKctBlocked,size:"lg",onClick:i.handleClickPublish},{default:_(()=>[x(y(e.needApprovalWorkflows?e.$t("builder.sendForApproval"):e.$t("builder.publish")),1)]),_:1},8,["disabled","onClick"])):(d(),C(m,{key:2,size:"lg",class:"capitalize",disabled:o.isKctBlocked,onClick:i.handleClickSendToReviewer},{default:_(()=>[x(y(e.$t("builder.sendToReviewer")),1)]),_:1},8,["disabled","onClick"]))],64))]),_:1},8,["title","poster","is-published","is-poster-disabled","is-title-disabled","workflow","onClose","onClickPoster","onChangeTitle"]),s.popupType===s.POPUP_TYPE.UPDATE_POSTER?(d(),C(u,{key:0,workflow:e.sourceWorkflow,steps:i.workflowVideoToStepsFormatForPosterPopup,onClosePosterPopup:i.handleClosePopup,onUpdatePoster:i.handleChangePoster},null,8,["workflow","steps","onClosePosterPopup","onUpdatePoster"])):s.popupType===s.POPUP_TYPE.UPDATE_CATEGORY?(d(),C(I,{key:1,workflow:e.sourceWorkflow,"is-edit-mode":o.isEditMode,onClose:i.handleClosePopup,onUpdateCategory:i.handleChangeCategory},null,8,["workflow","is-edit-mode","onClose","onUpdateCategory"])):s.popupType===s.POPUP_TYPE.SEND_TO_REVIEWER?(d(),C(k,{key:2,workflowId:n.workflowId,onOpenReviewerSuccessPopup:t[1]||(t[1]=K=>s.popupType=s.POPUP_TYPE.SEND_TO_REVIEWER_SUCCESS),onClose:i.handleClosePopup},null,8,["workflowId","onClose"])):s.popupType===s.POPUP_TYPE.SEND_TO_REVIEWER_SUCCESS?(d(),C(D,{key:3,"workspace-id":e.sourceWorkflow.group,onClose:i.handleClosePopup},null,8,["workspace-id","onClose"])):s.popupType===s.POPUP_TYPE.PUBLISH_CONFIRMED?(d(),C(v,{key:4,"workflow-id":n.workflowId,categories:e.sourceWorkflow.categories||[],languages:Object.entries(e.workflowTitleByLanguage),"workspace-id":e.sourceWorkflow.group,"has-outdated-content":o.hasOutdatedContent,onConfirmPublish:i.handleConfirmPublishWorkflow,onClose:i.handleClosePopup},null,8,["workflow-id","categories","languages","workspace-id","has-outdated-content","onConfirmPublish","onClose"])):s.popupType===s.POPUP_TYPE.RESET_WORKFLOW?(d(),C(P,{key:5,onClose:i.handleClosePopup,onConfirm:i.handleConfirmResetWorkflow},null,8,["onClose","onConfirm"])):s.popupType===s.POPUP_TYPE.SHARE_WORKFLOW?(d(),C(b,{key:6,steps:s.publishedSteps,workflow:e.sourceWorkflow,translationList:Object.keys(e.workflowTitleByLanguage),downloadVideoInfo:e.downloadVideoInfo,"initial-share-panel-key":s.initialSharePanelKeyForShare,onClose:i.handleClosePopup,onReloadWorkflow:t[2]||(t[2]=K=>e.$emit("reload-workflow")),onSetDownloadVideoInfo:t[3]||(t[3]=K=>e.setDownloadVideoInfo(K)),onUpdateWorkflow:t[4]||(t[4]=K=>e.$emit("reload-workflow"))},null,8,["steps","workflow","translationList","downloadVideoInfo","initial-share-panel-key","onClose"])):s.popupType===s.POPUP_TYPE.MANAGE_EXTERNAL_ID?(d(),C(E,{key:7,"workflow-id":n.workflowId,onClose:i.handleClosePopup},null,8,["workflow-id","onClose"])):T("",!0),h(N,{"model-value":s.popupType===s.POPUP_TYPE.PREVIEW_WORKFLOW,videoLink:i.previewVideoSrc,"onUpdate:modelValue":i.handleClosePopup},null,8,["model-value","videoLink","onUpdate:modelValue"]),i.confirmPopConfig?(d(),C(G,{key:8,showRedConfirm:i.confirmPopConfig.showRedConfirm,title:i.confirmPopConfig.title,cancelText:i.confirmPopConfig.cancelText,confirmText:i.confirmPopConfig.confirmText,onConfirm:i.confirmPopConfig.confirm,onCancel:i.confirmPopConfig.cancel},{default:_(()=>[c("span",{innerHTML:i.confirmPopConfig.contentText},null,8,mn)]),_:1},8,["showRedConfirm","title","cancelText","confirmText","onConfirm","onCancel"])):T("",!0),o.isKctBlocked&&e.isOpenEditModePop?(d(),C(H,{key:9,"unpublish-only":"",type:e.$t("all.workflow"),"unpublish-title":e.$t("explorer.unpublishWorkflow"),onCancel:t[5]||
2(t[5]=K=>e.setOpenEditModePop(!1)),onConfirm:i.handleConfirmEditMode},null,8,["type","unpublish-title","onConfirm"])):T("",!0),o.isBlocking?(d(),C(X,{key:10,"is-loading":o.isSaving,onConfirm:o.handleConfirm,onCancel:o.handleDiscard,onClose:o.handleCloseBlockedPopup},null,8,["is-loading","onConfirm","onCancel","onClose"])):T("",!0),i.showRecallWorkflowPopup?(d(),C(G,{key:11,title:e.$t("approvalWorkflows.recallConfirmTitle"),"cancel-text":e.$t("action.cancel"),"confirm-text":e.$t("approvalWorkflows.recallConfirmYes"),analytics:{confirm:"confirm-recall",cancel:"cancel-recall",close:"cancel-recall"},onConfirm:(le=o.editorApprovalRequest)==null?void 0:le.confirmRecallWorkflow,onCancel:(V=o.editorApprovalRequest)==null?void 0:V.cancelRecallWorkflow,onClose:(z=o.editorApprovalRequest)==null?void 0:z.cancelRecallWorkflow},{default:_(()=>[x(y(e.$t("builder.popupMsgEditWorkflow")),1)]),_:1},8,["title","cancel-text","confirm-text","onConfirm","onCancel","onClose"])):T("",!0)])}const gn=ie(hn,[["render",fn]]),Sn={name:"EditorSidebar",components:{},props:{isLoading:{type:Boolean,default:!1},modelValue:{type:String,required:!0}},emits:["click-menu"],data(){return{}},setup(){const{isTranslationOutdated:e,isQuizOutdated:t,isSummaryOutdated:n}=st(),{isSupportAiSummaryLanguage:o}=ho(),{isKctBlocked:s}=de();return{isTranslationOutdated:e,isQuizOutdated:t,isSummaryOutdated:n,isSupportAiSummaryLanguage:o,isKctBlocked:s}},computed:{...pe(Oe,["systemFeatureGates","orgAiAssistance"]),...O("editorAdvance",["pendingTranslationList"]),...O("aiQuizEditor",["isQuizPublished"]),...O("aiSummary",["isAISummaryPublished"]),hasSummmaryPermission(){return this.systemFeatureGates.aiSummaryFeatureEnabled&&this.orgAiAssistance.aiSummaryEnabled},menuItems(){const t=[{title:this.$t("newEditor.quickEdit"),icon:"pen-to-square",value:M.EDITOR_CONTENT,show:!0,tooltip:this.$t("newEditor.quickEditTooltip")},{title:this.$t("newEditor.dubbing"),icon:"waveform-lines",value:M.EDITOR_DUBBING,show:!1,disabled:this.isLoading,tooltip:this.$t("newEditor.updateAudioTooltip")},{title:this.$t("newEditor.importVideo"),icon:"video-arrow-down-left",value:M.EDITOR_IMPORT,show:!0,disabled:this.isLoading,tooltip:this.$t("newEditor.importVideoTooltip")},{title:this.$t("newEditor.videoOverlays"),icon:"notes",value:M.EDITOR_ANNOTATION,show:!0,disabled:this.isLoading,tooltip:this.$t("newEditor.annotationTooltip")},{title:this.$t("newEditor.aiQuiz"),icon:"square-question",value:M.EDITOR_QUIZ,show:this.systemFeatureGates.quizEnabled,disabled:this.isLoading,checked:this.isQuizPublished,outdated:this.isQuizOutdated,tooltip:this.$t("newEditor.quizTooltip")},{title:this.$t("newEditor.aiSummary"),titleTip:this.isSupportAiSummaryLanguage?"":this.$t("newEditor.aiNotSupportLanguage"),icon:"square-list",value:M.EDITOR_SUMMARY,show:this.hasSummmaryPermission,disabled:this.isLoading||!this.isSupportAiSummaryLanguage,checked:this.isAISummaryPublished,outdated:this.isSummaryOutdated,tooltip:this.$t("newEditor.summaryTooltip")},{title:this.$t("newEditor.attachments"),icon:"paperclip",value:M.EDITOR_ATTACHMENT,show:!0,disabled:this.isLoading,tooltip:this.$t("newEditor.attachmentTooltip")},{title:this.$t("newEditor.translations"),icon:"message-captions",value:M.EDITOR_TRANSLATION,show:!0,disabled:this.isLoading,pending:this.pendingTranslationList.length>0,outdated:this.isTranslationOutdated,tooltip:this.$t("newEditor.translationTooltip")}].filter(({show:n})=>n);return this.isKctBlocked?t.map(n=>({...n,disabled:!0})):t}},methods:{handleClick(e){e.disabled||this.$emit("click-menu",e.value)}}},wn={class:"editor-sidebar"},Tn={class:"editor-sidebar__list"},_n=["onClick"],En={key:0,class:"custom-tooltip tooltip-bg"},yn={class:"custom-tooltip__title flex items-center gap-1"},vn={class:"capitalize text-main"},kn={class:"custom-tooltip__content"},Cn={class:"editor-sidebar__item-text"},bn={key:1,class:"editor-sidebar__item-tag"},In={key:2,class:"fa-layers absolute top-0 right-[18px] text-xs"},Pn={key:3,class:"absolute top-0 right-[18px] dot bg-danger-400"};function Dn(e,t,n,o,s,i){const r=w("font-awesome-icon"),a=w("DTag");return d(),g("div",wn,[c("ul",Tn,[(d(!0),g(L,null,ae(i.menuItems,(l,f)=>(d(),g("li",{key:f,class:R(["editor-sidebar__item",{"editor-sidebar__item--active":n.modelValue===l.value,"editor-sidebar__item--disabled":l.disabled||l.isComingSoon}]),onClick:p=>i.handleClick(l)},[l.tooltip||l.isComingSoon?(d(),g("div",En,[t[0]||(t[0]=c("div",{class:"custom-tooltip__arrow border-gray-700 light:border-white"},null,-1)),c("div",yn,[c("span",vn,y(l.isComingSoon?e.$t("newEditor.comingSoon"):l.title),
21),l.titleTip?(d(),C(a,{key:0,size:"sm",class:"rounded-3xl",closeable:!1},{default:_(()=>[h(r,{class:"text-warning",icon:["fas","warning"]}),x(" "+y(l.titleTip),1)]),_:2},1024)):T("",!0)]),c("div",kn,y(l.isComingSoon?e.$t("newEditor.comingSoonDesc"):l.tooltip),1)])):T("",!0),h(r,{icon:[n.modelValue===l.value?"fas":"far",l.icon],class:"editor-sidebar__item-icon"},null,8,["icon"]),c("span",Cn,y(l.title),1),l.tag?(d(),g("span",bn,y(l.tag),1)):T("",!0),l.checked?(d(),g("span",In,[h(r,{icon:["fas","circle"],class:"text-primary-400"}),h(r,{icon:["fas","check"],transform:"shrink-6",inverse:""})])):l.pending?(d(),g("span",Pn)):T("",!0),!n.isLoading&&l.outdated?(d(),C(r,{key:4,class:"absolute top-3.5 right-[18px] text-xs text-warning",icon:["far","rotate-exclamation"]})):T("",!0)],10,_n))),128))])])}const xn=ie(Sn,[["render",Dn],["__scopeId","data-v-57976daf"]]),be=250;function Wn(){const{workflowForm:e,primaryContentHash:t,primaryTitleHash:n,sourceWorkflow:o,transcriptionIdByLanguage:s}=me("editorAdvance",["workflowForm","primaryContentHash","primaryTitleHash","sourceWorkflow","transcriptionIdByLanguage"]),{questionId:i,questions:r}=me("aiQuizEditor",["questionId","questions"]),{summaryId:a,summary:l}=me("aiSummary",["summaryId","summary"]),{getter_source_sentences_array:f,getter_step_titles:p}=ge("editorAdvance",["getter_source_sentences_array","getter_step_titles"]),{updatePrimaryContentHash:m,updatePrimaryTitleHash:S,updatePrimarySummaryHash:u,updatePrimaryQuizHash:I,syncDerivedHashes:k}=Te("editorAdvance",["updatePrimaryContentHash","updatePrimaryTitleHash","updatePrimarySummaryHash","updatePrimaryQuizHash","syncDerivedHashes"]),D=te(()=>({primaryContentHash:t.value,primaryTitleHash:n.value,questionId:i.value??"",summaryId:a.value??""})),v=te(()=>{var z;const V=Object.keys(s.value??{});return{summaryTranslationLanguages:V,quizTranslationLanguages:V,hasQuiz:!!(i.value||(((z=r.value)==null?void 0:z.length)??0)>0),hasSummary:!!(a.value||Object.keys(l.value??{}).length>0)}}),P=te(()=>[f.value]),b=te(()=>{var V,z;return!((V=e.value)!=null&&V.title)||p.value.length===0?null:[((z=e.value)==null?void 0:z.title)??"",p.value]}),E=te(()=>{var K;const V=(K=o.value)==null?void 0:K.languageCode,z=l.value;return z?$t(z,V)??"":null}),N=te(()=>r.value??[]),G=ke(()=>m(),be),H=ke(()=>S(),be),X=ke(()=>{const V=E.value;u({summaryForPrimaryLang:V&&String(V).trim()?V:null})},be),le=ke(()=>{I({questions:Array.isArray(N.value)?N.value:[]})},be);return he(D,()=>k(v.value),{deep:!0,immediate:!0}),he(P,()=>G()),he(b,()=>H()),he(E,()=>X()),he(N,()=>le()),{derivedHashFillTriggers:D}}const An={name:ei.EDITOR_ADVANCED,mixins:[qe],setup(){const e=$e(),{isEditMode:t,ensureEditModePopup:n}=_e(),{isKctBlocked:o}=de();Wn();const{startSaving:s,finishSaving:i}=ot(),r=Ue(null),a=Ue(null);Fe("handleDubbingSaveAndClose",r),Fe("handleDubbingExitFallback",a);const{sourceWorkflow:l}=me("editorAdvance",["sourceWorkflow"]),{canRecallWorkflow:f,showRecallWorkflowPopup:p,openRecallWorkflowPopup:m,confirmRecallWorkflow:S,cancelRecallWorkflow:u,getApprovalRequest:I}=po({getApprovalRequestId:()=>{var P;return(P=l==null?void 0:l.value)==null?void 0:P.approvalRequestId},refreshData:()=>{var P,b;return(b=(P=e==null?void 0:e.proxy)==null?void 0:P.getAllWorkflowData)==null?void 0:b.call(P)}}),k=F(!1),D=te(()=>{var P;return((P=l.value)==null?void 0:P.published)===!0}),v=F(!1);return ro(k,D,v),{isEditMode:t,isKctBlocked:o,ensureEditModePopup:n,startSaving:s,finishSaving:i,canRecallWorkflow:f,showRecallWorkflowPopup:p,openRecallWorkflowPopup:m,confirmRecallWorkflow:S,cancelRecallWorkflow:u,getApprovalRequest:I,openShareExportTrigger:k,isWorkflowDataLoaded:v}},components:{EditorAdvancedBanner:bi,EditorContent:Fs,EditorHeader:gn,EditorFooter:un,EditorSidebar:xn,EditorEntry:A(()=>W(()=>import("./EditorEntry-DBSLUcpN.js"),__vite__mapDeps([68,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,69]))),EditorAnnotation:A(()=>W(()=>import("./EditorAnnotation-VLpid9Qp.js"),__vite__mapDeps([70,71,4,2,3,1,5,6,7,8,9,10,11,12,13,14,15,16,17,72,73,74,75,76,77,78,79,80,81,82,83,84,42,20,85,86,87,88,89,90,91,92,21,34,93,94,95,96,97,98,99,100,29,101,102,32,33,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119]))),EditorAttachment:A(()=>W(()=>import("./EditorAttachment-KiMTBDW9.js"),__vite__mapDeps([120,4,2,3,1,5,6,7,8,9,10,11,12,13,14,15,16,17,121,84,122,81,78,75,72,82,42,20,85,86,87,88,89,90,91,92,21,34,93,94,95,96,97,98,99,100,29,101,102,32,33,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118]))),EditorTranslation:A(()=>W(()=>import("./EditorTranslation-CgSTk9JK.js"),__vite__mapDeps([123,4,2,3,1,5,6,7,8,9,10,11,12,13,14,15,16,17,124,125,126,127,128,129,103,92,21,34,20,84,90,130,89,91,131,132,133,134,81,78,75,72,82,135]))),EditorDubbing:A(()=>W(()=>import("./EditorDubbing-DxWdwu7_.js"),__vite__mapDeps([136,4,2,3,1,5,6,7,8,9,10,11,12,13,14,15,16,17,137,138,69,139,134,135,140,108,78,109,110,141,142,143,117,144,145,84,42,20,85,86,87,88,89,90,91,92,21,34,93,94,95,96,97,98,99,100,29,101,102,81,75,72,82,32,33,103,104,105,106,107,111,112,113,114,115,116,118]))),EditorQuiz:A(()=>W(()=>import("./EditorQuiz-DuBQhXdi.js"),__vite__mapDeps([146,4,2,3,1,5,6,7,8,9,10,11,12,13,14,15,16,17,147,148,149,128,129,103,92,21,34,20,84,90,130,124,150,151,132,133,81,78,75,72,82,89,91,152]))),GenerateQuizPopup:A(()=>W(()=>import("./GenerateQuizPopup-DbERHIAx.js"),__vite__mapDeps([153,4,2,3,1,5,6,7,8,9,10,11,12,13,14,15,16,17,150,151,154,93,94,95,155]))),EditorSummary:A(()=>W(()=>import("./EditorAISummary-6pFGtb80.js"),__vite__mapDeps([156,1,2,3,157,4,5,6,7,8,9,10,11,12,13,14,15,16,17,148,131,129,132,158,81,78,75,72,82,133,89,90,91,92,21,34,20,84]))),EditorImport:A(()=>W(()=>import("./EditorImport-DSvbT5yT.js"),__vite__mapDeps([159,4,2,3,1,5,6,7,8,9,10,11,12,13,14,15,16,17,81,78,75,72,82,84,42,20,85,86,87,88,89,90,91,92,21,34,93,94,95,96,97,98,99,100,29,101,102,32,33,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118]))),VideoEditingProcessingPopup:A(()=>W(()=>import("./VideoEditingProcessingPopup-C0UE9ovm.js"),__vite__mapDeps([160,4,2,3,1,5,6,7,8,9,10,11,12,13,14,15,16,17,161,56,162,163]))),WarnLeavePageWithoutSavingPop:A(()=>W(()=>import("./WarnLeavePageWithoutSavingPop-JyzEfShO.js"),__vite__mapDeps([164,4,2,3,1,5,6,7,8,9,10,11,12,13,14,15,16,17,65]))),AudioGeneratedSuccessPop:A(()=>W(()=>import("./AudioGeneratedSuccessPop-BvRqnC7I.js"),__vite__mapDeps([165,4,2,3,1,5,6,7,8,9,10,11,12,13,14,15,16,17])
2))},props:{},emits:[],provide(){return{getIsDubbingMenuContent:()=>this.currentMenu===M.EDITOR_DUBBING,getCurrentMenu:()=>this.currentMenu,getIsEditMode:()=>this.isEditMode,resetMenu:()=>this.handleResetMenu(),setMenu:e=>this.handleMenuClick(e),ensureEditModePopup:this.ensureEditModePopup,startSaving:this.startSaving,finishSaving:this.finishSaving,[Je]:()=>this.getAllWorkflowData(),[so]:()=>this.readModeText,[pi]:{toolbar:"bg-gray-600",content:"bg-gray-700"},[Qe]:{getCanRecallWorkflow:()=>this.canRecallWorkflow,getShowRecallWorkflowPopup:()=>this.showRecallWorkflowPopup,openRecallWorkflowPopup:this.openRecallWorkflowPopup,confirmRecallWorkflow:this.confirmRecallWorkflow,cancelRecallWorkflow:this.cancelRecallWorkflow}}},data(){return{isLoading:!0,timer:{workflowPublishing:0,AIProcessing:0,AIProcessingSummary:0},allowPublish:!1,workflowId:"",currentMenu:M.EDITOR_ENTRY,previousClickMenu:"",EDITOR_MENU:M,isShowAudioGeneratedSuccessPop:!1,transcriptionSyncBannerDismissed:!1}},computed:{...O("editorAdvance",["sourceWorkflow","workflowForm","isStateChanged","isStateSaving","transcriptionIdByLanguage","workflowTitleByLanguage","segments","isDubbingInProgress"]),...O("editorDubbing",["contentType"]),...O("aiQuizEditor",["questionId"]),...O("aiSummary",["summaryId"]),...Q("aiQuizEditor",["getter_is_ai_processing"]),...Q("aiSummary",["getter_is_ai_processing_summary","getter_is_summary_dirty"]),...pe(Oe,["orgCustomized"]),currentContent(){return this.currentMenu},showSidebar(){return![M.EDITOR_ENTRY,M.EDITOR_DUBBING].includes(this.currentMenu)},showFooter(){const e=[M.EDITOR_CONTENT,M.EDITOR_ANNOTATION];return(this.currentMenu===M.EDITOR_DUBBING?this.contentType!==we.ENTRY:!1)||e.includes(this.currentMenu)},isWorkflowProcessing(){return ki(this.sourceWorkflow)||this.isDubbingInProgress},isOpenProcessingPopup(){return this.isWorkflowProcessing},isApprovalInProgress(){return Ve(this.sourceWorkflow)},readModeText(){return this.isKctBlocked||this.isEditMode?"":this.isApprovalInProgress&&!this.canRecallWorkflow?this.$t("builder.bannerPendingApprovalText"):this.$t("newEditor.bannerReadOnlyMode")}},methods:{...B("annotation",["storeNewEditorAnnotations"]),...B("category",["fetchAllCategories"]),...B("editorAdvance",["patchWorkflowForm","resetEditorAdvance","setDerivedHashMap","setEditingSentences","setEditorWorkflow","setIsStateChanged","setSegments","setSourceIntro","setSentences","setSteps","setTranscriptionInfo","setVideoInfo","setIsDubbingInProgress"]),...B("editorDubbing",["setLastSavedDubbingType","setTranslatedInfos"]),...B("editorZoom",["
2storeImageMaps","dynamicAddUniteByVideoDuration"]),...B("aiSummary",["fetchSummaryFromDb","setIsSummaryDirty"]),...B("aiQuizEditor",["fetchQuizFromDb"]),...Pe(tt,["setNeedApprovalWorkflows"]),...Pe(et,["initAddons"]),handleShareExportClosed(){this.openShareExportTrigger=!1},handleConfirmPreviousClickMenu(){this.setIsStateChanged(!1),this.setIsSummaryDirty(!1),this.currentMenu=this.previousClickMenu,this.previousClickMenu=""},handleGoBack(){window.history.length>1?this.$router.go(-1):this.$router.push(hi.OWNED_BY_ME_WORKFLOWS)},handleMenuClick(e){if(e!==this.currentMenu){if(this.isStateChanged&&this.isEditMode||this.getter_is_summary_dirty){this.previousClickMenu=e;return}this.currentMenu=e}},async fetchSteps(){try{const{ok:e,data:t}=await Ze(this.workflowId,{needSign:!1,originalSteps:!0});return e?(this.setSteps(t.items),t.items):void 0}catch(e){console.error(e)}},async fetchTranscriptionFromDB(e,t){var s;const n=e.languageCode||"en",o=(s=e.transcriptions)==null?void 0:s[n];if(o){const{ok:i,data:r}=await ci(o);if(!i)return;const a=JSON.parse(r.item.sentences),l=ui({sentences:a,steps:t});this.setSentences(l),this.setEditingSentences(Ei(l))}},async fetchImageMapFromDB(e){var o;const{ok:t,data:n}=await vi(e);t&&await this.storeImageMaps(((o=n.item)==null?void 0:o.imageMap)||{})},async getInitialData(){try{this.isLoading=!0,this.fetchAllCategories(),await this.getAllWorkflowData({isFirstTime:!0});const{url:e}=await di("workflow",this.workflowId,"360");this.setVideoInfo({videoSigned360:e})}catch(e){console.error(e)}finally{this.isLoading=!1}},async getInitialDataByWorkflow(e){var t;try{const n=await this.fetchSteps();this.fetchImageMapFromDB(e.imageMap),this.fetchTranscriptionFromDB(e,n),this.dynamicAddUniteByVideoDuration({sourceDuration:((t=e.originalVideo)==null?void 0:t.videoDuration)||0,extraUnit:li})}catch(n){console.error(n)}},async getWorkflowDataOnly(){try{const e=await this.getDocument("workflows",this.workflowId);this.setEditorWorkflow(e);const{ok:t,data:n}=await ai(e.group);return t&&this.setNeedApprovalWorkflows(this.orgCustomized.approvalWorkflowsEnabled&&n.item.requireApprovalWorkflows),this.patchWorkflowForm({title:e.title,poster:e.poster,published:e.published}),e}catch(e){return console.error(e),null}},async getAllWorkflowData({isFirstTime:e=!1}={}){var t,n,o,s;try{const i=await this.getWorkflowDataOnly(),r=i.editType;if(!oi({editType:r})){si({editType:r}).redirect(this.$router,{params:{workflowId:this.workflowId},useReplace:!0});return}e&&this.getInitialDataByWorkflow(i),this.fetchQuizFromDb({id:this.workflowId,quizBy:"workflow"}),this.fetchSummaryFromDb(this.workflowId);const{ok:a,data:l}=await ni(i.workflowEditStep);if(!a)return;const{segments:f=[],annotationElements:p=[],addons:m,translation:S={},titleTranslations:u={},isDubbingInProgress:I=!1,lastSavedDubbingType:k=we.ENTRY,translatedTitle:D="",needsDubbing:v=!1,pendingTranslationList:P=[],intro:b=null,derivedHashMap:E={}}=l.item;if(e){const N=i.audioGsURL!==((t=i.originalVideo)==null?void 0:t.audioGsURL),G=i.published||Ve(i);N||f.length>0||p.length>0||((n=m==null?void 0:m.diagram)==null?void 0:n.length)>0||((o=m==null?void 0:m.links)==null?void 0:o.length)>0||((s=m==null?void 0:m.pdf)==null?void 0:s.length)>0||Object.keys(S).length>0||Object.keys(u).length>0||I||G?this.currentMenu=M.EDITOR_CONTENT:ri.includes(k)?v&&(this.currentMenu=M.EDITOR_DUBBING):(this.setLastSavedDubbingType(k),this.setTranslatedInfos({workflowTitle:D,sentences:[]}),this.currentMenu=M.EDITOR_DUBBING)}this.setIsDubbingInProgress(I),this.setSegments(f),this.setTranscriptionInfo({transcriptionIdByLanguage:S,workflowTitleByLanguage:u,pendingTranslationList:P}),this.setSourceIntro(b),this.setDerivedHashMap(E),this.storeNewEditorAnnotations(p),m&&this.initAddons(m)}catch(i){console.error(i)}},handleResetMenu(){this.currentMenu=M.EDITOR_CONTENT},async handleDubbinggIsCompleted(e){try{await ii({id:e.workflowEditStep,payload:{isDubbingInProgress:!1}}),this.setIsDubbingInProgress(!1),this.isShowAudioGeneratedSuccessPop=!0,await this.getInitialData(),this.currentMenu=M.EDITOR_CONTENT}catch(t){console.error(t)}}},watch:{isLoading:{handler(){this.isWorkflowDataLoaded=!this.isLoading},immediate:!0},"sourceWorkflow.approvalRequestId":{handler(e){e&&this.getApprovalRequest
2(e)},immediate:!0},isWorkflowProcessing:{handler(e){if(!e){clearInterval(this.timer.workflowPublishing);return}this.timer.workflowPublishing=setInterval(()=>{this.getWorkflowDataOnly()},5e3)},immediate:!0},getter_is_ai_processing:{handler(e){if(!e){clearInterval(this.timer.AIProcessing);return}this.timer.AIProcessing=setInterval(()=>{this.fetchQuizFromDb({id:this.workflowId,quizBy:"workflow"})},5e3)},immediate:!0},getter_is_ai_processing_summary:{handler(e){if(!e){clearInterval(this.timer.AIProcessingSummary);return}this.timer.AIProcessingSummary=setInterval(()=>{this.fetchSummaryFromDb(this.workflowId)},5e3)},immediate:!0},sourceWorkflow:{handler(e){He(e)&&this.isDubbingInProgress&&this.handleDubbinggIsCompleted(e)},immediate:!0},isDubbingInProgress:{handler(e){He(this.sourceWorkflow)&&e&&this.handleDubbinggIsCompleted(this.sourceWorkflow)}}},async created(){this.workflowId=this.$route.params.workflowId;const{ok:e,data:t,code:n}=await Ye(this.workflowId);if(!e||!t.item.allowView||!t.item.allowEdit){ti(n)||this.$router.push({name:"404"});return}this.allowPublish=t.item.allowPublish,this.getInitialData()},beforeUnmount(){clearInterval(this.timer.workflowPublishing),clearInterval(this.timer.AIProcessing),clearInterval(this.timer.AIProcessingSummary),this.resetEditorAdvance()}},Mn={class:"EditorAdvanced editor overlay-page"},Rn={class:"editor__header"},On={class:"editor__content"},Ln={class:"editor__content-sidebar"},Bn={class:"editor__content-wrapper"},Vn={class:"editor__content-container"},Nn={class:"editor__content-main"},Un={class:"editor__content-footer"};function Fn(e,t,n,o,s,i){const r=w("EditorHeader"),a=w("EditorSidebar"),l=w("EditorAdvancedBanner"),f=w("EditorFooter"),p=w("VideoEditingProcessingPopup"),m=w("WarnLeavePageWithoutSavingPop"),S=w("AudioGeneratedSuccessPop");return d(),g("div",Mn,[c("div",Rn,[h(r,{"allow-publish":s.allowPublish,"workflow-id":s.workflowId,"is-approval-in-progress":i.isApprovalInProgress,"open-share-export-trigger":o.openShareExportTrigger,onClose:i.handleGoBack,onReloadWorkflow:i.getAllWorkflowData,onShareClosed:i.handleShareExportClosed},null,8,["allow-publish","workflow-id","is-approval-in-progress","open-share-export-trigger","onClose","onReloadWorkflow","onShareClosed"])]),c("div",On,[Z(c("div",Ln,[h(a,{"is-loading":s.isLoading,"model-value":s.currentMenu,onClickMenu:i.handleMenuClick},null,8,["is-loading","model-value","onClickMenu"])],512),[[re,i.showSidebar]]),c("div",Bn,[c("div",Vn,[i.showSidebar?(d(),C(l,{key:0,"is-new-editor":"","transcription-sync-banner-dismissed":s.transcriptionSyncBannerDismissed,onDismiss:t[0]||(t[0]=u=>s.transcriptionSyncBannerDismissed=!0)},null,8,["transcription-sync-banner-dismissed"])):T("",!0),c("div",Nn,[(d(),C(_i(i.currentContent),{"is-loading":s.isLoading},null,8,["is-loading"]))])]),c("div",Un,[Z(h(f,{"is-loading":s.isLoading},null,8,["is-loading"]),[[re,i.showFooter]])])])]),i.isOpenProcessingPopup?(d(),C(p,{key:0,"workspace-id":e.sourceWorkflow.group,"workflow-editor-status":e.sourceWorkflow.editorStatus,"disabled-back":!1},null,8,["workspace-id","workflow-editor-status"])):T("",!0),s.previousClickMenu?(d(),C(m,{key:1,onConfirm:i.handleConfirmPreviousClickMenu,onClose:t[1]||(t[1]=u=>s.previousClickMenu="")},null,8,["onConfirm"])):T("",!0),s.isShowAudioGeneratedSuccessPop?(d(),C(S,{key:2,onConfirm:t[2]||(t[2]=u=>s.isShowAudioGeneratedSuccessPop=!1)})):T("",!0)])}const Hn=ie(An,[["render",Fn],["__scopeId","data-v-00e64b0c"]]),vr=Object.freeze(Object.defineProperty({__proto__:null,default:Hn},Symbol.toStringTag,{value:"Module"}));export{To as E,$o as S,vr as a};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.