import{c4 as N,bc as V,az as i,bw as s,aI as _,o,W as c,p as r,E as p,r as l,v as A,f as S,e as T,ao as e,aF as B,L as F,bU as d,fD as P,dv as H,m as W}from"./app-k0jcl5PQ.js";import{g as u}from"./kHHlT7Na.chunk.js";const q="interactives.unpublishInteractive",h=F.encloseNamespace(q);function Y(I){var y,b,C,E;const{interactiveMetadataId:w,closePopup:v}=I,x=N(),U=V(),t=i(s.interactiveMetadata(w)),g=i(t.data?s.interactiveResultSet(t.data.interactiveId,t.data.id):null),n=i(s.isContributed(I.interactiveMetadataId)),D=!!((y=n.data)!=null&&y.community)||!!((b=n==null?void 0:n.data)!=null&&b.school),[R,j]=_.useState(!1);function k(){j(!0);const a={name:t.data.name,description:t.data.description,status:H.Draft};W(x,s.updateInteractiveMetadata(t.data.id,a,L,M))}function L(){v(),A.trigger({application:T.INTERACTIVES,action:S.Interactives.EDIT_INTERACTIVE,args:[t.data.id]});const a=u(t.data);o.logUserAction(a,{actionType:l.Publish,entity:p.Interactive,location:r.UnpublishInteractive,workflowPhase:c.Complete,descriptor:P.Unpublish})}function m(){const a=u(t.data);o.logUserAction(a,{actionType:l.Publish,entity:p.Interactive,location:r.UnpublishInteractive,workflowPhase:c.Discard,descriptor:P.Unpublish}),v()}function M(){U.error(h("error"))}const f=!!t.data&&!!g.data&&!!n.hasCompleted;if(f&&((E=(C=g.data)==null?void 0:C.students)!=null&&E.length||D)){const a=u(t.data);return o.logUserAction(a,{actionType:l.Copy,entity:p.Interactive,location:r.UnpublishInteractive,workflowPhase:c.Start}),A.trigger({application:T.INTERACTIVES,action:S.Interactives.COPY_INTERACTIVE,args:[t.data.id],params:{fromEdit:!0}}),e.jsx(e.Fragment,{})}return e.jsxs(B,{title:"Edit interactive",closePopup:m,showLoadingSpinner:!f,children:[e.jsx("p",{dangerouslySetInnerHTML:{__html:h("popupBody")}}),e.jsxs(d,{children:[e.jsx(d.Cancel,{onClick:m}),e.jsx(d.Submit,{variant:"danger",onClick:k,text:h("edit"),showSpinner:R})]})]})}export{Y as UnpublishInteractiveView};
//# sourceMappingURL=yhRPyePi.chunk.js.map
