import{b0 as k,bc as L,aX as S,az as c,bw as o,dK as w,aj as H,aI as q,aZ as U,v as d,T as l,f as u,e as m,cu as _,ao as e,aF as F,L as G,aq as p,aP as N,bU as I}from"./app-k0jcl5PQ.js";import{u as W}from"./2Rcc29RN.chunk.js";const i="interactives.contributeInteractive",t=G.encloseNamespace(i);function X(a){var C,f,T,j,V;const h=k(),{loading:R,handleGenerateReportError:b}=W(),x=L(),{hasPermissions:y,isLoaded:n}=S(),s=c(o.interactiveMetadata(a.interactiveMetadataId)),g=c(((f=(C=s.data)==null?void 0:C._parentVideo)==null?void 0:f.id)&&w.video((j=(T=s.data)==null?void 0:T._parentVideo)==null?void 0:j.id)),E=c(H.currentUser());async function A(){try{await h(o.contributeToCommunity(a.interactiveMetadataId)),x.success(t("success")),d.trigger({application:m.INTERACTIVES,action:u.Interactives.VIEW_INTERACTIVE,args:[a.interactiveMetadataId,l.slugify(s.data.name)]})}catch(M){b(M,t("error"),t("noEmailError"))}finally{a.closePopup()}}async function P(){try{await h(o.revokefromCommunity(a.interactiveMetadataId)),d.trigger({application:m.INTERACTIVES,action:u.Interactives.VIEW_INTERACTIVE,args:[a.interactiveMetadataId,l.slugify(s.data.name)]})}catch{x.error(t("error"))}finally{a.closePopup()}}q.useEffect(()=>{!n||!y(U.StudentExperience)||d.trigger({application:m.INTERACTIVES,action:u.Interactives.VIEW_INTERACTIVE,args:[a.interactiveMetadataId,l.slugify(s.data.name)]})},[n]);const r=_.isInExchange(g.data),v=s.hasCompleted&&g.hasCompleted&&n&&E.hasCompleted;return e.jsx(F,{title:t("title"),closePopup:a.closePopup,showLoadingSpinner:!v||R,children:v&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"alert alert-success p-2 fw-semibold text-success border-0",children:e.jsx(p,{namespace:i,phrase:"confirmationText"})}),e.jsx("div",{className:"p-2 px-4",children:e.jsx("img",{className:"img img-fluid px-5",src:r?N.Interactives.Contribute.EXCHANGE:N.Interactives.Contribute.SCHOOL})}),r?e.jsx("p",{children:e.jsx(p,{namespace:i,phrase:"exchangeMessage"})}):e.jsx("p",{children:e.jsx(p,{namespace:i,phrase:"schoolMessage",options:{schoolName:(V=E.data)==null?void 0:V.customerName}})}),e.jsxs(I,{children:[e.jsx(I.Cancel,{text:t("cancel"),onClick:P}),e.jsx(I.Submit,{onClick:A,text:t(r?"confirmExchange":"confirm"),variant:"outline-dark"})]})]})})}export{X as ContributeInteractiveView};
//# sourceMappingURL=D-56OnDA.chunk.js.map
