import{l as y,k as B,o as p,e8 as a,R as b,j as d,aR as L,aS as V,dT as j}from"./app-BgLa5dit.js";import{C as E}from"./RP02HACF.chunk.js";import{E as x}from"./BZdMvuHR.chunk.js";import{E as U}from"./D-bfnq46.chunk.js";import{g as A}from"./DdbSDhh9.chunk.js";import"./w68yffRy.chunk.js";import"./CanLAf7a.chunk.js";import"./B0KtsevF.chunk.js";import"./IEOSPmnY.chunk.js";import"./C8_78Eqq.chunk.js";import"./Bkj-W53y.chunk.js";import"./KIVqng-q.chunk.js";import"./DIopWku2.chunk.js";import"./B4CwEi02.chunk.js";import"./CULwvqVp.chunk.js";import"./VIUZq4Vp.chunk.js";import"./B3xA170I.chunk.js";import"./t8cVFCZO.chunk.js";import"./Cu2-dDll.chunk.js";import"./kOrk-qeI.chunk.js";function tt(e){var P;const m=y(),o=B(),n=p(a.getContentPartner(e.contentPartnerId)),i=p(L.currentUser()),I=p(j.contentRegions()),[r,u]=b.useState(null);async function h(t){u(t)}async function k(t,l){var f,R,w;const s=E.getPartnerLinkObjectByType(n.data.links,"website"),g=!!((f=t.websiteLink)!=null&&f.length),C={...V.omit(t,["contentRegions","parent","websiteLink"]),contentRegionIds:t.contentRegions.map(c=>c.id),websiteLink:g?t.websiteLink:null,parentId:(R=t.parent)==null?void 0:R.id};try{if(await o(a.updateContentPartner(e.contentPartnerId,C,l,l)),s!=null&&s.id&&!g&&await o(a.deleteContentPartnerLink(e.contentPartnerId,s.id)),!C.videoBanner&&n.data.videoBanner&&await o(a.deleteContentPartnerVideoBanner(e.contentPartnerId,n.data.videoBanner.id)),r)if(r.masterVideoId&&r.pendingProcessId)await o(a.updateVideoBanner(n.data._slug.value,r.masterVideoId,r.pendingProcessId)),u(null);else throw new Error("Pending video banner is not valid.");m.success("Successfully updated the content partner.")}catch(c){m.error(((w=c.responseJSON)==null?void 0:w.message)||"There was an error updating the content partner. Please try again.")}}const v=A();return d.jsxs(d.Fragment,{children:[!!i.data&&d.jsx(U,{contentPartnerId:e.contentPartnerId,activeAction:v.editContentPartner(e.contentPartnerId).action,currentUser:i.data}),!!n.data&&!!i.data&&d.jsx(x,{currentUser:i.data,contentPartner:n.data,contentRegions:(P=I.data)==null?void 0:P.data,onSave:k,onVideoUploadComplete:h})]})}export{tt as EditContentPartnerView};
//# sourceMappingURL=BRte7WbI.chunk.js.map
