import{cg as O,L as i,c4 as F,aI as a,m as w,bw as f,t as D,ay as _,az as o,bu as $,aj as C,bN as Q,eb as W,ec as z,h6 as R,ao as r,dv as B,W as G,p as T,E as J,dc as A,o as j,r as k,v as S,f as X,e as Y,h7 as Z,ff as tt,h5 as et}from"./app-k0jcl5PQ.js";import{u as rt}from"./CAxN5LKv.chunk.js";import{C as at,I as it}from"./C6o7Noe-.chunk.js";import{I as N}from"./COlNonQJ.chunk.js";import{g as st}from"./kHHlT7Na.chunk.js";import{I as L}from"./DTRakM4e.chunk.js";import"./DIAJ896Y.chunk.js";import"./DCUV69GJ.chunk.js";import"./Crww-RVm.chunk.js";import"./80MCcucU.chunk.js";import"./ZlF_2kui.chunk.js";import"./Bj7bJt_4.chunk.js";import"./CGYNvpr2.chunk.js";import"./Q_WQ5xs9.chunk.js";import"./DdN4NAtQ.chunk.js";import"./CBiwFpxE.chunk.js";import"./BYBYoVkn.chunk.js";import"./CW7x8M-z.chunk.js";import"./CIa53I7v.chunk.js";import"./BhTtYYQR.chunk.js";import"./CCcIOoB4.chunk.js";import"./CovOloHp.chunk.js";import"./Cu7pgtf6.chunk.js";import"./B31bqZwo.chunk.js";import"./uoUaCILN.chunk.js";import"./GA2y9Z4q.chunk.js";import"./CvO2hNpe.chunk.js";import"./NRZx5qCo.chunk.js";import"./CNtKSILN.chunk.js";import"./CG1PE8VW.chunk.js";import"./CX9BGBTP.chunk.js";import"./CMnqIsoM.chunk.js";import"./U4M4wGTR.chunk.js";import"./DoFMWlew.chunk.js";import"./DtZoWt5r.chunk.js";import"./wCY37Ze3.chunk.js";import"./BHJbqrq4.chunk.js";import"./lKJuB19y.chunk.js";import"./BlAcjINT.chunk.js";import"./QjJsDpFa.chunk.js";import"./D7h2WwBF.chunk.js";import"./Bg9cG42T.chunk.js";import"./ByBCp1MC.chunk.js";import"./DwvfEevL.chunk.js";import"./BDeUEvb2.chunk.js";import"./BDviDDog.chunk.js";import"./BfnLVVhM.chunk.js";const g="shared.cannotEditPublishedInteractive";class nt extends O{constructor(){super(i.getPhrase(g,"title"))}get name(){return"CannotEditPublishedInteractiveError"}get heading(){return i.getPhrase(g,"heading")}get description(){return i.getPhrase(g,"description")}}const h="shared.cannotEditInteractive";class ot extends O{constructor(){super(i.getPhrase(h,"title"))}get name(){return"CannnotEditInteractiveError"}get heading(){return i.getPhrase(h,"heading")}get description(){return i.getPhrase(h,"description")}}const ct=e=>{const s=F(),[l,m]=a.useState(!1),[c,d]=a.useState(!1);return a.useEffect(()=>{if(!e||c||l)return;if(e.originType===L.Original){d(!0);return}const p=()=>{D.throw(new ot)},n=u=>{const t={originType:L.Original,interactiveId:u.id};w(s,f.updateInteractiveMetadata(e.id,t,()=>d(!0),p))};m(!0),w(s,f.copyInteractive(e.interactiveId,n,p))},[e]),c},dt="interactives.editInteractiveView",pt=i.encloseNamespace(dt),U={application:Y.INTERACTIVES,action:X.Interactives.EDIT_INTERACTIVE_DETAILS},ut={notFound:et,forbidden:{privacy:tt}};function se(e){const[s,l]=a.useState(!1),[m,c]=a.useState(!1),d=a.useRef(null),{experimentalInteractiveQuestions:p}=_(null),n=o($.config()),u=o(C.currentUser()),t=o(!!u.data&&f.interactiveMetadata(e.id));Q({title:t.data?pt("pageTitle",{name:t.data.name}):null});const V=ct(t.data),y=o(V?W.createViewKey(t.data.id,z.MasterObject):null),v=o(C.token()),I=a.useMemo(()=>R(),[]),E=a.useMemo(()=>R(),[]),q=a.useRef(null);rt(t,ut);function H(b){d.current=b,l(!0),q.current=new Z({player:b,video:t.data,analyticsLocation:T.EditInteractive})}if(!y.data||!n.data||!t.data||!v.data)return r.jsx(N,{});if(!m&&(c(!0),t.data.status!==B.Draft))return D.throw(new nt),null;const P=st(t.data),x={entity:J.Interactive,location:T.EditInteractive,workflowPhase:G.Start};function K(){j.logUserAction(P,{actionType:k.Edit,...x}),S.trigger({...U,args:[e.id]})}function M(){j.logUserAction(P,{actionType:k.Publish,...x}),S.trigger({...U,args:[e.id],params:{publish:!0}})}return r.jsxs(r.Fragment,{children:[!s&&r.jsx(N,{}),r.jsxs("div",{className:`px-3 ${s?"":"d-none"}`,children:[r.jsxs("div",{className:"d-flex justify-content-between align-items-center mb-3",children:[r.jsx("h1",{className:"h3 text-truncate mb-0 pb-1",children:t.data.name}),r.jsx("div",{className:"flex-shrink-0",children:r.jsx(A,{node:I})})]}),r.jsx(at,{viewKey:y.data.viewKey,imageApi:new URL(n.data.imageCdnUrl),playerApi:new URL(n.data.playerApiUrl),hotkeyElQuerySelector:"body",autoplay:!0,onReady:H,currentUser:u.data,mode:it.Create,actionsPortalNode:I,questionListPortalNode:E,authToken:v.data.value,onClickEditDetails:K,onClickPublish:M,enableImmersiveReader:!0,experimentalInteractiveQuestions:p}),r.jsx(A,{node:E})]})]})}export{se as EditInteractiveView};
//# sourceMappingURL=DIRSP2lC.chunk.js.map
