import{bc as q,b0 as E,aI as k,az as c,aj as F,aA as U,bw as g,ao as t,aO as G,aF as N,L,aq as I,bU as u}from"./app-k0jcl5PQ.js";import{b as M}from"./CBeYA-N4.chunk.js";import{I as D}from"./s-4A5pEU.chunk.js";import{a as H}from"./BzIt8QkE.chunk.js";import{g as T,c as B}from"./CssKhUy4.chunk.js";import{I as a}from"./CG1PE8VW.chunk.js";import{u as O}from"./CAxN5LKv.chunk.js";import{u as V}from"./2Rcc29RN.chunk.js";import{I as z}from"./CNtKSILN.chunk.js";import{g as Q,a as J}from"./CX9BGBTP.chunk.js";import{b as K}from"./Bc38NwUJ.chunk.js";import"./B6Awc0tS.chunk.js";import"./Bcve7ust.chunk.js";import"./CnoMMtVD.chunk.js";import"./B31bqZwo.chunk.js";import"./uoUaCILN.chunk.js";import"./BEDdXV-K.chunk.js";import"./DIAJ896Y.chunk.js";import"./_XP6hjk3.chunk.js";const f="shared.generateReport",r=L.encloseNamespace(f);function he(s){var l,p,h;const R=q(),v=E(),[x,j]=k.useState(!1),{loading:b,handleGenerateReportError:C}=V(),n=c(F.currentUser()),m=c(U.getShare(s.shareId)),o=c(((l=m.data)==null?void 0:l.objectId)&&g.interactiveMetadata(m.data.objectId)),i=c(((p=o.data)==null?void 0:p.interactiveId)&&g.interactive(o.data.interactiveId)),y=K(s.shareId);O([i,o]);const d=Q(i.data),P=M(i.data,y.data,!1,!1);function S(){j(!0);const w={interactiveName:o.data.name,userId:n.data.id,customerId:n.data.customerId,questions:d.map(e=>e.name),rows:P.map(e=>({name:H(e.user,!1),email:e.user.email,username:e.user.username,unanswered:e.summary.unanswered,percentage:T(B(e.summary.percentCorrect)),correct:e.summary.correct,totalQuestions:e.summary.answered+e.summary.unanswered,results:d.map(A=>{switch(z.isInteractionCorrect(A,J(e))){case a.Correct:return r("correct");case a.Incorrect:return r("incorrect");case a.NotApplicable:return"-";case a.AwaitingMarking:return r("awaitingMarking");case a.UnAnswered:case a.Answered:default:return""}})}))};v(D.interactiveResultsReport(w)).then(()=>{R.success(r("success"))}).catch(e=>C(e,r("error"),r("noEmailError"))).finally(s.closePopup)}return t.jsx(G.Provider,{value:f,children:t.jsx(N,{title:r("title"),showLoadingSpinner:!n.hasCompleted||b,closePopup:s.closePopup,children:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:t.jsx(I,{phrase:"description"})}),t.jsx("p",{children:t.jsx(I,{phrase:"emailDescription",options:{email:(h=n.data)==null?void 0:h.email}})}),t.jsxs(u,{children:[t.jsx(u.Cancel,{onClick:s.closePopup}),t.jsx(u.Submit,{variant:"dark",onClick:S,text:r("generateReport"),showSpinner:x})]})]})})})}export{he as GenerateInteractiveResultsReportView};
//# sourceMappingURL=CyS5n-CE.chunk.js.map
