import{j as a,G as v,aA as s,F as b,b9 as P,az as j,ba as T,bb as w,al as f,ag as S,ax as m,a9 as l,k as y,l as I,o,s as k,aV as L,E as F,aJ as R,aR as V,aW as E,r as N,aZ as q,g as A,h as D,i as U}from"./app-BgLa5dit.js";const W="shared.editClipDetails",t=b.encloseNamespace(W),z=s.object().shape({name:s.string().trim().max(255,()=>t("titleTooLong")).required(()=>t("titleRequired")).default(""),description:s.string().trim().max(16e3,()=>t("descriptionTooLong")).default(""),startTime:s.number().required(),endTime:s.number().required(),status:s.mixed()}).noUnknown();function _(e){const i=P();return a.jsxs(j,{children:[a.jsxs("div",{className:"row form-group",children:[a.jsx("div",{className:"col-5",children:a.jsx(T,{video:{_parentVideo:e.video,typeId:S.Clip,...i.values},type:"cosmetic",imageOptions:{size:f.Small},textPosition:w.Independent,preload:!0})}),a.jsx("div",{className:"col-7",children:a.jsx("h2",{className:"h6",children:i.values.name})})]}),a.jsx(m,{label:t("nameLabel"),type:"text",name:"name",id:"name",placeholder:t("namePlaceholder"),autoFocus:!0,value:i.values.name}),a.jsx(m,{label:t("descriptionLabel"),component:"textarea",name:"description",id:"description",placeholder:t("descriptionPlaceholder"),value:i.values.description}),a.jsxs(l,{children:[a.jsx(l.Cancel,{onClick:e.onClickCancel}),a.jsx(l.Submit,{isNew:e.isNew,text:e.isNew&&t("createClip"),variant:"dark"})]})]})}function B(e){var i;return a.jsx(v,{initialValues:e.clip,validationSchema:z,onSubmit:e.saveClip,allowInitialSubmit:e.allowInitialSubmit,children:a.jsx(_,{video:e.video,isNew:!((i=e.clip)!=null&&i.id)||e.isCopying,onClickCancel:e.onClickCancel})})}function H(e){const i=y(),r=I(),c=o(V.currentUser()),d=o(k.video(e.videoId)),u=o(L.curationTags());function p(h){const g=u.data.find(n=>n.name===E.CLICKVIEW_CURATED),x={...h,permissions:q.getProtectedReadPermission(),owner:{id:c.data.id},tags:[{id:g.id}]};i(N.createClip(e.videoId,x)).then(n=>{r.success(`Successfully created clip <strong>${n.name}</strong>`),A.trigger({application:U.CLIPS,action:D.Clips.PREVIEW_CLIP,args:[n.id]},{replace:!0})}).catch(()=>r.error("Something went wrong while trying to create your clip. Please try again")).finally(e.closePopup)}const C=!!d.data&&!!c.data&&!!u.data;return a.jsx(F,{title:"Create clip",closePopup:e.closePopup,showLoadingSpinner:!C,children:a.jsx(B,{video:d.data,clip:{name:"",description:"",startTime:e.startTime,endTime:e.endTime,status:R.Draft},saveClip:p,onClickCancel:e.closePopup,isCopying:!1,allowInitialSubmit:!0})})}export{H as CreateClipDetailsView};
//# sourceMappingURL=DwOEWK5F.chunk.js.map
