1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4014],{29647:function(e,t,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/transcription-editor/[shotId]",function(){return s(63182)}])},63182:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return et}});var a=s(85893),o=s(11163),n=(s(69447),s(63259)),i=s(67294),l=s(9008),r=s.n(l),c=s(6154),d=s(64712),u=s(28011),m=s(94246),h=s(41491),x=s(51526),p=s(74509),f=s(4960),g=s(48828),v=s(4002);s(41664);const w=e=>{let{items:t,desktopClassName:s,mobileClassName:o}=e;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(y,{items:t,className:s}),(0,a.jsx)(j,{items:t,className:o})]})},j=e=>{let{items:t,className:s}=e;const[o,n]=(0,i.useState)(!1);return(0,a.jsxs)("div",{className:(0,m.cn)("relative block md:hidden",s),children:[(0,a.jsx)(x.M,{children:o&&(0,a.jsx)(p.E.div,{layoutId:"nav",className:"absolute bottom-full mb-2 inset-x-0 flex flex-col gap-2 z-[1000]",children:t.map(((e,s)=>(0,a.jsx)(p.E.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10,transition:{delay:.05*s}},transition:{delay:.05*(t.length-1-s)},children:(0,a.jsx)("button",{onClick:e.onClick,className:"h-10 w-10 rounded-full bg-gray-50 flex items-center justify-center",children:(0,a.jsx)("div",{className:"h-4 w-4",children:e.icon})},e.title)},e.title)))})}),(0,a.jsx)("button",{onClick:()=>n(!o),className:"h-10 w-10 rounded-full bg-gray-50 flex items-center justify-center",children:(0,a.jsx)(h.Z,{className:"h-5 w-5 text-neutral-500"})})]})},y=e=>{let{items:t,className:s}=e,o=(0,f.c)(1/0);return(0,a.jsx)(p.E.div,{onMouseMove:e=>o.set(e.pageX),onMouseLeave:()=>o.set(1/0),className:(0,m.cn)("mx-auto hidden md:flex h-16 gap-4 items-end rounded-2xl bg-gray-100 px-4 pb-3",s),children:t.map((e=>(0,a.jsx)(b,{mouseX:o,...e},e.title)))})};function b(e){let{mouseX:t,title:s,icon:o,onClick:n,disabled:l}=e,r=(0,i.useRef)(null),c=(0,g.H)(t,(e=>{var t,s;let a=null!==(s=null===(t=r.current)||void 0===t?void 0:t.getBoundingClientRect())&&void 0!==s?s:{x:0,width:0};return e-a.x-a.width/2})),d=(0,g.H)(c,[-150,0,150],[40,80,40]),u=(0,g.H)(c,[-150,0,150],[40,80,40]),m=(0,g.H)(c,[-150,0,150],[20,40,20]),h=(0,g.H)(c,[-150,0,150],[20,40,20]),f=(0,v.q)(d,{mass:.1,stiffness:150,damping:12}),w=(0,v.q)(u,{mass:.1,stiffness:150,damping:12}),j=(0,v.q)(m,{mass:.1,stiffness:150,damping:12}),y=(0,v.q)(h,{mass:.1,stiffness:150,damping:12});const[b,N]=(0,i.useState)(!1);return(0,a.jsx)("button",{onClick:n,disabled:l,children:(0,a.jsxs)(p.E.div,{ref:r,style:{width:f,height:w},onMouseEnter:()=>N(!0),onMouseLeave:()=>N(!1),className:"aspect-square rounded-full bg-gray-200 flex items-center justify-center relative ".concat(l?"opacity-50 cursor-not-allowed":""),children:[(0,a.jsx)(x.M,{children:b&&(0,a.jsx)(p.E.div,{initial:{opacity:0,y:10,x:"-50%"},animate:{opacity:1,y:0,x:"-50%"},exit:{opacity:0,y:2,x:"-50%"},className:"px-2 py-0.5 whitespace-pre rounded-md bg-gray-100 border text-neutral-700 absolute left-1/2 -translate-x-1/2 -top-8 w-fit text-xs",children:s})}),(0,a.jsx)(p.E.div,{style:{width:j,height:y},className:"flex items-center justify-center",children:o})]})})}var N=s(97975),k=s(70278),S=s(84678),_=s(57820),C=s(15637),L=s(72926),A=s(25675),E=s.n(A);var T=e=>{let{createNewPortion:t,deletePortion:s,handleAudioGenerationSettings:o,splitPortion:n,isSplitDisabled:i,mergePortion:l,isMergeDisabled:r,toggleDeleteDialog:c,undo:d,isUndoDisabled:u,redo:m,isRedoDisabled:h}=e;const x=[{title:"Add New Line",icon:(0,a.jsx)(N.Z,{className:"h-full w-full text-neutral-500 "}),onClick:t},{title:"Delete Line",icon:(0,a.jsx)(k.Z,{className:"h-full w-full text-neutral-500 "}),onClick:c},{title:"Split Line",icon:(0,a.jsx)(S.Z,{className:"h-full w-full text-neutral-500 "}),onClick:n,disabled:i},{title:"Merge Line",icon:(0,a.jsx)(_.Z,{className:"h-full w-full text-neutral-500 "}),onClick:l,disabled:r},{title:"Undo",icon:(0,a.jsx)(C.Z,{className:"h-full w-full text-neutral-500 "}),onClick:d,disabled:u},{title:"Redo",icon:(0,a.jsx)(L.Z,{className:"h-full w-full text-neutral-500 "}),onClick:m,disabled:h}];return(0,a.jsx)("div",{className:"flex items-center justify-center w-full z-[1000]",children:(0,a.jsx)(w,{mobileClassName:"translate-y-20",items:x})})},M=s(18687),z=s(90714),F=s(22899),Z=s(39937),P=s(36035),D=s(24661);var I=e=>{let{showDeleteLineDialog:t,setShowDeleteLineDialog:s,deletePortion:o}=e;return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(M.u,{appear:!0,show:t,as:i.Fragment,children:(0,a.jsxs)(z.Vq,{as:"div",className:"relative z-[70]",onClose:()=>s(!1),children:[(0,a.jsx)(M.x,{as:i.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{className:"fixed inset-0 bg-black/25"})}),(0,a.jsx)("div",{className:"fixed inset-0 overflow-y-auto ",children:(0,a.jsx)("div",{className:"flex min-h-full items-center justify-center p-4 text-center",children:(0,a.jsx)(M.x,{as:"div",enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:(0,a.jsxs)(z.EM,{className:"dialog-panel-5a w-full transform overflow-visible rounded-lg bg-white text-left align-middle shadow-xl transition-all flex flex-col",children:[(0,a.jsx)("div",{className:"flex flex-col flex-grow",children:(0,a.jsxs)(z.$N,{as:"h3",className:"pl-6 pr-6 pt-6 text-lg font-medium leading-6 flex flex-row justify-between",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-y-2",children:[(0,a.jsx)("div",{className:"p-3 rounded-full w-fit bg-red-100",children:(0,a.jsx)("div",{className:"p-1.5 rounded-full bg-red-200",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-7 h-7 text-red-600",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"})})})}),"Delete Line"]}),(0,a.jsx)("button",{className:"items-start justify-start flex",onClick:()=>s(!1),children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-7 w-7 text-gray-400 hover:text-gray-600",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18
118 6M6 6l12 12"})})})]})}),(0,a.jsx)("div",{className:" max-w-[450px] pt-2 text-gray-500 pl-6 pr-6 justify-start flex w-full text-sm",children:"Are you sure you want to delete this line? This action can be undone."}),(0,a.jsx)("div",{className:"flex w-full items-center justify-between gap-x-3 p-6",children:(0,a.jsxs)("div",{className:"w-full flex gap-x-3",children:[(0,a.jsx)(D.z,{variant:"outline",className:"py-6 text-base w-full shadow shadow-sm bg-white",onClick:()=>s(!1),children:"Cancel"}),(0,a.jsx)(D.z,{className:"w-full py-6 text-base bg-red-500 hover:bg-red-600 text-white",onClick:()=>{s(!1),o()},children:"Delete"})]})})]})})})})]})})})};const B=[{name:"DeepL",type:"Text-to-Speech",description:"Description of model 1",model:"deepl-trl-2",cost:50,similarity_and_stability:!0,supported_langs:["English","Spanish","French","German","Italian","Portuguese","Russian","Japanese","Chinese","Korean"],recommended:!0,tag:"Ole Reliable",tag_variant:"brand",features:["For most languages","ML Assisted","High Accuracy"]},{name:"LLSOLLU",type:"Text-to-Speech",description:"Description of model 1",model:"llsollu-1",cost:100,similarity_and_stability:!1,supported_langs:["English","Spanish","French","German","Italian","Portuguese","Russian","Japanese","Chinese","Korean"],recommended:!1,tag:"Best Price",tag_variant:"easy",features:["For Korean to English","High Precision","Error Prone"]}];var U=e=>{let{showTranslationModelSelectionDialog:t,setShowTranslationModelSelectionDialog:s,selectedTranslationModel:o,setSelectedTranslationModel:n}=e;const[l,r]=(0,i.useState)(o);return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(M.u,{appear:!0,show:t,as:i.Fragment,children:(0,a.jsxs)(z.Vq,{as:"div",className:"relative z-[70]",onClose:()=>s(!1),children:[(0,a.jsx)(M.x,{as:i.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{className:"fixed inset-0 bg-black/25"})}),(0,a.jsx)("div",{className:"fixed inset-0 overflow-y-auto ",children:(0,a.jsx)("div",{className:"flex min-h-full items-center justify-center p-4 text-center",children:(0,a.jsx)(M.x,{as:"div",enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:(0,a.jsxs)(z.EM,{className:"dialog-panel- w-full transform overflow-visible rounded-lg bg-white text-left align-middle shadow-xl transition-all flex flex-col",children:[(0,a.jsx)("div",{className:"flex flex-col flex-grow",children:(0,a.jsxs)(z.$N,{as:"h3",className:"pl-6 pr-6 pt-6 text-lg font-medium leading-6 flex flex-row justify-between",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-y-2",children:[(0,a.jsx)("div",{className:"p-3 rounded-full w-fit bg-cerise-red-100",children:(0,a.jsx)("div",{className:"p-1.5 rounded-full bg-cerise-red-200",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-7 h-7 text-cerise-red-600",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m10.5 21 5.25-11.25L21 21m-9-3h7.5M3 5.621a48.474 48.474 0 0 1 6-.371m0 0c1.12 0 2.233.038 3.334.114M9 5.25V3m3.334 2.364C11.176 10.658 7.69 15.08 3 17.502m9.334-12.138c.896.061 1.785.147 2.666.257m-4.589 8.495a18.023 18.023 0 0 1-3.827-5.802"})})})}),"Select Translation Model"]}),(0,a.jsx)("button",{className:"items-start justify-start flex",onClick:()=>s(!1),children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-7 w-7 text-gray-400 hover:text-gray-600",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18 18 6M6 6l12 12"})})})]})}),(0,a.jsx)("div",{className:" pt-2 text-gray-500 pl-6 pr-6 justify-start flex w-full text-sm",children:(0,a.jsx)("div",{className:"grid grid-cols-3 gap-y-4 gap-x-4 mt-3",children:B.map((e=>(0,a.jsxs)("button",{style:{borderColor:l===e.model?"#e63c6c":"rgb(205, 213, 223)"},className:"_16uipyo text-left hover:bg-gray-100/40 ".concat(!e.name||e.disabled||e.isDisabled?"disabled":""," flex-1 w-full min-w-0"),type:"button",onClick:()=>{e.disabled||e.isDisabled||r(e.model)}
1,disabled:e.disabled||e.isDisabled,children:[(0,a.jsxs)("div",{class:"flex justify-between w-full",children:[(0,a.jsx)(F.C,{variant:e.tag_variant,children:e.tag}),(0,a.jsx)("div",{className:"flex-center w-[22px] h-[22px] rounded-full border border-solid flex justify-center items-center",style:{borderColor:l===e.model?"#e63c6c":"rgb(205, 213, 223)",backgroundColor:l===e.model?"#e63c6c":"transparent"},children:l===e.model&&(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"#fff",className:"w-4 h-4",children:(0,a.jsx)("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 12.75l6 6 9-13.5"})})})]}),(0,a.jsx)("div",{class:"text-gray-700 font-semibold mt-4",children:e.name}),(0,a.jsxs)("div",{class:"text-sm font-medium text-gray-600 mt-2 flex flex-col gap-1",children:[e.features[0],(0,a.jsxs)("div",{children:[e.features[1]," "]}),(0,a.jsxs)("div",{children:[null===e||void 0===e?void 0:e.features[2]," "]})]})]},e.job_type_id)))})}),(0,a.jsx)("div",{className:"flex w-full items-center justify-between gap-x-3 p-6",children:(0,a.jsxs)("div",{className:"w-full flex gap-x-3",children:[(0,a.jsx)(D.z,{variant:"outline",className:"py-6 text-base w-full shadow shadow-sm bg-white",onClick:()=>s(!1),children:"Cancel"}),(0,a.jsx)(D.z,{onClick:()=>{n(l),s(!1)},className:"w-full py-6 text-base bg-cerise-red-500 hover:bg-cerise-red-600 text-white",children:"Save"})]})})]})})})})]})})})},R=s(64729),V=s(86010),G=s(57349),O=s(13840),H=s(77e3);var W=e=>{let{showActorConfirmation:t,setShowActorConfirmation:s,handleConfirmActorChange:o,actorName:n}=e;return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(M.u,{appear:!0,show:t,as:i.Fragment,children:(0,a.jsxs)(z.Vq,{as:"div",className:"relative z-[70]",onClose:()=>s(!1),children:[(0,a.jsx)(M.x,{as:i.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{className:"fixed inset-0 bg-black/25"})}),(0,a.jsx)("div",{className:"fixed inset-0 overflow-y-auto ",children:(0,a.jsx)("div",{className:"flex min-h-full items-center justify-center p-4 text-center",children:(0,a.jsx)(M.x,{as:"div",enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:(0,a.jsxs)(z.EM,{className:"dialog-panel- w-full transform overflow-visible rounded-lg bg-white text-left align-middle shadow-xl transition-all flex flex-col",children:[(0,a.jsx)("div",{className:"flex flex-col flex-grow",children:(0,a.jsxs)(z.$N,{as:"h3",className:"pl-6 pr-6 pt-6 text-lg font-medium leading-6 flex flex-row justify-between",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-y-2",children:[(0,a.jsx)("div",{className:"p-3 rounded-full w-fit bg-cerise-red-100",children:(0,a.jsx)("div",{className:"p-1.5 rounded-full bg-cerise-red-200",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-7 h-7 text-cerise-red-600",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19.128a9.38 9.38 0 002.625.372 9.337 9.337 0 004.121-.952 4.125 4.125 0 00-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 018.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0111.964-3.07M12 6.375a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zm8.25 2.25a2.625 2.625 0 11-5.25 0 2.625 2.625 0 015.25 0z"})})})}),"Auto-Assign Actor"]}),(0,a.jsx)("button",{className:"items-start justify-start flex",onClick:()=>s(!1),children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-7 w-7 text-gray-400 hover:text-gray-600",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18 18 6M6 6l12 12"})})})]})}),(0,a.jsxs)("div",{className:" max-w-[450px] pt-2 text-gray-500 pl-6 pr-6 justify-start flex w-full text-sm",children:["Do you want to assign ",n," to all similar portions in this track?"]}),(0,a.jsx)("div",{className:"flex w-full items-center justify-between gap-x-3 p-6",children:(0,a.jsxs)("div",{className:"w-full flex gap-x-3",children:[(0,a.jsx)(D.z,{variant:"outline",className:"py-6 text-base w-full shadow shadow-sm bg-white",onClick:()=>{s(!1),o(!1)},children:"No, just this portion"}),(0,a.jsx)(D.z,{className:"w-full py-6 text-base bg-cerise-red-500 hover:bg-cerise-red-600 text-white",onClick:()=>{s(!1),o(!0)},children:"Yes, assign to all"})]})})]})})})})]})})})},q=s(86215),Y=s(67992);Y.zt,Y.fC,Y.xz,Y.VY,Y.Eh;var K=s(95292),J=s(59335),$=s(61403);const Q=e=>{const t=e=>e.toString().padStart(2,"0"),s=Math.floor(e/3600),a=Math.floor(e%3600/60),o=Math.floor(e%60),n=Math.floor(e%1*1e3);return"".concat(t(s),":").concat(t(a),":").concat(t(o),",").concat(n.toString().padStart(3,"0"))};var X=e=>{let{onFocusChange:t,tracks:s,index:o,start:n,end:l,shotId:r,onPortionChange:u,token:m,actors:h,onOpenActorSettings:f,throwSettingsDialog:g,setThrowSettingsDialog:v,audioPlayerUrl:w,setAudioPlayerUrl:j,openAudioPlayer:y,setOpenAudioPlayer:b,activePortion:N,setActivePortion:k,setActiveTrackId:S,setShowActorSettings:_,setAudioPlayerAudioName:C,updatePortionText:L,pushToUndoStack:A,undoRedoCounter:E,sourceText:M,translatedText:z,translatedTrackLanguage:F,selectedTranslationModel:Z,setSelectedTranslationModel:P,undoStack:B,redoStack:Y,undo:X,redo:ee,isPortionActive:te,shouldSwitchToPortionsTab:se,setShouldSwitchToPortionsTab:ae,selectedAudioModel:oe,actorVoicePortionUpdated:ne,setActorVoicePortionUpdated:ie}=e;var le,re,ce,de;const[ue,me]=(0,i.useState)(M),[he,xe]=(0,i.useState)(z),[pe,fe]=(0,i.useState)(M),[ge,ve]=(0,i.useState)(z),[we,je]=(0,i.useState)(!1),[ye,be]=(0,i.useState)(!1),[Ne,ke]=(0,i.useState)(!1),[Se,_e]=(0,i.useState)((null===(le=null===(re=s[s.length-1])||void 0===re?void 0:re.portions[o])||void 0===le?void 0:le.actor_id)||null),[Ce,Le]=(0,i.useState)(null),[Ae,Ee]=(0,i.useState)(!0),[Te,Me]=(0,i.useState)(null),[ze,Fe]=(0,i.useState)(null),[Ze,Pe]=(0,i.useState)(!1),[De,Ie]=(0,i.useState)(!1),[Be,Ue]=(0,i.useState)(!1),{setCreditsChanged:Re}=(0,$.a)(),[Ve,Ge]=(0,i.useState)(Q(n)),[Oe,He]=(0,i.useState)(Q(l)),[We,qe]=(0,i.useState)(!1),[Ye,Ke]=(0,i.useState)(!1),[Je,$e]=(0,i.useState)(null),[Qe,Xe]=(0,i.useState)(!1),[et,tt]=(0,i.useState)(!1),[st,at]=(0,i.useState)(null),[ot,nt]=(0,i.useState)(null),[it,lt]=(0,i.useState)(null),[rt,ct]=(0,i.useState)(!1),[dt,ut]=(0,i.useState)(!1),[mt,ht]=(0,i.useState)(!1),xt=(0,i.useRef)(null),pt=(0,i.useRef)(null),ft=(0,i.useRef)(null),gt=(0,i.useRef)(null),vt=(0,i.useRef)(null),wt=(0,i.useRef)(null),jt=(0,i.useRef)(null),[yt,bt]=(0,i.useState)(!1),[Nt,kt]=(0,i.useState)(!1),[St,_t]=(0,i.useState)(!1),Ct=(0,i.useRef)([]),[Lt,At]=(0,i.useState)(!1),Et="EDIT_SOURCE_TEXT",Tt=(0,i.useCallback)((()=>{let e;s.length>1?(e=s[1].portions[o],S(s[1].id)):(e=s[0].portions[o],S(s[0].id)),N&&N.portion_id===e.portion_id||k(e)}),[s,o,k,N]);(0,i.useEffect)((()=>{me(M),xe(z)}),[M,z,E]),(0,i.useEffect)((()=>{var e,t,a,n;fe((null===(e=null===(t=s[0])||void 0===t?void 0:t.portions[o])||void 0===e?void 0:e.text)||""),ve((null===(a=null===(n=s[1])||void 0===n?void 0:n.portions[o])||void 0===a?void 0:a.text)||"")}),[s,o]);const Mt=e=>(0,V.default)("w-full p-2 rounded resize-none focus:outline-none transition-colors duration-200",{"bg-blue-50":Te===e,"text-[#b6b8c1]":Ne&&ze!==e,"cursor-not-allowed":Ne&&ze!==e},"disabled:bg-transparent disabled:border-transparent"),zt=async function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];try{if(t){const t=s[0].portions[o].speaker;for(const a of s)await c.Z.put("/shots/".concat(r,"/tracks/").concat(a.id),{actor_id:e,speaker:t})}else for(const t of s){const s={actor_id:e};await c.Z.put("/shots/".concat(r,"/tracks/").concat(t.id,"/portions/").concat(t.portions[o].portion_id),s)}_e(e),await u(),ie(!ne)}catch(a){console.error("Error updating actor:",a),d.A.error("Failed to assign actor")}};(0,i.useEffect)((()=>{const e=e=>{ft.current&&!ft.current.contains(e.target)&&(be(!1),je(!1),t(!1))};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[t]),(0,i.useEffect)((()=>{const e=e=>{pt.current&&!pt.current.contains(e.target)&&tt(!1)};return et&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[et]);const Ft=async()=>{for(const a of s){var e;const s=null===(e=a.portions[o])||void 0===e?void 0:e.portion_id;if(s)try{c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(m);(await c.Z.delete("/shots/".concat(r,"/tracks/").concat(a.id,"/portions/").concat(s))).status}catch(t){console.error("Error deleting portion from ".concat(a.portions[o]," track:"),t),d.A.error("Failed to delete portion from ".concat(a.portions[o]," track"))}}u()};(0,i.useEffect)((()=>{const e=()=>{const e=Ct.current.filter(Boolean),t=window.innerHeight+window.pageYOffset>=document.documentElement.scrollHeight-1,s=e.map((e=>{const t=e.getBoundingClientRect();return{textarea:e,top:t.top,bottom:t.bottom}}));e.forEach((e=>{e.style.height="auto",e.style.height="".concat(e.scrollHeight,"px")})),requestAnimationFrame((()=>
1{if(t)window.scrollTo(0,document.documentElement.scrollHeight);else{const e=s.reduce(((e,t)=>{let{textarea:s,top:a}=t;return e+(a-s.getBoundingClientRect().top)}),0);window.scrollBy(0,e)}}))};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[ue,he,s.length,s]),(0,i.useEffect)((()=>{const e=e=>{e.preventDefault(),e.stopPropagation()};return Ct.current.forEach((t=>{t&&t.addEventListener("focus",e,{passive:!1})})),()=>{Ct.current.forEach((t=>{t&&t.removeEventListener("focus",e)}))}}),[]);const Zt=e=>{Me(e),be(!0),t(!0);const s=Ct.current[e];if(s){const e=s.getBoundingClientRect();if(e.bottom>window.innerHeight){const t=window.pageYOffset+e.top-20;window.scrollTo({top:t,behavior:"smooth"})}}},Pt=async()=>{var e;if(!Nt)return;const a=s.find((e=>"basic"===e.type));s.find((e=>"translated"===e.type));if(a&&(null===(e=a.portions[o])||void 0===e?void 0:e.text)!==ue)if(s.length>1)At(!0);else{const e=a.portions[o].portion_id;A({type:Et,trackId:a.id,portionId:e,data:ue,previousData:a.portions[o].text}),await L(a.id,e,ue,!0)}kt(!1),setTimeout((()=>{var e,s;(null===(e=gt.current)||void 0===e?void 0:e.contains(document.activeElement))||(null===(s=vt.current)||void 0===s?void 0:s.contains(document.activeElement))||(Me(null),t(!1))}),0)},Dt=(e,t)=>{if(0===t||t===e.length)return!1;const s=e[t-1],a=e[t];return/\S/.test(s)&&/\s/.test(a)||/\s/.test(s)&&/\S/.test(a)},It=(e,t,s)=>{const a=e.target.value;if(t(a),(e=>{const t=Ct.current[e];if(t){const e=window.pageYOffset;t.style.height="auto",t.style.height="".concat(t.scrollHeight,"px"),window.scrollTo(0,e)}})(e.target),kt(!0),Fe(s),0===s){const t=e.target.selectionStart,s=Dt(a,t);Ee(!s)}else Ee(!0)},Bt=(e,t)=>
1{const s=0===t?ue:he,a=e.target.selectionStart;if(Le(a),0===t){const t=e.target.selectionStart,o=e.target.selectionEnd,n=Dt(s,a)&&t===o;Ee(!n)}else Ee(!0)},Ut=async()=>{ht(!0);const e=s.length>1,t=e?s[1].portions[o].text:s[0].portions[o].text;try{c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(m);const s=(await c.Z.post("/openai",{text:t,model:"gpt-4o-mini"})).data.text;e?(xe(s),ke(!0),Fe(1)):(me(s),ke(!0),Fe(0))}catch(a){console.error("Error fixing portion length:",a)}finally{ht(!1)}},[Rt,Vt]=(0,i.useState)(!1),Gt=()=>{if(ts)(async e=>{const t=s.find((e=>{var t;return(null===(t=e.portions[o])||void 0===t?void 0:t.text)!==(e.id===s[0].id?ue:he)}));if(!t)return;const a=t.portions[o].portion_id;t.id,s[0].id;try{c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(m),200===(await c.Z.put("/shots/".concat(r,"/tracks/").concat(t.id,"/portions/").concat(a),{text:e})).status&&(ke(!1),xe(e),u())}catch(n){console.error("Error updating portion:",n),d.A.error("Failed to update portion")}})(as);else if(Lt){var e,t;me((null===(e=null===(t=s[0])||void 0===t?void 0:t.portions[o])||void 0===e?void 0:e.text)||"")}else{var a,n,i,l;me((null===(a=null===(n=s[0])||void 0===n?void 0:n.portions[o])||void 0===a?void 0:a.text)||""),xe((null===(i=null===(l=s[1])||void 0===l?void 0:l.portions[o])||void 0===i?void 0:i.text)||"")}ke(!1),ss(!1),At(!1)},[Ot,Ht]=(0,i.useState)(!1),Wt=o===s[0].portions.length-1,qt={createNewPortion:async()=>{for(const t of s)try{c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(m);const e=await c.Z.post("/shots/".concat(r,"/tracks/").concat(t.id,"/portions"),{index:o+1,text:""});200===e.status&&console.log("create new portion succeded",e.data)}catch(e){console.error("Error creating portion in ".concat(t.language," track:"),e),d.A.error("Failed to create new portion in ".concat(t.language," track"))}u()},deletePortion:Ft,handleAudioGenerationSettings:()=>{console.log("Audio generation settings clicked")},splitPortion:async()=>{if(Ae||Rt)return;be(!1),Vt(!0);d.A.promise((async()=>{const e=s.find((e=>"basic"===e.type)),t=s.find((e=>"translated"===e.type)),a=e.portions[o].words;let n=null,i=null,l=0;for(let s=0;s<a.length;s++){const e=a[s];if(e.value.length+a.slice(0,s).reduce(((e,t)=>e+t.value.length),0)>=Ce){var d;n=e.id,l=s,(null===(d=null===t||void 0===t?void 0:t.portions[o])||void 0===d?void 0:d.words[l])&&(i=t.portions[o].words[l].id);break}}if(!n)throw new Error("No word found at cursor position");if(await c.Z.post("/shots/".concat(r,"/tracks/").concat(e.id,"/portions/").concat(e.portions[o].portion_id,"/split"),{word_id:n}),t&&i){await c.Z.post("/shots/".concat(r,"/tracks/").concat(t.id,"/portions/").concat(t.portions[o].portion_id,"/split"),{word_id:i});const s=await c.Z.get("/shots/".concat(r)),a=s.data.shot_editor_json.tracks.find((e=>"basic"===e.type)),n=s.data.shot_editor_json.tracks.find((e=>"translated"===e.type)),l=async(s,a)=>{const o=await c.Z.post("/tasks",{name:"translate-portion",data:{track_id:t.id,source_track_id:e.id,dest_track_id:t.id,dest_portion_id:a,source_portion_id:s,shot_id:r,trl_model:Z},shot_id:r});return 200===o.status?(await c.Z.post("/tasks/".concat(o.data.id,"/submit")),o.data.id):null},[d,u]=await Promise.all([l(a.portions[o].portion_id,n.portions[o].portion_id),l(a.portions[o+1].portion_id,n.portions[o+1].portion_id)]),m=async()=>{for(;;){const e=await Promise.all([c.Z.get("/tasks/".concat(d)),c.Z.get("/tasks/".concat(u))]);if(e.some((e=>"FAILED"===e.data.status)))throw new Error("Translation failed");if(e.every((e=>"COMPLETED"===e.data.status)))break;await new Promise((e=>setTimeout(e,1e3)))}};await m()}return u(),{translated:!!t}}),{loading:"Splitting portion...",success:e=>(Vt(!1),e.translated?"Successfully split and translated portions":"Successfully split portion"),error:e=>(Vt(!1),console.error("Split operation failed:",e),"Failed to split portion"),position:"top-center",closeButton:!1})},isSplitDisabled:Ae||Rt,isSplitting:Rt,mergePortion:async()=>
1{if(!Wt&&!Ot){Ht(!0);try{be(!1),c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(m);const e=await c.Z.post("/shots/".concat(r,"/tracks/").concat(s[0].id,"/portions/").concat(s[0].portions[o].portion_id,"/merge"));if(s.length>1){await c.Z.post("/shots/".concat(r,"/tracks/").concat(s[1].id,"/portions/").concat(s[1].portions[o].portion_id,"/merge"))}200===e.status&&u()}catch(e){console.error("Error merging portions:",e),d.A.error("Failed to merge portions")}finally{Ht(!1)}}},isMergeDisabled:Wt||Ot,isMerging:Ot,toggleDeleteDialog:()=>{Pe(!Ze)},undo:X,isUndoDisabled:0===B.length,redo:ee,isRedoDisabled:0===Y.length},Yt=(0,i.useRef)(null),Kt=()=>{clearTimeout(Yt.current),bt(!0)},Jt=()=>{Yt.current=setTimeout((()=>{bt(!1)}),100)};(0,i.useEffect)((()=>()=>{Yt.current&&clearTimeout(Yt.current)}),[]);const $t=e=>{const[t,s]=e.split(","),[a,o,n]=t.split(":").map(Number);return 3600*a+60*o+n+Number(s)/1e3},Qt=(e,t)=>{const a=e.target.value,n=((e,t)=>{var a,n;const i=$t(e),l=s.find((e=>"translated"===e.type))||s.find((e=>"basic"===e.type));if(!l)return console.error("No valid track found"),!1;const r=(null===(a=l.portions[o-1])||void 0===a?void 0:a.end)||0,c=(null===(n=l.portions[o+1])||void 0===n?void 0:n.start)||1/0;return t?i>=r&&i<$t(Oe):i>$t(Ve)&&i<=c})(a,t);qe(!n),t?Ge(a):He(a)};(0,i.useEffect)((()=>{var e;let t;t=s.length>1?s[1].portions[o]:s[0].portions[o];const a=h.find((e=>e.actor_id===(null===t||void 0===t?void 0:t.actor_id)));Ge(Q(null===t||void 0===t?void 0:t.start)),He(Q(null===t||void 0===t?void 0:t.end)),!(null===t||void 0===t?void 0:t.actor_id)|!a||!(null===a||void 0===a?void 0:a.voice_id)?at("text-red-600"):(null===t||void 0===t?void 0:t.audio)&&0!==Object.keys(null===t||void 0===t?void 0:t.audio).length?at("text-green-600"):at
1("text-yellow-600"),(null===t||void 0===t||null===(e=t.audio)||void 0===e?void 0:e.media_id)&&at("text-green-600"),ut((null===t||void 0===t?void 0:t.has_time_inconsistency)||!1)}),[s,o,h,u]);const Xt=async e=>{if(e?Ie(!1):Ue(!1),We)e?Ge(Q(n)):He(Q(l)),qe(!1);else try{c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(m);const t=s.find((e=>"translated"===e.type))||s.find((e=>"basic"===e.type)),a=e?{start:$t(Ve)}:{end:$t(Oe)};200===(await c.Z.put("/shots/".concat(r,"/tracks/").concat(t.id,"/portions/").concat(t.portions[o].portion_id),a)).status&&u()}catch(t){console.error("Error updating time:",t)}},es=e=>{const t=h.find((t=>t.actor_id===e));return t?t.name||"Actor ".concat(h.indexOf(t)+1):"Select Actor"},[ts,ss]=(0,i.useState)(!1),[as,os]=(0,i.useState)(null),[ns,is]=(0,i.useState)(!1),ls=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:700;for(let o=0;o<t;o++)try{c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(m);const t=await c.Z.get("/media/".concat(e,"?signed_url=true&downloadable=true"));Math.round(16e3*t.data.metadata.duration*2/8);return t.data.signed_url}catch(a){if(!a.response||400!==a.response.status)throw a;console.log("Media ".concat(e," still uploading. Retrying in ").concat(s/1e3," seconds...")),await new Promise((e=>setTimeout(e,s)))}throw new Error("Failed to fetch media ".concat(e," after ").concat(t," attempts"))},rs=e=>{if("Enter"===e.key)if(e.ctrlKey){const t=e.target.selectionStart,s=e.target.value.substring(0,t),a=e.target.value.substring(t);e.target===gt.current?me(s+"\n"+a):e.target===vt.current&&xe(s+"\n"+a),setTimeout((()=>{e.target.selectionStart=e.target.selectionEnd=t+1}),0)}else e.preventDefault(),e.target.blur();else"Escape"===e.key&&(e.preventDefault(),e.target.blur())};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(W,{showActorConfirmation:Ye,setShowActorConfirmation:Ke,handleConfirmActorChange:async e=>{e?await zt(Je,!0):await zt(Je,!1),$e(null)},actorName:es(Je)}),(0,a.jsxs)("div",{ref:ft,onClick:()=>{var e;return Tt(null===(e=s[0])||void 0===e?void 0:e.portions[o])},className:"flex flex-col space-y-2 border border-1 border-t-0 border-l-0 border-r-0 w-full relative",children:[(0,a.jsxs)("div",{className:"pt-4 flex justify-between items-center mb-2 relative",children:[(0,a.jsx)("div",{className:"ml-4",children:(0,a.jsx)("div",{ref:pt,className:"relative w-40",children:(0,a.jsxs)(R.Ri,{value:Se,onChange:async e=>{if("Create New Actor"===e)try{c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(m);const e=h.length,t=await c.Z.post("/shots/".concat(r,"/actors"),{name:"Actor ".concat(e+1)});if(200===t.status){t.data;u(),d.A.success("New actor created successfully")}}catch(n){console.error("Error creating new actor:",n),d.A.error("Failed to create new actor")}else{const n=e;let i;var t,a;if(s.length>1)i=null===(t=s[1].portions[o])||void 0===t?void 0:t.actor_id;else i=null===(a=s[0].portions[o])||void 0===a?void 0:a.actor_id;const l=s.some((e=>e.portions.some((e=>e.actor_id===n))));n===i||l?(_e(e),await zt(e,!1)):($e(n),Ke(!0))}},children:[(0,a.jsxs)(R.Y4,{ref:xt,className:(0,V.default)("relative w-full rounded-lg bg-white py-2 pl-3 pr-10 text-left text-sm text-gray-900 border","focus:outline-none focus:ring-2 focus:ring-cerise-red-500 focus:border-cerise-red-500",te&&"border-cerise-red-500"),onClick:()=>tt(!et),children:[(0,a.jsx)("span",{className:"block truncate",children:Se?es(Se):"Select Actor"}),(0,a.jsx)("span",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2",children:(0,a.jsx)(G.Z,{className:"h-5 w-5 text-gray-400","aria-hidden":"true"})})]}),(0,a.jsxs)(R.O_,{className:(0,V.default)("absolute z-10 mt-1 w-full rounded-md bg-white py-1 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none","max-h-60 overflow-auto text-sm scrollbar-thin scrollbar-thumb-gray-300 scrollbar-track-gray-100"),children:[h.map(((e,t)=>(0,a.jsx)(R.wt,{value:e.actor_id,className:e=>{let{active:t,selected:s}=e;return(0,V.default)("cursor-default select-none relative py-2 pl-9 pr-4",t?"text-white bg-cerise-red-600":"text-gray-900",s&&"bg-cerise-red-100")},children:t=>{let{selected:s,active:o}=t;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:(0,V.default)("block truncate",s&&"font-semibold"),children:es(e.actor_id)}),s&&(0,a.jsx)("span",{className:(0,V.default)("absolute inset-y-0 left-0 flex items-center pl-3",o?"text-white":"text-cerise-red-600"),children:(0,a.jsx)(O.Z,{className:"h-5 w-5","aria-hidden":"true"})})]})}},e.actor_id))),(0,a.jsxs)(R.wt,{value:"Create New Actor",className:e=>{let{active:t}=e;return(0,V.default)("cursor-default select-none relative py-2 pl-3 pr-9 flex items-center",t?"text-white bg-cerise-red-600":"text-gray-900")},children:[(0,a.jsx)(H.Z,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),(0,a.jsx)("span",{children:"Add Actor"})]})]})]})})}),(0,a.jsxs)("span",{className:"text-xs text-gray-400 absolute left-1/2 transform -translate-x-1/2 whitespace-nowrap",children:[De?(0,a.jsx)("input",{ref:wt,type:"text",value:Ve,onChange:e=>Qt(e,!0),onBlur:()=>Xt(!0),className:"w-24 text-center ".concat(We?"text-red-500":"")}
1):(0,a.jsx)("span",{onClick:()=>{Ie(!0),setTimeout((()=>{var e;return null===(e=wt.current)||void 0===e?void 0:e.focus()}),0)},className:"".concat(te?"text-cerise-red-500":"text-gray-400"),children:Ve}),(0,a.jsx)("span",{className:"".concat(te?"text-cerise-red-500":"text-gray-400"),children:" \u2014 "}),Be?(0,a.jsx)("input",{ref:jt,type:"text",value:Oe,onChange:e=>Qt(e,!1),onBlur:()=>Xt(!1),className:"w-24 text-center ".concat(We?"text-red-500":""," ").concat(te?"text-cerise-red-500":"")}):(0,a.jsx)("span",{onClick:()=>{Ue(!0),setTimeout((()=>{var e;return null===(e=jt.current)||void 0===e?void 0:e.focus()}),0)},className:"".concat(te?"text-cerise-red-500":"text-gray-400"),children:Oe})]}),(0,a.jsxs)("div",{className:" flex items-start justify-start relative",children:[(0,a.jsx)("div",{onClick:async()=>{let e,t;console.log("handleAudioClick called");const s=await c.Z.get("/shots/".concat(r));console.log("Track repo",s.data.shot_editor_json);let a=s.data.shot_editor_json.tracks,n=s.data.shot_editor_json.actors;const i=a.find((e=>"translated"===e.type)),l=a.find((e=>"basic"===e.type));if(i){if(console.log("translated track found"),t=i,e=i.portions[o],e.audio){console.log("currentPortion.audio found",e.audio);const t=await ls(e.audio.media_id);return console.log("signedAudioUrl",t),ae(!0),j(t),C(e.audio.media_id),void b(!0)}}else{if(!l)return console.error("No suitable track found"),void console.log("tracks",a);if(t=l,e=l.portions[o],e.audio){const t=await ls(e.audio.media_id);return console.log("signedAudioUrl",t),ae(!0),j(t),C(e.audio.media_id),void b(!0)}}if(!e.actor_id)return console.log("no actor id"),tt(!0),void setTimeout((()=>{xt.current&&xt.current.click()}),0);{const s=n.find((t=>t.actor_id===e.actor_id));if(s&&!s.voice_id)f(e.actor_id);else{console.log("actor found");const s=await c.Z.post("/tasks",{name:"portion-to-audio",data:{track_id:t.id,actor_id:e.actor_id,portion_id:e.portion_id,shot_id:r,model:oe}});if(200===s.status&&s.data){console.log("task creation response",s.data);const e=s.data.credits;await Promise.all([lt(s.data.id),nt(e)]),setTimeout((()=>ct(!0)),0)}else d.A.error("Failed to create job")}}},className:"w-4 h-4 flex-shrink-0 mr-3 place-items-end cursor-pointer",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 ".concat(st),children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.114 5.636a9 9 0 0 1 0 12.728M16.463 8.288a5.25 5.25 0 0 1 0 7.424M6.75 8.25l4.72-4.72a.75.75 0 0 1 1.28.53v15.88a.75.75 0 0 1-1.28.53l-4.72-4.72H4.51c-.88 0-1.704-.507-1.938-1.354A9.009 9.009 0 0 1 2.25 12c0-.83.112-1.633.322-2.396C2.806 8.756 3.63 8.25 4.51 8.25H6.75Z"})})}),null!==ot&&(0,a.jsx)("div",{className:" z-[50] cursor-pointer place-items-end",children:(0,a.jsxs)(K.fC,{className:"z-[70] ",open:rt,onOpenChange:e=>{e||(ct(!1),nt(null),lt(null))},children:[(0,a.jsx)(K.xz,{asChild:!0,children:(0,a.jsx)("div",{className:" h-4"})}),(0,a.jsx)(K.h_,{children:(0,a.jsxs)(K.VY,{transition:!0,anchor:"right",focus:!0,className:"z-[30] right-0 w-64 mr-9 rounded-md shadow-lg bg-white divide-y divide-gray-100 relative",children:[(0,a.jsx)(K.Eh,{className:"stroke-gray-200 stroke-1.5 fill-white",width:16,height:8}),(0,a.jsx)("div",{className:"z-[30] relative bg-white rounded-md border items-center justify-centerborder-gray-200",children:(0,a.jsxs)("div",{className:"pt-3 pl-2 ",children:[(0,a.jsx)("h3",{className:"text-base font-medium text-gray-900",children:"Confirm Audio Generation"}),(0,a.jsx)("div",{className:"flex justify-between text-xs mt-3 ",children:(0,a.jsxs)("div",{children:["Are you sure you want to generate audio for ",(0,a.jsx)("span",{className:"font-bold",children:Se?"Actor ".concat(h.findIndex((e=>e.actor_id===Se))+1):"Select Actor"}),"? Doing so will cost ",(0,a.jsx)("span",{className:"font-bold",children:ot})," credits."]})})]})}),(0,a.jsx)("div",{className:"mt-4 flex justify-end space-x-2 p-2",children:(0,a.jsx)(D.z,{disabled:ns,onClick:()=>(async e=>{try{is(!0),console.log("calling with taskid",e),await c.Z.post("/tasks/".concat(e,"/submit"));const t=async()=>{const s=await c.Z.get("/tasks/".concat(e)),a=s.data.status;if("COMPLETED"===a){console.log("completed task response",s.data);const e=(await c.Z.get("/shots/".concat(r))).data.shot_editor_json.tracks.filter((e=>"source"!==e.type));let t;t=e.length>
11?e[e.length-1].portions[o]:e.find((e=>"basic"===e.type)).portions[o],c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(m),k(t);const a=await ls(t.audio.media_id);console.log("signedAudioUrl",a),j(a),C(t.audio.media_id),b(!0),ct(!1),is(!1),Re(!0),at("text-green-600"),u()}else"FAILED"===a?(console.error("Translation task failed"),d.A.error("Translation task failed"),is(!1)):setTimeout(t,5e3)};t()}catch(s){var t;402===(null===(t=s.response)||void 0===t?void 0:t.status)?d.A.error(s.response.data.message||"Insufficient credits. Wait for your subscription to renew or upgrade your plan to continue."):d.A.error("Error generating audio. Your voice might have been blocked by ElevenLabs which causes this error. If you have continued issues, reach out on our discord or shoot us a email."),is(!1)}})(it),variant:"outline",className:"w-full flex flex-row gap-x-1",children:ns?(0,a.jsx)(J.Spinner,{className:"w-5 h-5"}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m3.75 13.5 10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75Z"})}),"Confirm & Generate"]})})})]})})]})})]})]}),(0,a.jsxs)("div",{className:"flex w-full items-stretch relative",children:[(0,a.jsx)("div",{className:" p-2 w-full",children:(0,a.jsx)("textarea",{ref:e=>{Ct.current[0]=e,gt.current=e},value:ue,onChange:e=>It(e,me,0),onSelect:e=>Bt(e,0),onFocus:()=>Zt(0),onBlur:Pt,onKeyDown:rs,className:Mt(0),style:{overflow:"hidden",minHeight:"2rem"},disabled:Ne&&1===ze},"source-".concat(E))}),s.length>1&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col justify-center px-2",children:[(0,a.jsx)("div",{className:"flex flex-row items-center rounded-lg mb-2 ",children:(0,a.jsxs)("svg",{onClick:()=>async function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];if(s.length<2)return void d.A.error("Not enough tracks for translation");const t=s.find((e=>"basic"===e.type)),a=s.find((e=>"translated"===e.type));if(!t||!a)return void d.A.error("Missing required tracks for translation");const n=async()=>{const s=t,n=a,i=t.portions[o],l=a.portions[o],d={track_id:n.id,source_track_id:s.id,dest_track_id:n.id,dest_portion_id:l.portion_id,source_portion_id:i.portion_id,shot_id:r,trl_model:Z},u=await c.Z.post("/tasks",{name:"translate-portion",data:d,shot_id:r});if(200!==u.status)throw new Error("Failed to create translation task");return await c.Z.post("/tasks/".concat(u.data.id,"/submit")),new Promise(((t,s)=>{const a=async()=>{try{const o=await c.Z.get("/tasks/".concat(u.data.id)),n=o.data.status;if("COMPLETED"===n){const s=o.data.data.sub_tasks[1].input.text;os(he),s!==he&&(xe(s),e&&ke(!0),Fe(1),ss(!0)),t(s)}else"FAILED"===n?s(new Error("Translation task failed")):setTimeout(a,5e3)}catch(o){s(o)}};a()}))};d.A.promise(n,{loading:"Translating portion...",success:()=>(setTimeout((()=>{d.A.dismiss()}),1e3),"Translation completed successfully"),error:e=>(console.error("Error in translation task:",e),e.message||"An error occurred during translation"),position:"top-center"})}(),xmlns:"http://www.w3.org/2000/svg",strokeWidth:1.5,stroke:"currentColor","data-name":"Layer 1",viewBox:"0 0 30 30",className:"w-4 h-4 cursor-pointer ".concat(Lt?"text-cerise-red-500 animate-pulse":"text-gray-400 hover:text-black"),children:[(0,a.jsx)("path",{d:"M13.83 19.55 19.08 8.3l5.25 11.25m-9-3h7.5M6.33 4.17c1.99-.25 3.99-.37 6-.37m0 0c1.12 0 2.23.04 3.33.11m-3.33-.11V1.55m3.34 2.36a18.04 18.04 0 0 1-9.33 12.14m9.33-12.14c.9.06 1.78.15 2.67.26m-4.6 8.49a18.1 18.1 0 0 1-3.83-5.8",fill:"none"}),(0,a.jsx)("path",{d:"M19.72 20.81c.29-.29.77-.29 1.06 0l3.75 3.75c.29.29.29.77 0 1.06l-3.75 3.75c-.28.3-.76.32-1.06.04s-.32-.76-.04-1.06c.01-.01.02-.03.04-.04l2.47-2.47H6c-.41 0-.75-.34-.75-.75s.34-.75.75-.75h16.19l-2.47-2.47a.754.754 0 0 1 0-1.06",stroke:"none",fill:"currentColor"})]})}),(0,a.jsx)("div",{className:"w-px flex-grow mx-auto bg-gray-200"})]}),(0,a.jsxs)("div",{className:"w-full flex flex-row items-stretch",children:[(0,a.jsx)("div",{className:"p-2 w-full relative",children:(0,a.jsx)("textarea",{ref:e=>{Ct.current[1]=e,vt.current=e}
1,value:he,onChange:e=>It(e,xe,1),onKeyUp:e=>Bt(e,1),onFocus:()=>Zt(1),onBlur:Pt,onKeyDown:rs,className:Mt(1),style:{overflow:"hidden",minHeight:"2rem"},disabled:Ne&&0===ze||Lt},"source-".concat(E))}),dt&&(0,a.jsx)(q.J2,{className:"relative flex items-center ",children:e=>{let{open:t}=e;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(q.O7,{className:"focus:outline-none",onMouseEnter:Kt,onMouseLeave:Jt,children:(0,a.jsx)("div",{className:"mr-2.5",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-5 h-5 text-yellow-600",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z"})})})}),yt&&(0,a.jsxs)(q.Hi,{static:!0,transition:!0,anchor:"right",className:"absolute overflow-hidden z-10 right-0 mt-2 ml-6 w-64 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 divide-y divide-gray-100",onMouseEnter:Kt,onMouseLeave:Jt,children:[(0,a.jsx)("div",{className:"py-3 block px-4 text-sm text-gray-700 ",children:(0,a.jsx)("p",{className:"font-semibold",children:"Portion Duration Warning"})}),(0,a.jsx)("div",{className:"p-2 px-4 py-2 text-sm text-gray-500",children:"Translated text is longer than the original. We recommend reducing the number of characters for natural speech rhythm."}),(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)(D.z,{disabled:mt,onClick:Ut,variant:"outline",className:"w-full flex flex-row gap-x-1",children:mt?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(J.Spinner,{className:"w-5 h-5"})," Rewriting"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-5 h-5",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m3.75 13.5 10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75Z"})}),"Rewrite with AI"]})})})]})]})}})]})]}),dt&&1===s.length&&(0,a.jsx)(q.J2,{className:"relative",children:e=>{let{open:t}=e;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(q.O7,{className:"focus:outline-none",onMouseEnter:Kt,onMouseLeave:Jt,children:(0,a.jsx)("div",{className:"mr-2.5",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-5 h-5 text-yellow-600",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z"})})})}),yt&&(0,a.jsxs)(q.Hi,{static:!0,transition:!0,anchor:"right",className:"absolute z-10 right-0 mt-2 ml-6 w-64 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 divide-y divide-gray-100 overflow-hidden",onMouseEnter:Kt,onMouseLeave:Jt,children:[(0,a.jsx)("div",{className:"py-3 block px-4 text-sm text-gray-700 ",children:(0,a.jsx)("p",{className:"font-semibold",children:"Portion Duration Warning"})}),(0,a.jsx)("div",{className:"p-2 px-4 py-2 text-sm text-gray-500",children:"Current portion is longer or shorter than the original. We recommend adding or removing characters for natural speech rhythm."}),(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)(D.z,{disabled:mt,onClick:Ut,variant:"outline",className:"w-full flex flex-row gap-x-1",children:mt?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(J.Spinner,{className:"w-5 h-5"})," Rewriting"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-5 h-5",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m3.75 13.5 10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75Z"})}),"Rewrite with AI"]})})})]})]})}})]}),(0,a.jsx)(x.M,{children:Ne&&(0,a.jsxs)(p.E.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},className:"flex flex-row justify-between items-center gap-x-2 text-sm w-full pr-1.5 pb-4 pt-2",children:[(0,a.jsx)("div",{className:"w-5"}),(0,a.jsxs)("div",{className:"flex flex-row items-center gap-x-2",children:[(0,a.jsx)("div",{onClick:Gt,className:"text-gray-400 hover:text-gray-600 cursor-pointer font-base mr-2",children:(0,a.jsx)("span",{className:"mr-1",children:"Cancel"})}),(0,a.jsx)("div",{onClick:async()=>{const e=s.find((e=>{var t;return(null===(t=e.portions[o])||void 0===t?void 0:t.text)!==(e.id===s[0].id?ue:he)}));if(!e)return;const t=e.portions[o].portion_id,a=e.id===s[0].id?ue:he;try{c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(m);200===(await c.Z.put("/shots/".concat(r,"/tracks/").concat(e.id,"/portions/").concat(t),{text:a})).status&&(ke(!1),ss(!1),u())}catch(n){console.error("Error updating portion:",n),d.A.error("Failed to update portion")}},className:"text-cerise-red-600 hover:text-cerise-red-800 cursor-pointer font-base -ml-1",children:"Save"})]})]})}),(0,a.jsx)(x.M,{children:Lt&&(0,a.jsxs)(p.E.div,{initial:{opacity:0,y:20}
1,animate:{opacity:1,y:0},exit:{opacity:0,y:20},className:"flex flex-row justify-between items-center gap-x-2 text-sm w-full pr-1.5 pb-4 pt-2",children:[(0,a.jsx)("div",{className:"w-5"}),(0,a.jsxs)("div",{className:"flex flex-row items-center gap-x-2",children:[(0,a.jsx)("div",{onClick:Gt,className:"text-gray-400 hover:text-gray-600 cursor-pointer font-base mr-2",children:(0,a.jsx)("span",{className:"mr-1",children:"Cancel"})}),(0,a.jsx)("div",{onClick:async()=>{if(!Lt)return;const e=s.find((e=>"basic"===e.type)),t=s.find((e=>"translated"===e.type)),a=e.portions[o].portion_id;A({type:Et,trackId:e.id,portionId:a,data:ue,previousData:e.portions[o].text}),await L(e.id,a,ue,!0);d.A.promise((async()=>{const s=e,a=t,n=e.portions[o],i=t.portions[o],l={track_id:a.id,source_track_id:s.id,dest_track_id:a.id,dest_portion_id:i.portion_id,source_portion_id:n.portion_id,shot_id:r,trl_model:Z},d=await c.Z.post("/tasks",{name:"translate-portion",data:l,shot_id:r});if(200!==d.status)throw new Error("Failed to create translation task");for(await c.Z.post("/tasks/".concat(d.data.id,"/submit"));;){const e=await c.Z.get("/tasks/".concat(d.data.id)),t=e.data.status;if("COMPLETED"===t){const t=e.data.data.sub_tasks[1].input.text;xe(t);break}if("FAILED"===t)throw new Error("Translation task failed");await new Promise((e=>setTimeout(e,1e3)))}}),{loading:"Translating portion...",success:()=>(At(!1),ss(!1),u(),"Translation completed successfully"),error:e=>(console.error("Error in translation task:",e),e.message||"An error occurred during translation"),position:"top-center"})},className:"text-cerise-red-600 hover:text-cerise-red-800 cursor-pointer font-base -ml-1",children:"Translate & Save"})]})]})}),ye&&N&&N.portion_id===((null===(ce=null===(de=s[1])||void 0===de?void 0:de.portions[o])||void 0===ce?void 0:ce.portion_id)||s[0].portions[o].portion_id)&&(0,a.jsx)("div",{className:"fixed ".concat((()=>{const e=s.find((e=>"translated"===e.type))||s.find((e=>"basic"===e.type));return o===e.portions.length-1?"bottom-24":"bottom-4"})()," left-1/2 transform -translate-x-1/2 z-10 floating-dock-container"),children:(0,a.jsx)(T,{...qt})})]}),(0,a.jsx)(U,{showTranslationModelSelectionDialog:St,setShowTranslationModelSelectionDialog:_t,selectedTranslationModel:Z,setSelectedTranslationModel:P}),(0,a.jsx)(I,{showDeleteLineDialog:Ze,setShowDeleteLineDialog:Pe,deletePortion:Ft})]})},ee=s(42317);const te=e=>{if(isNaN(e)||!isFinite(e))return"00:00:00";const t=new Date(1e3*e).toISOString().substr(11,8);return t.startsWith("00:")?t.substr(3):t},se=(0,i.forwardRef)(((e,t)=>{let{vidUrl:s,vidRef:o,preload:n,actorId:l,processedVideoUrl:r,color:c,onTimeUpdate:d,isAudioPlaying:u,playbackRate:m,audioOffset:h,onVideoLoaded:x,pauseVideo:p,setPauseVideo:f}=e;const[g,v]=(0,i.useState)(0),[w,j]=(0,i.useState)(0),[y,b]=(0,i.useState)(0),[N,k]=(0,i.useState)(!0),[S,_]=(0,i.useState)(!1),[C,L]=(0,i.useState)(1),[A,E]=(0,i.useState)(!1),[T,M]=(0,i.useState)(!1),[z,F]=(0,i.useState)(1),[Z,P]=(0,i.useState)(!1),[D,I]=(0,i.useState)(!1);(0,i.useEffect)((()=>{t&&("function"===typeof t?t(t.current):t.current=t.current)}),[t]),(0,i.useEffect)((()=>{const e=t.current;e&&(console.log("pausing video"),e.pause())}),[t]),(0,i.useEffect)((()=>{p&&(null===t||void 0===t?void 0:t.current)&&(t.current.pause(),k(!0))}),[p]),(0,i.useEffect)((()=>{const e=t.current;e&&isFinite(m)&&(e.playbackRate=m)}),[m]);const[B,U]=(0,i.useState)(!1);(0,i.useEffect)((()=>{if(!t.current)return;const e=new IntersectionObserver((e=>{let[t]=e;U(t.isIntersecting)}),{threshold:.1});return e.observe(t.current),()=>{t.current&&e.unobserve(t.current)}}),[t]),(0,i.useEffect)((()=>{const e=t.current;e&&D&&isFinite(m)&&(B&&u?e.play().catch((e=>console.error("Error playing video:",e))):e.pause(),e.playbackRate=m)}),[u,m,D,B]),(0,i.useEffect)((()=>{const e=t.current;if(e&&D&&isFinite(d)&&B){const t=Math.min(Math.max(d,0),y);e.currentTime=t}}),[d,D,y,B]),(0,i.useEffect)((()=>{const e=t.current;if(e){const t=()=>{console.log("Video loaded with duration:",e.duration),b(e.duration),I(!0),x&&x(e.duration)},s=()=>{j(e.currentTime),v(e.currentTime/e.duration*100)};return e.addEventListener("loadedmetadata",t),e.addEventListener("timeupdate",s),e.readyState>=2&&t(),()=>{e.removeEventListener("loadedmetadata",t),e.removeEventListener("timeupdate",s)}}}),[t,x]);const R=()=>{const e=t.current;e&&(e.paused?(e.play(),k(!1)):(e.pause(),k(!0)))};return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{className:"items-center justify-center w-full ".concat(n?"preload-video":" rounded-xl video-container"),children:(0,a.jsx)("div",{className:"z-0 overflow-hidden mx-auto relative",children:(0,a.jsxs)("div",{className:"video-container select-none z-0",children:[(0,a.jsx)("video",{className:"rounded-lg w-full h-full",ref:t,loop:!0,preload:"metadata",onLoadedMetadata:()=>{t.current&&x&&x(t.current.duration)},onClick:R,onPlay:()=>k(!1),onPause:()=>k(!0),style:{visibility:n?"hidden":"visible"},children:(0,a.jsx)("source",{src:r})}),(0,a.jsx)("div",{className:"absolute bottom-0 left-0 w-full h-1/2 bg-gradient-to-t from-black/30 to-transparent pointer-events-none"}),(0,a.jsxs)("div",{className:"absolute bottom-0 left-0 w-full z-10 pb-1 px-3 flex flex-col ",children:[(0,a.jsx)("div",{onMouseEnter:()=>_(!0),onMouseLeave:()=>_(!1),children:(0,a.jsxs)(ee.fC,{className:"relative flex w-full touch-none select-none items-center group mb-1",value:[g],onValueChange:e=>{v(e[0]),t.current&&(t.current.currentTime=e[0]/100*y)},max:100,step:.1,children:[(0,a.jsx)(ee.fQ,{className:"relative w-full grow overflow-hidden bg-gray-400/60 transition-all duration-300 ease-in-out h-1",children:(0,a.jsx)(ee.e6,{className:"absolute h-full bg-cerise-red-600"})}),(0,a.jsx)(ee.bU,{className:"block rounded-full bg-cerise-red-600 shadow transition-all duration-300 ease-in-out ".concat(S?"h-4 w-4 opacity-100":"h-0 w-0 opacity-0"," focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50")})]})}),(0,a.jsx)("div",{className:"flex items-center justify-between w-full space-x-2",children:(0,a.jsxs)("div",{className:"flex items-center justify-start w-full space-x-2",children:[(0,a.jsx)("button",{onClick:R,children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 36 36",fill:c,height:"46px",width:"46px",children:N?(0,a.jsx)("path",{className:"ytp-svg-fill",d:"M 12,26 18.5,22 18.5,14 12,10 z M 18.5,22 25,18 25,18 18.5,14 z",id:"ytp-id-284"}):(0,a.jsx)("path",{className:"ytp-svg-fill",d:"M 12,26 16,26 16,10 12,10 z M 21,26 25,26 25,10 21,10 z",id:"ytp-id-386"})})}),(0,a.jsx)("button",{onClick:()=>{const e=t.current;e&&(e.currentTime=Math.min(e.currentTime+5,e.duration))},children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 36 36",fill:c,height:"46px",width:"46px",children:(0,a.jsx)("path",{className:"ytp-svg-fill",d:"M 12,24 20.5,18 12,12 V 24 z M 22,12 v 12 h 2 V 12 h -2 z",id:"ytp-id-28"})})}),(0,a.jsxs)("div",{className:"flex items-center space-x-2 w-48",children:[(0,a.jsxs)("div",{className:"relative flex items-center",onMouseEnter:()=>M(!0),onMouseLeave:()=>M(!1),children:[(0,a.jsx)("button",{onClick:()=>{t.current&&(A?(t.current.volume=z,L(z),E(!1)):(F(C),t.current.volume=0,L(0),E(!0)))},children:(0,a.jsx)("svg",{height:"46px",version:"1.1",fill:c,viewBox:"0 0 36 36",width:"46px",children:A?(0,a.jsx)("path",{className:"ytp-svg-fill",d:"m 21.48,17.98 c 0,-1.77 -1.02,-3.29 -2.5,-4.03 v 2.21 l 2.45,2.45 c .03,-0.2 .05,-0.41 .05,-0.63 z m 2.5,0 c 0,.94 -0.2,1.82 -0.54,2.64 l 1.51,1.51 c .66,-1.24 1.03,-2.65 1.03,-4.15 0,-4.28 -2.99,-7.86 -7,-8.76 v 2.05 c 2.89,.86 5,3.54 5,6.71 z M 9.25,8.98 l -1.27,1.26 4.72,4.73 H 7.98 v 6 H 11.98 l 5,5 v -6.73 l 4.25,4.25 c -0.67,.52 -1.42,.93 -2.25,1.18 v 2.06 c 1.38,-0.31 2.63,-0.95 3.69,-1.81 l 2.04,2.05 1.27,-1.27 -9,-9 -7.72,-7.72 z m 7.72,.99 -2.09,2.08 2.09,2.09 V 9.98 z",id:"ytp-id-412",fill:c}):(0,a.jsx)("path",{className:"ytp-svg-fill ytp-svg-volume-animation-speaker",d:"M8,21 L12,21 L17,26 L17,10 L12,15 L8,15 L8,21 Z M19,14 L19,22 C20.48,21.32 21.5,19.77 21.5,18 C21.5,16.26 20.48,14.74 19,14 ZM19,11.29 C21.89,12.15 24,14.83 24,18 C24,21.17 21.89,23.85 19,24.71 L19,26.77 C23.01,25.86 26,22.28 26,18 C26,13.72 23.01,10.14 19,9.23 L19,11.29 Z",fill:c,id:"ytp-id-30"})})}),(0,a.jsx)("div",{className:"absolute left-full ml-2 overflow-hidden transition-all duration-300 ease-in-out ".concat(T?"w-24 opacity-100":"w-0 opacity-0"),children:(0,a.jsx)("div",{className:"w-24",children:(0,a.jsxs)(ee.fC,{className:"relative flex h-5 w-full touch-none select-none items-center",value:[100*C],onValueChange:e=>{const s=e[0]/100;L(s),t.current&&(t.current.volume=s,E(0===s))},max:100,step:1,children:[(0,a.jsx)(ee.fQ,{className:"relative h-1 w-full grow overflow-hidden rounded-full bg-gray-400/60",children:(0,a.jsx)(ee.e6,{className:"absolute h-full bg-cerise-red-600"})}),(0,a.jsx)(ee.bU,{className:"block h-3 w-3 rounded-full bg-cerise-red-600 shadow transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cerise-red-600 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]})})})]}),(0,a.jsx)("div",{className:"flex items-center space-x-1 transition-all duration-300 ease-in-out ".concat(T?"transform translate-x-28":""),children:(0,a.jsxs)("span",{className:"text-sm whitespace-nowrap",style:{color:c},children:[te(w)," / ",te(y)]})})]}),(0,a.jsx)("div",{className:"flex w-full justify-end items-end",children:(0,a.jsx)("button",{onClick:()=>{const e=t.current;e&&(document.fullscreenElement?(document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen(),P(!1)):(e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen(),P(!0)))},children:(0,a.jsxs)("svg",{height:"36px",version:"1.1",fill:c,viewBox:"0 0 36 36",width:"36px",children:[(0,a.jsx)("path",{d:"m 10,16 2,0 0,-4 4,0 0,-2 L 10,10 l 0,6 0,0 z"}),(0,a.jsx)("path",{d:"m 20,10 0,2 4,0 0,4 2,0 L 26,10 l -6,0 0,0 z"}),(0,a.jsx)("path",{d:"m 24,24 -4,0 0,2 L 26,26 l 0,-6 -2,0 0,4 0,0 z"}),(0,a.jsx)("path",{d:"M 12,20 10,20 10,26 l 6,0 0,-2 -4,0 0,-4 0,0 z"})]})})})]})})]})]})})})})}));
1se.displayName="VideoPlayer";var ae=se,oe=s(94367),ne=s(16981),ie=s(39739),le=s(57632),re=s(34958),ce=s(13742),de=s(85247),ue=s(42154),me=s(32512),he=s(30473);s(34694),s(90889);var xe=e=>{let{showActorSettings:t,setShowActorSettings:s,index:o,onClose:n,token:l,actors:r,shotId:c,tracks:d,onPortionChange:u,shouldSwitchBackToMain:m,setShouldSwitchBackToMain:h,setActiveTab:x,selectedMethod:f,setSelectedMethod:g,submitActorCreationType:v,isAutomaticCreationDisabled:w,automaticVoiceCreationInProgress:j}=e;const[y,b]=(0,i.useState)(!1),[N,k]=(0,i.useState)({}),S=[50,75,0,!0],[_,C]=(0,i.useState)("eleven_multilingual_v2"),[L,A]=(0,i.useState)(!1),[E,T]=(0,i.useState)(!1),[F,Z]=(0,i.useState)(null),[P,I]=(0,i.useState)(!1),[B,U]=(0,i.useState)(!1),[R,V]=(0,i.useState)([]),[G,O]=(0,i.useState)(""),[H,W]=(0,i.useState)(null),[q,Y]=(0,i.useState)(null),[K,J]=(0,i.useState)(!1),[$,Q]=(0,i.useState)(!1),[X,ee]=(0,i.useState)(0),[te,se]=(0,i.useState)(!1),[ae,oe]=(0,i.useState)([]),[ne,ie]=(0,i.useState)(S[0]),[le,re]=(0,i.useState)(S[1]),[ce,de]=(0,i.useState)(S[2]),[ue,me]=(0,i.useState)(S[3]),[he,xe]=(0,i.useState)("auto"),pe=((0,i.useRef)(null),G&&ae.filter((e=>e.name.toLowerCase().includes(G.toLowerCase()))),()=>{s(!1),n&&n()});return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(M.u,{appear:!0,show:t,as:i.Fragment,children:(0,a.jsxs)(z.Vq,{as:"div",className:"relative z-[50]",onClose:()=>pe(),children:[(0,a.jsx)(M.x,{as:i.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{className:"fixed inset-0 bg-black/25"})}),(0,a.jsx)("div",{className:"fixed inset-0 overflow-y-auto ",children:(0,a.jsx)("div",{className:"flex min-h-full items-center justify-center p-4 text-center",children:(0,a.jsx)(M.x,{as:"div",enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:(0,a.jsxs)(z.EM,{className:"dialog-panel-3 w-full transform overflow-hidden rounded-lg bg-white text-left align-middle shadow-xl transition-all flex flex-col",children:[(0,a.jsx)("div",{className:"flex flex-col",children:(0,a.jsxs)(z.$N,{as:"h3",className:"pl-6 pr-6 pt-6 text-lg font-medium leading-6 flex flex-row justify-between",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-y-2",children:[(0,a.jsx)("div",{className:"p-3 rounded-full w-fit bg-cerise-red-100",children:(0,a.jsx)("div",{className:"p-1.5 rounded-full bg-cerise-red-200",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-7 h-7 text-cerise-red-600",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M18 7.5v3m0 0v3m0-3h3m-3 0h-3m-2.25-4.125a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0ZM3 19.235v-.11a6.375 6.375 0 0 1 12.75 0v.109A12.318 12.318 0 0 1 9.374 21c-2.331 0-4.512-.645-6.374-1.766Z"})})})}),"Select Voice Creation Method"]}),(0,a.jsx)("button",{className:"items-start justify-start flex",onClick:pe,children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-7 w-7 text-gray-400 hover:text-gray-600",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18 18 6M6 6l12 12"})})})]})}),(0,a.jsx)("div",{className:"h-full flex-grow transition-all duration-300",children:(0,a.jsxs)("div",{className:"flex flex-col pt-4 pb-4 pr-9 gap-y-3 pl-6",children:[(0,a.jsxs)("button",{className:"w-full p-3 flex flex-row gap-x-4 border border-1 rounded-lg relative ".concat(w?"bg-gray-100 border-gray-200 cursor-not-allowed opacity-60":"automatic"===f?"border-cerise-red-500 bg-cerise-red-50":"bg-white hover:border-cerise-red-500 cursor-pointer"),onClick:()=>!w&&g("automatic"),disabled:w,children:[(0,a.jsx)("div",{className:"flex rounded-lg p-1.5 bg-yellow-100 w-8 h-8 items-center justify-center",children:(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"
1currentColor",className:"w-4 h-4 text-yellow-500",children:[(0,a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,a.jsx)("path",{d:"M13 2l.018 .001l.016 .001l.083 .005l.011 .002h.011l.038 .009l.052 .008l.016 .006l.011 .001l.029 .011l.052 .014l.019 .009l.015 .004l.028 .014l.04 .017l.021 .012l.022 .01l.023 .015l.031 .017l.034 .024l.018 .011l.013 .012l.024 .017l.038 .034l.022 .017l.008 .01l.014 .012l.036 .041l.026 .027l.006 .009c.12 .147 .196 .322 .218 .513l.001 .012l.002 .041l.004 .064v6h5a1 1 0 0 1 .868 1.497l-.06 .091l-8 11c-.568 .783 -1.808 .38 -1.808 -.588v-6h-5a1 1 0 0 1 -.868 -1.497l.06 -.091l8 -11l.01 -.013l.018 -.024l.033 -.038l.018 -.022l.009 -.008l.013 -.014l.04 -.036l.028 -.026l.008 -.006a1 1 0 0 1 .402 -.199l.011 -.001l.027 -.005l.074 -.013l.011 -.001l.041 -.002z"})]})}),(0,a.jsxs)("div",{className:"flex flex-col items-start justify-start w-full",children:[(0,a.jsxs)("div",{className:"flex flex-row gap-x-2",children:[(0,a.jsx)("span",{className:"font-semibold ".concat(""),children:"Automatic Voice Creation"}),(0,a.jsx)("div",{className:"items-center justify-center flex px-2 rounded-lg bg-yellow-100",children:(0,a.jsx)("span",{className:"text-xs text-yellow-500",children:"Experimental"})})]}),(0,a.jsx)("span",{className:"text-sm mt-2 text-good-gray-100",children:"Automatically create a voice for your actor using audio segments from your current video."}),(0,a.jsxs)("span",{className:"text-sm text-good-gray-100 ",children:[" Only recommended in instances where there is ",(0,a.jsx)("strong",{children:"over a minute"})," of your actor speaking."]})]}),(0,a.jsx)("div",{className:"absolute top-2 right-2 flex-center w-[22px] h-[22px] rounded-full border border-solid flex justify-center items-center",style:{borderColor:"automatic"===f?"#e63c6c":"rgb(205, 213, 223)",backgroundColor:"automatic"===f?"#e63c6c":"transparent"},children:"automatic"===f&&(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"#fff",className:"w-4 h-4",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})})]}),(0,a.jsxs)("button",{className:"w-full p-3 flex flex-row gap-x-4 border border-1 rounded-lg cursor-pointer relative ".concat("existing"===f?"border-cerise-red-500 bg-cerise-red-50/40":"bg-white hover:border-cerise-red-500"),onClick:()=>g("existing"),children:[(0,a.jsx)("div",{className:"flex rounded-lg bg-green-100 p-1.5 w-8 h-8 items-center justify-center",children:(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",className:"text-green-500 w-4 h-4",children:[(0,a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,a.jsx)("path",{d:"M12 2a5 5 0 1 1 -5 5l.005 -.217a5 5 0 0 1 4.995 -4.783z"}),(0,a.jsx)("path",{d:"M14 14a5 5 0 0 1 5 5v1a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-1a5 5 0 0 1 5 -5h4z"})]})}),(0,a.jsxs)("div",{className:"flex flex-col items-start justify-start w-full",children:[(0,a.jsxs)("div",{className:"flex flex-row gap-x-2",children:[(0,a.jsx)("span",{className:"font-semibold",children:"Select an Existing Voice"}),(0,a.jsx)("div",{className:"items-center justify-center flex px-2 rounded-lg bg-green-100",children:(0,a.jsx)("span",{className:"text-xs text-green-500",children:"Quickest"})})]}),(0,a.jsx)("span",{className:"text-sm mt-2 text-good-gray-100 ",children:"Assign an existing voice to this actor to be used for audio generations."}),(0,a.jsx)("span",{className:"text-sm text-good-gray-100 ",children:"If you don't like your output, you can add the samples from this voice to your voice at a later time."}),(0,a.jsx)("div",{className:"absolute top-2 right-2 flex-center w-[22px] h-[22px] rounded-full border border-solid flex justify-center items-center",style:{borderColor:"existing"===f?"#e63c6c":"rgb(205, 213, 223)",backgroundColor:"existing"===f?"#e63c6c":"transparent"},children:"existing"===f&&(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"#fff",className:"w-4 h-4",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})})]})]}),(0,a.jsxs)("button",{className:"w-full p-3 flex flex-row gap-x-4 border border-1 rounded-lg cursor-pointer relative ".concat("upload"===f?"border-cerise-red-500 bg-cerise-red-50/40":"bg-white hover:border-cerise-red-500"),onClick:()=>g("upload"),children:[(0,a.jsx)("div",{className:"flex rounded-lg bg-blue-100 p-1.5 w-8 h-8 items-center justify-center",children:(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:"h-4 w-4 text-blue-500",children:[(0,a.jsx)("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),(0,a.jsx)("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),(0,a.jsx)("path",{d:"M7 9l5 -5l5 5"}),(0,a.jsx)("path",{d:"M12 4l0 12"})]})}),(0,a.jsxs)("div",{className:"flex flex-col items-start justify-start w-full",children:[(0,a.jsxs)("div",{className:"flex flex-row gap-x-2",children:[(0,a.jsx)("span",{className:"font-semibold",children:"Upload Samples for Actor"}),(0,a.jsx)("div",{className:"items-center justify-center flex px-2 rounded-lg bg-blue-100",children:(0,a.jsx)("span",{className:"text-xs text-blue-500",children:"Reliable"})})]}),(0,a.jsx)("span",{className:"text-sm mt-2 text-good-gray-100 ",children:"Create a new voice for your actor using your own audio samples."}),(0,a.jsxs)("span",{className:"text-sm text-good-gray-100 ",children:["It is recommended that you have at least ",(0,a.jsx)("strong",{children:"one to two minutes"})," of your actor speaking."]})]}),(0,a.jsx)("div",{className:"absolute top-2 right-2 flex-center w-[22px] h-[22px] rounded-full border border-solid flex justify-center items-center",style:{borderColor:"upload"===f?"#e63c6c":"rgb(205, 213, 223)",backgroundColor:"upload"===f?"#e63c6c":"transparent"},children:"upload"===f&&(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"#fff",className:"w-4 h-4",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})})]})]})}),(0,a.jsx)("div",{className:"flex w-full h-full items-center justify-end gap-x-3 p-6 ",children:(0,a.jsxs)("div",{className:"w-full flex gap-x-3 mt-auto",children:[(0,a.jsx)(D.z,{variant:"outline",className:"py-6 text-base w-full shadow shadow-sm bg-white",onClick:pe,children:"Close"}),(0,a.jsx)(D.z,{disabled:!f||j,variant:"primary",className:"py-6 text-base w-full shadow text-white shadow-sm bg-cerise-red-600",onClick:v,children:j?(0,a.jsxs)("div",{className:"flex flex-row items-center justify-center gap-x-2",children:[(0,a.jsx)("div",{className:"flex items-center justify-center space-x-1",children:[...Array(7)].map(((e,t)=>(0,a.jsx)(p.E.div,{className:"h-3 w-1 rounded-full bg-white",animate:{scaleY:[.5,1.5,.5],scaleX:[1,.8,1],translateY:["0%","-15%","0%"]},transition:{duration:1,repeat:1/0,ease:"easeInOut",delay:.1*t}},t)))}),(0,a.jsx)("span",{children:"Creating Voice..."})]}):"Select"})]})})]})})})})]})})})};var pe=e=>{let{showActorSettings:t,setShowActorSettings:s,index:o,onClose:n,token:l,actors:r,shotId:u,tracks:m,onPortionChange:h,shouldSwitchBackToMain:x,setShouldSwitchBackToMain:p,setActiveTab:f,activeActorSettingsId:g}=e;var v,w;const[j,y]=(0,i.useState)(!1),[b,N]=(0,i.useState)({}),k=[50,75,0,!0],[S,_]=(0,i.useState)(null),[C,L]=(0,i.useState)("eleven_multilingual_v2"),[A,E]=(0,i.useState)(!1),[T,F]=(0,i.useState)(!1),[Z,P]=(0,i.useState)(null),[I,B]=(0,i.useState)(k[0]),[U,R]=(0,i.useState)(k[1]),[V,G]=(0,i.useState)(k[2]),[O,H]=(0,i.useState)(k[3]),[W,q]=(0,i.useState)(!1),[Y,K]=(0,i.useState)(!1),[J,$]=(0,i.useState)(!1),[Q,X]=(0,i.useState)([]),[ee,te]=(0,i.useState)(""),[se,ae]=(0,i.useState)(null),[oe,pe]=(0,i.useState)(null),[fe,ge]=(0,i.useState)(!1),[ve,we]=(0,i.useState)(!1),[je,ye]=(0,i.useState)(0),[be,Ne]=(0,i.useState)(!1),[ke,Se]=(0,i.useState)([]),[_e,Ce]=(0,i.useState)(k[0]),[Le,Ae]=(0,i.useState)(k[1]),[Ee,Te]=(0,i.useState)(k[2]),[Me,ze]=(0,i.useState)(k[3]),[Fe,Ze]=(0,i.useState)("auto"),[Pe,De]=(0,i.useState)(!1),[Ie,Be]=(0,i.useState)(!1),[Ue,Re]=(0,i.useState)(null),[Ve,Ge]=(0,i.useState)(!1),[Oe,He]=(0,i.useState)(!1),[We,qe]=(0,i.useState)(null),[Ye,Ke]=(0,i.useState)(null),[Je,$e]=(0,i.useState)(!1),[Qe,Xe]=(0,i.useState)(!0),et=(0,i.useRef)(null),[tt,st]=(0,i.useState)(!1),[at,ot]=(0,i.useState)(!1),[nt,it]=(0,i.useState)(!1),[lt,rt]=(0,i.useState)(!1),[ct,dt]=(0,i.useState)(!1),[ut,mt]=(0,i.useState)(!0),[ht,xt]=(0,i.useState)(!1),pt=e=>new Promise(((t,s)=>{const a=URL.createObjectURL(e),o=new Audio(a);o.onloadedmetadata=()=>{URL.revokeObjectURL(a),t(o.duration)},o.onerror=e=>{URL.revokeObjectURL(a),s(e)}}));(0,i.useEffect)((()=>
1{if(!et.current)return;const e=()=>{if(et.current){const e=et.current.querySelector("button");e&&Ze("".concat(e.offsetWidth,"px"))}};e();const t=new ResizeObserver(e);t.observe(et.current);const s=new MutationObserver((t=>{t.forEach((t=>{"attributes"===t.type&&"style"===t.attributeName&&e()}))}));return s.observe(et.current,{attributes:!0,attributeFilter:["style"]}),()=>{t.disconnect(),s.disconnect()}}),[Pe]),(0,i.useEffect)((()=>{Pe&&setTimeout((()=>{var e;const t=null===(e=et.current)||void 0===e?void 0:e.querySelector("button");t&&Ze("".concat(t.offsetWidth,"px"))}),0)}),[Pe]),(0,i.useEffect)((()=>{E("eleven_multilingual_v2"!==C&&"eleven_multilingual_sts_v2"!==C)}),[C]);const ft=ee?ke.filter((e=>e.name.toLowerCase().includes(ee.toLowerCase()))):ke,gt=()=>{De(!1),Be(!1),pe(null),P(null),ae(null),X([]),ge(!1),Xe(!0),n&&n(),s(!1),Re(null)};(0,i.useEffect)((()=>{var e;t&&(null===(e=r[o])||void 0===e?void 0:e.actor_id)===g&&(c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(l),(async()=>{console.log("fetching voice data");try{var e;const l=await c.Z.get("/voices");Se(l.data),console.log("voices",l.data);const d=await c.Z.get("/user");if(Ke(d.data),console.log("index is",o),qe(d.data.user.account.subscription_config.max_profiles),null===(e=r[o])||void 0===e?void 0:e.voice_id){var s,a,n,i;console.log("setting selected voice id is",null===(s=r[o])||void 0===s?void 0:s.voice_id),console.log("actor is",r[o]),pe(null===(a=r[o])||void 0===a?void 0:a.voice_id),P(null===(n=r[o])||void 0===n?void 0:n.voice_id);const e=l.data.find((e=>{var t;return e.voice_id===(null===(t=r[o])||void 0===t?void 0:t.voice_id)}));if(ae(e),console.log("index is",o),e&&e.voice_data&&e.voice_data.sample_sources){const t=e.voice_data.sample_sources.includes("PORTION"),s=e.voice_data.sample_sources.every((e=>"PORTION"===e));$e(t),st(t),ot(s),console.log("index is",o)}else $e(!1),st(!1),ot(!1),console.log("index is",o);vt(null===(i=r[o])||void 0===i?void 0:i.voice_id),console.log("index is",o),t&&(console.log("showing actor voice settings"),De(!0),console.log("index is",o))}else{pe(null),P(null),t&&Be(!0),ae(null),X([]);const e=m.find((e=>"translated"===e.type)),s=m.find((e=>"basic"===e.type));let a;if(e?a=e:s&&(a=s),a){const e=a.portions.some((e=>e.actor_id===r[o].actor_id));console.log("hasAssignment",e),Ge(!e)}else Ge(!1)}}catch(l){console.error("Error fetching voice data:",l),d.A.error("Error fetching voice data:")}finally{Xe(!1)}})())}),[l,o,g]);const vt=async e=>{try{we(!0);const t=(await c.Z.get("/voices/".concat(e))).data;ye(t.voice_data.samples.length);const s=await Promise.all(t.voice_data.samples.map((async(e,s)=>{const a=(await c.Z.get("/media/".concat(e,"?signed_url=true"))).data,o=Math.round(16e3*a.metadata.duration*2/8);return{id:e,url:a.signed_url,fileName:a.name,duration:a.metadata.duration,size:o,isFromPortion:"PORTION"===t.voice_data.sample_sources[s]}})));X(s),xt(s.some((e=>e.isFromPortion)))}catch(t){console.error("Error fetching voice props",t)}finally{we(!1)}},wt=(0,i.useCallback)((e=>{const t=e.map((e=>({id:(0,le.Z)(),file:e,fileName:e.name,size:e.size,type:e.type,url:URL.createObjectURL(e),progress:0,isUploading:!0}))),s=[...Q,...t];X(s),jt(s),it(!0),ot(!1)}),[Q,se]),jt=e=>{const t=e.some((e=>!e.id))||se&&se.voice_data&&se.voice_data.sample_sources.some((e=>"PORTION"!==e));ot(!t),it(t)},{getRootProps:yt,getInputProps:bt,isDragActive:Nt}=(0,me.uI)({onDrop:wt,accept:{"audio/mpeg":[".mp3"]},maxSize:10485760,onDropRejected:e=>{e.forEach((e=>{e.errors.forEach((t=>{"file-too-large"===t.code?d.A.error("File ".concat(e.file.name," is larger than 10MB")):"file-invalid-type"===t.code&&d.A.error("File ".concat(e.file.name," is not an .mp3 file"))}))}))}}),kt=async()=>{rt(!0);try{let e;const t=m.find((e=>"translated"===e.type)),s=m.find((e=>"basic"===e.type));if(t)e=t.id;else{if(!s)throw new Error("No suitable track found");e=s.id}const a=await c.Z.post("/tasks",{name:"auto-create-voice",data:{track_id:e,actor_id:r[o].actor_id,shot_id:u}});c.Z.post("/tasks/".concat(a.data.id,"/submit")),_(a.data.id),await St(a.data.id)}catch(e){console.error("Error creating automatic voice:",e),d.A.error("Error creating automatic voice: "+e.message),rt(!1)}},St=async e=>{c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(l),console.log("poll task called with task id",e);try{const t=await c.Z.get("/tasks/".concat(e));if(console.log("task response",t),"COMPLETED"===t.data.status)return _(null),Be(!1),rt(!1),ge(!1),De(!1),s(!1),Be(!1),pe(null),P(null),ae(null),X([]),dt(!1),void(await gt());setTimeout((()=>St(e)),5e3)}catch(t){console.error("Error polling task:",t),d.A.error("Error polling task: "+t.message),rt(!1)}},_t=async e=>{try{await c.Z.delete("/voices/".concat(e,"/samples?source=PORTION"))}catch(t){console.error("Error removing portion audio from voice:",t),d.A.error("Error removing portion audio from voice: "+t.message)}};return(0,i.useEffect)((()=>{at&&mt(!0)}),[at]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(xe,{showActorSettings:Ie,setShowActorSettings:Be,index:o,onClose:gt,token:l,actors:r,shotId:u,onPortionChange:h,tracks:m,shouldSwitchBackToMain:x,setShouldSwitchBackToMain:p,setActiveTab:f,selectedMethod:Ue,setSelectedMethod:Re,submitActorCreationType:()=>{"upload"===Ue?(Be(!1),De(!0),He(!0)):"existing"===Ue?(Be(!1),De(!0)):"automatic"===Ue&&kt()},isAutomaticCreationDisabled:Ve,automaticVoiceCreationInProgress:lt}),(0,a.jsx)(M.u,{appear:!0,show:Pe,as:i.Fragment,children:(0,a.jsxs)(z.Vq,{as:"div",className:"relative z-[50]",onClose:gt,children:[(0,a.jsx)(M.x,{as:i.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{className:"fixed inset-0 bg-black/25"})}),(0,a.jsx)("div",{className:"fixed inset-0 overflow-y-auto ",children:(0,a.jsx)("div",{className:"flex min-h-full items-center justify-center p-4 text-center",children:(0,a.jsx)(M.x,{as:"div",enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:(0,a.jsxs)(z.EM,{className:"dialog-panel-3 w-full transform overflow-hidden rounded-lg bg-white text-left align-middle shadow-xl transition-all flex flex-col",children:[(0,a.jsx)("div",{className:"flex flex-col",children:(0,a.jsxs)(z.$N,{as:"h3",className:"pl-6 pr-6 pt-6 text-lg font-medium leading-6",children:[(null===(v=r[o])||void 0===v?void 0:v.name)||"Actor "+(o+1)," Voice Settings"]})}),(0,a.jsx)("div",{className:"grid ".concat(fe?"grid-cols-2":"grid-cols-1"," h-full flex-grow transition-all duration-300"),children:(0,a.jsxs)("div",{className:"col-span-1",children:[(0,a.jsxs)("div",{className:"p-6 pb-4 w-full justify-between flex flex-col gap-y-2",children:[(0,a.jsx)(ne.__,{className:"pl-1",tooltip:"The voice that will be used for creating audio",children:"Selected Voice"}),(0,a.jsxs)(ue.J2,{open:be,onOpenChange:Ne,className:"z-50 w-full",children:[(0,a.jsx)(ue.xo,{asChild:!0,children:(0,a.jsx)("div",{ref:et,className:"w-full",children:(0,a.jsxs)(D.z,{variant:"outline",role:"combobox","aria-expanded":open,className:"w-full justify-between",children:[Z?null===(w=ke.find((e=>e.voice_id===Z)))||void 0===w?void 0:w.name:"Select a Voice",(0,a.jsx)(re.Z,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})})}),(0,a.jsx)(ue.yk,{style:{width:Fe},className:"p-0 z-[51]",children:(0,a.jsxs)(de.mY,{className:"w-full",children:[(0,a.jsx)(de.sZ,{placeholder:"Search voices...",onChange:e=>te(e.target.value)}),0===ft.length&&(0,a.jsx)(de.rb,{children:"No profile found."}),(0,a.jsx)(de.fu,{style:{maxHeight:"192px",overflowY:"auto",zIndex:50,width:Fe},children:ft.map((e=>(0,a.jsxs)(de.di,{value:e.voice_id,onSelect:()=>{pe(e.voice_id),P(e.voice_id),ae(e),Ne(!1),vt(e.voice_id)},children:[(0,a.jsx)(ce.Z,{className:"mr-2 h-4 w-4 ".concat(Z===e.voice_id?"opacity-100":"opacity-0")}),e.name]},e.voice_id)))})]})})]})]}),(0,a.jsxs)("div",{className:"pl-6 pr-6 flex flex-col gap-y-2 col-start-1",children:[(0,a.jsx)(ne.__,{className:"pl-1",children:"Add Audio To Voice"}),(0,a.jsx)("div",{className:"flex flex-grow justify-center items-center w-full",children:(0,a.jsxs)("div",{...yt(),className:"flex flex-col justify-center items-center w-full ".concat(Nt?"bg-blue-100 border-blue-500":"bg-gray-50 border-gray-300"," rounded-lg border-2 border-dashed cursor-pointer"),children:[(0,a.jsx)("input",{...bt()}),(0,a.jsxs)("div",{className:"flex flex-col justify-center items-center pr-28 pl-28 pt-12 pb-12",children:[(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"text-gray-400",height:"32",width:"32",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m6.75 12-3-3m0 0-3 3m3-3v6m-1.5-15H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z"})}),(0,a.jsx)("p",{className:"mt-1 mb-2 text-sm text-gray-500",children:(0,a.jsx)("span",{className:"font-semibold",children:Nt?"Drop your files here":"Upload Audio to add to your actor's voice"})}),(0,a.jsx)("p",{className:"text-xs text-gray-500",children:".MP3 (max. 10MB)"})]})]})})]}),(0,a.jsxs)("div",{className:"pl-6 pr-6 mt-1 flex w-full justify-between mb-3",children:[(0,a.jsx)("p",{className:"text-xs text-gray-400",children:"Supported formats: MP3"}),(0,a.jsx)("p",{className:"text-xs text-gray-400",children:"Maximum Size: 10 MB"})]}),(0,a.jsx)("div",{className:"pl-6 pr-6 col-start-1 mt-5",children:(0,a.jsxs)("div",{className:"max-h-[310px] overflow-y-auto pr-2",children:[" ",ve?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ne.__,{className:"pl-1 pb-2",children:"Current Audio Clips"}),(0,a.jsx)(ie.O,{className:"w-full h-[65px] mb-4 rounded-lg"},o)]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ne.__,{className:"pl-1",children:"Current Audio Clips"}),(Ct=Q,ut||at?Ct:Ct.filter((e=>!e.isFromPortion))).map(((e,t)=>{return(0,a.jsxs)("div",{className:"rounded-lg bg-gray-100 w-full p-3 mb-4 mt-2",children:[(0,a.jsxs)("div",{className:"flex justify-between w-full",children:[(0,a.jsxs)("div",{className:"flex flex-row gap-x-2",children:[(0,a.jsx)("div",{className:"pt-2 pb-2 pr-3 pl-3 bg-white rounded-md border border-1",children:(0,a.jsx)("img",{src:"https://storage.googleapis.com/ivt-project-prod.appspot.com/email_assets/newicon.png",className:"select-none",width:"16",height:"60"})}),(0,a.jsxs)("div",{className:"flex flex-col justify-between",children:[(0,a.jsx)("span",{className:"text-sm font-semibold",children:(null===e||void 0===e?void 0:e.fileName)||"Sample "+(t+1)}),(0,a.jsx)("span",{className:"text-xs text-gray-400",children:(s=e.size,s<1024?s+" B":s<1048576?(s/1024).toFixed(1)+" KB":s<1073741824?(s/1048576).toFixed(1)+" MB":(s/1073741824).toFixed(1)+" GB")})]})]}),(0,a.jsx)("div",{children:(0,a.jsx)("button",{onClick:()=>X(Q.filter((t=>
1t.id!==e.id))),children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-6 h-6 hover:text-red-500",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18 18 6M6 6l12 12"})})})})]}),e.isUploading&&(0,a.jsxs)("div",{className:"flex flex-row items-center gap-x-3 w-full mt-2",children:[(0,a.jsx)(he.E,{value:e.progress,className:"".concat(e.error?"bg-red-500":"")}),(0,a.jsxs)("span",{className:"text-xs ".concat(e.error?"text-red-500":"text-gray-400"),children:[e.progress,"%"]})]})]},t);var s}))]})]})})]})}),(0,a.jsx)("div",{className:"flex w-full h-full items-center justify-end gap-x-3 p-6 ",children:(0,a.jsxs)("div",{className:"w-full flex gap-x-3 mt-auto",children:[(0,a.jsx)(D.z,{variant:"outline",className:"py-6 text-base w-full shadow shadow-sm bg-white",onClick:gt,children:"Cancel"}),(0,a.jsx)(D.z,{disabled:0===Q.legnth||ct,className:"w-full py-6 text-base bg-cerise-red-500 hover:bg-cerise-red-600 text-white",onClick:()=>{(async()=>{dt(!0);try{const e=r[o].actor_id;c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(l);
1let t=oe,a=!1;const i=await c.Z.get("/voices");if(!t&&Q.length>0){if(i.data.length>=We)return d.A.error("You have reached the maximum number of voices allowed for your subscription. Upgrade plans or delete an existing voice.",{position:"bottom-right",className:"custom-toast-button2"}),void dt(!1);const e="Actor ".concat(o+1," Voice");t=(await c.Z.post("/voices",{name:e,shot_id:u})).data.voice_id,a=!0}if(t){if(tt&&!Je&&await _t(t),!a&&se&&se.voice_data){const e=se.voice_data.samples.filter((e=>!Q.some((t=>t.id===e))));for(const s of e)await c.Z.delete("/voices/".concat(t,"/samples/").concat(s))}const s=Q.filter((e=>!e.id||e.isUploading));for(const e of s){const s={metadata:{duration:await pt(e.file)}},a=(await c.Z.post("/voices/".concat(t,"/samples"),s,{headers:{"Content-Type":"application/json"}})).data.signed_url,o=c.Z.create();delete o.defaults.baseURL,delete o.defaults.headers.common.Authorization,delete o.defaults.headers.common["x-group-id"],await o.put(a,e.file,{headers:{"Content-Type":e.type},onUploadProgress:t=>{const s=Math.round(100*t.loaded/t.total);X((t=>t.map((t=>t.file===e.file?{...t,progress:s}:t))))}})}await c.Z.put("/shots/".concat(u,"/actors/").concat(e),{voice_id:t})}!tt&&Je&&await kt(),n&&n()}catch(e){console.error("Error updating actor voice:",e),dt(!1),d.A.error("Error updating actor voice: "+e.message)}finally{ge(!1),De(!1),s(!1),Be(!1),pe(null),X([]),dt(!1),x&&(p(!1),f(0))}})()},children:ct?"Saving...":"Save"})]})})]})})})})]})})]});var Ct},fe=s(8193),ge=s(37884);s(96486);const ve=e=>{let{audioRef:t,audioUrl:s,showPopup:o,setShowPopup:n,recordedAudioDuration:l,audioLocation:r,audioId:c,portion:d,onTimeUpdate:u,onPlayStateChange:m,audioName:h}=e;const[x,p]=(0,i.useState)(0),[f,g]=(0,i.useState)(!1),[v,w]=((0,i.useRef)(t),(0,i.useState)(l||0)),[j,y]=(0,i.useState)(!0),[b,N]=(0,i.useState)(!1);(0,i.useEffect)((()=>{l&&w(l)}),[l]),(0,i.useEffect)((()=>{const e=t.current,s=()=>{w(l||e.duration)},a=()=>{p(e.currentTime)};return e.addEventListener("loadedmetadata",s),e.addEventListener("timeupdate",a),y(!1),()=>{e.removeEventListener("loadedmetadata",s),e.removeEventListener("timeupdate",a)}}),[s,l]);const[k,S]=(0,i.useState)(1);(0,i.useEffect)((()=>{const e=t.current,s=()=>{var t;const s=e.currentTime+((null===d||void 0===d||null===(t=d.audio)||void 0===t?void 0:t.offset)||0);u(s)},a=()=>{m(!0,e.playbackRate)},o=()=>{m(!1,e.playbackRate)};return e.addEventListener("timeupdate",s),e.addEventListener("play",a),e.addEventListener("pause",o),()=>{e.removeEventListener("timeupdate",s),e.removeEventListener("play",a),e.removeEventListener("pause",o)}}),[t,d,u,m]);(0,i.useEffect)((()=>{const e=t.current,s=()=>{var t,s;const a=e.currentTime+((null===d||void 0===d||null===(t=d.audio)||void 0===t||null===(s=t.trim)||void 0===s?void 0:s.start)||0);u(a)},a=()=>{m(!0)},o=()=>{m(!1)};return e.addEventListener("timeupdate",s),e.addEventListener("play",a),e.addEventListener("pause",o),()=>{e.removeEventListener("timeupdate",s),e.removeEventListener("play",a),e.removeEventListener("pause",o)}}),[t,d,u,m]);return(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)("div",{className:"fixed bottom-0 left-0 w-full px-4 py-2",children:[(0,a.jsx)("audio",{ref:t,src:s,onTimeUpdate:e=>p(e.target.currentTime),onDurationChange:e=>w(e.target.duration),onEnded:()=>g(!1)}),o&&!j&&(0,a.jsx)("div",{className:"fixed bottom-0 left-1/2 transform -translate-x-1/2 w-1/2 bg-white p-4 shadow-lg rounded-lg mb-4",children:(0,a.jsx)("div",{className:"container",children:(0,a.jsxs)("div",{className:"flex items-start",children:[(0,a.jsx)("button",{onClick:()=>{var e,s;const a=t.current;a.paused?(a.play(),g(!0)):(a.pause(),g(!1)),u(a.currentTime+((null===d||void 0===d||null===(e=d.audio)||void 0===e||null===(s=e.trim)||void 0===s?void 0:s.start)||0))},className:"text-cerise-red-500 text-6xl",children:f?(0,a.jsx)(fe.civ,{}):(0,a.jsx)(fe.sT9,{})}),(0,a.jsxs)("div",{className:"flex flex-col ml-4 mr-4 w-full",children:[(0,a.jsxs)("span",{className:"text-xs font-semibold",children:["Playing Audio ",h]}),(0,a.jsx)("div",{className:"flex items-center mt-3",children:(0,a.jsxs)("div",{className:"flex flex-grow items-center w-full",children:[(0,a.jsx)(ge.i,{value:[x],max:v,onValueChange:e=>{var s,a;const o=e[0];t.current.currentTime=o,p(o),u(o+((null===d||void 0===d||null===(s=d.audio)||void 0===s||null===(a=s.trim)||void 0===a?void 0:a.start)||0))},step:.1}),(0,a.jsx)("span",{className:"text-xs font-semibold ml-4 text-good-gray-100",style:{fontFamily:'"Courier New", monospace'},children:(()=>
1{if(!isFinite(v))return"00:00/00:00";let e=Math.floor(x/60).toString().padStart(2,"0"),t=Math.round(x%60).toString().padStart(2,"0"),s=Math.floor(v/60).toString().padStart(2,"0"),a=Math.round(v%60).toString().padStart(2,"0");return"".concat(e,":").concat(t,"/").concat(s,":").concat(a)})()})]})})]}),(0,a.jsxs)("div",{className:"flex items-start ml-1 mt-4 ",children:[(0,a.jsx)("button",{className:"text-2xl",onClick:()=>{window.open(s)},children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-6 h-6",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3"})})}),(0,a.jsx)("button",{onClick:()=>n(!1),className:"text-2xl ml-2",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-6 h-6",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m19.5 8.25-7.5 7.5-7.5-7.5"})})})]})]})})})]})})};var we=e=>{let{showDeleteActorDialog:t,setShowDeleteActorDialog:s,deleteActor:o,idx:n,actors:l}=e;var r;return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(M.u,{appear:!0,show:t,as:i.Fragment,children:(0,a.jsxs)(z.Vq,{as:"div",className:"relative z-[70]",onClose:()=>s(!1),children:[(0,a.jsx)(M.x,{as:i.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{className:"fixed inset-0 bg-black/25"})}),(0,a.jsx)("div",{className:"fixed inset-0 overflow-y-auto ",children:(0,a.jsx)("div",{className:"flex min-h-full items-center justify-center p-4 text-center",children:(0,a.jsx)(M.x,{as:"div",enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:(0,a.jsxs)(z.EM,{className:"dialog-panel- w-full transform overflow-visible rounded-lg bg-white text-left align-middle shadow-xl transition-all flex flex-col",children:[(0,a.jsx)("div",{className:"flex flex-col flex-grow",children:(0,a.jsxs)(z.$N,{as:"h3",className:"pl-6 pr-6 pt-6 text-lg font-medium leading-6 flex flex-row justify-between",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-y-2",children:[(0,a.jsx)("div",{className:"p-3 rounded-full w-fit bg-red-100",children:(0,a.jsx)("div",{className:"p-1.5 rounded-full bg-red-200",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-7 h-7 text-red-600",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"})})})}),"Delete Actor"]}),(0,a.jsx)("button",{className:"items-start justify-start flex",onClick:()=>s(!1),children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-7 w-7 text-gray-400 hover:text-gray-600",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18 18 6M6 6l12 12"})})})]})}),(0,a.jsx)("div",{className:" max-w-[450px] pt-2 text-gray-500 pl-6 pr-6 justify-start flex w-full text-sm",children:(0,a.jsxs)("span",{children:["Are you sure you want to delete ",(0,a.jsx)("strong",{children:null===(r=l[n])||void 0===r?void 0:r.name})," from this shot? This action can be undone."]})}),(0,a.jsx)("div",{className:"flex w-full items-center justify-between gap-x-3 p-6",children:(0,a.jsxs)("div",{className:"w-full flex gap-x-3",children:[(0,a.jsx)(D.z,{variant:"outline",className:"py-6 text-base w-full shadow shadow-sm bg-white",onClick:()=>s(!1),children:"Cancel"}),(0,a.jsx)(D.z,{className:"w-full py-6 text-base bg-red-500 hover:bg-red-600 text-white",onClick:()=>{o(l[n].actor_id),s(!1)},children:"Delete"})]})})]})})})})]})})})},je=s(3086),ye=s(3003);const be=Y.zt,Ne=Y.fC,ke=Y.xz,Se=Y.VY,_e=Y.Eh;var Ce=e=>{let{children:t,content:s,open:o,defaultOpen:n,onOpenChange:i,side:l="top",align:r="center",sideOffset:c=5,...d}=e;return(0,a.jsx)(be,{children:(0,a.jsxs)(Ne,{open:o,defaultOpen:n,onOpenChange:i,children:[(0,a.jsx)(ke,{asChild:!0,children:t}),(0,a.jsxs)(Se,{side:l,align:r,sideOffset:c,className:"bg-white text-gray-700 px-4 py-2.5 rounded-md mr-3 text-sm shadow-md animate-in fade-in-50 duration-200 z-50 ",...d,children:[s,(0,a.jsx)(_e,{className:"fill-current text-white"})]})]})})},Le=s(20355),Ae=s(15741),Ee=s(62630);const Te=e=>{if(isNaN(e)||!isFinite(e))return"00:00:00";const t=new Date(1e3*e).toISOString().substr(11,8);return t.startsWith("00:")?t.substr(3):t};var Me=function(e){let{vidUrl:t,vidRef:s,preload:o,actorId:n,processedVideoUrl:l,color:r,onTimeUpdate:d,isAudioPlaying:u,playbackRate:m,audioOffset:h,downloadVideo:x,pauseVideo:p,mediaId:f,token:g,shotId:v}=e;const[w,j]=(0,i.useState)(0),[y,b]=(0,i.useState)(0),[N,k]=(0,i.useState)(0),[S,_]=(0,i.useState)(!0),C=(0,i.useRef)(null),[L,A]=(0,i.useState)(!1),[E,T]=(0,i.useState)(1),[M,z]=(0,i.useState)(!1),[F,Z]=(0,i.useState)(!1),[P,D]=(0,i.useState)(1),[I,B]=(0,i.useState)(!1),[U,R]=(0,i.useState)(!1),[V,G]=(0,i.useState)(null);(0,i.useEffect)((()=>{f&&(async()=>{try{R(!0),console.log("Fetching tasks for mediaId: in downloadable vid player",f),c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(g);const i=await c.Z.get("/tasks?shot_id=".concat(v,"&task_type_name=lip-sync-s
1hot"));console.log("Tasks response:",i.data);const l=i.data.find((e=>{var t,s,a,o;const n=(null===(t=e.data)||void 0===t||null===(s=t.output)||void 0===s?void 0:s.output_media_id)===f,i=(null===(a=e.data)||void 0===a||null===(o=a.input)||void 0===o?void 0:o.dest_media_id)===f;return n||i}));if(console.log("Relevant task found:",l),l){var e,t,s,a,o,n;const i=null===(e=l.data)||void 0===e||null===(t=e.sub_tasks)||void 0===t?void 0:t.find((e=>"ffmpeg-insert-audios-1"===e.model)),r=(null===i||void 0===i||null===(s=i.input)||void 0===s||null===(a=s.audio_media_ids)||void 0===a?void 0:a.length)||0,c=l.updated_at?new Date(l.updated_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):null,d={model:(null===(o=l.data)||void 0===o||null===(n=o.input)||void 0===n?void 0:n.lsd_model)||"Unknown Model",credits:(null===l||void 0===l?void 0:l.credits)||0,timestamp:c||"Unknown Date",portionsGenerated:r||0};console.log("Setting generation info:",d),G(d)}else console.log("No relevant task found"),G(null)}catch(i){console.error("Error fetching task information:",i),G(null)}finally{R(!1)}})()}),[f,g]),(0,i.useEffect)((()=>{const e=C.current;e&&isFinite(m)&&(e.playbackRate=m)}),[m]),(0,i.useEffect)((()=>{const e=C.current;e&&(u?e.play():e.pause())}),[u]),(0,i.useEffect)((()=>{p&&C.current&&(C.current.pause(),_(!0))}),[p]),(0,i.useEffect)((()=>{const e=C.current;e&&isFinite(d)&&(e.currentTime=d)}),[d]),(0,i.useEffect)((()=>{const e=C.current;if(e){const t=()=>{k(e.duration),b(0)},s=()=>{b(e.currentTime),j(e.currentTime/e.duration*100)};return e.addEventListener("loadedmetadata",t),e.addEventListener("timeupdate",s),l&&e.load(),()=>{e.removeEventListener("loadedmetadata",t),e.removeEventListener("timeupdate",s)}}}),[C,l]);const O=()=>{const e=C.current;e&&(e.paused?(e.play(),_(!1)):(e.pause(),_(!0)))},H=e=>{const t=e[0]/100*N;b(t),(e=>{const t=C.current;t&&(t.currentTime=e)})(t)},W=e=>{const t=e[0]/100*N;b(t),(e=>{const t=C.current;t&&(t.currentTime=e)})(t)};return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{className:"items-center justify-center w-full ".concat(o?"preload-video":" rounded-xl video-container"),children:(0,a.jsx)("div",{className:"z-0 overflow-hidden mx-auto relative",children:(0,a.jsxs)("div",{className:"video-container select-none z-0",children:[(0,a.jsx)("video",{className:"rounded-lg w-full h-full",ref:C,loop:!0,preload:"auto",onClick:O,onPlay:()=>_(!1),onPause:()=>_(!0),style:{visibility:o?"hidden":"visible"},children:(0,a.jsx)("source",{src:l})}),(0,a.jsx)("div",{className:"absolute bottom-0 left-0 w-full h-1/2 bg-gradient-to-t from-black/30 to-transparent pointer-events-none"}),(0,a.jsxs)("div",{className:"absolute bottom-0 left-0 w-full z-10 pb-1 px-3 flex flex-col ",children:[(0,a.jsx)("div",{onMouseEnter:()=>A(!0),onMouseLeave:()=>A(!1),children:(0,a.jsxs)(ee.fC,{className:"relative flex w-full touch-none select-none items-center group mb-1",value:[w],onValueChange:e=>{j(e[0]),H(e)},onValueCommit:e=>{j(e[0]),W(e)},max:100,step:.1,children:[(0,a.jsx)(ee.fQ,{className:"relative w-full grow overflow-hidden bg-gray-400/60 transition-all duration-300 ease-in-out h-1",children:(0,a.jsx)(ee.e6,{className:"absolute h-full bg-cerise-red-600"})}),(0,a.jsx)(ee.bU,{className:"block rounded-full bg-cerise-red-600 shadow transition-all duration-300 ease-in-out ".concat(L?"h-4 w-4 opacity-100":"h-0 w-0 opacity-0"," focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50")})]})}),(0,a.jsx)("div",{className:"flex items-center justify-between w-full space-x-2",children:(0,a.jsxs)("div",{className:"flex items-center justify-start w-full space-x-2",children:[(0,a.jsx)("button",{onClick:O,children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 36 36",fill:r,height:"46px",width:"46px",children:S?(0,a.jsx)("path",{className:"ytp-svg-fill",d:"M 12,26 18.5,22 18.5,14 12,10 z M 18.5,22 25,18 25,18 18.5,14 z",id:"ytp-id-284"}):(0,a.jsx)("path",{className:"ytp-svg-fill",d:"M 12,26 16,26 16,10 12,10 z M 21,26 25,26 25,10 21,10 z",id:"ytp-id-386"})})}),(0,a.jsx)("button",{onClick:()=>{const e=C.current;e&&(e.currentTime=Math.min(e.currentTime+5,e.duration))},children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 36 36",fill:r,height:"46px",width:"46px",children:(0,a.jsx)("path",{className:"ytp-svg-fill",d:"M 12,24 20.5,18 12,12 V 24 z M 22,12 v 12 h 2 V 12 h -2 z",id:"ytp-id-28"})})}),(0,a.jsxs)("div",{className:"flex items-center space-x-2 w-48",children:[(0,a.jsxs)("div",{className:"relative flex items-center",onMouseEnter:()=>Z(!0),onMouseLeave:()=>Z(!1),children:[(0,a.jsx)("button",{onClick:()=>{C.current&&(M?(C.current.volume=P,T(P),z(!1)):(D(E),C.current.volume=0,T(0),z(!0)))},children:(0,a.jsx)("svg",{height:"46px",version:"1.1",fill:r,viewBox:"0 0 36 36",width:"46px",children:M?(0,a.jsx)("path",{className:"ytp-svg-fill",d:"m 21.48,17.98 c 0,-1.77 -1.02,-3.29 -2.5,-4.03 v 2.21 l 2.45,2.45 c .03,-0.2 .05,-0.41 .05,-0.63 z m 2.5,0 c 0,.94 -0.2,1.82 -0.54,2.64 l 1.51,1.51 c .66,-1.24 1.03,-2.65 1.03,-4.15 0,-4.28 -2.99,-7.86 -7,-8.76 v 2.05 c 2.89,.86 5,3.54 5,6.71 z M 9.25,8.98 l -1.27,1.26 4.72,4.73 H 7.98 v 6 H 11.98 l 5,5 v -6.73 l 4.25,4.25 c -0.67,.52 -1.42,.93 -2.25,1.18 v 2.06 c 1.38,-0.31 2.63,-0.95 3.69,-1.81 l 2.04,2.05 1.27,-1.27 -9,-9 -7.72,-7.72 z m 7.72,.99 -2.09,2.08 2.09,2.09 V 9.98 z",id:"ytp-id-412",fill:r}):(0,a.jsx)("path",{className:"ytp-svg-fill ytp-svg-volume-animation-speaker",d:"M8,21 L12,21 L17,26 L17,10 L12,15 L8,15 L8,21 Z M19,14 L19,22 C20.48,21.32 21.5,19.77 21.5,18 C21.5,16.26 20.48,14.74 19,14 ZM19,11.29 C21.89,12.15 24,14.83 24,18 C24,21.17 21.89,23.85 19,24.71 L19,26.77 C23.01,25.86 26,22.28 26,18 C26,13.72 23.01,10.14 19,9.23 L19,11.29 Z",fill:r,id:"ytp-id-30"})})}),(0,a.jsx)("div",{className:"absolute left-full ml-2 overflow-hidden transition-all duration-300 ease-in-out ".concat(F?"w-24 opacity-100":"w-0 opacity-0"),children:(0,a.jsx)("div",{className:"w-24",children:(0,a.jsxs)(ee.fC,{className:"relative flex h-5 w-full touch-none select-none items-center",value:[100*E],onValueChange:e=>{const t=e[0]/100;T(t),C.current&&(C.current.volume=t,z(0===t))},max:100,step:1,children:[(0,a.jsx)(ee.fQ,{className:"relative h-1 w-full grow overflow-hidden rounded-full bg-gray-400/60",children:(0,a.jsx)(ee.e6,{className:"absolute h-full bg-cerise-red-600"})}),(0,a.jsx)(ee.bU,{className:"block h-3 w-3 rounded-full bg-cerise-red-600 shadow transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cerise-red-600 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]})})})]}),(0,a.jsx)("div",{className:"flex items-center space-x-1 transition-all duration-300 ease-in-out ".concat(F?"transform translate-x-28":""),children:(0,a.jsxs)("span",{className:"text-sm whitespace-nowrap",style:{color:r},children:[Te(y)," / ",Te(N)]})})]}),(0,a.jsxs)("div",{className:"flex w-full flex-row gap-x-1 justify-end items-center",children:[!U&&null!==V&&(0,a.jsx)(Y.zt,{delayduration:0,
1children:(0,a.jsxs)(Y.fC,{children:[(0,a.jsx)(Y.xz,{asChild:!0,children:(0,a.jsx)("button",{children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:r,className:"w-6 h-6",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z"})})})}),(0,a.jsx)(Y.h_,{children:(0,a.jsxs)(Y.VY,{className:"TooltipContent ",sideOffset:5,children:[(0,a.jsxs)("div",{className:"flex flex-col gap-y-4 pt-2",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-y-1 ",children:[(0,a.jsx)("p",{className:"font-medium text-md",children:"Generation Details"}),(0,a.jsxs)("p",{className:"text-xs text-good-gray-100/90",children:["Information about the generation of ",(0,a.jsx)("br",{})," this video"]})]}),(0,a.jsx)("div",{className:"flex flex-col gap-y-2 ",children:Object.entries(V).map((e=>{let[t,s]=e;return(0,a.jsxs)("div",{className:"flex flex-row items-center text-xs gap-x-1",children:[(0,a.jsx)("div",{className:"p-1 bg-gray-200/60 rounded-sm",children:t}),(0,a.jsxs)("div",{className:"rounded-md",children:["- ",s]})]},t)}))})]}),(0,a.jsx)(Y.Eh,{className:"TooltipArrow"})]})})]})}),(0,a.jsx)("button",{className:"ml-1.5",onClick:x,children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:r,className:"w-6 h-6",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3"})})}),(0,a.jsx)("button",{onClick:()=>{const e=C.current;e&&(document.fullscreenElement?(document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen(),B(!1)):(e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen(),B(!0)))},children:(0,a.jsxs)("svg",{height:"36px",version:"1.1",fill:r,viewBox:"0 0 36 36",width:"36px",children:[(0,a.jsx)("path",{d:"m 10,16 2,0 0,-4 4,0 0,-2 L 10,10 l 0,6 0,0 z"}),(0,a.jsx)("path",{d:"m 20,10 0,2 4,0 0,4 2,0 L 26,10 l -6,0 0,0 z"}),(0,a.jsx)("path",{d:"m 24,24 -4,0 0,2 L 26,26 l 0,-6 -2,0 0,4 0,0 z"}),(0,a.jsx)("path",{d:"M 12,20 10,20 10,26 l 6,0 0,-2 -4,0 0,-4 0,0 z"})]})})]})]})})]})]})})})})},ze=s(95507);const Fe=[{name:"Eleven Multilingual v2",type:"Text-to-Speech",description:"Description of model 1",model_id:"eleven_multilingual_v2",service:"TTS",cost:50,similarity_and_stability:!0,supported_langs:["English","Spanish","French","German","Italian","Portuguese","Russian","Japanese","Chinese","Korean"],recommended:!0,tag:"Best Quality",tag_variant:"brand",available:!0}];var Ze=e=>{let{showAudioModelSelection:t,setShowAudioModelSelection:s,selectedAudioModel:o,setSelectedAudioModel:n,token:l}=e;const[r,d]=(0,i.useState)(o),[u,m]=(0,i.useState)(!1),h=[50,75,0,!0],[x,p]=(0,i.useState)(h[3]),[f,g]=(0,i.useState)(h[0]),[v,w]=(0,i.useState)(h[1]),[j,y]=(0,i.useState)(h[2]),[b,N]=(0,i.useState)(h[3]),[k,S]=(0,i.useState)(Fe),[_,C]=(0,i.useState)(!1),[L,A]=(0,i.useState)(!1),[E,T]=(0,i.useState)(!1),[I,B]=(0,i.useState)(!1),[U,R]=(0,i.useState)(f),[V,G]=(0,i.useState)(v),[O,H]=(0,i.useState)(j),[W,q]=(0,i.useState)(b),[K,J]=(0,i.useState)(x);(0,i.useEffect)((()=>{C("eleven_multilingual_v2"!==r&&"eleven_multilingual_sts_v2"!==r)}),[r]);return(0,i.useEffect)((()=>{m(!0);(async()=>{try{c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(l);const e=await c.Z.get("/job-types");console.log("job type response",e.data);const t=k.map((t=>{const s=e.data.find((e=>e.model===t.model_id));return s&&s.params&&s.params.model_details&&s.params.model_details.languages?{...t,supported_langs_count:s.params.model_details.languages.length}:t}));S(t),m(!1)}catch(e){console.error("Error fetching model info:",e),m(!1)}})()}),[]),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(M.u,{appear:!0,show:t,as:i.Fragment,children:(0,a.jsxs)(z.Vq,{as:"div",className:"relative z-[70]",o
1pen:t,onClose:()=>s(!1),children:[(0,a.jsx)(M.x,{as:"div",enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{className:" fixed inset-0 bg-black/25"})}),(0,a.jsx)("div",{className:"fixed inset-0 overflow-y-auto ",children:(0,a.jsx)("div",{className:"flex min-h-full items-center justify-center p-4 text-center",children:(0,a.jsx)(M.x,{as:"div",enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:(0,a.jsxs)(z.EM,{className:"dialog-panel-3 w-full transform overflow-hidden rounded-lg bg-white text-left align-middle shadow-xl transition-all flex flex-col",children:[(0,a.jsxs)("div",{className:"flex flex-col flex-grow",children:[(0,a.jsx)(ne.__,{className:"text-base pl-6 pr-6 pt-6",children:"Audio Generation Model"}),u?(0,a.jsxs)("div",{className:"flex flex-col pl-6 pr-6 pt-6 pb-8 h-full",children:[(0,a.jsxs)("div",{className:"flex flex-row gap-x-4 mt-3",children:[(0,a.jsx)(ze.Z,{className:"rounded-lg",variant:"rectangular",width:220,height:175,animation:"wave"}),(0,a.jsx)(ze.Z,{className:"rounded-lg",variant:"rectangular",width:220,height:175,animation:"wave"})]}),(0,a.jsxs)("div",{className:"mt-9",children:[(0,a.jsx)(ne.__,{className:"text-base",children:"Voice Settings"}),(0,a.jsx)("div",{className:"w-full mt-7",children:(0,a.jsx)(ze.Z,{className:"rounded-lg w-full",variant:"rectangular",height:40,animation:"wave"})}),(0,a.jsx)("div",{className:"w-full mt-8",children:(0,a.jsx)(ze.Z,{className:"rounded-lg w-full",variant:"rectangular",height:40,animation:"wave"})}),(0,a.jsx)("div",{className:"w-full mt-8",children:(0,a.jsx)(ze.Z,{className:"rounded-lg w-full",variant:"rectangular",height:40,animation:"wave"})}),(0,a.jsx)("div",{className:"w-full mt-8 mb-5.5",children:(0,a.jsx)(ze.Z,{className:"rounded-lg w-1/4",variant:"rectangular",height:35,animation:"wave"})})]})]}):(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)("div",{className:"flex flex-col pt-2 p-6",children:[(0,a.jsx)("div",{className:"flex flex-row gap-x-4 mt-3",children:k.map((e=>(0,a.jsxs)("button",{style:{borderColor:r===e.model_id?"#e63c6c":"rgb(205, 213, 223)",opacity:e.available?1:.5,cursor:e.available?"pointer":"not-allowed"},className:"_16uipyo text-left hover:bg-gray-100/40 ".concat(e.name?"":"disabled"," flex-1 min-w-[220px] max-w-[220px] relative"),type:"button",onClick:()=>{e.available&&d(e.model_id)},disabled:!e.available,children:[(0,a.jsxs)("div",{class:"flex justify-between w-full",children:[(0,a.jsx)(F.C,{variant:e.tag_variant,children:e.tag}),(0,a.jsx)("div",{className:"flex-center w-[22px] h-[22px] rounded-full border border-solid flex justify-center items-center",style:{borderColor:r===e.model_id?"#e63c6c":"rgb(205, 213, 223)",backgroundColor:r===e.model_id?"#e63c6c":"transparent"},children:r===e.model_id&&(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"#fff",className:"w-4 h-4",children:(0,a.jsx)("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 12.75l6 6 9-13.5"})})})]}),(0,a.jsx)("div",{class:"text-gray-700 font-semibold mt-4",children:e.name}),(0,a.jsxs)("div",{class:"text-sm font-medium text-gray-600 mt-2 flex flex-col gap-1",children:[e.type,(0,a.jsxs)("div",{children:[e.supported_langs_count," ",e.supp
1orted_langs_count<2?"Language":"Languages"]}),(0,a.jsxs)("div",{class:"-mr-1",children:[e.cost," credits per min"]})]})]},e.model_id)))}),(0,a.jsxs)("div",{className:"mt-5 ".concat(_?"opacity-50 pointer-events-none":""),children:[(0,a.jsx)(ne.__,{className:"text-base",children:"Voice Settings"}),(0,a.jsxs)("div",{className:"w-full flex flex-col mt-6",children:[(0,a.jsx)(ne.__,{children:"Stability"}),(0,a.jsxs)("div",{className:"w-full flex flex-row text-good-gray-100 text-xs justify-between mt-1",children:[(0,a.jsx)(Y.zt,{children:(0,a.jsxs)(Y.fC,{children:[(0,a.jsx)(Y.xz,{asChild:!0,children:(0,a.jsx)("div",{children:"More Variable"})}),(0,a.jsx)(Y.h_,{children:(0,a.jsx)(Y.VY,{className:"TooltipContent2 z-20",children:(0,a.jsx)("p",{className:"font-medium",children:"Increasing variability can make speech more expressive with output varying between re-generations. It can also lead to instabilities."})})})]})}),(0,a.jsx)(Y.zt,{children:(0,a.jsxs)(Y.fC,{children:[(0,a.jsx)(Y.xz,{asChild:!0,children:(0,a.jsx)("div",{children:"More Stable"})}),(0,a.jsx)(Y.h_,{children:(0,a.jsx)(Y.VY,{className:"TooltipContent2 z-20",children:(0,a.jsx)("p",{className:"font-medium",children:"Increasing stability will make the voice more consistent between re-generations, but it can also make it sound a bit monotone. On longer text fragments we recommend lowering this value."})})})]})})]}),(0,a.jsxs)("div",{className:"w-full mt-1",children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(P.i,{defaultValue:[U],max:100,step:1,value:[U],disabled:_,onValueChange:e=>R(e[0]),onPointerDown:()=>A(!0),onPointerUp:()=>A(!1)}),L&&(0,a.jsxs)("div",{className:"absolute top-[-35px] left-1/2 transform -translate-x-1/2 bg-black text-white px-1.5 py-1 rounded rounded-lg font-medium text-xs",style:{left:"calc(".concat(U,"% + (").concat(8-.16*U,"px))")},children:[U,"%"]})]})," "]})]}),(0,a.jsxs)("div",{className:"w-full flex flex-col mt-6",children:[(0,a.jsx)(ne.__,{children:"Similarity"}),(0,a.jsxs)("div",{className:"w-full flex flex-row text-good-gray-100 text-xs justify-between mt-1",children:[(0,a.jsx)(Y.zt,{children:(0,a.jsxs)(Y.fC,{children:[(0,a.jsx)(Y.xz,{asChild:!0,children:(0,a.jsx)("div",{children:"Low"})}),(0,a.jsx)(Y.h_,{children:(0,a.jsx)(Y.VY,{className:"TooltipContent2 z-20",children:(0,a.jsx)("p",{className:"font-medium",children:"Low values are recommended if background artifacts are present in generated speech."})})})]})}),(0,a.jsx)(Y.zt,{children:(0,a.jsxs)(Y.fC,{children:[(0,a.jsx)(Y.xz,{asChild:!0,children:(0,a.jsx)("div",{children:"High"})}),(0,a.jsx)(Y.h_,{children:(0,a.jsx)(Y.VY,{className:"TooltipContent2 z-20",children:(0,a.jsx)("p",{className:"font-medium",children:"High enhancement boosts overall voice clarity and target speaker similarity. Very high values can cause artifacts, so adjusting this setting to find the optimal value is encouraged."})})})]})})]}),(0,a.jsx)("div",{className:"w-full mt-1",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(P.i,{defaultValue:[V],max:100,step:1,value:[V],disabled:_,onValueChange:e=>G(e[0]),onPointerDown:()=>T(!0),onPointerUp:()=>T(!1)}),E&&(0,a.jsxs)("div",{className:"absolute top-[-35px] left-1/2 transform -translate-x-1/2 bg-black text-white px-1.5 py-1 rounded rounded-lg font-medium text-xs",style:{left:"calc(".concat(V,"% + (").concat(8-.16*V,"px))")},children:[V,"%"]})]})})]}),(0,a.jsxs)("div",{className:"w-full flex flex-col mt-6",children:[(0,a.jsx)(ne.__,{children:"Style Exaggeration"}),(0,a.jsxs)("div",{className:"w-full flex flex-row text-good-gray-100 text-xs justify-between mt-1",children:[(0,a.jsx)("div",{children:"None"}),(0,a.jsx)(Y.zt,{children:(0,a.jsxs)(Y.fC,{children:[(0,a.jsx)(Y.xz,{asChild:!0,children:(0,a.jsx)("div",{children:"Exaggerated"})}),(0,a.jsx)(Y.h_,{children:(0,a.jsx)(Y.VY,{className:"TooltipContent2 z-20",children:(0,a.jsx)("p",{className:"font-medium",children:"High values are recommended if the style of the speech should be exaggerated compared to the uploaded audio. Higher values can lead to more instability in the generated speech. Setting this to 0.0 will greatly increase generation speed and is the deafult setting."})})})]})})]}),(0,a.jsx)("div",{className:"w-full mt-1",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(P.i,{defaultValue:[O],max:100,step:1,disabled:_,value:[O],onValueChange:e=>H(e[0]),onPointerDown:()=>B(!0),onPointerUp:()=>B(!1)}),I&&(0,a.jsxs)("div",{className:"absolute top-[-35px] left-1/2 transform -translate-x-1/2 bg-black text-white px-1.5 py-1 rounded rounded-lg font-medium text-xs",style:{left:"calc(".concat(O,"% + (").concat(8-.16*O,"px))")},children:[O,"%"]})]})})]}),(0,a.jsxs)("div",{className:"w-full flex flex-row justify-between mt-8",children:[(0,a.jsx)("div",{className:" items-center flex space-x-2",children:(0,a.jsx)(Y.zt,{children:(0,a.jsxs)(Y.fC,{children:[(0,a.jsx)(Y.xz,{asChild:!0,children:(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(Z.r,{value:W,disabled:_,onCheckedChange:e=>q(e)}),(0,a.jsx)(ne.__,{htmlFor:"speaker-boost",children:"Speaker Boost"})]})}),(0,a.jsx)(Y.h_,{children:(0,a.jsx)(Y.VY,{className:"TooltipContent2 z-2
10",children:(0,a.jsx)("p",{className:"font-medium",children:"Boost the similarity of the synthesized speech and the voice at the cost of some generation speed."})})})]})})}),(0,a.jsx)("div",{onClick:()=>resetToDefaults(),className:"flex underline text-sm cursor-pointer font-medium",children:"Reset to Defaults"})]})]})]})})]}),(0,a.jsx)("div",{className:"p-6 w-full justify-start items-start flex"}),(0,a.jsx)("div",{className:"flex w-full items-center justify-between gap-x-3 p-6",children:(0,a.jsxs)("div",{className:"w-full flex gap-x-3",children:[(0,a.jsx)(D.z,{variant:"outline",className:"py-6 text-base w-full shadow shadow-sm bg-white",onClick:()=>s(!1),children:"Cancel"}),(0,a.jsx)(D.z,{className:"w-full py-6 text-base bg-cerise-red-500 hover:bg-cerise-red-600 text-white",onClick:()=>{n(r),s(!1)},children:"Save"})]})})]})})})})]})})})};function Pe(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return t.filter(Boolean).join(" ")}var De=e=>{let{showGenerationDialog:t,setShowGenerationDialog:s}=e;const[o,n]=(0,i.useState)("upload");return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(M.u,{appear:!0,show:t,as:i.Fragment,children:(0,a.jsxs)(z.Vq,{as:"div",className:"relative z-[70]",onClose:()=>s(!1),children:[(0,a.jsx)(M.x,{as:i.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{className:"fixed inset-0 bg-black/25"})}),(0,a.jsx)("div",{className:"fixed inset-0 overflow-y-auto ",children:(0,a.jsx)("div",{className:"flex min-h-full items-center justify-center p-4 text-center",children:(0,a.jsx)(M.x,{as:"div",enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:(0,a.jsxs)(z.EM,{className:"dialog-panel-3 w-full transform overflow-visible rounded-lg bg-white text-left align-middle shadow-xl transition-all flex flex-col",children:[(0,a.jsx)("div",{className:"flex flex-col",children:(0,a.jsxs)(z.$N,{as:"h3",className:"pl-6 pr-6 pt-6 text-lg font-medium leading-6 flex flex-row justify-between",children:[(0,a.jsx)("div",{className:"flex flex-col gap-y-2",children:"Generate Video"}),(0,a.jsx)("button",{className:"items-start justify-start flex",onClick:()=>s(!1),children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-7 w-7 text-gray-400 hover:text-gray-600",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18 18 6M6 6l12 12"})})})]})}),(0,a.jsxs)("div",{className:"flex flex-col flex-grow",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 pl-6 pr-6 pt-4 ",children:[(0,a.jsx)("div",{className:"rounded-full w-6 h-6 flex justify-center items-center bg-gray-100 text-gray-700 text-xs font-semibold",children:"1"}),(0,a.jsx)(ne.__,{required:!0,className:"font-semibold text-gray-800",tooltip:"The language of your uploaded video",children:"Select Generation Type"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-y-2 pl-6 pr-6 pt-4",children:[(0,a.jsxs)("div",{className:"flex flex-row space-x-1 w-full rounded-md bg-gray-100 p-1",children:[(0,a.jsxs)("button",{onClick:()=>n("upload"),className:Pe("relative w-full rounded-lg py-2 text-sm font-medium leading-5","z-10","upload"===o?"text-black":"text-gray-600 hover:text-gray-700"),children:[(0,a.jsx)("span",{className:"relative z-10",children:"Lip-Sync"}),"upload"===o&&(0,a.jsx)(p.E.div,{className:"absolute inset-0 bg-white rounded-lg shadow",layoutId:"activeTab",initial:!1,transition:{type:"spring",stiffness:500,damping:30}})]}),(0,a.jsxs)("button",{onClick:()=>n("url"),className:Pe("relative w-full rounded-lg py-2 text-sm font-medium leading-5","z-10","url"===o?"text-black":"text-gray-600 hover:text-gray-700"),children:[(0,a.jsx)("span",{className:"relative z-10",children:"Dub"}),"url"===o&&(0,a.jsx)(p.E.div,{className:"absolute inset-0 bg-white rounded-lg shadow",layoutId:"activeTab",initial:!1,transition:{type:"spring",stiffness:500,damping:30}})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3 pt-4 ",children:[(0,a.jsx)("div",{className:"rounded-full w-6 h-6 flex justify-center items-center bg-gray-100 text-gray-700 text-xs font-semibold",children:"2"}),(0,a.jsx)(ne.__,{required:!0,className:"font-semibold text-gray-800",tooltip:"The language of your uploaded video",children:"Select Lip-Sync Model"})]}),(0,a.jsx)("div",{className:"flex flex-row gap-x-3 pt-4"})]})]}),(0,a.jsxs)("div",{className:"mt-1 w-full flex flex-row justify-between px-1 pl-6 pr-6",children:[(0,a.jsx)("span",{className:"text-gray-400 text-sm",children:"Generation Cost:"}),(0,a.jsx)("span",{className:"text-gray-400 text-sm",children:"11"})]}),(0,a.jsx)("div",{className:"flex w-full items-center justify-between gap-x-3 p-6",children:(0,a.jsxs)("div",{className:"w-full flex gap-x-3",children:[(0,a.jsx)(D.z,{variant:"outline",className:"py-6 text-base w-full shadow shadow-sm bg-white",onClick:()=>s(!1),children:"Cancel"}),(0,a.jsx)(D.z,{className:"w-full py-6 text-base bg-cerise-red-500 hover:bg-cerise-red-600 text-white",children:"Process"})]})})]})})})})]})})})};var Ie=e=>{let{showActorMergingDialog:t,setShowActorMergingDialog:s,actors:o,token:n,shotId:l,onPortionChange:r}=e;var u;const[m,h]=(0,i.useState)(null),[f,g]=(0,i.useState)(null),[v,w]=(0,i.useState)([]),[j,y]=(0,i.useState)(null),[b,N]=(0,i.useState)(!1),[k,S]=(0,i.useState)(null),[_,C]=(0,i.useState)(!1),L=async e=>{const t=await c.Z.get("/tasks/".concat(e)),a=t.data.status;return"COMPLETED"===a?(console.log("completed task response",t.data),s(!1),C(!1),void r()):"FAILED"===a?(console.error("Translation task failed"),d.A.error("Translation task failed"),void C(!1)):void setTimeout((()=>L(e)),5e3)},A=function(e,t){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return(0,a.jsxs)(p.E.div,{className:(0,V.default)("w-full cursor-pointer flex flex-row items-center justify-between p-2.5 rounded-lg border transition-colors duration-200",s?"border-cerise-red-500 bg-cerise-red-50":"border-[#e0e0e0] hover:border-cerise-red-300"),onClick:()=>{b?w((e=>e.includes(t)?e.filter((e=>e!==t)):[...e,t])):y(t)},children:[(0,a.jsxs)("div",{className:"flex flex-row items-center gap-x-2",children:[(0,a.jsx)("div",{className:"rounded-lg bg-gradient-to-br from-[#F16067] via-[#FB8D58] to-[#E63C6C] p-1",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"white",className:"w-6 h-6",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.982 18.725A7.488 7.488 0 0 0 12 15.75a7.488 7.488 0 0 0-5.982 2.975m11.963 0a9 9 0 1 0-11.963 0m11.963 0A8.966 8.966 0 0 1 12 21a8.966 8.966 0 0 1-5.982-2.275M15 9.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})})}),(0,a.jsx)("span",{className:"font-semibold",children:e.name||"Actor ".concat(t+1)})]}),(0,a.jsx)("div",{className:(0,V.default)("w-6 h-6 rounded-full border-1 border flex items-center justify-center",s?"bg-cerise-red-500 border-cerise-red-500":"border-gray-400"),children:s&&(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-white",viewBox:"0 0 20 20",fill:"currentColor",children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})})]},"".concat(t,"-").concat(o.length))};return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(M.u,{appear:!0,show:t,as:i.Fragment,children:(0,a.jsxs)(z.Vq,{as:"div",className:"relative z-[70]",o
1pen:t,onClose:()=>s(!1),children:[(0,a.jsx)(M.x,{as:"div",enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{className:" fixed inset-0 bg-black/25"})}),(0,a.jsx)("div",{className:"fixed inset-0 overflow-y-auto ",children:(0,a.jsx)("div",{className:"flex min-h-full items-center justify-center p-4 text-center",children:(0,a.jsx)(M.x,{as:"div",enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:(0,a.jsxs)(z.EM,{className:"dialog-panel-3 w-full transform overflow-hidden rounded-lg bg-white text-left align-middle shadow-xl transition-all flex flex-col",children:[(0,a.jsx)("div",{className:"flex flex-col ",children:(0,a.jsx)(ne.__,{className:"text-base pl-6 pr-6 pt-6",children:"Merge Actors"})}),(0,a.jsxs)("div",{className:"p-6 w-full justify-start items-start flex flex-col gap-2 flex-grow",children:[(0,a.jsxs)("div",{className:"col-start-1 flex items-center gap-3",children:[(0,a.jsx)("div",{className:"rounded-full w-6 h-6 flex justify-center items-center bg-gray-100 text-gray-700 text-xs font-semibold",children:b?"2":"1"}),(0,a.jsx)(ne.__,{className:"font-semibold text-gray-800",required:!0,tooltip:b?"Select actors to merge into the source actor":"Select the actor you want to be preserved after merging",children:b?"Select the actors to merge with ".concat((null===(u=o[f])||void 0===u?void 0:u.name)||"Actor ".concat(f+1)):"Select Source Actor"})]}),(0,a.jsx)(x.M,{mode:"wait",children:(0,a.jsx)("div",{className:"w-full flex flex-col gap-2",children:b?o.map(((e,t)=>t!==f&&A(e,t,v.includes(t)))):o.map(((e,t)=>A(e,t,t===j)))})})]}),(0,a.jsx)("div",{className:"flex w-full items-center justify-between gap-x-3 p-6",children:(0,a.jsxs)("div",{className:"w-full flex gap-x-3",children:[(0,a.jsx)(D.z,{variant:"outline",className:"py-6 text-base w-full shadow shadow-sm bg-white",onClick:()=>b?(g(null),y(null),N(!1),void w([])):s(!1),children:b?"Back":"Cancel"}),(0,a.jsx)(D.z,{disabled:b?0===v.length||_:null===j,className:"w-full py-6 text-base bg-cerise-red-500 hover:bg-cerise-red-600 text-white",onClick:()=>b?(async()=>{console.log("merging actors",v),C(!0);try{const e=await c.Z.post("/tasks",{name:"merge-actors",data:{actor_ids:[o[f].actor_id,...v.map((e=>o[e].actor_id))],shot_id:l}});200===e.status?(c.Z.post("/tasks/".concat(e.data.id,"/submit")),S(),await L(e.data.id)):C(!1)}catch(e){C(!1),console.error("Error merging actors",e)}})():(g(j),void N(!0)),children:b?_?"Merging...":"Merge":"Select"})]})})]})})})})]})})})},Be=s(88219);const Ue=[{name:"Startup",ram:"12GB",cpus:"6 CPUs",disk:"256GB SSD disk"},{name:"Business",ram:"16GB",cpus:"8 CPUs",disk:"512GB SSD disk"},{name:"Enterprise",ram:"32GB",cpus:"12 CPUs",disk:"1TB SSD disk"}];Array(12).fill(0);function Re(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return t.filter(Boolean).join(" ")}var Ve=e=>{let{originalVideoUrl:t,lipSyncVideoUrl:s,setLipSyncVideoUrl:o,showActorSettings:n,setShowActorSettings:l,actors:r,setActors:u,token:m,activeActorSettingsId:h,setActiveActorSettingsId:x,shotId:f,tracks:g,onPortionChange:v,throwSettingsDialog:w,setThrowSettingsDialog:j,audioPlayerUrl:y,setAudioPlayerUrl:b,openAudioPlayer:N,setOpenAudioPlayer:k,activePortion:S,setActivePortion:_,activeTrackId:C,selectedLSModel:L,setSelectedLSModel:A,audioPlayerAudioName:E,setAudioPlayerAudioName:T,isGenerationInProgress:M,setIsGenerationInProgress:z,shouldSwitchToPortionsTab:Z,setShouldSwitchToPortionsTab:P,selectedTranslationModel:I,setSelectedTranslationModel:B,portionMedia:U,setPortionMedia:R,selectedAudioModel:V,setSelectedAudioModel:G,setGenerationError:O,setGenerationSuccess:H,actorVoicePortionUpdated:W,setActorVoicePortionUpdated:q}=e;const Y=(0,i.useRef)(null),Q=(0,i.useRef)(null),[X,ee]=(0,i.useState)(0),[te,se]=(0,i.useState)(Ue[0]),[ie,le]=(0,i.useState)(!1),[re,ce]=(0,i.useState)(!0),[de,me]=(0,i.useState)(!1),{setCreditsChanged:he}=(0,$.a)(),[xe,fe]=(0,i.useState)(!1),[ge,be]=(0,i.useState)(!1),[Ne,ke]=(0,i.useState)([{name:"Original",value:"original"},{name:"Actors",value:"speakers"},{name:"Portion",value:"portion"},{name:"Generated",value:"generated"}]),[Se,_e]=(0,i.useState)(!1),[Te,ze]=(0,i.useState)(!1),[Fe,Pe]=(0,i.useState)([]),[Ve,Ge]=(0,i.useState)("desc"),[Oe,He]=(0,i.useState)(!1),[We,qe]=(0,i.useState)([]),[Ye,Ke]=(0,i.useState)(0),[Je,$e]=(0,i.useState)(0),Qe=(0,i.useRef)(S),Xe=(0,i.useRef)(null),[et,tt]=(0,i.useState)(null),[st,at]=(0,i.useState)(0),[ot,nt]=(0,i.useState)(!1),[it,lt]=(0,i.useState)(!1),[rt,ct]=(0,i.useState)(!1),[dt,ut]=(0,i.useState)(!0),[mt,ht]=(0,i.useState)(!1),[xt,pt]=(0,i.useState)(0),[ft,gt]=(0,i.useState)(null),vt=(0,i.useRef)([]),wt=(0,i.useRef)(null),[jt,yt]=(0,i.useState)([]),[bt,Nt]=(0,i.useState)([]),[kt,St]=(0,i.useState)(!1),[_t,Ct]=(0,i.useState)({}),[Lt,At]=(0,i.useState)(!0),[Et,Tt]=(0,i.useState)(!1),[Mt,zt]=(0,i.useState)(!1),[Ft,Zt]=(0,i.useState)(!0),[Pt,Dt]=(0,i.useState)(!1),[It,Bt]=(0,i.useState)(!1),[Ut,Rt]=(0,i.useState)({}),Vt=e=>{const t=Date.now()-e,s=Math.floor(t/1e3),a=Math.floor(s/60),o=Math.floor(a/60);return o>0?"".concat(o,"h ").concat(a%60,"m ").concat(s%60,"s"):a>0?"".concat(a,"m ").concat(s%60,"s"):"".concat(s,"s")};(0,i.useEffect)((()=>{vt.current=vt.current.slice(0,bt.length)}),[bt]);const Gt=(e,t)=>{gt(t?e:null);const s=vt.current[e];s&&(t?(s.currentTime=0,s.play()):s.pause())},Ot=()=>{Ge((e=>"desc"===e?"asc":"desc"))},Ht=(0,i.useMemo)((()=>{var e,t;return[{name:"DeepL",type:"Text-to-Speech",description:"Description of model 1",model:"deepl-trl-2",cost:50,similarity_and_stability:!0,supported_langs:["English","Spanish","French","German","Italian","Portuguese","Russian","Japanese","Chinese","Korean"],recommended:!0,tag:"Reliable",tag_variant:"brand",features:["For most languages","ML Assisted","High Accuracy"]},{name:"LLSOLLU",type:"Text-to-Speech",description:"Description of model 1",model:"llsollu-1",cost:100,similarity_and_stability:!1,supported_langs:["English","Spanish","French","German","Italian","Portuguese","Russian","Japanese","Chinese","Korean"],recommended:!1,tag:"New",tag_variant:"easy",features:["For Korean to English","High Precision","Error Prone"],disabled:!(null===(e=g.find((e=>"translated"===e.type)))||void 0===e||null===(t=e.language)||void 0===t?void 0:t.includes("ko"))}]}),[g]);(0,i.useEffect)((()=>{(async()=>{const e=await Promise.all(r.map((async e=>{var t;if(null===e||void 0===e||null===(t=e.actor_source_clip)||void 0===t?void 0:t.clean_media_id){var s;const t=null===e||void 0===e||null===(s=e.actor_source_clip)||void 0===s?void 0:s.clean_media_id;c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(m);return(await c.Z.get("/media/".concat(t,"?signed_url=true"))).data.signed_url}})));
1Pe(e)})()}),[r]),(0,i.useEffect)((()=>{(()=>{if(!g||0===g.length)return void ht(!0);const e=g.find((e=>"basic"===e.type)),t=g.find((e=>"translated"===e.type));if(t){const e=t.portions.some((e=>e.audio&&Object.keys(e.audio).length>0));ht(!e)}else if(e){const t=e.portions.some((e=>e.audio&&Object.keys(e.audio).length>0&&!1===e.matches_source));ht(!t)}else ht(!0)})()}),[g,v]),(0,i.useEffect)((()=>{if(h&&n){ee(1);const e=r.findIndex((e=>e.actor_id===h));-1!==e&&($e(e),l(!0),le(!0))}else l(!1)}),[r,n]),(0,i.useEffect)((()=>{ke([{name:"Original",value:"original",signedUrl:t},{name:"Actors",value:"speakers",signedUrl:Fe},{name:"Portion",value:"portion"},{name:"Generated",value:"generated",signedUrl:s}])}),[t,s,Fe]);(0,i.useEffect)((()=>{console.log("shouldSwitchToPortionsTab",Z),Z&&N&&(es(2),P(!1))}),[N,Z]);const[Wt,qt]=(0,i.useState)(null);(0,i.useEffect)((()=>{if(!Xe.current)return;const e=()=>{if(Xe.current){const e=Xe.current.querySelector("button");e&&qt("".concat(e.offsetWidth,"px"))}};e();const t=new ResizeObserver(e);t.observe(Xe.current);const s=new MutationObserver((t=>{t.forEach((t=>{"attributes"===t.type&&"style"===t.attributeName&&e()}))}));return s.observe(Xe.current,{attributes:!0,attributeFilter:["style"]}),()=>{t.disconnect(),s.disconnect()}}),[X]),(0,i.useEffect)((()=>{0===X&&setTimeout((()=>{var e;const t=null===(e=Xe.current)||void 0===e?void 0:e.querySelector("button");t&&qt("".concat(t.offsetWidth,"px"))}),0)}),[X]);const[Yt,Kt]=(0,i.useState)(!1),Jt=(0,i.useCallback)((async()=>{var e;console.log("fetch portion media called"),lt(!0);const t=S.actor_id;console.log("current actor id is",t);const s=r.find((e=>e.actor_id===t));if(tt(s),Kt(!!(null===s||void 0===s?void 0:s.voice_id)),Dt(!S.actor_id),Bt(!(null===s||void 0===s?void 0:s.voice_id)),!S||Qe.current===S||!S.audio||!S.audio.media_id)return R([]),lt(!1),void zt(!0);const a=[S.audio.media_id,...(null===(e=S.audio_history)||void 0===e?void 0:e.map((e=>e.media_id)))||[]].filter((e=>e)).map((e=>$t(e))),o=await Promise.all(a);R(o),lt(!1),Ws&&(qs(!1),Hs(!1)),zt(!0)}),[S,r,m,v,Et,g,W]),$t=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:700;for(let o=0;o<t;o++)try{c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(m);const t=await c.Z.get("/media/".concat(e,"?signed_url=true&downloadable=true")),s=Math.round(16e3*t.data.metadata.duration*2/8);return{media_id:e,signed_url:t.data.signed_url,isActive:e===S.audio.media_id,size:s,metadata:t.data.metadata}}catch(a){if(!a.response||400!==a.response.status)throw a;await new Promise((e=>setTimeout(e,s)))}throw new Error("Failed to fetch media ".concat(e," after ").concat(t," attempts"))};(0,i.useEffect)((()=>{S&&S!==Qe.current&&(Jt(),Qe.current=S)}),[S,Jt]);const[Qt,Xt]=(0,i.useState)(!1),es=e=>{0===X&&0!==e?(Xt(!0),Y.current&&Y.current.pause()):3===X&&3!==e&&(Xt(!0),wt.current&&wt.current.pause()),ee(e)};(0,i.useEffect)((()=>{S&&S.audio&&S.audio.offset&&xt>0&&ss(S.audio.offset)}),[X,xt]);const[ts,ss]=(0,i.useState)(null),[as,os]=(0,i.useState)(!1),[ns,is]=(0,i.useState)(1),ls=e=>{pt(e)},[rs,cs]=(0,i.useState)(0),[ds,us]=(0,i.useState)(null),[ms,hs]=(0,i.useState)(null),[xs,ps]=(0,i.useState)(!1),[fs,gs]=(0,i.useState)(0),[vs,ws]=(0,i.useState)(null),[js,ys]=(0,i.useState)(!1),[bs,Ns]=(0,i.useState)(null),[ks,Ss]=(0,i.useState)(!1),[_s,Cs]=(0,i.useState)(!1),[Ls,As]=(0,i.useState)(!1);(0,i.useEffect)((()=>{if(0===jt.length)return;const e=setInterval((()=>{Rt((e=>{const t={...e};let s=!1;return jt.forEach((e=>{e.startTimeMs&&(t[e.taskId]=e.startTimeMs,s=!0)})),s?t:e}))}),1e3);return()=>clearInterval(e)}),[jt]);const[Es,Ts]=(0,i.useState)(null),[Ms,zs]=(0,i.useState)(!1),Fs=async(e,t)=>{z(!0),gs(0);const s=setInterval((()=>{gs((e=>e+1))}),1e3);try{for(;;){c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(m);const t=await c.Z.get("/tasks/".concat(e));if(console.log("Status Response: ",t.data),["COMPLETED","FAILED"].includes(t.data.status)){if(clearInterval(s),As(!1),ys(!1),z(!1),"COMPLETED"===t.data.status){yt((t=>t.filter((t=>t.taskId!==e)))),d.A.success("Lip Sync completed successfully!");const t=(await c.Z.get("/shots/".concat(f))).data.shot_editor_json.background_target_clips;if(t&&t.length>0){const e=t[t.length-1];if(e.media_id){const t=(await c.Z.get("/media/".concat(e.media_id,"?signed_url=true"))).data.signed_url;ke((e=>e.map((e=>"generated"===e.value?{...e,signedUrl:t}:e))))}}H(!0),ee(3),zs(!0)}else yt((t=>t.filter((t=>t.taskId!==e)))),d.A.error("Lip Sync failed. Join our Discord or email us at [email protected] for support."),z(!1),O(!0);return}await new Promise((e=>setTimeout(e,5e3)))}}catch(a){yt((t=>t.filter((t=>t.taskId!==e)))),clearInterval(s),console.error("Error generating shot:",a),As(!1),ys(!1),d.A.error("Lip Sync failed. Please try again."),z(!1),O(!0)}},Zs=(e,t)=>{const s=e=>{var a,o,n,i,l,r,c,d;let u=!1,m=null;(null===(a=e.data)||void 0===a||null===(o=a.output)||void 0===o?void 0:o.output_media_id)!==t&&(null===(n=e.data)||void 0===n||null===(i=n.input)||void 0===i?void 0:i.dest_media_id)!==t&&(null===(l=e.output)||void 0===l?void 0:l.output_media_id)!==t&&(null===(r=e.input)||void 0===r?void 0:r.dest_media_id)!==t||(u=!0),"ffmpeg-insert-audios-1"===e.model&&(m=e);const h=(null===(c=e.data)||void 0===c?void 0:c.sub_tasks)||(null===(d=e.input)||void 0===d?void 0:d.sub_tasks)||[];for(const t of h){const e=s(t);e.mediaId&&(u=!0),e.ffmpegTask&&(m=e.ffmpegTask)}return{mediaId:u,ffmpegTask:m}},a=s(e);return!!a.mediaId&&{isMatch:!0,ffmpegTask:a.ffmpegTask}};(0,i.useEffect)((()=>{(async()=>{try{c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(m);const[e,t,s,a]=await Promise.all([c.Z.get("/shots/".concat(f)),c.Z.get("/tasks?shot_id=".concat(f,"&task_type_name=lip-sync-s
1hot&status=COMPLETED")),c.Z.get("/tasks?shot_id=".concat(f,"&task_type_name=lip-sync-text-shot&status=COMPLETED")),c.Z.get("/tasks?shot_id=".concat(f,"&task_type_name=lip-sync-timeline-shot&status=COMPLETED"))]);console.log("lip sync tasks",t.data),console.log("lip sync text tasks",s.data);const o=[...t.data,...s.data,...a.data];console.log("shot response",e.data);const n=e.data.shot_editor_json.background_target_clips;if(n&&n.length>0){const e=n.map((e=>c.Z.get("/media/".concat(e.media_id,"?signed_url=true")))),t=(await Promise.all(e)).map(((e,t)=>{const s=n[t].media_id;let a=null;const i=o.find((e=>{const t=Zs(e,s);return t&&t.isMatch}));if(i){var l,r,c,d,u,m;const e=Zs(i,s),t=e?e.ffmpegTask:null,o=(null===t||void 0===t||null===(l=t.input)||void 0===l||null===(r=l.audio_media_ids)||void 0===r?void 0:r.length)||0,n=i.updated_at?new Date(i.updated_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"Unknown";a={model:(null===(c=i.data)||void 0===c||null===(d=c.input)||void 0===d?void 0:d.lsd_model)||(null===(u=i.data)||void 0===u||null===(m=u.input)||void 0===m?void 0:m.model)||"Unknown Model",credits:i.credits,timestamp:n,portionsGenerated:o}}return{media_id:s,signed_url:e.data.signed_url,taskInfo:a}})),s=t.length>0?t[t.length-1]:null;console.log("past urls with task info:",t),Nt(t),ke(s?e=>e.map((e=>"generated"===e.value?{...e,signedUrl:s.signed_url,media_id:s.media_id,taskInfo:s.taskInfo}:e)):e=>e.map((e=>"generated"===e.value?{...e,signedUrl:null,media_id:null,taskInfo:null}:e)))}else Nt([]),ke((e=>e.map((e=>"generated"===e.value?{...e,signedUrl:null,media_id:null,taskInfo:null}:e))))}catch(e){console.error("Error fetching output video:",e),Nt([]),ke((e=>e.map((e=>"generated"===e.value?{...e,signedUrl:null,media_id:null,taskInfo:null}:e))))}})()}),[f,m,Ms,M]);const[Ps,Ds]=(0,i.useState)(null),[Is,Bs]=(0,i.useState)(null),[Us,Rs]=(0,i.useState)(!1),[Vs,Gs]=(0,i.useState)(!1),[Os,Hs]=(0,i.useState)(!1),[Ws,qs]=(0,i.useState)(!1),Ys=async()=>{try{if(!et)return void d.A.error("Assign an actor to this portion to generate audio.");if(!Yt&&et)return void d.A.error("Assign a voice to your actor in order to generate audio.");Gs(!0),Hs(!0);const e=g.find((e=>"translated"===e.type))||g.find((e=>"basic"===e.type));if(!e)throw new Error("No suitable track found");const t=await c.Z.post("/tasks",{name:"portion-to-audio",data:{track_id:e.id,actor_id:S.actor_id,portion_id:S.portion_id,shot_id:f,model:V}});200===t.status?(console.log("task response",t.data),Bs(t.data.credits),Rs(!0),Ds(t.data.id)):d.A.error("Failed to create job")}catch(e){console.error("Error creating audio task:",e),d.A.error("Error creating audio task")}finally{Gs(!1)}},Ks=async e=>{if(_s)return;Cs(!0),Gs(!0),qs(!0),Hs(!0);d.A.promise((async()=>{await c.Z.post("/tasks/".concat(e,"/submit"));return new Promise(((t,s)=>{const a=async()=>{try{const n=(await c.Z.get("/tasks/".concat(e))).data.status;if("COMPLETED"===n){var o;const e=await c.Z.get("/shots/".concat(f)),s=e.data.shot_editor_json.tracks.filter((e=>"source"!==e.type)),a=s.find((e=>"translated"===e.type)),n=s.find((e=>"basic"===e.type)),i=null===(o=a||n)||void 0===o?void 0:o.portions.find((e=>e.portion_id===S.portion_id));if(!i)throw new Error("Current portion not found");const l=await async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:700;for(let o=0;o<t;o++)try{c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(m);const t=await c.Z.get("/media/".concat(e,"?signed_url=true"));return Math.round(16e3*t.data.metadata.duration*2/8),t.data}catch(a){if(!a.response||400!==a.response.status)throw a;console.log("Media ".concat(e," still uploading. Retrying in ").concat(s/1e3," seconds...")),await new Promise((e=>setTimeout(e,s)))}throw new Error("Failed to fetch media ".concat(e," after ").concat(t," attempts"))}(i.audio.media_id);b(l.signed_url),T(i.audio.media_id),k(!0),Rs(!1),Gs(!1),he(!0),Tt(!0),qs(!1);const r=Math.round(16e3*l.metadata.duration*2/8);R((e=>{if(e.some((e=>e.media_id===i.audio.media_id)))return e.map((e=>({...e,isActive:e.media_id===i.audio.media_id})));const t={media_id:i.audio.media_id,signed_url:l.signed_url,isActive:!0,size:r};return[...e.map((e=>({...e,isActive:!1}))),t]})),Hs(!1),_(i),v(),t(i)}else"FAILED"===n?s(new Error("Audio generation failed")):setTimeout(a,5e3)}catch(n){s(n)}};a()}))}),{loading:"Generating audio...",success:()=>(setTimeout((()=>{d.A.dismiss()}),1e3),"Audio generated successfully"),error:e=>{var t;return Gs(!1),qs(!1),Hs(!1),Cs(!1),402===(null===(t=e.response)||void 0===t?void 0:t.status)?e.response.data.message||"Insufficient credits. Wait for your subscription to renew or upgrade your plan to continue."
1:"Error generating audio. Your voice might have been blocked by ElevenLabs which causes this error. If you have continued issues, reach out on our discord or shoot us a email."},position:"top-center"})},Js=g.some((e=>"translated"===e.type));g.some((e=>"basic"===e.type));return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex w-full flex-col h-full h-[calc(100vh] lg:h-[calc(100vh-90px)] overflow-y-auto no-horizontal-scroll",children:[(0,a.jsx)("div",{className:"flex space-x-1 rounded-md bg-gray-100 p-1",children:Ne.map(((e,t)=>"generated"!==e.value||s&&M?(0,a.jsxs)("button",{onClick:()=>ee(t),className:Re("relative w-full rounded-lg py-2.5 text-sm font-medium leading-5","z-0",X===t?"text-black":"text-gray-600 hover:text-gray-700","portion"!==e.value||S?"":"text-gray-400 bg-gray-100/20 cursor-not-allowed"),disabled:"portion"===e.value&&!S,children:[(0,a.jsx)("span",{className:"relative z-[1]",children:e.name}),X===t&&(0,a.jsx)(p.E.div,{className:"absolute inset-0 bg-white rounded-lg shadow",layoutId:"activeTab",initial:!1,transition:{type:"spring",stiffness:500,damping:30}})]},e.value):(0,a.jsx)(Ce,{content:e.signedUrl?"View generated videos":"Generate your video to view the result.",delayDuration:300,side:"top",alignOffset:-20,align:"start",sideOffset:5,children:(0,a.jsxs)("button",{onClick:()=>es(t),className:Re("relative w-full rounded-lg py-2.5 text-sm font-medium leading-5","z-0",X===t?"text-black":"text-gray-600 hover:text-gray-700",e.signedUrl?"":"text-gray-400 bg-gray-100/20 "),disabled:!e.signedUrl,children:[(0,a.jsx)("span",{className:"relative z-[1]",children:e.name}),X===t&&(0,a.jsx)(p.E.div,{className:"absolute inset-0 bg-white rounded-lg shadow",layoutId:"activeTab",initial:!1,transition:{type:"spring",stiffness:500,damping:30}})]})},e.value)))}),(0,a.jsx)("div",{className:"mt-2 flex-grow overflow-hidden flex flex-col",children:Ne.map(((e,t)=>{var s;return(0,a.jsx)("div",{className:Re("rounded-xl bg-white h-full flex flex-col","ring-0 focus:outline-none",X===t?"block":"hidden"),children:"speakers"===e.value?(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{children:(0,a.jsx)(oe.Z,{color:"white",preload:!1,vidUrl:Fe[Ye],processedVideoUrl:Fe[Ye],pauseVideo:1!==X})},Ye),(0,a.jsx)("div",{className:"mt-4 flex flex-col gap-y-2 max-h-80 overflow-y-auto",children:r.map(((e,t)=>(0,a.jsxs)("div",{className:"cursor-pointer flex flex-row items-center justify-between p-2.5 mr-1 rounded-lg border border-[#e0e0e0] transition-colors duration-200",children:[(0,a.jsxs)("div",{className:"flex flex-row items-center gap-x-2",children:[(0,a.jsx)("div",{className:"rounded-lg bg-gradient-to-br from-[#F16067] via-[#FB8D58] to-[#E63C6C] p-1",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"white",className:"w-6 h-6",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.982 18.725A7.488 7.488 0 0 0 12 15.75a7.488 7.488 0 0 0-5.982 2.975m11.963 0a9 9 0 1 0-11.963 0m11.963 0A8.966 8.966 0 0 1 12 21a8.966 8.966 0 0 1-5.982-2.275M15 9.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})})}),(0,a.jsx)("span",{className:"font-semibold",children:e.name||"Actor ".concat(t+1)}),(0,a.jsx)("button",{onClick:()=>{ze(!0),$e(t)},children:(0,a.jsx)(Le.Z,{size:20,className:"text-gray-400 hover:text-slate-800"})})]}),(0,a.jsxs)("div",{className:"flex flex-row items-center gap-x-2",children:[(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,onClick:()=>(e=>{Ke(e)})(t),stroke:"currentColor",className:"w-5 h-5 ".concat(Ye===t?"text-green-500":"text-gray-400"),children:[(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z"}),(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})]}),(0,a.jsx)("button",{onClick:()=>(e=>{$e(e),l(!0),x(r[e].actor_id)})(t),children:(0,a.jsx)(Ae.Z,{size:20,className:"text-gray-400 hover:text-slate-800"})}),(0,a.jsx)("button",{onClick:()=>{nt(!0),$e(t)},children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-5 h-5 text-gray-400 hover:text-red-600",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"})})})]})]},"".concat(t,"-").concat(rs))))}),r.length>1&&(0,a.jsx)(D.z,{variant:"outline",className:"mt-2 w-full",onClick:()=>be(!0),children:"Merge Actors"})]}):"portion"===e.value?(0,a.jsx)("div",{className:"flex-grow flex flex-col h-full overflow-y-auto pr-4",children:it?(0,a.jsx)("div",{className:"flex-grow flex items-center justify-center",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("div",{className:"flex items-center justify-center rounded-lg p-1 mb-2",children:(0,a.jsx)(J.Spinner,{className:"w-5 h-5"})}),(0,a.jsx)("p",{children:"Fetching Portion Media..."})]})}):U.length>0||Js?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"mt-5 flex flex-col w-full",children:[(0,a.jsxs)("div",{className:"flex flex-row items-center gap-x-2 cursor-pointer w-full mb-4",onClick:()=>Zt(!Ft),children:[Ft?(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-4 w-4",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m19.5 8.25-7.5 7.5-7.5-7.5"})}):(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-4 w-4",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m8.25 4.5 7.5 7.5-7.5 7.5"})}),(0,a.jsx)("h3",{className:"text-sm font-semibold relative",children:"Audio Settings"}),(0,a.jsx)("div",{className:"flex-grow border-t border-black"})]}),Ft&&(0,a.jsxs)("div",{className:"flex flex-row gap-y-4 gap-x-4 mt-3",children:[(0,a.jsxs)("button",{style:{borderColor:"eleven_multilingual_v2"===V?"#e63c6c":"rgb(205, 213, 223)"},className:"_17uipyo text-left hover:bg-gray-100/40 min-w-0",type:"button",onClick:()=>G("eleven_multilingual_v2"),children:[(0,a.jsxs)("div",{class:"flex justify-between w-full",children:[(0,a.jsx)(F.C,{variant:"brand",className:"text-xs",children:"Reliable"}),(0,a.jsx)("div",{className:"flex-center w-[22px] h-[22px] rounded-full border border-solid flex justify-center items-center",style:{borderColor:"eleven_multilingual_v2"===V?"#e63c6c":"rgb(205, 213, 223)",backgroundColor:"eleven_multilingual_v2"===V?"#e63c6c":"transparent"},children:"eleven_multilingual_v2"===V&&(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"#fff",className:"w-4 h-4",children:(0,a.jsx)("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 12.75l6 6 9-13.5"})})})]}),(0,a.jsx)("div",{class:"text-gray-700 font-semibold mt-4 text-sm",children:"ElevenLabs"}),(0,a.jsxs)("div",{className:"text-xs font-medium text-gray-600 mt-2 flex flex-col gap-2",children:[(0,a.jsx)("div",{className:"h-4 flex items-center",children:"80 credits/1k characters"}),(0,a.jsx)("div",{className:"h-4 flex items-center",children:"Longer Latency"}),(0,a.jsxs)("div",{className:"h-4 flex flex-row items-center",children:[(0,a.jsx)("span",{className:"mr-1",children:"29 Languages"}),(0,a.jsx)(ne.u,{animation:!0,content:"Supported Languages: English (USA), English (UK), English (Australia), English (Canad
1a), Japanese, Chinese, German, Hindi, French (France), French (Canada), Korean, Portuguese (Brazil), Portuguese (Portugal), Italian, Spanish (Spain), Spanish (Mexico), Indonesian, Dutch, Turkish, Filipino, Polish, Swedish, Bulgarian, Romanian, Arabic (Saudi Arabia), Arabic (UAE), Czech, Greek, Finnish, Croatian, Malay, Slovak, Danish, Tamil, Ukrainian, Russian",delayDuration:0})]})]})]}),(0,a.jsxs)("button",{style:{borderColor:"aurora"===V?"#e63c6c":"rgb(205, 213, 223)"},className:"_17uipyo text-left hover:bg-gray-100/40 min-w-0",type:"button",onClick:()=>G("aurora"),children:[(0,a.jsxs)("div",{class:"flex justify-between w-full",children:[(0,a.jsx)(F.C,{variant:"hard",className:"text-xs",children:"New"}),(0,a.jsx)("div",{className:"flex-center w-[22px] h-[22px] rounded-full border border-solid flex justify-center items-center",style:{borderColor:"aurora"===V?"#e63c6c":"rgb(205, 213, 223)",backgroundColor:"aurora"===V?"#e63c6c":"transparent"},children:"aurora"===V&&(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"#fff",className:"w-4 h-4",children:(0,a.jsx)("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 12.75l6 6 9-13.5"})})})]}),(0,a.jsx)("div",{class:"text-gray-700 font-semibold mt-4 text-sm",children:"LMNT"}),(0,a.jsxs)("div",{className:"text-xs font-medium text-gray-600 mt-2 flex flex-col gap-2",children:[(0,a.jsx)("div",{className:"h-4 flex items-center",children:"70 credits/1k characters"}),(0,a.jsx)("div",{className:"h-4 flex items-center",children:"~150ms latency"}),(0,a.jsxs)("div",{className:"h-4 flex flex-row items-center",children:[(0,a.jsx)("span",{className:"mr-1",children:"8 Languages"}),(0,a.jsx)(ne.u,{animation:!0,content:"Supported Languages: English, Chinese, French, German, Portuguese, Spanish, Korean, and Hindi",delayDuration:0})]})]})]})]})]}),(Yt||Js)&&(0,a.jsx)(a.Fragment,{children:Js&&(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)("div",{className:"mt-5 flex flex-col w-full",children:[(0,a.jsxs)("div",{className:"flex flex-row items-center gap-x-2 cursor-pointer w-full mb-4",onClick:()=>He(!Oe),children:[Oe?(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-4 w-4",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m19.5 8.25-7.5 7.5-7.5-7.5"})}):(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-4 w-4",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m8.25 4.5 7.5 7.5-7.5 7.5"})}),(0,a.jsx)("h3",{className:"text-sm font-semibold relative",children:"Translation Settings"}),(0,a.jsx)("div",{className:"flex-grow border-t border-black"})]}),Oe&&(0,a.jsx)("div",{className:"flex flex-row gap-y-4 gap-x-4 mt-3",children:Ht.map((e=>(0,a.jsxs)("button",{style:{borderColor:I===e.model?"#e63c6c":"rgb(205, 213, 223)"},className:"_17uipyo text-left hover:bg-gray-100/40 ".concat(!e.name||e.disabled?"disabled":""," min-w-0"),type:"button",onClick:()=>B(e.model),disabled:e.disabled,children:[(0,a.jsxs)("div",{class:"flex justify-between w-full",children:[(0,a.jsx)(F.C,{variant:e.tag_variant,className:"text-xs",children:e.tag}),(0,a.jsx)("div",{className:"flex-center w-[22px] h-[22px] rounded-full border border-solid flex justify-center items-center",style:{borderColor:!1===e.model?"#e63c6c":"rgb(205, 213, 223)",backgroundColor:I===e.model?"#e63c6c":"transparent"},children:I===e.model&&(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"#fff",className:"w-4 h-4",children:(0,a.jsx)("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 12.75l6 6 9-13.5"})})})]}),(0,a.jsx)("div",{class:"text-gray-700 font-semibold mt-4 text-sm",children:e.name}),(0,a.jsxs)("div",{class:"text-xs font-medium text-gray-600 mt-2 flex flex-col gap-1",children:[e.features[0],(0,a.jsxs)("div",{children:[e.features[1]," "]}),(0,a.jsxs)("div",{children:[null===e||void 0===e?void 0:e.features[2]," "]})]})]},e.job_type_id)))})]})})}),U.length>0&&(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)("div",{className:"mt-5 flex flex-col w-full",children:[(0,a.jsxs)("div",{className:"flex flex-row items-center gap-x-2 cursor-pointer w-full mb-4",onClick:()=>ut(!dt),children:[dt?(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-4 w-4",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m19.5 8.25-7.5 7.5-7.5-7.5"})}):(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-4 w-4",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m8.25 4.5 7.5 7.5-7.5 7.5"})}),(0,a.jsx)("h3",{className:"text-sm font-semibold relative",children:"Audio History"}),(0,a.jsx)("div",{className:"flex-grow border-t border-black"})]}),dt&&(0,a.jsx)("div",{className:"mt-3 flex flex-col p-1",children:U.map(((e,t)=>{var s,o;return(0,a.jsxs)("div",{layoutId:"portion-media-".concat(t),className:"relative overflow-hidden bg-white flex flex-col items-start justify-start h-24 p-4 ".concat(t>0?"mt-4":""," w-full mx-auto rounded-md border border-1 ").concat(e.isActive?"border-cerise-red-400 shadow-cerise-red-400/60 shadow-sm":"shadow-sm border-cerise-red-100 shadow-cerise-red-100"),children:[(0,a.jsxs)("div",{className:"flex justify-between w-full items-center gap-4",children:[(0,a.jsx)("p",{className:"text-base text-neutral-700 truncate max-w-xs",children:e.media_id}
1),(0,a.jsx)("p",{className:"rounded-lg px-2 py-1 w-fit flex-shrink-0 text-sm text-neutral-600 border border-1 ".concat(e.isActive?"border-cerise-red-500 ":""),children:(o=e.size,o<1024?o+" B":o<1048576?(o/1024).toFixed(1)+" KB":o<1073741824?(o/1048576).toFixed(1)+" MB":(o/1073741824).toFixed(1)+" GB")})]}),(0,a.jsxs)("div",{className:"flex text-sm flex-row items-center w-full mt-2 justify-between text-neutral-600",children:[(0,a.jsxs)("div",{className:"flex flex-row items-center gap-x-2",children:[(0,a.jsx)("p",{className:"px-1 py-0.5 rounded-md bg-gray-100",children:"audio/MP3"}),e.isActive&&(0,a.jsx)("p",{className:"px-1 py-0.5 rounded-md bg-cerise-red-500 text-white",children:"active"}),"FFMPEG"===(null===(s=e.metadata)||void 0===s?void 0:s.source)&&(0,a.jsx)("p",{className:"px-1 py-0.5 rounded-md bg-tan-hide-100 text-tan-hide-700",children:"source audio"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{onClick:()=>{return t=e.signed_url,b(t),k(!0),void(Z&&(es(2),P(!1)));var t},className:"hover:text-cerise-red-500",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-4 w-4",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5.25 5.653c0-.856.917-1.398 1.667-.986l11.54 6.347a1.125 1.125 0 0 1 0 1.972l-11.54 6.347a1.125 1.125 0 0 1-1.667-.986V5.653Z"})})}),!e.isActive&&(0,a.jsx)("button",{onClick:()=>(async e=>{if(S&&f&&S.portion_id&&g)if(S.audio.media_id!==e)try{const t=await c.Z.put("/shots/".concat(f,"/tracks/").concat(C,"/portions/").concat(S.portion_id),{audio_id:e});if(200===t.status){console.log("Active audio updated successfully");const e=t.data.shot_editor_json,s=e.tracks.find((e=>"translated"===e.type))||e.tracks.find((e=>"basic"===e.type));if(!s)return void console.error("No suitable track found");const a=s.portions.find((e=>e.portion_id===S.portion_id));if(!a)return void console.error("Updated portion not found");_(a),R((e=>e.map((e=>({...e,isActive:e.media_id===a.audio.media_id})))))}else console.error("Failed to update active audio")}catch(t){console.error("Error updating active audio:",t)}else console.log("This audio is already active");else console.error("Missing required data for updating active audio")})(e.media_id),className:"hover:text-cerise-red-500",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-4 w-4",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7.5 21 3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5"})})})]})]})]},t)}))})]})}),(0,a.jsx)("div",{className:"flex flex-row items-center gap-x-2 mt-4",children:et&&Yt?(0,a.jsxs)(ue.J2,{onOpenChange:e=>{e||_s||(Hs(!1),Gs(!1))},children:[(0,a.jsx)(ue.xo,{asChild:!0,children:(0,a.jsx)(D.z,{ref:Xe,disabled:Os||Ws,className:" w-full bg-cerise-red-500 hover:bg-cerise-red-600",onClick:()=>{Ys(),Gs(!0)},children:Ws?(0,a.jsx)(J.Spinner,{className:"w-5 h-5"}):"Generate Audio"})}),(0,a.jsxs)(ue.yk,{style:{width:Wt},side:"bottom",className:"w-full z-50 ",children:[(0,a.jsx)("div",{className:"font-medium",children:"Confirm Request"}),Vs?(0,a.jsxs)("div",{className:"mt-3 flex flex-col w-full p-auto items-center justify-center",children:[(0,a.jsx)(J.Spinner,{}),(0,a.jsx)(D.z,{type:"submit",variant:"outline",disabled:!0,className:"mt-3 w-full",children:"Confirm & Generate Audio"})]}):(0,a.jsxs)("div",{className:"flex flex-col mt-3",children:[(0,a.jsx)("div",{className:"flex justify-between",children:(0,a.jsxs)("div",{children:["Are you sure you want to generate audio for ",(0,a.jsx)("span",{className:"font-bold",children:et?"Actor ".concat(r.findIndex((e=>e.actor_id===et.actor_id))+1||1):"Select Actor"}),"? Doing so will cost ",(0,a.jsx)("span",{className:"font-bold",children:Is})," credits."]})}),(0,a.jsx)(K.xp,{asChild:!0,children:(0,a.jsx)(D.z,{onClick:()=>{Ks(Ps)},type:"submit",variant:"outline",className:"mt-3 w-full",children:"Confirm & Generate Audio"})})]})]})]}):(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(D.z,{ref:Xe,disabled:Os||Ws,className:" w-full bg-cerise-red-500 hover:bg-cerise-red-600",onClick:()=>{Ys(),Gs(!0)},children:Ws?(0,a.jsx)(J.Spinner,{className:"w-5 h-5"}):"Generate Audio"})})})]}):(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center h-full",children:[(0,a.jsx)("div",{className:"flex items-center justify-center rounded-lg p-3",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-8 h-8 text-red-600",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.25 9.75 19.5 12m0 0 2.25 2.25M19.5 12l2.25-2.25M19.5 12l-2.25 2.25m-10.5-6 4.72-4.72a.75.75 0 0 1 1.28.53v15.88a.75.75 0 0 1-1.28.53l-4.72-4.72H4.51c-.88 0-1.704-.507-1.938-1.354A9.009 9.009 0 0 1 2.25 12c0-.83.112-1.633.322-2.396C2.806 8.756 3.63 8.25 4.51 8.25H6.75Z"})})}),(0,a.jsx)("p",{className:"font-medium",children:"No media detected."}),(0,a.jsx)("p",{className:"text-sm",children:"Audio that is generated for this portion will appear here."})]})}):"original"===e.value?(0,a.jsxs)(a.Fragment,{children:[e.signedUrl?(0,a.jsx)("div",{className:"w-full",children:(0,a.jsx)(ae,{color:"white",preload:!1,ref:Y,vidUrl:e.signedUrl,processedVideoUrl:e.signedUrl,onTimeUpdate:ts,isAudioPlaying:as,playbackRate:ns,audioOffset:(null===S||void 0===S||null===(s=S.audio)||void 0===s?void 0:s.offset)||0,onVideoLoaded:ls,pauseVideo:0!==X})}):(0,a.jsx)("div",{className:"relative w-full aspect-video border border-1 rounded-lg flex items-center justify-center",children:(0,a.jsxs)("div",{className:"flex flex-col gap-y-2 items-center justify-cemter",children:[(0,a.jsx)(J.Spinner,{className:"w-5 h-5"}),(0,a.jsx)("span",{className:"text-sm",children:"Fetching your video..."})]})}),(0,a.jsxs)("div",{className:"mt-5 flex w-full flex-row gap-x-2",children:[(0,a.jsxs)(ue.J2,{onOpenChange:e=>{e||ks||(ys(!1),ps(!1))},children:[(0,a.jsx)(ue.xo,{asChild:!0,children:(0,a.jsx)(D.z,{ref:Xe,disabled:js||mt,variant:"outline",onClick:()=>{(async()=>{let e;ys(!0),Ss(!1),hs(null),c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(m),console.log("selected ls model is ",L);const t=g.find((e=>"basic"===e.type)),s=g.find((e=>"translated"===e.type));if(s)e=s;else{if(!t)return console.error("No suitable track found"),d.A.error("No suitable track found for lip sync"),ps(!1),void ys(!1);e=t}try{const t=await c.Z.post("/tasks",{name:"lip-sync-text-shot",data:{shot_id:f,lsd_model:L,track_id:e.id}});Date.now(),console.log("Audio generation response:",t.data),hs(t.data.credits),Ns(t.data.id),ps(!1)}catch(a){console.error("Error creating job:",a),d.A.error("Error creating job"),ps(!1),ys(!1)}})(),ps(!0)},className:" text-white w-full bg-cerise-red-500 hover:bg-cerise-red-600",children:"Generate Video"})}),(0,a.jsxs)(ue.yk,{style:{width:Wt},side:"bottom",className:"w-full z-50 ",children:[(0,a.jsx)("div",{className:"font-medium",children:"Confirm Request"}),xs?(0,a.jsxs)("div",{className:"mt-3 flex flex-col w-full p-auto items-center justify-center",children:[(0,a.jsx)(J.Spinner,{}),(0,a.jsx)(D.z,{type:"submit",variant:"outline",disabled:!0,className:"mt-3 w-full",children:"Confirm & Generate Video"})]}):(0,a.jsxs)("div",{className:"flex flex-col mt-3",children:[(0,a.jsx)("div",{className:"flex justify-between",children:(0,a.jsxs)("div",{children:["Are you sure you want to lip sync this video? Doing so will cost ",(0,a.jsx)("span",{className:"font-bold",children:ms})," credits."]})}),(0,a.jsx)(K.xp,{asChild:!0,children:(0,a.jsx)(D.z,{onClick:()=>(async(e,t)=>{try{c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(m);const s=await c.Z.post("/tasks/".concat(e,"/submit"));console.log("Lip Sync task submitted:",s.data);const a=Date.now();yt((s=>[...s,{taskId:e,timestamp:(new Date).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),startTimeMs:a,credits:t,status:"pending"}])),Rt((t=>({...t,[e]:a}))),_e(!0),await Fs(bs,a),Ss(!0),he(!0)}catch(a){var s;402===(null===(s=a.response)||void 0===s?void 0:s.status)?d.A.error(a.response.data.message||"Insufficient credits. Wait for your subscription to renew or upgrade your plan to continue."):d.A.error("Error submitting lip sync task. If you have continued issues, join our discord or shoot us an email for assistance.")}})(bs,ms),type:"submit",variant:"outline",className:"mt-3 w-full",children:"Confirm & Generate Video"})})]})]})]}),(0,a.jsx)(D.z,{onClick:()=>ct(!0),variant:"outline",className:"text-gray-700 px-3",children:(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-5 h-5",children:[(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.
1074.04.147.083.22.127.325.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 0 1 1.37.49l1.296 2.247a1.125 1.125 0 0 1-.26 1.431l-1.003.827c-.293.241-.438.613-.43.992a7.723 7.723 0 0 1 0 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.955.26 1.43l-1.298 2.247a1.125 1.125 0 0 1-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 0 1-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.94-1.11.94h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 0 1-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 0 1-1.369-.49l-1.297-2.247a1.125 1.125 0 0 1 .26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 0 1 0-.255c.007-.38-.138-.751-.43-.992l-1.004-.827a1.125 1.125 0 0 1-.26-1.43l1.297-2.247a1.125 1.125 0 0 1 1.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.28Z"}),(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})]})})]}),(0,a.jsxs)("div",{className:"mt-1 w-full flex flex-row justify-between px-1",children:[(0,a.jsx)("span",{className:"text-gray-400 text-xs",children:"Selected Model:"}),(0,a.jsx)("span",{className:"text-gray-400 text-xs",children:L})]}),jt.length>0&&(0,a.jsx)("div",{className:"mt-auto pt-4 pb-4 px-2",children:(0,a.jsx)("div",{className:"w-full",children:(0,a.jsx)("button",{onClick:()=>_e(!0),className:"w-full animate-buttonheartbeat rounded-lg border bg-cerise-red-500 border-cerise-red-500 px-8 py-2 text-sm font-medium text-white",children:"View In Progress Generations"})})})]}):"generated"===e.value?(0,a.jsxs)(a.Fragment,{children:[e.signedUrl&&!M?(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{className:"w-full overflow-x-hidden",children:(0,a.jsx)(Me,{color:"white",preload:!1,ref:wt,vidUrl:e.signedUrl,processedVideoUrl:e.signedUrl,mediaId:e.media_id,token:m,shotId:f})})}):(0,a.jsx)("div",{className:"relative w-full aspect-video border border-1 rounded-lg flex items-center justify-center",children:(0,a.jsxs)("div",{className:"flex flex-col gap-y-2 items-center justify-cemter",children:[(0,a.jsx)(J.Spinner,{className:"w-5 h-5"}),(0,a.jsx)("span",{className:"text-sm",children:M?"Generating your video...":"Fetching your generation..."})]})}),(0,a.jsxs)(je.yo,{open:Se,onOpenChange:_e,children:[(0,a.jsx)(je.aM,{asChild:!0,children:(0,a.jsxs)(D.z,{className:"mt-5 w-full bg-cerise-red-500 hover:bg-cerise-red-600 flex flex-row items-center justify-center gap-x-2",children:[(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:"w-4 h-4",children:[(0,a.jsx)("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,a.jsx)("path",{d:"M3 3v5h5"}),(0,a.jsx)("path",{d:"M12 7v5l4 2"})]}),"View All Generations"]})}),(0,a.jsxs)(je.ue,{side:"left",className:"w-3/4 sm:max-w-md",children:[(0,a.jsxs)(je.Tu,{children:[(0,a.jsx)(je.bC,{className:"font-Avantt",children:"Shot Generation History"}),(0,a.jsx)(je.Ei,{className:"font-Avantt",children:"View ongoing and past generations for your shot."})]}),(0,a.jsx)("div",{className:"mt-6 space-y-6 overflow-y-auto h-[calc(100vh-200px)]",children:0===jt.length&&0===bt.length?(0,a.jsxs)("div",{className:"flex flex-col flex-grow items-center justify-center h-full text-center text-black",children:[(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",className:"h-12 w-12 mb-2",children:(0,a.jsx)("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m15.75 10.5 4.72-4.72a.75.75 0 0 1 1.28.53v11.38a.75.75 0 0 1-1.28.53l-4.72-4.72M12 18.75H4.5a2.25 2.25 0 0 1-2.25-2.25V9m12.841 9.091L16.5 19.5m-1.409-1.409c.407-.407.659-.97.659-1.591v-9a2.25 2.25 0 0 0-2.25-2.25h-9c-.621 0-1.184.252-1.591.659m12.182 12.182L2.909 5.909M1.5 4.5l1.409 1.409"})}),(0,a.jsx)("p",{className:"text-sm",children:"No generations found"}),(0,a.jsx)("p",{className:"text-xs mt-1",children:"Past and ongoing generations will appear here."})]}):(0,a.jsxs)(a.Fragment,{children:[jt.length>0&&(0,a.jsx)("div",{className:"flex flex-row items-center gap-x-1 hover:text-gray-700",children:(0,a.jsx)("span",{className:"text-base font-Avantt font-bold",children:"Ongoing Generations"})}),jt.map(((e,t)=>(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)("div",{className:"relative group rounded-lg flex border hover:shadow-md border-1 border-gray-300 p-3 flex-row gap-x-2 items-start justify-start",children:[(0,a.jsx)("div",{className:"aspect-video w-2/5 relative bg-gray-100 rounded-lg flex items-center justify-center",children:(0,a.jsx)(J.Spinner,{className:"w-8 h-8"})}),(0,a.jsxs)("div",{className:"flex flex-col items-start justify-start w-full",children:[(0,a.jsx)("div",{className:"flex flex-col items-center justify-center font-Avantt",children:(0,a.jsxs)("span",{className:"text-sm whitespace-nowrap overflow-hidden text-ellipsis max-w-[220px]",children:[(0,a.jsx)("span",{className:"font-bold",children:"Task ID: "}),e.taskId]})}),(0,a.jsxs)("div",{className:"flex flex-row items-center gap-x-2 w-full",children:[(0,a.jsxs)("span",{className:"text-sm whitespace-nowrap font-Avantt overflow-hidden text-ellipsis",children:[(0,a.jsx)("span",{className:"font-bold",children:"Started: "}),e.timestamp]}),e.startTimeMs&&(0,a.jsxs)("span",{className:"text-sm font-Avantt ",children:[(0,a.jsx)("span",{className:"font-bold",children:"Elapsed: "}),Vt(e.startTimeMs)]})]}),(0,a.jsx)("div",{className:"flex flex-col items-start justify-start",children:(0,a.jsxs)("span",{className:"text-sm whitespace-nowrap font-Avantt overflow-hidden text-ellipsis max-w-[200px]",children:[(0,a.jsx)("span",{className:"font-bold",children:"Credits: "}),e.credits]})})]})]},e.taskId)}))),(0,a.jsxs)("div",{className:"flex flex-row items-center justify-between",children:[(0,a.jsx)("div",{className:"flex flex-row items-center gap-x-1 hover:text-gray-700",children:(0,a.jsx)("span",{className:"text-base font-Avantt font-bold",children:"Past Generations"})}),(0,a.jsxs)("button",{onClick:Ot,className:"flex flex-row items-center gap-x-1 hover:text-gray-700",children:[(0,a.jsx)("span",{className:"text-base font-Avantt font-bold",children:"Date"}),"desc"===Ve?(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m19.5 8.25-7.5 7.5-7.5-7.5"})}):(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m4.5 15.75 7.5-7.5 7.5 7.5"})})]})]}),[...bt].sort(((e,t)=>{var s,a;const o=new Date((null===(s=e.taskInfo)||void 0===s?void 0:s.timestamp)||0),n=new Date((null===(a=t.taskInfo)||void 0===a?void 0:a.timestamp)||0);return"desc"===Ve?n-o:o-n})).map(((e,t)=>{var s,o;return(0,a.jsxs)("div",{onClick:()=>{Ct({media_id:e.media_id,signed_url:e.signed_url}),St(!0)},onMouseEnter:()=>Gt(t,!0),onMouseLeave:()=>Gt(t,!1),className:"relative group rounded-lg flex border hover:shadow-md border-1 border-gray-300 p-3 flex-row gap-x-2 items-start justify-start cursor-pointer",children:[(0,a.jsx)("div",{className:"aspect-video w-2/5 relative",children:(0,a.jsx)("video",{ref:e=>vt.current[t]=e,src:e.signed_url,className:"w-full h-full object-cover rounded-lg",muted:!0,loop:!0,playsInl
1ine:!0})}),(0,a.jsxs)("div",{className:"flex flex-col items-start justify-start w-full",children:[(0,a.jsx)("div",{className:"flex flex-col items-center justify-center font-Avantt",children:(0,a.jsxs)("span",{className:"text-sm whitespace-nowrap overflow-hidden text-ellipsis max-w-[220px]",children:[(0,a.jsx)("span",{className:"font-bold",children:"Lip Sync ID: "}),e.media_id]})}),(0,a.jsx)("div",{className:"flex flex-col items-start justify-start",children:(0,a.jsxs)("span",{className:"text-sm whitespace-nowrap font-Avantt overflow-hidden text-ellipsis max-w-[200px]",children:[(0,a.jsx)("span",{className:"font-bold",children:"Generated: "}),(null===e||void 0===e||null===(s=e.taskInfo)||void 0===s?void 0:s.timestamp)||"Unknown"]})}),(0,a.jsx)("div",{className:"flex flex-col items-start justify-start",children:(0,a.jsxs)("span",{className:"text-sm whitespace-nowrap font-Avantt overflow-hidden text-ellipsis max-w-[200px]",children:[(0,a.jsx)("span",{className:"font-bold",children:"Credits: "}),(null===e||void 0===e||null===(o=e.taskInfo)||void 0===o?void 0:o.credits)||"Unknown"]})})]}),(0,a.jsx)("div",{className:"flex flex-col items-center justify-center",children:(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-4 w-4",children:[(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z"}),(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})]})})]},t)}))]})}),(0,a.jsx)(je.FF,{})]})]})]}):null},e.value)}))})]}),(0,a.jsx)(De,{showGenerationDialog:de,setShowGenerationDialog:me}),(0,a.jsx)(pe,{showActorSettings:n,setShowActorSettings:l,index:Je,onClose:()=>{l(!1),x(null),v()},token:m,actors:r,shotId:f,onPortionChange:v,tracks:g,shouldSwitchBackToMain:ie,setShouldSwitchBackToMain:le,setActiveTab:ee,activeActorSettingsId:h}),(0,a.jsx)(we,{showDeleteActorDialog:ot,setShowDeleteActorDialog:nt,deleteActor:async e=>{if(f&&e)try{c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(m);200===(await c.Z.delete("/shots/".concat(f,"/actors/").concat(e))).status?(console.log("Actor deleted successfully"),u((t=>t.filter((t=>t.actor_id!==e)))),cs(r.length),v()):console.error("Failed to delete actor")}catch(t){console.error("Error deleting actor:",t)}else console.error("Missing required data for deletion")},idx:Je,actors:r}),(0,a.jsx)(ve,{audioRef:Q,audioUrl:y,showPopup:N,setShowPopup:k,portion:S,onTimeUpdate:e=>{var t,s;if(0===X&&(null===(t=Y.current)||void 0===t?void 0:t.offsetParent)&&(null===S||void 0===S||null===(s=S.audio)||void 0===s?void 0:s.offset)){const t=S.audio.offset+e,s=Math.min(Math.max(t,0),xt);ss(s)}},onPlayStateChange:(e,t)=>
1{var s;if(os(e),is(t),e&&Y.current&&void 0!==(null===S||void 0===S||null===(s=S.audio)||void 0===s?void 0:s.offset)&&0===X&&Y.current.offsetParent){var a;const e=(null===(a=Q.current)||void 0===a?void 0:a.currentTime)||0,t=S.audio.offset+e;isFinite(t)&&t>=0&&t<=xt&&(Y.current.currentTime=t)}},audioName:E}),(0,a.jsx)(Be.Z,{showRenameActorDialog:Te,setShowRenameActorDialog:ze,actors:r,selectedActorIndex:Je,handleRenameActor:async(e,t)=>{try{200===(await c.Z.put("/shots/".concat(f,"/actors/").concat(r[e].actor_id),{name:t})).status?await v():d.A.error("Failed to rename actor")}catch(s){console.error("Error renaming actor:",s),d.A.error("Failed to rename actor")}}}),(0,a.jsx)(ye.Z,{showModelSelection:rt,setShowModelSelection:ct,setSelectedModel:A,selectedModel:L,shotId:f,token:m}),(0,a.jsx)(Ee.Z,{showPastGenerationPlayerDialog:kt,setShowPastGenerationPlayerDialog:St,videoUrl:_t,token:m,shotId:f},null===_t||void 0===_t?void 0:_t.media_id),(0,a.jsx)(Ie,{showActorMergingDialog:ge,setShowActorMergingDialog:be,actors:r,token:m,shotId:f,onPortionChange:v}),(0,a.jsx)(Ze,{showAudioModelSelection:xe,setShowAudioModelSelection:fe,token:m})]})};const Ge=[{name:"Eleven Multilingual v2",type:"Text-to-Speech",description:"Description of model 1",model_id:"eleven_multilingual_v2",cost:50,similarity_and_stability:!0,supported_langs:["English","Spanish","French","German","Italian","Portuguese","Russian","Japanese","Chinese","Korean"],recommended:!0,tag:"Best Quality",tag_variant:"brand"},{name:"Fish Audio",type:"Text-to-Speech",description:"Description of model 1",model_id:"fishspeech-tts-1.3",cost:100,similarity_and_stability:!1,supported_langs:["English","Spanish","French","German","Italian","Portuguese","Russian","Japanese","Chinese","Korean"],recommended:!1,tag:"Best Price",tag_variant:"default"},{name:"LLSOUL",description:"Description of model 1",type:"Text-to-Speech",model_id:"llsoul-tts",cost:150,similarity_and_stability:!1,supported_langs:["English","Spanish","French","German","Italian","Portuguese","Russian","Japanese","Chinese","Korean"],recommended:!1,tag:"Korean Only",tag_variant:"easy",supported_langs_count:1}];var Oe=e=>{let{showAudioGenerationSettings:t,setShowAudioGenerationSettings:s}=e;const[o,n]=(0,i.useState)(!1),[l,r]=(0,i.useState)("eleven_multilingual_v2"),[c,d]=(0,i.useState)(0),[u,m]=(0,i.useState)(0),[h,x]=(0,i.useState)(0),[p,f]=(0,i.useState)(!1),[g,v]=(0,i.useState)(!1),[w,j]=(0,i.useState)(!1),[y,b]=(0,i.useState)(!1),[N,k]=(0,i.useState)(!1),[S,_]=(0,i.useState)(!1);return(0,i.useEffect)((()=>{v("eleven_multilingual_v2"!==l&&"eleven_multilingual_sts_v2"!==l)}),[l]),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(M.u,{appear:!0,show:t,as:i.Fragment,children:(0,a.jsxs)(z.Vq,{as:"div",className:"relative z-[70]",onClose:()=>s(!1),children:[(0,a.jsx)(M.x,{as:i.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{className:"fixed inset-0 bg-black/25"})}),(0,a.jsx)("div",{className:"fixed inset-0 overflow-y-auto ",children:(0,a.jsx)("div",{className:"flex min-h-full items-center justify-center p-4 text-center",children:(0,a.jsx)(M.x,{as:"div",enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:(0,a.jsxs)(z.EM,{className:"dialog-panel-3 w-full transform overflow-hidden rounded-lg bg-white text-left align-middle shadow-xl transition-all flex flex-col",children:[(0,a.jsxs)("div",{className:"flex flex-col flex-grow",children:[(0,a.jsx)(z.$N,{as:"h3",className:"pl-6 pr-6 pt-6 text-lg font-medium leading-6",children:"Audio Generation Settings"}),o?(0,a.jsxs)("div",{className:"flex flex-col pl-6 pr-6 pt-6 pb-8 h-full",children:[(0,a.jsx)(ne.__,{children:"Audio Generation Model"}),(0,a.jsxs)("div",{className:"flex flex-row gap-x-4 mt-3",children:[(0,a.jsx)(ze.Z,{className:"rounded-lg",variant:"rectangular",width:220,height:175,animation:"wave"}),(0,a.jsx)(ze.Z,{className:"rounded-lg",variant:"rectangular",width:220,height:175,animation:"wave"}),(0,a.jsx)(ze.Z,{className:"rounded-lg",variant:"rectangular",width:220,height:175,animation:"wave"})]}),(0,a.jsxs)("div",{className:"mt-9",children:[(0,a.jsx)(ne.__,{className:"text-base",children:"Voice Settings"}),(0,a.jsx)("div",{className:"w-full mt-7",children:(0,a.jsx)(ze.Z,{className:"rounded-lg w-full",variant:"rectangular",height:40,animation:"wave"})}),(0,a.jsx)("div",{className:"w-full mt-8",children:(0,a.jsx)(ze.Z,{className:"rounded-lg w-full",variant:"rectangular",height:40,animation:"wave"})}),(0,a.jsx)("div",{className:"w-full mt-8",children:(0,a.jsx)(ze.Z,{className:"rounded-lg w-full",variant:"rectangular",height:40,animation:"wave"})}),(0,a.jsx)("div",{className:"w-full mt-8 mb-5.5",children:(0,a.jsx)(ze.Z,{className:"rounded-lg w-1/4",variant:"rectangular",height:35,animation:"wave"})})]})]}):(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)("div",{className:"flex flex-col p-6",children:[(0,a.jsx)(ne.__,{children:"Audio Generation Model"}),(0,a.jsx)("div",{className:"flex flex-row gap-x-4 mt-3",children:Ge.map((e=>(0,a.jsxs)("button",{style:{borderColor:l===e.model_id?"#e63c6c":"rgb(205, 213, 223)"},className:"_16uipyo text-left hover:bg-gray-100/40 ".concat(e.name?"":"disabled"," flex-1 min-w-[150px] max-w-[220px]"),type:"button",onClick:()=>{r(e.model_id)},children:[(0,a.jsxs)("div",{class:"flex justify-between w-full",children:[(0,a.jsx)(F.C,{variant:e.tag_variant,children:e.tag}),(0,a.jsx)("div",{className:"flex-center w-[22px] h-[22px] rounded-full border border-solid flex justify-center items-center",style:{borderColor:l===e.model_id?"#e63c6c":"rgb(205, 213, 223)",backgroundColor:l===e.model_id?"#e63c6c":"transparent"},children:l===e.model_id&&(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"2",stroke:"#fff",className:"w-4 h-4",children:(0,a.jsx)("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 12.75l6 6 9-13.5"})})})]}),(0,a.jsx)("div",{class:"text-gray-700 font-semibold mt-4",children:e.name}),(0,a.jsxs)("div",{class:"text-sm font-medium text-gray-600 mt-2 flex flex-col gap-1",children:[e.type,(0,a.jsxs)("div",{children:[e.supported_langs_count," ",e.supp
1orted_langs_count<2?"Language":"Languages"]}),(0,a.jsxs)("div",{class:"-mr-1",children:[e.cost," credits per min"]})]})]})))}),(0,a.jsxs)("div",{className:"mt-5 ".concat(g?"opacity-50 pointer-events-none":""),children:[(0,a.jsx)(ne.__,{className:"text-base",children:"Voice Settings"}),(0,a.jsxs)("div",{className:"w-full flex flex-col mt-6",children:[(0,a.jsx)(ne.__,{children:"Stability"}),(0,a.jsxs)("div",{className:"w-full flex flex-row text-good-gray-100 text-xs justify-between mt-1",children:[(0,a.jsx)(Y.zt,{children:(0,a.jsxs)(Y.fC,{children:[(0,a.jsx)(Y.xz,{asChild:!0,children:(0,a.jsx)("div",{children:"More Variable"})}),(0,a.jsx)(Y.h_,{children:(0,a.jsx)(Y.VY,{className:"TooltipContent2 z-20",children:(0,a.jsx)("p",{className:"font-medium",children:"Increasing variability can make speech more expressive with output varying between re-generations. It can also lead to instabilities."})})})]})}),(0,a.jsx)(Y.zt,{children:(0,a.jsxs)(Y.fC,{children:[(0,a.jsx)(Y.xz,{asChild:!0,children:(0,a.jsx)("div",{children:"More Stable"})}),(0,a.jsx)(Y.h_,{children:(0,a.jsx)(Y.VY,{className:"TooltipContent2 z-20",children:(0,a.jsx)("p",{className:"font-medium",children:"Increasing stability will make the voice more consistent between re-generations, but it can also make it sound a bit monotone. On longer text fragments we recommend lowering this value."})})})]})})]}),(0,a.jsxs)("div",{className:"w-full mt-1",children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(P.i,{defaultValue:[c],max:100,step:1,value:[c],disabled:g,onValueChange:e=>d(e[0]),onPointerDown:()=>j(!0),onPointerUp:()=>j(!1)}),w&&(0,a.jsxs)("div",{className:"absolute top-[-35px] left-1/2 transform -translate-x-1/2 bg-black text-white px-1.5 py-1 rounded rounded-lg font-medium text-xs",style:{left:"calc(".concat(c,"% + (").concat(8-.16*c,"px))")},children:[c,"%"]})]})," "]})]}),(0,a.jsxs)("div",{className:"w-full flex flex-col mt-6",children:[(0,a.jsx)(ne.__,{children:"Similarity"}),(0,a.jsxs)("div",{className:"w-full flex flex-row text-good-gray-100 text-xs justify-between mt-1",children:[(0,a.jsx)(Y.zt,{children:(0,a.jsxs)(Y.fC,{children:[(0,a.jsx)(Y.xz,{asChild:!0,children:(0,a.jsx)("div",{children:"Low"})}),(0,a.jsx)(Y.h_,{children:(0,a.jsx)(Y.VY,{className:"TooltipContent2 z-20",children:(0,a.jsx)("p",{className:"font-medium",children:"Low values are recommended if background artifacts are present in generated speech."})})})]})}),(0,a.jsx)(Y.zt,{children:(0,a.jsxs)(Y.fC,{children:[(0,a.jsx)(Y.xz,{asChild:!0,children:(0,a.jsx)("div",{children:"High"})}),(0,a.jsx)(Y.h_,{children:(0,a.jsx)(Y.VY,{className:"TooltipContent2 z-20",children:(0,a.jsx)("p",{className:"font-medium",children:"High enhancement boosts overall voice clarity and target speaker similarity. Very high values can cause artifacts, so adjusting this setting to find the optimal value is encouraged."})})})]})})]}),(0,a.jsx)("div",{className:"w-full mt-1",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(P.i,{defaultValue:[u],max:100,step:1,value:[u],disabled:g,onValueChange:e=>m(e[0]),onPointerDown:()=>b(!0),onPointerUp:()=>b(!1)}),y&&(0,a.jsxs)("div",{className:"absolute top-[-35px] left-1/2 transform -translate-x-1/2 bg-black text-white px-1.5 py-1 rounded rounded-lg font-medium text-xs",style:{left:"calc(".concat(u,"% + (").concat(8-.16*u,"px))")},children:[u,"%"]})]})})]}),(0,a.jsxs)("div",{className:"w-full flex flex-col mt-6",children:[(0,a.jsx)(ne.__,{children:"Style Exaggeration"}),(0,a.jsxs)("div",{className:"w-full flex flex-row text-good-gray-100 text-xs justify-between mt-1",children:[(0,a.jsx)("div",{children:"None"}),(0,a.jsx)(Y.zt,{children:(0,a.jsxs)(Y.fC,{children:[(0,a.jsx)(Y.xz,{asChild:!0,children:(0,a.jsx)("div",{children:"Exaggerated"})}),(0,a.jsx)(Y.h_,{children:(0,a.jsx)(Y.VY,{className:"TooltipContent2 z-20",children:(0,a.jsx)("p",{className:"font-medium",children:"High values are recommended if the style of the speech should be exaggerated compared to the uploaded audio. Higher values can lead to more instability in the generated speech. Setting this to 0.0 will greatly increase generation speed and is the deafult setting."})})})]})})]}),(0,a.jsx)("div",{className:"w-full mt-1",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(P.i,{defaultValue:[h],max:100,step:1,disabled:g,value:[h],onValueChange:e=>x(e[0]),onPointerDown:()=>k(!0),onPointerUp:()=>k(!1)}),N&&(0,a.jsxs)("div",{className:"absolute top-[-35px] left-1/2 transform -translate-x-1/2 bg-black text-white px-1.5 py-1 rounded rounded-lg font-medium text-xs",style:{left:"calc(".concat(h,"% + (").concat(8-.16*h,"px))")},children:[h,"%"]})]})})]}),(0,a.jsxs)("div",{className:"w-full flex flex-row justify-between mt-8",children:[(0,a.jsx)("div",{className:" items-center flex space-x-2",children:(0,a.jsx)(Y.zt,{children:(0,a.jsxs)(Y.fC,{children:[(0,a.jsx)(Y.xz,{asChild:!0,children:(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(Z.r,{value:p,disabled:g,onCheckedChange:e=>f(e)}),(0,a.jsx)(ne.__,{htmlFor:"speaker-boost",children:"Speaker Boost"})]})}),(0,a.jsx)(Y.h_,{children:(0,a.jsx)(Y.VY,{className:"TooltipContent2 z-2
10",children:(0,a.jsx)("p",{className:"font-medium",children:"Boost the similarity of the synthesized speech and the voice at the cost of some generation speed."})})})]})})}),(0,a.jsx)("div",{onClick:()=>resetToDefaults(),className:"flex underline text-sm cursor-pointer font-medium",children:"Reset to Defaults"})]})]})]})})]}),(0,a.jsx)("div",{className:"p-6 w-full justify-start items-start flex"}),(0,a.jsxs)("div",{className:"flex w-full items-center justify-between gap-x-3 p-6 bg-gray-100",children:[(0,a.jsxs)("div",{className:"w-full items-center flex space-x-2",children:[(0,a.jsx)(Z.r,{value:S,onCheckedChange:e=>_(e)}),(0,a.jsx)(ne.__,{htmlFor:"airplane-mode",children:"Set As Global Default"})]}),(0,a.jsxs)("div",{className:"w-full flex gap-x-3 justify-end",children:[(0,a.jsx)(D.z,{variant:"outline",className:"shadow shadow-sm bg-white",onClick:()=>s(!1),children:"Cancel"}),(0,a.jsx)(D.z,{onClick:()=>s(!1),children:"Save"})]})]})]})})})})]})})})},He=s(31012),We=s(41352),qe=s(16050);const Ye=[{id:"af",name:"Afrikaans",code:"af",countryCode:"za"},{id:"ar",name:"Arabic",code:"ar",countryCode:"sa"},{id:"az",name:"Azerbaijani",code:"az",countryCode:"az"},{id:"be",name:"Belarusian",code:"be",countryCode:"by"},{id:"bg",name:"Bulgarian",code:"bg",countryCode:"bg"},{id:"bs",name:"Bosnian",code:"bs",countryCode:"ba"},{id:"ca",name:"Catalan",code:"ca",countryCode:"ad"},{id:"cs",name:"Czech",code:"cs",countryCode:"cz"},{id:"cy",name:"Welsh",code:"cy",countryCode:"gb-wls"},{id:"da",name:"Danish",code:"da",countryCode:"dk"},{id:"de",name:"German",code:"de",countryCode:"de"},{id:"el",name:"Greek",code:"el",countryCode:"gr"},{id:"en",name:"English",code:"en",countryCode:"gb"},{id:"en-gb",name:"English (British)",code:"en-gb",countryCode:"gb"},{id:"en-us",name:"English (American)",code:"en-us",countryCode:"us"},{id:"en/es",name:"English/Spanish",code:"en/es",countryCode:"us"},{id:"es",name:"Spanish",code:"es",countryCode:"es"},{id:"et",name:"Estonian",code:"et",countryCode:"ee"},{id:"fa",name:"Farsi",code:"fa",countryCode:"ir"},{id:"fi",name:"Finnish",code:"fi",countryCode:"fi"},{id:"fr",name:"French",code:"fr",countryCode:"fr"},{id:"gl",name:"Galician",code:"gl",countryCode:"es"},{id:"he",name:"Hebrew",code:"he",countryCode:"il"},{id:"hi",name:"Hindi",code:"hi",countryCode:"in"},{id:"hr",name:"Croatian",code:"hr",countryCode:"hr"},{id:"hu",name:"Hungarian",code:"hu",countryCode:"hu"},{id:"hy",name:"Armenian",code:"hy",countryCode:"am"},{id:"id",name:"Indonesian",code:"id",countryCode:"id"},{id:"is",name:"Icelandic",code:"is",countryCode:"is"},{id:"it",name:"Italian",code:"it",countryCode:"it"},{id:"ja",name:"Japanese",code:"ja",countryCode:"jp"},{id:"kk",name:"Kazakh",code:"kk",countryCode:"kz"},{id:"kn",name:"Kannada",code:"kn",countryCode:"in"},{id:"ko",name:"Korean",code:"ko",countryCode:"kr"},{id:"lt",name:"Lithuanian",code:"lt",countryCode:"lt"},{id:"lv",name:"Latvian",code:"lv",countryCode:"lv"},{id:"mk",name:"Macedonian",code:"mk",countryCode:"mk"},{id:"mr",name:"Marathi",code:"mr",countryCode:"in"},{id:"ms",name:"Malay",code:"ms",countryCode:"my"},{id:"nb",name:"Norwegian Bokm\xe5l",code:"nb",countryCode:"no"},{id:"ne",name:"Nepali",code:"ne",countryCode:"np"},{id:"nl",name:"Dutch",code:"nl",countryCode:"nl"},{id:"no",name:"Norwegian",code:"no",countryCode:"no"},{id:"pl",name:"Polish",code:"pl",countryCode:"pl"},{id:"pt",name:"Portuguese",code:"pt",countryCode:"pt"},{id:"pt-br",name:"Portuguese (Brazilian)",code:"pt-br",countryCode:"br"},{id:"pt-pt",name:"Portuguese (European)",code:"pt-pt",countryCode:"pt"},{id:"ro",name:"Romanian",code:"ro",countryCode:"ro"},{id:"ru",name:"Russian",code:"ru",countryCode:"ru"},{id:"sk",name:"Slovak",code:"sk",countryCode:"sk"},{id:"sl",name:"Slovenian",code:"sl",countryCode:"si"},{id:"sr",name:"Serbian",code:"sr",countryCode:"rs"},{id:"sv",name:"Swedish",code:"sv",countryCode:"se"},{id:"sw",name:"Swahili",code:"sw",countryCode:"tz"},{id:"ta",name:"Tamil",code:"ta",countryCode:"in"},{id:"te",name:"Telugu",code:"te",countryCode:"in"},{id:"th",name:"Thai",code:"th",countryCode:"th"},{id:"tl-ph",name:"Filipino / Tagalog (Philippines)",code:"tl-ph",countryCode:"ph"},{id:"tr",name:"Turkish",code:"tr",countryCode:"tr"},{id:"uk",name:"Ukrainian",code:"uk",countryCode:"ua"}
1,{id:"ur",name:"Urdu",code:"ur",countryCode:"pk"},{id:"vi",name:"Vietnamese",code:"vi",countryCode:"vn"},{id:"zh",name:"Chinese",code:"zh",countryCode:"cn"},{id:"zh-hans",name:"Chinese (Simplified)",code:"zh-hans",countryCode:"cn"},{id:"zh-hant",name:"Chinese (Traditional)",code:"zh-hant",countryCode:"tw"}];var Ke=e=>{let{shotId:t,token:s,basicTrackLanguage:o,showAddNewLanguageDialog:n,setShowAddNewLanguageDialog:l,selectedLanguage:r,setSelectedLanguage:d,createNewTrack:u,selectedDeepLCode:m,setSelectedDeepLCode:h}=e;const[x,p]=(0,i.useState)(!1),[f,g]=(0,i.useState)("eleven_multilingual_v2"),[v,w]=(0,i.useState)(0),[j,y]=(0,i.useState)(0),[b,N]=(0,i.useState)(0),[k,S]=(0,i.useState)(!1),[_,C]=(0,i.useState)(!1),[L,A]=(0,i.useState)(!1),[T,F]=(0,i.useState)(!1),[Z,P]=(0,i.useState)(!1),[I,B]=(0,i.useState)(!1),[U,R]=(0,i.useState)(""),[H,W]=(0,i.useState)([]);(0,i.useEffect)((()=>{C("eleven_multilingual_v2"!==f&&"eleven_multilingual_sts_v2"!==f)}),[f]),(0,i.useEffect)((()=>{t&&s&&q()}),[t,s]);const q=async()=>{try{c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(s);const e=(await c.Z.get("/job-types")).data.find((e=>"TRL"===e.service&&"deepl-trl-2"===e.model));if(e&&e.params.model_details.target_languages){const t=Object.keys(e.params.model_details.target_languages),s=Ye.filter((e=>t.includes(e.code)));W(s)}}catch(e){console.error("Error fetching supported languages:",e)}},Y=(0,i.useMemo)((()=>""===U?H.filter((e=>"English"!==e.name&&e.code.toLowerCase()!==(null===o||void 0===o?void 0:o.toLowerCase()))):H.filter((e=>e.name.toLowerCase().includes(U.toLowerCase())&&"English"!==e.name&&e.code.toLowerCase()!==(null===o||void 0===o?void 0:o.toLowerCase())))),[U,H,o]);return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(M.u,{appear:!0,show:n,as:i.Fragment,children:(0,a.jsxs)(z.Vq,{as:"div",className:"relative z-[70]",onClose:()=>l(!1),children:[(0,a.jsx)(M.x,{as:i.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{className:"fixed inset-0 bg-black/25"})}),(0,a.jsx)("div",{className:"fixed inset-0 overflow-y-auto ",children:(0,a.jsx)("div",{className:"flex min-h-full items-center justify-center p-4 text-center",children:(0,a.jsx)(M.x,{as:"div",enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:(0,a.jsxs)(z.EM,{className:"dialog-panel-4 w-full transform overflow-visible rounded-lg bg-white text-left align-middle shadow-xl transition-all flex flex-col",children:[(0,a.jsx)("div",{className:"flex flex-col flex-grow",children:(0,a.jsxs)(z.$N,{as:"h3",className:"pl-6 pr-6 pt-6 text-lg font-medium leading-6 flex flex-row justify-between",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-y-2",children:[(0,a.jsx)("div",{className:"p-3 rounded-full w-fit bg-cerise-red-100",children:(0,a.jsx)("div",{className:"p-1.5 rounded-full bg-cerise-red-200",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-7 h-7 text-cerise-red-600",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m10.5 21 5.25-11.25L21 21m-9-3h7.5M3 5.621a48.474 48.474 0 0 1 6-.371m0 0c1.12 0 2.233.038 3.334.114M9 5.25V3m3.334 2.364C11.176 10.658 7.69 15.08 3 17.502m9.334-12.138c.896.061 1.785.147 2.666.257m-4.589 8.495a18.023 18.023 0 0 1-3.827-5.802"})})})}),"Add New Language Track"]}),(0,a.jsx)("button",{className:"items-start justify-start flex",onClick:()=>l(!1),children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-7 w-7 text-gray-400 hover:text-gray-600",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18 18 6M6 6l12 12"})})})]})}),(0,a.jsx)("div",{className:" max-w-[550px] pt-2 text-gray-500 pl-6 pr-6 justify-start flex w-full text-sm",children:"Choose a language to translate your video to. This will create a side-by-side linked transcription for your video in its original and selected new language."}),(0,a.jsx)("div",{className:"p-6 w-full justify-start items-start flex",children:(0,a.jsxs)("div",{className:"relative w-full",children:[(0,a.jsx)(ne.__,{children:"Select a Language"}),(0,a.jsxs)(qe.hQ,{value:r,onChange:e=>{d(e),e&&e.code?h(e.code.toUpperCase()):h(null)},onClose:()=>R(""),children:[" ",(0,a.jsxs)("div",{className:"relative w-full",children:[(0,a.jsxs)("div",{className:"relative",children:[r&&(0,a.jsx)("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3",children:(0,a.jsx)(E(),{src:"https://flagcdn.com/".concat(r.countryCode,".svg"),alt:"".concat(r.name," flag"),width:20,height:15})}),(0,a.jsx)(qe.gA,{className:(0,V.default)("w-full rounded-lg border border-gray-300 bg-white py-3 pr-12",r?"pl-12":"pl-4","text-base","focus:outline-none focus:ring-2 focus:ring-cerise-red-500 focus:border-cerise-red-500"),autoComplete:"off","aria-label":"Assignee",displayValue:e=>null===e||void 0===e?void 0:e.name,onChange:e=>R(e.target.value),placeholder:"Select a language"})]}),(0,a.jsx)(qe.Q$,{className:"absolute inset-y-0 right-0 flex items-center pr-2",children:(0,a.jsx)(G.Z,{className:"h-5 w-5 text-gray-400","aria-hidden":"true"})})]}),(0,a.jsx)(qe.L5,{className:(0,V.default)("absolute z-[80] mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm","transition duration-100 ease-in data-[leave]:data-[closed]:opacity-0"),children:0===Y.length&&""!==U?(0,a.jsx)("div",{className:"relative cursor-default select-none py-2 px-4 text-gray-700",children:"Nothing found."}):Y.map((e=>(0,a.jsx)(qe.O2,{value:e,className:e=>{let{active:t}=e;return(0,V.default)("relative cursor-default select-none py-3 px-4",t?"bg-cerise-red-600 text-white":"text-gray-900")},children:t=>{let{selected:s,active:o}=t;return(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(E(),{src:"https://flagcdn.com/".concat(e.countryCode,".svg"),alt:"".concat(e.name," flag"),width:20,height:15,className:"mr-3"}),(0,a.jsx)("span",{className:(0,V.default)("block truncate",s&&"font-medium"),children:e.name})]}),s&&(0,a.jsx)(O.Z,{className:(0,V.default)("h-5 w-5",o?"text-white":"text-cerise-red-600")})]})}},e.id)))})]})]})}),(0,a.jsx)("div",{className:"flex w-full items-center justify-between gap-x-3 p-6",children:(0,a.jsx)("div",{className:"w-full flex gap-x-3",children:(0,a.jsx)(D.z,{disabled:null===r,onClick:()=>{u(),l(!1)},className:"w-full py-6 text-base bg-cerise-red-500 hover:bg-cerise-red-600 text-white",children:"Create"})})})]})})})})]})})})};var Je=e=>{let{showDeleteTrackDialog:t,setShowDeleteTrackDialog:s,deleteTrack:o}=e;return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(M.u,{appear:!0,show:t,as:i.Fragment,children:(0,a.jsxs)(z.Vq,{as:"div",className:"relative z-[70]",onClose:()=>s(!1),children:[(0,a.jsx)(M.x,{as:i.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{className:"fixed inset-0 bg-black/25"})}),(0,a.jsx)("div",{className:"fixed inset-0 overflow-y-auto ",children:(0,a.jsx)("div",{className:"flex min-h-full items-center justify-center p-4 text-center",children:(0,a.jsx)(M.x,{as:"div",enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:(0,a.jsxs)(z.EM,{className:"dialog-panel-5a w-full transform overflow-visible rounded-lg bg-white text-left align-middle shadow-xl transition-all flex flex-col",children:[(0,a.jsx)("div",{className:"flex flex-col flex-grow",children:(0,a.jsxs)(z.$N,{as:"h3",className:"pl-6 pr-6 pt-6 text-lg font-medium leading-6 flex flex-row justify-between",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-y-2",children:[(0,a.jsx)("div",{className:"p-3 rounded-full w-fit bg-red-100",children:(0,a.jsx)("div",{className:"p-1.5 rounded-full bg-red-200",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-7 h-7 text-red-600",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"})})})}),"Delete Track"]}),(0,a.jsx)("button",{className:"items-start justify-start flex",onClick:()=>s(!1),children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-7 w-7 text-gray-400 hover:text-gray-600",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18
118 6M6 6l12 12"})})})]})}),(0,a.jsx)("div",{className:" max-w-[450px] pt-2 text-gray-500 pl-6 pr-6 justify-start flex w-full text-sm",children:"Are you sure you want to delete this track? This action can be undone."}),(0,a.jsx)("div",{className:"flex w-full items-center justify-between gap-x-3 p-6",children:(0,a.jsxs)("div",{className:"w-full flex gap-x-3",children:[(0,a.jsx)(D.z,{variant:"outline",className:"py-6 text-base w-full shadow shadow-sm bg-white",onClick:()=>s(!1),children:"Cancel"}),(0,a.jsx)(D.z,{className:"w-full py-6 text-base bg-red-500 hover:bg-red-600 text-white",onClick:()=>{o(),s(!1)},children:"Delete"})]})})]})})})})]})})})};s(24041),s(82844),s(22258),s(27727);const $e=e=>{let{visible:t}=e;return(0,a.jsx)("div",{className:"sonner-loading-wrapper","data-visible":t,children:(0,a.jsx)("div",{className:"sonner-spinner",children:Qe.map(((e,t)=>(0,a.jsx)("div",{className:"sonner-loading-bar"},"spinner-bar-".concat(t))))})})},Qe=Array(12).fill(0);var Xe=function(e){let{userGroups:t,activeGroupId:s,setActiveGroupId:o,shotId:n,token:l,sourceVideoUrl:r,shouldThrowTour:m,setShouldThrowTour:h,faceDetectionRunning:x,setFaceDetectionRunning:p,lipSyncVidUrl:f,setLipSyncVidUrl:g,isGenerationInProgress:v,setIsGenerationInProgress:w,setGenerationSuccess:j,setGenerationError:y}=e;var b;const[N,k]=(0,i.useState)([]),[S,_]=(0,i.useState)(!1),[C,L]=(0,i.useState)(!1),[A,E]=(0,i.useState)(!1),[T,F]=(0,i.useState)(null),[Z,P]=(0,i.useState)(0),[I,B]=(0,i.useState)([]),[U,R]=(0,i.useState)([]),{setCreditsChanged:V}=(0,$.a)(),[G,O]=(0,i.useState)(null),[H,W]=(0,i.useState)(null),[q,Y]=(0,i.useState)(!1),[Q,ee]=(0,i.useState)(!1),[te,se]=(0,i.useState)(null),[ae,oe]=(0,i.useState)(null),[ne,ie]=(0,i.useState)(null),[le,re]=(0,i.useState)(!1),[ce,de]=(0,i.useState)(null),[ue,me]=(0,i.useState)(!1),[he,xe]=(0,i.useState)(null),[pe,fe]=(0,i.useState)(!1),[ge,ve]=(0,i.useState)("deepsync-2-sd"),[we,je]=(0,i.useState)(0),[ye,be]=(0,i.useState)(0),[Ne,ke]=(0,i.useState)(0),[Se,_e]=(0,i.useState)(null),[Ce,Le]=(0,i.useState)([]),[Ae,Ee]=(0,i.useState)(null),[Te,Me]=(0,i.useState)(null),[ze,Fe]=(0,i.useState)(!1),[Ze,Pe]=(0,i.useState)(!1),[De,Ie]=(0,i.useState)(0),[Be,Ue]=(0,i.useState)(!0),[Re,Ge]=(0,i.useState)(!1),[qe,Ye]=(0,i.useState)(0),[Qe,Xe]=(0,i.useState)(!1),[et,tt]=(0,i.useState)(null),[st,at]=(0,i.useState)(!1),[ot,nt]=(0,i.useState)(0),[it,lt]=(0,i.useState)(0),[rt,ct]=(0,i.useState)(!1),[dt,ut]=(0,i.useState)(!0),[mt,ht]=(0,i.useState)(!1),[xt,pt]=(0,i.useState)(!0),[ft,gt]=(0,i.useState)(!1),[vt,wt]=(0,i.useState)("aurora"),[jt,yt]=(0,i.useState)([]),[bt,Nt]=(0,i.useState)([]),[kt,St]=(0,i.useState)("deepl-trl-2"),[_t,Ct]=(0,i.useState)(null),[Lt,At]=(0,i.useState)(0),[Et,Tt]=(0,i.useState)(null),Mt="EDIT_SOURCE_TEXT",zt="EDIT_TRANSLATED_TEXT",Ft=(0,i.useCallback)((e=>{yt((t=>[...t,e])),Nt([])}),[]),Zt=()=>{const e=jt[jt.length-1];if(e){switch(yt((e=>e.slice(0,-1))),e.type){case Mt:case zt:Dt(e.trackId,e.portionId,e.previousData)}Nt((t=>[...t,e])),At((e=>e+1))}},Pt=()=>{const e=bt[bt.length-1];if(e){switch(Nt((e=>e.slice(0,-1))),e.type){case Mt:case zt:Dt(e.trackId,e.portionId,e.data)}yt((t=>[...t,e])),At((e=>e+1))}};(0,i.useEffect)((()=>{const e=e=>{if(e.ctrlKey)switch(e.key){case"z":e.shiftKey||(e.preventDefault(),Zt());break;case"Z":e.shiftKey&&(e.preventDefault(),Pt());break;case"y":e.preventDefault(),Pt()}};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}}),[Zt,Pt]);const Dt=async(e,t,s)=>{try{c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(l),await c.Z.put("/shots/".concat(n,"/tracks/").concat(e,"/portions/").concat(t),{text:s}),await Ut()}catch(a){console.error("Error updating portion:",a),d.A.error("Failed to update portion")}},It=(0,i.useCallback)((()=>{const e=I.find((e=>"translated"===e.type))||I.find((e=>"basic"===e.type));if(!e)return void Ue(!0);const t=e.portions.some((e=>{const t=U.find((t=>t.actor_id===e.actor_id));return e.actor_id&&t&&t.voice_id&&!e.audio}));Ue(!t)}),[I,U]);(0,i.useEffect)((()=>{It()}),[I,U,It]);const Bt=async()=>{await Ut()},Ut=async()=>{try{var e,t,s;c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(l);const o=await c.Z.get("/shots/".concat(n));console.log("Shot Response: ",o.data);const i=o.data.shot_editor_json.tracks.filter((e=>"source"!==e.type)),r=o.data.shot_editor_json.actors||[],d=null===Te||void 0===Te?void 0:Te.portion_id,u=Te?null===(e=i.find((e=>e.portions.some((e=>e.portion_id===d)))))||void 0===e?void 0:e.type:null;B(i),R(o.data.shot_editor_json.actors||[]),lt(r.length);const m=(null===(t=i[0])||void 0===t?void 0:t.portions.length)||0;if(nt(m),gt(i.length>0),d&&u){const e=i.find((e=>e.type===u));if(e){const t=e.portions.find((e=>e.portion_id===d));t&&JSON.stringify(t)!==JSON.stringify(Te)&&Me(t)}}const h=i.find((e=>"translated"===e.type));if(Ct(h?h.language:null),Se&&Ae){const e=Rt(Se,i),t=Vt(Ae,r);Le(e),Fe(t)}else{var a;_e(i),Ee(r),Le(Array((null===(a=i[0])||void 0===a?void 0:a.portions.length)||0).fill(!0)),Fe(!0)}ve((null===(s=o.data.shot_config)||void 0===s?void 0:s.selected_model)||"deepsync-2-sd"),console.log("actors",o.data.shot_editor_json.actors||[]),c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(l);const x=await c.Z.get("/task_types");console.log("taskTypeResponse",x.data);const p=i.flatMap((e=>e.portions.filter((e=>e.audio)))).length;je(p);const f=r.filter((e=>e.voice_id)).length;be(f);const g=i.flatMap((e=>e.portions.filter((e=>e.actor_id)))).length;ke(g)}catch(o){console.error("Error fetching tracks:",o),d.A.error("Failed to fetch updated tracks")}},Rt=(e,t)=>
1{const s=[],a=Math.max(...e.map((e=>{var t;return(null===(t=e.portions)||void 0===t?void 0:t.length)||0})),...t.map((e=>{var t;return(null===(t=e.portions)||void 0===t?void 0:t.length)||0})));for(let r=0;r<a;r++){let a=!1;for(let s=0;s<e.length;s++){var o,n,i,l;const c=null===(o=e[s])||void 0===o||null===(n=o.portions)||void 0===n?void 0:n[r],d=null===(i=t[s])||void 0===i||null===(l=i.portions)||void 0===l?void 0:l[r];if(!c||!d||JSON.stringify(c)!==JSON.stringify(d)){a=!0;break}}s.push(a)}return s},Vt=(e,t)=>JSON.stringify(e)!==JSON.stringify(t),[Gt,Ot]=(0,i.useState)(null);(0,i.useEffect)((()=>{const e=e=>{e.target.closest(".floating-dock-container")||e.target.closest(".translation-input")||E(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[]);const[Ht,Wt]=(0,i.useState)(null),qt=(0,i.useCallback)((e=>{Wt(e),fe(!0)}),[]);(0,i.useEffect)((()=>{if(mt){const e=async()=>{const t=await Yt();t?Kt(t.job_id,n):setTimeout(e,5e3)};e()}}),[mt]);const Yt=async()=>{try{console.log("begin transcript fetch"),c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(l);const e=await c.Z.get("/jobs?shot_id=".concat(n));console.log("transcription fetch job response",e.data);return e.data.find((e=>"STT"===e.job_type.service))||null}catch(e){console.error("Error fetching transcription job:",e)}},Kt=async(e,t)=>{try{for(console.log("Setting axios defaults...");;){console.log("Requesting transcription polling status..."),c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(l);const s=await c.Z.get("/jobs/".concat(e));switch(console.log("Transcription Status Response: ",s.data),s.data.job_status){case"IN_PROGRESS":case"SUBMITTED":case"IN_QUEUE":case"DRAFTED":c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(l);await c.Z.get("/jobs/".concat(e,"/submit"));break;case"COMPLETED":return ht(!1),pt(!1),void(await Ut());case"FAILED":return ht(!1),await deleteShot(t),void router.push("/shots");default:return void console.log("Unexpected status received for transcription")}await new Promise((e=>setTimeout(e,5e3)))}}catch(s){console.error("Error polling transcription job:",s)}};(0,i.useEffect)((()=>{pt(!(!x&&!mt))}),[x,mt]),(0,i.useEffect)((()=>{!x&&mt&&Yt().then((e=>{if(e){const{job_id:t}=e;Kt(t,n)}}))}),[x,mt]),(0,i.useEffect)((()=>{n&&l&&Ut()}),[n,l]);const Jt={af:{flag:"https://flagcdn.com/za.svg",name:"Afrikaans"},ar:{flag:"https://flagcdn.com/sa.svg",name:"Arabic"},az:{flag:"https://flagcdn.com/az.svg",name:"Azerbaijani"},be:{flag:"https://flagcdn.com/by.svg",name:"Belarusian"},bg:{flag:"https://flagcdn.com/bg.svg",name:"Bulgarian"},bs:{flag:"https://flagcdn.com/ba.svg",name:"Bosnian"},ca:{flag:"https://flagcdn.com/ad.svg",name:"Catalan"},cs:{flag:"https://flagcdn.com/cz.svg",name:"Czech"},cy:{flag:"https://flagcdn.com/gb-wls.svg",name:"Welsh"},da:{flag:"https://flagcdn.com/dk.svg",name:"Danish"},de:{flag:"https://flagcdn.com/de.svg",name:"German"},el:{flag:"https://flagcdn.com/gr.svg",name:"Greek"},en:{flag:"https://flagcdn.com/gb.svg",name:"English"},"en-gb":{flag:"https://flagcdn.com/gb.svg",name:"English (British)"},"en-us":{flag:"https://flagcdn.com/us.svg",name:"English (American)"},"en/es":{flag:"https://flagcdn.com/us.svg",name:"English/Spanish"},es:{flag:"https://flagcdn.com/es.svg",name:"Spanish"},et:{flag:"https://flagcdn.com/ee.svg",name:"Estonian"},fa:{flag:"https://flagcdn.com/ir.svg",name:"Farsi"},fi:{flag:"https://flagcdn.com/fi.svg",name:"Finnish"},fr:{flag:"https://flagcdn.com/fr.svg",name:"French"},gl:{flag:"https://flagcdn.com/es.svg",name:"Galician"},he:{flag:"https://flagcdn.com/il.svg",name:"Hebrew"},hi:{flag:"https://flagcdn.com/in.svg",name:"Hindi"},hr:{flag:"https://flagcdn.com/hr.svg",name:"Croatian"},hu:{flag:"https://flagcdn.com/hu.svg",name:"Hungarian"},hy:{flag:"https://flagcdn.com/am.svg",name:"Armenian"},id:{flag:"https://flagcdn.com/id.svg",name:"Indonesian"},is:{flag:"https://flagcdn.com/is.svg",name:"Icelandic"},it:{flag:"https://flagcdn.com/it.svg",name:"Italian"},ja:{flag:"https://flagcdn.com/jp.svg",name:"Japanese"},kk:{flag:"https://flagcdn.com/kz.svg",name:"Kazakh"},kn:{flag:"https://flagcdn.com/in.svg",name:"Kannada"},ko:{flag:"https://flagcdn.com/kr.svg",name:"Korean"},lt:{flag:"https://flagcdn.com/lt.svg",name:"Lithuanian"},lv:{flag:"https://flagcdn.com/lv.svg",name:"Latvian"},mk:{flag:"https://flagcdn.com/mk.svg",name:"Macedonian"},mr:{flag:"https://flagcdn.com/in.svg",name:"Marathi"},ms:{flag:"https://flagcdn.com/my.svg",name:"Malay"},nb:{flag:"https://flagcdn.com/no.svg",name:"Norwegian Bokm\xe5l"},ne:{flag:"https://flagcdn.com/np.svg",name:"Nepali"},nl:{flag:"https://flagcdn.com/nl.svg",name:"Dutch"},no:{flag:"https://flagcdn.com/no.svg",name:"Norwegian"},pl:{flag:"https://flagcdn.com/pl.svg",name:"Polish"},pt:{flag:"https://flagcdn.com/pt.svg",name:"Portuguese"},"pt-br":{flag:"https://flagcdn.com/br.svg",name:"Portuguese (Brazilian)"},"pt-pt":{flag:"https://flagcdn.com/pt.svg",name:"Portuguese (European)"},ro:{flag:"https://flagcdn.com/ro.svg",name:"Romanian"},ru:{flag:"https://flagcdn.com/ru.svg",name:"Russian"},sk:{flag:"https://flagcdn.com/sk.svg",name:"Slovak"},sl:{flag:"https://flagcdn.com/si.svg",name:"Slovenian"},sr:{flag:"https://flagcdn.com/rs.svg",name:"Serbian"},sv:{flag:"https://flagcdn.com/se.svg",name:"Swedish"},sw:{flag:"https://flagcdn.com/tz.svg",name:"Swahili"},ta:{flag:"https://flagcdn.com/in.svg",name:"Tamil"},te:{flag:"https://flagcdn.com/in.svg",name:"Telugu"},th:{flag:"https://flagcdn.com/th.svg",name:"Thai"},"tl-ph":{flag:"https://flagcdn.com/ph.svg",name:"Filipino / Tagalog (Philippines)"},tr:{flag:"https://flagcdn.com/tr.svg",name:"Turkish"},uk:{flag:"https://flagcdn.com/ua.svg",name:"Ukrainian"},ur:{flag:"https://flagcdn.com/pk.svg",name:"Urdu"},vi:{flag:"https://flagcdn.com/vn.svg",name:"Vietnamese"},zh:{flag:"https://flagcdn.com/cn.svg",name:"Chinese"},"zh-hans":{flag:"https://flagcdn.com/cn.svg",name:"Chinese (Simplified)"},"zh-hant":{flag:"https://flagcdn.com/tw.svg",name:"Chinese (Traditional)"}},$t=(Math.max(...I.map((e=>e.portions.length))),e=>null===e||void 0===e?void 0:e.toLowerCase()),Qt=e=>{const t=$t(e);return Jt[t]||{flag:null,name:e}};return(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)("div",{className:"min-h-screen flex flex-col overflow-y-hidden ",children:[(0,a.jsx)(Oe,{showAudioGenerationSettings:C,setShowAudioGenerationSettings:L}),(0,a.jsx)(Ke,{shotId:n,basicTrackLanguage:null===(b=I.find((e=>"basic"===e.type)))||void 0===b?void 0:b.language,token:l,selectedDeepLCode:ne,setSelectedDeepLCode:ie,showAddNewLanguageDialog:q,setShowAddNewLanguageDialog:Y,selectedLanguage:G,setSelectedLanguage:O,createNewTrack:async()=>{try{var e,t;let s=d.A.info("Creating New Track",{icon:(0,a.jsx)($e,{}),duration:1/0,position:"bottom-right",className:"custom-toast-button2"});c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(l);const o=null===(e=I[0])||void 0===e?void 0:e.id,i=await c.Z.post("/shots/".concat(n,"/tracks"),{type:"translated",source_track_id:o,language:ne.toLowerCase()});console.log("New track created:",i.data),null===s||d.A.info("Translating New Track",{id:s,icon:(0,a.jsx)($e,{}),duration:1/0,position:"bottom-right",className:"custom-toast-button2"});const r=null===(t=(await c.Z.get("/shots/".concat(n))).data.shot_editor_json.tracks.find((e=>"translated"===e.type)))||void 0===t?void 0:t.id,u=await c.Z.post("/tasks",{task_type_id:"1698ab19-453e-4369-a120-8e5542129d15",data:{shot_id:n,track_id:o,dest_track_id:r,trl_model:"deepl-trl-2"},shot_id:n});O(null),ie(null);const m=u.data.id;c.Z.post("/tasks/".concat(m,"/submit"));const h=async e=>{const t=(await c.Z.get("/tasks/".concat(m))).data.status;if("COMPLETED"===t){d.A.dismiss();const e=null===Te||void 0===Te?void 0:Te.portion_id;if(await Ut(),k([]),e){const t=I.find((e=>"translated"===e.type));if(t){const s=t.portions.find((t=>t.portion_id===e));s&&Me(s)}}}else"FAILED"===t?(console.error("Translation task failed"),d.A.error("Translation task failed"),d.A.dismiss()):setTimeout(h,5e3)};h(s)}catch(s){console.error("Error in track creation or translation:",s),d.A.error("Failed to create or translate new track")}}}),(0,a.jsx)(Je,{showDeleteTrackDialog:Q,setShowDeleteTrackDialog:ee,deleteTrack:async()=>{try{var e;c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(l);const t=null===(e=I[1])||void 0===e?void 0:e.id;await c.Z.delete("/shots/".concat(n,"/tracks/").concat(t)),Me(null),de(null),me(!1),await Bt();const s=I.find((e=>"basic"===e.type));if(s&&s.portions.length>0){const e=s.portions.find((e=>e.portion_id===(null===Te||void 0===Te?void 0:Te.portion_id)));e&&Me(e)}}catch(t){console.error("Error deleting track:",t),d.A.error("Failed to delete track")}}}),(0,a.jsx)(u.Z,{activeGroupId:s,userGroups:t,setActiveGroupId:o}),(0,a.jsxs)("div",{className:"flex flex-col lg:flex-row justify-between gap-4 mx-4 lg:mx-12 pt-12 flex-grow ",children:[(0,a.jsxs)("div",{className:"flex flex-col w-full lg:w-2/3 order-2 lg:order-1",children:[(0,a.jsx)("div",{className:"flex flex-row justify-between w-full",children:I.map(((e,t)=>(0,a.jsxs)("div",{className:"flex w-full border border-gray-200\n ".concat(I.length>1&&0===t?"border-r-0":"","\n ").concat(0===t?"rounded-tl-md":"","\n ").concat(t===I.length-1?"rounded-tr-md":"","\n border-b-0"),children:[(0,a.jsx)("div",{className:"p-3 font-medium flex-grow",children:(0,a.jsxs)("div",{className:"flex flex-row gap-x-2 items-center justify-start",children:[Jt[$t(e.language)]&&(0,a.jsx)("img",{className:"w-5 h-3.5",src:Qt(e.language).flag,alt:"".concat(Qt(e.language).name," Flag")}),(0,a.jsx)("span",{className:"text-sm",children:Qt(e.language).name}),1===t&&(0,a.jsx)("div",{className:"w-6 h-6 flex items-center justify-center relative",children:Re&&(0,a.jsx)("div",{className:" z-[50] cursor-pointer place-items-end",children:(0,a.jsxs)(K.fC,{className:"z-[70] ",open:Re,onOpenChange:()=>{Ge(!1),Ye(null)},children:[(0,a.jsx)(K.xz,{className:"focus:outline-none "}),(0,a.jsx)(K.h_,{children:(0,a.jsxs)(K.VY,{transition:!0,anchor:"right",focus:!0,className:"z-[30] right-0 mr-3.5 mt-0.5 w-64 roun
1ded-md shadow-lg bg-white divide-y divide-gray-100 relative",children:[(0,a.jsx)(K.Eh,{className:"stroke-gray-200 stroke-1.5 fill-white",width:16,height:8}),(0,a.jsx)("div",{className:"z-[30] relative bg-white rounded-md border items-center justify-centerborder-gray-200",children:(0,a.jsxs)("div",{className:"pt-3 pl-2 ",children:[(0,a.jsx)("h3",{className:"text-base font-medium text-gray-900",children:"Confirm Audio Generation"}),(0,a.jsx)("div",{className:"flex justify-between text-xs mt-3 ",children:(0,a.jsxs)("div",{children:["Are you sure you want to generate audio for all non-generated portions with assigned actors? Doing so will cost ",(0,a.jsx)("span",{className:"font-bold",children:qe})," credits."]})})]})}),(0,a.jsx)("div",{className:"mt-4 flex justify-end space-x-2 p-2",children:(0,a.jsx)(D.z,{onClick:()=>{(async e=>{at(!0);try{const t=await c.Z.post("/tasks/".concat(e,"/submit"));console.log("Task submitted:",t.data),setTimeout((()=>{Ge(!1)}),1e3);const s=async()=>{const t=(await c.Z.get("/tasks/".concat(e))).data.status;"COMPLETED"===t?await Ut():"FAILED"===t?(console.error("Translation task failed"),at(!1)):setTimeout(s,5e3)};s()}catch(t){console.error("Error in track to audio generation:",t),d.A.error("Failed to generate track to audio")}finally{at(!1)}})(et)},disabled:Qe||st,variant:"outline",className:"w-full flex flex-row gap-x-1",children:Qe||st?(0,a.jsx)(J.Spinner,{className:"w-5 h-5"}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m3.75 13.5 10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75Z"})}),"Confirm & Generate"]})})})]})})]})})})]})}),1===I.length&&(0,a.jsx)("div",{className:"flex items-center pr-2",children:(0,a.jsxs)(D.z,{onClick:()=>Y(!0),variant:"ghost",size:"icon",className:"w-full flex flex-row gap-x-2 py-2 px-2",children:[(0,a.jsx)(He.Z,{className:"h-4 w-4"}),(0,a.jsx)("span",{className:"text-sm",children:"Add Language"})]})}),t===I.length-1&&I.length>1&&(0,a.jsx)("div",{className:"flex items-center pr-4",children:(0,a.jsx)("button",{onClick:()=>ee(!0),className:"text-gray-600 hover:text-red-600",children:(0,a.jsx)(We.Z,{className:"h-4 w-4"})})})]},e.id)))}),(0,a.jsx)("div",{className:"flex flex-col w-full h-[calc(100vh-300px)] lg:h-[calc(100vh-185px)] overflow-y-auto border border-r-1",children:ft?I.length>0&&Array.from({length:Math.max(...I.map((e=>e.portions.length)))},((e,t)=>{var s,o,i,r,c,d,u,m,h,x,p;const f=I.find((e=>"translated"===e.type)),g=f?f.portions:null===(s=I[0])||void 0===s?void 0:s.portions,v=Te&&((null===(o=null===(i=I[0])||void 0===i?void 0:i.portions[t])||void 0===o?void 0:o.portion_id)===Te.portion_id||(null===(r=null===(c=I[1])||void 0===c?void 0:c.portions[t])||void 0===r?void 0:r.portion_id)===Te.portion_id);return(0,a.jsx)(X,{onFocusChange:e=>{var s,a,o,n,i,l,r,c;return((e,t,s)=>{e?(E(!0),se(t),oe(s)):s!==ae&&(se(null),oe(null))})(e,{index:t,start:null===(s=null===(a=I[0])||void 0===a?void 0:a.portions[t])||void 0===s?void 0:s.start,end:null===(o=null===(n=I[0])||void 0===n?void 0:n.portions[t])||void 0===o?void 0:o.end,sourceText:null===(i=null===(l=I[0])||void 0===l?void 0:l.portions[t])||void 0===i?void 0:i.text,translatedText:null===(r=null===(c=I[1])||void 0===c?void 0:c.portions[t])||void 0===r?void 0:r.text},t)},sourceText:(null===(d=null===(u=I[0])||void 0===u?void 0:u.portions[t])||void 0===d?void 0:d.text)||"",translatedText:(null===(m=null===(h=I[1])||void 0===h?void 0:h.portions[t])||void 0===m?void 0:m.text)||"",tracks:I,index:t,token:l,selectedAudioModel:vt,shouldSwitchToPortionsTab:rt,setShouldSwitchToPortionsTab:ct,start:null===(x=g[t])||void 0===x?void 0:x.start,end:null===(p=g[t])||void 0===p?void 0:p.end,isPortionActive:v,shotId:n,actors:U,onPortionChange:Bt,onOpenActorSettings:qt,throwSettingsDialog:le,setThrowSettingsDialog:re,audioPlayerUrl:ce,setAudioPlayerUrl:de,openAudioPlayer:ue,setOpenAudioPlayer:me,activePortion:Te,actorVoicePortionUpdated:Et,
1setActorVoicePortionUpdated:Tt,setActivePortion:Me,setActiveTrackId:xe,setShowActorSettings:fe,setAudioPlayerAudioName:W,pushToUndoStack:Ft,updatePortionText:Dt,undoRedoCounter:Lt,translatedTrackLanguage:_t,selectedTranslationModel:kt,setSelectedTranslationModel:St,undoStack:jt,redoStack:bt,undo:Zt,redo:Pt},"".concat(I[0].id,"-").concat(t,"-").concat(Ce[t],"-").concat(ze,"-").concat(ot))})):(0,a.jsxs)("div",{className:"flex flex-col gap-y-4 items-center justify-center h-full",children:[(0,a.jsx)(J.Spinner,{color:"black",className:"h-8 w-8"}),(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"Fetching Shot Info..."})]})})]}),(0,a.jsxs)("div",{className:"flex flex-col w-full lg:w-1/3 order-1 lg:order-2 h-[calc(100vh-280px)] lg:h-[calc(100vh-140px)] lg:mb-0",children:[(0,a.jsx)(Ve,{originalVideoUrl:r,lipSyncVideoUrl:f,setLipSyncVidUrl:g,actors:U,selectedAudioModel:vt,setSelectedAudioModel:wt,setActors:R,token:l,activeActorSettingsId:Ht,setActiveActorSettingsId:Wt,onPortionChange:Bt,shotId:n,tracks:I,shouldSwitchToPortionsTab:rt,setShouldSwitchToPortionsTab:ct,throwSettingsDialog:le,setThrowSettingsDialog:re,audioPlayerUrl:ce,actorVoicePortionUpdated:Et,setActorVoicePortionUpdated:Tt,setAudioPlayerUrl:de,openAudioPlayer:ue,selectedTranslationModel:kt,setSelectedTranslationModel:St,setOpenAudioPlayer:me,activePortion:Te,setActivePortion:Me,activeTrackId:he,setShowActorSettings:fe,showActorSettings:pe,selectedLSModel:ge,setSelectedLSModel:ve,audioPlayerAudioName:H,setAudioPlayerAudioName:W,isGenerationInProgress:v,setIsGenerationInProgress:w,portionMedia:N,setPortionMedia:k,setGenerationSuccess:j,setGenerationError:y}),(0,a.jsx)(M.u,{show:xt,appear:!0,as:i.Fragment,children:(0,a.jsxs)(z.Vq,{as:"div",className:"relative z-[1000]",onClose:()=>{},children:[(0,a.jsx)(M.x,{as:i.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{className:"fixed inset-0 bg-black/25"})}),(0,a.jsx)("div",{className:"fixed inset-0 overflow-y-auto",children:(0,a.jsx)("div",{className:"flex min-h-full items-center justify-center p-4 text-center",children:(0,a.jsx)(M.x,{as:i.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:(0,a.jsxs)(z.EM,{className:"w-full max-w-md transform overflow-hidden rounded-2xl bg-white p-6 text-left align-middle shadow-xl transition-all",children:[(0,a.jsx)(z.$N,{as:"h3",className:"text-lg font-medium leading-6 text-gray-900",children:"Your shot is still being prepared"}),(0,a.jsx)("div",{className:"flex items-center justify-center pt-2 mt-12",children:(0,a.jsx)(J.Spinner,{color:"black",className:"h-8 w-8"})}),(0,a.jsx)("div",{className:"mt-2 mb-10",children:(0,a.jsx)("p",{className:"text-xs text-center text-gray-500",children:"Finishing Up..."})})]})})})})]})}),m&&(0,a.jsxs)("div",{className:"fixed bottom-4 right-4 z-[100] w-[20%] rounded-lg bg-white shadow-lg border border-gray-200",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between p-2 border-b border-gray-200",children:[(0,a.jsx)("div",{className:"flex items-center flex-col",children:(0,a.jsxs)("div",{className:"space-x-2 flex flex-row items-center",children:[(0,a.jsx)("div",{className:"w-6 h-6 bg-gray-100 rounded-full flex items-center justify-center",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4",children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M18 10a8 8 0 1 1-16 0 8 8 0 0 1 16 0ZM8.94 6.94a.75.75 0 1 1-1.061-1.061 3 3 0 1 1 2.871 5.026v.345a.75.75 0 0 1-1.5 0v-.5c0-.72.57-1.172 1.081-1.287A1.5 1.5 0 1 0 8.94 6.94ZM10 15a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z",clipRule:"evenodd"})})}),(0,a.jsx)("span",{className:"font-medium text-sm",children:"Transcription Editor Walkthrough"})]})}),(0,a.jsx)("button",{className:"text-gray-400 hover:text-gray-600",onClick:async()=>{h(!1);try{c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(l);const e=await c.Z.get("/shots/".concat(n)),t={...e.data.shot_config,throw_tour:!1};await c.Z.put("/shots/".concat(n),{shot_config:t}),console.log("Shot configuration updated successfully")}catch(e){console.error("Error updating shot configuration:",e)}},children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-5 h-5",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18
118 6M6 6l12 12"})})})]}),(0,a.jsxs)("div",{className:"p-2",children:[(0,a.jsxs)("div",{className:"relative aspect-video rounded-md overflow-hidden bg-gray-100",children:[(0,a.jsx)("video",{className:"w-full h-full object-cover",src:"https://storage.googleapis.com/ivt-project-prod.appspot.com/email_assets/transcription_tutorial.mp4",autoPlay:!0,loop:!0,muted:!0,playsInline:!0}),(0,a.jsx)("button",{onClick:e=>{e.stopPropagation();const t=e.currentTarget.previousElementSibling;t.muted=!t.muted,ut(!dt)},className:"absolute bottom-2 left-2 w-8 h-8 bg-white rounded-full flex items-center justify-center shadow-md hover:bg-gray-50 transition-colors",children:dt?(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"black",className:"w-4 h-4",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.25 9.75 19.5 12m0 0 2.25 2.25M19.5 12l2.25-2.25M19.5 12l-2.25 2.25m-10.5-6 4.72-4.72a.75.75 0 0 1 1.28.53v15.88a.75.75 0 0 1-1.28.53l-4.72-4.72H4.51c-.88 0-1.704-.507-1.938-1.354A9.009 9.009 0 0 1 2.25 12c0-.83.112-1.633.322-2.396C2.806 8.756 3.63 8.25 4.51 8.25H6.75Z"})}):(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"black",className:"w-4 h-4",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.114 5.636a9 9 0 0 1 0 12.728M16.463 8.288a5.25 5.25 0 0 1 0 7.424M6.75 8.25l4.72-4.72a.75.75 0 0 1 1.28.53v15.88a.75.75 0 0 1-1.28.53l-4.72-4.72H4.51c-.88 0-1.704-.507-1.938-1.354A9.009 9.009 0 0 1 2.25 12c0-.83.112-1.633.322-2.396C2.806 8.756 3.63 8.25 4.51 8.25H6.75Z"})})}),(0,a.jsxs)("div",{className:"absolute bottom-2 right-2 group",children:[(0,a.jsx)("div",{className:"absolute bottom-full right-0 mb-2 hidden group-hover:block",children:(0,a.jsx)("div",{className:"bg-gray-900 text-white text-xs rounded py-1 px-2 whitespace-nowrap",children:"Open in YouTube"})}),(0,a.jsx)("button",{onClick:()=>window.open("https://youtu.be/61lM2woV58o","_blank"),className:"w-8 h-8 bg-white rounded-full flex items-center justify-center shadow-md hover:bg-gray-50 transition-colors",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m16.49 12 3.75-3.751m0 0-3.75-3.75m3.75 3.75H3.74V19.5"})})})]})]}),(0,a.jsx)("div",{className:"flex items-start mt-1 flex-col",children:(0,a.jsx)("p",{className:"text-xs text-gray-600 mt-2 pl-1",children:"Not sure where to start? Check out this tutorial showcasing all the features our transcription editor has to offer."})})]})]})]})]})]})})};var et=(0,n.Z)((function(e){let{token:t,userGroups:s,activeGroupId:n,setActiveGroupId:l}=e;const[u,m]=(0,i.useState)(!1),[h,x]=(0,i.useState)(null),[p,f]=(0,i.useState)(null),[g,v]=(0,i.useState)(!1),[w,j]=(0,i.useState)(!1),[y,b]=(0,i.useState)(!1),N=(0,o.useRouter)(),[k,S]=(0,i.useState)(!1);d.A.dismiss();const[_,C]=(0,i.useState)(null);(0,i.useEffect)((()=>{C(N.query.shotId)}),[N.query.shotId]),(0,i.useEffect)((()=>{if(!_)return;c.Z.defaults.baseURL="https://deep-api-service-unilglm46a-uc.a.run.app",c.Z.defaults.headers.common.Authorization="Bearer ".concat(t);const e=setInterval((()=>{L()}),36e5);return L(),()=>clearInterval(e)}),[_]);const L=async()=>{try{var e;const s=await c.Z.get("/shots/".concat(_)),a=await c.Z.get("/tasks?shot_id=".concat(_,"&status=IN_PROGRESS"));a.data.length>0&&(v(!0),A(),console.log("task response",a.data));const o=s.data;if(o.shot_editor_json.background_source_clip.media_id){var t;const e=await c.Z.get("/media/".concat(null===(t=o.shot_editor_json.background_source_clip)||void 0===t?void 0:t.media_id,"?signed_url=true"));x(e.data.signed_url)}o.shot_editor_json.actors.length<=0&&m(!0),o.shot_config.throw_tour&&S(!0);const n=null===(e=o.shot_editor_json)||void 0===e?void 0:e.background_target_clips;if(n&&(null===n||void 0===n?void 0:n.length)>0){const e=n[n.length-1];if(e.media_id){const t=(await c.Z.get("/media/".concat(e.media_id,"?signed_url=true"))).data.signed_url;f(t)}}}catch(s){console.error(s)}},A=async()=>{let e=!0;for(;e;)try{const t=await c.Z.get("/tasks?shot_id=".concat(_,"&status=IN_PROGRESS"));t.data.length>0?(v(!0),console.log("task response",t.data),await new Promise((e=>setTimeout(e,1e4)))):(e=!1,v(!1))}catch(t){console.error("Error polling tasks:",t),e=!1}};return(0,i.useEffect)((()=>
1{if(!y&&!w)return;const e=()=>{"visible"===document.visibilityState&&(y&&b(!1),w&&j(!1))};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}}),[y,w]),(0,a.jsxs)("div",{className:"w-full h-full overflow-y-hidden flex flex-col",children:[(0,a.jsxs)(r(),{children:[(0,a.jsxs)("title",{children:[g?"Generating Video":w?"Video Generation Complete":y?"Video Generation Failed":"Transcription Editor"," | Deepshot"]}),(0,a.jsx)("meta",{name:"description",content:""})]}),_&&(0,a.jsx)(Xe,{userGroups:s,activeGroupId:n,setActiveGroupId:l,shouldThrowTour:k,setShouldThrowTour:S,setGenerationSuccess:j,setGenerationError:b,shotId:_,token:t,sourceVideoUrl:h,faceDetectionRunning:u,setFaceDetectionRunning:m,lipSyncVidUrl:p,setLipSyncVidUrl:f,isGenerationInProgress:g,setIsGenerationInProgress:v})]})}))}},function(e){e.O(0,[6664,7409,277,3662,5445,7719,4617,3061,9545,1485,61,8216,31,4509,65,5538,2004,6312,6143,4241,4497,2831,1635,8408,1788,9447,7136,3310,9774,2888,179],(function(){return t=29647,e(e.s=t);var t}));var t=e.O();_N_E=t}]);
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.