PageSourceSearch

https://apvball.net/chunk-ZH2F2FAO.js

js apvball.net collected 2026-09-24 14:04:16 UTC 23,804 bytes, 1 lines download raw bytes

1import{d as C}from"./chunk-QQKJHWTF.js";import{xa as b}from"./chunk-CWIKEVUT.js";import{_ as D,ba as O,e as f,ij as L}from"./chunk-45UQS2YE.js";import{a as l,b as u,h as E}from"./chunk-BMIYOSOG.js";function X(a,h){return(a||[]).some(m=>m.registrationID===h)}function x(a,h){let m=new Set;return(a||[]).forEach(e=>{if(!e||e.isCancelled||!e.completed)return;let t=e.registrationID;if(!(!Number.isFinite(t)||t<=0))switch(e.registration?.registrationCostTypeID){case C.FIXED:(e.remainingSessions??0)>0&&m.add(t);break;case C.UNLIMITED:{let r=e.registration?.endDate;r&&new Date(r)>h&&m.add(t);break}case C.SUBSCRIPTION:m.add(t);break;default:break}}),m}var P=(function(a){return a.REGISTRATION="registration",a.TIME_SLOT="time-slot",a.BUNDLE="bundle",a})(P||{}),G=(function(a){return a.CATEGORY="category",a.TYPE="type",a})(G||{}),p=(function(a){return a.RESERVE="reserve",a.CHECKOUT="checkout",a})(p||{}),g=(function(a){return a.PENDING="pending",a.IN_PROGRESS="in-progress",a.COMPLETED="completed",a})(g||{}),_=(function(a){return a.EXISTING_BUNDLE="existing-bundle",a.NEW_BUNDLE="new-bundle",a.A_LA_CARTE="a-la-carte",a})(_||{}),K=2;var F=E(L());var N=(()=>{let h=class h{get selectedPlayer(){return this._selectedPlayer}set selectedPlayer(e){this._selectedPlayer=e,this.selectedPlayerIsIdentityOnly=!1}constructor(){this.cartItemsSubject=new f([]),this.selectedTimeSlotsSubject=new f([]),this.cartItems$=this.cartItemsSubject.asObservable(),this.selectedTimeSlots$=this.selectedTimeSlotsSubject.asObservable(),this.selectedPlayerIsIdentityOnly=!1,this.allOpenProgramCategories=[],this.openProgramCategoriesLoaded=!1,this.playerEligibleRegistrationsCache=new Map,this.programStateByProgram=new Map,this.checkoutOrchestrationPlan=null}isTimeSlotCartItem(e){return e.cartItemType===P.TIME_SLOT||!!e.timeSlot}isSignUpTimeSlot(e){return e?.signUpTimeSlotID!==void 0}getAllCartItems(){return this.cartItemsSubject.value}getItemProgramID(e){return e.programID??e.timeSlot?.programID??e.registration?.programID??0}clonePlan(e){return(0,F.cloneDeep)(e)}getCartItems(e){let t=this.getAllCartItems();return e==null?t:t.filter(r=>this.getItemProgramID(r)===e)}getCartItemsForProgram(e){return this.getCartItems(e)}getCartItemsForPlayer(e,t){return this.getCartItems(t).filter(r=>r.player?.playerID===e)}getRegistrationCartItems(e){return this.getCartItems(e).filter(t=>!this.isTimeSlotCartItem(t)&&!!t.registration)}getProgramsWithCartItems(){let e=this.getAllCartItems(),t=new Set(e.map(r=>this.getItemProgramID(r)).filter(r=>r>0));return Array.from(t)}getCartCount(e){return this.getCartItems(e).length}getCartCountAcrossAllPrograms(){return this.getAllCartItems().length}getCartCountByProgram(){let e=new Map;for(let t of this.getAllCartItems()){let r=this.getItemProgramID(t);e.set(r,(e.get(r)??0)+1)}return e}isInCart(e,t){return this.getCartItems(t).some(r=>!this.isTimeSlotCartItem(r)&&r.registration?.registrationID===e)}isTimeSlotInCart(e,t,r){return this.getCartItems(r).some(s=>this.isTimeSlotCartItem(s)&&s.timeSlot?.signUpTimeSlotID===e&&(!t||s.player?.playerID===t))}getBundleRegistrationIDsForPlayer(e,t){if(!Number.isFinite(e)||e<=0)return new Set;let r=this.getCartItems(t).filter(s=>!this.isTimeSlotCartItem(s)&&s.player?.playerID===e&&Number.isFinite(s.registration?.registrationID)&&s.registration.registrationID>0).map(s=>s.registration.registrationID);return new Set(r)}switchToProgram(e){this.currentProgramID=e}clearCartForProgram(e){let t=this.getAllCartItems().filter(r=>this.getItemProgramID(r)!==e);this.cartItemsSubject.next(t),this.syncSelectedTimeSlots()}clearAllCarts(){this.cartItemsSubject.next([]),this.selectedTimeSlotsSubject.next([]),this.checkoutOrchestrationPlan=null,this.clearPurchasedBundleState()}clearCart(){this.clearAllCarts()}clearTrainingSessionCartItems(e,t){let r=this.getAllCartItems().filter(s=>!(s.player?.playerID===e&&this.getItemProgramID(s)===t));this.cartItemsSubject.next(r),this.syncSelectedTimeSlots()}addToCart(e,t,r){if(this.isSignUpTimeSlot(e)){this.addTimeSlotToCart(e,t,r);return}this.addRegistrationToCart(e,t)}addBundleToCart(e,t,r){this.addRegistrationToCart(e,t,!0,r)}setCartItemCoverage(e,t,r){let s=this.getAllCartItems(),n=s.find(i=>
1this.isTimeSlotCartItem(i)&&i.timeSlot?.signUpTimeSlotID===e&&i.player?.playerID===t);if(!n)return;let c=s.map(i=>i===n?u(l({},i),{chosenCoverage:r??void 0}):i);this.cartItemsSubject.next(c)}addRegistrationToCart(e,t,r=!1,s){if(!this.getCartItemsForProgram(e.programID||this.currentProgramID).some(i=>!this.isTimeSlotCartItem(i)&&i.registration.registrationID===e.registrationID&&(t?i.player?.playerID===t.playerID:!i.player))){let o=(t?this.getPlayerEligibleRegistrationsFromCache(t.playerID):[]).find(U=>U.registration.registrationID===e.registrationID),I=o?.program.programTypeID,S=e.programID||this.currentProgramID,d=e.registrationCostTypeID===C.VARIABLE,k=I===b.TRAINING_SESSIONS&&!d;I===b.TRAINING_SESSIONS&&(d?this.setALaCarteRegistrationIDForProgram(S,e.registrationID):this.setBaseRegistrationIDForProgram(S,e.registrationID));let w=r||k?P.BUNDLE:P.REGISTRATION,R={programName:s??o?.program.programName,registration:e,player:t,cartItemType:w,programID:S},v=this.getAllCartItems(),M=I===b.TEAM?[R,...v]:[...v,R];this.cartItemsSubject.next(M),this.syncSelectedTimeSlots()}}addTimeSlotToCart(e,t,r,s){if(!e?.signUpTimeSlotID)return;let n=this.getAllCartItems();if(n.some(o=>this.isTimeSlotCartItem(o)&&o.timeSlot?.signUpTimeSlotID===e.signUpTimeSlotID&&o.player?.playerID===t?.playerID&&(!s||o.sourceRegistrationID===s)))return;let i={programName:r,bundleName:null,registration:null,player:t,cartItemType:P.TIME_SLOT,timeSlot:e,sourceRegistrationID:s,programID:e.programID||this.currentProgramID};this.cartItemsSubject.next([...n,i]),this.syncSelectedTimeSlots()}removeFromCart(e,t,r){let n=this.getAllCartItems().filter(c=>{let i=!r||this.getItemProgramID(c)===r;return!(c.registration?.registrationID===e&&c.player?.playerID===t&&i)});this.cartItemsSubject.next(n),this.syncSelectedTimeSlots()}removeTimeSlotFromCart(e,t,r){let n=this.getAllCartItems().filter(c=>{let i=!r||this.getItemProgramID(c)===r;return!(this.isTimeSlotCartItem(c)&&c.timeSlot?.signUpTimeSlotID===e&&c.player?.playerID===t&&i)});this.cartItemsSubject.next(n),this.syncSelectedTimeSlots()}pruneReservedTimeSlots(e,t){if(!e?.length||!(t>0))return[];let r=new Set(e),s=i=>this.isTimeSlotCartItem(i)&&i.player?.playerID===t&&r.has(i.timeSlot?.signUpTimeSlotID),n=this.getAllCartItems(),c=n.filter(s).map(i=>i.timeSlot.signUpTimeSlotID);return c.length?(this.cartItemsSubject.next(n.filter(i=>!s(i))),this.syncSelectedTimeSlots(),c):[]}get selectedTimeSlots(){return this.selectedTimeSlotsSubject.value}syncSelectedTimeSlots(){let e=this.getAllCartItems().filter(t=>this.isTimeSlotCartItem(t)).map(t=>t.timeSlot).filter(t=>!!t?.signUpTimeSlotID).sort((t,r)=>new Date(r.startDate).getTime()-new Date(t.startDate).getTime());this.selectedTimeSlotsSubject.next(e)}newProgramCartState(){return{aLaCarteRegistrationID:0,baseRegistrationID:0,purchasedBundleIDs:new Set,activePurchasedBundleIDs:new Set,remainingBundleSessions:new Map,purchasedBundlesFull:[]}}getProgramState(e){return this.programStateByProgram.get(e)}getOrCreateProgramState(e){let t=this.programStateByProgram.get(e);return t||(t=this.newProgramCartState(),this.programStateByProgram.set(e,t)),t}setALaCarteRegistrationIDForProgram(e,t){let r=this.getOrCreateProgramState(e);r.aLaCarteRegistrationID=t,t>0&&(r.baseRegistrationID=t)}setBaseRegistrationIDForProgram(e,t){t>0&&(this.getOrCreateProgramState(e).baseRegistrationID=t)}setPurchasedBundleState(e,t){let r=t??this.currentProgramID,s=e||[],n=this.getOrCreateProgramState(r);n.purchasedBundlesFull=s;let c=new Map;s.forEach(i=>{let o=i?.registrationID;if(!Number.isFinite(o)||o<=0)return;if(i?.registration?.registrationCostTypeID===C.UNLIMITED){c.set(o,Number.POSITIVE_INFINITY);return}let I=c.get(o)??0,S=Number(i?.remainingSessions??0);c.set(o,I+S)}),n.purchasedBundleIDs=new Set(c.keys()),n.activePurchasedBundleIDs=x(s,new Date),n.remainingBundleSessions=c}clearPurchasedBundleState(){this.programStateByProgram.forEach(e=>{e.purchasedBundlesFull=[],e.purchasedBundleIDs=new Set,e.activePurchasedBundleIDs=new Set,e.remainingBundleSessions=new Map})}getALaCarteRegistrationIDForProgram(e){return this.getProgramState(e)?.aLaCarteRegistrationID??0}getBaseRegistrationIDForProgram(e){let t=this.getProgramState(e);return(t?.baseRegistrationID||t?.aLaCarteRegistrationID)??0}isTrainingSessionProgram(e){return this.getBaseRegistrationIDForProgram(e)>0||this.getCartItems(e).some(t=>
1this.isTimeSlotCartItem(t))}getPurchasedBundlesFullForProgram(e){return this.getProgramState(e)?.purchasedBundlesFull??[]}getPurchasedBundleIDsForProgram(e){return new Set(this.getProgramState(e)?.purchasedBundleIDs??[])}getActiveBundleIDsForProgram(e){return new Set(this.getProgramState(e)?.activePurchasedBundleIDs??[])}getRemainingBundleSessionsForProgram(e){return new Map(this.getProgramState(e)?.remainingBundleSessions??[])}getCombinedBundleSessionsForProgram(e){let t=this.getRemainingBundleSessionsForProgram(e);return this.getCartItems(e).filter(r=>r.cartItemType===P.BUNDLE&&r.registration).forEach(r=>{let s=r.registration;t.has(s.registrationID)||t.set(s.registrationID,s.registrationCostTypeID===C.UNLIMITED?Number.POSITIVE_INFINITY:s.numberOfSessions??0)}),t}getTotalBundleSessionsForProgram(e){let t=0;return this.getCombinedBundleSessionsForProgram(e).forEach(r=>t+=r),t}setCheckoutOrchestrationPlan(e){if(!e){this.checkoutOrchestrationPlan=null;return}this.checkoutOrchestrationPlan=this.clonePlan(e)}getCheckoutOrchestrationPlan(){return this.checkoutOrchestrationPlan?this.clonePlan(this.checkoutOrchestrationPlan):null}clearCheckoutOrchestrationPlan(){this.checkoutOrchestrationPlan=null}markCheckoutOrchestrationPlanCompleted(e){this.checkoutOrchestrationPlan&&(this.checkoutOrchestrationPlan=u(l({},this.checkoutOrchestrationPlan),{checkoutCompleted:!0,registrationConfirmID:e}))}updateCheckoutPendingReservations(e,t){this.checkoutOrchestrationPlan&&(this.checkoutOrchestrationPlan=u(l({},this.checkoutOrchestrationPlan),{pendingReservations:[...e||[]],completedReservationTimeSlotIDs:[...t||[]]}))}removeItemsByPlan(e){let t=e.checkoutPlan??e.reservePlan,r=t?.playerID,s=new Set(t?.selectedRegistrationIDsForCheckout??[]),n=this.getAllCartItems(),c=n.filter(i=>{if(Number.isFinite(r)&&i.player?.playerID!==r)return!0;if(this.getItemProgramID(i)===e.programID)return!1;let o=i.registration?.registrationID;return!(Number.isFinite(o)&&s.has(o))});c.length!==n.length&&(this.cartItemsSubject.next(c),this.syncSelectedTimeSlots())}getPersistableState(){let e=[];return this.programStateByProgram.forEach((t,r)=>{(t.aLaCarteRegistrationID>0||t.baseRegistrationID>0)&&e.push({programID:r,aLaCarteRegistrationID:t.aLaCarteRegistrationID,baseRegistrationID:t.baseRegistrationID})}),{cartItems:this.getAllCartItems(),currentProgramID:this.currentProgramID,selectedPlayer:this.selectedPlayer,aLaCarteRegistrationIDsByProgram:e}}restoreState(e){e&&(e.selectedPlayer&&(this._selectedPlayer=e.selectedPlayer,this.selectedPlayerIsIdentityOnly=!0),Number.isFinite(e.currentProgramID)&&(this.currentProgramID=e.currentProgramID),(e.aLaCarteRegistrationIDsByProgram||[]).forEach(t=>{this.setALaCarteRegistrationIDForProgram(t.programID,t.aLaCarteRegistrationID),this.setBaseRegistrationIDForProgram(t.programID,t.baseRegistrationID)}),this.cartItemsSubject.next(e.cartItems||[]),this.syncSelectedTimeSlots())}isSelectedPlayerIdentityOnly(){return this.selectedPlayerIsIdentityOnly}setAllOpenProgramCategories(e){this.allOpenProgramCategories=e??[],this.openProgramCategoriesLoaded=!0,this.playerEligibleRegistrationsCache.clear()}hasLoadedOpenProgramCategories(){return this.openProgramCategoriesLoaded}hasAllOpenProgramCategories(){return this.allOpenProgramCategories&&this.allOpenProgramCategories.length>0}getPlayerEligibleRegistrationsFromCache(e){if(this.playerEligibleRegistrationsCache.has(e))return this.playerEligibleRegistrationsCache.get(e);let t=[];return!this.allOpenProgramCategories||this.allOpenProgramCategories.length===0||(this.allOpenProgramCategories.forEach(r=>{r.openPrograms?.forEach(s=>{s.openRegistrations?.forEach(n=>{n.playerOpenRegistrations?.some(i=>i.playerID===e)&&t.push({registration:n,program:s})})})}),this.playerEligibleRegistrationsCache.set(e,t)),t}hasPlayerEligibleRegistrations(e){return this.hasAllOpenProgramCategories()?this.getPlayerEligibleRegistrationsFromCache(e).length>0:!1}};h.\u0275fac=function(t){return new(t||h)},h.\u0275prov=D({token:h,factory:h.\u0275fac,providedIn:"root"});let a=h;return a})();function $(a){let h=(a||[]).map(e=>[e?.firstName,e?.lastName].map(t=>t?.trim()).filter(t=>!!t).join(" ")).filter(e=>!!e),m=h.slice(0,3).join(", ");return h.length>3?`${m}...`:m}function y(a,h){return{signUpTimeSlotID:a?.signUpTimeSlotID,startDate:a?.startDate,endD
1ate:a?.endDate,timeSlotName:a?.timeSlotName,locationName:a?.locationName,facilityFieldName:a?.facilityFieldName,price:a?.price,bundleName:h,coachLabel:$(a?.staffAssignments)}}function j(a){return(a?.playerRegistrationCosts?.playerRegistrations||[]).map(h=>(h.playerRegistrationTimeSlotCosts||[]).map(m=>y(m.signUpTimeSlot)))}function B(a){if(!a||a.paymentPlan?.payOffline)return 0;if(a.paymentBypassed)return a.subtotal||0;let h=(a.surcharges||[]).reduce((m,e)=>m+(e.invoiceRoundedTotal||0),0);return(a.subtotal||0)+(a.paymentFee||0)+h}function A(a){return a?.clubPaymentFee?.userFee??0}var T=E(L());var ce=(()=>{let h=class h{constructor(e){this.cartService=e,this.checkoutChainSubject=new f(null),this.completedChainCheckoutsSubject=new f([]),this.checkoutChain$=this.checkoutChainSubject.asObservable(),this.completedChainCheckouts$=this.completedChainCheckoutsSubject.asObservable(),this.restoring=!1,this.overduePaymentGatePending=!1,this.pendingLinkBuilder=null,this.cartService.cartItems$.subscribe(()=>this.onCartItemsChanged())}setCheckoutChain(e){if(this.completedChainCheckoutsSubject.next([]),this.overduePaymentGatePending=!!e?.length,!e?.length){this.checkoutChainSubject.next(null);return}let t={links:e.map(r=>u(l({},r),{programName:r.programName||this.getProgramNameFromCart(r.programID)})),currentLinkIndex:0,chainStartedAt:Date.now(),isReadyForCheckout:!0};this.checkoutChainSubject.next(t)}cancelCheckoutChain(){this.checkoutChainSubject.next(null),this.overduePaymentGatePending=!1}consumeOverduePaymentGate(){let e=this.overduePaymentGatePending;return this.overduePaymentGatePending=!1,e}completeCheckoutChainPhase(e){let t=this.checkoutChainSubject.value;if(!t)return;let r=t.links[t.currentLinkIndex];if(r)if(r.currentPhase===p.RESERVE){let s=u(l({},r),{currentPhase:p.CHECKOUT,status:g.IN_PROGRESS}),n=[...t.links];n[t.currentLinkIndex]=s,this.checkoutChainSubject.next(u(l({},t),{links:n}))}else{let s=[...t.links],n=u(l({},r),{status:g.COMPLETED,checkoutPlan:u(l({},r.checkoutPlan),{checkoutCompleted:!0,registrationConfirmID:e})});s[t.currentLinkIndex]=n;let c=t.currentLinkIndex+1;c<s.length?(s[c]=u(l({},s[c]),{status:g.IN_PROGRESS}),this.checkoutChainSubject.next(u(l({},t),{links:s,currentLinkIndex:c}))):this.checkoutChainSubject.next(u(l({},t),{links:s})),this.cartService.removeItemsByPlan(n)}}recordChainCheckout(e){if(!e||!Number.isFinite(e.programID))return;this.mergeChainProgramSummary(e.programID,{programName:e.programName,registrationConfirmID:e.registrationConfirmID,checkedOut:!0,programTotal:B(e.cart),paymentFeeUserFee:A(e.cart),purchasedSlotGroups:j(e.cart),cart:(0,T.cloneDeep)(e.cart)});let t=this.checkoutChainSubject.value;if(!t)return;let r=t.links[t.currentLinkIndex];if(!r||r.programID!==e.programID||r.status===g.COMPLETED)return;let s=[...t.links];s[t.currentLinkIndex]=u(l({},r),{status:g.COMPLETED,checkoutPlan:r.checkoutPlan?u(l({},r.checkoutPlan),{checkoutCompleted:!0,registrationConfirmID:e.registrationConfirmID}):r.checkoutPlan}),this.checkoutChainSubject.next(u(l({},t),{links:s}))}recordChainReservations(e){if(!e||!Number.isFinite(e.programID)||!e.reservedSlots?.length)return;this.mergeChainProgramSummary(e.programID,{programName:e.programName,reservedSlots:e.reservedSlots.map(n=>y(n.timeSlot,n.bundleName))});let t=this.checkoutChainSubject.value?.links.find(n=>n.programID===e.programID),r=(t?.checkoutPlan??t?.reservePlan)?.playerID,s=Number.isFinite(r)?r:this.cartService.selectedPlayer?.playerID;Number.isFinite(s)&&e.reservedSlots.forEach(n=>this.cartService.removeTimeSlotFromCart(n.signUpTimeSlotID,s,e.programID))}getCompletedChainCheckouts(){return this.completedChainCheckoutsSubject.value}isInCheckoutChain(){return this.checkoutChainSubject.value?.isReadyForCheckout===!0}getCheckoutChainCurrentLink(){let e=this.checkoutChainSubject.value;return!e||!e.isReadyForCheckout?null:e.links[e.currentLinkIndex]??null}getCheckoutChainCurrentProgram(){return this.getCheckoutChainCurrentLink()?.programID??null}getCheckoutChainCurrentPhase(){return this.getCheckoutChainCurrentLink()?.currentPhase??null}getCheckoutChainCompletionStatus(){let e=this.checkoutChainSubject.value;if(!e)return{completed:0,total:0,remainingProgramIDs:[]};let t=e.links.filter(s=>s.status===g.COMPLETED).length,r=e.links.filter(s=>s.status!==g.COMPLETED).map(s=>s.programID);return{completed:t,total:e.links.length,remainingProgramIDs:r}}getRemainingCheckoutChainLinks(){let e=this.checkoutChainSubject.value;return e?e.links.filter(t=>t.status!==g.COMPLETED):[]}shouldReturnToCheckoutChainAfterCompletion(){let e=this.checkoutChainSubject.value;if(!e||!e.isReadyForCheckout)return!1;let t=e.links[e.currentLinkIndex];return t?t.currentPhase===p.RESERVE?!0:e.currentLinkIndex<e.links.length-1:!1}isCheckoutChainComplete(){let e=this.checkoutChainSubject.value;return e?e.links.every(t=>t.status===g.COMPLETED):!1}getCheckoutOrchestrationPlan(){if(this.checkoutChainSubject.value){let e=this.getCheckoutChainCurrentLink();if(!e)return null;let t=e.currentPhase===p.RESERVE?e.reservePlan:e.checkoutPlan;return t?(0,T.cloneDeep)(t):null}return this.cartService.getCheckoutOrchestrationPlan()}updateCheckoutPendingReservations(e,t){if(this.checkoutChainSubject.value){let r=this.checkoutChainSubject.value,s=r.links[r.currentLinkIndex];if(!s)return;let n=[...e||[]],c=[...t||[]],i;if(s.currentPhase===p.RESERVE&&s.reservePlan)i=u(l({},s),{reservePlan:u(l({},s.reservePlan),{pendingReservations:n,completedReservationTimeSlotIDs:c})});else if(s.checkoutPlan)i=u(l({},s),{checkoutPlan:u(l({},s.checkoutPlan),{pendingReservations:n,completedReservationTimeSlotIDs:c})});else return;let o=[...r.links];o[r.currentLinkIndex]=i,this.checkoutChainSubject.next(u(l({},r),{links:o}));return}this.cartService.updateCheckoutPendingReservations(e,t)}applyCoverageChange(e){if(!e)return;let t=this.checkoutChainSubject.value;if(t){let r=t.links[t.currentLinkIndex];if(!r)return;let s=[...t.links];s[t.currentLinkIndex]=u(l({},r),{reservePlan:this.withCoverageFrom(r.reservePlan,e),checkoutPlan:this.withCoverageFrom(r.checkoutPlan,e)}),this.checkoutChainSubject.next(u(l({},t),{links:s}));return}this.cartService.setCheckoutOrchestrationPlan(e)}withCoverageFrom(e,t){if(!e)return e;let r=new Map((t.assignedSlots||[]).map(n=>[n.signUpTimeSlotID,n])),s=n=>r.get(n.signUpTimeSlotID)??n;return u(l({},e),{slotCoverageOverrides:l({},t.slotCoverageOverrides||{}),assignedSlots:(e.assignedSlots||[]).map(s),pendingReservations:(e.pendingReservations||[]).map(s)})}getPersistableState(){let e=this.checkoutChainSubject.value;if(!e?.isReadyForCheckout||this.isCheckoutChainComplete())return null;let t=this.completedChainCheckoutsSubject.value.map(r=>{let s=l({},r);return delete s.cart,s});return{chain:e,completedSummaries:t}}restoreState(e){return e?.chain?.links?.length?(this.completedChainCheckoutsSubject.next(e.completedSummaries||[]),this.checkoutChainSubject.next(e.chain),this.overduePaymentGatePending=!1,!0):!1}beginRestore(){this.restoring=!0}endRestore(){this.restoring=!1}onCartItemsChanged(){if(this.restoring)return;let e=this.checkoutChainSubject.value;if(!e||!e.isReadyForCheckout){this.tryUpdateSkeletonChain();return}this.syncCheckoutChainWithCart()}tryUpdateSkeletonChain(){let e=this.checkoutChainSubject.value;if(e?.isReadyForCheckout)return;let t=this.cartService.getProgramsWithCartItems(),r=this.cartService.currentProgramID,s=t.includes(r)?[r,...t.filter(i=>i!==r)]:t,n=s.filter(i=>this.cartService.isTrainingSessionProgram(i)),c=s.find(i=>!this.cartService.isTrainingSessionProgram(i));if(c!==void 0&&n.push(c),n.length<2){e&&this.checkoutChainSubject.next(null);return}this.checkoutChainSubject.next({links:n.map(i=>({programID:i,programName:this.getProgramNameFromCart(i),currentPhase:p.CHECKOUT,status:g.PENDING})),currentLinkIndex:0,chainStartedAt:e?.chainStartedAt??Date.now(),isReadyForCheckout:!1})}syncCheckoutChainWithCart(){let e=this.checkoutChainSubject.value;if(!e)return;let t=this.cartService.getProgramsWithCartItems(),r=e.links[e.currentLinkIndex];if(e.links.filter(o=>o!==r&&o.status!==g.COMPLETED).length>0&&t.length===0){this.checkoutChainSubject.next(null);return}let n=e.links.filter(o=>o===r||o.status===g.COMPLETED||t.some(I=>this.linkCoversProgram(o,I)));if(!n.length){this.checkoutChainSubject.next(null);return}let c=Math.max(0,n.findIndex(o=>o===r)),i=this.withRebuiltPendingTail(n,c,t,r);i.length===e.links.length&&i.every((o,I)=>this.linkSignature(o)===this.linkSignature(e.links[I]))||this.checkoutChainSubject.next(u(l({},e),{links:i,currentLinkIndex:c}))}withRebuiltPendingTail(e,t,r,s){let n=this.cartService.selectedPlayer?.playerID,c=e.every(d=>d.status===g.COMPLETED);if(!this.pendingLinkBuilder||!(n>0)||!s||c)return e;let i=e.filter((d,k)=>k<=t||d.status===g.COMPLETED),o=r.filter(d=>!i.some(k=>this.linkCoversProgram(k,d)));if(!o.length)return i;let I=e.find(d=>d.collection)?.collection??null,S=this.pendingLinkBuilder(n,o,I).map(d=>u(l({},d),{status:g.PENDING}));return this.withPlainRegistrationsMerged(i,S)}withPlainRegistrationsMerged(e,t){let r=e.findIndex(o=>
1o.isCombinedRegistrationLink&&o.status!==g.COMPLETED),s=t.filter(o=>o.isCombinedRegistrationLink);if(r===-1||!s.length)return[...e,...t];let n=e[r],c=Array.from(new Set([...n.checkoutPlan?.selectedRegistrationIDsForCheckout??[],...s.flatMap(o=>o.checkoutPlan?.selectedRegistrationIDsForCheckout??[])]));return[...e.map((o,I)=>I!==r?o:u(l({},o),{checkoutPlan:u(l({},o.checkoutPlan),{selectedRegistrationIDsForCheckout:c})})),...t.filter(o=>!s.includes(o))]}linkCoversProgram(e,t){if(e.programID===t)return!0;let r=e.checkoutPlan?.selectedRegistrationIDsForCheckout;return r?.length?this.cartService.getRegistrationCartItems(t).some(s=>r.includes(s.registration?.registrationID)):!1}linkSignature(e){let t=e.checkoutPlan;return[e.programID,e.status,e.currentPhase,e.reservePlan?"r":"-",(t?.selectedRegistrationIDsForCheckout??[]).join("."),(t?.checkoutTimeSlots??[]).map(r=>r?.signUpTimeSlotID??0).join("."),(t?.pendingReservations??[]).map(r=>r?.signUpTimeSlotID??0).join(".")].join("|")}registerPendingLinkBuilder(e){this.pendingLinkBuilder=e}getProgramNameFromCart(e){return this.cartService.getCartItems().find(t=>(t.programID??t.timeSlot?.programID??t.registration?.programID)===e&&t.programName)?.programName||`Program ${e}`}mergeChainProgramSummary(e,t){let r=this.completedChainCheckoutsSubject.value,s=r.findIndex(n=>n.programID===e);if(s>=0){let n=u(l(l({},r[s]),t),{programID:e,programName:t.programName||r[s].programName});this.completedChainCheckoutsSubject.next(r.map((c,i)=>i===s?n:c))}else this.completedChainCheckoutsSubject.next([...r,l({programID:e,programName:t.programName||`Program ${e}`},t)])}};h.\u0275fac=function(t){return new(t||h)(O(N))},h.\u0275prov=D({token:h,factory:h.\u0275fac,providedIn:"root"});let a=h;return a})();export{X as a,x as b,P as c,G as d,p as e,g as f,_ as g,K as h,N as i,$ as j,ce as k};

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.