PageSourceSearch

https://my.monroeinstitute.org/assets/index-DPe_8UMB.js

js monroeinstitute.org collected 2026-09-24 08:46:03 UTC 88,753 bytes, 1 lines download raw bytes

1import{j as e}from"./jsx-runtime-D0s_QEiX.js";import{al as ae,am as Tt,an as kt,ao as It,ap as Vt,aq as Rt,ar as Et,S as W,as as Ft,at as Mt,au as Ee,av as Lt,aw as _t,ax as De,ay as Bt,P as Ut,az as Ot,aA as $t,K as I,g as le,aB as Wt,aC as zt,aD as Xt,G as Ht,aE as Gt,aF as qt,aG as Yt,aH as Kt,aI as Qt,aJ as Jt,aK as Zt}from"./database-models-DyTQVKu0.js";import{j as ea,k as ta,t as aa,l as sa,d as ne,f as z,c as et}from"./session-block-form-utils-WuQyIFq6.js";import{I as de}from"./index-CEcQJZ8N.js";import{r as b,A as Te,D as na,z as tt}from"./chunk-EVOBXE3Y-BApN7SSY.js";import{f as ve}from"./money-IAJhVEfl.js";import{S as ra,T as ia,h as oa,p as ye,q as la,r as da,t as ca,v as ua,w as pa,g as ma,a as fe,C as be,P as at,D as st,x as nt,V as v,y as fa,W as rt,B as ha,b as X,E as $e,d as Fe}from"./application-requirement-iLNYJpaY.js";import{C as it,m as ga,E as Pe}from"./form-theme-DJm_MbNE.js";import"./use-trainer-access-DYyNX1xj.js";import{u as re}from"./useTranslation-C7xSDmjz.js";import{u as G}from"./useMutation-B14VQVEf.js";import{u as Z}from"./useQuery-xKopMHFq.js";import{F as We}from"./ExclamationTriangleIcon-7CkiH-sx.js";import{F as xa}from"./ClipboardDocumentIcon-BDjRckzX.js";import{W as ba}from"./web-admin-application-document-upload-ui-LYMAWe0G.js";import{n as va,c as ya}from"./form-block-renderer-DENAqV8j.js";import{u as ke}from"./useLazyQuery-CDBI4_nY.js";import{F as ze}from"./ChevronLeftIcon-YT7fuYHO.js";import{F as ja}from"./EnvelopeIcon-BZIrcbuA.js";import{F as wa}from"./PrinterIcon-Dqs0OLd7.js";import{F as Sa}from"./ArrowUturnLeftIcon-7y_x3GxY.js";import{F as Na}from"./TrashIcon-DHmQaN4B.js";import{F as Aa}from"./PencilSquareIcon-C2SmFQ4H.js";import{F as Da}from"./CheckIcon-BapUAaxp.js";function Pa({title:t,titleId:a,...s},n){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":a},s),t?b.createElement("title",{id:a},t):null,b.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7.5 21 3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5"}))}const Ca=b.forwardRef(Pa);function Ta(t){switch(t){case ae.Credit:return"Credit on account";case ae.CreditUsed:return"Credit used";case ae.Deposit:return"Deposit";case ae.Discount:return"Discount";case ae.Fee:return"Fee for cancellation";case ae.Refund:return"Refund";case ae.RefundCredit:return"Refund Credit";case ae.Payment:return"Payment";default:return""}}function ot(t){return"variant"in t}function Me(t){if(t==null||t==="")return null;const a=Number(t);return Number.isFinite(a)&&a>0?a:null}function lt(t){return typeof t.sku=="string"&&t.sku.trim()!==""}function dt(t){return Me(t.price)}function ka(t){return Me(t.price)===null?"noPrice":lt(t)?null:"noSku"}function Ia(t,a){const s=a.sku?.trim()?`Variant ${a.sku.trim()}`:"This variant";return t==="noPrice"?`${s} has no price set, so the coupon amount cannot be calculated. Set the variant price, or choose another variant.`:`${s} has no SKU, so the coupon cannot be restricted to the program in Shopify. Set the variant SKU, or choose another variant.`}function ct(t,a=new Date){if(!t.startDate)return!0;const s=new Date(t.startDate).getTime();if(Number.isNaN(s))return!0;const n=new Date(a);return n.setHours(0,0,0,0),s>=n.getTime()}function Va(t){return!t.startDate||t.openEnrollment===!0}function Ra(t,a=new Date){if(t.length===0)return{reason:"noVariants",candidates:[]};const s=t.filter(i=>ct(i,a)),n=s.filter(i=>Me(i.price)!==null),r=n.filter(lt);if(r.length===1)return{variant:r[0],candidates:r};if(r.length>1){const i=r.filter(Va);return i.length===1?{variant:i[0],candidates:r}:{reason:"ambiguous",candidates:r}}return n.length>0?{reason:"noSku",candidates:n}:s.length>0?{reason:"noPricedVariant",candidates:s}:{reason:"noVariants",candidates:[]}}function Ea(t,a,s=[]){const n=a?.trim()?a.trim():"This program";switch(t){case"noVariants":return`${n} has no variants, so there is nothing to price the scholarship against or scope the coupon to. Create a variant with a price and a SKU first.`;case"noPricedVariant":return`None of ${n}'s variants has a price set, so the coupon amount cannot be calculated. Set the variant price before approving.`;case"noSku":return`${n}'s priced variants have no SKU, so the coupon cannot be restricted to the program in Shopify. Set the variant SKU first.`;case"ambiguous":{const r=s.map(l=>
1l.sku).filter(Boolean).join(", "),i=r?` (${r})`:"";return`${n} has ${s.length} variants that could be awarded${i}. Choose the one this scholarship is for.`}default:return`${n} has no variant this scholarship can be awarded against. Check that it has a variant with a price and a SKU.`}}function Fa({formDefinition:t,existingAnswers:a={},onSubmit:s,submitButton:n,title:r,description:i,formId:l="form-block",className:o="",isLoading:d=!1,error:m=null}){const p=n===void 0?void 0:n||{text:"Submit",variant:"primary"},f=va(t,a),u=ya(t,f,p);return d?e.jsxs("div",{className:`w-full bg-white border border-gray-200 rounded-lg p-6 ${o}`,children:[e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"h-6 bg-gray-300 rounded w-1/3 mb-4"}),e.jsx("div",{className:"h-4 bg-gray-300 rounded w-2/3 mb-6"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"h-4 bg-gray-300 rounded w-full"}),e.jsx("div",{className:"h-4 bg-gray-300 rounded w-3/4"}),e.jsx("div",{className:"h-4 bg-gray-300 rounded w-1/2"})]}),e.jsx("div",{className:"mt-6 h-10 bg-gray-300 rounded w-32"})]}),e.jsx("p",{className:"text-gray-500 mt-4 text-center",children:"Loading form..."})]}):m?e.jsx("div",{className:`w-full bg-red-50 border border-red-200 rounded-lg p-6 ${o}`,children:e.jsx("p",{className:"text-red-700",children:m})}):t?u.length===0?e.jsx("div",{className:`w-full text-center py-8 text-gray-500 ${o}`,children:"No form fields configured."}):e.jsx("div",{className:`w-full ${o}`,children:e.jsxs("div",{className:"bg-white border border-gray-200 rounded-lg p-6",children:[r&&e.jsx("h3",{className:"text-lg font-semibold mb-2",children:r}),i&&e.jsx("p",{className:"text-gray-600 mb-4",children:i}),e.jsx(it,{id:l,fields:u,submit:s,theme:ga,defaultValues:f})]})}):e.jsxs("div",{className:`w-full bg-white border border-gray-200 rounded-lg p-6 ${o}`,children:[e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"h-6 bg-gray-300 rounded w-1/3 mb-4"}),e.jsx("div",{className:"h-4 bg-gray-300 rounded w-2/3 mb-6"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"h-4 bg-gray-300 rounded w-full"}),e.jsx("div",{className:"h-4 bg-gray-300 rounded w-3/4"}),e.jsx("div",{className:"h-4 bg-gray-300 rounded w-1/2"})]}),e.jsx("div",{className:"mt-6 h-10 bg-gray-300 rounded w-32"})]}),e.jsx("p",{className:"text-gray-500 mt-4 text-center",children:"Loading form..."})]})}const c=ra.create({pdfViewer:{width:"100%",height:"100%"},page:{display:"flex",flexDirection:"column"},title:{paddingBottom:5,paddingHorizontal:20,textAlign:"center",display:"flex",flexDirection:"column",flexShrink:1,justifyContent:"center",alignItems:"center"},body:{flexGrow:1},w100:{width:"100%"},h100:{height:"100%"},flex:{display:"flex"},flexRow:{flexDirection:"row"},flexColumn:{flexDirection:"column"},wrap:{flexWrap:"wrap"},center:{justifyContent:"center",alignItems:"center"},rowGapXs:{rowGap:3},rowGapSm:{rowGap:5},rowGapMd:{rowGap:8},border:{border:"1px solid black"},borderGrayRound:{border:"1px solid #e5e7eb",borderRadius:2},borderBottom:{borderBottom:1,borderBottomWidth:1},borderTop:{borderTop:1,borderTopWidth:1},bg_light_gray:{backgroundColor:"#e5e7eb"},bg_md_gray:{backgroundColor:"#b5b9c0"},px_20:{paddingHorizontal:20},mx_20:{marginHorizontal:20},alignLeft:{textAlign:"left"},alignCenter:{textAlign:"center"},alignRight:{textAlign:"right"},textStyle:{fontFamily:"Helvetica"},bold:{fontFamily:"Helvetica-Bold"},semibold:{fontWeight:"medium"},textXxs:{fontSize:"6px"},textXs:{fontSize:"8px"},textSm:{fontSize:"10px"},textMd:{fontSize:"12px"},textLg:{fontSize:"14px"},textXl:{fontSize:"18px"},paddingXs:{padding:5},paddingSm:{padding:10},paddingMd:{padding:15},paddingLg:{padding:20},paddingXl:{padding:30},paddingXxl:{padding:40},paddingXxxl:{padding:50},leftPaddingXs:{paddingLeft:5},leftPaddingSm:{paddingLeft:10},leftPaddingMd:{paddingLeft:15},leftPaddingLg:{paddingLeft:20},rightPaddingXs:{paddingLeft:5},rightPaddingSm:{paddingLeft:10},rightPaddingMd:{paddingLeft:15},rightPaddingLg:{paddingLeft:20},verticalPaddingXs:{paddingVertical:5},verticalPaddingSm:{paddingVertical:10},verticalPaddingMd:{paddingVertical:15},verticalPaddingLg:{paddingVertical:20},horizontalPaddingXs:{paddingHorizontal:5},horizontalPaddingSm:{paddingHorizontal:10},horizontalPaddingMd:{paddingHorizontal:15},horizontalPaddingLg:{paddingHorizontal:20},topPaddingXs:{paddingTop:5},topPaddingSm:{paddingTop:10},topPaddingMd:{paddingTop:15},topPaddingLg:{paddingTop:20},bottomPaddingXs:{paddingBottom:5},bottomPaddingSm:{paddingBottom:10},bottomPaddingMd:{paddingBottom:15},bottomPaddingLg:{paddingBottom:20},col5:{width:"5%"},col10:{width:"10%"},col15:{width:"15%"},col20:{width:"20%"},col25:{width:"25%"},col30:{width:"30%"},col33:{width:"33%"},col35:{width:"35%"},col40:{width:"40%"},col50:{width:"50%"},col60:{width:"60%"}});var F=(t=>(t.Xs="8px",t.Sm="10px",t.Md="12px",t.Lg="14px",t.Xl="18px",t))(F||{}),k=(t=>(t.Bold="bold",t.Medium="medium",t.Normal="normal",t))(k||{});function S(t){const{children:a,size:s=F.Md,weight:n="normal",align:r="left",style:i={},wrap:l=!1}=t,o=[c.textStyle,{fontSize:s},r==="center"&&c.alignCenter,r==="right"&&c.alignRight,r==="left"&&c.alignLeft,n==="bold"&&c.bold,n==="medium"&&c.semibold,i].filter(
1Boolean);return e.jsx(ia,{style:o,wrap:l,children:a})}function Ma(t){const{block:a}=t;return a?.textContent?e.jsxs("div",{className:"w-full",children:[a.title&&e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:a.title}),e.jsx("div",{className:"prose prose-gray max-w-none prose-headings:text-gray-900 prose-a:text-green-web hover:prose-a:text-green-web-800",children:"Experience embed"})]}):e.jsx("div",{className:"w-full h-60 bg-gray-100 flex items-center justify-center",children:e.jsx("p",{className:"text-gray-500",children:"No markdown content available"})})}function La(t){const{block:a}=t;return a?.url?e.jsxs("div",{className:"w-full",children:[a.title&&e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:a.title}),e.jsx(Te,{to:a.url,target:"_blank",children:a.url})]}):e.jsx("div",{className:"w-full h-60 bg-gray-100 flex items-center justify-center",children:e.jsx("p",{className:"text-gray-500",children:"No externallink content available"})})}function _a(t){const{block:a}=t,s=()=>{a.url&&window.open(ye(a.signedUrl,a.url),"_blank")};return a?.url?e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"border-2 border-dashed border-gray-300 rounded-lg p-6 text-center",children:[e.jsx(oa,{className:"h-12 w-12 text-gray-400 mx-auto mb-4"}),e.jsx("h4",{className:"text-lg font-medium text-gray-900 mb-2",children:a.fileName||"Download File"}),a.fileSize?e.jsxs("p",{className:"text-sm text-gray-500 mb-4",children:[(a.fileSize/1024/1024).toFixed(1)," MB"]}):null,e.jsx("button",{onClick:s,className:"bg-purple-600 text-white px-6 py-2 rounded-md hover:bg-purple-700 transition-colors",children:"Download File"})]}),a.title&&a.displayTitle&&e.jsx("h3",{className:"mt-4 text-lg font-semibold text-gray-900",children:a.title}),a.textContent&&e.jsx("p",{className:"mt-2 text-gray-600",children:a.textContent})]}):e.jsx("div",{className:"w-full h-60 bg-gray-100 flex items-center justify-center",children:e.jsx("p",{className:"text-gray-500",children:"No download URL provided"})})}function Ba(t,a=1e3){const[s,n]=b.useState(!1),[r,i]=b.useState(!1),l=b.useRef(!0);return b.useEffect(()=>{let o=null;return t?r?l.current&&n(!0):o=setTimeout(()=>{l.current&&(n(!0),i(!0))},a):(l.current&&(n(!1),i(!1)),o&&clearTimeout(o)),()=>{o&&clearTimeout(o)}},[t,a,r]),b.useEffect(()=>()=>{l.current=!1},[]),s}function Ua(t){const{block:a,participantId:s,sessionId:n}=t,[r,i]=b.useState(null),[l,o]=b.useState(!1),d=la(),{data:m,loading:p,refetch:f}=Z(Tt,{variables:{participantId:s,formDefinitionId:a.formDefinitionId,sessionId:n},skip:!a.formDefinitionId||!s}),u=m?.formResponses?.[0],{data:h,loading:g}=Z(kt,{variables:{participantId:s,formDefinitionId:a.formDefinitionId,sessionId:n},skip:!a.formDefinitionId||!s,errorPolicy:"ignore"}),{data:w,loading:x,error:j}=Z(It,{variables:{formDefinitionId:a.formDefinitionId},skip:!a.formDefinitionId}),[A]=G(Vt),[y]=G(Rt),[T]=G(Et);b.useEffect(()=>{if(!d)return;const U=`form-${a.id}`,O={id:U,submit:async()=>new Promise((_,L)=>{globalThis[`formSubmitResolve_${a.id}`]=_,globalThis[`formSubmitReject_${a.id}`]=L}),onSubmissionStateChange:_=>{o(_)}};return d.registerForm(U,O),()=>{d.unregisterForm(U)}},[d,a.id]);const P=b.useCallback(async U=>{d?.setFormSubmitting(`form-${a.id}`,!0),i(null);const O=globalThis.handleContinueWithForms;try{if(p){i("Please wait while we check for existing responses..."),o(!1);return}const _=new Date,L=m?.formResponses?.[0];let H;if(L){const{data:R}
1=await y({variables:{formResponseId:L.id,input:{submittedAt:_,isComplete:!0,isDraft:!1,userAgent:navigator.userAgent}}});if(!R?.updateFormResponse?.id)throw new Error("Failed to update form response");H=R.updateFormResponse.id}else{const{data:R}=await A({variables:{input:{formDefinitionId:a.formDefinitionId,participantId:s,sessionId:n,submittedAt:_,isComplete:!0,isDraft:!1,userAgent:navigator.userAgent}}});if(!R?.createFormResponse?.id)throw new Error("Failed to create form response");H=R.createFormResponse.id}const $=[];Object.entries(U).forEach(([R,E])=>{let Y;Array.isArray(E)&&E.length>0?Y={values:E}:Array.isArray(E)&&E.length===0?Y={values:[]}:E===null||E===""||E===void 0?Y={value:""}:typeof E=="string"?Y={value:E}:typeof E=="boolean"?Y={value:E}:Y={value:E.toString()};const Ae=async()=>{try{return await T({variables:{input:{responseId:H,questionId:R,value:Y}}})}catch(pe){return console.error(`❌ Failed to upsert answer for question ${R}:`,pe),null}};$.push(Ae())}),await Promise.all($),await f();const V=globalThis[`formSubmitResolve_${a.id}`];V&&(V(),delete globalThis[`formSubmitResolve_${a.id}`],delete globalThis[`formSubmitReject_${a.id}`]),O&&setTimeout(()=>{O()},100)}catch(_){console.error("Form submission error:",_),i(_ instanceof Error?_.message:"An error occurred while submitting the form");const L=globalThis[`formSubmitReject_${a.id}`];L&&(L(_),delete globalThis[`formSubmitResolve_${a.id}`],delete globalThis[`formSubmitReject_${a.id}`])}finally{d?.setFormSubmitting(`form-${a.id}`,!1)}},[a.formDefinitionId,a.id,s,n,m,p,A,y,T,f,d]),C=!!u,M=w?.userFormDefinition,D=u?h?.formResponses?.[0]:null,K=b.useMemo(()=>!D?.answers||!M?.questions?{}:D.answers.reduce((U,O)=>{if(!M?.questions?.some($=>$.id===O.questionId))return U;const L=O.value;let H=L;if(typeof L=="object"&&L!==null){const $=L;"values"in $?H=$.values:"value"in $&&(H=$.value)}return U[O.questionId]=H,U},{}),[D?.answers,M?.questions]),q=!!u&&g,Q=Ba(x||p||q,1e3);b.useEffect(()=>{o(!1),d?.setFormSubmitting(`form-${a.id}`,!1)},[n,d,a.id]),b.useEffect(()=>()=>{i(null),d?.setFormSubmitting(`form-${a.id}`,!1)},[a.id,s,n,d]);const ue=b.useMemo(()=>p?"Checking existing responses...":q?"Loading your previous answers...":l?C?"Updating...":"Submitting...":C?"Update Entry":"Submit Form",[p,q,l,C]);return e.jsxs("div",{className:"w-full",children:[r&&e.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-md",children:e.jsx("p",{className:"text-red-700 text-sm",children:r})}),e.jsx(Fa,{formDefinition:M,existingAnswers:K,onSubmit:P,title:a?.title??M?.title,description:M?.description,formId:"course-form",isLoading:Q,error:j?"Error loading form":null,submitButton:d?void 0:{text:ue,disabled:l||p,variant:"primary"}}),a.textContent&&e.jsx("p",{className:"mt-4 text-gray-600",children:a.textContent})]})}function Oa(t){const{block:a}=t;return a?.textContent?e.jsxs("div",{className:"w-full",children:[a.title&&e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:a.title}),e.jsx("div",{className:"prose prose-gray max-w-none prose-headings:text-gray-900 prose-a:text-green-web hover:prose-a:text-green-web-800",children:"heading"})]}):e.jsx("div",{className:"w-full h-60 bg-gray-100 flex items-center justify-center",children:e.jsx("p",{className:"text-gray-500",children:"No heading content available"})})}function $a(t){const{block:a}=t;return a?.textContent?e.jsxs("div",{className:"w-full",children:[a.title&&e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:a.title}),e.jsx("div",{className:"prose prose-gray max-w-none prose-images:text-gray-900 prose-a:text-green-web hover:prose-a:text-green-web-800",children:"image"})]}):e.jsx("div",{className:"w-full h-60 bg-gray-100 flex items-center justify-center",children:e.jsx("p",{className:"text-gray-500",children:"No image content available"})})}function Wa(t){const{block:a}=t;return a?.url?e.jsxs("div",{className:"w-full",children:[e.jsx("div",{className:"aspect-[4/3] bg-gray-50 rounded-lg",children:e.jsx("iframe",{src:ye(a.signedUrl,a.url),className:"w-full h-full rounded-lg",title:a.title??""})}),a.title&&e.jsx("h3",{className:"mt-4 text-lg font-semibold text-gray-600",children:a.title}),a.textContent&&e.jsx("p",{className:"mt-2 text-gray-600",children:a.textContent})]}):e.jsx("div",{className:"w-full h-60 bg-gray-100 flex items-center justify-center",children:e.jsx("p",{className:"text-gray-500",children:"No PDF available"})})}function za(t){const{block:a}=t;return a?.textContent?e.jsxs("div",{className:"w-full",children:[a.title&&e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:a.title}),e.jsx("div",{className:"prose prose-gray max-w-none prose-quizplaceholders:text-gray-900 prose-a:text-green-web hover:prose-a:text-green-web-800",children:"quizplaceholder"})]}):e.jsx("div",{className:"w-full h-60 bg-gray-100 flex items-center justify-center",children:e.jsx("p",{className:"text-gray-500",children:"No quizplaceholder content available"})})}function Xa(t){const{block:a}=t;return a?.textContent?e.jsxs("div",{className:"w-full",children:[a.title&&a.displayTitle&&e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:a.title}),e.jsx("div",{className:"prose prose-gray max-w-none prose-quotes:text-gray-900 prose-a:text-green-web hover:prose-a:text-green-web-800",children:"quote"})]}):e.jsx("div",{className:"w-full h-60 bg-gray-100 flex items-center justify-center",children:e.jsx("p",{className:"text-gray-500",children:"No quote content available"})})}function Ha(t){const{block:a}=t,[s,n]=b.useState(null);if(b.useEffect(()=>{n(null)},[a?.url]),!a?.url)return e.jsx("div",{className:"w-full h-60 bg-gray-100 flex items-center justify-center",children:e.jsx("p",{className:"text-gray-500",children:"No video available"})});const r=ea(a.url),i=!r&&ta(a.url),l=a.title&&a.displayTitle?a.title:null;if(r||i){const m=r?aa(a.url):sa(a.url);return m?e.jsxs("div",{className:"w-full",children:[e.jsx("div",{className:"aspect-video",children:e.jsx("iframe",{src:m,className:"w-full h-full rounded-lg border ",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:a.title||"Video content"})}),l&&e.jsx("h3",{className:"mt-4 text-lg font-semibold text-gray-900",children:l}),a.textContent&&e.jsx("p",{className:"mt-2 text-gray-600",children:a.textContent})]}):e.jsx("div",{className:"w-full h-60 bg-gray-100 flex items-center justify-center",children:e.jsx("p",{className:"text-gray-500",children:"Invalid video URL"})})}const o=ye(a.signedUrl,a.url)??"",d=ye(a.signedPosterImage,a.posterImage);return e.jsxs("div",{className:"w-full",children:[s?e.jsx(da,{mediaError:s,blockId:a.id,objectUrl:o,message:"This video couldn't be played. Please contact support."}):e.jsx("div",{className:"aspect-video",children:e.jsx("video",{className:"w-full h-full rounded-lg border",src:o,poster:d,controls:!0,preload:"metadata",playsInl
1ine:!0,onError:m=>n(m.currentTarget.error??{code:0}),children:e.jsx("track",{kind:"captions",srcLang:"en",label:"English captions"})})}),l&&e.jsx("h3",{className:"mt-4 text-lg font-semibold text-gray-900",children:l}),a.textContent&&e.jsx("p",{className:"mt-2 text-gray-600",children:a.textContent})]})}function Ga(t){const{block:a,participantId:s,sessionId:n,imageUrl:r}=t;switch(a.type){case W.Video:return e.jsx(Ha,{block:a});case W.Audio:return e.jsx(pa,{block:a,imageUrl:r});case W.Text:return e.jsx(ua,{block:a});case W.Markdown:return e.jsx(ca,{block:a});case W.FileDownload:return e.jsx(_a,{block:a});case W.Quote:return e.jsx(Xa,{block:a});case W.QuizPlaceholder:return e.jsx(za,{block:a});case W.ExperienceEmbed:return e.jsx(Ma,{block:a});case W.ExternalLink:return e.jsx(La,{block:a});case W.Heading:return e.jsx(Oa,{block:a});case W.PdfEmbed:return e.jsx(Wa,{block:a});case W.Image:return e.jsx($a,{block:a});case W.Form:return!s||!n?e.jsx("div",{className:"w-full bg-yellow-50 border border-yellow-200 rounded-lg p-6",children:e.jsx("p",{className:"text-yellow-700",children:"Form cannot be displayed: missing participant or session context"})}):e.jsx(Ua,{block:a,participantId:s,sessionId:n});default:return e.jsx("div",{className:"w-full h-60 bg-gray-100 flex items-center justify-center rounded-lg",children:e.jsxs("p",{className:"text-gray-500",children:["Unsupported block type: ",a.type]})})}}function ee(t){const a=t.value==null?null:Number(t.value);let s="-";return a!=null&&!Number.isNaN(a)&&(s=a<0?"-$"+Math.abs(a).toFixed(2):"$"+a.toFixed(2)),e.jsx(S,{align:"center",size:t.size,weight:t.weight,style:t.style,children:s})}function qa(t){return ct(t)}function Xe(t){const a=t.startDate,s=a&&Ie(t)?ne(a,"MMM D, YYYY"):"Self-paced",n=dt(t);return`${t.sku??"(no SKU)"} — ${s} (${n===null?"no price set":ve(n)})`}function Ie(t){if(!t.startDate)return null;const a=new Date(t.startDate);return Number.isNaN(a.getTime())?null:a}function Ya(t){return t.slice().sort((a,s)=>{const n=Ie(a),r=Ie(s);return n===null&&r===null?0:n===null?-1:r===null?1:n.getTime()-r.getTime()})}function Ka(){globalThis.location.reload()}const Ce="w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500";function He(t,a){return t?"…":a===null?"—":ve(a)}function Qa(t){if(!t)return null;const a=ka(t);return a?Ia(a,t):null}function Ja(t,a){return ot(t)?null:Ea(t.reason,a,t.candidates)}function Za(t,a,s,n){const r=Ra(t),i=ot(r)?r.variant:null,l=a||i?.id||"",o=t.find(p=>p.id===l)??null,d=n==null?null:Number(n),m=o?dt(o):null;return{options:Ya(t.filter(qa)),resolvedVariant:i,effectiveVariantId:l,contribution:d,variantPrice:m,discount:m===null?null:Math.max(m-(d??0),0),blockingMessage:a?Qa(o):Ja(r,s)}}function es({result:t,onReload:a}){const{t:s}=re(),[n,r]=b.useState(!1);function i(){t.couponCode&&navigator.clipboard?.writeText(t.couponCode).then(()=>{r(!0),setTimeout(()=>r(!1),2e3)})}return e.jsxs("div",{className:"space-y-4",children:[e.jsx(fe,{alertType:"success",title:s("admin:applications.scholarshipApproval.successTitle",{defaultValue:"Scholarship Approved"}),message:t.message??s("admin:applications.scholarshipApproval.couponCreated",{defaultValue:"The scholarship coupon has been created."})}),e.jsxs("div",{className:"p-4 bg-gray-50 border border-gray-200 rounded-md space-y-2",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-800",children:s("admin:applications.scholarshipApproval.couponCode",{defaultValue:"Coupon Code"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"px-3 py-1.5 bg-white border border-gray-300 rounded font-mono text-lg tracking-wide",children:t.couponCode}),e.jsxs("button",{type:"button",onClick:i,className:"flex items-center text-gray-500 hover:text-gray-700",title:"Copy coupon code",children:[e.jsx(xa,{className:"w-5 h-5"}),e.jsx("span",{className:"ml-1 text-xs",children:n?"Copied!":"Copy"})]})]}),t.couponExpiresAt&&e.jsxs("div",{className:"text-sm text-gray-600",children:[s("admin:applications.scholarshipApproval.couponExpires",{defaultValue:"Expires:"})," ",ne(t.couponExpiresAt,"MMM D, YYYY h:mm A")]}),e.jsx("div",{className:"text-sm",children:t.emailSent?e.jsx("span",{className:"text-green-700",children:s("admin:applications.scholarshipApproval.emailSent",{defaultValue:"The acceptance email with the coupon was sent to the applicant."})}):e.jsx("span",{className:"text-amber-700",children:s("admin:applications.scholarshipApproval.emailNotSent",{defaultValue:"The acceptance email could not be sent — share the coupon code with the applicant manually."})})})]}),e.jsx("div",{className:"flex justify-end space-x-3",children:e.jsx("button",{type:"button",onClick:a,className:"px-4 py-2 bg-green-web text-white rounded-md hover:bg-green-web-800",children:s("admin:applications.scholarshipApproval.reload",{defaultValue:"Reload Page"})})})]})}function ts({isOpen:t,onClose:a,applicationId:s,programId:n,programName:r,contributionAmount:i,campaignBudgetId:l,onSuccess:o}){const{t:d}=re(),[m,p]=b.useState(!1),[f,u]=b.useState(null),[h,g]=b.useState(null),[w,x]=b.useState(null),[j,A]=b.useState(n),[y,T]=b.useState(""),[P,C]=b.useState(null),[M]=G(Ft),{data:D}=Z(Mt),q=[...D?.scholarshipPrograms??[]].sort((N,he)=>N.name.localeCompare(he.name)).map(N=>({value:N.id,label:N.name})),{data:ie,loading:Q}=Z(Ee,{variables:{input:{programId:j}},skip:!j}),{data:ue}=Z(Lt,{variables:{programId:j},skip:!j}),U=(ue?.staffScholarshipBudgetsForProgram??[]).filter(N=>N.active),O=P??(l&&U.some(N=>N.id===l)?l:""),{options:_,resolvedVariant:L,effectiveVariantId:H,contribution:$,variantPrice:V,discount:R,blockingMessage:E}=Za(ie?.variants??[],y,r,i),Y=U.find(N=>
1N.id===O),Ae=R!==null&&Y&&Number(Y.remainingAmount)<R;async function pe(N){if(!H||E){u(E??d("admin:applications.scholarshipApproval.noVariant",{defaultValue:"Please select a program variant."}));return}p(!0),u(null),x(null);try{const te=(await M({variables:{input:{applicationId:s,...y?{variantId:y}:{},...O?{budgetId:O}:{},confirmOverBudget:N,sendEmail:!0}}})).data?.approveScholarshipApplication;te?.requiresBudgetConfirmation?x(te.budgetWarning??d("admin:applications.scholarshipApproval.overBudget",{defaultValue:"This award exceeds the remaining budget."})):te?.success?(g({couponCode:te.couponCode,couponExpiresAt:te.couponExpiresAt,emailSent:te.emailSent,message:te.message}),o?.()):u(te?.message??d("admin:applications.scholarshipApproval.failed",{defaultValue:"Failed to approve the scholarship application."}))}catch(he){u(he?.message??d("admin:applications.scholarshipApproval.error",{defaultValue:"An error occurred while approving the scholarship."}))}finally{p(!1)}}function Oe(){u(null),g(null),x(null),A(n),T(""),C(null),a()}function Ct(N){A(N),T(""),C(null),x(null)}return e.jsx(ma,{title:d("admin:applications.scholarshipApproval.title",{defaultValue:"Approve Scholarship Application"}),isOpen:t,onClose:Oe,widthClass:"w-full max-w-lg",children:e.jsxs("div",{className:"space-y-4",children:[r&&!h&&e.jsxs("p",{className:"text-gray-600",children:[d("admin:applications.scholarshipApproval.appliedFor",{defaultValue:"Applied for:"})," ",e.jsx("span",{className:"font-medium text-gray-900",children:r})]}),f&&e.jsx(fe,{alertType:"error",title:d("admin:applications.scholarshipApproval.errorTitle",{defaultValue:"Error"}),message:f}),h&&e.jsx(es,{result:h,onReload:Ka}),!h&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-gray-600",children:d("admin:applications.scholarshipApproval.description",{defaultValue:"Choose a budget. Approving mints a single-use Shopify coupon for the discount and emails it to the applicant — they enroll themselves by checking out with the coupon."})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:d("admin:applications.scholarshipApproval.programLabel",{defaultValue:"Program"})}),e.jsx("select",{value:j,onChange:N=>Ct(N.target.value),className:Ce,children:q.map(N=>e.jsx("option",{value:N.value,children:N.label},N.value))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:Q?d("admin:applications.scholarshipApproval.loadingVariants",{defaultValue:"Loading variants..."}):d("admin:applications.scholarshipApproval.selectVariant",{defaultValue:"Program Variant (optional)"})}),e.jsxs("select",{value:y,onChange:N=>{T(N.target.value),x(null)},className:Ce,disabled:Q,"aria-label":d("admin:applications.scholarshipApproval.selectVariant",{defaultValue:"Program Variant (optional)"}),children:[e.jsx("option",{value:"",children:L?`Automatic — ${Xe(L)}`:"Select a variant..."}),_.map(N=>e.jsx("option",{value:N.id,children:Xe(N)},N.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:d("admin:applications.scholarshipApproval.budgetLabel",{defaultValue:"Budget"})}),e.jsxs("select",{value:O,onChange:N=>{C(N.target.value),x(null)},className:Ce,children:[e.jsx("option",{value:"",children:"No budget (untracked)"}),U.map(N=>e.jsxs("option",{value:N.id,children:[N.name," — ",ve(N.remainingAmount)," remaining",N.programName?` (${N.programName})`:" (Global)",N.id===l?" · campaign budget":""]},N.id))]})]}),!Q&&E&&e.jsx(fe,{alertType:"error",title:d("admin:applications.scholarshipApproval.noAwardableVariantTitle",{defaultValue:"Cannot approve this program yet"}),message:E}),e.jsxs("div",{className:"p-3 bg-gray-50 border border-gray-200 rounded-md text-sm space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-600",children:d("admin:applications.scholarshipApproval.programPrice",{defaultValue:"Program price"})}),e.jsx("span",{className:"font-medium text-gray-900",children:He(Q,V)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-600",children:d("admin:applications.scholarshipApproval.contribution",{defaultValue:"Applicant contribution"})}),e.jsx("span",{className:"font-medium text-gray-900",children:$!==null?ve($):"—"})]}),e.jsxs("div",{className:"flex justify-between border-t border-gray-200 pt-1",children:[e.jsx("span",{className:"text-gray-700 font-medium",children:d("admin:applications.scholarshipApproval.discount",{defaultValue:"Scholarship discount (coupon value)"})}),e.jsx("span",{className:"font-semibold text-gray-900",children:He(Q,R)})]}),Ae&&e.jsxs("div",{className:"flex items-start gap-2 pt-1 text-amber-700",children:[e.jsx(We,{className:"w-4 h-4 shrink-0 mt-0.5"}),e.jsx("span",{children:d("admin:applications.scholarshipApproval.overBudgetHint",{defaultValue:"The discount exceeds the remaining balance of the selected budget."})})]})]}),w&&e.jsxs("div",{className:"p-4 bg-amber-50 border border-amber-200 rounded-md space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(We,{className:"w-5 h-5 text-amber-600 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-amber-800",children:d("admin:applications.scholarshipApproval.budgetWarningTitle",{defaultValue:"Budget Warning"})}),e.jsx("div",{className:"text-sm text-amber-700 mt-0.5",children:w})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button",onClick:()=>pe(!0),className:"px-4 py-2 bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 text-sm",disabled:m,children:m?d("admin:applications.scholarshipApproval.approv
1ing",{defaultValue:"Approving..."}):d("admin:applications.scholarshipApproval.confirmOverBudget",{defaultValue:"Approve Anyway (Over Budget)"})})})]}),e.jsxs("div",{className:"mt-6 flex justify-end space-x-3 pt-4 border-t",children:[e.jsx("button",{type:"button",onClick:Oe,className:"px-4 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-50",disabled:m,children:d("admin:applications.scholarshipApproval.cancel",{defaultValue:"Cancel"})}),e.jsx("button",{type:"button",onClick:()=>pe(!1),className:"px-4 py-2 bg-green-web text-white rounded-md hover:bg-green-web-800 disabled:opacity-50",disabled:m||!H||!!E,children:m?d("admin:applications.scholarshipApproval.approving",{defaultValue:"Approving..."}):d("admin:applications.scholarshipApproval.approve",{defaultValue:"Approve & Generate Coupon"})})]})]})]})})}const as={[De.Residential]:"Residential",[De.Virtual]:"Virtual",[De.Online]:"Online"};function In(t){const a=na(),s=t?.balanceDate||a?.balanceDate,n=t?.programTypes,r=s?new Date(s):new Date,i=n?.length?n.map(f=>as[f]||f).join(", "):"All",{data:l,loading:o,error:d}=Z(_t,{variables:{input:{date:r,take:1e3,...n?.length&&{programTypes:n}}}}),m=["GVO","CWG","IBM"],p=(l?.reconciliationReportWithDataIntegrity||[]).filter(f=>!m.some(u=>f.participant?.sku?.startsWith(u)));return o?e.jsx(be,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen bg-gray-100",children:e.jsxs("div",{className:"bg-white p-8 rounded-lg shadow-lg max-w-md w-full text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-800 mb-4",children:"Loading Payment Data..."}),e.jsxs("p",{className:"text-gray-600 mb-4",children:["Report Date: ",z(r.toISOString())]}),e.jsx("div",{className:"animate-pulse bg-gray-200 h-4 rounded mb-2"}),e.jsx("div",{className:"animate-pulse bg-gray-200 h-4 rounded mb-2"}),e.jsx("div",{className:"animate-pulse bg-gray-200 h-4 rounded"})]})}),children:e.jsx("div",{className:"flex items-center justify-center min-h-screen bg-gray-100",children:e.jsxs("div",{className:"bg-white p-8 rounded-lg shadow-lg max-w-md w-full text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-800 mb-4",children:"Loading Payment Data..."}),e.jsxs("p",{className:"text-gray-600 mb-4",children:["Report Date: ",z(r.toISOString())]}),e.jsx("div",{className:"animate-pulse bg-gray-200 h-4 rounded mb-2"}),e.jsx("div",{className:"animate-pulse bg-gray-200 h-4 rounded mb-2"}),e.jsx("div",{className:"animate-pulse bg-gray-200 h-4 rounded"})]})})}):d?e.jsx(be,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen bg-gray-100",children:e.jsxs("div",{className:"bg-white p-8 rounded-lg shadow-lg max-w-md w-full text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-red-800 mb-4",children:"Error Loading Report"}),e.jsxs("p",{className:"text-gray-600 mb-4",children:["Report Date: ",z(r.toISOString())]}),e.jsx("p",{className:"text-red-600",children:"Unable to load payment transaction data"})]})}),children:e.jsx("div",{className:"flex items-center justify-center min-h-screen bg-gray-100",children:e.jsxs("div",{className:"bg-white p-8 rounded-lg shadow-lg max-w-md w-full text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-red-800 mb-4",children:"Error Loading Report"}),e.jsxs("p",{className:"text-gray-600 mb-4",children:["Report Date: ",z(r.toISOString())]}),e.jsx("p",{className:"text-red-600",children:"Unable to load payment transaction data"})]})})}):e.jsx(be,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen bg-gray-100",children:e.jsxs("div",{className:"bg-white p-8 rounded-lg shadow-lg max-w-md w-full text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-800 mb-4",children:"Loading PDF Report..."}),e.jsxs("p",{className:"text-gray-600 mb-4",children:["Report Date: ",z(r.toISOString())]}),e.jsx("div",{className:"animate-pulse bg-gray-200 h-4 rounded mb-2"}),e.jsx("div",{className:"animate-pulse bg-gray-200 h-4 rounded mb-2"}),e.jsx("div",{className:"animate-pulse bg-gray-200 h-4 rounded"})]})}),children:e.jsx(at,{style:c.pdfViewer,children:e.jsx(st,{title:`Daily Reconciliation Report for ${r}`,children:e.jsxs(nt,{size:"LETTER",orientation:"landscape",style:{...c.page,...c.paddingLg},children:[e.jsx(v,{style:[c.title],children:e.jsx(v,{style:[c.flexRow,c.center,c.w100,c.wrap,c.verticalPaddingSm],children:e.jsx(S,{size:F.Xl,children:`Daily Reconciliation Report for: ${z(r.toISOString())} (${i})`})})}),e.jsxs(v,{style:[c.w100],children:[e.jsxs(v,{style:[c.flexRow,c.center,c.w100,c.verticalPaddingSm,c.bg_md_gray],children:[e.jsx(v,{style:[c.col20,c.leftPaddingSm],children:e.jsx(S,{weight:k.Bold,align:"left",children:"Name"})}),e.jsx(v,{style:[c.col20,c.leftPaddingXs],children:e.jsx(S,{weight:k.Bold,children:"Location"})}),e.jsx(v,{style:[c.col20,c.leftPaddingXs],children:e.jsx(S,{weight:k.Bold,children:"Program (SKU)"})}),e.jsx(v,{style:[c.col20,c.leftPaddingXs],children:e.jsx(S,{weight:k.Bold,children:"Type"})}),e.jsx(v,{style:[c.col10,c.leftPaddingXs],children:e.jsx(S,{weight:k.Bold,align:"center",children:"Amount"})}),e.jsx(v,{style:[c.col10,c.leftPaddingXs],children:e.jsx(S,{weight:k.Bold,align:"center",children:"Date"})})]}),p.map((f,u)=>e.jsxs(v,{style:[c.flexRow,c.center,c.w100,c.verticalPaddingSm,u%2===0?c.bg_light_gray:{}],children:[e.jsx(v,{style:[c.col20,c.leftPaddingSm],children:e.jsx(S,{children:fa(f.user??{})})}),e.jsx(v,{style:[c.col20,c.leftPaddingXs],children:e.jsx(S,{children:(()=>{const h=f.user?.city,g=f.user?.stateOrProvince;return h?g?`${h}, ${g}`:h:"N/A"})()})}),e.jsx(v,{style:[c.col20,c.leftPaddingXs],children:e.jsx(S,{children:f.participant?.sku||"N/A"})}),e.jsx(v,{style:[c.col20,c.leftPaddingXs],children:e.jsx(S,{children:Ta(f.type)})}),e.jsx(v,{style:[c.col10,c.leftPaddingXs],children:e.jsxs(S,{align:"center",children:["$",Math.abs(Number(f.amount)).toFixed(2)]})}),e.jsx(v,{style:[c.col10,c.leftPaddingXs],children:e.jsx(S,{align:"center",children:z(f.date||f.createdAt,!0)})})]},f.id)),(!p||p?.length===0)&&e.jsx(v,{style:[c.paddingLg],children:e.jsxs(S,{align:"center",children:["No transactions foun
1d for ",z(r.toISOString()),"."]})}),p?.length>0&&e.jsx(v,{style:[c.paddingLg],children:e.jsx(S,{align:"center",style:{color:"#666"},children:(()=>{const f=new Date().toLocaleDateString(),u=p.length;return`Report generated on ${f} • ${u} ${u===1?"transaction":"transactions"} found`})()})})]})]})})})})}function ut(t,a){return[t.startDate?a(t.startDate,!0):"",t.endDate?a(t.endDate,!0):""].filter(Boolean).join(" - ")}function pt(t,a="asc"){const s=[];for(const n of t)for(const r of n.variants)s.push({...r});return s.sort((n,r)=>{const i=n.startDate?new Date(n.startDate).getTime():0,l=r.startDate?new Date(r.startDate).getTime():0;return a==="asc"?i-l:l-i}),s}function ss(t,a){const s=[];if(!t||a.size===0)return s;const n=new Map;t.forEach(i=>{const l=i.variantId;if(l){const o=n.get(l)||[];o.push(i),n.set(l,o)}});const r=new Map;return a.forEach(i=>{const l=n.get(i.variantId)||[];let o=0,d=0;l.forEach(h=>{o+=Number(h.calculatedAmountPaid??0),d+=Number(h.calculatedAmountDue??0)});const m=Number.parseFloat(o.toFixed(2)),p=Number.parseFloat(d.toFixed(2)),f={variantId:i.variantId,variantSku:i.variantSku,startDate:i.startDate,endDate:i.endDate,location:i.location,totalPaid:m,totalDue:p,variance:Number.parseFloat((m-p).toFixed(2)),participantCount:l.length,programName:i.programName,programId:i.programId};let u=r.get(i.programId);u||(u={programId:i.programId,programName:i.programName,variants:[],totalPaid:0,totalDue:0,totalParticipants:0},r.set(i.programId,u)),u.variants.push(f),u.totalPaid=Number.parseFloat((u.totalPaid+f.totalPaid).toFixed(2)),u.totalDue=Number.parseFloat((u.totalDue+f.totalDue).toFixed(2)),u.totalParticipants+=f.participantCount}),r.forEach(i=>{i.variants.sort((l,o)=>{const d=l.startDate?new Date(l.startDate).getTime():0,m=o.startDate?new Date(o.startDate).getTime():0;return d-m})}),s.push(...Array.from(r.values()).filter(i=>i.variants.length>0).sort((i,l)=>i.programName.localeCompare(l.programName))),s}function ns(t){return{grandTotalPaid:Number.parseFloat(t.reduce((a,s)=>a+s.totalPaid,0).toFixed(2)),grandTotalDue:Number.parseFloat(t.reduce((a,s)=>a+s.totalDue,0).toFixed(2)),grandTotalParticipants:t.reduce((a,s)=>a+s.totalParticipants,0)}}function rs(t){const a=new Date(t?.startDateFrom??Date.now());a.setHours(0,0,0,0);const s=t?.startDateTo,n=t?.programId,{data:r,loading:i,error:l}=Z(Bt,{variables:{input:{search:"",skip:0,take:1e3,orderBy:"name",orderDirection:"asc"}}}),o=[],d=new Map;r?.customPrograms?.forEach(P=>{o.push({id:P.id,name:P.name??""}),!(n&&P.id!==n)&&P.variants?.forEach(C=>{const M=C.startDate?new Date(C.startDate):null;if(M&&M>=a){if(s&&M>s)return;d.set(C.id,{variantId:C.id,variantSku:C.sku??"",startDate:C.startDate,endDate:C.endDate,location:C.programLocation?.name??C.location,programId:P.id,programName:P.name??""})}})}),o.sort((P,C)=>P.name.localeCompare(C.name));const m=Array.from(d.keys()),{data:p,loading:f,error:u}=Z(Ot,{variables:{input:{filters:{AND:[{variantId:{in:m}},{status:Ut.Active},{trainer:null}]},take:1e4}},skip:m.length===0||i}),h=p?.customParticipantsWithPaymentTransactions,g=ss(h,d),{grandTotalPaid:w,grandTotalDue:x,grandTotalParticipants:j}=ns(g),A=pt(g,"asc");return{programSummaries:g,allVariantsByDate:A,grandTotalPaid:w,grandTotalDue:x,grandTotalParticipants:j,loading:i||f,error:l||u,allPrograms:o}}const is="#15803d",os="#b91c1c",ls={backgroundColor:"#d1d5db"},Ge=[c.flexRow,c.center,c.w100,c.verticalPaddingSm];function Le(t){return{color:t>=0?is:os}}function oe({background:t,wrap:a=!0,children:s}){return e.jsx(v,{style:t?[...Ge,t]:Ge,wrap:a,children:s})}function ge({col:t,align:a="center",children:s}){return e.jsx(v,{style:[t,c.leftPaddingXs],children:e.jsx(S,{weight:k.Bold,align:a,children:s})})}function mt({variant:t,varianceCol:a}){return e.jsxs(e.Fragment,{children:[e.jsx(v,{style:[c.col10,c.leftPaddingXs],children:e.jsx(S,{size:F.Sm,align:"center",children:t.participantCount.toString()})}),e.jsx(v,{style:[c.col15,c.leftPaddingXs],children:e.jsx(ee,{value:t.totalPaid,size:F.Sm})}),e.jsx(v,{style:[c.col15,c.leftPaddingXs],children:e.jsx(ee,{value:t.totalDue,size:F.Sm})}),e.jsx(v,{style:[a,c.leftPaddingXs],children:e.jsx(ee,{value:t.variance,size:F.Sm,style:Le(t.variance)})})]})}function ft({grandTotalParticipants:t,grandTotalPaid:a,grandTotalDue:s,grandTotalVariance:n,varianceCol:r}){return e.jsxs(e.Fragment,{children:[e.jsx(v,{style:[c.col10,c.leftPaddingXs],children:e.jsx(S,{weight:k.Bold,align:"center",children:t.toString()})}),e.jsx(v,{style:[c.col15,c.leftPaddingXs],children:e.jsx(ee,{value:a,size:F.Lg,weight:k.Bold})}),e.jsx(v,{style:[c.col15,c.leftPaddingXs],children:e.jsx(ee,{value:s,size:F.Lg,weight:k.Bold})}),e.jsx(v,{style:[r,c.leftPaddingXs],children:e.jsx(ee,{value:n,size:F.Lg,weight:k.Bold,style:Le(n)})})]})}function ht({varianceCol:t}){return e.jsxs(e.Fragment,{children:[e.jsx(ge,{col:c.col10,children:"Participants"}),e.jsx(ge,{col:c.col15,children:"Total Paid"}),e.jsx(ge,{col:c.col15,children:"Total Due"}),e.jsx(ge,{col:t,children:"Variance"})]})}const ds=new Set(["byProgram","byDate"]),cs=new Set(["asc","desc"]);function qe(t){if(!t)return;const a=new Date(t);return Number.isNaN(a.getTime())?void 0:a}function us(){if(globalThis.window===void 0)return{view:"byProgram",sort:"asc",options:{}};const t=new URLSearchParams(globalThis.location.search),a=t.get("view"),s=ds.has(a)?a:"byProgram",n=t.get("sort"),r=cs.has(n)?n:"asc",i={},l=qe(t.get("from"));l&&(i.startDateFrom=l);const o=qe(t.get("to"));o&&(i.startDateTo=o);const d=t.get("programId");return d&&(i.programId=d),{view:s,sort:r,options:i}}function ps(t,a){const s=[];if(t.startDateFrom||t.startDateTo){const n=t.startDateFrom?z(t.startDateFrom.toISOString(),!0):"start",r=t.startDateTo?z(t.startDateTo.toISOString(),!0):"open";s.push(`Variants from ${n} – ${r}`)}else s.push(`Future variants as of ${z(new Date().toISOString())}`);return a&&s.push(`Program: ${a}`),s.join(" • ")}function Vn(){const{view:t,sort:a,options:s}=us(),{programSummaries:n,grandTotalPaid:r,grandTotalDue:i,grandTotalParticipants:l,loading:o,error:d,allPrograms:m}=rs(s),p=Number.parseFloat((r-i).toFixed(2)),f=pt(n,a),u=s.programId?m.find(g=>g.id===s.programId)?.name:void 0,h=ps(s,u);
1return d?e.jsx("div",{className:"w-full h-full flex flex-col items-center justify-center",children:e.jsxs("div",{className:"text-red-600 text-center",children:[e.jsx("p",{className:"text-lg font-semibold",children:"Error loading report"}),e.jsx("p",{className:"text-sm mt-2",children:d.message})]})}):o?e.jsx("div",{className:"w-full h-full flex flex-col items-center justify-center",children:e.jsx(rt,{loading:!0})}):e.jsx(be,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen bg-gray-100",children:e.jsxs("div",{className:"bg-white p-8 rounded-lg shadow-lg max-w-md w-full text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-800 mb-4",children:"Loading PDF Report..."}),e.jsx("div",{className:"animate-pulse bg-gray-200 h-4 rounded mb-2"}),e.jsx("div",{className:"animate-pulse bg-gray-200 h-4 rounded mb-2"}),e.jsx("div",{className:"animate-pulse bg-gray-200 h-4 rounded"})]})}),children:e.jsx(at,{style:c.pdfViewer,children:e.jsx(st,{title:"Paid vs Due by Program Report",children:e.jsxs(nt,{size:"LETTER",orientation:"landscape",style:{...c.page,...c.paddingLg},children:[e.jsxs(v,{style:[c.title],children:[e.jsx(v,{style:[c.flexRow,c.center,c.w100,c.wrap,c.verticalPaddingSm],children:e.jsx(S,{size:F.Xl,children:"Paid vs Due by Program Report"})}),e.jsx(v,{style:[c.flexRow,c.center,c.w100],children:e.jsx(S,{size:F.Sm,style:{color:"#666"},children:h})})]}),t==="byProgram"?e.jsx(ms,{programSummaries:n,grandTotalPaid:r,grandTotalDue:i,grandTotalParticipants:l,grandTotalVariance:p}):e.jsx(fs,{variants:f,grandTotalPaid:r,grandTotalDue:i,grandTotalParticipants:l,grandTotalVariance:p}),n.length>0&&e.jsx(v,{style:[c.paddingLg],children:e.jsx(S,{align:"center",style:{color:"#666"},children:`Report generated on ${new Date().toLocaleDateString()} • ${n.length} programs • ${l} participants`})})]})})})})}function ms({programSummaries:t,grandTotalPaid:a,grandTotalDue:s,grandTotalParticipants:n,grandTotalVariance:r}){const i=c.col15;return e.jsxs(e.Fragment,{children:[e.jsxs(oe,{background:c.bg_md_gray,children:[e.jsx(v,{style:[c.col30,c.leftPaddingSm],children:e.jsx(S,{weight:k.Bold,align:"left",children:"Program / Variant"})}),e.jsx(v,{style:[c.col15,c.leftPaddingXs],children:e.jsx(S,{weight:k.Bold,children:"Dates"})}),e.jsx(ht,{varianceCol:i})]}),t.map(l=>{const o=l.totalPaid-l.totalDue;return e.jsxs(v,{wrap:!1,children:[e.jsxs(oe,{background:ls,children:[e.jsx(v,{style:[c.col30,c.leftPaddingSm],children:e.jsx(S,{weight:k.Bold,children:l.programName})}),e.jsx(v,{style:[c.col15,c.leftPaddingXs]}),e.jsx(v,{style:[c.col10,c.leftPaddingXs],children:e.jsx(S,{weight:k.Bold,align:"center",children:l.totalParticipants.toString()})}),e.jsx(v,{style:[c.col15,c.leftPaddingXs],children:e.jsx(ee,{value:l.totalPaid,weight:k.Bold})}),e.jsx(v,{style:[c.col15,c.leftPaddingXs],children:e.jsx(ee,{value:l.totalDue,weight:k.Bold})}),e.jsx(v,{style:[i,c.leftPaddingXs],children:e.jsx(ee,{value:o,weight:k.Bold,style:Le(o)})})]}),l.variants.map((d,m)=>e.jsxs(oe,{background:m%2===0?c.bg_light_gray:void 0,children:[e.jsx(v,{style:[c.col30,{paddingLeft:20}],children:e.jsx(S,{size:F.Sm,children:d.variantSku})}),e.jsx(v,{style:[c.col15,c.leftPaddingXs],children:e.jsx(S,{size:F.Sm,children:ut(d,z)})}),e.jsx(mt,{variant:d,varianceCol:i})]},d.variantId))]},l.programId)}),t.length===0&&e.jsx(v,{style:[c.paddingLg],children:e.jsx(S,{align:"center",children:"No future variants found."})}),t.length>0&&e.jsxs(oe,{background:c.bg_md_gray,children:[e.jsx(v,{style:[c.col30,c.leftPaddingSm],children:e.jsx(S,{weight:k.Bold,size:F.Lg,children:"GRAND TOTAL"})}),e.jsx(v,{style:[c.col15,c.leftPaddingXs]}),e.jsx(ft,{grandTotalParticipants:n,grandTotalPaid:a,grandTotalDue:s,grandTotalVariance:r,varianceCol:i})]})]})}function fs({variants:t,grandTotalPaid:a,grandTotalDue:s,grandTotalParticipants:n,grandTotalVariance:r}){const i=c.col10;return e.jsxs(e.Fragment,{children:[e.jsxs(oe,{background:c.bg_md_gray,children:[e.jsx(v,{style:[c.col20,c.leftPaddingSm],children:e.jsx(S,{weight:k.Bold,align:"left",children:"Program"})}),e.jsx(v,{style:[c.col15,c.leftPaddingXs],children:e.jsx(S,{weight:k.Bold,children:"Variant SKU"})}),e.jsx(v,{style:[c.col15,c.leftPaddingXs],children:e.jsx(S,{weight:k.Bold,children:"Dates"})}),e.jsx(ht,{varianceCol:i})]}),t.map((l,o)=>e.jsxs(oe,{background:o%2===0?c.bg_light_gray:void 0,children:[e.jsx(v,{style:[c.col20,c.leftPaddingSm],children:e.jsx(S,{size:F.Sm,children:l.programName})}),e.jsx(v,{style:[c.col15,c.leftPaddingXs],children:e.jsx(S,{size:F.Sm,children:l.variantSku})}),e.jsx(v,{style:[c.col15,c.leftPaddingXs],children:e.jsx(S,{size:F.Sm,children:ut(l,z)})}),e.jsx(mt,{variant:l,varianceCol:i})]},l.variantId)),t.length===0&&e.jsx(v,{style:[c.paddingLg],children:e.jsx(S,{align:"center",children:"No variants found."})}),t.length>0&&e.jsxs(oe,{background:c.bg_md_gray,children:[e.jsx(v,{style:[c.col20,c.leftPaddingSm],children:e.jsx(S,{weight:k.Bold,size:F.Lg,children:"GRAND TOTAL"})}),e.jsx(v,{style:[c.col15,c.leftPaddingXs]}),e.jsx(v,{style:[c.col15,c.leftPaddingXs]}),e.jsx(ft,{grandTotalParticipants:n,grandTotalPaid:a,grandTotalDue:s,grandTotalVariance:r,varianceCol:i})]})]})}function Rn(t){return de.searchSelectApollo("variantId",{label:"Variant",dataType:"variants",document:Ee,required:!1,searchFields:["sku"],selectOptionsFunction:a=>a?.map(s=>({value:s.id,label:s.sku}))??[],initialOptions:[]})}function En(t){return de.searchSelectApollo("userId",{dataType:"users",document:$t,label:"User",required:!1,searchFields:["emails.email","realFirstName","realLastName"],selectOptionsFunction:a=>a?.map(s=>{const n=`${s.realFirstName||""} ${s.realLastName||""}
1`.trim(),r=s.email?` (${s.email})`:"";return{value:s.id,label:n+r||s.id}})??[],initialOptions:[]})}function hs(t){return de.checkbox("scholarshipApplication",{required:!1,defaultValue:t?.scholarshipApplication??!1,label:"Scholarship"})}function gs(t){return de.select("status",{required:!1,defaultValue:t?.status??I.Incomplete,options:[{value:I.Incomplete,label:"Incomplete"},{value:I.InProgress,label:"In Progress"},{value:I.Submitted,label:"Submitted"},{value:I.UnderReview,label:"Under Review"},{value:I.ScholarshipReview,label:"Scholarship Review"},{value:I.Rejected,label:"Rejected"},{value:I.Approved,label:"Approved"},{value:I.Cancelled,label:"Cancelled"}]})}function Fn(t){return de.searchSelectApollo("variantIdChoice2",{label:"Second Variant Choice (Optional)",dataType:"variants",document:Ee,required:!1,searchFields:["sku"],selectOptionsFunction:a=>a?.map(s=>({value:s.id,label:s.sku}))??[],initialOptions:[],showWhen:a=>a.scholarshipApplication===!0})}function xs(t){return de.textArea("staffNotes",{label:"Notes",placeholder:"Add internal notes or comments about this application...",required:!1,defaultValue:t?.staffNotes})}const se=et("CourseHelpers");function gt(t){const a=t.directSessions||[],s=t.modules?.flatMap(n=>n.sessions||[])||[];return[...a,...s]}function xt(t,a){return t.modules?.find(s=>s.sessions?.some(n=>n.id===a))}function _e(t,a){return!t?.sessions||t.sessions.length===0?!1:t.sessions.every(s=>a.has(s.id)?!0:s.userProgress?.some(n=>n.status===le.Completed))}function Mn(t,a,s,n,r){const i=new Set(r);if(!t?.accessMode||t.accessMode==="OPEN_ENROLLMENT")return i;if(t.accessMode==="SEQUENTIAL"){const l=gt(s);l.length>0&&i.add(l[0].id);for(let o=0;o<l.length-1;o++){const d=l[o],m=l[o+1];n.has(d.id)&&i.add(m.id)}}return i}function bs(t,a,s,n,r,i){if(_e(t,n)&&a===t.sessions.length-1)return i&&t.showCompletionScreen!==!1&&(i.setCompletedModule(t),i.setShowModuleCompletion(!0)),!1;if(a<t.sessions.length-1){const o=t.sessions[a+1],d=r?.has(o.id)??!1;if(se.debug("🔍 Next session check in module",{nextSessionId:o.id,nextSessionTitle:o.title,isNextSessionUnlocked:d,hasPredictedIds:!!r,predictedIdsSize:r?.size||0}),d)return se.debug("✅ Navigating to next session in module"),s(o,d),!0;se.debug("❌ Next session not unlocked, cannot navigate")}return!1}function Be(t,a,s,n){if(!t?.chapters||!a)return!1;const r=[...t.chapters].sort((o,d)=>o.order-d.order),i=r.findIndex(o=>o.id===a.id);if(i===-1||i>=r.length-1)return!1;const l=r[i+1];return l?(s(`/course/${n.courseId}/participant/${n.participantId}/chapter/${l.id}`),!0):!1}function vs(t,a,s,n,r,i,l){const o=[...t.modules||[]].sort((m,p)=>m.order-p.order),d=o.findIndex(m=>m.id===a.id);if(d===-1)return!1;if(d<o.length-1){const m=o[d+1];if(m.sessions&&m.sessions.length>0){const p=m.sessions[0],f=l?.has(p.id)??!1;return s(p,f),!0}}return Be(n,t,r,i)}function Ye(t,a){return t?.directSessions&&t?.directSessions?.length>0?t.directSessions:a?.sessions?a.sessions:null}function ys(t){const{currentModule:a,locallyCompletedSessions:s,handlers:{setCompletedModule:n,setShowModuleCompletion:r,setShowChapterCompletion:i},navigation:{course:l,chapter:o,navigate:d,params:m}}=t;if((_e(a,s)||a.sessions.length===1)&&a.showCompletionScreen!==!1){n(a),r(!0),i(!0);return}Be(l,o,d,m)}function js(t){const{currentModule:a,locallyCompletedSessions:s,handlers:{setCompletedModule:n,setShowModuleCompletion:r,handleSessionClick:i},navigation:{chapter:l,course:o,navigate:d,params:m},predictedUnlockedIds:p}=t;if(_e(a,s)){if(a.showCompletionScreen!==!1){n(a),r(!0);return}vs(l,a,i,o,d,m,p)}}function Ln(t){const{chapter:a,currentModule:s,currentSession:n,course:r,locallyCompletedSessions:i,handlers:{handleSessionClick:l,setShowModuleCompletion:o,setCompletedModule:d,setShowChapterCompletion:m},navigation:{navigate:p,params:f},predictedUnlockedIds:u}=t;se.debug("🧭 goToNextSession called with",{currentSessionId:n?.id,currentModuleId:s?.id,chapterId:a?.id});const h=Ye(a,s);if(!n||!h){se.debug("❌ No current session or sessions found",{hasCurrentSession:!!n,hasSessions:!!h,sessionsCount:h?.length||0});return}const g=h.findIndex(w=>w.id===n.id);if(se.debug("🚀 Navigation attempt details",{currentSessionId:n.id,currentSessionTitle:n.title,currentSessionIndex:g,totalSessions:h.length,nextSessionId:g<h.length-1?h[g+1].id:null,nextSessionTitle:g<h.length-1?h[g+1].title:null,predictedUnlockedCount:u?.size||0,isNextSessionPredictedUnlocked:g<h.length-1?u?.has(h[g+1].id):!1}),!bs(s,g,l,i,u,{setShowModuleCompletion:o,setCompletedModule:d})){if(a?.directSessions&&a.directSessions.length>0){Be(r,a,p,f);return}if(a?.modules&&s){const w=[...a.modules].sort((P,C)=>P.order-C.order),x=w.findIndex(P=>P.id===s.id),j=x===w.length-1,A=Ye(a,s),y=A?.findIndex(P=>P.id===n.id)??-1,T=A&&y>=0&&y<A.length-1;if(se.debug("🏗️ Module navigation decision",{isLastModule:j,currentModuleIndex:x,totalModules:w.length,hasMoreSessionsInModule:T,currentSessionIndex:y,totalSessionsInModule:A?.length||0}),T){se.debug("❌ Still has sessions in current module - should not navigate away yet");return}j?ys({currentModule:s,locallyCompletedSessions:i,handlers:{setCompletedModule:d,setShowModuleCompletion:o,setShowChapterCompletion:m},navigation:{course:r,chapter:a,navigate:p,params:f}}):js({currentModule:s,locallyCompletedSessions:i,handlers:{setCompletedModule:d,setShowModuleCompletion:o,handleSessionClick:l},navigation:{chapter:a,course:r,navigate:p,params:f},predictedUnlockedIds:u})}}}function _n(t,a,s,n){if(!t?.chapters||!a)return!1;const r=[...t.chapters].sort((u,h)=>u.order-h.order);
1if(!(r.findIndex(u=>u.id===a.id)===r.length-1))return!1;if(a.directSessions&&a.directSessions.length>0){if(!n)return!1;const u=[...a.directSessions].sort((g,w)=>g.order-w.order);return u.findIndex(g=>g.id===n.id)===u.length-1}if(!a.modules||!s)return!1;const o=[...a.modules].sort((u,h)=>u.order-h.order);if(!(o.findIndex(u=>u.id===s.id)===o.length-1)||!n||!s.sessions||s.sessions.length===0)return!1;const p=[...s.sessions].sort((u,h)=>u.order-h.order);return p.findIndex(u=>u.id===n.id)===p.length-1}const xe=et("CourseHooks"),Ke=(t,a,s)=>{if(!s)return{};const n=a.find(i=>i.id===s),r=n?xt(t,n.id):void 0;return{session:n,module:r}},ws=(t,a)=>{const s=a[0],n=s?xt(t,s.id):void 0;return{session:s,module:n??t.modules?.[0]}},Ss=(t,a,s,n)=>{const r=gt(t),i=s&&n!==s?Ke(t,r,s):{};if(i.session)return i;const l=Ke(t,r,a?.lastAccessedSessionId);return l.session?l:ws(t,r)};function Bn(t,a,s){const[n,r]=b.useState(),[i,l]=b.useState(),o=b.useRef(void 0),d=b.useRef(void 0),m=b.useRef(void 0);return b.useLayoutEffect(()=>{if(!t)return;const p=t.id!==o.current,f=a?.id!==d.current,u=a?.lastAccessedSessionId!==m.current;if(!p&&!f&&!u)return;const{session:h,module:g}=Ss(t,a,s,n?.id);h&&h.id!==n?.id&&(r(h),l(g)),o.current=t.id,d.current=a?.id,m.current=a?.lastAccessedSessionId},[t,a,n,s]),{currentSession:n,currentModule:i,setCurrentSession:r,setCurrentModule:l}}function Un(t,a){const[s,n]=b.useState(new Set),[r,i]=b.useState(!1),[l]=G(zt),[o]=G(Xt),d=t?s.has(t.id)?!0:t.userProgress?.some(u=>u.status===le.Completed)||!1:!1,m=()=>t&&t.userProgress?.[0]||null;return{locallyCompletedSessions:s,isMarkingComplete:r,isCurrentSessionCompleted:d,handleMarkAsComplete:async()=>{if(!(!t||!a||r)){i(!0),n(f=>new Set(f).add(t.id));try{const f=m();f?await o({variables:{userSessionProgressId:f.id,input:{status:le.Completed,completedAt:new Date().toISOString()}},update:(u,{data:h})=>{u.modify({id:u.identify(f),fields:{status:()=>le.Completed}})}}):await l({variables:{input:{sessionId:t.id,participantId:a.id,status:le.Completed,startedAt:new Date().toISOString(),completedAt:new Date().toISOString()}},update:(u,{data:h})=>{h?.userCreateSessionProgress?.id&&u.modify({id:h.userCreateSessionProgress.id,fields:{status:()=>le.Completed}})}})}catch(f){xe.error("Error marking session as complete",{error:f});const u=f?.message||f?.toString()||"",h=u.includes("Unique constraint failed")&&u.includes("participantId")&&u.includes("sessionId");if(xe.debug("Checking error type",{errorString:u,isUniqueConstraintError:h,errorType:typeof f}),h)xe.debug("✅ Session already marked as complete in database - continuing with navigation");else{xe.error("❌ Genuine error occurred, stopping navigation");return}}finally{i(!1)}}}}}function On(){const[t,a]=b.useState(!1);return b.useEffect(()=>{const s=()=>{a(window.innerWidth<768)};return s(),window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[]),t}function $n(){const[t,{loading:a}]=G(Wt);return{startGatewayTrial:b.useCallback(async()=>{const{data:n}=await t();return n?.userStartGatewayTrial??null},[t]),loading:a}}const Ns=()=>e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"h-6 bg-gray-200 rounded w-1/3 mb-4"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-4 bg-gray-200 rounded w-full"}),e.jsx("div",{className:"h-4 bg-gray-200 rounded w-5/6"}),e.jsx("div",{className:"h-4 bg-gray-200 rounded w-4/6"})]})]}),e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"h-6 bg-gray-200 rounded w-1/4 mb-4"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-4 bg-gray-200 rounded w-full"}),e.jsx("div",{className:"h-4 bg-gray-200 rounded w-3/4"})]})]})]}),Wn=b.memo(function(a){const{params:s,currentSession:n,imageUrl:r}=a,[i,l]=b.useState(!1),[o,d]=b.useState(n?.contentBlocks),m=b.useMemo(()=>o?.length?[...o].sort((p,f)=>(p.order??0)-(f.order??0)):[],[o]);return b.useEffect(()=>{l(!1);const p=setTimeout(()=>{d(n?.contentBlocks);const f=setTimeout(()=>{l(!0)},50);return()=>clearTimeout(f)},200);return()=>{clearTimeout(p)}},[n?.contentBlocks,n?.id]),n?.contentBlocks?o?.length?e.jsx("div",{className:`transition-opacity duration-300 ${i?"opacity-100":"opacity-0"}`,children:m.map(p=>e.jsx(Ga,{block:p,imageUrl:r,participantId:s.participantId,sessionId:n?.id},p.id))}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h4",{className:"text-xl font-medium mb-2",children:"No content available"}),e.jsx("p",{className:"text-gray-600",children:"This session doesn't have any content blocks yet."})]})}):e.jsx("div",{className:"flex-1",children:e.jsx(Ns,{})})}),bt=b.createContext(void 0);
1function zn(){return b.useContext(bt)?.redirectToShopify||(a=>{setTimeout(()=>{globalThis.window!==void 0&&(globalThis.location.href=a)},0)})}function Xn({children:t,user:a=null}){const[s,{data:n}]=ke(Ht),r=b.useRef(null),i=b.useCallback((o,d)=>{r.current=d,s({variables:{returnUrl:o}}).catch(console.error)},[s]);b.useEffect(()=>{if(n?.getShopifyToken?.url&&r.current&&globalThis.window!==void 0){const o=n.getShopifyToken.url;r.current==="new_tab"?globalThis.open(o,"about:blank"):r.current==="same_tab"?globalThis.location.replace(o):console.error("Invalid target"),r.current=null}},[n]);const l=b.useMemo(()=>({redirectToShopify:i,user:a}),[i,a]);return e.jsx(bt.Provider,{value:l,children:t})}const J={BASE_URL:"/",DEV:!0,MODE:"production",PROD:!1,SSR:!1,VITE_API_URL:"http://localhost:3008",VITE_TURNSTILE_SITE_KEY:"0x4AAAAAAD6fYZiEghZs5jYo"};function vt(t){return"init"in t}function Ve(t){return!!t.write}function Qe(t){return"v"in t||"e"in t}function je(t){if("e"in t)throw t.e;if((J?"production":void 0)!=="production"&&!("v"in t))throw new Error("[Bug] atom state is not initialized");return t.v}const we=new WeakMap;function yt(t){var a;return Se(t)&&!!((a=we.get(t))!=null&&a[0])}function As(t){const a=we.get(t);a?.[0]&&(a[0]=!1,a[1].forEach(s=>s()))}function Ds(t,a){let s=we.get(t);if(!s){s=[!0,new Set],we.set(t,s);const n=()=>{s[0]=!1};t.then(n,n)}s[1].add(a)}function Se(t){return typeof t?.then=="function"}function jt(t,a,s){if(!s.p.has(t)){s.p.add(t);const n=()=>s.p.delete(t);a.then(n,n)}}function wt(t,a,s){var n;const r=new Set;for(const i of((n=s.get(t))==null?void 0:n.t)||[])s.has(i)&&r.add(i);for(const i of a.p)r.add(i);return r}const Ps=(t,a,...s)=>a.read(...s),Cs=(t,a,...s)=>a.write(...s),Ts=(t,a)=>{var s;return(s=a.unstable_onInit)==null?void 0:s.call(a,t)},ks=(t,a,s)=>{var n;return(n=a.onMount)==null?void 0:n.call(a,s)},Is=(t,a)=>{var s;const n=B(t),r=n[0],i=n[6],l=n[9];if((J?"production":void 0)!=="production"&&!a)throw new Error("Atom is undefined or null");let o=r.get(a);return o||(o={d:new Map,p:new Set,n:0},r.set(a,o),(s=i.i)==null||s.call(i,a),l?.(t,a)),o},Vs=t=>{const a=B(t),s=a[1],n=a[3],r=a[4],i=a[5],l=a[6],o=a[13],d=[],m=p=>{try{p()}catch(f){d.push(f)}};do{l.f&&m(l.f);const p=new Set,f=p.add.bind(p);n.forEach(u=>{var h;return(h=s.get(u))==null?void 0:h.l.forEach(f)}),n.clear(),i.forEach(f),i.clear(),r.forEach(f),r.clear(),p.forEach(m),n.size&&o(t)}while(n.size||i.size||r.size);
1if(d.length)throw new AggregateError(d)},Rs=t=>{const a=B(t),s=a[1],n=a[2],r=a[3],i=a[11],l=a[14],o=a[17],d=[],m=new WeakSet,p=new WeakSet,f=Array.from(r);for(;f.length;){const u=f[f.length-1],h=i(t,u);if(p.has(u)){f.pop();continue}if(m.has(u)){if(n.get(u)===h.n)d.push([u,h]);else if((J?"production":void 0)!=="production"&&n.has(u))throw new Error("[Bug] invalidated atom exists");p.add(u),f.pop();continue}m.add(u);for(const g of wt(u,h,s))m.has(g)||f.push(g)}for(let u=d.length-1;u>=0;--u){const[h,g]=d[u];let w=!1;for(const x of g.d.keys())if(x!==h&&r.has(x)){w=!0;break}w&&(l(t,h),o(t,h)),n.delete(h)}},Re=new WeakSet,Es=(t,a)=>{var s,n;const r=B(t),i=r[1],l=r[2],o=r[3],d=r[6],m=r[7],p=r[11],f=r[12],u=r[13],h=r[14],g=r[16],w=r[17],x=p(t,a);if(Qe(x)&&(i.has(a)&&l.get(a)!==x.n||Array.from(x.d).every(([D,K])=>h(t,D).n===K)))return x;x.d.clear();let j=!0;function A(){i.has(a)&&(w(t,a),u(t),f(t))}function y(D){var K;if(D===a){const ie=p(t,D);if(!Qe(ie))if(vt(D))Ne(t,D,D.init);else throw new Error("no atom init");return je(ie)}const q=h(t,D);try{return je(q)}finally{x.d.set(D,q.n),yt(x.v)&&jt(a,x.v,q),(K=i.get(D))==null||K.t.add(a),j||A()}}let T,P;const C={get signal(){return T||(T=new AbortController),T.signal},get setSelf(){return(J?"production":void 0)!=="production"&&!Ve(a)&&console.warn("setSelf function cannot be used with read-only atom"),!P&&Ve(a)&&(P=(...D)=>{if((J?"production":void 0)!=="production"&&j&&console.warn("setSelf function cannot be called in sync"),!j)try{return g(t,a,...D)}finally{u(t),f(t)}}),P}},M=x.n;try{(J?"production":void 0)!=="production"&&Re.delete(t);const D=m(t,a,y,C);
1return(J?"production":void 0)!=="production"&&Re.has(t)&&console.warn("Detected store mutation during atom read. This is not supported."),Ne(t,a,D),Se(D)&&(Ds(D,()=>T?.abort()),D.then(A,A)),(s=d.r)==null||s.call(d,a),x}catch(D){return delete x.v,x.e=D,++x.n,x}finally{j=!1,M!==x.n&&l.get(a)===M&&(l.set(a,x.n),o.add(a),(n=d.c)==null||n.call(d,a))}},Fs=(t,a)=>{const s=B(t),n=s[1],r=s[2],i=s[11],l=[a];for(;l.length;){const o=l.pop(),d=i(t,o);for(const m of wt(o,d,n)){const p=i(t,m);r.set(m,p.n),l.push(m)}}},St=(t,a,...s)=>{const n=B(t),r=n[3],i=n[6],l=n[8],o=n[11],d=n[12],m=n[13],p=n[14],f=n[15],u=n[17];let h=!0;const g=x=>je(p(t,x)),w=(x,...j)=>{var A;const y=o(t,x);try{if(x===a){if(!vt(x))throw new Error("atom not writable");(J?"production":void 0)!=="production"&&Re.add(t);const T=y.n,P=j[0];Ne(t,x,P),u(t,x),T!==y.n&&(r.add(x),(A=i.c)==null||A.call(i,x),f(t,x));return}else return St(t,x,...j)}finally{h||(m(t),d(t))}};try{return l(t,a,g,w,...s)}finally{h=!1}},Ms=(t,a)=>{var s;const n=B(t),r=n[1],i=n[3],l=n[6],o=n[11],d=n[15],m=n[18],p=n[19],f=o(t,a),u=r.get(a);if(u&&!yt(f.v)){for(const[h,g]of f.d)if(!u.d.has(h)){const w=o(t,h);m(t,h).t.add(a),u.d.add(h),g!==w.n&&(i.add(h),(s=l.c)==null||s.call(l,h),d(t,h))}for(const h of u.d||[])if(!f.d.has(h)){u.d.delete(h);const g=p(t,h);g?.t.delete(a)}}},Nt=(t,a)=>{var s;const n=B(t),r=n[1],i=n[4],l=n[6],o=n[10],d=n[11],m=n[12],p=n[13],f=n[14],u=n[16],h=d(t,a);let g=r.get(a);if(!g){f(t,a);for(const w of h.d.keys())Nt(t,w).t.add(a);if(g={l:new Set,d:new Set(h.d.keys()),t:new Set},r.set(a,g),(s=l.m)==null||s.call(l,a),Ve(a)){const w=()=>{let x=!0;const j=(...A)=>{try{return u(t,a,...A)}finally{x||(p(t),m(t))}};try{const A=o(t,a,j);A&&(g.u=()=>{x=!0;try{A()}finally{x=!1}})}finally{x=!1}};i.add(w)}}return g},Ls=(t,a)=>{var s;const n=B(t),r=n[1],i=n[5],l=n[6],o=n[11],d=n[19],m=o(t,a);let p=r.get(a);if(p&&!p.l.size&&!Array.from(p.t).some(f=>{var u;return(u=r.get(f))==null?void 0:u.d.has(a)})){p.u&&i.add(p.u),p=void 0,r.delete(a),(s=l.u)==null||s.call(l,a);for(const f of m.d.keys()){const u=d(t,f);u?.t.delete(a)}return}return p},Ne=(t,a,s)=>{const n=B(t)[11],r=n(t,a),i="v"in r,l=r.v;if(Se(s))for(const o of r.d.keys())jt(a,s,n(t,o));r.v=s,delete r.e,(!i||!Object.is(l,r.v))&&(++r.n,Se(l)&&As(l))},_s=(t,a)=>{const s=B(t)[14];return je(s(t,a))},Bs=(t,a,...s)=>{const n=B(t),r=n[12],i=n[13],l=n[16];try{return l(t,a,...s)}finally{i(t),r(t)}},Us=(t,a,s)=>{const n=B(t),r=n[12],i=n[18],l=n[19],d=i(t,a).l;return d.add(s),r(t),()=>{d.delete(s),l(t,a),r(t)}},At=new WeakMap,B=t=>{const a=At.get(t);if((J?"production":void 0)!=="production"&&!a)throw new Error("Store must be created by buildStore to read its building blocks");return a};function Os(...t){const a={get(n){const r=B(a)[21];return r(a,n)},set(n,...r){const i=B(a)[22];return i(a,n,...r)},sub(n,r){const i=B(a)[23];return i(a,n,r)}},s=[new WeakMap,new WeakMap,new WeakMap,new Set,new Set,new Set,{},Ps,Cs,Ts,ks,Is,Vs,Rs,Es,Fs,St,Ms,Nt,Ls,Ne,_s,Bs,Us,void 0].map((n,r)=>t[r]||n);return At.set(a,Object.freeze(s)),a}const Dt={};let $s=0;function Je(t,a){const s=`atom${++$s}`,n={toString(){return(Dt?"production":void 0)!=="production"&&this.debugLabel?s+":"+this.debugLabel:s}};return typeof t=="function"?n.read=t:(n.init=t,n.read=Ws,n.write=zs),a&&(n.write=a),n}function Ws(t){return t(this)}function zs(t,a,s){return a(this,typeof s=="function"?s(t(this)):s)}function Xs(){return Os()}let me;function Hn(){return me||(me=Xs(),(Dt?"production":void 0)!=="production"&&(globalThis.__JOTAI_DEFAULT_STORE__||(globalThis.__JOTAI_DEFAULT_STORE__=me),globalThis.__JOTAI_DEFAULT_STORE__!==me&&console.warn("Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"))),me}function Hs(t){return t?.documents?.filter(a=>a.historicApplication)??[]}function Ze(t){return t?.user?.email||t?.email||null}function Gs(t,a){if(t?.id){if(a.length>0&&(t.reissueCount??0)>0){globalThis.open(`/pdf/programApplication/${t.id}`,"_blank");return}a.length>0?a.forEach(s=>{const n=ha(s);n&&globalThis.open(n,"_blank","noopener,noreferrer")}):globalThis.open(`/pdf/programApplication/${t.id}`,"_blank")}}function qs(t){t&&(globalThis.location.href=`mailto:${t}`)}const Ys=new Set([I.Submitted,I.UnderReview,I.ScholarshipReview,I.Approved]);function Ks(t){return!t?.status||t.reissuedAt?!1:Ys.has(t.status)}function Gn({application:t,loading:a,linkBase:s,readOnly:n=!1,isAdmin:r=!1}){const{t:i}=re(),l=tt(),[o,d]=b.useState(null),[m,p]=b.useState(!1),[f]=G(Gt),u=t?.id,h=t?.scholarshipApplication===!0&&t?.programId&&!t?.variantId;async function g(j){if(t?.id){d(null);try{const A=typeof j.status=="object"?j.status.value:j.status;
1await f({variables:{applicationId:t.id,input:{status:A||t.status,staffNotes:j.staffNotes||t.staffNotes||null,scholarshipApplication:j.scholarshipApplication??t.scholarshipApplication??!1}}})}catch(A){d({alertType:"error",title:i("admin:applications.header.errors.savingApplication",{defaultValue:"Error saving application"}),message:A instanceof Error?A.message:i("admin:applications.header.errors.savingApplicationMessage",{defaultValue:"An unexpected error occurred while saving the application."})})}}}async function w(){if(t?.id){d(null);try{await f({variables:{applicationId:t.id,input:{status:I.Approved,staffNotes:t.staffNotes||null,sendAcceptanceEmail:r}}})}catch(j){d({alertType:"error",title:i("admin:applications.header.errors.acceptingApplication",{defaultValue:"Error accepting application"}),message:j instanceof Error?j.message:i("admin:applications.header.errors.acceptingApplicationMessage",{defaultValue:"An unexpected error occurred while accepting the application."})})}}}function x(){l(-1)}return u?a||!t?e.jsx("div",{className:"p-4 w-full h-full flex items-center justify-center",children:e.jsx(rt,{loading:!0})}):t?e.jsxs("div",{className:"w-full flex flex-col space-y-1 bg-white py-4 px-6 border-b border-gray-200",children:[e.jsx("div",{className:"w-full flex items-center justify-between",children:e.jsxs("div",{className:"flex flex-row items-center w-full",children:[e.jsx(X,{onClick:x,children:e.jsx("div",{className:"flex flex-row items-center text-green-web",children:e.jsx(ze,{className:"w-8 h-8 -ml-2 mr-2"})})}),e.jsx("div",{className:"grow",children:e.jsx(Qs,{application:t,linkBase:s})}),!n&&e.jsx(Js,{application:t,setError:d})]})}),t.reissuedAt&&e.jsx("div",{className:"py-2",children:e.jsx(fe,{alertType:"warning",title:i("admin:applications.header.reissuedBannerTitle",{defaultValue:"Re-issued to the applicant"}),message:i("admin:applications.header.reissuedBannerMessage",{defaultValue:"Re-issued on {{date}}{{by}} — {{reason}} Awaiting their correction and signature.",date:ne(t.reissuedAt,"MM/DD/YYYY"),by:t.reissuedBy?` by ${[t.reissuedBy.firstName,t.reissuedBy.lastName].filter(Boolean).join(" ")}`:"",reason:t.reissueReason??""})})}),!n&&e.jsx(en,{application:t,handleSubmit:g}),o&&e.jsx("div",{className:" py-4",children:e.jsx(fe,{alertType:o.alertType,title:o.title,message:o.message})}),!n&&(t?.status===I.Submitted||t?.status===I.UnderReview||t?.status===I.ScholarshipReview)&&e.jsx("div",{className:"-mt-2",children:h?e.jsxs(e.Fragment,{children:[e.jsx($e,{reviewText:i("admin:applications.header.scholarshipReviewText",{defaultValue:"Scholarship Application"}),onClick:()=>p(!0),buttonText:i("admin:applications.header.approveAndSelectVariant",{defaultValue:"Approve & Select Variant"})}),e.jsx(ts,{isOpen:m,onClose:()=>p(!1),applicationId:u??"",programId:t.programId??"",programName:t.program?.name??void 0,contributionAmount:t.scholarship?.canPayAmount??null,campaignBudgetId:t.campaign?.budgetId??null})]}):e.jsx($e,{reviewText:i("admin:applications.header.reviewText",{defaultValue:"Application"}),onClick:w,buttonText:r?i("admin:applications.header.acceptAndEmailUser",{defaultValue:"Accept & Email User"}):i("admin:applications.header.acceptApplication",{defaultValue:"Accept Application"})})})]}):e.jsx("div",{className:"w-full flex flex-col space-y-1 bg-white px-6 py-4 border-b border-gray-200",children:e.jsxs("div",{className:"w-full flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-row items-center",children:[e.jsx(X,{onClick:x,children:e.jsx("div",{className:"flex flex-row items-center text-green-web",children:e.jsx(ze,{className:"w-8 h-6 -ml-2 mr-2"})})}),e.jsx("h1",{className:"text-2xl text-gray-800 font-semibold",children:i("admin:applications.detail.title",{defaultValue:"Application Details"})})]}),e.jsx("div",{className:"flex items-center space-x-3",children:e.jsx("div",{className:"flex flex-row gap-2"})})]})}):e.jsx("div",{className:"p-4",children:i("admin:applications.header.applicationIdRequired",{defaultValue:"Application ID is required"})})}function Qs(t){const{t:a}=re(),{application:s,linkBase:n}=t,r=s?.user?.id||s?.participant?.id,i=s?.variant?.id,l=s?.user?.realFirstName??s?.firstName??"",o=s?.user?.realLastName??s?.lastName??"",d=s?.variant?.sku??"",m=s?.program?.name??s?.variant?.program?.name??"",p=s?.scholarshipApplication===!0;if(!s)return e.jsx("div",{className:"grow h-10 bg-gray-200 rounded-md"});const f=p?a("admin:applications.header.scholarshipApplicationFor",{defaultValue:"Scholarship Application for"}):a("admin:applications.header.applicationFor",{defaultValue:"Application for"});return e.jsxs("div",{className:"text-xl text-green-web font-medium",children:[f," ",n&&r?e.jsxs(Te,{to:`${n}/contact/${r}`,className:"text-green-web hover:text-green-web-800 hover:underline",children:[l," ",o]}):e.jsxs("span",{children:[l," ",o]}),p&&m?e.jsxs(e.Fragment,{children:[" ",a("admin:applications.header.forProgram",{defaultValue:"for"})," ",e.jsx("span",{className:"font-medium",children:m})]}):null,d?e.jsxs(e.Fragment,{children:[" - ",n&&i?e.jsx(Te,{to:`${n}/variant/${i}`,className:"text-green-web hover:text-green-web-800 hover:underline",children:d}):e.jsx("span",{children:d})]}
1):null,s.status===I.Submitted&&s.submittedDate&&e.jsxs("span",{className:"text-gray-600 text-sm ml-4",children:["(",a("admin:applications.header.submittedOn",{defaultValue:"Submitted on"})," ",ne(s.submittedDate,"MM/DD/YY"),")"]}),s.status===I.Rejected&&s.confirmDate&&e.jsxs("span",{className:"text-red-600 text-sm ml-4",children:[a("admin:applications.header.rejectedOn",{defaultValue:"Rejected on"})," ",ne(s.confirmDate,"MM/DD/YY"),")"]}),s.status===I.Approved&&s.confirmDate&&e.jsxs("span",{className:"text-green-web text-sm ml-4",children:[a("admin:applications.header.approvedOn",{defaultValue:"Approved on"})," ",ne(s.confirmDate,"MM/DD/YY"),")"]})]})}function Js(t){const{t:a}=re(),s=tt(),{application:n,setError:r}=t,[i,l]=b.useState(!1),[o]=G(qt),[d,m]=b.useState(!1),[p,f]=b.useState(null),[u]=G(Yt),[h]=G(Kt),[g,w]=b.useState(!1),[x,j]=b.useState(""),[A,{loading:y}]=G(Qt),[T,{data:P,loading:C,error:M}]=ke(Jt,{fetchPolicy:"network-only"}),[D,{data:K,loading:q,error:ie}]=ke(Zt),Q=n?Hs(n):[];function ue(){n&&Gs(n,Q)}function U(){if(!n)return;const V=Ze(n);qs(V)}async function O(){if(n?.id){r(null);try{await o({variables:{programApplicationId:n.id}}),s(-1)}catch(V){r({alertType:"error",title:a("admin:applications.header.errors.deletingApplication",{defaultValue:"Error deleting application"}),message:V instanceof Error?V.message:a("admin:applications.header.errors.deletingApplicationMessage",{defaultValue:"An unexpected error occurred while deleting the application."})}),l(!1)}}}function _(){n?.user?.id&&(T({variables:{userId:n.user.id}}),D({variables:{userId:n.user.id}}),m(!0),f(null))}async function L(){if(!(!n?.id||!p)){r(null);try{let V;if(p.type==="participant"&&p.participantId){const{data:R}=await u({variables:{input:{applicationId:n.id,targetParticipantId:p.participantId}},refetchQueries:["ProgramApplication"]});V=R?.staffTransferApplication}else if(p.type==="trainer-variant"&&p.variantId){const{data:R}=await h({variables:{input:{applicationId:n.id,targetVariantId:p.variantId}},refetchQueries:["ProgramApplication"]});V=R?.staffTransferApplicationToVariant}V?.success||r({alertType:"error",title:a("admin:applications.header.errors.transferFailed",{defaultValue:"Transfer Failed"}),message:V?.message}),m(!1)}catch(V){r({alertType:"error",title:a("admin:applications.header.errors.transferringApplication",{defaultValue:"Error transferring application"}),message:V instanceof Error?V.message:a("admin:applications.header.errors.transferringApplicationMessage",{defaultValue:"An unexpected error occurred."})}),m(!1)}}}async function H(){if(!n?.id)return;const V=x.trim();if(V){r(null);try{await A({variables:{input:{applicationId:n.id,reason:V}},refetchQueries:["ProgramApplication","StaffProgramApplicationSignedVersions"]}),w(!1),j("")}catch(R){r({alertType:"error",title:a("admin:applications.header.errors.reissuingApplication",{defaultValue:"Error re-issuing application"}),message:R instanceof Error?R.message:a("admin:applications.header.errors.reissuingApplicationMessage",{defaultValue:"An unexpected error occurred while re-issuing the application."})}),w(!1)}}}const $=n?Ze(n):null;return e.jsxs("div",{className:"flex flex-row gap-2",children:[e.jsx(ba,{applicationId:n?.id??"",documents:n?.documents??void 0}),$&&e.jsx(X,{onClick:U,className:"text-gray-700",type:"secondary",title:a("admin:applications.header.emailParticipant",{defaultValue:"Email Participant"}),children:e.jsx(ja,{className:"w-5 h-5"})}),e.jsx(X,{onClick:ue,className:"text-gray-700",type:"secondary",title:a("admin:applications.header.printApplication",{defaultValue:"Print Application"}),children:e.jsx(wa,{className:"w-5 h-5"})}),e.jsx(X,{onClick:_,className:"text-gray-700",type:"secondary",title:a("admin:applications.header.transferApplication",{defaultValue:"Transfer Application"}),children:e.jsx(Ca,{className:"w-5 h-5"})}),Ks(n)&&e.jsx(X,{onClick:()=>{j(""),w(!0)},className:"text-gray-700",type:"secondary",title:a("admin:applications.header.reissueApplication",{defaultValue:"Re-issue to Applicant"}),children:e.jsx(Sa,{className:"w-5 h-5"})}),e.jsx(Zs,{isOpen:g,setIsOpen:w,reason:x,setReason:j,onConfirm:H,saving:y,isApproved:n?.status===I.Approved}),e.jsx(X,{onClick:()=>l(!0),className:"text-red-600 hover:text-red-700",type:"secondary",title:a("admin:applications.header.deleteApplication",{defaultValue:"Delete Application"}),children:e.jsx(Na,{className:"w-5 h-5"})}),e.jsx(Fe,{title:a("admin:applications.header.deleteConfirmTitle",{defaultValue:"Delete Application"}),isOpen:i,setIsOpen:l,onConfirm:O,confirmText:"Delete",destructive:!0,children:e.jsx("p",{className:"px-6 py-4",children:a("admin:applications.header.deleteConfirmMessage",{defaultValue:"Are you sure you want to delete this application? This action cannot be undone."})})}),e.jsx(an,{application:n,isOpen:d,setIsOpen:m,selectedTransferTarget:p,setSelectedTransferTarget:f,handleTransfer:L,participantsData:P,participantsLoading:C,participantsError:M,trainerData:K,trainerLoading:q,trainerError:ie})]})}function Zs(t){const{t:a}=re(),{isOpen:s,setIsOpen:n,reason:r,setReason:i,onConfirm:l,saving:o,isApproved:d}=t,m=r.trim().length>0&&!o;return e.jsxs(Fe,{title:a("admin:applications.header.reissueConfirmTitle",{defaultValue:"Re-issue to Applicant"}),isOpen:s,setIsOpen:n,hideBottomButtons:!0,children:[e.jsxs("div",{className:"px-6 py-4",children:[e.jsx("p",{className:"text-sm text-gray-600",children:a("admin:applications.header.reissueConfirmMessage",{defaultValue:"The application goes back to the applicant with all their answers still filled 
1in. Their signature is cleared, so they have to correct it and sign again before it counts as submitted. The version they signed is kept in this application's history."})}),d&&e.jsx("p",{className:"mt-3 text-sm font-medium text-yellow-800",children:a("admin:applications.header.reissueApprovedWarning",{defaultValue:"This application is already approved. Re-issuing it withdraws that decision — it will have to be approved again after they re-sign."})}),e.jsx("label",{htmlFor:"reissue-reason",className:"block mt-4 text-sm font-medium text-gray-700",children:a("admin:applications.header.reissueReasonLabel",{defaultValue:"What should they correct? (shown to the applicant)"})}),e.jsx("textarea",{id:"reissue-reason",value:r,onChange:p=>i(p.target.value),rows:4,maxLength:1e3,required:!0,className:"mt-1 block w-full rounded-md border border-gray-300 p-2 text-sm focus:border-green-web focus:outline-none",placeholder:a("admin:applications.header.reissueReasonPlaceholder",{defaultValue:"e.g. Your date of birth looks like a typo — please check it and sign again."})})]}),e.jsxs("div",{className:"flex flex-row w-full justify-end gap-3 border-t px-6 py-4 bg-gray-50",children:[e.jsx(X,{type:"secondary",onClick:()=>n(!1),className:"px-4 py-2",children:a("admin:applications.header.reissueCancel",{defaultValue:"Cancel"})}),e.jsx(X,{type:"primary",onClick:l,disabled:!m,className:"px-4 py-2 min-w-24",children:a("admin:applications.header.reissueConfirm",{defaultValue:"Re-issue"})})]})]})}function en(t){const{t:a}=re(),{application:s,handleSubmit:n}=t,[r,i]=b.useState(!1);return b.useEffect(()=>{s?.staffNotes&&i(!0)},[s?.staffNotes]),s?e.jsx(it,{id:"admin-application-form",defaultValues:{status:s.status,staffNotes:s.staffNotes||"",scholarshipApplication:s.scholarshipApplication??!1},submit:n,children:e.jsxs("div",{className:"flex w-full gap-2 flex-col mt-2",children:[e.jsxs("div",{className:"flex flex-row items-center gap-2",children:[e.jsx("label",{htmlFor:"status",className:"text-sm h-10 mt-1 pt-2.5  pb-2 px-3 -mr-3 shadow-sm z-10 bg-gray-200 font-medium text-gray-500 border border-gray-300 rounded-md rounded-r-none ",children:a("admin:applications.header.status",{defaultValue:"Status"})}),e.jsx("div",{className:`grow ${r||s.staffNotes?"w-full":""}`,children:e.jsx(Pe,{field:gs({status:s.status})})}),e.jsx("div",{className:"flex items-center ml-2",children:e.jsx(Pe,{field:hs({scholarshipApplication:s.scholarshipApplication})})}),!r&&!s.staffNotes&&e.jsxs(X,{onClick:()=>i(!0),type:"secondary",className:"ml-2 text-gray-700 ",children:[e.jsx("div",{children:a("admin:applications.header.addNotes",{defaultValue:"Add Notes"})}),e.jsx(Aa,{className:"w-5 h-5 ml-2"})]}),e.jsxs(X,{type:"primary",submitButton:!0,form:"admin-application-form",children:[a("admin:applications.header.save",{defaultValue:"Save"})," ",e.jsx(Da,{className:"w-4 h-4 ml-2 font-bold"})]})]}),(r||s.staffNotes)&&e.jsx("div",{className:"w-full",children:e.jsx(Pe,{field:xs({staffNotes:s.staffNotes??void 0})})})]})}):null}function tn(t,a,s){const n=[],r=new Set,i=new Set;for(const o of a?.participants??[])r.add(o.variantId),!(o.id===t?.participant?.id||o.application)&&(i.add(o.variantId),n.push({key:`participant-${o.id}`,type:"participant",participantId:o.id,variantId:o.variantId,programName:o.variant?.program?.name??"Unknown Program",sku:o.variant?.sku??"",location:o.variant?.location??"",startDate:o.variant?.startDate??null,endD
1ate:o.variant?.endDate??null,status:o.status??"",isTrainerOnly:!1}));const l=new Set;for(const o of s?.trainers??[])!o.variantId||i.has(o.variantId)||r.has(o.variantId)||o.variant?.id!==t?.variant?.id&&(l.has(o.variantId)||(l.add(o.variantId),n.push({key:`trainer-${o.id}`,type:"trainer-variant",variantId:o.variantId,programName:o.variant?.program?.name??"Unknown Program",sku:o.variant?.sku??"",location:o.variant?.location??"",startDate:o.variant?.startDate??null,endDate:o.variant?.endDate??null,isTrainerOnly:!0})));return n.sort((o,d)=>!o.startDate&&!d.startDate?0:o.startDate?d.startDate?new Date(d.startDate).getTime()-new Date(o.startDate).getTime():-1:1),n}function an(t){const{t:a}=re(),{application:s,isOpen:n,setIsOpen:r,selectedTransferTarget:i,setSelectedTransferTarget:l,handleTransfer:o,participantsData:d,participantsLoading:m,participantsError:p,trainerData:f,trainerLoading:u,trainerError:h}=t,g=m||u,w=p||h,x=tn(s,d,f);function j(y){return i?y.type==="participant"?i.type==="participant"&&i.participantId===y.participantId:i.type==="trainer-variant"&&i.variantId===y.variantId:!1}function A(y){y.type==="participant"?l({type:"participant",participantId:y.participantId}):l({type:"trainer-variant",variantId:y.variantId})}return e.jsxs(Fe,{title:a("admin:applications.header.transferApplication",{defaultValue:"Transfer Application"}),isOpen:n,setIsOpen:r,hideBottomButtons:!0,children:[e.jsxs("div",{className:"px-6 py-4",children:[e.jsx("p",{className:"text-sm text-gray-600 mb-4",children:a("admin:applications.header.transferDescription",{defaultValue:"Select a target to transfer this application to. Existing participant records and trainer variant assignments are shown."})}),g&&e.jsx("p",{className:"text-sm text-gray-500",children:a("admin:applications.header.loadingParticipants",{defaultValue:"Loading transfer targets..."})}),!g&&w&&e.jsx("p",{className:"text-sm text-red-600",children:a("admin:applications.header.errors.loadingParticipants",{defaultValue:"Failed to load transfer targets. Please try again."})}),!g&&!w&&e.jsxs("div",{className:"space-y-2 max-h-64 overflow-y-auto",role:"radiogroup","aria-label":"Transfer target",children:[x.map(y=>e.jsxs("div",{role:"radio","aria-checked":j(y),tabIndex:0,onClick:()=>A(y),onKeyDown:T=>{(T.key===" "||T.key==="Enter")&&(T.preventDefault(),A(y))},className:`flex items-center gap-3 p-3 border rounded-md cursor-pointer hover:bg-gray-50 ${j(y)?"border-green-web bg-green-50":"border-gray-200"}`,children:[e.jsx("input",{type:"radio",name:"targetParticipant",value:y.key,checked:j(y),onChange:()=>A(y),className:"text-green-web",tabIndex:-1,"aria-hidden":"true"}),e.jsxs("span",{className:"flex flex-col",children:[e.jsxs("span",{className:"font-medium text-sm",children:[y.programName,y.isTrainerOnly&&e.jsx("span",{className:"ml-2 text-xs font-normal text-amber-600 bg-amber-50 px-1.5 py-0.5 rounded",children:"Trainer — participant will be created"})]}),e.jsxs("span",{className:"text-xs text-gray-500",children:[y.sku,y.location?` · ${y.location}`:"",y.startDate?` · ${ne(y.startDate,"MM/DD/YY")}`:"",y.endDate?` - ${ne(y.endDate,"MM/DD/YY")}`:"",y.status?` · ${y.status}`:""]})]})]},y.key)),x.length===0&&e.jsx("p",{className:"text-sm text-gray-500",children:a("admin:applications.header.noEligibleParticipants",{defaultValue:"No eligible participant records found."})})]})]}),e.jsxs("div",{className:"flex flex-row w-full justify-end gap-3 border-t px-6 py-4 bg-gray-50",children:[e.jsx(X,{type:"secondary",onClick:()=>r(!1),className:"px-4 py-2",children:a("admin:applications.header.cancel",{defaultValue:"Cancel"})}),e.jsx(X,{type:"primary",onClick:o,disabled:!i,className:"px-4 py-2 min-w-24",children:a("admin:applications.header.transfer",{defaultValue:"Transfer"})})]})]})}const Ue={},sn=Symbol((Ue?"production":void 0)!=="production"?"RESET":""),Pt=t=>typeof t?.then=="function";function nn(t=()=>{try{return window.localStorage}catch(s){(Ue?"production":void 0)!=="production"&&typeof window<"u"&&console.warn(s);return}},a){var s;let n,r;const i={getItem:(d,m)=>{var p,f;const u=g=>{if(g=g||"",n!==g){try{r=JSON.parse(g,a?.reviver)}catch{return m}n=g}return r},h=(f=(p=t())==null?void 0:p.getItem(d))!=null?f:null;return Pt(h)?h.then(u):u(h)},setItem:(d,m)=>{var p;return(p=t())==null?void 0:p.setItem(d,JSON.stringify(m,void 0))},removeItem:d=>{var m;return(m=t())==null?void 0:m.removeItem(d)}},l=d=>(m,p,f)=>d(m,u=>{let h;try{h=JSON.parse(u||"")}catch{h=f}p(h)});let o;try{o=(s=t())==null?void 0:s.subscribe}catch{}return!o&&typeof window<"u"&&typeof window.addEventListener=="function"&&window.Storage&&(o=(d,m)=>{if(!(t()instanceof window.Storage))return()=>{};const p=f=>{f.storageArea===t()&&f.key===d&&m(f.newValue)};return window.addEventListener("storage",p),()=>{window.removeEventListener("storage",p)}}),o&&(i.subscribe=l(o)),i}const rn=nn();function ce(t,a,s=rn,n){const r=Je(a);return(Ue?"production":void 0)!=="production"&&(r.debugPrivate=!0),r.onMount=l=>{l(s.getItem(t,a));let o;return s.subscribe&&(o=s.subscribe(t,l,a)),o},Je(l=>l(r),(l,o,d)=>{const m=typeof d=="function"?d(l(r)):d;return m===sn?(o(r,a),s.removeItem(t)):Pt(m)?m.then(p=>(o(r,p),s.setItem(t,p))):(o(r,m),s.setItem(t,m))})}ce("user",null);ce("token","");const qn=ce("showRequiredInfoForm",null),Yn=ce("socialUsed",null),Kn=ce("emulatedUser",null),Qn=ce("activeUser",null);export{En as A,qa as B,Xe as C,Ha as D,In as E,Fa as F,Xn as G,c as H,S as I,F as J,k as K,ee as L,Vn as P,Wn as R,Gn as W,Qn as a,Yn as b,$n as c,On as d,Kn as e,Bn as f,Un as g,Ln as h,_n as i,Be as j,Hn as k,Rn as l,gs as m,hs as 
1n,Fn as o,Mn as p,xs as q,Ds as r,qn as s,Hs as t,zn as u,Ta as v,rs as w,pt as x,ut as y,Ya as z};

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.