pdf-factory 1.1.3 → 1.1.4
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/composition/resolveCompositionConfig.d.ts +10 -8
- package/dist/composition/resolveCompositionConfig.d.ts.map +1 -1
- package/dist/pdf-factory.cjs +1 -1
- package/dist/pdf-factory.cjs.map +1 -1
- package/dist/pdf-factory.js +78 -69
- package/dist/pdf-factory.js.map +1 -1
- package/package.json +2 -2
|
@@ -8,7 +8,8 @@ interface ProviderConfigShape {
|
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
/** A tournament record, event or drawDefinition: anything that can hold the factory's `appliedPolicies` extension. */
|
|
12
|
+
interface PolicyElementShape {
|
|
12
13
|
extensions?: {
|
|
13
14
|
name: string;
|
|
14
15
|
value: any;
|
|
@@ -18,17 +19,18 @@ export interface ResolveCompositionConfigParams {
|
|
|
18
19
|
/**
|
|
19
20
|
* Provider config object as delivered to the client at login. The
|
|
20
21
|
* resolver reads `providerConfigSettings.policies.printPolicies[printType]`.
|
|
21
|
-
* Pass `undefined` if no provider context is available
|
|
22
|
-
* resolution starts from the tournament override (or the runtime layer,
|
|
23
|
-
* or the empty config).
|
|
22
|
+
* Pass `undefined` if no provider context is available.
|
|
24
23
|
*/
|
|
25
24
|
providerConfig?: ProviderConfigShape;
|
|
26
25
|
/**
|
|
27
|
-
* The tournament record (as held by tournamentEngine)
|
|
28
|
-
*
|
|
29
|
-
* and reads `extension.value[printType]`.
|
|
26
|
+
* The full tournament record (as held by tournamentEngine), not `getTournamentInfo()` output, which has no
|
|
27
|
+
* `extensions`. The resolver reads its own `appliedPolicies.print[printType]`.
|
|
30
28
|
*/
|
|
31
|
-
tournamentRecord?:
|
|
29
|
+
tournamentRecord?: PolicyElementShape;
|
|
30
|
+
/** The event the print belongs to, if any. Its own `appliedPolicies.print[printType]` overlays the tournament's. */
|
|
31
|
+
event?: PolicyElementShape;
|
|
32
|
+
/** The drawDefinition the print belongs to, if any. Its own print policy overlays the event's. */
|
|
33
|
+
drawDefinition?: PolicyElementShape;
|
|
32
34
|
/**
|
|
33
35
|
* Which print type's config to resolve.
|
|
34
36
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveCompositionConfig.d.ts","sourceRoot":"","sources":["../../src/composition/resolveCompositionConfig.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"resolveCompositionConfig.d.ts","sourceRoot":"","sources":["../../src/composition/resolveCompositionConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,MAAM,SAAS,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;AAK7C,UAAU,mBAAmB;IAC3B,sBAAsB,CAAC,EAAE;QACvB,QAAQ,CAAC,EAAE;YACT,aAAa,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;SACxE,CAAC;KACH,CAAC;CACH;AAED,sHAAsH;AACtH,UAAU,kBAAkB;IAC1B,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,GAAG,CAAA;KAAE,EAAE,CAAC;CAC7C;AAED,MAAM,WAAW,8BAA8B;IAC7C;;;;OAIG;IACH,cAAc,CAAC,EAAE,mBAAmB,CAAC;IACrC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,kBAAkB,CAAC;IACtC,oHAAoH;IACpH,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B,kGAAkG;IAClG,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC;;OAEG;IACH,SAAS,EAAE,SAAS,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACtC;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,8BAA8B,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAY3G"}
|
package/dist/pdf-factory.cjs
CHANGED
|
@@ -2,5 +2,5 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
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(`
|
|
5
|
-
`)}function fi(e){return e.replace(/^Court\s*/i,`Ct `)}var pi=`print`;function mi(e){let{providerConfig:t,tournamentRecord:n,printType:r,runtime:i}=e;return hi(hi(t?.providerConfigSettings?.policies?.printPolicies?.[r]??{},(n?.extensions?.find(e=>e.name===pi))?.value?.[r]??{}),i??{})}function hi(e,t){let n={...e};for(let e of Object.keys(t)){let r=t[e];if(r===void 0)continue;let i=n[e];n[e]=gi(i)&&gi(r)?hi(i,r):r}return n}function gi(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}var _i=[120,50,140];function vi(e,t={}){let n={pageSize:t.page?.pageSize||`a4`,orientation:t.page?.orientation||`portrait`,margins:t.page?.margins||{top:12,right:15,bottom:12,left:15}},r=Te(n),{margins:i}=n,a=r.internal.pageSize.getWidth(),o=r.internal.pageSize.getHeight(),s=a-i.left-i.right,c=t.accentColor||_i,l=t.footer||{layout:`none`},u=B(l),d=i.top;t.header&&(d=i.top+z(r,t.header,n)+3);let f=Ci(e);for(let[e,a]of f){d+30>o-i.bottom-u&&(wi(r,t,n,l),r.addPage(),d=i.top),d=yi(r,e,i.left,d,s);let f=``;for(let e of a){let a=e.scheduledTime||e.notBeforeTime||``;a&&a!==f&&(d+25>o-i.bottom-u&&(wi(r,t,n,l),r.addPage(),d=i.top),d=bi(r,a,!!e.notBeforeTime,i.left,d,s,c),f=a),d+22>o-i.bottom-u&&(wi(r,t,n,l),r.addPage(),d=i.top),d=xi(r,e,i.left,d,s)}d+=4}return t.disclaimer&&(d+=2,L(r,F.TINY,P.ITALIC),r.setTextColor(100),r.text(t.disclaimer,a/2,d,{align:`center`}),r.setTextColor(0)),wi(r,t,n,l),r}function yi(e,t,n,r,i){return L(e,F.HEADING,P.BOLD),e.setTextColor(40),e.text(t.toUpperCase(),n+i/2,r,{align:`center`}),e.setTextColor(0),r+7}function bi(e,t,n,r,i,a,o){let s=n?`Not before ${t}`:`Starting at ${t}`;return e.setFillColor(o[0],o[1],o[2]),e.rect(r+20,i,a-40,5,`F`),L(e,F.SMALL,P.ITALIC),e.setTextColor(255,255,255),e.text(s,r+a/2,i+3.5,{align:`center`}),e.setTextColor(0),i+7}function xi(e,t,n,r,i){let a=n+15,o=i-30,s=r;L(e,F.TINY,P.ITALIC),e.setTextColor(100);let c=t.eventAbbr?`${t.eventAbbr} ${t.roundName}`:t.roundName;e.text(c,a+o-2,r+3,{align:`right`}),e.setTextColor(0),t.score&&(L(e,F.SMALL,P.BOLD),e.setTextColor(120,50,140),e.text(t.score,a+o/2,r+3,{align:`center`}),e.setTextColor(0),r+=4),r+=2,r=Si(e,t.side1,a,r,o),L(e,F.TINY,P.ITALIC),e.setTextColor(120),e.text(`vs`,a+o/2,r+2.5,{align:`center`}),e.setTextColor(0),r+=4,r=Si(e,t.side2,a,r,o),r+=2;let l=r-s;return e.setDrawColor(180),e.setLineWidth(.3),e.rect(a,s,o,l),r+2}function Si(e,t,n,r,i){if(!t.name||t.name===`TBD`)return L(e,F.BODY,P.ITALIC),e.setTextColor(150),e.text(`TBD`,n+10,r+3),e.setTextColor(0),r+4;L(e,F.BODY,P.NORMAL);let a=t.nationality?`${t.name} ${t.nationality}`:t.name;return e.text(a,n+10,r+3),r+4}function Ci(e){let t=new Map;for(let n of e.courts)t.set(n,[]);for(let n of e.timeSlots)for(let e of n.matches)t.has(e.courtName)||t.set(e.courtName,[]),t.get(e.courtName).push(e);for(let[e,n]of t)n.length===0&&t.delete(e);return t}function wi(e,t,n,r){let{margins:i}=n,a=e.internal.pageSize.getWidth(),o=e.internal.pageSize.getHeight();if(t.officials?.length){let n=o-i.bottom-10;e.setDrawColor(120),e.setLineWidth(.2),e.line(i.left,n-2,a-i.right,n-2);let r=(a-i.left-i.right)/t.officials.length;t.officials.forEach((t,a)=>{let o=i.left+a*r;L(e,F.TINY,P.BOLD),e.text(t.role,o,n),L(e,F.TINY,P.NORMAL),e.text(t.name,o,n+3)})}qe(e,r,n)}var Ti=.2645833;function Ei(e){let t={};for(let n of e){let e={};n.type===`number`&&(e.halign=`right`),n.width?e.cellWidth=Math.round(n.width*Ti*10)/10:n.fitData&&(e.cellWidth=`wrap`),Object.keys(e).length&&(t[n.key]=e)}return t}function Di(e,r,i={}){let a=i.orientation||`landscape`,o=new t.default({orientation:a,format:`a4`});I(o);let s=15;if(i.header?s=Ot(o,{...i.header,subtitle:i.header.subtitle||i.title}):i.title&&(L(o,F.SUBTITLE,P.BOLD),o.text(i.title,15,s),s+=8),e.length===0)return L(o,F.BODY,P.ITALIC),o.text(`No columns defined`,15,s),U(o,`Generated ${new Date().toLocaleDateString()}`,1),o;let c=e.map(e=>({header:e.title,dataKey:e.key})),l=r.map(t=>{let n={};for(let r of e){let e=t[r.key];n[r.key]=e==null?``:String(e)}return n}),u=Ei(e);return(0,n.default)(o,{...kt.report,startY:s,columns:c,body:l,columnStyles:u,didDrawPage:e=>{U(o,`Generated ${new Date().toLocaleDateString()}`,e.pageNumber)}}),o}var Z=15;function Oi(e){if(typeof document<`u`){let t=document.createElement(`div`);return t.innerHTML=e,t.textContent||``}let t=``,n=!1;for(let r of e)r===`<`?n=!0:r===`>`?n=!1:n||(t+=r);return t.trim()}function Q(e,t,n){return L(e,F.HEADING,P.BOLD),e.setTextColor(40),e.text(t.toUpperCase(),Z,n),e.setTextColor(0),n+=1.5,e.setDrawColor(180),e.setLineWidth(.2),e.line(Z,n,e.internal.pageSize.getWidth()-Z,n),n+=4,n}function ki(e,t,n,r){L(e,F.BODY,P.NORMAL);let i=r||e.internal.pageSize.getWidth()-30,a=e.splitTextToSize(t,i);return e.text(a,Z,n),n+a.length*3.2}function $(e,t,n){let r=e.internal.pageSize.getHeight();return t+n>r-20?(e.addPage(),20):t}function Ai(e,t,n){let r={pageSize:`a4`,orientation:`portrait`,margins:{top:n,right:Z,bottom:15,left:Z}};return n+z(e,Ve(t,{layout:`itf`}),r)}function ji(e,t,r){let i=(t.participants||[]).filter(e=>e.participantRole&&e.participantRole!==`COMPETITOR`);if(!i.length)return r;r=$(e,r,20),r=Q(e,`Tournament Contacts`,r);let a=i.map(e=>{let t=e.person||{},n=[t.standardGivenName,t.standardFamilyName].filter(Boolean).join(` `)||e.participantName||``,r=e.participantRoleResponsibilities?.[0]||e.participantRole||``,i=t.contacts?.[0]||{};return[n,r,[i.emailAddress,i.telephone||i.mobileTelephone].filter(Boolean).join(` | `)]});return(0,n.default)(e,{startY:r,head:[[`Name`,`Role`,`Contact`]],body:a,margin:{left:Z,right:Z},styles:{fontSize:7,cellPadding:1.5},headStyles:{fillColor:[60,60,60],textColor:255,fontStyle:`bold`},theme:`grid`}),e.lastAutoTable.finalY+6}function Mi(e,t,r){let i=t.events||[];if(!i.length)return r;r=$(e,r,20),r=Q(e,`Events`,r);let a=i.map(e=>{let t=e.drawDefinitions?.[0]?.drawSize||``;return[e.eventName||``,e.eventType||``,e.matchUpFormat||``,String(t)]});return(0,n.default)(e,{startY:r,head:[[`Event`,`Type`,`Format`,`Draw Size`]],body:a,margin:{left:Z,right:Z},styles:{fontSize:7,cellPadding:1.5},headStyles:{fillColor:[60,60,60],textColor:255,fontStyle:`bold`},theme:`grid`}),e.lastAutoTable.finalY+6}function Ni(e,t,n){let r=t.registrationProfile;if(!r)return n;let i=[];if(r.entriesOpen&&i.push(`Entries Open: `+r.entriesOpen),r.entriesClose&&i.push(`Entries Close: `+r.entriesClose),r.withdrawalDeadline&&i.push(`Withdrawal Deadline: `+r.withdrawalDeadline),r.entryMethod&&i.push(`Entry Method: `+r.entryMethod),r.entryUrl&&i.push(`Entry URL: `+r.entryUrl),r.eligibilityNotes&&i.push(`Eligibility: `+r.eligibilityNotes),r.entryFees?.length){let e=r.entryFees.map(e=>(e.eventType?e.eventType+`: `:``)+e.currencyCode+` `+e.amount).join(`, `);i.push(`Entry Fees: `+e)}if(!i.length)return n;n=$(e,n,10+i.length*3.5),n=Q(e,`Entry Information`,n),L(e,F.BODY,P.NORMAL);for(let t of i)e.text(t,Z,n),n+=3.5;return n+3}function Pi(e,t,n){let r=t.venues||[];if(!r.length)return n;n=$(e,n,15),n=Q(e,`Venue`,n),L(e,F.BODY,P.NORMAL);for(let t of r){L(e,F.BODY,P.BOLD),e.text(t.venueName||`Venue`,Z,n),n+=3.5,L(e,F.BODY,P.NORMAL);let r=t.addresses?.[0];if(r){let t=[r.street,r.city,r.state,r.postalCode,r.countryCode].filter(Boolean);t.length&&(e.text(t.join(`, `),Z,n),n+=3.5)}let i=t.courts?.length;i&&(e.text(`Courts: `+i,Z,n),n+=3.5)}return n+3}function Fi(e,t,r,i){if(!r)return i;let a=r.options?.length,o=r.notes&&Oi(r.notes);if(!a&&!o)return i;if(i=$(e,i,15),i=Q(e,t,i),a){let t=r.options.map(e=>{let t=[e.phone,e.email,e.priceRange].filter(Boolean).join(` | `);return[e.name,e.address||``,t]});(0,n.default)(e,{startY:i,head:[[`Name`,`Address`,`Details`]],body:t,margin:{left:Z,right:Z},styles:{fontSize:7,cellPadding:1.5},headStyles:{fillColor:[60,60,60],textColor:255,fontStyle:`bold`},theme:`grid`}),i=e.lastAutoTable.finalY+3}return o&&(i=ki(e,Oi(r.notes),i)),i+3}function Ii(e,t,n){let r=t.totalPrizeMoney;if(!r?.length)return n;n=$(e,n,10),n=Q(e,`Prize Money`,n),L(e,F.BODY,P.NORMAL);for(let t of r)e.text(t.currencyCode+` `+t.amount.toLocaleString(),Z,n),n+=3.5;return n+3}function Li(e,t,r){let i=(t.participants||[]).filter(e=>e.participantRole===`OFFICIAL`||e.participantRole===`DIRECTOR`);if(!i.length)return r;r=$(e,r,15),r=Q(e,`Officials`,r);let a=i.map(e=>{let t=e.person||{};return[[t.standardGivenName,t.standardFamilyName].filter(Boolean).join(` `)||e.participantName||``,e.participantRoleResponsibilities?.[0]||e.participantRole||``]});return(0,n.default)(e,{startY:r,head:[[`Name`,`Role`]],body:a,margin:{left:Z,right:Z},styles:{fontSize:7,cellPadding:1.5},headStyles:{fillColor:[60,60,60],textColor:255,fontStyle:`bold`},theme:`grid`}),e.lastAutoTable.finalY+6}function Ri(e,t,n){let r=t.registrationProfile;if(!r)return n;let i=[];if(r.codeOfConduct){let e=r.codeOfConduct;i.push(`Code of Conduct: `+(e.name||``)+(e.url?` — `+e.url:``))}if(r.regulations?.length)for(let e of r.regulations)i.push((e.name||`Regulation`)+(e.url?` — `+e.url:``));if(r.dressCode&&i.push(`Dress Code: `+r.dressCode),r.contingencyPlan&&i.push(`Contingency: `+r.contingencyPlan),!i.length)return n;n=$(e,n,10+i.length*3.5),n=Q(e,`Regulations`,n),L(e,F.BODY,P.NORMAL);for(let t of i)e.text(t,Z,n),n+=3.5;return n+3}function zi(e,t,n){let r=t.registrationProfile?.sponsors;if(!r?.length)return n;n=$(e,n,10),n=Q(e,`Sponsors`,n),L(e,F.BODY,P.NORMAL);for(let t of r){let r=t.tier?` [`+t.tier+`]`:``;e.text(t.name+r,Z,n),n+=3.5}return n+3}function Bi(e,t,n){let r=t.registrationProfile?.socialEvents;if(!r?.length)return n;let i=t.registrationProfile;n=$(e,n,15),n=Q(e,`Social Events & Ceremonies`,n),L(e,F.BODY,P.NORMAL),i?.drawCeremonyDate&&(e.text(`Draw Ceremony: `+i.drawCeremonyDate,Z,n),n+=3.5),i?.awardsCeremonyDate&&(e.text(`Awards Ceremony: `+i.awardsCeremonyDate,Z,n),n+=3.5);for(let t of r){L(e,F.BODY,P.BOLD),e.text(t.name,Z,n),n+=3.5,L(e,F.BODY,P.NORMAL);let r=[t.date,t.time,t.location].filter(Boolean).join(` | `);r&&(e.text(r,Z,n),n+=3.5),t.description&&(e.text(t.description,Z,n),n+=3.5)}return n+3}function Vi(e,t,n){let r=t.notes;if(!r)return n;let i=Oi(r);return i?(n=$(e,n,15),n=Q(e,`Additional Information`,n),n=ki(e,i,n),n+3):n}var Hi={"tournament-header":Ai,contacts:ji,events:Mi,"entry-info":Ni,"venue-info":Pi,accommodation:(e,t,n)=>Fi(e,`Accommodation`,t.registrationProfile?.accommodation,n),transportation:(e,t,n)=>Fi(e,`Transportation`,t.registrationProfile?.transportation,n),hospitality:(e,t,n)=>Fi(e,`Hospitality`,t.registrationProfile?.hospitality,n),medical:(e,t,n)=>Fi(e,`Medical`,t.registrationProfile?.medicalInfo,n),regulations:Ri,"prize-money":Ii,officials:Li,sponsors:zi,"social-events":Bi,"custom-notes":Vi};function Ui(e,n={}){let{templateId:r=`itf-junior`}=n,i=pe(r)?.sections||pe(`itf-junior`).sections,a=n.enabledSections?new Set(n.enabledSections):null,o=new t.default({orientation:`portrait`,format:`a4`});I(o);let s=Z;for(let t of i){if(!t.enabled||a&&!a.has(t.type))continue;let n=Hi[t.type];n&&(s=n(o,e,s))}let c=o.getNumberOfPages();for(let e=1;e<=c;e++)o.setPage(e),U(o,`Generated `+new Date().toLocaleDateString(),e);return o}function Wi(e,t={}){let n=e?.drawsData||[],r=e?.tournamentInfo||{},i=e?.eventInfo||{},a=ee(t.catalogPreset||`club-basic`),o=_(a?.drawFormatPreset||`itfJunior`),s={layout:`itf`,tournamentName:r.tournamentName||`Tournament`,...a?.header,subtitle:i.eventName||a?.header?.subtitle,startDate:r.startDate,endDate:r.endDate,location:r.venues?.[0]?.venueName,city:r.venues?.[0]?.city,country:r.hostCountryCode,surface:i.surfaceCategory,...t.headerOverrides},c={layout:`standard`,showPageNumbers:!0,showTimestamp:!0,...a?.footer,...t.footerOverrides},l=n?.[0]?.structures||[],u=l.some(e=>e.stage===`CONSOLATION`),d=l.some(e=>e.stage===`PLAY_OFF`),f=l.find(e=>e.stage===`MAIN`),p={header:s,footer:c,format:o};if(u&&d)return hr({winnersBracket:f?M(f):Gi(),losersBracket:N(n,`CONSOLATION`)?M(N(n,`CONSOLATION`)):Gi(),deciderMatch:N(n,`PLAY_OFF`)?M(N(n,`PLAY_OFF`)):void 0},p);if(u)return dr(l.map(e=>({name:e.structureName,stage:e.stage,drawData:M(e)})),p);let m=t.structureId&&l.find(e=>e.structureId===t.structureId)||f;if(!m)return Te({pageSize:`a4`,orientation:`portrait`,margins:{top:12,right:15,bottom:12,left:15}});let h=M(m);return t.mirrored?pr(h,p):t.splitPages||h.drawSize>=256?lr(h,{...p,maxPositionsPerPage:t.maxPositionsPerPage||32}):cr(h,p)}function Gi(){return{drawName:``,drawSize:0,drawType:``,totalRounds:0,slots:[],matchUps:[],seedAssignments:[]}}exports.COMPOSITION_CATALOG=C,exports.DRAW_MODAL_TABS=Ur,exports.FACT_SHEET_CATALOG=fe,exports.FONT=_e,exports.FOOTER_LAYOUT_OPTIONS=zr,exports.HEADER_LAYOUT_OPTIONS=Rr,exports.ORIENTATION_OPTIONS=Vr,exports.PAGE_SIZE_OPTIONS=Br,exports.PRESETS=g,exports.SCHEDULE_MODAL_TABS=Wr,exports.SIZE=F,exports.SPLIT_STRATEGY_OPTIONS=Hr,exports.STYLE=P,exports.TABLE_STYLES=kt,exports.activeFontFamily=xe,exports.applyDefaultFont=I,exports.buildFooterFromTournament=He,exports.buildHeaderFromTournament=Ve,exports.calculateBracketPositions=ni,exports.createDoc=Te,exports.drawBracketConnectors=ii,exports.drawBracketSlot=ri,exports.drawPageFooter=U,exports.drawTournamentHeader=Ot,exports.entryStatusDisplay=st,exports.eventAbbreviation=dt,exports.executePrint=br,exports.extractCompassData=ei,exports.extractConsolationStructures=Gn,exports.extractCourtCardData=vt,exports.extractDrawData=Lt,exports.extractParticipantData=gt,exports.extractRoundRobinData=Gr,exports.extractScheduleData=mt,exports.findStructure=N,exports.formatDate=lt,exports.formatMatchScore=K,exports.formatPlayerEntry=Bt,exports.formatScore=ct,exports.formatTime=ut,exports.generateBackdrawPDF=mr,exports.generateCompassDrawPDF=fr,exports.generateConsolationDrawPDF=dr,exports.generateCourtCardPDF=Mt,exports.generateDoubleEliminationPDF=hr,exports.generateDrawPDF=or,exports.generateDrawSheetPDF=oi,exports.generateFactSheet=Ui,exports.generateFeedInDrawPDF=ur,exports.generateFromEventData=Wi,exports.generateLuckyDrawPDF=gr,exports.generateMatchCardPDF=Pt,exports.generateMirroredDrawPDF=pr,exports.generateOrderOfPlayPDF=xt,exports.generateScheduleV2PDF=xt,exports.generatePlayerListPDF=At,exports.generateReportPDF=Di,exports.generateSchedulePDF=ui,exports.generateSequentialOOP=vi,exports.generateSignInSheetPDF=jt,exports.generateSplitDrawPDF=lr,exports.generateTraditionalDrawPDF=cr,exports.getCatalogPreset=ee,exports.getDefaultFont=we,exports.getDefaultPageConfig=Ee,exports.getFactSheetTemplate=pe,exports.getPageRegions=R,exports.getPreset=_,exports.getRoundLabel=W,exports.listCatalogPresets=te,exports.listFactSheetTemplates=me,exports.measureFooterHeight=B,exports.measureSeedingsHeight=at,exports.mergeCatalogPreset=ne,exports.mergePreset=v,exports.nationality=H,exports.participantName=V,exports.registerFont=be,exports.renderCompassDraw=Hn,exports.renderConsolationDraw=Kn,exports.renderDoubleEliminationDraw=qn,exports.renderFooter=qe,exports.renderHeader=z,exports.renderLuckyDraw=Qn,exports.renderRoundRobinGroup=Xr,exports.renderSeedingsFooter=rt,exports.renderTraditionalDraw=q,exports.resolveCompositionConfig=mi,exports.roundName=ft,exports.seedDisplay=ot,exports.setDefaultFont=Ce,exports.setFont=L,exports.splitDraw=tr,exports.structureToDrawData=M;
|
|
5
|
+
`)}function fi(e){return e.replace(/^Court\s*/i,`Ct `)}var pi=`appliedPolicies`,mi=`print`;function hi(e){let{providerConfig:t,tournamentRecord:n,event:r,drawDefinition:i,printType:a,runtime:o}=e;return[t?.providerConfigSettings?.policies?.printPolicies?.[a]??{},gi(n,a),gi(r,a),gi(i,a),o??{}].reduce((e,t)=>_i(e,t),{})}function gi(e,t){return(e?.extensions?.find(e=>e?.name===pi)?.value)?.[mi]?.[t]??{}}function _i(e,t){let n={...e};for(let e of Object.keys(t)){let r=t[e];if(r===void 0)continue;let i=n[e];n[e]=vi(i)&&vi(r)?_i(i,r):r}return n}function vi(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}var yi=[120,50,140];function bi(e,t={}){let n={pageSize:t.page?.pageSize||`a4`,orientation:t.page?.orientation||`portrait`,margins:t.page?.margins||{top:12,right:15,bottom:12,left:15}},r=Te(n),{margins:i}=n,a=r.internal.pageSize.getWidth(),o=r.internal.pageSize.getHeight(),s=a-i.left-i.right,c=t.accentColor||yi,l=t.footer||{layout:`none`},u=B(l),d=i.top;t.header&&(d=i.top+z(r,t.header,n)+3);let f=Ti(e);for(let[e,a]of f){d+30>o-i.bottom-u&&(Ei(r,t,n,l),r.addPage(),d=i.top),d=xi(r,e,i.left,d,s);let f=``;for(let e of a){let a=e.scheduledTime||e.notBeforeTime||``;a&&a!==f&&(d+25>o-i.bottom-u&&(Ei(r,t,n,l),r.addPage(),d=i.top),d=Si(r,a,!!e.notBeforeTime,i.left,d,s,c),f=a),d+22>o-i.bottom-u&&(Ei(r,t,n,l),r.addPage(),d=i.top),d=Ci(r,e,i.left,d,s)}d+=4}return t.disclaimer&&(d+=2,L(r,F.TINY,P.ITALIC),r.setTextColor(100),r.text(t.disclaimer,a/2,d,{align:`center`}),r.setTextColor(0)),Ei(r,t,n,l),r}function xi(e,t,n,r,i){return L(e,F.HEADING,P.BOLD),e.setTextColor(40),e.text(t.toUpperCase(),n+i/2,r,{align:`center`}),e.setTextColor(0),r+7}function Si(e,t,n,r,i,a,o){let s=n?`Not before ${t}`:`Starting at ${t}`;return e.setFillColor(o[0],o[1],o[2]),e.rect(r+20,i,a-40,5,`F`),L(e,F.SMALL,P.ITALIC),e.setTextColor(255,255,255),e.text(s,r+a/2,i+3.5,{align:`center`}),e.setTextColor(0),i+7}function Ci(e,t,n,r,i){let a=n+15,o=i-30,s=r;L(e,F.TINY,P.ITALIC),e.setTextColor(100);let c=t.eventAbbr?`${t.eventAbbr} ${t.roundName}`:t.roundName;e.text(c,a+o-2,r+3,{align:`right`}),e.setTextColor(0),t.score&&(L(e,F.SMALL,P.BOLD),e.setTextColor(120,50,140),e.text(t.score,a+o/2,r+3,{align:`center`}),e.setTextColor(0),r+=4),r+=2,r=wi(e,t.side1,a,r,o),L(e,F.TINY,P.ITALIC),e.setTextColor(120),e.text(`vs`,a+o/2,r+2.5,{align:`center`}),e.setTextColor(0),r+=4,r=wi(e,t.side2,a,r,o),r+=2;let l=r-s;return e.setDrawColor(180),e.setLineWidth(.3),e.rect(a,s,o,l),r+2}function wi(e,t,n,r,i){if(!t.name||t.name===`TBD`)return L(e,F.BODY,P.ITALIC),e.setTextColor(150),e.text(`TBD`,n+10,r+3),e.setTextColor(0),r+4;L(e,F.BODY,P.NORMAL);let a=t.nationality?`${t.name} ${t.nationality}`:t.name;return e.text(a,n+10,r+3),r+4}function Ti(e){let t=new Map;for(let n of e.courts)t.set(n,[]);for(let n of e.timeSlots)for(let e of n.matches)t.has(e.courtName)||t.set(e.courtName,[]),t.get(e.courtName).push(e);for(let[e,n]of t)n.length===0&&t.delete(e);return t}function Ei(e,t,n,r){let{margins:i}=n,a=e.internal.pageSize.getWidth(),o=e.internal.pageSize.getHeight();if(t.officials?.length){let n=o-i.bottom-10;e.setDrawColor(120),e.setLineWidth(.2),e.line(i.left,n-2,a-i.right,n-2);let r=(a-i.left-i.right)/t.officials.length;t.officials.forEach((t,a)=>{let o=i.left+a*r;L(e,F.TINY,P.BOLD),e.text(t.role,o,n),L(e,F.TINY,P.NORMAL),e.text(t.name,o,n+3)})}qe(e,r,n)}var Di=.2645833;function Oi(e){let t={};for(let n of e){let e={};n.type===`number`&&(e.halign=`right`),n.width?e.cellWidth=Math.round(n.width*Di*10)/10:n.fitData&&(e.cellWidth=`wrap`),Object.keys(e).length&&(t[n.key]=e)}return t}function ki(e,r,i={}){let a=i.orientation||`landscape`,o=new t.default({orientation:a,format:`a4`});I(o);let s=15;if(i.header?s=Ot(o,{...i.header,subtitle:i.header.subtitle||i.title}):i.title&&(L(o,F.SUBTITLE,P.BOLD),o.text(i.title,15,s),s+=8),e.length===0)return L(o,F.BODY,P.ITALIC),o.text(`No columns defined`,15,s),U(o,`Generated ${new Date().toLocaleDateString()}`,1),o;let c=e.map(e=>({header:e.title,dataKey:e.key})),l=r.map(t=>{let n={};for(let r of e){let e=t[r.key];n[r.key]=e==null?``:String(e)}return n}),u=Oi(e);return(0,n.default)(o,{...kt.report,startY:s,columns:c,body:l,columnStyles:u,didDrawPage:e=>{U(o,`Generated ${new Date().toLocaleDateString()}`,e.pageNumber)}}),o}var Z=15;function Ai(e){if(typeof document<`u`){let t=document.createElement(`div`);return t.innerHTML=e,t.textContent||``}let t=``,n=!1;for(let r of e)r===`<`?n=!0:r===`>`?n=!1:n||(t+=r);return t.trim()}function Q(e,t,n){return L(e,F.HEADING,P.BOLD),e.setTextColor(40),e.text(t.toUpperCase(),Z,n),e.setTextColor(0),n+=1.5,e.setDrawColor(180),e.setLineWidth(.2),e.line(Z,n,e.internal.pageSize.getWidth()-Z,n),n+=4,n}function ji(e,t,n,r){L(e,F.BODY,P.NORMAL);let i=r||e.internal.pageSize.getWidth()-30,a=e.splitTextToSize(t,i);return e.text(a,Z,n),n+a.length*3.2}function $(e,t,n){let r=e.internal.pageSize.getHeight();return t+n>r-20?(e.addPage(),20):t}function Mi(e,t,n){let r={pageSize:`a4`,orientation:`portrait`,margins:{top:n,right:Z,bottom:15,left:Z}};return n+z(e,Ve(t,{layout:`itf`}),r)}function Ni(e,t,r){let i=(t.participants||[]).filter(e=>e.participantRole&&e.participantRole!==`COMPETITOR`);if(!i.length)return r;r=$(e,r,20),r=Q(e,`Tournament Contacts`,r);let a=i.map(e=>{let t=e.person||{},n=[t.standardGivenName,t.standardFamilyName].filter(Boolean).join(` `)||e.participantName||``,r=e.participantRoleResponsibilities?.[0]||e.participantRole||``,i=t.contacts?.[0]||{};return[n,r,[i.emailAddress,i.telephone||i.mobileTelephone].filter(Boolean).join(` | `)]});return(0,n.default)(e,{startY:r,head:[[`Name`,`Role`,`Contact`]],body:a,margin:{left:Z,right:Z},styles:{fontSize:7,cellPadding:1.5},headStyles:{fillColor:[60,60,60],textColor:255,fontStyle:`bold`},theme:`grid`}),e.lastAutoTable.finalY+6}function Pi(e,t,r){let i=t.events||[];if(!i.length)return r;r=$(e,r,20),r=Q(e,`Events`,r);let a=i.map(e=>{let t=e.drawDefinitions?.[0]?.drawSize||``;return[e.eventName||``,e.eventType||``,e.matchUpFormat||``,String(t)]});return(0,n.default)(e,{startY:r,head:[[`Event`,`Type`,`Format`,`Draw Size`]],body:a,margin:{left:Z,right:Z},styles:{fontSize:7,cellPadding:1.5},headStyles:{fillColor:[60,60,60],textColor:255,fontStyle:`bold`},theme:`grid`}),e.lastAutoTable.finalY+6}function Fi(e,t,n){let r=t.registrationProfile;if(!r)return n;let i=[];if(r.entriesOpen&&i.push(`Entries Open: `+r.entriesOpen),r.entriesClose&&i.push(`Entries Close: `+r.entriesClose),r.withdrawalDeadline&&i.push(`Withdrawal Deadline: `+r.withdrawalDeadline),r.entryMethod&&i.push(`Entry Method: `+r.entryMethod),r.entryUrl&&i.push(`Entry URL: `+r.entryUrl),r.eligibilityNotes&&i.push(`Eligibility: `+r.eligibilityNotes),r.entryFees?.length){let e=r.entryFees.map(e=>(e.eventType?e.eventType+`: `:``)+e.currencyCode+` `+e.amount).join(`, `);i.push(`Entry Fees: `+e)}if(!i.length)return n;n=$(e,n,10+i.length*3.5),n=Q(e,`Entry Information`,n),L(e,F.BODY,P.NORMAL);for(let t of i)e.text(t,Z,n),n+=3.5;return n+3}function Ii(e,t,n){let r=t.venues||[];if(!r.length)return n;n=$(e,n,15),n=Q(e,`Venue`,n),L(e,F.BODY,P.NORMAL);for(let t of r){L(e,F.BODY,P.BOLD),e.text(t.venueName||`Venue`,Z,n),n+=3.5,L(e,F.BODY,P.NORMAL);let r=t.addresses?.[0];if(r){let t=[r.street,r.city,r.state,r.postalCode,r.countryCode].filter(Boolean);t.length&&(e.text(t.join(`, `),Z,n),n+=3.5)}let i=t.courts?.length;i&&(e.text(`Courts: `+i,Z,n),n+=3.5)}return n+3}function Li(e,t,r,i){if(!r)return i;let a=r.options?.length,o=r.notes&&Ai(r.notes);if(!a&&!o)return i;if(i=$(e,i,15),i=Q(e,t,i),a){let t=r.options.map(e=>{let t=[e.phone,e.email,e.priceRange].filter(Boolean).join(` | `);return[e.name,e.address||``,t]});(0,n.default)(e,{startY:i,head:[[`Name`,`Address`,`Details`]],body:t,margin:{left:Z,right:Z},styles:{fontSize:7,cellPadding:1.5},headStyles:{fillColor:[60,60,60],textColor:255,fontStyle:`bold`},theme:`grid`}),i=e.lastAutoTable.finalY+3}return o&&(i=ji(e,Ai(r.notes),i)),i+3}function Ri(e,t,n){let r=t.totalPrizeMoney;if(!r?.length)return n;n=$(e,n,10),n=Q(e,`Prize Money`,n),L(e,F.BODY,P.NORMAL);for(let t of r)e.text(t.currencyCode+` `+t.amount.toLocaleString(),Z,n),n+=3.5;return n+3}function zi(e,t,r){let i=(t.participants||[]).filter(e=>e.participantRole===`OFFICIAL`||e.participantRole===`DIRECTOR`);if(!i.length)return r;r=$(e,r,15),r=Q(e,`Officials`,r);let a=i.map(e=>{let t=e.person||{};return[[t.standardGivenName,t.standardFamilyName].filter(Boolean).join(` `)||e.participantName||``,e.participantRoleResponsibilities?.[0]||e.participantRole||``]});return(0,n.default)(e,{startY:r,head:[[`Name`,`Role`]],body:a,margin:{left:Z,right:Z},styles:{fontSize:7,cellPadding:1.5},headStyles:{fillColor:[60,60,60],textColor:255,fontStyle:`bold`},theme:`grid`}),e.lastAutoTable.finalY+6}function Bi(e,t,n){let r=t.registrationProfile;if(!r)return n;let i=[];if(r.codeOfConduct){let e=r.codeOfConduct;i.push(`Code of Conduct: `+(e.name||``)+(e.url?` — `+e.url:``))}if(r.regulations?.length)for(let e of r.regulations)i.push((e.name||`Regulation`)+(e.url?` — `+e.url:``));if(r.dressCode&&i.push(`Dress Code: `+r.dressCode),r.contingencyPlan&&i.push(`Contingency: `+r.contingencyPlan),!i.length)return n;n=$(e,n,10+i.length*3.5),n=Q(e,`Regulations`,n),L(e,F.BODY,P.NORMAL);for(let t of i)e.text(t,Z,n),n+=3.5;return n+3}function Vi(e,t,n){let r=t.registrationProfile?.sponsors;if(!r?.length)return n;n=$(e,n,10),n=Q(e,`Sponsors`,n),L(e,F.BODY,P.NORMAL);for(let t of r){let r=t.tier?` [`+t.tier+`]`:``;e.text(t.name+r,Z,n),n+=3.5}return n+3}function Hi(e,t,n){let r=t.registrationProfile?.socialEvents;if(!r?.length)return n;let i=t.registrationProfile;n=$(e,n,15),n=Q(e,`Social Events & Ceremonies`,n),L(e,F.BODY,P.NORMAL),i?.drawCeremonyDate&&(e.text(`Draw Ceremony: `+i.drawCeremonyDate,Z,n),n+=3.5),i?.awardsCeremonyDate&&(e.text(`Awards Ceremony: `+i.awardsCeremonyDate,Z,n),n+=3.5);for(let t of r){L(e,F.BODY,P.BOLD),e.text(t.name,Z,n),n+=3.5,L(e,F.BODY,P.NORMAL);let r=[t.date,t.time,t.location].filter(Boolean).join(` | `);r&&(e.text(r,Z,n),n+=3.5),t.description&&(e.text(t.description,Z,n),n+=3.5)}return n+3}function Ui(e,t,n){let r=t.notes;if(!r)return n;let i=Ai(r);return i?(n=$(e,n,15),n=Q(e,`Additional Information`,n),n=ji(e,i,n),n+3):n}var Wi={"tournament-header":Mi,contacts:Ni,events:Pi,"entry-info":Fi,"venue-info":Ii,accommodation:(e,t,n)=>Li(e,`Accommodation`,t.registrationProfile?.accommodation,n),transportation:(e,t,n)=>Li(e,`Transportation`,t.registrationProfile?.transportation,n),hospitality:(e,t,n)=>Li(e,`Hospitality`,t.registrationProfile?.hospitality,n),medical:(e,t,n)=>Li(e,`Medical`,t.registrationProfile?.medicalInfo,n),regulations:Bi,"prize-money":Ri,officials:zi,sponsors:Vi,"social-events":Hi,"custom-notes":Ui};function Gi(e,n={}){let{templateId:r=`itf-junior`}=n,i=pe(r)?.sections||pe(`itf-junior`).sections,a=n.enabledSections?new Set(n.enabledSections):null,o=new t.default({orientation:`portrait`,format:`a4`});I(o);let s=Z;for(let t of i){if(!t.enabled||a&&!a.has(t.type))continue;let n=Wi[t.type];n&&(s=n(o,e,s))}let c=o.getNumberOfPages();for(let e=1;e<=c;e++)o.setPage(e),U(o,`Generated `+new Date().toLocaleDateString(),e);return o}function Ki(e,t={}){let n=e?.drawsData||[],r=e?.tournamentInfo||{},i=e?.eventInfo||{},a=ee(t.catalogPreset||`club-basic`),o=_(a?.drawFormatPreset||`itfJunior`),s={layout:`itf`,tournamentName:r.tournamentName||`Tournament`,...a?.header,subtitle:i.eventName||a?.header?.subtitle,startDate:r.startDate,endDate:r.endDate,location:r.venues?.[0]?.venueName,city:r.venues?.[0]?.city,country:r.hostCountryCode,surface:i.surfaceCategory,...t.headerOverrides},c={layout:`standard`,showPageNumbers:!0,showTimestamp:!0,...a?.footer,...t.footerOverrides},l=n?.[0]?.structures||[],u=l.some(e=>e.stage===`CONSOLATION`),d=l.some(e=>e.stage===`PLAY_OFF`),f=l.find(e=>e.stage===`MAIN`),p={header:s,footer:c,format:o};if(u&&d)return hr({winnersBracket:f?M(f):qi(),losersBracket:N(n,`CONSOLATION`)?M(N(n,`CONSOLATION`)):qi(),deciderMatch:N(n,`PLAY_OFF`)?M(N(n,`PLAY_OFF`)):void 0},p);if(u)return dr(l.map(e=>({name:e.structureName,stage:e.stage,drawData:M(e)})),p);let m=t.structureId&&l.find(e=>e.structureId===t.structureId)||f;if(!m)return Te({pageSize:`a4`,orientation:`portrait`,margins:{top:12,right:15,bottom:12,left:15}});let h=M(m);return t.mirrored?pr(h,p):t.splitPages||h.drawSize>=256?lr(h,{...p,maxPositionsPerPage:t.maxPositionsPerPage||32}):cr(h,p)}function qi(){return{drawName:``,drawSize:0,drawType:``,totalRounds:0,slots:[],matchUps:[],seedAssignments:[]}}exports.COMPOSITION_CATALOG=C,exports.DRAW_MODAL_TABS=Ur,exports.FACT_SHEET_CATALOG=fe,exports.FONT=_e,exports.FOOTER_LAYOUT_OPTIONS=zr,exports.HEADER_LAYOUT_OPTIONS=Rr,exports.ORIENTATION_OPTIONS=Vr,exports.PAGE_SIZE_OPTIONS=Br,exports.PRESETS=g,exports.SCHEDULE_MODAL_TABS=Wr,exports.SIZE=F,exports.SPLIT_STRATEGY_OPTIONS=Hr,exports.STYLE=P,exports.TABLE_STYLES=kt,exports.activeFontFamily=xe,exports.applyDefaultFont=I,exports.buildFooterFromTournament=He,exports.buildHeaderFromTournament=Ve,exports.calculateBracketPositions=ni,exports.createDoc=Te,exports.drawBracketConnectors=ii,exports.drawBracketSlot=ri,exports.drawPageFooter=U,exports.drawTournamentHeader=Ot,exports.entryStatusDisplay=st,exports.eventAbbreviation=dt,exports.executePrint=br,exports.extractCompassData=ei,exports.extractConsolationStructures=Gn,exports.extractCourtCardData=vt,exports.extractDrawData=Lt,exports.extractParticipantData=gt,exports.extractRoundRobinData=Gr,exports.extractScheduleData=mt,exports.findStructure=N,exports.formatDate=lt,exports.formatMatchScore=K,exports.formatPlayerEntry=Bt,exports.formatScore=ct,exports.formatTime=ut,exports.generateBackdrawPDF=mr,exports.generateCompassDrawPDF=fr,exports.generateConsolationDrawPDF=dr,exports.generateCourtCardPDF=Mt,exports.generateDoubleEliminationPDF=hr,exports.generateDrawPDF=or,exports.generateDrawSheetPDF=oi,exports.generateFactSheet=Gi,exports.generateFeedInDrawPDF=ur,exports.generateFromEventData=Ki,exports.generateLuckyDrawPDF=gr,exports.generateMatchCardPDF=Pt,exports.generateMirroredDrawPDF=pr,exports.generateOrderOfPlayPDF=xt,exports.generateScheduleV2PDF=xt,exports.generatePlayerListPDF=At,exports.generateReportPDF=ki,exports.generateSchedulePDF=ui,exports.generateSequentialOOP=bi,exports.generateSignInSheetPDF=jt,exports.generateSplitDrawPDF=lr,exports.generateTraditionalDrawPDF=cr,exports.getCatalogPreset=ee,exports.getDefaultFont=we,exports.getDefaultPageConfig=Ee,exports.getFactSheetTemplate=pe,exports.getPageRegions=R,exports.getPreset=_,exports.getRoundLabel=W,exports.listCatalogPresets=te,exports.listFactSheetTemplates=me,exports.measureFooterHeight=B,exports.measureSeedingsHeight=at,exports.mergeCatalogPreset=ne,exports.mergePreset=v,exports.nationality=H,exports.participantName=V,exports.registerFont=be,exports.renderCompassDraw=Hn,exports.renderConsolationDraw=Kn,exports.renderDoubleEliminationDraw=qn,exports.renderFooter=qe,exports.renderHeader=z,exports.renderLuckyDraw=Qn,exports.renderRoundRobinGroup=Xr,exports.renderSeedingsFooter=rt,exports.renderTraditionalDraw=q,exports.resolveCompositionConfig=hi,exports.roundName=ft,exports.seedDisplay=ot,exports.setDefaultFont=Ce,exports.setFont=L,exports.splitDraw=tr,exports.structureToDrawData=M;
|
|
6
6
|
//# sourceMappingURL=pdf-factory.cjs.map
|