tods-competition-factory
Version:
Create and mutate TODS compliant tournament objects
1 lines • 1.02 MB
JavaScript
var pL=Object.defineProperty;var Jt=(t,e)=>{for(var r in e)pL(t,r,{get:e[r],enumerable:!0})};function Ba(){return"2.2.29"}var EA={};Jt(EA,{competitionGovernor:()=>bU,drawsGovernor:()=>_N,entriesGovernor:()=>VN,eventGovernor:()=>ZN,generationGovernor:()=>iM,matchUpFormatGovernor:()=>Fy,matchUpGovernor:()=>NM,mocksGovernor:()=>TI,participantGovernor:()=>rR,policyGovernor:()=>uN,publishingGovernor:()=>mR,queryGovernor:()=>vN,reportGovernor:()=>dR,scheduleGovernor:()=>PR,scoreGovernor:()=>$g,tieFormatGovernor:()=>xR,tournamentGovernor:()=>qR,venueGovernor:()=>rC});var bU={};Jt(bU,{getLinkedTournamentIds:()=>au,getTournamentIds:()=>Tp,linkTournaments:()=>DU,mutate:()=>RU,query:()=>CU,unlinkTournament:()=>MU,unlinkTournaments:()=>NU});var RU={};Jt(RU,{linkTournaments:()=>DU,unlinkTournament:()=>MU,unlinkTournaments:()=>NU});var ua="SINGLES",kt="SINGLES",xi="DOUBLES",xt="DOUBLES",_r="TEAM",Wt="TEAM",mC={SINGLES_MATCHUP:ua,SINGLES:kt,DOUBLES_MATCHUP:xi,DOUBLES:xt,TEAM_MATCHUP:_r,TEAM:Wt};var MI={[kt]:[kt,"S"],[xt]:[xt,"D"],[Wt]:[Wt,"T"],S:[kt,"S"],D:[xt,"D"],T:[Wt,"T"]};function le(t,e){return(t??0)-(e??0)}function dt(t){return typeof t=="number"?parseInt(t.toString()):typeof t=="string"?parseInt(t):0}function _n(t){return isNaN(t)?!1:t&&(t&t-1)===0}function NA(t){if(!t.length)return;let e=[...t].sort(le),r=Math.floor(e.length/2);return e.length%2?e[r]:(e[r-1]+e[r])/2}function dC(t){if(!_n(t))return!1;let e=t,r=1;for(;e!==2;)r+=1,e=e/2;return r}function ym(t){return isNaN(t)?0:t%2&&t+1||t}function Am(t){return Math.pow(2,Math.round(Math.log(t)/Math.log(2)))}function Zt(t){return!isNaN(parseFloat(t))}function RI(t){let e=dt(t);if(!isNaN(e))return e===0?!1:(e&-e)===1}function rs(t){if(isNaN(t))return!1;for(;!_n(t);)t++;return t}function go(t,e){return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t}function It(t){return Number.isSafeInteger(typeof t=="string"?+t:t)}function lC(t=1,e=3,r=!0){let n=0;for(let o=0;o<e;o++)n+=Math.random()*(t/e);return r&&t>1?Math.round(n):n}function mL(t,e){e||(e=1);let r=1/e;return Math.round(t*r)/r}function MA(t,e,r,n,o=2){let i=1-Math.random(),s=1-Math.random(),a=Math.sqrt(-2*Math.log(i))*Math.cos(2*Math.PI*s);return a=a/10+.5,a>1||a<0?a=MA(t,e,r):(a=Math.pow(a,r),a*=e-t,a+=t),n&&(a=mL(a,n)),parseFloat(a.toFixed(o))}function Ll(t,e=2){return parseFloat(Number(Math.round(t*1e3)/1e3).toFixed(e))}function pt(t){return Array.isArray(t)?t?.filter((e,r,n)=>n.lastIndexOf(e)===r):[]}function fC(t){return Array.isArray(t)?t?.map(e=>e===null?void 0:e):t}function hr(t){return Array.isArray(t)?t.map(e=>[Math.random(),e]).sort((e,r)=>e[0]-r[0]).map(e=>e[1]):[]}function Ha(t){return It(t)?t:1/0}function Tr(t){return Array.isArray(t)?t.reduce((e,r)=>(e[r]||(e[r]=0),e[r]++,e),{}):{}}function gC(t){return RA(Tr(t))}function RA(t){return Object.keys(t).reduce((e,r)=>{let n=t[r];return e[n]?e[n].push(r):e[n]=[r],e},{})}function dL(t,e,r){return r.indexOf(t)===e}function CI(t){return t.filter(dL)}function Zr(t){return Array.isArray(t)&&t.length?t.splice(Math.floor(Math.random()*t.length),1)[0]:void 0}function yn(t){let e=Math.floor(Math.random()*t.length);return t[e]}function tt(t,e){return Array.from({length:e-t},(r,n)=>n+t)}function Io(t,e){return e.reduce((r,n,o)=>(n===t&&r.push(o),r),[])}function jt(t,e){return!Array.isArray(t)||!Array.isArray(e)?[]:t.filter(r=>e.indexOf(r)!==-1).filter((r,n,o)=>o.indexOf(r)===n)}function CA(t,e){return!Array.isArray(t)||!Array.isArray(e)?[]:t.filter(r=>!e.includes(r))}function ke(t,e){return!Array.isArray(t)||!Array.isArray(e)?!1:t.some(r=>e.includes(r))}function IC(t,e){return Array.isArray(e)&&e.reduce((r,n)=>(r[n]=1+r[n]||1,r),{})[t]||0}function hC(t,e,r,n){return Array.isArray(t)?[].concat(...t.slice(0,e),...t.slice(e,e+r).sort(n),...t.slice(e+r,t.length)):[]}function Ue(t,e){return Array.isArray(t)?t.reduce((r,n,o)=>{let i=Math.floor(o/e);return r[i]=[].concat(r[i]||[],n),r},[]):[]}function bA(t,[e,...r]){return t.length?[t.slice(0,e),...bA(t.slice(e),[...r,e])]:[]}function SC(t){return t.reduce((e,r)=>{let n=e[e.length-1];return(!n||n[n.length-1]!==r-1)&&e.push([]),e[e.length-1].push(r),e},[])}function bI(t){return Array.isArray(t)?t.reduce((e,r)=>!isNaN(parseInt(r))&&e,!0):!1}function vI(t){return Array.isArray(t)?t.reduce((e,r)=>isNaN(parseInt(r))&&e,!0):!1}function Fl(t,e,r){return Array.isArray(t)?t.reduce((n,o,i)=>{let s=r?!!(Math.floor(i/e)%2):!1,a=i%e,c=s?e-1-a:a;return n[c]||(n[c]=[]),n[c].push(o),n},[]):[]}function TC(t,e=1){if(!Array.isArray(t)||!t.every(It))return[];let r=Math.min(...t,e),n=Math.max(...t);return tt(r,n+1).filter(o=>!t.includes(o))}function Wr(t){return typeof t=="function"}function Vt(t){return typeof t=="string"}function ht(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function yC(t,e){if(!ht(t)||!ht(e))return!1;let r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(let o of r)if(t[o]!==e[o])return!1;return!0}function _I(t,e){return Array.isArray(t)?Object.assign({},...(t??[]).filter(ht).map(r=>r[e]&&{[r[e]]:r}).filter(Boolean)):{}}var AC=t=>e=>Object.keys(t).every(r=>e[r]===t[r]);function OI(t,e){if(t===void 0)return null;if(!ht(t)||t===null)return t;let r=Object.keys(t),n=o=>o===void 0?null:o;return Object.assign({},...r.map(o=>Array.isArray(t[o])?{[o]:e?t[o]:t[o].map(i=>OI(i))}:{[o]:e?n(t[o]):OI(t[o])}))}function vA(t){return Array.isArray(t)?t.length+t.map(vA).reduce((e,r)=>e+r,0):ht(t)&&t!==null?Object.keys(t).length+Object.keys(t).map(e=>vA(t[e])).reduce((e,r)=>e+r,0):0}function EC(t){if(t===null||typeof t!="object")return;let e=JSON.stringify(t),r=vA(t),n=e.split("").reduce((o,i)=>o+i.charCodeAt(0),0);return[e.length,r,n].map(o=>o.toString(36)).join("")}function kc(t,e){return!Array.isArray(t)||!Vt(e)?!1:jt(t,MI[e]).length}var C={success:!0},OA="error",UC={SUCCESS:C,ERROR:OA};function xI({collectionValueProfiles:t,matchUpCount:e}){let r=[];if(!Array.isArray(t))return r.push(`collectionValueProfiles is not an array: ${t}`),{errors:r};if(t.length&&t.length!==e)return r.push("collectionValueProfiles do not align with matchUpsCount"),{errors:r};for(let o of t){if(typeof o!="object")return r.push(`valueProfile is not type object: ${o}`),{errors:r};let{matchUpValue:i,collectionPosition:s}=o;if(typeof i!="number"||typeof s!="number"||s>e||s<1)return r.push("Invalid value profile: value and collectionPosition must be numeric. collectionPosition cannot be greater than matchUpCount"),{errors:r}}let n=t.map(o=>o.collectionPosition);return n.length!==pt(n).length?(r.push("collectionPositions are not unique"),{errors:r}):{...C}}var wC={};Jt(wC,{addNotice:()=>lt,callListener:()=>Mm,createInstanceState:()=>VE,cycleMutationStatus:()=>lf,deepCopyEnabled:()=>df,deleteNotice:()=>QI,deleteNotices:()=>Vi,disableNotifications:()=>BE,enableNotifications:()=>mf,getDevContext:()=>Ur,getMethods:()=>ff,getNotices:()=>zI,getProvider:()=>XI,getTopics:()=>wr,getTournamentId:()=>os,getTournamentRecord:()=>gf,getTournamentRecords:()=>Vo,globalLog:()=>jE,handleCaughtError:()=>ap,hasTopic:()=>ip,removeTournamentRecord:()=>WE,setDeepCopy:()=>jc,setDevContext:()=>Wc,setGlobalLog:()=>OC,setGlobalMethods:()=>_C,setGlobalSubscriptions:()=>HL,setMethods:()=>xC,setStateMethods:()=>YE,setStateProvider:()=>VL,setSubscriptions:()=>WL,setTournamentId:()=>sp,setTournamentRecord:()=>HE,setTournamentRecords:()=>Rm,timeKeeper:()=>BL});var wI={message:"Chronological error; time violation.",code:"ANACHRONISM"},Em={message:"Duplicate entry",code:"DUPLICATE_ENTRY"},_A={message:"Cannot remove main structure",code:"ERR_CANNOT_REMOVE_MAIN_STRUCTURE"},LI={message:"records must be an object with tournamentId keys",code:"ERR_INVALID_TOURNAMENTS"},Lt={message:"Missing tournamentRecords",code:"ERR_MISSING_TOURNAMENTS"},$={message:"Missing tournamentRecord",code:"ERR_MISSING_TOURNAMENT"},Wa={message:"Invalid tournamentRecord",code:"ERR_INVALID_TOURNAMENT"},pa={message:"Missing tournamentId",code:"ERR_MISSING_TOURNAMENT_ID"},ma={message:"Invalid drawDefinition",code:"ERR_INVALID_DRAWDEF"},Z={message:"Missing drawDefinition",code:"ERR_MISSING_DRAWDEF"},xA={message:"Existing drawDefinition(s)",code:"ERR_EXISTING_DRAWDEFS"},Rr={message:"drawDefinition not found",code:"ERR_NOT_FOUND_DRAWDEF"},ti={message:"Invalid structure",code:"ERR_INVALID_STRUCTURE"},kl={message:"Incomplete source structure",code:"ERR_INCOMPLETE_STRUCTURE"},Gl={message:"Invalid drawPosition for seedAssignment",code:"ERR_INVALID_SEEDING_POSITION"},ja={message:"drawPosition already assigned",code:"ERR_EXISTING_POSITION_ASSIGNMENT"},wA={message:"Schedule not cleared",code:"ERR_UNCHANGED_SCHEDULE_NOT_CLEARED"},LA={message:"drawPosition not cleared",code:"ERR_FAILURE_POSITION_NOT_CLEARED"},lL={message:"drawPosition not found",code:"ERR_NOT_FOUND_DRAW_POSITION"},Vl={message:"Unrecognized drawType",code:"ERR_UNRECOGNIZED_DRAW_TYPE"},Ya={message:"Missing drawPositions",code:"ERR_MISSING_DRAW_POSITIONS"},zu={message:"drawPosition is active",code:"ERR_ACTIVE_DRAW_POSITION"},PC={message:"drawPosition is occupied",code:"ERR_OCCUPIED_DRAW_POSITION"},Cs={message:"Invlid drawPosition",code:"ERR_INVALID_DRAW_POSITION"},bs={message:"Missing drawPosition",code:"ERR_MISSING_DRAW_POSITION"},Um={message:"Invalid drawType",code:"ERR_INVALID_DRAW_TYPE"},Qu={message:"Invalid drawSize",code:"ERR_INVALID_DRAW_SIZE"},FI={message:"Cannot set drawSize to be less than existing entries",code:"ERR_INVALID_DRAW_SIZE_MISMATCH"},qa={message:"Missing drawSize",code:"ERR_MISSING_DRAW_SIZE"},sn={message:"Missing drawId",code:"ERR_MISSING_DRAW_ID"},FA={message:"drawId exists",code:"ERR_EXISTING_DRAW_ID"},kA={message:"participantId cannot be assigned to multiple seedNumbers",code:"INVALID_PARTICIPANT_SEEDING"},GA={message:"seedsCount greater than drawSize",code:"ERR_INVALID_SEED_COUNT"},VA={message:"Missing seedCountThresholds",code:"ERR_MISSING_SEED_COUNT_THRESHOLD"},BA={message:"Invalid action",code:"ERR_INVALID_ACTION"},kI={message:"Invalid assignment",code:"ERR_INVALID_ASSIGNMENT"},HA={message:"Missing seedAssignments",code:"ERR_MISSING_SEED_ASSIGNMENTS"},WA={message:"Invalid seedNumber",code:"ERR_INVALID_SEED_NUMBER"},jA={message:"Invalid seedPosition",code:"ERR_INVALID_SEED_POSITION"},Bl={message:"Missing targetLink",code:"ERR_MISSING_LINK_TARGET"},YA={message:"Existing round",code:"ERR_EXISTING_ROUND"},fL={message:"Missing roundNumber",code:"ERR_MISSING_ROUND_NUMBER"},Er={message:"Missing structureId",code:"ERR_MISSING_STRUCTURE_ID"},wt={message:"structure not found",code:"ERR_NOT_FOUND_STRUCTURE"},Hl={message:"Missing structures",code:"ERR_MISSING_STRUCTURES"},li={message:"Missing structure",code:"ERR_MISSING_STRUCTURE"},Wl={message:"Missing MAIN structure",code:"ERR_MISSING_MAIN_STRUCTURE"},qA={message:"drawDefinition contains unlinked structures",code:"ERR_MISSING_STRUCTURE_LINKS"},Yn={message:"Invalid eventType",code:"ERR_INVALID_EVENT_TYPE"};var _t={message:"Missing event / eventId",code:"ERR_MISSING_EVENT_ID"},jr={message:"Event not found",code:"ERR_NOT_FOUND_EVENT"},$A={message:"Event exists",code:"ERR_EXISTING_EVENT"},KA={message:"Missing entries",code:"ERR_MISSING_ENTRIES"},zA={message:"Invalid entries",code:"ERR_INVALID_ENTRIES"},jl={message:"Missing assignments",code:"ERR_MISSING_ASSIGNMENTS"},QA={message:"Missing stage",code:"ERR_MISSING_STAGE"},wi={message:"Invalid stage",code:"ERR_INVALID_STAGE"},XA={message:"stageSequence limit",code:"ERR_LIMIT_STAGE_SEQUENCE"},JA={message:"Missing positionAssignments",code:"ERR_MISSING_POSITION_ASSIGNMENTS"},ZA={message:"Cannot Assign BYE status if no assignment: { bye: true }",code:"ERR_UNCHANGED_CANNOT_ASSIGN_BYE"},GI={message:"Unrecognized matchUpStatus",code:"ERR_UNRECOGNIZED_MATCHUP_STATUS"},$a={message:"Unrecognized matchUpFormat",code:"ERR_UNRECOGNIZED_MATCHUP_FORMAT"},Yl={message:"Incompatible matchUpStatus",code:"ERR_INCOMPATIBLE_MATCHUP_STATUS"},da={message:"Invalid matchUpStatus",code:"ERR_INVALID_MATCHUP_STATUS"},Go={message:"Invalid tieFormat",code:"ERR_INVALID_TIE_FORMAT"},ql={message:"Invalid matchUpFormat",code:"ERR_INVALID_MATCHUP_FORMAT"},$l={message:"Missing matchUpFormat",code:"ERR_MISSING_MATCHUP_FORMAT"},tE={message:"Missing collectionDefinition",code:"ERR_MISSING_COLLECTION_DEFINITION"},vs={message:"Missing tieFormat",code:"ERR_MISSING_TIE_FORMAT"},cr={message:"Missing matchUpId",code:"ERR_MISSING_MATCHUP_ID"},ns={message:"Missing matchUpIds",code:"ERR_MISSING_MATCHUP_IDS"},Le={message:"matchUp not found",code:"ERR_NOT_FOUND_MATCHUP"},ro={message:"Missing matchUps",code:"ERR_MISSING_MATCHUPS"},Sr={message:"Missing matchUp",code:"ERR_MISSING_MATCHUP"},dr={message:"Invalid matchUp",code:"ERR_INVALID_MATCHUP"},VI={message:"Missing policyType",code:"ERR_MISSING_POLICY_TYPE"},Xu={message:"Missing policyDefinitions",code:"ERR_MISSING_POLICY_DEFINITIONS"},gL={message:"Missing seeding policy",code:"ERR_MISSING_POLICY_SEEDING"},eE={message:"Missing avoidance policy",code:"ERR_MISSING_POLICY_AVOIDANCE"},BI={message:"Missing policy attributes",code:"ERR_MISSING_POLICY_ATTRIBUTES"},rE={message:"Invalid policyDefinitions",code:"ERR_INVALID_POLICY_DEFINITIONS"},HI={message:"existing policyType",code:"ERR_EXISTING_POLICY_TYPE"},IL={message:"Policy not attached",code:"ERR_FAILURE_POLICY_NOT_ATTACHED"},Gc={message:"Policy not found",code:"ERR_NOT_FOUND_POLICY"},hL={message:"Missing scoring policy / matchUpFormats",code:"ERR_MISSING_POLICY_SCORING_MATCHUP_FORMATS"},Kl={message:"Invalid sideNumber",code:"ERR_INVALID_SIDE_NUMBER"},SL={message:"Invalid setNumber",code:"ERR_INVALID_SET_NUMBER"},zl={message:"Missing setObject",code:"ERR_MISSING_SET_ATTRIBUTE"},TL={message:"Missing setNumber",code:"ERR_MISSING_SET_NUMBER"},yL={message:"Missing sideNumber",code:"ERR_MISSING_SIDE_NUMBER"},Li={message:"Missing courtId",code:"ERR_MISSING_COURT_ID"},st={message:"Missing value",code:"ERR_MISSING_VALUE"},nE={message:"Missing birthdate",code:"ERR_MISSING_BIRTH_DATE"},oE={message:"Missing date",code:"ERR_MISSING_DATE"},iE={message:"No valid dates",code:"ERR_NO_VALID_DATES"},Pm={message:"Invalid bookings",code:"ERR_INVALID_BOOKINGS"},Ql={message:"Invalid dateAvailability",code:"ERR_INVALID_DATE_AVAILABILITY"},sE={message:"Missing dateAvailability",code:"ERR_MISSING_DATE_AVAILABILITY"},je={message:"Invalid Date",code:"ERR_INVALID_DATE"},Do={message:"Invalid time",code:"ERR_INVALID_TIME"},aE={message:"Invalid tournament dates",code:"ERR_INVALID_DATES_TOURNAMENT"};var WI={message:"Invalid game scores",code:"ERR_INVALID_SCORES_GAME"},cE={message:"Invalid score",code:"ERR_INVALID_SCORE"},Dm={message:"Invalid winningSide",code:"ERR_INVALID_WINNING_SIDE"};var DC={message:"No participants generated",code:"ERR_NO_PARTICIPANTS_GENERATED"},Xl={message:"Cannot modify tieFormat",code:"ERR_UNCHANGED_CANNOT_MODIFY_TIEFORMAT"},uE={message:"Cannot modify participantType",code:"ERR_UNCHANGED_CANNOT_MODIFY_PARTICIPANT_TYPE"},Ju={message:"Cannot remove participants",code:"ERR_UNCHANGED_CANNOT_REMOVE_PARTICIPANTS"},jI={message:"Participant category mismatch",code:"ERR_CATEGORY_MISMATCH"},Nm={message:"Cannot change winningSide",code:"ERR_UNCHANGED_CANNOT_CHANGE_WINNING_SIDE"},Fi={message:"Invalid participant",code:"ERR_INVALID_PARTICIPANT"},mn={message:"Invalid participantId",code:"ERR_INVALID_PARTICIPANT_ID"},xr={message:"Invalid participantIds",code:"ERR_INVALID_PARTICIPANT_IDS"},pE={message:"Invalid participantRole",code:"ERR_INVALID_PARTICIPANT_ROLE"},An={message:"Invalid participantType",code:"ERR_INVALID_PARTICIPANT_TYPE"},mE={message:"Missing participantRole",code:"ERR_MISSING_PARTICIPANT_ROLE"},ki={message:"Missing participant",code:"ERR_MISSING_PARTICIPANT"},Ka={message:"Missing participants",code:"ERR_MISSING_PARTICIPANTS"},ie={message:"Missing participantId",code:"ERR_MISSING_PARTICIPANT_ID"},dE={message:"Missing qualified participants",code:"ERR_MISSING_QUALIFIED_PARTICIPANTS"},re={message:"Participant Not Found",code:"ERR_NOT_FOUND_PARTICIPANT"},lE={message:"participantId exists",code:"ERR_EXISTING_PARTICIPANT_ID"},AL={message:"participant pair exists",code:"ERR_EXISTING_PARTICIPANT_PAIR"},fE={message:"No participant removed",code:"ERR_UNCHANGED_NO_PARTICIPANT_REMOVED"},No={message:"Missing participantIds",code:"ERR_MISSING_PARTICIPANT_IDS"},gE={message:"Missing participantsCount",code:"ERR_MISSING_PARTICIPANT_COUNT"},IE={message:"Participant not checked in",code:"ERR_UNCHANGED_PARTICIPANT_NOT_CHECKED_IN"},hE={message:"Missing person details",code:"ERR_MISSING_PERSON_DETAILS"},Os={message:"Existing participant drawPosition assignment",code:"ERR_EXISTING_PARTICIPANT_DRAW_POSITION_ASSIGNMENT"},Zu={message:"Existing participant",code:"ERR_EXISTING_PARTICIPANT"},Jl={message:"participantsCount exceeds drawSize",code:"ERR_INVALID_PARTICIPANT_COUNT"},Zl={message:"Invalid entry status",code:"ERR_INVALID_ENTRY_STATUS"},YI={message:"Participant Entry Not Found",code:"ERR_NOT_FOUND_PARTICIPANT_ENTRY"},NC={message:"Participant not entered in stage",code:"ERR_UNCHANGED_PARTICIPANT_NOT_ENTERED"},MC={message:"Participant not found in stageSequence",code:"ERR_NOT_FOUND_PARTICIPANT_IN_STAGE"},SE={message:"entryStatus not allowed in stage",code:"ERR_INVALID_ENTRY_STATUS_IN_STAGE"},TE={message:"entryStatus not allowed for event",code:"ERR_INVALID_ENTRY_STATUS_IN_EVENT"},qI={message:"No stage space available for entryStatus",code:"ERR_UNCHANGED_NO_AVAILABLE_STAGE_SPACE"},tf={message:"Insufficient drawPositions to accommodate qualifiers",code:"ERR_UNCHANGED_NO_DRAW_POSITIONS_FOR_QUALIFIERS"},ef={message:"Insufficient drawPositions to accommodate entries",code:"ERR_INSUFFICIENT_DRAW_POSITIONS"},yE={message:"Missing penaltyType",code:"ERR_MISSING_PENALTY_TYPE"},rf={message:"Missing penaltyId",code:"ERR_MISSING_PENALTY_ID"},Vc={message:"Penalty not found",code:"ERR_NOT_FOUND_PENALTY"},AE={message:"Missing courtsCount/courtNames",code:"ERR_MISSING_COURTS_INFO"},_s={message:"Court not found",code:"ERR_NOT_FOUND_COURT"},EE={message:"Court exists",code:"ERR_EXISTING_COURT"},UE={message:"Venue exists",code:"ERR_EXISTING_VENUE"},Gi={message:"Venue not found",code:"ERR_NOT_FOUND_VENUE"},ei={message:"Missing venueId",code:"ERR_MISSING_VENUE_ID"},PE={message:"Invalid endTime",code:"ERR_INVALID_END_TIME"},$I={message:"Existing endTime",code:"ERR_EXISTING_END_TIME"},DE={message:"Invalid stopTime",code:"ERR_INVALID_STOP_TIME"},NE={message:"Invalid startTime",code:"ERR_INVALID_START_TIME"},RC={message:"Invalid resumeTime",code:"ERR_INVALID_RESUME_TIME"},nf={message:"Invalid timeItem",code:"ERR_INVALID_TIME_ITEMS"},ME={message:"Missing async state provider",code:"ERR_MISSING_ASYNC_STATE_PROVIDER"},of={message:"Missing timeItem",code:"ERR_MISSING_TIME_ITEM"},sf={message:"Missing timeItems",code:"ERR_MISSING_TIME_ITEMS"},Bc={message:"Missing context",code:"ERR_MISSING_CONTEXT"},RE={message:"Missing schedule",code:"ERR_MISSING_SCHEDULE"},za={message:"Invalid scaleItem",code:"ERR_INVALID_SCALE_ITEM"},CE={message:"Modifications failed",code:"ERR_FAILURE_MODIFICATIONS"},xs={message:"No modifications applied",code:"ERR_UNCHANGED_NO_MODIFICATIONS_APPLIED"},bE={message:"Unable to assign court",code:"ERR_UNCHANGED_COURT_NOT_ASSIGNED"},tp={message:"No Candidates",code:"ERR_UNCHANGED_NO_CANDIDATES"},vE={message:"Invalid configuration",code:"ERR_INVALID_CONFIG"},OE={message:"Invalid collectionDefinition",code:"ERR_INVALID_COLLECTION_DEFINITION"},ho={message:"Invalid object",code:"ERR_INVALID_OBJECT"},ep={message:"Invalid gender",code:"ERR_INVALID_GENDER"},Hc={message:"Invalid category",code:"ERR_INVALID_CATEGORY"},V={message:"Invalid values",code:"ERR_INVALID_VALUES"},_E={message:"Duplicate value",code:"ERR_DUPLICATE_VALUE"},af={message:"Team not found",code:"ERR_NOT_FOUND_TEAM"},xE={message:"No valid actions",code:"ERR_NO_VALID_ACTIONS"},rp={message:"No valid attributes",code:"ERR_NO_VALID_ATTRIBUTES"},cf={message:"Value unchanged",code:"ABORT_UNCHANGED"},ve={message:"Not found",code:"ERR_NOT_FOUND"},np={message:"Not implemented",code:"ERR_NOT_IMPLEMENTED"},wE={message:"Existing flight",code:"ERR_EXISTING_FLIGHT"},uf={message:"Existing flight profile",code:"ERR_EXISTING_FLIGHT_PROFILE"},LE={message:"Existing outcome",code:"ERR_EXISTING_OUTCOME"},FE={message:"Existing matchUpId",code:"ERR_EXISTING_MATCHUP_ID"},KI={message:"Existing stage",code:"ERR_EXISTING_STAGE"},pf={message:"Existing structure",code:"ERR_EXISTING_STRUCTURE"},Qa={message:"Method not found",code:"ERR_NOT_FOUND_METHOD"},kE={message:"Scheduled matchUps",code:"ERR_SCHEDULED_MATCHUPS"},Xa={message:"Scores present",code:"ERR_SCORES_PRESENT"},CC={ANACHRONISM:wI,CANNOT_CHANGE_WINNING_SIDE:Nm,CANNOT_MODIFY_TIEFORMAT:Xl,CANNOT_MODIFY_PARTICIPANT_TYPE:uE,CANNOT_REMOVE_MAIN_STRUCTURE:_A,CANNOT_REMOVE_PARTICIPANTS:Ju,CATEGORY_MISMATCH:jI,COURT_EXISTS:EE,COURT_NOT_FOUND:_s,DRAW_DEFINITION_NOT_FOUND:Rr,DRAW_ID_EXISTS:FA,DRAW_POSITION_ACTIVE:zu,DRAW_POSITION_ASSIGNED:ja,DRAW_POSITION_NOT_CLEARED:LA,DRAW_POSITION_NOT_FOUND:lL,DRAW_SIZE_MISMATCH:FI,DUPLICATE_ENTRY:Em,DUPLICATE_VALUE:_E,ENTRY_STATUS_NOT_ALLOWED_FOR_EVENT:TE,ENTRY_STATUS_NOT_ALLOWED_IN_STAGE:SE,EVENT_EXISTS:$A,EVENT_NOT_FOUND:jr,EXISTING_DRAW_DEFINITIONS:xA,EXISTING_END_TIME:$I,EXISTING_FLIGHT:wE,EXISTING_MATCHUP_ID:FE,EXISTING_OUTCOME:LE,EXISTING_PARTICIPANT_DRAW_POSITION_ASSIGNMENT:Os,EXISTING_PARTICIPANT:Zu,EXISTING_POLICY_TYPE:HI,EXISTING_PROFILE:uf,EXISTING_ROUND:YA,EXISTING_STAGE:KI,EXISTING_STRUCTURE:pf,INCOMPATIBLE_MATCHUP_STATUS:Yl,INCOMPLETE_SOURCE_STRUCTURE:kl,INSUFFICIENT_DRAW_POSITIONS:ef,INVALID_ACTION:BA,INVALID_ASSIGNMENT:kI,INVALID_BOOKINGS:Pm,INVALID_CATEGORY:Hc,INVALID_COLLECTION_DEFINITION:OE,INVALID_CONFIGURATION:vE,INVALID_DATE_AVAILABILITY:Ql,INVALID_DATE:je,INVALID_DRAW_DEFINITION:ma,INVALID_DRAW_POSITION_FOR_SEEDING:Gl,INVALID_DRAW_POSITION:Cs,INVALID_DRAW_SIZE:Qu,INVALID_END_TIME:PE,INVALID_ENTRIES:zA,INVALID_EVENT_TYPE:Yn,INVALID_GAME_SCORES:WI,INVALID_GENDER:ep,INVALID_MATCHUP_FORMAT:ql,INVALID_MATCHUP_STATUS:da,INVALID_MATCHUP_STATUS_BYE:ZA,INVALID_MATCHUP:dr,INVALID_OBJECT:ho,INVALID_PARTICIPANT_ID:mn,INVALID_PARTICIPANT_IDS:xr,INVALID_PARTICIPANT_ROLE:pE,INVALID_PARTICIPANT_SEEDING:kA,INVALID_PARTICIPANT_TYPE:An,INVALID_PARTICIPANT:Fi,INVALID_POLICY_DEFINITION:rE,INVALID_RECORDS:LI,INVALID_SCALE_ITEM:za,INVALID_SEED_NUMBER:WA,INVALID_SEED_POSITION:jA,INVALID_SET_NUMBER:SL,INVALID_SIDE_NUMBER:Kl,INVALID_SCORE:cE,INVALID_STAGE:wi,INVALID_START_TIME:NE,INVALID_STRUCTURE:ti,INVALID_STOP_TIME:DE,INVALID_TIE_FORMAT:Go,INVALID_TIME:Do,INVALID_TIME_ITEM:nf,INVALID_TOURNAMENT_DATES:aE,INVALID_TOURNAMENT_RECORD:Wa,INVALID_VALUES:V,INVALID_WINNING_SIDE:Dm,MATCHUP_NOT_FOUND:Le,METHOD_NOT_FOUND:Qa,MISSING_ASSIGNMENTS:jl,MISSING_ASYNC_STATE_PROVIDER:ME,MISSING_AVOIDANCE_POLICY:eE,MISSING_BIRTH_DATE:nE,MISSING_COLLECTION_DEFINITION:tE,MISSING_COURT_ID:Li,MISSING_COURTS_INFO:AE,MISSING_DATE_AVAILABILITY:sE,MISSING_DATE:oE,MISSING_DRAW_DEFINITION:Z,MISSING_DRAW_ID:sn,MISSING_DRAW_POSITION:bs,MISSING_DRAW_POSITIONS:Ya,MISSING_DRAW_SIZE:qa,MISSING_ENTRIES:KA,MISSING_EVENT:_t,MISSING_QUALIFIED_PARTICIPANTS:dE,MISSING_MATCHUP_FORMAT:$l,MISSING_MATCHUP_ID:cr,MISSING_MATCHUP_IDS:ns,MISSING_MATCHUP:Sr,MISSING_MATCHUPS:ro,MISSING_PARTICIPANT_COUNT:gE,MISSING_PARTICIPANT_ID:ie,MISSING_PARTICIPANT_IDS:No,MISSING_PARTICIPANT_ROLE:mE,MISSING_PARTICIPANT:ki,MISSING_PARTICIPANTS:Ka,MISSING_PENALTY_ID:rf,MISSING_PENALTY_TYPE:yE,MISSING_PERSON_DETAILS:hE,MISSING_POLICY_ATTRIBUTES:BI,MISSING_POLICY_DEFINITION:Xu,MISSING_POLICY_TYPE:VI,MISSING_POSITION_ASSIGNMENTS:JA,MISSING_ROUND_NUMBER:fL,MISSING_SCHEDULE:RE,MISSING_SCORING_POLICY:hL,MISSING_SEED_ASSIGNMENTS:HA,MISSING_SEEDCOUNT_THRESHOLDS:VA,MISSING_SEEDING_POLICY:gL,MISSING_SET_NUMBER:TL,MISSING_SET_OBJECT:zl,MISSING_SIDE_NUMBER:yL,MISSING_STAGE:QA,MISSING_STRUCTURE_ID:Er,MISSING_STRUCTURE:li,MISSING_MAIN_STRUCTURE:Wl,MISSING_STRUCTURES:Hl,MISSING_TARGET_LINK:Bl,MISSING_TIE_FORMAT:vs,MISSING_TIME_ITEM:of,MISSING_TIME_ITEMS:sf,MISSING_TOURNAMENT_ID:pa,MISSING_TOURNAMENT_RECORD:$,MISSING_TOURNAMENT_RECORDS:Lt,MISSING_VALUE:st,MISSING_VENUE_ID:ei,MODIFICATIONS_FAILED:CE,NO_CANDIDATES:tp,NO_DRAW_POSITIONS_AVAILABLE_FOR_QUALIFIERS:tf,NO_MODIFICATIONS_APPLIED:xs,NO_STAGE_SPACE_AVAILABLE_FOR_ENTRY_STATUS:qI,NO_PARTICIPANT_REMOVED:fE,NO_VALID_ACTIONS:xE,NO_VALID_ATTRIBUTES:rp,NO_VALID_DATES:iE,NOT_FOUND:ve,NOT_IMPLEMENTED:np,PARTICIPANT_COUNT_EXCEEDS_DRAW_SIZE:Jl,PARTICIPANT_ID_EXISTS:lE,PARTICIPANT_NOT_CHECKED_IN:IE,PARTICIPANT_NOT_FOUND:re,PARTICIPANT_PAIR_EXISTS:AL,PENALTY_NOT_FOUND:Vc,POLICY_NOT_ATTACHED:IL,POLICY_NOT_FOUND:Gc,SCHEDULE_NOT_CLEARED:wA,SCHEDULED_MATCHUPS:kE,SCORES_PRESENT:Xa,SEEDSCOUNT_GREATER_THAN_DRAW_SIZE:GA,STAGE_SEQUENCE_LIMIT:XA,STRUCTURE_NOT_FOUND:wt,TEAM_NOT_FOUND:af,UNABLE_TO_ASSIGN_COURT:bE,UNLINKED_STRUCTURES:qA,UNRECOGNIZED_DRAW_TYPE:Vl,UNRECOGNIZED_MATCHUP_FORMAT:$a,UNRECOGNIZED_MATCHUP_STATUS:GI,VALUE_UNCHANGED:cf,VENUE_EXISTS:UE};var Ze={disableNotifications:!1,tournamentId:void 0,tournamentRecords:{},subscriptions:{},modified:!1,methods:{},notices:[]},GE={addNotice:_L,callListener:kL,cycleMutationStatus:OL,deleteNotice:LL,deleteNotices:wL,disableNotifications:EL,enableNotifications:UL,getMethods:op,getNotices:xL,getTopics:FL,getTournamentId:bC,getTournamentRecord:PL,getTournamentRecords:DL,removeTournamentRecord:CL,setMethods:vL,setSubscriptions:bL,setTournamentId:ML,setTournamentRecord:NL,setTournamentRecords:RL,handleCaughtError:GL};function EL(){Ze.disableNotifications=!0}function UL(){Ze.disableNotifications=!1}function bC(){return Ze.tournamentId}function PL(t){return Ze.tournamentRecords[t]}function DL(){return Ze.tournamentRecords}function NL(t){let e=t?.tournamentId;return e?(Ze.tournamentRecords[e]=t,{success:!0}):{error:Wa}}function ML(t){return t?Ze.tournamentRecords[t]?(Ze.tournamentId=t,{success:!0}):{error:$}:(Ze.tournamentId=void 0,{success:!0})}function RL(t){Ze.tournamentRecords=t;let e=Object.keys(t);e.length===1?Ze.tournamentId=e[0]:e.length||(Ze.tournamentId=void 0)}function CL(t){if(typeof t!="string")return{error:V};if(!Ze.tournamentRecords[t])return{error:ve};delete Ze.tournamentRecords[t];let e=Object.keys(Ze.tournamentRecords);return e.length===1?Ze.tournamentId=e[0]:e.length||(Ze.tournamentId=void 0),{success:!0}}function bL(t){return typeof t.subscriptions!="object"?{error:V}:(Object.keys(t.subscriptions).forEach(e=>{typeof t.subscriptions[e]=="function"?Ze.subscriptions[e]=t.subscriptions[e]:delete Ze.subscriptions[e]}),{...C})}function vL(t){return typeof t!="object"?{error:V}:(Object.keys(t).forEach(e=>{typeof t[e]=="function"&&(Ze.methods[e]=t[e])}),{...C})}function OL(){let t=Ze.modified;return Ze.modified=!1,t}function _L({topic:t,payload:e,key:r},n){if(!(typeof t!="string"||typeof e!="object")&&(Ze.disableNotifications||(Ze.modified=!0),!(Ze.disableNotifications||!Ze.subscriptions[t]&&!n)))return r&&(Ze.notices=Ze.notices.filter(o=>!(o.topic===t&&o.key===r))),Ze.notices.push({topic:t,payload:e,key:r}),{...C}}function op(){return Ze.methods??{}}function xL({topic:t}){return Ze.notices.filter(e=>e.topic===t).map(e=>e.payload)}function wL(){Ze.notices=[]}function LL({topic:t,key:e}){Ze.notices=Ze.notices.filter(r=>(!t||r.topic===t)&&r.key!==e)}function FL(){return{topics:Object.keys(Ze.subscriptions)}}function kL({topic:t,notices:e},r){let n=Ze.subscriptions[t];n&&typeof n=="function"&&n(e);let o=r?.[t];o&&typeof o=="function"&&o(e)}function GL({engineName:t,methodName:e,params:r,err:n}){let o;return typeof n=="string"?o=n.toUpperCase():n instanceof Error&&(o=n.message),console.log("ERROR",{tournamentId:bC(),params:JSON.stringify(r),engine:t,methodName:e,error:o}),{error:o}}var Oe={timers:{default:{elapsedTime:0}},globalSubscriptions:{},deepCopyAttributes:{stringify:[],ignore:[],toJSON:[]},globalMethods:[],deepCopy:!0},an=GE,vC=["addNotice","callListener","cycleMutationStatus","deleteNotice","deleteNotices","disableNotifications","enableNotifications","getMethods","getNotices","getTopics","getTournamentId","getTournamentRecord","getTournamentRecords","removeTournamentRecord","setSubscriptions","setTournamentId","setTournamentRecord","setTournamentRecords"];function VL(t){if(typeof t!="object")throw new Error("Global state provider can not be undefined or null");if(jt(Object.keys(t),vC).length!==vC.length)throw new Error("Global state provider is missing required methods");return an=t,{success:!0}}function VE(){if(an.createInstanceState){try{an.createInstanceState()}catch(t){return{error:t}}return{success:!0}}else return{error:ME}}function Ur(t){return!t||typeof t!="object"?Oe.devContext??!1:typeof Oe.devContext!="object"?!1:Object.keys(t).every(e=>Oe.devContext?.[e]===t[e])&&Oe.devContext}function BL(t="reset",e="default"){let r=Date.now();if(t==="report"){if(e==="allTimers")return Object.keys(Oe.timers).filter(o=>o!=="default"||Oe.timers[o].startTime).map(o=>{let i=Oe.timers[o],s=i.state==="stopped"?0:(r-(i?.startTime??0))/1e3,a=i.elapsedTime+s;return{state:Oe.timers[o].state,elapsedTime:a.toFixed(2),timer:o}});{let n=Oe.timers[e].state==="stopped"?0:(r-(Oe.timers[e]?.startTime??0))/1e3,o=Oe.timers[e].elapsedTime+n;return{state:Oe.timers[e].state,elapsedTime:o.toFixed(2),timer:e}}}if(!Oe.timers[e]||t==="reset"){if(e==="allTimers")return Oe.timers={default:{elapsedTime:0}},!0;Oe.timers[e]={startTime:r,state:"active",elapsedTime:0}}return Oe.timers[e].elapsedTime||(Oe.timers[e].elapsedTime=0),t==="stop"&&Oe.timers[e].state!=="stopped"&&(Oe.timers[e].state="stopped")&&(Oe.timers[e].elapsedTime+=(r-(Oe.timers[e]?.startTime??0))/1e3),t==="start"&&(Oe.timers[e].startTime=r)&&(Oe.timers[e].state="active"),Oe.timers[e]}function OC(t){Wr(t)?Oe.globalLog=t:delete Oe.globalLog}function Wc(t){Oe.devContext=t}function BE(){an.disableNotifications()}function mf(){an.enableNotifications()}function jc(t,e){typeof t=="boolean"&&(Oe.deepCopy=t),typeof e=="object"&&(Array.isArray(e.ignore)&&(Oe.deepCopyAttributes.ignore=e.ignore),Array.isArray(e.toJSON)&&(Oe.deepCopyAttributes.toJSON=e.toJSON),Array.isArray(e.stringify)&&(Oe.deepCopyAttributes.stringify=e.stringify),e.threshold&&(Oe.deepCopyAttributes.threshold=e.threshold))}function df(){return{enabled:Oe.deepCopy,...Oe.deepCopyAttributes}}function HL(t){return t?.subscriptions?(Object.keys(t.subscriptions).forEach(e=>{Oe.globalSubscriptions[e]=t.subscriptions[e]}),{...C}):{error:st,info:"missing subscriptions"}}function WL(t){return t?.subscriptions?an.setSubscriptions({subscriptions:t.subscriptions}):{error:st,info:"missing subscriptions"}}function _C(t){return t?typeof t!="object"?{error:V}:(Object.keys(t).forEach(e=>{Wr(t[e])&&(Oe.globalMethods[e]=t[e])}),{...C}):{error:st,info:"missing method declarations"}}function xC(t){return t?typeof t!="object"?{error:V}:an.setMethods(t):{error:st,info:"missing method declarations"}}function lf(){return an.cycleMutationStatus()}function lt(t){if(typeof t?.topic!="string")return;let e=Oe.globalSubscriptions[t.topic];return an.addNotice(t,e)}function ff(){return{...Oe.globalMethods,...an.getMethods()}}function zI(t){return an.getNotices(t)}function QI({key:t,topic:e}){return an.deleteNotice({key:t,topic:e})}function Vi(){return an.deleteNotices()}function wr(){return an.getTopics()}function ip(t){return wr()?.topics?.includes(t)}async function Mm(t){return an.callListener(t,Oe.globalSubscriptions)}function os(){return an.getTournamentId()}function gf(t){return an.getTournamentRecord(t)}function Vo(){return an.getTournamentRecords()}function HE(t){return an.setTournamentRecord(t)}function Rm(t){return an.setTournamentRecords(t)}function sp(t){return an.setTournamentId(t)}function WE(t){return an.removeTournamentRecord(t)}function XI(){return an}function ap({engineName:t,methodName:e,params:r,err:n}){let o=Wr(an.handleCaughtError)&&an.handleCaughtError||GE.handleCaughtError,{tournamentRecord:i,...s}=r;return o({params:s,engineName:t,methodName:e,err:n})}function jE(t,e){if(Oe.globalLog)try{Oe.globalLog({log:t,engine:e})}catch(r){console.log("globalLog error",r),console.log(e,t),OC()}else console.log(e,t)}function YE(t,e,r,n){if(!ht(t))return{error:V};Zt||(r=1);let o=Array.isArray(e)?e:[],i={},s=(a,c=0)=>{Object.keys(a).forEach(u=>{Wr(a[u])?i[u]=a[u]:ht(a[u])&&(e===!0||o?.includes(u))&&(r===void 0||c<r)&&s(a[u],c+1)})};return s(t),n?_C(i):xC(i),{methods:i}}function jL(t,e,r){return Object.keys(t).filter(n=>!e.includes(t[n])&&(!r||(Array.isArray(t[n])?t[n].length:!0)))}function nt(t,e,r,n){if(typeof t!="object"||t===null)return t;df()?.enabled||(n=!0);let i=["",void 0,null];e&&i.push(!1);let s=jL(t,i,r);return Object.assign({},...s.map(a=>Array.isArray(t[a])?{[a]:n?t[a]:t[a].map(c=>nt(c))}:{[a]:n?t[a]:nt(t[a])}))}function _({context:t,result:e,stack:r,info:n}){return e&&!Array.isArray(e?.stack)&&(e.stack=[]),e&&Array.isArray(e?.stack)&&typeof r=="string"&&e.stack.push(r),e&&n&&(e.info=n),e&&typeof t=="object"&&Object.keys(t).length&&Object.assign(e,nt(t)),e&&!e?.error&&!e?.success&&Object.assign(e,{...C}),e??{success:!0}}var Pn="ANY",zt="MALE",yr="MIXED",is="OTHER",oe="FEMALE",Cm={ANY:Pn,MALE:zt,FEMALE:oe,MIXED:yr,OTHER:is};var YL="MIXED events can not contain mixed singles or { gender: ANY } collections",qL="events with { gender: ANY } can not contain MIXED singles collections";function bm(t){let e="tieFormatGenderValidityCheck",{referenceGender:r,matchUpType:n,gender:o}=t;return r&&o&&[zt,oe].includes(r)&&r!==o?_({result:{valid:!1,error:ep},context:{gender:o},stack:e}):r===yr&&(o===Pn||o===yr&&n!==xt)?_({result:{error:ep,valid:!1},info:YL,stack:e}):r===Pn&&o===yr&&n!==xt?_({result:{error:ep,valid:!1},info:qL,stack:e}):{valid:!0}}var $L="normal",qE="timed",KL="final",If="NOAD",vm="SET",LC={S:$L,F:KL};function cp(t,e){if(ht(t),(t?.bestOf||t?.exactly)&&t?.setFormat)return zL(t,e)}function hf(t){return!isNaN(Number(t))&&Number(t)}function GC(t){let e=`T${t.minutes}`;return t.based&&(e+=t.based),t.modifier&&(e+=`@${t.modifier}`),e}function zL(t,e){let r=hf(t.bestOf)||void 0,n=hf(t.exactly)||void 0,o=r||n;if(t.setFormat?.timed&&t.simplified&&o===1)return GC(t.setFormat);let i=o&&`${vm}${o}`||"",s=FC(t.setFormat,e),a=s&&`S:${s}`||"",c=FC(t.finalSetFormat,e),u=o&&o>1&&c&&s!==c&&`F:${c}`||"";if(i&&s)return[i,a,u].filter(m=>m).join("-")}function FC(t,e){if(typeof t=="object"&&Object.keys(t).length){if(t.timed)return GC(t);if(t.tiebreakSet)return kC(t.tiebreakSet);let r=hf(t.setTo);if(r){let n=t.NoAD&&If||"",o=kC(t.tiebreakFormat),i=o&&`/${o}`||"",s=hf(t.tiebreakAt),a=s&&(s!==r||e)&&`@${s}`||"";if(o!==!1)return`${r}${n}${i}${a}`}}}function kC(t){if(t){if(typeof t=="object"&&!t.tiebreakTo)return"";if(typeof t=="object"&&hf(t.tiebreakTo)){let e=`TB${t.tiebreakTo}${t.NoAD?If:""}`;return t.modifier&&(e+=`@${t.modifier}`),e}else return!1}}function Ye(t){if(Vt(t)){let e=t.startsWith("T")&&qE||t.startsWith(vm)&&vm||"";if(e===qE){let r=WC(t),n={simplified:!0,setFormat:r,bestOf:1};if(r)return n}if(e===vm)return QL(t)}}function QL(t){let e=t.split("-"),r=Sf(e[0].slice(3)),n=r===1||r%2!==0?r:void 0,o=r!==1&&r%2===0?r:void 0,i=e&&VC(e[1]),s=e&&VC(e[2]),a=i&&i.timed||s&&s.timed,c=n&&n<6||a&&o,u=!e[2]||s,p=i,m=nt({setFormat:i,exactly:o,bestOf:n});if(s&&(m.finalSetFormat=s),c&&p&&u)return m}function VC(t){if(t?.[1]===":"){let e=t.split(":"),r=LC[e[0]],n=e[1];if(r&&n){if(n.startsWith("TB")){let I=BC(n);return I===!1?!1:typeof I=="object"?{tiebreakSet:I}:void 0}if(n.startsWith("T"))return WC(n);let s=t.match(/^[FS]:(\d+)([A-Za-z]*)/),a=s&&jC(s[2])||!1,c=!s?.[2]||a,u=s?Sf(s[1]):void 0,p=HC(n),m=p!==!1,d=m&&p||u,l=BC(n.split("/")[1]),f=l!==!1,g={setTo:u};return a&&(g.NoAD=!0),l?(g.tiebreakFormat=l,g.tiebreakAt=d):g.noTiebreak=!0,u&&c&&f&&m&&g||!1}}}function HC(t,e=!0){let r=t?.indexOf("@")>0&&t.split("@");if(r)return(e?Sf(r[1]):r[1])||!1}function BC(t){if(t)if(t.startsWith("TB")){let e=HC(t,!1),r=t.match(/^TB(\d+)([A-Za-z]*)/),n=r?.[1],o=r&&jC(r[2]),i=!r?.[2]||o,s=Sf(n);if(s&&i){let a={tiebreakTo:s};return e&&typeof e=="string"&&!It(e)&&(a.modifier=e),o&&(a.NoAD=!0),a}else return!1}else return!1}function WC(t){let e=t.slice(1),r=e.match(/^(\d+)(@?[A-Za-z]*)/),n=Sf(r?.[1]);if(!n)return;let o={timed:!0,minutes:n},i=r?.[2],s=[void 0,"P","G"].includes(i);if(i&&!s){let a=e.match(/^(\d+)(@)([A-Za-z]+)$/)?.[3];return a?(o.modifier=a,o):void 0}return i&&(o.based=r[2]),o}function jC(t){return t&&t.indexOf(If)>=0}function Sf(t){return isNaN(Number(t))?0:Number(t)}function Pr({matchUpFormat:t}){if(!Vt(t)||t==="")return!1;let e=Ye(t),r=t.match(/-S:([1-9])+\/TB(\d{1,2})@?([1-9]?)*/),n=r?.[1],o=r?.[2],i=r?.[3],s=t.match(/-F:([1-9])+\/TB(\d{1,2})@?([1-9]?)*/),a=s?.[1],c=s?.[2],u=s?.[3];return cp(e,!!(r&&o&&n===i||s&&c&&a===u))===t}var Om=/^[\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1])$/,JI=/^((0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)([.,][0-9]{3})?$/,Mo=/^([\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1]))([ T](0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)?([.,][\d]{3})?Z?$/,ws=/^([\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1]))?([ T]?(0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)?([.,][\d]{3})?Z?$/;function _m(t){let{scheduledDate:e}=t;if(!e&&t.scheduledTime&&(e=Ut(t.scheduledTime)),!e)return;let r=Qt(t.scheduledTime),n=Ut(e);return n&&r&&(n+=`T${r}`),n}function YC(t){return typeof t!="object"||Array.isArray(t)?!1:Object.prototype.toString.call(t)==="[object Date]"}function Yc(t){let e=typeof t=="string"?t?.split(" "):[];return t&&e?.length>1&&!["AM","PM"].includes(e[1].toUpperCase())?!1:!!(!t||ws.test(Za(t,!0,!0)))}function Dr(t){return Ja(t)||Om.test(t)}function XL(t){let e=new Date(t),r=e.getSeconds()+60*e.getMinutes()+60*60*e.getHours();return JL(r,{displaySeconds:!1})}function JL(t,e){let r=parseInt(t,10),n=Math.floor(r/3600),o=Math.floor((r-n*3600)/60),i=r-n*3600-o*60;return(!e||e?.displaySeconds?n+":"+o+":"+i:n+":"+o).split(":").map(no).join(":")}var Af=t=>{let e=Tf(t)||Ja(t)?new Date(t):new Date,r=e.getUTCMonth()+1,n=r<10?`0${r}`:`${r}`;return`${e.getUTCFullYear()}-${no(n)}-${no(e.getUTCDate())}`};function ZL(t){let e=Tf(t)||Ja(t)?new Date(t):new Date;return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())}function qn(t,e="-",r="YMD"){if(!t)return"";typeof t=="string"&&t.indexOf("T")<0&&(t=t+"T00:00");let n=new Date(t),o=""+(n.getMonth()+1),i=""+n.getDate(),s=n.getFullYear();return o.length<2&&(o="0"+o),i.length<2&&(i="0"+i),r==="DMY"?[i,o,s].join(e):r==="MDY"?[o,i,s].join(e):r==="YDM"?[s,i,o].join(e):r==="DYM"?[i,s,o].join(e):r==="MYD"?[o,s,i].join(e):[s,o,i].join(e)}function ZI(t){let e=t?new Date(t):new Date,r=e.getTimezoneOffset();return new Date(e.getTime()-r*60*1e3)}function tF(t){return ZI(t).getTime()}function Tf(t){if(typeof t=="boolean")return!1;let e=t instanceof Date&&t||!isNaN(t)&&new Date(t)||!1;return e&&!isNaN(e.valueOf())}function Ls(t,e){if(!Dr(t)||!Dr(e))return[];let r=Ut(t)+"T00:00",n=Ut(e)+"T00:00",o=new Date(r),i=new Date(n),s=Tf(i)&&Tf(o)&&u(o,i),a=[],c=0;if(s){let p=o,m=p.getTime();for(;m<=i.getTime()&&c<300;)c+=1,a.push(new Date(p)),m=p.setDate(p.getDate()+1)}return a.map(p=>qn(p));function u(p,m){return p<=m}}var eF=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;function Ja(t){return typeof t!="string"?!1:eF.test(t)}function eh(t){if(typeof t!="string")return!1;let r=t.split("Z")[0].split(":"),n=r.every(i=>!isNaN(parseInt(i)));return!(r.length<2||!n||parseInt(r[0])>23||parseInt(r[1])>60)}function Yt(t){let e=Qt(t);if(!e)return 0;let[r,n]=e.split(":").map(o=>parseInt(o));return r*60+n}function qC(t){let e=Math.floor(t/60),r=t-e*60;return e>23&&(e=e%24),[no(e),no(r)].join(":")}function yf(t){return eh(t)?t.split(":").slice(0,2).map(no).join(":"):void 0}function Qt(t){return Ja(t)&&t.indexOf("T")>0?yf(t.split("T").reverse()[0]):yf(t)}function Ut(t){return Ja(t)||Mo.test(t)?t.split("T")[0]:void 0}function up(t,e){let r=new Date(t);return r.setDate(r.getDate()+e),Ut(r.toISOString())}function th(t){t=typeof t!="string"?"00:00":t;let e={},r={};return{0:e.time,1:e.ampm}=t.split(" ")||[],{0:r.hours,1:r.minutes}=e.time.split(":")||[],r.ampm=e.ampm,isNaN(r.hours)||isNaN(r.minutes)||r.ampm&&!["AM","PM"].includes(r.ampm.toUpperCase())?{}:r}function rF(t){let e=th(t);return e.ampm&&e.hours&&(e.ampm.toLowerCase()==="pm"&&parseInt(e.hours)<12&&(e.hours=(e.hours&&parseInt(e.hours)||0)+12),e.ampm.toLowerCase()==="am"&&e.hours==="12"&&(e.hours="00")),`${e.hours||"12"}:${e.minutes||"00"}`.split(":").map(no).join(":")}function nF(t){let e=th(t);if(!(typeof e=="object"&&!Object.keys(e).length))return e.ampm?t:(e.hours>12?(e.hours-=12,e.ampm="PM"):e.hours==="12"?e.ampm="PM":(e.hours==="00"&&(e.hours="12"),e.ampm="AM"),e.hours?.[0]==="0"&&(e.hours=e.hours.slice(1)),`${e.hours||"12"}:${e.minutes||"00"} ${e.ampm}`)}function Za(t,e,r){let n=Ut(t),o=Qt(t),i=n?o:t;return t?e&&(n&&r&&t||rF(i))||nF(i):void 0}function rh(t,e){let r=th(t),n=th(e);if(parseInt(r.hours)<parseInt(n.hours))return-1;if(parseInt(r.hours)>parseInt(n.hours))return 1;if(r.hours===n.hours){if(parseInt(r.minutes)<parseInt(n.minutes))return-1;if(parseInt(r.minutes)>parseInt(n.minutes))return 1}return 0}function nh(t,e=7){let r=Ut(t)+"T00:00",n=new Date(r),o=new Date(n.setDate(n.getDate()+e));return qn(o)}function oF(t){return nh(t)}function iF(t,e,r,n=!1){let o=new Date(e,0,1+(t-1)*7),i=n?0:1;return o.setDate(o.getDate()+(i-o.getDay())),qn(o,r)}function $C(t,e,r){let n=new Date(t,0);return qn(new Date(n.setDate(e)),r)}function Ge(t,e=void 0){let[r,n]=(t||"00:00").split(":").map(no),o=ZI(e).setHours(r,n,0,0);return ZI(o)}function la(t,e,r=!0){let n=new Date(t),i=(new Date(e).getTime()-n.getTime())/1e3/60;return r?Math.abs(Math.round(i)):Math.round(i)}function Yr(t,e){let r=Qt(t);if(!r)return"00:00";let n=isNaN(e)?0:e;return Qt(Ef(Ge(r),n).toISOString())}function Ef(t,e){let r=new Date(t);return new Date(r.getTime()+e*6e4)}function no(t){return t.toString()[1]?t:"0"+t}function $n(t,e){let r=new Date(t),n=new Date(e);return r.getFullYear()===n.getFullYear()&&r.getMonth()===n.getMonth()&&r.getDate()===n.getDate()}var oh={addDays:nh,addWeek:oF,addMinutesToTimeString:Yr,convertTime:Za,getIsoDateString:_m,getUTCdateString:Af,DateHHMM:XL,extractDate:Ut,extractTime:Qt,formatDate:qn,getDateByWeek:iF,isISODateString:Ja,isDate:Tf,isTimeString:eh,offsetDate:ZI,offsetTime:tF,sameDay:$n,timeStringMinutes:Yt,timeToDate:Ge,timeUTC:ZL,validTimeValue:Yc,validDateString:Om,timeValidation:ws,dateValidation:Mo};var sF=(t,e)=>t.filter(Boolean).every(r=>typeof r===e),aF=t=>t.filter(Boolean).every(Zt);function Fs(t){let e=t.category;if(typeof e!="object")return{error:Hc};let{ageCategoryCode:r,ageMaxDate:n,ageMinDate:o,ageMax:i,ageMin:s}=e,a=e.categoryName,c;if(!(sF([r,n,o,a],"string")&&aF([i,s])&&[n,o].filter(Boolean).every(Dr)))return{error:Hc};let p=t.consideredDate??Ut(new Date().toLocaleDateString("sv"));if(!Dr(p))return{error:je};let[m]=p.split("-").slice(0,3).map(G=>parseInt(G)),d=up(p,-1),[l,f]=d.split("-").slice(1,3).map(G=>parseInt(G)),g=`${no(l)}-${no(f)}`,I=up(p,1),[h,S]=I.split("-").slice(1,3).map(G=>parseInt(G)),T=`${no(h)}-${no(S)}`,y=s&&up(p,-1*365*s),E=i&&up(p,-1*365*i),P=[],A=G=>!P.includes(G)&&P.push(G);r=r??a;let U=/^([UO]?)(\d{1,2})([UO]?)$/,N=/^C(\d{1,2})-(\d{1,2})$/,D=r?.includes("-"),M=D&&r?.match(N),R=r?.match(U),b=(G,k)=>`${G}-${k}`,v=G=>{let k=m-G,H=b(k,T);e.ageMinDate&&e.ageMinDate!==H&&A(`Invalid submitted ageMinDate: ${o}`),o=H,r&&(e.ageMax&&e.ageMax!==G-1&&(A(`Invalid submitted ageMax: ${i}`),E=void 0),i=G-1)},O=G=>{let k=m-G-1,H=b(k,T);e.ageMin&&e.ageMin>G&&A(`Invalid submitted ageMin: ${s}`),e.ageMax&&e.ageMax>G&&A(`Invalid submitted ageMax: ${i}`),e.ageMinDate&&e.ageMinDate!==H&&A(`Invalid submitted ageMinDate: ${o}`),o=H,r&&(e.ageMax&&e.ageMax!==G&&(A(`Invalid submitted ageMax: ${i}`),y=void 0),i=G)},x=G=>{let k=m-G,H=b(k,g);e.ageMaxDate&&e.ageMaxDate!==H&&A(`Invalid submitted ageMaxDate: ${n}`),n=H,r&&(e.ageMin&&e.ageMin!==G+1&&(A(`Invalid submitted ageMin: ${s}`),y=void 0),s=G+1)},F=G=>{let k=m-G-1,H=b(k,g);e.ageMaxDate&&e.ageMaxDate!==H&&A(`Invalid submitted ageMaxDate: ${n}`),n=H,r&&(e.ageMin&&e.ageMin!==G&&(A(`Invalid submitted ageMin: ${s}`),y=void 0),s=G)},w=G=>{let[k,H,W]=(G.match(U)||[]).slice(1),q=parseInt(H);k==="U"?(e.ageMaxDate&&e.ageMaxDate!==n&&A(`Invalid submitted ageMaxDate: ${e.ageMaxDate}`),v(q)):k==="O"&&x(q),W==="U"?(e.ageMaxDate&&e.ageMaxDate!==n&&A(`Invalid submitted ageMaxDate: ${e.ageMaxDate}`),O(q)):W==="O"&&F(q),n=n??y,o=o??E};if(M){if(n=void 0,o=void 0,i=void 0,s=void 0,e.ageMin){let H=m-e.ageMin;n=b(H,g)}if(e.ageMax){let H=m-e.ageMax-1;o=b(H,T)}let[G,k]=(r?.match(N)??[]).slice(1).map(H=>parseInt(H));G<=k?(s=G,i=k,c=!0):A(`Invalid combined age range ${r}`)}else D?r?.split("-").forEach(w):R?w(r):(s&&x(s),i&&O(i));i&&e.ageMin&&e.ageMin>i&&(A(`Invalid submitted ageMin: ${e.ageMin}`),s=void 0);let L=nt({consideredDate:p,combinedAge:c,ageMaxDate:n,ageMinDate:o,ageMax:i,ageMin:s});return P.length&&(L.errors=P),L}function qc({category:t}){if(!ht(t))return{error:V};let e=Fs({category:t});if(e.error)return{error:e};let{ratingMax:r,ratingMin:n}=t;return r&&!Zt(r)?_({result:{error:V},context:{ratingMax:r}}):n&&!Zt(n)?_({result:{error:V},context:{ratingMin:n}}):{...e}}function $c({childCategory:t,withDetails:e,category:r}){let n=qc({category:r}),o=qc({category:t}),i=o.ageMin&&(n.ageMin&&o.ageMin<n.ageMin||n.ageMax&&o.ageMin>n.ageMax),s=o.ageMax&&(n.ageMax&&o.ageMax>n.ageMax||n.ageMin&&o.ageMax<n.ageMin),a=o.ageMinDate&&n.ageMaxDate&&new Date(o.ageMinDate)>new Date(n.ageMaxDate),c=o.ageMaxDate&&n.ageMinDate&&new Date(o.ageMaxDate)<new Date(n.ageMinDate),p=r?.ratingType&&t?.ratingType&&r.ratingType===t.ratingType&&(r.ratingMin&&t.ratingMin&&t.ratingMin<r.ratingMin||r.ratingMax&&t.ratingMax&&t.ratingMax>r.ratingMax||r.ratingMin&&t.ratingMax&&t.ratingMax<r.ratingMin||r.ratingMax&&t.ratingMin&&t.ratingMin>r.ratingMax),m=r?.ballType&&t?.ballType&&r.ballType!==t.ballType,f=nt({invalidRatingRange:p,invalidAgeMinDate:a,invalidAgeMaxDate:c,invalidBallType:m,invalidAgeMax:s,invalidAgeMin:i,valid:!p&&!a&&!c&&!m&&!s&&!i},!0);return e&&Object.assign(f,{categoryDetails:n,childCategoryDetails:o}),f}function Kc({checkCategory:t=!0,collectionDefinition:e,checkCollectionIds:r,checkGender:n=!0,referenceCategory:o,referenceGender:i,event:s}){i=i??s?.gender;let a="validateCollectionDefinition",c=[];if(typeof e!="object")return c.push(`collectionDefinition must be an object: ${e}`),_({result:{errors:c,error:ho},stack:a});let{collectionValueProfiles:u,collectionGroupNumber:p,collectionValue:m,collectionId:d,matchUpCount:l,matchUpFormat:f,matchUpValue:g,matchUpType:I,scoreValue:h,setValue:S,category:T,gender:y}=e;if(r&&typeof d!="string"&&c.push(`collectionId is not type string: ${d}`),typeof l!="number"&&c.push(`matchUpCount is not type number: ${l}`),I&&!kc([kt,xt],I)&&c.push(`matchUpType must be SINGLES or DOUBLES: ${I}`),[!!u?.length].concat([g,m,h,S].map(It)).filter(Boolean).length!==1&&c.push("Missing value definition for matchUps: matchUpValue, collectionValue, or collectionValueProfiles"),g&&typeof g!="number"&&c.push(`matchUpValue is not type number: ${g}`),m&&typeof m!="number"&&c.push(`collectionValue is not type number: ${m}`),u&&l){let P=xI({collectionValueProfiles:u,matchUpCount:l});P.errors&&c.push(...P.errors)}if(p&&typeof p!="number"&&c.push(`collectionGroupNumber is not type number: ${m}`),f&&!Pr({matchUpFormat:f})&&c.push(`Invalid matchUpFormat: ${f}`),n){let P=bm({referenceGender:i,matchUpType:I,gender:y});if(P.error)return _({context:{referenceGender:i,gender:y},result:P,stack:a})}if(t&&o&&T){let P=$c({category:o,childCategory:T});if(!P.valid)return _({result:{error:Hc},context:P,stack:a})}return c.length?_({result:{errors:c,error:OE},stack:a}):{valid:!0}}function ur(t){let e=!!(t?.enforceCategory!==!1&&t?.category),r=!!(t?.enforceGender!==!1&&t?.gender),n=t?.checkCollectionIds,o=t?.tieFormat,i=t?.event,s="validateTieFormat",a=[],c=cF({...t,stack:s});if(c?.error)return c;let u,p=o.collectionDefinitions.every(I=>{let{setValue:h,scoreValue:S,collectionValue:T}=I;(h||S)&&!T&&(u=!0);let{valid:y,errors:E}=Kc({referenceCategory:t.category,referenceGender:t.gender,collectionDefinition:I,checkCollectionIds:n,checkCategory:e,checkGender:r,event:i});return y?!0:(Array.isArray(E)&&a.push(...E),!1)}),m=typeof o.winCriteria?.valueGoal=="number"&&o.winCriteria?.valueGoal>0&&!u||o.winCriteria?.aggregateValue;if(!(m||o.winCriteria?.aggregateValue))return u?a.push("aggregateValue is required"):a.push("Either non-zero valueGoal, or { aggregateValue: true } must be specified in winCriteria"),_({context:{tieFormat:o,errors:a,aggregateValueImperative:u},result:{error:Go},stack:s});let d=o.collectionDefinitions.map(({collectionId:I})=>I),l=!n||d.length===pt(d).length,f=p&&m&&l,g={valid:f,errors:a};return f?g:_({result:{error:Go},context:{tieFormat:o,errors:a},stack:s})}function cF(t){let{tieFormat:e,stack:r}=t;return!t||!e||!ht(e)?_({result:{error:Go},context:{tieFormat:e,message:"tieformat must be an object"},stack:r}):ht(e.winCriteria)?Array.isArray(e.collectionDefinitions)?{...C}:_({result:{error:Go},context:{tieFormat:e,message:"collectionDefinitions must be an array"},stack:r}):_({result:{error:Go},context:{tieFormat:e,message:"tieformat.winCritiera must be an object"},stack:r})}var tc="resourceSubType",ec="resourceType",rc="identifier",KC={RESOURCE_SUB_TYPE:tc,RESOURCE_TYPE:ec,IDENTIFIER:rc};function J(t,e,r,n,o=0){if(XI().makeDeepCopy)return XI().makeDeepCopy(t,e,r,n);let i=df(),{stringify:s,toJSON:a,ignore:c,modulate:u}=i||{};if(!i?.enabled&&!r||typeof t!="object"||Wr(t)||t===null||typeof i?.threshold=="number"&&o>=i.threshold)return t;let p=Array.isArray(t)?[]:{},m=Object.keys(t).filter(l=>!r||!c||Array.isArray(c)&&!c.includes(l)||Wr(c)&&!c(l)),d=(l,f)=>{p[l]=Wr(f?.toString)?f.toString():JSON.stringify(f)};for(let l of m){let f=t[l],g=Wr(u)?u(f):void 0;if(g!==void 0)p[l]=g;else if(e&&l==="extensions"&&Array.isArray(f)){let I=Uf(f);Object.assign(p,...I)}else n&&l==="extensions"?p[l]=[]:Array.isArray(s)&&s.includes(l)?d(l,f):Array.isArray(a)&&a.includes(l)&&Wr(f?.toJSON)?p[l]=