pdf-factory 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/parser.cjs +2 -2
- package/dist/parser.cjs.map +1 -1
- package/dist/parser.js +178 -99
- package/dist/parser.js.map +1 -1
- package/dist/pdf-factory.cjs +1 -1
- package/dist/pdf-factory.cjs.map +1 -1
- package/dist/rolldown-runtime-5iZMYShA.cjs +1 -0
- package/package.json +4 -4
- package/dist/rolldown-runtime-CYJQrBu7.cjs +0 -1
package/dist/pdf-factory.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-CYJQrBu7.cjs");let t=require("jspdf");t=e.n(t,1);let n=require("jspdf-autotable");n=e.n(n,1);let r=require("tods-competition-factory");var i={F:`Final`,SF:`Semi-Finals`,QF:`Quarter-Finals`,R16:`Round of 16`,R32:`Round of 32`,R64:`Round of 64`,R128:`Round of 128`},a={F:`Final`,SF:`Semi-Finals`,QF:`Quarter-Finals`,R16:`Fourth Round`,R32:`Third Round`,R64:`Second Round`,R128:`First Round`},o={F:`Final`,SF:`Semifinals`,QF:`Quarterfinals`,R16:`Round 4`,R32:`Round 3`,R64:`Round 2`,R128:`Round 1`},s={F:`Final`,SF:`Semifinals`,QF:`Quarterfinals`,R16:`Round of 16`,R32:`Round of 32`,R64:`Round of 64`,R128:`Round of 128`},c={F:`FINALE`,SF:`1/2 FINALE`,QF:`1/4 FINALE`,R16:`1/8 FINALE`,R32:`3eme TOUR`,R64:`2eme TOUR`,R128:`1er TOUR`},l={pageSize:`a4`,orientation:`auto`,margins:{top:15,right:10,bottom:15,left:10}},u=`LAST, First`,d=`bare`,f=`before-position`,p=`brackets`,m=`-`,h=`traditional-lines`,g={wimbledon:{nameFormat:u,nationalityFormat:d,seedPosition:f,seedFormat:p,entryFormat:`parens`,gameScoreSeparator:m,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:a,renderStyle:h,page:{...l}},usOpen:{nameFormat:u,nationalityFormat:d,seedPosition:f,seedFormat:p,entryFormat:`parens`,gameScoreSeparator:m,setScoreSeparator:` | `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:o,renderStyle:h,page:{...l}},rolandGarros:{nameFormat:`LAST First`,nationalityFormat:d,seedPosition:`after-country`,seedFormat:p,entryFormat:`parens`,gameScoreSeparator:`/`,setScoreSeparator:` `,retirementLabel:`Ab`,walkoverLabel:`w/o`,roundLabels:c,renderStyle:h,page:{...l}},australianOpen:{nameFormat:u,nationalityFormat:`parens`,seedPosition:`after-name`,seedFormat:p,entryFormat:`hyphen`,gameScoreSeparator:`/`,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:i,renderStyle:h,page:{...l,pageSize:`letter`,orientation:`portrait`}},atp:{nameFormat:u,nationalityFormat:d,seedPosition:f,seedFormat:`bare`,entryFormat:`bare`,gameScoreSeparator:`none`,setScoreSeparator:` `,retirementLabel:`RET`,walkoverLabel:`W/O`,roundLabels:i,renderStyle:h,page:{...l}},wta:{nameFormat:u,nationalityFormat:d,seedPosition:f,seedFormat:`bare`,entryFormat:`bare`,gameScoreSeparator:`none`,setScoreSeparator:` `,retirementLabel:`RET`,walkoverLabel:`W/O`,roundLabels:i,renderStyle:h,page:{...l}},atpFinals:{nameFormat:u,nationalityFormat:`parens`,seedPosition:f,seedFormat:p,entryFormat:`bare`,gameScoreSeparator:m,setScoreSeparator:` `,retirementLabel:`RET`,walkoverLabel:`W/O`,roundLabels:i,renderStyle:`round-robin`,page:{...l,orientation:`landscape`}},itfJunior:{nameFormat:u,nationalityFormat:d,seedPosition:f,seedFormat:p,entryFormat:`bare`,gameScoreSeparator:m,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:i,renderStyle:h,page:{...l}},lta:{nameFormat:u,nationalityFormat:d,seedPosition:f,seedFormat:p,entryFormat:`bare`,gameScoreSeparator:m,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:s,renderStyle:h,page:{...l}},usta:{nameFormat:u,nationalityFormat:d,seedPosition:f,seedFormat:p,entryFormat:`bare`,gameScoreSeparator:m,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`W/O`,roundLabels:i,renderStyle:h,page:{...l}}};function _(e){return g[e]||g.itfJunior}function v(e,t){return{..._(e),...t}}var y=`itfJunior`,b=`combined-tour`,x=`grand-slam`,S=`officials-signoff`,C={[x]:{id:x,name:`Grand Slam`,description:`Minimal chrome — large tournament name, timestamp footer`,category:x,tier:1,header:{layout:x},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`wimbledon`},wimbledon:{id:`wimbledon`,name:`Wimbledon`,description:`Green/purple Grand Slam style with crest`,category:x,tier:1,header:{layout:x},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`wimbledon`},"australian-open":{id:`australian-open`,name:`Australian Open`,description:`Grand Slam with seedings + prize money footer`,category:x,tier:2,header:{layout:x},footer:{layout:b,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`australianOpen`},"wta-500":{id:`wta-500`,name:`WTA 500`,description:`Tour header with logos, seedings + prize money footer`,category:`tour`,tier:2,header:{layout:`wta-tour`},footer:{layout:b,showPageNumbers:!1,showTimestamp:!0},drawFormatPreset:y},"wta-1000":{id:`wta-1000`,name:`WTA 1000`,description:`Tour header with logos, full footer with officials`,category:`tour`,tier:2,header:{layout:`wta-tour`},footer:{layout:b,showPageNumbers:!1,showTimestamp:!0},drawFormatPreset:y},"atp-250":{id:`atp-250`,name:`ATP 250`,description:`ATP tour header, seedings + prize money footer with sign-off`,category:`tour`,tier:2,header:{layout:`wta-tour`},footer:{layout:b,showPageNumbers:!1,showTimestamp:!0},drawFormatPreset:y},"atp-finals":{id:`atp-finals`,name:`ATP Finals`,description:`Full official sign-off with signature lines`,category:`tour`,tier:3,header:{layout:x},footer:{layout:S,showTimestamp:!0},drawFormatPreset:y},"itf-junior":{id:`itf-junior`,name:`ITF Junior`,description:`ITF header with metadata row, officials sign-off footer`,category:`itf`,tier:3,header:{layout:`itf`},footer:{layout:S,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:y},"itf-pro-circuit":{id:`itf-pro-circuit`,name:`ITF Pro Circuit`,description:`ITF header, seedings + officials footer`,category:`itf`,tier:2,header:{layout:`itf`},footer:{layout:b,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:y},"national-federation":{id:`national-federation`,name:`National Federation`,description:`Detailed metadata header, full sign-off footer with ceremony date`,category:`national`,tier:3,header:{layout:`national-federation`},footer:{layout:S,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`usta`},"collegiate-ncaa":{id:`collegiate-ncaa`,name:`NCAA Collegiate`,description:`Mirrored bracket layout, team logos, minimal footer`,category:`collegiate`,tier:1,header:{layout:x},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:y},"club-basic":{id:`club-basic`,name:`Club Basic`,description:`Minimal header, standard footer — clean and simple`,category:`club`,tier:1,header:{layout:`minimal`},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:y}};function ee(e){return C[e]}function te(e){let t=Object.values(C);return e?t.filter(t=>t.category===e):t}function ne(e,t,n){let r=C[e]||C[`club-basic`];return{header:{...r.header,...t},footer:{...r.footer,...n}}}var w=`tournament-header`,T=`contacts`,E=`events`,D=`entry-info`,O=`venue-info`,k=`accommodation`,A=`transportation`,re=`hospitality`,ie=`medical`,ae=`regulations`,oe=`prize-money`,se=`officials`,ce=`sponsors`,le=`social-events`,ue=`custom-notes`;function j(e,t=!0,n){return{type:e,enabled:t,...n&&{title:n}}}var de=[j(w),j(T),j(E),j(D),j(O),j(k),j(A),j(re),j(ie),j(ae),j(oe),j(se),j(ce),j(le),j(ue)],fe={"itf-junior":{id:`itf-junior`,name:`ITF Junior`,description:`Full fact sheet with all sections — ITF header style`,category:`itf`,headerLayout:`itf`,sections:de},"itf-pro-circuit":{id:`itf-pro-circuit`,name:`ITF Pro Circuit`,description:`Pro circuit fact sheet — contacts, events, entry, venue, prize money, officials`,category:`itf`,headerLayout:`itf`,sections:[j(w),j(T),j(E),j(D),j(O),j(oe),j(se),j(ae),j(ue)]},"national-federation":{id:`national-federation`,name:`National Federation`,description:`Detailed national federation fact sheet with all logistics`,category:`national`,headerLayout:`national-federation`,sections:de},"tour-atp-wta":{id:`tour-atp-wta`,name:`ATP/WTA Tour`,description:`Tour-level fact sheet — contacts, events, prize money, officials, sponsors`,category:`tour`,headerLayout:`wta-tour`,sections:[j(w),j(T),j(E),j(oe),j(se),j(ce),j(k),j(A),j(le),j(ue)]},"club-basic":{id:`club-basic`,name:`Club Basic`,description:`Simple club-level fact sheet — essentials only`,category:`club`,headerLayout:`minimal`,sections:[j(w),j(T),j(E),j(D),j(O),j(ue)]}};function pe(e){return fe[e]}function me(e){let t=Object.values(fe);return e?t.filter(t=>t.category===e):t}function he(e,t){let n=e?.sides??[],r=[1,2].map(e=>n.find(t=>t?.sideNumber===e)?.drawPosition);if(r.some(Boolean))return r;let i=t?.[e?.roundNumber]?.pairedDrawPositions?.[(e?.roundPosition??0)-1];return Array.isArray(i)&&i.some(Boolean)?[i[0]??void 0,i[1]??void 0]:e?.drawPositions??[]}function ge(e){if(!e?.winningSide)return;let t=e.sides?.find(t=>t?.sideNumber===e.winningSide)?.drawPosition;if(t)return t;let n=(e.drawPositions??[]).filter(Boolean);return n.length===1?n[0]:e.drawPositions?.[e.winningSide-1]}function M(e){let t=e.roundMatchUps||{},n=e.roundProfile||{},r=Object.keys(t).map(Number).sort((e,t)=>e-t),i=new Map;for(let e of r)for(let n of t[e]||[])for(let e of n.sides||[])if(e?.drawPosition&&!i.has(e.drawPosition)){let t=e.entryStatus||e.participant?.entryStatus,n=t&&t!==`DIRECT_ACCEPTANCE`?t:void 0;i.set(e.drawPosition,{drawPosition:e.drawPosition,participantName:e.participant?.participantName||``,nationality:e.participant?.nationalityCode||``,seedValue:e.seedValue,entryStatus:n,isBye:e.bye===!0})}let a=[];for(let e of r)for(let r of t[e]||[])a.push({roundNumber:r.roundNumber,roundPosition:r.roundPosition,drawPositions:he(r,n),winnerDrawPosition:ge(r),score:r.score?.scoreStringSide1||``,winningSide:r.winningSide,matchUpStatus:r.matchUpStatus});let o={};for(let e of r){let t=n[e];o[e]=t?.abbreviatedRoundName||t?.roundName||`R${e}`}let s=r.length>0?Math.max(...r):0,c=[...i.values()].sort((e,t)=>e.drawPosition-t.drawPosition),l=e.stage===`QUALIFYING`,u=t[s]?.length||0,d=l||u>1;return{drawName:e.structureName||``,drawSize:c.length,drawType:`SINGLE_ELIMINATION`,totalRounds:s,noWinnerColumn:d,slots:c,matchUps:a,seedAssignments:(e.seedAssignments||[]).filter(e=>e.participantName).map(e=>({seedValue:e.seedValue,participantName:e.participantName||``,nationality:e.nationalityCode||``,seedingBasis:e.seedingBasis})),roundLabelMap:o}}function N(e,t){return e?.[0]?.structures?.find(e=>e.stage===t)}var _e={REGULAR:`helvetica`,BOLD:`helvetica`},P={NORMAL:`normal`,BOLD:`bold`,ITALIC:`italic`},F={TITLE:16,SUBTITLE:12,HEADING:10,BODY:8,SMALL:7,TINY:6},ve=new WeakMap,ye=[`normal`,`bold`,`italic`,`bolditalic`];function be(e,t){if(!t?.family||!t?.normal)return _e.REGULAR;for(let n of ye){let r=t[n]??t.normal,i=`${t.family}-${n}.ttf`;e.addFileToVFS(i,r),e.addFont(i,t.family,n)}return ve.set(e,t.family),t.family}function xe(e){return ve.get(e)??_e.REGULAR}var Se;function Ce(e){Se=e}function we(){return Se}function I(e){return Se?be(e,Se):_e.REGULAR}function L(e,t,n=P.NORMAL){e.setFont(xe(e),n),e.setFontSize(t)}function Te(e,n){let r=e.orientation;r===`auto`&&(r=n&&n>=32?`landscape`:`portrait`);let i=new t.default({orientation:r,format:e.pageSize,unit:`mm`});return e.font?be(i,e.font):I(i),i}function R(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=t;return{headerHeight:n,footerHeight:r,contentY:o.top+n,contentHeight:a-o.top-o.bottom-n-r,contentWidth:i-o.left-o.right,pageWidth:i,pageHeight:a}}function Ee(){return{pageSize:`a4`,orientation:`auto`,margins:{top:15,right:10,bottom:15,left:10}}}function z(e,t,n){switch(t.layout){case`grand-slam`:return De(e,t,n);case`itf`:return Oe(e,t,n);case`minimal`:return ke(e,t,n);case`wta-tour`:return Ae(e,t,n);case`national-federation`:return je(e,t,n);case`none`:return 0}}function De(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth(),a=i-r.right,o=r.top;L(e,18,P.BOLD),e.text(t.tournamentName.toUpperCase(),i/2,o,{align:`center`}),o+=7,t.subtitle&&(L(e,12,P.BOLD),e.text(t.subtitle.toUpperCase(),i/2,o,{align:`center`}),o+=6),L(e,F.BODY,P.NORMAL);let s=[];if(t.startDate){let e=t.endDate?`${t.startDate} - ${t.endDate}`:t.startDate;s.push(e)}return t.location&&s.push(t.location),s.forEach((t,n)=>{e.text(t,a,r.top+n*4,{align:`right`})}),o+=2,e.setDrawColor(0),e.setLineWidth(.5),e.line(r.left,o,a,o),o+=3,o-r.top}function Oe(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth()-r.right,a=r.top;L(e,F.TITLE,P.BOLD),e.text(t.tournamentName,r.left,a),a+=6,t.subtitle&&(L(e,F.SUBTITLE,P.BOLD),e.text(t.subtitle,r.left,a),a+=5),L(e,F.SMALL,P.NORMAL);let o=[];t.grade&&o.push(`Grade: ${t.grade}`),t.surface&&o.push(`Surface: ${t.surface}`),t.supervisor&&o.push(`Supervisor: ${t.supervisor}`),o.forEach((t,n)=>{e.text(t,i,r.top+n*3.5,{align:`right`})}),L(e,F.BODY,P.NORMAL);let s=[];return t.startDate&&s.push(t.startDate),t.location&&s.push(t.location),t.organizer&&s.push(t.organizer),s.length&&(e.text(s.join(` | `),r.left,a),a+=4),a+=1,e.setDrawColor(0),e.setLineWidth(.3),e.line(r.left,a,i,a),a+=3,a-r.top}function ke(e,t,n){let{margins:r}=n,i=r.top;L(e,F.SUBTITLE,P.BOLD),e.text(t.tournamentName,r.left,i);let a=e.getTextWidth(t.tournamentName);return t.subtitle&&(L(e,F.BODY,P.NORMAL),e.text(` - ${t.subtitle}`,r.left+a,i)),i+=6,i-r.top}function Ae(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth(),a=i-r.right,o=i/2,s=r.top;if(t.leftLogoBase64)try{e.addImage(t.leftLogoBase64,`PNG`,r.left,s-2,12,12)}catch{}if(t.rightLogoBase64)try{e.addImage(t.rightLogoBase64,`PNG`,a-12,s-2,12,12)}catch{}L(e,14,P.BOLD),e.text(t.tournamentName,o,s,{align:`center`}),s+=5;let c=[t.city,t.country].filter(Boolean).join(`, `);c&&(L(e,F.BODY,P.NORMAL),e.setTextColor(80),e.text(c.toUpperCase(),o,s,{align:`center`}),e.setTextColor(0),s+=4);let l=[];if(t.startDate){let e=t.endDate?`${t.startDate} - ${t.endDate}`:t.startDate;l.push(e)}if(t.prizeMoney){let e=t.currency?`${t.currency} ${t.prizeMoney}`:t.prizeMoney;l.push(e)}return t.surface&&l.push(t.surface),l.length&&(L(e,F.SMALL,P.NORMAL),e.text(l.join(` | `),o,s,{align:`center`}),s+=4),t.sectionLabel&&(L(e,F.SMALL,P.BOLD),e.text(t.sectionLabel.toUpperCase(),a,s,{align:`right`}),s+=3),s+=1,e.setDrawColor(0),e.setLineWidth(.3),e.line(r.left,s,a,s),s+=3,s-r.top}function je(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth()-r.right,a=r.top;if(t.rightLogoBase64)try{e.addImage(t.rightLogoBase64,`PNG`,i-14,a-2,14,14)}catch{}L(e,F.TITLE,P.BOLD),e.text(t.tournamentName,r.left,a),a+=6,t.subtitle&&(L(e,F.HEADING,P.BOLD),e.text(t.subtitle,r.left,a),a+=4),L(e,F.TINY,P.NORMAL),e.setTextColor(80);let o=[];return t.startDate&&o.push(t.startDate),t.organizer&&o.push(t.organizer),(t.city||t.country)&&o.push([t.city,t.country].filter(Boolean).join(`, `)),t.tournamentId&&o.push(`ID: ${t.tournamentId}`),t.grade&&o.push(`Grade: ${t.grade}`),t.chiefUmpire&&o.push(`Umpire: ${t.chiefUmpire}`),o.length&&(e.text(o.join(` | `),r.left,a),a+=3),e.setTextColor(0),a+=1,e.setDrawColor(0),e.setLineWidth(.3),e.line(r.left,a,i,a),a+=3,a-r.top}function Me(e){let t=e.person;if(t?.standardFamilyName){let e=t.standardGivenName||``;return e?t.standardFamilyName+`, `+e:t.standardFamilyName}return e.participantName||``}function Ne(e,t){return e.find(e=>e.participantRole===t)}function Pe(e,t){return e.find(e=>e.participantRole===`OFFICIAL`&&e.participantRoleResponsibilities?.some(e=>e.toUpperCase().includes(t.toUpperCase())))}function Fe(e){let t=(e.venues?.[0])?.addresses?.[0],n=[];return t?.city&&n.push(t.city),t?.state&&n.push(t.state),(t?.countryCode||e.hostCountryCode)&&n.push(t?.countryCode||e.hostCountryCode||``),n.join(`, `)}function Ie(e){return e.venues?.[0]?.addresses?.[0]?.city}function Le(e){return e.venues?.[0]?.addresses?.[0]?.countryCode||e.hostCountryCode}function Re(e){if(e.tournamentTier){let t=e.tournamentTier;return t.system?t.system+` `+(t.value||``):t.value}return e.tournamentLevel}function ze(e){let t=e.totalPrizeMoney?.[0];if(t)return String(t.amount)}function Be(e){return e.totalPrizeMoney?.[0]?.currencyCode}function Ve(e,t={}){let{layout:n=`itf`,sectionLabel:r,overrides:i}=t,a=e.participants||[],o=Ne(a,`DIRECTOR`),s=Pe(a,`REFEREE`),c=Pe(a,`CHIEF_UMPIRE`)||Pe(a,`UMPIRE`),l=Pe(a,`SUPERVISOR`)||s;return{layout:n,tournamentName:e.formalName||e.tournamentName||``,startDate:e.startDate,endDate:e.endDate,location:Fe(e),city:Ie(e),country:Le(e),surface:e.surfaceCategory,grade:Re(e),tournamentId:e.tournamentId,organizer:o?Me(o):void 0,supervisor:l?Me(l):void 0,chiefUmpire:c?Me(c):void 0,prizeMoney:ze(e),currency:Be(e),sectionLabel:r,...i}}function He(e,t={}){let{layout:n=`standard`,seedAssignments:r,prizeMoney:i,overrides:a}=t,o=(e.participants||[]).filter(e=>e.participantRole===`OFFICIAL`||e.participantRole===`DIRECTOR`).map(e=>({role:e.participantRoleResponsibilities?.[0]||e.participantRole||`Official`,name:Me(e)}));return{layout:n,showPageNumbers:!0,showTimestamp:!0,...o.length&&{signatureLines:o},...r?.length&&{seedAssignments:r},...i?.length&&{prizeMoney:i},...e.registrationProfile?.drawCeremonyDate&&{drawCeremonyDate:e.registrationProfile.drawCeremonyDate},...a}}var Ue=[`†`,`‡`,`§`,`¶`],We={ORGANISER_DISCRETION:`organiser discretion`,PROTECTED_RANKING:`protected ranking`,RANKING:`ranking`,RATING:`rating`},Ge=`RANKING`;function Ke(e){let t=new Map,n=e.map(e=>{let n=e?.seedingBasis;if(!n||n===Ge)return``;let r=t.get(n);if(r)return r;let i=Ue[t.size]??Ue[Ue.length-1];return t.set(n,i),i}),r=[...t.entries()].map(([e,t])=>`${t} Additional seed — ${We[e]??e.toLowerCase()}`);return{markers:n,footnotes:r,hasAnnotations:r.length>0}}function qe(e,t,n,r){switch(t.layout){case`standard`:return Ye(e,t,n,r);case`seedings`:case`seedings-table`:return Xe(e,t,n,r);case`prize-money`:return Ze(e,t,n,r);case`officials`:case`officials-signoff`:return Qe(e,t,n,r);case`combined-tour`:return $e(e,t,n,r);case`none`:return 0}}function Je(e){return Ke(e.seedAssignments||[]).footnotes.length}function B(e){switch(e.layout){case`standard`:return 8+(e.notes?.length||0)*3;case`seedings`:case`seedings-table`:return 12+Math.ceil((e.seedAssignments?.length||0)/2)*3+Je(e)*3;case`prize-money`:return 12+(e.prizeMoney?.length||0)*2.5;case`officials`:case`officials-signoff`:return 12+(e.signatureLines?.length||e.officials?.length||0)*5;case`combined-tour`:{let t=(e.seedAssignments?.length||0)+Je(e),n=e.prizeMoney?.length||0;return 16+Math.max(t*2.5,n*2.5)+(e.withdrawals?.length?6:0)}case`none`:return 0}}function Ye(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=a-o.bottom;if(L(e,F.TINY,P.NORMAL),e.setTextColor(120),t.showTimestamp&&e.text(`Generated ${new Date().toLocaleDateString()}`,o.left,c),t.showPageNumbers&&r!==void 0&&e.text(`Page ${r}`,s,c,{align:`right`}),e.setTextColor(0),c-=3,e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,c,s,c),c-=2,t.notes?.length){L(e,F.TINY,P.ITALIC),e.setTextColor(100);for(let n=t.notes.length-1;n>=0;n--)e.text(t.notes[n],o.left,c),c-=3;e.setTextColor(0)}return B(t)}function Xe(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=B(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=3,L(e,F.SMALL,P.BOLD),e.text(`Seeded Players`,o.left,l),l+=3;let u=t.seedAssignments||[],d=(s-o.left)/2,{markers:f,footnotes:p,hasAnnotations:m}=Ke(u);L(e,F.TINY,P.NORMAL);for(let t=0;t<u.length;t++){let n=t<Math.ceil(u.length/2)?0:1,r=n===0?t:t-Math.ceil(u.length/2),i=o.left+n*d,a=l+r*3,s=u[t],c=s.ranking?` (${s.ranking})`:``,p=f[t]?` ${f[t]}`:``;e.text(`${s.seedValue}. ${s.participantName}${c}${p}`,i,a)}let h=Math.ceil(u.length/2);if(l+=h*3+2,m){L(e,F.TINY,P.ITALIC);for(let t of p)e.text(t,o.left,l),l+=3;L(e,F.TINY,P.NORMAL)}return et(e,t,n,r,l),c}function Ze(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=B(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=3,L(e,F.SMALL,P.BOLD),e.text(`Prize Money`,o.left,l),l+=3;let u=t.prizeMoney||[];L(e,F.TINY,P.NORMAL);for(let t of u){let n=[t.round];t.amount&&n.push(t.amount),t.points&&n.push(`${t.points} pts`),e.text(n.join(` — `),o.left,l),l+=2.5}return l+=2,et(e,t,n,r,l),c}function Qe(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=B(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=4,t.drawCeremonyDate&&(L(e,F.TINY,P.ITALIC),e.setTextColor(80),e.text(`Draw ceremony: ${t.drawCeremonyDate}`,o.left,l),e.setTextColor(0),l+=3),t.releaseDate&&(L(e,F.TINY,P.ITALIC),e.setTextColor(80),e.text(`Released: ${t.releaseDate}`,o.left,l),e.setTextColor(0),l+=3);let u=t.signatureLines||(t.officials||[]).map(e=>({role:e})),d=(s-o.left)/Math.min(u.length,3);for(let t=0;t<u.length;t++){let n=t%3,r=Math.floor(t/3),i=o.left+n*d,a=l+r*10;L(e,F.TINY,P.ITALIC),e.setTextColor(100),e.text(u[t].role,i,a),e.setTextColor(0);let s=u[t].name;s&&(L(e,F.TINY,P.BOLD),e.text(s,i,a+3)),e.setDrawColor(150),e.setLineWidth(.15),e.line(i,a+5,i+d-8,a+5)}let f=Math.ceil(u.length/3);return l+=f*10+2,et(e,t,n,r,l),c}function $e(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=B(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=3;let u=s-o.left,d=o.left,f=o.left+u*.55,p=l,m=l,h=t.seedAssignments||[];if(h.length){let{markers:t,footnotes:n,hasAnnotations:r}=Ke(h);if(L(e,F.SMALL,P.BOLD),e.text(`Seeded Players`,d,p),p+=3,L(e,F.TINY,P.NORMAL),h.forEach((n,r)=>{let i=n.ranking?` (${n.ranking})`:``,a=t[r]?` ${t[r]}`:``;e.text(`${n.seedValue}. ${n.participantName}${i}${a}`,d,p),p+=2.5}),r){L(e,F.TINY,P.ITALIC);for(let t of n)e.text(t,d,p),p+=2.5;L(e,F.TINY,P.NORMAL)}}let g=t.prizeMoney||[];if(g.length){L(e,F.SMALL,P.BOLD),e.text(`Prize Money`,f,m),m+=3,L(e,F.TINY,P.NORMAL);for(let t of g){let n=[t.round];t.amount&&n.push(t.amount),t.points&&n.push(`${t.points} pts`),e.text(n.join(` — `),f,m),m+=2.5}}if(l=Math.max(p,m)+2,t.withdrawals?.length){L(e,F.TINY,P.ITALIC),e.setTextColor(80);let n=t.withdrawals.map(e=>e.reason?`${e.name} (${e.reason})`:e.name).join(`, `);e.text(`Withdrawals: ${n}`,o.left,l,{maxWidth:u}),e.setTextColor(0),l+=3}return t.luckyLosers?.length&&(L(e,F.TINY,P.ITALIC),e.setTextColor(80),e.text(`Lucky Losers: ${t.luckyLosers.join(`, `)}`,o.left,l,{maxWidth:u}),e.setTextColor(0),l+=3),t.officials?.length&&(L(e,F.TINY,P.NORMAL),e.setTextColor(80),e.text(t.officials.join(` | `),o.left,l),e.setTextColor(0),l+=3),et(e,t,n,r,l),c}function et(e,t,n,r,i){let a=e.internal.pageSize.getWidth(),o=e.internal.pageSize.getHeight(),{margins:s}=n,c=a-s.right,l=o-s.bottom+2;if(L(e,F.TINY,P.NORMAL),e.setTextColor(120),t.showTimestamp&&e.text(`Generated ${new Date().toLocaleDateString()}`,s.left,l),t.releaseDate){let n=t.showTimestamp?s.left+50:s.left;e.text(`Released: ${t.releaseDate}`,n,l)}t.showPageNumbers&&r!==void 0&&e.text(`Page ${r}`,c,l,{align:`right`}),e.setTextColor(0)}var tt=5,nt=2.5;function rt(e,t,n,r){let i=t.seedAssignments;if(!i.length)return r;let a=n.page.margins,o=e.internal.pageSize.getWidth()-a.left-a.right;L(e,6,P.BOLD),e.text(`Seeded players`,a.left,r),e.setDrawColor(150),e.setLineWidth(.15),e.line(a.left,r+1,a.left+o*.5,r+1),r+=3;let s=Math.ceil(i.length/2),c=i.slice(0,s),l=i.slice(s),u=o*.25,d=r;for(let t=0;t<Math.max(c.length,l.length);t++)c[t]&&it(e,c[t],a.left,d,u),l[t]&&it(e,l[t],a.left+u+4,d,u),d+=nt;return d}function it(e,t,n,r,i){L(e,tt,P.BOLD),e.text(`${t.seedValue}`,n+4,r,{align:`right`}),L(e,tt,P.NORMAL),e.text(t.participantName,n+6,r),e.setTextColor(100),e.text(t.nationality,n+45,r),e.setTextColor(0)}function at(e){return e===0?0:4+Math.ceil(e/2)*nt}function V(e){if(!e)return``;if(e.person){let{standardFamilyName:t,standardGivenName:n}=e.person;if(t)return`${t.toUpperCase()}, ${n||``}`.trim()}return e.participantName||``}function H(e){return e&&e.person?.nationalityCode||``}function ot(e){return e?`[${e}]`:``}function st(e){return e?{DIRECT_ACCEPTANCE:`DA`,WILDCARD:`WC`,LUCKY_LOSER:`LL`,QUALIFIER:`Q`,ALTERNATE:`A`,SPECIAL_EXEMPT:`SE`}[e]||e:``}function ct(e){return e?typeof e==`string`?e:e.scoreStringSide1?e.scoreStringSide1:``:``}function lt(e){return e?new Date(e+`T00:00:00`).toLocaleDateString(`en-US`,{day:`2-digit`,month:`short`,year:`numeric`}):``}function ut(e){if(!e)return``;let[t,n]=e.split(`:`),r=parseInt(t),i=r>=12?`PM`:`AM`,a=r;return r===0?a=12:r>12&&(a=r-12),`${a}:${n} ${i}`}function dt(e){return e?e.split(/\s+/).map(e=>e[0]).join(``).toUpperCase():``}function ft(e,t){let n=t-e+1;return n===1?`F`:n===2?`SF`:n===3?`QF`:`R${2**n}`}function pt(e,t){return e.find(e=>e?.sideNumber===t)??e[t-1]}function mt(e){let{matchUps:t=[],venues:n=[],scheduledDate:r=``}=e,i=new Set;n.forEach(e=>{(e.courts||[]).forEach(e=>{i.add(e.courtName||`Court ${e.courtId}`)})});let a=new Map;n.forEach(e=>{(e.courts||[]).forEach(e=>{a.set(e.courtId,e.courtName||`Court ${e.courtId}`)})});let o=t.filter(e=>e.schedule?.scheduledDate===r||!r),s=new Map;for(let e of o){let t=e.schedule||{},n=t.scheduledTime||`00:00`,r=t.venueCourtId||t.courtId||``,o=a.get(r)||r;o&&i.add(o);let c=e.sides||[],l=ht(pt(c,1)),u=ht(pt(c,2)),d={courtName:o,scheduledTime:ut(n),eventName:e.eventName||e.event?.eventName||``,eventAbbr:dt(e.eventName||e.event?.eventName||``),roundName:e.roundName||``,side1:l,side2:u,score:ct(e.score),matchUpStatus:e.matchUpStatus,notBeforeTime:t.notBeforeTime?ut(t.notBeforeTime):void 0},f=t.notBeforeTime||n;s.has(f)||s.set(f,[]),s.get(f).push(d)}let c=[...s.keys()].sort().map(e=>({time:e,label:ut(e)||`TBD`,matches:s.get(e)||[]}));return{scheduledDate:r,courts:[...i].sort(),timeSlots:c}}function ht(e){if(!e)return{name:``,nationality:``};let t=e.participant;return t?{name:V(t),nationality:H(t)}:{name:``,nationality:``}}function gt(e){let{participants:t=[],eventEntries:n=[]}=e,r=new Map;for(let{eventName:e,entries:t}of n)for(let n of t){let t=n.participantId;r.has(t)||r.set(t,{events:[],entryStatus:``,seedValue:void 0});let i=r.get(t);if(i.events.push(e),n.entryStatus&&(i.entryStatus=n.entryStatus),n.seedValue!==void 0&&i.seedValue===void 0){let e=Number(n.seedValue);Number.isNaN(e)||(i.seedValue=e)}}return t.filter(e=>e.participantType===`INDIVIDUAL`).map(e=>{let t=r.get(e.participantId);return{name:V(e),nationality:H(e),ranking:_t(e),seedValue:t?.seedValue,entryStatus:st(t?.entryStatus||``),events:t?.events||[],signedIn:e.signInStatus===`SIGNED_IN`}}).sort((e,t)=>e.name.localeCompare(t.name))}function _t(e){for(let t of[e.rankings,e.ratings])if(t&&typeof t==`object`)for(let e of Object.values(t)){let t=e?.[0]?.scaleValue;if(t!=null&&t!==``)return String(t)}return``}function vt(e){let{matchUps:t=[],venues:n=[]}=e,r=new Map;n.forEach(e=>{(e.courts||[]).forEach(t=>{r.set(t.courtId,{courtName:t.courtName||`Court ${t.courtId}`,venueName:e.venueName||``})})});let i=new Map;for(let e of t){let t=e.schedule?.venueCourtId||e.schedule?.courtId;t&&(i.has(t)||i.set(t,[]),i.get(t).push(e))}let a=[];for(let[e,t]of i){let n=r.get(e)||{courtName:e,venueName:``};t.sort((e,t)=>{let n=e.schedule?.scheduledTime||``,r=t.schedule?.scheduledTime||``;return n.localeCompare(r)});let i=new Set([`COMPLETED`,`RETIRED`,`WALKOVER`,`DEFAULTED`,`ABANDONED`]),o=t.find(e=>e.matchUpStatus===`IN_PROGRESS`),s=t.filter(e=>!i.has(e.matchUpStatus)),c=t.filter(e=>i.has(e.matchUpStatus)),l=o||s[0]||c.at(-1),u;o?u=s[0]:s.length>1&&(u=s[1]),a.push({courtName:n.courtName,venueName:n.venueName,currentMatch:l?yt(l):void 0,nextMatch:u?yt(u):void 0})}return a.sort((e,t)=>e.courtName.localeCompare(t.courtName))}function yt(e){let t=e.sides||[];return{eventName:e.eventName||e.event?.eventName||``,roundName:e.roundName||``,scheduledTime:e.schedule?.scheduledTime?ut(e.schedule.scheduledTime):void 0,side1:bt(pt(t,1)),side2:bt(pt(t,2))}}function bt(e){return e?.participant?{name:V(e.participant),nationality:H(e.participant)}:{name:`TBD`,nationality:``}}function xt(e,t={}){let n=e.courts.length>=4,r={pageSize:t.page?.pageSize||`a4`,orientation:t.page?.orientation||(n?`landscape`:`portrait`),margins:t.page?.margins||{top:12,right:8,bottom:10,left:8}},i=Te(r),a=t.footer||{layout:`standard`,showTimestamp:!0,showPageNumbers:!0},o=B(a)+(t.notes?.length?t.notes.length*3:0),s=r.margins.top;if(t.header){let e=z(i,t.header,r);s=r.margins.top+e}t.alertBanner&&(s=St(i,t.alertBanner,r,s)),Ct(i,e,r,s,t);let c=i.internal.pageSize.getHeight();if(t.notes?.length){let e=c-r.margins.bottom-o+2;L(i,F.TINY,P.ITALIC),i.setTextColor(80);for(let n of t.notes)i.text(n,r.margins.left,e),e+=3;i.setTextColor(0)}if(t.officials?.length){let e=c-r.margins.bottom-6;Dt(i,t.officials,r,e)}return qe(i,a,r,1),i}function St(e,t,n,r){let{margins:i}=n,a=e.internal.pageSize.getWidth(),o=a-i.left-i.right;return e.setFillColor(200,30,30),e.rect(i.left,r,o,7,`F`),L(e,F.SMALL,P.BOLD),e.setTextColor(255,255,255),e.text(t,a/2,r+4.5,{align:`center`}),e.setTextColor(0),r+9}function Ct(e,t,r,i,a){let{margins:o}=r,s=t.courts,c=a.cellStyle===`compact`,l=[{header:``,dataKey:`slot`}];for(let e of s)l.push({header:e,dataKey:e});let u=[];t.timeSlots.forEach((e,t)=>{let n=[],r=wt(e,t);n.push({content:r,styles:{fontStyle:`bold`,valign:`top`,cellWidth:12}});for(let t of s){let r=e.matches.filter(e=>e.courtName===t),i=r.length>0?r.map(e=>Tt(e,c)).join(`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-5iZMYShA.cjs");let t=require("jspdf");t=e.n(t,1);let n=require("jspdf-autotable");n=e.n(n,1);let r=require("tods-competition-factory");var i={F:`Final`,SF:`Semi-Finals`,QF:`Quarter-Finals`,R16:`Round of 16`,R32:`Round of 32`,R64:`Round of 64`,R128:`Round of 128`},a={F:`Final`,SF:`Semi-Finals`,QF:`Quarter-Finals`,R16:`Fourth Round`,R32:`Third Round`,R64:`Second Round`,R128:`First Round`},o={F:`Final`,SF:`Semifinals`,QF:`Quarterfinals`,R16:`Round 4`,R32:`Round 3`,R64:`Round 2`,R128:`Round 1`},s={F:`Final`,SF:`Semifinals`,QF:`Quarterfinals`,R16:`Round of 16`,R32:`Round of 32`,R64:`Round of 64`,R128:`Round of 128`},c={F:`FINALE`,SF:`1/2 FINALE`,QF:`1/4 FINALE`,R16:`1/8 FINALE`,R32:`3eme TOUR`,R64:`2eme TOUR`,R128:`1er TOUR`},l={pageSize:`a4`,orientation:`auto`,margins:{top:15,right:10,bottom:15,left:10}},u=`LAST, First`,d=`bare`,f=`before-position`,p=`brackets`,m=`-`,h=`traditional-lines`,g={wimbledon:{nameFormat:u,nationalityFormat:d,seedPosition:f,seedFormat:p,entryFormat:`parens`,gameScoreSeparator:m,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:a,renderStyle:h,page:{...l}},usOpen:{nameFormat:u,nationalityFormat:d,seedPosition:f,seedFormat:p,entryFormat:`parens`,gameScoreSeparator:m,setScoreSeparator:` | `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:o,renderStyle:h,page:{...l}},rolandGarros:{nameFormat:`LAST First`,nationalityFormat:d,seedPosition:`after-country`,seedFormat:p,entryFormat:`parens`,gameScoreSeparator:`/`,setScoreSeparator:` `,retirementLabel:`Ab`,walkoverLabel:`w/o`,roundLabels:c,renderStyle:h,page:{...l}},australianOpen:{nameFormat:u,nationalityFormat:`parens`,seedPosition:`after-name`,seedFormat:p,entryFormat:`hyphen`,gameScoreSeparator:`/`,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:i,renderStyle:h,page:{...l,pageSize:`letter`,orientation:`portrait`}},atp:{nameFormat:u,nationalityFormat:d,seedPosition:f,seedFormat:`bare`,entryFormat:`bare`,gameScoreSeparator:`none`,setScoreSeparator:` `,retirementLabel:`RET`,walkoverLabel:`W/O`,roundLabels:i,renderStyle:h,page:{...l}},wta:{nameFormat:u,nationalityFormat:d,seedPosition:f,seedFormat:`bare`,entryFormat:`bare`,gameScoreSeparator:`none`,setScoreSeparator:` `,retirementLabel:`RET`,walkoverLabel:`W/O`,roundLabels:i,renderStyle:h,page:{...l}},atpFinals:{nameFormat:u,nationalityFormat:`parens`,seedPosition:f,seedFormat:p,entryFormat:`bare`,gameScoreSeparator:m,setScoreSeparator:` `,retirementLabel:`RET`,walkoverLabel:`W/O`,roundLabels:i,renderStyle:`round-robin`,page:{...l,orientation:`landscape`}},itfJunior:{nameFormat:u,nationalityFormat:d,seedPosition:f,seedFormat:p,entryFormat:`bare`,gameScoreSeparator:m,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:i,renderStyle:h,page:{...l}},lta:{nameFormat:u,nationalityFormat:d,seedPosition:f,seedFormat:p,entryFormat:`bare`,gameScoreSeparator:m,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:s,renderStyle:h,page:{...l}},usta:{nameFormat:u,nationalityFormat:d,seedPosition:f,seedFormat:p,entryFormat:`bare`,gameScoreSeparator:m,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`W/O`,roundLabels:i,renderStyle:h,page:{...l}}};function _(e){return g[e]||g.itfJunior}function v(e,t){return{..._(e),...t}}var y=`itfJunior`,b=`combined-tour`,x=`grand-slam`,S=`officials-signoff`,C={[x]:{id:x,name:`Grand Slam`,description:`Minimal chrome — large tournament name, timestamp footer`,category:x,tier:1,header:{layout:x},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`wimbledon`},wimbledon:{id:`wimbledon`,name:`Wimbledon`,description:`Green/purple Grand Slam style with crest`,category:x,tier:1,header:{layout:x},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`wimbledon`},"australian-open":{id:`australian-open`,name:`Australian Open`,description:`Grand Slam with seedings + prize money footer`,category:x,tier:2,header:{layout:x},footer:{layout:b,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`australianOpen`},"wta-500":{id:`wta-500`,name:`WTA 500`,description:`Tour header with logos, seedings + prize money footer`,category:`tour`,tier:2,header:{layout:`wta-tour`},footer:{layout:b,showPageNumbers:!1,showTimestamp:!0},drawFormatPreset:y},"wta-1000":{id:`wta-1000`,name:`WTA 1000`,description:`Tour header with logos, full footer with officials`,category:`tour`,tier:2,header:{layout:`wta-tour`},footer:{layout:b,showPageNumbers:!1,showTimestamp:!0},drawFormatPreset:y},"atp-250":{id:`atp-250`,name:`ATP 250`,description:`ATP tour header, seedings + prize money footer with sign-off`,category:`tour`,tier:2,header:{layout:`wta-tour`},footer:{layout:b,showPageNumbers:!1,showTimestamp:!0},drawFormatPreset:y},"atp-finals":{id:`atp-finals`,name:`ATP Finals`,description:`Full official sign-off with signature lines`,category:`tour`,tier:3,header:{layout:x},footer:{layout:S,showTimestamp:!0},drawFormatPreset:y},"itf-junior":{id:`itf-junior`,name:`ITF Junior`,description:`ITF header with metadata row, officials sign-off footer`,category:`itf`,tier:3,header:{layout:`itf`},footer:{layout:S,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:y},"itf-pro-circuit":{id:`itf-pro-circuit`,name:`ITF Pro Circuit`,description:`ITF header, seedings + officials footer`,category:`itf`,tier:2,header:{layout:`itf`},footer:{layout:b,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:y},"national-federation":{id:`national-federation`,name:`National Federation`,description:`Detailed metadata header, full sign-off footer with ceremony date`,category:`national`,tier:3,header:{layout:`national-federation`},footer:{layout:S,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`usta`},"collegiate-ncaa":{id:`collegiate-ncaa`,name:`NCAA Collegiate`,description:`Mirrored bracket layout, team logos, minimal footer`,category:`collegiate`,tier:1,header:{layout:x},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:y},"club-basic":{id:`club-basic`,name:`Club Basic`,description:`Minimal header, standard footer — clean and simple`,category:`club`,tier:1,header:{layout:`minimal`},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:y}};function ee(e){return C[e]}function te(e){let t=Object.values(C);return e?t.filter(t=>t.category===e):t}function ne(e,t,n){let r=C[e]||C[`club-basic`];return{header:{...r.header,...t},footer:{...r.footer,...n}}}var w=`tournament-header`,T=`contacts`,E=`events`,D=`entry-info`,O=`venue-info`,k=`accommodation`,A=`transportation`,re=`hospitality`,ie=`medical`,ae=`regulations`,oe=`prize-money`,se=`officials`,ce=`sponsors`,le=`social-events`,ue=`custom-notes`;function j(e,t=!0,n){return{type:e,enabled:t,...n&&{title:n}}}var de=[j(w),j(T),j(E),j(D),j(O),j(k),j(A),j(re),j(ie),j(ae),j(oe),j(se),j(ce),j(le),j(ue)],fe={"itf-junior":{id:`itf-junior`,name:`ITF Junior`,description:`Full fact sheet with all sections — ITF header style`,category:`itf`,headerLayout:`itf`,sections:de},"itf-pro-circuit":{id:`itf-pro-circuit`,name:`ITF Pro Circuit`,description:`Pro circuit fact sheet — contacts, events, entry, venue, prize money, officials`,category:`itf`,headerLayout:`itf`,sections:[j(w),j(T),j(E),j(D),j(O),j(oe),j(se),j(ae),j(ue)]},"national-federation":{id:`national-federation`,name:`National Federation`,description:`Detailed national federation fact sheet with all logistics`,category:`national`,headerLayout:`national-federation`,sections:de},"tour-atp-wta":{id:`tour-atp-wta`,name:`ATP/WTA Tour`,description:`Tour-level fact sheet — contacts, events, prize money, officials, sponsors`,category:`tour`,headerLayout:`wta-tour`,sections:[j(w),j(T),j(E),j(oe),j(se),j(ce),j(k),j(A),j(le),j(ue)]},"club-basic":{id:`club-basic`,name:`Club Basic`,description:`Simple club-level fact sheet — essentials only`,category:`club`,headerLayout:`minimal`,sections:[j(w),j(T),j(E),j(D),j(O),j(ue)]}};function pe(e){return fe[e]}function me(e){let t=Object.values(fe);return e?t.filter(t=>t.category===e):t}function he(e,t){let n=e?.sides??[],r=[1,2].map(e=>n.find(t=>t?.sideNumber===e)?.drawPosition);if(r.some(Boolean))return r;let i=t?.[e?.roundNumber]?.pairedDrawPositions?.[(e?.roundPosition??0)-1];return Array.isArray(i)&&i.some(Boolean)?[i[0]??void 0,i[1]??void 0]:e?.drawPositions??[]}function ge(e){if(!e?.winningSide)return;let t=e.sides?.find(t=>t?.sideNumber===e.winningSide)?.drawPosition;if(t)return t;let n=(e.drawPositions??[]).filter(Boolean);return n.length===1?n[0]:e.drawPositions?.[e.winningSide-1]}function M(e){let t=e.roundMatchUps||{},n=e.roundProfile||{},r=Object.keys(t).map(Number).sort((e,t)=>e-t),i=new Map;for(let e of r)for(let n of t[e]||[])for(let e of n.sides||[])if(e?.drawPosition&&!i.has(e.drawPosition)){let t=e.entryStatus||e.participant?.entryStatus,n=t&&t!==`DIRECT_ACCEPTANCE`?t:void 0;i.set(e.drawPosition,{drawPosition:e.drawPosition,participantName:e.participant?.participantName||``,nationality:e.participant?.nationalityCode||``,seedValue:e.seedValue,entryStatus:n,isBye:e.bye===!0})}let a=[];for(let e of r)for(let r of t[e]||[])a.push({roundNumber:r.roundNumber,roundPosition:r.roundPosition,drawPositions:he(r,n),winnerDrawPosition:ge(r),score:r.score?.scoreStringSide1||``,winningSide:r.winningSide,matchUpStatus:r.matchUpStatus});let o={};for(let e of r){let t=n[e];o[e]=t?.abbreviatedRoundName||t?.roundName||`R${e}`}let s=r.length>0?Math.max(...r):0,c=[...i.values()].sort((e,t)=>e.drawPosition-t.drawPosition),l=e.stage===`QUALIFYING`,u=t[s]?.length||0,d=l||u>1;return{drawName:e.structureName||``,drawSize:c.length,drawType:`SINGLE_ELIMINATION`,totalRounds:s,noWinnerColumn:d,slots:c,matchUps:a,seedAssignments:(e.seedAssignments||[]).filter(e=>e.participantName).map(e=>({seedValue:e.seedValue,participantName:e.participantName||``,nationality:e.nationalityCode||``,seedingBasis:e.seedingBasis})),roundLabelMap:o}}function N(e,t){return e?.[0]?.structures?.find(e=>e.stage===t)}var _e={REGULAR:`helvetica`,BOLD:`helvetica`},P={NORMAL:`normal`,BOLD:`bold`,ITALIC:`italic`},F={TITLE:16,SUBTITLE:12,HEADING:10,BODY:8,SMALL:7,TINY:6},ve=new WeakMap,ye=[`normal`,`bold`,`italic`,`bolditalic`];function be(e,t){if(!t?.family||!t?.normal)return _e.REGULAR;for(let n of ye){let r=t[n]??t.normal,i=`${t.family}-${n}.ttf`;e.addFileToVFS(i,r),e.addFont(i,t.family,n)}return ve.set(e,t.family),t.family}function xe(e){return ve.get(e)??_e.REGULAR}var Se;function Ce(e){Se=e}function we(){return Se}function I(e){return Se?be(e,Se):_e.REGULAR}function L(e,t,n=P.NORMAL){e.setFont(xe(e),n),e.setFontSize(t)}function Te(e,n){let r=e.orientation;r===`auto`&&(r=n&&n>=32?`landscape`:`portrait`);let i=new t.default({orientation:r,format:e.pageSize,unit:`mm`});return e.font?be(i,e.font):I(i),i}function R(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=t;return{headerHeight:n,footerHeight:r,contentY:o.top+n,contentHeight:a-o.top-o.bottom-n-r,contentWidth:i-o.left-o.right,pageWidth:i,pageHeight:a}}function Ee(){return{pageSize:`a4`,orientation:`auto`,margins:{top:15,right:10,bottom:15,left:10}}}function z(e,t,n){switch(t.layout){case`grand-slam`:return De(e,t,n);case`itf`:return Oe(e,t,n);case`minimal`:return ke(e,t,n);case`wta-tour`:return Ae(e,t,n);case`national-federation`:return je(e,t,n);case`none`:return 0}}function De(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth(),a=i-r.right,o=r.top;L(e,18,P.BOLD),e.text(t.tournamentName.toUpperCase(),i/2,o,{align:`center`}),o+=7,t.subtitle&&(L(e,12,P.BOLD),e.text(t.subtitle.toUpperCase(),i/2,o,{align:`center`}),o+=6),L(e,F.BODY,P.NORMAL);let s=[];if(t.startDate){let e=t.endDate?`${t.startDate} - ${t.endDate}`:t.startDate;s.push(e)}return t.location&&s.push(t.location),s.forEach((t,n)=>{e.text(t,a,r.top+n*4,{align:`right`})}),o+=2,e.setDrawColor(0),e.setLineWidth(.5),e.line(r.left,o,a,o),o+=3,o-r.top}function Oe(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth()-r.right,a=r.top;L(e,F.TITLE,P.BOLD),e.text(t.tournamentName,r.left,a),a+=6,t.subtitle&&(L(e,F.SUBTITLE,P.BOLD),e.text(t.subtitle,r.left,a),a+=5),L(e,F.SMALL,P.NORMAL);let o=[];t.grade&&o.push(`Grade: ${t.grade}`),t.surface&&o.push(`Surface: ${t.surface}`),t.supervisor&&o.push(`Supervisor: ${t.supervisor}`),o.forEach((t,n)=>{e.text(t,i,r.top+n*3.5,{align:`right`})}),L(e,F.BODY,P.NORMAL);let s=[];return t.startDate&&s.push(t.startDate),t.location&&s.push(t.location),t.organizer&&s.push(t.organizer),s.length&&(e.text(s.join(` | `),r.left,a),a+=4),a+=1,e.setDrawColor(0),e.setLineWidth(.3),e.line(r.left,a,i,a),a+=3,a-r.top}function ke(e,t,n){let{margins:r}=n,i=r.top;L(e,F.SUBTITLE,P.BOLD),e.text(t.tournamentName,r.left,i);let a=e.getTextWidth(t.tournamentName);return t.subtitle&&(L(e,F.BODY,P.NORMAL),e.text(` - ${t.subtitle}`,r.left+a,i)),i+=6,i-r.top}function Ae(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth(),a=i-r.right,o=i/2,s=r.top;if(t.leftLogoBase64)try{e.addImage(t.leftLogoBase64,`PNG`,r.left,s-2,12,12)}catch{}if(t.rightLogoBase64)try{e.addImage(t.rightLogoBase64,`PNG`,a-12,s-2,12,12)}catch{}L(e,14,P.BOLD),e.text(t.tournamentName,o,s,{align:`center`}),s+=5;let c=[t.city,t.country].filter(Boolean).join(`, `);c&&(L(e,F.BODY,P.NORMAL),e.setTextColor(80),e.text(c.toUpperCase(),o,s,{align:`center`}),e.setTextColor(0),s+=4);let l=[];if(t.startDate){let e=t.endDate?`${t.startDate} - ${t.endDate}`:t.startDate;l.push(e)}if(t.prizeMoney){let e=t.currency?`${t.currency} ${t.prizeMoney}`:t.prizeMoney;l.push(e)}return t.surface&&l.push(t.surface),l.length&&(L(e,F.SMALL,P.NORMAL),e.text(l.join(` | `),o,s,{align:`center`}),s+=4),t.sectionLabel&&(L(e,F.SMALL,P.BOLD),e.text(t.sectionLabel.toUpperCase(),a,s,{align:`right`}),s+=3),s+=1,e.setDrawColor(0),e.setLineWidth(.3),e.line(r.left,s,a,s),s+=3,s-r.top}function je(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth()-r.right,a=r.top;if(t.rightLogoBase64)try{e.addImage(t.rightLogoBase64,`PNG`,i-14,a-2,14,14)}catch{}L(e,F.TITLE,P.BOLD),e.text(t.tournamentName,r.left,a),a+=6,t.subtitle&&(L(e,F.HEADING,P.BOLD),e.text(t.subtitle,r.left,a),a+=4),L(e,F.TINY,P.NORMAL),e.setTextColor(80);let o=[];return t.startDate&&o.push(t.startDate),t.organizer&&o.push(t.organizer),(t.city||t.country)&&o.push([t.city,t.country].filter(Boolean).join(`, `)),t.tournamentId&&o.push(`ID: ${t.tournamentId}`),t.grade&&o.push(`Grade: ${t.grade}`),t.chiefUmpire&&o.push(`Umpire: ${t.chiefUmpire}`),o.length&&(e.text(o.join(` | `),r.left,a),a+=3),e.setTextColor(0),a+=1,e.setDrawColor(0),e.setLineWidth(.3),e.line(r.left,a,i,a),a+=3,a-r.top}function Me(e){let t=e.person;if(t?.standardFamilyName){let e=t.standardGivenName||``;return e?t.standardFamilyName+`, `+e:t.standardFamilyName}return e.participantName||``}function Ne(e,t){return e.find(e=>e.participantRole===t)}function Pe(e,t){return e.find(e=>e.participantRole===`OFFICIAL`&&e.participantRoleResponsibilities?.some(e=>e.toUpperCase().includes(t.toUpperCase())))}function Fe(e){let t=(e.venues?.[0])?.addresses?.[0],n=[];return t?.city&&n.push(t.city),t?.state&&n.push(t.state),(t?.countryCode||e.hostCountryCode)&&n.push(t?.countryCode||e.hostCountryCode||``),n.join(`, `)}function Ie(e){return e.venues?.[0]?.addresses?.[0]?.city}function Le(e){return e.venues?.[0]?.addresses?.[0]?.countryCode||e.hostCountryCode}function Re(e){if(e.tournamentTier){let t=e.tournamentTier;return t.system?t.system+` `+(t.value||``):t.value}return e.tournamentLevel}function ze(e){let t=e.totalPrizeMoney?.[0];if(t)return String(t.amount)}function Be(e){return e.totalPrizeMoney?.[0]?.currencyCode}function Ve(e,t={}){let{layout:n=`itf`,sectionLabel:r,overrides:i}=t,a=e.participants||[],o=Ne(a,`DIRECTOR`),s=Pe(a,`REFEREE`),c=Pe(a,`CHIEF_UMPIRE`)||Pe(a,`UMPIRE`),l=Pe(a,`SUPERVISOR`)||s;return{layout:n,tournamentName:e.formalName||e.tournamentName||``,startDate:e.startDate,endDate:e.endDate,location:Fe(e),city:Ie(e),country:Le(e),surface:e.surfaceCategory,grade:Re(e),tournamentId:e.tournamentId,organizer:o?Me(o):void 0,supervisor:l?Me(l):void 0,chiefUmpire:c?Me(c):void 0,prizeMoney:ze(e),currency:Be(e),sectionLabel:r,...i}}function He(e,t={}){let{layout:n=`standard`,seedAssignments:r,prizeMoney:i,overrides:a}=t,o=(e.participants||[]).filter(e=>e.participantRole===`OFFICIAL`||e.participantRole===`DIRECTOR`).map(e=>({role:e.participantRoleResponsibilities?.[0]||e.participantRole||`Official`,name:Me(e)}));return{layout:n,showPageNumbers:!0,showTimestamp:!0,...o.length&&{signatureLines:o},...r?.length&&{seedAssignments:r},...i?.length&&{prizeMoney:i},...e.registrationProfile?.drawCeremonyDate&&{drawCeremonyDate:e.registrationProfile.drawCeremonyDate},...a}}var Ue=[`†`,`‡`,`§`,`¶`],We={ORGANISER_DISCRETION:`organiser discretion`,PROTECTED_RANKING:`protected ranking`,RANKING:`ranking`,RATING:`rating`},Ge=`RANKING`;function Ke(e){let t=new Map,n=e.map(e=>{let n=e?.seedingBasis;if(!n||n===Ge)return``;let r=t.get(n);if(r)return r;let i=Ue[t.size]??Ue[Ue.length-1];return t.set(n,i),i}),r=[...t.entries()].map(([e,t])=>`${t} Additional seed — ${We[e]??e.toLowerCase()}`);return{markers:n,footnotes:r,hasAnnotations:r.length>0}}function qe(e,t,n,r){switch(t.layout){case`standard`:return Ye(e,t,n,r);case`seedings`:case`seedings-table`:return Xe(e,t,n,r);case`prize-money`:return Ze(e,t,n,r);case`officials`:case`officials-signoff`:return Qe(e,t,n,r);case`combined-tour`:return $e(e,t,n,r);case`none`:return 0}}function Je(e){return Ke(e.seedAssignments||[]).footnotes.length}function B(e){switch(e.layout){case`standard`:return 8+(e.notes?.length||0)*3;case`seedings`:case`seedings-table`:return 12+Math.ceil((e.seedAssignments?.length||0)/2)*3+Je(e)*3;case`prize-money`:return 12+(e.prizeMoney?.length||0)*2.5;case`officials`:case`officials-signoff`:return 12+(e.signatureLines?.length||e.officials?.length||0)*5;case`combined-tour`:{let t=(e.seedAssignments?.length||0)+Je(e),n=e.prizeMoney?.length||0;return 16+Math.max(t*2.5,n*2.5)+(e.withdrawals?.length?6:0)}case`none`:return 0}}function Ye(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=a-o.bottom;if(L(e,F.TINY,P.NORMAL),e.setTextColor(120),t.showTimestamp&&e.text(`Generated ${new Date().toLocaleDateString()}`,o.left,c),t.showPageNumbers&&r!==void 0&&e.text(`Page ${r}`,s,c,{align:`right`}),e.setTextColor(0),c-=3,e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,c,s,c),c-=2,t.notes?.length){L(e,F.TINY,P.ITALIC),e.setTextColor(100);for(let n=t.notes.length-1;n>=0;n--)e.text(t.notes[n],o.left,c),c-=3;e.setTextColor(0)}return B(t)}function Xe(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=B(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=3,L(e,F.SMALL,P.BOLD),e.text(`Seeded Players`,o.left,l),l+=3;let u=t.seedAssignments||[],d=(s-o.left)/2,{markers:f,footnotes:p,hasAnnotations:m}=Ke(u);L(e,F.TINY,P.NORMAL);for(let t=0;t<u.length;t++){let n=t<Math.ceil(u.length/2)?0:1,r=n===0?t:t-Math.ceil(u.length/2),i=o.left+n*d,a=l+r*3,s=u[t],c=s.ranking?` (${s.ranking})`:``,p=f[t]?` ${f[t]}`:``;e.text(`${s.seedValue}. ${s.participantName}${c}${p}`,i,a)}let h=Math.ceil(u.length/2);if(l+=h*3+2,m){L(e,F.TINY,P.ITALIC);for(let t of p)e.text(t,o.left,l),l+=3;L(e,F.TINY,P.NORMAL)}return et(e,t,n,r,l),c}function Ze(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=B(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=3,L(e,F.SMALL,P.BOLD),e.text(`Prize Money`,o.left,l),l+=3;let u=t.prizeMoney||[];L(e,F.TINY,P.NORMAL);for(let t of u){let n=[t.round];t.amount&&n.push(t.amount),t.points&&n.push(`${t.points} pts`),e.text(n.join(` — `),o.left,l),l+=2.5}return l+=2,et(e,t,n,r,l),c}function Qe(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=B(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=4,t.drawCeremonyDate&&(L(e,F.TINY,P.ITALIC),e.setTextColor(80),e.text(`Draw ceremony: ${t.drawCeremonyDate}`,o.left,l),e.setTextColor(0),l+=3),t.releaseDate&&(L(e,F.TINY,P.ITALIC),e.setTextColor(80),e.text(`Released: ${t.releaseDate}`,o.left,l),e.setTextColor(0),l+=3);let u=t.signatureLines||(t.officials||[]).map(e=>({role:e})),d=(s-o.left)/Math.min(u.length,3);for(let t=0;t<u.length;t++){let n=t%3,r=Math.floor(t/3),i=o.left+n*d,a=l+r*10;L(e,F.TINY,P.ITALIC),e.setTextColor(100),e.text(u[t].role,i,a),e.setTextColor(0);let s=u[t].name;s&&(L(e,F.TINY,P.BOLD),e.text(s,i,a+3)),e.setDrawColor(150),e.setLineWidth(.15),e.line(i,a+5,i+d-8,a+5)}let f=Math.ceil(u.length/3);return l+=f*10+2,et(e,t,n,r,l),c}function $e(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=B(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=3;let u=s-o.left,d=o.left,f=o.left+u*.55,p=l,m=l,h=t.seedAssignments||[];if(h.length){let{markers:t,footnotes:n,hasAnnotations:r}=Ke(h);if(L(e,F.SMALL,P.BOLD),e.text(`Seeded Players`,d,p),p+=3,L(e,F.TINY,P.NORMAL),h.forEach((n,r)=>{let i=n.ranking?` (${n.ranking})`:``,a=t[r]?` ${t[r]}`:``;e.text(`${n.seedValue}. ${n.participantName}${i}${a}`,d,p),p+=2.5}),r){L(e,F.TINY,P.ITALIC);for(let t of n)e.text(t,d,p),p+=2.5;L(e,F.TINY,P.NORMAL)}}let g=t.prizeMoney||[];if(g.length){L(e,F.SMALL,P.BOLD),e.text(`Prize Money`,f,m),m+=3,L(e,F.TINY,P.NORMAL);for(let t of g){let n=[t.round];t.amount&&n.push(t.amount),t.points&&n.push(`${t.points} pts`),e.text(n.join(` — `),f,m),m+=2.5}}if(l=Math.max(p,m)+2,t.withdrawals?.length){L(e,F.TINY,P.ITALIC),e.setTextColor(80);let n=t.withdrawals.map(e=>e.reason?`${e.name} (${e.reason})`:e.name).join(`, `);e.text(`Withdrawals: ${n}`,o.left,l,{maxWidth:u}),e.setTextColor(0),l+=3}return t.luckyLosers?.length&&(L(e,F.TINY,P.ITALIC),e.setTextColor(80),e.text(`Lucky Losers: ${t.luckyLosers.join(`, `)}`,o.left,l,{maxWidth:u}),e.setTextColor(0),l+=3),t.officials?.length&&(L(e,F.TINY,P.NORMAL),e.setTextColor(80),e.text(t.officials.join(` | `),o.left,l),e.setTextColor(0),l+=3),et(e,t,n,r,l),c}function et(e,t,n,r,i){let a=e.internal.pageSize.getWidth(),o=e.internal.pageSize.getHeight(),{margins:s}=n,c=a-s.right,l=o-s.bottom+2;if(L(e,F.TINY,P.NORMAL),e.setTextColor(120),t.showTimestamp&&e.text(`Generated ${new Date().toLocaleDateString()}`,s.left,l),t.releaseDate){let n=t.showTimestamp?s.left+50:s.left;e.text(`Released: ${t.releaseDate}`,n,l)}t.showPageNumbers&&r!==void 0&&e.text(`Page ${r}`,c,l,{align:`right`}),e.setTextColor(0)}var tt=5,nt=2.5;function rt(e,t,n,r){let i=t.seedAssignments;if(!i.length)return r;let a=n.page.margins,o=e.internal.pageSize.getWidth()-a.left-a.right;L(e,6,P.BOLD),e.text(`Seeded players`,a.left,r),e.setDrawColor(150),e.setLineWidth(.15),e.line(a.left,r+1,a.left+o*.5,r+1),r+=3;let s=Math.ceil(i.length/2),c=i.slice(0,s),l=i.slice(s),u=o*.25,d=r;for(let t=0;t<Math.max(c.length,l.length);t++)c[t]&&it(e,c[t],a.left,d,u),l[t]&&it(e,l[t],a.left+u+4,d,u),d+=nt;return d}function it(e,t,n,r,i){L(e,tt,P.BOLD),e.text(`${t.seedValue}`,n+4,r,{align:`right`}),L(e,tt,P.NORMAL),e.text(t.participantName,n+6,r),e.setTextColor(100),e.text(t.nationality,n+45,r),e.setTextColor(0)}function at(e){return e===0?0:4+Math.ceil(e/2)*nt}function V(e){if(!e)return``;if(e.person){let{standardFamilyName:t,standardGivenName:n}=e.person;if(t)return`${t.toUpperCase()}, ${n||``}`.trim()}return e.participantName||``}function H(e){return e&&e.person?.nationalityCode||``}function ot(e){return e?`[${e}]`:``}function st(e){return e?{DIRECT_ACCEPTANCE:`DA`,WILDCARD:`WC`,LUCKY_LOSER:`LL`,QUALIFIER:`Q`,ALTERNATE:`A`,SPECIAL_EXEMPT:`SE`}[e]||e:``}function ct(e){return e?typeof e==`string`?e:e.scoreStringSide1?e.scoreStringSide1:``:``}function lt(e){return e?new Date(e+`T00:00:00`).toLocaleDateString(`en-US`,{day:`2-digit`,month:`short`,year:`numeric`}):``}function ut(e){if(!e)return``;let[t,n]=e.split(`:`),r=parseInt(t),i=r>=12?`PM`:`AM`,a=r;return r===0?a=12:r>12&&(a=r-12),`${a}:${n} ${i}`}function dt(e){return e?e.split(/\s+/).map(e=>e[0]).join(``).toUpperCase():``}function ft(e,t){let n=t-e+1;return n===1?`F`:n===2?`SF`:n===3?`QF`:`R${2**n}`}function pt(e,t){return e.find(e=>e?.sideNumber===t)??e[t-1]}function mt(e){let{matchUps:t=[],venues:n=[],scheduledDate:r=``}=e,i=new Set;n.forEach(e=>{(e.courts||[]).forEach(e=>{i.add(e.courtName||`Court ${e.courtId}`)})});let a=new Map;n.forEach(e=>{(e.courts||[]).forEach(e=>{a.set(e.courtId,e.courtName||`Court ${e.courtId}`)})});let o=t.filter(e=>e.schedule?.scheduledDate===r||!r),s=new Map;for(let e of o){let t=e.schedule||{},n=t.scheduledTime||`00:00`,r=t.venueCourtId||t.courtId||``,o=a.get(r)||r;o&&i.add(o);let c=e.sides||[],l=ht(pt(c,1)),u=ht(pt(c,2)),d={courtName:o,scheduledTime:ut(n),eventName:e.eventName||e.event?.eventName||``,eventAbbr:dt(e.eventName||e.event?.eventName||``),roundName:e.roundName||``,side1:l,side2:u,score:ct(e.score),matchUpStatus:e.matchUpStatus,notBeforeTime:t.notBeforeTime?ut(t.notBeforeTime):void 0},f=t.notBeforeTime||n;s.has(f)||s.set(f,[]),s.get(f).push(d)}let c=[...s.keys()].sort().map(e=>({time:e,label:ut(e)||`TBD`,matches:s.get(e)||[]}));return{scheduledDate:r,courts:[...i].sort(),timeSlots:c}}function ht(e){if(!e)return{name:``,nationality:``};let t=e.participant;return t?{name:V(t),nationality:H(t)}:{name:``,nationality:``}}function gt(e){let{participants:t=[],eventEntries:n=[]}=e,r=new Map;for(let{eventName:e,entries:t}of n)for(let n of t){let t=n.participantId;r.has(t)||r.set(t,{events:[],entryStatus:``,seedValue:void 0});let i=r.get(t);if(i.events.push(e),n.entryStatus&&(i.entryStatus=n.entryStatus),n.seedValue!==void 0&&i.seedValue===void 0){let e=Number(n.seedValue);Number.isNaN(e)||(i.seedValue=e)}}return t.filter(e=>e.participantType===`INDIVIDUAL`).map(e=>{let t=r.get(e.participantId);return{name:V(e),nationality:H(e),ranking:_t(e),seedValue:t?.seedValue,entryStatus:st(t?.entryStatus||``),events:t?.events||[],signedIn:e.signInStatus===`SIGNED_IN`}}).sort((e,t)=>e.name.localeCompare(t.name))}function _t(e){for(let t of[e.rankings,e.ratings])if(t&&typeof t==`object`)for(let e of Object.values(t)){let t=e?.[0]?.scaleValue;if(t!=null&&t!==``)return String(t)}return``}function vt(e){let{matchUps:t=[],venues:n=[]}=e,r=new Map;n.forEach(e=>{(e.courts||[]).forEach(t=>{r.set(t.courtId,{courtName:t.courtName||`Court ${t.courtId}`,venueName:e.venueName||``})})});let i=new Map;for(let e of t){let t=e.schedule?.venueCourtId||e.schedule?.courtId;t&&(i.has(t)||i.set(t,[]),i.get(t).push(e))}let a=[];for(let[e,t]of i){let n=r.get(e)||{courtName:e,venueName:``};t.sort((e,t)=>{let n=e.schedule?.scheduledTime||``,r=t.schedule?.scheduledTime||``;return n.localeCompare(r)});let i=new Set([`COMPLETED`,`RETIRED`,`WALKOVER`,`DEFAULTED`,`ABANDONED`]),o=t.find(e=>e.matchUpStatus===`IN_PROGRESS`),s=t.filter(e=>!i.has(e.matchUpStatus)),c=t.filter(e=>i.has(e.matchUpStatus)),l=o||s[0]||c.at(-1),u;o?u=s[0]:s.length>1&&(u=s[1]),a.push({courtName:n.courtName,venueName:n.venueName,currentMatch:l?yt(l):void 0,nextMatch:u?yt(u):void 0})}return a.sort((e,t)=>e.courtName.localeCompare(t.courtName))}function yt(e){let t=e.sides||[];return{eventName:e.eventName||e.event?.eventName||``,roundName:e.roundName||``,scheduledTime:e.schedule?.scheduledTime?ut(e.schedule.scheduledTime):void 0,side1:bt(pt(t,1)),side2:bt(pt(t,2))}}function bt(e){return e?.participant?{name:V(e.participant),nationality:H(e.participant)}:{name:`TBD`,nationality:``}}function xt(e,t={}){let n=e.courts.length>=4,r={pageSize:t.page?.pageSize||`a4`,orientation:t.page?.orientation||(n?`landscape`:`portrait`),margins:t.page?.margins||{top:12,right:8,bottom:10,left:8}},i=Te(r),a=t.footer||{layout:`standard`,showTimestamp:!0,showPageNumbers:!0},o=B(a)+(t.notes?.length?t.notes.length*3:0),s=r.margins.top;if(t.header){let e=z(i,t.header,r);s=r.margins.top+e}t.alertBanner&&(s=St(i,t.alertBanner,r,s)),Ct(i,e,r,s,t);let c=i.internal.pageSize.getHeight();if(t.notes?.length){let e=c-r.margins.bottom-o+2;L(i,F.TINY,P.ITALIC),i.setTextColor(80);for(let n of t.notes)i.text(n,r.margins.left,e),e+=3;i.setTextColor(0)}if(t.officials?.length){let e=c-r.margins.bottom-6;Dt(i,t.officials,r,e)}return qe(i,a,r,1),i}function St(e,t,n,r){let{margins:i}=n,a=e.internal.pageSize.getWidth(),o=a-i.left-i.right;return e.setFillColor(200,30,30),e.rect(i.left,r,o,7,`F`),L(e,F.SMALL,P.BOLD),e.setTextColor(255,255,255),e.text(t,a/2,r+4.5,{align:`center`}),e.setTextColor(0),r+9}function Ct(e,t,r,i,a){let{margins:o}=r,s=t.courts,c=a.cellStyle===`compact`,l=[{header:``,dataKey:`slot`}];for(let e of s)l.push({header:e,dataKey:e});let u=[];t.timeSlots.forEach((e,t)=>{let n=[],r=wt(e,t);n.push({content:r,styles:{fontStyle:`bold`,valign:`top`,cellWidth:12}});for(let t of s){let r=e.matches.filter(e=>e.courtName===t),i=r.length>0?r.map(e=>Tt(e,c)).join(`
|
|
2
2
|
---
|
|
3
3
|
`):``;n.push(i)}u.push(n)}),(0,n.default)(e,{startY:i,head:[l.map(e=>e.header)],body:u,styles:{fontSize:c?6:6.5,cellPadding:c?1.5:2,lineWidth:.3,lineColor:[80,80,80],valign:`top`,overflow:`linebreak`},headStyles:{fillColor:[255,255,255],textColor:[0,0,0],fontStyle:`bold`,fontSize:7,halign:`center`,lineWidth:.5,lineColor:[0,0,0]},columnStyles:{0:{cellWidth:14,fontStyle:`bold`}},alternateRowStyles:{fillColor:[252,252,252]},margin:{left:o.left,right:o.right},tableWidth:`auto`,didParseCell:t=>{if(t.column.index>0&&t.section===`body`){let n=e.internal.pageSize.getWidth()-o.left-o.right-14;t.cell.styles.cellWidth=n/s.length,t.cell.styles.halign=`center`,t.cell.styles.valign=`middle`}}})}function wt(e,t){return`${t+1}`}function Tt(e,t){let n=[];e.notBeforeTime?n.push(`NB ${e.notBeforeTime}`):e.scheduledTime&&n.push(e.scheduledTime),(e.eventAbbr||e.roundName)&&n.push(`${e.eventAbbr} ${e.roundName}`.trim());let r=Et(e.side1,t);r&&n.push(r),n.push(`vs.`);let i=Et(e.side2,t);return i&&n.push(i),e.score?n.push(e.score):e.matchUpStatus===`IN_PROGRESS`&&n.push(`In progress`),n.join(`
|
|
4
4
|
`)}function Et(e,t){return e.name?t||e.nationality?`${e.name} (${e.nationality})`:e.name:`TBD`}function Dt(e,t,n,r){let{margins:i}=n,a=e.internal.pageSize.getWidth();e.setDrawColor(120),e.setLineWidth(.2),e.line(i.left,r-2,a-i.right,r-2),L(e,F.TINY,P.NORMAL);let o=(a-i.left-i.right)/t.length;t.forEach((t,n)=>{let a=i.left+n*o;L(e,F.TINY,P.ITALIC),e.setTextColor(100),e.text(t.role,a,r),L(e,F.TINY,P.BOLD),e.setTextColor(0),e.text(t.name,a,r+3)})}function Ot(e,t,n=15){let r=e.internal.pageSize.getWidth(),i=n;L(e,F.TITLE,P.BOLD),e.text(t.tournamentName,15,i),i+=7,t.subtitle&&(L(e,F.SUBTITLE,P.BOLD),e.text(t.subtitle,15,i),i+=6),L(e,F.BODY,P.NORMAL);let a=[];if(t.startDate){let e=t.endDate?`${t.startDate} - ${t.endDate}`:t.startDate;a.push(e)}return t.location&&a.push(t.location),t.organizer&&a.push(t.organizer),a.forEach((t,i)=>{e.text(t,r-15,n+i*4,{align:`right`})}),i+=2,e.setDrawColor(0),e.setLineWidth(.5),e.line(15,i,r-15,i),i+=5,i}function U(e,t,n){let r=e.internal.pageSize.getWidth(),i=e.internal.pageSize.getHeight();L(e,F.SMALL,P.ITALIC),e.setTextColor(120),e.text(t,15,i-10),n!==void 0&&e.text(`Page ${n}`,r-15,i-10,{align:`right`}),e.setTextColor(0)}var kt={compact:{styles:{fontSize:7,cellPadding:1.5,lineWidth:.1,lineColor:[200,200,200]},headStyles:{fillColor:[50,50,50],textColor:[255,255,255],fontStyle:`bold`,fontSize:7},alternateRowStyles:{fillColor:[245,245,245]}},schedule:{styles:{fontSize:7,cellPadding:2,lineWidth:.2,lineColor:[180,180,180],valign:`top`},headStyles:{fillColor:[30,60,120],textColor:[255,255,255],fontStyle:`bold`,fontSize:8,halign:`center`},alternateRowStyles:{fillColor:[240,244,250]}},playerList:{styles:{fontSize:8,cellPadding:2,lineWidth:.1,lineColor:[200,200,200]},headStyles:{fillColor:[40,80,40],textColor:[255,255,255],fontStyle:`bold`,fontSize:8},alternateRowStyles:{fillColor:[242,248,242]}},report:{styles:{fontSize:8,cellPadding:2,lineWidth:.1,lineColor:[200,200,200]},headStyles:{fillColor:[35,55,90],textColor:[255,255,255],fontStyle:`bold`,fontSize:8},alternateRowStyles:{fillColor:[244,246,250]}},courtCard:{styles:{fontSize:14,cellPadding:6,lineWidth:.3,lineColor:[100,100,100],halign:`center`},headStyles:{fillColor:[20,20,80],textColor:[255,255,255],fontStyle:`bold`,fontSize:16}}};function At(e,r={}){let{header:i,includeRanking:a=!0,includeEvents:o=!0}=r,s=new t.default({orientation:`portrait`,format:`a4`});I(s);let c=15;i&&(c=Ot(s,{...i,subtitle:i.subtitle||`Player List`}));let l=[{header:`#`,dataKey:`index`},{header:`Name`,dataKey:`name`},{header:`Nat.`,dataKey:`nationality`}];a&&l.push({header:`Rank`,dataKey:`ranking`}),l.push({header:`Seed`,dataKey:`seed`}),l.push({header:`Entry`,dataKey:`entryStatus`}),o&&l.push({header:`Events`,dataKey:`events`});let u=e.map((e,t)=>({index:t+1,name:e.name,nationality:e.nationality,ranking:e.ranking||``,seed:e.seedValue?.toString()||``,entryStatus:e.entryStatus,events:e.events.join(`, `)}));return(0,n.default)(s,{...kt.playerList,startY:c,columns:l,body:u,columnStyles:{index:{cellWidth:10,halign:`center`},name:{cellWidth:`auto`,fontStyle:`bold`},nationality:{cellWidth:15,halign:`center`},ranking:{cellWidth:15,halign:`center`},seed:{cellWidth:12,halign:`center`},entryStatus:{cellWidth:15,halign:`center`},events:{cellWidth:`auto`}},didDrawPage:e=>{U(s,`Generated ${new Date().toLocaleDateString()}`,e.pageNumber)}}),s}function jt(e,r={}){let{header:i,eventName:a,signInDate:o,signInTime:s}=r,c=new t.default({orientation:`portrait`,format:`a4`});I(c);let l=15;if(i&&(l=Ot(c,{...i,subtitle:i.subtitle||`Player Sign-In Sheet`})),a||o){L(c,F.BODY,P.NORMAL);let e=[];a&&e.push(`Event: ${a}`),o&&e.push(`Date: ${o}`),s&&e.push(`Time: ${s}`),c.text(e.join(` | `),15,l),l+=6}let u=[{header:`#`,dataKey:`index`},{header:`Player Name`,dataKey:`name`},{header:`Nat.`,dataKey:`nationality`},{header:`Rank`,dataKey:`ranking`},{header:`Seed`,dataKey:`seed`},{header:`Entry`,dataKey:`entry`},{header:`Signature`,dataKey:`signature`},{header:`Time`,dataKey:`time`}],d=e.map((e,t)=>({index:t+1,name:e.name,nationality:e.nationality,ranking:e.ranking||``,seed:e.seedValue?.toString()||``,entry:e.entryStatus,signature:``,time:``}));return(0,n.default)(c,{startY:l,columns:u,body:d,styles:{fontSize:8,cellPadding:1.5,lineWidth:.2,lineColor:[150,150,150]},headStyles:{fillColor:[40,60,100],textColor:[255,255,255],fontStyle:`bold`,fontSize:7,cellPadding:2},alternateRowStyles:{fillColor:[245,247,250]},columnStyles:{index:{cellWidth:10,halign:`center`},name:{cellWidth:`auto`,fontStyle:`bold`},nationality:{cellWidth:14,halign:`center`},ranking:{cellWidth:14,halign:`center`},seed:{cellWidth:14,halign:`center`},entry:{cellWidth:14,halign:`center`},signature:{cellWidth:35},time:{cellWidth:15}}}),c}function Mt(e,n={}){let{tournamentName:r=``,pageSize:i=`a5`,cardsPerPage:a=1}=n,o=new t.default({orientation:`landscape`,format:i});return I(o),e.forEach((e,t)=>{t>0&&o.addPage(),Nt(o,e,r,a)}),o}function Nt(e,t,r,i){let a=e.internal.pageSize.getWidth(),o=a/2,s=15;if(r&&(L(e,F.BODY,P.NORMAL),e.setTextColor(100),e.text(r,o,s,{align:`center`}),e.setTextColor(0),s+=8),L(e,28,P.BOLD),e.text(t.courtName,o,s,{align:`center`}),s+=5,t.venueName&&(L(e,F.HEADING,P.NORMAL),e.setTextColor(100),e.text(t.venueName,o,s,{align:`center`}),e.setTextColor(0)),s+=8,e.setDrawColor(0),e.setLineWidth(1),e.line(30,s,a-30,s),s+=8,t.currentMatch&&(L(e,F.HEADING,P.BOLD),e.setTextColor(30,60,120),e.text(`NOW PLAYING`,o,s,{align:`center`}),e.setTextColor(0),s+=6,L(e,F.BODY,P.ITALIC),e.text(`${t.currentMatch.eventName} - ${t.currentMatch.roundName}`,o,s,{align:`center`}),s+=8,(0,n.default)(e,{startY:s,margin:{left:25,right:25},theme:`plain`,styles:{halign:`center`,fontSize:16,cellPadding:4},body:[[{content:`${t.currentMatch.side1.name} (${t.currentMatch.side1.nationality})`,styles:{fontStyle:`bold`}}],[{content:`vs.`,styles:{fontSize:12,textColor:[120,120,120]}}],[{content:`${t.currentMatch.side2.name} (${t.currentMatch.side2.nationality})`,styles:{fontStyle:`bold`}}]]}),s=e.lastAutoTable?.finalY||s+40,s+=8),t.nextMatch){e.setDrawColor(180),e.setLineWidth(.3),e.line(50,s,a-50,s),s+=6,L(e,F.BODY,P.BOLD),e.setTextColor(100);let n=t.nextMatch.scheduledTime?`UP NEXT (${t.nextMatch.scheduledTime})`:`UP NEXT`;e.text(n,o,s,{align:`center`}),e.setTextColor(0),s+=5,L(e,F.BODY,P.NORMAL),e.text(`${t.nextMatch.eventName} - ${t.nextMatch.roundName}`,o,s,{align:`center`}),s+=5,L(e,F.HEADING,P.NORMAL),e.text(`${t.nextMatch.side1.name} vs. ${t.nextMatch.side2.name}`,o,s,{align:`center`})}}function Pt(e,n={}){let{cardsPerPage:r=2,includeScoreBoxes:i=!0}=n,a=new t.default({orientation:`landscape`,format:`a5`});return I(a),e.forEach((e,t)=>{t>0&&(r===1||t%r===0)&&a.addPage();let n=r===2&&t%2==1?a.internal.pageSize.getHeight()/2:5;Ft(a,e,n,i)}),a}function Ft(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=i/2,o=n;if(t.tournamentName&&(L(e,F.BODY,P.NORMAL),e.setTextColor(100),e.text(t.tournamentName,a,o,{align:`center`}),e.setTextColor(0),o+=5),L(e,F.HEADING,P.BOLD),e.text(`${t.eventName} - ${t.roundName}`,a,o,{align:`center`}),o+=5,t.courtName||t.scheduledTime){L(e,F.BODY,P.NORMAL);let n=[];t.courtName&&n.push(`Court: ${t.courtName}`),t.scheduledTime&&n.push(`Time: ${t.scheduledTime}`),e.text(n.join(` `),a,o,{align:`center`}),o+=5}if(e.setDrawColor(0),e.setLineWidth(.5),e.line(10,o,i-10,o),o+=6,It(e,t.side1,10,o,i),o+=8,L(e,F.BODY,P.ITALIC),e.setTextColor(120),e.text(`vs.`,a,o,{align:`center`}),e.setTextColor(0),o+=6,It(e,t.side2,10,o,i),o+=8,r){e.setDrawColor(0),e.setLineWidth(.5),e.line(10,o,i-10,o),o+=4,L(e,F.SMALL,P.BOLD),e.text(`Score:`,10,o);for(let t=0;t<5;t++){let n=28+t*15;e.rect(n,o-4,12,8),L(e,F.TINY,P.NORMAL),e.setTextColor(150),e.text(`Set ${t+1}`,n+6,o-5,{align:`center`}),e.setTextColor(0)}o+=14,L(e,F.SMALL,P.NORMAL),e.text(`Umpire:`,10,o),e.setDrawColor(150),e.setLineWidth(.3),e.line(30,o,90,o),e.text(`Signature:`,i-10-70,o),e.line(i-10-40,o,i-10,o)}}function It(e,t,n,r,i){L(e,14,P.BOLD);let a=t.seedValue?`[${t.seedValue}] `:``;e.text(`${a}${t.name}`,n,r),L(e,F.HEADING,P.NORMAL),e.setTextColor(80),e.text(t.nationality,i-n,r,{align:`right`}),e.setTextColor(0)}function Lt(e){let{drawDefinition:t,participants:n=[]}=e;if(!t)return zt();let i=e.structureId?t.structures?.find(t=>t.structureId===e.structureId):t.structures?.[0];if(!i)return zt();let a=new Map;n.forEach(e=>a.set(e.participantId,e));let o=i.positionAssignments||[],s=i.matchUps||[],c=s.reduce((e,t)=>Math.max(e,t.roundNumber||0),0),l=e.structureId?o.length:t.drawSize||o.length,u=e.structureId?c:Math.log2(l),d=i.seedAssignments||[],f=o.map(e=>{let t=e.participantId?a.get(e.participantId):void 0,n=d.find(t=>t.participantId===e.participantId);return{drawPosition:e.drawPosition,participantName:t?V(t):``,nationality:t?H(t):``,seedValue:n?.seedValue,entryStatus:e.entryStatus,isBye:e.bye===!0}}),{roundProfile:p}=r.matchUpGovernor.getRoundMatchUps({matchUps:s})??{},m=(i.matchUps||[]).map(e=>({roundNumber:e.roundNumber,roundPosition:e.roundPosition,drawPositions:he(e,p),winnerDrawPosition:ge(e),score:ct(e.score),winningSide:e.winningSide,matchUpStatus:e.matchUpStatus})),h=d.filter(e=>e.participantId).map(e=>{let t=a.get(e.participantId);return{seedValue:e.seedValue,participantName:t?V(t):``,nationality:t?H(t):``,seedingBasis:e.seedingBasis}}).sort((e,t)=>e.seedValue-t.seedValue),g=Rt(m,u,e.processedMatchUps);return{drawName:t.drawName||``,drawSize:l,drawType:t.drawType||`SINGLE_ELIMINATION`,totalRounds:u,slots:f,matchUps:m,seedAssignments:h,roundLabelMap:g}}function W(e,t){return ft(e,t)}function Rt(e,t,n){if(n?.length){let e={};for(let t of n)t.roundNumber&&!e[t.roundNumber]&&(e[t.roundNumber]=t.abbreviatedRoundName||t.roundName||`R${t.roundNumber}`);if(Object.keys(e).length>0)return e}let r=new Map;for(let t of e)r.set(t.roundNumber,(r.get(t.roundNumber)||0)+1);let i=[...r.keys()].sort((e,t)=>e-t);if(i.length>0&&i.every((e,t)=>{if(t===0)return!0;let n=r.get(i[t-1])||0;return(r.get(e)||0)<=Math.ceil(n/2)})){let e={};for(let n of i)e[n]=ft(n,t);return e}let a={};for(let e of i)a[e]=`R${e}`;return a}function zt(){return{drawName:``,drawSize:0,drawType:``,totalRounds:0,slots:[],matchUps:[],seedAssignments:[]}}function Bt(e,t){if(e.isBye)return`Bye`;if(!e.participantName)return``;let n=Vt(e.participantName,t),r=Ht(e.nationality,t),i=e.seedValue?Ut(e.seedValue,t):``,a=e.entryStatus?Gt(e.entryStatus,t):``,o=[];return t.seedPosition===`before-position`&&i&&o.push(i),o.push(n),t.seedPosition===`after-name`&&i&&o.push(i),r&&o.push(r),t.seedPosition===`after-country`&&i&&o.push(i),a&&o.push(a),o.join(` `)}function G(e,t){if(e.isBye)return{name:`Bye`,nationality:``};if(!e.participantName)return{name:``,nationality:``};let n=Vt(e.participantName,t),r=e.seedValue?Ut(e.seedValue,t):``,i=e.entryStatus?Gt(e.entryStatus,t):``,a=[];return t.seedPosition===`before-position`&&r&&a.push(r),a.push(n),t.seedPosition===`after-name`&&r&&a.push(r),t.seedPosition===`after-country`&&r&&a.push(r),i&&a.push(i),{name:a.join(` `),nationality:e.nationality||``}}function Vt(e,t){if(t.nameFormat===`LAST First`)return e.replace(`,`,``);if(t.nameFormat===`F. LAST`){let t=e.match(/^([^,]+),\s*(.+)/);if(t)return`${t[2][0]}. ${t[1]}`}return e}function Ht(e,t){if(!e)return``;switch(t.nationalityFormat){case`parens`:return`(${e})`;case`hyphen`:return`-${e}`;default:return e}}function Ut(e,t){switch(t.seedFormat){case`parens`:return`(${e})`;case`bare`:return`${e}`;default:return`[${e}]`}}var Wt={DIRECT_ACCEPTANCE:``,WILDCARD:`WC`,QUALIFIER:`Q`,LUCKY_LOSER:`LL`,SPECIAL_EXEMPT:`SE`,ALTERNATE:`ALT`,JUNIOR_EXEMPT:`JE`,ORGANISER_ACCEPTANCE:`OA`};function Gt(e,t){if(!e)return``;let n=Wt[e];if(n===void 0)return e;if(!n)return``;switch(t.entryFormat){case`parens`:return`(${n})`;case`hyphen`:return`-${n}`;default:return n}}function K(e,t){if(!e)return``;switch(t.gameScoreSeparator){case`/`:return e.replace(/(\d)-(\d)/g,`$1/$2`);case`none`:return e.replace(/(\d)-(\d)/g,`$1$2`);default:return e}}function Kt(e,t,n){let r=n||Math.log2(e),i=(t.contentHeight-9)/e,a=i<3.5,o=a?.8:1.5,s=r,c=o*(s+1),l=i<2,u=a?.18:.3,d=Math.min(a?38:65,t.contentWidth*u),f=t.contentWidth-d-c,p=l?8:0,m=f-p,h=Math.min(65,Math.max(8,m/Math.max(1,s))),g=h+p,_=F.SMALL;return i<2.5?_=5:i<3.5&&(_=F.TINY),{lineHeight:i,roundColumnWidth:h,firstRoundWidth:d,secondRoundWidth:g,connectorGap:o,fontSize:_,scoreFontSize:a?5:F.TINY}}function q(e,t,n,r,i=0,a){qt(t.matchUps)?Jt(e,t,n,r):sn(e,t,n,r,i,a)}function qt(e){let t=new Map;for(let n of e)t.set(n.roundNumber,(t.get(n.roundNumber)||0)+1);let n=[...t.keys()].sort((e,t)=>e-t);for(let e=1;e<n.length;e++){let r=t.get(n[e-1])||0;if((t.get(n[e])||0)>=r)return!0}return!1}function Jt(e,t,n,r){let i=n.page.margins,a=r.contentY+9,o=r.contentHeight-9,s=Yt(t.matchUps),c=[...s.keys()].sort((e,t)=>e-t),l=c.length,u=new Map(t.slots.map(e=>[e.drawPosition,e])),d=Xt(c,s),{feedConfig:f,connectorGap:p,firstRoundWidth:m,roundColumnWidth:h,fontSize:g,scoreFontSize:_}=Zt(o,s,c,l,r),v=e=>e===0?i.left:i.left+m+p+(e-1)*(h+p);on(e,c,t,f,n,r,v,l,h);let y=Qt(c,l,s,d,a,o,f.lineHeight);$t(e,c,l,s,y,d,u,f,n,v,m,h,p,_),an(e,t,c,l,s,y,u,v,a,o,h,g,_,n)}function Yt(e){let t=new Map;for(let n of e)t.has(n.roundNumber)||t.set(n.roundNumber,[]),t.get(n.roundNumber).push(n);for(let[,e]of t)e.sort((e,t)=>e.roundPosition-t.roundPosition);return t}function Xt(e,t){let n=new Set;for(let r=1;r<e.length;r++){let i=t.get(e[r-1])?.length||0;(t.get(e[r])?.length||0)>=i&&n.add(e[r])}return n}function Zt(e,t,n,r,i){let a=1.5,o=e/((t.get(n[0])?.length||1)*2),s=o<3.5,c=Math.min(s?50:60,i.contentWidth*.25),l=i.contentWidth-c-a*(r+1),u=Math.max(8,l/Math.max(1,r)),d=F.SMALL;o<2.5?d=5:o<3.5&&(d=F.TINY);let f=s?5:F.TINY;return{feedConfig:{lineHeight:o,roundColumnWidth:u,firstRoundWidth:c,secondRoundWidth:u,connectorGap:a,fontSize:d,scoreFontSize:f},connectorGap:a,firstRoundWidth:c,roundColumnWidth:u,fontSize:d,scoreFontSize:f}}function Qt(e,t,n,r,i,a,o){let s=new Map;for(let c=0;c<t;c++){let t=e[c],l=n.get(t)?.length||0;if(r.has(t)){let n=e[c-1],r=(s.get(n)||[]).slice(0,l).map(e=>e.bottomY-e.topY>o*2?{topY:e.midY-o,bottomY:e.midY+o,midY:e.midY}:{topY:e.topY,bottomY:e.bottomY,midY:e.midY});s.set(t,r)}else if(c===0){let e=a/(l*2+1),n=[];for(let t=0;t<l;t++){let r=i+e*(t*2+1),a=i+e*(t*2+2);n.push({topY:r,bottomY:a,midY:(r+a)/2})}s.set(t,n)}else{let n=e[c-1],r=s.get(n)||[],i=[];for(let e=0;e<l;e++){let t=r[e*2],n=r[e*2+1];if(t&&n){let e=t.midY,r=n.midY;i.push({topY:e,bottomY:r,midY:(e+r)/2})}}s.set(t,i)}}return s}function $t(e,t,n,r,i,a,o,s,c,l,u,d,f,p){for(let m=0;m<n;m++){let h=t[m],g=r.get(h)||[],_=i.get(h)||[],v=l(m),y=m===0?u:d,b=a.has(h),x=v+y,S=m<n-1&&a.has(t[m+1]);for(let i=0;i<g.length;i++){let a=g[i],h=_[i];if(h){if(e.setDrawColor(40),e.setLineWidth(.25),m===0?en(e,a,h,o,c,s,v,u,x,f,S):b?tn(e,a,h,o,r,t,m,c,s,v,d,x,f,S):nn(e,a,h,o,c,s,v,d,x,f,S),m<n-1){let t=l(m+1);S?e.line(x,h.midY,t,h.midY):e.line(x+f,h.midY,t,h.midY)}if(a.score){let t=K(a.score,c);L(e,p,P.NORMAL),e.setTextColor(60,60,160);let n=h.midY+p*.12;e.text(t,x-1,n,{align:`right`}),e.setTextColor(0)}}}}}function en(e,t,n,r,i,a,o,s,c,l,u){t.drawPositions[0]&&pn(e,r.get(t.drawPositions[0]),t.drawPositions[0],i,a,o,n.topY,s),t.drawPositions[1]&&pn(e,r.get(t.drawPositions[1]),t.drawPositions[1],i,a,o,n.bottomY,s),rn(e,n,c,l,u)}function tn(e,t,n,r,i,a,o,s,c,l,u,d,f,p){let m=a[o-1],h=i.get(m)||[],g=new Set;for(let e of h)e.winningSide&&e.winnerDrawPosition!==void 0&&g.add(e.winnerDrawPosition);let _=t.drawPositions.find(e=>e&&g.has(e)),v=t.drawPositions.find(e=>e&&e!==_);if(e.line(l,n.midY,l,n.bottomY),v?pn(e,r.get(v),v,s,c,l,n.topY,u):e.line(l,n.topY,l+u,n.topY),e.line(l,n.bottomY,l+u,n.bottomY),_){let t=r.get(_);t?.participantName&&mn(e,t,s,c,l,n.bottomY)}rn(e,n,d,f,p)}function nn(e,t,n,r,i,a,o,s,c,l,u){if(e.line(o,n.topY,o+s,n.topY),e.line(o,n.bottomY,o+s,n.bottomY),t.drawPositions[0]){let s=r.get(t.drawPositions[0]);s?.participantName&&mn(e,s,i,a,o,n.topY)}if(t.drawPositions[1]){let s=r.get(t.drawPositions[1]);s?.participantName&&mn(e,s,i,a,o,n.bottomY)}rn(e,n,c,l,u)}function rn(e,t,n,r,i){i?e.line(n,t.topY,n,t.bottomY):(e.line(n+r,t.topY,n+r,t.bottomY),e.line(n,t.topY,n+r,t.topY),e.line(n,t.bottomY,n+r,t.bottomY))}function an(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(t.noWinnerColumn)return;let m=s(r),h=n.at(-1),g=(a.get(h)||[])[0]?.midY||c+l/2;e.setDrawColor(40),e.setLineWidth(.25),e.line(m,g,m+Math.min(65,u),g);let _=(i.get(h)||[])[0];if(_?.winningSide){let t=_.winnerDrawPosition,n=t===void 0?void 0:o.get(t);if(n){L(e,d+1,P.BOLD);let{name:t}=G(n,p);if(e.text(t,m+1,g-.5),_.score){let t=K(_.score,p);L(e,f,P.NORMAL),e.setTextColor(60,60,160),e.text(t,m+1,g+f*.4),e.setTextColor(0)}}}}function on(e,t,n,r,i,a,o,s,c){L(e,r.fontSize<=F.TINY?5.5:F.SMALL,P.BOLD),e.setTextColor(40);for(let l=0;l<s;l++){let s=t[l],u=W(s,n.totalRounds),d=n.roundLabelMap?.[s]||i.roundLabels[u]||u,f=o(l),p=l===0?r.firstRoundWidth:c;e.text(d,f+p/2,a.contentY+2,{align:`center`}),e.setDrawColor(160),e.setLineWidth(.15),e.line(f+2,a.contentY+3.5,f+p-2,a.contentY+3.5)}let l=o(s);e.text(`Winner`,l+c/2,a.contentY+2,{align:`center`}),e.setDrawColor(160),e.line(l+2,a.contentY+3.5,l+c-2,a.contentY+3.5),e.setTextColor(0)}function sn(e,t,n,r,i=0,a){let o=a||t.drawSize,s=t.totalRounds||Math.ceil(Math.log2(o)),c=Math.log2(o),l=Number.isInteger(c)?Math.min(c,s):s,u=Kt(o,r,l),d=n.page.margins.left,f=r.contentY+9;dn(e,l,t.totalRounds,u,n,d,r.contentY+2,t.roundLabelMap,t.noWinnerColumn);for(let r=0;r<l;r++)cn(e,t,n,u,o,r,l,d,f,i);t.noWinnerColumn||un(e,t,n,u,l,d,f)}function cn(e,t,n,r,i,a,o,s,c,l){let u=i/2**(a+1),d=r.lineHeight*2**a,f=J(a,r,s),p=(2**a-1)*r.lineHeight/2,m=2**(a+1)*r.lineHeight;for(let i=0;i<u;i++){let u=c+p+i*m,h=u+d,g=(u+h)/2;if(a===0){let a=l+i*2+1,o=l+i*2+2;pn(e,gn(t.slots,a),a,n,r,f,u),pn(e,gn(t.slots,o),o,n,r,f,h)}else{let t=fn(a,r);e.setDrawColor(40),e.setLineWidth(.25),e.line(f,u,f+t,u),e.line(f,h,f+t,h)}let _=a===o-1,v=f+fn(a,r);if(e.setDrawColor(40),e.setLineWidth(.25),e.line(v+r.connectorGap,u,v+r.connectorGap,h),e.line(v,u,v+r.connectorGap,u),e.line(v,h,v+r.connectorGap,h),!_||!t.noWinnerColumn){let t=J(a+1,r,s);e.line(v+r.connectorGap,g,t,g)}let y=_n(t.matchUps,a+1,i+1);if(_&&t.noWinnerColumn){let i=vn(y,t.slots);i&&(e.setDrawColor(40),e.setLineWidth(.25),e.line(v+r.connectorGap,g,v+r.connectorGap+r.roundColumnWidth,g),mn(e,i,n,r,v+r.connectorGap,g),y?.score&&ln(e,y,n,r,d,v+r.connectorGap,a,g))}else if(!_){let i=vn(y,t.slots);if(i){let t=J(a+1,r,s);mn(e,i,n,r,t,g),y?.score&&ln(e,y,n,r,d,t,a,g)}}}}function ln(e,t,n,r,i,a,o,s){let c=K(t.score,n);if(L(e,r.scoreFontSize,P.NORMAL),e.setTextColor(60,60,160),i*2<r.scoreFontSize*1.2){let t=a+fn(o+1,r)-1;e.text(c,t,s-.5,{align:`right`})}else{let t=r.scoreFontSize*.4;e.text(c,a+1,s-.5+t)}e.setTextColor(0)}function un(e,t,n,r,i,a,o){let s=J(i,r,a),c=(2**(i-1)-1)*r.lineHeight/2,l=r.lineHeight*2**(i-1),u=o+c+l/2;e.setDrawColor(40),e.setLineWidth(.25),e.line(s,u,s+r.roundColumnWidth,u);let d=_n(t.matchUps,i,1);if(d?.winningSide){let i=d.winnerDrawPosition,a=gn(t.slots,i);if(a){L(e,r.fontSize+1,P.BOLD);let{name:t}=G(a,n);if(e.text(t,s+1,u-.5),d.score){let t=K(d.score,n);L(e,r.scoreFontSize,P.NORMAL),e.setTextColor(60,60,160),e.text(t,s+1,u+r.scoreFontSize*.4),e.setTextColor(0)}}}}function dn(e,t,n,r,i,a,o,s,c){L(e,r.fontSize<=F.TINY?5.5:F.SMALL,P.BOLD),e.setTextColor(40);for(let c=0;c<t;c++){let l=n-t+c+1,u=W(l,n),d=s?.[l]||i.roundLabels[u]||u,f=J(c,r,a),p=fn(c,r),m=f+p/2;e.text(d,m,o,{align:`center`}),e.setDrawColor(160),e.setLineWidth(.15),e.line(f+2,o+1.5,f+p-2,o+1.5)}if(!c){let n=J(t,r,a);e.text(`Winner`,n+r.roundColumnWidth/2,o,{align:`center`}),e.setDrawColor(160),e.setLineWidth(.15),e.line(n+2,o+1.5,n+r.roundColumnWidth-2,o+1.5)}e.setTextColor(0)}function fn(e,t){return e===0?t.firstRoundWidth:e===1?t.secondRoundWidth:t.roundColumnWidth}function J(e,t,n){if(e===0)return n;let r=n+t.firstRoundWidth+t.connectorGap;for(let n=1;n<e;n++)r+=fn(n,t)+t.connectorGap;return r}function pn(e,t,n,r,i,a,o,s){let c=i.fontSize<=5?4:5,l=i.fontSize<=5?5:6,u=s||i.firstRoundWidth,d=i.lineHeight<2?.15:.3;L(e,i.scoreFontSize,P.NORMAL),e.setTextColor(120),e.text(`${n}`,a,o-d,{align:`left`}),e.setTextColor(0),t?.nationality&&(L(e,i.scoreFontSize,P.NORMAL),e.setTextColor(100),e.text(t.nationality,a+c+l-1,o-d,{align:`right`}),e.setTextColor(0));let f=a+c+l,p=a+u;if(e.setDrawColor(40),e.setLineWidth(.25),e.line(f,o,p,o),!t)return;let{name:m}=G(t,r);if(!m)return;L(e,i.fontSize,t.isBye?P.ITALIC:P.NORMAL),t.isBye&&e.setTextColor(150);let h=p-f-2,g=m;e.getTextWidth(m)>h&&(g=hn(t.participantName));let _=i.lineHeight<2?.2:.5;e.text(g,f+1,o-_),t.isBye&&e.setTextColor(0)}function mn(e,t,n,r,i,a){let o=hn(t.participantName),s=``;if(t.seedValue)switch(n.seedFormat){case`parens`:s=`(${t.seedValue})`;break;case`bare`:s=`${t.seedValue}`;break;default:s=`[${t.seedValue}]`}let c=s?`${o} ${s}`:o;L(e,r.fontSize,P.BOLD),e.text(c,i+1,a-.5)}function hn(e){let t=e.match(/^([^,]+),\s*(.+)/);if(t)return`${t[2][0]}. ${t[1]}`;let n=e.match(/^(\S+)\s+(.+)/);return n?`${n[1][0]}. ${n[2]}`:e}function gn(e,t){return t===void 0?void 0:e.find(e=>e.drawPosition===t)}function _n(e,t,n){return e.find(e=>e.roundNumber===t&&e.roundPosition===n)}function vn(e,t){if(e){if(e.winningSide){let n=e.winnerDrawPosition;return gn(t,n)}if(e.matchUpStatus===`BYE`)for(let n of e.drawPositions){let e=gn(t,n);if(e&&!e.isBye&&e.participantName)return e}}}function yn({partitionCount:e,matchUps:t,matchUp:n}){if(e<1)return;let r=t.filter(e=>e.roundNumber===n.roundNumber).length;if(r<e)return;let i=r/e,a=n.roundPosition??1,o=Math.floor((a-1)/i);return Math.min(o,e-1)}function bn({positionPredicate:e,partitionIndex:t,partitionCount:n,matchUps:r,matchUp:i}){let a=(i.drawPositions??[]).filter(e=>!!e);return a.length?a.every(e):yn({matchUps:r,matchUp:i,partitionCount:n})===t}function xn(e,t,n,r){let i=n.page.margins,a=r.contentY+9,o=r.contentHeight-9,s=t.drawSize/2,c=Math.log2(s),l=r.contentWidth,u=Math.min(30,l*.08),d=(l-u)/2,f=i.left+d,p=o/s,m=p<3.5,h=m?.8:1.5,g=Math.min(m?30:50,d*.22),_=c,v=d-g-h*(_+1),y=Math.max(8,v/Math.max(1,_)),b=F.SMALL;p<2.5?b=5:m&&(b=F.TINY);let x=m?5:F.TINY,S={lineHeight:p,roundColumnWidth:y,firstRoundWidth:g,connectorGap:h,fontSize:b,scoreFontSize:x},C=t.slots.filter(e=>e.drawPosition<=s),ee=t.slots.filter(e=>e.drawPosition>s),te=t.matchUps.filter(e=>bn({positionPredicate:e=>e<=s,matchUps:t.matchUps,partitionIndex:0,partitionCount:2,matchUp:e})),ne=t.matchUps.filter(e=>bn({positionPredicate:e=>e>s,matchUps:t.matchUps,partitionIndex:1,partitionCount:2,matchUp:e})),w=ee.map(e=>({...e,drawPosition:e.drawPosition-s})),T=new Map;for(let e of ne)T.has(e.roundNumber)||T.set(e.roundNumber,[]),T.get(e.roundNumber).push(e);let E=[];for(let[,e]of T)e.sort((e,t)=>e.roundPosition-t.roundPosition),e.forEach((e,t)=>{E.push({...e,drawPositions:e.drawPositions.map(e=>e===void 0?void 0:e-s),winnerDrawPosition:e.winnerDrawPosition===void 0?void 0:e.winnerDrawPosition-s,roundPosition:t+1})});let D=new Map;for(let e of te)D.has(e.roundNumber)||D.set(e.roundNumber,[]),D.get(e.roundNumber).push(e);let O=[];for(let[,e]of D)e.sort((e,t)=>e.roundPosition-t.roundPosition),e.forEach((e,t)=>{O.push({...e,roundPosition:t+1})});wn(e,c,t.totalRounds,S,n,i.left,i.left+l,r.contentY+2,t.roundLabelMap),L(e,m?5.5:F.SMALL,P.BOLD),e.setTextColor(40),e.text(`Winner`,f+u/2,r.contentY+2,{align:`center`}),e.setDrawColor(160),e.setLineWidth(.15),e.line(f+2,r.contentY+3.5,f+u-2,r.contentY+3.5),e.setTextColor(0),Sn(e,C,O,c,S,n,i.left,a,t.totalRounds),Cn(e,w,E,c,S,n,i.left+l,a,t.totalRounds);let k=t.matchUps.find(e=>e.roundNumber===t.totalRounds);if(k){let r=a+o/2;if(e.setDrawColor(40),e.setLineWidth(.25),e.line(f+2,r,f+u-2,r),k.winningSide){let i=k.winnerDrawPosition,a=t.slots.find(e=>e.drawPosition===i);if(a){let{name:t}=G(a,n);L(e,b+1,P.BOLD),e.text(t,f+u/2,r-1,{align:`center`})}}k.score&&(L(e,x,P.NORMAL),e.setTextColor(60,60,160),e.text(K(k.score,n),f+u/2,r+x*.4,{align:`center`}),e.setTextColor(0))}}function Sn(e,t,n,r,i,a,o,s,c){let l=new Map(t.map(e=>[e.drawPosition,e])),u=t.length;for(let t=0;t<r;t++){let c=u/2**(t+1),d=i.lineHeight*2**t,f=(2**t-1)*i.lineHeight/2,p=2**(t+1)*i.lineHeight,m=Tn(t,i,o),h=t===0?i.firstRoundWidth:i.roundColumnWidth;for(let u=0;u<c;u++){let c=s+f+u*p,g=c+d,_=(c+g)/2;if(t===0){let t=u*2+1,n=u*2+2;Dn(e,l.get(t),i,m,c,h,`ltr`),Dn(e,l.get(n),i,m,g,h,`ltr`)}else e.setDrawColor(40),e.setLineWidth(.25),e.line(m,c,m+h,c),e.line(m,g,m+h,g);let v=m+h,y=Tn(t+1,i,o);e.setDrawColor(40),e.setLineWidth(.25),e.line(v+i.connectorGap,c,v+i.connectorGap,g),e.line(v,c,v+i.connectorGap,c),e.line(v,g,v+i.connectorGap,g),e.line(v+i.connectorGap,_,y,_);let b=kn(n,t+1,u+1);if(t<r-1&&b?.winningSide){let t=b.winnerDrawPosition,n=t===void 0?void 0:l.get(t);if(n){L(e,i.fontSize,P.BOLD);let t=n.participantName;e.getTextWidth(t)>i.roundColumnWidth-2&&(t=On(t)),e.text(t,y+1,_-.5)}}b?.score&&t<r-1&&(L(e,i.scoreFontSize,P.NORMAL),e.setTextColor(60,60,160),e.text(K(b.score,a),y+1,_-.5+i.scoreFontSize*.4),e.setTextColor(0))}}}function Cn(e,t,n,r,i,a,o,s,c){let l=new Map(t.map(e=>[e.drawPosition,e])),u=t.length;for(let t=0;t<r;t++){let c=u/2**(t+1),d=i.lineHeight*2**t,f=(2**t-1)*i.lineHeight/2,p=2**(t+1)*i.lineHeight,m=En(t,i,o),h=t===0?i.firstRoundWidth:i.roundColumnWidth;for(let u=0;u<c;u++){let c=s+f+u*p,g=c+d,_=(c+g)/2;if(t===0){let t=u*2+1,n=u*2+2;Dn(e,l.get(t),i,m,c,h,`rtl`),Dn(e,l.get(n),i,m,g,h,`rtl`)}else e.setDrawColor(40),e.setLineWidth(.25),e.line(m,c,m+h,c),e.line(m,g,m+h,g);let v=m,y=En(t+1,i,o);e.setDrawColor(40),e.setLineWidth(.25),e.line(v-i.connectorGap,c,v-i.connectorGap,g),e.line(v,c,v-i.connectorGap,c),e.line(v,g,v-i.connectorGap,g),e.line(v-i.connectorGap,_,y+i.roundColumnWidth,_);let b=kn(n,t+1,u+1);if(t<r-1&&b?.winningSide){let t=b.winnerDrawPosition,n=t===void 0?void 0:l.get(t);if(n){L(e,i.fontSize,P.BOLD);let t=n.participantName;e.getTextWidth(t)>i.roundColumnWidth-2&&(t=On(t));let r=y;e.text(t,r+i.roundColumnWidth-1,_-.5,{align:`right`})}}if(b?.score&&t<r-1){let t=y;L(e,i.scoreFontSize,P.NORMAL),e.setTextColor(60,60,160),e.text(K(b.score,a),t+i.roundColumnWidth-1,_-.5+i.scoreFontSize*.4,{align:`right`}),e.setTextColor(0)}}}}function wn(e,t,n,r,i,a,o,s,c){L(e,r.fontSize<=F.TINY?5.5:F.SMALL,P.BOLD),e.setTextColor(40);for(let l=0;l<t;l++){let u=n-t+l+1,d=W(u,n),f=c?.[u]||i.roundLabels[d]||d,p=l===0?r.firstRoundWidth:r.roundColumnWidth,m=Tn(l,r,a);e.text(f,m+p/2,s,{align:`center`}),e.setDrawColor(160),e.setLineWidth(.15),e.line(m+2,s+1.5,m+p-2,s+1.5);let h=En(l,r,o);e.text(f,h+p/2,s,{align:`center`}),e.line(h+2,s+1.5,h+p-2,s+1.5)}e.setTextColor(0)}function Tn(e,t,n){return e===0?n:n+t.firstRoundWidth+t.connectorGap+(e-1)*(t.roundColumnWidth+t.connectorGap)}function En(e,t,n){return e===0?n-t.firstRoundWidth:n-t.firstRoundWidth-t.connectorGap-(e-1)*(t.roundColumnWidth+t.connectorGap)-t.roundColumnWidth}function Dn(e,t,n,r,i,a,o){if(e.setDrawColor(40),e.setLineWidth(.25),e.line(r,i,r+a,i),!t||t.isBye){t?.isBye&&(L(e,n.fontSize,P.ITALIC),e.setTextColor(150),o===`ltr`?e.text(`Bye`,r+1,i-.3):e.text(`Bye`,r+a-1,i-.3,{align:`right`}),e.setTextColor(0));return}let s=t.seedValue?`[${t.seedValue}]`:``;L(e,n.fontSize,P.NORMAL);let c=t.participantName,l=s?`${s} ${c}`:c;e.getTextWidth(l)>a-2&&(c=On(t.participantName),l=s?`${s} ${c}`:c),o===`ltr`?e.text(l,r+1,i-.3):e.text(l,r+a-1,i-.3,{align:`right`})}function On(e){let t=e.match(/^([^,]+),\s*(.+)/);if(t)return`${t[2][0]}. ${t[1]}`;let n=e.match(/^(\S+)\s+(.+)/);return n?`${n[1][0]}. ${n[2]}`:e}function kn(e,t,n){return e.find(e=>e.roundNumber===t&&e.roundPosition===n)}function An(e,t,n,r){let i=n.page.margins,a=r.contentY+9,o=r.contentHeight-9,s=r.contentWidth,c=t.mainDraw.matchUps,l=t.mainDraw.slots,u=t.consolation.matchUps,d=t.consolation.slots,f=new Map(l.map(e=>[e.drawPosition,e])),p=new Map(d.map(e=>[e.drawPosition,e])),m=c.filter(e=>e.roundNumber===1).sort((e,t)=>e.roundPosition-t.roundPosition),h=m.length,g=h*2,_=Math.max(...c.map(e=>e.roundNumber)),v=_-1,y=u.length>0?Math.max(...u.map(e=>e.roundNumber)):0,b=1.5,x=s-28-b*4,S=v+1,C=Math.max(y+1,1),ee=x*(S/(S+C)),te=x-ee,ne=i.left+te+b,w=S>0?(ee-b*S)/S:0,T=ne+28+b,E=C>0?(te-b*C)/C:0,D=i.left+te,O=o/g,k=O<3.5,A=F.SMALL;O<2.5?A=5:k&&(A=F.TINY);let re=k?5:F.TINY;zn(e,_,y,t,n,ne,28,T,w,D,E,b,r.contentY+2,A),jn(e,m,h,f,ne,28,b,T,D,a,O,A,y),Nn(e,c,f,_,h,T,w,b,a,O,A,re,n,t.mainDraw.roundLabelMap),Pn(e,u,p,y,D,E,b,a,O,h,A,re,n,t.consolation.roundLabelMap)}function jn(e,t,n,r,i,a,o,s,c,l,u,d,f){for(let p=0;p<n;p++){let n=t[p],m=l+p*u*2,h=m+u,g=(m+h)/2,_=n.drawPositions[0],v=n.drawPositions[1],y=u*.9;e.setDrawColor(40),e.setLineWidth(.3),e.rect(i,m,a,y),e.rect(i,h,a,y);let b=_?r.get(_):void 0,x=v?r.get(v):void 0;L(e,d,P.NORMAL),_&&Mn(e,_,b,n.winningSide===1,i,m,y,a,d),v&&Mn(e,v,x,n.winningSide===2,i,h,y,a,d),e.setDrawColor(40),e.setLineWidth(.25),e.line(i+a,m+y/2,i+a+o,m+y/2),e.line(i+a,h+y/2,i+a+o,h+y/2),e.line(i+a+o,m+y/2,i+a+o,h+y/2),e.line(i+a+o,g,s,g),f>0&&(e.line(i,m+y/2,i-o,m+y/2),e.line(i,h+y/2,i-o,h+y/2),e.line(i-o,m+y/2,i-o,h+y/2),e.line(i-o,g,c,g))}}function Mn(e,t,n,r,i,a,o,s,c){if(e.setTextColor(120),L(e,c,P.NORMAL),e.text(`${t}`,i+1,a+o/2+c*.12),e.setTextColor(0),n?.participantName){let t=Bn(n.participantName);L(e,c,r?P.BOLD:P.NORMAL),e.text(t,i+5,a+o/2+c*.12,{maxWidth:s-6})}}function Nn(e,t,n,r,i,a,o,s,c,l,u,d,f,p){for(let i=0;i<r-1;i++){let p=i+2,m=t.filter(e=>e.roundNumber===p).sort((e,t)=>e.roundPosition-t.roundPosition),h=l*2**(i+1),g=(2**(i+1)-1)*l/2,_=a+i*(o+s);for(let t=0;t<m.length;t++){let l=m[t],p=c+g+t*h*2,v=p+h,y=(p+v)/2;if(e.setDrawColor(40),e.setLineWidth(.25),e.line(_,p,_+o,p),e.line(_,v,_+o,v),Rn(e,l,n,_,p,v,o,u,f),i<r-2){let t=_+o;e.line(t+s,p,t+s,v),e.line(t,p,t+s,p),e.line(t,v,t+s,v),e.line(t+s,y,_+o+s+o+s>0?a+(i+1)*(o+s):t+s+5,y)}l.score&&(L(e,d,P.NORMAL),e.setTextColor(60,60,160),e.text(K(l.score,f),_+o-1,y+d*.12,{align:`right`}),e.setTextColor(0))}}let m=a+(r-2)*(o+s)+o+s,h=c+(2**(r-1)-1)*l/2+l*2**(r-2);e.setDrawColor(40),e.setLineWidth(.25),e.line(m,h,m+o,h);let g=t.find(e=>e.roundNumber===r);if(g?.winningSide){let t=g.winnerDrawPosition,r=t===void 0?void 0:n.get(t);if(r){let{name:t}=G(r,f);L(e,u+1,P.BOLD),e.text(t,m+1,h-.5)}}}function Pn(e,t,n,r,i,a,o,s,c,l,u,d,f,p){for(let l=0;l<r;l++)Fn(e,t,n,l,r,i,a,o,s,c,u,d,f);Ln(e,t,n,r,i,a,o,s,c,u,f)}function Fn(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=r+1,m=t.filter(e=>e.roundNumber===p).sort((e,t)=>e.roundPosition-t.roundPosition),h=l*2**(r+1),g=(2**(r+1)-1)*l/2,_=a-(r+1)*(o+s);for(let t=0;t<m.length;t++){let l=m[t],p=c+g+t*h*2,v=p+h,y=(p+v)/2;if(e.setDrawColor(40),e.setLineWidth(.25),e.line(_,p,_+o,p),e.line(_,v,_+o,v),In(e,l.drawPositions[0],n,u,_,o,p),In(e,l.drawPositions[1],n,u,_,o,v),r<i-1){e.line(_-s,p,_-s,v),e.line(_,p,_-s,p),e.line(_,v,_-s,v);let t=a-(r+2)*(o+s);e.line(_-s,y,t+o,y)}l.score&&(L(e,d,P.NORMAL),e.setTextColor(60,60,160),e.text(K(l.score,f),_+1,y+d*.12),e.setTextColor(0))}}function In(e,t,n,r,i,a,o){if(!t)return;let s=n.get(t);if(!s?.participantName)return;L(e,r,P.BOLD);let c=s.participantName;e.getTextWidth(c)>a-2&&(c=Bn(c)),e.text(c,i+a-1,o-.3,{align:`right`})}function Ln(e,t,n,r,i,a,o,s,c,l,u){if(r<=0)return;let d=i-(r+1)*(a+o),f=s+(2**r-1)*c/2+c*2**(r-1);e.setDrawColor(40),e.setLineWidth(.25),e.line(d,f,d+a,f);let p=t.find(e=>e.roundNumber===r);if(p?.winningSide){let t=p.winnerDrawPosition,r=t===void 0?void 0:n.get(t);if(r){let{name:t}=G(r,u);L(e,l+1,P.BOLD),e.text(t,d+a-1,f-.5,{align:`right`})}}}function Rn(e,t,n,r,i,a,o,s,c){if(t.drawPositions[0]){let a=n.get(t.drawPositions[0]);if(a?.participantName){L(e,s,P.BOLD);let t=a.participantName;e.getTextWidth(t)>o-2&&(t=Bn(t)),e.text(t,r+1,i-.3)}}if(t.drawPositions[1]){let i=n.get(t.drawPositions[1]);if(i?.participantName){L(e,s,P.BOLD);let t=i.participantName;e.getTextWidth(t)>o-2&&(t=Bn(t)),e.text(t,r+1,a-.3)}}}function zn(e,t,n,r,i,a,o,s,c,l,u,d,f,p){L(e,p<=F.TINY?5.5:F.SMALL,P.BOLD),e.setTextColor(40);let m=r.mainDraw.roundLabelMap?.[1]||`R1`;e.text(m,a+o/2,f,{align:`center`});for(let n=0;n<t-1;n++){let t=n+2,i=r.mainDraw.roundLabelMap?.[t]||`R${t}`,a=s+n*(c+d);e.text(i,a+c/2,f,{align:`center`})}for(let t=0;t<n;t++){let n=t+1,i=r.consolation.roundLabelMap?.[n]||`C-R${n}`,a=l-(t+1)*(u+d);e.text(i,a+u/2,f,{align:`center`})}e.setTextColor(0)}function Bn(e){let t=e.match(/^([^,]+),\s*(.+)/);if(t)return`${t[2][0]}. ${t[1]}`;let n=e.match(/^(\S+)\s+(.+)/);return n?`${n[1][0]}. ${n[2]}`:e}var Vn=[`E`,`W`,`N`,`S`,`NE`,`NW`,`SE`,`SW`];function Hn(e,t,n,r){let i=n.page.margins,a=[...t.structures].sort((e,t)=>Vn.indexOf(e.abbreviation)-Vn.indexOf(t.abbreviation)),o=r.contentY+3;for(let s of a){if(s.drawSize===0)continue;let a=Un(s,r);o+a>r.contentY+r.contentHeight&&(e.addPage(),o=r.contentY);let c=s.abbreviation===`E`;L(e,c?F.HEADING:F.BODY,P.BOLD),c||e.setTextColor(30,60,120);let l=c?`Main Draw (${s.name})`:`${s.name} Draw`;e.text(l,i.left,o),c||e.setTextColor(0),o+=c?5:4;let u={...r,contentY:o,contentHeight:a-6};q(e,Wn(s,t.drawName),n,u),o+=a+3}}function Un(e,t){let n=t.contentHeight*.7,r=Math.max(5,Math.min(8,n/e.drawSize));return e.drawSize*r+10}function Wn(e,t){return{drawName:`${t} - ${e.name}`,drawSize:e.drawSize,drawType:`SINGLE_ELIMINATION`,totalRounds:e.totalRounds,slots:e.slots,matchUps:e.matchUps,seedAssignments:[]}}function Gn(e){let{drawDefinition:t,participants:n=[]}=e;if(!t?.structures)return[];let r=new Map;return n.forEach(e=>r.set(e.participantId,e)),t.structures.map(t=>{let n=t.positionAssignments||[],i=t.seedAssignments||[],a=n.length,o=n.map(e=>{let t=e.participantId?r.get(e.participantId):void 0,n=i.find(t=>t.participantId===e.participantId);return{drawPosition:e.drawPosition,participantName:t?V(t):``,nationality:t?H(t):``,seedValue:n?.seedValue,isBye:e.bye===!0}}),s=(t.matchUps||[]).map(e=>({roundNumber:e.roundNumber,roundPosition:e.roundPosition,drawPositions:e.drawPositions||[],winnerDrawPosition:ge(e),score:e.score?.scoreStringSide1||``,winningSide:e.winningSide,matchUpStatus:e.matchUpStatus})),c=t.stage||`MAIN`,l=c===`MAIN`,u=t.structureName||(l?`Main Draw`:`Consolation`),d=s.reduce((e,t)=>Math.max(e,t.roundNumber||0),0),f=(e.processedMatchUps||[]).filter(e=>e.structureId===t.structureId),p;if(f.length){p={};for(let e of f)e.roundNumber&&!p[e.roundNumber]&&(p[e.roundNumber]=e.abbreviatedRoundName||e.roundName||`R${e.roundNumber}`)}return{name:u,stage:c,drawData:{drawName:u,drawSize:a,drawType:`SINGLE_ELIMINATION`,totalRounds:d,slots:o,matchUps:s,seedAssignments:i.filter(e=>e.participantId).map(e=>{let t=r.get(e.participantId);return{seedValue:e.seedValue,participantName:t?V(t):``,nationality:t?H(t):``,seedingBasis:e.seedingBasis}}),roundLabelMap:p}}})}function Kn(e,t,n,r){let i=n.page.margins,a=r.contentY,o={MAIN:0,CONSOLATION:1,PLAY_OFF:2},s=[...t].filter(e=>e.drawData.drawSize>0).sort((e,t)=>(o[e.stage]??9)-(o[t.stage]??9));for(let t of s){let o=t.stage===`MAIN`,s=t.drawData.drawSize*3.5+8;a+s>r.contentY+r.contentHeight&&a>r.contentY+10&&(e.addPage(),a=r.contentY),a+=3,L(e,o?F.HEADING:F.BODY,P.BOLD),o||e.setTextColor(120,40,40),e.text(t.name,i.left,a),o||e.setTextColor(0),a+=o?4:3;let c={...r,contentY:a,contentHeight:Math.min(s,r.contentY+r.contentHeight-a)};q(e,t.drawData,n,c),a+=s+4}}function qn(e,t,n,r){let i=n.page.margins,a=r.contentHeight,o=a*.44,s=a*.44,c=r.contentWidth-30-8,l=Jn(t.winnersBracket),u=r.contentY+3;L(e,F.BODY,P.BOLD),e.setTextColor(30,80,30),e.text(`Winner's Bracket`,i.left,u),e.setTextColor(0),u+=3,q(e,l,n,{...r,contentY:u,contentHeight:o-6,contentWidth:c}),u=r.contentY+o+6,L(e,F.BODY,P.BOLD),e.setTextColor(140,40,40),e.text(`Loser's Bracket (Backdraw)`,i.left,u),e.setTextColor(0),u+=3;let d={...r,contentY:u,contentHeight:s-6,contentWidth:c};q(e,t.losersBracket,n,d);let f=i.left+c+8,p=r.contentY+a/2;if(L(e,F.SMALL,P.BOLD),e.text(`Decider`,f+14,p-14-4,{align:`center`}),e.setDrawColor(60),e.setLineWidth(.5),e.rect(f,p-14-1,28,14),e.setLineWidth(.2),e.line(f,p-7-1,f+28,p-7-1),t.deciderMatch?.matchUps?.length){let n=t.deciderMatch.matchUps[0],r=new Map(t.deciderMatch.slots.map(e=>[e.drawPosition,e]));if(n.drawPositions[0]){let t=r.get(n.drawPositions[0]);if(t?.participantName){let r=n.winningSide===1;L(e,F.TINY,r?P.BOLD:P.NORMAL),e.text(t.participantName,f+1,p-7-3,{maxWidth:26})}}if(n.drawPositions[1]){let t=r.get(n.drawPositions[1]);if(t?.participantName){let r=n.winningSide===2;L(e,F.TINY,r?P.BOLD:P.NORMAL),e.text(t.participantName,f+1,p-3,{maxWidth:26})}}n.score&&(L(e,F.TINY,P.NORMAL),e.setTextColor(60,60,160),e.text(n.score,f+28-1,p-14+2,{align:`right`}),e.setTextColor(0))}}function Jn(e){let t={...e.roundLabelMap||{}};for(let e of Object.keys(t))t[Number(e)]===`F-Q`&&(t[Number(e)]=`SF`);return{...e,roundLabelMap:t}}var Yn=1,Xn=16,Zn=1;function Qn(e,t,n,r){let i=n.page.margins,a=new Map;for(let e of t.matchUps)a.has(e.roundNumber)||a.set(e.roundNumber,[]),a.get(e.roundNumber).push(e);let o=new Map(t.slots.map(e=>[e.drawPosition,e])),s=[...a.keys()].sort((e,t)=>e-t),c=s.length,l=r.contentY+7,u=r.contentHeight-7,d=Math.min(55,(r.contentWidth-(c-1)*6)/c),f=a.get(s[0])?.length||1,p=Math.min(Xn,(u-(f+1)*Zn)/f);L(e,F.SMALL,P.BOLD),e.setTextColor(30,60,120);for(let a=0;a<c;a++){let o=s[a],c=n.roundLabels[W(o,t.totalRounds)]||W(o,t.totalRounds),l=i.left+a*(d+6);e.text(c,l+d/2,r.contentY+3,{align:`center`})}e.setTextColor(0);for(let t=0;t<c;t++){let r=s[t],c=a.get(r)||[],f=c.length,m=i.left+t*(d+6),h=f*p,g=f>1?(u-h)/(f+1):(u-p)/2;for(let t=0;t<f;t++){let r=l+g+t*(p+g);$n(e,c[t],o,n,m,r,d,p)}}}function $n(e,t,n,r,i,a,o,s){let c=s<10?5:F.TINY;e.setDrawColor(100),e.setLineWidth(.3),e.rect(i,a,o,s);let l=a+s/2;e.setLineWidth(.15),e.line(i,l,i+o,l);let u=t.drawPositions[0]?n.get(t.drawPositions[0]):void 0;if(u){let n=Bt(u,r);L(e,c,t.winningSide===1?P.BOLD:P.NORMAL),e.text(n,i+Yn,l-c*.15,{maxWidth:o-2})}let d=t.drawPositions[1]?n.get(t.drawPositions[1]):void 0;if(d){let n=Bt(d,r);L(e,c,t.winningSide===2?P.BOLD:P.NORMAL),e.text(n,i+Yn,l+c*.55,{maxWidth:o-2})}if(t.score){let n=K(t.score,r);L(e,c,P.NORMAL),e.setTextColor(60,60,160),e.text(n,i+o-Yn,a+c*.5,{align:`right`}),e.setTextColor(0)}}var er={maxPositionsPerPage:64,includeOverlapRounds:!0,summaryPage:!0};function tr(e,t=er){let{drawSize:n,slots:r,matchUps:i,totalRounds:a}=e;if(n<=t.maxPositionsPerPage)return[{label:`Full Draw`,startPosition:1,endPosition:n,slots:r,matchUps:i,segmentRounds:a}];let o=t.maxPositionsPerPage,s=Math.ceil(n/o),c=Math.log2(o),l=[];for(let e=0;e<s;e++)l.push(nr(e,o,s,c,n,r,i));return t.summaryPage&&s>1&&l.push(rr(e)),l}function nr(e,t,n,r,i,a,o){let s=e*t+1,c=Math.min((e+1)*t,i),l=`Section ${e+1}`;n===2&&(l=e===0?`Top Half`:`Bottom Half`);let u=a.filter(e=>e.drawPosition>=s&&e.drawPosition<=c),d=ir(o.filter(t=>t.roundNumber>r?!1:bn({positionPredicate:e=>e>=s&&e<=c,partitionCount:n,partitionIndex:e,matchUp:t,matchUps:o})));return{label:l,startPosition:s,endPosition:c,slots:u,matchUps:d,segmentRounds:r,noWinnerColumn:!0}}function rr(e){let{slots:t,matchUps:n,totalRounds:r,roundLabelMap:i}=e,a=Math.max(1,r-5+1),o=r-a+1,s=a-1,c=n.filter(e=>e.roundNumber===a).sort((e,t)=>e.roundPosition-t.roundPosition),l=c.length*2,u=ar(c),d=ir(n.filter(e=>e.roundNumber>=a).map(e=>({...e,roundNumber:e.roundNumber-s,roundPosition:e.roundNumber===a?c.findIndex(t=>t.roundPosition===e.roundPosition)+1:e.roundPosition,drawPositions:e.drawPositions.map(e=>e===void 0?void 0:u.get(e)||e),winnerDrawPosition:e.winnerDrawPosition===void 0?void 0:u.get(e.winnerDrawPosition)||e.winnerDrawPosition}))),f=[];for(let[e,n]of u){let r=t.find(t=>t.drawPosition===e);r&&f.push({...r,drawPosition:n})}return f.sort((e,t)=>e.drawPosition-t.drawPosition),{label:`Final Rounds`,startPosition:1,endPosition:l,slots:f,matchUps:d,segmentRounds:o,roundLabelMap:i?Object.fromEntries(Object.entries(i).filter(([e])=>Number(e)>=a).map(([e,t])=>[Number(e)-s,t])):void 0}}function ir(e){let t=new Map;for(let n of e)t.has(n.roundNumber)||t.set(n.roundNumber,[]),t.get(n.roundNumber).push(n);let n=[];for(let[,e]of t)e.sort((e,t)=>e.roundPosition-t.roundPosition),e.forEach((e,t)=>{n.push({...e,roundPosition:t+1})});return n}function ar(e){let t=new Map,n=1;for(let r of e)for(let e of r.drawPositions)e&&!t.has(e)&&t.set(e,n++);return t}function or(e,t={}){return sr(e.matchUps)?ur(e,t):cr(e,t)}function sr(e){let t=new Map;for(let n of e)t.set(n.roundNumber,(t.get(n.roundNumber)||0)+1);let n=[...t.keys()].sort((e,t)=>e-t);for(let e=1;e<n.length;e++){let r=t.get(n[e-1])||0;if((t.get(n[e])||0)>=r)return!0}return!1}function cr(e,t={}){if(e.drawSize>=256)return lr(e,{...t,maxPositionsPerPage:64});let n=Y(e.drawSize,t),r=R(n.doc,n.pageConfig,n.headerH,n.footerH);return q(n.doc,e,n.format,r),X(n),n.doc}function lr(e,t={}){let n=Y(e.drawSize,t),r=tr(e,{maxPositionsPerPage:t.maxPositionsPerPage||32,includeOverlapRounds:!0,summaryPage:!0});for(let t=0;t<r.length;t++){t>0&&n.doc.addPage();let i=z(n.doc,{...n.headerConfig,subtitle:r[t].label},n.pageConfig),a=R(n.doc,n.pageConfig,i,n.footerH);if(r[t].slots.length>0||r[t].matchUps.length>0){let i=r[t],o=i.endPosition-i.startPosition+1,s={...e,slots:i.slots,matchUps:i.matchUps,noWinnerColumn:i.noWinnerColumn,roundLabelMap:i.roundLabelMap||e.roundLabelMap,drawSize:o,totalRounds:i.segmentRounds};q(n.doc,s,n.format,a,i.startPosition-1,o)}}return X(n),n.doc}function ur(e,t={}){let n=e.totalRounds>=5||e.slots.length>=12,r=Y(e.drawSize,t,n),i=R(r.doc,r.pageConfig,r.headerH,r.footerH);return q(r.doc,e,r.format,i),X(r),r.doc}function dr(e,t={}){let n=Y(Math.max(...e.map(e=>e.drawData.drawSize),8),t),r=R(n.doc,n.pageConfig,n.headerH,n.footerH);return Kn(n.doc,e,n.format,r),_r(n,1),X(n),n.doc}function fr(e,t={}){let n=Y(e.mainStructure?.drawSize||8,t),r=R(n.doc,n.pageConfig,n.headerH,n.footerH);return Hn(n.doc,e,n.format,r),_r(n,1),X(n),n.doc}function pr(e,t={}){let n=Y(e.drawSize,t,!0),r=R(n.doc,n.pageConfig,n.headerH,n.footerH);return xn(n.doc,e,n.format,r),X(n),n.doc}function mr(e,t={}){let n=Y(e.mainDraw.drawSize,t,!0),r=R(n.doc,n.pageConfig,n.headerH,n.footerH);return An(n.doc,e,n.format,r),X(n),n.doc}function hr(e,t={}){let n=Y(Math.max(e.winnersBracket.drawSize,e.losersBracket.drawSize,8),t,!0),r=R(n.doc,n.pageConfig,n.headerH,n.footerH);return qn(n.doc,e,n.format,r),X(n),n.doc}function gr(e,t={}){let n=Y(e.drawSize,t),r=R(n.doc,n.pageConfig,n.headerH,n.footerH);return Qn(n.doc,e,n.format,r),X(n),n.doc}function Y(e,t,n){let r=t.format||_(t.preset||`itfJunior`),i={...r.page,...t.page,orientation:n?`landscape`:t.page?.orientation||r.page.orientation},a=t.header||{layout:`none`,tournamentName:``},o=t.footer||{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},s=Te(i,e),c=B(o);return{doc:s,pageConfig:i,headerConfig:a,footerConfig:o,format:r,headerH:z(s,a,i),footerH:c}}function _r(e,t){let n=e.doc.getNumberOfPages();for(let r=t+1;r<=n;r++)e.doc.setPage(r),z(e.doc,e.headerConfig,e.pageConfig)}function X(e){let t=e.doc.getNumberOfPages();for(let n=1;n<=t;n++)e.doc.setPage(n),qe(e.doc,e.footerConfig,e.pageConfig,n);e.doc.setPage(t)}function vr(e){let t=e.header?{...e.header,layout:e.header.layout??`itf`,tournamentName:e.header.tournamentName??``}:void 0,n=e.footer?{...e.footer,layout:e.footer.layout??`standard`}:void 0,r=e.content?.schedule;return{header:t,footer:n,page:e.page,cellStyle:r?.cellStyle??`detailed`,showMatchNumbers:r?.showMatchNumbers,alertBanner:r?.alertBanner}}function yr(e,t){let n=e?.sides?.find(e=>e?.sideNumber===t);return{name:n?.participant?.participantName??`TBD`,nationality:n?.participant?.nationalityCode??``,seedValue:n?.seedValue}}function br(e,t){if(!e?.type)return{success:!1,error:`Missing request type`};if(!e.composition)return{success:!1,error:`Missing composition config`};if(!t?.tournamentEngine)return{success:!1,error:`Missing tournamentEngine in context`};switch(e.type){case`schedule`:return Ir(e,t);case`playerList`:return jr(e,t);case`signInSheet`:return Mr(e,t);case`courtCards`:return Nr(e,t);case`matchCard`:return Fr(e,t);case`draw`:return xr(e,t)}}function xr(e,t){if(!e.drawId)return{success:!1,error:`PrintDrawRequest requires drawId`};let n=t.tournamentEngine;if(typeof n.getEventData!=`function`)return{success:!1,error:`engine.getEventData is not a function`};let{eventData:r}=n.getEventData({drawId:e.drawId})??{};if(!r?.drawsData?.length)return{success:!1,error:`No draw data found for drawId "${e.drawId}"`};let i=r.tournamentInfo??{},a=r.eventInfo??{},o=r.drawsData[0].structures??[],s=o.find(e=>e.stage===`MAIN`),c=o.some(e=>e.stage===`CONSOLATION`),l=o.some(e=>e.stage===`PLAY_OFF`),u=Or(e.composition,`draw`)?.splitStrategy??`single-page`,d={header:Tr(e.composition,i,a),footer:Er(e.composition),page:e.composition.page,preset:void 0},f;try{if(c&&l)f=hr({winnersBracket:s?M(s):Sr(),losersBracket:Cr(r),deciderMatch:wr(r)},d);else if(c)f=dr(o.map(e=>({name:e.structureName,stage:e.stage,drawData:M(e)})),d);else if(s){let e=M(s);f=u===`single-page`?cr(e,d):lr(e,d)}}catch(e){return{success:!1,error:`draw generator failed: ${e instanceof Error?e.message:String(e)}`}}if(!f)return{success:!1,error:`No matching draw renderer for this structure`};let p=(a.eventName||i.tournamentName||`draw`).replace(/[^a-z0-9]/gi,`_`).toLowerCase();return{success:!0,doc:f,blob:f.output(`blob`),filename:`draw-${p}.pdf`}}function Sr(){return{drawName:``,drawSize:0,drawType:``,totalRounds:0,slots:[],matchUps:[],seedAssignments:[]}}function Cr(e){let t=N(e.drawsData,`CONSOLATION`);return t?M(t):Sr()}function wr(e){let t=N(e.drawsData,`PLAY_OFF`);return t?M(t):void 0}function Tr(e,t,n){if(e.header?.layout===`none`)return;let r=e.header??{};return{layout:r.layout??`itf`,tournamentName:r.tournamentName??t?.tournamentName??n?.eventName??`Tournament`,subtitle:r.subtitle??n?.eventName,startDate:r.startDate??t?.startDate,endDate:r.endDate??t?.endDate,location:r.location??t?.venues?.[0]?.venueName,organizer:r.organizer,surface:r.surface??n?.surfaceCategory,grade:r.grade,supervisor:r.supervisor,city:r.city,country:r.country??t?.hostCountryCode,prizeMoney:r.prizeMoney,currency:r.currency,tournamentId:r.tournamentId,sectionLabel:r.sectionLabel,leftLogoBase64:r.leftLogoBase64,rightLogoBase64:r.rightLogoBase64,chiefUmpire:r.chiefUmpire}}function Er(e){if(e.footer?.layout===`none`)return;let t=e.footer??{};return{layout:t.layout??`standard`,showPageNumbers:t.showPageNumbers??!0,showTimestamp:t.showTimestamp??!0,notes:t.notes,officials:t.officials,seedAssignments:t.seedAssignments,prizeMoney:t.prizeMoney,signatureLines:t.signatureLines,drawCeremonyDate:t.drawCeremonyDate,releaseDate:t.releaseDate,withdrawals:t.withdrawals,luckyLosers:t.luckyLosers}}function Dr(e){let t=e.header;if(t&&t.layout!==`none`)return{tournamentName:t.tournamentName??``,subtitle:t.subtitle,startDate:t.startDate,endDate:t.endDate,location:t.location,organizer:t.organizer}}function Or(e,t){return e.content?.[t]}function kr(e,t){if(typeof e.getParticipants!=`function`)return{success:!1,error:`engine.getParticipants is not a function`};let{participants:n=[]}=e.getParticipants({participantFilters:{participantTypes:[`INDIVIDUAL`]},withScaleValues:!0,withSeeding:!0})??{};if(t){if(typeof e.getEvent!=`function`)return{success:!1,error:`engine.getEvent is not a function`};let{event:r}=e.getEvent({eventId:t})??{};if(!r)return{success:!1,error:`Event "${t}" not found`};let i=new Set((r.entries??[]).map(e=>e.participantId));return{success:!0,participants:n.filter(e=>i.has(e.participantId)),eventEntries:[{eventName:r.eventName??``,entries:Ar(r)}],eventName:r.eventName??``}}return{success:!0,participants:n,eventEntries:(e.getEvents?.()?.events??[]).map(e=>({eventName:e.eventName??``,entries:Ar(e)})),eventName:``}}function Ar(e){let t=e.entries??[],n=new Map;for(let t of e.drawDefinitions??[])for(let e of t.structures??[])if(!(e.stage&&e.stage!==`MAIN`))for(let t of e.seedAssignments??[]){if(!t?.participantId||t.seedValue===void 0)continue;let e=Number(t.seedValue);!Number.isNaN(e)&&!n.has(t.participantId)&&n.set(t.participantId,e)}return n.size===0?t:t.map(e=>n.has(e.participantId)?{...e,seedValue:n.get(e.participantId)}:e)}function jr(e,t){let n=kr(t.tournamentEngine,e.eventId);if(!n.success)return n;let r=gt({participants:n.participants,eventEntries:n.eventEntries}),i=Or(e.composition,`playerList`),a;try{a=At(r,{header:Dr(e.composition),includeRanking:i?.includeRanking,includeEvents:i?.includeEvents,groupByEvent:i?.groupByEvent})}catch(e){return{success:!1,error:`generatePlayerListPDF failed: ${e instanceof Error?e.message:String(e)}`}}let o=(n.eventName||`all`).replace(/[^a-z0-9]/gi,`_`).toLowerCase();return{success:!0,doc:a,blob:a.output(`blob`),filename:`player-list-${o}.pdf`}}function Mr(e,t){if(!e.eventId)return{success:!1,error:`PrintSignInSheetRequest requires eventId`};let n=kr(t.tournamentEngine,e.eventId);if(!n.success)return n;let r=gt({participants:n.participants,eventEntries:n.eventEntries}),i;try{i=jt(r,{header:Dr(e.composition),eventName:n.eventName})}catch(e){return{success:!1,error:`generateSignInSheetPDF failed: ${e instanceof Error?e.message:String(e)}`}}let a=(n.eventName||`all`).replace(/[^a-z0-9]/gi,`_`).toLowerCase();return{success:!0,doc:i,blob:i.output(`blob`),filename:`sign-in-sheet-${a}.pdf`}}function Nr(e,t){let n=t.tournamentEngine,r=Lr(n,e.venueId);if(!r.success)return r;let i=vt({matchUps:r.matchUps,venues:r.venues,scheduledDate:e.scheduledDate}),a=Pr(e.composition,n),o=Or(e.composition,`courtCard`),s;try{s=Mt(i,{tournamentName:a,cardsPerPage:o?.cardsPerPage})}catch(e){return{success:!1,error:`generateCourtCardPDF failed: ${e instanceof Error?e.message:String(e)}`}}let c=e.scheduledDate?`-${e.scheduledDate}`:``;return{success:!0,doc:s,blob:s.output(`blob`),filename:`court-cards${c}.pdf`}}function Pr(e,t){return e.header?.tournamentName||(typeof t.getTournamentInfo==`function`?t.getTournamentInfo()?.tournamentInfo?.tournamentName??``:``)}function Fr(e,t){if(!Array.isArray(e.matchUpIds)||e.matchUpIds.length===0)return{success:!1,error:`PrintMatchCardRequest requires non-empty matchUpIds`};let n=t.tournamentEngine;if(typeof n.allTournamentMatchUps!=`function`)return{success:!1,error:`engine.allTournamentMatchUps is not a function`};let{matchUps:r=[]}=n.allTournamentMatchUps()??{},i=new Set(e.matchUpIds),a=r.filter(e=>i.has(e.matchUpId));if(a.length===0)return{success:!1,error:`No matchUps match the requested matchUpIds`};let o=Pr(e.composition,n),s=a.map(e=>({tournamentName:o,eventName:e.eventName??``,roundName:e.roundName??e.abbreviatedRoundName??``,matchUpId:e.matchUpId,courtName:e.schedule?.courtName,scheduledTime:e.schedule?.scheduledTime,side1:yr(e,1),side2:yr(e,2)})),c;try{c=Pt(s,{cardsPerPage:2,includeScoreBoxes:!0})}catch(e){return{success:!1,error:`generateMatchCardPDF failed: ${e instanceof Error?e.message:String(e)}`}}return{success:!0,doc:c,blob:c.output(`blob`),filename:`match-cards-${s.length}.pdf`}}function Ir(e,t){if(!e.scheduledDate)return{success:!1,error:`PrintScheduleRequest requires scheduledDate`};let n=t.tournamentEngine,r=Lr(n,e.venueId);if(!r.success)return r;let i=mt({matchUps:r.matchUps,venues:r.venues,scheduledDate:e.scheduledDate}),a=vr(e.composition),o;try{o=xt(i,a)}catch(e){return{success:!1,error:`generateOrderOfPlayPDF failed: ${e instanceof Error?e.message:String(e)}`}}return{success:!0,doc:o,blob:o.output(`blob`),filename:`order-of-play-${e.scheduledDate}.pdf`}}function Lr(e,t){if(typeof e.competitionScheduleMatchUps!=`function`)return{success:!1,error:`engine.competitionScheduleMatchUps is not a function`};if(typeof e.getVenuesAndCourts!=`function`)return{success:!1,error:`engine.getVenuesAndCourts is not a function`};let n=e.competitionScheduleMatchUps()??{},r=[...n.dateMatchUps??[],...n.completedMatchUps??[]],i=t?r.filter(e=>e?.schedule?.venueId===t):r,a=(e.getVenuesAndCourts()??{}).venues??[];return{success:!0,matchUps:i,venues:t?a.filter(e=>e.venueId===t):a}}var Rr=[{value:`grand-slam`,label:`Grand Slam`,description:`Centered tournament name, uppercase, date/location right`},{value:`itf`,label:`ITF/Professional`,description:`Left-aligned name, grade/supervisor on right, separator line`},{value:`minimal`,label:`Minimal`,description:`Single line with tournament name and subtitle`},{value:`none`,label:`No Header`,description:`Skip header entirely`}],zr=[{value:`standard`,label:`Standard`,description:`Timestamp, page number, optional notes`},{value:`seedings`,label:`Seedings Table`,description:`Seeded players list in compact columns`},{value:`officials`,label:`Officials`,description:`Tournament officials with roles`},{value:`none`,label:`No Footer`,description:`Skip footer entirely`}],Br=[{value:`a4`,label:`A4 (210 × 297mm)`},{value:`letter`,label:`US Letter (216 × 279mm)`}],Vr=[{value:`auto`,label:`Auto (landscape for large draws)`},{value:`landscape`,label:`Landscape`},{value:`portrait`,label:`Portrait`}],Hr=[{value:`single-page`,label:`Single Page (dense)`},{value:`halves`,label:`Two Halves (64+64)`},{value:`quarters`,label:`Four Quarters (32×4)`}],Ur=[{id:`content`,label:`Content`,fields:[{id:`includeSeedings`,label:`Include seedings`,type:`checkbox`,defaultValue:!0,configPath:`content.draw.includeSeedings`},{id:`includeScores`,label:`Include scores`,type:`checkbox`,defaultValue:!0,configPath:`content.draw.includeScores`},{id:`showDrawPositions`,label:`Show draw positions`,type:`checkbox`,defaultValue:!0,configPath:`content.draw.showDrawPositions`},{id:`showByes`,label:`Show byes`,type:`checkbox`,defaultValue:!0,configPath:`content.draw.showByes`},{id:`splitStrategy`,label:`Split strategy`,type:`select`,options:[{value:`single-page`,label:`Single page`},{value:`halves`,label:`Split in halves`},{value:`quarters`,label:`Split in quarters`}],defaultValue:`single-page`,configPath:`content.draw.splitStrategy`}]},{id:`layout`,label:`Layout`,fields:[{id:`headerLayout`,label:`Header style`,type:`select`,options:[{value:`itf`,label:`ITF`},{value:`minimal`,label:`Minimal`},{value:`branded`,label:`Branded`}],defaultValue:`itf`,configPath:`header.layout`},{id:`orientation`,label:`Orientation`,type:`select`,options:[{value:`landscape`,label:`Landscape`},{value:`portrait`,label:`Portrait`}],defaultValue:`landscape`,configPath:`page.orientation`}]}],Wr=[{id:`content`,label:`Content`,fields:[{id:`cellStyle`,label:`Cell style`,type:`select`,options:[{value:`detailed`,label:`Detailed`},{value:`compact`,label:`Compact`}],defaultValue:`detailed`,configPath:`content.schedule.cellStyle`},{id:`showMatchNumbers`,label:`Show match numbers`,type:`checkbox`,defaultValue:!1,configPath:`content.schedule.showMatchNumbers`},{id:`alertBanner`,label:`Alert banner text`,type:`text`,configPath:`content.schedule.alertBanner`}]},{id:`layout`,label:`Layout`,fields:[{id:`headerLayout`,label:`Header style`,type:`select`,options:[{value:`itf`,label:`ITF`},{value:`minimal`,label:`Minimal`},{value:`branded`,label:`Branded`}],defaultValue:`itf`,configPath:`header.layout`}]}];function Gr(e){let{structure:t,participants:n=[]}=e;if(!t)return[];let r=new Map;n.forEach(e=>r.set(e.participantId,e));let i=t.structures||[];return i.length?i.map((e,t)=>{let n=e.positionAssignments||[],i=e.seedAssignments||[],a=n.filter(e=>e.participantId).map(e=>{let t=r.get(e.participantId),n=i.find(t=>t.participantId===e.participantId);return{participantName:t?V(t):``,nationality:t?H(t):``,seedValue:n?.seedValue,groupPosition:e.drawPosition}}).sort((e,t)=>e.groupPosition-t.groupPosition),o=[];for(let t of e.matchUps||[]){if(!t.drawPositions||t.drawPositions.length<2)continue;let[e,n]=t.drawPositions,r=ct(t.score);r&&o.push({rowPosition:e,colPosition:n,score:r,winningSide:t.winningSide})}return{groupName:e.structureName||`Group ${t+1}`,participants:a,results:o}}):[]}var Kr=[200,200,200],qr=[20,80,20],Jr=[160,40,40],Yr=[50,50,50];function Xr(e,t,r,i,a){let o=r.page.margins,s=t.participants.length;L(e,F.HEADING,P.BOLD),e.text(t.groupName,o.left,a),a+=5;let c=[`#`,`Player`,`Nat.`];for(let e=0;e<s;e++)c.push(`${e+1}`);c.push(`W`,`L`);let l=Zr(t,r),u=t.participants.map((e,t)=>{let n=[{content:`${t+1}`,styles:{fontStyle:`bold`,halign:`center`}},{content:e.participantName+(e.seedValue?` [${e.seedValue}]`:``),styles:{fontStyle:`bold`}},{content:e.nationality,styles:{halign:`center`}}];for(let e=0;e<s;e++)if(t===e)n.push({content:``,styles:{fillColor:Kr}});else{let r=l[t]?.[e];if(r){let e=r.isWin?qr:Jr;n.push({content:r.score,styles:{halign:`center`,textColor:e}})}else n.push({content:``,styles:{halign:`center`}})}let r=l[t]?.filter(e=>e?.isWin).length||0,i=l[t]?.filter(e=>e&&!e.isWin).length||0;return n.push({content:`${r}`,styles:{halign:`center`,fontStyle:`bold`}}),n.push({content:`${i}`,styles:{halign:`center`}}),n});return(0,n.default)(e,{startY:a,head:[c],body:u,styles:{fontSize:7,cellPadding:1.5,lineWidth:.2,lineColor:[150,150,150]},headStyles:{fillColor:Yr,textColor:[255,255,255],fontStyle:`bold`,halign:`center`,fontSize:7},columnStyles:{0:{cellWidth:8},1:{cellWidth:`auto`},2:{cellWidth:12}},margin:{left:o.left,right:o.right}}),e.lastAutoTable?.finalY||a+40}function Zr(e,t){let n=e.participants.length,r=Array.from({length:n},()=>Array(n).fill(null)),i=new Map;e.participants.forEach((e,t)=>i.set(e.groupPosition,t));for(let n of e.results){let e=i.get(n.rowPosition),a=i.get(n.colPosition);if(e===void 0||a===void 0)continue;let o=K(n.score,t),s=n.winningSide===1;r[e][a]={score:o,isWin:s},r[a][e]={score:Qr(o),isWin:!s}}return r}function Qr(e){return e.split(/\s+/).map(e=>{let t=e.match(/^(\d+)([/-])(\d+)(\(\d+\))?$/);return t?`${t[3]}${t[2]}${t[1]}${t[4]||``}`:e}).join(` `)}var $r={East:{name:`East`,abbreviation:`E`},West:{name:`West`,abbreviation:`W`},North:{name:`North`,abbreviation:`N`},South:{name:`South`,abbreviation:`S`},Northeast:{name:`Northeast`,abbreviation:`NE`},Northwest:{name:`Northwest`,abbreviation:`NW`},Southeast:{name:`Southeast`,abbreviation:`SE`},Southwest:{name:`Southwest`,abbreviation:`SW`}};function ei(e){let{drawDefinition:t,participants:n=[]}=e;if(!t)return{drawName:``,structures:[]};let r=new Map;n.forEach(e=>r.set(e.participantId,e));let i=[];for(let e of t.structures||[]){let t=e.structureName||``,n=$r[t]||{name:t,abbreviation:t},a=e.positionAssignments||[],o=e.seedAssignments||[],s=a.length||0,c=a.map(e=>{let t=e.participantId?r.get(e.participantId):void 0,n=o.find(t=>t.participantId===e.participantId);return{drawPosition:e.drawPosition,participantName:t?V(t):``,nationality:t?H(t):``,seedValue:n?.seedValue,isBye:e.bye===!0}}),l=(e.matchUps||[]).map(e=>({roundNumber:e.roundNumber,roundPosition:e.roundPosition,drawPositions:e.drawPositions||[],winnerDrawPosition:ge(e),score:e.score?.scoreStringSide1||``,winningSide:e.winningSide,matchUpStatus:e.matchUpStatus}));i.push({name:n.name,abbreviation:n.abbreviation,drawSize:s,slots:c,matchUps:l,totalRounds:s>0?Math.log2(s):0})}let a=i.find(e=>e.abbreviation===`E`);return{drawName:t.drawName||``,structures:i,mainStructure:a}}var ti={slotWidth:90,slotHeight:14,roundGap:20,verticalGap:4,startX:15,startY:10};function ni(e,t=ti,n){let r=Math.log2(e),i=[],a=e,o=t.slotHeight+t.verticalGap;n&&a*o>n&&(o=n/a);let s=Math.max(o*.7,5);for(let n=0;n<r;n++){let r=e/2**(n+1),a=[];for(let e=0;e<r;e++){let r=2**n*o,i=t.startY+r/2-o/2+e*r*2,c=i+r,l=t.startX+n*(t.slotWidth+t.roundGap);a.push({x:l,y:i,width:t.slotWidth,height:s},{x:l,y:c,width:t.slotWidth,height:s})}i.push(a)}return i}function ri(e,t){e.setDrawColor(150),e.setLineWidth(.3),e.rect(t.x,t.y,t.width,t.height),t.isBye?(L(e,F.SMALL,P.ITALIC),e.setTextColor(150),e.text(`Bye`,t.x+2,t.y+t.height/2+1.5),e.setTextColor(0)):t.participantName&&(t.seed?(L(e,F.TINY,P.BOLD),e.text(`[${t.seed}]`,t.x+1,t.y+t.height/2+1),L(e,F.SMALL,P.NORMAL),e.text(t.participantName,t.x+9,t.y+t.height/2+1)):(L(e,F.SMALL,P.NORMAL),e.text(t.participantName,t.x+2,t.y+t.height/2+1)),t.nationality&&(L(e,F.TINY,P.NORMAL),e.setTextColor(100),e.text(t.nationality,t.x+t.width-2,t.y+t.height/2+1,{align:`right`}),e.setTextColor(0)))}function ii(e,t,n){e.setDrawColor(100),e.setLineWidth(.3);for(let r=0;r<t.length-1;r++){let i=t[r],a=t[r+1];for(let t=0;t<i.length;t+=2){let r=i[t],o=i[t+1],s=a[Math.floor(t/2)];if(!r||!o||!s)continue;let c=r.x+r.width,l=c+n.roundGap/2,u=r.y+r.height/2,d=o.y+o.height/2,f=s.y+s.height/2;e.line(c,u,l,u),e.line(c,d,l,d),e.line(l,u,l,d),e.line(l,f,s.x,f)}}}function ai(e,t,n,r){L(e,F.TINY,P.NORMAL),e.setTextColor(60,60,180),e.text(t,n,r),e.setTextColor(0)}function oi(e,n={}){let{header:r,includeSeedings:i=!0,includeScores:a=!0}=n,o=e.drawSize>=32,s=new t.default({orientation:o?`landscape`:`portrait`,format:`a4`});I(s);let c=15;if(r){let t=`${e.drawName} - ${e.drawType.replace(/_/g,` `)} (${e.drawSize})`;c=Ot(s,{...r,subtitle:t})}return c=e.drawSize<=64&&e.drawSize>0?si(s,e,c,a):ci(s,e,c),i&&e.seedAssignments.length>0&&li(s,e,c+8),U(s,`Generated ${new Date().toLocaleDateString()}`),s}function si(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),o=i-30,s=a-n-30,c=t.totalRounds,l=Math.min(90,(o-c*10)/c),u=Math.min(14,s/t.drawSize),d={...ti,slotWidth:l,slotHeight:u,verticalGap:Math.max(1,u*.3),startX:15,startY:n},f=ni(t.drawSize,d,s),p=new Map(t.slots.map(e=>[e.drawPosition,e]));L(e,F.SMALL,P.BOLD);for(let t=0;t<c;t++){let r=d.startX+t*(d.slotWidth+d.roundGap),i=W(t+1,c);e.text(i,r+d.slotWidth/2,n-2,{align:`center`})}if(f.length>0){let n=f[0];for(let e=0;e<n.length;e++){let t=e+1,r=p.get(t);r&&(n[e].participantName=r.participantName,n[e].nationality=r.nationality,n[e].seed=r.seedValue,n[e].isBye=r.isBye)}for(let t of f)for(let n of t)ri(e,n);if(ii(e,f,d),r)for(let n of t.matchUps){if(!n.score)continue;let t=n.roundNumber-1;if(t<f.length){let r=(n.roundPosition-1)*2,i=f[t]?.[r];i&&ai(e,n.score,i.x+i.width+2,i.y+i.height+3)}}let i=f[0][f[0].length-1];return i.y+i.height+5}return n}function ci(e,t,r){let i=[{header:`Pos`,dataKey:`pos`},{header:`Seed`,dataKey:`seed`},{header:`Player`,dataKey:`name`},{header:`Nat.`,dataKey:`nat`},{header:`Entry`,dataKey:`entry`}],a=t.slots.map(e=>({pos:e.drawPosition,seed:e.seedValue?.toString()||``,name:e.isBye?`Bye`:e.participantName,nat:e.nationality,entry:e.entryStatus||``}));return(0,n.default)(e,{...kt.compact,startY:r,columns:i,body:a,columnStyles:{pos:{cellWidth:12,halign:`center`},seed:{cellWidth:12,halign:`center`},name:{cellWidth:`auto`},nat:{cellWidth:15,halign:`center`},entry:{cellWidth:15,halign:`center`}}}),e.lastAutoTable?.finalY||r+20}function li(e,t,r){L(e,F.HEADING,P.BOLD),e.text(`Seeded Players`,15,r),r+=4;let i=[{header:`Seed`,dataKey:`seed`},{header:`Player`,dataKey:`name`},{header:`Nat.`,dataKey:`nat`}],{markers:a,footnotes:o,hasAnnotations:s}=Ke(t.seedAssignments),c=t.seedAssignments.map((e,t)=>({seed:[e.seedValue,a[t]].filter(Boolean).join(` `),name:e.participantName,nat:e.nationality}));(0,n.default)(e,{...kt.compact,startY:r,columns:i,body:c,tableWidth:120,columnStyles:{seed:{cellWidth:15,halign:`center`,fontStyle:`bold`},name:{cellWidth:`auto`},nat:{cellWidth:20,halign:`center`}}});let l=e.lastAutoTable?.finalY||r+20;if(s){l+=3,L(e,F.TINY,P.ITALIC);for(let t of o)e.text(t,15,l),l+=3;L(e,F.BODY,P.NORMAL)}return l}function ui(e,r={}){let{header:i,fullCourtNames:a=!0,notes:o}=r,s=(r.landscape===`auto`?e.courts.length>=5:r.landscape)?`landscape`:`portrait`,c=new t.default({orientation:s,format:`a4`});I(c);let l=15;if(i){let t=e.scheduledDate?`Order of Play - ${e.scheduledDate}`:`Order of Play`;l=Ot(c,{...i,subtitle:t})}let u=e.courts,d=a?u:u.map(fi);for(let t of e.timeSlots){L(c,F.BODY,P.BOLD),c.setTextColor(30,60,120),c.text(t.label,15,l),c.setTextColor(0),l+=4;let e=d.map(e=>({header:e,dataKey:e})),r=new Map;u.forEach(e=>r.set(e,[]));for(let e of t.matches){let t=di(e),n=r.get(e.courtName)||[];n.push(t),r.set(e.courtName,n)}let o=Math.max(1,...Array.from(r.values()).map(e=>e.length)),s=[];for(let e=0;e<o;e++){let t={};u.forEach((n,i)=>{let o=r.get(n)||[],s=a?n:d[i];t[s]=o[e]||``}),s.push(t)}(0,n.default)(c,{...kt.schedule,startY:l,columns:e,body:s,tableWidth:`auto`,didDrawPage:e=>{U(c,i?.tournamentName||``,e.pageNumber)}}),l=c.lastAutoTable?.finalY+6||l+20}if(o?.length){l+=4,L(c,F.SMALL,P.ITALIC),c.setTextColor(80);for(let e of o)c.text(e,15,l),l+=4;c.setTextColor(0)}return c}function di(e){let t=[];return t.push(`${e.eventAbbr} ${e.roundName}`),t.push(`${e.side1.name} (${e.side1.nationality})`),t.push(`vs ${e.side2.name} (${e.side2.nationality})`),e.score&&t.push(e.score),t.join(`
|