1import{j as e,r as v,u as we,B as Q,L as J,b as j,e as _e}from"./index-uPuoBMhx.js";import{c as K}from"./index-A7ElDbZk.js";import{B as S}from"./badge-CrRB5M6z.js";import{P as Ne}from"./pages.config-hgExbgEC.js";import{A as re,a as oe,b as ae,c as le}from"./accordion-CF13j6fk.js";import{T as Se,a as ke,b as X,c as Y}from"./tabs-CJ62Nd3v.js";import{p as Ce,D as Re,P as k,S as Le,V as u,T as r,I as Te}from"./react-pdf.browser-CLEewKCM.js";import{c as E,a as z,b as H,d as ie,e as ne,f as ce,g as de}from"./deriveDirectReports-CTgZh3AO.js";import{C as Ae,c as Be,M as De}from"./reviewAccess-CMQIA5K9.js";import{L as ze}from"./constants-C7eot9Ct.js";import{P as Fe}from"./PageContainer-DxZiU86J.js";import{L as Z}from"./loader-circle-CClJTEjr.js";import{F as me}from"./file-chart-column-increasing-Bp1oD-5u.js";import{A as $e}from"./arrow-left-CONOWcLb.js";import{C as Pe}from"./clipboard-check-Cw1HgXoO.js";import{B as Ie}from"./building-2-CH0TgYOF.js";import{D as Me}from"./trending-up-DI8OWV5v.js";import{L as Ve}from"./lock-BWkWm970.js";import{C as Ee}from"./circle-check-BO0sHK-q.js";import{a as He}from"./clock-D9btEWFO.js";import"./tooltip-B-l-dOqs.js";import"./index-BaASz1SR.js";import"./index-CPcWs2mZ.js";import"./index-Wvdu2dI_.js";import"./index-BLbwat6W.js";import"./index-ovzA6VBT.js";import"./index-BIK2eHIR.js";import"./skeleton-DOGFCoEw.js";import"./dialog-DXhopuNX.js";import"./index-Cu1sS3TT.js";import"./index-BmCJDWmK.js";import"./x-ChRmB3ff.js";import"./input-BmSpt0Eh.js";import"./label-BejpMhEw.js";import"./select-D07I9jAC.js";import"./index-BdQq_4o_.js";import"./index-DoY6TkfM.js";import"./chevron-down-BNqv1YJ1.js";import"./quill.snow-CfUTnqzn.js";import"./plus-nao29ywL.js";import"./dropdown-menu-iCIlU9cC.js";import"./link-q-TY0bPt.js";import"./circle-check-big-DOAasZi7.js";import"./mail-Dn9HRcgA.js";import"./textarea-lM6uA-MR.js";import"./switch-BehuccBp.js";import"./card-1lN1_Se8.js";import"./format-WoXbaKoi.js";import"./circle-alert-C0QDXt7F.js";import"./sparkles-BMLEjkPv.js";import"./square-pen-CBgOWTmU.js";import"./users-U-Rdm9PF.js";import"./crown-Dka_-Nxk.js";import"./waypoints-DB6uEXAV.js";import"./graduation-cap-DFwKZhhE.js";import"./arrow-right-VpgmkQjv.js";import"./SupervisedGuidesRoster-DrArdAB4.js";import"./avatar-Bhxn90qL.js";import"./ChurchTag-FinbzF8x.js";import"./clipboard-list-3xEa1kOf.js";import"./journeyApi-CQ6eKrk4.js";import"./search-CqNdnPxG.js";import"./external-link-DCG1godj.js";import"./video-CYNXJfA8.js";import"./proxy-kYcqYoy3.js";import"./JourneyCard-6WViabqj.js";import"./info-D7uJ7LVm.js";import"./shield-check-Ds0sNnHc.js";import"./globe-CcruHzdM.js";import"./badge-check-D0W_elOA.js";import"./megaphone-CGb0rIfX.js";import"./user-plus-DYMIVDGV.js";import"./sheet-CRixps9Y.js";import"./useQuery-BHFaz3Mh.js";import"./Loader-yhtKwwRu.js";import"./index-Ck7DnIc4.js";import"./user-CtT-IPS_.js";import"./index-DksKLqqw.js";import"./typeof-QjJsDpFa.js";import"./asyncToGenerator-BfWTt6ZC.js";import"./extends-CF3RwP-h.js";const N="#00584f",T="#c5914c",Oe="https://media.base44.com/images/public/68d5721b1b37e5d85630c192/79ce5d472_tmg_web_dark1.png",M={character:"Character",capacity:"Capacity","role-specific":"Role-Specific"},t=Le.create({page:{fontFamily:"Helvetica",fontSize:10,color:"#1a1a1a",padding:0,backgroundColor:"#ffffff"},pageWithFooter:{fontFamily:"Helvetica",fontSize:10,color:"#1a1a1a",paddingTop:48,paddingLeft:48,paddingRight:48,paddingBottom:56,backgroundColor:"#ffffff"},coverPage:{backgroundColor:N,flex:1,padding:60,justifyContent:"center"},coverEyebrow:{fontSize:11,color:"rgba(255,255,255,0.7)",letterSpacing:2,marginBottom:24,textTransform:"uppercase"},coverTitle:{fontSize:34,fontFamily:"Helvetica-Bold",color:"#ffffff",marginBottom:8,lineHeight:1.2},coverSubtitle:{fontSize:15,color:"rgba(255,255,255,0.85)",marginBottom:40},coverDivider:{width:60,height:3,backgroundColor:T,marginBottom:40},coverMeta:{flexDirection:"row",gap:32,flexWrap:"wrap"},coverMetaItem:{gap:4},coverMetaLabel:{fontSize:9,color:"rgba(255,255,255,0.6)",textTransform:"uppercase",letterSpacing:1},coverMetaValue:{fontSize:13,color:"#ffffff",fontFamily:"Helvetica-Bold"},coverScore:{marginTop:48,backgroundColor:"rgba(255,255,255,0.12)",borderRadius:12,padding:"20 28",alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:24},coverScoreNum:{fontSize:48,fontFamily:"Helvetica-Bold",color:"#ffffff"},coverScoreLabel:{fontSize:11,color:"rgba(255,255,255,0.75)"},coverScoreNote:{marginTop:4,fontSize:9,color:"rgba(255,255,255,0.65)",maxWidth:260},sectionEyebrow:{fontSize:8,color:T,letterSpacing:2,textTransform:"uppercase",marginBottom:6,fontFamily:"Helvetica-Bold"},sectionTitle:{fontSize:20,fontFamily:"Helvetica-Bold",color:N,marginBottom:4}
1,sectionSubtitle:{fontSize:10,color:"#6b7280",marginBottom:14},sectionDivider:{flexDirection:"row",alignItems:"center",marginBottom:22},sectionDividerAccent:{width:48,height:3,backgroundColor:T,borderRadius:2},sectionDividerLine:{flex:1,height:1,backgroundColor:"#dbe6e4",marginLeft:6},metricsGrid:{flexDirection:"row",gap:12,marginBottom:20,flexWrap:"wrap"},metricBox:{flex:1,minWidth:100,backgroundColor:"#f0f7f5",borderRadius:8,padding:"14 12",alignItems:"center",borderWidth:1,borderColor:"#d5e6e3"},metricValue:{fontSize:22,fontFamily:"Helvetica-Bold",color:N,marginBottom:2},metricLabel:{fontSize:8,color:"#6b7280",textAlign:"center"},scoreRow:{flexDirection:"row",alignItems:"center",marginBottom:10},scoreLabel:{fontSize:10,color:"#374151",width:150,fontFamily:"Helvetica-Bold"},scoreTrack:{flex:1,height:12,backgroundColor:"#e5e7eb",borderRadius:4,overflow:"hidden"},scoreFill:{height:12,borderRadius:4},scoreValue:{fontSize:10,fontFamily:"Helvetica-Bold",color:N,width:44,textAlign:"right"},competencyCard:{backgroundColor:"#f7faf9",borderWidth:1,borderColor:"#e0eae8",borderRadius:8,padding:14,marginBottom:12,breakInside:"avoid"},competencyHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"flex-start",marginBottom:8},competencyName:{fontSize:12,fontFamily:"Helvetica-Bold",color:"#1a1a1a"},competencyGroupTag:{fontSize:7,color:"#6b7280",textTransform:"uppercase",letterSpacing:.5,marginTop:2},competencyScoreBadge:{backgroundColor:N,borderRadius:6,paddingVertical:3,paddingHorizontal:8},competencyScoreBadgeText:{fontSize:11,fontFamily:"Helvetica-Bold",color:"#ffffff"},levelRow:{flexDirection:"row",alignItems:"center",marginTop:6},levelLabel:{fontSize:8,color:"#6b7280",width:130},levelTrack:{flex:1,height:8,backgroundColor:"#e5e7eb",borderRadius:3,overflow:"hidden"},levelFill:{height:8,backgroundColor:T,borderRadius:3},levelValue:{fontSize:8,color:"#374151",width:34,textAlign:"right"},commentBlock:{marginTop:8,fontSize:8.5,color:"#4b5563",fontStyle:"italic",lineHeight:1.5},selfCompareText:{fontSize:8,color:"#6b7280",marginTop:6},questionCard:{backgroundColor:"#f7faf9",borderWidth:1,borderColor:"#e0eae8",borderRadius:8,padding:12,marginBottom:10,breakInside:"avoid"},questionText:{fontSize:10,fontFamily:"Helvetica-Bold",color:"#1a1a1a",marginBottom:6},questionAnswer:{fontSize:9,color:"#374151",lineHeight:1.5},footer:{position:"absolute",bottom:20,left:48,right:48,flexDirection:"row",justifyContent:"space-between",alignItems:"center",borderTopWidth:1,borderTopColor:"#e5e7eb",paddingTop:8},footerText:{fontSize:8,color:"#9ca3af"},footerLogo:{height:20,width:60}});function qe(s){return s==null?"#9ca3af":s>=4.3?"#15803d":s>=3.5?"#b45309":s>=2.5?"#c2410c":"#b91c1c"}function B({revieweeName:s}){return e.jsxs(u,{style:t.footer,fixed:!0,children:[e.jsx(Te,{src:Oe,style:t.footerLogo}),e.jsxs(r,{style:t.footerText,children:[s," · Annual Leadership Review"]}),e.jsx(r,{style:t.footerText,render:({pageNumber:o,totalPages:a})=>`Page ${o} of ${a}`})]})}function D(){return e.jsxs(u,{style:t.sectionDivider,children:[e.jsx(u,{style:t.sectionDividerAccent}),e.jsx(u,{style:t.sectionDividerLine})]})}function V({label:s,score:o,max:a=5}){const x=o!=null?o/a*100:0;return e.jsxs(u,{style:t.scoreRow,children:[e.jsx(r,{style:t.scoreLabel,children:s}),e.jsx(u,{style:t.scoreTrack,children:e.jsx(u,{style:[t.scoreFill,{width:`${x}%`,backgroundColor:qe(o)}]})}),e.jsx(r,{style:t.scoreValue,children:o!=null?`${o} / ${a}`:"â"})]})}function We({review:s,churchName:o,overall:a,selfOverall:x,selfOnly:l}){return e.jsx(k,{size:"A4",style:t.page,children:e.jsxs(u,{style:t.coverPage,children:[e.jsx(r,{style:t.coverEyebrow,children:"Annual Leadership Review"}),e.jsx(r,{style:t.coverTitle,children:s.reviewee_name}),e.jsxs(r,{style:t.coverSubtitle,children:[s.reviewee_role_title||"Leader",s.reviewee_leadership_level?` · ${s.reviewee_leadership_level}`:""," · ",s.review_year," Review"]}),e.jsx(u,{style:t.coverDivider}),e.jsxs(u,{style:t.coverMeta,children:[e.jsxs(u,{style:t.coverMetaItem,children:[e.jsx(r,{style:t.coverMetaLabel,children:"Organization"}),e.jsx(r,{style:t.coverMetaValue,children:o||"â"})]}),e.jsxs(u,{style:t.coverMetaItem,children:[e.jsx(r,{style:t.coverMetaLabel,children:"Status"}),e.jsx(r,{style:t.coverMetaValue,children:s.status==="completed"?"Completed":"In Progress"})]}),e.jsxs(u,{style:t.coverMetaItem,children:[e.jsx(r,{style:t.coverMetaLabel,children:s.finalized_date?"Finalized":"Due Date"}),e.jsx(r,{style:t.coverMetaValue,children:s.finalized_date?new Date(s.finalized_date).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}):new Date(`${s.due_date}T00:00:00`).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})})]})]}),a.hasExternalFeedback&&a.score!==null?e.jsx(u,{style:t.coverScore,children:e.jsxs(u,{children:[e.jsx(r,{style:[t.coverMetaLabel,{color:"rgba(255,255,255,0.6)"}],children:"Overall Score"}),e.jsxs(r,{style:t.coverScoreNum,children:[a.score,e.jsx(r,{style:{fontSize:18},children:"/5"})]}),e.jsx(r,{style:t.coverScoreNote,children:"Average across all competencies, based on supervisor and peer feedback"})]})}):l&&x!==null?e.jsx(u,{style:t.coverScore,children:e.jsxs(u,{children:[e.jsx(r,{style:[t.coverMetaLabel,{color:"rgba(255,255,255,0.6)"}],children:"Self Score"}),e.jsxs(r,{style:t.coverScoreNum,children:[x,e.jsx(r,{style:{fontSize:18},children:"/5"})]}),e.jsx(r,{style:t.coverScoreNote,children:"No supervisor or peer reviewers were included in this cycle â this is the self-assessment score only."})]})}):e.jsx(u,{style:t.coverScore,children:e.jsx(r,{style:t.coverScoreNote,children:s.status==="completed"?"No supervisor or peer reviewers were included in this cycle, and no self-assessment score is available either.":"This review is still in progress. Scores will appear here once it's completed."})})]})})}function Ge({review:s,overall:o,selfOnly:a}){var n,h,p,d;const x=["character","capacity","role-specific"],l=H(s),c=a?z(s):o.score;return e.jsxs(k,{size:"A4",style:t.pageWithFooter,children:[e.jsx(r,{style:t.sectionEyebrow,children:"Overview"}),e.jsx(r,{style:t.sectionTitle,children:"Summary of Results"}),e.jsx(r,{style:t.sectionSubtitle,children:a?"Self-assessment only â no supervisor or peer feedback was collected for this cycle":`${((n=s.results)==null?void 0:n.submitted_count)??0} of ${((h=s.results)==null?void 0:h.reviewer_count)??0} reviewer${(((p=s.results)==null?void 0:p.reviewer_count)??0)===1?"":"s"} submitted (self-assessment shown separately, not included in this average)`}),e.jsx(D,{}),e.jsxs(u,{style:t.metricsGrid,children:[e.jsxs(u,{style:t.metricBox,children:[e.jsx(r,{style:t.metricValue,children:c!==null?c:"â"}),e.jsx(r,{style:t.metricLabel,children:a?"Self Score":"Overall Score"})]}),x.map(m=>{const i=a?ie(s,m):ne(s,m);return e.jsxs(u,{style:t.metricBox,children:[e.jsx(r,{style:t.metricValue,children:i!==null?i:"â"}),e.jsx(r,{style:t.metricLabel,children:M[m]})]},m)})]}),(((d=s.results)==null?void 0:d.competency_results)||[]).length>0&&e.jsxs(u,{children:[e.jsx(r,{style:{fontSize:11,fontFamily:"Helvetica-Bold",color:"#374151",marginBottom:10},children:"Competency Scores at a Glance"}),s.results.competency_results.map(m=>e.jsx(V,{label:m.competency_name,score:a?l.get(m.competency_id)??null:m.overall_average},m.competency_id))]}),e.jsx(B,{revieweeName:s.reviewee_name})]})}function Ue({review:s,selfOnly:o}){var n;const a=((n=s.results)==null?void 0:n.competency_results)||[];if(a.length===0)return null;const x=H(s),l=ce(s);return["character","capacity","role-specific"].filter(h=>a.some(p=>p.competency_group===h)).map(h=>{const p=a.filter(d=>d.competency_group===h);return e.jsxs(k,{size:"A4",style:t.pageWithFooter,children:[e.jsx(r,{style:t.sectionEyebrow,children:"Detail"}),e.jsxs(r,{style:t.sectionTitle,children:[M[h]," Competencies"]}
1),e.jsx(r,{style:t.sectionSubtitle,children:o?"Level-by-level self-assessment (no supervisor or peer feedback yet)":"Level-by-level breakdown, from supervisor and peer feedback"}),e.jsx(D,{}),p.map(d=>{const m=x.get(d.competency_id),i=l.get(d.competency_id);return e.jsxs(u,{style:t.competencyCard,children:[e.jsxs(u,{style:t.competencyHeader,children:[e.jsxs(u,{children:[e.jsx(r,{style:t.competencyName,children:d.competency_name}),e.jsx(r,{style:t.competencyGroupTag,children:M[d.competency_group]||d.competency_group})]}),e.jsx(u,{style:t.competencyScoreBadge,children:e.jsx(r,{style:t.competencyScoreBadgeText,children:o?m!==void 0?`${m} / 5 (self)`:"No self score":d.overall_average!==null&&d.overall_average!==void 0?`${d.overall_average} / 5`:"No responses"})})]}),(d.level_results||[]).map(f=>{var w;const g=o?((w=i==null?void 0:i.get(f.level))==null?void 0:w.score)??null:f.average_score;return e.jsxs(u,{style:t.levelRow,children:[e.jsxs(r,{style:t.levelLabel,children:[f.level," â ",f.expectation]}),e.jsx(u,{style:t.levelTrack,children:e.jsx(u,{style:[t.levelFill,{width:`${g?g/5*100:0}%`}]})}),e.jsx(r,{style:t.levelValue,children:g??"â"})]},f.level)}),!o&&m!==void 0&&e.jsxs(r,{style:t.selfCompareText,children:["Self-assessment: ",m," / 5",d.overall_average!==null&&d.overall_average!==void 0?` (feedback average: ${d.overall_average} / 5)`:""]}),!o&&d.comment_summary?e.jsx(r,{style:t.commentBlock,children:d.comment_summary}):null]},d.competency_id)}),e.jsx(B,{revieweeName:s.reviewee_name})]},h)})}function Qe({review:s,questions:o=[],selfOnly:a}){var c;const x=new Map(o.map(n=>[n.id,n]));if(a){const n=Array.from(de(s).values());return n.length===0?null:e.jsxs(k,{size:"A4",style:t.pageWithFooter,children:[e.jsx(r,{style:t.sectionEyebrow,children:"Detail"}),e.jsx(r,{style:t.sectionTitle,children:"Additional Questions"}),e.jsx(r,{style:t.sectionSubtitle,children:"Self-assessment answers (no supervisor or peer feedback yet)"}),e.jsx(D,{}),n.map(h=>{const p=x.get(h.question_id);return e.jsxs(u,{style:t.questionCard,children:[e.jsx(r,{style:t.questionText,children:(p==null?void 0:p.question_text)||"Question"}),(p==null?void 0:p.question_type)==="likert"?e.jsx(V,{label:"Self",score:h.likert_score}):e.jsx(r,{style:t.questionAnswer,children:h.open_text||"â"})]},h.question_id)}),e.jsx(B,{revieweeName:s.reviewee_name})]})}const l=((c=s.results)==null?void 0:c.additional_question_results)||[];return l.length===0?null:e.jsxs(k,{size:"A4",style:t.pageWithFooter,children:[e.jsx(r,{style:t.sectionEyebrow,children:"Detail"}),e.jsx(r,{style:t.sectionTitle,children:"Additional Questions"}),e.jsx(r,{style:t.sectionSubtitle,children:"Responses to questions beyond the core competencies"}),e.jsx(D,{}),l.map(n=>e.jsxs(u,{style:t.questionCard,children:[e.jsx(r,{style:t.questionText,children:n.question_text}),n.question_type==="likert"?e.jsx(V,{label:"Average",score:n.likert_average}):e.jsx(r,{style:t.questionAnswer,children:n.comment_summary||`${n.open_answer_count||0} response(s) â no summary available.`})]},n.question_id)),e.jsx(B,{revieweeName:s.reviewee_name})]})}function Je({review:s,churchName:o,questions:a=[]}){const x=E(s),l=!(s!=null&&s.results)||!s.results.reviewer_count,c=z(s);return e.jsxs(Re,{title:`${s.reviewee_name} ${s.review_year} Annual Review`,children:[e.jsx(We,{review:s,churchName:o,overall:x,selfOverall:c,selfOnly:l}),e.jsx(Ge,{review:s,overall:x,selfOnly:l}),e.jsx(Ue,{review:s,selfOnly:l}),e.jsx(Qe,{review:s,questions:a,selfOnly:l})]})}async function Ke({review:s,churchName:o,questions:a=[]}){const l=await Ce(e.jsx(Je,{review:s,churchName:o,questions:a})).toBlob(),c=URL.createObjectURL(l),n=document.createElement("a"),h=`${(s.reviewee_name||"leader").toLowerCase().replace(/[^a-z0-9]+/g,"-")}-${s.review_year||"review"}`;n.href=c,n.download=`annual-review-${h}.pdf`,document.body.appendChild(n),n.click(),n.remove(),URL.revokeObjectURL(c)}const Xe={character:"Character",capacity:"Capacity","role-specific":"Role-Specific"},ee={pending:{label:"Not Started",className:"bg-gray-100 text-gray-700",icon:De},in_progress:{label:"In Progress",className:"bg-blue-100 text-blue-800",icon:He},submitted:{label:"Submitted",className:"bg-green-100 text-green-800",icon:Ee}};
1function A({label:s,average:o,count:a,max:x=5}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-baseline mb-1",children:[e.jsx("span",{className:"text-sm text-gray-700",children:s}),e.jsxs("span",{className:"text-sm font-medium text-gray-900",children:[o!=null?`${o} / ${x}`:"No responses",a?e.jsxs("span",{className:"text-gray-400 font-normal ml-1",children:["(",a,")"]}):null]})]}),e.jsx(Ne,{value:o?o/x*100:0,className:"h-2"})]})}function te({value:s,label:o}){return e.jsxs("div",{className:"bg-white rounded-xl border border-gray-100 shadow-sm p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-[#00584f] mb-1",children:s??"â"}),e.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wide",children:o})]})}function Ye({invitations:s,review:o}){const a=v.useMemo(()=>{var c;return new Map((((c=o.results)==null?void 0:c.competency_results)||[]).map(n=>[n.competency_id,n]))},[o]),x=v.useMemo(()=>{var c;return new Map((((c=o.results)==null?void 0:c.additional_question_results)||[]).map(n=>[n.question_id,n]))},[o]),l=s.filter(c=>c.status==="submitted"&&c.reviewer_type!=="self");return l.length===0?e.jsx("p",{className:"text-gray-500 text-sm",children:"No non-self reviewers have submitted yet."}):e.jsx(re,{type:"multiple",className:"space-y-2",children:l.map(c=>{var n,h;return e.jsxs(oe,{value:c.id,className:"border rounded-lg px-4 bg-white",children:[e.jsx(ae,{className:"hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-3 text-left",children:[e.jsx("span",{className:"font-medium",children:c.reviewer_name}),e.jsx(S,{variant:"outline",className:"capitalize",children:c.reviewer_type})]})}),e.jsxs(le,{className:"space-y-4 pb-4",children:[(((n=c.responses)==null?void 0:n.competency_scores)||[]).map(p=>{const d=a.get(p.competency_id);return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-800",children:(d==null?void 0:d.competency_name)||"Unknown Competency"}),(p.level_scores||[]).map(m=>e.jsxs("div",{className:"pl-3 border-l-2 border-gray-200",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600",children:m.level}),e.jsxs("span",{className:"font-medium text-gray-900",children:[m.score??"â"," / 5"]})]}),m.comment&&e.jsx("p",{className:"text-sm text-gray-500 italic mt-0.5",children:m.comment})]},m.level))]},p.competency_id)}),(((h=c.responses)==null?void 0:h.additional_answers)||[]).length>0&&e.jsx("div",{className:"space-y-2 pt-2 border-t",children:c.responses.additional_answers.map(p=>{const d=x.get(p.question_id);return e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-gray-700 font-medium",children:(d==null?void 0:d.question_text)||"Question"}),e.jsx("p",{className:"text-gray-600",children:(d==null?void 0:d.question_type)==="likert"?`${p.likert_score??"â"} / 5`:p.open_text||"â"})]},p.question_id)})})]})]},c.id)})})}function se({review:s,questions:o=[]}){const a=s.results,x=E(s),l=H(s),c=z(s),n=ce(s),h=de(s),p=v.useMemo(()=>new Map(o.map(i=>[i.id,i])),[o]),d=["character","capacity","role-specific"],m=!a||a.reviewer_count===0;return!a||!(a.competency_results||[]).length?e.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-gray-100 p-8 text-center",children:[e.jsx(me,{className:"w-10 h-10 text-gray-300 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-700 font-medium",children:"No results to report yet"}),e.jsx("p",{className:"text-gray-500 text-sm mt-1 max-w-md mx-auto",children:"This review doesn't have any recorded responses yet."})]}):e.jsxs("div",{className:"space-y-8",children:[m&&e.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-xl p-4 text-sm text-amber-800",children:"No supervisor or peer reviewers were included in this review cycle, so these are self-assessment scores only â not yet compared against outside feedback. Start a new review and add at least one other reviewer to get feedback scores here."}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(te,{value:m?c:x.score,label:m?"Self Score":"Overall Score"}),d.map(i=>e.jsx(te,{value:m?ie(s,i):ne(s,i),label:Xe[i]},i))]}),e.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-gray-100 p-6 md:p-8",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 mb-1",children:"Competency Scores"}),e.jsx("p",{className:"text-sm text-gray-500 mb-5",children:m?"Self-assessment only â no supervisor or peer feedback collected yet":`${a.submitted_count} of ${a.reviewer_count} reviewer${a.reviewer_count===1?"":"s"} submitted (self-assessment shown separately, not included in this average)`}),e.jsx(re,{type:"multiple",className:"space-y-2",children:(a.competency_results||[]).map(i=>{var w;const f=l.get(i.competency_id),g=n.get(i.competency_id);return e.jsxs(oe,{value:i.competency_id,className:"border rounded-lg px-4",children:[e.jsx(ae,{className:"hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-3 text-left flex-wrap",children:[e.jsx(S,{variant:"outline",className:"capitalize",children:(w=i.competency_group)==null?void 0:w.replace("-"," ")}),e.jsx("span",{className:"font-medium",children:i.competency_name}),e.jsx("span",{className:"text-gray-500 text-sm",children:m?f!==void 0?`${f} / 5 (self)`:"No self score":i.overall_average!==null?`${i.overall_average} / 5`:"No responses"}),!m&&f!==void 0&&e.jsxs("span",{className:"text-xs text-gray-400",children:["Self: ",f," / 5"]})]})}),e.jsxs(le,{className:"space-y-4 pb-4",children:[!m&&i.comment_summary&&e.jsx("p",{className:"text-sm text-gray-600 bg-gray-50 rounded-md p-3 italic",children:i.comment_summary}),e.jsx("div",{className:"space-y-3",children:(i.level_results||[]).map(y=>{var C,R;return m?e.jsxs("div",{children:[e.jsx(A,{label:`${y.level} â ${y.expectation}`,average:((C=g==null?void 0:g.get(y.level))==null?void 0:C.score)??null}),((R=g==null?void 0:g.get(y.level))==null?void 0:R.comment)&&e.jsx("p",{className:"text-xs text-gray-500 italic mt-1",children:g.get(y.level).comment})]},y.level):e.jsx(A,{label:`${y.level} â ${y.expectation}`,average:y.average_score,count:y.response_count},y.level)})})]})]},i.competency_id)})})]}),m?h.size>0&&e.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-gray-100 p-6 md:p-8",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 mb-5",children:"Additional Questions (Self-Assessment)"}),e.jsx("div",{className:"space-y-3",children:Array.from(h.values()).map(i=>{const f=p.get(i.question_id);return e.jsxs("div",{className:"border rounded-lg p-3",children:[e.jsx("p",{className:"font-medium text-sm text-gray-900",children:(f==null?void 0:f.question_text)||"Question"}),(f==null?void 0:f.question_type)==="likert"?e.jsx("div",{className:"mt-2",children:e.jsx(A,{label:"Self",average:i.likert_score})}):e.jsx("p",{className:"text-sm text-gray-600 mt-2 italic",children:i.open_text||"â"})]},i.question_id)})})]}):(a.additional_question_results||[]).length>0&&e.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-gray-100 p-6 md:p-8",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 mb-5",children:"Additional Questions"}),e.jsx("div",{className:"space-y-3",children:a.additional_question_results.map(i=>e.jsxs("div",{className:"border rounded-lg p-3",children:[e.jsx("p",{className:"font-medium text-sm text-gray-900",children:i.question_text}),i.question_type==="likert"?e.jsx("div",{className:"mt-2",children:e.jsx(A,{label:"Average",average:i.likert_average,count:i.likert_response_count})}):e.jsx("p",{className:"text-sm text-gray-600 mt-2 italic",children:i.comment_summary||`${i.open_answer_
1count} response(s), no summary available.`})]},i.question_id))})]})]})}function Ze({review:s,invitations:o}){return e.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-gray-100 p-6 md:p-8",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 mb-4",children:"Reviewers"}),e.jsx("div",{className:"space-y-3",children:o.map(a=>{const x=ee[a.status]||ee.pending,l=x.icon;return e.jsxs("div",{className:"flex items-center justify-between border rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l,{className:"w-4 h-4 text-gray-400"}),e.jsx("span",{className:"text-sm font-medium",children:a.reviewer_name}),e.jsx(S,{variant:"outline",className:"capitalize text-xs",children:a.reviewer_type})]}),e.jsx(S,{className:x.className,children:x.label})]},a.id)})}),e.jsx("p",{className:"text-xs text-gray-500 pt-4",children:"This report will fill in with scores once every reviewer submits, or the review is closed manually from the Reviews page."})]})}function et(){const[s,o]=v.useState(!0),[a,x]=v.useState(null),[l,c]=v.useState(null),[n,h]=v.useState([]),[p,d]=v.useState([]),[m,i]=v.useState(""),[f,g]=v.useState(null),[w,y]=v.useState(!1),[C,R]=v.useState("results"),O=we();v.useEffect(()=>{(async()=>{var W;o(!0);try{const F=new URLSearchParams(O.search).get("id");if(!F){o(!1),c(null);return}const[$,b]=await Promise.all([j.auth.me(),j.entities.Review.get(F)]);if(x($),!b||b.deleted_at){c(null),o(!1);return}const[fe,ge,ye,ve,P,be,je]=await Promise.all([j.entities.OrgChartRole.filter({corporate_account_id:b.corporate_account_id,deleted_at:null}),j.entities.TeamStructure.filter({corporate_account_id:b.corporate_account_id,deleted_at:null}),j.entities.VolunteerProfile.filter({corporate_account_id:b.corporate_account_id,deleted_at:null}),j.entities.VolunteerRoleAssignment.filter({corporate_account_id:b.corporate_account_id,deleted_at:null,is_primary:!0}),j.entities.CorporateProfile.filter({corporate_account_id:b.corporate_account_id}),j.entities.ReviewInvitation.filter({review_id:F,deleted_at:null}),j.entities.ReviewQuestion.filter({corporate_account_id:b.corporate_account_id,deleted_at:null})]),I=Be({user:$,volunteers:ye,roles:fe,teams:ge,roleAssignments:ve}),U=!!(b.reviewee_user_id&&$.id===b.reviewee_user_id);if(!(I.canViewAll||I.matchesReview(b)||U)){c(null),o(!1);return}g({...I,isOwnReview:U}),c(b),h(be||[]),d(je||[]),i(((W=P==null?void 0:P[0])==null?void 0:W.church_name)||"")}catch(G){console.error("[AnnualReview] Failed to load report:",G),c(null)}finally{o(!1)}})()},[O.search]);const ue=async()=>{y(!0);try{await new Promise(L=>setTimeout(L,50)),await Ke({review:l,churchName:m,questions:p})}catch(L){console.error("[AnnualReview] Failed to generate PDF:",L),_e.error("Failed to generate the PDF. Please try again.")}finally{y(!1)}};if(s)return e.jsx("div",{className:"flex items-center justify-center min-h-screen bg-gradient-to-br from-gray-50 to-gray-100",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Z,{className:"h-12 w-12 animate-spin text-[#00584f] mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600",children:"Loading the review..."})]})});if(!l)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-gray-50 to-gray-100 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center max-w-md",children:[e.jsx("div",{className:"w-20 h-20 bg-gray-200 rounded-full flex items-center justify-center mx-auto mb-6",children:e.jsx(me,{className:"w-10 h-10 text-gray-400"})}),e.jsx("h2",{className:"text-2xl font-bold text-gray-800 mb-3",children:"Review Not Found"}),e.jsx("p",{className:"text-gray-600 mb-6",children:"We couldn't find this review, or you don't have permission to view it."}),e.jsx(Q,{asChild:!0,className:"bg-[#00584f] hover:bg-[#004d45]",children:e.jsx(J,{to:K("Reviews"),children:"Back to Reviews"})})]})});const pe=!(f!=null&&f.isOwnReview),_=E(l),xe=z(l),q=_.hasExternalFeedback&&_.score!==null?_.score:xe,he=_.hasExternalFeedback&&_.score!==null?"Overall / 5":"Self / 5";return e.jsxs("div",{className:"space-y-8",children:[e.jsx("div",{className:"overflow-hidden rounded-2xl shadow-sm border border-gray-100",children:e.jsx("div",{className:"bg-gradient-to-br from-[#00584f] via-[#004d45] to-[#003d37] p-8 md:p-12",children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs(J,{to:K("Reviews"),className:"inline-flex items-center gap-1.5 text-white/80 hover:text-white text-sm mb-6 transition-colors",children:[e.jsx($e,{className:"w-4 h-4"}),"Back to Reviews"]}),e.jsxs("div",{className:"flex flex-col md:flex-row items-start md:items-center gap-6",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-20 h-20 md:w-24 md:h-24 bg-white/90 backdrop-blur-sm rounded-2xl shadow-xl flex items-center justify-center",children:e.jsx(Pe,{className:"w-10 h-10 md:w-12 md:h-12 text-[#00584f]"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-white mb-2 break-words",children:l.reviewee_name}),e.jsxs("p",{className:"text-white/90 text-lg font-medium mb-4",children:[l.reviewee_role_title||"No role on file"," · ",l.review_year," Annual Review"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[l.reviewee_leadership_level&&e.jsx(S,{variant:"outline",className:`${ze[l.reviewee_leadership_level]} bg-white/10 border-white/30 text-white`,children:l.reviewee_leadership_level}),m&&e.jsxs("div",{className:"flex items-center gap-2 text-white/90 bg-white/10 backdrop-blur-sm px-3 py-1.5 rounded-lg",children:[e.jsx(Ie,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:m})]}),e.jsxs("div",{className:"flex items-center gap-2 text-white/90 bg-white/10 backdrop-blur-sm px-3 py-1.5 rounded-lg",children:[e.jsx(Ae,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:l.status==="completed"?`Finalized ${l.finalized_date?new Date(l.finalized_date).toLocaleDateString():""}`:`Due ${new Date(`${l.due_date}T00:00:00`).toLocaleDateString()}`})]}),e.jsx(Q,{onClick:ue,disabled:w||l.status!=="completed",className:"bg-white/10 hover:bg-white/20 text-white border border-white/20 backdrop-blur-sm",title:l.status!=="completed"?"Available once the review is completed":void 0,children:w?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"w-4 h-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{className:"w-4 h-4 mr-2"}),"Download PDF"]})})]})]}),l.status==="completed"&&q!==null&&e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"bg-white rounded-xl p-4 shadow-lg",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-4xl font-bold text-[#00584f] mb-1",children:q}),e.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wide",children:he})]})})})]})]})})}),l.status==="in_progress"?e.jsx(Ze,{review:l,invitations:n}):pe?e.jsxs(Se,{value:C,onValueChange:R,children:[e.jsxs(ke,{children:[e.jsx(X,{value:"results",children:"Results"}),e.jsxs(X,{value:"individual",children:[e.jsx(Ve,{className:"w-3.5 h-3.5 mr-1.5"}),"Individual Responses"]})]}),e.jsx(Y,{value:"results",className:"mt-6",children:e.jsx(se,{review:l,questions:p})}),e.jsx(Y,{value:"individual",className:"mt-6",children:e.jsx("div",{className:"bg-white rounded-2xl shadow-sm border border-gray-100 p-6 md:p-8",children:e.jsx(Ye,{invitations:n,review:l})})})]}):e.jsx(se,{review:l,questions:p}),e.jsxs("div",{className:"text-center py-8 border-t border-gray-200 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 text-gray-500 mb-2",children:[e.jsx("div",{className:"w-2 h-2 bg-[#c5914c] rounded-full"}),e.jsx("div",{className:"w-2 h-2 bg-[#00584f] rounded-full"}),e.jsx("div",{className:"w-2 h-2 bg-[#c5914c] rounded-full"})]}),e.jsxs("p",{className:"text-gray-600 text-sm",children:["This review is confidential and prepared exclusively for ",l.reviewee_name,"."]})]})]})}function Ls(){return e.jsx(Fe,{children:e.jsx(et,{})})}
1export{Ls as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.